Completed
Push — master ( d00936...2b9629 )
by Sebastian
03:18 queued 01:30
created

FeedController::feed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Spatie\Feed\Http;
4
5
use Spatie\Feed\Feed;
6
use Illuminate\Routing\Controller;
7
8
class FeedController extends Controller
9
{
10
    public function feed()
11
    {
12
        $configuration = $this->getFeedConfiguration();
13
14
        // Overwrite the relative feed url with the request's absolute url
15
        $configuration['url'] = request()->url();
16
17
        return (new Feed($configuration))->getFeedResponse();
18
    }
19
20
    protected function getFeedConfiguration(): array
21
    {
22
        $feeds = config('laravel-feed.feeds');
23
24
        $feedIndex = (int) str_replace('spatieLaravelFeed', '', app('router')->currentRouteName());
25
26
        return $feeds[$feedIndex] ?? abort(404);
27
    }
28
}
29