Code Duplication    Length = 19-21 lines in 3 locations

src/Rate.php 1 location

@@ 89-109 (lines=21) @@
86
     *
87
     * @return RateRequest
88
     */
89
    private function sendRequest(RateRequest $rateRequest)
90
    {
91
        $request = $this->createRequest($rateRequest);
92
        //$response = $this->request($this->createAccess(), $request, $this->compileEndpointUrl(self::ENDPOINT));
93
94
        $this->response = $this->getRequest()->request($this->createAccess(), $request, $this->compileEndpointUrl(self::ENDPOINT));
95
        $response = $this->response->getResponse();
96
97
        if (null === $response) {
98
            throw new Exception('Failure (0): Unknown error', 0);
99
        }
100
101
        if ($response->Response->ResponseStatusCode == 0) {
102
            throw new Exception(
103
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
104
                (int)$response->Response->Error->ErrorCode
105
            );
106
        } else {
107
            return $this->formatResponse($response);
108
        }
109
    }
110
111
    /**
112
     * Create the Rate request.

src/Locator.php 1 location

@@ 64-82 (lines=19) @@
61
     *
62
     * @return \stdClass
63
     */
64
    private function sendRequest(LocatorRequest $request, $requestOption)
65
    {
66
        $request = $this->createRequest($request, $requestOption);
67
        $this->response = $this->getRequest()->request($this->createAccess(), $request, $this->compileEndpointUrl(self::ENDPOINT));
68
        $response = $this->response->getResponse();
69
70
        if (null === $response) {
71
            throw new Exception('Failure (0): Unknown error', 0);
72
        }
73
74
        if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) {
75
            throw new Exception(
76
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
77
                (int)$response->Response->Error->ErrorCode
78
            );
79
        } else {
80
            return $this->formatResponse($response);
81
        }
82
    }
83
84
    /**
85
     * Create the TimeInTransit request.

src/TimeInTransit.php 1 location

@@ 61-79 (lines=19) @@
58
     *
59
     * @return TimeInTransitRequest
60
     */
61
    private function sendRequest(TimeInTransitRequest $timeInTransitRequest)
62
    {
63
        $request = $this->createRequest($timeInTransitRequest);
64
        $this->response = $this->getRequest()->request($this->createAccess(), $request, $this->compileEndpointUrl(self::ENDPOINT));
65
        $response = $this->response->getResponse();
66
67
        if (null === $response) {
68
            throw new Exception('Failure (0): Unknown error', 0);
69
        }
70
71
        if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) {
72
            throw new Exception(
73
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
74
                (int)$response->Response->Error->ErrorCode
75
            );
76
        } else {
77
            return $this->formatResponse($response);
78
        }
79
    }
80
81
    /**
82
     * Create the TimeInTransit request.