url()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 14
rs 9.2222
cc 6
nc 6
nop 1
1
<?php
2
3
/**
4
 * ###############
5
 * ###   URL   ###
6
 * ###############
7
 */
8
9
/**
10
 * @param string $path
11
 * @return string
12
 */
13
function url(string $path = null): string
14
{
15
    if ($_SERVER['HTTP_HOST'] === "goomerapi.test") {
16
        if ($path) {
17
            return CONF_URL_TEST . "/" . CONF_VERSAO_TEST . "/" . ($path[0] == "/" ? mb_substr($path, 1) : $path);
18
        }
19
        return CONF_URL_TEST . "/" . CONF_VERSAO_TEST;
20
    }
21
22
    if ($path) {
23
        return CONF_URL_BASE . "/" . CONF_VERSAO_BASE . "/" . ($path[0] == "/" ? mb_substr($path, 1) : $path);
24
    }
25
26
    return CONF_URL_BASE . "/" . CONF_VERSAO_BASE;
27
}
28
29
/**
30
 * ##################
31
 * ###   ASSETS   ###
32
 * ##################
33
 */
34
35
/**
36
 * @param string $image
37
 * @param int $width
38
 * @param int|null $height
39
 * @return string
40
 */
41
function image(?string $image, int $width, int $height = null): ?string
42
{
43
    if ($image) {
44
        return url() . "/" . (new WagnerMontanini\GoomerApi\Support\Thumb())->make($image, $width, $height);
45
    }
46
47
    return null;
48
}
49