Conditions | 6 |
Paths | 8 |
Total Lines | 34 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public static function findOrders(ThreePlCentral $threepl, DateTime $beginDate, DateTime $endDate) |
||
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 | |||
21 | $response = $request->fetch([ |
||
22 | 'BeginDate' => $beginDate->format('Y-m-d'), |
||
23 | 'EndDate' => $endDate->format('Y-m-d') |
||
24 | ]); |
||
25 | |||
26 | $result = $response->json(); |
||
27 | if (!is_array($result)) { |
||
28 | $result = [$result]; |
||
29 | } |
||
30 | |||
31 | $finalOrders = []; |
||
32 | foreach ($result as $item) { |
||
33 | $entity = new OrderEntity(); |
||
34 | foreach ($item as $key => $value) { |
||
35 | $method = "set{$key}"; |
||
36 | if (is_string($value) && method_exists($entity, $method)) { |
||
37 | call_user_func([$entity, $method], $value); |
||
38 | } |
||
39 | } |
||
40 | $finalOrders[] = $entity; |
||
41 | } |
||
42 | |||
43 | return $finalOrders; |
||
44 | } |
||
45 | } |
||
46 |