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