| Total Complexity | 10 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 70.83% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Row |
||
| 10 | { |
||
| 11 | private array $row; |
||
| 12 | |||
| 13 | private array $changes = []; |
||
| 14 | |||
| 15 | 4 | public function __construct(array $row) |
|
| 16 | { |
||
| 17 | 4 | $this->row = $row; |
|
| 18 | 4 | } |
|
| 19 | |||
| 20 | public function isNull(string $column): bool |
||
| 21 | { |
||
| 22 | return $this->exists($column) |
||
| 23 | && $this->row[$column] === null; |
||
| 24 | } |
||
| 25 | |||
| 26 | 3 | public function exists(string $column): bool |
|
| 27 | { |
||
| 28 | 3 | return \array_key_exists($column, $this->row); |
|
| 29 | } |
||
| 30 | |||
| 31 | 3 | public function __get(string $name) |
|
| 32 | { |
||
| 33 | 3 | if ($this->exists($name)) { |
|
| 34 | 3 | return $this->row[$name]; |
|
| 35 | } |
||
| 36 | |||
| 37 | throw new InvalidArgumentException( |
||
| 38 | sprintf("Column with name `%s` does not exist.", $name) |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function __set(string $name, $value): void |
|
| 43 | { |
||
| 44 | 1 | if ($this->exists($name)) { |
|
| 45 | 1 | $this->row[$name] = $value; |
|
| 46 | |||
| 47 | 1 | $this->changes[$name] = $value; |
|
| 48 | |||
| 49 | 1 | return; |
|
| 50 | } |
||
| 51 | |||
| 52 | throw new InvalidArgumentException( |
||
| 53 | \sprintf("Column with name `%s` does not exist.", $name) |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | 1 | public function hasChanges(): bool |
|
| 58 | { |
||
| 59 | 1 | return !empty($this->changes); |
|
| 60 | } |
||
| 61 | |||
| 62 | 1 | public function getChanges() |
|
| 65 | } |
||
| 66 | } |
||
| 67 |