| Conditions | 2 |
| Paths | 2 |
| Total Lines | 65 |
| 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 |
||
| 109 | public static function statusProvider(): array |
||
| 110 | { |
||
| 111 | if (!class_exists(Success::class)) { |
||
| 112 | return [[1, 1, 1]]; |
||
| 113 | } |
||
| 114 | |||
| 115 | $data = []; |
||
| 116 | |||
| 117 | $data[] = [ |
||
| 118 | [ |
||
| 119 | MessageInterface::STATE_IN_PROGRESS => 11, //here |
||
| 120 | MessageInterface::STATE_ERROR => 31, |
||
| 121 | MessageInterface::STATE_OPEN => 100, |
||
| 122 | MessageInterface::STATE_DONE => 10000, |
||
| 123 | ], |
||
| 124 | new Failure(), |
||
| 125 | 'Too many messages processed at the same time (Database)', |
||
| 126 | ]; |
||
| 127 | |||
| 128 | $data[] = [ |
||
| 129 | [ |
||
| 130 | MessageInterface::STATE_IN_PROGRESS => 1, |
||
| 131 | MessageInterface::STATE_ERROR => 31, //here |
||
| 132 | MessageInterface::STATE_OPEN => 100, |
||
| 133 | MessageInterface::STATE_DONE => 10000, |
||
| 134 | ], |
||
| 135 | new Failure(), |
||
| 136 | 'Too many errors (Database)', |
||
| 137 | ]; |
||
| 138 | |||
| 139 | $data[] = [ |
||
| 140 | [ |
||
| 141 | MessageInterface::STATE_IN_PROGRESS => 1, |
||
| 142 | MessageInterface::STATE_ERROR => 1, |
||
| 143 | MessageInterface::STATE_OPEN => 101, //here |
||
| 144 | MessageInterface::STATE_DONE => 10000, |
||
| 145 | ], |
||
| 146 | new Warning(), |
||
| 147 | 'Too many messages waiting to be processed (Database)', |
||
| 148 | ]; |
||
| 149 | |||
| 150 | $data[] = [ |
||
| 151 | [ |
||
| 152 | MessageInterface::STATE_IN_PROGRESS => 1, |
||
| 153 | MessageInterface::STATE_ERROR => 1, |
||
| 154 | MessageInterface::STATE_OPEN => 100, |
||
| 155 | MessageInterface::STATE_DONE => 10001, //here |
||
| 156 | ], |
||
| 157 | new Warning(), |
||
| 158 | 'Too many processed messages, please clean the database (Database)', |
||
| 159 | ]; |
||
| 160 | |||
| 161 | $data[] = [ |
||
| 162 | [ |
||
| 163 | MessageInterface::STATE_IN_PROGRESS => 1, |
||
| 164 | MessageInterface::STATE_ERROR => 1, |
||
| 165 | MessageInterface::STATE_OPEN => 1, |
||
| 166 | MessageInterface::STATE_DONE => 1, |
||
| 167 | ], |
||
| 168 | new Success(), |
||
| 169 | 'Ok (Database)', |
||
| 170 | ]; |
||
| 171 | |||
| 172 | return $data; |
||
| 173 | } |
||
| 174 | } |
||
| 175 |