| Conditions | 1 |
| Paths | 1 |
| Total Lines | 87 |
| 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 | 'type' => 'select', |
||
| 40 | 'attributes' => array( |
||
| 41 | 'type' => 'select', |
||
| 42 | 'options' => array( |
||
| 43 | ), |
||
| 44 | ), |
||
| 45 | 'options' => array( |
||
| 46 | 'label' => 'role', |
||
| 47 | ), |
||
| 48 | ) |
||
| 49 | ); |
||
| 50 | $this->add( |
||
| 51 | array( |
||
| 52 | 'name' => 'aclresources_id', |
||
| 53 | 'type' => 'select', |
||
| 54 | 'attributes' => array( |
||
| 55 | 'type' => 'select', |
||
| 56 | 'options' => array( |
||
| 57 | ), |
||
| 58 | ), |
||
| 59 | 'options' => array( |
||
| 60 | 'label' => 'resource', |
||
| 61 | ), |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | $this->add( |
||
| 65 | array( |
||
| 66 | 'name' => 'state', |
||
| 67 | 'type' => 'select', |
||
| 68 | 'attributes' => array( |
||
| 69 | 'type' => 'select', |
||
| 70 | 'options' => array( |
||
| 71 | '' => '---', |
||
| 72 | 'allow' => 'allow', |
||
| 73 | 'deny' => 'deny', |
||
| 74 | ), |
||
| 75 | ), |
||
| 76 | 'options' => array( |
||
| 77 | 'label' => 'state', |
||
| 78 | ), |
||
| 79 | ) |
||
| 80 | ); |
||
| 81 | |||
| 82 | $this->add( |
||
| 83 | array( |
||
| 84 | 'name' => 'reset', |
||
| 85 | 'attributes' => array( |
||
| 86 | 'type' => 'reset', |
||
| 87 | 'value' => 'reset', |
||
| 88 | 'id' => 'resetbutton', |
||
| 89 | ), |
||
| 90 | 'options' => array( |
||
| 91 | 'label' => 'reset', |
||
| 92 | ), |
||
| 93 | ) |
||
| 94 | ); |
||
| 95 | $this->add( |
||
| 96 | array( |
||
| 97 | 'name' => 'submit', |
||
| 98 | 'attributes' => array( |
||
| 99 | 'type' => 'submit', |
||
| 100 | 'value' => 'save', |
||
| 101 | 'id' => 'submitbutton', |
||
| 102 | ), |
||
| 103 | 'options' => array( |
||
| 104 | 'label' => 'save', |
||
| 105 | ), |
||
| 106 | ) |
||
| 107 | ); |
||
| 108 | } |
||
| 109 | } |