Completed
Push — master ( 90174b...a197f9 )
by Changwan
03:50
created

functions.php ➔ route()   A

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
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Event
3
{
4
    use function Wandu\DI\container;
5
6
    /**
7
     * @param string|object $event
8
     */
9
    function trigger($event)
10
    {
11
        container()->get(EventEmitter::class)->trigger($event);
12
    }
13
}
14
15
namespace Wandu\Foundation
16
{
17
    use function Wandu\DI\container;
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
18
19
    /**
20
     * @deprecated use function Wandu\DI\container
21
     * @return \Wandu\DI\ContainerInterface
22
     */
23
    function app()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
24
    {
25
        return container();
26
    }
27
28
    /**
29
     * @param string $name
30
     * @param mixed $default
31
     * @return mixed
32
     */
33
    function config($name, $default = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
    {
35
        return container()->get('config')->get($name, $default);
36
    }
37
}
38
39
namespace Wandu\View
40
{
41
    use Wandu\View\Contracts\RenderInterface;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
42
    use function Wandu\DI\container;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
43
44
    /**
45
     * @param string $template
46
     * @param array $attributes
47
     * @param string $basePath
48
     * @return string
49
     */
50
    function render($template, array $attributes = [], $basePath = null)
51
    {
52
        return container()->get(RenderInterface::class)->render($template, $attributes, $basePath);
53
    }
54
}
55
56
namespace Wandu\Validator
57
{
58
    use Wandu\Validator\Contracts\Tester;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
59
    use function Wandu\DI\container;
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
60
61
    /**
62
     * @param string $tester
63
     * @param array $arguments
64
     * @return \Wandu\Validator\Contracts\Tester
65
     */
66
    function tester(string $tester, array $arguments = []): Tester
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
67
    {
68
        $factory = container()->get(TesterFactory::class);
69
        if (count($arguments)) {
70
            return $factory->create($tester, $arguments);
71
        }
72
        return $factory->parse($tester);
73
    }
74
75
    /**
76
     * @param string|\Wandu\Validator\Contracts\Rule $rule
77
     * @return \Wandu\Validator\Validator
78
     */
79
    function validator($rule): Validator
80
    {
81
        return container()->get(ValidatorFactory::class)->create($rule);
82
    }
83
}
84