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

SimpleNamingStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A format() 0 8 1
A formatName() 0 6 1
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