Completed
Push — develop ( f10e50...4f888d )
by Alec
03:20
created

BenchmarkedFunction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 69
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndex() 0 3 1
A getArgs() 0 3 1
A getEnumeratedName() 0 4 1
A getFunction() 0 3 1
A __construct() 0 7 1
A getComment() 0 3 2
1
<?php
2
/**
3
 * User: alec
4
 * Date: 03.12.18
5
 * Time: 22:24
6
 */
7
8
namespace AlecRabbit\Tools\Internal;
9
10
use AlecRabbit\Traits\GettableName;
11
use function AlecRabbit\brackets;
12
use function AlecRabbit\str_decorate;
13
use const AlecRabbit\Constants\BRACKETS_ANGLE;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Constants\BRACKETS_ANGLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
14
15
/**
16
 * Class BenchmarkedFunction
17
 * @package AlecRabbit
18
 * @internal
19
 */
20
class BenchmarkedFunction
21
{
22
    use GettableName;
23
24
    /** @var null|string */
25
    private $comment;
26
27
    /** @var int */
28
    private $index;
29
30
    /** @var array */
31
    private $args;
32
33
    /** @var callable */
34
    private $func;
35
36
    /**
37
     * BenchmarkedFunction constructor.
38
     * @param callable $func
39
     * @param string $name
40
     * @param int $index
41
     * @param array $args
42
     * @param null|string $comment
43
     */
44 1
    public function __construct($func, string $name, int $index, array $args, ?string $comment = null)
45
    {
46 1
        $this->func = $func;
47 1
        $this->comment = $comment;
48 1
        $this->name = $name;
49 1
        $this->index = $index;
50 1
        $this->args = $args;
51 1
    }
52
53
    /**
54
     * @return string
55
     */
56 1
    public function getComment(): string
57
    {
58 1
        return $this->comment ? str_decorate($this->comment, '"') : '';
59
    }
60
61
    /**
62
     * @return int
63
     */
64 1
    public function getIndex(): int
65
    {
66 1
        return $this->index;
67
    }
68
69
    /**
70
     * @return array
71
     */
72 1
    public function getArgs(): array
73
    {
74 1
        return $this->args;
75
    }
76
77
    /**
78
     * @return callable
79
     */
80 1
    public function getFunction(): callable
81
    {
82 1
        return $this->func;
83
    }
84
85 1
    public function getEnumeratedName(): string
86
    {
87
        return
88 1
            brackets((string)$this->index, BRACKETS_ANGLE) . ' ' . $this->name;
89
    }
90
}
91