mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58: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));
|
||||
|
|
@ -89,6 +100,16 @@ 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;
|
||||
|
|
@ -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,7 +185,17 @@ 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;
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Algorithm\Clustering;
|
||||
|
||||
use phpOMS\Math\Topology\MetricsND;
|
||||
|
||||
/**
|
||||
* Clustering points
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
<?php
|
||||
|
||||
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);
|
||||
|
|
@ -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));
|
||||
|
||||
|
|
@ -354,8 +355,8 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
'uom' => 'g',
|
||||
'value' => $package['weight'],
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$request->setData('shipments', $shipments);
|
||||
|
|
@ -383,8 +384,8 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
'code' => $result[0]['label']['format'],
|
||||
'url' => $result[0]['label']['url'],
|
||||
'data' => $label['data'],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -460,8 +461,8 @@ final class DHLParcelDEShipping implements ShippingInterface
|
|||
'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);
|
||||
|
|
@ -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;
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
|||
namespace phpOMS\Api\Shipping;
|
||||
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
|
||||
/**
|
||||
* Shipping interface.
|
||||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
@ -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),
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -523,7 +524,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'Description' => \substr($p['description'], 0, 35),
|
||||
'Packaging' => [
|
||||
'Code' => $p['package_code'],
|
||||
'Description' => $p['package_description']
|
||||
'Description' => $p['package_description'],
|
||||
],
|
||||
'Dimensions' => [
|
||||
'UnitOfMeasurement' => [
|
||||
|
|
@ -547,7 +548,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'Description' => \substr($p['package_weight_unit_description'], 0, 35),
|
||||
],
|
||||
'Weight' => $p['weight'],
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
|
@ -610,7 +611,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'url' => $result['ShipmentResults']['ReceiptURL'] ?? '',
|
||||
'local' => $result['ShipmentResults']['LocalLanguageReceiptURL'] ?? '',
|
||||
'data' => '',
|
||||
]
|
||||
],
|
||||
// @todo dangerous goods paper image
|
||||
];
|
||||
|
||||
|
|
@ -629,7 +630,7 @@ final class UPSShipping implements ShippingInterface
|
|||
'receipt' => [
|
||||
'code' => $package['ShippingReceipt']['ImageFormat']['Code'],
|
||||
'image' => $package['ShippingReceipt']['ImageFormat']['GraphicImage'],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ final class Simplex
|
|||
* @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, ' ');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,7 +383,17 @@ 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);
|
||||
$this->query[$key] = $value;
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -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
|
||||
) {
|
||||
|
|
@ -1278,20 +1278,20 @@ class Markdown
|
|||
'element' => [
|
||||
'name' => 'span',
|
||||
'attributes' => [
|
||||
'class' => 'spoiler'
|
||||
'class' => 'spoiler',
|
||||
],
|
||||
'elements' => [
|
||||
[
|
||||
'name' => 'input',
|
||||
'attributes' => [
|
||||
'type' => 'checkbox'
|
||||
]
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $matches[1],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -1360,7 +1360,7 @@ class Markdown
|
|||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'allowfullscreen' => '',
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms'
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
||||
];
|
||||
break;
|
||||
case 'vimeo':
|
||||
|
|
@ -1370,7 +1370,7 @@ class Markdown
|
|||
'frameborder' => '0',
|
||||
'allow' => 'autoplay',
|
||||
'allowfullscreen' => '',
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms'
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-forms',
|
||||
];
|
||||
break;
|
||||
case 'dailymotion':
|
||||
|
|
@ -1380,14 +1380,14 @@ class Markdown
|
|||
'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' => ''
|
||||
'controls' => '',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1396,7 +1396,7 @@ class Markdown
|
|||
'element' => [
|
||||
'name' => $element,
|
||||
'text' => $matches[1],
|
||||
'attributes' => $attributes
|
||||
'attributes' => $attributes,
|
||||
],
|
||||
];
|
||||
} elseif ($audio) {
|
||||
|
|
@ -1407,8 +1407,8 @@ class Markdown
|
|||
'text' => $matches[1],
|
||||
'attributes' => [
|
||||
'src' => UriFactory::build($url),
|
||||
'controls' => ''
|
||||
]
|
||||
'controls' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1457,7 +1457,7 @@ class Markdown
|
|||
'class' => 'map',
|
||||
'data-lat' => $lat,
|
||||
'data-lon' => $lon,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1578,7 +1578,6 @@ class Markdown
|
|||
case 'linkedin':
|
||||
$src = 'Resources/icons/company/linkedin.svg';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
@ -1595,14 +1594,14 @@ class Markdown
|
|||
'name' => 'img',
|
||||
'attributes' => [
|
||||
'class' => 'contactWidget-icon',
|
||||
'src' => $src
|
||||
'src' => $src,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'span',
|
||||
'text' => $matches[2],
|
||||
'attributes' => ['class' => 'contactWidget-contact'],
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
|
@ -1645,7 +1644,7 @@ class Markdown
|
|||
'attributes' => [
|
||||
'value' => $value,
|
||||
'max' => '100',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -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',
|
||||
|
|
@ -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,7 +3180,10 @@ class Markdown
|
|||
|
||||
$newStr = $str;
|
||||
|
||||
if ($count = $this->anchorDuplicates[$str]) {
|
||||
if (($count = $this->anchorDuplicates[$str]) === 0) {
|
||||
return $newStr;
|
||||
}
|
||||
|
||||
$newStr .= '-' . $count;
|
||||
|
||||
// increment until conversion doesn't produce new duplicates anymore
|
||||
|
|
@ -3188,7 +3192,6 @@ class Markdown
|
|||
} 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
0 => [
|
||||
'key' => 'A',
|
||||
0 => null,
|
||||
1 => null
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'I',
|
||||
|
|
@ -60,12 +60,12 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
0 => [
|
||||
'key' => 'R',
|
||||
0 => null,
|
||||
1 => null
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'U',
|
||||
0 => null,
|
||||
1 => null
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
@ -115,7 +115,7 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
0 => [
|
||||
'key' => 'A',
|
||||
0 => null,
|
||||
1 => null
|
||||
1 => null,
|
||||
],
|
||||
1 => [
|
||||
'key' => 'N',
|
||||
|
|
@ -131,13 +131,13 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
|||
1 => [
|
||||
'key' => 'T',
|
||||
0 => null,
|
||||
1 => null
|
||||
]
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
1 => [
|
||||
'key' => 'Z',
|
||||
0 => null,
|
||||
1 => null
|
||||
1 => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user