mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
Unit test fixes
This commit is contained in:
parent
082a493cc7
commit
a03f6ee047
|
|
@ -29,6 +29,7 @@ use phpOMS\Datatypes\Enum;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
* @todo Should be changed to int instead of string
|
||||||
*/
|
*/
|
||||||
abstract class AssetType extends Enum
|
abstract class AssetType extends Enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,42 @@ class NetPromoterScore {
|
||||||
|
|
||||||
$total = $promoters + $passives + $detractors;
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ abstract class CacheType extends Enum
|
||||||
/* public */ const _STRING = 1; /* Data is string */
|
/* public */ const _STRING = 1; /* Data is string */
|
||||||
/* public */ const _ARRAY = 2; /* Data is array */
|
/* public */ const _ARRAY = 2; /* Data is array */
|
||||||
/* public */ const _SERIALIZABLE = 3; /* Data is object */
|
/* public */ const _SERIALIZABLE = 3; /* Data is object */
|
||||||
/* public */ const _JSONSERIALIZABLE = 6;
|
|
||||||
/* public */ const _FLOAT = 4; /* Data is float */
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ use phpOMS\Datatypes\Enum;
|
||||||
abstract class ResponseType extends Enum
|
abstract class ResponseType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const HTTP = 0; /* HTTP */
|
/* public */ const HTTP = 0; /* HTTP */
|
||||||
/* public */ const JSON = 1; /* JSON */
|
/* public */ const SOCKET = 1; /* Socket */
|
||||||
/* public */ const SOCKET = 2; /* Socket */
|
/* public */ const CONSOLE = 2; /* Console */
|
||||||
/* public */ const CONSOLE = 3; /* Console */
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class Router
|
||||||
*/
|
*/
|
||||||
public function importFromFile(string $path) : bool
|
public function importFromFile(string $path) : bool
|
||||||
{
|
{
|
||||||
if (stream_resolve_include_path($path) !== false) {
|
if (file_exists($path)) {
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$this->routes += include $path;
|
$this->routes += include $path;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class PriorityMode extends Enum
|
abstract class PriorityMode extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const FIFO = 0;
|
/* public */ const FIFO = 1;
|
||||||
/* public */ const LIFO = 0;
|
/* public */ const LIFO = 2;
|
||||||
/* public */ const EARLIEST_DEADLINE = 0;
|
/* public */ const EARLIEST_DEADLINE = 4;
|
||||||
/* public */ const SHORTEST_JOB = 0;
|
/* public */ const SHORTEST_JOB = 8;
|
||||||
/* public */ const HIGHEST = 0;
|
/* public */ const HIGHEST = 16;
|
||||||
/* public */ const LOWEST = 0;
|
/* public */ const LOWEST = 32;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace phpOMS\Utils;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Color
|
class ColorUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,4 +83,15 @@ class Color
|
||||||
|
|
||||||
return $gradient;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +63,7 @@ class Caesar
|
||||||
$ascii = ord($source[$i]) + ord($key[$j]);
|
$ascii = ord($source[$i]) + ord($key[$j]);
|
||||||
|
|
||||||
if ($ascii > self::LIMIT_UPPER) {
|
if ($ascii > self::LIMIT_UPPER) {
|
||||||
$ascii -= self::LIMIT_UPPER;
|
$ascii = self::LIMIT_LOWER + ($ascii - self::LIMIT_UPPER);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= chr($ascii);
|
$result .= chr($ascii);
|
||||||
|
|
@ -89,7 +89,7 @@ class Caesar
|
||||||
$ascii = ord($raw[$i]) - ord($key[$j]);
|
$ascii = ord($raw[$i]) - ord($key[$j]);
|
||||||
|
|
||||||
if ($ascii < self::LIMIT_LOWER) {
|
if ($ascii < self::LIMIT_LOWER) {
|
||||||
$ascii += self::LIMIT_LOWER;
|
$ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= chr($ascii);
|
$result .= chr($ascii);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user