| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 18 | public function getFeedContent(array $feedConfiguration) : string |
||
| 19 | { |
||
| 20 | if (!str_contains($feedConfiguration['items'], '@')) { |
||
| 21 | throw InvalidConfiguration::delimiterNotPresent($feedConfiguration['items']); |
||
| 22 | } |
||
| 23 | |||
| 24 | list($class, $method) = explode('@', $feedConfiguration['items']); |
||
| 25 | |||
| 26 | $items = app($class)->$method(); |
||
| 27 | |||
| 28 | $meta = [ |
||
| 29 | 'link' => $feedConfiguration['url'], |
||
| 30 | 'description' => $feedConfiguration['description'], |
||
| 31 | 'title' => $feedConfiguration['title'], |
||
| 32 | 'updated' => $this->getLastUpdatedDate($items, 'Y-m-d H:i:s'), |
||
| 33 | ]; |
||
| 34 | |||
| 35 | return view('laravel-feed::feed', compact('meta', 'items'))->render(); |
||
|
|
|||
| 36 | } |
||
| 37 | |||
| 38 | protected function getLastUpdatedDate(Collection $items, string $format) : string |
||
| 39 | { |
||
| 40 | $lastItem = $items |
||
| 41 | ->sortBy(function (FeedItem $feedItem) { |
||
| 49 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: