| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 24 | class Header implements HeaderInterface |
||
| 25 | { |
||
| 26 | protected $columns; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Header constructor. |
||
| 30 | * |
||
| 31 | * @param array $columns |
||
| 32 | * |
||
| 33 | * @throws InvalidHeaderArrayException |
||
| 34 | */ |
||
| 35 | public function __construct(array $columns = []) |
||
| 36 | { |
||
| 37 | foreach ($columns as $column) { |
||
| 38 | if (!is_string($column)) { |
||
| 39 | throw new InvalidHeaderArrayException('Columns must be array of (string)'); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | $this->columns = $columns; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param string $column |
||
| 47 | * |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function addColumn(string $column) |
||
| 51 | { |
||
| 52 | if (!in_array($column, $this->columns)) { |
||
| 53 | $this->columns[] = $column; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return array |
||
| 59 | */ |
||
| 60 | public function getColumns(): array |
||
| 63 | } |
||
| 64 | } |
||
| 65 |