UserAgentResolver   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
1
<?php
2
3
namespace OwenIt\Auditing\Resolvers;
4
5
use Illuminate\Support\Facades\Request;
6
use OwenIt\Auditing\Contracts\Auditable;
7
use OwenIt\Auditing\Contracts\Resolver;
8
9
class UserAgentResolver implements Resolver
10
{
11 15
    public static function resolve(Auditable $auditable): string
12
    {
13 15
        return $auditable->preloadedResolverData['user_agent'] ?? Request::header('User-Agent');
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...
Bug Best Practice introduced by
The expression return $auditable->prelo...t::header('User-Agent') could return the type array|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
14
    }
15
}
16