Skip to content

Commit 3efa881

Browse files
fix(tables): use parent logic/implementation, revert formatting change
AI-assistant: Copilot v1.0.6 (Claude Sonnet 4.6) Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 71620ec commit 3efa881

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

lib/Service/ValueObject/ColumnOrderInformation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ public function getOrder(): int {
4242
}
4343

4444
public static function fromArray(array $data): self {
45+
static::assertRequiredFields($data);
46+
return new self((int)$data[self::KEY_ID], (int)$data[self::KEY_ORDER]);
47+
}
48+
49+
protected static function assertRequiredFields(array $data): void {
4550
if (!isset($data[self::KEY_ID], $data[self::KEY_ORDER])) {
4651
throw new \InvalidArgumentException('Column settings entry is missing required fields: columnId and order are required');
4752
}
48-
return new self((int)$data[self::KEY_ID], (int)$data[self::KEY_ORDER]);
4953
}
5054

5155
public function offsetExists(mixed $offset): bool {

lib/Service/ValueObject/ViewColumnInformation.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public function isMandatory(): bool {
4242
}
4343

4444
public static function fromArray(array $data): static {
45-
if (!isset($data[self::KEY_ID], $data[self::KEY_ORDER])) {
46-
throw new \InvalidArgumentException('Column settings entry is missing required fields: columnId and order are required');
47-
}
45+
static::assertRequiredFields($data);
4846
return new static(
4947
(int)$data[self::KEY_ID],
5048
(int)$data[self::KEY_ORDER],
@@ -57,21 +55,17 @@ public static function fromArray(array $data): static {
5755
* @return array{columnId: int, order: int, readonly: bool, mandatory: bool}
5856
*/
5957
public function jsonSerialize(): array {
60-
return [
61-
self::KEY_ID => $this->getId(),
62-
self::KEY_ORDER => $this->getOrder(),
58+
return array_merge(parent::jsonSerialize(), [
6359
self::KEY_READONLY => $this->isReadonly(),
6460
self::KEY_MANDATORY => $this->isMandatory(),
65-
];
61+
]);
6662
}
6763

6864
protected function ensureType(string $offset, mixed $value): int|bool {
6965
return match ($offset) {
70-
self::KEY_ID,
71-
self::KEY_ORDER => (int)$value,
72-
self::KEY_READONLY,
66+
self::KEY_READONLY => (bool)$value,
7367
self::KEY_MANDATORY => (bool)$value,
74-
default => throw new \InvalidArgumentException("Invalid offset: $offset"),
68+
default => parent::ensureType($offset, $value),
7569
};
7670
}
7771
}

0 commit comments

Comments
 (0)