State::generateName()   A
last analyzed

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 0
1
<?php
2
3
namespace ByTIC\Models\SmartProperties\Workflow;
4
5
/**
6
 * Class State
7
 * @package ByTIC\Models\SmartProperties\Workflow
8
 */
9
class State
10
{
11
    protected $name = null;
12
13
    /**
14
     * @return string
15
     */
16
    public function getName(): string
17
    {
18
        if ($this->name == null) {
19
            $this->initName();
20
        }
21
22
        return $this->name;
23
    }
24
25
    /**
26
     * @param null $name
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $name is correct as it would always require null to be passed?
Loading history...
27
     */
28
    public function setName($name): void
29
    {
30
        $this->name = $name;
31
    }
32
33
    protected function initName()
34
    {
35
        $this->setName($this->generateName());
36
    }
37
38
    protected function generateName()
39
    {
40
        throw new \Exception("State has not name set");
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function __toString(): string
47
    {
48
        return $this->getName();
49
    }
50
}
51