| Conditions | 19 |
| Paths | 19 |
| Total Lines | 86 |
| Code Lines | 77 |
| Lines | 0 |
| Ratio | 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 |
||
| 21 | public function __construct(\Doku_Form $oldform) { |
||
| 22 | parent::__construct($oldform->params); |
||
|
|
|||
| 23 | |||
| 24 | $this->hidden = $oldform->_hidden; |
||
| 25 | |||
| 26 | foreach($oldform->_content as $element) { |
||
| 27 | list($ctl, $attr) = $this->parseLegacyAttr($element); |
||
| 28 | |||
| 29 | if(is_array($element)) { |
||
| 30 | switch($ctl['elem']) { |
||
| 31 | case 'wikitext': |
||
| 32 | $this->addTextarea('wikitext') |
||
| 33 | ->attrs($attr) |
||
| 34 | ->id('wiki__text') |
||
| 35 | ->val($ctl['text']) |
||
| 36 | ->addClass($ctl['class']); |
||
| 37 | break; |
||
| 38 | case 'textfield': |
||
| 39 | $this->addTextInput($ctl['name'], $ctl['text']) |
||
| 40 | ->attrs($attr) |
||
| 41 | ->id($ctl['id']) |
||
| 42 | ->addClass($ctl['class']); |
||
| 43 | break; |
||
| 44 | case 'passwordfield': |
||
| 45 | $this->addPasswordInput($ctl['name'], $ctl['text']) |
||
| 46 | ->attrs($attr) |
||
| 47 | ->id($ctl['id']) |
||
| 48 | ->addClass($ctl['class']); |
||
| 49 | break; |
||
| 50 | case 'checkboxfield': |
||
| 51 | $this->addCheckbox($ctl['name'], $ctl['text']) |
||
| 52 | ->attrs($attr) |
||
| 53 | ->id($ctl['id']) |
||
| 54 | ->addClass($ctl['class']); |
||
| 55 | break; |
||
| 56 | case 'radiofield': |
||
| 57 | $this->addRadioButton($ctl['name'], $ctl['text']) |
||
| 58 | ->attrs($attr) |
||
| 59 | ->id($ctl['id']) |
||
| 60 | ->addClass($ctl['class']); |
||
| 61 | break; |
||
| 62 | case 'tag': |
||
| 63 | $this->addTag($ctl['tag']) |
||
| 64 | ->attrs($attr) |
||
| 65 | ->attr('name', $ctl['name']) |
||
| 66 | ->id($ctl['id']) |
||
| 67 | ->addClass($ctl['class']); |
||
| 68 | break; |
||
| 69 | case 'opentag': |
||
| 70 | $this->addTagOpen($ctl['tag']) |
||
| 71 | ->attrs($attr) |
||
| 72 | ->attr('name', $ctl['name']) |
||
| 73 | ->id($ctl['id']) |
||
| 74 | ->addClass($ctl['class']); |
||
| 75 | break; |
||
| 76 | case 'closetag': |
||
| 77 | $this->addTagClose($ctl['tag']); |
||
| 78 | break; |
||
| 79 | case 'openfieldset': |
||
| 80 | $this->addFieldsetOpen($ctl['legend']) |
||
| 81 | ->attrs($attr) |
||
| 82 | ->attr('name', $ctl['name']) |
||
| 83 | ->id($ctl['id']) |
||
| 84 | ->addClass($ctl['class']); |
||
| 85 | break; |
||
| 86 | case 'closefieldset': |
||
| 87 | $this->addFieldsetClose(); |
||
| 88 | break; |
||
| 89 | case 'button': |
||
| 90 | case 'field': |
||
| 91 | case 'fieldright': |
||
| 92 | case 'filefield': |
||
| 93 | case 'menufield': |
||
| 94 | case 'listboxfield': |
||
| 95 | throw new \UnexpectedValueException('Unsupported legacy field ' . $ctl['elem']); |
||
| 96 | break; |
||
| 97 | default: |
||
| 98 | throw new \UnexpectedValueException('Unknown legacy field ' . $ctl['elem']); |
||
| 99 | |||
| 100 | } |
||
| 101 | } else { |
||
| 102 | $this->addHTML($element); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | } |
||
| 107 | |||
| 182 |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.