Passed
Push — master ( 743cc2...6ffec3 )
by Oleg
02:50
created

SimpleProvider::getClassName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 0
cts 5
cp 0
crap 6
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Controllers;
5
6
class SimpleProvider implements DataProviderInterface
7
{
8
    use NamingTrait;
9
10
    /**
11
     * @var string
12
     */
13
    protected $entityClassName;
14
15
    public function __construct(string $entityClassName)
16
    {
17
        $this->entityClassName = $entityClassName;
18
    }
19
20
    /**
21
     * @return array
22
     * @throws \ReflectionException
23
     */
24
    public function provide(): array
25
    {
26
        return [
27
            'ns' => $this->getNs($this->entityClassName),
28
            'useStatement' => ltrim($this->entityClassName, '\\'),
29
            'entityName' => $this->getBaseName($this->entityClassName),
30
        ];
31
    }
32
33
    /**
34
     * @param string $type
35
     * @return string
36
     * @throws \ReflectionException
37
     */
38
    public function getClassName(string $type): string
39
    {
40
        if ($type === 'gets') {
41
            $className = 'Get' . $this->getBaseName($this->entityClassName) . 'sAction';
42
        } else {
43
            $className = ucwords($type) . $this->getBaseName($this->entityClassName) . 'Action';
44
        }
45
46
        return $this->getNs($this->entityClassName) . "\\$className";
47
    }
48
}
49