1 | <?php |
||
20 | class PriceFactory implements PriceFactoryInterface |
||
21 | { |
||
22 | protected $creators = [ |
||
23 | EnumPrice::class => 'createEnumPrice', |
||
24 | SinglePrice::class => 'createSinglePrice', |
||
25 | ]; |
||
26 | |||
27 | protected $types = [ |
||
28 | 'enum' => EnumPrice::class, |
||
29 | 'single' => SinglePrice::class, |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @var string default price class, when given will be used for not found types |
||
34 | */ |
||
35 | protected $defaultClass = null; |
||
36 | |||
37 | 2 | public function __construct(array $types = [], $defaultClass = null) |
|
42 | |||
43 | /** |
||
44 | * Creates price object. |
||
45 | * |
||
46 | * @param PriceCreationDto $dto |
||
47 | * @return Price |
||
48 | */ |
||
49 | 2 | public function create(PriceCreationDto $dto) |
|
59 | |||
60 | 2 | public function findClassForTypes(array $types) |
|
72 | |||
73 | 2 | public function findMethodForClass($class) |
|
80 | |||
81 | 1 | public function createEnumPrice(PriceCreationDto $dto) |
|
85 | |||
86 | 1 | public function createSinglePrice(PriceCreationDto $dto) |
|
90 | } |
||
91 |