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

CallbackPathItemList::jsonSerialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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