Code Duplication    Length = 26-26 lines in 2 locations

src/Smsa.php 2 locations

@@ 229-254 (lines=26) @@
226
     *
227
     * @return SMSAResponse
228
     */
229
    public function status($awb): SMSAResponse
230
    {
231
        $result = $this->service->getStatus(
232
            $payload = new GetStatus($awb, $this->passKey)
233
        );
234
235
        if (false === $result) {
236
            return $this->failedRequest('GetStatus', $payload);
237
        }
238
239
        $status = $result->getGetStatusResult();
240
241
        if (empty($status) || is_null($status)) {
242
            return $this->failedResponse('GetStatus', $payload, 'No status, shipment was not found');
243
        }
244
245
        if (0 === strpos(mb_strtolower($status), 'failed')) {
246
            return $this->failedResponse('GetStatus', $payload, $status);
247
        }
248
249
        return $this->successResponse(
250
            'GetStatus',
251
            $payload,
252
            $status
253
        );
254
    }
255
256
    /**
257
     * Cancel a shipment by AWB
@@ 267-292 (lines=26) @@
264
     *
265
     * @return SMSAResponse
266
     */
267
    public function cancel($awb, $reason): SMSAResponse
268
    {
269
        $result = $this->service->cancelShipment(
270
            $payload = new CancelShipment($awb, $this->passKey, $reason)
271
        );
272
273
        if (false === $result) {
274
            return $this->failedRequest('CancelShipment', $payload);
275
        }
276
277
        $data = $result->getCancelShipmentResult();
278
279
        if (empty($data) || is_null($data)) {
280
            return $this->failedResponse('CancelShipment', $payload, 'Cannot Cancel, shipment was not found');
281
        }
282
283
        if (0 === strpos(mb_strtolower($data), 'failed')) {
284
            return $this->failedResponse('CancelShipment', $payload, $data);
285
        }
286
287
        return $this->successResponse(
288
            'CancelShipment',
289
            $payload,
290
            $data
291
        );
292
    }
293
294
    /**
295
     * Create a new shipment