Barcode.php 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\librarys\Picqer\Barcode;
  8. class Barcode
  9. {
  10. protected $barcode;
  11. protected $width = 0;
  12. protected $height = 0;
  13. protected $bars = [];
  14. public function __construct(string $barcode)
  15. {
  16. $this->barcode = $barcode;
  17. }
  18. public function addBar(BarcodeBar $bar)
  19. {
  20. $this->bars[] = $bar;
  21. $this->width += $bar->getWidth();
  22. $this->height = max($this->height, $bar->getHeight());
  23. }
  24. public function getBarcode(): string
  25. {
  26. return $this->barcode;
  27. }
  28. public function getWidth(): int
  29. {
  30. return $this->width;
  31. }
  32. public function getHeight(): int
  33. {
  34. return $this->height;
  35. }
  36. public function getBars(): array
  37. {
  38. return $this->bars;
  39. }
  40. }