mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
PhpStorm cleanup
This commit is contained in:
parent
16320978d3
commit
669c3b7244
|
|
@ -55,6 +55,8 @@ class HttpSession implements SessionInterface
|
|||
* @param int $liftetime Session life time
|
||||
* @param string|int|bool $sid Session id
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use phpOMS\Message\RequestAbstract;
|
|||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Module\ModuleAbstract;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Views\ViewLayout;
|
||||
|
||||
/**
|
||||
* Dispatcher class.
|
||||
|
|
@ -83,7 +82,6 @@ class Dispatcher
|
|||
public function dispatch($controller, RequestAbstract $request, ResponseAbstract $response, $data = null) : array
|
||||
{
|
||||
$views = [];
|
||||
$type = ViewLayout::UNDEFINED;
|
||||
|
||||
if (is_array($controller) && isset($controller['dest'])) {
|
||||
$controller = $controller['dest'];
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class FileLogger implements LoggerInterface
|
|||
*
|
||||
* @param string $path Logging path
|
||||
*
|
||||
* @return self
|
||||
* @return FileLogger
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\Message;
|
||||
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
@ -26,7 +28,85 @@ namespace phpOMS\Message;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class HeaderAbstract
|
||||
abstract class HeaderAbstract
|
||||
{
|
||||
private static $isLocked = false;
|
||||
/**
|
||||
* Responses.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $isLocked = false;
|
||||
|
||||
/**
|
||||
* Set header.
|
||||
*
|
||||
* @param string $key Header key
|
||||
* @param string $value Header value
|
||||
* @param bool $overwrite Overwrite if key already exists
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function set(string $key, string $value, bool $overwrite = false);
|
||||
|
||||
/**
|
||||
* Generate header based on status code.
|
||||
*
|
||||
* @param string $statusCode Status code
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function generate(string $statusCode);
|
||||
|
||||
/**
|
||||
* Get header by key.
|
||||
*
|
||||
* @param string $key Header key
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function get(string $key) : array;
|
||||
|
||||
/**
|
||||
* Header has key?
|
||||
*
|
||||
* @param string $key Header key
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function has(string $key) : bool;
|
||||
|
||||
/**
|
||||
* Set header locked.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function lock()
|
||||
{
|
||||
CookieJar::lock();
|
||||
HttpSession::lock();
|
||||
self::$isLocked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is header locked?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function isLocked() : bool
|
||||
{
|
||||
return self::$isLocked;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,9 +16,6 @@
|
|||
namespace phpOMS\Message\Http;
|
||||
|
||||
use phpOMS\Message\HeaderAbstract;
|
||||
use phpOMS\Utils\ArrayUtils;
|
||||
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
@ -42,7 +39,13 @@ class Header extends HeaderAbstract
|
|||
*/
|
||||
private $header = [];
|
||||
|
||||
public function __constrct()
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->set('Content-Type', 'text/html; charset=utf-8');
|
||||
}
|
||||
|
|
@ -75,6 +78,8 @@ class Header extends HeaderAbstract
|
|||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
@ -93,26 +98,26 @@ class Header extends HeaderAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $id) : array
|
||||
public function get(string $key) : array
|
||||
{
|
||||
return $this->header[$id] ?? [];
|
||||
return $this->header[$key] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name) : bool
|
||||
public function has(string $key) : bool
|
||||
{
|
||||
return array_key_exists($name, $this->header);
|
||||
return array_key_exists($key, $this->header);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($key, string $header, bool $overwrite = false) : bool
|
||||
public function set(string $key, string $header, bool $overwrite = false) : bool
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
throw new \Exception('Already locked');
|
||||
|
|
@ -155,29 +160,7 @@ class Header extends HeaderAbstract
|
|||
}
|
||||
|
||||
/**
|
||||
* Lock other header pushing models.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
private function lock()
|
||||
{
|
||||
CookieJar::lock();
|
||||
HttpSession::lock();
|
||||
self::$isLocked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate header automatically based on code.
|
||||
*
|
||||
* @param string $code HTTP status code
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate(string $code)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ class Request extends RequestAbstract
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ namespace phpOMS\Message\Http;
|
|||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Utils\ArrayUtils;
|
||||
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
@ -85,15 +83,13 @@ class Response extends ResponseAbstract implements RenderableInterface
|
|||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function remove(int $id) : bool
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
throw new \Exception('Already locked');
|
||||
}
|
||||
|
||||
if (isset($this->response[$id])) {
|
||||
unset($this->response[$id]);
|
||||
|
||||
|
|
@ -149,7 +145,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
|||
*/
|
||||
private function getJson() : string
|
||||
{
|
||||
return json_encode($this->getArray());
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -157,6 +153,8 @@ class Response extends ResponseAbstract implements RenderableInterface
|
|||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
@ -182,20 +180,15 @@ class Response extends ResponseAbstract implements RenderableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate response array from views.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
private function getArray() : array
|
||||
public function toArray() : array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($this->response as $key => $response) {
|
||||
if($reponse instanceof Views) {
|
||||
$result += $response->getArray();
|
||||
if($response instanceof View) {
|
||||
$result += $response->toArray();
|
||||
} elseif(is_array($response)) {
|
||||
$result += $response;
|
||||
} elseif(is_scalar($response)) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ interface MessageInterface
|
|||
/**
|
||||
* Retrieves all message header values.
|
||||
*
|
||||
* @return array
|
||||
* @return HeaderAbstract
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ abstract class RequestAbstract implements MessageInterface
|
|||
*/
|
||||
public function setUri(UriInterface $uri)
|
||||
{
|
||||
return $this->uri = $uri;
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ namespace phpOMS\Message;
|
|||
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Utils\ArrayUtils;
|
||||
use phpOMS\Message\Http\Header;
|
||||
|
||||
/**
|
||||
* Response abstract class.
|
||||
|
|
@ -65,6 +64,12 @@ abstract class ResponseAbstract implements MessageInterface
|
|||
*/
|
||||
protected $account = null;
|
||||
|
||||
/**
|
||||
* Header.
|
||||
*
|
||||
* @var HeaderAbstract
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $header = null;
|
||||
|
||||
/**
|
||||
|
|
@ -156,6 +161,18 @@ abstract class ResponseAbstract implements MessageInterface
|
|||
return json_encode($this->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate response array from views.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
abstract public function toArray() : array;
|
||||
|
||||
/**
|
||||
* Get header.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class Meta implements RenderableInterface
|
|||
/**
|
||||
* Set description.
|
||||
*
|
||||
* @param string Descritpion
|
||||
* @param string $description Meta description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ namespace phpOMS\Module;
|
|||
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Utils\ArrayUtils;
|
||||
use phpOMS\Validation\Validator;
|
||||
|
||||
/**
|
||||
* InfoManager class.
|
||||
|
|
@ -54,7 +53,7 @@ class InfoManager
|
|||
/**
|
||||
* Object constructor.
|
||||
*
|
||||
* @param string $module Module name
|
||||
* @param string $path Info file path
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use phpOMS\Log\FileLogger;
|
|||
use phpOMS\Message\Http\Request;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Autoloader;
|
||||
use phpOMS\Utils\IO\Json\InvalidJsonException;
|
||||
|
||||
/**
|
||||
* Modules class.
|
||||
|
|
@ -326,7 +325,7 @@ class ModuleManager
|
|||
/**
|
||||
* Register module in database.
|
||||
*
|
||||
* @param string $module Module name
|
||||
* @param InfoManager $info Module info
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -400,6 +399,8 @@ class ModuleManager
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
namespace phpOMS\Router;
|
||||
|
||||
use phpOMS\Views\ViewLayout;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
||||
/**
|
||||
|
|
@ -62,6 +61,7 @@ class Router
|
|||
*/
|
||||
public function importFromFile(string $path)
|
||||
{
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$this->routes += include $path;
|
||||
}
|
||||
|
||||
|
|
@ -113,9 +113,9 @@ class Router
|
|||
* Match route and uri.
|
||||
*
|
||||
* @param string $route Route
|
||||
* @param string $verb GET,POST for this route
|
||||
* @param string $routeVerb GET,POST for this route
|
||||
* @param string $uri Uri
|
||||
* @param string $verb Verb this request is using
|
||||
* @param string $remoteVerb Verb this request is using
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\Stdlib\Map;
|
||||
use phpOMS\Utils\Permutation;
|
||||
|
||||
/**
|
||||
* Multimap utils.
|
||||
|
|
@ -51,7 +52,7 @@ class MultiMap implements \Countable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $keyType = KeyType::MULTIPLE;
|
||||
private $keyType = KeyType::SINGLE;
|
||||
|
||||
/**
|
||||
* Order type.
|
||||
|
|
@ -64,10 +65,13 @@ class MultiMap implements \Countable
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $key Key type (all keys need to match or just one)
|
||||
* @param int $order Order of the keys is important (only required for multiple keys)
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct(int $key = KeyType::MULTIPLE, int $order = OrderType::LOOSE)
|
||||
public function __construct(int $key = KeyType::SINGLE, int $order = OrderType::LOOSE)
|
||||
{
|
||||
$this->keyType = $key;
|
||||
$this->orderType = $order;
|
||||
|
|
@ -216,11 +220,9 @@ class MultiMap implements \Countable
|
|||
{
|
||||
if ($this->keyType === KeyType::MULTIPLE && is_array($key)) {
|
||||
return $this->setMultiple($key, $value);
|
||||
} else {
|
||||
return $this->setSingle($key, $value);
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->setSingle($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
62
Uri/Http.php
62
Uri/Http.php
|
|
@ -177,12 +177,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get scheme.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getScheme() : string
|
||||
{
|
||||
|
|
@ -190,12 +185,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get host.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHost() : string
|
||||
{
|
||||
|
|
@ -203,12 +193,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get port.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPort() : int
|
||||
{
|
||||
|
|
@ -229,12 +214,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get path.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPath() : string
|
||||
{
|
||||
|
|
@ -242,14 +222,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get query.
|
||||
*
|
||||
* @param null|string $key Query key
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuery(string $key = null)
|
||||
{
|
||||
|
|
@ -257,12 +230,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get fragment.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFragment() : string
|
||||
{
|
||||
|
|
@ -270,12 +238,7 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get base.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBase() : string
|
||||
{
|
||||
|
|
@ -283,16 +246,9 @@ class Http implements UriInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set uri.
|
||||
*
|
||||
* @param string $uri Uri
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
private function set(string $uri)
|
||||
public function set(string $uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
|
||||
|
|
|
|||
|
|
@ -142,4 +142,16 @@ interface UriInterface
|
|||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getBase() : string;
|
||||
|
||||
/**
|
||||
* Set uri.
|
||||
*
|
||||
* @param string $uri Uri
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function set(string $uri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,21 @@ namespace phpOMS\Utils\Encoding;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Ceasar {
|
||||
class Caesar {
|
||||
/**
|
||||
* ASCII lower char limit.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
const LIMIT_LOWER = 0;
|
||||
|
||||
/**
|
||||
* ASCII upper char limit.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
const LIMIT_UPPER = 127;
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +63,7 @@ class Ceasar {
|
|||
$ascii -= self::LIMIT_UPPER;
|
||||
}
|
||||
|
||||
$result .= char($ascii);
|
||||
$result .= chr($ascii);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
@ -76,7 +89,7 @@ class Ceasar {
|
|||
$ascii += self::LIMIT_LOWER;
|
||||
}
|
||||
|
||||
$result .= char($ascii);
|
||||
$result .= chr($ascii);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
@ -38,7 +38,7 @@ interface EncodingInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function decode($source);
|
||||
public function encode($source);
|
||||
|
||||
/**
|
||||
* Dedecodes text
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace phpOMS\Utils\Encoding;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Xor {
|
||||
final class XorEncoding {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -43,7 +43,7 @@ class Xor {
|
|||
}
|
||||
|
||||
$ascii = ord($source[$i]) ^ ord($key[$j]);
|
||||
$result .= char($ascii);
|
||||
$result .= chr($ascii);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
@ -54,6 +54,6 @@ class Xor {
|
|||
*/
|
||||
public static function decode(string $raw, string $key) : string
|
||||
{
|
||||
return self::encode($raw, $key)
|
||||
return self::encode($raw, $key);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,25 +30,6 @@ namespace phpOMS\Utils\Parser\Php;
|
|||
*/
|
||||
class ArrayParser
|
||||
{
|
||||
/**
|
||||
* Saving array to file.
|
||||
*
|
||||
* @param string $name Name of new array
|
||||
* @param array $arr Array to parse
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function createFile(string $name, array $arr) : string
|
||||
{
|
||||
$out = '<' . '?php' . PHP_EOL
|
||||
. '$' . $name . ' = ' . self::serializeArray($this->arr) . ';';
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializing array (recursively).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -172,16 +172,16 @@ class ClassParser
|
|||
|
||||
public function addInclude(string $include)
|
||||
{
|
||||
$this->include[] = $include;
|
||||
$this->includes[] = $include;
|
||||
|
||||
array_unique($this->include);
|
||||
array_unique($this->includes);
|
||||
}
|
||||
|
||||
public function addRequire(string $require)
|
||||
{
|
||||
$this->require[] = $require;
|
||||
$this->requires[] = $require;
|
||||
|
||||
array_unique($this->require);
|
||||
array_unique($this->requires);
|
||||
}
|
||||
|
||||
public function addTrait(string $trait, string $as = null)
|
||||
|
|
@ -267,7 +267,7 @@ class ClassParser
|
|||
$class .= PHP_EOL;
|
||||
}
|
||||
|
||||
if ($this->isfinal) {
|
||||
if ($this->isFinal) {
|
||||
$class .= 'final ';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,44 +146,44 @@ class FunctionParser
|
|||
public function parse() : string
|
||||
{
|
||||
$function = '';
|
||||
$member .= str_repeat(' ', ClassParser::INDENT);
|
||||
$function .= str_repeat(' ', ClassParser::INDENT);
|
||||
|
||||
if ($this->isFinal) {
|
||||
$member .= 'final ';
|
||||
$function .= 'final ';
|
||||
}
|
||||
|
||||
if ($this->isAbstract) {
|
||||
$member .= 'abstract ';
|
||||
$function .= 'abstract ';
|
||||
}
|
||||
|
||||
$member .= $this->visibility . ' ';
|
||||
$function .= $this->visibility . ' ';
|
||||
|
||||
if ($this->isStatic) {
|
||||
$member .= 'static ';
|
||||
$function .= 'static ';
|
||||
}
|
||||
|
||||
$member .= 'function ' . $this->name . '(';
|
||||
$function .= 'function ' . $this->name . '(';
|
||||
|
||||
$parameters = '';
|
||||
foreach ($this->parameters as $name => $para) {
|
||||
$parameters = (isset($para['typehint']) ? $para['typehint'] . ' ' : '') . $para['name'] . (array_key_exists('default', $para) ? ' = ' . MemberParser::parseVariable($para['default']) : '') . ', ';
|
||||
}
|
||||
|
||||
$member .= rtrim($parameters, ', ') . ') ';
|
||||
$member .= ($this->return ?? '') . PHP_EOL;
|
||||
$function .= rtrim($parameters, ', ') . ') ';
|
||||
$function .= ($this->return ?? '') . PHP_EOL;
|
||||
|
||||
if (isset($this->body)) {
|
||||
$member .= str_repeat(' ', ClassParser::INDENT) . '{' . PHP_EOL . $this->addIndent($this->body) . PHP_EOL . str_repeat(' ', ClassParser::INDENT) . '}';
|
||||
$function .= str_repeat(' ', ClassParser::INDENT) . '{' . PHP_EOL . $this->addIndent($this->body) . PHP_EOL . str_repeat(' ', ClassParser::INDENT) . '}';
|
||||
} else {
|
||||
$member .= ';';
|
||||
$function .= ';';
|
||||
}
|
||||
|
||||
return $member;
|
||||
return $function;
|
||||
}
|
||||
|
||||
private function addIndent($body) : string
|
||||
private function addIndent(string $body) : string
|
||||
{
|
||||
$body = preg_split('/\r\n|\r|\n/', $this->body);
|
||||
$body = preg_split('/\r\n|\r|\n/', $body);
|
||||
|
||||
foreach ($body as &$line) {
|
||||
$line = str_repeat(' ', ClassParser::INDENT) . $line;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,9 @@ class MemberParser
|
|||
$member .= 'const ';
|
||||
}
|
||||
|
||||
$member .= (!$this->isConst ? '$' : '') . $name . ' = ' . self::parseVariable($this->default) . ';';
|
||||
$member .= (!$this->isConst ? '$' : '') . $this->name . ' = ' . self::parseVariable($this->default) . ';';
|
||||
|
||||
return $member;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use phpOMS\Datatypes\Enum;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class MemberVisibility extends Enum
|
||||
abstract class Visibility extends Enum
|
||||
{
|
||||
const _PUBLIC = 'public';
|
||||
const _PRIVATE = 'private';
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Permutation
|
|||
$newres = $result;
|
||||
$newres[] = $val;
|
||||
unset($newArr[$key]);
|
||||
$permutations += permut($newArr, $newres);
|
||||
$permutations += self::permut($newArr, $newres);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +100,8 @@ class Permutation
|
|||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
|
|
@ -114,8 +116,8 @@ class Permutation
|
|||
}
|
||||
|
||||
$i = 0;
|
||||
for($key as $pos) {
|
||||
$temp = $toPermute[$i]
|
||||
foreach($key as $pos) {
|
||||
$temp = $toPermute[$i];
|
||||
$toPermute[$i] = $toPermute[$pos];
|
||||
$toPermute[$pos] = $temp;
|
||||
$i++;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\Version;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Version class.
|
||||
|
|
|
|||
|
|
@ -348,14 +348,14 @@ class View implements \Serializable
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getArray() : array
|
||||
public function toArray() : array
|
||||
{
|
||||
$viewArray = [];
|
||||
|
||||
$viewArray[] = $this->render();
|
||||
|
||||
foreach($this->views as $key => $view) {
|
||||
$viewArray[$key] = $view->getArray();
|
||||
$viewArray[$key] = $view->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ class View implements \Serializable
|
|||
*/
|
||||
public function unserialize($raw)
|
||||
{
|
||||
|
||||
// todo: implement
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user