Completed
Push — master ( 6b14db...a7e110 )
by Andrii
01:47
created

Target::getUniqId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing;
12
13
/**
14
 * Resource Type.
15
 *
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class Target implements TargetInterface
19
{
20
    /**
21
     * @var int|string
22
     */
23
    private $id;
24
25
    /**
26
     * @var string
27
     */
28
    private $type;
29
30
    /**
31
     * @var string
32
     */
33
    private $uniqId;
34
35
    public function __construct($type, $id)
36
    {
37
        $this->id = $id;
38
        $this->type = $type;
39
        $this->uniqId = $type . ':' . $id;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getId()
46
    {
47
        return $this->id;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getType()
54
    {
55
        return $this->type;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getUniqId()
62
    {
63
        return $this->uniqId;
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    public function equals(TargetInterface $other)
70
    {
71
        return $this->uniqId === $other->getUniqId();
72
    }
73
}
74