Application::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Air\Application;
4
5
use Air\Routing\Router\RouterInterface;
6
use Air\Routing\Dispatcher\DispatcherInterface;
7
use Air\HTTP\Request\RequestInterface;
8
9
abstract class Application
10
{
11
    /**
12
     * @var RouterInterface $router A router object.
13
     */
14
    protected $router;
15
16
17
    /**
18
     * @var DispatcherInterface $dispatcher A dispatcher object.
19
     */
20
    protected $dispatcher;
21
22
23
    /**
24
     * @var RequestInterface $request A request object.
25
     */
26
    protected $request;
27
28
29
    /**
30
     * @param RouterInterface $router A router.
31
     */
32
    public function setRouter(RouterInterface $router)
33
    {
34
        $this->router = $router;
35
    }
36
37
38
    /**
39
     * @param DispatcherInterface $dispatcher A dispatcher.
40
     */
41
    public function setDispatcher(DispatcherInterface $dispatcher)
42
    {
43
        $this->dispatcher = $dispatcher;
44
    }
45
46
47
    /**
48
     * @param RequestInterface $request A request.
49
     */
50
    public function setRequest(RequestInterface $request)
51
    {
52
        $this->request = $request;
53
    }
54
55
56
    /**
57
     * Runs the application.
58
     */
59
    public function run()
60
    {
61
        $resolvedRequest = $this->router->route($this->request);
62
        echo $this->dispatcher->dispatch($resolvedRequest);
63
    }
64
}
65