1 | <?php |
||
18 | class PriceFactory implements PriceFactoryInterface |
||
19 | { |
||
20 | protected $creators = [ |
||
21 | EnumPrice::class => 'createEnumPrice', |
||
22 | SinglePrice::class => 'createSinglePrice', |
||
23 | ]; |
||
24 | |||
25 | protected $types = [ |
||
26 | 'enum' => EnumPrice::class, |
||
27 | 'single' => SinglePrice::class, |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * @var string default price class, when given will be used for not found types |
||
32 | */ |
||
33 | protected $defaultClass = null; |
||
34 | |||
35 | 2 | public function __construct(array $types = [], $defaultClass = null) |
|
40 | |||
41 | /** |
||
42 | * Creates price object. |
||
43 | * @return Price |
||
44 | */ |
||
45 | 2 | public function create(PriceCreationDto $dto) |
|
53 | |||
54 | 2 | public function findClassForType($type) |
|
64 | |||
65 | 2 | public function findMethodForClass($class) |
|
72 | |||
73 | 1 | public function createEnumPrice(PriceCreationDto $dto) |
|
77 | |||
78 | 1 | public function createSinglePrice(PriceCreationDto $dto) |
|
82 | } |
||
83 |