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

Customer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 55
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUniqueId() 0 4 2
A getLogin() 0 4 1
A getSeller() 0 4 1
A jsonSerialize() 0 4 1
A __construct() 0 6 1
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