Conditions | 10 |
Paths | 10 |
Total Lines | 35 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
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 |
||
45 | public function __construct(\O2System\Database\DataObjects\Result $result, Model &$model) |
||
46 | { |
||
47 | if ($result->count() > 0) { |
||
48 | $ormResult = new \SplFixedArray($result->count()); |
||
49 | |||
50 | foreach ($result as $key => $row) { |
||
51 | if (method_exists($model, 'rebuildRow')) { |
||
52 | $row = $model->rebuildRow($row); |
||
|
|||
53 | } |
||
54 | |||
55 | // Visible Columns |
||
56 | if (count($model->visibleColumns)) { |
||
57 | $columns = $row->getColumns(); |
||
58 | foreach ($columns as $column) { |
||
59 | if ( ! in_array($column, $model->visibleColumns)) { |
||
60 | array_push($model->hideColumns, $column); |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | |||
65 | // Hide Columns |
||
66 | if (count($model->hideColumns)) { |
||
67 | foreach ($model->hideColumns as $column) { |
||
68 | if ($row->offsetExists($column)) { |
||
69 | $row->offsetUnset($column); |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 | |||
74 | $ormResult[ $key ] = new Result\Row($row, $model); |
||
75 | } |
||
76 | |||
77 | parent::__construct($ormResult->toArray()); |
||
78 | |||
79 | unset($ormResult); |
||
80 | } |
||
128 | } |