ConsoleKit\Utils::find PHP Method

find() public static method

Finds the first file that match the filename in any of the specified directories.
public static find ( string $filename, array $dirs = [] ) : string
$filename string
$dirs array
return string
    public static function find($filename, $dirs = array())
    {
        if (empty($dirs)) {
            if ($filename = realpath($filename)) {
                return $filename;
            }
        } else {
            foreach ((array) $dirs as $dir) {
                $pathname = self::join($dir, $filename);
                if ($pathname = realpath($pathname)) {
                    return $pathname;
                }
            }
        }
        return false;
    }

Usage Example

Ejemplo n.º 1
0
 public function testFind()
 {
     $this->assertEquals(realpath(__FILE__), Utils::find(basename(__FILE__), __DIR__));
 }