Completed
Push — master ( b2a65d...63a169 )
by Kirill
02:18
created

SimpleNamingStrategy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Naming;
11
12
use Railt\SDL\IR\Type\TypeNameInterface;
13
14
/**
15
 * Class SimpleNamingStrategy
16
 */
17
class SimpleNamingStrategy extends Strategy
18
{
19
    /**
20
     * SimpleNamingStrategy constructor.
21
     */
22
    public function __construct()
23
    {
24
        parent::__construct(function (TypeNameInterface $name, iterable $arguments) {
25
            return $this->format($name, $arguments);
26
        });
27
    }
28
29
    /**
30
     * @param TypeNameInterface $name
31
     * @param iterable $arguments
32
     * @return string
33
     */
34
    private function format(TypeNameInterface $name, iterable $arguments): string
35
    {
36
        echo \str_repeat('-', 100) . "\n";
37
        echo $name . " ";
38
        \dump($arguments);
39
40
        return $this->formatName($name);
41
    }
42
43
    /**
44
     * @param TypeNameInterface $name
45
     * @return string
46
     */
47
    private function formatName(TypeNameInterface $name): string
48
    {
49
        $from = TypeNameInterface::NAMESPACE_SEPARATOR;
50
51
        return \str_replace($from, '_', $name->getFullyQualifiedName());
52
    }
53
}
54