Call   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 3 1
1
<?php
2
3
namespace Bdf\Collection\Util\Functor\Consumer;
4
5
/**
6
 * Consumer for call a method of the input element
7
 *
8
 * <code>
9
 * $entities->forEach(new Call('update', [['enabled']]);
10
 * </code>
11
 */
12
final class Call implements ConsumerInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    private $method;
18
19
    /**
20
     * @var array
21
     */
22
    private $arguments;
23
24
25
    /**
26
     * Call constructor.
27
     *
28
     * @param string $method
29
     * @param array $arguments
30
     */
31 1
    public function __construct(string $method, array $arguments = [])
32
    {
33 1
        $this->method = $method;
34 1
        $this->arguments = $arguments;
35 1
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function __invoke($element, $key = null): void
41
    {
42 1
        $element->{$this->method}(...$this->arguments);
43 1
    }
44
}
45