Passed
Push — master ( 81d3f9...4ab6f6 )
by Gabriel
11:06
created

HasName   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
c 0
b 0
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 3 1
A initName() 0 4 1
A getName() 0 7 2
1
<?php
2
3
namespace ByTIC\Models\SmartProperties\Definitions\Definition;
4
5
/**
6
 * Trait HasName
7
 * @package ByTIC\Models\SmartProperties\Definitions\Traits
8
 */
9
trait HasName
10
{
11
12
    /**
13
     * @var string
14
     */
15
    protected $name = null;
16
17
18
    /**
19
     * @return mixed
20
     */
21
    public function getName(): ?string
22
    {
23
        if ($this->name === null) {
24
            $this->initName();
25
        }
26
27
        return $this->name;
28
    }
29
30
    /**
31
     * @param mixed $name
32
     */
33
    public function setName($name)
34
    {
35
        $this->name = $name;
36
    }
37
38
    protected function initName()
39
    {
40
        $name = inflector()->classify($this->getField());
0 ignored issues
show
Bug introduced by
It seems like getField() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $name = inflector()->classify($this->/** @scrutinizer ignore-call */ getField());
Loading history...
41
        $this->setName($name);
42
    }
43
44
}