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

SchemaMap::getWantedType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 10
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\Contract\SchemaContract;
10
use Apie\OpenapiSchema\Spec\Reference;
11
use Apie\OpenapiSchema\Spec\Schema;
12
use Apie\TypeJuggling\AnotherValueObject;
13
use Apie\TypeJuggling\Compound;
14
use Apie\TypeJuggling\TypeUtilInterface;
15
16
class SchemaMap implements ValueObjectListInterface
17
{
18
    use ValueObjectHashmapTrait;
19
20
    protected static function getWantedType(string $fieldName): TypeUtilInterface
21
    {
22
        if (!preg_match('/^[a-zA-Z0-9\.\-_]+$/', $fieldName)) {
23
            throw new InvalidKeyException($fieldName, null);
24
        }
25
        return new Compound(
26
            $fieldName,
27
            new AnotherValueObject($fieldName, SchemaContract::class),
28
            new AnotherValueObject($fieldName, Schema::class),
29
            new AnotherValueObject($fieldName, Reference::class)
30
        );
31
    }
32
}
33