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