ShortNamingStrategy   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeName() 0 8 3
A getAnonymousTypeName() 0 4 1
A getPropertyName() 0 4 1
A getItemName() 0 4 1
A classify() 0 4 1
1
<?php
2
namespace Goetas\Xsd\XsdToPhp\Naming;
3
4
use Doctrine\Common\Inflector\Inflector;
5
use GoetasWebservices\XML\XSDReader\Schema\Item;
6
use GoetasWebservices\XML\XSDReader\Schema\Type\Type;
7
8
class ShortNamingStrategy implements NamingStrategy
9
{
10
11 26
    public function getTypeName(Type $type)
12
    {
13 26
        $name = $this->classify($type->getName());
14 26
        if ($name && substr($name, -4) !== 'Type') {
15 26
            $name .= "Type";
16 26
        }
17 26
        return $name;
18
    }
19
20 4
    public function getAnonymousTypeName(Type $type, $parentName)
21
    {
22 4
        return $this->classify($parentName) . "AType";
23
    }
24
25 28
    public function getPropertyName($item)
26
    {
27 28
        return Inflector::camelize(str_replace(".", " ", $item->getName()));
28
    }
29
30 27
    public function getItemName(Item $item)
31
    {
32 27
        return $this->classify($item->getName());
33
    }
34
35 49
    private function classify($name)
36
    {
37 49
        return Inflector::classify(str_replace(".", " ", $name));
38
    }
39
}