Completed
Push — master ( 0148b2...8b8c0c )
by Pavel
03:00 queued 17s
created

CallbackCondition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Bankiru\Seo\Integration\Local;
4
5
use Bankiru\Seo\ConditionInterface;
6
use Bankiru\Seo\TargetDefinitionInterface;
7
8
final class CallbackCondition implements ConditionInterface
9
{
10
    /** @var callable */
11
    private $callback;
12
13
    /**
14
     * CallbackCondition constructor.
15
     *
16
     * @param callable $callback
17
     */
18 1
    public function __construct(callable $callback)
19
    {
20 1
        $this->callback = $callback;
21 1
    }
22
23
    /** {@inheritdoc} */
24
    public function attach(TargetDefinitionInterface $target, $code)
25
    {
26
        $target->setCondition($code, $this);
27
    }
28
29
    /** {@inheritdoc} */
30 1
    public function match($object)
31
    {
32 1
        return call_user_func($this->callback, $object) ? 1 : null;
33
    }
34
}
35