DiscountCode::getDisplayName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
}