Completed
Push — master ( 1bc299...b12741 )
by Kirill
03:33
created

ScalarHintReducer::reduce()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
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\Matchable;
14
use Serafim\Properties\Attribute\TypeHint;
15
use Serafim\Properties\Reducers\ReducerInterface;
16
17
/**
18
 * Class ScalarHintReducer
19
 */
20 View Code Duplication
class ScalarHintReducer implements ReducerInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @param RuleInterface $rule
24
     * @return bool
25
     */
26
    public function match(RuleInterface $rule): bool
27
    {
28
        return $rule->getName() === 'Scalar';
29
    }
30
31
    /**
32
     * @param RuleInterface $rule
33
     * @return \Generator|Matchable
34
     */
35
    public function reduce(RuleInterface $rule): \Generator
36
    {
37
        /** @var string $name */
38
        $name = yield $rule->first('Type');
39
40
        return new TypeHint($name, false);
41
    }
42
}
43