More static test fixes

This commit is contained in:
Dennis Eichhorn 2018-07-14 22:36:41 +02:00
parent 0069bdac9a
commit 2fdc68e7e6
3 changed files with 23 additions and 12 deletions

View File

@ -185,9 +185,15 @@ abstract class FileAbstract implements ContainerInterface
*/
public function index() : void
{
$this->createdAt->setTimestamp(filemtime($this->path));
$this->changedAt->setTimestamp(filectime($this->path));
$this->owner = fileowner($this->path);
$this->permission = (int) substr(sprintf('%o', fileperms($this->path)), -4);
$mtime = \filemtime($this->path);
$ctime = \filectime($this->path);
$this->createdAt->setTimestamp($mtime === false ? 0 : $mtime);
$this->changedAt->setTimestamp($ctime === false ? 0 : $ctime);
$owner = \fileowner($this->path);
$this->owner = $owner === false ? 0 : $owner;
$this->permission = (int) \substr(\sprintf('%o', \fileperms($this->path)), -4);
}
}

View File

@ -54,13 +54,7 @@ class LocalStorage extends StorageAbstract
}
/**
* Get the internal class type (directory or file) based on path.
*
* @param string $path Path to the directory or file
*
* @return string Class namespace
*
* @since 1.0.0
* {@inheritdoc}
*/
protected static function getClassType(string $path) : string
{

View File

@ -43,6 +43,17 @@ abstract class StorageAbstract
*/
abstract public static function getInstance() : StorageAbstract;
/**
* Get the internal class type (directory or file) based on path.
*
* @param string $path Path to the directory or file
*
* @return string Class namespace
*
* @since 1.0.0
*/
abstract protected static function getClassType(string $path) : string;
/**
* Get storage type.
*
@ -265,7 +276,7 @@ abstract class StorageAbstract
* @param bool $recursive Consider subdirectories
* @param array $ignore Files/paths to ignore (no regex)
*
* @return string
* @return int
*
* @since 1.0.0
*/