Passed
Push — master ( 32a2e1...73c03e )
by Derek Stephen
07:43
created

Resource   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResourceId() 0 3 1
A getResourceType() 0 3 1
A getObject() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Passport;
6
7
use function get_class;
8
9
class Resource implements ResourceInterface
10
{
11 1
    public function __construct(
12
        private readonly object $object,
13
        private readonly string $idMethod = 'getId'
14 1
    ) {}
15
16 1
    public function getResourceType(): string
17
    {
18 1
        return get_class($this->object);
19
    }
20
21 1
    public function getResourceId(): int
22
    {
23 1
        return $this->object->{$this->idMethod}();
24
    }
25
26
    public function getObject(): object
27
    {
28
        return $this->object;
29
    }
30
}
31