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

CallbackPathItemList::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
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