public function test__call() { $conn = null; $this->given($wrapper = new TestedClass($conn))->exception(function () use($wrapper) { $wrapper->doNotExist(); })->isInstanceOf('\\FtpClient\\FtpException')->isInstanceOf('\\Exception')->variable(array($wrapper, 'alloc'))->isCallable(); }
/** * Returns a detailed list of files in the given directory. * * @see FtpClient::nlist() * @see FtpClient::scanDir() * @see FtpClient::dirSize() * @param string $directory The directory, by default is the current directory * @param bool $recursive * @return array * @throws FtpException */ public function rawlist($directory = '.', $recursive = false) { if (!$this->isDir($directory)) { throw new FtpException('"' . $directory . '" is not a directory.'); } $list = $this->ftp->rawlist($directory); $items = array(); if (!$list) { return $items; } if (false == $recursive) { foreach ($list as $path => $item) { $chunks = preg_split("/\\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (isset($chunks[9])) { $nbChunks = count($chunks); for ($i = 9; $i < $nbChunks; $i++) { $path .= ' ' . $chunks[$i]; } } if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; } return $items; } $path = ''; foreach ($list as $item) { $len = strlen($item); if (!$len || ($item[$len - 1] == '.' && $item[$len - 2] == ' ' or $item[$len - 1] == '.' && $item[$len - 2] == '.' && $item[$len - 3] == ' ')) { continue; } $chunks = preg_split("/\\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (isset($chunks[9])) { $nbChunks = count($chunks); for ($i = 9; $i < $nbChunks; $i++) { $path .= ' ' . $chunks[$i]; } } if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; if ($item[0] == 'd') { $sublist = $this->rawlist($path, true); foreach ($sublist as $subpath => $subitem) { $items[$subpath] = $subitem; } } } return $items; }