| Total Complexity | 10 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Attribute |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $serializedKey; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $type; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var bool |
||
| 26 | */ |
||
| 27 | private $isIdentifier; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | private $attributeName; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @throws \InvalidArgumentException |
||
| 36 | */ |
||
| 37 | public function __construct( |
||
| 38 | string $serializedKey, |
||
| 39 | ?string $attributeName = null, |
||
| 40 | ?string $type = null, |
||
| 41 | bool $isIdentifier = false |
||
| 42 | ) { |
||
| 43 | if (empty($serializedKey)) { |
||
| 44 | throw new \InvalidArgumentException('attribute name must be set'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->serializedKey = $serializedKey; |
||
| 48 | $this->attributeName = $attributeName ?? $this->serializedKey; |
||
| 49 | $this->type = $type ?? 'string'; |
||
| 50 | $this->isIdentifier = $isIdentifier; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function getSerializedKey(): string |
||
| 56 | } |
||
| 57 | |||
| 58 | public function setSerializedKey(string $serializedKey): self |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getType(): string |
||
| 66 | { |
||
| 67 | return $this->type; |
||
| 68 | } |
||
| 69 | |||
| 70 | public function setType(string $type): self |
||
| 71 | { |
||
| 72 | $this->type = $type; |
||
| 73 | |||
| 74 | return $this; |
||
| 75 | } |
||
| 76 | |||
| 77 | public function isIdentifier(): bool |
||
| 78 | { |
||
| 79 | return $this->isIdentifier; |
||
| 80 | } |
||
| 81 | |||
| 82 | public function setIsIdentifier(bool $isIdentifier): self |
||
| 83 | { |
||
| 84 | $this->isIdentifier = $isIdentifier; |
||
| 85 | |||
| 86 | return $this; |
||
| 87 | } |
||
| 88 | |||
| 89 | public function getAttributeName(): string |
||
| 90 | { |
||
| 91 | return $this->attributeName; |
||
| 92 | } |
||
| 93 | |||
| 94 | public function setAttributeName(string $attributeName): self |
||
| 99 | } |
||
| 100 | } |
||
| 101 |