Conditions | 9 |
Paths | 4 |
Total Lines | 61 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
92 | protected function getRightGroupField(TabulatorGrid_ItemRequest $itemRequest) |
||
93 | { |
||
94 | $rightGroup = CompositeField::create()->setName('RightGroup'); |
||
95 | $rightGroup->addExtraClass('ml-auto'); |
||
96 | $rightGroup->setFieldHolderTemplate(get_class($rightGroup) . '_holder_buttongroup'); |
||
97 | |||
98 | $previousAndNextGroup = CompositeField::create()->setName('PreviousAndNextGroup'); |
||
99 | $previousAndNextGroup->addExtraClass('btn-group--circular mr-2'); |
||
100 | $previousAndNextGroup->setFieldHolderTemplate(CompositeField::class . '_holder_buttongroup'); |
||
101 | |||
102 | $grid = $itemRequest->getTabulatorGrid(); |
||
103 | $record = $itemRequest->getRecord(); |
||
104 | $pagination = $grid->getOption("pagination"); |
||
105 | if ($pagination) { |
||
106 | $previousIsDisabled = !$itemRequest->getPreviousRecordID(); |
||
107 | $nextIsDisabled = !$itemRequest->getNextRecordID(); |
||
108 | |||
109 | $previousAndNextGroup->push( |
||
110 | LiteralField::create( |
||
111 | 'previous-record', |
||
112 | HTML::createTag($previousIsDisabled ? 'span' : 'a', [ |
||
113 | 'href' => $previousIsDisabled ? '#' : $itemRequest->getEditLink($itemRequest->getPreviousRecordID()), |
||
114 | 'title' => _t(__CLASS__ . '.PREVIOUS', 'Go to previous record'), |
||
115 | 'aria-label' => _t(__CLASS__ . '.PREVIOUS', 'Go to previous record'), |
||
116 | 'class' => 'btn btn-secondary font-icon-left-open action--previous discard-confirmation' |
||
117 | . ($previousIsDisabled ? ' disabled' : ''), |
||
118 | ]) |
||
119 | ) |
||
120 | ); |
||
121 | |||
122 | $previousAndNextGroup->push( |
||
123 | LiteralField::create( |
||
124 | 'next-record', |
||
125 | HTML::createTag($nextIsDisabled ? 'span' : 'a', [ |
||
126 | 'href' => $nextIsDisabled ? '#' : $itemRequest->getEditLink($itemRequest->getNextRecordID()), |
||
127 | 'title' => _t(__CLASS__ . '.NEXT', 'Go to next record'), |
||
128 | 'aria-label' => _t(__CLASS__ . '.NEXT', 'Go to next record'), |
||
129 | 'class' => 'btn btn-secondary font-icon-right-open action--next discard-confirmation' |
||
130 | . ($nextIsDisabled ? ' disabled' : ''), |
||
131 | ]) |
||
132 | ) |
||
133 | ); |
||
134 | } |
||
135 | |||
136 | $rightGroup->push($previousAndNextGroup); |
||
137 | |||
138 | if ($record->canCreate()) { |
||
139 | $rightGroup->push( |
||
140 | LiteralField::create( |
||
141 | 'new-record', |
||
142 | HTML::createTag('a', [ |
||
143 | 'href' => Controller::join_links($grid->Link('item'), 'new'), |
||
144 | 'title' => _t(__CLASS__ . '.NEW', 'Add new record'), |
||
145 | 'aria-label' => _t(__CLASS__ . '.NEW', 'Add new record'), |
||
146 | 'class' => 'btn btn-primary font-icon-plus-thin btn--circular action--new discard-confirmation', |
||
147 | ]) |
||
148 | ) |
||
149 | ); |
||
150 | } |
||
151 | |||
152 | return $rightGroup; |
||
153 | } |
||
209 |
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.