CallbackResolver::find()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * Copyright (c) Phauthentic (https://github.com/Phauthentic)
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @copyright     Copyright (c) Phauthentic (https://github.com/Phauthentic)
11
 * @link          https://github.com/Phauthentic
12
 * @license       https://opensource.org/licenses/mit-license.php MIT License
13
 */
14
15
declare(strict_types=1);
16
17
namespace Phauthentic\Authentication\Identifier\Resolver;
18
19
use ArrayAccess;
20
21
/**
22
 * A simple callable resolver that allows a quick implementation of any kind
23
 * of resolver logic
24
 */
25
class CallbackResolver implements ResolverInterface
26
{
27
    /**
28
     * Callable
29
     *
30
     * @var callable
31
     */
32
    protected $callable;
33
34
    /**
35
     * Constructor.
36 4
     *
37
     * @param callable $callable Callable.
38 4
     */
39 4
    public function __construct(callable $callable)
40
    {
41
        $this->callable = $callable;
42
    }
43
44 4
    /**
45
     * {@inheritDoc}
46 4
     */
47
    public function find(array $conditions): ?ArrayAccess
48 4
    {
49
        $callable = $this->callable;
50
51
        return $callable($conditions);
52
    }
53
}
54