DocTitleReducer::reduce()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 4
nc 4
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;
11
12
use Railt\Parser\Ast\RuleInterface;
13
use Serafim\Properties\Attribute\AttributeInterface;
14
15
/**
16
 * Class DocTitleReducer
17
 */
18
class DocTitleReducer implements ReducerInterface
19
{
20
    /**
21
     * @param RuleInterface $rule
22
     * @return bool
23
     */
24
    public function match(RuleInterface $rule): bool
25
    {
26
        return $rule->getName() === 'DocBlockTitle';
27
    }
28
29
    /**
30
     * @param RuleInterface $rule
31
     * @return int
32
     */
33
    public function reduce(RuleInterface $rule): int
34
    {
35
        $title = $rule->getChild(0)->getValue(1);
0 ignored issues
show
Bug introduced by
The method getValue() does not exist on Railt\Parser\Ast\NodeInterface. Did you maybe mean getValues()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
36
37
        switch ($title) {
38
            case 'property':
39
                return AttributeInterface::TYPE_PROPERTY;
40
41
            case 'property-read':
42
                return AttributeInterface::TYPE_READABLE;
43
44
            case 'property-write':
45
                return AttributeInterface::TYPE_WRITABLE;
46
47
            default:
48
                return AttributeInterface::TYPE_UNDEFINED;
49
        }
50
    }
51
}
52