Passed
Push — master ( 4826f7...743cc2 )
by Oleg
04:24
created

Add::getClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Controllers\Add;
5
6
use Doctrine\Common\Annotations\AnnotationReader;
7
use Doctrine\ORM\Mapping\ManyToMany;
8
use Doctrine\ORM\Mapping\ManyToOne;
9
use Doctrine\ORM\Mapping\OneToOne;
10
use Zend\Code\Reflection\ClassReflection;
11
12
class Add extends AbstractUniqueFieldsAction
13
{
14
    protected $template = 'Add.php.twig';
15
16
    private $relations = [
17
        ManyToOne::class,
18
        ManyToMany::class,
19
        OneToOne::class,
20
    ];
21
22
    /**
23
     * @return array
24
     * @throws \Doctrine\Common\Annotations\AnnotationException
25
     * @throws \ReflectionException
26
     */
27
    protected function getParams(): array
28
    {
29
        $params = parent::getParams();
30
31
        $reflectionClassName = new ClassReflection($this->entityClassName);
32
        foreach ($reflectionClassName->getProperties() as $property) {
33
            foreach ($this->relations as $type) {
34
                $annotation = (new AnnotationReader())
35
                    ->getPropertyAnnotation($property, $type);
36
                if ($annotation) {
37
                    $params['dataRelationship'] = '//TODO process data relationship';
38
                }
39
            }
40
        }
41
42
        return $params;
43
    }
44
45
    public function getClassName(): string
46
    {
47
        return $this->getNs($this->entityClassName) . '\\Add' . $this->getBaseName($this->entityClassName) . 'Action';
48
    }
49
}
50