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
Error
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
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
 of
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace LambdaTwelve\OneRecord\Api;
6
7/**
8 * api:Error: a title that stays the same for every occurrence of a problem,
9 * plus details specific to this one. Used for HTTP error bodies, for the
10 * errors recorded on failed action requests, and for verification requests.
11 */
12final readonly class Error
13{
14    /**
15     * @param list<ErrorDetail> $details
16     */
17    public function __construct(
18        public string $title,
19        public array $details = [],
20        public Severity $severity = Severity::Error,
21    ) {}
22
23    public static function of(string $title, ?string $code = null, ?string $message = null, ?string $property = null, ?string $resource = null): self
24    {
25        return new self($title, [new ErrorDetail($code, $message, $property, $resource)]);
26    }
27}