BaseNameEntity::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NekoAPI\Component\Entity;
4
5
/**
6
 * Class BaseNameEntity
7
 *
8
 * @package NekoAPI\Component\Entity
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
abstract class BaseNameEntity extends BaseEntity
12
{
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18 11
    public function __construct(string $name)
19
    {
20 11
        $this->name = $name;
21 11
    }
22
23
    /**
24
     * @return string
25
     */
26 8
    public function getName(): ?string
27
    {
28 8
        return $this->name;
29
    }
30
31
    /**
32
     * @param string $name
33
     *
34
     * @return BaseNameEntity
35
     */
36 2
    public function setName(string $name): BaseNameEntity
37
    {
38 2
        $this->name = $name;
39
40 2
        return $this;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46 1
    public function jsonSerialize(): array
47
    {
48
        return [
49 1
            'name' => $this->getName(),
50
        ];
51
    }
52
}