Passed
Push — 6.0 ( 70657e...b737f6 )
by Olivier
11:54
created

Error   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A jsonSerialize() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie;
13
14
use JsonSerializable;
15
16
/**
17
 * Representation of an error.
18
 */
19
class Error implements JsonSerializable
20
{
21
    /**
22
     * @param array<int|string, mixed> $args
23
     */
24
    public function __construct(
25
        public readonly string $format,
26
        public readonly array $args = []
27
    ) {
28
    }
29
30
    public function __toString()
31
    {
32
        return format($this->format, $this->args);
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function jsonSerialize(): string
39
    {
40
        return (string) $this;
41
    }
42
}
43