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

UrlResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 22
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 7 2
A resolveCommandLine() 0 8 2
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