1<?php 2/* 3 * This file is part of PHPUnit. 4 * 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11/** 12 * Constraint that asserts that the value it is evaluated for is less than 13 * a given value. 14 */ 15class PHPUnit_Framework_Constraint_LessThan extends PHPUnit_Framework_Constraint 16{ 17 /** 18 * @var numeric 19 */ 20 protected $value; 21 22 /** 23 * @param numeric $value 24 */ 25 public function __construct($value) 26 { 27 parent::__construct(); 28 $this->value = $value; 29 } 30 31 /** 32 * Evaluates the constraint for parameter $other. Returns true if the 33 * constraint is met, false otherwise. 34 * 35 * @param mixed $other Value or object to evaluate. 36 * 37 * @return bool 38 */ 39 protected function matches($other) 40 { 41 return $this->value > $other; 42 } 43 44 /** 45 * Returns a string representation of the constraint. 46 * 47 * @return string 48 */ 49 public function toString() 50 { 51 return 'is less than ' . $this->exporter->export($this->value); 52 } 53} 54