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.

RackTransformer::includeWarehouse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Transformers;
4
5
use App\Rack;
6
use League\Fractal\TransformerAbstract;
7
8
class RackTransformer extends TransformerAbstract
9
{
10
    /**
11
     * List of resources possible to include.
12
     *
13
     * @var array
14
     */
15
    protected $availableIncludes = ['warehouse', 'guitars'];
16
17
    /**
18
     * Turn this item object into a generic array.
19
     *
20
     * @param Rack $rack
21
     *
22
     * @return array
23
     */
24
    public function transform(Rack $rack)
25
    {
26
        return [
27
            'id'       => (int) $rack->id,
28
            'name'     => (string) $rack->name,
29
            'capacity' => (int) $rack->capacity,
30
            'used'     => (int) $rack->used,
31
            'usage'    => (float) $rack->usage,
32
            'make_id'  => (int) $rack->make_id,
33
            'make'     => [
34
                'id'   => (int) $rack->make->id,
35
                'name' => (string) $rack->make->name,
36
            ],
37
        ];
38
    }
39
40
    /**
41
     * Include warehouse.
42
     *
43
     * @param Rack $rack
44
     *
45
     * @return \League\Fractal\Resource\Collection
46
     */
47
    public function includeWarehouse(Rack $rack)
48
    {
49
        return $this->item($rack->warehouse, new WarehouseTransformer);
0 ignored issues
show
Documentation introduced by
new \App\Transformers\WarehouseTransformer() is of type object<App\Transformers\WarehouseTransformer>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
    }
51
52
    /**
53
     * Include guitars.
54
     *
55
     * @param Rack $rack
56
     *
57
     * @return \League\Fractal\Resource\Collection
58
     */
59
    public function includeGuitars(Rack $rack)
60
    {
61
        return $this->collection($rack->guitars, new GuitarTransformer);
0 ignored issues
show
Documentation introduced by
new \App\Transformers\GuitarTransformer() is of type object<App\Transformers\GuitarTransformer>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
62
    }
63
}
64