Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
InvalidDocument
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 because
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace LambdaTwelve\OneRecord\Api;
6
7use RuntimeException;
8
9/**
10 * A request body that is well-formed JSON-LD but not a valid instance of the
11 * API class the endpoint expects (400 Bad Request).
12 */
13class InvalidDocument extends RuntimeException
14{
15    /**
16     * @param list<Error> $errors
17     */
18    final public function __construct(string $message, public readonly array $errors = [])
19    {
20        parent::__construct($message);
21    }
22
23    public static function because(string $title, ?string $message = null, ?string $property = null): static
24    {
25        return new static($message === null ? $title : $title . ': ' . $message, [Error::of($title, '400', $message ?? $title, $property)]);
26    }
27}