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   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 1
dl 0
loc 73
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C getKernel() 0 44 13
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