mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-07 04:58:40 +00:00
Optimize imports and order
This commit is contained in:
parent
f176329d6c
commit
0376d85ace
|
|
@ -17,7 +17,6 @@ namespace phpOMS\Account;
|
||||||
|
|
||||||
use phpOMS\Contract\ArrayableInterface;
|
use phpOMS\Contract\ArrayableInterface;
|
||||||
use phpOMS\Localization\Localization;
|
use phpOMS\Localization\Localization;
|
||||||
use phpOMS\Localization\NullLocalization;
|
|
||||||
use phpOMS\Validation\Base\Email;
|
use phpOMS\Validation\Base\Email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Account;
|
namespace phpOMS\Account;
|
||||||
|
|
||||||
use phpOMS\Contract\ArrayableInterface;
|
use phpOMS\Contract\ArrayableInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,19 +132,6 @@ class Group implements ArrayableInterface, \JsonSerializable
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get group description.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public function getDescription() : string
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set group name.
|
* Set group name.
|
||||||
*
|
*
|
||||||
|
|
@ -157,6 +145,19 @@ class Group implements ArrayableInterface, \JsonSerializable
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get group description.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set group description.
|
* Set group description.
|
||||||
*
|
*
|
||||||
|
|
@ -170,22 +171,6 @@ class Group implements ArrayableInterface, \JsonSerializable
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function toArray() : array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'name' => $this->name,
|
|
||||||
'description' => $this->description,
|
|
||||||
'createdBy' => $this->createdBy,
|
|
||||||
'createdAt' => $this->createdAt->format('Y-m-d H:i:s'),
|
|
||||||
'permissions' => $this->permissions,
|
|
||||||
'members' => $this->members,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get string representation.
|
* Get string representation.
|
||||||
*
|
*
|
||||||
|
|
@ -211,4 +196,20 @@ class Group implements ArrayableInterface, \JsonSerializable
|
||||||
{
|
{
|
||||||
return json_encode($this->toArray());
|
return json_encode($this->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'description' => $this->description,
|
||||||
|
'createdBy' => $this->createdBy,
|
||||||
|
'createdAt' => $this->createdAt->format('Y-m-d H:i:s'),
|
||||||
|
'permissions' => $this->permissions,
|
||||||
|
'members' => $this->members,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Config;
|
namespace phpOMS\Config;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseExceptionFactory;
|
||||||
use phpOMS\DataStorage\Database\DatabaseType;
|
use phpOMS\DataStorage\Database\DatabaseType;
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
use phpOMS\DataStorage\Database\DatabaseExceptionFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings class.
|
* Settings class.
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,16 @@ class Address implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function toArray() : array
|
public function jsonSerialize(int $option = 0) : string
|
||||||
{
|
{
|
||||||
return ['recipient' => $this->recipient, 'fao' => $this->fao, 'location' => $this->location->toArray()];
|
return json_encode($this->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function jsonSerialize(int $option = 0) : string
|
public function toArray() : array
|
||||||
{
|
{
|
||||||
return json_encode($this->toArray());
|
return ['recipient' => $this->recipient, 'fao' => $this->fao, 'location' => $this->location->toArray()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,38 +31,6 @@ namespace phpOMS\Datatypes;
|
||||||
abstract class Enum
|
abstract class Enum
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Checking enum name.
|
|
||||||
*
|
|
||||||
* Checking if a certain const name exists (case sensitive)
|
|
||||||
*
|
|
||||||
* @param string $name Name of the value (case sensitive)
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public static function isValidName(string $name) : bool
|
|
||||||
{
|
|
||||||
return defined($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getting all constants of this enum.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public static function getConstants() : array
|
|
||||||
{
|
|
||||||
$reflect = new \ReflectionClass(get_called_class());
|
|
||||||
|
|
||||||
return $reflect->getConstants();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check enum value.
|
* Check enum value.
|
||||||
*
|
*
|
||||||
|
|
@ -82,6 +50,21 @@ abstract class Enum
|
||||||
return in_array($value, $values, true);
|
return in_array($value, $values, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getting all constants of this enum.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public static function getConstants() : array
|
||||||
|
{
|
||||||
|
$reflect = new \ReflectionClass(get_called_class());
|
||||||
|
|
||||||
|
return $reflect->getConstants();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get random enum value.
|
* Get random enum value.
|
||||||
*
|
*
|
||||||
|
|
@ -111,11 +94,28 @@ abstract class Enum
|
||||||
*/
|
*/
|
||||||
public static function getByName(string $name)
|
public static function getByName(string $name)
|
||||||
{
|
{
|
||||||
if(!self::isValidName($name)) {
|
if (!self::isValidName($name)) {
|
||||||
throw new \Exception('Undefined constant');
|
throw new \Exception('Undefined constant');
|
||||||
}
|
}
|
||||||
|
|
||||||
return constant($name);
|
return constant($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checking enum name.
|
||||||
|
*
|
||||||
|
* Checking if a certain const name exists (case sensitive)
|
||||||
|
*
|
||||||
|
* @param string $name Name of the value (case sensitive)
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public static function isValidName(string $name) : bool
|
||||||
|
{
|
||||||
|
return defined($name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,16 +73,18 @@ class Iban implements \Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get 2 digit country code
|
* Normalize iban
|
||||||
|
*
|
||||||
|
* @param string $iban Iban to normalize
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getCountry() : string
|
public static function normalize(string $iban) : string
|
||||||
{
|
{
|
||||||
return substr($this->iban, 0, 2);
|
return strtoupper(str_replace(' ', '', $iban));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,6 +100,19 @@ class Iban implements \Serializable
|
||||||
return strlen($this->iban);
|
return strlen($this->iban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get iban checksum
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getChecksum() : string
|
||||||
|
{
|
||||||
|
return $this->getSequence('k');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sequence specified in the layout
|
* Get sequence specified in the layout
|
||||||
*
|
*
|
||||||
|
|
@ -124,16 +139,16 @@ class Iban implements \Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get iban checksum
|
* Get 2 digit country code
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getChecksum() : string
|
public function getCountry() : string
|
||||||
{
|
{
|
||||||
return $this->getSequence('k');
|
return substr($this->iban, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -255,6 +270,17 @@ class Iban implements \Serializable
|
||||||
return $this->getSequence('a');
|
return $this->getSequence('a');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String representation of object
|
||||||
|
* @link http://php.net/manual/en/serializable.serialize.php
|
||||||
|
* @return string the string representation of the object or null
|
||||||
|
* @since 5.1.0
|
||||||
|
*/
|
||||||
|
public function serialize()
|
||||||
|
{
|
||||||
|
return $this->prettyPrint();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pretty print iban
|
* Pretty print iban
|
||||||
*
|
*
|
||||||
|
|
@ -268,32 +294,6 @@ class Iban implements \Serializable
|
||||||
return wordwrap($this->iban, 4, ' ', true);
|
return wordwrap($this->iban, 4, ' ', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize iban
|
|
||||||
*
|
|
||||||
* @param string $iban Iban to normalize
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public static function normalize(string $iban) : string
|
|
||||||
{
|
|
||||||
return strtoupper(str_replace(' ', '', $iban));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* String representation of object
|
|
||||||
* @link http://php.net/manual/en/serializable.serialize.php
|
|
||||||
* @return string the string representation of the object or null
|
|
||||||
* @since 5.1.0
|
|
||||||
*/
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return $this->prettyPrint();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object
|
* Constructs the object
|
||||||
* @link http://php.net/manual/en/serializable.unserialize.php
|
* @link http://php.net/manual/en/serializable.unserialize.php
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,25 @@ class Location implements \JsonSerializable, \Serializable
|
||||||
$this->geo = $geo;
|
$this->geo = $geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String representation of object
|
||||||
|
* @link http://php.net/manual/en/serializable.serialize.php
|
||||||
|
* @return string the string representation of the object or null
|
||||||
|
* @since 5.1.0
|
||||||
|
*/
|
||||||
|
public function serialize()
|
||||||
|
{
|
||||||
|
return $this->jsonSerialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize() : string
|
||||||
|
{
|
||||||
|
return json_encode($this->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -246,25 +265,6 @@ class Location implements \JsonSerializable, \Serializable
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function jsonSerialize() : string
|
|
||||||
{
|
|
||||||
return json_encode($this->toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* String representation of object
|
|
||||||
* @link http://php.net/manual/en/serializable.serialize.php
|
|
||||||
* @return string the string representation of the object or null
|
|
||||||
* @since 5.1.0
|
|
||||||
*/
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return $this->jsonSerialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object
|
* Constructs the object
|
||||||
* @link http://php.net/manual/en/serializable.unserialize.php
|
* @link http://php.net/manual/en/serializable.unserialize.php
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,13 @@ use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||||
class Localization
|
class Localization
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Localization manager.
|
||||||
|
*
|
||||||
|
* @var L11nManager
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public $l11nManager = null;
|
||||||
/**
|
/**
|
||||||
* Country ID.
|
* Country ID.
|
||||||
*
|
*
|
||||||
|
|
@ -38,7 +45,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $country = ISO3166Enum::_US;
|
private $country = ISO3166Enum::_US;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timezone.
|
* Timezone.
|
||||||
*
|
*
|
||||||
|
|
@ -46,7 +52,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $timezone = 'America/New_York';
|
private $timezone = 'America/New_York';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language ISO code.
|
* Language ISO code.
|
||||||
*
|
*
|
||||||
|
|
@ -54,7 +59,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $language = ISO639x1Enum::_EN;
|
private $language = ISO639x1Enum::_EN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency.
|
* Currency.
|
||||||
*
|
*
|
||||||
|
|
@ -62,7 +66,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $currency = ISO4217Enum::C_USD;
|
private $currency = ISO4217Enum::C_USD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number format.
|
* Number format.
|
||||||
*
|
*
|
||||||
|
|
@ -70,7 +73,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $decimal = '.';
|
private $decimal = '.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number format.
|
* Number format.
|
||||||
*
|
*
|
||||||
|
|
@ -78,7 +80,6 @@ class Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $thousands = ',';
|
private $thousands = ',';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time format.
|
* Time format.
|
||||||
*
|
*
|
||||||
|
|
@ -87,14 +88,6 @@ class Localization
|
||||||
*/
|
*/
|
||||||
private $datetime = 'Y-m-d H:i:s';
|
private $datetime = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
/**
|
|
||||||
* Localization manager.
|
|
||||||
*
|
|
||||||
* @var L11nManager
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public $l11nManager = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Localization;
|
namespace phpOMS\Localization;
|
||||||
|
|
||||||
use \phpOMS\Math\Number\OperationInterface;
|
use phpOMS\Math\Number\OperationInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Money class.
|
* Money class.
|
||||||
|
|
@ -74,46 +74,18 @@ class Money implements \Serializable, OperationInterface
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $currency Currency symbol
|
* @param string $currency Currency symbol
|
||||||
* @param string $thousands Thousands separator
|
* @param string $thousands Thousands separator
|
||||||
* @param string $decimal Decimal separator
|
* @param string $decimal Decimal separator
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function __construct(string $currency = ISO4217CharEnum::C_USD, string $thousands = ',', string $decimal = '.')
|
public function __construct(string $currency = ISO4217CharEnum::C_USD, string $thousands = ',', string $decimal = '.')
|
||||||
{
|
{
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->thousands = $thousands;
|
$this->thousands = $thousands;
|
||||||
$this->decimal = $decimal;
|
$this->decimal = $decimal;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set money value.
|
|
||||||
*
|
|
||||||
* @param int $value Value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public function setInt(int $value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get money value.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public function getInt() : int
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,8 +106,8 @@ class Money implements \Serializable, OperationInterface
|
||||||
/**
|
/**
|
||||||
* Money to int.
|
* Money to int.
|
||||||
*
|
*
|
||||||
* @param string $value Money value
|
* @param string $value Money value
|
||||||
* @param string $decimal Decimal character
|
* @param string $decimal Decimal character
|
||||||
* @param string $thousands Thousands character
|
* @param string $thousands Thousands character
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
|
|
@ -151,7 +123,7 @@ class Money implements \Serializable, OperationInterface
|
||||||
$left = str_replace($thousands, '', $left);
|
$left = str_replace($thousands, '', $left);
|
||||||
|
|
||||||
$right = '';
|
$right = '';
|
||||||
if(count($split) > 1) {
|
if (count($split) > 1) {
|
||||||
$right = $split[1];
|
$right = $split[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,13 +144,13 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function getAmount(int $decimals = 2) : string
|
public function getAmount(int $decimals = 2) : string
|
||||||
{
|
{
|
||||||
if($decimals > ($dec = constant('\phpOMS\Localization\ISO4217DecimalEnum::C_' . strtoupper($this->currency)))) {
|
if ($decimals > ($dec = constant('\phpOMS\Localization\ISO4217DecimalEnum::C_' . strtoupper($this->currency)))) {
|
||||||
$decimals = $dec ;
|
$decimals = $dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = (string) round($this->value, - self::MAX_DECIMALS + $decimals);
|
$value = (string) round($this->value, -self::MAX_DECIMALS + $decimals);
|
||||||
|
|
||||||
$left = substr($value, 0, -self::MAX_DECIMALS);
|
$left = substr($value, 0, -self::MAX_DECIMALS);
|
||||||
$right = substr($value, -self::MAX_DECIMALS);
|
$right = substr($value, -self::MAX_DECIMALS);
|
||||||
|
|
||||||
return ($decimals > 0) ? number_format($left, 0, $this->thousands, $this->decimal) . $this->decimal . $right : (string) $left;
|
return ($decimals > 0) ? number_format($left, 0, $this->thousands, $this->decimal) . $this->decimal . $right : (string) $left;
|
||||||
|
|
@ -196,17 +168,30 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function add($value) : Money
|
public function add($value) : Money
|
||||||
{
|
{
|
||||||
if(is_string($value) || is_float($value)) {
|
if (is_string($value) || is_float($value)) {
|
||||||
$this->value += self::toInt((string) $value, $this->decimal, $this->thousands);
|
$this->value += self::toInt((string) $value, $this->decimal, $this->thousands);
|
||||||
} elseif(is_int($value)) {
|
} elseif (is_int($value)) {
|
||||||
$this->value += $value;
|
$this->value += $value;
|
||||||
} elseif($value instanceof Money) {
|
} elseif ($value instanceof Money) {
|
||||||
$this->value += $value->getInt();
|
$this->value += $value->getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get money value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInt() : int
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub money.
|
* Sub money.
|
||||||
*
|
*
|
||||||
|
|
@ -219,11 +204,11 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function sub($value) : Money
|
public function sub($value) : Money
|
||||||
{
|
{
|
||||||
if(is_string($value) || is_float($value)) {
|
if (is_string($value) || is_float($value)) {
|
||||||
$this->value -= self::toInt((string) $value, $this->decimal, $this->thousands);
|
$this->value -= self::toInt((string) $value, $this->decimal, $this->thousands);
|
||||||
} elseif(is_int($value)) {
|
} elseif (is_int($value)) {
|
||||||
$this->value -= $value;
|
$this->value -= $value;
|
||||||
} elseif($value instanceof Money) {
|
} elseif ($value instanceof Money) {
|
||||||
$this->value -= $value->getInt();
|
$this->value -= $value->getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,7 +227,7 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function mult($value) : Money
|
public function mult($value) : Money
|
||||||
{
|
{
|
||||||
if(is_float($value) || is_int($value)) {
|
if (is_float($value) || is_int($value)) {
|
||||||
$this->value *= $value;
|
$this->value *= $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,7 +246,7 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function div($value) : Money
|
public function div($value) : Money
|
||||||
{
|
{
|
||||||
if(is_float($value) || is_int($value)) {
|
if (is_float($value) || is_int($value)) {
|
||||||
$this->value = self::toInt((string) ($this->value / $value), $this->decimal, $this->thousands);
|
$this->value = self::toInt((string) ($this->value / $value), $this->decimal, $this->thousands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -295,7 +280,7 @@ class Money implements \Serializable, OperationInterface
|
||||||
*/
|
*/
|
||||||
public function pow($value) : Money
|
public function pow($value) : Money
|
||||||
{
|
{
|
||||||
if(is_float($value) || is_int($value)) {
|
if (is_float($value) || is_int($value)) {
|
||||||
$this->value = $this->value ** $value;
|
$this->value = $this->value ** $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,4 +314,19 @@ class Money implements \Serializable, OperationInterface
|
||||||
{
|
{
|
||||||
$this->setInt($value);
|
$this->setInt($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set money value.
|
||||||
|
*
|
||||||
|
* @param int $value Value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function setInt(int $value)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
namespace phpOMS\Log;
|
namespace phpOMS\Log;
|
||||||
|
|
||||||
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||||
use phpOMS\System\File\PathException;
|
|
||||||
use phpOMS\System\File\File;
|
|
||||||
use phpOMS\System\File\Directory;
|
use phpOMS\System\File\Directory;
|
||||||
|
use phpOMS\System\File\File;
|
||||||
|
use phpOMS\System\File\PathException;
|
||||||
use phpOMS\Validation\Validator;
|
use phpOMS\Validation\Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,6 @@ use phpOMS\Router\RouteVerb;
|
||||||
class Request extends RequestAbstract
|
class Request extends RequestAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Browser type.
|
|
||||||
*
|
|
||||||
* @var BrowserType
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
private $browser = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OS type.
|
|
||||||
*
|
|
||||||
* @var OSType
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
private $os = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path.
|
* Path.
|
||||||
*
|
*
|
||||||
|
|
@ -60,7 +44,6 @@ class Request extends RequestAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $path = null;
|
protected $path = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request status.
|
* Request status.
|
||||||
*
|
*
|
||||||
|
|
@ -68,7 +51,6 @@ class Request extends RequestAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $status = RequestStatus::R_200;
|
protected $status = RequestStatus::R_200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploaded files.
|
* Uploaded files.
|
||||||
*
|
*
|
||||||
|
|
@ -76,7 +58,20 @@ class Request extends RequestAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $files = [];
|
protected $files = [];
|
||||||
|
/**
|
||||||
|
* Browser type.
|
||||||
|
*
|
||||||
|
* @var BrowserType
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $browser = null;
|
||||||
|
/**
|
||||||
|
* OS type.
|
||||||
|
*
|
||||||
|
* @var OSType
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $os = null;
|
||||||
/**
|
/**
|
||||||
* Request information.
|
* Request information.
|
||||||
*
|
*
|
||||||
|
|
@ -181,6 +176,22 @@ class Request extends RequestAbstract
|
||||||
$this->uri->set($uri['uri']);
|
$this->uri->set($uri['uri']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up globals that musn't be used any longer
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
private function cleanupGlobals()
|
||||||
|
{
|
||||||
|
unset($_FILES);
|
||||||
|
unset($_GET);
|
||||||
|
unset($_POST);
|
||||||
|
unset($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup uri builder based on current request
|
* Setup uri builder based on current request
|
||||||
*
|
*
|
||||||
|
|
@ -218,19 +229,18 @@ class Request extends RequestAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up globals that musn't be used any longer
|
* Generate request hash.
|
||||||
*
|
*
|
||||||
* @return void
|
* @param array $request Request array
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
private function cleanupGlobals()
|
private function hashRequest(array $request) : string
|
||||||
{
|
{
|
||||||
unset($_FILES);
|
return sha1(implode('', $request));
|
||||||
unset($_GET);
|
|
||||||
unset($_POST);
|
|
||||||
unset($_REQUEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -253,21 +263,6 @@ class Request extends RequestAbstract
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate request hash.
|
|
||||||
*
|
|
||||||
* @param array $request Request array
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
private function hashRequest(array $request) : string
|
|
||||||
{
|
|
||||||
return sha1(implode('', $request));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -389,23 +384,6 @@ class Request extends RequestAbstract
|
||||||
return $lastElement;
|
return $lastElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get request type.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
public function getMethod() : string
|
|
||||||
{
|
|
||||||
if (!isset($this->method)) {
|
|
||||||
$this->method = $_SERVER['REQUEST_METHOD'] ?? RequestMethod::GET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->method;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -466,4 +444,21 @@ class Request extends RequestAbstract
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get request type.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getMethod() : string
|
||||||
|
{
|
||||||
|
if (!isset($this->method)) {
|
||||||
|
$this->method = $_SERVER['REQUEST_METHOD'] ?? RequestMethod::GET;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,22 @@ class ActivateAbstract
|
||||||
self::activateInDatabase($dbPool, $info);
|
self::activateInDatabase($dbPool, $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install routes.
|
||||||
|
*
|
||||||
|
* @param string $destRoutePath Destination route path
|
||||||
|
* @param string $srcRoutePath Source route path
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
private static function activateRoutes(string $destRoutePath, string $srcRoutePath)
|
||||||
|
{
|
||||||
|
// todo: remove route
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deactivate module in database.
|
* Deactivate module in database.
|
||||||
*
|
*
|
||||||
|
|
@ -79,21 +95,4 @@ class ActivateAbstract
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install routes.
|
|
||||||
*
|
|
||||||
* @param string $destRoutePath Destination route path
|
|
||||||
* @param string $srcRoutePath Source route path
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
private static function activateRoutes(string $destRoutePath, string $srcRoutePath)
|
|
||||||
{
|
|
||||||
// todo: remove route
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,22 @@ class DeactivateAbstract
|
||||||
self::deactivateInDatabase($dbPool, $info);
|
self::deactivateInDatabase($dbPool, $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install routes.
|
||||||
|
*
|
||||||
|
* @param string $destRoutePath Destination route path
|
||||||
|
* @param string $srcRoutePath Source route path
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
private static function deactivateRoutes(string $destRoutePath, string $srcRoutePath)
|
||||||
|
{
|
||||||
|
// todo: remove route
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deactivate module in database.
|
* Deactivate module in database.
|
||||||
*
|
*
|
||||||
|
|
@ -79,21 +95,4 @@ class DeactivateAbstract
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install routes.
|
|
||||||
*
|
|
||||||
* @param string $destRoutePath Destination route path
|
|
||||||
* @param string $srcRoutePath Source route path
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
*/
|
|
||||||
private static function deactivateRoutes(string $destRoutePath, string $srcRoutePath)
|
|
||||||
{
|
|
||||||
// todo: remove route
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,6 @@ namespace phpOMS\Module;
|
||||||
abstract class ModuleAbstract
|
abstract class ModuleAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Receiving modules from?
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected $receiving = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receiving modules from?
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected static $providing = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module name.
|
* Module name.
|
||||||
*
|
*
|
||||||
|
|
@ -52,7 +36,6 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const MODULE_NAME = '';
|
const MODULE_NAME = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module path.
|
* Module path.
|
||||||
*
|
*
|
||||||
|
|
@ -60,7 +43,6 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const MODULE_PATH = __DIR__ . '/../../Modules';
|
const MODULE_PATH = __DIR__ . '/../../Modules';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module version.
|
* Module version.
|
||||||
*
|
*
|
||||||
|
|
@ -68,7 +50,13 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const MODULE_VERSION = '1.0.0';
|
const MODULE_VERSION = '1.0.0';
|
||||||
|
/**
|
||||||
|
* Receiving modules from?
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $providing = [];
|
||||||
/**
|
/**
|
||||||
* Localization files.
|
* Localization files.
|
||||||
*
|
*
|
||||||
|
|
@ -76,7 +64,6 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $localization = [];
|
protected static $localization = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependencies.
|
* Dependencies.
|
||||||
*
|
*
|
||||||
|
|
@ -84,7 +71,13 @@ abstract class ModuleAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $dependencies = [];
|
protected static $dependencies = [];
|
||||||
|
/**
|
||||||
|
* Receiving modules from?
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $receiving = [];
|
||||||
/**
|
/**
|
||||||
* Application instance.
|
* Application instance.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@
|
||||||
namespace phpOMS\Module;
|
namespace phpOMS\Module;
|
||||||
|
|
||||||
use phpOMS\ApplicationAbstract;
|
use phpOMS\ApplicationAbstract;
|
||||||
|
use phpOMS\Autoloader;
|
||||||
use phpOMS\DataStorage\Database\DatabaseType;
|
use phpOMS\DataStorage\Database\DatabaseType;
|
||||||
use phpOMS\Log\FileLogger;
|
use phpOMS\Log\FileLogger;
|
||||||
use phpOMS\Message\Http\Request;
|
use phpOMS\Message\Http\Request;
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
use phpOMS\Autoloader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules class.
|
* Modules class.
|
||||||
|
|
@ -360,7 +360,7 @@ class ModuleManager
|
||||||
*/
|
*/
|
||||||
public function reInit(string $module) : bool
|
public function reInit(string $module) : bool
|
||||||
{
|
{
|
||||||
if(file_exists($path = __DIR__ . '/../Web/Routes.php')) {
|
if (file_exists($path = __DIR__ . '/../Web/Routes.php')) {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -600,7 +600,7 @@ class ModuleManager
|
||||||
*/
|
*/
|
||||||
public function initModule($module)
|
public function initModule($module)
|
||||||
{
|
{
|
||||||
if(!is_array($module)) {
|
if (!is_array($module)) {
|
||||||
$module = [$module];
|
$module = [$module];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
62
Uri/Http.php
62
Uri/Http.php
|
|
@ -135,10 +135,29 @@ class Http implements UriInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setRootPath(string $root)
|
public function set(string $uri)
|
||||||
{
|
{
|
||||||
$this->rootPath = $root;
|
$this->uri = $uri;
|
||||||
$this->set($this->uri);
|
|
||||||
|
$url = parse_url($this->uri);
|
||||||
|
|
||||||
|
$this->scheme = $url['scheme'] ?? '';
|
||||||
|
$this->host = $url['host'] ?? null;
|
||||||
|
$this->port = $url['port'] ?? null;
|
||||||
|
$this->user = $url['user'] ?? null;
|
||||||
|
$this->pass = $url['pass'] ?? null;
|
||||||
|
$this->path = $url['path'] ?? null;
|
||||||
|
$this->path = rtrim($this->path, '.php');
|
||||||
|
$this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language
|
||||||
|
$this->query = $url['query'] ?? null;
|
||||||
|
|
||||||
|
if (isset($this->query)) {
|
||||||
|
parse_str($this->query, $this->query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->fragment = $url['fragment'] ?? null;
|
||||||
|
|
||||||
|
$this->base = $this->scheme . '://' . $this->host . $this->rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -176,6 +195,15 @@ class Http implements UriInterface
|
||||||
return $this->rootPath;
|
return $this->rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setRootPath(string $root)
|
||||||
|
{
|
||||||
|
$this->rootPath = $root;
|
||||||
|
$this->set($this->uri);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -245,34 +273,6 @@ class Http implements UriInterface
|
||||||
return $this->base;
|
return $this->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function set(string $uri)
|
|
||||||
{
|
|
||||||
$this->uri = $uri;
|
|
||||||
|
|
||||||
$url = parse_url($this->uri);
|
|
||||||
|
|
||||||
$this->scheme = $url['scheme'] ?? '';
|
|
||||||
$this->host = $url['host'] ?? null;
|
|
||||||
$this->port = $url['port'] ?? null;
|
|
||||||
$this->user = $url['user'] ?? null;
|
|
||||||
$this->pass = $url['pass'] ?? null;
|
|
||||||
$this->path = $url['path'] ?? null;
|
|
||||||
$this->path = rtrim($this->path, '.php');
|
|
||||||
$this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language
|
|
||||||
$this->query = $url['query'] ?? null;
|
|
||||||
|
|
||||||
if (isset($this->query)) {
|
|
||||||
parse_str($this->query, $this->query);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->fragment = $url['fragment'] ?? null;
|
|
||||||
|
|
||||||
$this->base = $this->scheme . '://' . $this->host . $this->rootPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class JsonBuilder implements \Serializable
|
||||||
/**
|
/**
|
||||||
* Remove data.
|
* Remove data.
|
||||||
*
|
*
|
||||||
* @param string $path Path to the element to delete
|
* @param string $path Path to the element to delete
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class BitcoinValidator extends ValidatorAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::$msg = $e->getMessage();
|
self::$msg = $e->getMessage();
|
||||||
} finally {
|
} finally {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user