AbstractAchievementEntity::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 3
eloc 7
nc 4
nop 2
1
<?php
2
/**
3
 * AbstractAchievementEntity
4
 *
5
 * @category  AxalianAchievements\Entity
6
 * @package   AxalianAchievements\Entity
7
 * @author    Michel Maas <[email protected]>
8
 */
9
10
namespace AxalianAchievements\Entity;
11
12
class AbstractAchievementEntity
13
{
14
    /**
15
     * @var int
16
     */
17
    protected $id;
18
19
    /**
20
     * @param string|int $id
21
     * @param array $config
22
     */
23
    public function __construct($id, $config)
24
    {
25
        // Just a precaution.
26
        if (isset($config['id'])) {
27
            unset($config['id']);
28
        }
29
30
        $this->setID($id);
31
32
        foreach ($config as $key => $value) {
33
            $setter = 'set' . ucfirst($key);
34
35
            $this->$setter($value);
36
        }
37
    }
38
39
    /**
40
     * @return int
41
     */
42
    public function getID()
43
    {
44
        return $this->id;
45
    }
46
47
    /**
48
     * @param int $id
49
     * @return AbstractAchievementEntity
50
     */
51
    public function setID($id)
52
    {
53
        $this->id = $id;
54
55
        return $this;
56
    }
57
}
58