Completed
Push — master ( b12741...03b4a1 )
by Kirill
01:38
created

ConjunctionReducer::reduce()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of Properties package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Serafim\Properties\Reducers\TypeHint;
11
12
use Railt\Parser\Ast\RuleInterface;
13
use Serafim\Properties\Attribute\Conjunction;
14
use Serafim\Properties\Attribute\Matchable;
15
use Serafim\Properties\Attribute\Disjunction;
16
use Serafim\Properties\Reducers\ReducerInterface;
17
18
/**
19
 * Class ConjunctionReducer
20
 */
21
class ConjunctionReducer implements ReducerInterface
22
{
23
    /**
24
     * @param RuleInterface $rule
25
     * @return bool
26
     */
27
    public function match(RuleInterface $rule): bool
28
    {
29
        return $rule->getName() === 'Conjunction';
30
    }
31
32
    /**
33
     * @param RuleInterface $rule
34
     * @return \Generator|Matchable
35
     */
36
    public function reduce(RuleInterface $rule): \Generator
37
    {
38
        return new Conjunction(yield $rule->getChild(0));
39
    }
40
}
41