Test Failed
Push — develop ( 1bc728...a00b17 )
by Edwin
03:32
created

Article::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 75
Code Lines 56

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 57
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 75
ccs 57
cts 57
cp 1
rs 9
c 0
b 0
f 0
cc 1
eloc 56
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/article
10
 *
11
 * @method create(float $parentId, array $parameters = [])
12
 * @method get(float $parentId, float $childId)
13
 * @method all(float $parentId, array $parameters = [])
14
 * @method count(float $parentId)
15
 * @method update(float $parentId, float $childId, array $parameters = [])
16
 * @method tags(float $parentId, array $parameters = [])
17
 * @method authors
18
 * @method delete(float $parentId, float $childId)
19
 *
20
 * @property ArticleMetaField $metafields
21
 * @property CustomerAddress $addresses
22
 */
23
class Article extends AbstractResource implements Resource
24
{
25
    /**
26
     * @var array
27
     */
28
    protected $childResources = [
29
        'metafields' => ArticleMetaField::class,
30
    ];
31
32
    /**
33
     * Article constructor.
34
     * @param Request $request
35
     */
36 5
    public function __construct(Request $request)
37
    {
38 5
        parent::__construct($request);
39
40 5
        $this->actions->add(
41 5
            'create',
42 5
            new Action(
43 5
                Request::METHOD_POST,
44 5
                'blogs/%s/articles.json',
45 5
                'article',
46 5
                'article'
47
            )
48
        );
49 5
        $this->actions->add(
50 5
            'get',
51 5
            new Action(
52 5
                Request::METHOD_GET,
53 5
                'blogs/%s/articles/%s.json',
54 5
                'article',
55 5
                'article'
56
            )
57
        );
58 5
        $this->actions->add(
59 5
            'all',
60 5
            new Action(
61 5
                Request::METHOD_GET,
62 5
                'blogs/%s/articles.json',
63 5
                'articles',
64 5
                'articles'
65
            )
66
        );
67 5
        $this->actions->add(
68 5
            'count',
69 5
            new Action(
70 5
                Request::METHOD_GET,
71 5
                'blogs/%s/articles/count.json',
72 5
                'count',
73 5
                'count'
74
            )
75
        );
76 5
        $this->actions->add(
77 5
            'update',
78 5
            new Action(
79 5
                Request::METHOD_PUT,
80 5
                'blogs/%s/articles/%s.json',
81 5
                'article',
82 5
                'article'
83
            )
84
        );
85 5
        $this->actions->add(
86 5
            'tags',
87 5
            new Action(
88 5
                Request::METHOD_GET,
89 5
                'blogs/%s/articles/tags.json',
90 5
                'tags',
91 5
                'tags'
92
            )
93
        );
94 5
        $this->actions->add(
95 5
            'authors',
96 5
            new Action(
97 5
                Request::METHOD_GET,
98 5
                'articles/authors.json',
99 5
                'authors',
100 5
                'authors'
101
            )
102
        );
103 5
        $this->actions->add(
104 5
            'delete',
105 5
            new Action(
106 5
                Request::METHOD_DELETE,
107 5
                'blogs/%s/articles/%s.json'
108
            )
109
        );
110 5
    }
111
}
112