| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Calculates |
||
| 12 | { |
||
| 13 | protected const DEFAULT_BYTES_PER_PART = 262144; // 1024*256 |
||
| 14 | |||
| 15 | /** @var int<0, max> */ |
||
| 16 | protected int $bytesPerPart = 0; |
||
| 17 | |||
| 18 | 30 | public function __construct(Config $config) |
|
| 19 | { |
||
| 20 | 30 | $this->bytesPerPart = empty($config->bytesPerPart) |
|
| 21 | 4 | ? static::DEFAULT_BYTES_PER_PART |
|
| 22 | 26 | : max(0, $config->bytesPerPart) |
|
| 23 | ; |
||
| 24 | 30 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @return int<0, max> |
||
| 28 | */ |
||
| 29 | 17 | public function getBytesPerPart(): int |
|
| 30 | { |
||
| 31 | 17 | return $this->bytesPerPart; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param int<0, max> $length |
||
| 36 | * @return int<0, max> |
||
| 37 | */ |
||
| 38 | 21 | public function calcParts(int $length): int |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param Data $data |
||
| 46 | * @param int $segment |
||
| 47 | * @return int<0, max> |
||
| 48 | */ |
||
| 49 | 5 | public function bytesFromSegment(Data $data, int $segment): int |
|
| 54 |