Completed
Pull Request — master (#293)
by
unknown
02:49
created

CurrieTransformer::transform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

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 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
namespace League\Fractal\Hal;
4
5
use League\Fractal\TransformerAbstract;
6
7
class CurrieTransformer extends TransformerAbstract
8
{
9
    /**
10
     * List of resources to automatically include.
11
     *
12
     * @var array
13
     */
14
    protected $defaultIncludes = [
15
        'resources'
16
    ];
17
18
    /**
19
     * Transformation representation of currie OBJ.
20
     *
21
     * @param Currie $currie Currie OBJ.
22
     *
23
     * @return array Currie OBJ transformed.
24
     */
25
    public function transform(Currie $currie)
26
    {
27
        return [
28
            'name' => $currie->getName(),
29
            'href' => $currie->getHref()
30
        ];
31
    }
32
33
    /**
34
     * Include currie resources.
35
     *
36
     * @param Currie $currie Resource curries.
37
     *
38
     * @return \League\Fractal\Resource\Item Fractal resource item OBJ.
39
     */
40
    public function includeResources(Currie $currie)
41
    {
42
        return $this->collection($currie->getResources(), new CurrieResourceTransformer($currie->getName()));
0 ignored issues
show
Documentation introduced by
new \League\Fractal\Hal\...mer($currie->getName()) is of type object<League\Fractal\Ha...rieResourceTransformer>, 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...
43
    }
44
}
45