GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

KernelBuilder::getKernel()   C
last analyzed

Complexity

Conditions 13
Paths 41

Size

Total Lines 44
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 5.1234
c 0
b 0
f 0
cc 13
eloc 27
nc 41
nop 2

How to fix   Complexity   

Long Method

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:

1
<?php
2
/**
3
 * This file is part of the Global Trading Technologies Ltd workflow-extension-bundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * Author: Alex Medvedev
9
 * Date: 15.05.12
10
 */
11
12
namespace Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional\Kernel;
13
14
/**
15
 * Builds test kernel instance
16
 *
17
 * (c) fduch <[email protected]>
18
 */
19
class KernelBuilder
20
{
21
    /**
22
     * Defines default test kernel class name
23
     *
24
     * @var string
25
     */
26
    protected static $defaultTestKernelClass = '\Gtt\Bundle\WorkflowExtensionsBundle\Tests\Functional\Kernel\BaseTestKernel';
27
28
    /**
29
     * Returns kernel instance
30
     *
31
     * @param string $kernelClass kernel class name need to be instantiated
32
     * @param array $options kernel configuration options
33
     *     base options:
34
     *         environment - environment
35
     *         debug - debug mode
36
     *     test kernel specific options (for TestKernelInterface instances)
37
     *         app_name - name of test application kernel
38
     *         test_case - directory name where kernel configs are stored
39
     *         config_dir - path to directory with test cases configurations
40
     *         root_config - name of the application config file
41
     *         root_dir - path to root directory of test application. Can be unset
42
     *
43
     * @throws \InvalidArgumentException in case of invalid options specified
44
     *
45
     * @return \Symfony\Component\HttpKernel\KernelInterface
46
     */
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