Test Failed
Push — master ( 8efe5b...cfd85a )
by Morten
12:01
created

UrlResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace OwenIt\Auditing\Resolvers;
4
5
use Illuminate\Support\Facades\App;
6
use Illuminate\Support\Facades\Request;
7
use OwenIt\Auditing\Contracts\Auditable;
8
9
class UrlResolver implements \OwenIt\Auditing\Contracts\Resolver
10
{
11
    /**
12
     * @return string
13
     */
14 140
    public static function resolve(Auditable $auditable): string
15
    {
16 140
        if (App::runningInConsole()) {
17 138
            return self::resolveCommandLine();
18
        }
19
20 2
        return Request::fullUrl();
21
    }
22
23
    public static function resolveCommandLine(): string
24
    {
25
        $command = \Request::server('argv', null);
26
        if (is_array($command)) {
27
            return implode(' ', $command);
28
        }
29
30
        return 'console';
31
    }
32
}
33