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 if the file/dir(name) that it is evaluated for is readable. 13 * 14 * The file path to check is passed as $other in evaluate(). 15 */ 16class PHPUnit_Framework_Constraint_IsReadable 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 return is_readable($other); 29 } 30 31 /** 32 * Returns the description of the failure 33 * 34 * The beginning of failure messages is "Failed asserting that" in most 35 * cases. This method should return the second part of that sentence. 36 * 37 * @param mixed $other Evaluated value or object. 38 * 39 * @return string 40 */ 41 protected function failureDescription($other) 42 { 43 return sprintf( 44 '"%s" is readable', 45 $other 46 ); 47 } 48 49 /** 50 * Returns a string representation of the constraint. 51 * 52 * @return string 53 */ 54 public function toString() 55 { 56 return 'is readable'; 57 } 58} 59