| Conditions | 13 |
| Paths | 41 |
| Total Lines | 44 |
| Code Lines | 27 |
| 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 |
||
| 47 | public static function getKernel($kernelClass = null, array $options = array()) |
||
| 48 | { |
||
| 49 | if (!($kernelClass === null)) { |
||
| 50 | if (!class_exists($kernelClass)) { |
||
| 51 | throw new \InvalidArgumentException("Cannot load $kernelClass"); |
||
| 52 | } |
||
| 53 | } else { |
||
| 54 | $kernelClass = self::$defaultTestKernelClass; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (defined("KERNEL_ENV")) { |
||
| 58 | $options['environment'] = KERNEL_ENV; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (defined("KERNEL_DEBUG")) { |
||
| 62 | $options['debug'] = KERNEL_DEBUG; |
||
| 63 | } |
||
| 64 | |||
| 65 | $kernel = new $kernelClass( |
||
| 66 | isset($options['environment']) ? $options['environment'] : 'test', |
||
| 67 | isset($options['debug']) ? $options['debug'] : true |
||
| 68 | ); |
||
| 69 | |||
| 70 | if ($kernel instanceof TestKernelInterface) { |
||
| 71 | if (!isset($options['app_name'])) { |
||
| 72 | throw new \InvalidArgumentException('The option "app_name" must be set.'); |
||
| 73 | } |
||
| 74 | if (!isset($options['config_dir'])) { |
||
| 75 | throw new \InvalidArgumentException('The option "config_dir" must be set.'); |
||
| 76 | } |
||
| 77 | if (!isset($options['test_case'])) { |
||
| 78 | throw new \InvalidArgumentException('The option "test_case" must be set.'); |
||
| 79 | } |
||
| 80 | |||
| 81 | $kernel->setTestKernelConfiguration( |
||
| 82 | $options['app_name'], |
||
| 83 | $options['test_case'], |
||
| 84 | $options['config_dir'], |
||
| 85 | isset($options['root_config']) ? $options['root_config'] : 'config.yml', |
||
| 86 | isset($options['root_dir']) ? $options['root_dir'] : false); |
||
| 87 | } |
||
| 88 | |||
| 89 | return $kernel; |
||
| 90 | } |
||
| 91 | } |
||
| 92 |