NameProcessor::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 4
dl 0
loc 9
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
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