| 1 | <?php |
||
| 12 | abstract class BaseMapper |
||
| 13 | { |
||
| 14 | /** @var MqManagementConfig */ |
||
| 15 | protected $config; |
||
| 16 | |||
| 17 | 84 | public function __construct(MqManagementConfig $config) |
|
| 18 | { |
||
| 19 | 84 | $this->config = $config; |
|
| 20 | 84 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * @param JobBase $job |
||
| 24 | * @return MapResult |
||
| 25 | */ |
||
| 26 | 68 | public function map(JobBase $job) : MapResult |
|
| 27 | { |
||
| 28 | 68 | return new MapResult( |
|
| 29 | 68 | $this->mapMethod(), |
|
| 30 | 68 | $this->mapUrl($job), |
|
| 31 | 64 | $this->mapConfig($job) |
|
| 32 | ); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Created a HTTP method |
||
| 37 | * |
||
| 38 | * @return Method |
||
| 39 | */ |
||
| 40 | abstract protected function mapMethod() : Method; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Determens which url to call |
||
| 44 | * |
||
| 45 | * @param JobBase $job |
||
| 46 | * @return Url |
||
| 47 | * @throws |
||
| 48 | */ |
||
| 49 | abstract protected function mapUrl(JobBase $job) : Url ; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Maps the basic config of every API call |
||
| 53 | * |
||
| 54 | * @param JobBase $job |
||
| 55 | * @return array |
||
| 56 | */ |
||
| 57 | 64 | protected function mapConfig(JobBase $job) : array |
|
| 64 | } |
||
| 65 |