<commit_before><?php
/**
 * Author: <NAME> [<EMAIL>]
 * Authors-Website: http://petschko.org/
 * Date: 26.01.2017
 * Time: 15:37
 * Update: -
 * Version: 1.0.0
 *
 * Notes: Contains all Functions/Values for DHL-Business-Shipment
 */

// Set correct encoding
mb_internal_encoding('UTF-8');

// Get required classes
// Abstract classes first
require_once('DHL_Version.php');
require_once('DHL_Address.php');
require_once('DHL_SendPerson.php');

// Now all other classes
require_once('DHL_BankData.php');
require_once('DHL_Credentials.php');
require_once('DHL_ExportDocument.php');
require_once('DHL_IdentCheck.php');
require_once('DHL_Receiver.php');
require_once('DHL_Response.php');
require_once('DHL_ReturnReceiver.php');
require_once('DHL_Sender.php');
require_once('DHL_Service.php');
require_once('DHL_ShipmentDetails.php');


/**
 * Class DHL_BusinessShipment
 */
class DHL_BusinessShipment extends DHL_Version {
	/**
	 * DHL Origin WSDL-Lib-URL
	 */
	const DHL_WSDL_LIB_URL = 'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/';

	/**
	 * DHL-Soap-Header URL
	 */
	const DHL_SOAP_HEADER_URI = 'http://dhl.de/webservice/cisbase';

	/**
	 * DHL-Sandbox SOAP-URL
	 */
	const DHL_SANDBOX_URL = 'https://cig.dhl.de/services/sandbox/soap';

	/**
	 * DHL-Live SOAP-URL
	 */
	const DHL_PRODUCTION_URL = 'https://cig.dhl.de/services/production/soap';

	/**
	 * Newest-Version
	 */
	const NEWEST_VERSION = '2.2';

	/**
	 * Response-Type URL
	 */
	const RESPONSE_TYPE_URL = 'URL';

	/**
	 * Response-Type Base64
	 */
	const RESPONSE_TYPE_B64 = 'B64';

	// System-Fields
	/**
	 * Contains the Soap Client
	 *
	 * @var SoapClient|null $soapClient - Soap-Client
	 */
	private $soapClient = null;

	/**
	 * Contains the error array
	 *
	 * @var array $errors - Error-Array
	 */
	private $errors = array();

	// Setting-Fields
	/**
	 * Contains if the Object runs in Sandbox-Mode
	 *
	 * @var bool $test - Is Sandbox-Mode
	 */
	private $test;

	/**
	 * Contains if Log is enabled
	 *
	 * @var bool $log - Is Logging enabled
	 */
	private $log = false;

	// Object-Fields
	/**
	 * Contains the DHL_Credentials Object
	 *
	 * Notes: Is required every time! Used to login
	 *
	 * @var DHL_Credentials $credentials - DHL_Credentials Object
	 */
	private $credentials;

	/**
	 * Contains the Shipment Details
	 *
	 * @var DHL_ShipmentDetails $shipmentDetails - Shipment Details Object
	 */
	private $shipmentDetails;

	/**
	 * Contains the Service Object (Many settings for the Shipment)
	 *
	 * Note: Optional
	 *
	 * @var DHL_Service|null $service - Service Object
	 */
	private $service = null;

	/**
	 * Contains the Bank-Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_BankData|null $bank - Bank-Object
	 */
	private $bank = null;

	/**
	 * Contains the Sender-Object
	 *
	 * @var DHL_Sender $sender - Sender Object
	 */
	private $sender;

	/**
	 * Contains the Receiver-Object
	 *
	 * @var DHL_Receiver $receiver - Receiver Object
	 */
	private $receiver;

	/**
	 * Contains the Return Receiver Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_ReturnReceiver|null $returnReceiver - Return Receiver Object
	 */
	private $returnReceiver = null;

	/**
	 * Contains the Export-Document-Settings Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_ExportDocument|null $exportDocument - Export-Document-Settings Object
	 */
	private $exportDocument = null;

	// Fields
	/**
	 * Contains the Sequence-Number
	 *
	 * Min-Len: -
	 * Max-Len: 30
	 *
	 * @var string $sequenceNumber - Sequence-Number
	 */
	private $sequenceNumber = '1';

	/**
	 * Contains the Receiver-E-Mail (Used for Notification to the Receiver)
	 *
	 * Note: Optional
	 * Min-Len: -
	 * Max-Len: 70
	 *
	 * @var string|null $receiverEmail - Receiver-E-Mail
	 */
	private $receiverEmail = null;

	/**
	 * Contains if the label will be only be printable, if the receiver address is valid.
	 *
	 * Note: Optional
	 *
	 * @var bool|null $printOnlyIfReceiverIsValid - true will only print if receiver address is valid else false (null uses default)
	 */
	private $printOnlyIfReceiverIsValid = null;

	/**
	 * Contains if how the Label-Response-Type will be
	 *
	 * Note: Optional
	 * Values:
	 * RESPONSE_TYPE_URL -> Url
	 * RESPONSE_TYPE_B64 -> Base64
	 *
	 * @var string|null $labelResponseType - Label-Response-Type (Can use class constance's)
	 */
	private $labelResponseType = null;

	/**
	 * Custom-WSDL-File URL
	 *
	 * @var null|string $customAPIURL - Custom-API URL to use internal let this value null
	 */
	private $customAPIURL = null;

	/**
	 * DHL_BusinessShipment constructor.
	 *
	 * @param DHL_Credentials $credentials - DHL-Credentials-Object
	 * @param bool $testModus - Uses the Sandbox-Modus or Live (True uses test-Modus)
	 * @param null|string $version - Version to use or null for the newest
	 */
	public function __construct($credentials, $testModus = false, $version = null) {
		// Set Version
		if($version === null)
			$version = self::NEWEST_VERSION;

		parent::__construct($version);

		// Set Test-Modus
		$this->setTest($testModus);

		// Set Credentials
		if($this->isTest()) {
			$c = new DHL_Credentials(true);
			$c->setApiUser($credentials->getApiUser());
			$c->setApiPassword($credentials->getApiPassword());

			$credentials = $c;
		}

		$this->setCredentials($credentials);

		// Set DHL_Shipment-Class
		$this->setShipmentDetails(new DHL_ShipmentDetails($credentials->getEpk(10) . '0101'));

		// Create Soap-Client
		$this->buildSoapClient();
	}

	/**
	 * Clears Memory
	 */
	public function __destruct() {
		parent::__destruct();
		unset($this->soapClient);
		unset($this->errors);
		unset($this->test);
		unset($this->log);
		unset($this->credentials);
		unset($this->shipmentDetails);
		unset($this->service);
		unset($this->bank);
		unset($this->sender);
		unset($this->receiver);
		unset($this->returnReceiver);
		unset($this->exportDocument);
		unset($this->sequenceNumber);
		unset($this->receiverEmail);
		unset($this->printOnlyIfReceiverIsValid);
		unset($this->labelResponseType);
	}

	/**
	 * Get the full Server-URL to the WSDL-Directory or as Fallback value the URL to the DHL-Lib
	 *
	 * @return string - Server URL Pointing to the /includes/lib/ (WSDL-Dir)
	 */
	private static function getWSDLDirURL() {<commit_msg>Unset the customAPIURL field in destruction method<commit_after><?php
/**
 * Author: <NAME> [<EMAIL>]
 * Authors-Website: http://petschko.org/
 * Date: 26.01.2017
 * Time: 15:37
 * Update: -
 * Version: 1.0.0
 *
 * Notes: Contains all Functions/Values for DHL-Business-Shipment
 */

// Set correct encoding
mb_internal_encoding('UTF-8');

// Get required classes
// Abstract classes first
require_once('DHL_Version.php');
require_once('DHL_Address.php');
require_once('DHL_SendPerson.php');

// Now all other classes
require_once('DHL_BankData.php');
require_once('DHL_Credentials.php');
require_once('DHL_ExportDocument.php');
require_once('DHL_IdentCheck.php');
require_once('DHL_Receiver.php');
require_once('DHL_Response.php');
require_once('DHL_ReturnReceiver.php');
require_once('DHL_Sender.php');
require_once('DHL_Service.php');
require_once('DHL_ShipmentDetails.php');


/**
 * Class DHL_BusinessShipment
 */
class DHL_BusinessShipment extends DHL_Version {
	/**
	 * DHL Origin WSDL-Lib-URL
	 */
	const DHL_WSDL_LIB_URL = 'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/';

	/**
	 * DHL-Soap-Header URL
	 */
	const DHL_SOAP_HEADER_URI = 'http://dhl.de/webservice/cisbase';

	/**
	 * DHL-Sandbox SOAP-URL
	 */
	const DHL_SANDBOX_URL = 'https://cig.dhl.de/services/sandbox/soap';

	/**
	 * DHL-Live SOAP-URL
	 */
	const DHL_PRODUCTION_URL = 'https://cig.dhl.de/services/production/soap';

	/**
	 * Newest-Version
	 */
	const NEWEST_VERSION = '2.2';

	/**
	 * Response-Type URL
	 */
	const RESPONSE_TYPE_URL = 'URL';

	/**
	 * Response-Type Base64
	 */
	const RESPONSE_TYPE_B64 = 'B64';

	// System-Fields
	/**
	 * Contains the Soap Client
	 *
	 * @var SoapClient|null $soapClient - Soap-Client
	 */
	private $soapClient = null;

	/**
	 * Contains the error array
	 *
	 * @var array $errors - Error-Array
	 */
	private $errors = array();

	// Setting-Fields
	/**
	 * Contains if the Object runs in Sandbox-Mode
	 *
	 * @var bool $test - Is Sandbox-Mode
	 */
	private $test;

	/**
	 * Contains if Log is enabled
	 *
	 * @var bool $log - Is Logging enabled
	 */
	private $log = false;

	// Object-Fields
	/**
	 * Contains the DHL_Credentials Object
	 *
	 * Notes: Is required every time! Used to login
	 *
	 * @var DHL_Credentials $credentials - DHL_Credentials Object
	 */
	private $credentials;

	/**
	 * Contains the Shipment Details
	 *
	 * @var DHL_ShipmentDetails $shipmentDetails - Shipment Details Object
	 */
	private $shipmentDetails;

	/**
	 * Contains the Service Object (Many settings for the Shipment)
	 *
	 * Note: Optional
	 *
	 * @var DHL_Service|null $service - Service Object
	 */
	private $service = null;

	/**
	 * Contains the Bank-Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_BankData|null $bank - Bank-Object
	 */
	private $bank = null;

	/**
	 * Contains the Sender-Object
	 *
	 * @var DHL_Sender $sender - Sender Object
	 */
	private $sender;

	/**
	 * Contains the Receiver-Object
	 *
	 * @var DHL_Receiver $receiver - Receiver Object
	 */
	private $receiver;

	/**
	 * Contains the Return Receiver Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_ReturnReceiver|null $returnReceiver - Return Receiver Object
	 */
	private $returnReceiver = null;

	/**
	 * Contains the Export-Document-Settings Object
	 *
	 * Note: Optional
	 *
	 * @var DHL_ExportDocument|null $exportDocument - Export-Document-Settings Object
	 */
	private $exportDocument = null;

	// Fields
	/**
	 * Contains the Sequence-Number
	 *
	 * Min-Len: -
	 * Max-Len: 30
	 *
	 * @var string $sequenceNumber - Sequence-Number
	 */
	private $sequenceNumber = '1';

	/**
	 * Contains the Receiver-E-Mail (Used for Notification to the Receiver)
	 *
	 * Note: Optional
	 * Min-Len: -
	 * Max-Len: 70
	 *
	 * @var string|null $receiverEmail - Receiver-E-Mail
	 */
	private $receiverEmail = null;

	/**
	 * Contains if the label will be only be printable, if the receiver address is valid.
	 *
	 * Note: Optional
	 *
	 * @var bool|null $printOnlyIfReceiverIsValid - true will only print if receiver address is valid else false (null uses default)
	 */
	private $printOnlyIfReceiverIsValid = null;

	/**
	 * Contains if how the Label-Response-Type will be
	 *
	 * Note: Optional
	 * Values:
	 * RESPONSE_TYPE_URL -> Url
	 * RESPONSE_TYPE_B64 -> Base64
	 *
	 * @var string|null $labelResponseType - Label-Response-Type (Can use class constance's)
	 */
	private $labelResponseType = null;

	/**
	 * Custom-WSDL-File URL
	 *
	 * @var null|string $customAPIURL - Custom-API URL to use internal let this value null
	 */
	private $customAPIURL = null;

	/**
	 * DHL_BusinessShipment constructor.
	 *
	 * @param DHL_Credentials $credentials - DHL-Credentials-Object
	 * @param bool $testModus - Uses the Sandbox-Modus or Live (True uses test-Modus)
	 * @param null|string $version - Version to use or null for the newest
	 */
	public function __construct($credentials, $testModus = false, $version = null) {
		// Set Version
		if($version === null)
			$version = self::NEWEST_VERSION;

		parent::__construct($version);

		// Set Test-Modus
		$this->setTest($testModus);

		// Set Credentials
		if($this->isTest()) {
			$c = new DHL_Credentials(true);
			$c->setApiUser($credentials->getApiUser());
			$c->setApiPassword($credentials->getApiPassword());

			$credentials = $c;
		}

		$this->setCredentials($credentials);

		// Set DHL_Shipment-Class
		$this->setShipmentDetails(new DHL_ShipmentDetails($credentials->getEpk(10) . '0101'));

		// Create Soap-Client
		$this->buildSoapClient();
	}

	/**
	 * Clears Memory
	 */
	public function __destruct() {
		parent::__destruct();
		unset($this->soapClient);
		unset($this->errors);
		unset($this->test);
		unset($this->log);
		unset($this->credentials);
		unset($this->shipmentDetails);
		unset($this->service);
		unset($this->bank);
		unset($this->sender);
		unset($this->receiver);
		unset($this->returnReceiver);
		unset($this->exportDocument);
		unset($this->sequenceNumber);
		unset($this->receiverEmail);
		unset($this->printOnlyIfReceiverIsValid);
		unset($this->labelResponseType);
		unset($this->customAPIURL);
	}

	/**
	 * Get the full Server-URL to the WSDL-Directory or as Fallback value the URL to the DHL-Lib
	 *
	 * @return string - Server URL Pointing to the /includes/lib/ (WSDL-Dir)
	 */
	private static function getWSDLDirURL() {
{'fraction_non_alphanumeric': 0.14086304538565844, 'fraction_numerical': 0.006221584111031347, 'mean_word_length': 3.508450197770586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 64, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4419628', 'n_tokens_mistral': 4624, 'n_tokens_neox': 4160, 'n_words': 969}