Tracking::track()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Nickcheek\USPSLookup\Service;
4
5
use Nickcheek\USPSLookup\USPSLookup;
6
7
class Tracking extends USPSLookup
8
{
9
    /**
10
     * Tracking a package by USPS Tracking number
11
     * @param $trackingnumber
12
     * @return \SimpleXMLElement
13
     */
14 View Code Duplication
    public static function track(string $trackingnumber): object
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
    {
16
        $track = new \SimpleXMLElement("<TrackRequest></TrackRequest>");
17
        $track->addAttribute('USERID', self::$USPSuser);
18
        $pack = $track->addChild('TrackID');
19
        $pack->addAttribute('ID', $trackingnumber);
20
        $url = self::$service . 'TrackV2&XML=' . $track->asXML();
21
        return simplexml_load_file($url);
22
    }
23
24
    /**
25
     * Tracking more than one package by USPS Tracking number array
26
     * @param $trackingarray (Array)
27
     * @return \SimpleXMLElement
28
     */
29 View Code Duplication
    public static function trackMultiple(array $trackingarray): object
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $track = new \SimpleXMLElement("<TrackRequest></TrackRequest>");
32
        $track->addAttribute('USERID', self::$USPSuser);
33
        foreach($trackingarray as $trackingnumber){
34
            $pack = $track->addChild('TrackID');
35
            $pack->addAttribute('ID', $trackingnumber);
36
        }
37
        $url = self::$service . 'TrackV2&XML=' . $track->asXML();
38
        return simplexml_load_file($url);
39
    }
40
}
41