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.

TransactionTransfomer::transform()   B
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 36
Code Lines 26

Duplication

Lines 14
Ratio 38.89 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 26
nc 16
nop 1
dl 14
loc 36
rs 8.439
c 1
b 0
f 0
1
<?php
2
3
namespace App\Transformers;
4
5
use App\Models\Transaction;
6
use League\Fractal\TransformerAbstract;
7
8
class TransactionTransfomer extends TransformerAbstract
9
{
10
    /**
11
     * A Fractal transformer.
12
     *
13
     * @return array
14
     */
15
    public function transform(Transaction $item)
16
    {
17
        $data = [
18
            'id'                => $item->id,
19
            'account_name'      => $item->account_name,
20
            'to_account_name'   => $item->to_account_name,
21
            'payee_name'        => $item->payee_name,
22
            'category_name'     => $item->category_name,
23
            'sub_category_name' => $item->sub_category_name,
24
            'category_names'    => $item->sub_category_name ? $item->category_name.' / '.$item->sub_category_name : $item->category_name,
25
            'amount'            => round($item->amount, 2),
26
            'notes'             => $item->notes,
27
            'transaction_date'  => $item->transaction_date ? $item->transaction_date->toIso8601String() : null,
28
            'has_attachments'   => $item->hasAttachments(),
29
            'created_at'        => $item->created_at->toIso8601String(),
30
            'updated_at'        => $item->updated_at->toIso8601String(),
31
        ];
32
33 View Code Duplication
        if ($item->status) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
            $data['status'] = [
35
                'id'   => $item->status->id,
36
                'name' => __('mmex.'.$item->status->name),
37
                'slug' => $item->status->slug,
38
            ];
39
        }
40
41 View Code Duplication
        if ($item->type()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
            $data['type'] = [
43
                'id'   => $item->type->id,
44
                'name' => __('mmex.'.$item->type->name),
45
                'slug' => $item->type->slug,
46
            ];
47
        }
48
49
        return $data;
50
    }
51
}
52