1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- declare(strict_types = 1);
- namespace BaconQrCode\Common;
- final class EcBlocks
- {
-
- private $ecCodewordsPerBlock;
-
- private $ecBlocks;
- public function __construct(int $ecCodewordsPerBlock, EcBlock ...$ecBlocks)
- {
- $this->ecCodewordsPerBlock = $ecCodewordsPerBlock;
- $this->ecBlocks = $ecBlocks;
- }
-
- public function getEcCodewordsPerBlock() : int
- {
- return $this->ecCodewordsPerBlock;
- }
-
- public function getNumBlocks() : int
- {
- $total = 0;
- foreach ($this->ecBlocks as $ecBlock) {
- $total += $ecBlock->getCount();
- }
- return $total;
- }
-
- public function getTotalEcCodewords() : int
- {
- return $this->ecCodewordsPerBlock * $this->getNumBlocks();
- }
-
- public function getEcBlocks() : array
- {
- return $this->ecBlocks;
- }
- }
|