Abstract Factory
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:07
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
interface AbstractFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @return DeliveryServiceInterface
|
||||
*/
|
||||
public function createDeliveryService(): DeliveryServiceInterface;
|
||||
|
||||
/**
|
||||
* @return PackageInterface
|
||||
*/
|
||||
public function createPackage(): PackageInterface;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:02
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
interface DeliveryServiceInterface
|
||||
{
|
||||
public function sendPackage(PackageInterface $package): void;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:15
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class JustinDeliveryFactory implements AbstractFactoryInterface
|
||||
{
|
||||
public function createDeliveryService(): DeliveryServiceInterface
|
||||
{
|
||||
return new JustinDeliveryService();
|
||||
}
|
||||
|
||||
public function createPackage(): PackageInterface
|
||||
{
|
||||
return new JustinPackage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 19:57
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class JustinDeliveryService implements DeliveryServiceInterface
|
||||
{
|
||||
public function sendPackage(PackageInterface $package): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump("Sending package via Justin...");
|
||||
}
|
||||
}
|
||||
21
src/Pattern/Creational/AbstractFactory/JustinPackage.php
Normal file
21
src/Pattern/Creational/AbstractFactory/JustinPackage.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:00
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class JustinPackage implements PackageInterface
|
||||
{
|
||||
public function getConsist(): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump('Checking package from Justin...');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:15
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class MeestDeliveryFactory implements AbstractFactoryInterface
|
||||
{
|
||||
public function createDeliveryService(): DeliveryServiceInterface
|
||||
{
|
||||
return new MeestDeliveryService();
|
||||
}
|
||||
|
||||
public function createPackage(): PackageInterface
|
||||
{
|
||||
return new MeestPackage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 19:57
|
||||
*/
|
||||
|
||||
//phpcs:ignore
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class MeestDeliveryService implements DeliveryServiceInterface
|
||||
{
|
||||
public function sendPackage(PackageInterface $package): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump("Sending package via Meest...");
|
||||
}
|
||||
}
|
||||
21
src/Pattern/Creational/AbstractFactory/MeestPackage.php
Normal file
21
src/Pattern/Creational/AbstractFactory/MeestPackage.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:00
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class MeestPackage implements PackageInterface
|
||||
{
|
||||
public function getConsist(): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump('Checking package from Meest...');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:15
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class NovapostDeliveryFactory implements AbstractFactoryInterface
|
||||
{
|
||||
public function createDeliveryService(): DeliveryServiceInterface
|
||||
{
|
||||
return new NovapostDeliveryService();
|
||||
}
|
||||
|
||||
public function createPackage(): PackageInterface
|
||||
{
|
||||
return new NovapostPackage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 19:57
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class NovapostDeliveryService implements DeliveryServiceInterface
|
||||
{
|
||||
public function sendPackage(PackageInterface $package): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump("Sending package via Novapost...");
|
||||
}
|
||||
}
|
||||
21
src/Pattern/Creational/AbstractFactory/NovapostPackage.php
Normal file
21
src/Pattern/Creational/AbstractFactory/NovapostPackage.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:00
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class NovapostPackage implements PackageInterface
|
||||
{
|
||||
public function getConsist(): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump('Checking package from Novapost...');
|
||||
}
|
||||
}
|
||||
17
src/Pattern/Creational/AbstractFactory/PackageInterface.php
Normal file
17
src/Pattern/Creational/AbstractFactory/PackageInterface.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 19:59
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
interface PackageInterface
|
||||
{
|
||||
public function getConsist(): void;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:15
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class UkrpostDeliveryFactory implements AbstractFactoryInterface
|
||||
{
|
||||
public function createDeliveryService(): DeliveryServiceInterface
|
||||
{
|
||||
return new UkrpostDeliveryService();
|
||||
}
|
||||
|
||||
public function createPackage(): PackageInterface
|
||||
{
|
||||
return new UkrpostPackage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 19:57
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class UkrpostDeliveryService implements DeliveryServiceInterface
|
||||
{
|
||||
public function sendPackage(PackageInterface $package): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump("Sending package via Ukrpost...");
|
||||
}
|
||||
}
|
||||
21
src/Pattern/Creational/AbstractFactory/UkrpostPackage.php
Normal file
21
src/Pattern/Creational/AbstractFactory/UkrpostPackage.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-03
|
||||
* @time: 20:00
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\AbstractFactory;
|
||||
|
||||
class UkrpostPackage implements PackageInterface
|
||||
{
|
||||
public function getConsist(): void
|
||||
{
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump('Checking package from Ukrpost...');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user