TypeError   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A fromArray() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Data;
6
7
use FRZB\Component\RequestMapper\Exception\TypeErrorInvalidArgumentException;
8
use FRZB\Component\RequestMapper\Helper\ClassHelper;
9
use JetBrains\PhpStorm\Immutable;
10
11
#[Immutable]
12
final class TypeError
13
{
14 5
    public function __construct(
15
        public readonly string $class,
16
        public readonly string $method,
17
        public readonly int $position,
18
        public readonly string $expected,
19
        public readonly string $proposed,
20
    ) {
21
    }
22
23 6
    public static function fromArray(array $params): self
24
    {
25 6
        if (!ClassHelper::isArrayHasAllPropertiesFromClass($params, self::class)) {
26 1
            throw TypeErrorInvalidArgumentException::fromParams($params);
27
        }
28
29 5
        return new self($params['class'], $params['method'], (int) $params['position'], $params['expected'], $params['proposed']);
30
    }
31
}
32