Service::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix;
14
15
class Service
16
{
17
18
    /**
19
     * Returns the specified service -- or all if unspecified.
20
     *
21
     * @param  string     $key=null  The service key to retrieve.
0 ignored issues
show
Bug introduced by
There is no parameter named $key=null. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
22
     * @param  array|null $args=null An array of argument to pass to the service.
0 ignored issues
show
Bug introduced by
There is no parameter named $args=null. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
23
     * @return mixed
24
     */
25
    public static function get($key=null, $args=null)
26
    {
27
        return Config::getInstance()->getServices($key, $args);
28
    }
29
30
    /**
31
     * Sets the specified name, value as a service.
32
     *
33
     * @param  string $name The service name to set.
34
     * @param  mixed  $mix  The corresponding value to set.
35
     * @return void
36
     */
37
    public static function set($name, $mix)
38
    {
39
        Config::getInstance()->setService($name, $mix);
40
    }
41
42
    /**
43
     * Checks wether the named service exists or not.
44
     *
45
     * @param  string  $name The service name to look for.
46
     * @return boolean
47
     */
48
    public static function has($name)
49
    {
50
        $services = Config::getInstance()->get('services');
51
52
        return isset($services[$name]);
53
    }
54
55
    /**
56
     * Checks wether the named service exists or not.
57
     *
58
     * @param  string  $name The service name to look for.
0 ignored issues
show
Bug introduced by
There is no parameter named $name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
59
     * @return boolean
60
     */
61
    public static function debug($key=null)
62
    {
63
        echo '<pre>';
64
        var_dump( Config::getInstance()->getServices($key) );
0 ignored issues
show
Security Debugging Code introduced by
var_dump(\Apix\Config::g...()->getServices($key)); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
65
        echo '</pre>';
66
    }
67
68
}
69