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 |
||
134 | public function validate(): bool |
||
135 | { |
||
136 | $errorStorage = $this->getNode()->getZone()->getErrorsStore(); |
||
137 | |||
138 | \Yii::error($this->getTag(), 'check'); |
||
139 | |||
140 | if (!in_array($this->tag, [self::TAG_ISSUE, self::TAG_ISSUEWILD, self::TAG_IODEF])) { |
||
141 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_TAG(), 'tag')); |
||
142 | } |
||
143 | |||
144 | if ($this->flags < 0 || $this->flags > 128) { |
||
145 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_FLAG(), 'flag')); |
||
|
|||
146 | } |
||
147 | |||
148 | if (!Int16Validator::validate($this->getFlags())) { |
||
149 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_INT16(), 'flags')); |
||
150 | } |
||
151 | |||
152 | if (in_array($this->getTag(), [self::TAG_ISSUEWILD, self::TAG_ISSUE]) && |
||
153 | $this->getValue() !== ';' |
||
154 | ) { |
||
155 | $parts = explode(";", $this->getValue()); |
||
156 | |||
157 | if (!preg_match(self::PATTERN_FQDN, $parts[0])) { |
||
158 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_VALUE(), 'value')); |
||
159 | } |
||
160 | } |
||
161 | |||
162 | if ($this->getTag() == self::TAG_IODEF) { |
||
163 | if (!filter_var($this->getValue(), FILTER_VALIDATE_EMAIL) && !filter_var($this->getValue(), FILTER_VALIDATE_URL)) { |
||
164 | $errorStorage->add(ValidationError::makeRecordError($this, eErrorCode::WRONG_CAA_VALUE(), 'value')); |
||
165 | } |
||
166 | } |
||
167 | |||
168 | /** @noinspection PhpInternalEntityUsedInspection */ |
||
169 | return parent::validate(); |
||
170 | } |
||
171 | |||
183 | } |
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.