DiscountCode   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
dl 0
loc 67
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDiscountType() 0 3 1
A apply() 0 3 1
A getDisplayName() 0 3 1
A getCode() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace ConferenceTools\Tickets\Domain\ValueObject;
4
5
use ConferenceTools\Tickets\Domain\ValueObject\DiscountType\DiscountTypeInterface;
6
use JMS\Serializer\Annotation as Jms;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * Class DiscountCode
11
 * @package ConferenceTools\Tickets\Domain\ValueObject
12
 * @ORM\Embeddable()
13
 */
14
class DiscountCode
15
{
16
    /**
17
     * @JMS\Type("string")
18
     * @ORM\Column(type="string")
19
     * @var string
20
     */
21
    private $code;
22
23
    /**
24
     * @JMS\Type("string")
25
     * @ORM\Column(type="string")
26
     * @var string
27
     */
28
    private $displayName;
29
30
    /**
31
     * @JMS\Type("Object")
32
     * @ORM\Column(type="json_object")
33
     * @var DiscountTypeInterface
34
     */
35
    private $discountType;
36
37
    /**
38
     * DiscountCode constructor.
39
     * @param $code
40
     * @param $displayName
41
     * @param $discountType
42
     */
43 5
    public function __construct(string $code, string $displayName, DiscountTypeInterface $discountType)
44
    {
45 5
        $this->code = $code;
46 5
        $this->displayName = $displayName;
47 5
        $this->discountType = $discountType;
48 5
    }
49
50
    /**
51
     * @return string
52
     */
53 5
    public function getCode(): string
54
    {
55 5
        return $this->code;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getDisplayName(): string
62
    {
63
        return $this->displayName;
64
    }
65
66
    /**
67
     * @return DiscountTypeInterface
68
     */
69
    public function getDiscountType(): DiscountTypeInterface
70
    {
71
        return $this->discountType;
72
    }
73
74
    /**
75
     * @param Basket $to
76
     * @return Price
77
     */
78 4
    public function apply(Basket $to): Price
79
    {
80 4
        return $this->discountType->apply($to);
81
    }
82
}