Skip to content

Commit c4c143b

Browse files
committed
minor refactor on feed item method calls
1 parent d6fc6c2 commit c4c143b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/FeedItem.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ public function build()
5959
{
6060
return array_filter(
6161
$this->flatMap($this->acceptedProperties, function ($property) {
62-
63-
$method = $this->getMethodForProperty($property);
64-
65-
return [$property => $this->$method()];
62+
return [$property => $this->getValueForProperty($property)];
6663
})
6764
);
6865
}

src/Traits/itemGetters.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public function getMethodForProperty($method)
9393
return $this->getMethodsMap()[$method] ?? null;
9494
}
9595

96+
public function getValueForProperty($property)
97+
{
98+
if ($method = $this->getMethodForProperty($property)) {
99+
return $this->$method();
100+
}
101+
102+
return null;
103+
}
104+
96105
public function call($method)
97106
{
98107
return method_exists($this->object, $method) ? $this->object->$method() : null;

0 commit comments

Comments
 (0)