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

FeedController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A feed() 0 9 1
A getFeedConfiguration() 0 8 1
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