Completed
Push — master ( a935c4...ac4ac7 )
by Jim
04:30
created

helpers.php ➔ value()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TimSDK;
4
5
use TimSDK\Container\ServiceContainer;
6
use TimSDK\Support\Dumper;
7
8
/**
9
 * Return the default value of the given value.
10
 *
11
 * @param  mixed  $value
12
 * @return mixed
13
 */
14
function value($value)
15
{
16 20
    return $value instanceof \Closure ? $value() : $value;
17
}
18
19
/**
20
 * Get the available container instance.
21
 *
22
 * @param string $abstract
23
 * @return mixed
24
 */
25
function app($abstract = null)
26
{
27 7
    if (is_null($abstract)) {
28 1
        return ServiceContainer::getInstance();
29
    }
30
31 7
    return ServiceContainer::getInstance()->offsetGet($abstract);
32
}
33
34
/**
35
 * Dump the passed variables and end the script.
36
 */
37
function dd()
38
{
39
    foreach (func_get_args() as $arg) {
40
        (new Dumper)->dump($arg);
41
    }
42
43
    die(1);
0 ignored issues
show
Coding Style Compatibility introduced by
The function dd() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
44
}
45
46
/**
47
 * Dump the passed variables and end the script.
48
 */
49
function d()
50
{
51
    foreach (func_get_args() as $arg) {
52
        (new Dumper)->dump($arg);
53
    }
54
}
55