1: <?php
2: namespace SmsOrange;
3:
4: /**
5: * Class Dispatcher
6: *
7: * Router for the booking service requests.
8: *
9: * @package SmsOrange
10: */
11: class Dispatcher
12: {
13: private $service;
14:
15: /**
16: * Dispatcher constructor.
17: *
18: * @param Bookable $service instance of Cruise or Tour
19: */
20: public function __construct(Bookable $service)
21: {
22: $this->service = $service;
23: }
24:
25: /**
26: * Calls the injected service's search method.
27: *
28: * @param array $parameters search form
29: * @return mixed (\Unirest\Response object)
30: */
31: public function search( $parameters )
32: {
33: return $this->service->search( $parameters );
34: }
35:
36: /**
37: * Handles package selection by service.
38: *
39: * @param array $parameters
40: * @return mixed (\Unirest\Response object)
41: */
42: public function select( $parameters )
43: {
44: return $this->service->select( $parameters );
45: }
46:
47: /**
48: * Gets the components for a service.
49: *
50: * @param array $parameters
51: * @return mixed (\Unirest\Response object)
52: */
53: public function getComponents( $parameters )
54: {
55: return $this->service->getComponents( $parameters );
56: }
57:
58: /**
59: * Gets the available categories for a service.
60: *
61: * @param array $parameters
62: * @return mixed (\Unirest\Response object)
63: */
64: public function getAvailableCategories( $parameters )
65: {
66: return $this->service->getAvailableCategories( $parameters );
67: }
68:
69: /**
70: * Gets the cabins for a service.
71: *
72: * @param array $parameters
73: * @return mixed (\Unirest\Response object)
74: */
75: public function getCabins( $parameters )
76: {
77: return $this->service->getCabins( $parameters );
78: }
79:
80: /**
81: * Gets the price quote for a service.
82: *
83: * @param array $parameters
84: * @return mixed (\Unirest\Response object)
85: */
86: public function getQuote( $parameters )
87: {
88: return $this->service->getQuote( $parameters );
89: }
90:
91: /**
92: * Holds the cabin for a service.
93: *
94: * @param array $parameters
95: * @return mixed (\Unirest\Response object)
96: */
97: public function holdCabin( $parameters )
98: {
99: return $this->service->holdCabin( $parameters );
100: }
101:
102: /**
103: * Handles the final booking step by service.
104: *
105: * @param array $parameters
106: * @return mixed (\Unirest\Response object)
107: */
108: public function book( $parameters )
109: {
110: return $this->service->book( $parameters );
111: }
112: }
113: