Cleanup implementations

Remove old files, change directory name and implement new function after
testing
This commit is contained in:
Dennis Eichhorn 2017-10-01 00:17:56 +02:00
parent cfadeb5e36
commit b6680a6d1b
46 changed files with 914 additions and 66 deletions

View File

@ -81,4 +81,41 @@ class FileUtils
return ExtensionType::UNKNOWN;
}
/**
* Make file path absolute
*
* @param string $origPath File path
*
* @return string
*
* @since 1.0.0
*/
public static function absolute(string $origPath) : string
{
if(!file_exists($origPath)) {
$startsWithSlash = strpos($origPath, '/') === 0 ? '/' : '';
$path = [];
$parts = explode('/', $origPath);
foreach($parts as $part) {
if (empty($part) || $part === '.') {
continue;
}
if ($part !== '..') {
$path[] = $part;
} elseif (!empty($path)) {
array_pop($path);
} else {
throw new PathException($origPath);
}
}
return $startsWithSlash . implode('/', $path);
}
return realpath($origPath);
}
}

View File

@ -0,0 +1,30 @@
<?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\Utils\EDI\AnsiX12\Components;
/**
* EDI Header
*
* @link https://www.erico.com/public/library/edi/ERICO850_4010.pdf
* @category Framework
* @package phpOMS\Utils\Converter
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class BEG
{
}

View File

@ -0,0 +1,97 @@
<?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\Utils\EDI\AnsiX12\Components;
/**
* EDI Header
*
* @link https://www.erico.com/public/library/edi/ERICO850_4010.pdf
* @category Framework
* @package phpOMS\Utils\Converter
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class BIG
{
private $invoiceDate = null;
private $purchaseDate = null;
private $invoice = '';
private $purchase = '';
private $transactionTypeCode = 0;
public function setInvoiceDate(\DateTime $invoiceDate) /* : void */
{
$this->invoiceDate = $invoiceDate;
}
public function getInvoiceDate() : string
{
return $this->invoiceDate->format('Ymd');
}
public function setInvoiceNumber(string $invoice) /* : void */
{
if(strlen($invoice) < 1 || strlen($invoice) > 22) {
throw new \Exception();
}
$this->invoice = $invoice;
}
public function getInvoiceNumber() : string
{
return $this->invoice;
}
public function setPurchaseDate(\DateTime $purchaseDate) /* : void */
{
$this->purchaseDate = $purchaseDate;
}
public function getPurchaseDate() : string
{
return $this->purchaseDate->format('Ymd');
}
public function setPurchaseNumber(string $purchase) /* : void */
{
if(strlen($purchase) < 1 || strlen($purchase) > 22) {
throw new \Exception();
}
$this->purchase = $purchase;
}
public function getPurchaseNumber() : string
{
return $this->purchase;
}
public function setTransactionTypeCode(int $code) /* : void */
{
if($code < 10 || $code > 99) {
throw new \Exception();
}
$this->transactionTypeCode = $code;
}
public function getTransactionTypeCode() : string
{
return str_pad((string) $this->transactionTypeCode, 2, '0', STR_PAD_LEFT);
}
}

View File

@ -0,0 +1,176 @@
<?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\Utils\EDI\AnsiX12\Components;
/**
* EDI Header
*
* @category Framework
* @package phpOMS\Utils\Converter
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class GS
{
private $functionalGroupHeader = 'GS';
private $functionalIdentifierCode = FunctionalIdentifierCode::PO;
private $applicationSenderCode = '';
private $appicationReceiverCode = '';
private $date = null;
private $groupControlNumber = 0;
private $responsibleAgencyCode = '';
private $version = '';
public function __construct()
{
$this->date = new \DateTime();
}
public function getFunctionalGroupHeader() : string
{
return $this->functionalGroupHeader;
}
public function getFunctionalIdentifierCode() : string
{
return $this->functionalIdentifierCode;
}
public function setFunctionalIdentifierCode(string $code) /* : void */
{
if(!FunctionalIdentifierCode::isValidValue($code)) {
throw \Exception();
}
$this->functionalIdentifierCode = $code;
}
public function getApplicationSenderCode() : string
{
return str_pad((string) $this->applicationSenderCode, 2, '0', STR_PAD_LEFT);
}
public function setApplicationSenderCode(string $code) /* : void */
{
if(strlen($code) < 2 || strlen($code) > 15) {
throw new \Exception();
}
$this->applicationSenderCode = $code;
}
public function getApplicationReceiverCode() : string
{
return str_pad((string) $this->applicationReceiverCode, 2, '0', STR_PAD_LEFT);
}
public function setApplicationReceiverCode(string $code) /* : void */
{
if(strlen($code) < 2 || strlen($code) > 15) {
throw new \Exception();
}
$this->applicationReceiverCode = $code;
}
public function setDate(\DateTime $date) /* : void */
{
$this->date = $date;
}
public function getDate() : string
{
return $this->date->format('d:m:y');
}
public function getTime() : string
{
return $this->date->format('d:m:y');
}
public function getGroupControlNumber() : int
{
return $this->groupControlNumber;
}
public function setGroupControlNumber(int $number) /* : void */
{
if($number < 0) {
throw new \Exception();
}
$this->groupControlNumber = $number;
}
public function getResponsibleAgencyCode() : int
{
return $this->responsibleAgencyCode;
}
public function setResponsibleAgencyCode(int $code) /* : void */
{
if($code < 0 || $code > 99) {
throw new \Exception();
}
$this->responsibleAgencyCode = $code;
}
public function getVersion() : string
{
return $this->version;
}
public function setVersion(string $version) /* : void */
{
$this->version = $version;
}
public function serialize()
{
return $this->functionalGroupHeader . '*'
. $this->getFunctionalIdentifierCode() . '*'
. $this->getApplicationSenderCode() . '*'
. $this->getApplicationReceiverCode() . '*'
. $this->getDate() . '*'
. $this->getTime() . '*'
. $this->getGroupControlNumber() . '*'
. $this->getResponsibleAgencyCode() . '*'
. $this->getVersion() . '*' . self::COMPONENT_ELEMENT_SEPARATOR;
}
public function unserialize($raw)
{
$split = explode($raw);
$this->setFunctionalGroupHeader(trim($split[0]));
$this->setFunctionalIdentifierCode(trim($split[1]));
$this->setApplicationSenderCode(trim($split[2]));
$this->setApplicationReceiverCode(trim($split[3]));
$this->setDate(new \DateTime(trim($split[4]) . '-' . trim($split[5])));
$this->setGroupControlNumber(trim($split[6]));
$this->setResponsibleAgencyCode((int) trim($split[7]));
$this->setVersion(trim($split[8]));
}
}

View File

@ -0,0 +1,427 @@
<?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\Utils\EDI\AnsiX12\Components;
/**
* EDI Header
*
* @link https://www.erico.com/public/library/edi/ERICO850_4010.pdf
* @category Framework
* @package phpOMS\Utils\Converter
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class ISA
{
/* private */ const COMPONENT_ELEMENT_SEPARATOR = '>';
private $interchangeControlHeader = 'ISA';
/**
* Code to identify the type of information in the Authorization Information.
*
* Req: M
* Type: ID
* Min/Max: 2/2
* Usage: Must
*
* 00 = No Authorization Information available
*
* @var int
* @since 1.0.0
*/
private $authorizationInformationQualifier = 0;
/**
* Information used for additional identification or authorization of the interchange
* sender or the data in the interchange; the type of information is set by the Authorization
* Information Qualifier.
*
* Req: M
* Type: AN
* Min/Max: 10/10
* Usage: Must
*
* @var string
* @since 1.0.0
*/
private $authorizationInformation = '';
/**
* Code to identify the type of information in the Security Information.
*
* Req: M
* Type: ID
* Min/Max: 2/2
* Usage: Must
*
* 00 = No Security Information available
*
* @var int
* @since 1.0.0
*/
private $securityInformationQualifer = 0;
/**
* This is used for identifying the security information about the interchange
* sender or the data in the interchange; the type of information is set by the Security
* Information Qualifier.
*
* Req: M
* Type: AN
* Min/Max: 10/10
* Usage: Must
*
* @var string
* @since 1.0.0
*/
private $securityInformation = '';
/**
* Qualifier to designate the system/method of code structure used to designate
* the sender or receiver ID element being qualifiedn.
*
* Req: M
* Type: ID
* Min/Max: 2/2
* Usage: Must
*
* 00 = No Security Information available
*
* @var int
* @since 1.0.0
*/
private $interchangeIdQualifier = 0;
/**
* Interchange Sender
*
* Req: M
* Type: AN
* Min/Max: 15/15
* Usage: Must
*
* @var string
* @since 1.0.0
*/
private $interchangeSender = '';
/**
* DateTime of the interchange
*
* Req: M
* Type: DTM
* Usage: Must
*
* @var \DateTime
* @since 1.0.0
*/
private $interchangeDateTime = null;
/**
* Code to identify the agency responsible for the control standard used by the
* message that is enclosed by the interchange header and trailer.
*
* Req: M
* Type: ID
* Min/Max: 1/1
* Usage: Must
*
* @var string
* @since 1.0.0
*/
private $interchangeControlStandardId = '';
/**
* Code specifying the version number of the interchange control segments.
*
* Req: M
* Type: ID
* Min/Max: 5/5
* Usage: Must
*
* @var int
* @since 1.0.0
*/
private $interchangeControlVersionNumber = 401;
/**
* A control number assigned by the interchange sender.
*
* Req: M
* Type: int
* Min/Max: 9/9
* Usage: Must
*
* @var int
* @since 1.0.0
*/
private $interchangeControlNumber = 0;
/**
* Code sent by the sender to request an interchange acknowledgment.
*
* Req: M
* Type: bool
* Min/Max: 1/1
* Usage: Must
*
* @var bool
* @since 1.0.0
*/
private $acknowledgementRequested = false;
/**
* Code to indicate whether data enclosed by this interchange envelope is test,
* production or information.
*
* Req: M
* Type: ID
* Min/Max: 1/1
* Usage: Must
*
* @var int
* @since 1.0.0
*/
private $usageIndicator = 'T';
public function setInterchangeControlHeader(string $header) /* : void */
{
$this->interchangeControlHeader = $header;
}
public function setAuthorizationInformationQualifier(int $qualifer) /* : void */
{
if($qualifer > 99) {
throw new \Exception();
}
$this->authorizationInformationQualifier = $qualifier;
}
public function getAuthorizationInformationQualifier() : string
{
return str_pad((string) $this->authorizationInformationQualifier, 2, '0', STR_PAD_LEFT);
}
public function setAuthorizationInformation(string $information) /* : void */
{
if(strlen($information) > 10) {
throw new \Exception();
}
$this->authorizationInformation = $information;
}
public function getAuthorizationInformation() : string
{
return str_pad((string) $this->authorizationInformation, 10, ' ', STR_PAD_RIGHT);
}
public function setSecurityInformationQualifer(int $qualifer) /* : void */
{
if($qualifer > 99) {
throw new \Exception();
}
$this->securityInformationQualifer = $qualifier;
}
public function getSecurityInformationQualifer() : string
{
return str_pad((string) $this->securityInformationQualifer, 2, '0', STR_PAD_LEFT);
}
public function setSecurityInformation(string $information) /* : void */
{
if(strlen($information) > 10) {
throw new \Exception();
}
$this->securityInformation = $information;
}
public function getSecurityInformation() : string
{
return str_pad((string) $this->securityInformation, 10, ' ', STR_PAD_RIGHT);
}
public function setInterchangeIdQualifier(int $qualifer) /* : void */
{
if($qualifer > 99) {
throw new \Exception();
}
$this->interchangeIdQualifier = $qualifier;
}
public function getInterchangeIdQualifier() : string
{
return str_pad((string) $this->interchangeIdQualifier, 2, '0', STR_PAD_LEFT);
}
public function setInterchangeSender(string $information) /* : void */
{
if(strlen($information) > 15) {
throw new \Exception();
}
$this->interchangeSender = $information;
}
public function getInterchangeSender() : string
{
return str_pad((string) $this->interchangeSender, 15, ' ', STR_PAD_RIGHT);
}
public function setInterchangeReceiver(string $information) /* : void */
{
if(strlen($information) > 15) {
throw new \Exception();
}
$this->interchangeReceiver = $information;
}
public function getInterchangeReceiver() : string
{
return str_pad((string) $this->interchangeReceiver, 15, ' ', STR_PAD_RIGHT);
}
public function setInterchangeDatetime(\DateTime $interchange) /* : void */
{
$this->interchangeDateTime = $interchange;
}
public function getInterchangeDate() : string
{
return $this->interchangeDateTime->format('d:m:y');
}
public function getInterchangeTime() : string
{
return $this->interchangeDateTime->format('H:i');
}
public function setInterchangeControlStandardId(string $id) /* : void */
{
if(strlen($id) !== 1) {
throw new \Exception();
}
$this->interchangeControlStandardId = $id;
}
public function getInterchangeControlStandardId() : string
{
return $this->interchangeControlStandardId;
}
public function setInterchangeControlVersionNumber(int $version) /* : void */
{
if($version > 99999) {
throw new \Exception();
}
$this->interchangeControlVersionNumber = $version;
}
public function getInterchangeControlVersionNumber() : string
{
return str_pad((string) $this->interchangeControlVersionNumber, 5, '0', STR_PAD_LEFT);
}
public function setInterchangeControlNumber(int $number) /* : void */
{
if($number > 999999999) {
throw new \Exception();
}
$this->interchangeControlNumber = $number;
}
public function getInterchangeControlNumber() : string
{
return str_pad((string) $this->interchangeControlNumber, 9, '0', STR_PAD_LEFT);
}
public function setAcknowledgmentRequested(bool $ack) /* : void */
{
$this->acknowledgmentRequested = $ack;
}
public function getAcknowledgmentRequested() : string
{
return (string) $this->acknowledgmentRequested;
}
public function setUsageUndicator(string $id) /* : void */
{
if(strlen($id) !== 1) {
throw new \Exception();
}
$this->usageIndicator = $id;
}
public function getUsageUndicator() : string
{
return $this->usageIndicator;
}
public function serialize()
{
return $this->interchangeControlHeader . '*'
. $this->getAuthorizationInformationQualifier() . '*'
. $this->getAuthorizationInformation() . '*'
. $this->getSecurityInformationQualifer() . '*'
. $this->getSecurityInformation() . '*'
. $this->getInterchangeIdQualifier() . '*'
. $this->getInterchangeSender() . '*'
. $this->getInterchangeIdQualifier() . '*'
. $this->getInterchangeReceiver() . '*'
. $this->getInterchangeDate() . '*'
. $this->getInterchangeTime() . '*'
. $this->getInterchangeControlStandardId() . '*'
. $this->getInterchangeControlVersionNumber() . '*'
. $this->getInterchangeControlNumber() . '*'
. $this->getAcknowledgmentRequested() . '*'
. $this->getUsageUndicator() . '*' . self::COMPONENT_ELEMENT_SEPARATOR;
}
public function unserialize($raw)
{
$split = explode('*', $raw);
$this->setInterchangeControlHeader(trim($split[0]));
$this->setAuthorizationInformationQualifier((int) trim($split[1]));
$this->setAuthorizationInformation(trim($split[2]));
$this->setSecurityInformationQualifer((int) trim($split[3]));
$this->setSecurityInformation(trim($split[4]));
$this->setInterchangeIdQualifier((int) trim($split[5]));
$this->setInterchangeSender(trim($split[6]));
$this->setInterchangeReceiver(trim($split[8]));
$this->setInterchangeDatetime(new \DateTime(trim($split[9]) . '-' . trim($split[10])));
$this->setInterchangeControlStandardId(trim($split[11]));
$this->setInterchangeControlVersionNumber((int) trim($split[12]));
$this->setInterchangeControlNumber((int) trim($split[13]));
$this->setAcknowledgmentRequested((bool) $split[14]);
$this->setUsageUndicator($split[15]);
}
}

View File

@ -0,0 +1,82 @@
<?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\Utils\EDI\AnsiX12\Components;
/**
* EDI Header
*
* @category Framework
* @package phpOMS\Utils\Converter
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class ST
{
/* private */ const IDENTIFIER = 'ST';
private $transactionSetIdentifierCode = 0;
private $transactionSetControlNumber = '';
public function __construct(int $idCode = 0)
{
$this->transactionSetIdentifierCode = $idCode;
}
public function setTransactionSetIdentifierCode(int $idCode)
{
if($idCode < 100 || $idCode > 999) {
throw new \Exception();
}
$this->transactionSetIdentifierCode = $idCode;
}
public function getTransactionSetIdentifierCode() : int
{
return $this->transactionSetIdentifierCode;
}
public function setTransactionSetControlNumber(string $controlNumber)
{
if(strlen($controlNumber) < 4 || strlen($controlNumber) > 9) {
throw new \Exception();
}
$this->transactionSetControlNumber = $controlNumber;
}
public function getTransactionSetControlNumber() : string
{
return str_pad((string) $this->transactionSetControlNumber, 9, '0', STR_PAD_LEFT);
}
public function serialize()
{
return self::IDENTIFIER . '*'
. $this->getTransactionSetIdentifierCode() . '*'
. $this->getTransactionSetControlNumber() . '*' . self::COMPONENT_ELEMENT_SEPARATOR;
}
public function unserialize($raw)
{
$split = explode('*', $raw);
$this->setTransactionSetIdentifierCode((int) $split[1]);
$this->setTransactionSetControlNumber(substr($split[2], -1));
}
}

View File

@ -16,6 +16,7 @@ declare(strict_types=1);
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
use phpOMS\Utils\EDI\AnsiX12\EDIAbstract;
use phpOMS\Utils\EDI\AnsiX12\Component;
/**
* EDI 850 - Purchase order.
@ -28,11 +29,30 @@ use phpOMS\Utils\EDI\AnsiX12\EDIAbstract;
*/
class EDI850 extends EDIAbstract
{
private $interchangeControlHeader = null;
private $functionalGroupHeader = null;
private $heading = null;
private $detail = null;
private $summary = null;
private $functionalGroupTrailer = null;
private $interchangeControlTrailer = null;
public function __construct()
{
parent::__construct();
$this->heading = new EDIT850Heading();
$this->detail = new EDIT850Detail();
$this->interchangeControlHeader = new ISA();
$this->functionalGroupHeader = new GS();
$this->heading = new EDI850Heading();
$this->detail = new EDI850Detail();
$this->summary = new EDI850Summary();
$this->functionalGroupTrailer = new GE();
$this->interchangeControlTrailer = new IEA();
}
}

View File

@ -15,6 +15,8 @@ declare(strict_types=1);
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
use phpOMS\Utils\EDI\AnsiX12\Component;
/**
* EDI 850 - Purchase order.
*

View File

@ -15,6 +15,8 @@ declare(strict_types=1);
namespace phpOMS\Utils\EDI\AnsiX12\Purchase;
use phpOMS\Utils\EDI\AnsiX12\Component;
/**
* EDI 850 - Purchase order.
*
@ -46,6 +48,7 @@ class EDI850Heading
public function __construct()
{
$this->headingTransactionSetHeader = new TransactionSetHeader();
$this->headingTransactionSetHeader = new ST(850);
$this->headingBeginningSegmentPO = new BEG();
}
}

View File

@ -15,6 +15,8 @@ declare(strict_types=1);
namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder;
use phpOMS\Utils\EDI\AnsiX12\Component;
/**
* EDI 850 - Purchase order.
*

View File

@ -86,7 +86,6 @@ final class Dictionary
}
sort($count);
while (count($count) > 1) {
$row1 = array_shift($count);
$row2 = array_shift($count);
@ -101,14 +100,14 @@ final class Dictionary
/**
* Fill dictionary.
*
* @param string $entry Source data to generate dictionary from
* @param array $entry Source data to generate dictionary from
* @param string $value Dictionary value
*
* @return void
*
* @since 1.0.0
*/
private function fill(string $entry, string $value = '') /* : void */
private function fill(array $entry, string $value = '') /* : void */
{
if (!is_array($entry[0][1])) {
$this->set($entry[0][1], $value . '0');
@ -143,8 +142,8 @@ final class Dictionary
throw new \Exception('Must be a character.');
}
if (!isset($this->dictionary[$entry])) {
throw new \Exception('Character does not exist');
if (isset($this->dictionary[$entry])) {
throw new \Exception('Character already exists');
}
if (strlen(str_replace('0', '', str_replace('1', '', $value))) !== 0) {

View File

@ -15,6 +15,9 @@ declare(strict_types=1);
namespace phpOMS\Utils\IO\Zip;
use phpOMS\System\File\FileUtils;
use phpOMS\Utils\StringUtils;
/**
* Zip class for handling zip files.
*
@ -34,19 +37,19 @@ class Zip implements ArchiveInterface
*/
public static function pack($sources, string $destination, bool $overwrite = true) : bool
{
$destination = str_replace('\\', '/', realpath($destination));
$destination = FileUtils::absolute(str_replace('\\', '/', $destination));
if (!$overwrite && file_exists($destination)) {
return false;
}
$zip = new \ZipArchive();
if (!$zip->open($destination, $overwrite ? \ZipArchive::OVERWRITE : \ZipArchive::CREATE)) {
if (!$zip->open($destination, $overwrite ? \ZipArchive::CREATE | \ZipArchive::OVERWRITE : \ZipArchive::CREATE)) {
return false;
}
/** @var array $sources */
foreach ($sources as $source) {
foreach ($sources as $source => $relative) {
$source = str_replace('\\', '/', realpath($source));
if (!file_exists($source)) {
@ -67,13 +70,13 @@ class Zip implements ArchiveInterface
$file = realpath($file);
if (is_dir($file)) {
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
$zip->addEmptyDir(str_replace($relative . '/', '', $file . '/'));
} elseif (is_file($file)) {
$zip->addFile(str_replace($source . '/', '', $file), $file);
$zip->addFile(str_replace($relative . '/', '', $file), $file);
}
}
} elseif (is_file($source)) {
$zip->addFile(basename($source), $source);
$zip->addFile($source, $relative);
}
}

View File

@ -26,6 +26,9 @@ namespace phpOMS\Utils\RnG;
*/
class LinearCongruentialGenerator
{
private static $bsdSeed = 0;
private static $msvcrtSeed = 0;
/**
* BSD random number
*
@ -35,11 +38,13 @@ class LinearCongruentialGenerator
*
* @since 1.0.0
*/
public static function bsd(int $seed)
public static function bsd(int $seed = 0)
{
return function () use (&$seed) {
return $seed = (1103515245 * $seed + 12345) % (1 << 31);
};
if($seed !== 0) {
self::$bsdSeed = $seed;
}
return self::$bsdSeed = (1103515245 * self::$bsdSeed + 12345) % (1 << 31);
}
/**
@ -51,10 +56,12 @@ class LinearCongruentialGenerator
*
* @since 1.0.0
*/
public static function msvcrt(int $seed)
public static function msvcrt(int $seed = 0)
{
return function () use (&$seed) {
return ($seed = (214013 * $seed + 2531011) % (1 << 31)) >> 16;
};
if($seed !== 0) {
self::$msvcrtSeed = $seed;
}
return (self::$msvcrtSeed = (214013 * self::$msvcrtSeed + 2531011) % (1 << 31)) >> 16;
}
}

View File

@ -48,6 +48,11 @@ class StringCompare
$this->dictionary = $dictionary;
}
public function add(string $word) /* : void */
{
$this->dictionary[] = $word;
}
/**
* Match word against dictionary.
*
@ -66,6 +71,7 @@ class StringCompare
$score = self::fuzzyMatch($word, $match);
if($score < $bestScore) {
$bestScore = $score;
$bestMatch = $word;
}
}

View File

@ -1,43 +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\Views;
use phpOMS\Stdlib\Base\Enum;
/**
* View layout enum.
*
* @category Framework
* @package phpOMS\Socket
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class ViewLayout extends Enum
{
/* public */ const UNDEFINED = -1;
/* public */ const VALUE = 0;
/* public */ const HEAD = 1;
/* public */ const GLOBAL = 2;
/* public */ const HEADER = 3;
/* public */ const MAIN = 4;
/* public */ const FOOTER = 5;
/* public */ const SIDE = 6;
/* public */ const FUNC = 7;
/* public */ const CLOSURE = 8; // TODO: this could be very dangerous
/* public */ const OBJECT = 9;
/* public */ const NULL = 10;
}