Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
57 / 57 |
|
100.00% |
37 / 37 |
CRAP | |
100.00% |
1 / 1 |
| Package | |
100.00% |
57 / 57 |
|
100.00% |
37 / 37 |
39 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |||
| setWidth | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setHeight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getHeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasHeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDepth | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDepth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasDepth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setWeight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getWeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasWeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setValue | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDimensionUnit | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDimensionUnit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setWeightUnit | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getWeightUnit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setValueUnit | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getValueUnit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPackaging | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getPackaging | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasPackaging | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDescription | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setTrackingNumber | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getTrackingNumber | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasTrackingNumber | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <dev@noladev.com> |
| 8 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Shipping; |
| 16 | |
| 17 | /** |
| 18 | * Pop shipping package class |
| 19 | * |
| 20 | * @category Pop |
| 21 | * @package Pop\Shipping |
| 22 | * @author Nick Sagona, III <dev@noladev.com> |
| 23 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 24 | * @license https://www.popphp.org/license New BSD License |
| 25 | * @version 4.0.0 |
| 26 | */ |
| 27 | class Package |
| 28 | { |
| 29 | |
| 30 | /** |
| 31 | * Package width |
| 32 | * @var mixed |
| 33 | */ |
| 34 | protected mixed $width = null; |
| 35 | |
| 36 | /** |
| 37 | * Package height |
| 38 | * @var mixed |
| 39 | */ |
| 40 | protected mixed $height = null; |
| 41 | |
| 42 | /** |
| 43 | * Package depth |
| 44 | * @var mixed |
| 45 | */ |
| 46 | protected mixed $depth = null; |
| 47 | |
| 48 | /** |
| 49 | * Package weight |
| 50 | * @var mixed |
| 51 | */ |
| 52 | protected mixed $weight = null; |
| 53 | |
| 54 | /** |
| 55 | * Package overall value (for insurance) |
| 56 | * @var mixed |
| 57 | */ |
| 58 | protected mixed $value = null; |
| 59 | |
| 60 | /** |
| 61 | * Package dimension unit |
| 62 | * @var mixed |
| 63 | */ |
| 64 | protected mixed $dimensionUnit = 'IN'; |
| 65 | |
| 66 | /** |
| 67 | * Package weight unit |
| 68 | * @var mixed |
| 69 | */ |
| 70 | protected mixed $weightUnit = 'LB'; |
| 71 | |
| 72 | /** |
| 73 | * Package value unit |
| 74 | * @var mixed |
| 75 | */ |
| 76 | protected mixed $valueUnit = 'USD'; |
| 77 | |
| 78 | /** |
| 79 | * Packaging cost value (box, wrapping, tape, etc) |
| 80 | * @var mixed |
| 81 | */ |
| 82 | protected mixed $packaging = null; |
| 83 | |
| 84 | /** |
| 85 | * Package ID |
| 86 | * @var mixed |
| 87 | */ |
| 88 | protected mixed $id = null; |
| 89 | |
| 90 | /** |
| 91 | * Package name |
| 92 | * @var ?string |
| 93 | */ |
| 94 | protected ?string $name = null; |
| 95 | |
| 96 | /** |
| 97 | * Package description |
| 98 | * @var ?string |
| 99 | */ |
| 100 | protected ?string $description = null; |
| 101 | |
| 102 | /** |
| 103 | * Package tracking number |
| 104 | * @var ?string |
| 105 | */ |
| 106 | protected ?string $trackingNumber = null; |
| 107 | |
| 108 | /** |
| 109 | * Constructor |
| 110 | * |
| 111 | * Instantiate the shipping package object |
| 112 | * |
| 113 | * @param mixed $width |
| 114 | * @param mixed $height |
| 115 | * @param mixed $depth |
| 116 | * @param mixed $weight |
| 117 | * @param mixed $value |
| 118 | * @param mixed $packaging |
| 119 | */ |
| 120 | public function __construct( |
| 121 | mixed $width, mixed $height, mixed $depth, mixed $weight, mixed $value = null, mixed $packaging = null |
| 122 | ) |
| 123 | { |
| 124 | $this->setWidth($width); |
| 125 | $this->setHeight($height); |
| 126 | $this->setDepth($depth); |
| 127 | $this->setWeight($weight); |
| 128 | |
| 129 | if (null !== $value) { |
| 130 | $this->setValue($value); |
| 131 | } |
| 132 | |
| 133 | if (null !== $packaging) { |
| 134 | $this->setPackaging($packaging); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Set package width |
| 140 | * |
| 141 | * @param mixed $width |
| 142 | * @return Package |
| 143 | */ |
| 144 | public function setWidth(mixed $width): Package |
| 145 | { |
| 146 | $this->width = $width; |
| 147 | return $this; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Get package width |
| 152 | * |
| 153 | * @return mixed |
| 154 | */ |
| 155 | public function getWidth(): mixed |
| 156 | { |
| 157 | return $this->width; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Has package width |
| 162 | * |
| 163 | * @return bool |
| 164 | */ |
| 165 | public function hasWidth(): bool |
| 166 | { |
| 167 | return !empty($this->width); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Set package height |
| 172 | * |
| 173 | * @param mixed $height |
| 174 | * @return Package |
| 175 | */ |
| 176 | public function setHeight(mixed $height): Package |
| 177 | { |
| 178 | $this->height = $height; |
| 179 | return $this; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Get package height |
| 184 | * |
| 185 | * @return mixed |
| 186 | */ |
| 187 | public function getHeight(): mixed |
| 188 | { |
| 189 | return $this->height; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Has package height |
| 194 | * |
| 195 | * @return bool |
| 196 | */ |
| 197 | public function hasHeight(): bool |
| 198 | { |
| 199 | return !empty($this->height); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Set package depth |
| 204 | * |
| 205 | * @param mixed $depth |
| 206 | * @return Package |
| 207 | */ |
| 208 | public function setDepth(mixed $depth): Package |
| 209 | { |
| 210 | $this->depth = $depth; |
| 211 | return $this; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Get package depth |
| 216 | * |
| 217 | * @return mixed |
| 218 | */ |
| 219 | public function getDepth(): mixed |
| 220 | { |
| 221 | return $this->depth; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Has package depth |
| 226 | * |
| 227 | * @return bool |
| 228 | */ |
| 229 | public function hasDepth(): bool |
| 230 | { |
| 231 | return !empty($this->depth); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Set package weight |
| 236 | * |
| 237 | * @param mixed $weight |
| 238 | * @return Package |
| 239 | */ |
| 240 | public function setWeight(mixed $weight): Package |
| 241 | { |
| 242 | $this->weight = $weight; |
| 243 | return $this; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Get package weight |
| 248 | * |
| 249 | * @return mixed |
| 250 | */ |
| 251 | public function getWeight(): mixed |
| 252 | { |
| 253 | return $this->weight; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Has package weight |
| 258 | * |
| 259 | * @return bool |
| 260 | */ |
| 261 | public function hasWeight(): bool |
| 262 | { |
| 263 | return !empty($this->weight); |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Set package value |
| 268 | * |
| 269 | * @param mixed $value |
| 270 | * @return Package |
| 271 | */ |
| 272 | public function setValue(mixed $value): Package |
| 273 | { |
| 274 | $this->value = $value; |
| 275 | return $this; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Get package value |
| 280 | * |
| 281 | * @return mixed |
| 282 | */ |
| 283 | public function getValue(): mixed |
| 284 | { |
| 285 | return $this->value; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Has package value |
| 290 | * |
| 291 | * @return bool |
| 292 | */ |
| 293 | public function hasValue(): bool |
| 294 | { |
| 295 | return (null !== $this->value); |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Set package dimension unit |
| 300 | * |
| 301 | * @param string $unit |
| 302 | * @return Package |
| 303 | */ |
| 304 | public function setDimensionUnit(string $unit): Package |
| 305 | { |
| 306 | $this->dimensionUnit = $unit; |
| 307 | return $this; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Get package dimension unit |
| 312 | * |
| 313 | * @return string |
| 314 | */ |
| 315 | public function getDimensionUnit(): string |
| 316 | { |
| 317 | return $this->dimensionUnit; |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Set package weight unit |
| 322 | * |
| 323 | * @param string $unit |
| 324 | * @return Package |
| 325 | */ |
| 326 | public function setWeightUnit(string $unit): Package |
| 327 | { |
| 328 | $this->weightUnit = $unit; |
| 329 | return $this; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Get package weight unit |
| 334 | * |
| 335 | * @return string |
| 336 | */ |
| 337 | public function getWeightUnit(): string |
| 338 | { |
| 339 | return $this->weightUnit; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Set package value unit |
| 344 | * |
| 345 | * @param string $unit |
| 346 | * @return Package |
| 347 | */ |
| 348 | public function setValueUnit(string $unit): Package |
| 349 | { |
| 350 | $this->valueUnit = $unit; |
| 351 | return $this; |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Get package value unit |
| 356 | * |
| 357 | * @return string |
| 358 | */ |
| 359 | public function getValueUnit(): string |
| 360 | { |
| 361 | return $this->valueUnit; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Set packaging cost |
| 366 | * |
| 367 | * @param mixed $packaging |
| 368 | * @return Package |
| 369 | */ |
| 370 | public function setPackaging(mixed $packaging): Package |
| 371 | { |
| 372 | $this->packaging = $packaging; |
| 373 | return $this; |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Get packaging cost |
| 378 | * |
| 379 | * @return mixed |
| 380 | */ |
| 381 | public function getPackaging(): mixed |
| 382 | { |
| 383 | return $this->packaging; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Has packaging cost |
| 388 | * |
| 389 | * @return bool |
| 390 | */ |
| 391 | public function hasPackaging(): bool |
| 392 | { |
| 393 | return (null !== $this->packaging); |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Set package id |
| 398 | * |
| 399 | * @param mixed $id |
| 400 | * @return Package |
| 401 | */ |
| 402 | public function setId(mixed $id): Package |
| 403 | { |
| 404 | $this->id = $id; |
| 405 | return $this; |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * Get package id |
| 410 | * |
| 411 | * @return mixed |
| 412 | */ |
| 413 | public function getId(): mixed |
| 414 | { |
| 415 | return $this->id; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Has package id |
| 420 | * |
| 421 | * @return bool |
| 422 | */ |
| 423 | public function hasId(): bool |
| 424 | { |
| 425 | return (null !== $this->id); |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Set package name |
| 430 | * |
| 431 | * @param string $name |
| 432 | * @return Package |
| 433 | */ |
| 434 | public function setName(string $name): Package |
| 435 | { |
| 436 | $this->name = $name; |
| 437 | return $this; |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Get package name |
| 442 | * |
| 443 | * @return ?string |
| 444 | */ |
| 445 | public function getName(): ?string |
| 446 | { |
| 447 | return $this->name; |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * Has package name |
| 452 | * |
| 453 | * @return bool |
| 454 | */ |
| 455 | public function hasName(): bool |
| 456 | { |
| 457 | return (null !== $this->name); |
| 458 | } |
| 459 | |
| 460 | /** |
| 461 | * Set package description |
| 462 | * |
| 463 | * @param string $description |
| 464 | * @return Package |
| 465 | */ |
| 466 | public function setDescription(string $description): Package |
| 467 | { |
| 468 | $this->description = $description; |
| 469 | return $this; |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Get package description |
| 474 | * |
| 475 | * @return ?string |
| 476 | */ |
| 477 | public function getDescription(): ?string |
| 478 | { |
| 479 | return $this->description; |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Has package description |
| 484 | * |
| 485 | * @return bool |
| 486 | */ |
| 487 | public function hasDescription(): bool |
| 488 | { |
| 489 | return (null !== $this->description); |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Set package tracking number |
| 494 | * |
| 495 | * @param string $trackingNumber |
| 496 | * @return Package |
| 497 | */ |
| 498 | public function setTrackingNumber(string $trackingNumber): Package |
| 499 | { |
| 500 | $this->trackingNumber = $trackingNumber; |
| 501 | return $this; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * Get package tracking number |
| 506 | * |
| 507 | * @return ?string |
| 508 | */ |
| 509 | public function getTrackingNumber(): ?string |
| 510 | { |
| 511 | return $this->trackingNumber; |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Has package tracking number |
| 516 | * |
| 517 | * @return bool |
| 518 | */ |
| 519 | public function hasTrackingNumber(): bool |
| 520 | { |
| 521 | return (null !== $this->trackingNumber); |
| 522 | } |
| 523 | |
| 524 | } |