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