3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Constraint that checks whether a variable is empty().
14 * @since Class available since Release 3.5.0
16 class PHPUnit_Framework_Constraint_IsEmpty extends PHPUnit_Framework_Constraint
19 * Evaluates the constraint for parameter $other. Returns true if the
20 * constraint is met, false otherwise.
22 * @param mixed $other Value or object to evaluate.
26 protected function matches($other)
28 if ($other instanceof Countable) {
29 return count($other) === 0;
36 * Returns a string representation of the constraint.
40 public function toString()
46 * Returns the description of the failure
48 * The beginning of failure messages is "Failed asserting that" in most
49 * cases. This method should return the second part of that sentence.
51 * @param mixed $other Evaluated value or object.
55 protected function failureDescription($other)
57 $type = gettype($other);
61 $type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a',