Skip to content

Commit 481c94f

Browse files
authored
Merge pull request #118 from tyrsson/simplify-get-method
Simply the __get method body
2 parents 532981a + 545e7b4 commit 481c94f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/TableGateway/AbstractTableGateway.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410,20 +410,15 @@ public function getLastInsertValue(): int
410410
*/
411411
public function __get(string $property): mixed
412412
{
413-
try {
414-
return match ($property) {
415-
'lastInsertValue', 'adapter', 'table' => $this->$property,
416-
default => throw new Exception\InvalidArgumentException(),
417-
};
418-
} catch (Exception\InvalidArgumentException) {
419-
if ($this->featureSet->canCallMagicGet($property)) {
420-
return $this->featureSet->callMagicGet($property);
421-
}
422-
}
423-
424-
throw new Exception\InvalidArgumentException(
425-
'Invalid magic property access in ' . self::class . '::__get()'
426-
);
413+
return match (true) {
414+
'lastInsertValue' === $property,
415+
'adapter' === $property,
416+
'table' === $property => $this->$property,
417+
$this->featureSet->canCallMagicGet($property) => $this->featureSet->callMagicGet($property),
418+
default => throw new Exception\InvalidArgumentException(
419+
'Invalid magic property access in ' . self::class . '::__get()'
420+
),
421+
};
427422
}
428423

429424
/**

0 commit comments

Comments
 (0)