mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 21:18:39 +00:00
Standardizing
Matching static and object calls. Adding some public helper calls.
This commit is contained in:
parent
a225921e75
commit
7898a31c41
|
|
@ -14,7 +14,6 @@
|
|||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
use phpOMS\System\File\Local\FileAbstract;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
|
|
@ -72,12 +71,12 @@ interface ContainerInterface
|
|||
*
|
||||
* @param string $path Path of the resource
|
||||
*
|
||||
* @return int Permissions (e.g. 0644);
|
||||
* @return string Permissions (e.g. 0644);
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function permission(string $path) : int;
|
||||
public static function permission(string $path) : string;
|
||||
|
||||
/**
|
||||
* Get the parent path of the resource.
|
||||
|
|
@ -293,7 +292,6 @@ interface ContainerInterface
|
|||
/**
|
||||
* Move resource to different location.
|
||||
*
|
||||
* @param string $from Path of the resource to move
|
||||
* @param string $to Path of the resource to move to
|
||||
* @param bool $overwrite Overwrite/replace existing file
|
||||
*
|
||||
|
|
@ -347,7 +345,7 @@ interface ContainerInterface
|
|||
/**
|
||||
* Get the permissions id of the resource.
|
||||
*
|
||||
* @return int Permissions (e.g. 0644);
|
||||
* @return string Permissions (e.g. 0644);
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
|
|
|
|||
39
System/File/ContentPutMode.php
Normal file
39
System/File/ContentPutMode.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\System\File;
|
||||
|
||||
use phpOMS\Datatypes\Enum;
|
||||
|
||||
/**
|
||||
* Database type enum.
|
||||
*
|
||||
* Database types that are supported by the application
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\System
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class ContentPutMode extends Enum
|
||||
{
|
||||
const APPEND = 1;
|
||||
const PREPEND = 2;
|
||||
const REPLACE = 4;
|
||||
const CREATE = 8;
|
||||
}
|
||||
|
|
@ -43,7 +43,52 @@ interface FileInterface extends ContainerInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function put(string $path, string $content, int $mode = 0) : bool;
|
||||
public static function put(string $path, string $content, int $mode = ContentPutMode::APPEND | ContentPutMode::CREATE) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or overwrites existing file.
|
||||
*
|
||||
* @param string $path File path to save the content to
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function set(string $path, string $content) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or appends existing file.
|
||||
*
|
||||
* @param string $path File path to save the content to
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function append(string $path, string $content) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or prepends existing file.
|
||||
*
|
||||
* @param string $path File path to save the content to
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function prepend(string $path, string $content) : bool;
|
||||
|
||||
/**
|
||||
* Get content from file.
|
||||
|
|
@ -57,6 +102,18 @@ interface FileInterface extends ContainerInterface
|
|||
*/
|
||||
public static function get(string $path) : string;
|
||||
|
||||
/**
|
||||
* Get file extension.
|
||||
*
|
||||
* @param string $path File path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function extension(string $path) : string;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
|
|
@ -68,7 +125,49 @@ interface FileInterface extends ContainerInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function putContent(string $content, int $mode = 0) : bool;
|
||||
public function putContent(string $content, int $mode = ContentPutMode::APPEND | ContentPutMode::CREATE) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or overwrites existing file.
|
||||
*
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setContent(string $content) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or overwrites existing file.
|
||||
*
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function appendContent(string $content) : bool;
|
||||
|
||||
/**
|
||||
* Save content to file.
|
||||
*
|
||||
* Creates new file if it doesn't exist or overwrites existing file.
|
||||
*
|
||||
* @param string $content Content to save in file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function prependContent(string $content) : bool;
|
||||
|
||||
/**
|
||||
* Get content from file.
|
||||
|
|
@ -79,4 +178,14 @@ interface FileInterface extends ContainerInterface
|
|||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getContent() : string;
|
||||
|
||||
/**
|
||||
* Get file extension.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getExtension() : string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Index directory.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
|
@ -183,14 +178,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete directory and all its content.
|
||||
*
|
||||
* @param string $path Path to folder
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
|
|
@ -218,14 +206,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get parent directory path.
|
||||
*
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function parent(string $path) : string
|
||||
{
|
||||
|
|
@ -235,55 +216,65 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
return implode('/', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function created(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement created() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function changed(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement changed() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function owner(string $path) : int
|
||||
{
|
||||
// TODO: Implement owner() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function permission(string $path) : int
|
||||
{
|
||||
// TODO: Implement permission() method.
|
||||
}
|
||||
|
||||
/* Iterator */
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copy() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement move() method.
|
||||
}
|
||||
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool
|
||||
{
|
||||
// TODO: Implement put() method.
|
||||
}
|
||||
|
||||
public static function get(string $path) : string
|
||||
{
|
||||
// TODO: Implement get() method.
|
||||
}
|
||||
|
||||
/* ArrayAccess */
|
||||
|
||||
public static function size(string $path) : int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function size(string $path, bool $recursive = true) : int
|
||||
{
|
||||
// TODO: Implement size() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function exists(string $path) : bool
|
||||
{
|
||||
return file_exists($path);
|
||||
|
|
@ -301,7 +292,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
*/
|
||||
public function getNode(string $name) : FileAbstract
|
||||
{
|
||||
return $this->nodes[$name] ?? new NullFile('');
|
||||
return $this->nodes[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -313,16 +304,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create directory.
|
||||
*
|
||||
* @param string $path Path
|
||||
* @param string $permission Directory permission
|
||||
* @param bool $recursive Create parent directories if applicable
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(string $path, string $permission = '0644', bool $recursive = false) : bool
|
||||
{
|
||||
|
|
@ -336,14 +318,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove by name.
|
||||
*
|
||||
* @param string $name Name to remove
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove(string $name) : bool
|
||||
{
|
||||
|
|
@ -436,38 +411,70 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
public static function name(string $path) : string
|
||||
{
|
||||
return $this->nodes[$offset] ?? null;
|
||||
// TODO: Implement name() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function basename(string $path) : string
|
||||
{
|
||||
// TODO: Implement basename() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function count(string $path, bool $recursive = false) : int
|
||||
{
|
||||
// TODO: Implement count() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent() : ContainerInterface
|
||||
{
|
||||
// TODO: Implement getParent() method.
|
||||
}
|
||||
|
||||
public function copyNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function copyNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copyNode() method.
|
||||
}
|
||||
|
||||
public function moveNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function moveNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement moveNode() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteNode() : bool
|
||||
{
|
||||
// TODO: Implement deleteNode() method.
|
||||
}
|
||||
|
||||
public function putContent() : bool
|
||||
/**
|
||||
* Offset to retrieve
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to retrieve.
|
||||
* </p>
|
||||
* @return mixed Can return all value types.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
// TODO: Implement putContent() method.
|
||||
}
|
||||
|
||||
public function getContent() : string
|
||||
{
|
||||
// TODO: Implement getContent() method.
|
||||
// TODO: Implement offsetGet() method.
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
namespace phpOMS\System\File\Local;
|
||||
use phpOMS\System\File\ContainerInterface;
|
||||
use phpOMS\System\File\ContentPutMode;
|
||||
use phpOMS\System\File\FileInterface;
|
||||
use phpOMS\System\File\PathException;
|
||||
|
||||
|
|
@ -53,12 +54,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Index file.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
|
@ -68,27 +64,17 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Save string to file.
|
||||
*
|
||||
* If the directory doesn't exist where the string should be saved it will be created
|
||||
* as well as potential subdirectories. The directories will be created with '0644'
|
||||
* permission.
|
||||
*
|
||||
* @param string $path Path to save the string to
|
||||
* @param string $content Content to save to file
|
||||
* @param bool $overwrite Should the file be overwritten if it already exists
|
||||
*
|
||||
* @example File::put('/var/www/html/test.txt', 'string'); // true
|
||||
* @example File::put('/var/www/html/test.txt', 'string', false); // false
|
||||
*
|
||||
* @return bool Returns true on successfule file write and false on failure
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool
|
||||
public static function put(string $path, string $content, int $mode = ContentPutMode::APPEND | ContentPutMode::CREATE) : bool
|
||||
{
|
||||
if ($overwrite || !file_exists($path)) {
|
||||
// todo: create all else cases, right now all getting handled the same way which is wrong
|
||||
if (
|
||||
(($mode & ContentPutMode::APPEND) === ContentPutMode::APPEND && file_exists($path))
|
||||
|| (($mode & ContentPutMode::PREPEND) === ContentPutMode::PREPEND && file_exists($path))
|
||||
|| (($mode & ContentPutMode::REPLACE) === ContentPutMode::REPLACE && file_exists($path))
|
||||
|| (!file_exists($path) && ($mode & ContentPutMode::CREATE) === ContentPutMode::CREATE)
|
||||
) {
|
||||
if (!Directory::exists(dirname($path))) {
|
||||
Directory::create(dirname($path), '0644', true);
|
||||
}
|
||||
|
|
@ -102,18 +88,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get content of file.
|
||||
*
|
||||
* @param string $path Path to read from
|
||||
*
|
||||
* @example File::get('/var/www/html/test.txt');
|
||||
*
|
||||
* @return string The content of the file to read from.
|
||||
*
|
||||
* @throws PathException In case the file doesn't exist this exception gets thrown.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function get(string $path) : string
|
||||
{
|
||||
|
|
@ -125,16 +100,31 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if a file exists.
|
||||
*
|
||||
* @param string $path Path of the file to check the existance for.
|
||||
*
|
||||
* @example File::exists('/var/www/html/test.txt');
|
||||
*
|
||||
* @return bool Returns true if the file exists and false if it doesn't.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function set(string $path, string $content) : bool
|
||||
{
|
||||
return self::put($path, $content, ContentPutMode::REPLACE | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function append(string $path, string $content) : bool
|
||||
{
|
||||
return self::put($path, $content, ContentPutMode::APPEND | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function prepend(string $path, string $content) : bool
|
||||
{
|
||||
return self::put($path, $content, ContentPutMode::PREPEND | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function exists(string $path) : bool
|
||||
{
|
||||
|
|
@ -142,16 +132,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the parent directory path of the specified file.
|
||||
*
|
||||
* @param string $path Path of the file to get the parent directory for.
|
||||
*
|
||||
* @example File::parent('/var/www/html/test.txt'); // /var/www
|
||||
*
|
||||
* @return string Returns the parent full directory path.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function parent(string $path) : string
|
||||
{
|
||||
|
|
@ -159,18 +140,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the date when the file got created.
|
||||
*
|
||||
* @param string $path Path of the file to get the date of creation for.
|
||||
*
|
||||
* @return \DateTime Returns the \DateTime of when the file was created.
|
||||
*
|
||||
* @throws PathException Throws this exception if the file to get the creation date for doesn't exist.
|
||||
*
|
||||
* @example File::created('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function created(string $path) : \DateTime
|
||||
{
|
||||
|
|
@ -185,18 +155,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the date when the file got changed the last time.
|
||||
*
|
||||
* @param string $path Path of the file to get the last date of change for.
|
||||
*
|
||||
* @return \DateTime Returns the \DateTime of when the file was last changed.
|
||||
*
|
||||
* @throws PathException Throws this exception if the file to get the last change date for doesn't exist.
|
||||
*
|
||||
* @example File::changed('/var/www/html/test.txt');
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function changed(string $path) : \DateTime
|
||||
{
|
||||
|
|
@ -211,16 +170,9 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the size of a file in bytes.
|
||||
*
|
||||
* @param string $path Path of the file to get the size for.
|
||||
*
|
||||
* @return int Returns the size of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function size(string $path) : int
|
||||
public static function size(string $path, bool $recursive = true) : int
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
throw new PathException($path);
|
||||
|
|
@ -230,14 +182,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the id of the owner of the file.
|
||||
*
|
||||
* @param string $path Path of the file to get the owner for.
|
||||
*
|
||||
* @return int Returns the owner of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function owner(string $path) : int
|
||||
{
|
||||
|
|
@ -249,14 +194,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the permission of a file.
|
||||
*
|
||||
* @param string $path Path of the file to get the permission for.
|
||||
*
|
||||
* @return int Returns the permission of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function permission(string $path) : int
|
||||
{
|
||||
|
|
@ -282,6 +220,9 @@ class File extends FileAbstract implements FileInterface
|
|||
return dirname($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
if (!file_exists($from)) {
|
||||
|
|
@ -301,6 +242,9 @@ class File extends FileAbstract implements FileInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
if (!file_exists($from)) {
|
||||
|
|
@ -320,6 +264,9 @@ class File extends FileAbstract implements FileInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -349,6 +296,9 @@ class File extends FileAbstract implements FileInterface
|
|||
return self::create($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(string $path) : bool
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
|
|
@ -365,12 +315,7 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the content of the current file.
|
||||
*
|
||||
* @return string Content of the file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent() : string
|
||||
{
|
||||
|
|
@ -378,23 +323,40 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set file content.
|
||||
*
|
||||
* @param string $content Content to set
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContent(string $content)
|
||||
public function setContent(string $content) : bool
|
||||
{
|
||||
file_put_contents($this->path, $content);
|
||||
return $this->putContent($content, ContentPutMode::REPLACE | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
public function getFileName() : string
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function appendContent(string $content) : bool
|
||||
{
|
||||
return $this->putContent($content, ContentPutMode::APPEND | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prependContent(string $content) : bool
|
||||
{
|
||||
return $this->putContent($content, ContentPutMode::PREPEND | ContentPutMode::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() : string
|
||||
{
|
||||
return explode('.', $this->name)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getExtension() : string
|
||||
{
|
||||
$extension = explode('.', $this->name);
|
||||
|
|
@ -402,28 +364,77 @@ class File extends FileAbstract implements FileInterface
|
|||
return $extension[1] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent() : ContainerInterface
|
||||
{
|
||||
// TODO: Implement getParent() method.
|
||||
}
|
||||
|
||||
public function copyNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function copyNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copyNode() method.
|
||||
}
|
||||
|
||||
public function moveNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function moveNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement moveNode() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteNode() : bool
|
||||
{
|
||||
// TODO: Implement deleteNode() method.
|
||||
}
|
||||
|
||||
public function putContent() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function putContent(string $content, int $mode = ContentPutMode::APPEND | ContentPutMode::CREATE) : bool
|
||||
{
|
||||
// TODO: Implement putContent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function name(string $path) : string
|
||||
{
|
||||
return explode('.', basename($path))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function basename(string $path) : string
|
||||
{
|
||||
// TODO: Implement basename() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function count(string $path, bool $recursive = false) : int
|
||||
{
|
||||
// TODO: Implement count() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function extension(string $path) : string
|
||||
{
|
||||
$extension = explode('.', basename($path));
|
||||
|
||||
return $extension[1] ?? '';
|
||||
}
|
||||
}
|
||||
|
|
@ -113,38 +113,23 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get directory/file count.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCount() : int
|
||||
public function getCount(bool $recursive = true) : int
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory/file size.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSize() : int
|
||||
public function getSize(bool $recursive = true) : int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() : string
|
||||
{
|
||||
|
|
@ -152,12 +137,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get path.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPath() : string
|
||||
{
|
||||
|
|
@ -165,12 +145,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get parent directory.
|
||||
*
|
||||
* @return Directory
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parentNode() : Directory
|
||||
{
|
||||
|
|
@ -178,12 +153,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get created at.
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
|
|
@ -191,12 +161,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get last changed at.
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getChangedAt() : \DateTime
|
||||
{
|
||||
|
|
@ -204,12 +169,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get owner.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : int
|
||||
{
|
||||
|
|
@ -217,12 +177,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get permission.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermission() : string
|
||||
{
|
||||
|
|
@ -230,12 +185,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* (Re-)Index path.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
namespace phpOMS\System\File\Local;
|
||||
use phpOMS\System\File\ContainerInterface;
|
||||
use phpOMS\System\File\FileInterface;
|
||||
use phpOMS\System\File\StorageAbstract;
|
||||
|
||||
/**
|
||||
|
|
@ -33,127 +32,225 @@ use phpOMS\System\File\StorageAbstract;
|
|||
*/
|
||||
class LocalStorage extends StorageAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function created(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement created() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function changed(string $path) : \DateTime
|
||||
{
|
||||
// TODO: Implement changed() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function owner(string $path) : int
|
||||
{
|
||||
// TODO: Implement owner() method.
|
||||
}
|
||||
|
||||
public static function permission(string $path) : int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function permission(string $path) : string
|
||||
{
|
||||
// TODO: Implement permission() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function parent(string $path) : string
|
||||
{
|
||||
// TODO: Implement parent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(string $path) : bool
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function copy(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copy() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function move(string $from, string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement move() method.
|
||||
}
|
||||
|
||||
public static function size(string $path) : int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function size(string $path, bool $recursive = true) : int
|
||||
{
|
||||
// TODO: Implement size() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function exists(string $path) : bool
|
||||
{
|
||||
// TODO: Implement exists() method.
|
||||
}
|
||||
|
||||
public function getCount() : int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function name(string $path) : string
|
||||
{
|
||||
// TODO: Implement name() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function basename(string $path) : string
|
||||
{
|
||||
// TODO: Implement basename() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function count(string $path, bool $recursive = false) : int
|
||||
{
|
||||
// TODO: Implement count() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCount(bool $recursive = false) : int
|
||||
{
|
||||
// TODO: Implement getCount() method.
|
||||
}
|
||||
|
||||
public function getSize() : int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSize(bool $recursive = false) : int
|
||||
{
|
||||
// TODO: Implement getSize() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() : string
|
||||
{
|
||||
// TODO: Implement getName() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPath() : string
|
||||
{
|
||||
// TODO: Implement getPath() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent() : ContainerInterface
|
||||
{
|
||||
// TODO: Implement getParent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createNode() : bool
|
||||
{
|
||||
// TODO: Implement createNode() method.
|
||||
}
|
||||
|
||||
public function copyNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function copyNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement copyNode() method.
|
||||
}
|
||||
|
||||
public function moveNode() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function moveNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
// TODO: Implement moveNode() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteNode() : bool
|
||||
{
|
||||
// TODO: Implement deleteNode() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
// TODO: Implement getCreatedAt() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getChangedAt() : \DateTime
|
||||
{
|
||||
// TODO: Implement getChangedAt() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : int
|
||||
{
|
||||
// TODO: Implement getOwner() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermission() : string
|
||||
{
|
||||
// TODO: Implement getPermission() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// TODO: Implement index() method.
|
||||
|
|
@ -161,7 +258,7 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Return the current element
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return mixed Can return any type.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -172,7 +269,7 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Move forward to next element
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void Any returned value is ignored.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -183,7 +280,7 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Return the key of the current element
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return mixed scalar on success, or null on failure.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -194,7 +291,7 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Checks if current position is valid
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean The return value will be casted to boolean and then evaluated.
|
||||
* Returns true on success or false on failure.
|
||||
* @since 5.0.0
|
||||
|
|
@ -206,7 +303,7 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Rewind the Iterator to the first element
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void Any returned value is ignored.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -217,14 +314,14 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Whether a offset exists
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
||||
* @param mixed $offset <p>
|
||||
* An offset to check for.
|
||||
* </p>
|
||||
* An offset to check for.
|
||||
* </p>
|
||||
* @return boolean true on success or false on failure.
|
||||
* </p>
|
||||
* <p>
|
||||
* The return value will be casted to boolean if non-boolean was returned.
|
||||
* </p>
|
||||
* <p>
|
||||
* The return value will be casted to boolean if non-boolean was returned.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
|
|
@ -234,10 +331,10 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Offset to retrieve
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to retrieve.
|
||||
* </p>
|
||||
* The offset to retrieve.
|
||||
* </p>
|
||||
* @return mixed Can return all value types.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -248,13 +345,13 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Offset to set
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to assign the value to.
|
||||
* </p>
|
||||
* @param mixed $value <p>
|
||||
* The value to set.
|
||||
* </p>
|
||||
* The offset to assign the value to.
|
||||
* </p>
|
||||
* @param mixed $value <p>
|
||||
* The value to set.
|
||||
* </p>
|
||||
* @return void
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -265,10 +362,10 @@ class LocalStorage extends StorageAbstract
|
|||
|
||||
/**
|
||||
* Offset to unset
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
||||
* @param mixed $offset <p>
|
||||
* The offset to unset.
|
||||
* </p>
|
||||
* The offset to unset.
|
||||
* </p>
|
||||
* @return void
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
|
@ -277,28 +374,35 @@ class LocalStorage extends StorageAbstract
|
|||
// TODO: Implement offsetUnset() method.
|
||||
}
|
||||
|
||||
public static function put(string $path, string $content, bool $overwrite = true) : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function put(string $path, string $content, int $mode = 0) : bool
|
||||
{
|
||||
// TODO: Implement put() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function get(string $path) : string
|
||||
{
|
||||
// TODO: Implement get() method.
|
||||
}
|
||||
|
||||
public function putContent() : bool
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function putContent(string $content, int $mode = 0) : bool
|
||||
{
|
||||
// TODO: Implement putContent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent() : string
|
||||
{
|
||||
// TODO: Implement getContent() method.
|
||||
}
|
||||
|
||||
protected function getType() : ContainerInterface
|
||||
{
|
||||
// TODO: Implement getType() method.
|
||||
}
|
||||
}
|
||||
|
|
@ -37,25 +37,32 @@ final class Storage
|
|||
* @since 1.0.0
|
||||
*/
|
||||
private static $registered = [];
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get registred env instance.
|
||||
*
|
||||
* @param string $env Environment name
|
||||
*
|
||||
* @return StorageAbstract
|
||||
*
|
||||
* @throws \Exception Throws exception in case of invalid storage
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function env(string $env = 'local') : string
|
||||
public static function env(string $env = 'local') : StorageAbstract
|
||||
{
|
||||
if (isset(self::$registered[$env])) {
|
||||
if(is_string(self::$registered[$env])) {
|
||||
$env = self::$registered[$env]::getInstance();
|
||||
} elseif(self::$registered[$env] instanceof StorageAbstract) {
|
||||
$env = self::$registered[$env]::getInstance();
|
||||
} elseif(self::$regsitered[$env] instanceof ContainerInterface) {
|
||||
} elseif(self::$registered[$env] instanceof ContainerInterface) {
|
||||
$env = self::$registered[$env];
|
||||
} else {
|
||||
throw new \Exception('Invalid type');
|
||||
|
|
@ -75,6 +82,8 @@ final class Storage
|
|||
* @param string $name Name of the environment
|
||||
* @param string|StorageAbstract|mixed $class Class to register. This can be either a namespace path, a anonymous class or storage implementation.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user