TypeErrorInvalidArgumentException::fromParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Exception;
6
7
use JetBrains\PhpStorm\Immutable;
8
use JetBrains\PhpStorm\Pure;
9
use Throwable;
10
11
#[Immutable]
12
final class TypeErrorInvalidArgumentException extends \InvalidArgumentException
13
{
14 1
    private const MESSAGE_TEMPLATE = 'Params have not needed values "%s"';
15
16
    #[Pure]
17 1
    private function __construct(string $message, int $code = 0, ?Throwable $previous = null)
18
    {
19
        parent::__construct($message, $code, $previous);
20 1
    }
21
22 1
    public static function fromParams(array $params, ?Throwable $previous = null): self
23
    {
24 1
        $message = sprintf(self::MESSAGE_TEMPLATE, implode(', ', array_keys($params)));
25
26
        return new self($message, $previous?->getCode() ?? 0, $previous);
27
    }
28
}
29