Code Duplication    Length = 19-21 lines in 3 locations

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 TimeInTransitResponse
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.

src/Rate.php 1 location

@@ 128-148 (lines=21) @@
125
     *
126
     * @return RateResponse
127
     */
128
    private function sendRequest(RateRequest $rateRequest)
129
    {
130
        $request = $this->createRequest($rateRequest);
131
132
        $this->response = $this->getRequest()->request($this->createAccess(), $request, $this->compileEndpointUrl(self::ENDPOINT));
133
        $response = $this->response->getResponse();
134
135
        if (null === $response) {
136
            throw new Exception('Failure (0): Unknown error', 0);
137
        }
138
139
        if ($response->Response->ResponseStatusCode == 0) {
140
            throw new Exception(
141
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
142
                (int)$response->Response->Error->ErrorCode
143
            );
144
        } else {
145
            return $this->formatResponse($response);
146
        }
147
    }
148
149
    /**
150
     * Create the Rate request.
151
     *