Country::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 57
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 43
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 43
cts 43
cp 1
rs 9.6818
c 0
b 0
f 0
cc 1
eloc 42
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
use ShopifyClient\Action\Action;
6
use ShopifyClient\Request;
7
8
/**
9
 * https://help.shopify.com/api/reference/country
10
 *
11
 * @method create(array $parameters = [])
12
 * @method get(float $parentId)
13
 * @method all(float $parentId)
14
 * @method count(float $parentId)
15
 * @method update(float $parentId, array $parameters = [])
16
 * @method delete(float $parentId)
17
 */
18
class Country extends AbstractResource implements Resource
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $childResources = [
24
        'provinces' => Province::class,
25
    ];
26
27
    /**
28
     * Country constructor.
29
     * @param Request $request
30
     */
31 5
    public function __construct(Request $request)
32
    {
33 5
        parent::__construct($request);
34
35 5
        $this->actions->add(
36 5
            'create',
37 5
            new Action(
38 5
                Request::METHOD_POST,
39 5
                'countries.json',
40 5
                'country',
41 5
                'country'
42
            )
43
        );
44 5
        $this->actions->add(
45 5
            'get',
46 5
            new Action(
47 5
                Request::METHOD_GET,
48 5
                'countries/%s.json',
49 5
                'country',
50 5
                'country'
51
            )
52
        );
53 5
        $this->actions->add(
54 5
            'all',
55 5
            new Action(
56 5
                Request::METHOD_GET,
57 5
                'countries.json',
58 5
                'countries',
59 5
                'countries'
60
            )
61
        );
62 5
        $this->actions->add(
63 5
            'count',
64 5
            new Action(
65 5
                Request::METHOD_GET,
66 5
                'countries/count.json',
67 5
                'count',
68 5
                'count'
69
            )
70
        );
71 5
        $this->actions->add(
72 5
            'update',
73 5
            new Action(
74 5
                Request::METHOD_PUT,
75 5
                'countries/%s.json',
76 5
                'country',
77 5
                'country'
78
            )
79
        );
80 5
        $this->actions->add(
81 5
            'delete',
82 5
            new Action(
83 5
                Request::METHOD_DELETE,
84 5
                'countries/%s.json'
85
            )
86
        );
87 5
    }
88
}
89