| Conditions | 10 | 
| Paths | 12 | 
| Total Lines | 39 | 
| Code Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
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  | 
            ||
| 68 | public function queueMiddleware($middleWareClass, $priority = 50)  | 
            ||
| 69 |     { | 
            ||
| 70 |         if (isset($this->index)) { | 
            ||
| 71 |             throw new RuntimeException('You are forbidden to add new middleware after start.'); | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | // Don't throw error if the user defines the default middleware classes.  | 
            ||
| 75 |         if (in_array($middleWareClass, $this->keyMiddlewareList)) { | 
            ||
| 76 | return $this;  | 
            ||
| 77 | }  | 
            ||
| 78 | |||
| 79 |         if (in_array($middleWareClass, $this->pipelineList)) { | 
            ||
| 80 | throw new InvalidArgumentException(  | 
            ||
| 81 |                 sprintf('The class "%s" is already added to the pipeline.', $middleWareClass) | 
            ||
| 82 | );  | 
            ||
| 83 | }  | 
            ||
| 84 | |||
| 85 | $interfaces = class_implements($middleWareClass);  | 
            ||
| 86 | |||
| 87 |         if ($interfaces && !in_array(MiddlewareInterface::class, $interfaces)) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 88 | throw new InvalidArgumentException(  | 
            ||
| 89 |                 sprintf('The class "%s" does not implement MiddlewareInterface.', $middleWareClass) | 
            ||
| 90 | );  | 
            ||
| 91 | }  | 
            ||
| 92 | |||
| 93 |         if ($priority === 0 || $priority == 100) { | 
            ||
| 94 | $priority++;  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 |         if (!isset($this->priorityList[$priority])) { | 
            ||
| 98 | $this->priorityList[$priority] = [];  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 |         if (!in_array($middleWareClass, $this->priorityList[$priority])) { | 
            ||
| 102 | $this->priorityList[$priority][] = $middleWareClass;  | 
            ||
| 103 | }  | 
            ||
| 104 | |||
| 105 | return $this;  | 
            ||
| 106 | }  | 
            ||
| 107 | |||
| 148 | 
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.