UrlResolver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 11 3
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
use OwenIt\Auditing\Contracts\Resolver;
9
10
class UrlResolver implements Resolver
11
{
12
    public static function resolve(Auditable $auditable): string
13
    {
14 15
        if (! empty($auditable->preloadedResolverData['url'] ?? null)) {
0 ignored issues
show
Bug introduced by
Accessing preloadedResolverData on the interface OwenIt\Auditing\Contracts\Auditable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
15
            return $auditable->preloadedResolverData['url'] ?? '';
16 15
        }
17 15
18
        if (App::runningInConsole()) {
19
            return self::resolveCommandLine();
20 15
        }
21 13
22
        return Request::fullUrl();
23
    }
24 2
25
    public static function resolveCommandLine(): string
26
    {
27 13
        $command = Request::server('argv', null);
28
        if (is_array($command)) {
29 13
            return implode(' ', $command);
30 13
        }
31 13
32
        return 'console';
33
    }
34
}
35