Code Duplication    Length = 24-24 lines in 2 locations

src/Tracking.php 2 locations

@@ 86-109 (lines=24) @@
83
     *
84
     * @return stdClass
85
     */
86
    public function track($trackingNumber, $requestOption = 'activity')
87
    {
88
        $this->trackingNumber = $trackingNumber;
89
        $this->requestOption = $requestOption;
90
91
        $access = $this->createAccess();
92
        $request = $this->createRequest();
93
94
        $this->response = $this->getRequest()->request($access, $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 instanceof SimpleXMLElement && $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
     * Get package tracking information.
@@ 121-144 (lines=24) @@
118
     *
119
     * @return stdClass
120
     */
121
    public function trackByReference($referenceNumber, $requestOption = 'activity')
122
    {
123
        $this->referenceNumber = $referenceNumber;
124
        $this->requestOption = $requestOption;
125
126
        $access = $this->createAccess();
127
        $request = $this->createRequest();
128
129
        $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT));
130
        $response = $this->response->getResponse();
131
132
        if (null === $response) {
133
            throw new Exception('Failure (0): Unknown error', 0);
134
        }
135
136
        if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) {
137
            throw new Exception(
138
                "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}",
139
                (int)$response->Response->Error->ErrorCode
140
            );
141
        } else {
142
            return $this->formatResponse($response);
143
        }
144
    }
145
146
    /**
147
     * Set shipper number