GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Presenter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A present() 0 17 4
A setMeta() 0 4 1
1
<?php
2
3
namespace Milkmeowo\Framework\Base\Presenters;
4
5
use Exception;
6
use Illuminate\Support\Collection;
7
use Illuminate\Pagination\AbstractPaginator;
8
use Prettus\Repository\Presenter\FractalPresenter;
9
10
abstract class Presenter extends FractalPresenter
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $meta = [];
16
17
    /**
18
     * Prepare data to present.
19
     *
20
     * @param $data
21
     *
22
     * @return mixed
23
     * @throws Exception
24
     */
25
    public function present($data)
26
    {
27
        if (! class_exists('League\Fractal\Manager')) {
28
            throw new Exception(trans('repository::packages.league_fractal_required'));
29
        }
30
        if ($data instanceof Collection) {
31
            $this->resource = $this->transformCollection($data);
32
        } elseif ($data instanceof AbstractPaginator) {
33
            $this->resource = $this->transformPaginator($data);
34
        } else {
35
            $this->resource = $this->transformItem($data);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->transformItem($data) of type object<League\Fractal\Resource\Item> is incompatible with the declared type object<League\Fractal\Resource\Collection> of property $resource.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36
        }
37
        // set meta
38
        $this->resource->setMeta($this->meta);
39
40
        return $this->fractal->createData($this->resource)->toArray();
41
    }
42
43
    /**
44
     * @param array $meta
45
     */
46
    public function setMeta(array $meta)
47
    {
48
        $this->meta = $meta;
49
    }
50
}
51