| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 15 | ||
| Bugs | 2 | Features | 8 |
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 |
||
| 30 | public function rules() |
||
| 31 | { |
||
| 32 | return [ |
||
| 33 | [['id', 'tariff_id', 'client_id', 'seller_id'], 'integer'], |
||
| 34 | [['osimage'], EidValidator::class], |
||
| 35 | [['panel'], RefValidator::class], |
||
| 36 | [ |
||
| 37 | [ |
||
| 38 | 'name', 'dc', |
||
| 39 | 'client', 'seller', |
||
| 40 | 'os', 'panel', 'rcp', |
||
| 41 | 'parent_tariff', 'tariff', 'tariff_note', 'discounts', |
||
| 42 | 'request_state', 'request_state_label', |
||
| 43 | 'autorenewal', |
||
| 44 | 'type', 'type_label', 'state', 'state_label', 'statuses', |
||
| 45 | 'block_reason_label', |
||
| 46 | 'running_task', |
||
| 47 | 'ip', 'ips', 'mac', |
||
| 48 | 'vnc', |
||
| 49 | 'note', 'label', 'hwsummary', |
||
| 50 | ], |
||
| 51 | 'safe', |
||
| 52 | ], |
||
| 53 | [['switches', 'rack', 'net', 'kvm', 'pdu', 'ipmi'], 'safe'], |
||
| 54 | [['last_expires', 'expires', 'status_time', 'sale_time'], 'date'], |
||
| 55 | [ |
||
| 56 | ['state'], |
||
| 57 | 'isOperable', |
||
| 58 | 'on' => [ |
||
| 59 | 'reinstall', |
||
| 60 | 'reboot', |
||
| 61 | 'reset', |
||
| 62 | 'shutdown', |
||
| 63 | 'power-off', |
||
| 64 | 'power-on', |
||
| 65 | 'boot-live', |
||
| 66 | 'regen-root-password', |
||
| 67 | 'reset-password', |
||
| 68 | ], |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | ['id'], |
||
| 72 | 'required', |
||
| 73 | 'on' => [ |
||
| 74 | 'refuse', 'delete', 'enable-autorenewal', |
||
| 75 | 'enable-vnc', 'set-note', 'set-label', |
||
| 76 | 'enable-block', 'disable-block', |
||
| 77 | ], |
||
| 78 | ], |
||
| 79 | [ |
||
| 80 | ['id'], |
||
| 81 | 'integer', |
||
| 82 | 'on' => [ |
||
| 83 | 'refuse', 'delete', 'enable-autorenewal', |
||
| 84 | 'enable-vnc', 'set-note', 'set-label', |
||
| 85 | 'enable-block', 'disable-block', |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | [['id', 'osimage', 'panel'], 'required', 'on' => ['reinstall']], |
||
| 89 | [['id', 'osimage'], 'required', 'on' => ['boot-live']], |
||
| 90 | [['type', 'comment'], 'required', 'on' => ['enable-block']], |
||
| 91 | [['comment'], 'safe', 'on' => ['disable-block']], |
||
| 92 | ]; |
||
| 93 | } |
||
| 94 | |||
| 234 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.