Created
December 28, 2014 19:12
-
-
Save aik099/2fe455db22145e69e73c to your computer and use it in GitHub Desktop.
Example file to demonstrate fixing issue with "Squiz.WhiteSpace.FunctionSpacing" sniff in PHP_CodeSniffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FedExShippingQuotingEngine extends ShippingQuoteEngine | |
{ | |
function GetTrack($tracking_number) | |
{ | |
$path_to_wsdl = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR . $this->GetWsdlFolder() . DIRECTORY_SEPARATOR.'TrackService_v9.wsdl'; | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information. | |
$request = $this->_getRequestBase('trck:9.0.0'); | |
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Track Request v9 using PHP ***'); | |
$request['SelectionDetails']['PackageIdentifier'] = array( | |
'Value' => $tracking_number, | |
'Type' => 'TRACKING_NUMBER_OR_DOORTAG' | |
); | |
try { | |
$response = $client->track($request); | |
$tracks = array(); | |
if ( $response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') { | |
$tracks[] = array( | |
'Timestamp' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Timestamp, | |
'EventDescription' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> EventDescription, | |
'City' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> City, | |
'PostalCode' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> PostalCode, | |
'State' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> StateOrProvinceCode, | |
'CountryCode' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> CountryCode | |
); | |
return $tracks; | |
} | |
else { | |
$error_code = $response->Notifications -> Code; | |
$error_message = $response->Notifications -> Message; | |
return array('error_code' => $error_code, 'error_message' => $error_message); | |
} | |
} | |
catch (SoapFault $exception) { | |
return array('error_code' => '-1', 'error_message' => $exception->faultstring); | |
} | |
} | |
/*$params = array( | |
'AccountLogin' => 'login', | |
'AccountPassword' => 'password', | |
'carriers' => array( | |
array( | |
'name' => 'UPS', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'DHL', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'FDX', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'USP', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'ARB', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
), | |
'classes' => array('1DY', '2DY', '3DY', 'GND'), | |
'ShipMethod' => 'DRP', | |
'orig_name' => 'John%20Smith', | |
'orig_addr1' => '2275%20Union%20Road', | |
'orig_city' => 'Cheektowaga', | |
'orig_state' => 'NY', | |
'orig_postal' => '14227', | |
'orig_country' => 'US', | |
// this section is required. | |
'dest_name' => 'Vasya%20Pupkin', | |
'dest_addr1' => '175%20E.Hawthorn%20pkwy.', | |
'dest_city' => 'Vernon%20Hills', | |
'dest_state' => 'IL', | |
'dest_postal' => '60061', | |
'dest_country' => 'US', | |
// this section is required. | |
'packages' => array( | |
array( | |
'package_key' => 'package1', | |
'weight' => '50', | |
'weight_unit' => 'LB', | |
'length' => '25', | |
'width' => '15', | |
'height' => '15', | |
'dim_unit' => 'IN', | |
'packaging' => 'BOX', | |
'contents' => 'OTR', | |
'insurance' => '0' | |
), | |
array( | |
'package_key' => 'package2', | |
'weight' => '50', | |
'weight_unit' => 'LB', | |
'length' => '25', | |
'width' => '15', | |
'height' => '15', | |
'dim_unit' => 'IN', | |
'packaging' => 'BOX', | |
'contents' => 'OTR', | |
'insurance' => '0' | |
), | |
), | |
'shipment_id' => 1234; | |
); | |
Returns: | |
$quotes = array( | |
'package1' => | |
array( | |
array( | |
'id' => 'INTSH_FDX_2DY', | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
array( | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
), | |
'package2' => | |
array( | |
array( | |
'id' => 'INTSH_FDX_3DY', | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
array( | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
), | |
) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FedExShippingQuotingEngine extends ShippingQuoteEngine | |
{ | |
function GetTrack($tracking_number) | |
{ | |
$path_to_wsdl = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR . $this->GetWsdlFolder() . DIRECTORY_SEPARATOR.'TrackService_v9.wsdl'; | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information. | |
$request = $this->_getRequestBase('trck:9.0.0'); | |
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Track Request v9 using PHP ***'); | |
$request['SelectionDetails']['PackageIdentifier'] = array( | |
'Value' => $tracking_number, | |
'Type' => 'TRACKING_NUMBER_OR_DOORTAG' | |
); | |
try { | |
$response = $client->track($request); | |
$tracks = array(); | |
if ( $response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') { | |
$tracks[] = array( | |
'Timestamp' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Timestamp, | |
'EventDescription' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> EventDescription, | |
'City' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> City, | |
'PostalCode' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> PostalCode, | |
'State' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> StateOrProvinceCode, | |
'CountryCode' => $response -> CompletedTrackDetails -> TrackDetails -> Events -> Address -> CountryCode | |
); | |
return $tracks; | |
} | |
else { | |
$error_code = $response->Notifications -> Code; | |
$error_message = $response->Notifications -> Message; | |
return array('error_code' => $error_code, 'error_message' => $error_message); | |
} | |
} | |
catch (SoapFault $exception) { | |
return array('error_code' => '-1', 'error_message' => $exception->faultstring); | |
} | |
} | |
} | |
/*$params = array( | |
'AccountLogin' => 'login', | |
'AccountPassword' => 'password', | |
'carriers' => array( | |
array( | |
'name' => 'UPS', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'DHL', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'FDX', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'USP', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
array( | |
'name' => 'ARB', | |
'account' => '', | |
'invoiced' => '0' | |
), | |
), | |
'classes' => array('1DY', '2DY', '3DY', 'GND'), | |
'ShipMethod' => 'DRP', | |
'orig_name' => 'John%20Smith', | |
'orig_addr1' => '2275%20Union%20Road', | |
'orig_city' => 'Cheektowaga', | |
'orig_state' => 'NY', | |
'orig_postal' => '14227', | |
'orig_country' => 'US', | |
// this section is required. | |
'dest_name' => 'Vasya%20Pupkin', | |
'dest_addr1' => '175%20E.Hawthorn%20pkwy.', | |
'dest_city' => 'Vernon%20Hills', | |
'dest_state' => 'IL', | |
'dest_postal' => '60061', | |
'dest_country' => 'US', | |
// this section is required. | |
'packages' => array( | |
array( | |
'package_key' => 'package1', | |
'weight' => '50', | |
'weight_unit' => 'LB', | |
'length' => '25', | |
'width' => '15', | |
'height' => '15', | |
'dim_unit' => 'IN', | |
'packaging' => 'BOX', | |
'contents' => 'OTR', | |
'insurance' => '0' | |
), | |
array( | |
'package_key' => 'package2', | |
'weight' => '50', | |
'weight_unit' => 'LB', | |
'length' => '25', | |
'width' => '15', | |
'height' => '15', | |
'dim_unit' => 'IN', | |
'packaging' => 'BOX', | |
'contents' => 'OTR', | |
'insurance' => '0' | |
), | |
), | |
'shipment_id' => 1234; | |
); | |
Returns: | |
$quotes = array( | |
'package1' => | |
array( | |
array( | |
'id' => 'INTSH_FDX_2DY', | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
array( | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
), | |
'package2' => | |
array( | |
array( | |
'id' => 'INTSH_FDX_3DY', | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
array( | |
'type' => 'FDX', | |
.. | |
'amount' => 24.24, | |
) | |
), | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment