BaseIdNameEntity   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A setId() 0 6 1
A jsonSerialize() 0 7 1
1
<?php
2
3
namespace NekoAPI\Component\Entity;
4
5
/**
6
 * Class BaseIdNameEntity
7
 *
8
 * @package NekoAPI\Component\Entity
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
abstract class BaseIdNameEntity extends BaseNameEntity
12
{
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18 4
    public function __construct(int $id, string $name)
19
    {
20 4
        parent::__construct($name);
21
22 4
        $this->id = $id;
23 4
    }
24
25
    /**
26
     * @return int
27
     */
28 3
    public function getId(): ?int
29
    {
30 3
        return $this->id;
31
    }
32
33
    /**
34
     * @param int $id
35
     *
36
     * @return BaseIdNameEntity
37
     */
38 1
    public function setId(int $id): BaseIdNameEntity
39
    {
40 1
        $this->id = $id;
41
42 1
        return $this;
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 1
    public function jsonSerialize(): array
49
    {
50
        return [
51 1
            'id'   => $this->getId(),
52 1
            'name' => $this->getName(),
53
        ];
54
    }
55
}