TypeErrorInvalidArgumentException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromParams() 0 5 1
A __construct() 0 4 1
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