-
Notifications
You must be signed in to change notification settings - Fork 19
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 #17 from stefandoorn/refactor-product-detail-impre…
…ssion Refactor Product Detail Impression
- Loading branch information
Showing
19 changed files
with
590 additions
and
59 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 |
---|---|---|
|
@@ -52,3 +52,6 @@ | |
/vendor/ | ||
/etc/build/* | ||
!/etc/build/.gitkeep | ||
|
||
# PHPStorm | ||
.idea/ |
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
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 GtmEnhancedEcommercePlugin\Object\Factory; | ||
|
||
use GtmEnhancedEcommercePlugin\Object\ProductDetail; | ||
use GtmEnhancedEcommercePlugin\Object\ProductDetailInterface; | ||
|
||
final class ProductDetailFactory implements ProductDetailFactoryInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function create(): ProductDetailInterface | ||
{ | ||
return new ProductDetail(); | ||
} | ||
} |
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 GtmEnhancedEcommercePlugin\Object\Factory; | ||
|
||
use GtmEnhancedEcommercePlugin\Object\ProductDetailInterface; | ||
|
||
/** | ||
* Interface ProductDetailFactoryInterface | ||
* @package GtmEnhancedEcommercePlugin\Object\Factory | ||
*/ | ||
interface ProductDetailFactoryInterface | ||
{ | ||
/** | ||
* @return ProductDetailInterface | ||
*/ | ||
public function create(): ProductDetailInterface; | ||
} |
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,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace GtmEnhancedEcommercePlugin\Object\Factory; | ||
|
||
use GtmEnhancedEcommercePlugin\Object\ProductDetailImpression; | ||
use GtmEnhancedEcommercePlugin\Object\ProductDetailImpressionInterface; | ||
|
||
/** | ||
* Class ProductDetailImpressionFactory | ||
* @package GtmEnhancedEcommercePlugin\Object\Factory | ||
*/ | ||
final class ProductDetailImpressionFactory implements ProductDetailImpressionFactoryInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function create(): ProductDetailImpressionInterface | ||
{ | ||
return new ProductDetailImpression(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Object/Factory/ProductDetailImpressionFactoryInterface.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,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace GtmEnhancedEcommercePlugin\Object\Factory; | ||
|
||
use GtmEnhancedEcommercePlugin\Object\ProductDetailImpressionInterface; | ||
|
||
/** | ||
* Interface ProductDetailImpressionFactoryInterface | ||
* @package GtmEnhancedEcommercePlugin\Object\Factory | ||
*/ | ||
interface ProductDetailImpressionFactoryInterface | ||
{ | ||
/** | ||
* @return ProductDetailImpressionInterface | ||
*/ | ||
public function create(): ProductDetailImpressionInterface; | ||
} |
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,129 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace GtmEnhancedEcommercePlugin\Object; | ||
|
||
/** | ||
* Class ProductDetail | ||
* @package GtmEnhancedEcommercePlugin\Object | ||
*/ | ||
final class ProductDetail implements ProductDetailInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var float | ||
*/ | ||
private $price; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
private $category; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
private $variant; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setId(int $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getPrice(): float | ||
{ | ||
return $this->price; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setPrice(float $price): void | ||
{ | ||
$this->price = $price; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getCategory(): ?string | ||
{ | ||
return $this->category; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setCategory(?string $category) | ||
{ | ||
$this->category = $category; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getVariant(): ?string | ||
{ | ||
return $this->variant; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setVariant(?string $variant) | ||
{ | ||
$this->variant = $variant; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'name' => $this->name, | ||
'id' => $this->id, | ||
'price' => $this->price, | ||
'category' => $this->category ?? '', | ||
'variant' => $this->variant ?? '', | ||
]; | ||
} | ||
} |
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 GtmEnhancedEcommercePlugin\Object; | ||
|
||
/** | ||
* Class ProductDetailImpressionData | ||
* @package GtmEnhancedEcommercePlugin\Object | ||
*/ | ||
final class ProductDetailImpression implements ProductDetailImpressionInterface | ||
{ | ||
/** | ||
* @var array|ProductDetailInterface[] | ||
*/ | ||
private $variants = []; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function add(ProductDetailInterface $productDetail): void | ||
{ | ||
$this->variants[] = $productDetail; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return array_map(function(ProductDetailInterface $productDetail) { | ||
return $productDetail->toArray(); | ||
}, $this->variants); | ||
} | ||
} |
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,20 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace GtmEnhancedEcommercePlugin\Object; | ||
|
||
/** | ||
* Interface ProductDetailImpressionDataInterface | ||
* @package GtmEnhancedEcommercePlugin\Object | ||
*/ | ||
interface ProductDetailImpressionInterface | ||
{ | ||
/** | ||
* @param ProductDetailInterface $productDetail | ||
*/ | ||
public function add(ProductDetailInterface $productDetail): void; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray(): array; | ||
} |
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,65 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace GtmEnhancedEcommercePlugin\Object; | ||
|
||
/** | ||
* Interface ProductDetailInterface | ||
* @package GtmEnhancedEcommercePlugin\Object | ||
*/ | ||
interface ProductDetailInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string; | ||
|
||
/** | ||
* @param string $name | ||
*/ | ||
public function setName(string $name): void; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId(): int; | ||
|
||
/** | ||
* @param int $id | ||
*/ | ||
public function setId(int $id): void; | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getPrice(): float; | ||
|
||
/** | ||
* @param float $price | ||
*/ | ||
public function setPrice(float $price): void; | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
public function getCategory(): ?string; | ||
|
||
/** | ||
* @param null|string $category | ||
*/ | ||
public function setCategory(?string $category); | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
public function getVariant(): ?string; | ||
|
||
/** | ||
* @param null|string $variant | ||
*/ | ||
public function setVariant(?string $variant); | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray(): array; | ||
} |
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
Oops, something went wrong.