Callback   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 3 1
A execute() 0 5 1
1
<?php
2
/**
3
 * This file is part of NACL.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2019 Nuglif (2018) Inc.
9
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
10
 * @author    Pierrick Charron <[email protected]>
11
 * @author    Charle Demers <[email protected]>
12
 */
13
14
declare(strict_types=1);
15
16
namespace Nuglif\Nacl\Macros;
17
18
use Nuglif\Nacl\MacroInterface;
19
20
class Callback implements MacroInterface
21
{
22
    private string $name;
23
    private $callback;
24
25 41
    public function __construct(string $name, callable $callback)
26
    {
27 41
        $this->name     = $name;
28 41
        $this->callback = $callback;
29
    }
30
31 47
    public function getName(): string
32
    {
33 47
        return $this->name;
34
    }
35
36 7
    public function execute(mixed $parameter, array $options = []): mixed
37
    {
38 7
        $callback = $this->callback;
39
40 7
        return $callback($parameter, $options);
41
    }
42
}
43