Total Complexity | 7 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
21 | class Type |
||
22 | { |
||
23 | /** |
||
24 | * @var string|null |
||
25 | */ |
||
26 | private $class; |
||
27 | |||
28 | /** |
||
29 | * Is the class having the annotation a GraphQL type itself? |
||
30 | * |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $selfType = false; |
||
34 | |||
35 | /** |
||
36 | * @param mixed[] $attributes |
||
37 | */ |
||
38 | public function __construct(array $attributes = []) |
||
39 | { |
||
40 | if (isset($attributes['class'])) { |
||
41 | $this->setClass($attributes['class']); |
||
42 | if (!class_exists($this->class)) { |
||
43 | throw ClassNotFoundException::couldNotFindClass($this->class); |
||
44 | } |
||
45 | } else { |
||
46 | $this->selfType = true; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Returns the fully qualified class name of the targeted class. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function getClass(): string |
||
56 | { |
||
57 | if ($this->class === null) { |
||
58 | throw new \RuntimeException('Empty class for @Type annotation. You MUST create the Type annotation object using the GraphQL-Controllers AnnotationReader'); |
||
59 | } |
||
60 | return $this->class; |
||
61 | } |
||
62 | |||
63 | public function setClass(string $class): void |
||
66 | } |
||
67 | |||
68 | public function isSelfType(): bool |
||
71 | } |
||
72 | } |
||
73 |