Conditions | 9 |
Paths | 4 |
Total Lines | 60 |
Code Lines | 43 |
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 |
||
90 | protected function getRightGroupField(TabulatorGrid_ItemRequest $itemRequest) |
||
91 | { |
||
92 | $rightGroup = CompositeField::create()->setName('RightGroup'); |
||
93 | $rightGroup->addExtraClass('ms-auto'); |
||
94 | $rightGroup->setFieldHolderTemplate(get_class($rightGroup) . '_holder_buttongroup'); |
||
95 | |||
96 | $previousAndNextGroup = CompositeField::create()->setName('PreviousAndNextGroup'); |
||
97 | $previousAndNextGroup->setFieldHolderTemplate(CompositeField::class . '_holder_buttongroup'); |
||
98 | |||
99 | $grid = $itemRequest->getTabulatorGrid(); |
||
100 | $record = $itemRequest->getRecord(); |
||
101 | $pagination = $grid->getOption("pagination"); |
||
102 | if ($pagination) { |
||
103 | $previousIsDisabled = !$itemRequest->getPreviousRecordID(); |
||
104 | $nextIsDisabled = !$itemRequest->getNextRecordID(); |
||
105 | |||
106 | $previousAndNextGroup->push( |
||
107 | LiteralField::create( |
||
108 | 'previous-record', |
||
109 | HTML::createTag($previousIsDisabled ? 'span' : 'a', [ |
||
110 | 'href' => $previousIsDisabled ? '#' : $itemRequest->getEditLink($itemRequest->getPreviousRecordID()), |
||
111 | 'title' => _t(__CLASS__ . '.PREVIOUS', 'Go to previous record'), |
||
112 | 'aria-label' => _t(__CLASS__ . '.PREVIOUS', 'Go to previous record'), |
||
113 | 'class' => 'btn btn-light action--previous discard-confirmation' |
||
114 | . ($previousIsDisabled ? ' disabled' : ''), |
||
115 | ], '<l-i name="navigate_before"></l-i>') |
||
116 | ) |
||
117 | ); |
||
118 | |||
119 | $previousAndNextGroup->push( |
||
120 | LiteralField::create( |
||
121 | 'next-record', |
||
122 | HTML::createTag($nextIsDisabled ? 'span' : 'a', [ |
||
123 | 'href' => $nextIsDisabled ? '#' : $itemRequest->getEditLink($itemRequest->getNextRecordID()), |
||
124 | 'title' => _t(__CLASS__ . '.NEXT', 'Go to next record'), |
||
125 | 'aria-label' => _t(__CLASS__ . '.NEXT', 'Go to next record'), |
||
126 | 'class' => 'btn btn-light action--next discard-confirmation' |
||
127 | . ($nextIsDisabled ? ' disabled' : ''), |
||
128 | ], '<l-i name="navigate_next"></l-i>') |
||
129 | ) |
||
130 | ); |
||
131 | } |
||
132 | |||
133 | $rightGroup->push($previousAndNextGroup); |
||
134 | |||
135 | if ($record->canCreate()) { |
||
136 | $rightGroup->push( |
||
137 | LiteralField::create( |
||
138 | 'new-record', |
||
139 | HTML::createTag('a', [ |
||
140 | 'href' => Controller::join_links($grid->Link('item'), 'new'), |
||
141 | 'title' => _t(__CLASS__ . '.NEW', 'Add new record'), |
||
142 | 'aria-label' => _t(__CLASS__ . '.NEW', 'Add new record'), |
||
143 | 'class' => 'btn btn-success action--new discard-confirmation', |
||
144 | ], '<l-i name="add"></l-i>') |
||
145 | ) |
||
146 | ); |
||
147 | } |
||
148 | |||
149 | return $rightGroup; |
||
150 | } |
||
193 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.