Conditions | 12 |
Paths | 259 |
Total Lines | 24 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 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 |
||
33 | public function store($offset, $data) |
||
34 | { |
||
35 | if ($offset === 'permission') { |
||
36 | if (in_array($data, ['GRANTED', 'DENIED'])) { |
||
37 | $data = strtoupper($data); |
||
38 | } else { |
||
39 | return; |
||
40 | } |
||
41 | } elseif ($offset === 'privileges') { |
||
42 | list($create, $read, $update, $delete, $import, $export, $print, $special) = array_pad(str_split($data), 8, |
||
43 | 0); |
||
44 | $data = [ |
||
45 | 'create' => ($create == '1' ? true : false), |
||
46 | 'read' => ($read == '1' ? true : false), |
||
47 | 'update' => ($update == '1' ? true : false), |
||
48 | 'delete' => ($delete == '1' ? true : false), |
||
49 | 'import' => ($import == '1' ? true : false), |
||
50 | 'export' => ($export == '1' ? true : false), |
||
51 | 'print' => ($print == '1' ? true : false), |
||
52 | 'special' => ($special == '1' ? true : false), |
||
53 | ]; |
||
54 | } |
||
55 | |||
56 | parent::store($offset, $data); |
||
57 | } |
||
117 | } |