Merge pull request #143 from Orange-Management/develop

Develop
This commit is contained in:
Dennis Eichhorn 2017-10-26 19:27:56 +02:00 committed by GitHub
commit eede030e76
20 changed files with 70 additions and 262 deletions

View File

@ -28,8 +28,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class AccountStatus extends Enum
{
/* public */ const ACTIVE = 1;
/* public */ const INACTIVE = 2;
/* public */ const TIMEOUT = 3;
/* public */ const BANNED = 4;
/* public */ const ACTIVE = 1;
/* public */ const INACTIVE = 2;
/* public */ const TIMEOUT = 3;
/* public */ const BANNED = 4;
}

View File

@ -28,6 +28,6 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class AccountType extends Enum
{
/* public */ const USER = 0;
/* public */ const GROUP = 1;
/* public */ const USER = 0;
/* public */ const GROUP = 1;
}

View File

@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class GroupStatus extends Enum
{
/* public */ const ACTIVE = 1;
/* public */ const INACTIVE = 2;
/* public */ const HIDDEN = 4;
/* public */ const ACTIVE = 1;
/* public */ const INACTIVE = 2;
/* public */ const HIDDEN = 4;
}

View File

@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class AssetType extends Enum
{
/* public */ const CSS = 0;
/* public */ const JS = 1;
/* public */ const JSLATE = 2;
/* public */ const CSS = 0;
/* public */ const JS = 1;
/* public */ const JSLATE = 2;
}

View File

@ -89,7 +89,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
/**
* Database grammar.
*
* @var Grammar
* @var SchemaGrammar
* @since 1.0.0
*/
protected $schemaGrammar = null;

View File

@ -269,8 +269,6 @@ class DataMapperAbstract implements DataMapperInterface
// todo: how to handle with of parent objects/extends/relations
self::$fields = $objects;
//return __CLASS__;
}
/**

View File

@ -15,6 +15,6 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
class GrammarInterface
interface GrammarInterface
{
}

View File

@ -138,7 +138,8 @@ class Polygon implements D2ShapeInterface
* @param array $polygon Polygon definition
*
* @return int
*
*
* @link http://erich.realtimerendering.com/ptinpoly/
* @since 1.0.0
*/
public static function isPointInPolygon(array $point, array $polygon) : int

View File

@ -84,6 +84,8 @@ class LUDecomposition
public function getL()
{
$L = [[]];
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i > $j) {
@ -104,6 +106,8 @@ class LUDecomposition
public function getU()
{
$U = [[]];
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i <= $j) {
@ -154,8 +158,6 @@ class LUDecomposition
if (!$this->isNonsingular()) {
}
var_dump($this->piv);
$nx = $B->getM();
$X = $B->getMatrix($this->piv, 0, $nx-1);

View File

@ -81,6 +81,8 @@ class QRDecomposition
public function getH()
{
$H = [[]];
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i >= $j) {
@ -99,6 +101,8 @@ class QRDecomposition
public function getR()
{
$R = [[]];
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i < $j) {
@ -119,10 +123,13 @@ class QRDecomposition
public function getQ()
{
$Q = [[]];
for ($k = $this->n-1; $k >= 0; --$k) {
for ($i = 0; $i < $this->m; ++$i) {
$Q[$i][$k] = 0.0;
}
}
$Q[$k][$k] = 1.0;
for ($j = $k; $j < $this->n; ++$j) {
if ($this->QR[$k][$k] != 0) {

View File

@ -1,222 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace phpOMS\Math\Optimization\Graph;
use phpOMS\Stdlib\Map\KeyType;
use phpOMS\Stdlib\Map\MultiMap;
use phpOMS\Stdlib\Map\OrderType;
/**
* Graph class
*
* @category Framework
* @package phpOMS\Asset
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Graph
{
/**
* Vertices.
*
* @var VerticeInterface[]
* @since 1.0.0
*/
private $vertices = [];
/**
* Edge.
*
* @var EdgeInterface[]
* @since 1.0.0
*/
private $edges = null;
/**
* Constructor
*
* @since 1.0.0
*/
public function __construct()
{
$this->edges = new MultiMap(KeyType::MULTIPLE, OrderType::LOOSE);
}
/**
* Add vertice to graph.
*
* @param VerticeInterface $vertice Vertice
*
* @return bool
*
* @since 1.0.0
*/
public function addVertice(VerticeInterface $vertice) : bool
{
if (!isset($this->vertices[$vertice->getId()])) {
$this->vertices[$vertice->getId()] = $vertice;
return true;
}
return false;
}
/**
* Add edge to graph.
*
* @param EdgeInterface $edge Edge
*
* @return bool
*
* @since 1.0.0
*/
public function addEdge(EdgeInterface $edge) : bool
{
if (!isset($this->edges[$edge->getId()])) {
$this->edges[$edge->getId()] = $edge;
return true;
}
return false;
}
/**
* Remove vertice from graph.
*
* @param mixed $id Id of vertice to remove
*
* @return bool
*
* @since 1.0.0
*/
public function removeVertice($id) : bool
{
if (isset($this->vertices[$id])) {
unset($this->vertices[$id]);
return true;
}
return false;
}
/**
* Remove edge by nodes from graph.
*
* @param mixed $a First node of edge
* @param mixed $b Second node of edge
*
* @return bool
*
* @since 1.0.0
*/
public function removeEdge($a, $b) : bool
{
return $this->edges->remove([$a, $b]);
}
/**
* Remove edge from graph.
*
* @param mixed $id Id of edge to remove
*
* @return bool
*
* @since 1.0.0
*/
public function removeEdgeById($id) : bool
{
if (isset($this->edges[$id])) {
unset($this->edges[$id]);
return true;
}
return false;
}
/**
* Get vertice.
*
* @param mixed $id Id of vertice
*
* @return VerticeInterface
*
* @since 1.0.0
*/
public function getVertice($id) : VerticeInterface
{
return $this->vertices[$id] ?? new NullVertice();
}
/**
* Get edge by nodes.
*
* Order of nodes is irrelevant
*
* @param mixed $a First node of edge
* @param mixed $b Second node of edge
*
* @return EdgeInterface
*
* @since 1.0.0
*/
public function getEdge($a, $b) : EdgeInterface
{
return $this->edges->get([$a, $b]) ?? new NullEdge();
}
/**
* Get edge by id.
*
* @param int $id Edge id
*
* @return EdgeInterface
*
* @since 1.0.0
*/
public function getEdgeById(int $id) : EdgeInterface
{
return $this->edges->get($id) ?? new NullEdge();
}
/**
* Count vertices.
*
* @return int
*
* @since 1.0.0
*/
public function countVertices() : int
{
return count($this->vertices);
}
/**
* Count edges.
*
* @return int
*
* @since 1.0.0
*/
public function countEdges() : int
{
return count($this->edges);
}
}

View File

@ -52,11 +52,11 @@ class Average
*
* @since 1.0.0
*/
public static function averageChange(array $x, int $h = 1) : float
public static function averageDatasetChange(array $x, int $h = 1) : float
{
$count = count($x);
return $x[$count - 1] + $h * ($x[$count - 1] - $x[0]) / ($count - 1);
return $h * ($x[$count - 1] - $x[0]) / ($count - 1);
}
/**

View File

@ -47,7 +47,7 @@ class MeasureOfDispersion
$end = end($values);
$start = reset($values);
return $start - $end;
return $end - $start;
}
/**

View File

@ -147,6 +147,12 @@ class Response extends ResponseAbstract implements RenderableInterface
return trim(preg_replace('/(\s{2,}|\n)(?![^<>]*<\/pre>)/', ' ', $render);
}
$types = $this->header->get('Content-Type');
if(stripos($types[0], MimeType::M_HTML) !== false) {
return trim(preg_replace('/(\s{2,}|\n|\t)(?![^<>]*<\/pre>)/', ' ', $render));
}
return $render;
}

View File

@ -99,7 +99,7 @@ class InfoManager
*/
public function update() /* : void */
{
if (!file_exists($this->path)) {
if (!file_exists($this->path)) {
throw new PathException((string) $this->path);
}

View File

@ -419,13 +419,13 @@ class ModuleManager
public function reInit(string $module) : bool
{
$info = $this->loadInfo($module);
/** @var $class InstallerAbstract */
$class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer';
if (!Autoloader::exists($class)) {
throw new InvalidModuleException($info->getDirectory());
}
/** @var $class InstallerAbstract */
$class::reInit($this->modulePath, $info);
}
@ -511,13 +511,13 @@ class ModuleManager
*/
private function installModule(InfoManager $info) /* : void */
{
/** @var $class InstallerAbstract */
$class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer';
if (!Autoloader::exists($class)) {
throw new InvalidModuleException($info->getDirectory());
}
/** @var $class InstallerAbstract */
$class::install($this->modulePath, $this->app->dbPool, $info);
}

View File

@ -30,8 +30,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class SystemType extends Enum
{
/* public */ const UNKNOWN = 1;
/* public */ const WIN = 2;
/* public */ const LINUX = 3;
/* public */ const OSX = 4;
/* public */ const UNKNOWN = 1;
/* public */ const WIN = 2;
/* public */ const LINUX = 3;
/* public */ const OSX = 4;
}

View File

@ -79,9 +79,7 @@ class SystemUtils
{
$memusage = 0;
if (stristr(PHP_OS, 'WIN')) {
} elseif (stristr(PHP_OS, 'LINUX')) {
if (stristr(PHP_OS, 'LINUX')) {
$free = shell_exec('free');
$free = (string) trim($free);
$free_arr = explode("\n", $free);

View File

@ -74,7 +74,7 @@ class ArrayUtils
}
/**
* Check if needle exists in multidimensional array.
* Set element in array by path
*
* @param string $path Path to element
* @param array $data Array
@ -112,6 +112,29 @@ class ArrayUtils
return $data;
}
/**
* Get element of array by path
*
* @param string $path Path to element
* @param array $data Array
* @param string $delim Delimiter for path
*
* @return mixed
*
* @since 1.0.0
*/
public static function getArray(string $path, array $data, string $delim = '/')
{
$pathParts = explode($delim, trim($path, $delim));
$current = $data;
foreach ($pathParts as $key) {
$current = $current[$key];
}
return $current;
}
/**
* Check if needle exists in multidimensional array.
*

View File

@ -91,12 +91,7 @@ class JobQueue
fclose(STDOUT);
fclose(STDERR);
function shutdown()
{
posix_kill(posix_getpid(), SIGHUP);
}
register_shutdown_function('shutdown');
register_shutdown_function(function() { posix_kill(posix_getpid(), SIGHUP); });
}
public function setRunning(bool $run = true) /* : void */