diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index ba99af0..a37753d 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -4,6 +4,7 @@ . vendor/ + .history/ diff --git a/phpstan.neon b/phpstan.neon index e6c9f72..9ca525b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,3 +4,5 @@ parameters: treatPhpDocTypesAsCertain: false paths: - src/ + ignoreErrors: + - '#Unsafe usage of new static\(\)#' diff --git a/src/BusinessLogic/Domain/Order/Models/OrderRequest/Cart.php b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Cart.php index c8105d1..4410cac 100644 --- a/src/BusinessLogic/Domain/Order/Models/OrderRequest/Cart.php +++ b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Cart.php @@ -15,6 +15,7 @@ use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\ItemType; use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\OtherPaymentItem; use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\ProductItem; +use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\RegistrationItem; use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\ServiceItem; /** @@ -126,6 +127,9 @@ public static function fromArray(array $data): Cart case ItemType::TYPE_DISCOUNT: $itemInstances[] = DiscountItem::fromArray($itemData); break; + case ItemType::TYPE_REGISTRATION: + $itemInstances[] = RegistrationItem::fromArray($itemData); + break; case ItemType::TYPE_SERVICE: $itemInstances[] = ServiceItem::fromArray($itemData); break; diff --git a/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/ItemType.php b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/ItemType.php index 1724ae6..c4a4793 100644 --- a/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/ItemType.php +++ b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/ItemType.php @@ -15,4 +15,5 @@ class ItemType public const TYPE_INVOICE_FEE = 'invoice_fee'; public const TYPE_HANDLING = 'handling'; public const TYPE_DISCOUNT = 'discount'; + public const TYPE_REGISTRATION = 'registration'; } diff --git a/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/RegistrationItem.php b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/RegistrationItem.php new file mode 100644 index 0000000..f8a6666 --- /dev/null +++ b/src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/RegistrationItem.php @@ -0,0 +1,74 @@ +reference = $reference; + $this->name = $name; + } + + /** + * Create RegistrationItem object from array. + * + * @param array $data + * + * @return RegistrationItem + */ + public static function fromArray(array $data): Item + { + $totalWithTax = self::getDataValue($data, 'total_with_tax', 0); + $reference = self::getDataValue($data, 'reference'); + $name = self::getDataValue($data, 'name'); + + return new self($reference, $name, $totalWithTax); + } + + /** + * @return int|string + */ + public function getReference() + { + return $this->reference; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return $this->transformPropertiesToAnArray(get_object_vars($this)); + } +}