Test Setup Failed
Push — main ( e03535...dde247 )
by Pieter
03:39
created

CallbackPathItemList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getWantedType() 0 6 2
A __construct() 0 2 1
1
<?php
2
3
4
namespace Apie\OpenapiSchema\Map;
5
6
use Apie\CompositeValueObjects\Exceptions\InvalidKeyException;
7
use Apie\CompositeValueObjects\ValueObjectListInterface;
8
use Apie\CompositeValueObjects\ValueObjectListTrait;
9
use Apie\OpenapiSchema\Constants;
10
use Apie\OpenapiSchema\Spec\Callback;
11
use Apie\TypeJuggling\AnotherValueObject;
12
use Apie\TypeJuggling\TypeUtilInterface;
13
14
final class CallbackPathItemList implements ValueObjectListInterface
15
{
16
    use ValueObjectListTrait;
17
18
    private function __construct()
19
    {
20
    }
21
22
    protected static function getWantedType(string $key): TypeUtilInterface
23
    {
24
        if (!preg_match(Constants::VALID_KEY_REGEX, $key)) {
25
            throw new InvalidKeyException($key, new CallbackPathItemList());
26
        }
27
        return new AnotherValueObject($key, Callback::class);
28
    }
29
}
30