Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Tests | 43 |
CRAP Score | 1 |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
24 | 5 | public function __construct(Request $request) |
|
25 | { |
||
26 | 5 | parent::__construct($request); |
|
27 | |||
28 | 5 | $this->actions->add( |
|
29 | 5 | 'create', |
|
30 | 5 | new Action( |
|
31 | 5 | Request::METHOD_POST, |
|
32 | 5 | 'products/%s/images.json', |
|
33 | 5 | 'image', |
|
34 | 5 | 'image' |
|
35 | ) |
||
36 | ); |
||
37 | 5 | $this->actions->add( |
|
38 | 5 | 'get', |
|
39 | 5 | new Action( |
|
40 | 5 | Request::METHOD_GET, |
|
41 | 5 | 'products/%s/images/%s.json', |
|
42 | 5 | 'image', |
|
43 | 5 | 'image' |
|
44 | ) |
||
45 | ); |
||
46 | 5 | $this->actions->add( |
|
47 | 5 | 'all', |
|
48 | 5 | new Action( |
|
49 | 5 | Request::METHOD_GET, |
|
50 | 5 | 'products/%s/images.json', |
|
51 | 5 | 'images', |
|
52 | 5 | 'images' |
|
53 | ) |
||
54 | ); |
||
55 | 5 | $this->actions->add( |
|
56 | 5 | 'count', |
|
57 | 5 | new Action( |
|
58 | 5 | Request::METHOD_GET, |
|
59 | 5 | 'products/%s/images/count.json', |
|
60 | 5 | 'count', |
|
61 | 5 | 'count' |
|
62 | ) |
||
63 | ); |
||
64 | 5 | $this->actions->add( |
|
65 | 5 | 'update', |
|
66 | 5 | new Action( |
|
67 | 5 | Request::METHOD_PUT, |
|
68 | 5 | 'products/%s/images/%s.json', |
|
69 | 5 | 'image', |
|
70 | 5 | 'image' |
|
71 | ) |
||
72 | ); |
||
73 | 5 | $this->actions->add( |
|
74 | 5 | 'delete', |
|
75 | 5 | new Action( |
|
76 | 5 | Request::METHOD_DELETE, |
|
77 | 5 | 'products/%s/images/%s.json' |
|
78 | ) |
||
79 | ); |
||
80 | 5 | } |
|
81 | } |
||
82 |