NameProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 11
ccs 4
cts 5
cp 0.8
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
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 NameProcessor implements PropertyProcessorInterface
21
{
22 3
    public function process(PropertyDefinition $propertyDefinition, ClassDefinition $classDefinition, array $propertyData, array $classList): void
23
    {
24 3
        $propertyName = $propertyData[PreparationProcessorInterface::PROP_NAME];
25
26 3
        if (!preg_match('/^\w+$/i', $propertyName)) {
27
            throw new \RuntimeException(sprintf('Invalid property name "%s"', $propertyName));
28
        }
29
30 3
        $propertyDefinition->setName($propertyName);
31
    }
32
}
33