1 | <?php |
||
40 | class Tracker |
||
41 | { |
||
42 | /** |
||
43 | * Webservice endpoint |
||
44 | */ |
||
45 | const WEBSERVICE_URL = 'https://webservice.correios.com.br/service/rastro/Rastro.wsdl'; |
||
46 | |||
47 | /** |
||
48 | * Fetches a single package |
||
49 | */ |
||
50 | const FETCH_SINGLE = 'L'; |
||
51 | |||
52 | /** |
||
53 | * Fetches an interval of packages |
||
54 | */ |
||
55 | const FETCH_INTERVAL = 'F'; |
||
56 | |||
57 | /** |
||
58 | * The results mode. 'T' will return the entire package history. |
||
59 | */ |
||
60 | const RESULT_MODE = 'T'; |
||
61 | |||
62 | /** |
||
63 | * Webservice username, supplied by Correios |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $username; |
||
67 | |||
68 | /** |
||
69 | * Webservice password, supplied by Correios |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $password; |
||
73 | |||
74 | |||
75 | /** |
||
76 | * Sets up user credentials |
||
77 | * @param string $username Webservice username |
||
78 | * @param string $password Webservice password |
||
79 | */ |
||
80 | 6 | public function __construct($username, $password) |
|
85 | |||
86 | /** |
||
87 | * Validates the format of a tracking number |
||
88 | * @param string $trackingNumber The tracking number |
||
89 | * @return boolean |
||
90 | */ |
||
91 | 6 | protected function validTrackingNumber($trackingNumber) |
|
99 | |||
100 | /** |
||
101 | * Tracks one or more packages |
||
102 | * @param mixed $trackingNumber A single tracking number or an array of tracking numbers |
||
103 | * @return mixed |
||
104 | */ |
||
105 | 6 | public function track($trackingNumber) |
|
117 | |||
118 | /** |
||
119 | * Queries the Correios webservice |
||
120 | * @param string $trackingNumbers A collection of tracking numbers |
||
121 | * @param string $fetchMode The fetch mode (for one or more tracking numbers) |
||
122 | * @return mixed |
||
123 | */ |
||
124 | 1 | protected function queryAPI($trackingNumbers, $fetchMode) |
|
150 | |||
151 | /** |
||
152 | * Processes the webservice response and builds a readable associative |
||
153 | * array of the events associated to one or more packages |
||
154 | * @param string $responseBody The response body (xml) |
||
155 | * @return mixed |
||
156 | */ |
||
157 | 1 | protected function processResponse($responseBody) |
|
182 | } |
||
183 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.