Application   A
last analyzed

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
class Application
6
{
7
    private static $config = [];
8
9
    public static function setConfig(array $config)
10
    {
11
        self::$config = $config;
12
    }
13
14
    /**
15
     * Return url path with site url
16
     * @param  string $url sub url
17
     * @return string
18
     */
19
    public static function getUrl($url = '')
20
    {
21
        return self::getPrefixUrl(self::$config['url'], $url);
22
    }
23
24
    public static function getPublicUrl($url = '')
25
    {
26
        return self::getPrefixUrl(self::$config['publicPath'], $url);
27
    }
28
29
    private static function getPrefixUrl($prefix, $path)
30
    {
31
        $prefix = $prefix . (substr($prefix, -1) !== '/' ? '/' : '');
32
        $path = substr($path, 0, 1) === '/' ? substr($path, 1) : $path;
33
34
        return $prefix . $path;
35
    }
36
}
37