Completed
Push — master ( d3d92b...e2ac41 )
by Park Jong-Hun
03:08
created

Application   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 4 1
A getUrl() 0 4 1
A getPublicUrl() 0 4 1
A getPrefixUrl() 0 7 3
1
<?php
2
3
namespace Core;
4
5
use JBZoo\Event\EventManager;
6
7
class Application
8
{
9
    private static $config = [];
10
11
    public static function setConfig(array $config)
12
    {
13
        self::$config = $config;
14
    }
15
16
    /**
17
     * Return url path with site url
18
     * @param  string $url sub url
19
     * @return string
20
     */
21
    public static function getUrl($url = '')
22
    {
23
        return self::getPrefixUrl(self::$config['url'], $url);
24
    }
25
26
    public static function getPublicUrl($url = '')
27
    {
28
        return self::getPrefixUrl(self::$config['publicPath'], $url);
29
    }
30
31
    private static function getPrefixUrl($prefix, $path)
32
    {
33
        $prefix = $prefix . (substr($prefix, -1) !== '/' ? '/' : '');
34
        $path = substr($path, 0, 1) === '/' ? substr($path, 1) : $path;
35
36
        return $prefix . $path;
37
    }
38
}
39