-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #620 from extcode/add_bevariant_interface
[TASK] Add BeVariantInterface and ProductInterface
- Loading branch information
Showing
34 changed files
with
938 additions
and
694 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
interface AdditionalDataInterface | ||
{ | ||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
public function getAdditionals(): array; | ||
|
||
/** | ||
* @param array<string, mixed> $additional | ||
*/ | ||
public function setAdditionals(array $additional): void; | ||
|
||
public function unsetAdditionals(): void; | ||
|
||
public function getAdditional(string $key): mixed; | ||
|
||
public function setAdditional(string $key, mixed $value): void; | ||
|
||
public function unsetAdditional(string $key): void; | ||
} |
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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
trait AdditionalDataTrait | ||
{ | ||
/** | ||
* @var array<string, mixed> | ||
*/ | ||
private array $additionals; | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
public function getAdditionals(): array | ||
{ | ||
return $this->additionals; | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $additionals | ||
*/ | ||
public function setAdditionals(array $additionals): void | ||
{ | ||
$this->additionals = $additionals; | ||
} | ||
|
||
public function unsetAdditionals(): void | ||
{ | ||
$this->additionals = []; | ||
} | ||
|
||
public function getAdditional(string $key): mixed | ||
{ | ||
return $this->additionals[$key]; | ||
} | ||
|
||
public function setAdditional(string $key, mixed $value): void | ||
{ | ||
$this->additionals[$key] = $value; | ||
} | ||
|
||
public function unsetAdditional(string $key): void | ||
{ | ||
if (isset($this->additionals[$key])) { | ||
unset($this->additionals[$key]); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
final readonly class BeVariantFactory implements BeVariantFactoryInterface | ||
{ | ||
public function create( | ||
string $id, | ||
BeVariantInterface|ProductInterface $parent, | ||
string $title, | ||
string $sku, | ||
int $priceCalcMethod, | ||
float $price, | ||
int $quantity = 0 | ||
): BeVariantInterface { | ||
return new BeVariant( | ||
$id, | ||
$parent, | ||
$title, | ||
$sku, | ||
$priceCalcMethod, | ||
$price, | ||
$quantity, | ||
); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Domain\Model\Cart; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
interface BeVariantFactoryInterface | ||
{ | ||
public function create(string $id, BeVariantInterface|ProductInterface $parent, string $title, string $sku, int $priceCalcMethod, float $price, int $quantity = 0): BeVariantInterface; | ||
} |
Oops, something went wrong.