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.

GuitarTransformer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B transform() 0 38 5
1
<?php
2
3
namespace App\Transformers;
4
5
use App\Guitar;
6
use League\Fractal\TransformerAbstract;
7
8
class GuitarTransformer extends TransformerAbstract
9
{
10
    /**
11
     * List of resources possible to include.
12
     *
13
     * @var array
14
     */
15
    protected $availableIncludes = ['purchase', 'sale'];
16
17
    /**
18
     * Turn this item object into a generic array.
19
     *
20
     * @param Guitar $guitar
21
     *
22
     * @return array
23
     */
24
    public function transform(Guitar $guitar)
25
    {
26
        return [
27
            'id'        => $guitar->id,
28
            'make'      => [
29
                'id'   => $guitar->make->id,
30
                'name' => $guitar->make->name,
31
            ],
32
            'model'     => [
33
                'id'    => $guitar->model->id,
34
                'name'  => $guitar->model->name,
35
                'photo' => $guitar->model->photo,
36
            ],
37
            'warehouse' => [
38
                'id'   => $guitar->rack->warehouse->id,
39
                'name' => $guitar->rack->warehouse->name,
40
            ],
41
            'rack'      => [
42
                'id'       => $guitar->rack->id,
43
                'name'     => $guitar->rack->name,
44
                'capacity' => $guitar->rack->capacity,
45
            ],
46
            'sale'      => [
47
                'id'      => $guitar->isSold() ? $guitar->sale->id : null,
48
                'name'    => $guitar->isSold() ? $guitar->sale->name : null,
49
                'address' => $guitar->isSold() ? $guitar->sale->address : null,
50
                'date'    => $guitar->isSold() ? (string) $guitar->sale->created_at->toFormattedDateString() : null,
51
            ],
52
            'make_id'   => $guitar->make_id,
53
            'model_id'  => $guitar->model_id,
54
            'rack_id'   => $guitar->rack_id,
55
            'colour'    => $guitar->colour,
56
            'price'     => (float) $guitar->price,
57
            'damaged'   => (bool) $guitar->damaged,
58
            'condition' => $guitar->condition,
59
            'sold'      => (bool) $guitar->isSold(),
60
        ];
61
    }
62
}
63