ReplyTransformer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includeUser() 0 4 1
A transformData() 0 4 1
1
<?php
2
3
namespace PHPHub\Transformers;
4
5
/**
6
 * Class ReplyTransformer.
7
 */
8
class ReplyTransformer extends BaseTransformer
9
{
10
    /**
11
     * Resources that can be included if requested.
12
     *
13
     * @var array
14
     */
15
    protected $availableIncludes = ['user'];
16
17
    /**
18
     * Transform the \Reply entity.
19
     *
20
     * @param \Reply $model
21
     *
22
     * @return array
23
     */
24
    public function transformData($model)
25
    {
26
        return $model->toArray();
27
    }
28
29
    public function includeUser($model)
30
    {
31
        return $this->item($model->user, new UserTransformer());
0 ignored issues
show
Documentation introduced by
new \PHPHub\Transformers\UserTransformer() is of type object<PHPHub\Transformers\UserTransformer>, 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...
32
    }
33
}
34