GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PayeeTransformer::transform()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 13
nc 4
nop 1
dl 0
loc 21
rs 9.0534
c 1
b 0
f 0
1
<?php
2
3
namespace App\Transformers;
4
5
use App\Models\Category;
6
use App\Models\Payee;
7
use League\Fractal\TransformerAbstract;
8
9
class PayeeTransformer extends TransformerAbstract
10
{
11
    /**
12
     * A Fractal transformer.
13
     *
14
     * @return array
15
     */
16
    public function transform(Payee $payee)
17
    {
18
        $data = [
19
            'id'   => $payee->id,
20
            'name' => $payee->name,
21
        ];
22
23
        $category = null;
0 ignored issues
show
Unused Code introduced by
$category is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24
        if ($category = Category::find($payee->last_category_id)) {
25
            if ($category) {
26
                if ($category->parent_id) {
27
                    $data['category_id'] = $category->parent_id;
28
                    $data['sub_category_id'] = $category->id;
29
                } else {
30
                    $data['category_id'] = $category->id;
31
                }
32
            }
33
        }
34
35
        return $data;
36
    }
37
}
38