mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
update
This commit is contained in:
parent
b5944503d8
commit
ea0b033e1c
|
|
@ -49,12 +49,24 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
|
||||
private array $availabilityMatrix = [];
|
||||
|
||||
/**
|
||||
* Original points used for clusters
|
||||
*
|
||||
* @var PointInterface[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $points = [];
|
||||
|
||||
/**
|
||||
* @param PointInterface[] $points
|
||||
* Create similarity matrix from points
|
||||
*
|
||||
* @param PointInterface[] $points Points to create the similarity matrix for
|
||||
*
|
||||
* @return array<int, array<int, int|float>>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createSimilarityMatrix(array $points)
|
||||
private function createSimilarityMatrix(array $points) : array
|
||||
{
|
||||
$n = \count($points);
|
||||
$coordinates = \count($points[0]->coordinates);
|
||||
|
|
@ -63,7 +75,6 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
$temp = [];
|
||||
for ($i = 0; $i < $n - 1; ++$i) {
|
||||
for ($j = $i + 1; $j < $n; ++$j) {
|
||||
|
||||
$sum = 0.0;
|
||||
for ($c = 0; $c < $coordinates; ++$c) {
|
||||
$sum += ($points[$i]->getCoordinate($c) - $points[$j]->getCoordinate($c)) * ($points[$i]->getCoordinate($c) - $points[$j]->getCoordinate($c));
|
||||
|
|
@ -71,7 +82,7 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
|
||||
$similarityMatrix[$i][$j] = -$sum;
|
||||
$similarityMatrix[$j][$i] = -$sum;
|
||||
$temp[] = $similarityMatrix[$i][$j];
|
||||
$temp[] = $similarityMatrix[$i][$j];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,14 +100,24 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
return $similarityMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate clusters for points
|
||||
*
|
||||
* @param PointInterface[] $points Points to cluster
|
||||
* @param int $iterations Iterations for cluster generation
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function generateClusters(array $points, int $iterations = 100) : void
|
||||
{
|
||||
$this->points = $points;
|
||||
$n = \count($points);
|
||||
$n = \count($points);
|
||||
|
||||
$this->similarityMatrix = $this->createSimilarityMatrix($points);
|
||||
$this->similarityMatrix = $this->createSimilarityMatrix($points);
|
||||
$this->responsibilityMatrix = clone $this->similarityMatrix;
|
||||
$this->availabilityMatrix = clone $this->similarityMatrix;
|
||||
$this->availabilityMatrix = clone $this->similarityMatrix;
|
||||
|
||||
for ($c = 0; $c < $iterations; ++$c) {
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
|
|
@ -127,7 +148,7 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
$sum += \max(0.0, $this->responsibilityMatrix[$j][$k]);
|
||||
}
|
||||
|
||||
for ($j = $j + 1; $j < $n; ++$j) {
|
||||
for ($j += 1; $j < $n; ++$j) {
|
||||
$sum += \max(0.0, $this->responsibilityMatrix[$j][$k]);
|
||||
}
|
||||
|
||||
|
|
@ -164,15 +185,25 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
}
|
||||
}
|
||||
|
||||
private function findNearestGroup(array $similarityMatrix, int $point, int $clusterCount) : int
|
||||
/**
|
||||
* Find the nearest group for a point
|
||||
*
|
||||
* @param array<int, array<int, int|float> $similarityMatrix Similarity matrix
|
||||
* @param int $point Point id in the similarity matrix to compare
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function findNearestGroup(array $similarityMatrix, int $point) : int
|
||||
{
|
||||
$maxSim = \PHP_INT_MIN;
|
||||
$group = 0;
|
||||
$group = 0;
|
||||
|
||||
foreach ($this->clusterCenters as $c => $_) {
|
||||
if ($similarityMatrix[$point][$c] > $maxSim) {
|
||||
$maxSim = $similarityMatrix[$point][$c];
|
||||
$group = $c;
|
||||
$group = $c;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +223,6 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
$c = $this->findNearestGroup(
|
||||
$similarityMatrix,
|
||||
\count($points) - 1,
|
||||
\count($this->clusterCenters)
|
||||
);
|
||||
|
||||
return $this->clusterCenters[$c];
|
||||
|
|
@ -207,10 +237,9 @@ final class AffinityPropagation implements ClusteringInterface
|
|||
return $this->clusters;
|
||||
}
|
||||
|
||||
$clusterCount = \count($this->clusterCenters);
|
||||
$n = \count($this->points);
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$group = $this->findNearestGroup($this->points, $i, $clusterCount);
|
||||
$group = $this->findNearestGroup($this->points, $i);
|
||||
|
||||
$this->clusters[$group] = $this->points[$i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,13 +69,12 @@ final class AgglomerativeClustering implements ClusteringInterface
|
|||
};
|
||||
|
||||
$this->linkage = $linkage ?? function (array $a, array $b, array $distances) {
|
||||
return AgglomerativeClustering::averageDistanceLinkage($a, $b, $distances);
|
||||
return self::averageDistanceLinkage($a, $b, $distances);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum/Complete-Linkage clustering
|
||||
*
|
||||
*/
|
||||
public static function maximumDistanceLinkage(array $setA, array $setB, array $distances) : float
|
||||
{
|
||||
|
|
@ -93,7 +92,6 @@ final class AgglomerativeClustering implements ClusteringInterface
|
|||
|
||||
/**
|
||||
* Minimum/Single-Linkage clustering
|
||||
*
|
||||
*/
|
||||
public static function minimumDistanceLinkage(array $setA, array $setB, array $distances) : float
|
||||
{
|
||||
|
|
@ -111,7 +109,6 @@ final class AgglomerativeClustering implements ClusteringInterface
|
|||
|
||||
/**
|
||||
* Unweighted average linkage clustering (UPGMA)
|
||||
*
|
||||
*/
|
||||
public static function averageDistanceLinkage(array $setA, array $setB, array $distances) : float
|
||||
{
|
||||
|
|
@ -122,6 +119,4 @@ final class AgglomerativeClustering implements ClusteringInterface
|
|||
|
||||
return $distance / \count($setA) / \count($setB);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ interface ClusteringInterface
|
|||
|
||||
// Not possible to interface due to different implementations
|
||||
// public function generateClusters(...) : void
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Algorithm\Clustering;
|
||||
|
||||
use phpOMS\Math\Topology\MetricsND;
|
||||
|
||||
/**
|
||||
* Clustering points
|
||||
*
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ final class Kmeans implements ClusteringInterface
|
|||
}
|
||||
|
||||
foreach ($this->points as $point) {
|
||||
$c = $this->cluster($point);
|
||||
$c = $this->cluster($point);
|
||||
$this->clusters[$c] = $point;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Job implements JobInterface
|
|||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Cosntructor.
|
||||
* Constructor.
|
||||
*
|
||||
* @param float $value Value of the job
|
||||
* @param \DateTime $start Start time of the job
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Item implements ItemInterface
|
|||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Cosntructor.
|
||||
* Constructor.
|
||||
*
|
||||
* @param float $value Value of the item
|
||||
* @param float $cost Cost of the item
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Path
|
|||
private array $expandedNodes = [];
|
||||
|
||||
/**
|
||||
* Cosntructor.
|
||||
* Constructor.
|
||||
*
|
||||
* @param Grid $grid Grid this path belongs to
|
||||
*
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ final class Elo
|
|||
/**
|
||||
* Calculate an approximated win probability based on elo points.
|
||||
*
|
||||
* @param int $elo1 Elo of the player we want to calculate the win probability for
|
||||
* @param int $elo2 Opponent elo
|
||||
* @param int $elo1 Elo of the player we want to calculate the win probability for
|
||||
* @param int $elo2 Opponent elo
|
||||
* @param bool $canDraw Is a draw possible?
|
||||
*
|
||||
* @return float
|
||||
|
|
|
|||
|
|
@ -40,9 +40,13 @@ class TrueSkill
|
|||
public const DEFAULT_DRAW_PROBABILITY = 0.1;
|
||||
|
||||
private float $mu = 0.0;
|
||||
|
||||
private float $sigma = 0.0;
|
||||
|
||||
private float $beta = 0.0;
|
||||
|
||||
private float $tau = 0.0;
|
||||
|
||||
private float $drawProbability = 0.0;
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -52,25 +56,25 @@ class TrueSkill
|
|||
float $tau = null,
|
||||
float $drawProbability = null)
|
||||
{
|
||||
$this->mu = $mu ?? self::DEFAULT_MU;
|
||||
$this->sigma = $sigma ?? self::DEFAULT_SIGMA;
|
||||
$this->beta = $beta ?? self::DEFAULT_BETA;
|
||||
$this->tau = $tau ?? self::DEFAULT_TAU;
|
||||
$this->mu = $mu ?? self::DEFAULT_MU;
|
||||
$this->sigma = $sigma ?? self::DEFAULT_SIGMA;
|
||||
$this->beta = $beta ?? self::DEFAULT_BETA;
|
||||
$this->tau = $tau ?? self::DEFAULT_TAU;
|
||||
$this->drawProbability = $drawProbability ?? self::DEFAULT_DRAW_PROBABILITY;
|
||||
}
|
||||
|
||||
public function winProbability(array $team1, array $team2, float $drawMargin = 0.0)
|
||||
{
|
||||
$sigmaSum = 0.0;
|
||||
$mu1 = 0.0;
|
||||
$mu1 = 0.0;
|
||||
foreach ($team1 as $player) {
|
||||
$mu1 += $player->mu;
|
||||
$mu1 += $player->mu;
|
||||
$sigmaSum += $player->sigma * $player->sigma;
|
||||
}
|
||||
|
||||
$mu2 = 0.0;
|
||||
foreach ($team2 as $player) {
|
||||
$mu2 += $player->mu;
|
||||
$mu2 += $player->mu;
|
||||
$sigmaSum += $player->sigma * $player->sigma;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
<?php
|
||||
|
||||
// @todo implement address validation (google?)
|
||||
declare(strict_types=1);
|
||||
|
||||
// @todo implement address validation (google?)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use phpOMS\Api\Shipping\ShippingInterface;
|
|||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
|
|
@ -192,7 +193,7 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
$request = new HttpRequest(new HttpUri($uri));
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
|
||||
$request->header->set('Content-Type', 'application/json');
|
||||
$request->header->set('Content-Type', MimeType::M_JSON);
|
||||
$request->header->set('Accept', '*/*');
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($login . ':' . $password));
|
||||
|
||||
|
|
@ -274,14 +275,18 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
array $data
|
||||
) : array
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cancel(string $shipment, array $packages = []) : bool
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function track(string $shipment) : array
|
||||
{
|
||||
$base = self::$ENV === 'live' ? self::LIVE_URL : self::SANDBOX2_URL;
|
||||
|
|
@ -302,7 +307,7 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
$request = new HttpRequest($httpUri);
|
||||
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
$request->header->set('accept', 'application/json');
|
||||
$request->header->set('accept', MimeType::M_JSON);
|
||||
$request->header->set('dhl-api-key', $this->apiKey);
|
||||
|
||||
$response = Rest::request($request);
|
||||
|
|
@ -311,7 +316,7 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
}
|
||||
|
||||
$shipments = $response->getDataArray('shipments') ?? [];
|
||||
$tracking = [];
|
||||
$tracking = [];
|
||||
|
||||
// @todo add general shipment status (not just for individual packages)
|
||||
|
||||
|
|
@ -322,9 +327,9 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
$activities = [];
|
||||
foreach ($package['events'] as $activity) {
|
||||
$activities[] = [
|
||||
'date' => new \DateTime($activity['timestamp']),
|
||||
'date' => new \DateTime($activity['timestamp']),
|
||||
'description' => $activity['description'],
|
||||
'location' => [
|
||||
'location' => [
|
||||
'address' => [
|
||||
$activity['location']['address']['streetAddress'],
|
||||
$activity['location']['address']['addressLocality'],
|
||||
|
|
@ -339,7 +344,7 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
'code' => $activity['statusCode'],
|
||||
'statusCode' => $activity['statusCode'],
|
||||
'description' => $activity['status'],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +363,8 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
'by' => $package['details']['proofOfDelivery']['familyName'],
|
||||
'signature' => $package['details']['proofOfDelivery']['signatureUrl'],
|
||||
'location' => '',
|
||||
'date' => $package['details']['proofOfDelivery']['timestamp']
|
||||
]
|
||||
'date' => $package['details']['proofOfDelivery']['timestamp'],
|
||||
],
|
||||
];
|
||||
|
||||
$tracking[] = $packages;
|
||||
|
|
@ -379,10 +384,20 @@ final class DHLInternationalShipping implements ShippingInterface
|
|||
*/
|
||||
public function label(string $shipment) : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize shipments (no further changes possible)
|
||||
*
|
||||
* @param string[] $shipment Shipments to finalize
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function finalize(array $shipment = []) : bool
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use phpOMS\Localization\ISO3166CharEnum;
|
|||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
|
|
@ -258,7 +259,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
|
||||
$request = new HttpRequest(new HttpUri($uri));
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
$request->header->set('Accept', 'application/json');
|
||||
$request->header->set('Accept', MimeType::M_JSON);
|
||||
$request->header->set('dhl-api-key', $key);
|
||||
|
||||
$response = Rest::request($request);
|
||||
|
|
@ -312,7 +313,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
|
||||
$request = new HttpRequest($httpUri);
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
$request->header->set('Content-Type', 'application/json');
|
||||
$request->header->set('Content-Type', MimeType::M_JSON);
|
||||
$request->header->set('Accept-Language', 'en-US');
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($this->login . ':' . $this->password));
|
||||
|
||||
|
|
@ -320,42 +321,42 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
|
||||
$shipments = [
|
||||
[
|
||||
'product' => 'V01PAK', // V53WPAK, V53WPAK
|
||||
'product' => 'V01PAK', // V53WPAK, V53WPAK
|
||||
'billingNumber' => $data['costcenter'], // @todo maybe dhl number, check
|
||||
'refNo' => $package['id'],
|
||||
'shipper' => [
|
||||
'name1' => $sender['name'],
|
||||
'addressStreet' => $sender['address'],
|
||||
'refNo' => $package['id'],
|
||||
'shipper' => [
|
||||
'name1' => $sender['name'],
|
||||
'addressStreet' => $sender['address'],
|
||||
'additionalAddressInformation1' => $sender['address_addition'],
|
||||
'postalCode' => $sender['zip'],
|
||||
'city' => $sender['city'],
|
||||
'country' => ISO3166CharEnum::getBy2Code($sender['country_code']),
|
||||
'email' => $sender['email'],
|
||||
'phone' => $sender['phone'],
|
||||
'postalCode' => $sender['zip'],
|
||||
'city' => $sender['city'],
|
||||
'country' => ISO3166CharEnum::getBy2Code($sender['country_code']),
|
||||
'email' => $sender['email'],
|
||||
'phone' => $sender['phone'],
|
||||
],
|
||||
'consignee' => [
|
||||
'name1' => $receiver['name'],
|
||||
'addressStreet' => $receiver['address'],
|
||||
'name1' => $receiver['name'],
|
||||
'addressStreet' => $receiver['address'],
|
||||
'additionalAddressInformation1' => $receiver['address_addition'],
|
||||
'postalCode' => $receiver['zip'],
|
||||
'city' => $receiver['city'],
|
||||
'country' => ISO3166CharEnum::getBy2Code($receiver['country_code']),
|
||||
'email' => $receiver['email'],
|
||||
'phone' => $receiver['phone'],
|
||||
'postalCode' => $receiver['zip'],
|
||||
'city' => $receiver['city'],
|
||||
'country' => ISO3166CharEnum::getBy2Code($receiver['country_code']),
|
||||
'email' => $receiver['email'],
|
||||
'phone' => $receiver['phone'],
|
||||
],
|
||||
'details' => [
|
||||
'dim' => [
|
||||
'uom' => 'mm',
|
||||
'uom' => 'mm',
|
||||
'height' => $package['height'],
|
||||
'length' => $package['length'],
|
||||
'width' => $package['width'],
|
||||
'width' => $package['width'],
|
||||
],
|
||||
'weight' => [
|
||||
'uom' => 'g',
|
||||
'uom' => 'g',
|
||||
'value' => $package['weight'],
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$request->setData('shipments', $shipments);
|
||||
|
|
@ -368,23 +369,23 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
$result = $response->getDataArray('items') ?? [];
|
||||
|
||||
$labelUri = new HttpUri($result[0]['label']['url']);
|
||||
$label = $this->label($labelUri->getQuery('token'));
|
||||
$label = $this->label($labelUri->getQuery('token'));
|
||||
|
||||
return [
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'label' => [
|
||||
'code' => $result[0]['label']['format'],
|
||||
'url' => $result[0]['label']['url'],
|
||||
'data' => $label['data'],
|
||||
],
|
||||
'packages' => [
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'label' => [
|
||||
'code' => $result[0]['label']['format'],
|
||||
'url' => $result[0]['label']['url'],
|
||||
'data' => $label['data'],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -445,23 +446,23 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
$result = $response->getDataArray('items') ?? [];
|
||||
|
||||
$labelUri = new HttpUri($result[0]['label']['url']);
|
||||
$label = $this->label($labelUri->getQuery('token'));
|
||||
$label = $this->label($labelUri->getQuery('token'));
|
||||
|
||||
return [
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'label' => [
|
||||
'code' => $result[0]['label']['format'],
|
||||
'url' => $result[0]['label']['url'],
|
||||
'data' => $label['data'],
|
||||
],
|
||||
'packages' => [
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'id' => $result[0]['shipmentNo'],
|
||||
'label' => [
|
||||
'code' => $result[0]['label']['format'],
|
||||
'url' => $result[0]['label']['url'],
|
||||
'data' => $label['data'],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +485,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
|
||||
$request = new HttpRequest($httpUri);
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
$request->header->set('Content-Type', 'application/pdf');
|
||||
$request->header->set('Content-Type', MimeType::M_PDF);
|
||||
|
||||
$response = Rest::request($request);
|
||||
if ($response->header->status !== 200) {
|
||||
|
|
@ -519,7 +520,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
$request = new HttpRequest($httpUri);
|
||||
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
$request->header->set('accept', 'application/json');
|
||||
$request->header->set('accept', MimeType::M_JSON);
|
||||
$request->header->set('dhl-api-key', $this->apiKey);
|
||||
|
||||
$response = Rest::request($request);
|
||||
|
|
@ -528,7 +529,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
}
|
||||
|
||||
$shipments = $response->getDataArray('shipments') ?? [];
|
||||
$tracking = [];
|
||||
$tracking = [];
|
||||
|
||||
// @todo add general shipment status (not just for individual packages)
|
||||
|
||||
|
|
@ -539,9 +540,9 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
$activities = [];
|
||||
foreach ($package['events'] as $activity) {
|
||||
$activities[] = [
|
||||
'date' => new \DateTime($activity['timestamp']),
|
||||
'date' => new \DateTime($activity['timestamp']),
|
||||
'description' => $activity['description'],
|
||||
'location' => [
|
||||
'location' => [
|
||||
'address' => [
|
||||
$activity['location']['address']['streetAddress'],
|
||||
$activity['location']['address']['addressLocality'],
|
||||
|
|
@ -556,7 +557,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
'code' => $activity['statusCode'],
|
||||
'statusCode' => $activity['statusCode'],
|
||||
'description' => $activity['status'],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -575,8 +576,8 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
'by' => $package['details']['proofOfDelivery']['familyName'],
|
||||
'signature' => $package['details']['proofOfDelivery']['signatureUrl'],
|
||||
'location' => '',
|
||||
'date' => $package['details']['proofOfDelivery']['timestamp']
|
||||
]
|
||||
'date' => $package['details']['proofOfDelivery']['timestamp'],
|
||||
],
|
||||
];
|
||||
|
||||
$tracking[] = $packages;
|
||||
|
|
@ -615,10 +616,10 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
}
|
||||
|
||||
return [
|
||||
'date' => $response->getDataDateTime('manifestDate'),
|
||||
'b64' => $response->getDataArray('manifest')['b64'],
|
||||
'zpl2' => $response->getDataArray('manifest')['zpl2'],
|
||||
'url' => $response->getDataArray('manifest')['url'],
|
||||
'date' => $response->getDataDateTime('manifestDate'),
|
||||
'b64' => $response->getDataArray('manifest')['b64'],
|
||||
'zpl2' => $response->getDataArray('manifest')['zpl2'],
|
||||
'url' => $response->getDataArray('manifest')['url'],
|
||||
'format' => $response->getDataArray('manifest')['printFormat'],
|
||||
];
|
||||
}
|
||||
|
|
@ -644,7 +645,7 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
|
||||
$request = new HttpRequest($httpUri);
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
$request->header->set('Content-Type', 'application/json');
|
||||
$request->header->set('Content-Type', MimeType::M_JSON);
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($this->login . ':' . $this->password));
|
||||
|
||||
if (!empty($shipment)) {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\DHL;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -33,4 +29,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class DHLParcelDEShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\DPD;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -32,4 +28,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class DPDShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\Fedex;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -31,4 +27,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class FedexShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\RoyalMail;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -31,4 +27,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class RoyalMailShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping;
|
||||
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
|
||||
/**
|
||||
* Shipping interface.
|
||||
|
|
@ -32,7 +31,7 @@ use phpOMS\Message\Http\HttpResponse;
|
|||
*
|
||||
* @todo implement Sender, Receiver, Package, Transit, Tracking classes for better type hinting instead of arrays
|
||||
*
|
||||
* @property string $ENV ('live' = live environment, 'test' or 'sandbox' = test environment)
|
||||
* @property string $ENV ('live' = live environment, 'test' or 'sandbox' = test environment)
|
||||
* @property string $client
|
||||
* @property string $token
|
||||
* @property string $refreshToken
|
||||
|
|
@ -93,7 +92,7 @@ interface ShippingInterface
|
|||
*
|
||||
* @param string $login Login name/email
|
||||
* @param string $password Password
|
||||
* @param HttpRequest $redirect Redirect request after the user successfully logged in.
|
||||
* @param HttpRequest $redirect redirect request after the user successfully logged in
|
||||
*
|
||||
* @return int Returns auth status
|
||||
*
|
||||
|
|
@ -131,7 +130,7 @@ interface ShippingInterface
|
|||
*
|
||||
* @param array $sender Sender
|
||||
* @param array $shipFrom Ship from location (sometimes sender != pickup location)
|
||||
* @param array $recevier Receiver
|
||||
* @param array $receiver Receiver
|
||||
* @param array $package Package
|
||||
* @param array $data Shipping data
|
||||
*
|
||||
|
|
@ -150,7 +149,7 @@ interface ShippingInterface
|
|||
/**
|
||||
* Cancel shipment.
|
||||
*
|
||||
* @param string $shipment Shipment id
|
||||
* @param string $shipment Shipment id
|
||||
* @param string[] $packages Packed ids (if a shipment consists of multiple packages)
|
||||
*
|
||||
* @return bool
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\TNT;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -31,4 +27,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class TNTShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use phpOMS\Api\Shipping\ShippingInterface;
|
|||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
|
|
@ -177,7 +178,7 @@ final class UPSShipping implements ShippingInterface
|
|||
$request = new HttpRequest(new HttpUri($uri));
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
$request->setData('grant_type', 'client_credentials');
|
||||
$request->header->set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
$request->header->set('Content-Type', MimeType::M_POST);
|
||||
$request->header->set('x-merchant-id', $client);
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($login . ':' . $password));
|
||||
|
||||
|
|
@ -255,7 +256,7 @@ final class UPSShipping implements ShippingInterface
|
|||
// Personally I don't see why a redirect is required or even helpful. Will try without it!
|
||||
$request->setData('grant_type', 'authorization_code');
|
||||
$request->setData('code', $code);
|
||||
$request->header->set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
$request->header->set('Content-Type', MimeType::M_POST);
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($login . ':' . $password));
|
||||
|
||||
$this->expire = new \DateTime('now');
|
||||
|
|
@ -306,7 +307,7 @@ final class UPSShipping implements ShippingInterface
|
|||
$request = new HttpRequest(new HttpUri($uri));
|
||||
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
$request->header->set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
$request->header->set('Content-Type', MimeType::M_POST);
|
||||
$request->header->set('Authorization', 'Basic ' . \base64_encode($this->login . ':' . $this->password));
|
||||
|
||||
$request->setData('grant_type', 'refresh_token');
|
||||
|
|
@ -367,7 +368,7 @@ final class UPSShipping implements ShippingInterface
|
|||
$request = new HttpRequest(new HttpUri($uri));
|
||||
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
$request->header->set('Content-Type', 'application/json');
|
||||
$request->header->set('Content-Type', MimeType::M_JSON);
|
||||
$request->header->set('Authorization', 'Bearer ' . $this->token);
|
||||
$request->header->set('transId', ((string) \microtime(true)) . '-' . \bin2hex(\random_bytes(6)));
|
||||
$request->header->set('transactionSrc', 'jingga');
|
||||
|
|
@ -402,10 +403,10 @@ final class UPSShipping implements ShippingInterface
|
|||
|
||||
foreach ($services as $service) {
|
||||
$transits[] = [
|
||||
'serviceLevel' => $service['serviceLevel'],
|
||||
'deliveryDate' => new \DateTime($service['deliveryDaye']),
|
||||
'serviceLevel' => $service['serviceLevel'],
|
||||
'deliveryDate' => new \DateTime($service['deliveryDaye']),
|
||||
'deliveryDateFrom' => null,
|
||||
'deliveryDateTo' => null,
|
||||
'deliveryDateTo' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -440,9 +441,9 @@ final class UPSShipping implements ShippingInterface
|
|||
'SubVersion' => '2205',
|
||||
],
|
||||
'Shipment' => [
|
||||
'Description' => $package['description'],
|
||||
'Description' => $package['description'],
|
||||
'DocumentsOnlyIndicator' => '0',
|
||||
'Shipper' => [
|
||||
'Shipper' => [
|
||||
'Name' => \substr($sender['name'], 0, 35),
|
||||
'AttentionName' => \substr($sender['fao'], 0, 35),
|
||||
'CompanyDisplayableName' => \substr($sender['name'], 0, 35),
|
||||
|
|
@ -452,7 +453,7 @@ final class UPSShipping implements ShippingInterface
|
|||
],
|
||||
'ShipperNumber' => $sender['number'],
|
||||
'EMailAddress' => \substr($sender['email'], 0, 50),
|
||||
'Address' => [
|
||||
'Address' => [
|
||||
'AddressLine' => \substr($sender['address'], 0, 35),
|
||||
'City' => \substr($sender['city'], 0, 30),
|
||||
'StateProvinceCode' => \substr($sender['state'], 0, 5),
|
||||
|
|
@ -470,7 +471,7 @@ final class UPSShipping implements ShippingInterface
|
|||
],
|
||||
'ShipperNumber' => $receiver['number'],
|
||||
'EMailAddress' => \substr($receiver['email'], 0, 50),
|
||||
'Address' => [
|
||||
'Address' => [
|
||||
'AddressLine' => \substr($receiver['address'], 0, 35),
|
||||
'City' => \substr($receiver['city'], 0, 30),
|
||||
'StateProvinceCode' => \substr($receiver['state'], 0, 5),
|
||||
|
|
@ -497,7 +498,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'CostCenter' => \substr($package['costcenter'], 0, 30),
|
||||
'PackageID' => \substr($package['id'], 0, 30),
|
||||
'PackageIDBarcodeIndicator' => '1',
|
||||
'Package' => []
|
||||
'Package' => [],
|
||||
],
|
||||
'LabelSpecification' => [
|
||||
'LabelImageFormat' => [
|
||||
|
|
@ -507,13 +508,13 @@ final class UPSShipping implements ShippingInterface
|
|||
'LabelStockSize' => [
|
||||
'Height' => $data['label_height'],
|
||||
'Width' => $data['label_width'],
|
||||
]
|
||||
],
|
||||
],
|
||||
'ReceiptSpecification' => [
|
||||
'ImageFormat' => [
|
||||
'Code' => $data['receipt_code'],
|
||||
'Description' => \substr($data['receipt_description'], 0, 35),
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -521,13 +522,13 @@ final class UPSShipping implements ShippingInterface
|
|||
foreach ($package['packages'] as $p) {
|
||||
$packages[] = [
|
||||
'Description' => \substr($p['description'], 0, 35),
|
||||
'Packaging' => [
|
||||
'Packaging' => [
|
||||
'Code' => $p['package_code'],
|
||||
'Description' => $p['package_description']
|
||||
'Description' => $p['package_description'],
|
||||
],
|
||||
'Dimensions' => [
|
||||
'UnitOfMeasurement' => [
|
||||
'Code' => $p['package_dim_unit'], // IN or CM or 00 or 01
|
||||
'Code' => $p['package_dim_unit'], // IN or CM or 00 or 01
|
||||
'Description' => \substr($p['package_dim_unit_description'], 0, 35),
|
||||
],
|
||||
'Length' => $p['length'],
|
||||
|
|
@ -547,7 +548,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'Description' => \substr($p['package_weight_unit_description'], 0, 35),
|
||||
],
|
||||
'Weight' => $p['weight'],
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
|
@ -566,7 +567,7 @@ final class UPSShipping implements ShippingInterface
|
|||
],
|
||||
'ShipperNumber' => $shipFrom['number'],
|
||||
'EMailAddress' => \substr($shipFrom['email'], 0, 50),
|
||||
'Address' => [
|
||||
'Address' => [
|
||||
'AddressLine' => \substr($shipFrom['address'], 0, 35),
|
||||
'City' => \substr($shipFrom['city'], 0, 30),
|
||||
'StateProvinceCode' => \substr($shipFrom['state'], 0, 5),
|
||||
|
|
@ -586,7 +587,7 @@ final class UPSShipping implements ShippingInterface
|
|||
$result = $response->getDataArray('ShipmentResponse') ?? [];
|
||||
|
||||
$shipment = [
|
||||
'id' => $result['ShipmentResults']['ShipmentIdentificationNumber'] ?? '',
|
||||
'id' => $result['ShipmentResults']['ShipmentIdentificationNumber'] ?? '',
|
||||
'costs' => [
|
||||
'service' => $result['ShipmentResults']['ShipmentCharges']['BaseServiceCharge']['MonetaryValue'] ?? null,
|
||||
'transportation' => $result['ShipmentResults']['ShipmentCharges']['TransportationCharges']['MonetaryValue'] ?? null,
|
||||
|
|
@ -598,38 +599,38 @@ final class UPSShipping implements ShippingInterface
|
|||
'currency' => $result['ShipmentResults']['ShipmentCharges']['TotalCharges']['CurrencyCode'] ?? null,
|
||||
],
|
||||
'packages' => [],
|
||||
'label' => [
|
||||
'code' => '',
|
||||
'url' => $result['ShipmentResults']['LabelURL'] ?? '',
|
||||
'label' => [
|
||||
'code' => '',
|
||||
'url' => $result['ShipmentResults']['LabelURL'] ?? '',
|
||||
'barcode' => $result['ShipmentResults']['BarCodeImage'] ?? '',
|
||||
'local' => $result['ShipmentResults']['LocalLanguageLabelURL'] ?? '',
|
||||
'local' => $result['ShipmentResults']['LocalLanguageLabelURL'] ?? '',
|
||||
'data' => '',
|
||||
],
|
||||
'receipt' => [
|
||||
'code' => '',
|
||||
'url' => $result['ShipmentResults']['ReceiptURL'] ?? '',
|
||||
'local' => $result['ShipmentResults']['LocalLanguageReceiptURL'] ?? '',
|
||||
'data' => '',
|
||||
]
|
||||
'data' => '',
|
||||
],
|
||||
// @todo dangerous goods paper image
|
||||
];
|
||||
|
||||
$packages = [];
|
||||
foreach ($result['ShipmentResults']['Packages'] as $package) {
|
||||
$packages[] = [
|
||||
'id' => $package['TrackingNumber'],
|
||||
'id' => $package['TrackingNumber'],
|
||||
'label' => [
|
||||
'code' => $package['ShippingLabel']['ImageFormat']['Code'],
|
||||
'code' => $package['ShippingLabel']['ImageFormat']['Code'],
|
||||
'url' => '',
|
||||
'barcode' => $package['PDF417'],
|
||||
'image' => $package['ShippingLabel']['GraphicImage'],
|
||||
'browser' => $package['HTMLImage'],
|
||||
'data' => '',
|
||||
'barcode' => $package['PDF417'],
|
||||
'image' => $package['ShippingLabel']['GraphicImage'],
|
||||
'browser' => $package['HTMLImage'],
|
||||
'data' => '',
|
||||
],
|
||||
'receipt' => [
|
||||
'code' => $package['ShippingReceipt']['ImageFormat']['Code'],
|
||||
'image' => $package['ShippingReceipt']['ImageFormat']['GraphicImage'],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -707,9 +708,9 @@ final class UPSShipping implements ShippingInterface
|
|||
$activities = [];
|
||||
foreach ($package['activity'] as $activity) {
|
||||
$activities[] = [
|
||||
'date' => new \DateTime($activity['date'] . ' ' . $activity['time']),
|
||||
'date' => new \DateTime($activity['date'] . ' ' . $activity['time']),
|
||||
'description' => '',
|
||||
'location' => [
|
||||
'location' => [
|
||||
'address' => [
|
||||
$activity['location']['address']['addressLine1'],
|
||||
$activity['location']['address']['addressLine2'],
|
||||
|
|
@ -725,7 +726,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'code' => $activity['status']['code'],
|
||||
'statusCode' => $activity['status']['statusCode'],
|
||||
'description' => $activity['status']['description'],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -745,7 +746,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'signature' => $package['deliveryInformation']['signature'],
|
||||
'location' => $package['deliveryInformation']['location'],
|
||||
'date' => '',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping\Usps;
|
||||
|
||||
use phpOMS\Api\Shipping\ShippingInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\Http\Rest;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Shipment api.
|
||||
|
|
@ -31,4 +27,4 @@ use phpOMS\Uri\HttpUri;
|
|||
*/
|
||||
final class UspsShipping implements ShippingInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,17 @@ final class Autoloader
|
|||
$class = \ltrim($class, '\\');
|
||||
$class = \strtr($class, '_\\', '//');
|
||||
|
||||
if (self::$useClassMap) {
|
||||
$nspacePos = \strpos($class, '/');
|
||||
$subclass = $nspacePos === false ? '' : \substr($class, 0, $nspacePos);
|
||||
|
||||
if (isset(self::$classmap[$subclass])) {
|
||||
$found[] = self::$classmap[$subclass] . $class . '.php';
|
||||
|
||||
return $found;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$paths as $path) {
|
||||
if (\is_file($file = $path . $class . '.php')) {
|
||||
$found[] = $file;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ final class Metrics
|
|||
}
|
||||
|
||||
/**
|
||||
* Calculate the profitability of customers based on their purchase behaviour
|
||||
* Calculate the profitability of customers based on their purchase behavior
|
||||
*
|
||||
* The basis for the calculation is the migration model using a markov chain
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ final class ArticleCorrelationAffinity
|
|||
private array $affinity = [];
|
||||
|
||||
/**
|
||||
* Item order behaviour (when are which items ordered)
|
||||
* Item order behavior (when are which items ordered)
|
||||
*
|
||||
* In tearms of the pearson correlation these are our random variables
|
||||
*
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ abstract class MapperType extends Enum
|
|||
|
||||
public const GET_RANDOM = 11;
|
||||
|
||||
// @IMPORTANT All read operations which use column names must have an ID < 12
|
||||
// In the read mapper exists a line which checks for < COUNT_MODELS to decide if columns should be selected.
|
||||
// The reason for this is that **pure** count, sum, ... don't want to select additional column names.
|
||||
// By doing this we avoid loading all the unwanted columns coming from the `with()` relation.
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
||||
public const COUNT_MODELS = 12;
|
||||
|
||||
public const SUM_MODELS = 13;
|
||||
|
|
|
|||
|
|
@ -536,9 +536,14 @@ final class ReadMapper extends DataMapperAbstract
|
|||
public function getQuery(Builder $query = null, array $columns = []) : Builder
|
||||
{
|
||||
$query ??= $this->query ?? new Builder($this->db, true);
|
||||
$columns = empty($columns)
|
||||
? (empty($this->columns) ? $this->mapper::COLUMNS : $this->columns)
|
||||
: $columns;
|
||||
|
||||
if (empty($columns) && $this->type < MapperType::COUNT_MODELS) {
|
||||
if (empty($this->columns)) {
|
||||
$columns = $this->mapper::COLUMNS;
|
||||
} else {
|
||||
$columns = $this->columns;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($columns as $key => $values) {
|
||||
if (\is_string($values) || \is_int($values)) {
|
||||
|
|
@ -731,6 +736,7 @@ final class ReadMapper extends DataMapperAbstract
|
|||
/** @var self $relMapper */
|
||||
$relMapper = $this->createRelationMapper($rel['mapper']::reader(db: $this->db), $member);
|
||||
$relMapper->depth = $this->depth + 1;
|
||||
$relMapper->type = $this->type;
|
||||
|
||||
$query = $relMapper->getQuery(
|
||||
$query,
|
||||
|
|
@ -846,7 +852,7 @@ final class ReadMapper extends DataMapperAbstract
|
|||
}
|
||||
|
||||
if (empty($value)) {
|
||||
// @todo find better solution. this was because of a bug with the sales billing list query depth = 4. The address was set (from the client, referral or creator) but then somehow there was a second address element which was all null and null cannot be asigned to a string variable (e.g. country). The problem with this solution is that if the model expects an initialization (e.g. at lest set the elements to null, '', 0 etc.) this is now not done.
|
||||
// @todo find better solution. this was because of a bug with the sales billing list query depth = 4. The address was set (from the client, referral or creator) but then somehow there was a second address element which was all null and null cannot be assigned to a string variable (e.g. country). The problem with this solution is that if the model expects an initialization (e.g. at lest set the elements to null, '', 0 etc.) this is now not done.
|
||||
$value = $isPrivate ? $refProp->getValue($obj) : $obj->{$member};
|
||||
}
|
||||
} elseif (isset($this->mapper::BELONGS_TO[$def['internal']])) {
|
||||
|
|
@ -912,10 +918,16 @@ final class ReadMapper extends DataMapperAbstract
|
|||
|
||||
// @todo How is this allowed? at the bottom we set $obj->hasMany = value. A has many should be always an array?!
|
||||
foreach ($this->mapper::HAS_MANY as $member => $def) {
|
||||
if (!isset($this->with[$member])
|
||||
|| !isset($def['column']) // @todo is this required? The code below indicates that this might be stupid
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$column = $def['mapper']::getColumnByMember($def['column'] ?? $member);
|
||||
$alias = $column . '_d' . ($this->depth + 1);
|
||||
|
||||
if (!\array_key_exists($alias, $result) || !isset($def['column'])) {
|
||||
if (!\array_key_exists($alias, $result)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1145,7 +1157,7 @@ final class ReadMapper extends DataMapperAbstract
|
|||
->where($many['table'] . '.' . $many['self'], '=', $primaryKey);
|
||||
|
||||
// Cannot use join, because join only works on members and we don't have members for a relation table
|
||||
// This is why we need to create a "base" query which contians the join on table columns
|
||||
// This is why we need to create a "base" query which contains the join on table columns
|
||||
$objectMapper->query($query);
|
||||
}
|
||||
|
||||
|
|
@ -1162,12 +1174,12 @@ final class ReadMapper extends DataMapperAbstract
|
|||
$refProp = $refClass->getProperty($member);
|
||||
$refProp->setValue($obj, !\is_array($objects) && ($many['conditional'] ?? false) === false
|
||||
? [$many['mapper']::getObjectId($objects) => $objects]
|
||||
: $objects // if conditional === true the obj will be asigned (e.g. has many localizations but only one is loaded for the model)
|
||||
: $objects // if conditional === true the obj will be assigned (e.g. has many localizations but only one is loaded for the model)
|
||||
);
|
||||
} else {
|
||||
$obj->{$member} = !\is_array($objects) && ($many['conditional'] ?? false) === false
|
||||
? [$many['mapper']::getObjectId($objects) => $objects]
|
||||
: $objects; // if conditional === true the obj will be asigned (e.g. has many localizations but only one is loaded for the model)
|
||||
: $objects; // if conditional === true the obj will be assigned (e.g. has many localizations but only one is loaded for the model)
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
@ -1244,7 +1256,7 @@ final class ReadMapper extends DataMapperAbstract
|
|||
->where($many['table'] . '.' . $many['self'], '=', $primaryKey);
|
||||
|
||||
// Cannot use join, because join only works on members and we don't have members for a relation table
|
||||
// This is why we need to create a "base" query which contians the join on table columns
|
||||
// This is why we need to create a "base" query which contains the join on table columns
|
||||
$objectMapper->query($query);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -458,9 +458,11 @@ class Grammar extends GrammarAbstract
|
|||
$expression .= '(' . \rtrim($this->compileWhereQuery($element['column']), ';') . ')';
|
||||
}
|
||||
|
||||
// @todo on doesn't allow values as value (only table column names). This is bad and needs to be fixed!
|
||||
// @todo on doesn't allow string values as value (only table column names). This is bad and needs to be fixed!
|
||||
// Other types such as int etc. are kind of possible
|
||||
if (isset($element['value'])) {
|
||||
$expression .= ' ' . \strtoupper($element['operator']) . ' ' . $this->compileSystem($element['value']);
|
||||
$expression .= ' ' . \strtoupper($element['operator']) . ' '
|
||||
. (\is_string($element['value']) ? $this->compileSystem($element['value']) : $element['value']);
|
||||
} else {
|
||||
$operator = $element['operator'] === '=' ? 'IS' : 'IS NOT';
|
||||
$expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value']);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ final class Kernel
|
|||
/**
|
||||
* Apply kernel matrix
|
||||
*
|
||||
* @param string $inParth Image file path
|
||||
* @param string $inPath Image file path
|
||||
* @param string $outPath Image output path
|
||||
* @param array $kernel Kernel matrix
|
||||
*
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
|
||||
if ($mDim > 10 || $nDim > 10) {
|
||||
// Standard transposed for iteration over rows -> higher cache hit
|
||||
$transposedMatrixArr = array();
|
||||
$transposedMatrixArr = [];
|
||||
for ($k = 0; $k < $mDim; ++$k) {
|
||||
for ($j = 0; $j < $nDim; ++$j) {
|
||||
$transposedMatrixArr[$k][$j] = $matrixArr[$j][$k];
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ final class Vector extends Matrix
|
|||
return $dotProduct / ($magnitude1 * $magnitude2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the eucledian dot product
|
||||
*
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ final class Simplex
|
|||
}
|
||||
}
|
||||
|
||||
$this->b[$x] /= -$this->A[$x][$y];
|
||||
$this->b[$x] /= -$this->A[$x][$y];
|
||||
$this->A[$x][$y] = 1.0 / $this->A[$x][$y];
|
||||
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
|
|
@ -142,7 +142,7 @@ final class Simplex
|
|||
}
|
||||
}
|
||||
|
||||
$this->b[$i] += $this->A[$i][$y] * $this->b[$x];
|
||||
$this->b[$i] += $this->A[$i][$y] * $this->b[$x];
|
||||
$this->A[$i][$y] *= $this->A[$x][$y];
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ final class Simplex
|
|||
}
|
||||
}
|
||||
|
||||
$this->v += $this->c[$y] * $this->b[$x];
|
||||
$this->v += $this->c[$y] * $this->b[$x];
|
||||
$this->c[$y] *= $this->A[$x][$y];
|
||||
|
||||
$temp = $this->basic[$x];
|
||||
|
|
@ -329,7 +329,7 @@ final class Simplex
|
|||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
if ($j === $this->nonbasic[$k]) {
|
||||
$this->c[$k] += $oldC[$j];
|
||||
$ok = true;
|
||||
$ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -357,10 +357,10 @@ final class Simplex
|
|||
* Solve simplex problem
|
||||
*
|
||||
* @param array<int, array<int|float>> $A Bounding equations
|
||||
* @param int[]|float[] $b Boundings for equations
|
||||
* @param int[]|float[] $c Equation to maximize
|
||||
* @param int[]|float[] $b Boundings for equations
|
||||
* @param int[]|float[] $c Equation to maximize
|
||||
*
|
||||
* @return array{0:array<int|float>, 1:float}
|
||||
* @return array<void>|array{0:array<int|float>, 1:float}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -374,6 +374,10 @@ final class Simplex
|
|||
// @todo create minimize
|
||||
|
||||
$this->m = \count($A);
|
||||
if ($this->m < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->n = \count(\reset($A));
|
||||
|
||||
if ($this->initialize() === -1) {
|
||||
|
|
|
|||
|
|
@ -215,6 +215,47 @@ abstract class RequestAbstract implements MessageInterface
|
|||
: new \DateTime((string) $this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
* @param string $key Data key
|
||||
*
|
||||
* @return null|\DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getDataDateTimeFromTimestamp(string $key) : ?\DateTime
|
||||
{
|
||||
$key = \mb_strtolower($key);
|
||||
|
||||
if (empty($this->data[$key] ?? null)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dt = new \DateTime();
|
||||
$dt->setTimestamp((int) $this->data[$key]);
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
* @param string $key Data key
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getDataTimestampFromDateTime(string $key) : ?int
|
||||
{
|
||||
$key = \mb_strtolower($key);
|
||||
|
||||
return empty($this->data[$key] ?? null)
|
||||
? null
|
||||
: \strtotime((string) $this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ final class ModuleInfo
|
|||
/**
|
||||
* Info data.
|
||||
*
|
||||
* @var array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, description:string, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>}|array
|
||||
* @var array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>}|array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $info = [];
|
||||
|
|
@ -86,7 +86,7 @@ final class ModuleInfo
|
|||
|
||||
$contents = \file_get_contents($this->path);
|
||||
|
||||
/** @var array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, description:string, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>} $info */
|
||||
/** @var array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>} $info */
|
||||
$info = \json_decode($contents === false ? '[]' : $contents, true);
|
||||
$this->info = $info === false ? [] : $info;
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ final class ModuleInfo
|
|||
/**
|
||||
* Get info data.
|
||||
*
|
||||
* @return array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, description:string, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>}|array
|
||||
* @return array{name:array{id:int, internal:string, external:string}, category:string, vision:string, requirements:array, creator:array{name:string, website:string}, directory:string, dependencies:array<string, string>, providing:array<string, string>, load:array<int, array{pid:string[], type:int, for:string, file:string, from:string}>}|array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Address extends Location
|
|||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return \array_merge (
|
||||
return \array_merge(
|
||||
[
|
||||
'name' => $this->name,
|
||||
'fao' => $this->fao,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class SmartDateTime extends \DateTime
|
|||
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
||||
|
||||
$monthNew = (int) $this->format('m') + $m;
|
||||
$monthNew = $monthNew < 0
|
||||
$monthNew = $monthNew <= 0
|
||||
? 12 + ($monthNew - 1) % 12 + 1
|
||||
: ($monthNew - 1) % 12 + 1;
|
||||
|
||||
|
|
@ -445,4 +445,32 @@ class SmartDateTime extends \DateTime
|
|||
|
||||
return \abs(($mod < 0 ? 12 + $mod : $mod) % 12) + 1;
|
||||
}
|
||||
|
||||
public static function formatDuration(int $duration) : string
|
||||
{
|
||||
$days = \floor($duration / (24 * 3600));
|
||||
$hours = \floor(($duration % (24 * 3600)) / 3600);
|
||||
$minutes = \floor(($duration % 3600) / 60);
|
||||
$seconds = $duration % 60;
|
||||
|
||||
$result = '';
|
||||
|
||||
if ($days > 0) {
|
||||
$result .= \sprintf('%02dd', $days);
|
||||
}
|
||||
|
||||
if ($hours > 0) {
|
||||
$result .= \sprintf('%02dh', $hours);
|
||||
}
|
||||
|
||||
if ($minutes > 0) {
|
||||
$result .= \sprintf('%02dm', $minutes);
|
||||
}
|
||||
|
||||
if ($seconds > 0) {
|
||||
$result .= \sprintf('%02ds', $seconds);
|
||||
}
|
||||
|
||||
return \rtrim($result, ' ');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ class Node
|
|||
{
|
||||
return [
|
||||
'key' => $this->key,
|
||||
0 => $this->left?->toArray(),
|
||||
1 => $this->right?->toArray(),
|
||||
0 => $this->left?->toArray(),
|
||||
1 => $this->right?->toArray(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -734,9 +734,8 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
}
|
||||
|
||||
$state = $this->copyNode($to, $overwrite);
|
||||
$state = $state && $this->deleteNode();
|
||||
|
||||
return $state;
|
||||
return $state && $this->deleteNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -549,9 +549,8 @@ class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
$state = $this->copyNode($to, $overwrite);
|
||||
$state = $state && $this->deleteNode();
|
||||
|
||||
return $state;
|
||||
return $state && $this->deleteNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -660,9 +660,8 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
|||
public function moveNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
$state = $this->copyNode($to, $overwrite);
|
||||
$state = $state && $this->deleteNode();
|
||||
|
||||
return $state;
|
||||
return $state && $this->deleteNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -509,9 +509,8 @@ final class File extends FileAbstract implements FileInterface
|
|||
public function moveNode(string $to, bool $overwrite = false) : bool
|
||||
{
|
||||
$state = $this->copyNode($to, $overwrite);
|
||||
$state = $state && $this->deleteNode();
|
||||
|
||||
return $state;
|
||||
return $state && $this->deleteNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ final class SystemUtils
|
|||
}
|
||||
|
||||
$status = \proc_close($resource);
|
||||
|
||||
if ($status == -1) {
|
||||
throw new \Exception((string) $stderr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,9 +383,19 @@ final class HttpUri implements UriInterface
|
|||
$this->query = \array_change_key_case($this->query, \CASE_LOWER);
|
||||
}
|
||||
|
||||
public function addQuery(string $key, mixed $value = null)
|
||||
/**
|
||||
* Add query parameter
|
||||
*
|
||||
* @param string $key Parameter key
|
||||
* @param mixed $value Value (null = omitted)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addQuery(string $key, mixed $value = null) : void
|
||||
{
|
||||
$key = \strtolower($key);
|
||||
$key = \strtolower($key);
|
||||
$this->query[$key] = $value;
|
||||
|
||||
$toAdd = (empty($this->queryString) ? '?' : '&')
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Utils;
|
||||
|
||||
use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
|
||||
|
||||
/**
|
||||
* Array utils.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ class Markdown
|
|||
* @since 1.0.0
|
||||
*/
|
||||
private const CONTINUABLE = [
|
||||
'Code', 'Comment', 'FencedCode', 'List', 'Quote', 'Table', 'Math', 'Spoiler', 'Checkbox', 'Footnote', 'DefinitionList', 'Markup'
|
||||
'Code', 'Comment', 'FencedCode', 'List', 'Quote', 'Table', 'Math', 'Spoiler', 'Checkbox', 'Footnote', 'DefinitionList', 'Markup',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -302,7 +302,7 @@ class Markdown
|
|||
* @since 1.0.0
|
||||
*/
|
||||
private const COMPLETABLE = [
|
||||
'Math', 'Spoiler', 'Table', 'Checkbox', 'Footnote', 'Markup', 'Code', 'FencedCode', 'List'
|
||||
'Math', 'Spoiler', 'Table', 'Checkbox', 'Footnote', 'Markup', 'Code', 'FencedCode', 'List',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -598,7 +598,7 @@ class Markdown
|
|||
// Add footnotes
|
||||
if (isset($this->definitionData['Footnote'])) {
|
||||
$element = $this->buildFootnoteElement();
|
||||
$html .= "\n" . $this->element($element);
|
||||
$html .= "\n" . $this->element($element);
|
||||
}
|
||||
|
||||
return $this->decodeToCTagFromHash($html); // Unescape the ToC tag
|
||||
|
|
@ -935,7 +935,7 @@ class Markdown
|
|||
protected function inlineUrl(array $excerpt) : ?array
|
||||
{
|
||||
if (!($this->options['links'] ?? true)
|
||||
|| $this->urlsLinked !== true || !\str_starts_with($excerpt['text'], '://')
|
||||
|| !$this->urlsLinked || !\str_starts_with($excerpt['text'], '://')
|
||||
|| \strpos($excerpt['context'], 'http') === false
|
||||
|| \preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $excerpt['context'], $matches, \PREG_OFFSET_CAPTURE) !== 1
|
||||
) {
|
||||
|
|
@ -1276,27 +1276,27 @@ class Markdown
|
|||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'span',
|
||||
'name' => 'span',
|
||||
'attributes' => [
|
||||
'class' => 'spoiler'
|
||||
'class' => 'spoiler',
|
||||
],
|
||||
'elements' => [
|
||||
[
|
||||
'name' => 'input',
|
||||
'name' => 'input',
|
||||
'attributes' => [
|
||||
'type' => 'checkbox'
|
||||
]
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $matches[1],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handle keystrokes
|
||||
*
|
||||
* @param array{text:string, context:string, before:string} $excerpt Inline data
|
||||
|
|
@ -1307,7 +1307,7 @@ class Markdown
|
|||
*/
|
||||
protected function inlineKeystrokes(array $excerpt) : ?array
|
||||
{
|
||||
if (!str_starts_with($excerpt['text'], '[[')
|
||||
if (!\str_starts_with($excerpt['text'], '[[')
|
||||
|| \preg_match('/^(?<!\[)(?:\[\[([^\[\]]*|[\[\]])\]\])(?!\])/s', $excerpt['text'], $matches) !== 1
|
||||
) {
|
||||
return null;
|
||||
|
|
@ -1354,61 +1354,61 @@ class Markdown
|
|||
|
||||
switch ($type) {
|
||||
case 'youtube':
|
||||
$element = 'iframe';
|
||||
$element = 'iframe';
|
||||
$attributes = [
|
||||
'src' => \preg_replace('/.*\?v=([^\&\]]*).*/', 'https://www.youtube.com/embed/$1', $url),
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'src' => \preg_replace('/.*\?v=([^\&\]]*).*/', 'https://www.youtube.com/embed/$1', $url),
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'allowfullscreen' => '',
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms'
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
||||
];
|
||||
break;
|
||||
case 'vimeo':
|
||||
$element = 'iframe';
|
||||
$element = 'iframe';
|
||||
$attributes = [
|
||||
'src' => \preg_replace('/(?:https?:\/\/(?:[\w]{3}\.|player\.)*vimeo\.com(?:[\/\w:]*(?:\/videos)?)?\/([0-9]+)[^\s]*)/', 'https://player.vimeo.com/video/$1', $url),
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'src' => \preg_replace('/(?:https?:\/\/(?:[\w]{3}\.|player\.)*vimeo\.com(?:[\/\w:]*(?:\/videos)?)?\/([0-9]+)[^\s]*)/', 'https://player.vimeo.com/video/$1', $url),
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'allowfullscreen' => '',
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms'
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
||||
];
|
||||
break;
|
||||
case 'dailymotion':
|
||||
$element = 'iframe';
|
||||
$element = 'iframe';
|
||||
$attributes = [
|
||||
'src' => $url,
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'src' => $url,
|
||||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'allowfullscreen' => '',
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms'
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$element = 'video';
|
||||
$attributes = [
|
||||
'src' => UriFactory::build($url),
|
||||
'controls' => ''
|
||||
'src' => UriFactory::build($url),
|
||||
'controls' => '',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => $element,
|
||||
'text' => $matches[1],
|
||||
'attributes' => $attributes
|
||||
'name' => $element,
|
||||
'text' => $matches[1],
|
||||
'attributes' => $attributes,
|
||||
],
|
||||
];
|
||||
} elseif ($audio) {
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'audio',
|
||||
'text' => $matches[1],
|
||||
'name' => 'audio',
|
||||
'text' => $matches[1],
|
||||
'attributes' => [
|
||||
'src' => UriFactory::build($url),
|
||||
'controls' => ''
|
||||
]
|
||||
'src' => UriFactory::build($url),
|
||||
'controls' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1448,16 +1448,16 @@ class Markdown
|
|||
}
|
||||
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'div',
|
||||
'text' => '',
|
||||
'name' => 'div',
|
||||
'text' => '',
|
||||
'attributes' => [
|
||||
'id' => 'i' . \bin2hex(\random_bytes(4)),
|
||||
'class' => 'map',
|
||||
'id' => 'i' . \bin2hex(\random_bytes(4)),
|
||||
'class' => 'map',
|
||||
'data-lat' => $lat,
|
||||
'data-lon' => $lon,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1487,7 +1487,7 @@ class Markdown
|
|||
$address = $matches[5];
|
||||
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'div',
|
||||
//'text' => '',
|
||||
|
|
@ -1496,28 +1496,28 @@ class Markdown
|
|||
],
|
||||
'elements' => [
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $name,
|
||||
'name' => 'span',
|
||||
'text' => $name,
|
||||
'attributes' => ['class' => 'addressWidget-name'],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $address,
|
||||
'name' => 'span',
|
||||
'text' => $address,
|
||||
'attributes' => ['class' => 'addressWidget-address'],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $zip,
|
||||
'name' => 'span',
|
||||
'text' => $zip,
|
||||
'attributes' => ['class' => 'addressWidget-zip'],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $city,
|
||||
'name' => 'span',
|
||||
'text' => $city,
|
||||
'attributes' => ['class' => 'addressWidget-city'],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $country,
|
||||
'name' => 'span',
|
||||
'text' => $country,
|
||||
'attributes' => ['class' => 'addressWidget-country'],
|
||||
],
|
||||
],
|
||||
|
|
@ -1578,11 +1578,10 @@ class Markdown
|
|||
case 'linkedin':
|
||||
$src = 'Resources/icons/company/linkedin.svg';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'a',
|
||||
//'text' => '',
|
||||
|
|
@ -1592,17 +1591,17 @@ class Markdown
|
|||
],
|
||||
'elements' => [
|
||||
[
|
||||
'name' => 'img',
|
||||
'name' => 'img',
|
||||
'attributes' => [
|
||||
'class' => 'contactWidget-icon',
|
||||
'src' => $src
|
||||
'src' => $src,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $matches[2],
|
||||
'name' => 'span',
|
||||
'text' => $matches[2],
|
||||
'attributes' => ['class' => 'contactWidget-contact'],
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
|
@ -1638,14 +1637,14 @@ class Markdown
|
|||
}
|
||||
|
||||
return [
|
||||
'extent' => \strlen($matches[0]),
|
||||
'extent' => \strlen($matches[0]),
|
||||
'element' => [
|
||||
'name' => 'progress',
|
||||
'text' => '',
|
||||
'name' => 'progress',
|
||||
'text' => '',
|
||||
'attributes' => [
|
||||
'value' => $value,
|
||||
'max' => '100',
|
||||
]
|
||||
'max' => '100',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1789,7 +1788,7 @@ class Markdown
|
|||
|| ($state && !\preg_match('/^(?<!\\\\)(?<!\\\\\()\\\\\((.{2,}?)(?<!\\\\\()\\\\\)(?!\\\\\))/s', $excerpt['text']))
|
||||
) {
|
||||
return [
|
||||
'extent' => 2,
|
||||
'extent' => 2,
|
||||
'element' => [
|
||||
'rawHtml' => $excerpt['text'][1],
|
||||
],
|
||||
|
|
@ -1968,7 +1967,7 @@ class Markdown
|
|||
],
|
||||
];
|
||||
|
||||
if (preg_match('/[ #]*{(' . $this->regexAttribute . '+)}[ ]*$/', $block['element']['handler']['argument'], $matches, \PREG_OFFSET_CAPTURE)) {
|
||||
if (\preg_match('/[ #]*{(' . $this->regexAttribute . '+)}[ ]*$/', $block['element']['handler']['argument'], $matches, \PREG_OFFSET_CAPTURE)) {
|
||||
$attributeString = $matches[1][0];
|
||||
|
||||
$block['element']['attributes'] = $this->parseAttributeData($attributeString);
|
||||
|
|
@ -2038,8 +2037,7 @@ class Markdown
|
|||
|
||||
$matches[1] = \substr($matches[1], 0, -$contentIndent);
|
||||
$matches[3] = \str_repeat(' ', $contentIndent) . $matches[3];
|
||||
}
|
||||
elseif ($contentIndent === 0) {
|
||||
} elseif ($contentIndent === 0) {
|
||||
$matches[1] .= ' ';
|
||||
}
|
||||
|
||||
|
|
@ -2108,7 +2106,6 @@ class Markdown
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'element' => [
|
||||
'name' => 'blockquote',
|
||||
|
|
@ -2690,7 +2687,7 @@ class Markdown
|
|||
'element' => [
|
||||
'name' => 'details',
|
||||
'element' => [
|
||||
'text' => '',
|
||||
'text' => '',
|
||||
'elements' => [
|
||||
[
|
||||
'name' => 'summary',
|
||||
|
|
@ -2699,9 +2696,9 @@ class Markdown
|
|||
[
|
||||
'name' => 'span', // @todo check if without span possible
|
||||
'text' => '',
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -3153,8 +3150,12 @@ class Markdown
|
|||
// - [Header3](#Header3)
|
||||
// - [Header2-2](#Header2-2)
|
||||
// ...
|
||||
$this->contentsListString .= \str_repeat(' ', $this->firstHeadLevel - 1 > $level ? 1 : $level - ($this->firstHeadLevel - 1))
|
||||
. ' - ' . '[' . $text . '](#' . $id . ')' . \PHP_EOL;
|
||||
$this->contentsListString .= \str_repeat(
|
||||
' ',
|
||||
$this->firstHeadLevel - 1 > $level
|
||||
? 1
|
||||
: $level - ($this->firstHeadLevel - 1)
|
||||
) . ' - [' . $text . '](#' . $id . ")\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3179,15 +3180,17 @@ class Markdown
|
|||
|
||||
$newStr = $str;
|
||||
|
||||
if ($count = $this->anchorDuplicates[$str]) {
|
||||
$newStr .= '-' . $count;
|
||||
if (($count = $this->anchorDuplicates[$str]) === 0) {
|
||||
return $newStr;
|
||||
}
|
||||
|
||||
// increment until conversion doesn't produce new duplicates anymore
|
||||
if (isset($this->anchorDuplicates[$newStr])) {
|
||||
$newStr = $this->incrementAnchorId($str);
|
||||
} else {
|
||||
$this->anchorDuplicates[$newStr] = 0;
|
||||
}
|
||||
$newStr .= '-' . $count;
|
||||
|
||||
// increment until conversion doesn't produce new duplicates anymore
|
||||
if (isset($this->anchorDuplicates[$newStr])) {
|
||||
$newStr = $this->incrementAnchorId($str);
|
||||
} else {
|
||||
$this->anchorDuplicates[$newStr] = 0;
|
||||
}
|
||||
|
||||
return $newStr;
|
||||
|
|
@ -3491,7 +3494,7 @@ class Markdown
|
|||
'attributes' => ['href' => '#fn:' . $name, 'class' => 'footnote-ref'],
|
||||
'text' => $this->definitionData['Footnote'][$name]['number'],
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -3559,8 +3562,7 @@ class Markdown
|
|||
return $inline;
|
||||
}
|
||||
|
||||
foreach ($this->definitionData['Abbreviation'] as $abbreviation => $meaning)
|
||||
{
|
||||
foreach ($this->definitionData['Abbreviation'] as $abbreviation => $meaning) {
|
||||
$this->currentAbreviation = $abbreviation;
|
||||
$this->currentMeaning = $meaning;
|
||||
|
||||
|
|
@ -4725,7 +4727,7 @@ class Markdown
|
|||
/**
|
||||
* Sanitize url in attribute
|
||||
*
|
||||
* @param array $element Element to sanitize
|
||||
* @param array $element Element to sanitize
|
||||
* @param string $attribute Attribute to sanitize
|
||||
*
|
||||
* @return array
|
||||
|
|
|
|||
|
|
@ -288,9 +288,7 @@ final class StringUtils
|
|||
}
|
||||
}
|
||||
|
||||
$result = \rtrim($result, $delim);
|
||||
|
||||
return $result;
|
||||
return \rtrim($result, $delim);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Karaka
|
||||
* @package Jingga
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
|
|
|
|||
|
|
@ -29,20 +29,20 @@ final class AprioriTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
self::assertEquals(
|
||||
[
|
||||
'theta' => 2,
|
||||
'epsilon' => 2,
|
||||
'epsilon:theta' => 0,
|
||||
'beta' => 4,
|
||||
'beta:theta' => 2,
|
||||
'beta:epsilon' => 2,
|
||||
'beta:epsilon:theta' => 0,
|
||||
'alpha' => 4,
|
||||
'alpha:theta' => 2,
|
||||
'alpha:epsilon' => 2,
|
||||
'alpha:epsilon:theta' => 0,
|
||||
'alpha:beta' => 4,
|
||||
'alpha:beta:theta' => 2,
|
||||
'alpha:beta:epsilon' => 2,
|
||||
'theta' => 2,
|
||||
'epsilon' => 2,
|
||||
'epsilon:theta' => 0,
|
||||
'beta' => 4,
|
||||
'beta:theta' => 2,
|
||||
'beta:epsilon' => 2,
|
||||
'beta:epsilon:theta' => 0,
|
||||
'alpha' => 4,
|
||||
'alpha:theta' => 2,
|
||||
'alpha:epsilon' => 2,
|
||||
'alpha:epsilon:theta' => 0,
|
||||
'alpha:beta' => 4,
|
||||
'alpha:beta:theta' => 2,
|
||||
'alpha:beta:epsilon' => 2,
|
||||
'alpha:beta:epsilon:theta' => 0,
|
||||
],
|
||||
Apriori::apriori([
|
||||
|
|
@ -55,20 +55,20 @@ final class AprioriTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
[
|
||||
'4' => 5,
|
||||
'3' => 3,
|
||||
'3:4' => 3,
|
||||
'2' => 5,
|
||||
'2:4' => 4,
|
||||
'2:3' => 2,
|
||||
'2:3:4' => 2,
|
||||
'1' => 3,
|
||||
'1:4' => 2,
|
||||
'1:3' => 1,
|
||||
'1:3:4' => 1,
|
||||
'1:2' => 3,
|
||||
'1:2:4' => 2,
|
||||
'1:2:3' => 1,
|
||||
'4' => 5,
|
||||
'3' => 3,
|
||||
'3:4' => 3,
|
||||
'2' => 5,
|
||||
'2:4' => 4,
|
||||
'2:3' => 2,
|
||||
'2:3:4' => 2,
|
||||
'1' => 3,
|
||||
'1:4' => 2,
|
||||
'1:3' => 1,
|
||||
'1:3:4' => 1,
|
||||
'1:2' => 3,
|
||||
'1:2:4' => 2,
|
||||
'1:2:3' => 1,
|
||||
'1:2:3:4' => 1,
|
||||
],
|
||||
Apriori::apriori([
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ final class DependencyResolverTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testResolveCircular() : void
|
||||
{
|
||||
self::assertEquals(
|
||||
null,
|
||||
self::assertNull(
|
||||
DependencyResolver::resolve([0 => [1, 2], 1 => [0, 2], 2 => []])
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
"name": "Jingga",
|
||||
"website": "jingga.app"
|
||||
},
|
||||
"description": "The administration module.",
|
||||
"directory": "Admin",
|
||||
"providing": {
|
||||
"Navigation": "*",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
"name": "Jingga",
|
||||
"website": "jingga.app"
|
||||
},
|
||||
"description": "The administration module.",
|
||||
"directory": "Admin",
|
||||
"providing": {
|
||||
"Navigation": "*"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\tests\Business\Recommendation;
|
||||
|
||||
use phpOMS\Business\Recommendation\BayesianPersonalizedRanking;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Business\Recommendation\BayesianPersonalizedRankingTest: Article affinity/correlation
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,23 +25,23 @@ class BaseModelMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'test_base_id' => ['name' => 'test_base_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'test_base_string' => ['name' => 'test_base_string', 'type' => 'string', 'internal' => 'string', 'autocomplete' => true],
|
||||
'test_base_id' => ['name' => 'test_base_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'test_base_string' => ['name' => 'test_base_string', 'type' => 'string', 'internal' => 'string', 'autocomplete' => true],
|
||||
'test_base_compress' => ['name' => 'test_base_compress', 'type' => 'compress', 'internal' => 'compress',],
|
||||
'test_base_pstring' => ['name' => 'test_base_pstring', 'type' => 'pstring', 'internal' => 'pstring', 'private' => true],
|
||||
'test_base_int' => ['name' => 'test_base_int', 'type' => 'int', 'internal' => 'int'],
|
||||
'test_base_bool' => ['name' => 'test_base_bool', 'type' => 'bool', 'internal' => 'bool'],
|
||||
'test_base_null' => ['name' => 'test_base_null', 'type' => 'int', 'internal' => 'null'],
|
||||
'test_base_float' => ['name' => 'test_base_float', 'type' => 'float', 'internal' => 'float'],
|
||||
'test_base_json' => ['name' => 'test_base_json', 'type' => 'Json', 'internal' => 'json'],
|
||||
'test_base_json_serializable' => ['name' => 'test_base_json_serializable', 'type' => 'Json', 'internal' => 'jsonSerializable'],
|
||||
'test_base_serializable' => ['name' => 'test_base_serializable', 'type' => 'Serializable', 'internal' => 'serializable'],
|
||||
'test_base_datetime' => ['name' => 'test_base_datetime', 'type' => 'DateTime', 'internal' => 'datetime'],
|
||||
'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'],
|
||||
'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'],
|
||||
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'],
|
||||
'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true],
|
||||
'test_base_belongs_top_one' => ['name' => 'test_base_belongs_top_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true],
|
||||
'test_base_pstring' => ['name' => 'test_base_pstring', 'type' => 'pstring', 'internal' => 'pstring', 'private' => true],
|
||||
'test_base_int' => ['name' => 'test_base_int', 'type' => 'int', 'internal' => 'int'],
|
||||
'test_base_bool' => ['name' => 'test_base_bool', 'type' => 'bool', 'internal' => 'bool'],
|
||||
'test_base_null' => ['name' => 'test_base_null', 'type' => 'int', 'internal' => 'null'],
|
||||
'test_base_float' => ['name' => 'test_base_float', 'type' => 'float', 'internal' => 'float'],
|
||||
'test_base_json' => ['name' => 'test_base_json', 'type' => 'Json', 'internal' => 'json'],
|
||||
'test_base_json_serializable' => ['name' => 'test_base_json_serializable', 'type' => 'Json', 'internal' => 'jsonSerializable'],
|
||||
'test_base_serializable' => ['name' => 'test_base_serializable', 'type' => 'Serializable', 'internal' => 'serializable'],
|
||||
'test_base_datetime' => ['name' => 'test_base_datetime', 'type' => 'DateTime', 'internal' => 'datetime'],
|
||||
'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'],
|
||||
'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'],
|
||||
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'],
|
||||
'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true],
|
||||
'test_base_belongs_top_one' => ['name' => 'test_base_belongs_top_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,7 @@ class BaseModelMapper extends DataMapperFactory
|
|||
'table' => 'test_has_many_rel_relationsp',
|
||||
'external' => 'test_has_many_rel_relationsp_src',
|
||||
'self' => 'test_has_many_rel_relationsp_dest',
|
||||
'private' => true
|
||||
'private' => true,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ final class SimplexTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEqualsWithDelta(
|
||||
[
|
||||
[11.333333, 3.333333, 0.0, 11.666667, 0.0],
|
||||
21.333333
|
||||
21.333333,
|
||||
],
|
||||
$simplex->solve(
|
||||
[
|
||||
|
|
@ -53,7 +53,7 @@ final class SimplexTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEqualsWithDelta(
|
||||
[
|
||||
[1.0, 0.0, 0.0, 0.0],
|
||||
5.0
|
||||
5.0,
|
||||
],
|
||||
$simplex->solve(
|
||||
[
|
||||
|
|
@ -73,7 +73,7 @@ final class SimplexTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(
|
||||
[
|
||||
[-2, -2, -2, -2, -2],
|
||||
\INF
|
||||
\INF,
|
||||
],
|
||||
$simplex->solve(
|
||||
[
|
||||
|
|
@ -92,7 +92,7 @@ final class SimplexTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEqualsWithDelta(
|
||||
[
|
||||
[-1, -1, -1, -1],
|
||||
\INF
|
||||
\INF,
|
||||
],
|
||||
$simplex->solve(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -128,8 +128,8 @@ final class RequestAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
public function testDataBoolInputOutput() : void
|
||||
{
|
||||
$this->request->setData('asdf', 1);
|
||||
self::assertEquals(true, $this->request->getDataBool('asdf'));
|
||||
self::assertEquals(true, $this->request->getData('asdf', 'bool'));
|
||||
self::assertTrue($this->request->getDataBool('asdf'));
|
||||
self::assertTrue($this->request->getData('asdf', 'bool'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,10 +163,10 @@ final class RequestAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidDataTypeInputOutput() : void
|
||||
{
|
||||
self::assertEquals(null, $this->request->getDataString('a'));
|
||||
self::assertEquals(null, $this->request->getDataBool('a'));
|
||||
self::assertEquals(null, $this->request->getDataInt('a'));
|
||||
self::assertEquals(null, $this->request->getDataFloat('a'));
|
||||
self::assertEquals(null, $this->request->getDataDateTime('a'));
|
||||
self::assertNull($this->request->getDataString('a'));
|
||||
self::assertNull($this->request->getDataBool('a'));
|
||||
self::assertNull($this->request->getDataInt('a'));
|
||||
self::assertNull($this->request->getDataFloat('a'));
|
||||
self::assertNull($this->request->getDataDateTime('a'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ final class ResponseAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
public function testDataBoolInputOutput() : void
|
||||
{
|
||||
$this->response->set('asdf', 1);
|
||||
self::assertEquals(true, $this->response->getDataBool('asdf'));
|
||||
self::assertEquals(true, $this->response->getData('asdf', 'bool'));
|
||||
self::assertTrue($this->response->getDataBool('asdf'));
|
||||
self::assertTrue($this->response->getData('asdf', 'bool'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -154,10 +154,10 @@ final class ResponseAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidDataTypeInputOutput() : void
|
||||
{
|
||||
self::assertEquals(null, $this->response->getDataString('a'));
|
||||
self::assertEquals(null, $this->response->getDataBool('a'));
|
||||
self::assertEquals(null, $this->response->getDataInt('a'));
|
||||
self::assertEquals(null, $this->response->getDataFloat('a'));
|
||||
self::assertEquals(null, $this->response->getDataDateTime('a'));
|
||||
self::assertNull($this->response->getDataString('a'));
|
||||
self::assertNull($this->response->getDataBool('a'));
|
||||
self::assertNull($this->response->getDataInt('a'));
|
||||
self::assertNull($this->response->getDataFloat('a'));
|
||||
self::assertNull($this->response->getDataDateTime('a'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
"name": "Jingga",
|
||||
"website": "jingga.app"
|
||||
},
|
||||
"description": "The administration module.",
|
||||
"directory": "Admin",
|
||||
"dependencies": [],
|
||||
"providing": {
|
||||
|
|
|
|||
|
|
@ -41,31 +41,31 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(
|
||||
[
|
||||
'key' => 'D',
|
||||
0 => [
|
||||
0 => [
|
||||
'key' => 'A',
|
||||
0 => null,
|
||||
1 => null
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'I',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'N',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'O',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'S',
|
||||
0 => [
|
||||
0 => [
|
||||
'key' => 'R',
|
||||
0 => null,
|
||||
1 => null
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'U',
|
||||
0 => null,
|
||||
1 => null
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
@ -112,32 +112,32 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(
|
||||
[
|
||||
'key' => 'D',
|
||||
0 => [
|
||||
0 => [
|
||||
'key' => 'A',
|
||||
0 => null,
|
||||
1 => null
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'N',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'O',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'U',
|
||||
0 => [
|
||||
0 => [
|
||||
'key' => 'R',
|
||||
0 => null,
|
||||
1 => [
|
||||
0 => null,
|
||||
1 => [
|
||||
'key' => 'T',
|
||||
0 => null,
|
||||
1 => null
|
||||
]
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
1 => [
|
||||
'key' => 'Z',
|
||||
0 => null,
|
||||
1 => null
|
||||
0 => null,
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ final class DocumentWriterTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testParsing() : void
|
||||
{
|
||||
$doc = IOFactory::load(__DIR__ . '/data/Word.docx');
|
||||
$doc = IOFactory::load(__DIR__ . '/data/Word.docx');
|
||||
$writer = new DocumentWriter($doc);
|
||||
|
||||
$pdf = $writer->toPdfString(__DIR__ . '/data/WordMpdf.pdf');
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testSafeMode() : void
|
||||
{
|
||||
$parser = new Markdown();
|
||||
$parser = new Markdown();
|
||||
$parser->safeMode = true;
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -60,8 +60,8 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$parser = new Markdown([
|
||||
'tables' => [
|
||||
'tablespan' => true
|
||||
]
|
||||
'tablespan' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -73,7 +73,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testMap() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'map' => true
|
||||
'map' => true,
|
||||
]);
|
||||
|
||||
self::assertLessThan(9,
|
||||
|
|
@ -87,7 +87,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testContact() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'contact' => true
|
||||
'contact' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -99,7 +99,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testTypographer() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'typographer' => true
|
||||
'typographer' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -111,7 +111,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testAddress() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'address' => true
|
||||
'address' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -123,7 +123,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testProgress() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'progress' => true
|
||||
'progress' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -135,7 +135,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testEmbed() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'embeding' => true
|
||||
'embeding' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -147,7 +147,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testMath() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'math' => true
|
||||
'math' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
@ -159,7 +159,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testTOC() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'toc' => true
|
||||
'toc' => true,
|
||||
]);
|
||||
$parser->text(\file_get_contents(__DIR__ . '/manualdata/toc.md'));
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSpoiler() : void
|
||||
{
|
||||
$parser = new Markdown([
|
||||
'spoiler' => true
|
||||
'spoiler' => true,
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ namespace phpOMS\tests\Utils\Parser\Presentation;
|
|||
|
||||
include_once __DIR__ . '/../../../Autoloader.php';
|
||||
|
||||
use phpOMS\Utils\Parser\Presentation\PresentationWriter;
|
||||
use PhpOffice\PhpPresentation\IOFactory;
|
||||
use phpOMS\Utils\Parser\Presentation\PresentationWriter;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
@ -31,7 +31,7 @@ final class PresentationWriterTest extends \PHPUnit\Framework\TestCase
|
|||
$writer = new PresentationWriter($presentation);
|
||||
|
||||
self::assertTrue(
|
||||
abs(\strlen(\file_get_contents(__DIR__ . '/data/Powerpoint.html'))
|
||||
\abs(\strlen(\file_get_contents(__DIR__ . '/data/Powerpoint.html'))
|
||||
- \strlen($writer->renderHtml())) < 100
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ final class SpreadsheetWriterTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testParsing() : void
|
||||
{
|
||||
$sheet = IOFactory::load(__DIR__ . '/data/Excel.xlsx');
|
||||
$sheet = IOFactory::load(__DIR__ . '/data/Excel.xlsx');
|
||||
$writer = new SpreadsheetWriter($sheet);
|
||||
|
||||
$pdf = $writer->toPdfString(__DIR__ . '/data/ExcelMpdf.pdf');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user