Code Duplication    Length = 24-24 lines in 2 locations

src/Tracking.php 2 locations

@@ 85-108 (lines=24) @@
82
     *
83
     * @return stdClass
84
     */
85
    public function track($trackingNumber, $requestOption = 'activity')
86
    {
87
        $this->trackingNumber = $trackingNumber;
88
        $this->requestOption = $requestOption;
89
90
        $access = $this->createAccess();
91
        $request = $this->createRequest();
92
93
        $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT));
94
        $response = $this->response->getResponse();
95
96
        if (null === $response) {
97
            throw new Exception('Failure (0): Unknown error', 0);
98
        }
99
100
        if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) {
101
            throw new Exception(
102
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
103
                (int)$response->Response->Error->ErrorCode
104
            );
105
        } else {
106
            return $this->formatResponse($response);
107
        }
108
    }
109
110
    /**
111
     * Set shipper number
@@ 151-174 (lines=24) @@
148
     *
149
     * @return stdClass
150
     */
151
    public function trackByReference($referenceNumber, $requestOption = 'activity')
152
    {
153
        $this->referenceNumber = $referenceNumber;
154
        $this->requestOption = $requestOption;
155
156
        $access = $this->createAccess();
157
        $request = $this->createRequest();
158
159
        $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT));
160
        $response = $this->response->getResponse();
161
162
        if (null === $response) {
163
            throw new Exception('Failure (0): Unknown error', 0);
164
        }
165
166
        if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) {
167
            throw new Exception(
168
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
169
                (int)$response->Response->Error->ErrorCode
170
            );
171
        } else {
172
            return $this->formatResponse($response);
173
        }
174
    }
175
176
    /**
177
     * Create the Tracking request.