LinkObjectMap   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getWantedType() 0 10 2
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\Spec\LinkObject;
10
use Apie\OpenapiSchema\Spec\Reference;
11
use Apie\TypeJuggling\AnotherValueObject;
12
use Apie\TypeJuggling\Compound;
13
use Apie\TypeJuggling\StringLiteral;
14
use Apie\TypeJuggling\TypeUtilInterface;
15
16
class LinkObjectMap 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, LinkObject::class),
28
            new AnotherValueObject($fieldName, Reference::class),
29
            new StringLiteral($fieldName)
30
        );
31
    }
32
}
33