1 <?php
2 3 4
5 namespace Team3\PayU\Communication\Process;
6
7 use Psr\Log\LoggerInterface;
8 use Symfony\Component\Validator\Validator\ValidatorInterface;
9 use Team3\PayU\Communication\ClientAdapterFactory;
10 use Team3\PayU\Communication\ClientInterface;
11 use Team3\PayU\Communication\HttpStatusParser\HttpStatusParser;
12 use Team3\PayU\Communication\Process\ResponseDeserializer\ResponseDeserializer;
13 use Team3\PayU\Communication\Process\ResponseDeserializer\ResponseDeserializerFactory;
14 use Team3\PayU\Serializer\SerializerFactory;
15 use Team3\PayU\Serializer\SerializerInterface;
16 use Team3\PayU\ValidatorBuilder\ValidatorBuilder;
17
18 19 20
21 class RequestProcessFactory implements RequestProcessFactoryInterface
22 {
23 24 25 26 27
28 public function build(LoggerInterface $logger)
29 {
30 $requestProcess = new RequestProcess(
31 $this->getDeserializer($logger),
32 $this->getClient($logger),
33 $this->getValidator(),
34 new HttpStatusParser()
35 );
36
37 return $requestProcess;
38 }
39
40 41 42 43 44
45 private function getDeserializer(LoggerInterface $logger)
46 {
47 $deserializerFactory = new ResponseDeserializerFactory();
48
49 return $deserializerFactory->build($logger);
50 }
51
52 53 54 55 56
57 private function getSerializer(LoggerInterface $logger)
58 {
59 $serializerFactory = new SerializerFactory();
60
61 return $serializerFactory->build($logger);
62 }
63
64 65 66 67 68
69 private function getClient(LoggerInterface $logger)
70 {
71 $clientAdapterFactory = new ClientAdapterFactory();
72
73 return $clientAdapterFactory->build(
74 $this->getSerializer($logger),
75 $logger
76 );
77 }
78
79 80 81
82 private function getValidator()
83 {
84 $validatorBuilder = new ValidatorBuilder();
85
86 return $validatorBuilder->getValidator();
87 }
88 }
89