1 | <?php |
||
24 | final class Manager extends AbstractManager |
||
25 | { |
||
26 | use TranslatorManagerTrait; |
||
27 | use LoadTrait; |
||
28 | use DateTimeTrait; |
||
29 | |||
30 | protected $entity = 'Order'; |
||
31 | |||
32 | /** |
||
33 | * @codeCoverageIgnore |
||
34 | */ |
||
35 | protected function setUp() |
||
39 | |||
40 | 1 | public function factoryDecorator(Order $order, $decoratorName) |
|
48 | |||
49 | 1 | protected function resolvePrevious(Order $entity) |
|
60 | |||
61 | 1 | protected function normalizeShipping(Order $entity, Order $existent) |
|
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | 7 | public function update(EntityInterface $entity, EntityInterface $existent = null) |
|
75 | { |
||
76 | 7 | parent::update($entity, $existent); |
|
77 | |||
78 | 7 | $factory204 = function ($message) { |
|
79 | return new Response([ |
||
80 | 'raw' => '{"message":"'.$message.'"}', |
||
81 | 'httpStatusCode' => 204, |
||
82 | ]); |
||
83 | 7 | }; |
|
84 | |||
85 | 7 | if (empty($existent)) { |
|
86 | 7 | $existent = $this->resolvePrevious($entity); |
|
|
|||
87 | } |
||
88 | |||
89 | 7 | if ($entity->getOrderStatus() === $existent->getOrderStatus()) { |
|
90 | $this->log('info', 'Order sem atualização'); |
||
91 | |||
92 | return $factory204('Order status not changed!'); |
||
93 | } |
||
94 | |||
95 | 7 | if ('processing' === $entity->getOrderStatus()) { |
|
96 | return $factory204('Order status not used!'); |
||
97 | } |
||
98 | |||
99 | 7 | $entity = $this->normalizeShipping($entity, $existent); |
|
100 | |||
101 | 7 | if (in_array($entity->getOrderStatus(), ['approved', 'canceled', |
|
102 | 7 | 'delivered', 'invoiced', 'shipped', ], true)) { |
|
103 | 6 | $decorator = $this->factoryDecorator($entity, 'Status\\'.ucfirst($entity->getOrderStatus())); |
|
104 | 6 | $json = $decorator->toJson(); |
|
105 | 6 | $mapKey = 'to'.ucfirst($entity->getOrderStatus()); |
|
106 | 6 | $shipping = $entity->getShipping(); |
|
107 | 6 | $code = $shipping->getShippingCode(); |
|
108 | 6 | $shipping->toJson(); |
|
109 | 5 | $map = $this->factoryMap($mapKey, [ |
|
110 | 5 | 'orderNumber' => $entity->getOrderNumber(), |
|
111 | 5 | 'itemId' => $entity->getOrderNumber(), |
|
112 | 5 | 'shippingCode' => $code, |
|
113 | ]); |
||
114 | |||
115 | 5 | return $this->execute($map, $json); |
|
116 | } |
||
117 | |||
118 | 1 | throw new \InvalidArgumentException('Order Status ['.$entity->getOrderStatus().'] não suportado', 1); |
|
119 | } |
||
120 | |||
121 | public function factoryTranslator(array $data = []) |
||
127 | |||
128 | 1 | public function fetchQueue($offset = 0, $limit = 50, array $parameters = []) |
|
135 | } |
||
136 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.