Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
11 / 11 |
LowerThanExpectation | |
100.00% |
1 / 1 |
|
100.00% |
6 / 6 |
7 | |
100.00% |
11 / 11 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
jsonSerialize | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getType | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
expect | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
getValue | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
setValue | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
<?php | |
/** | |
* Copyright (c) Tony Bogdanov <tonybogdanov@gmail.com> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
namespace DataExpectation; | |
use DataExpectation\Exceptions\UnexpectedDataException; | |
/** | |
* Class LowerThanExpectation | |
* | |
* @package DataExpectation | |
* @author Tony Bogdanov <tonybogdanov@gmail.com> | |
*/ | |
class LowerThanExpectation extends AbstractExpectation { | |
/** | |
* @var int|float | |
*/ | |
protected $value; | |
/** | |
* LowerThanExpectation constructor. | |
* | |
* @param float|int $value | |
*/ | |
public function __construct( $value ) { | |
$this->setValue( $value ); | |
} | |
/** | |
* @return array | |
*/ | |
public function jsonSerialize(): array { | |
return array_replace( parent::jsonSerialize(), [ | |
'expectationArguments' => [ $this->value ], | |
] ); | |
} | |
/** | |
* @return string | |
*/ | |
public function getType(): string { | |
return 'lt( ' . $this->getValue() . ' )'; | |
} | |
/** | |
* @param $data | |
* @param string|null $path | |
* | |
* @return $this | |
* @throws UnexpectedDataException | |
*/ | |
public function expect( $data, string $path = null ) { | |
if ( $data >= $this->getValue() ) { | |
throw new UnexpectedDataException( $data, $this, $path ); | |
} | |
return $this; | |
} | |
/** | |
* @return float|int | |
*/ | |
public function getValue() { | |
return $this->value; | |
} | |
/** | |
* @param float|int $value | |
* | |
* @return $this | |
*/ | |
public function setValue( $value ) { | |
$this->value = $value; | |
return $this; | |
} | |
} |