BaseTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includeUser() 0 5 2
A includeAuthUser() 0 5 2
1
<?php
2
3
namespace Yeelight\Transformers;
4
5
use Yeelight\Base\Models\BaseModel;
6
use Yeelight\Base\Transformers\Transformer;
7
8
/**
9
 * Class BaseTransformer
10
 *
11
 * @category Yeelight
12
 *
13
 * @package Yeelight\Transformers
14
 *
15
 * @author Sheldon Lee <[email protected]>
16
 *
17
 * @license https://opensource.org/licenses/MIT MIT
18
 *
19
 * @link https://www.yeelight.com
20
 */
21
class BaseTransformer extends Transformer
22
{
23
    /**
24
     * Include User.
25
     *
26
     * @param BaseModel $model
27
     *
28
     * @return \League\Fractal\Resource\Item
29
     */
30
    public function includeUser(BaseModel $model)
31
    {
32
        $user = $model->user;
0 ignored issues
show
Bug introduced by
The property user does not exist on Yeelight\Base\Models\BaseModel. Did you mean user_id?
Loading history...
33
        if ($user) {
34
            return $this->item($user, new UserTransformer(), 'user');
35
        }
36
    }
37
38
    /**
39
     * Include User.
40
     *
41
     * @param BaseModel $model
42
     *
43
     * @return \League\Fractal\Resource\Item
44
     */
45
    public function includeAuthUser(BaseModel $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
    public function includeAuthUser(/** @scrutinizer ignore-unused */ BaseModel $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        $user = auth_user();
48
        if ($user) {
0 ignored issues
show
introduced by
$user is of type Yeelight\Models\Foundation\BaseUser, thus it always evaluated to true.
Loading history...
49
            return $this->item($user, new UserTransformer());
50
        }
51
    }
52
}
53