This commit is contained in:
Dennis Eichhorn 2017-10-07 14:40:44 +02:00
parent aaa936ad99
commit 0110db8edb
5 changed files with 67 additions and 11 deletions

View File

@ -97,7 +97,7 @@ class FtpStorage extends StorageAbstract
/**
* {@inheritdoc}
*/
public static function permission(string $path) : string
public static function permission(string $path) : int
{
// TODO: Implement permission() method.
}
@ -174,6 +174,30 @@ class FtpStorage extends StorageAbstract
// TODO: Implement basename() method.
}
/**
* {@inheritdoc}
*/
public static function dirname(string $path) : string
{
// TODO: Implement basename() method.
}
/**
* {@inheritdoc}
*/
public static function dirpath(string $path) : string
{
// TODO: Implement basename() method.
}
/**
* {@inheritdoc}
*/
public static function list(string $path, string $filter = '*') : array
{
// TODO: Implement basename() method.
}
/**
* {@inheritdoc}
*/

View File

@ -178,11 +178,12 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*/
public static function count(string $path, bool $recursive = true, array $ignore = ['.', '..', 'cgi-bin',
'.DS_Store']) : int
public static function count(string $path, bool $recursive = true, array $ignore = []) : int
{
$size = 0;
$files = scandir($path);
$ignore[] = '.';
$ignore[] = '..';
foreach ($files as $t) {
if (in_array($t, $ignore)) {

View File

@ -107,7 +107,7 @@ class File extends FileAbstract implements FileInterface
/**
* {@inheritdoc}
*/
public static function count(string $path) : int
public static function count(string $path, bool $recursive = true, array $ignore = []) : int
{
return 1;
}

View File

@ -47,7 +47,7 @@ class LocalStorage extends StorageAbstract
private static function getClassType(string $path) : string
{
return is_dir($path) ? Directory::class : File::class;
return is_dir($path) || (!is_file($path) && stripos($path, '.') === false) ? Directory::class : File::class;
}
/**
@ -77,7 +77,7 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*/
public static function permission(string $path) : string
public static function permission(string $path) : int
{
return self::getClassType($path)::permission($path);
}
@ -95,7 +95,7 @@ class LocalStorage extends StorageAbstract
*/
public static function create(string $path) : bool
{
return self::getClassType($path)::create($path);
return stripos($path, '.') === false ? Directory::create($path, 0644, true) : File::create($path);
}
/**
@ -154,6 +154,22 @@ class LocalStorage extends StorageAbstract
return self::getClassType($path)::basename($path);
}
/**
* {@inheritdoc}
*/
public static function dirname(string $path) : string
{
return self::getClassType($path)::dirname($path);
}
/**
* {@inheritdoc}
*/
public static function dirpath(string $path) : string
{
return self::getClassType($path)::dirpath($path);
}
/**
* {@inheritdoc}
*/
@ -189,7 +205,7 @@ class LocalStorage extends StorageAbstract
/**
* {@inheritdoc}
*/
public static function list(string $path, string $filter = '*') : string
public static function list(string $path, string $filter = '*') : array
{
if(is_file($path)) {
throw new \Exception();
@ -215,7 +231,7 @@ class LocalStorage extends StorageAbstract
throw new \Exception();
}
return File::set_socket_blocking($path, $content);
return File::set($path, $content);
}
/**
@ -251,6 +267,6 @@ class LocalStorage extends StorageAbstract
throw new \Exception();
}
return File::extension($path, $content);
return File::extension($path);
}
}

View File

@ -86,7 +86,7 @@ abstract class StorageAbstract
/**
* {@inheritdoc}
*/
public abstract static function permission(string $path) : string;
public abstract static function permission(string $path) : int;
/**
* {@inheritdoc}
@ -133,6 +133,21 @@ abstract class StorageAbstract
*/
public abstract static function basename(string $path) : string;
/**
* {@inheritdoc}
*/
public abstract static function dirname(string $path) : string;
/**
* {@inheritdoc}
*/
public abstract static function dirpath(string $path) : string;
/**
* {@inheritdoc}
*/
public abstract static function list(string $path, string $filter = '*') : array;
/**
* {@inheritdoc}
*/