mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
Cleanup
This commit is contained in:
parent
f4df9a6f84
commit
1535d8fdbe
|
|
@ -26,7 +26,7 @@ namespace phpOMS\Account;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class AccountManager
|
class AccountManager implements \Countable
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,4 +83,37 @@ class AccountManager
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove account.
|
||||||
|
*
|
||||||
|
* @param int $id Account id
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function remove(int $id) : bool
|
||||||
|
{
|
||||||
|
if (isset($this->accounts[$id])) {
|
||||||
|
unset($this->accounts[$id]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get accounts count.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function count() : int {
|
||||||
|
return count($this->accounts);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class ApplicationAbstract
|
||||||
/**
|
/**
|
||||||
* App name.
|
* App name.
|
||||||
*
|
*
|
||||||
* @var \phpOMS\DataStorage\Database\Pool
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public $appName = '';
|
public $appName = '';
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
/**
|
/**
|
||||||
* Cache manager (pool).
|
* Cache manager (pool).
|
||||||
*
|
*
|
||||||
* @var \phpOMS\DataStorage\Cache\CacheManager
|
* @var \phpOMS\DataStorage\Cache\Pool
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $cache = null;
|
protected $cache = null;
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,16 @@ use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||||
*/
|
*/
|
||||||
abstract class BuilderAbstract
|
abstract class BuilderAbstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Grammar.
|
||||||
|
*
|
||||||
|
* @var GrammarAbstract
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $grammar = null;
|
protected $grammar = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database connectino.
|
* Database connection.
|
||||||
*
|
*
|
||||||
* @var ConnectionAbstract
|
* @var ConnectionAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
@ -61,7 +67,7 @@ abstract class BuilderAbstract
|
||||||
*
|
*
|
||||||
* @param string $prefix Prefix
|
* @param string $prefix Prefix
|
||||||
*
|
*
|
||||||
* @return BuilderAbstract
|
* @return $this
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
/**
|
/**
|
||||||
* Create object in db.
|
* Create object in db.
|
||||||
*
|
*
|
||||||
* @param mixed $obj Object reference (gets filled with insert id)
|
* @param mixed $obj Object reference (gets filled with insert id)
|
||||||
|
* @param bool $relations Create all relations as well
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
|
|
@ -256,11 +257,13 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
/* Insert has one first */
|
/* Insert has one first */
|
||||||
if (isset(static::$hasOne[$pname]) && is_object($relObj = $property->getValue($obj))) {
|
if (isset(static::$hasOne[$pname]) && is_object($relObj = $property->getValue($obj))) {
|
||||||
/* only insert if not already inserted */
|
/* only insert if not already inserted */
|
||||||
|
/** @var DataMapperAbstract $mapper */
|
||||||
$mapper = static::$hasOne[$pname]['mapper'];
|
$mapper = static::$hasOne[$pname]['mapper'];
|
||||||
$mapper = new $mapper($this->db);
|
$mapper = new $mapper($this->db);
|
||||||
|
|
||||||
$relReflectionClass = new \ReflectionClass(get_class($relObj));
|
$relReflectionClass = new \ReflectionClass(get_class($relObj));
|
||||||
$relProperty = $relReflectionClass->getProperty($mapper::$columns[$mapper::$primaryField]['internal']);
|
/** @var array $columns */
|
||||||
|
$relProperty = $relReflectionClass->getProperty($mapper::$columns[$mapper::$primaryField]['internal']);
|
||||||
$relProperty->setAccessible(true);
|
$relProperty->setAccessible(true);
|
||||||
$primaryKey = $relProperty->getValue($relObj);
|
$primaryKey = $relProperty->getValue($relObj);
|
||||||
$relProperty->setAccessible(false);
|
$relProperty->setAccessible(false);
|
||||||
|
|
@ -327,6 +330,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
foreach ($values as $key => &$value) {
|
foreach ($values as $key => &$value) {
|
||||||
// Skip if already in db/has key
|
// Skip if already in db/has key
|
||||||
|
/** @noinspection PhpUndefinedVariableInspection */
|
||||||
$relProperty = $relReflectionClass->getProperty($mapper::$columns[$mapper::$primaryField]['internal']);
|
$relProperty = $relReflectionClass->getProperty($mapper::$columns[$mapper::$primaryField]['internal']);
|
||||||
$relProperty->setAccessible(true);
|
$relProperty->setAccessible(true);
|
||||||
$primaryKey = $relProperty->getValue($value);
|
$primaryKey = $relProperty->getValue($value);
|
||||||
|
|
@ -552,6 +556,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$reflectionProperty->setAccessible(true);
|
$reflectionProperty->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var DataMapperAbstract $mapper */
|
||||||
$mapper = static::$hasOne[$column]['mapper'];
|
$mapper = static::$hasOne[$column]['mapper'];
|
||||||
$mapper = new $mapper($this->db);
|
$mapper = new $mapper($this->db);
|
||||||
|
|
||||||
|
|
@ -792,6 +797,16 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
return $this->populateIterable($results);
|
return $this->populateIterable($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get raw by primary key
|
||||||
|
*
|
||||||
|
* @param mixed $primaryKey Primary key
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getManyRaw($primaryKey) : array
|
public function getManyRaw($primaryKey) : array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,17 @@ namespace phpOMS\Datatypes\Exception;
|
||||||
class InvalidEnumName extends \UnexpectedValueException
|
class InvalidEnumName extends \UnexpectedValueException
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct($message, $code = 0, \Exception $previous = null)
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
parent::__construct('The enum name "' . $message . '" is not valid.', $code, $previous);
|
parent::__construct('The enum name "' . $message . '" is not valid.', $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,17 @@ namespace phpOMS\Datatypes\Exception;
|
||||||
class InvalidEnumValue extends \UnexpectedValueException
|
class InvalidEnumValue extends \UnexpectedValueException
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct($message, $code = 0, \Exception $previous = null)
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
parent::__construct('The enum value "' . $message . '" is not valid.', $code, $previous);
|
parent::__construct('The enum value "' . $message . '" is not valid.', $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,20 @@ namespace phpOMS\Datatypes;
|
||||||
*/
|
*/
|
||||||
class SmartDateTime extends \DateTime
|
class SmartDateTime extends \DateTime
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
const FORMAT = 'Y-m-d hh:mm:ss';
|
const FORMAT = 'Y-m-d hh:mm:ss';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default timezone
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
const TIMEZONE = 'UTC';
|
const TIMEZONE = 'UTC';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -103,4 +116,30 @@ class SmartDateTime extends \DateTime
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get days of current month
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getDaysOfMonth() : int
|
||||||
|
{
|
||||||
|
return cal_days_in_month(CAL_GREGORIAN, $this->format('m'), $this->format('Y'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get first day of current month
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getFirstDayOfMonth() : int
|
||||||
|
{
|
||||||
|
return getdate(mktime(null, null, null, $this->format('m'), 1, $this->format('Y')))['wday'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,9 @@ class Dispatcher
|
||||||
* Dispatch controller.
|
* Dispatch controller.
|
||||||
*
|
*
|
||||||
* @param string|array|\Closure $controller Controller string
|
* @param string|array|\Closure $controller Controller string
|
||||||
* @param RequestAbstract $request Request
|
* @param RequestAbstract $request Request
|
||||||
* @param ResponseAbstract $response Response
|
* @param ResponseAbstract $response Response
|
||||||
* @param mixed $data Data
|
* @param mixed $data Data
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
|
|
@ -94,11 +94,13 @@ class Dispatcher
|
||||||
$dispatch = explode(':', $controller);
|
$dispatch = explode(':', $controller);
|
||||||
$this->get($dispatch[0]);
|
$this->get($dispatch[0]);
|
||||||
|
|
||||||
if (count($dispatch) == 3) {
|
if (($c = count($dispatch)) == 3) {
|
||||||
/* Handling static functions */
|
/* Handling static functions */
|
||||||
$views[$type][$controller] = $dispatch[0]::$dispatch[2]();
|
$views[$type][$controller] = $dispatch[0]::$dispatch[2]();
|
||||||
} else {
|
} elseif ($c == 2) {
|
||||||
$views[$type][$controller] = $this->controllers[$dispatch[0]]->{$dispatch[1]}($request, $response, $data);
|
$views[$type][$controller] = $this->controllers[$dispatch[0]]->{$dispatch[1]}($request, $response, $data);
|
||||||
|
} else {
|
||||||
|
throw new \UnexpectedValueException('Unexpected function.');
|
||||||
}
|
}
|
||||||
} elseif (is_array($controller)) {
|
} elseif (is_array($controller)) {
|
||||||
foreach ($controller as $controllerSingle) {
|
foreach ($controller as $controllerSingle) {
|
||||||
|
|
@ -142,7 +144,7 @@ class Dispatcher
|
||||||
* Set controller by alias.
|
* Set controller by alias.
|
||||||
*
|
*
|
||||||
* @param ModuleAbstract $controller Controller
|
* @param ModuleAbstract $controller Controller
|
||||||
* @param string $name Controller string
|
* @param string $name Controller string
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -611,12 +611,23 @@ class FileLogger implements LoggerInterface
|
||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function console(string $text, bool $verbose)
|
/**
|
||||||
|
* Create console log.
|
||||||
|
*
|
||||||
|
* @param string $message Log message
|
||||||
|
* @param bool $verbose Is verbose
|
||||||
|
* @param array $context Context
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function console(string $message, bool $verbose = true, array $context = [])
|
||||||
{
|
{
|
||||||
$text = date('[Y-m-d H:i:s] ') . $text . "\r\n";
|
$message = date('[Y-m-d H:i:s] ') . $message . "\r\n";
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
echo $text;
|
echo $message;
|
||||||
|
} else {
|
||||||
|
$this->info($message, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
# Log #
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
# Math #
|
|
||||||
|
|
@ -14,7 +14,9 @@
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Module;
|
namespace phpOMS\Module;
|
||||||
|
|
||||||
use phpOMS\System\FilePathException;
|
use phpOMS\System\FilePathException;
|
||||||
|
use phpOMS\Utils\ArrayUtils;
|
||||||
use phpOMS\Validation\Validator;
|
use phpOMS\Validation\Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,20 +36,20 @@ class InfoManager
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File pointer.
|
* File path.
|
||||||
*
|
|
||||||
* @var mixed
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
private $fp = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module path.
|
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const MODULE_PATH = __DIR__ . '/../../Modules/';
|
private $path = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Info data.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $info = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object constructor.
|
* Object constructor.
|
||||||
|
|
@ -59,26 +61,54 @@ class InfoManager
|
||||||
*/
|
*/
|
||||||
public function __construct(string $module)
|
public function __construct(string $module)
|
||||||
{
|
{
|
||||||
if (($path = realpath($oldPath = self::MODULE_PATH . $module . '/info.json')) === false || Validator::startsWith($path, self::MODULE_PATH)) {
|
if (($path = realpath($oldPath = ModuleAbstract::MODULE_PATH . '/' . $module . '/info.json')) === false || Validator::startsWith($path, ModuleAbstract::MODULE_PATH)) {
|
||||||
throw new FilePathException($oldPath);
|
throw new FilePathException($oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fp = fopen($oldPath, 'r');
|
$this->path = $path;
|
||||||
}
|
$this->info = json_decode(file_get_contents($this->path), true);
|
||||||
|
|
||||||
public function update()
|
|
||||||
{
|
|
||||||
// TODO: update file (convert to json)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object destructor.
|
* Update info file
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn
|
* @author Dennis Eichhorn
|
||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function update()
|
||||||
{
|
{
|
||||||
$this->fp->close();
|
file_put_contents($this->path, json_encode($this->info, JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set data
|
||||||
|
*
|
||||||
|
* @param string $path Value path
|
||||||
|
* @param mixed $data Scalar or array of data to set
|
||||||
|
* @param string $delim Delimiter of path
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function set(string $path, $data, string $delim = '/')
|
||||||
|
{
|
||||||
|
if (!is_scalar($data) || !is_array($data)) {
|
||||||
|
throw new \InvalidArgumentException('Type of $data "' . gettype($data) . '" is not supported.');
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayUtils::setArray($path, $this->info, $data, $delim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get info data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function get() : array
|
||||||
|
{
|
||||||
|
return $this->info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Module;
|
namespace phpOMS\Module;
|
||||||
|
|
||||||
use phpOMS\System\FilePathException;
|
use phpOMS\System\FilePathException;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -61,7 +62,7 @@ abstract class ModuleAbstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const MODULE_PATH = __DIR__;
|
const MODULE_PATH = __DIR__ . '/../../Modules';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module version.
|
* Module version.
|
||||||
|
|
@ -148,8 +149,9 @@ abstract class ModuleAbstract
|
||||||
{
|
{
|
||||||
$lang = [];
|
$lang = [];
|
||||||
if (isset(static::$localization[$destination])) {
|
if (isset(static::$localization[$destination])) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
foreach (static::$localization[$destination] as $file) {
|
foreach (static::$localization[$destination] as $file) {
|
||||||
if(($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) === false) {
|
if (($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) === false) {
|
||||||
throw new FilePathException($oldPath);
|
throw new FilePathException($oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,4 +199,17 @@ abstract class ModuleAbstract
|
||||||
/** @noinspection PhpUndefinedFieldInspection */
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
return static::$dependencies;
|
return static::$dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get event id prefix.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getEventId() : string
|
||||||
|
{
|
||||||
|
return static::class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
namespace phpOMS\Module;
|
namespace phpOMS\Module;
|
||||||
|
|
||||||
use phpOMS\ApplicationAbstract;
|
use phpOMS\ApplicationAbstract;
|
||||||
use phpOMS\Module\NullModule;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModuleFactory class.
|
* ModuleFactory class.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ use phpOMS\Message\Http\Request;
|
||||||
use phpOMS\System\FilePathException;
|
use phpOMS\System\FilePathException;
|
||||||
use phpOMS\Utils\IO\Json\InvalidJsonException;
|
use phpOMS\Utils\IO\Json\InvalidJsonException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules class.
|
* Modules class.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ namespace phpOMS\Stdlib;
|
||||||
* @category Stdlib
|
* @category Stdlib
|
||||||
* @package Framework
|
* @package Framework
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*
|
|
||||||
* @todo : implement JsonableInterface
|
|
||||||
*/
|
*/
|
||||||
class PriorityQueue implements \Countable, \Serializable
|
class PriorityQueue implements \Countable, \Serializable
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,17 @@ namespace phpOMS\System;
|
||||||
*/
|
*/
|
||||||
class FilePathException extends \UnexpectedValueException
|
class FilePathException extends \UnexpectedValueException
|
||||||
{
|
{
|
||||||
public function __construct($message, $code = 0, \Exception $previous = null)
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
parent::__construct('The path "' . $message . '" is not a valid path.', $code, $previous);
|
parent::__construct('The path "' . $message . '" is not a valid path.', $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class FileSystem
|
||||||
*
|
*
|
||||||
* @param string $path Path to folder
|
* @param string $path Path to folder
|
||||||
* @param bool $recursive Should sub folders be counted as well?
|
* @param bool $recursive Should sub folders be counted as well?
|
||||||
* @param array $ignore Ignore these sub-paths
|
* @param array $ignore Ignore these sub-paths
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
|
|
@ -56,7 +56,7 @@ class FileSystem
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function getFileCount(string $path, bool $recursive = true, array $ignore = ['.', '..', 'cgi-bin',
|
public static function getFileCount(string $path, bool $recursive = true, array $ignore = ['.', '..', 'cgi-bin',
|
||||||
'.DS_Store'])
|
'.DS_Store'])
|
||||||
{
|
{
|
||||||
$size = 0;
|
$size = 0;
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
|
|
@ -77,23 +77,21 @@ class FileSystem
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function copy()
|
/**
|
||||||
{
|
* Delete directory and all its content.
|
||||||
}
|
*
|
||||||
|
* @param string $path Path to folder
|
||||||
public function rename()
|
*
|
||||||
{
|
* @return bool
|
||||||
}
|
*
|
||||||
|
* @since 1.0.0
|
||||||
public function move()
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
{
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public static function deletePath($path) : bool
|
public static function deletePath($path) : bool
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = $path);
|
$path = realpath($oldPath = $path);
|
||||||
if ($path === false || !is_dir($path) || Validator::startsWith($path, ROOT_PATH)) {
|
if ($path === false || !is_dir($path) || Validator::startsWith($path, ROOT_PATH)) {
|
||||||
return false;
|
throw new FilePathException($oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
|
|
@ -114,52 +112,4 @@ class FileSystem
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function touch()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mkdir()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function exists()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function chmod()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function chown()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function chgrp()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function symlink()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toRelative()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toAbsolute()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isRelative()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isAbsolute()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dump()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,17 @@ namespace phpOMS\Uri;
|
||||||
*/
|
*/
|
||||||
class InvalidUriException extends \UnexpectedValueException
|
class InvalidUriException extends \UnexpectedValueException
|
||||||
{
|
{
|
||||||
public function __construct($message, $code = 0, \Exception $previous = null)
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $message Exception message
|
||||||
|
* @param int $code Exception code
|
||||||
|
* @param \Exception Previous exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct(string $message, int $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
parent::__construct('The uri "' . $message . '" is not valid.', $code, $previous);
|
parent::__construct('The uri "' . $message . '" is not valid.', $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Uri;
|
namespace phpOMS\Uri;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UriFactory class.
|
* UriFactory class.
|
||||||
*
|
*
|
||||||
|
|
@ -93,8 +91,7 @@ class UriFactory
|
||||||
* Build uri.
|
* Build uri.
|
||||||
*
|
*
|
||||||
* @param string $uri Path data
|
* @param string $uri Path data
|
||||||
* @param array $toMatch Optional special replacements
|
* @param array $toMatch Optional special replacements
|
||||||
* @param UriScheme|int $scheme Scheme type
|
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*
|
*
|
||||||
|
|
@ -103,7 +100,7 @@ class UriFactory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function build(string $uri, array $toMatch = [], int $scheme = UriScheme::HTTP)
|
public static function build(string $uri, array $toMatch = [])
|
||||||
{
|
{
|
||||||
$uri = preg_replace_callback('(\{[\/#\?@\.\$][a-zA-Z0-9]*\})', function ($match) use ($toMatch) {
|
$uri = preg_replace_callback('(\{[\/#\?@\.\$][a-zA-Z0-9]*\})', function ($match) use ($toMatch) {
|
||||||
$match = substr($match[0], 1, strlen($match[0]) - 2);
|
$match = substr($match[0], 1, strlen($match[0]) - 2);
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,21 @@ namespace phpOMS\Utils\IO\Csv;
|
||||||
* @package phpOMS\Config
|
* @package phpOMS\Config
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
trait CsvSettingsTrait
|
class CsvSettings
|
||||||
{
|
{
|
||||||
private function getFileDelimiter($file, int $checkLines = 2, array $delimiters = [',', '\t', ';', '|', ':']) : string
|
/**
|
||||||
|
* Get csv file delimiter.
|
||||||
|
*
|
||||||
|
* @param mixed $file File resource
|
||||||
|
* @param int $checkLines Lines to check for evaluation
|
||||||
|
* @param array $delimiters Potential delimiters
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public static function getFileDelimiter($file, int $checkLines = 2, array $delimiters = [',', '\t', ';', '|', ':']) : string
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user