Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| ClassInfo | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getFullyQualifiedClassName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getShortClassName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAnnotations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAnnotation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProperties | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProperty | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Miniframe\Annotation\Model; |
| 4 | |
| 5 | class ClassInfo |
| 6 | { |
| 7 | /** |
| 8 | * Classname including namespace |
| 9 | * |
| 10 | * @var string |
| 11 | */ |
| 12 | protected $fullyQualifiedClassName; |
| 13 | /** |
| 14 | * List of annotations |
| 15 | * |
| 16 | * @var object[] |
| 17 | */ |
| 18 | protected $annotations; |
| 19 | /** |
| 20 | * List of properties |
| 21 | * |
| 22 | * @var Property[] |
| 23 | */ |
| 24 | protected $properties; |
| 25 | |
| 26 | /** |
| 27 | * Class data model |
| 28 | * |
| 29 | * @param string $fullyQualifiedClassName Classname including the namespace. |
| 30 | * @param object[] $annotations List of annotations. |
| 31 | * @param Property[] $properties List of properties. |
| 32 | */ |
| 33 | public function __construct(string $fullyQualifiedClassName, array $annotations, array $properties) |
| 34 | { |
| 35 | $this->fullyQualifiedClassName = $fullyQualifiedClassName; |
| 36 | $this->annotations = $annotations; |
| 37 | $this->properties = $properties; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns the fully qualified classname |
| 42 | * |
| 43 | * @return string |
| 44 | */ |
| 45 | public function getFullyQualifiedClassName(): string |
| 46 | { |
| 47 | return $this->fullyQualifiedClassName; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the short classname (without namespace) |
| 52 | * |
| 53 | * @return string |
| 54 | */ |
| 55 | public function getShortClassName(): string |
| 56 | { |
| 57 | return array_reverse(explode('\\', $this->fullyQualifiedClassName))[0]; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns a list of all annotations |
| 62 | * |
| 63 | * @return object[] |
| 64 | */ |
| 65 | public function getAnnotations(): array |
| 66 | { |
| 67 | return $this->annotations; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns a single annotation |
| 72 | * |
| 73 | * @param string $name Name of the annotation. |
| 74 | * |
| 75 | * @return object|null |
| 76 | */ |
| 77 | public function getAnnotation(string $name) |
| 78 | { |
| 79 | return $this->annotations[$name] ?? null; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns a list of all properties |
| 84 | * |
| 85 | * @return Property[] |
| 86 | */ |
| 87 | public function getProperties(): array |
| 88 | { |
| 89 | return $this->properties; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Returns a single property |
| 94 | * |
| 95 | * @param string $propertyName Name of the property. |
| 96 | * |
| 97 | * @return Property|null |
| 98 | */ |
| 99 | public function getProperty(string $propertyName): ?Property |
| 100 | { |
| 101 | return $this->properties[$propertyName] ?? null; |
| 102 | } |
| 103 | } |