Passed
Push — master ( 399fd0...af4f7a )
by Elf
02:32
created

is_app()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
nc 4
nop 1
dl 0
loc 15
ccs 8
cts 8
cp 1
crap 4
rs 9.2
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A app_id() 0 9 3
1
<?php
2
3
use ElfSundae\Laravel\Apps\AppIdentifier;
4
5
if (! function_exists('app_id')) {
6
    /**
7
     * Get or check the current application identifier.
8
     *
9
     * @return string|bool
10
     */
11
    function app_id()
12
    {
13
        $identifier = AppIdentifier::get();
14
15
        if (func_num_args() > 0) {
16
            return in_array($identifier, is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args());
17
        }
18
19
        return $identifier;
20
    }
21
}
22
23
if (! function_exists('app_url')) {
24
    /**
25
     * Generate an absolute URL to the given path.
26
     *
27
     * @param  string  $path
28
     * @param  mixed  $query
29
     * @param  mixed  $identifier
30
     * @return string
31
     */
32
    function app_url($path = '', $query = [], $identifier = '')
33
    {
34 1
        if (is_string($query)) {
35 1
            list($query, $identifier) = [$identifier, $query];
36
        }
37
38 1
        if ($path = ltrim($path, '/')) {
39 1
            $path = '/'.$path;
40
        }
41
42 1
        if ($query && $query = http_build_query($query)) {
43 1
            $path .= (str_contains($path, ['?', '&', '#']) ? '&' : '?').$query;
44
        }
45
46 1
        return config("apps.url.$identifier", config('app.url')).$path;
47
    }
48
}
49