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.
Completed
Push — master ( 79e180...3094b9 )
by Miles
09:00
created

VarsServiceProvider   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 9
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 75
ccs 21
cts 21
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
C register() 0 26 7
A boot() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the m1\vars library
5
 *
6
 * (c) m1 <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @package     m1/vars
12
 * @version     0.2.0
13
 * @author      Miles Croxford <[email protected]>
14
 * @copyright   Copyright (c) Miles Croxford <[email protected]>
15
 * @license     http://github.com/m1/vars/blob/master/LICENSE
16
 * @link        http://github.com/m1/vars/blob/master/README.MD Documentation
17
 */
18
19
namespace M1\Vars\Provider\Silex;
20
21
use Silex\Application;
22
use Silex\ServiceProviderInterface;
23
use M1\Vars\Vars;
24
25
/**
26
 * The Silex service provider for Vars
27
 *
28
 * @since 0.1.0
29
 */
30
class VarsServiceProvider implements ServiceProviderInterface
31
{
32
    /**
33
     * The entity to use Vars with
34
     *
35
     * @var null
36
     */
37
    private $entity;
38
39
    /**
40
     * The available option keys
41
     *
42
     * @var array
43
     */
44
    private $option_keys = array(
45
        'cache',
46
        'cache_path',
47
        'cache_expire',
48
        'loaders',
49
        'variables'
50
    );
51
52
    /**
53
     * The service provider constructor sets the entity to use with vars
54
     *
55
     * @param mixed $entity The entity
56
     */
57 3
    public function __construct($entity = null)
58
    {
59 3
        $this->entity = $entity;
60 3
    }
61
62
    /**
63
     * Registers the service provider, sets the user defined options and returns the vars instance
64
     *
65
     * @param \Silex\Application $app The silex app
66
     */
67
    public function register(Application $app)
68
    {
69 3
        $app['vars'] = function ($app) {
70 3
            $options = array();
71
72 3
            if (isset($app['vars.path'])) {
73 1
                $options['base_path'] = $app['vars.path'];
74 1
            }
75
76 3
            if (isset($app['vars.options'])) {
77 2
                $keyed_options = $app['vars.options'];
78
79 2
                foreach ($this->option_keys as $option) {
80 2
                    if (isset($keyed_options[$option])) {
81 2
                        $options[$option] = $keyed_options[$option];
82 2
                    }
83 2
                }
84 2
            }
85
86 3
            if (isset($app['debug']) && $app['debug']) {
87 1
                $options['cache'] = false;
88 1
            }
89
90 3
            return new Vars($this->entity, $options);
91
        };
92 3
    }
93
94
    /**
95
     * The silex service provider boot function
96
     *
97
     * @param \Silex\Application $app The silex app
98
     *
99
     * @codeCoverageIgnore
100
     */
101
    public function boot(Application $app)
102
    {
103
    }
104
}
105