| Conditions | 1 |
| Paths | 1 |
| Total Lines | 84 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 64 |
| 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 |
||
| 40 | 5 | public function __construct(Request $request) |
|
| 41 | { |
||
| 42 | 5 | parent::__construct($request); |
|
| 43 | |||
| 44 | 5 | $this->actions->add( |
|
| 45 | 5 | 'create', |
|
| 46 | 5 | new Action( |
|
| 47 | 5 | Request::METHOD_POST, |
|
| 48 | 5 | 'orders.json', |
|
| 49 | 5 | 'order', |
|
| 50 | 5 | 'order' |
|
| 51 | ) |
||
| 52 | ); |
||
| 53 | 5 | $this->actions->add( |
|
| 54 | 5 | 'get', |
|
| 55 | 5 | new Action( |
|
| 56 | 5 | Request::METHOD_GET, |
|
| 57 | 5 | 'orders/%s.json', |
|
| 58 | 5 | 'order', |
|
| 59 | 5 | 'order' |
|
| 60 | ) |
||
| 61 | ); |
||
| 62 | 5 | $this->actions->add( |
|
| 63 | 5 | 'all', |
|
| 64 | 5 | new Action( |
|
| 65 | 5 | Request::METHOD_GET, |
|
| 66 | 5 | 'orders.json', |
|
| 67 | 5 | 'orders', |
|
| 68 | 5 | 'orders' |
|
| 69 | ) |
||
| 70 | ); |
||
| 71 | 5 | $this->actions->add( |
|
| 72 | 5 | 'count', |
|
| 73 | 5 | new Action( |
|
| 74 | 5 | Request::METHOD_GET, |
|
| 75 | 5 | 'orders/count.json', |
|
| 76 | 5 | 'count', |
|
| 77 | 5 | 'count' |
|
| 78 | ) |
||
| 79 | ); |
||
| 80 | 5 | $this->actions->add( |
|
| 81 | 5 | 'update', |
|
| 82 | 5 | new Action( |
|
| 83 | 5 | Request::METHOD_PUT, |
|
| 84 | 5 | 'orders/%s.json', |
|
| 85 | 5 | 'order', |
|
| 86 | 5 | 'order' |
|
| 87 | ) |
||
| 88 | ); |
||
| 89 | 5 | $this->actions->add( |
|
| 90 | 5 | 'open', |
|
| 91 | 5 | new Action( |
|
| 92 | 5 | Request::METHOD_POST, |
|
| 93 | 5 | 'orders/%s/open.json', |
|
| 94 | 5 | 'order', |
|
| 95 | 5 | 'order' |
|
| 96 | ) |
||
| 97 | ); |
||
| 98 | 5 | $this->actions->add( |
|
| 99 | 5 | 'close', |
|
| 100 | 5 | new Action( |
|
| 101 | 5 | Request::METHOD_POST, |
|
| 102 | 5 | 'orders/%s/close.json', |
|
| 103 | 5 | 'order', |
|
| 104 | 5 | 'order' |
|
| 105 | ) |
||
| 106 | ); |
||
| 107 | 5 | $this->actions->add( |
|
| 108 | 5 | 'cancel', |
|
| 109 | 5 | new Action( |
|
| 110 | 5 | Request::METHOD_POST, |
|
| 111 | 5 | 'orders/%s/cancel.json', |
|
| 112 | 5 | 'order', |
|
| 113 | 5 | 'order' |
|
| 114 | ) |
||
| 115 | ); |
||
| 116 | 5 | $this->actions->add( |
|
| 117 | 5 | 'delete', |
|
| 118 | 5 | new Action( |
|
| 119 | 5 | Request::METHOD_DELETE, |
|
| 120 | 5 | 'orders/%s.json' |
|
| 121 | ) |
||
| 122 | ); |
||
| 123 | 5 | } |
|
| 124 | |||
| 127 |