Completed
Push — master ( a4f70a...5b7a0f )
by Andrii
05:16
created

Customer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 2
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-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\customer;
12
13
use hiqdev\php\billing\target\AbstractTarget;
14
15
/**
16
 * Customer.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class Customer extends AbstractTarget implements CustomerInterface
21
{
22
    /**
23
     * @var integer
24
     */
25
    protected $id;
26
27
    /**
28
     * @var string
29
     */
30
    protected $login;
31
32
    /**
33
     * @var CustomerInterface
34
     */
35
    protected $seller;
36
37
    /**
38
     * @var Customer[]
39
     */
40
    protected $sellers = [];
41
42
    public function __construct($id, $login, CustomerInterface $seller = null)
43
    {
44
        $this->id = $id;
45
        $this->login = $login;
46
        $this->seller = $seller;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getUniqueId()
53
    {
54
        return $this->getId() ?: $this->getLogin();
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getLogin()
61
    {
62
        return $this->login;
63
    }
64
65
    public function getSeller()
66
    {
67
        return $this->seller;
68
    }
69
70
    public function jsonSerialize()
71
    {
72
        return get_object_vars($this);
73
    }
74
}
75