Code Duplication    Length = 19-21 lines in 2 locations

src/Locator.php 1 location

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

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.