ExampleMap::getWantedType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 6
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\Spec\Example;
10
use Apie\TypeJuggling\AnotherValueObject;
11
use Apie\TypeJuggling\TypeUtilInterface;
12
13
class ExampleMap implements ValueObjectListInterface
14
{
15
    use ValueObjectHashmapTrait;
16
17
    protected static function getWantedType(string $fieldName): TypeUtilInterface
18
    {
19
        if (!preg_match('/^[a-zA-Z-0-9]+$/', $fieldName)) {
20
            throw new InvalidKeyException($fieldName, null);
21
        }
22
        return new AnotherValueObject($fieldName, Example::class);
23
    }
24
}
25