Skip to content

Commit bc2c77b

Browse files
committed
refactor: bring back streamlined micro-optimisation as it has real-world value
1 parent 60cd5fa commit bc2c77b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Granada/Granada.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,19 @@ public function __get($property)
414414
$class = static::class;
415415
$result = $this->orm->get($property);
416416

417+
$_has_method = [];
418+
417419
if ($result !== null) {
418420
$method = 'get_' . $property;
419-
if (method_exists($this, $method)) {
421+
if ($_has_method[$class][$method] ??= method_exists($this, $method)) {
420422
return $this->$method($result);
421423
}
422424

423425
return $result;
424426
}
425427

426428
$method = 'missing_' . $property;
427-
if (method_exists($this, $method)) {
429+
if ($_has_method[$class][$method] ??= method_exists($this, $method)) {
428430
return $this->$method();
429431
}
430432

@@ -433,7 +435,7 @@ public function __get($property)
433435
}
434436

435437
$method = $property;
436-
if (method_exists($this, $method)) {
438+
if ($_has_method[$class][$method] ??= method_exists($this, $method)) {
437439
if ($property != self::_get_id_column_name($class)) {
438440
$relation = $this->$property();
439441

0 commit comments

Comments
 (0)