| Total Complexity | 11 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class Block |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $type; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | private $blockId; |
||
| 31 | |||
| 32 | public function __construct(?string $type) |
||
| 33 | { |
||
| 34 | $this->setType($type); |
||
|
|
|||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | public function getType(): string |
||
| 41 | { |
||
| 42 | return $this->type; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param string $type |
||
| 47 | * |
||
| 48 | * @return $this |
||
| 49 | */ |
||
| 50 | public function setType(string $type): self |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Convert this block to its array representation. |
||
| 59 | * |
||
| 60 | * @return array |
||
| 61 | */ |
||
| 62 | public function toArray(): array |
||
| 63 | { |
||
| 64 | $data = [ |
||
| 65 | 'type' => $this->type, |
||
| 66 | 'block_id' => $this->blockId |
||
| 67 | ]; |
||
| 68 | |||
| 69 | return $this->removeNulls($data); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param string $blockId |
||
| 74 | */ |
||
| 75 | public function setBlockId(string $blockId): self |
||
| 76 | { |
||
| 77 | $this->blockId = $blockId; |
||
| 78 | |||
| 79 | return $this; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return string |
||
| 84 | */ |
||
| 85 | public function getBlockId(): string |
||
| 88 | } |
||
| 89 | |||
| 90 | protected function removeNulls(array $data): array |
||
| 98 | } |
||
| 99 | } |
||
| 100 |