Conditions | 11 |
Paths | 72 |
Total Lines | 37 |
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 |
||
139 | public function validate(): bool |
||
140 | { |
||
141 | $errorStorage = $this->getNode()->getZone()->getErrorsStore(); |
||
142 | |||
143 | \Yii::error($this->getTag(), 'check'); |
||
144 | |||
145 | if (!in_array($this->tag, [self::TAG_ISSUE, self::TAG_ISSUEWILD, self::TAG_IODEF])) { |
||
146 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_TAG(), 'tag')); |
||
147 | } |
||
148 | |||
149 | if ($this->flags < 0 || $this->flags > 128) { |
||
150 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_FLAG(), 'flag')); |
||
|
|||
151 | } |
||
152 | |||
153 | if (!Int16Validator::validate($this->getFlags())) { |
||
154 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_INT16(), 'flags')); |
||
155 | } |
||
156 | |||
157 | if (in_array($this->getTag(), [self::TAG_ISSUEWILD, self::TAG_ISSUE]) && |
||
158 | $this->getValue() !== ';' |
||
159 | ) { |
||
160 | $parts = explode(";", $this->getValue()); |
||
161 | |||
162 | if (!preg_match(self::PATTERN_FQDN, $parts[0])) { |
||
163 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_VALUE(), 'value')); |
||
164 | } |
||
165 | } |
||
166 | |||
167 | if ($this->getTag() == self::TAG_IODEF) { |
||
168 | if (!filter_var($this->getValue(), FILTER_VALIDATE_EMAIL) && !filter_var($this->getValue(), FILTER_VALIDATE_URL)) { |
||
169 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_VALUE(), 'value')); |
||
170 | } |
||
171 | } |
||
172 | |||
173 | /** @noinspection PhpInternalEntityUsedInspection */ |
||
174 | return parent::validate(); |
||
175 | } |
||
176 | |||
188 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.