1 <?php
2 3 4
5 namespace Team3\PayU\Order\Transformer\UserOrder;
6
7 use Psr\Log\LoggerInterface;
8 use Team3\PayU\Order\Transformer\UserOrder\Strategy\UserOrderTransformerStrategiesProvider;
9 use Team3\PayU\PropertyExtractor\ExtractorInterface;
10 use Team3\PayU\PropertyExtractor\PropertyExtractorFactory;
11
12 class UserOrderTransformerFactory implements UserOrderTransformerFactoryInterface
13 {
14 15 16 17 18
19 public function build(LoggerInterface $logger)
20 {
21 $extractor = $this->getPropertyExtractor($logger);
22 $transformer = new UserOrderTransformer($extractor);
23 $strategiesProvider = new UserOrderTransformerStrategiesProvider();
24 $strategies = $strategiesProvider->getStrategies($extractor, $transformer);
25
26 foreach ($strategies as $strategy) {
27 $transformer->addStrategy($strategy);
28 }
29
30 return $transformer;
31 }
32
33 34 35 36 37
38 private function getPropertyExtractor(LoggerInterface $logger)
39 {
40 $factory = new PropertyExtractorFactory();
41
42 return $factory->build($logger);
43 }
44 }
45