Completed
Push — master ( 3309bb...059e5b )
by Changwan
02:58
created

functions.php ➔ trigger()   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 1
dl 0
loc 4
ccs 0
cts 2
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 \Wandu\Event\EventInterface $event
8
     */
9
    function trigger(EventInterface $event)
10
    {
11
        container()->get(Dispatcher::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 1
        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\Router
57
{
58
    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...
59
60
    /**
61
     * @return \Wandu\Router\Dispatcher
62
     */
63
    function dispatcher()
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...
64
    {
65
        return container()->get(Dispatcher::class);
66
    }
67
    
68
    /**
69
     * @param string $name
70
     * @param array $attributes
71
     * @return string
72
     */
73
    function route(string $name, array $attributes = [])
74
    {
75
        return dispatcher()->getPath($name, $attributes);
76
    }
77
}
78
79
namespace Wandu\Validator
80
{
81
    use Wandu\Validator\Contracts\Tester;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
82
    use function Wandu\DI\container;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
83
84
    /**
85
     * @param string $tester
86
     * @param array $arguments
87
     * @return \Wandu\Validator\Contracts\Tester
88
     */
89
    function tester(string $tester, array $arguments = []): Tester
90
    {
91
        $factory = container()->get(TesterFactory::class);
92
        if (count($arguments)) {
93
            return $factory->create($tester, $arguments);
94
        }
95
        return $factory->parse($tester);
96
    }
97
98
    /**
99
     * @param string|\Wandu\Validator\Contracts\Rule $rule
100
     * @return \Wandu\Validator\Validator
101
     */
102
    function validator($rule): Validator
103
    {
104
        return container()->get(ValidatorFactory::class)->create($rule);
105
    }
106
}
107