| Conditions | 7 |
| Paths | 10 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 27 | public function doValidation( $value ) { |
||
| 28 | if ( !is_array( $value ) ) { |
||
| 29 | $this->addErrorMessage( 'Not an array' ); |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | $validator = new RangeValidator(); |
||
| 34 | |||
| 35 | if ( array_key_exists( 'elementcount', $this->options ) ) { |
||
| 36 | $range = $this->options['elementcount']; |
||
| 37 | |||
| 38 | if ( !is_array( $range ) || count( $range ) !== 2 ) { |
||
| 39 | throw new Exception( 'The elementcount option must be an array with two elements' ); |
||
| 40 | } |
||
| 41 | |||
| 42 | $validator->setRange( $range[0], $range[1] ); |
||
| 43 | } |
||
| 44 | |||
| 45 | // min- and maxelements options are allowed to overwrite the elementcount option! |
||
| 46 | if ( array_key_exists( 'minelements', $this->options ) ) { |
||
| 47 | $validator->setLowerBound( $this->options['minelements'] ); |
||
| 48 | } |
||
| 49 | if ( array_key_exists( 'maxelements', $this->options ) ) { |
||
| 50 | $validator->setUpperBound( $this->options['maxelements'] ); |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->runSubValidator( count( $value ), $validator, 'length' ); |
||
| 54 | } |
||
| 55 | |||
| 68 |