| Conditions | 6 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public static function findOrders(ThreePlCentral $threepl, DateTime $beginDate, DateTime $endDate): array |
||
| 12 | { |
||
| 13 | $request = RequestFactory::create( |
||
| 14 | $threepl, |
||
| 15 | 'POST', |
||
| 16 | 'http://www.JOI.com/schemas/ViaSub.WMS/FindOrders' |
||
| 17 | ); |
||
| 18 | |||
| 19 | $request->setTemplate(__DIR__ . '/../Request/findOrders.xml'); |
||
| 20 | $response = $request->fetch([ |
||
| 21 | 'BeginDate' => $beginDate->format('YYYY-MM-DD'), |
||
| 22 | 'EndDate' => $endDate->format('YYYY-MM-DD') |
||
| 23 | ]); |
||
| 24 | |||
| 25 | $result = $response->json(); |
||
| 26 | if (!is_array($result)) $result = [$result]; |
||
| 27 | |||
| 28 | $finalOrders = []; |
||
| 29 | foreach ($result as $item) { |
||
| 30 | $entity = new OrderEntity(); |
||
| 31 | foreach ($item as $key => $value) { |
||
| 32 | $method = "set{$key}"; |
||
| 33 | if (is_string($value) && method_exists($entity, $method)) { |
||
| 34 | call_user_func([$entity, $method], $value); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | $finalOrders[] = $entity; |
||
| 38 | } |
||
| 39 | |||
| 40 | return $finalOrders; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |