| 1 | <?php  | 
            ||
| 7 | class Length  | 
            ||
| 8 | { | 
            ||
| 9 | /**  | 
            ||
| 10 | * @var int  | 
            ||
| 11 | */  | 
            ||
| 12 | protected $min;  | 
            ||
| 13 | |||
| 14 | /**  | 
            ||
| 15 | * @var int  | 
            ||
| 16 | */  | 
            ||
| 17 | protected $max;  | 
            ||
| 18 | |||
| 19 | /**  | 
            ||
| 20 | * @param int $min  | 
            ||
| 21 | * @param int|null $max  | 
            ||
| 22 | */  | 
            ||
| 23 | 9 | public function __construct ( $min = 8, $max = null )  | 
            |
| 28 | |||
| 29 | /**  | 
            ||
| 30 | * @param int $min  | 
            ||
| 31 | *  | 
            ||
| 32 | * @return bool  | 
            ||
| 33 | *  | 
            ||
| 34 | * @throws InvalidArgumentException  | 
            ||
| 35 | */  | 
            ||
| 36 | 9 | protected function setMin ( $min )  | 
            |
| 37 |     { | 
            ||
| 38 | 9 |         if ( $min > 0 && $min <= 100 ) { | 
            |
| 39 | 8 | $this->min = (int) $min;  | 
            |
| 40 | 8 | return true;  | 
            |
| 41 | }  | 
            ||
| 42 | 1 | throw new InvalidArgumentException( 'The min length should be from 1 to 100' );  | 
            |
| 43 | }  | 
            ||
| 44 | |||
| 45 | /**  | 
            ||
| 46 | * @param int $max  | 
            ||
| 47 | *  | 
            ||
| 48 | * @return bool  | 
            ||
| 49 | *  | 
            ||
| 50 | * @throws InvalidArgumentException  | 
            ||
| 51 | */  | 
            ||
| 52 | 8 | protected function setMax ( $max )  | 
            |
| 53 |     { | 
            ||
| 54 | 8 |         if ( $max > 0 && $max <= 100 ) { | 
            |
| 55 | 7 | $this->max = (int) $max;  | 
            |
| 56 | 7 | return true;  | 
            |
| 57 | }  | 
            ||
| 58 | 1 | throw new InvalidArgumentException( 'The max length should be from 1 to 100' );  | 
            |
| 59 | }  | 
            ||
| 60 | |||
| 61 | /**  | 
            ||
| 62 | * @return int  | 
            ||
| 63 | *  | 
            ||
| 64 | * @throws InvalidArgumentException  | 
            ||
| 65 | */  | 
            ||
| 66 | 5 | public function getLength ()  | 
            |
| 73 | }  | 
            ||
| 74 |