This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
3 | namespace Radowoj\Yaah\Journal; |
||
4 | |||
5 | use stdClass; |
||
6 | use InvalidArgumentException; |
||
7 | |||
8 | /** |
||
9 | * Journal entry for a single Deal event (doGetSiteJournalDeals()) |
||
10 | */ |
||
11 | class Deal implements DealInterface |
||
12 | { |
||
13 | /** |
||
14 | * @see http://allegro.pl/webapi/documentation.php/show/id,742#method-output |
||
15 | */ |
||
16 | const EVENT_TYPE_CREATE_DEAL = 1; |
||
17 | const EVENT_TYPE_CREATE_POST_SALE_FORM = 2; |
||
18 | const EVENT_TYPE_ABORT_POST_SALE_FORM = 3; |
||
19 | const EVENT_TYPE_FINISH_DEAL = 4; |
||
20 | |||
21 | protected $eventId = null; |
||
22 | |||
23 | protected $eventType = null; |
||
24 | |||
25 | protected $eventTime = null; |
||
26 | |||
27 | protected $id = null; |
||
28 | |||
29 | protected $transactionId = null; |
||
30 | |||
31 | protected $sellerId = null; |
||
32 | |||
33 | protected $itemId = null; |
||
34 | |||
35 | protected $buyerId = null; |
||
36 | |||
37 | protected $quantity = null; |
||
38 | |||
39 | |||
40 | 7 | public function __construct(stdClass $deal) |
|
41 | { |
||
42 | 7 | $this->mapFromObject($deal); |
|
43 | 5 | } |
|
44 | |||
45 | |||
46 | /** |
||
47 | * Validate and set a Deal property based on WebAPI's returned object property |
||
48 | * @param string $originalProperty original (WebAPI) property name (i.e. dealEventId) |
||
49 | * @param string $value value |
||
50 | */ |
||
51 | 7 | protected function setProperty($originalProperty, $value) |
|
52 | { |
||
53 | 7 | if (strpos($originalProperty, 'deal') !== 0) { |
|
54 | 1 | throw new InvalidArgumentException("Original deal property name must start with \"deal\""); |
|
55 | } |
||
56 | |||
57 | 6 | $localProperty = lcfirst( |
|
58 | 6 | preg_replace('/^deal/', '', $originalProperty) |
|
59 | 6 | ); |
|
60 | |||
61 | 6 | if (!property_exists($this, $localProperty)) { |
|
62 | 1 | throw new InvalidArgumentException("Unknown Deal property: {$localProperty}"); |
|
63 | } |
||
64 | |||
65 | 5 | $this->{$localProperty} = $value; |
|
66 | 5 | } |
|
67 | |||
68 | |||
69 | /** |
||
70 | * Set properties based on WebAPI's returned object |
||
71 | * @param stdClass $deal deal object returned by doGetSiteJournalDeals() |
||
72 | */ |
||
73 | 7 | protected function mapFromObject(stdClass $deal) |
|
74 | { |
||
75 | 7 | foreach($deal as $prop => $value) { |
|
0 ignored issues
–
show
|
|||
76 | 7 | $this->setProperty($prop, $value); |
|
77 | 5 | } |
|
78 | 5 | } |
|
79 | |||
80 | |||
81 | 1 | public function getEventId() |
|
82 | { |
||
83 | 1 | return $this->eventId; |
|
84 | } |
||
85 | |||
86 | |||
87 | 1 | public function getEventType() |
|
88 | { |
||
89 | 1 | return $this->eventType; |
|
90 | } |
||
91 | |||
92 | |||
93 | 1 | public function getEventTime($dateFormat = 'Y-m-d H:i:s') |
|
94 | { |
||
95 | 1 | return date($dateFormat, $this->eventTime); |
|
96 | } |
||
97 | |||
98 | |||
99 | 1 | public function getId() |
|
100 | { |
||
101 | 1 | return $this->id; |
|
102 | } |
||
103 | |||
104 | |||
105 | 1 | public function getTransactionId() |
|
106 | { |
||
107 | 1 | return $this->transactionId; |
|
108 | } |
||
109 | |||
110 | |||
111 | 1 | public function getSellerId() |
|
112 | { |
||
113 | 1 | return $this->sellerId; |
|
114 | } |
||
115 | |||
116 | |||
117 | 1 | public function getItemId() |
|
118 | { |
||
119 | 1 | return $this->itemId; |
|
120 | } |
||
121 | |||
122 | |||
123 | 1 | public function getBuyerId() |
|
124 | { |
||
125 | 1 | return $this->buyerId; |
|
126 | } |
||
127 | |||
128 | |||
129 | 1 | public function getQuantity() |
|
130 | { |
||
131 | 1 | return $this->quantity; |
|
132 | } |
||
133 | |||
134 | |||
135 | 1 | public function isTypeCreateDeal() |
|
136 | { |
||
137 | 1 | return $this->eventType === self::EVENT_TYPE_CREATE_DEAL; |
|
138 | } |
||
139 | |||
140 | 1 | public function isTypeCreatePostSaleForm() |
|
141 | { |
||
142 | 1 | return $this->eventType === self::EVENT_TYPE_CREATE_POST_SALE_FORM; |
|
143 | } |
||
144 | |||
145 | 1 | public function isTypeAbortPostSaleForm() |
|
146 | { |
||
147 | 1 | return $this->eventType === self::EVENT_TYPE_ABORT_POST_SALE_FORM; |
|
148 | } |
||
149 | |||
150 | 1 | public function isTypeFinishDeal() |
|
151 | { |
||
152 | 1 | return $this->eventType === self::EVENT_TYPE_FINISH_DEAL; |
|
153 | } |
||
154 | |||
155 | |||
156 | } |
||
157 |