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

ServerVariableObjectList::isValidKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Apie\OpenapiSchema\Map;
5
6
use Apie\CompositeValueObjects\Exceptions\InvalidKeyException;
7
use Apie\CompositeValueObjects\ValueObjectHashmapTrait;
8
use Apie\CompositeValueObjects\ValueObjectListInterface;
9
use Apie\OpenapiSchema\Constants;
10
use Apie\OpenapiSchema\Spec\ServerVariable;
11
use Apie\TypeJuggling\AnotherValueObject;
12
use Apie\TypeJuggling\TypeUtilInterface;
13
14
final class ServerVariableObjectList implements ValueObjectListInterface
15
{
16
    use ValueObjectHashmapTrait;
17
18
    protected static function getWantedType(string $fieldName): TypeUtilInterface
19
    {
20
        if (!preg_match(Constants::VALID_KEY_REGEX, $fieldName)) {
21
            throw new InvalidKeyException($fieldName, null);
22
        }
23
        return new AnotherValueObject($fieldName, ServerVariable::class);
24
    }
25
}
26