DefaultNamingStrategy   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getGraphQLType() 0 4 1
A getClassName() 0 4 1
A getGeneratedClassName() 0 4 1
A getFieldName() 0 4 1
A getFieldNameFromRelationshipDescriptor() 0 4 1
1
<?php
2
3
4
namespace TheCodingMachine\Tdbm\GraphQL;
5
6
use TheCodingMachine\TDBM\Utils\AbstractBeanPropertyDescriptor;
7
use TheCodingMachine\TDBM\Utils\DirectForeignKeyMethodDescriptor;
8
use TheCodingMachine\TDBM\Utils\MethodDescriptorInterface;
9
10
class DefaultNamingStrategy implements NamingStrategyInterface
11
{
12
    public function getGraphQLType(string $beanClassName): string
13
    {
14
        return $beanClassName;
15
    }
16
17
    public function getClassName(string $beanClassName) : string
18
    {
19
        return $this->getGraphQLType($beanClassName).'Type';
20
    }
21
22
    public function getGeneratedClassName(string $beanClassName) : string
23
    {
24
        return 'Abstract'.$this->getClassName($beanClassName);
25
    }
26
27
    public function getFieldName(AbstractBeanPropertyDescriptor $descriptor): string
28
    {
29
        return substr($descriptor->getVariableName(), 1);
30
    }
31
32
    public function getFieldNameFromRelationshipDescriptor(MethodDescriptorInterface $descriptor): string
33
    {
34
        return lcfirst(substr($descriptor->getName(), 3));
35
    }
36
}
37