Fix bug in style changes for the Use cases on the live site.
[yaffs-website] / vendor / phpunit / phpunit / src / Framework / Constraint / IsEmpty.php
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 checks whether a variable is empty().
13  *
14  * @since Class available since Release 3.5.0
15  */
16 class PHPUnit_Framework_Constraint_IsEmpty extends PHPUnit_Framework_Constraint
17 {
18     /**
19      * Evaluates the constraint for parameter $other. Returns true if the
20      * constraint is met, false otherwise.
21      *
22      * @param mixed $other Value or object to evaluate.
23      *
24      * @return bool
25      */
26     protected function matches($other)
27     {
28         if ($other instanceof Countable) {
29             return count($other) === 0;
30         }
31
32         return empty($other);
33     }
34
35     /**
36      * Returns a string representation of the constraint.
37      *
38      * @return string
39      */
40     public function toString()
41     {
42         return 'is empty';
43     }
44
45     /**
46      * Returns the description of the failure
47      *
48      * The beginning of failure messages is "Failed asserting that" in most
49      * cases. This method should return the second part of that sentence.
50      *
51      * @param mixed $other Evaluated value or object.
52      *
53      * @return string
54      */
55     protected function failureDescription($other)
56     {
57         $type = gettype($other);
58
59         return sprintf(
60             '%s %s %s',
61             $type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a',
62             $type,
63             $this->toString()
64         );
65     }
66 }