-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add registration type items for carts
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ parameters: | |
treatPhpDocTypesAsCertain: false | ||
paths: | ||
- src/ | ||
ignoreErrors: | ||
- '#Unsafe usage of new static\(\)#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/BusinessLogic/Domain/Order/Models/OrderRequest/Item/RegistrationItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item; | ||
|
||
/** | ||
* Class RegistrationItem | ||
* | ||
* @package SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item | ||
*/ | ||
class RegistrationItem extends Item | ||
{ | ||
/** | ||
* @var string|int A unique code that refers to this registration. | ||
*/ | ||
private $reference; | ||
|
||
/** | ||
* @var string A name to describe this registration. | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @param int|string $reference | ||
* @param string $name | ||
* @param int $totalWithTax | ||
*/ | ||
public function __construct($reference, string $name, int $totalWithTax) | ||
{ | ||
parent::__construct($totalWithTax, ItemType::TYPE_REGISTRATION); | ||
|
||
$this->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)); | ||
} | ||
} |