Passed
Push — master ( c4a808...c45372 )
by Gabriel
15:08
created

HasName::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ByTIC\Models\SmartProperties\Definitions\Traits;
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
}