| Conditions | 11 |
| Paths | 10 |
| Total Lines | 23 |
| Code Lines | 16 |
| 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 declare(strict_types=1); |
||
| 54 | public function validate() |
||
| 55 | { |
||
| 56 | if (1 == $this->required) { // If value is required |
||
| 57 | if (\is_array($this->checkText) && isset($this->checkText['size'])) { // If this is a file |
||
|
|
|||
| 58 | if ('' === $this->checkText['name']) { |
||
| 59 | $this->setError(\_XHELP_MESSAGE_REQUIRED); // Return message saying required value |
||
| 60 | } |
||
| 61 | } else { // If not a file |
||
| 62 | if ('' != $this->pattern) { // If regex pattern is not empty |
||
| 63 | if (!\preg_match('/' . $this->pattern . '/', (string)$this->checkText)) { // Check regex against supplied text |
||
| 64 | $this->setError(\_XHELP_MESSAGE_INVALID); // Return message saying invalid value |
||
| 65 | } |
||
| 66 | } else { |
||
| 67 | if (empty($this->checkText)) { // If text is not supplied |
||
| 68 | $this->setError(\_XHELP_MESSAGE_REQUIRED); // Return message saying required value |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | } else { |
||
| 73 | if (empty($this->checkText)) { |
||
| 74 | if ('' != $this->pattern) { |
||
| 75 | if (!\preg_match('/' . $this->pattern . '/', $this->checkText)) { |
||
| 76 | $this->setError(\_XHELP_MESSAGE_INVALID); |
||
| 77 | } |
||
| 83 |