AbstractType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 54.55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 28
ccs 6
cts 11
cp 0.5455
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTypeOf() 0 18 4
1
<?php
2
3
namespace Fubhy\GraphQL\Type\Definition\Types;
4
5
abstract class AbstractType extends Type implements AbstractTypeInterface {
6
7
    /**
8
     * @param mixed $value
9
     *
10
     * @return \Fubhy\GraphQL\Type\Definition\Types\ObjectType|null
11
     *
12
     * @throws \Exception
13
     */
14 9
    public function getTypeOf($value)
15
    {
16 9
        foreach ($this->getPossibleTypes() as $type) {
17 9
            if ($isTypeOf = $type->isTypeOf($value)) {
18 9
                return $type;
19
            }
20
21 9
            if (!isset($isTypeOf)) {
22
                throw new \Exception(sprintf(
23
                    'Non-Object Type %s does not implement resolveType and Object ' .
24
                    'Type %s does not implement isTypeOf. There is no way to ' .
25
                    'determine if a value is of this type.', $this->getName(), $type->getName()
26
                ));
27
            }
28 9
        }
29
30
        return NULL;
31
    }
32
}
33