CommentProcessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Library\DTO\Preparation\Processor\Property;
15
16
use Micro\Library\DTO\ClassDef\ClassDefinition;
17
use Micro\Library\DTO\ClassDef\PropertyDefinition;
18
use Micro\Library\DTO\Preparation\PreparationProcessorInterface;
19
20
class CommentProcessor implements PropertyProcessorInterface
21
{
22 1
    public function process(PropertyDefinition $propertyDefinition, ClassDefinition $classDefinition, array $propertyData, array $classList): void
23
    {
24 1
        $isDeprecated = $propertyData[PreparationProcessorInterface::DEPRECATED] ?? false;
25 1
        $description = $propertyData[PreparationProcessorInterface::DESCRIPTION] ?? '';
26
27 1
        if ($description) {
28 1
            $propertyDefinition->addComment($description);
29
        }
30
        /*
31
        $propertyDefinition->addComment(
32
            sprintf('@var %s', implode(
33
                separator: '|',
34
                array: $propertyDefinition->getTypes())
35
            )
36
        );
37
        */
38
39 1
        if (false !== $isDeprecated) {
40 1
            $propertyDefinition->addComment(sprintf('@deprecated %s', $isDeprecated));
41
        }
42
    }
43
}
44