| Conditions | 1 |
| Paths | 1 |
| Total Lines | 72 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| 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 |
||
| 22 | public function __construct($name = null) |
||
| 23 | { |
||
| 24 | // we want to ignore the name passed |
||
| 25 | parent::__construct('acl'); |
||
| 26 | $this->setAttribute('method', 'post'); |
||
| 27 | |||
| 28 | $this->add( |
||
| 29 | array( |
||
| 30 | 'name' => 'acl_id', |
||
| 31 | 'attributes' => array( |
||
| 32 | 'type' => 'hidden', |
||
| 33 | ), |
||
| 34 | ) |
||
| 35 | ); |
||
| 36 | $this->add( |
||
| 37 | array( |
||
| 38 | 'name' => 'aclroles_id', |
||
| 39 | 'attributes' => array( |
||
| 40 | 'type' => 'hidden', |
||
| 41 | ), |
||
| 42 | ) |
||
| 43 | ); |
||
| 44 | $this->add( |
||
| 45 | array( |
||
| 46 | 'name' => 'aclresources_id', |
||
| 47 | 'attributes' => array( |
||
| 48 | 'type' => 'hidden', |
||
| 49 | ), |
||
| 50 | ) |
||
| 51 | ); |
||
| 52 | $this->add( |
||
| 53 | array( |
||
| 54 | 'name' => 'state', |
||
| 55 | 'type' => 'select', |
||
| 56 | 'attributes' => array( |
||
| 57 | 'type' => 'select', |
||
| 58 | 'options' => array( |
||
| 59 | '' => '---', |
||
| 60 | 'allow' => 'allow', |
||
| 61 | 'deny' => 'deny', |
||
| 62 | ), |
||
| 63 | ), |
||
| 64 | ) |
||
| 65 | ); |
||
| 66 | |||
| 67 | $this->add( |
||
| 68 | array( |
||
| 69 | 'name' => 'reset', |
||
| 70 | 'attributes' => array( |
||
| 71 | 'type' => 'reset', |
||
| 72 | 'value' => 'reset', |
||
| 73 | 'id' => 'resetbutton', |
||
| 74 | ), |
||
| 75 | 'options' => array( |
||
| 76 | 'label' => 'reset', |
||
| 77 | ), |
||
| 78 | ) |
||
| 79 | ); |
||
| 80 | $this->add( |
||
| 81 | array( |
||
| 82 | 'name' => 'submit', |
||
| 83 | 'attributes' => array( |
||
| 84 | 'type' => 'submit', |
||
| 85 | 'value' => 'save', |
||
| 86 | 'id' => 'submitbutton', |
||
| 87 | ), |
||
| 88 | 'options' => array( |
||
| 89 | 'label' => 'save', |
||
| 90 | ), |
||
| 91 | ) |
||
| 92 | ); |
||
| 93 | } |
||
| 94 | } |