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

CurrieTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 38
ccs 0
cts 6
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 7 1
A includeResources() 0 4 1
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