diff --git a/Asset/AssetType.php b/Asset/AssetType.php index 0e54cab85..e6433fa03 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -29,6 +29,7 @@ use phpOMS\Datatypes\Enum; * @license OMS License 1.0 * @link http://orange-management.com * @since 1.0.0 + * @todo Should be changed to int instead of string */ abstract class AssetType extends Enum { diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 2367d9a8b..079aa5a7b 100644 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -88,6 +88,42 @@ class NetPromoterScore { $total = $promoters + $passives + $detractors; - return ((int) ($promoters / $total)) - ((int) ($detractors / $total)); + return $total === 0 ? 0 : ((int) ($promoters * 100 / $total)) - ((int) ($detractors * 100 / $total)); + } + + public function countDetractors() : int + { + $count = 0; + foreach($this->scores as $score) { + if($score < 7) { + $count++; + } + } + + return $count; + } + + public function countPassives() : int + { + $count = 0; + foreach($this->scores as $score) { + if($score > 6 && $score < 9) { + $count++; + } + } + + return $count; + } + + public function countPromoters() : int + { + $count = 0; + foreach($this->scores as $score) { + if($score > 8) { + $count++; + } + } + + return $count; } } \ No newline at end of file diff --git a/DataStorage/Cache/CacheType.php b/DataStorage/Cache/CacheType.php index bac55635d..9b9b0b108 100644 --- a/DataStorage/Cache/CacheType.php +++ b/DataStorage/Cache/CacheType.php @@ -38,7 +38,7 @@ abstract class CacheType extends Enum /* public */ const _STRING = 1; /* Data is string */ /* public */ const _ARRAY = 2; /* Data is array */ /* public */ const _SERIALIZABLE = 3; /* Data is object */ - /* public */ const _JSONSERIALIZABLE = 6; /* public */ const _FLOAT = 4; /* Data is float */ - /* public */ const _BOOL = 5; /* Data is float */ + /* public */ const _BOOL = 5; /* Data is bool */ + /* public */ const _JSONSERIALIZABLE = 6; } diff --git a/Message/ResponseType.php b/Message/ResponseType.php index d1091b6dc..415b41a14 100644 --- a/Message/ResponseType.php +++ b/Message/ResponseType.php @@ -33,7 +33,6 @@ use phpOMS\Datatypes\Enum; abstract class ResponseType extends Enum { /* public */ const HTTP = 0; /* HTTP */ - /* public */ const JSON = 1; /* JSON */ - /* public */ const SOCKET = 2; /* Socket */ - /* public */ const CONSOLE = 3; /* Console */ + /* public */ const SOCKET = 1; /* Socket */ + /* public */ const CONSOLE = 2; /* Console */ } diff --git a/Router/Router.php b/Router/Router.php index 45e5c031a..324875181 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -63,7 +63,7 @@ class Router */ public function importFromFile(string $path) : bool { - if (stream_resolve_include_path($path) !== false) { + if (file_exists($path)) { /** @noinspection PhpIncludeInspection */ $this->routes += include $path; diff --git a/Stdlib/Queue/PriorityMode.php b/Stdlib/Queue/PriorityMode.php index f1b28208f..8f2274d01 100644 --- a/Stdlib/Queue/PriorityMode.php +++ b/Stdlib/Queue/PriorityMode.php @@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum; */ abstract class PriorityMode extends Enum { - /* public */ const FIFO = 0; - /* public */ const LIFO = 0; - /* public */ const EARLIEST_DEADLINE = 0; - /* public */ const SHORTEST_JOB = 0; - /* public */ const HIGHEST = 0; - /* public */ const LOWEST = 0; + /* public */ const FIFO = 1; + /* public */ const LIFO = 2; + /* public */ const EARLIEST_DEADLINE = 4; + /* public */ const SHORTEST_JOB = 8; + /* public */ const HIGHEST = 16; + /* public */ const LOWEST = 32; } diff --git a/Utils/Color.php b/Utils/ColorUtils.php similarity index 89% rename from Utils/Color.php rename to Utils/ColorUtils.php index 84be837b3..654434161 100644 --- a/Utils/Color.php +++ b/Utils/ColorUtils.php @@ -28,7 +28,7 @@ namespace phpOMS\Utils; * @link http://orange-management.com * @since 1.0.0 */ -class Color +class ColorUtils { /** @@ -83,4 +83,15 @@ class Color return $gradient; } + + public static function intToRgb(int $rgbInt) : array + { + $rgb = []; + + $rgb['b'] = $rgbInt & 255; + $rgb['g'] = ($rgbInt >> 8) & 255; + $rgb['r'] = ($rgbInt >> 16) & 255; + + return $rgb; + } } diff --git a/Utils/Encoding/Caesar.php b/Utils/Encoding/Caesar.php index b88064384..9576a6e6e 100644 --- a/Utils/Encoding/Caesar.php +++ b/Utils/Encoding/Caesar.php @@ -63,7 +63,7 @@ class Caesar $ascii = ord($source[$i]) + ord($key[$j]); if ($ascii > self::LIMIT_UPPER) { - $ascii -= self::LIMIT_UPPER; + $ascii = self::LIMIT_LOWER + ($ascii - self::LIMIT_UPPER); } $result .= chr($ascii); @@ -89,7 +89,7 @@ class Caesar $ascii = ord($raw[$i]) - ord($key[$j]); if ($ascii < self::LIMIT_LOWER) { - $ascii += self::LIMIT_LOWER; + $ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ; } $result .= chr($ascii);