FtpClient\FtpClient::count PHP Method

count() public method

Count the items (file, directory, link, unknown).
public count ( string $directory = '.', string | null $type = null, boolean $recursive = true ) : integer
$directory string The directory, by default is the current directory.
$type string | null The type of item to count (file, directory, link, unknown)
$recursive boolean true by default
return integer
    public function count($directory = '.', $type = null, $recursive = true)
    {
        $items = null === $type ? $this->nlist($directory, $recursive) : $this->scanDir($directory, $recursive);
        $count = 0;
        foreach ($items as $item) {
            if (null === $type or $item['type'] == $type) {
                $count++;
            }
        }
        return $count;
    }