1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Cart Item |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Omnipay\Common; |
7
|
|
|
|
8
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Cart Item |
12
|
|
|
* |
13
|
|
|
* This class defines a single cart item in the Omnipay system. |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
class Item implements ItemInterface |
17
|
|
|
{ |
18
|
|
|
use ParametersTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Create a new item with the specified parameters |
22
|
|
|
* |
23
|
|
|
* @param array|null $parameters An array of parameters to set on the new object |
24
|
|
|
*/ |
25
|
48 |
|
public function __construct(array $parameters = null) |
26
|
|
|
{ |
27
|
48 |
|
$this->initialize($parameters); |
28
|
48 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Initialize this item with the specified parameters |
32
|
|
|
* |
33
|
|
|
* @param array|null $parameters An array of parameters to set on this object |
34
|
|
|
* @return $this Item |
35
|
|
|
*/ |
36
|
48 |
|
public function initialize(array $parameters = null) |
37
|
|
|
{ |
38
|
48 |
|
$this->parameters = new ParameterBag; |
39
|
|
|
|
40
|
48 |
|
Helper::initialize($this, $parameters); |
41
|
|
|
|
42
|
48 |
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritDoc} |
47
|
|
|
*/ |
48
|
15 |
|
public function getName() |
49
|
|
|
{ |
50
|
15 |
|
return $this->getParameter('name'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Set the item name |
55
|
|
|
*/ |
56
|
30 |
|
public function setName($value) |
57
|
|
|
{ |
58
|
30 |
|
return $this->setParameter('name', $value); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritDoc} |
63
|
|
|
*/ |
64
|
3 |
|
public function getDescription() |
65
|
|
|
{ |
66
|
3 |
|
return $this->getParameter('description'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Set the item description |
71
|
|
|
*/ |
72
|
3 |
|
public function setDescription($value) |
73
|
|
|
{ |
74
|
3 |
|
return $this->setParameter('description', $value); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritDoc} |
79
|
|
|
*/ |
80
|
3 |
|
public function getQuantity() |
81
|
|
|
{ |
82
|
3 |
|
return $this->getParameter('quantity'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Set the item quantity |
87
|
|
|
*/ |
88
|
3 |
|
public function setQuantity($value) |
89
|
|
|
{ |
90
|
3 |
|
return $this->setParameter('quantity', $value); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritDoc} |
95
|
|
|
*/ |
96
|
3 |
|
public function getPrice() |
97
|
|
|
{ |
98
|
3 |
|
return $this->getParameter('price'); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Set the item price |
103
|
|
|
*/ |
104
|
3 |
|
public function setPrice($value) |
105
|
|
|
{ |
106
|
3 |
|
return $this->setParameter('price', $value); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|