Abstract Factory

This commit is contained in:
2025-07-03 21:15:26 +03:00
parent 0f4618edf5
commit 7fe2402ff3
19 changed files with 376 additions and 115 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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();
}
}

View File

@@ -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...");
}
}

View 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...');
}
}

View File

@@ -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();
}
}

View File

@@ -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...");
}
}

View 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...');
}
}

View File

@@ -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();
}
}

View File

@@ -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...");
}
}

View 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...');
}
}

View 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;
}

View File

@@ -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();
}
}

View File

@@ -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...");
}
}

View 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...');
}
}