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

HalTransformer::includeCurries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace League\Fractal\Hal;
4
5
use League\Fractal\TransformerAbstract;
6
7
/**
8
 * Class responsible for the Hypertext Application Language (HAL) transformation.
9
 *
10
 * @package League\Fractal\Hal
11
 */
12
class HalTransformer extends TransformerAbstract
13
{
14
    /**
15
     * List of resources to automatically include.
16
     *
17
     * @var array
18
     */
19
    protected $defaultIncludes = [
20
        'curries'
21
    ];
22
23
    /**
24
     * Transform data to output.
25
     *
26
     * @param HalInterface $resource Links to the current data.
27
     *
28
     * @return array List with transformed data.
29
     */
30 1
    public function transform(HalInterface $resource)
31
    {
32
        return [
33 1
            'self'     => $resource->getSelfLink(),
34 1
            'next'     => $resource->getNextLink(),
35 1
            'previous' => $resource->getPreviousLink()
36 1
        ];
37
    }
38
39
    /**
40
     * Include resources locations.
41
     *
42
     * @param HalInterface $resource Links to the current data.
43
     *
44
     * @return \League\Fractal\Resource\Item Fractal resource item OBJ.
45
     */
46 1
    public function includeCurries(HalInterface $resource)
47
    {
48 1
        return $this->collection($resource->getCurries(), new CurrieTransformer());
0 ignored issues
show
Documentation introduced by
new \League\Fractal\Hal\CurrieTransformer() is of type object<League\Fractal\Hal\CurrieTransformer>, 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...
49
    }
50
}
51