| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 11 | 12 | public function __construct($size) |
|
| 12 | { |
||
| 13 | 12 | $exception = new \InvalidArgumentException("Given chunk size is not valid"); |
|
| 14 | |||
| 15 | 12 | if(preg_match("~^(\d+)(K|M)?$~", $size, $matches) !== 1) |
|
| 16 | 12 | { |
|
| 17 | 5 | throw $exception; |
|
| 18 | } |
||
| 19 | |||
| 20 | 7 | $this->size = (int) $matches[1]; |
|
| 21 | 7 | if($this->size <= 0) |
|
| 22 | 7 | { |
|
| 23 | 2 | throw $exception; |
|
| 24 | } |
||
| 25 | |||
| 26 | 5 | $this->unit = null; |
|
| 27 | 5 | if(isset($matches[2])) |
|
| 28 | 5 | { |
|
| 29 | 2 | $this->unit = $matches[2]; |
|
| 30 | 2 | } |
|
| 31 | 5 | } |
|
| 32 | |||
| 48 |