Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // config.php
- return {
- 'types' => [
- OrderType::ACTIVE => \App\ActiveOrder::class,
- OrderType::NEW => \App\NewOrder::class,
- OrderType::DISABLED => \App\DisabledOrder::class,
- ]
- }
- // OrderFactory.php
- class OrderFactory {
- public function getOrder(int $type): Order {
- if (
- config()->has('types.' . $type) &&
- class_exist(config()->get('types.' . $type))
- ) {
- return new (config()->get('types.' . $type));
- }
- throw new \InvalidArgumentException('Undefined order type');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement