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 |
||
23 | 5 | public function __construct(Request $request) |
|
24 | { |
||
25 | 5 | parent::__construct($request); |
|
26 | |||
27 | 5 | $this->actions->add( |
|
28 | 5 | 'create', |
|
29 | 5 | new Action( |
|
30 | 5 | Request::METHOD_POST, |
|
31 | 5 | 'fulfillment_services.json', |
|
32 | 5 | 'fulfillment_service', |
|
33 | 5 | 'fulfillment_service' |
|
34 | ) |
||
35 | ); |
||
36 | 5 | $this->actions->add( |
|
37 | 5 | 'get', |
|
38 | 5 | new Action( |
|
39 | 5 | Request::METHOD_GET, |
|
40 | 5 | 'fulfillment_services/%s.json', |
|
41 | 5 | 'fulfillment_service', |
|
42 | 5 | 'fulfillment_service' |
|
43 | ) |
||
44 | ); |
||
45 | 5 | $this->actions->add( |
|
46 | 5 | 'all', |
|
47 | 5 | new Action( |
|
48 | 5 | Request::METHOD_GET, |
|
49 | 5 | 'fulfillment_services.json', |
|
50 | 5 | 'fulfillment_services', |
|
51 | 5 | 'fulfillment_services' |
|
52 | ) |
||
53 | ); |
||
54 | 5 | $this->actions->add( |
|
55 | 5 | 'count', |
|
56 | 5 | new Action( |
|
57 | 5 | Request::METHOD_GET, |
|
58 | 5 | 'orders/%s/fulfillments/count.json', |
|
59 | 5 | 'count', |
|
60 | 5 | 'count' |
|
61 | ) |
||
62 | ); |
||
63 | 5 | $this->actions->add( |
|
64 | 5 | 'update', |
|
65 | 5 | new Action( |
|
66 | 5 | Request::METHOD_PUT, |
|
67 | 5 | 'fulfillment_services/%s.json', |
|
68 | 5 | 'fulfillment_service', |
|
69 | 5 | 'fulfillment_service' |
|
70 | ) |
||
71 | ); |
||
72 | 5 | $this->actions->add( |
|
73 | 5 | 'delete', |
|
74 | 5 | new Action( |
|
75 | 5 | Request::METHOD_DELETE, |
|
76 | 5 | 'fulfillment_services/%s.json' |
|
77 | ) |
||
78 | ); |
||
79 | 5 | } |
|
80 | } |
||
81 |