Completed
Push — master ( faca0c...e03155 )
by Park Jong-Hun
03:46
created

Application::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Core;
4
5
use Doctrine\ORM\Tools\Setup;
6
use Doctrine\ORM\EntityManager;
7
use JBZoo\Event\EventManager;
8
use Core\ControllerDispatcher\Dispatcher;
9
use Psr\Http\Message\ServerRequestInterface;
10
11
class Application
12
{
13
    private $siteConfig = [];
14
15
    /**
16
     * Singleton: private constructor
17
     */
18
    private function __construct()
19
    {
20
    }
21
22
    /**
23
     * @return Application
24
     */
25
    public static function getInstance()
26
    {
27
        static $instance = null;
28
29
        if ($instance === null) {
30
            $instance = new self();
31
        }
32
33
        return $instance;
34
    }
35
36
    public function setSiteConfig(array $siteConfig)
37
    {
38
        $this->siteConfig = $siteConfig;
39
    }
40
41
42
    /**
43
     * Return url path with site url
44
     * @param  string $url sub url
45
     * @return string
46
     */
47
    public function url($url = '')
48
    {
49
        $url = $url === '/' ? '' : $url;
50
        return $this->siteConfig['url'] . $url;
51
    }
52
53
    public function getPublicUrl($url = '')
54
    {
55
        $url = $url === '/' ? '' : $url;
56
        return $this->siteConfig['publicPath'] . $url;
57
    }
58
59
60
    /**
61
     * @return EventManager
62
     */
63
    public function getEventManager()
64
    {
65
        static $instance = null;
66
67
        if ($instance === null) {
68
            $instance = new EventManager();
69
        }
70
71
        return $instance;
72
    }
73
}
74