Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| Property | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAccessLevel | |
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 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Miniframe\Annotation\Model; |
| 4 | |
| 5 | class Property |
| 6 | { |
| 7 | /** |
| 8 | * Name of the property |
| 9 | * |
| 10 | * @var string |
| 11 | */ |
| 12 | protected $name; |
| 13 | /** |
| 14 | * Access level |
| 15 | * |
| 16 | * @var string |
| 17 | */ |
| 18 | protected $accessLevel; |
| 19 | /** |
| 20 | * List of all annotations |
| 21 | * |
| 22 | * @var object[] |
| 23 | */ |
| 24 | protected $annotations; |
| 25 | |
| 26 | /** |
| 27 | * Property data model |
| 28 | * |
| 29 | * @param string $name Name of the property. |
| 30 | * @param string $accessLevel Access level. |
| 31 | * @param object[] $annotations List of annotations. |
| 32 | */ |
| 33 | public function __construct(string $name, string $accessLevel, array $annotations) |
| 34 | { |
| 35 | $this->name = $name; |
| 36 | $this->accessLevel = $accessLevel; |
| 37 | $this->annotations = $annotations; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns the name of the property |
| 42 | * |
| 43 | * @return string |
| 44 | */ |
| 45 | public function getName(): string |
| 46 | { |
| 47 | return $this->name; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the access level |
| 52 | * |
| 53 | * @return string |
| 54 | */ |
| 55 | public function getAccessLevel(): string |
| 56 | { |
| 57 | return $this->accessLevel; |
| 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 | } |