\ No newline at end of file
diff --git a/src/BusinessLogic/Resources/templates/pick-shipping-services.html b/src/BusinessLogic/Resources/templates/pick-shipping-services.html
index 98b4ecbc..b762e1e3 100644
--- a/src/BusinessLogic/Resources/templates/pick-shipping-services.html
+++ b/src/BusinessLogic/Resources/templates/pick-shipping-services.html
@@ -1,12 +1,12 @@
\ No newline at end of file
diff --git a/src/BusinessLogic/Resources/templates/shipping-services-table.html b/src/BusinessLogic/Resources/templates/shipping-services-table.html
index 11e1a17e..699798a7 100644
--- a/src/BusinessLogic/Resources/templates/shipping-services-table.html
+++ b/src/BusinessLogic/Resources/templates/shipping-services-table.html
@@ -1,25 +1,25 @@
-
+
-
+
{$shippingServices.carrier}
-
+
{$shippingServices.serviceTitle}
-
+
{$shippingServices.transitTime}
-
+
{$shippingServices.type}
-
+
{$shippingServices.origin}
-
+
{$shippingServices.destination}
-
+
diff --git a/src/BusinessLogic/Scheduler/Models/Schedule.php b/src/BusinessLogic/Scheduler/Models/Schedule.php
index c36b754f..87214233 100644
--- a/src/BusinessLogic/Scheduler/Models/Schedule.php
+++ b/src/BusinessLogic/Scheduler/Models/Schedule.php
@@ -103,6 +103,20 @@ public function __construct(Task $task = null, $queueName = null, $context = '')
$this->context = $context;
}
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Transforms raw array data to this entity instance.
*
diff --git a/src/BusinessLogic/Scheduler/ScheduleCheckTask.php b/src/BusinessLogic/Scheduler/ScheduleCheckTask.php
index 3f46c58b..031de409 100644
--- a/src/BusinessLogic/Scheduler/ScheduleCheckTask.php
+++ b/src/BusinessLogic/Scheduler/ScheduleCheckTask.php
@@ -36,7 +36,7 @@ class ScheduleCheckTask extends Task
*/
public static function fromArray(array $array)
{
- return new static();
+ return new self();
}
/**
diff --git a/src/BusinessLogic/ShipmentDraft/Models/OrderSendDraftTaskMap.php b/src/BusinessLogic/ShipmentDraft/Models/OrderSendDraftTaskMap.php
index 22c782f5..1291b518 100644
--- a/src/BusinessLogic/ShipmentDraft/Models/OrderSendDraftTaskMap.php
+++ b/src/BusinessLogic/ShipmentDraft/Models/OrderSendDraftTaskMap.php
@@ -40,6 +40,20 @@ class OrderSendDraftTaskMap extends Entity
*/
protected $executionId;
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* @inheritDoc
*/
diff --git a/src/BusinessLogic/ShipmentDraft/Objects/ShipmentDraftStatus.php b/src/BusinessLogic/ShipmentDraft/Objects/ShipmentDraftStatus.php
index 6fd5acef..e3c97b73 100644
--- a/src/BusinessLogic/ShipmentDraft/Objects/ShipmentDraftStatus.php
+++ b/src/BusinessLogic/ShipmentDraft/Objects/ShipmentDraftStatus.php
@@ -41,7 +41,7 @@ class ShipmentDraftStatus extends DataTransferObject
*/
public static function fromArray(array $raw)
{
- $me = new static();
+ $me = new self();
$me->status = static::getDataValue($raw, 'status');
$me->message = static::getDataValue($raw, 'message');
diff --git a/src/BusinessLogic/ShipmentDraft/OrderSendDraftTaskMapService.php b/src/BusinessLogic/ShipmentDraft/OrderSendDraftTaskMapService.php
index 84daa291..9ef0a5ef 100644
--- a/src/BusinessLogic/ShipmentDraft/OrderSendDraftTaskMapService.php
+++ b/src/BusinessLogic/ShipmentDraft/OrderSendDraftTaskMapService.php
@@ -45,6 +45,18 @@ public function __construct()
$this->repository = new OrderSendDraftTaskRepository();
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Retrieves Order - SendDraftTask map instance.
*
diff --git a/src/BusinessLogic/ShipmentDraft/ShipmentDraftService.php b/src/BusinessLogic/ShipmentDraft/ShipmentDraftService.php
index 82572c34..19bdf5e6 100644
--- a/src/BusinessLogic/ShipmentDraft/ShipmentDraftService.php
+++ b/src/BusinessLogic/ShipmentDraft/ShipmentDraftService.php
@@ -33,6 +33,18 @@ class ShipmentDraftService extends BaseService
*/
protected static $instance;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Enqueues the task for creating shipment draft for provided order id.
* Ensures proper mapping between the order and the created task are persisted.
diff --git a/src/BusinessLogic/ShippingMethod/Models/ShippingMethod.php b/src/BusinessLogic/ShippingMethod/Models/ShippingMethod.php
index 8b5bdd04..016e9197 100644
--- a/src/BusinessLogic/ShippingMethod/Models/ShippingMethod.php
+++ b/src/BusinessLogic/ShippingMethod/Models/ShippingMethod.php
@@ -168,6 +168,20 @@ class ShippingMethod extends Entity
*/
public $systemDefaults;
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Transforms raw array data to this entity instance.
*
diff --git a/src/BusinessLogic/ShippingMethod/Models/ShippingPricePolicy.php b/src/BusinessLogic/ShippingMethod/Models/ShippingPricePolicy.php
index 480b0898..9a909ddb 100644
--- a/src/BusinessLogic/ShippingMethod/Models/ShippingPricePolicy.php
+++ b/src/BusinessLogic/ShippingMethod/Models/ShippingPricePolicy.php
@@ -113,6 +113,20 @@ class ShippingPricePolicy extends FrontDto
'increase',
);
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Transforms raw array data to this entity instance.
*
diff --git a/src/BusinessLogic/ShippingMethod/Models/ShippingService.php b/src/BusinessLogic/ShippingMethod/Models/ShippingService.php
index 0f10c872..23af356a 100644
--- a/src/BusinessLogic/ShippingMethod/Models/ShippingService.php
+++ b/src/BusinessLogic/ShippingMethod/Models/ShippingService.php
@@ -93,7 +93,7 @@ public function __construct(
*/
public static function fromArray($data)
{
- return new static(
+ return new self(
$data['serviceId'],
$data['serviceName'],
$data['departure'],
@@ -113,7 +113,7 @@ public static function fromArray($data)
*/
public static function fromServiceDetails(ShippingServiceDetails $shippingServiceDetails)
{
- return new static(
+ return new self(
$shippingServiceDetails->id,
$shippingServiceDetails->serviceName,
$shippingServiceDetails->departureCountry,
diff --git a/src/BusinessLogic/ShippingMethod/PackageTransformer.php b/src/BusinessLogic/ShippingMethod/PackageTransformer.php
index 1f666847..b2da6e9a 100644
--- a/src/BusinessLogic/ShippingMethod/PackageTransformer.php
+++ b/src/BusinessLogic/ShippingMethod/PackageTransformer.php
@@ -42,6 +42,18 @@ protected function __construct()
$this->configuration = ServiceRegister::getService(Configuration::CLASS_NAME);
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Transforms array of packages into one grouped package.
*
diff --git a/src/BusinessLogic/ShippingMethod/ShippingMethodService.php b/src/BusinessLogic/ShippingMethod/ShippingMethodService.php
index 728688ac..c2928d3e 100644
--- a/src/BusinessLogic/ShippingMethod/ShippingMethodService.php
+++ b/src/BusinessLogic/ShippingMethod/ShippingMethodService.php
@@ -59,6 +59,18 @@ protected function __construct()
$this->shippingMethodRepository = $this->getRepository(ShippingMethod::CLASS_NAME);
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Returns all shipping methods for current user.
*
diff --git a/src/BusinessLogic/ShippingMethod/Utility/ShipmentStatus.php b/src/BusinessLogic/ShippingMethod/Utility/ShipmentStatus.php
index 2017086a..cdf35fea 100644
--- a/src/BusinessLogic/ShippingMethod/Utility/ShipmentStatus.php
+++ b/src/BusinessLogic/ShippingMethod/Utility/ShipmentStatus.php
@@ -33,6 +33,14 @@ class ShipmentStatus
* Status when shipment is cancelled.
*/
const STATUS_CANCELLED = 'cancelled';
+ /**
+ * Status when shipmnet is out for delivery
+ */
+ const OUT_FOR_DELIVERY = 'outForDelivery';
+ /**
+ * Status when some incident happens
+ */
+ const INCIDENT = 'incident';
/**
* Maps raw shipment status from Packlink to shipment status.
@@ -63,6 +71,10 @@ public static function getStatus($shipmentStatus)
return self::STATUS_ACCEPTED;
case 'CANCELED':
return self::STATUS_CANCELLED;
+ case 'OUT_FOR_DELIVERY':
+ return self::OUT_FOR_DELIVERY;
+ case 'INCIDENT' :
+ return self::INCIDENT;
case 'AWAITING_COMPLETION':
case 'READY_TO_PURCHASE':
default:
@@ -84,6 +96,8 @@ public static function getPossibleStatuses()
self::STATUS_IN_TRANSIT,
self::STATUS_DELIVERED,
self::STATUS_CANCELLED,
+ self::INCIDENT,
+ self::OUT_FOR_DELIVERY,
);
}
}
diff --git a/src/BusinessLogic/Tasks/BatchTaskCleanupTask.php b/src/BusinessLogic/Tasks/BatchTaskCleanupTask.php
index 978ad6d3..31124391 100644
--- a/src/BusinessLogic/Tasks/BatchTaskCleanupTask.php
+++ b/src/BusinessLogic/Tasks/BatchTaskCleanupTask.php
@@ -84,7 +84,7 @@ public function toArray()
*/
public static function fromArray(array $array)
{
- return new static($array['taskStatuses'], $array['taskTypes']);
+ return new self($array['taskStatuses'], $array['taskTypes']);
}
/**
diff --git a/src/BusinessLogic/Tasks/GetDefaultParcelAndWarehouseTask.php b/src/BusinessLogic/Tasks/GetDefaultParcelAndWarehouseTask.php
index da69f38f..987505bb 100644
--- a/src/BusinessLogic/Tasks/GetDefaultParcelAndWarehouseTask.php
+++ b/src/BusinessLogic/Tasks/GetDefaultParcelAndWarehouseTask.php
@@ -22,7 +22,7 @@ class GetDefaultParcelAndWarehouseTask extends Task
*/
public static function fromArray(array $array)
{
- return new static();
+ return new self();
}
/**
diff --git a/src/BusinessLogic/Tasks/SendDraftTask.php b/src/BusinessLogic/Tasks/SendDraftTask.php
index 89de2557..00b1aa63 100644
--- a/src/BusinessLogic/Tasks/SendDraftTask.php
+++ b/src/BusinessLogic/Tasks/SendDraftTask.php
@@ -67,7 +67,7 @@ public function __construct($orderId)
*/
public static function fromArray(array $array)
{
- return new static($array['order_id']);
+ return new self($array['order_id']);
}
/**
diff --git a/src/BusinessLogic/Tasks/TaskCleanupTask.php b/src/BusinessLogic/Tasks/TaskCleanupTask.php
index b472d386..5c94e3f1 100644
--- a/src/BusinessLogic/Tasks/TaskCleanupTask.php
+++ b/src/BusinessLogic/Tasks/TaskCleanupTask.php
@@ -69,7 +69,7 @@ public function __construct($taskType, array $taskStatuses, $taskAge)
*/
public static function fromArray(array $array)
{
- return new static(
+ return new self(
$array['task_type'],
!empty($array['task_statuses']) ? $array['task_statuses'] : array(),
$array['task_age']
diff --git a/src/BusinessLogic/Tasks/UpdateShipmentDataTask.php b/src/BusinessLogic/Tasks/UpdateShipmentDataTask.php
index fc5eb5f8..8e191d5b 100644
--- a/src/BusinessLogic/Tasks/UpdateShipmentDataTask.php
+++ b/src/BusinessLogic/Tasks/UpdateShipmentDataTask.php
@@ -6,13 +6,11 @@
use Logeecom\Infrastructure\Serializer\Serializer;
use Logeecom\Infrastructure\ServiceRegister;
use Logeecom\Infrastructure\TaskExecution\Task;
-use Packlink\BusinessLogic\Http\DTO\Shipment;
use Packlink\BusinessLogic\Http\Proxy;
use Packlink\BusinessLogic\Order\Interfaces\ShopOrderService;
use Packlink\BusinessLogic\Order\OrderService;
use Packlink\BusinessLogic\OrderShipmentDetails\Exceptions\OrderShipmentDetailsNotFound;
use Packlink\BusinessLogic\OrderShipmentDetails\OrderShipmentDetailsService;
-use Packlink\BusinessLogic\ShippingMethod\Utility\ShipmentStatus;
/**
* Class UpdateShipmentDataTask.
@@ -90,7 +88,7 @@ public function __construct(array $orderStatuses = array())
*/
public static function fromArray(array $array)
{
- $entity = new static();
+ $entity = new self();
$entity->progress = $array['progress'];
$entity->progressStep = $array['progress_step'];
@@ -268,22 +266,4 @@ protected function getOrderService()
return $this->orderService;
}
-
- /**
- * Checks if tracking info should be updated.
- *
- * @param \Packlink\BusinessLogic\Http\DTO\Shipment $shipment Shipment instance to be checked for updatability.
- *
- * @return bool TRUE if tracking info should be update; FALSE otherwise.
- */
- protected function isTrackingInfoUpdatable(Shipment $shipment)
- {
- $allowedUpdateStatuses = array(
- ShipmentStatus::STATUS_ACCEPTED,
- ShipmentStatus::STATUS_READY,
- ShipmentStatus::STATUS_IN_TRANSIT,
- );
-
- return in_array(ShipmentStatus::getStatus($shipment->status), $allowedUpdateStatuses, true);
- }
}
diff --git a/src/BusinessLogic/Tasks/UpdateShippingServicesTask.php b/src/BusinessLogic/Tasks/UpdateShippingServicesTask.php
index 5c60bb7e..ecc5fc97 100644
--- a/src/BusinessLogic/Tasks/UpdateShippingServicesTask.php
+++ b/src/BusinessLogic/Tasks/UpdateShippingServicesTask.php
@@ -37,7 +37,7 @@ class UpdateShippingServicesTask extends Task
*/
public static function fromArray(array $array)
{
- return new static();
+ return new self();
}
/**
diff --git a/src/BusinessLogic/Tax/TaxClass.php b/src/BusinessLogic/Tax/TaxClass.php
index aff907e4..d2e1115b 100644
--- a/src/BusinessLogic/Tax/TaxClass.php
+++ b/src/BusinessLogic/Tax/TaxClass.php
@@ -43,4 +43,18 @@ class TaxClass extends FrontDto
* @var array
*/
protected static $requiredFields = array('label', 'value');
+
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
}
diff --git a/src/BusinessLogic/User/UserAccountService.php b/src/BusinessLogic/User/UserAccountService.php
index 60173890..89b34f05 100644
--- a/src/BusinessLogic/User/UserAccountService.php
+++ b/src/BusinessLogic/User/UserAccountService.php
@@ -56,6 +56,18 @@ class UserAccountService extends BaseService
*/
private $brandConfigurationService;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Validates provided API key and initializes user's data.
*
diff --git a/src/BusinessLogic/Warehouse/Warehouse.php b/src/BusinessLogic/Warehouse/Warehouse.php
index 814071a9..15b1b57c 100644
--- a/src/BusinessLogic/Warehouse/Warehouse.php
+++ b/src/BusinessLogic/Warehouse/Warehouse.php
@@ -127,6 +127,20 @@ class Warehouse extends FrontDto
'email',
);
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Transforms raw array data to its DTO.
*
diff --git a/src/BusinessLogic/Warehouse/WarehouseService.php b/src/BusinessLogic/Warehouse/WarehouseService.php
index cc60bb61..67d02da1 100644
--- a/src/BusinessLogic/Warehouse/WarehouseService.php
+++ b/src/BusinessLogic/Warehouse/WarehouseService.php
@@ -30,6 +30,18 @@ class WarehouseService extends BaseService
*/
protected static $instance;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Gets a warehouse.
*
diff --git a/src/BusinessLogic/WebHook/WebHookEventHandler.php b/src/BusinessLogic/WebHook/WebHookEventHandler.php
index e319692b..b3af0c04 100644
--- a/src/BusinessLogic/WebHook/WebHookEventHandler.php
+++ b/src/BusinessLogic/WebHook/WebHookEventHandler.php
@@ -38,6 +38,18 @@ class WebHookEventHandler extends BaseService
'shipment.delivered',
);
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Validates input and handles Packlink webhook event.
*
diff --git a/src/DemoUI/src/Services/BusinessLogic/ConfigurationService.php b/src/DemoUI/src/Services/BusinessLogic/ConfigurationService.php
index 1c889621..940e636e 100644
--- a/src/DemoUI/src/Services/BusinessLogic/ConfigurationService.php
+++ b/src/DemoUI/src/Services/BusinessLogic/ConfigurationService.php
@@ -28,6 +28,18 @@ class ConfigurationService extends Configuration
*/
protected static $instance;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Gets max inactivity period for a task in seconds.
* After inactivity period is passed, system will fail such task as expired.
diff --git a/src/Infrastructure/AutoTest/AutoTestLogger.php b/src/Infrastructure/AutoTest/AutoTestLogger.php
index 5ead78ed..a2727220 100644
--- a/src/Infrastructure/AutoTest/AutoTestLogger.php
+++ b/src/Infrastructure/AutoTest/AutoTestLogger.php
@@ -21,6 +21,18 @@ class AutoTestLogger extends Singleton implements ShopLoggerAdapter
*/
protected static $instance;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Logs a message in system.
*
diff --git a/src/Infrastructure/AutoTest/AutoTestTask.php b/src/Infrastructure/AutoTest/AutoTestTask.php
index 78a42f19..103dc5d2 100644
--- a/src/Infrastructure/AutoTest/AutoTestTask.php
+++ b/src/Infrastructure/AutoTest/AutoTestTask.php
@@ -40,7 +40,7 @@ public function __construct($data)
*/
public static function fromArray(array $array)
{
- return new static($array['data']);
+ return new self($array['data']);
}
/**
diff --git a/src/Infrastructure/Configuration/ConfigEntity.php b/src/Infrastructure/Configuration/ConfigEntity.php
index e2c74a5e..27aa5f56 100644
--- a/src/Infrastructure/Configuration/ConfigEntity.php
+++ b/src/Infrastructure/Configuration/ConfigEntity.php
@@ -42,6 +42,20 @@ class ConfigEntity extends Entity
*/
protected $fields = array('id', 'name', 'value', 'systemId');
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Returns entity configuration object.
*
diff --git a/src/Infrastructure/Data/DataTransferObject.php b/src/Infrastructure/Data/DataTransferObject.php
index 44410ebd..4f0819a5 100644
--- a/src/Infrastructure/Data/DataTransferObject.php
+++ b/src/Infrastructure/Data/DataTransferObject.php
@@ -22,7 +22,7 @@ abstract class DataTransferObject
*/
public static function fromArray(array $data)
{
- throw new RuntimeException('Method from array not implemented');
+ return null;
}
/**
diff --git a/src/Infrastructure/Http/CurlHttpClient.php b/src/Infrastructure/Http/CurlHttpClient.php
index 6b2ff3c8..cb0fa954 100644
--- a/src/Infrastructure/Http/CurlHttpClient.php
+++ b/src/Infrastructure/Http/CurlHttpClient.php
@@ -89,8 +89,6 @@ protected function sendHttpRequest($method, $url, $headers = array(), $body = ''
* request body is '1' to ensure minimal request data in case of POST, PUT, PATCH methods. This will ensure
* that we have the upload progress and enable the async request termination as soon as the upload is finished
* without waiting for a response (without downloading a body or relaying on a fixed request timeout).
- *
- * @return bool|string
*/
protected function sendHttpRequestAsync($method, $url, $headers = array(), $body = '1')
{
@@ -98,7 +96,7 @@ protected function sendHttpRequestAsync($method, $url, $headers = array(), $body
$this->setCurlSessionOptionsForAsynchronousRequest();
$this->setCurlOptions();
- return $this->executeAsynchronousRequest();
+ $this->executeAsynchronousRequest();
}
/**
diff --git a/src/Infrastructure/Http/DTO/Options.php b/src/Infrastructure/Http/DTO/Options.php
index 89a5131e..5aaeae75 100644
--- a/src/Infrastructure/Http/DTO/Options.php
+++ b/src/Infrastructure/Http/DTO/Options.php
@@ -78,6 +78,6 @@ public function toArray()
*/
public static function fromArray(array $raw)
{
- return new static($raw['name'], $raw['value']);
+ return new self($raw['name'], $raw['value']);
}
}
diff --git a/src/Infrastructure/Logger/LogData.php b/src/Infrastructure/Logger/LogData.php
index bc2985cb..57f03a67 100644
--- a/src/Infrastructure/Logger/LogData.php
+++ b/src/Infrastructure/Logger/LogData.php
@@ -94,6 +94,20 @@ public function __construct(
}
}
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Returns entity configuration object.
*
diff --git a/src/Infrastructure/Logger/Logger.php b/src/Infrastructure/Logger/Logger.php
index a18c25ff..5b9b1d23 100644
--- a/src/Infrastructure/Logger/Logger.php
+++ b/src/Infrastructure/Logger/Logger.php
@@ -61,6 +61,18 @@ protected function __construct()
$this->timeProvider = ServiceRegister::getService(TimeProvider::CLASS_NAME);
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Logs error message.
*
diff --git a/src/Infrastructure/Logger/LoggerConfiguration.php b/src/Infrastructure/Logger/LoggerConfiguration.php
index 5a687c77..8196a084 100644
--- a/src/Infrastructure/Logger/LoggerConfiguration.php
+++ b/src/Infrastructure/Logger/LoggerConfiguration.php
@@ -52,6 +52,18 @@ class LoggerConfiguration extends Singleton
*/
private $integrationName;
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Set default logger status (turning on/off).
*
diff --git a/src/Infrastructure/ORM/Entity.php b/src/Infrastructure/ORM/Entity.php
index cc11d5b8..9eb09294 100644
--- a/src/Infrastructure/ORM/Entity.php
+++ b/src/Infrastructure/ORM/Entity.php
@@ -30,6 +30,20 @@ abstract class Entity extends DataTransferObject
*/
protected $fields = array('id');
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return null;
+ }
+
/**
* Returns full class name.
*
@@ -49,7 +63,7 @@ public static function getClassName()
*/
public static function fromArray(array $data)
{
- $instance = new static();
+ $instance = static::create($data);
$instance->inflate($data);
return $instance;
diff --git a/src/Infrastructure/Singleton.php b/src/Infrastructure/Singleton.php
index 929c3b75..ec0bb3a8 100644
--- a/src/Infrastructure/Singleton.php
+++ b/src/Infrastructure/Singleton.php
@@ -2,6 +2,8 @@
namespace Logeecom\Infrastructure;
+use RuntimeException;
+
/**
* Base class for all singleton implementations.
* Every class that extends this class MUST have its own protected static field $instance!
@@ -10,6 +12,13 @@
*/
abstract class Singleton
{
+ /**
+ * Singleton instance of this class.
+ *
+ * @var static
+ */
+ protected static $instance;
+
/**
* Hidden constructor.
*/
@@ -25,16 +34,28 @@ protected function __construct()
public static function getInstance()
{
if (static::$instance === null) {
- static::$instance = new static();
+ static::$instance = static::create();
}
if (!(static::$instance instanceof static)) {
- throw new \RuntimeException('Wrong static instance of a singleton class.');
+ throw new RuntimeException('Wrong static instance of a singleton class.');
}
return static::$instance;
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return null;
+ }
+
/**
* Resets singleton instance. Required for proper tests.
*/
diff --git a/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php b/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php
index 36da14b9..67a74f84 100644
--- a/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php
+++ b/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php
@@ -68,6 +68,18 @@ protected function __construct()
$this->processRepository = RepositoryRegistry::getRepository(Process::CLASS_NAME);
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Starts given runner asynchronously (in new process/web request or similar).
*
diff --git a/src/Infrastructure/TaskExecution/CompositeTask.php b/src/Infrastructure/TaskExecution/CompositeTask.php
index 46b264eb..c27d4c06 100644
--- a/src/Infrastructure/TaskExecution/CompositeTask.php
+++ b/src/Infrastructure/TaskExecution/CompositeTask.php
@@ -62,6 +62,19 @@ public function __construct(array $subTasks, $initialProgress = 0)
}
}
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $subTasks
+ * @param $initialProgress
+ *
+ * @return CompositeTask
+ */
+ public static function create(array $subTasks, $initialProgress)
+ {
+ return null;
+ }
+
/**
* Transforms array into an serializable object,
*
@@ -78,7 +91,7 @@ public static function fromArray(array $array)
$tasks[] = Serializer::unserialize($task);
}
- $entity = new static($tasks, $array['initial_progress']);
+ $entity = static::create($tasks, $array['initial_progress']);
$entity->taskProgressMap = $array['task_progress_map'];
$entity->tasksProgressShare = $array['tasks_progress_share'];
diff --git a/src/Infrastructure/TaskExecution/Process.php b/src/Infrastructure/TaskExecution/Process.php
index f84be06c..0cdfd8b3 100644
--- a/src/Infrastructure/TaskExecution/Process.php
+++ b/src/Infrastructure/TaskExecution/Process.php
@@ -31,6 +31,20 @@ class Process extends Entity
*/
protected $runner;
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* Sets raw array data to this entity instance properties.
*
diff --git a/src/Infrastructure/TaskExecution/QueueItem.php b/src/Infrastructure/TaskExecution/QueueItem.php
index 8e0b4297..800bb1cc 100644
--- a/src/Infrastructure/TaskExecution/QueueItem.php
+++ b/src/Infrastructure/TaskExecution/QueueItem.php
@@ -184,6 +184,20 @@ class QueueItem extends Entity
*/
private $timeProvider;
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
+
/**
* QueueItem constructor.
*
diff --git a/src/Infrastructure/TaskExecution/QueueItemStarter.php b/src/Infrastructure/TaskExecution/QueueItemStarter.php
index b856e299..402f70c3 100644
--- a/src/Infrastructure/TaskExecution/QueueItemStarter.php
+++ b/src/Infrastructure/TaskExecution/QueueItemStarter.php
@@ -54,7 +54,7 @@ public function __construct($queueItemId)
*/
public static function fromArray(array $array)
{
- return new static($array['queue_item_id']);
+ return new self($array['queue_item_id']);
}
/**
diff --git a/src/Infrastructure/TaskExecution/TaskRunnerStarter.php b/src/Infrastructure/TaskExecution/TaskRunnerStarter.php
index 563c2ec2..3c78ae13 100644
--- a/src/Infrastructure/TaskExecution/TaskRunnerStarter.php
+++ b/src/Infrastructure/TaskExecution/TaskRunnerStarter.php
@@ -65,7 +65,7 @@ public function __construct($guid)
*/
public static function fromArray(array $array)
{
- return new static($array['guid']);
+ return new self($array['guid']);
}
/**
diff --git a/src/Infrastructure/Utility/Events/EventBus.php b/src/Infrastructure/Utility/Events/EventBus.php
index 74a71f64..25c49df5 100644
--- a/src/Infrastructure/Utility/Events/EventBus.php
+++ b/src/Infrastructure/Utility/Events/EventBus.php
@@ -34,7 +34,7 @@ private function __construct()
public static function getInstance()
{
if (static::$instance === null) {
- static::$instance = new static();
+ static::$instance = new self();
}
return static::$instance;
diff --git a/src/Infrastructure/Utility/GuidProvider.php b/src/Infrastructure/Utility/GuidProvider.php
index 94a76c1e..a36c82b6 100644
--- a/src/Infrastructure/Utility/GuidProvider.php
+++ b/src/Infrastructure/Utility/GuidProvider.php
@@ -36,7 +36,7 @@ private function __construct()
public static function getInstance()
{
if (static::$instance === null) {
- static::$instance = new static();
+ static::$instance = new self();
}
return static::$instance;
diff --git a/src/Infrastructure/Utility/TimeProvider.php b/src/Infrastructure/Utility/TimeProvider.php
index 518edc33..14e7d225 100644
--- a/src/Infrastructure/Utility/TimeProvider.php
+++ b/src/Infrastructure/Utility/TimeProvider.php
@@ -37,7 +37,7 @@ private function __construct()
public static function getInstance()
{
if (static::$instance === null) {
- static::$instance = new static();
+ static::$instance = new self();
}
return static::$instance;
@@ -96,7 +96,7 @@ public function getMicroTimestamp()
*/
public function sleep($sleepTime)
{
- sleep($sleepTime);
+ usleep($sleepTime * 1000);
}
/**
diff --git a/tests/BusinessLogic/Common/TestComponents/Dto/EmptyFrontDto.php b/tests/BusinessLogic/Common/TestComponents/Dto/EmptyFrontDto.php
index e700e38c..d3bf2ba8 100644
--- a/tests/BusinessLogic/Common/TestComponents/Dto/EmptyFrontDto.php
+++ b/tests/BusinessLogic/Common/TestComponents/Dto/EmptyFrontDto.php
@@ -11,4 +11,17 @@
*/
class EmptyFrontDto extends FrontDto
{
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
}
diff --git a/tests/BusinessLogic/Common/TestComponents/Dto/FooDto.php b/tests/BusinessLogic/Common/TestComponents/Dto/FooDto.php
index 0a8d0242..e87cfafa 100644
--- a/tests/BusinessLogic/Common/TestComponents/Dto/FooDto.php
+++ b/tests/BusinessLogic/Common/TestComponents/Dto/FooDto.php
@@ -35,4 +35,18 @@ class FooDto extends FrontDto
* @var array
*/
protected static $requiredFields = array('foo', 'bar');
+
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
}
diff --git a/tests/BusinessLogic/Common/TestComponents/Dto/TestCountry.php b/tests/BusinessLogic/Common/TestComponents/Dto/TestCountry.php
index 2e1fd90d..680cc3ae 100644
--- a/tests/BusinessLogic/Common/TestComponents/Dto/TestCountry.php
+++ b/tests/BusinessLogic/Common/TestComponents/Dto/TestCountry.php
@@ -22,4 +22,18 @@ public function __construct()
$this->code = 'MU';
$this->postalCode = '42602';
}
+
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
}
diff --git a/tests/BusinessLogic/Common/TestComponents/Dto/TestWarehouse.php b/tests/BusinessLogic/Common/TestComponents/Dto/TestWarehouse.php
index c8fc03a5..776fef63 100644
--- a/tests/BusinessLogic/Common/TestComponents/Dto/TestWarehouse.php
+++ b/tests/BusinessLogic/Common/TestComponents/Dto/TestWarehouse.php
@@ -28,4 +28,18 @@ public function __construct()
$this->email = 'default@default.com';
$this->default = true;
}
+
+ /**
+ * Creates instance of this class.
+ *
+ * @param array $data
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create(array $data)
+ {
+ return new self();
+ }
}
diff --git a/tests/BusinessLogic/Common/TestComponents/Locations/MockLocationService.php b/tests/BusinessLogic/Common/TestComponents/Locations/MockLocationService.php
index 84243d04..46c1a759 100644
--- a/tests/BusinessLogic/Common/TestComponents/Locations/MockLocationService.php
+++ b/tests/BusinessLogic/Common/TestComponents/Locations/MockLocationService.php
@@ -13,6 +13,18 @@ class MockLocationService extends LocationService
public $callHistory = array();
public $searchLocationsResult = array();
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
public function searchLocations($country, $query)
{
$this->callHistory[] = array('searchLocations' => array($country, $query));
diff --git a/tests/BusinessLogic/Common/TestComponents/Registration/MockCountryService.php b/tests/BusinessLogic/Common/TestComponents/Registration/MockCountryService.php
index feb7427e..93dbb34c 100644
--- a/tests/BusinessLogic/Common/TestComponents/Registration/MockCountryService.php
+++ b/tests/BusinessLogic/Common/TestComponents/Registration/MockCountryService.php
@@ -11,6 +11,18 @@ class MockCountryService extends CountryService
public $callHistory = array();
public static $supportedCountries = array();
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
public function getSupportedCountries($associative = true)
{
$this->callHistory[] = array('getSupportedCountries' => array($associative));
diff --git a/tests/BusinessLogic/Common/TestComponents/TestShopConfiguration.php b/tests/BusinessLogic/Common/TestComponents/TestShopConfiguration.php
index 73a2374c..9b2ffb6b 100644
--- a/tests/BusinessLogic/Common/TestComponents/TestShopConfiguration.php
+++ b/tests/BusinessLogic/Common/TestComponents/TestShopConfiguration.php
@@ -22,6 +22,18 @@ public function __construct()
static::$instance = $this;
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Returns current system identifier.
*
diff --git a/tests/BusinessLogic/Common/TestComponents/Warehouse/MockWarehouseService.php b/tests/BusinessLogic/Common/TestComponents/Warehouse/MockWarehouseService.php
index c8f39b61..b1c5d91e 100644
--- a/tests/BusinessLogic/Common/TestComponents/Warehouse/MockWarehouseService.php
+++ b/tests/BusinessLogic/Common/TestComponents/Warehouse/MockWarehouseService.php
@@ -19,6 +19,18 @@ public function getWarehouse($createIfNotExist = true)
return $this->getWarehouseResult;
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
public function updateWarehouseData(array $payload)
{
$this->callHistory[] = array('updateWarehouseData' => array($payload));
diff --git a/tests/BusinessLogic/Dto/BaseDtoTest.php b/tests/BusinessLogic/Dto/BaseDtoTest.php
index 363e35ba..735ae926 100644
--- a/tests/BusinessLogic/Dto/BaseDtoTest.php
+++ b/tests/BusinessLogic/Dto/BaseDtoTest.php
@@ -31,11 +31,10 @@ protected function tearDown()
TestFrontDtoFactory::reset();
}
- /**
- * @expectedException \RuntimeException
- */
public function testFromArrayNotImplemented()
{
- Address::fromArray(array());
+ $dto = Address::fromArray(array());
+
+ self::assertNull($dto);
}
}
diff --git a/tests/BusinessLogic/Order/OrderServiceTest.php b/tests/BusinessLogic/Order/OrderServiceTest.php
index f250b380..09d7b923 100644
--- a/tests/BusinessLogic/Order/OrderServiceTest.php
+++ b/tests/BusinessLogic/Order/OrderServiceTest.php
@@ -11,6 +11,7 @@
use Logeecom\Tests\Infrastructure\Common\TestServiceRegister;
use Packlink\BusinessLogic\Http\DTO\ParcelInfo;
use Packlink\BusinessLogic\Http\DTO\ShippingServiceDetails;
+use Packlink\BusinessLogic\Order\Exceptions\EmptyOrderException;
use Packlink\BusinessLogic\Order\Interfaces\ShopOrderService;
use Packlink\BusinessLogic\Order\OrderService;
use Packlink\BusinessLogic\OrderShipmentDetails\Models\OrderShipmentDetails;
@@ -160,6 +161,16 @@ public function testPrepareDraftWrongDestinationCountry()
);
}
+ /**
+ * @throws EmptyOrderException
+ * @throws \Packlink\BusinessLogic\Order\Exceptions\OrderNotFound
+ */
+ public function testPrepareDraftShippingReference()
+ {
+ $draft = $this->orderService->prepareDraft('test');
+ self::assertEquals($draft->shipmentCustomReference, 'test');
+ }
+
/**
* @throws \Packlink\BusinessLogic\Order\Exceptions\OrderNotFound
*/
diff --git a/tests/BusinessLogic/Order/OrderShipmentDetailsEntityTest.php b/tests/BusinessLogic/Order/OrderShipmentDetailsEntityTest.php
index 1a40819b..8ef5ecb2 100644
--- a/tests/BusinessLogic/Order/OrderShipmentDetailsEntityTest.php
+++ b/tests/BusinessLogic/Order/OrderShipmentDetailsEntityTest.php
@@ -59,6 +59,18 @@ public function testFromArray()
$this->validateOrderDetails($orderDetails);
}
+ /**
+ * Test new shipment statuses: INCIDENT and OUT FOR DELIVERY
+ */
+ public function testIncidentAndOutForDeliveryStatuses()
+ {
+ $orderDetails = new OrderShipmentDetails();
+ $orderDetails->setStatus(ShipmentStatus::OUT_FOR_DELIVERY);
+ self::assertEquals($orderDetails->getStatus(), 'outForDelivery');
+ $orderDetails->setStatus(ShipmentStatus::INCIDENT);
+ self::assertEquals($orderDetails->getStatus(), 'incident');
+ }
+
/**
* Tests conversion of Packlink order shipment details entity object to array.
*/
diff --git a/tests/Infrastructure/Common/TestComponents/TestShopConfiguration.php b/tests/Infrastructure/Common/TestComponents/TestShopConfiguration.php
index 7be8581f..3b50d8a8 100644
--- a/tests/Infrastructure/Common/TestComponents/TestShopConfiguration.php
+++ b/tests/Infrastructure/Common/TestComponents/TestShopConfiguration.php
@@ -23,6 +23,18 @@ public function __construct()
static::$instance = $this;
}
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
+
/**
* Returns current system identifier.
*
diff --git a/tests/Infrastructure/Common/TestComponents/Utility/TestGuidProvider.php b/tests/Infrastructure/Common/TestComponents/Utility/TestGuidProvider.php
index 1c6b6ee4..792ebb6b 100644
--- a/tests/Infrastructure/Common/TestComponents/Utility/TestGuidProvider.php
+++ b/tests/Infrastructure/Common/TestComponents/Utility/TestGuidProvider.php
@@ -8,6 +8,24 @@ class TestGuidProvider extends GuidProvider
{
private $guid = '';
+ private function __construct()
+ {
+ }
+
+ /**
+ * Returns singleton instance of GuidProvider.
+ *
+ * @return GuidProvider Instance of GuidProvider class.
+ */
+ public static function getInstance()
+ {
+ if (static::$instance === null) {
+ static::$instance = new self();
+ }
+
+ return static::$instance;
+ }
+
public function generateGuid()
{
if (empty($this->guid)) {
diff --git a/tests/Infrastructure/Singleton/TestAutoTestLogger.php b/tests/Infrastructure/Singleton/TestAutoTestLogger.php
index f659a781..3598a04a 100644
--- a/tests/Infrastructure/Singleton/TestAutoTestLogger.php
+++ b/tests/Infrastructure/Singleton/TestAutoTestLogger.php
@@ -11,4 +11,15 @@
*/
class TestAutoTestLogger extends AutoTestLogger
{
+ /**
+ * Creates instance of this class.
+ *
+ * @return static
+ *
+ * @noinspection PhpDocSignatureInspection
+ */
+ public static function create()
+ {
+ return new self();
+ }
}
\ No newline at end of file