mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
cs fixes
This commit is contained in:
parent
f09df7ea16
commit
3938f56f88
|
|
@ -147,6 +147,21 @@ class Account implements \JsonSerializable
|
|||
|
||||
use PermissionHandlingTrait;
|
||||
|
||||
/**
|
||||
* Has permission.
|
||||
*
|
||||
* @param int $permission Permission
|
||||
* @param int|null $unit Unit
|
||||
* @param int|null $app App
|
||||
* @param string|null $module Module
|
||||
* @param int|null $category Category
|
||||
* @param int|null $element Element
|
||||
* @param int|null $component Component
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasPermission(
|
||||
int $permission,
|
||||
int $unit = null,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ final class Nominatim
|
|||
\usleep((int) (1000000 - ($time - self::$lastRun) + 100));
|
||||
}
|
||||
|
||||
$body = Rest::request($request)->getBody();
|
||||
$body = Rest::request($request)->getBody();
|
||||
$result['body'] = $body;
|
||||
|
||||
/** @var array $json */
|
||||
|
|
|
|||
|
|
@ -426,8 +426,8 @@ class DataMapperFactory
|
|||
/**
|
||||
* Get id of object
|
||||
*
|
||||
* @param object $obj Model to create
|
||||
* @param string $member Member name for the id, if it is not the primary key
|
||||
* @param object $obj Model to create
|
||||
* @param string $member Member name for the id, if it is not the primary key
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
|
|
|
|||
|
|
@ -570,9 +570,9 @@ final class ReadMapper extends DataMapperAbstract
|
|||
$path = \explode('/', \ltrim($def['internal'], '/'));
|
||||
$member = $path[0];
|
||||
|
||||
$refProp = $refClass->getProperty($path[0]);
|
||||
$refProp = $refClass->getProperty($path[0]);
|
||||
$isPublic = $refProp->isPublic();
|
||||
$aValue = $isPublic ? $obj->{$path[0]} : $refProp->getValue($obj);
|
||||
$aValue = $isPublic ? $obj->{$path[0]} : $refProp->getValue($obj);
|
||||
|
||||
\array_shift($path);
|
||||
$arrayPath = \implode('/', $path);
|
||||
|
|
@ -683,7 +683,7 @@ final class ReadMapper extends DataMapperAbstract
|
|||
$arrayPath = \implode('/', $path);
|
||||
$aValue = $isPublic ? $obj->{$path[0]} : $refProp->getValue($obj);
|
||||
} else {
|
||||
$refProp = $refClass->getProperty($member);
|
||||
$refProp = $refClass->getProperty($member);
|
||||
$isPublic = $refProp->isPublic();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,9 +91,16 @@ final class Money extends FloatInt
|
|||
return $this->symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Money from FloatInt.
|
||||
*
|
||||
* @param FloatInt $value FloatInt value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromFloatInt(FloatInt $value) : self
|
||||
{
|
||||
$money = new self();
|
||||
$money = new self();
|
||||
$money->value = $value->value;
|
||||
|
||||
return $money;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ final class HttpHeader extends HeaderAbstract
|
|||
*/
|
||||
public int $status = RequestStatusCode::R_200;
|
||||
|
||||
/**
|
||||
* Init header from current request.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function initCurrentRequest() : void
|
||||
{
|
||||
$this->header = self::getAllHeaders();
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ final class Rest
|
|||
$response->header->set('', $line = \trim($header[0]));
|
||||
|
||||
if (\stripos(\strtoupper($line), 'HTTP/') === 0) {
|
||||
$statusCode = \explode(' ', $line, 3);
|
||||
$statusCode = \explode(' ', $line, 3);
|
||||
$response->header->status = (int) $statusCode[1];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -354,6 +354,15 @@ abstract class RequestAbstract implements MessageInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create from data array
|
||||
*
|
||||
* @param array $data Data array
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function fromData(array $data) : void
|
||||
{
|
||||
$this->data = $data;
|
||||
|
|
|
|||
|
|
@ -228,6 +228,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model create response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardCreateResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -243,6 +254,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model update response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardUpdateResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -258,6 +280,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model delete response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardDeleteResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -273,6 +306,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model remove response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardRemoveResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -288,6 +332,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model return response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardReturnResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -303,6 +358,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create standard model relation add response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createStandardAddResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -318,6 +384,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model create response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidCreateResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -333,6 +410,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model update response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidUpdateResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -348,6 +436,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model delete response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidDeleteResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -363,6 +462,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model relation remove response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidRemoveResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -378,6 +488,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model return response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidReturnResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -393,6 +514,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model relation create response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidAddResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
@ -408,6 +540,17 @@ abstract class ModuleAbstract
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create invalid model permission response.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $obj Response object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createInvalidPermissionResponse(
|
||||
RequestAbstract $request,
|
||||
ResponseAbstract $response,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,17 @@ final class EncryptionHelper
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt a file with a shared key
|
||||
*
|
||||
* @param string $in File to encrypt
|
||||
* @param string $out Encrypted file
|
||||
* @param string $keyHex Shared key as hex string used for encryption
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function encryptFile(string $in, string $out, string $keyHex) : bool
|
||||
{
|
||||
$fpSource = \fopen($in, 'rb');
|
||||
|
|
@ -77,13 +88,13 @@ final class EncryptionHelper
|
|||
return false;
|
||||
}
|
||||
|
||||
$secretKey = \sodium_hex2bin($keyHex);
|
||||
$nonce = \random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
$secretKey = \sodium_hex2bin($keyHex);
|
||||
$nonce = \random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
|
||||
\fwrite($fpEncoded, $nonce);
|
||||
|
||||
while (!\feof($fpSource)) {
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
$ciphertext = \sodium_crypto_secretbox($buffer, $nonce, $secretKey);
|
||||
|
||||
fwrite($fpEncoded, $ciphertext);
|
||||
|
|
@ -155,7 +166,7 @@ final class EncryptionHelper
|
|||
}
|
||||
|
||||
$secretKey = \sodium_hex2bin($keyHex);
|
||||
$nonce = \fread($fpSource, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
$nonce = \fread($fpSource, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
|
||||
while (!\feof($fpSource)) {
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
|
|
|
|||
|
|
@ -1203,7 +1203,7 @@ class Graph
|
|||
$colors[$node->getId()] = 0;
|
||||
}
|
||||
|
||||
$node1 = \reset($this->nodes);
|
||||
$node1 = \reset($this->nodes);
|
||||
$colors[$node1->getId()] = 1;
|
||||
|
||||
$stack = [$node1];
|
||||
|
|
|
|||
|
|
@ -2167,7 +2167,7 @@ class QR extends TwoDAbstract
|
|||
|
||||
for ($i = 0; $i < $bits; ++$i) {
|
||||
$bstream[$i] = (($num & $mask) !== 0) ? 1 : 0;
|
||||
$mask >>= 1;
|
||||
$mask >>= 1;
|
||||
}
|
||||
|
||||
return $bstream;
|
||||
|
|
@ -2190,7 +2190,7 @@ class QR extends TwoDAbstract
|
|||
|
||||
for ($j = 0; $j < 8; ++$j) {
|
||||
$bstream[$p] = (($data[$i] & $mask) !== 0) ? 1 : 0;
|
||||
$mask >>= 1;
|
||||
$mask >>= 1;
|
||||
|
||||
++$p;
|
||||
}
|
||||
|
|
@ -2278,7 +2278,7 @@ class QR extends TwoDAbstract
|
|||
|
||||
for ($j = 0; $j < 8; ++$j) {
|
||||
$v <<= 1;
|
||||
$v |= $bstream[$p];
|
||||
$v |= $bstream[$p];
|
||||
++$p;
|
||||
}
|
||||
|
||||
|
|
@ -2290,7 +2290,7 @@ class QR extends TwoDAbstract
|
|||
|
||||
for ($j = 0; $j < ($size & 7); ++$j) {
|
||||
$v <<= 1;
|
||||
$v |= $bstream[$p];
|
||||
$v |= $bstream[$p];
|
||||
++$p;
|
||||
}
|
||||
|
||||
|
|
@ -2579,7 +2579,7 @@ class QR extends TwoDAbstract
|
|||
for ($x = 0; $x<6; ++$x) {
|
||||
for ($y = 0; $y<3; ++$y) {
|
||||
$frame[($width - 11)+$y][$x] = \chr(0x88 | ($v & 1));
|
||||
$v >>= 1;
|
||||
$v >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2587,7 +2587,7 @@ class QR extends TwoDAbstract
|
|||
for ($y = 0; $y < 6; ++$y) {
|
||||
for ($x = 0; $x < 3; ++$x) {
|
||||
$frame[$y][$x + ($width - 11)] = \chr(0x88 | ($v & 1));
|
||||
$v >>= 1;
|
||||
$v >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ final class Currency
|
|||
if ((!isset($currencies[$from]) && $from !== ISO4217CharEnum::_EUR)
|
||||
|| (!isset($currencies[$to]) && $to !== ISO4217CharEnum::_EUR)
|
||||
) {
|
||||
return -1.0;
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
if ($from !== ISO4217CharEnum::_EUR) {
|
||||
|
|
|
|||
|
|
@ -340,6 +340,20 @@ final class ImageUtils
|
|||
return $difference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the average color of an image at a specific position
|
||||
*
|
||||
* @param resource $src Image resource
|
||||
* @param int $x X position
|
||||
* @param int $y Y position
|
||||
* @param int $width Image width
|
||||
* @param int $height Image height
|
||||
* @param int $area Area to calculate average color
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function getAverageColor($src, $x, $y, $width, $height, $area = 10) : int
|
||||
{
|
||||
$colors = [];
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ final class NumericUtils
|
|||
public static function uRightShift(int $a, int $b) : int
|
||||
{
|
||||
if ($b >= 32 || $b < -32) {
|
||||
$m = (int) ($b / 32);
|
||||
$m = (int) ($b / 32);
|
||||
$b -= $m * 32;
|
||||
}
|
||||
|
||||
|
|
@ -61,8 +61,8 @@ final class NumericUtils
|
|||
|
||||
if ($a < 0) {
|
||||
$a >>= 1;
|
||||
$a &= 0x7fffffff;
|
||||
$a |= 0x40000000;
|
||||
$a &= 0x7fffffff;
|
||||
$a |= 0x40000000;
|
||||
$a >>= $b - 1;
|
||||
} else {
|
||||
$a >>= $b;
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ class Text
|
|||
}
|
||||
|
||||
/* Handle comma */
|
||||
$posComma = [];
|
||||
$posComma = [];
|
||||
|
||||
if (\mt_rand(0, 100) <= $probComma * 100 && $sentenceLength >= 2 * $minCommaSpacing) {
|
||||
$posComma[] = \mt_rand($minCommaSpacing, $sentenceLength - $minCommaSpacing);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user