mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-21 05:48:41 +00:00
Quick backup before crash
This commit is contained in:
parent
f1a2c81aeb
commit
1da071f202
|
|
@ -41,7 +41,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $unit = null;
|
||||
public ?int $unit = null;
|
||||
|
||||
/**
|
||||
* App name.
|
||||
|
|
@ -49,7 +49,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $app = null;
|
||||
public ?int $app = null;
|
||||
|
||||
/**
|
||||
* Module id.
|
||||
|
|
@ -57,7 +57,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?string $module = null;
|
||||
public ?string $module = null;
|
||||
|
||||
/**
|
||||
* Providing module id.
|
||||
|
|
@ -65,7 +65,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?string $from = null;
|
||||
public ?string $from = null;
|
||||
|
||||
/**
|
||||
* Type.
|
||||
|
|
@ -73,7 +73,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $category = null;
|
||||
public ?int $category = null;
|
||||
|
||||
/**
|
||||
* Element id.
|
||||
|
|
@ -81,7 +81,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $element = null;
|
||||
public ?int $element = null;
|
||||
|
||||
/**
|
||||
* Component id.
|
||||
|
|
@ -89,7 +89,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $component = null;
|
||||
public ?int $component = null;
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -97,7 +97,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $hasRead = false;
|
||||
public bool $hasRead = false;
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -105,7 +105,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $hasModify = false;
|
||||
public bool $hasModify = false;
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -113,7 +113,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $hasCreate = false;
|
||||
public bool $hasCreate = false;
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -121,7 +121,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $hasDelete = false;
|
||||
public bool $hasDelete = false;
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -129,7 +129,7 @@ class PermissionAbstract implements \JsonSerializable
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $hasPermission = false;
|
||||
public bool $hasPermission = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -170,200 +170,6 @@ class PermissionAbstract implements \JsonSerializable
|
|||
$this->hasPermission = ($permission & PermissionType::PERMISSION) === PermissionType::PERMISSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission id.
|
||||
*
|
||||
* @return int Retunrs the id of the permission
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unit id.
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getUnit() : ?int
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set unit id.
|
||||
*
|
||||
* @param null|int $unit Unit
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setUnit(int $unit = null) : void
|
||||
{
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app name.
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getApp() : ?int
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set app name.
|
||||
*
|
||||
* @param int $app App name
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setApp(int $app = null) : void
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module id.
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getModule() : ?string
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set module id.
|
||||
*
|
||||
* @param string $module Module
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setModule(string $module = null) : void
|
||||
{
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get providing module id.
|
||||
*
|
||||
* @return null|string Returns the module responsible for setting this permission
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFrom() : ?string
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set providing module id.
|
||||
*
|
||||
* @param null|string $from Providing module
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFrom(string $from = null) : void
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category.
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCategory() : ?int
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set category.
|
||||
*
|
||||
* @param int $category Category
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCategory(int $category = null) : void
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element id.
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getElement() : ?int
|
||||
{
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set element id.
|
||||
*
|
||||
* @param int $element Element id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setElement(int $element = null) : void
|
||||
{
|
||||
$this->element = $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get component id.
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getComponent() : ?int
|
||||
{
|
||||
return $this->component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set component id.
|
||||
*
|
||||
* @param int $component Component
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setComponent(int $component = null) : void
|
||||
{
|
||||
$this->component = $component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission
|
||||
*
|
||||
|
|
@ -508,12 +314,12 @@ class PermissionAbstract implements \JsonSerializable
|
|||
*/
|
||||
public function isEqual(self $permission) : bool
|
||||
{
|
||||
return $this->unit === $permission->getUnit()
|
||||
&& $this->app === $permission->getApp()
|
||||
&& $this->module === $permission->getModule()
|
||||
&& $this->category === $permission->getCategory()
|
||||
&& $this->element === $permission->getElement()
|
||||
&& $this->component === $permission->getComponent()
|
||||
return $this->unit === $permission->unit
|
||||
&& $this->app === $permission->app
|
||||
&& $this->module === $permission->module
|
||||
&& $this->category === $permission->category
|
||||
&& $this->element === $permission->element
|
||||
&& $this->component === $permission->component
|
||||
&& $this->getPermission() === $permission->getPermission();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,39 @@ namespace phpOMS\Api\CreditRating;
|
|||
*/
|
||||
interface CreditRatingInterface
|
||||
{
|
||||
/**
|
||||
* Authenticate with the API
|
||||
*
|
||||
* @param string $username Username
|
||||
* @param string $password Password
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function auth(string $username, string $password) : string;
|
||||
|
||||
/**
|
||||
* Find companies matching search parameters
|
||||
*
|
||||
* @param string $token API token
|
||||
* @param string $name Company name
|
||||
* @param string $address Company address
|
||||
* @param string $street Company street
|
||||
* @param string $city Company city
|
||||
* @param string $postal Company postal
|
||||
* @param string $province Company province
|
||||
* @param string $phoneNo Company phone number
|
||||
* @param string $houseNo Company house number
|
||||
* @param string $vatNo Company VAT number
|
||||
* @param string $localRegistrationNo Company registration number
|
||||
* @param array $countries countries to search in
|
||||
* @param int $threshold Match threshold
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function findCompanies(
|
||||
string $token,
|
||||
string $name = '',
|
||||
|
|
@ -39,11 +70,47 @@ interface CreditRatingInterface
|
|||
string $vatNo = '',
|
||||
string $localRegistrationNo = '',
|
||||
array $countries = [],
|
||||
int $threashold = 900,
|
||||
int $threshold = 900,
|
||||
) : array;
|
||||
|
||||
/**
|
||||
* Get credit report of company
|
||||
*
|
||||
* @param string $token API token
|
||||
* @param string $id Company id
|
||||
* @param string $template Report type
|
||||
* @param string $language Report language
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function creditReport(string $token, string $id, string $template = 'full', string $language = 'en') : array;
|
||||
|
||||
/**
|
||||
* Find companies matching search parameters if they couldn't be found in the database
|
||||
*
|
||||
* @param string $token API token
|
||||
* @param string $ownName Name of the person requesting the company
|
||||
* @param string $ownCompanyName Own company name
|
||||
* @param string $ownCompanyRegistrationNo Owm company registration number
|
||||
* @param string $ownEmail Email of the person requestion the company
|
||||
* @param string $name Company name
|
||||
* @param string $address Company address
|
||||
* @param string $street Company street
|
||||
* @param string $city Company city
|
||||
* @param string $postal Company postal
|
||||
* @param string $province Company province
|
||||
* @param string $phoneNo Company phone number
|
||||
* @param string $houseNo Company house number
|
||||
* @param string $vatNo Company VAT number
|
||||
* @param string $localRegistrationNo Company registration number
|
||||
* @param string $country Company country
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function investigate(
|
||||
string $token,
|
||||
string $ownName = '',
|
||||
|
|
@ -63,7 +130,27 @@ interface CreditRatingInterface
|
|||
string $country = ''
|
||||
) : string;
|
||||
|
||||
/**
|
||||
* Get investigations
|
||||
*
|
||||
* @param string $token API token
|
||||
* @param \DateTime $start Investitions requested from this starting date
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function showInvestigations(string $token, \DateTime $start) : array;
|
||||
|
||||
/**
|
||||
* Get the status/result of a investigation
|
||||
*
|
||||
* @param string $token API token
|
||||
* @param string $id Investigation ID
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getInvestigation(string $token, string $id) : array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,18 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class CreditSafe implements CreditRatingInterface
|
||||
{
|
||||
/**
|
||||
* CreditSafe API link
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const API_URL = 'https://connect.creditsafe.com/v1';
|
||||
//public const API_URL = 'https://connect.sandbox.creditsafe.com/v1';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function auth(string $username, string $password) : string
|
||||
{
|
||||
$url = '/authenticate';
|
||||
|
|
@ -46,6 +55,9 @@ final class CreditSafe implements CreditRatingInterface
|
|||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findCompanies(
|
||||
string $token,
|
||||
string $name = '',
|
||||
|
|
@ -59,11 +71,11 @@ final class CreditSafe implements CreditRatingInterface
|
|||
string $vatNo = '',
|
||||
string $localRegistrationNo = '',
|
||||
array $countries = [],
|
||||
int $threashold = 0,
|
||||
int $threshold = 0,
|
||||
) : array
|
||||
{
|
||||
$url = '/companies';
|
||||
if ($threashold > 0) {
|
||||
if ($threshold > 0) {
|
||||
$url .= '/matches';
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +88,8 @@ final class CreditSafe implements CreditRatingInterface
|
|||
$request->setData('pageSize', 100);
|
||||
$request->setData('language', 'en');
|
||||
|
||||
if ($threashold > 0) {
|
||||
$request->setData('matchThreshold', $threashold);
|
||||
if ($threshold > 0) {
|
||||
$request->setData('matchThreshold', $threshold);
|
||||
$request->setData('country', \implode(',', $countries));
|
||||
} else {
|
||||
$request->setData('countries', empty($countries) ? 'PLC' : \implode(',', $countries));
|
||||
|
|
@ -128,6 +140,9 @@ final class CreditSafe implements CreditRatingInterface
|
|||
return $response->get('companies') ?? ($response->get('matchedCompanies') ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function creditReport(string $token, string $id, string $template = 'full', string $language = 'en') : array
|
||||
{
|
||||
$url = '/companies/' . $id;
|
||||
|
|
@ -146,6 +161,9 @@ final class CreditSafe implements CreditRatingInterface
|
|||
return $response->get('report') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function investigate(
|
||||
string $token,
|
||||
string $ownName = '',
|
||||
|
|
@ -197,6 +215,9 @@ final class CreditSafe implements CreditRatingInterface
|
|||
return $response->get('orderID') ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function showInvestigations(string $token, \DateTime $start) : array
|
||||
{
|
||||
$url = '/freshinvestigations';
|
||||
|
|
@ -215,6 +236,9 @@ final class CreditSafe implements CreditRatingInterface
|
|||
return $response->get('orders') ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getInvestigation(string $token, string $id) : array
|
||||
{
|
||||
$url = '/freshinvestigations/' . $id;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ final class EUVATVies implements EUVATInterface
|
|||
if ($otherStreet === '') {
|
||||
$result['address'] = 'D';
|
||||
} elseif (\stripos($result['address'], $otherStreet) !== false
|
||||
&& \levenshtein($otherStreet, $result['address'], insertion_cost: 0) / \strlen($result['address']) < 0.2
|
||||
&& \levenshtein($otherStreet, $result['address'], 0) / \strlen($result['address']) < 0.2
|
||||
) {
|
||||
$result['address'] = 'A';
|
||||
} elseif ($result['address'] === '') {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,16 @@ class Grammar extends GrammarAbstract
|
|||
return ($query->distinct ? 'SELECT DISTINCT ' : 'SELECT ') . $expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get random entry
|
||||
*
|
||||
* @param Builder $query Builder
|
||||
* @param array $columns Columns
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function compileRandom(Builder $query, array $columns) : string
|
||||
{
|
||||
return '';
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ final class HttpSession implements SessionInterface
|
|||
* @var array<string, mixed>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $sessionData = [];
|
||||
public array $data = [];
|
||||
|
||||
/**
|
||||
* Session ID.
|
||||
|
|
@ -52,7 +52,7 @@ final class HttpSession implements SessionInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $sid;
|
||||
public string $sid;
|
||||
|
||||
/**
|
||||
* Inactivity Interval.
|
||||
|
|
@ -60,7 +60,7 @@ final class HttpSession implements SessionInterface
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $inactivityInterval = 0;
|
||||
public int $inactivityInterval = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -114,10 +114,10 @@ final class HttpSession implements SessionInterface
|
|||
$this->destroy(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$this->sessionData = $_SESSION ?? [];
|
||||
$_SESSION = null;
|
||||
$this->sessionData['lastActivity'] = \time();
|
||||
$this->sid = (string) \session_id();
|
||||
$this->data = $_SESSION ?? [];
|
||||
$_SESSION = null;
|
||||
$this->data['lastActivity'] = \time();
|
||||
$this->sid = (string) \session_id();
|
||||
|
||||
$this->setCsrfProtection();
|
||||
}
|
||||
|
|
@ -146,8 +146,8 @@ final class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function set(string $key, mixed $value, bool $overwrite = false) : bool
|
||||
{
|
||||
if (!$this->isLocked && ($overwrite || !isset($this->sessionData[$key]))) {
|
||||
$this->sessionData[$key] = $value;
|
||||
if (!$this->isLocked && ($overwrite || !isset($this->data[$key]))) {
|
||||
$this->data[$key] = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ final class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function get(string $key) : mixed
|
||||
{
|
||||
return $this->sessionData[$key] ?? null;
|
||||
return $this->data[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -192,7 +192,7 @@ final class HttpSession implements SessionInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
$_SESSION = $this->sessionData;
|
||||
$_SESSION = $this->data;
|
||||
|
||||
return \session_write_close();
|
||||
}
|
||||
|
|
@ -202,8 +202,8 @@ final class HttpSession implements SessionInterface
|
|||
*/
|
||||
public function remove(string $key) : bool
|
||||
{
|
||||
if (!$this->isLocked && isset($this->sessionData[$key])) {
|
||||
unset($this->sessionData[$key]);
|
||||
if (!$this->isLocked && isset($this->data[$key])) {
|
||||
unset($this->data[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ final class HttpSession implements SessionInterface
|
|||
{
|
||||
if (\session_status() !== \PHP_SESSION_NONE) {
|
||||
\session_destroy();
|
||||
$this->sessionData = [];
|
||||
$this->data = [];
|
||||
\session_start();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace phpOMS\DataStorage\Session;
|
|||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @property array $data
|
||||
*/
|
||||
interface SessionInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -257,11 +257,11 @@ final class L11nManager
|
|||
/**
|
||||
* Print a currency
|
||||
*
|
||||
* @param Localization $l11n Localization
|
||||
* @param int|float|Money $currency Currency value to print
|
||||
* @param null|string $symbol Currency name/symbol
|
||||
* @param null|string $format Format type to use
|
||||
* @param int $divide Divide currency by divisor
|
||||
* @param Localization $l11n Localization
|
||||
* @param int|float|FloatInt|Money $currency Currency value to print
|
||||
* @param null|string $symbol Currency name/symbol
|
||||
* @param null|string $format Format type to use
|
||||
* @param int $divide Divide currency by divisor
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
@ -292,14 +292,15 @@ final class L11nManager
|
|||
}
|
||||
}
|
||||
|
||||
if ($currency instanceof FloatInt) {
|
||||
$currency = $currency->value;
|
||||
$money = null;
|
||||
if ($currency instanceof Money) {
|
||||
$money = $currency;
|
||||
} elseif ($currency instanceof FloatInt) {
|
||||
$money = new Money((int) ($currency->value / $divide));
|
||||
} else {
|
||||
$money = new Money((int) ($currency / $divide));
|
||||
}
|
||||
|
||||
$money = $currency instanceof Money
|
||||
? $currency
|
||||
: new Money((int) ($currency / $divide));
|
||||
|
||||
$money->setLocalization(
|
||||
$l11n->getThousands(),
|
||||
$l11n->getDecimal(),
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa
|
|||
/**
|
||||
* Only return whitelisted results
|
||||
*
|
||||
* @param \string[] ...$whitelist List of whitelisted languages
|
||||
* @param string[] ...$whitelist List of whitelisted languages
|
||||
*
|
||||
* @return LanguageResult
|
||||
* @return self
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -125,9 +125,9 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa
|
|||
/**
|
||||
* Remove blacklisted languages
|
||||
*
|
||||
* @param \string[] ...$blacklist List of blacklist languages
|
||||
* @param string[] ...$blacklist List of blacklist languages
|
||||
*
|
||||
* @return LanguageResult
|
||||
* @return self
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -151,7 +151,7 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa
|
|||
/**
|
||||
* Get results based on internally defined threshold
|
||||
*
|
||||
* @return LanguageResult
|
||||
* @return self
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -182,7 +182,7 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa
|
|||
* @param int $offset Zero indexed start value
|
||||
* @param null|int $length Number of results
|
||||
*
|
||||
* @return LanguageResult
|
||||
* @return self
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -88,8 +88,9 @@ abstract class NgramParser
|
|||
protected function getNgrams(string $str) : array
|
||||
{
|
||||
$tokens = [];
|
||||
$words = $this->tokenize($str);
|
||||
|
||||
foreach ($this->tokenize($str) as $word) {
|
||||
foreach ($words as $word) {
|
||||
$l = \mb_strlen($word);
|
||||
$tmp = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,11 +35,16 @@ class WhitespaceTokenizer
|
|||
*/
|
||||
public function tokenize(string $str) : array
|
||||
{
|
||||
$split = \preg_split('/[^\pL]+(?<![\x27\x60\x{2019}])/u', $str, -1, \PREG_SPLIT_NO_EMPTY);
|
||||
if ($split === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \array_map(
|
||||
function ($word) {
|
||||
return "_{$word}_";
|
||||
},
|
||||
\preg_split('/[^\pL]+(?<![\x27\x60\x{2019}])/u', $str, -1, \PREG_SPLIT_NO_EMPTY)
|
||||
$split
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
// https://github.com/PetarV-/Algorithms/blob/master/Mathematical%20Algorithms/Simplex%20Algorithm.cpp
|
||||
namespace phpOMS\Math\Optimization;
|
||||
|
||||
/**
|
||||
* Simplex class.
|
||||
|
|
@ -20,6 +20,7 @@ declare(strict_types=1);
|
|||
* @package phpOMS\Math\Optimization
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @link https://github.com/PetarV-/Algorithms/blob/master/Mathematical%20Algorithms/Simplex%20Algorithm.cpp
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Simplex
|
||||
|
|
@ -42,22 +43,66 @@ class Simplex
|
|||
|
||||
private array $basicSolution = [];
|
||||
|
||||
/**
|
||||
* Define the function to optimize
|
||||
*
|
||||
* @param array $function Function to optimize
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFunction(array $function) : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add function constraint
|
||||
*
|
||||
* @param array $function Constraint function
|
||||
* @param string $type Constraint type
|
||||
* @param float $limit Constraint
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addConstraint(array $function, string $type, float $limit) : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Pivot element
|
||||
*
|
||||
* @param int $x X-Pivot
|
||||
* @param int $y Y-Pivot
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function pivot(int $x, int $y) : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform simplex iteration
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function iterateSimplex() : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize simplex algorithm
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function initialize() : bool
|
||||
{
|
||||
$k = -1;
|
||||
|
|
@ -198,6 +243,13 @@ class Simplex
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve the optimization
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function solve() : array
|
||||
{
|
||||
if (!$this->initialize()) {
|
||||
|
|
|
|||
|
|
@ -271,8 +271,8 @@ final class CliRequest extends RequestAbstract
|
|||
*/
|
||||
private function init() : void
|
||||
{
|
||||
$this->header->l11n->setLanguage('en');
|
||||
$this->data = $this->uri->getQueryArray();
|
||||
$this->header->l11n->language = 'en';
|
||||
$this->data = $this->uri->getQueryArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ final class HttpHeader extends HeaderAbstract
|
|||
/**
|
||||
* Server headers.
|
||||
*
|
||||
* @var string[]
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static $serverHeaders = [];
|
||||
|
|
|
|||
|
|
@ -146,7 +146,12 @@ final class Rest
|
|||
|
||||
$raw = \substr(\is_bool($result) ? '' : $result, $len === false ? 0 : $len);
|
||||
if (\stripos(\implode('', $response->header->get('content-type')), MimeType::M_JSON) !== false) {
|
||||
$response->setResponse(\json_decode($raw, true));
|
||||
$temp = \json_decode($raw, true);
|
||||
if (!\is_array($temp)) {
|
||||
$temp = [];
|
||||
}
|
||||
|
||||
$response->setResponse($temp);
|
||||
} else {
|
||||
$response->set('', $raw);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Email implements MessageInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $messageId = '';
|
||||
public string $messageId = '';
|
||||
|
||||
/**
|
||||
* Unique ID used for message ID and boundaries.
|
||||
|
|
@ -100,7 +100,7 @@ class Email implements MessageInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $uniqueid = '';
|
||||
public string $uniqueid = '';
|
||||
|
||||
/**
|
||||
* Hostname coming from the mail handler.
|
||||
|
|
@ -116,7 +116,7 @@ class Email implements MessageInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $mailer = SubmitType::MAIL;
|
||||
public string $mailer = SubmitType::MAIL;
|
||||
|
||||
/**
|
||||
* Mail from.
|
||||
|
|
@ -124,7 +124,7 @@ class Email implements MessageInterface
|
|||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $from = [];
|
||||
public array $from = [];
|
||||
|
||||
/**
|
||||
* Return path/bounce address
|
||||
|
|
@ -440,11 +440,6 @@ class Email implements MessageInterface
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getFrom() : array
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message type to html or plain.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ class MailHandler
|
|||
|
||||
$mail->hostname = $this->hostname;
|
||||
|
||||
$smtpFrom = $mail->sender === '' ? $mail->getFrom()[0] : $mail->sender;
|
||||
$smtpFrom = $mail->sender === '' ? $mail->from[0] : $mail->sender;
|
||||
|
||||
if (!$this->smtp->mail($smtpFrom)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -339,13 +339,13 @@ final class PackageManager
|
|||
*/
|
||||
private function authenticate(string $signedHash, string $rawHash) : bool
|
||||
{
|
||||
if ($signedHash === '' || $rawHash === '') {
|
||||
if ($signedHash === '' || $rawHash === '' || $this->publicKey === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return \sodium_crypto_sign_verify_detached($signedHash, $rawHash, $this->publicKey);
|
||||
} catch(\Throwable $t) {
|
||||
} catch(\Throwable $_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,11 @@ final class EncryptionHelper
|
|||
\fwrite($fpEncoded, $nonce);
|
||||
|
||||
while (!\feof($fpSource)) {
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
if ($buffer === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ciphertext = \sodium_crypto_secretbox($buffer, $nonce, $secretKey);
|
||||
|
||||
\fwrite($fpEncoded, $ciphertext);
|
||||
|
|
@ -179,11 +183,18 @@ final class EncryptionHelper
|
|||
$secretKey = \sodium_hex2bin($keyHex);
|
||||
$nonce = \fread($fpSource, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
|
||||
while (!\feof($fpSource)) {
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
$ciphertext = \mb_substr($buffer, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||
if ($nonce === false) {
|
||||
$nonce = '';
|
||||
}
|
||||
|
||||
$plaintext = \sodium_crypto_secretbox_open($ciphertext, $nonce, $secretKey);
|
||||
while (!\feof($fpSource)) {
|
||||
$buffer = \fread($fpSource, 4096);
|
||||
if ($buffer === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ciphertext = \mb_substr($buffer, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||
$plaintext = \sodium_crypto_secretbox_open($ciphertext, $nonce, $secretKey);
|
||||
|
||||
if ($plaintext === false) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class SmartDateTime extends \DateTime
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createModify(int $y, int $m = 0, int $d = 0, int $calendar = \CAL_GREGORIAN) : self
|
||||
public function createModify(int $y = 0, int $m = 0, int $d = 0, int $calendar = \CAL_GREGORIAN) : self
|
||||
{
|
||||
$dt = clone $this;
|
||||
$dt->smartModify($y, $m, $d, $calendar);
|
||||
|
|
@ -109,20 +109,18 @@ class SmartDateTime extends \DateTime
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = \CAL_GREGORIAN) : self
|
||||
public function smartModify(int $y = 0, int $m = 0, int $d = 0, int $calendar = \CAL_GREGORIAN) : self
|
||||
{
|
||||
$yearChange = (int) \floor(((int) $this->format('m') - 1 + $m) / 12);
|
||||
$yearChange = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $yearChange - 1 : $yearChange;
|
||||
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
||||
$monthNew = ((int) $this->format('m') + $m) % 12;
|
||||
$monthNew = $monthNew === 0 ? 12 : ($monthNew < 0 ? 12 + $monthNew : $monthNew);
|
||||
$yearChange = (int) \floor(((int) $this->format('m') - 1 + $m) / 12);
|
||||
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
||||
|
||||
$monthNew = ((int) $this->format('m') + $m - 1) % 12 + 1;
|
||||
|
||||
$dayMonthOld = \cal_days_in_month($calendar, (int) $this->format('m'), (int) $this->format('Y'));
|
||||
$dayMonthNew = \cal_days_in_month($calendar, $monthNew, $yearNew);
|
||||
$dayOld = (int) $this->format('d');
|
||||
|
||||
if ($dayOld > $dayMonthNew) {
|
||||
$dayNew = $dayMonthNew;
|
||||
} elseif ($dayOld < $dayMonthNew && $dayOld === $dayMonthOld) {
|
||||
if ($dayOld > $dayMonthNew || $dayOld === $dayMonthOld) {
|
||||
$dayNew = $dayMonthNew;
|
||||
} else {
|
||||
$dayNew = $dayOld;
|
||||
|
|
|
|||
|
|
@ -924,7 +924,7 @@ class Graph
|
|||
} elseif (!$j->isEqual($i) && !$j->isEqual($current)
|
||||
&& $distances[$j->getId()] >= $distances[$current->getId()]
|
||||
) {
|
||||
$girth = \min(
|
||||
$girth = (int) \min(
|
||||
$girth,
|
||||
$distances[$current->getId()] + $distances[$j->getId()] + 1
|
||||
);
|
||||
|
|
@ -1199,6 +1199,10 @@ class Graph
|
|||
*/
|
||||
public function isBipartite() : bool
|
||||
{
|
||||
if (empty($this->nodes)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($this->nodes as $node) {
|
||||
$colors[$node->getId()] = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ final class SystemUtils
|
|||
return $_SERVER['SERVER_NAME'];
|
||||
} elseif (($result = \gethostname()) !== false) {
|
||||
return $result;
|
||||
} elseif (\php_uname('n') !== false) {
|
||||
return \php_uname('n');
|
||||
} elseif (!empty($hostname = \php_uname('n'))) {
|
||||
return $hostname;
|
||||
}
|
||||
|
||||
return 'localhost.localdomain';
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ final class ArrayUtils
|
|||
$xml->addChild($key, \htmlspecialchars($value));
|
||||
}
|
||||
}
|
||||
return $xml->asXML();
|
||||
return (string) $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,14 +298,16 @@ final class ArrayUtils
|
|||
*
|
||||
* Useful for parsing command line parsing
|
||||
*
|
||||
* @param string $id Id to find
|
||||
* @param string[] $args CLI command list
|
||||
* @template T
|
||||
*
|
||||
* @return null|string
|
||||
* @param string $id Id to find
|
||||
* @param array<string|int, T> $args CLI command list
|
||||
*
|
||||
* @return null|T
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getArg(string $id, array $args) : ?string
|
||||
public static function getArg(string $id, array $args) : mixed
|
||||
{
|
||||
if (\is_numeric($id)) {
|
||||
return $args[(int) $id] ?? null;
|
||||
|
|
@ -321,8 +323,8 @@ final class ArrayUtils
|
|||
/**
|
||||
* Check if flag is set
|
||||
*
|
||||
* @param string $id Id to find
|
||||
* @param string[] $args CLI command list
|
||||
* @param string $id Id to find
|
||||
* @param array<string|int, mixed> $args CLI command list
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class Datamatrix extends TwoDAbstract
|
|||
// braw bits by case
|
||||
if ($r === 0) {
|
||||
// top finder pattern
|
||||
$this->codearray[$row][$col] = $c % 2 === 0;
|
||||
$this->codearray[$row][$col] = ($c % 2) === 0;
|
||||
} elseif ($r === $rdri) {
|
||||
// bottom finder pattern
|
||||
$this->codearray[$row][$col] = true;
|
||||
|
|
@ -223,17 +223,17 @@ class Datamatrix extends TwoDAbstract
|
|||
$this->codearray[$row][$col] = true;
|
||||
} elseif ($c === $rdci) {
|
||||
// right finder pattern
|
||||
$this->codearray[$row][$col] = $r % 2;
|
||||
} else { // data bit
|
||||
if ($places[$i] < 2) {
|
||||
$this->codearray[$row][$col] = (bool) $places[$i];
|
||||
} else {
|
||||
// codeword ID
|
||||
$cw_id = (\floor($places[$i] / 10) - 1);
|
||||
// codeword BIT mask
|
||||
$cw_bit = \pow(2, (8 - ($places[$i] % 10)));
|
||||
$this->codearray[$row][$col] = ($cw[$cw_id] & $cw_bit) !== 0;
|
||||
}
|
||||
$this->codearray[$row][$col] = ($r % 2) === 0;
|
||||
} elseif ($places[$i] < 2) { // data bit
|
||||
$this->codearray[$row][$col] = (bool) $places[$i];
|
||||
|
||||
++$i;
|
||||
} else {
|
||||
// codeword ID
|
||||
$cw_id = (int) (\floor($places[$i] / 10) - 1);
|
||||
// codeword BIT mask
|
||||
$cw_bit = \pow(2, (8 - ($places[$i] % 10)));
|
||||
$this->codearray[$row][$col] = ($cw[$cw_id] & $cw_bit) !== 0;
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
|
@ -967,11 +967,9 @@ class Datamatrix extends TwoDAbstract
|
|||
$cw_num += 2;
|
||||
}
|
||||
|
||||
if (!empty($temp_cw)) {
|
||||
// add B256 field
|
||||
foreach ($temp_cw as $p => $cht) {
|
||||
$cw[] = $this->get255StateCodeword($cht, ($cw_num + $p + 1));
|
||||
}
|
||||
// add B256 field
|
||||
foreach ($temp_cw as $p => $cht) {
|
||||
$cw[] = $this->get255StateCodeword($cht, ($cw_num + $p + 1));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -1099,19 +1097,13 @@ class Datamatrix extends TwoDAbstract
|
|||
if (($row === $nrow) && ($col === 0)) {
|
||||
$marr = $this->placeCornerA($marr, $nrow, $ncol, $chr);
|
||||
++$chr;
|
||||
}
|
||||
|
||||
if (($row === ($nrow - 2)) && ($col === 0) && ($ncol % 4)) {
|
||||
} elseif (($row === ($nrow - 2)) && ($col === 0) && ($ncol % 4)) {
|
||||
$marr = $this->placeCornerB($marr, $nrow, $ncol, $chr);
|
||||
++$chr;
|
||||
}
|
||||
|
||||
if (($row === ($nrow - 2)) && ($col === 0) && (($ncol % 8) === 4)) {
|
||||
} elseif (($row === ($nrow - 2)) && ($col === 0) && (($ncol % 8) === 4)) {
|
||||
$marr = $this->placeCornerC($marr, $nrow, $ncol, $chr);
|
||||
++$chr;
|
||||
}
|
||||
|
||||
if (($row === ($nrow + 4)) && ($col === 2) && (!($ncol % 8))) {
|
||||
} elseif (($row === ($nrow + 4)) && ($col === 2) && (!($ncol % 8))) {
|
||||
$marr = $this->placeCornerD($marr, $nrow, $ncol, $chr);
|
||||
++$chr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,6 +154,11 @@ final class ImageUtils
|
|||
if (\stripos($srcPath, '.png')) {
|
||||
\imagealphablending($dst, false);
|
||||
$transparent = \imagecolorallocatealpha($dst, 0, 0, 0, 127);
|
||||
|
||||
if ($transparent === false) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
\imagefill($dst, 0, 0, $transparent);
|
||||
\imagesavealpha($dst, true);
|
||||
}
|
||||
|
|
@ -342,7 +347,7 @@ final class ImageUtils
|
|||
/**
|
||||
* Calculate the average color of an image at a specific position
|
||||
*
|
||||
* @param resource $src Image resource
|
||||
* @param \GdImage $src Image resource
|
||||
* @param int $x X position
|
||||
* @param int $y Y position
|
||||
* @param int $width Image width
|
||||
|
|
|
|||
|
|
@ -227,7 +227,10 @@ class PresentationWriter
|
|||
}
|
||||
if ($oBkg instanceof Image) {
|
||||
$sBkgImgContents = \file_get_contents($oBkg->getPath());
|
||||
$this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,' . \base64_encode($sBkgImgContents) . '"></dd>');
|
||||
|
||||
if ($sBkgImgContents !== false) {
|
||||
$this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,' . \base64_encode($sBkgImgContents) . '"></dd>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +304,7 @@ class PresentationWriter
|
|||
$this->append('<dt>Name</dt><dd>' . $oShape->getName() . '</dd>');
|
||||
$this->append('<dt>Description</dt><dd>' . $oShape->getDescription() . '</dd>');
|
||||
\ob_start();
|
||||
\call_user_func($oShape->getRenderingFunction(), $oShape->getImageResource());
|
||||
$oShape->getRenderingFunction()($oShape->getImageResource());
|
||||
$sShapeImgContents = \ob_get_contents();
|
||||
\ob_end_clean();
|
||||
$this->append('<dt>Mime-Type</dt><dd>' . $oShape->getMimeType() . '</dd>');
|
||||
|
|
@ -327,20 +330,24 @@ class PresentationWriter
|
|||
$this->append('<dt>Alignment Margin (L / R)</dt><dd>' . $oParagraph->getAlignment()->getMarginLeft() . ' px / ' . $oParagraph->getAlignment()->getMarginRight() . 'px</dd>');
|
||||
$this->append('<dt>Alignment Indent</dt><dd>' . $oParagraph->getAlignment()->getIndent() . ' px</dd>');
|
||||
$this->append('<dt>Alignment Level</dt><dd>' . $oParagraph->getAlignment()->getLevel() . '</dd>');
|
||||
$this->append('<dt>Bullet Style</dt><dd> Bullet::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Bullet', $oParagraph->getBulletStyle()->getBulletType()) . '</dd>');
|
||||
|
||||
if ($oParagraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) {
|
||||
$this->append('<dt>Bullet Font</dt><dd>' . $oParagraph->getBulletStyle()->getBulletFont() . '</dd>');
|
||||
$this->append('<dt>Bullet Color</dt><dd>' . $oParagraph->getBulletStyle()->getBulletColor()->getARGB() . '</dd>');
|
||||
}
|
||||
$bulletStyle = $oParagraph->getBulletStyle();
|
||||
if ($bulletStyle !== null) {
|
||||
$this->append('<dt>Bullet Style</dt><dd> Bullet::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Bullet', $bulletStyle->getBulletType()) . '</dd>');
|
||||
|
||||
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) {
|
||||
$this->append('<dt>Bullet Char</dt><dd>' . $oParagraph->getBulletStyle()->getBulletChar() . '</dd>');
|
||||
}
|
||||
if ($bulletStyle->getBulletType() != Bullet::TYPE_NONE) {
|
||||
$this->append('<dt>Bullet Font</dt><dd>' . $bulletStyle->getBulletFont() . '</dd>');
|
||||
$this->append('<dt>Bullet Color</dt><dd>' . $bulletStyle->getBulletColor()->getARGB() . '</dd>');
|
||||
}
|
||||
|
||||
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) {
|
||||
$this->append('<dt>Bullet Start At</dt><dd>' . $oParagraph->getBulletStyle()->getBulletNumericStartAt() . '</dd>');
|
||||
$this->append('<dt>Bullet Style</dt><dd>' . $oParagraph->getBulletStyle()->getBulletNumericStyle() . '</dd>');
|
||||
if ($bulletStyle->getBulletType() == Bullet::TYPE_BULLET) {
|
||||
$this->append('<dt>Bullet Char</dt><dd>' . $bulletStyle->getBulletChar() . '</dd>');
|
||||
}
|
||||
|
||||
if ($bulletStyle->getBulletType() == Bullet::TYPE_NUMERIC) {
|
||||
$this->append('<dt>Bullet Start At</dt><dd>' . $bulletStyle->getBulletNumericStartAt() . '</dd>');
|
||||
$this->append('<dt>Bullet Style</dt><dd>' . $bulletStyle->getBulletNumericStyle() . '</dd>');
|
||||
}
|
||||
}
|
||||
|
||||
$this->append('<dt>Line Spacing</dt><dd>' . $oParagraph->getLineSpacing() . '</dd>');
|
||||
|
|
@ -408,8 +415,8 @@ class PresentationWriter
|
|||
$constName = '';
|
||||
|
||||
foreach ($constants as $key => $value) {
|
||||
if ($value == $search) {
|
||||
if (empty($startWith) || (!empty($startWith) && \strpos($key, $startWith) === 0)) {
|
||||
if ($value === $search) {
|
||||
if ($startWith === '' || \strpos($key, $startWith) === 0) {
|
||||
$constName = $key;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,15 @@ class SpreadsheetParser
|
|||
$spreadsheet = IOFactory::load($path);
|
||||
|
||||
$sheetCount = $spreadsheet->getSheetCount();
|
||||
$csv = [];
|
||||
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$csv[] = $spreadsheet->getSheet($i)->toArray(null, true, true, true);
|
||||
}
|
||||
|
||||
return \json_encode($csv);
|
||||
$json = \json_encode($csv);
|
||||
|
||||
return $json === false ? '' : $json;
|
||||
} elseif ($output === 'pdf') {
|
||||
$spreadsheet = IOFactory::load($path);
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class TaskScheduler extends SchedulerAbstract
|
|||
foreach ($lines as $line) {
|
||||
$line = \str_getcsv($line);
|
||||
|
||||
if (\stripos($line[1], $name) !== false) {
|
||||
if (\stripos($line[1] ?? '', $name) !== false) {
|
||||
$jobs[] = Schedule::createWith($line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
self::assertEquals(0, $perm->getId());
|
||||
self::assertNull($perm->getUnit());
|
||||
self::assertNull($perm->getApp());
|
||||
self::assertNull($perm->getModule());
|
||||
self::assertEquals(0, $perm->getFrom());
|
||||
self::assertNull($perm->getElement());
|
||||
self::assertNull($perm->getComponent());
|
||||
self::assertEquals(0, $perm->id);
|
||||
self::assertNull($perm->unit);
|
||||
self::assertNull($perm->app);
|
||||
self::assertNull($perm->module);
|
||||
self::assertEquals(0, $perm->from);
|
||||
self::assertNull($perm->element);
|
||||
self::assertNull($perm->component);
|
||||
self::assertEquals(PermissionType::NONE, $perm->getPermission());
|
||||
self::assertTrue($perm->hasPermission(PermissionType::NONE));
|
||||
self::assertTrue($perm->hasPermissionFlags(PermissionType::NONE));
|
||||
|
|
@ -64,97 +64,6 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The unit can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testUnitInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setUnit(1);
|
||||
self::assertEquals(1, $perm->getUnit());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The app can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testAppInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setApp(2);
|
||||
self::assertEquals(2, $perm->getApp());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The module can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testModuleInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setModule('2');
|
||||
self::assertEquals('2', $perm->getModule());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The from can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testFromInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setFrom('3');
|
||||
self::assertEquals('3', $perm->getFrom());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The category can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testCategoryInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setCategory(4);
|
||||
self::assertEquals(4, $perm->getCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The element can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testElementInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setElement(5);
|
||||
self::assertEquals(5, $perm->getElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The component can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
* @group framework
|
||||
*/
|
||||
public function testComponentInputOutput() : void
|
||||
{
|
||||
$perm = new class() extends PermissionAbstract {};
|
||||
|
||||
$perm->setComponent(6);
|
||||
self::assertEquals(6, $perm->getComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The permission can be set and returned correctly
|
||||
* @covers phpOMS\Account\PermissionAbstract
|
||||
|
|
@ -176,13 +85,13 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
public function testEqualPermissions() : void
|
||||
{
|
||||
$perm1 = new class() extends PermissionAbstract {};
|
||||
$perm1->setUnit(1);
|
||||
$perm1->unit = 1;
|
||||
$perm1->setPermission(PermissionType::READ);
|
||||
|
||||
self::assertTrue($perm1->isEqual($perm1));
|
||||
|
||||
$perm2 = new class() extends PermissionAbstract {};
|
||||
$perm2->setUnit(1);
|
||||
$perm2->unit = 1;
|
||||
$perm2->setPermission(PermissionType::CREATE);
|
||||
|
||||
self::assertFalse($perm1->isEqual($perm2));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user