| Conditions | 12 | 
| Paths | 32 | 
| Total Lines | 39 | 
| Code Lines | 20 | 
| 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  | 
            ||
| 85 | public static function getInstance($serviceName, $serviceInterface, $isSingleton = false)  | 
            ||
| 86 |     { | 
            ||
| 87 | // as the LogProviderInterface is itself a service, we don't call it's constructor again during instantiation  | 
            ||
| 88 |         if (self::$logger === null && $serviceInterface != 'Alpha\Util\Logging\LogProviderInterface') { | 
            ||
| 89 |             self::$logger = new Logger('ServiceFactory'); | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 |         if (self::$logger !== null) { | 
            ||
| 93 |             self::$logger->debug('>>getInstance(serviceName=['.$serviceName.'], serviceInterface=['.$serviceInterface.'], isSingleton=['.$isSingleton.'])'); | 
            ||
| 94 | }  | 
            ||
| 95 | |||
| 96 |         if (class_exists($serviceName)) { | 
            ||
| 97 |             if ($isSingleton && in_array($serviceName, self::$singletons)) { | 
            ||
| 98 | return self::$singletons[$serviceName];  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 | $instance = new $serviceName();  | 
            ||
| 102 | |||
| 103 |             if (!$instance instanceof $serviceInterface) { | 
            ||
| 104 |                 throw new IllegalArguementException('The class ['.$serviceName.'] does not implement the expected ['.$serviceInterface.'] interface!'); | 
            ||
| 105 | }  | 
            ||
| 106 | |||
| 107 |             if ($isSingleton && !in_array($serviceName, self::$singletons)) { | 
            ||
| 108 | self::$singletons[$serviceName] = $instance;  | 
            ||
| 109 | }  | 
            ||
| 110 | |||
| 111 |             if (self::$logger !== null) { | 
            ||
| 112 |                 self::$logger->debug('<<getInstance: [Object '.$serviceName.']'); | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | return $instance;  | 
            ||
| 116 |         } else { | 
            ||
| 117 |             if (self::$logger !== null) { | 
            ||
| 118 |                 self::$logger->debug('<<getInstance'); | 
            ||
| 119 | }  | 
            ||
| 120 | |||
| 121 |             throw new IllegalArguementException('The class ['.$serviceName.'] is not defined anywhere!'); | 
            ||
| 122 | }  | 
            ||
| 123 | }  | 
            ||
| 124 | }  | 
            ||
| 125 |