Completed
Push — master ( 744da7...90845d )
by Jolita
02:14
created

Feed   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B feed() 0 29 1
1
<?php
2
3
namespace Spatie\Feed;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Http\Response as HttpResponse;
7
use Illuminate\Support\Facades\Response;
8
9
class Feed
10
{
11
    protected $app;
12
13
    public function __construct(Application $app)
14
    {
15
        $this->app = $app;
16
    }
17
18
    public function feed($feed) : HttpResponse
19
    {
20
        $data = [];
21
        $items = explode('@', $feed['items']);
22
        $method = $items[1];
23
24
        $data['items'] = $this->app->make($items[0])->$method()->map(function (FeedItem $item) {
25
26
            return $item->getFeedData();
27
        });
28
29
30
        collect($data['items'])->filter(function($item){
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
//            dd($item['updated']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
        });
33
34
        $data['meta'] = [
35
            'link' => $feed['url'],
36
            'description' => $feed['description'],
37
            'title' => $feed['title'],
38
//            'updated' =>
39
        ];
40
41
        return Response::view(
42
            'laravel-feed::feed',
43
            $data, 200,
44
            ['Content-Type' => 'application/atom+xml; chartset=UTF-8']
45
        );
46
    }
47
}
48