Completed
Push — master ( 5acd24...5c27f0 )
by John
14s
created

KeyRepositoryAccessControl   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validateKey() 0 4 1
1
<?php
2
namespace LunixREST\Server\AccessControl;
3
4
use LunixREST\Server\AccessControl\KeyRepository\KeyRepository;
5
6
/**
7
 * An access control that relies on a key repository. Any keys in the repository are valid.
8
 * Class KeyRepositoryAccessControl
9
 * @package LunixREST\Server\AccessControl
10
 */
11
abstract class KeyRepositoryAccessControl implements AccessControl
12
{
13
    /**
14
     * @var KeyRepository
15
     */
16
    private $keyRepository;
17
18
    /**
19
     * KeyRepositoryAccessControl constructor.
20
     * @param KeyRepository $keyRepository
21
     */
22 6
    public function __construct(KeyRepository $keyRepository)
23
    {
24 6
        $this->keyRepository = $keyRepository;
25 6
    }
26
27
    /**
28
     * @param $apiKey
29
     * @return bool
30
     */
31 6
    public function validateKey($apiKey): bool
32
    {
33 6
        return $this->keyRepository->hasKey($apiKey);
34
    }
35
}
36