FriendsOfApi /
billogram
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 |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Billogram\Model\Item; |
||
| 6 | |||
| 7 | use Billogram\Model\CreatableFromArray; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @author Ibrahim Hizeoui <[email protected]> |
||
| 11 | */ |
||
| 12 | abstract class BaseItem implements CreatableFromArray |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $itemNo; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $title; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $description; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | protected $price; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var float |
||
| 36 | */ |
||
| 37 | protected $vat; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | protected $unit; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var Bookkeeping |
||
| 46 | */ |
||
| 47 | protected $bookkeeping; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var \DateTime |
||
| 51 | */ |
||
| 52 | protected $createdAt; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var \DateTime |
||
| 56 | */ |
||
| 57 | protected $updatedAt; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getItemNo() |
||
| 63 | { |
||
| 64 | return $this->itemNo; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param string $itemNo |
||
| 69 | * |
||
| 70 | * @return self |
||
| 71 | */ |
||
| 72 | 2 | public function withItemNo(string $itemNo) |
|
| 73 | { |
||
| 74 | 2 | $new = clone $this; |
|
| 75 | 2 | $new->itemNo = $itemNo; |
|
| 76 | |||
| 77 | 2 | return $new; |
|
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | public function getTitle(): string |
||
| 84 | { |
||
| 85 | return $this->title; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param string $title |
||
| 90 | * |
||
| 91 | * @return self |
||
| 92 | */ |
||
| 93 | 2 | public function withTitle(string $title) |
|
| 94 | { |
||
| 95 | 2 | $new = clone $this; |
|
| 96 | 2 | $new->title = $title; |
|
| 97 | |||
| 98 | 2 | return $new; |
|
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | public function getDescription(): string |
||
| 105 | { |
||
| 106 | return $this->description; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @param string $description |
||
| 111 | * |
||
| 112 | * @return self |
||
| 113 | */ |
||
| 114 | 2 | public function withDescription(string $description) |
|
| 115 | { |
||
| 116 | 2 | $new = clone $this; |
|
| 117 | 2 | $new->description = $description; |
|
| 118 | |||
| 119 | 2 | return $new; |
|
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @return string |
||
| 124 | */ |
||
| 125 | public function getPrice(): string |
||
| 126 | { |
||
| 127 | return $this->price; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @param float $price |
||
| 132 | * |
||
| 133 | * @return self |
||
| 134 | */ |
||
| 135 | 2 | public function withPrice(float $price) |
|
| 136 | { |
||
| 137 | 2 | $new = clone $this; |
|
| 138 | 2 | $new->price = $price; |
|
|
0 ignored issues
–
show
|
|||
| 139 | |||
| 140 | 2 | return $new; |
|
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @return float |
||
| 145 | */ |
||
| 146 | public function getVat(): float |
||
| 147 | { |
||
| 148 | return $this->vat; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @param float $vat |
||
| 153 | * |
||
| 154 | * @return self |
||
| 155 | */ |
||
| 156 | 2 | public function withVat(float $vat) |
|
| 157 | { |
||
| 158 | 2 | $new = clone $this; |
|
| 159 | 2 | $new->vat = $vat; |
|
| 160 | |||
| 161 | 2 | return $new; |
|
| 162 | } |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @return string |
||
| 166 | */ |
||
| 167 | public function getUnit(): string |
||
| 168 | { |
||
| 169 | return $this->unit; |
||
| 170 | } |
||
| 171 | |||
| 172 | /** |
||
| 173 | * @param string $unit |
||
| 174 | * |
||
| 175 | * @return self |
||
| 176 | */ |
||
| 177 | 2 | public function withUnit(string $unit) |
|
| 178 | { |
||
| 179 | 2 | $new = clone $this; |
|
| 180 | 2 | $new->unit = $unit; |
|
| 181 | |||
| 182 | 2 | return $new; |
|
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @return Bookkeeping |
||
| 187 | */ |
||
| 188 | public function getBookkeeping(): Bookkeeping |
||
| 189 | { |
||
| 190 | return $this->bookkeeping; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @param Bookkeeping $bookkeeping |
||
| 195 | * |
||
| 196 | * @return self |
||
| 197 | */ |
||
| 198 | 5 | public function withBookkeeping(Bookkeeping $bookkeeping) |
|
| 199 | { |
||
| 200 | 5 | $new = clone $this; |
|
| 201 | 5 | $new->bookkeeping = $bookkeeping; |
|
| 202 | |||
| 203 | 5 | return $new; |
|
| 204 | } |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @return \DateTime |
||
| 208 | */ |
||
| 209 | public function getCreatedAt(): \DateTime |
||
| 210 | { |
||
| 211 | return $this->createdAt; |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @return \DateTime |
||
| 216 | */ |
||
| 217 | public function getUpdatedAt(): \DateTime |
||
| 218 | { |
||
| 219 | return $this->updatedAt; |
||
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @param \DateTime $createdAt |
||
| 224 | */ |
||
| 225 | public function setCreatedAt(\DateTime $createdAt) |
||
| 226 | { |
||
| 227 | $this->createdAt = $createdAt; |
||
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @param \DateTime $updatedAt |
||
| 232 | */ |
||
| 233 | public function setUpdatedAt(\DateTime $updatedAt) |
||
| 234 | { |
||
| 235 | $this->updatedAt = $updatedAt; |
||
| 236 | } |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Create an API response object from the HTTP response from the API server. |
||
| 240 | * |
||
| 241 | * @return array |
||
| 242 | */ |
||
| 243 | 4 | public function toArray() |
|
| 244 | { |
||
| 245 | 4 | $data = []; |
|
| 246 | 4 | if (null !== $this->title) { |
|
| 247 | 2 | $data['title'] = $this->title; |
|
| 248 | } |
||
| 249 | 4 | if (null !== $this->itemNo) { |
|
| 250 | 2 | $data['item_no'] = $this->itemNo; |
|
| 251 | } |
||
| 252 | 4 | if (null !== $this->description) { |
|
| 253 | 2 | $data['description'] = $this->description; |
|
| 254 | } |
||
| 255 | 4 | if (null !== $this->price) { |
|
| 256 | 2 | $data['price'] = $this->price; |
|
| 257 | } |
||
| 258 | 4 | if (null !== $this->vat) { |
|
| 259 | 2 | $data['vat'] = $this->vat; |
|
| 260 | } |
||
| 261 | 4 | if (null !== $this->unit) { |
|
| 262 | 2 | $data['unit'] = $this->unit; |
|
| 263 | } |
||
| 264 | 4 | if (null !== $this->bookkeeping) { |
|
| 265 | 2 | $data['bookkeeping'] = $this->bookkeeping->toArray(); |
|
| 266 | } |
||
| 267 | |||
| 268 | 4 | return $data; |
|
| 269 | } |
||
| 270 | } |
||
| 271 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.