repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
magroski/frogg | src/CurlInterface.php | CurlInterface.deleteReq | public function deleteReq(string $url, $data = [], $dataQuery = [])
{
$query = http_build_query($dataQuery);
$params = implode('/', $data);
$ch = curl_init($url . $params . '?' . $query);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($this->authType == self::BASIC) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
} else {
if ($this->authType == self::SAFE) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
}
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
} | php | public function deleteReq(string $url, $data = [], $dataQuery = [])
{
$query = http_build_query($dataQuery);
$params = implode('/', $data);
$ch = curl_init($url . $params . '?' . $query);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($this->authType == self::BASIC) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
} else {
if ($this->authType == self::SAFE) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
}
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
} | [
"public",
"function",
"deleteReq",
"(",
"string",
"$",
"url",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"dataQuery",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"dataQuery",
")",
";",
"$",
"params",
"=",
"implode",
"(... | Send a DELETE request with its data as PARAMS
@param string $url Url to call
@param array $data Simple array with params to be passed
@param array $dataQuery Key-value array to be json_encoded
@return string request result | [
"Send",
"a",
"DELETE",
"request",
"with",
"its",
"data",
"as",
"PARAMS"
] | 669da2ed337e3a8477c5c99cfcf76503fd58b540 | https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/CurlInterface.php#L153-L173 | train |
magroski/frogg | src/CurlInterface.php | CurlInterface.putReq | public function putReq(string $url, $data = [], $dataQuery = [])
{
$query = http_build_query($dataQuery);
$ch = curl_init($url . '?' . $query);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($this->authType == self::BASIC) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
} else {
if ($this->authType == self::SAFE) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
}
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
} | php | public function putReq(string $url, $data = [], $dataQuery = [])
{
$query = http_build_query($dataQuery);
$ch = curl_init($url . '?' . $query);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($this->authType == self::BASIC) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
} else {
if ($this->authType == self::SAFE) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_USERPWD, $this->authParam);
}
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
} | [
"public",
"function",
"putReq",
"(",
"string",
"$",
"url",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"dataQuery",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"dataQuery",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
... | Send a PUT request with its data as PARAMS
@param string $url Url to call
@param array $data Key-value array with params
@param array $dataQuery Key-value array to be json_encoded
@return string request result | [
"Send",
"a",
"PUT",
"request",
"with",
"its",
"data",
"as",
"PARAMS"
] | 669da2ed337e3a8477c5c99cfcf76503fd58b540 | https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/CurlInterface.php#L184-L205 | train |
0x46616c6b/etherpad-lite-client | src/EtherpadLite/Response.php | Response.getData | public function getData($key = null, $defaultValue = null)
{
$data = $this->getPropertyFromData('data');
if (null !== $key) {
return isset($data[$key]) ? $data[$key] : $defaultValue;
}
return $data;
} | php | public function getData($key = null, $defaultValue = null)
{
$data = $this->getPropertyFromData('data');
if (null !== $key) {
return isset($data[$key]) ? $data[$key] : $defaultValue;
}
return $data;
} | [
"public",
"function",
"getData",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getPropertyFromData",
"(",
"'data'",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"key",
")",
"{",
"re... | Get Response Data Array.
By default the whole array will be returned. In order to retrieve just a key based response, provide an array Key.
```php
$response = (new Client())->createAuthorIfNotExistsFor(1, 'John Doe');
$authorId = $response->getData('authorID');
```
@param string $key Access a given key from the data array, if no key is provided all data will be returned.
@param mixed $defaultValue If the given key is not found in the array, the $defaultValue will be returned.
@return array|string|null | [
"Get",
"Response",
"Data",
"Array",
"."
] | 30dd5b3fb21af88ea59aff18b3abb7c150ae7218 | https://github.com/0x46616c6b/etherpad-lite-client/blob/30dd5b3fb21af88ea59aff18b3abb7c150ae7218/src/EtherpadLite/Response.php#L60-L69 | train |
Bacon/BaconStringUtils | src/BaconStringUtils/UniDecoder.php | UniDecoder.decode | public function decode($string)
{
$return = '';
foreach (preg_split('()u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
$codepoint = $this->uniOrd($char);
if ($codepoint < 0x80) {
// Basic ASCII
$return .= chr($codepoint);
continue;
}
if ($codepoint > 0xeffff) {
// Characters in Private Use Area and above are ignored
continue;
}
$section = $codepoint >> 8; // Chop off the last two hex digits
$position = $codepoint % 256; // Last two hex digits
if (!isset(self::$tables[$section])) {
self::$tables[$section] = @include sprintf('%s/UniDecoder/x%03x.php', __DIR__, $section);
}
if (isset(self::$tables[$section][$position])) {
$return .= self::$tables[$section][$position];
}
}
return $return;
} | php | public function decode($string)
{
$return = '';
foreach (preg_split('()u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
$codepoint = $this->uniOrd($char);
if ($codepoint < 0x80) {
// Basic ASCII
$return .= chr($codepoint);
continue;
}
if ($codepoint > 0xeffff) {
// Characters in Private Use Area and above are ignored
continue;
}
$section = $codepoint >> 8; // Chop off the last two hex digits
$position = $codepoint % 256; // Last two hex digits
if (!isset(self::$tables[$section])) {
self::$tables[$section] = @include sprintf('%s/UniDecoder/x%03x.php', __DIR__, $section);
}
if (isset(self::$tables[$section][$position])) {
$return .= self::$tables[$section][$position];
}
}
return $return;
} | [
"public",
"function",
"decode",
"(",
"$",
"string",
")",
"{",
"$",
"return",
"=",
"''",
";",
"foreach",
"(",
"preg_split",
"(",
"'()u'",
",",
"$",
"string",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
"as",
"$",
"char",
")",
"{",
"$",
"codepoint"... | Decodes an UTF-8 encoded unicode string to ASCII.
@param string $string
@return string | [
"Decodes",
"an",
"UTF",
"-",
"8",
"encoded",
"unicode",
"string",
"to",
"ASCII",
"."
] | 3d7818aca25190149a9a2415a0928d4964d6007e | https://github.com/Bacon/BaconStringUtils/blob/3d7818aca25190149a9a2415a0928d4964d6007e/src/BaconStringUtils/UniDecoder.php#L32-L63 | train |
Bacon/BaconStringUtils | src/BaconStringUtils/UniDecoder.php | UniDecoder.uniOrd | protected function uniOrd($char)
{
$h = ord($char[0]);
if ($h <= 0x7f) {
return $h;
} elseif ($h < 0xc2) {
return null;
} elseif ($h <= 0xdf) {
return ($h & 0x1f) << 6 | (ord($char[1]) & 0x3f);
} elseif ($h <= 0xef) {
return ($h & 0x0f) << 12 | (ord($char[1]) & 0x3f) << 6
| (ord($char[2]) & 0x3f);
} elseif ($h <= 0xf4) {
return ($h & 0x0f) << 18 | (ord($char[1]) & 0x3f) << 12
| (ord($char[2]) & 0x3f) << 6
| (ord($char[3]) & 0x3f);
} else {
return null;
}
} | php | protected function uniOrd($char)
{
$h = ord($char[0]);
if ($h <= 0x7f) {
return $h;
} elseif ($h < 0xc2) {
return null;
} elseif ($h <= 0xdf) {
return ($h & 0x1f) << 6 | (ord($char[1]) & 0x3f);
} elseif ($h <= 0xef) {
return ($h & 0x0f) << 12 | (ord($char[1]) & 0x3f) << 6
| (ord($char[2]) & 0x3f);
} elseif ($h <= 0xf4) {
return ($h & 0x0f) << 18 | (ord($char[1]) & 0x3f) << 12
| (ord($char[2]) & 0x3f) << 6
| (ord($char[3]) & 0x3f);
} else {
return null;
}
} | [
"protected",
"function",
"uniOrd",
"(",
"$",
"char",
")",
"{",
"$",
"h",
"=",
"ord",
"(",
"$",
"char",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"h",
"<=",
"0x7f",
")",
"{",
"return",
"$",
"h",
";",
"}",
"elseif",
"(",
"$",
"h",
"<",
"0xc2",... | Gets unicode codepoint from character.
@param string $char
@return integer | [
"Gets",
"unicode",
"codepoint",
"from",
"character",
"."
] | 3d7818aca25190149a9a2415a0928d4964d6007e | https://github.com/Bacon/BaconStringUtils/blob/3d7818aca25190149a9a2415a0928d4964d6007e/src/BaconStringUtils/UniDecoder.php#L71-L91 | train |
magroski/frogg | src/Services/Google/DistanceMatrixAPI.php | DistanceMatrixAPI.calculateDistanceMatrix | public function calculateDistanceMatrix(array $origins, array $destinations) : DistanceMatrixResponse
{
$formattedOrigins = $this->formatEntities($origins);
$formattedDestinations = $this->formatEntities($destinations);
$query = http_build_query([
'origins' => $formattedOrigins,
'destinations' => $formattedDestinations,
'key' => $this->apiKey,
]);
$url = $this->generateBaseUrl() . '?' . $query;
$data = $this->processRequest($url);
if (!$this->checkResponseStatus($data)) {
$data = $this->processRequest($url);
if (!$this->checkResponseStatus($data)) {
throw new ServiceProviderException('GoogleDistanceMatrix returned an unknown_error after retry');
}
}
if (!array_key_exists('rows', $data)) {
throw new ServiceProviderException('Missing key "rows" on data: ' . print_r($data, true));
}
return new DistanceMatrixResponse(
$data['rows'],
explode('|', $formattedOrigins),
explode('|', $formattedDestinations),
$data['origin_addresses'],
$data['destination_addresses']
);
} | php | public function calculateDistanceMatrix(array $origins, array $destinations) : DistanceMatrixResponse
{
$formattedOrigins = $this->formatEntities($origins);
$formattedDestinations = $this->formatEntities($destinations);
$query = http_build_query([
'origins' => $formattedOrigins,
'destinations' => $formattedDestinations,
'key' => $this->apiKey,
]);
$url = $this->generateBaseUrl() . '?' . $query;
$data = $this->processRequest($url);
if (!$this->checkResponseStatus($data)) {
$data = $this->processRequest($url);
if (!$this->checkResponseStatus($data)) {
throw new ServiceProviderException('GoogleDistanceMatrix returned an unknown_error after retry');
}
}
if (!array_key_exists('rows', $data)) {
throw new ServiceProviderException('Missing key "rows" on data: ' . print_r($data, true));
}
return new DistanceMatrixResponse(
$data['rows'],
explode('|', $formattedOrigins),
explode('|', $formattedDestinations),
$data['origin_addresses'],
$data['destination_addresses']
);
} | [
"public",
"function",
"calculateDistanceMatrix",
"(",
"array",
"$",
"origins",
",",
"array",
"$",
"destinations",
")",
":",
"DistanceMatrixResponse",
"{",
"$",
"formattedOrigins",
"=",
"$",
"this",
"->",
"formatEntities",
"(",
"$",
"origins",
")",
";",
"$",
"f... | Calculates the distance between multiple origins and destinations
@param DistanceMatrixLocation[] $origins
@param DistanceMatrixLocation[] $destinations
As Google always return the distance value in meters (not km), the function multiplies
the result by 0.62 (km:mile) to calculate an approximation in imperial.
Obs: Be aware that 1 Km = 0.62 miles but 1 meter != 0.62 yards.
@return DistanceMatrixResponse
@throws ServiceProviderException | [
"Calculates",
"the",
"distance",
"between",
"multiple",
"origins",
"and",
"destinations"
] | 669da2ed337e3a8477c5c99cfcf76503fd58b540 | https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Services/Google/DistanceMatrixAPI.php#L37-L69 | train |
SIELOnline/libAcumulus | src/WooCommerce/WooCommerce2/Invoice/Creator.php | Creator.getSourceMeta | public function getSourceMeta($property)
{
$value = get_post_meta($this->invoiceSource->getId(), $property, true);
// get_post_meta() can return false or ''.
if (empty($value)) {
// Not found: indicate so by returning null.
$value = null;
}
return $value;
} | php | public function getSourceMeta($property)
{
$value = get_post_meta($this->invoiceSource->getId(), $property, true);
// get_post_meta() can return false or ''.
if (empty($value)) {
// Not found: indicate so by returning null.
$value = null;
}
return $value;
} | [
"public",
"function",
"getSourceMeta",
"(",
"$",
"property",
")",
"{",
"$",
"value",
"=",
"get_post_meta",
"(",
"$",
"this",
"->",
"invoiceSource",
"->",
"getId",
"(",
")",
",",
"$",
"property",
",",
"true",
")",
";",
"// get_post_meta() can return false or ''... | Token callback to access the post meta when resolving tokens.
@param string $property
@return null|string
The value for the meta data with the given name, null if not available. | [
"Token",
"callback",
"to",
"access",
"the",
"post",
"meta",
"when",
"resolving",
"tokens",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/WooCommerce2/Invoice/Creator.php#L50-L59 | train |
SIELOnline/libAcumulus | src/WooCommerce/WooCommerce2/Invoice/Creator.php | Creator.getOrderMeta | public function getOrderMeta($property)
{
/** @var \WC_Order $order */
$order = $this->invoiceSource->getOrder()->getSource();
$value = get_post_meta( $order->id, $property, true);
// get_post_meta() can return false or ''.
if (empty($value)) {
// Not found: indicate so by returning null.
$value = null;
}
return $value;
} | php | public function getOrderMeta($property)
{
/** @var \WC_Order $order */
$order = $this->invoiceSource->getOrder()->getSource();
$value = get_post_meta( $order->id, $property, true);
// get_post_meta() can return false or ''.
if (empty($value)) {
// Not found: indicate so by returning null.
$value = null;
}
return $value;
} | [
"public",
"function",
"getOrderMeta",
"(",
"$",
"property",
")",
"{",
"/** @var \\WC_Order $order */",
"$",
"order",
"=",
"$",
"this",
"->",
"invoiceSource",
"->",
"getOrder",
"(",
")",
"->",
"getSource",
"(",
")",
";",
"$",
"value",
"=",
"get_post_meta",
"(... | Token callback to access the order post meta when resolving tokens.
@param string $property
@return null|string
The value for the meta data with the given name, null if not available. | [
"Token",
"callback",
"to",
"access",
"the",
"order",
"post",
"meta",
"when",
"resolving",
"tokens",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/WooCommerce2/Invoice/Creator.php#L69-L80 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.load | protected function load()
{
if (!$this->isConfigurationLoaded) {
$this->values = $this->getDefaults();
$values = $this->getConfigStore()->load();
if (is_array($values)) {
$this->values = array_merge($this->getDefaults(), $values);
}
$this->values = $this->castValues($this->values);
$this->isConfigurationLoaded = true;
}
} | php | protected function load()
{
if (!$this->isConfigurationLoaded) {
$this->values = $this->getDefaults();
$values = $this->getConfigStore()->load();
if (is_array($values)) {
$this->values = array_merge($this->getDefaults(), $values);
}
$this->values = $this->castValues($this->values);
$this->isConfigurationLoaded = true;
}
} | [
"protected",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isConfigurationLoaded",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"$",
"this",
"->",
"getDefaults",
"(",
")",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"getConfig... | Loads the configuration from the actual configuration provider. | [
"Loads",
"the",
"configuration",
"from",
"the",
"actual",
"configuration",
"provider",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L100-L111 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.save | public function save(array $values)
{
// Log values in a notice but without the password.
$copy = $values;
if (!empty($copy[Tag::Password])) {
$copy[Tag::Password] = 'REMOVED FOR SECURITY';
}
$this->log->notice('ConfigStore::save(): saving %s', serialize($copy));
// Remove password if not sent along. We have had some reports that
// passwords were gone missing, perhaps some shops do not send the value
// of password fields to the client???
if (array_key_exists(Tag::Password, $values) && empty($values[Tag::Password])) {
unset($values[Tag::Password]);
}
// As we have 2 setting screens, but also with updates, not all settings
// will be passed in: complete with other settings.
$this->load();
$values = array_merge($this->values, $values);
$values = $this->castValues($values);
$values = $this->removeValuesNotToBeStored($values);
$result = $this->getConfigStore()->save($values);
$this->isConfigurationLoaded = false;
// Sync internal values.
$this->load();
return $result;
} | php | public function save(array $values)
{
// Log values in a notice but without the password.
$copy = $values;
if (!empty($copy[Tag::Password])) {
$copy[Tag::Password] = 'REMOVED FOR SECURITY';
}
$this->log->notice('ConfigStore::save(): saving %s', serialize($copy));
// Remove password if not sent along. We have had some reports that
// passwords were gone missing, perhaps some shops do not send the value
// of password fields to the client???
if (array_key_exists(Tag::Password, $values) && empty($values[Tag::Password])) {
unset($values[Tag::Password]);
}
// As we have 2 setting screens, but also with updates, not all settings
// will be passed in: complete with other settings.
$this->load();
$values = array_merge($this->values, $values);
$values = $this->castValues($values);
$values = $this->removeValuesNotToBeStored($values);
$result = $this->getConfigStore()->save($values);
$this->isConfigurationLoaded = false;
// Sync internal values.
$this->load();
return $result;
} | [
"public",
"function",
"save",
"(",
"array",
"$",
"values",
")",
"{",
"// Log values in a notice but without the password.",
"$",
"copy",
"=",
"$",
"values",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"copy",
"[",
"Tag",
"::",
"Password",
"]",
")",
")",
"{",
... | Saves the configuration to the actual configuration provider.
@param array $values
A keyed array that contains the values to store, this may be a subset
of the possible keys. Keys that are not present will not be changed.
@return bool
Success. | [
"Saves",
"the",
"configuration",
"to",
"the",
"actual",
"configuration",
"provider",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L123-L150 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.castValues | protected function castValues(array $values)
{
$keyInfos = $this->getKeyInfo();
foreach ($keyInfos as $key => $keyInfo) {
if (array_key_exists($key, $values)) {
switch ($keyInfo['type']) {
case 'string':
if (!is_string($values[$key])) {
$values[$key] = (string) $values[$key];
}
break;
case 'int':
if (!is_int($values[$key])) {
$values[$key] = (int) $values[$key];
}
break;
case 'bool':
if (!is_bool($values[$key])) {
$values[$key] = (bool) $values[$key];
}
break;
case 'array':
if (!is_array($values[$key])) {
$values[$key] = array($values[$key]);
}
break;
}
}
}
return $values;
} | php | protected function castValues(array $values)
{
$keyInfos = $this->getKeyInfo();
foreach ($keyInfos as $key => $keyInfo) {
if (array_key_exists($key, $values)) {
switch ($keyInfo['type']) {
case 'string':
if (!is_string($values[$key])) {
$values[$key] = (string) $values[$key];
}
break;
case 'int':
if (!is_int($values[$key])) {
$values[$key] = (int) $values[$key];
}
break;
case 'bool':
if (!is_bool($values[$key])) {
$values[$key] = (bool) $values[$key];
}
break;
case 'array':
if (!is_array($values[$key])) {
$values[$key] = array($values[$key]);
}
break;
}
}
}
return $values;
} | [
"protected",
"function",
"castValues",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"keyInfos",
"=",
"$",
"this",
"->",
"getKeyInfo",
"(",
")",
";",
"foreach",
"(",
"$",
"keyInfos",
"as",
"$",
"key",
"=>",
"$",
"keyInfo",
")",
"{",
"if",
"(",
"array_k... | Casts the values to their correct types.
Values that come from a submitted form are all strings. Values that come
from the config store might be null. However, internally we work with
booleans or integers. So after reading from the config store or form, we
cast the values to their expected types.
@param array $values
@return array
Array with casted values. | [
"Casts",
"the",
"values",
"to",
"their",
"correct",
"types",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L165-L195 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.removeValuesNotToBeStored | protected function removeValuesNotToBeStored(array $values)
{
$result = array();
$keys = $this->getKeys();
$defaults = $this->getDefaults();
foreach ($keys as $key) {
if (isset($values[$key]) && (!isset($defaults[$key]) || $values[$key] !== $defaults[$key])) {
$result[$key] = $values[$key];
}
}
return $result;
} | php | protected function removeValuesNotToBeStored(array $values)
{
$result = array();
$keys = $this->getKeys();
$defaults = $this->getDefaults();
foreach ($keys as $key) {
if (isset($values[$key]) && (!isset($defaults[$key]) || $values[$key] !== $defaults[$key])) {
$result[$key] = $values[$key];
}
}
return $result;
} | [
"protected",
"function",
"removeValuesNotToBeStored",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getDefault... | Removes configuration values that do not have to be stored.
Values that do not have to be stored:
- Values that are not set.
- Values that equal their default value.
- Keys that are unknown.
@param array $values
The array to remove values from.
@return array
The passed in set of values reduced to values that should be stored. | [
"Removes",
"configuration",
"values",
"that",
"do",
"not",
"have",
"to",
"be",
"stored",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L211-L222 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.set | public function set($key, $value)
{
$this->load();
$oldValue = isset($this->values[$key]) ? $this->values[$key] : null;
$this->values[$key] = $value;
return $oldValue;
} | php | public function set($key, $value)
{
$this->load();
$oldValue = isset($this->values[$key]) ? $this->values[$key] : null;
$this->values[$key] = $value;
return $oldValue;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"$",
"oldValue",
"=",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"values",
... | Sets the internal value of the specified configuration key.
This value will not be stored, use save() for that.
@param string $key
The configuration value to set.
@param mixed $value
The new value for the configuration key.
@return mixed
The old value. | [
"Sets",
"the",
"internal",
"value",
"of",
"the",
"specified",
"configuration",
"key",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L254-L260 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.getCredentials | public function getCredentials()
{
$result = $this->getSettingsByGroup('credentials');
// No separate key for now.
$result[Tag::EmailOnWarning] = $result[Tag::EmailOnError];
return $result;
} | php | public function getCredentials()
{
$result = $this->getSettingsByGroup('credentials');
// No separate key for now.
$result[Tag::EmailOnWarning] = $result[Tag::EmailOnError];
return $result;
} | [
"public",
"function",
"getCredentials",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getSettingsByGroup",
"(",
"'credentials'",
")",
";",
"// No separate key for now.",
"$",
"result",
"[",
"Tag",
"::",
"EmailOnWarning",
"]",
"=",
"$",
"result",
"[",
... | Returns the contract credentials to authenticate with the Acumulus API.
@return array
A keyed array with the keys:
- contractcode
- username
- password
- emailonerror
- emailonwarning | [
"Returns",
"the",
"contract",
"credentials",
"to",
"authenticate",
"with",
"the",
"Acumulus",
"API",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L295-L301 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.getSettingsByGroup | protected function getSettingsByGroup($group)
{
$result = array();
foreach ($this->getKeyInfo() as $key => $keyInfo) {
if ($keyInfo['group'] === $group) {
$result[$key] = $this->get($key);
}
}
return $result;
} | php | protected function getSettingsByGroup($group)
{
$result = array();
foreach ($this->getKeyInfo() as $key => $keyInfo) {
if ($keyInfo['group'] === $group) {
$result[$key] = $this->get($key);
}
}
return $result;
} | [
"protected",
"function",
"getSettingsByGroup",
"(",
"$",
"group",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getKeyInfo",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"keyInfo",
")",
"{",
"if",
"(",
"$",
"ke... | Get all settings belonging to the same group.
@param string $group
@return array
An array of settings. | [
"Get",
"all",
"settings",
"belonging",
"to",
"the",
"same",
"group",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L433-L442 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.getKeys | public function getKeys()
{
$result = $this->getKeyInfo();
array_filter($result, function ($item) {
return $item['group'] !== 'environment';
});
return array_keys($result);
} | php | public function getKeys()
{
$result = $this->getKeyInfo();
array_filter($result, function ($item) {
return $item['group'] !== 'environment';
});
return array_keys($result);
} | [
"public",
"function",
"getKeys",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getKeyInfo",
"(",
")",
";",
"array_filter",
"(",
"$",
"result",
",",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"[",
"'group'",
"]",
"!==",
... | Returns a list of keys that are stored in the shop specific config store.
@return array | [
"Returns",
"a",
"list",
"of",
"keys",
"that",
"are",
"stored",
"in",
"the",
"shop",
"specific",
"config",
"store",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L449-L456 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.getConfigDefaults | protected function getConfigDefaults()
{
$result = $this->getKeyInfo();
$result = array_map(function ($item) {
return $item['default'];
}, $result);
return $result;
} | php | protected function getConfigDefaults()
{
$result = $this->getKeyInfo();
$result = array_map(function ($item) {
return $item['default'];
}, $result);
return $result;
} | [
"protected",
"function",
"getConfigDefaults",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getKeyInfo",
"(",
")",
";",
"$",
"result",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"[",
"'default'",
"]",... | Returns a set of default values for the various config settings.
Not to be used in isolation, use geDefaults() instead.
@return array | [
"Returns",
"a",
"set",
"of",
"default",
"values",
"for",
"the",
"various",
"config",
"settings",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L475-L482 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.getHostName | protected function getHostName()
{
if (!empty($_SERVER['REQUEST_URI'])) {
$hostName = parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST);
}
if (!empty($hostName)) {
if ($pos = strpos($hostName, 'www.') !== false) {
$hostName = substr($hostName, $pos + strlen('www.'));
}
} else {
$hostName = 'example.com';
}
return $hostName;
} | php | protected function getHostName()
{
if (!empty($_SERVER['REQUEST_URI'])) {
$hostName = parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST);
}
if (!empty($hostName)) {
if ($pos = strpos($hostName, 'www.') !== false) {
$hostName = substr($hostName, $pos + strlen('www.'));
}
} else {
$hostName = 'example.com';
}
return $hostName;
} | [
"protected",
"function",
"getHostName",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"{",
"$",
"hostName",
"=",
"parse_url",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"PHP_URL_HOST",
")",
... | Returns the hostname of the current request.
The hostname is returned without www. so it can be used as domain name
in constructing e-mail addresses.
@return string
The hostname of the current request. | [
"Returns",
"the",
"hostname",
"of",
"the",
"current",
"request",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L505-L518 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade | public function upgrade($currentVersion)
{
$result = true;
if (version_compare($currentVersion, '4.5.0', '<')) {
$result = $this->upgrade450();
}
if (version_compare($currentVersion, '4.5.3', '<')) {
$result = $this->upgrade453() && $result;
}
if (version_compare($currentVersion, '4.6.0', '<')) {
$result = $this->upgrade460() && $result;
}
if (version_compare($currentVersion, '4.7.0', '<')) {
$result = $this->upgrade470() && $result;
}
if (version_compare($currentVersion, '4.7.3', '<')) {
$result = $this->upgrade473() && $result;
}
if (version_compare($currentVersion, '4.8.5', '<')) {
$result = $this->upgrade496() && $result;
}
if (version_compare($currentVersion, '5.4.0', '<')) {
$result = $this->upgrade540() && $result;
}
if (version_compare($currentVersion, '5.4.1', '<')) {
$result = $this->upgrade541() && $result;
}
if (version_compare($currentVersion, '5.4.2', '<')) {
$result = $this->upgrade542() && $result;
}
if (version_compare($currentVersion, '5.5.0', '<')) {
$result = $this->upgrade550() && $result;
}
return $result;
} | php | public function upgrade($currentVersion)
{
$result = true;
if (version_compare($currentVersion, '4.5.0', '<')) {
$result = $this->upgrade450();
}
if (version_compare($currentVersion, '4.5.3', '<')) {
$result = $this->upgrade453() && $result;
}
if (version_compare($currentVersion, '4.6.0', '<')) {
$result = $this->upgrade460() && $result;
}
if (version_compare($currentVersion, '4.7.0', '<')) {
$result = $this->upgrade470() && $result;
}
if (version_compare($currentVersion, '4.7.3', '<')) {
$result = $this->upgrade473() && $result;
}
if (version_compare($currentVersion, '4.8.5', '<')) {
$result = $this->upgrade496() && $result;
}
if (version_compare($currentVersion, '5.4.0', '<')) {
$result = $this->upgrade540() && $result;
}
if (version_compare($currentVersion, '5.4.1', '<')) {
$result = $this->upgrade541() && $result;
}
if (version_compare($currentVersion, '5.4.2', '<')) {
$result = $this->upgrade542() && $result;
}
if (version_compare($currentVersion, '5.5.0', '<')) {
$result = $this->upgrade550() && $result;
}
return $result;
} | [
"public",
"function",
"upgrade",
"(",
"$",
"currentVersion",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"version_compare",
"(",
"$",
"currentVersion",
",",
"'4.5.0'",
",",
"'<'",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"upgrade... | Upgrade the datamodel to the given version.
This method is only called when the module gets updated.
@param string $currentVersion
The current version of the module.
@return bool
Success. | [
"Upgrade",
"the",
"datamodel",
"to",
"the",
"given",
"version",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L940-L985 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade450 | protected function upgrade450()
{
$result = true;
// Keep track of settings that should be updated.
$newSettings = array();
// 1) Log level.
switch ($this->get('logLevel')) {
case Log::Error:
case Log::Warning:
// This is often not giving enough information, so we set it
// to Notice by default.
$newSettings['logLevel'] = Log::Notice;
break;
case Log::Info:
// Info was inserted, so this is the former debug level.
$newSettings['logLevel'] = Log::Debug;
break;
}
// 2) Debug mode.
switch ($this->get('debug')) {
case 4: // Value for deprecated PluginConfig::Debug_StayLocal.
$newSettings['logLevel'] = PluginConfig::Send_TestMode;
break;
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | php | protected function upgrade450()
{
$result = true;
// Keep track of settings that should be updated.
$newSettings = array();
// 1) Log level.
switch ($this->get('logLevel')) {
case Log::Error:
case Log::Warning:
// This is often not giving enough information, so we set it
// to Notice by default.
$newSettings['logLevel'] = Log::Notice;
break;
case Log::Info:
// Info was inserted, so this is the former debug level.
$newSettings['logLevel'] = Log::Debug;
break;
}
// 2) Debug mode.
switch ($this->get('debug')) {
case 4: // Value for deprecated PluginConfig::Debug_StayLocal.
$newSettings['logLevel'] = PluginConfig::Send_TestMode;
break;
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | [
"protected",
"function",
"upgrade450",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// Keep track of settings that should be updated.",
"$",
"newSettings",
"=",
"array",
"(",
")",
";",
"// 1) Log level.",
"switch",
"(",
"$",
"this",
"->",
"get",
"(",
"'logLe... | 4.5.0 upgrade.
- Log level: added level info and set log level to notice if it currently
is error or warning.
- Debug mode: the values of test mode and stay local are switched. Stay
local is no longer used, so both these 2 values become the new test
mode.
@return bool | [
"4",
".",
"5",
".",
"0",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L998-L1029 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade453 | protected function upgrade453()
{
// Keep track of settings that should be updated.
$newSettings = array();
if ($this->get('triggerInvoiceSendEvent') == 2) {
$newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_Create;
} else {
$newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_None;
}
return $this->save($newSettings);
} | php | protected function upgrade453()
{
// Keep track of settings that should be updated.
$newSettings = array();
if ($this->get('triggerInvoiceSendEvent') == 2) {
$newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_Create;
} else {
$newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_None;
}
return $this->save($newSettings);
} | [
"protected",
"function",
"upgrade453",
"(",
")",
"{",
"// Keep track of settings that should be updated.",
"$",
"newSettings",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'triggerInvoiceSendEvent'",
")",
"==",
"2",
")",
"{",
"$",
"n... | 4.5.3 upgrade.
- setting triggerInvoiceSendEvent removed.
- setting triggerInvoiceEvent introduced.
@return bool | [
"4",
".",
"5",
".",
"3",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L1039-L1050 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade460 | protected function upgrade460()
{
$result = true;
$newSettings = array();
if ($this->get('removeEmptyShipping') !== null) {
$newSettings['sendEmptyShipping'] = !$this->get('removeEmptyShipping');
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | php | protected function upgrade460()
{
$result = true;
$newSettings = array();
if ($this->get('removeEmptyShipping') !== null) {
$newSettings['sendEmptyShipping'] = !$this->get('removeEmptyShipping');
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | [
"protected",
"function",
"upgrade460",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"$",
"newSettings",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'removeEmptyShipping'",
")",
"!==",
"null",
")",
"{",
"$",
"newSettings",... | 4.6.0 upgrade.
- setting removeEmptyShipping inverted.
@return bool | [
"4",
".",
"6",
".",
"0",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L1059-L1072 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade470 | protected function upgrade470()
{
$result = true;
$newSettings = array();
if ($this->get('salutation') && strpos($this->get('salutation'), '[#') !== false) {
$newSettings['salutation'] = str_replace('[#', '[', $this->get('salutation'));
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | php | protected function upgrade470()
{
$result = true;
$newSettings = array();
if ($this->get('salutation') && strpos($this->get('salutation'), '[#') !== false) {
$newSettings['salutation'] = str_replace('[#', '[', $this->get('salutation'));
}
if (!empty($newSettings)) {
$result = $this->save($newSettings);
}
return $result;
} | [
"protected",
"function",
"upgrade470",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"$",
"newSettings",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'salutation'",
")",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"get",
"(... | 4.7.0 upgrade.
- salutation could already use token, but with old syntax: remove # after [.
@return bool | [
"4",
".",
"7",
".",
"0",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L1081-L1094 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade540 | protected function upgrade540()
{
$result = true;
// ConfigStore::save should store all settings in 1 serialized value.
$configStore = $this->getConfigStore();
if (method_exists($configStore, 'loadOld')) {
$values = $configStore->loadOld($this->getKeys());
$result = $this->save($values);
}
return $result;
} | php | protected function upgrade540()
{
$result = true;
// ConfigStore::save should store all settings in 1 serialized value.
$configStore = $this->getConfigStore();
if (method_exists($configStore, 'loadOld')) {
$values = $configStore->loadOld($this->getKeys());
$result = $this->save($values);
}
return $result;
} | [
"protected",
"function",
"upgrade540",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// ConfigStore::save should store all settings in 1 serialized value.",
"$",
"configStore",
"=",
"$",
"this",
"->",
"getConfigStore",
"(",
")",
";",
"if",
"(",
"method_exists",
"... | 5.4.0 upgrade.
- ConfigStore->save should store all settings in 1 serialized value.
@return bool | [
"5",
".",
"4",
".",
"0",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L1138-L1150 | train |
SIELOnline/libAcumulus | src/Config/Config.php | Config.upgrade541 | protected function upgrade541()
{
$result = true;
$doSave = false;
$configStore = $this->getConfigStore();
$values = $configStore->load();
array_walk_recursive($values, function(&$value) use (&$doSave) {
if (is_string($value) && strpos($value, 'originalInvoiceSource::') !== false) {
str_replace('originalInvoiceSource::', 'order::', $value);
$doSave = true;
}
});
if ($doSave) {
$result = $this->save($values);
}
return $result;
} | php | protected function upgrade541()
{
$result = true;
$doSave = false;
$configStore = $this->getConfigStore();
$values = $configStore->load();
array_walk_recursive($values, function(&$value) use (&$doSave) {
if (is_string($value) && strpos($value, 'originalInvoiceSource::') !== false) {
str_replace('originalInvoiceSource::', 'order::', $value);
$doSave = true;
}
});
if ($doSave) {
$result = $this->save($values);
}
return $result;
} | [
"protected",
"function",
"upgrade541",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"$",
"doSave",
"=",
"false",
";",
"$",
"configStore",
"=",
"$",
"this",
"->",
"getConfigStore",
"(",
")",
";",
"$",
"values",
"=",
"$",
"configStore",
"->",
"load",
... | 5.4.1 upgrade.
- property source originalInvoiceSource renamed to order.
@return bool | [
"5",
".",
"4",
".",
"1",
"upgrade",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/Config.php#L1159-L1176 | train |
SIELOnline/libAcumulus | src/Helpers/TranslationCollection.php | TranslationCollection.get | public function get($language)
{
$result = array();
if (isset($this->{$language})) {
$result = $this->{$language};
}
if ($language !== 'nl' && isset($this->nl)) {
$result += $this->nl;
}
return $result;
} | php | public function get($language)
{
$result = array();
if (isset($this->{$language})) {
$result = $this->{$language};
}
if ($language !== 'nl' && isset($this->nl)) {
$result += $this->nl;
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"language",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"language",
"}",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"{",
"$",
"l... | Returns a set of translations for the given language, completed with Dutch
translations if no translation for the given language for some key was
defined.
@param string $language
@return array
A keyed array with translations. | [
"Returns",
"a",
"set",
"of",
"translations",
"for",
"the",
"given",
"language",
"completed",
"with",
"Dutch",
"translations",
"if",
"no",
"translation",
"for",
"the",
"given",
"language",
"for",
"some",
"key",
"was",
"defined",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/TranslationCollection.php#L25-L35 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.flattenInvoiceLines | protected function flattenInvoiceLines(array $lines)
{
$result = array();
foreach ($lines as $line) {
$children = null;
// Ignore children if we do not want to show them.
// If it has children, flatten them and determine how to add them.
if (array_key_exists(Meta::ChildrenLines, $line)) {
$children = $this->flattenInvoiceLines($line[Meta::ChildrenLines]);
// Remove children from parent.
unset($line[Meta::ChildrenLines]);
// Determine whether to add them at all and if so whether
// to add them as a single line or as separate lines.
if ($this->keepSeparateLines($line, $children)) {
// Keep them separate but perform the following actions:
// - Allow for some web shop specific corrections.
// - Add meta data to relate parent and children.
// - Indent product descriptions.
$this->correctInfoBetweenParentAndChildren($line, $children);
} else {
// Merge the children into the parent product:
// - Allow for some web shop specific corrections.
// - Add meta data about removed children.
// - Add text from children, eg. chosen variants, to parent.
$line = $this->collectInfoFromChildren($line, $children);
// Delete children as their info is merged into the parent.
$children = null;
}
}
// Add the line and its children, if any.
$result[] = $line;
if (!empty($children)) {
$result = array_merge($result, $children);
}
}
return $result;
} | php | protected function flattenInvoiceLines(array $lines)
{
$result = array();
foreach ($lines as $line) {
$children = null;
// Ignore children if we do not want to show them.
// If it has children, flatten them and determine how to add them.
if (array_key_exists(Meta::ChildrenLines, $line)) {
$children = $this->flattenInvoiceLines($line[Meta::ChildrenLines]);
// Remove children from parent.
unset($line[Meta::ChildrenLines]);
// Determine whether to add them at all and if so whether
// to add them as a single line or as separate lines.
if ($this->keepSeparateLines($line, $children)) {
// Keep them separate but perform the following actions:
// - Allow for some web shop specific corrections.
// - Add meta data to relate parent and children.
// - Indent product descriptions.
$this->correctInfoBetweenParentAndChildren($line, $children);
} else {
// Merge the children into the parent product:
// - Allow for some web shop specific corrections.
// - Add meta data about removed children.
// - Add text from children, eg. chosen variants, to parent.
$line = $this->collectInfoFromChildren($line, $children);
// Delete children as their info is merged into the parent.
$children = null;
}
}
// Add the line and its children, if any.
$result[] = $line;
if (!empty($children)) {
$result = array_merge($result, $children);
}
}
return $result;
} | [
"protected",
"function",
"flattenInvoiceLines",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"children",
"=",
"null",
";",
"// Ignore children if we do not... | Flattens the invoice lines for variants or composed products.
Invoice lines may recursively contain other invoice lines to indicate
that a product has variant lines or is a composed product (if supported
by the webshop).
With composed or variant child lines, amounts may appear twice. This will
also be corrected by this method.
@param array[] $lines
The lines to flatten.
@return array[]
The flattened lines. | [
"Flattens",
"the",
"invoice",
"lines",
"for",
"variants",
"or",
"composed",
"products",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L88-L127 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.keepSeparateLines | protected function keepSeparateLines(array $parent, array $children)
{
$invoiceSettings = $this->config->getInvoiceSettings();
if (!$this->haveSameVatRate($children)) {
// We MUST keep them separate to retain correct vat info.
$separateLines = true;
} elseif (!$invoiceSettings['optionsShow']) {
// Do not kshow the children info at all, but do collect price info.
$separateLines = false;
} elseif (count($children) <= $invoiceSettings['optionsAllOn1Line']) {
$separateLines = false;
} elseif (count($children) >= $invoiceSettings['optionsAllOnOwnLine']) {
$separateLines = true;
} else {
$childrenText = $this->getMergedLinesText($parent, $children);
$separateLines = strlen($childrenText) > $invoiceSettings['optionsMaxLength'];
}
return $separateLines;
} | php | protected function keepSeparateLines(array $parent, array $children)
{
$invoiceSettings = $this->config->getInvoiceSettings();
if (!$this->haveSameVatRate($children)) {
// We MUST keep them separate to retain correct vat info.
$separateLines = true;
} elseif (!$invoiceSettings['optionsShow']) {
// Do not kshow the children info at all, but do collect price info.
$separateLines = false;
} elseif (count($children) <= $invoiceSettings['optionsAllOn1Line']) {
$separateLines = false;
} elseif (count($children) >= $invoiceSettings['optionsAllOnOwnLine']) {
$separateLines = true;
} else {
$childrenText = $this->getMergedLinesText($parent, $children);
$separateLines = strlen($childrenText) > $invoiceSettings['optionsMaxLength'];
}
return $separateLines;
} | [
"protected",
"function",
"keepSeparateLines",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"$",
"invoiceSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getInvoiceSettings",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"h... | Determines whether to keep the children on separate lines.
This base implementation decides based on:
- Whether all lines have the same VAT rate (different VAT rates => keep)
- The settings for:
* optionsShow
* optionsAllOn1Line
* optionsAllOnOwnLine
* optionsMaxLength
Override if you want other logic to decide on.
@param array $parent
The parent invoice line.
@param array[] $children
A flattened array of child invoice lines.
@return bool
True if the lines should remain separate, false otherwise. | [
"Determines",
"whether",
"to",
"keep",
"the",
"children",
"on",
"separate",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L150-L168 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.getMergedLinesText | protected function getMergedLinesText(array $parent, array $children)
{
$childrenTexts = array();
foreach ($children as $child) {
$childrenTexts[] = $child[Tag::Product];
}
$childrenText = ' (' . implode(', ', $childrenTexts) . ')';
return $parent[Tag::Product] . $childrenText;
} | php | protected function getMergedLinesText(array $parent, array $children)
{
$childrenTexts = array();
foreach ($children as $child) {
$childrenTexts[] = $child[Tag::Product];
}
$childrenText = ' (' . implode(', ', $childrenTexts) . ')';
return $parent[Tag::Product] . $childrenText;
} | [
"protected",
"function",
"getMergedLinesText",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"$",
"childrenTexts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"childrenTexts",
"... | Returns a 'product' field for the merged lines.
@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines.
@return string
The concatenated product texts. | [
"Returns",
"a",
"product",
"field",
"for",
"the",
"merged",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L181-L189 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.correctInfoBetweenParentAndChildren | protected function correctInfoBetweenParentAndChildren(array &$parent, array &$children)
{
if (!empty($children)) {
$parent[Meta::Parent] = $this->parentIndex;
$parent[Meta::NumberOfChildren] = count($children);
foreach ($children as &$child) {
$child[Tag::Product] = $this->indentDescription($child[Tag::Product]);
$child[Meta::ParentIndex] = $this->parentIndex;
}
$this->parentIndex++;
}
} | php | protected function correctInfoBetweenParentAndChildren(array &$parent, array &$children)
{
if (!empty($children)) {
$parent[Meta::Parent] = $this->parentIndex;
$parent[Meta::NumberOfChildren] = count($children);
foreach ($children as &$child) {
$child[Tag::Product] = $this->indentDescription($child[Tag::Product]);
$child[Meta::ParentIndex] = $this->parentIndex;
}
$this->parentIndex++;
}
} | [
"protected",
"function",
"correctInfoBetweenParentAndChildren",
"(",
"array",
"&",
"$",
"parent",
",",
"array",
"&",
"$",
"children",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"children",
")",
")",
"{",
"$",
"parent",
"[",
"Meta",
"::",
"Parent",
"]",... | Allows to correct or remove info between or from parent and child lines.
This method is called before the child lines are added to the set of
invoice lines.
This base implementation performs the following actions:
- Add meta data to parent and children to link them to each other.
- Indent product descriptions of the children.
Situations that may have to be covered by web shop specific overrides:
- Price info only on parent.
- Price info only on children.
- Price info both on parent and children and the amounts are doubled.
(price on parent is the sum of the prices of the children).
- Price info both on parent and children but the amounts are not doubled
(base price on parent plus extra/less charges for options on children).
@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines. | [
"Allows",
"to",
"correct",
"or",
"remove",
"info",
"between",
"or",
"from",
"parent",
"and",
"child",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L214-L225 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.collectInfoFromChildren | protected function collectInfoFromChildren(array $parent, array $children)
{
$invoiceSettings = $this->config->getInvoiceSettings();
if (!$invoiceSettings['optionsShow']) {
$parent[Meta::ChildrenNotShown] = count($children);
} else {
$parent[Tag::Product] = $this->getMergedLinesText($parent, $children);
$parent[Meta::ChildrenMerged] = count($children);
}
return $parent;
} | php | protected function collectInfoFromChildren(array $parent, array $children)
{
$invoiceSettings = $this->config->getInvoiceSettings();
if (!$invoiceSettings['optionsShow']) {
$parent[Meta::ChildrenNotShown] = count($children);
} else {
$parent[Tag::Product] = $this->getMergedLinesText($parent, $children);
$parent[Meta::ChildrenMerged] = count($children);
}
return $parent;
} | [
"protected",
"function",
"collectInfoFromChildren",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"$",
"invoiceSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getInvoiceSettings",
"(",
")",
";",
"if",
"(",
"!",
"$",
"invoiceSettin... | Allows to collect info from the child lines and add it to the parent.
This method is called before the child lines are merged into the parent
invoice line.
This base implementation merges the product descriptions from the child
lines into the parent product description.
Situations that may have to be covered by web shop specific overrides:
- Price info only on parent.
- Price info only on children.
- Price info both on parent and children and the amounts appear twice
(price on parent is the sum of the prices of the children).
- Price info both on parent and children but the amounts are not doubled
(base price on parent plus extra charges for options on children).
Examples;
- There are amounts on the children but as they are going to be merged
into the parent they would get lost.
@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines.
@return array
The parent line extended with the collected info. | [
"Allows",
"to",
"collect",
"info",
"from",
"the",
"child",
"lines",
"and",
"add",
"it",
"to",
"the",
"parent",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L256-L266 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.copyVatInfoToChildren | protected function copyVatInfoToChildren(array $parent, array $children)
{
static $vatMetaInfoTags = array(
Meta::VatRateMin,
Meta::VatRateMax,
Meta::VatRateLookup,
Meta::VatRateLookupLabel,
Meta::VatRateLookupSource,
Meta::VatRateLookupMatches,
Meta::VatClassId,
Meta::VatClassName,
);
foreach ($children as &$child) {
if (isset($parent[Tag::VatRate])) {
$child[Tag::VatRate] = $parent[Tag::VatRate];
}
$child[Meta::VatAmount] = 0;
foreach ($vatMetaInfoTags as $tag) {
unset($child[$tag]);
}
if (Completor::isCorrectVatRate($parent[Meta::VatRateSource])) {
$child[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Parent;
} else {
// The parent does not yet have correct vat rate info, so also
// copy the meta data to the child, so later phases can also
// correct the children.
$child[Meta::VatRateSource] = $parent[Meta::VatRateSource];
foreach ($vatMetaInfoTags as $tag) {
if (isset($parent[$tag])) {
$child[$tag] = $parent[$tag];
}
}
}
$child[Meta::LineVatAmount] = 0;
unset($child[Meta::LineDiscountVatAmount]);
}
return $children;
} | php | protected function copyVatInfoToChildren(array $parent, array $children)
{
static $vatMetaInfoTags = array(
Meta::VatRateMin,
Meta::VatRateMax,
Meta::VatRateLookup,
Meta::VatRateLookupLabel,
Meta::VatRateLookupSource,
Meta::VatRateLookupMatches,
Meta::VatClassId,
Meta::VatClassName,
);
foreach ($children as &$child) {
if (isset($parent[Tag::VatRate])) {
$child[Tag::VatRate] = $parent[Tag::VatRate];
}
$child[Meta::VatAmount] = 0;
foreach ($vatMetaInfoTags as $tag) {
unset($child[$tag]);
}
if (Completor::isCorrectVatRate($parent[Meta::VatRateSource])) {
$child[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Parent;
} else {
// The parent does not yet have correct vat rate info, so also
// copy the meta data to the child, so later phases can also
// correct the children.
$child[Meta::VatRateSource] = $parent[Meta::VatRateSource];
foreach ($vatMetaInfoTags as $tag) {
if (isset($parent[$tag])) {
$child[$tag] = $parent[$tag];
}
}
}
$child[Meta::LineVatAmount] = 0;
unset($child[Meta::LineDiscountVatAmount]);
}
return $children;
} | [
"protected",
"function",
"copyVatInfoToChildren",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"static",
"$",
"vatMetaInfoTags",
"=",
"array",
"(",
"Meta",
"::",
"VatRateMin",
",",
"Meta",
"::",
"VatRateMax",
",",
"Meta",
"::",
"VatR... | Copies vat info from the parent to all children.
In Magento, VAT info on the children may contain a 0 vat rate. To correct
this, we copy the vat information (rate, source, correction info).
@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines.
@return array[]
The child invoice lines with vat info copied form the parent. | [
"Copies",
"vat",
"info",
"from",
"the",
"parent",
"to",
"all",
"children",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L390-L430 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.copyVatInfoToParent | protected function copyVatInfoToParent(array $parent, array $children)
{
$parent[Meta::VatAmount] = 0;
// Copy vat rate info from a child when the parent has no vat rate info.
if (empty($parent[Tag::VatRate]) || Number::isZero($parent[Tag::VatRate])) {
$parent[Tag::VatRate] = CompletorInvoiceLines::getMaxAppearingVatRate($children, $index);
$parent[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Children;
if (isset($children[$index][Meta::VatRateMin])) {
$parent[Meta::VatRateMin] = $children[$index][Meta::VatRateMin];
} else {
unset($parent[Meta::VatRateMin]);
}
if (isset($children[$index][Meta::VatRateMax])) {
$parent[Meta::VatRateMax] = $children[$index][Meta::VatRateMax];
} else {
unset($parent[Meta::VatRateMax]);
}
}
$parent[Meta::LineVatAmount] = 0;
unset($parent[Meta::LineDiscountVatAmount]);
return $parent;
} | php | protected function copyVatInfoToParent(array $parent, array $children)
{
$parent[Meta::VatAmount] = 0;
// Copy vat rate info from a child when the parent has no vat rate info.
if (empty($parent[Tag::VatRate]) || Number::isZero($parent[Tag::VatRate])) {
$parent[Tag::VatRate] = CompletorInvoiceLines::getMaxAppearingVatRate($children, $index);
$parent[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Children;
if (isset($children[$index][Meta::VatRateMin])) {
$parent[Meta::VatRateMin] = $children[$index][Meta::VatRateMin];
} else {
unset($parent[Meta::VatRateMin]);
}
if (isset($children[$index][Meta::VatRateMax])) {
$parent[Meta::VatRateMax] = $children[$index][Meta::VatRateMax];
} else {
unset($parent[Meta::VatRateMax]);
}
}
$parent[Meta::LineVatAmount] = 0;
unset($parent[Meta::LineDiscountVatAmount]);
return $parent;
} | [
"protected",
"function",
"copyVatInfoToParent",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"$",
"parent",
"[",
"Meta",
"::",
"VatAmount",
"]",
"=",
"0",
";",
"// Copy vat rate info from a child when the parent has no vat rate info.",
"if",
... | Copies vat info to the parent.
This prevents that amounts appear twice on the invoice.
@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines.
@return array
The parent invoice line with price info removed. | [
"Copies",
"vat",
"info",
"to",
"the",
"parent",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L445-L467 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.removePriceInfoFromChildren | protected function removePriceInfoFromChildren(array $children)
{
foreach ($children as &$child) {
$child[Tag::UnitPrice] = 0;
$child[Meta::UnitPriceInc] = 0;
unset($child[Meta::LineAmount]);
unset($child[Meta::LineAmountInc]);
unset($child[Meta::LineDiscountAmountInc]);
}
return $children;
} | php | protected function removePriceInfoFromChildren(array $children)
{
foreach ($children as &$child) {
$child[Tag::UnitPrice] = 0;
$child[Meta::UnitPriceInc] = 0;
unset($child[Meta::LineAmount]);
unset($child[Meta::LineAmountInc]);
unset($child[Meta::LineDiscountAmountInc]);
}
return $children;
} | [
"protected",
"function",
"removePriceInfoFromChildren",
"(",
"array",
"$",
"children",
")",
"{",
"foreach",
"(",
"$",
"children",
"as",
"&",
"$",
"child",
")",
"{",
"$",
"child",
"[",
"Tag",
"::",
"UnitPrice",
"]",
"=",
"0",
";",
"$",
"child",
"[",
"Me... | Removes price info from all children.
This can prevent that amounts appear twice on the invoice. This can only
be done if all children have the same vat rate as the parent, otherwise
the price (and vat) info should remain on the children and be removed
from the parent.
@param array[] $children
The child invoice lines.
@return array[]
The child invoice lines with price info removed. | [
"Removes",
"price",
"info",
"from",
"all",
"children",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L483-L493 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.removePriceInfoFromParent | protected function removePriceInfoFromParent(array $parent)
{
$parent[Tag::UnitPrice] = 0;
$parent[Meta::UnitPriceInc] = 0;
unset($parent[Meta::LineAmount]);
unset($parent[Meta::LineAmountInc]);
unset($parent[Meta::LineDiscountAmountInc]);
return $parent;
} | php | protected function removePriceInfoFromParent(array $parent)
{
$parent[Tag::UnitPrice] = 0;
$parent[Meta::UnitPriceInc] = 0;
unset($parent[Meta::LineAmount]);
unset($parent[Meta::LineAmountInc]);
unset($parent[Meta::LineDiscountAmountInc]);
return $parent;
} | [
"protected",
"function",
"removePriceInfoFromParent",
"(",
"array",
"$",
"parent",
")",
"{",
"$",
"parent",
"[",
"Tag",
"::",
"UnitPrice",
"]",
"=",
"0",
";",
"$",
"parent",
"[",
"Meta",
"::",
"UnitPriceInc",
"]",
"=",
"0",
";",
"unset",
"(",
"$",
"par... | Removes price info from the parent.
This can prevent that amounts appear twice on the invoice.
@param array $parent
The parent invoice line.
@return array
The parent invoice line with price info removed. | [
"Removes",
"price",
"info",
"from",
"the",
"parent",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L506-L514 | train |
SIELOnline/libAcumulus | src/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.getAppearingVatRates | protected function getAppearingVatRates(array $lines)
{
$vatRates = array();
foreach ($lines as $line) {
if (isset($line[Tag::VatRate])) {
$vatRate = sprintf('%.1f', $line[Tag::VatRate]);
if (isset($vatRates[$vatRate])) {
$vatRates[$vatRate]++;
} else {
$vatRates[$vatRate] = 1;
}
}
}
return $vatRates;
} | php | protected function getAppearingVatRates(array $lines)
{
$vatRates = array();
foreach ($lines as $line) {
if (isset($line[Tag::VatRate])) {
$vatRate = sprintf('%.1f', $line[Tag::VatRate]);
if (isset($vatRates[$vatRate])) {
$vatRates[$vatRate]++;
} else {
$vatRates[$vatRate] = 1;
}
}
}
return $vatRates;
} | [
"protected",
"function",
"getAppearingVatRates",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"vatRates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"Tag",
"::",
... | Returns a list of vat rates that actually appear in the given lines.
@param array[] $lines
an array of invoice lines.
@return array
An array with the vat rates as key and the number of times they appear
in the invoice lines as value. | [
"Returns",
"a",
"list",
"of",
"vat",
"rates",
"that",
"actually",
"appear",
"in",
"the",
"given",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/FlattenerInvoiceLines.php#L545-L559 | train |
ipunkt/rancherize | app/Services/DockerService.php | DockerService.build | public function build(string $imageName, $dockerfile = null) {
if( $dockerfile === null )
$dockerfile = 'Dockerfile';
$this->requireProcess();
$process = ProcessBuilder::create([
'docker', 'build', '-f', $dockerfile, '-t', $imageName, '.'
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new BuildFailedException($imageName, $dockerfile, 22);
} | php | public function build(string $imageName, $dockerfile = null) {
if( $dockerfile === null )
$dockerfile = 'Dockerfile';
$this->requireProcess();
$process = ProcessBuilder::create([
'docker', 'build', '-f', $dockerfile, '-t', $imageName, '.'
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new BuildFailedException($imageName, $dockerfile, 22);
} | [
"public",
"function",
"build",
"(",
"string",
"$",
"imageName",
",",
"$",
"dockerfile",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dockerfile",
"===",
"null",
")",
"$",
"dockerfile",
"=",
"'Dockerfile'",
";",
"$",
"this",
"->",
"requireProcess",
"(",
")",
... | Build the given image using the given dockerfile or 'Dockerfile' if none is given
@param string $imageName
@param string $dockerfile | [
"Build",
"the",
"given",
"image",
"using",
"the",
"given",
"dockerfile",
"or",
"Dockerfile",
"if",
"none",
"is",
"given"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/DockerService.php#L25-L42 | train |
ipunkt/rancherize | app/Services/DockerService.php | DockerService.login | public function login($username, $password, $server = null) {
$this->requireProcess();
$commandArguments = [
'docker',
'login',
'-u',
$username,
'--password-stdin'
];
if( !empty($server) )
$commandArguments[] = $server;
$process = ProcessBuilder::create( $commandArguments )
->setTimeout(null)->getProcess();
$process->setInput($password);
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_VERY_VERBOSE);
if($process->getExitCode() !== 0)
throw new LoginFailedException("Login failed", 21);
} | php | public function login($username, $password, $server = null) {
$this->requireProcess();
$commandArguments = [
'docker',
'login',
'-u',
$username,
'--password-stdin'
];
if( !empty($server) )
$commandArguments[] = $server;
$process = ProcessBuilder::create( $commandArguments )
->setTimeout(null)->getProcess();
$process->setInput($password);
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_VERY_VERBOSE);
if($process->getExitCode() !== 0)
throw new LoginFailedException("Login failed", 21);
} | [
"public",
"function",
"login",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"server",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requireProcess",
"(",
")",
";",
"$",
"commandArguments",
"=",
"[",
"'docker'",
",",
"'login'",
",",
"'-u'",
",",
... | login to Dockerhub using the given username and password
@param $username
@param $password
@param string|null $server | [
"login",
"to",
"Dockerhub",
"using",
"the",
"given",
"username",
"and",
"password"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/DockerService.php#L51-L72 | train |
ipunkt/rancherize | app/Services/DockerService.php | DockerService.push | public function push(string $imageName, string $server = null) {
$this->requireProcess();
$process = ProcessBuilder::create([
'docker', 'push', $imageName
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new PushFailedException($imageName, 20);
} | php | public function push(string $imageName, string $server = null) {
$this->requireProcess();
$process = ProcessBuilder::create([
'docker', 'push', $imageName
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new PushFailedException($imageName, 20);
} | [
"public",
"function",
"push",
"(",
"string",
"$",
"imageName",
",",
"string",
"$",
"server",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requireProcess",
"(",
")",
";",
"$",
"process",
"=",
"ProcessBuilder",
"::",
"create",
"(",
"[",
"'docker'",
",",
"'... | Push the given image to dockerhub. You will most likely need to login before using this
@param string $imageName
@param string|null $server | [
"Push",
"the",
"given",
"image",
"to",
"dockerhub",
".",
"You",
"will",
"most",
"likely",
"need",
"to",
"login",
"before",
"using",
"this"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/DockerService.php#L80-L92 | train |
ipunkt/rancherize | app/Services/DockerService.php | DockerService.buildImages | public function buildImages(string $directory, string $projectName) {
$this->requireProcess();
$process = ProcessBuilder::create([
'docker-compose', '-p', $projectName, '-f', $directory.'/docker-compose.yml', 'build'
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new StartFailedException($projectName);
} | php | public function buildImages(string $directory, string $projectName) {
$this->requireProcess();
$process = ProcessBuilder::create([
'docker-compose', '-p', $projectName, '-f', $directory.'/docker-compose.yml', 'build'
])
->setTimeout(null)->getProcess();
$this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if($process->getExitCode() !== 0)
throw new StartFailedException($projectName);
} | [
"public",
"function",
"buildImages",
"(",
"string",
"$",
"directory",
",",
"string",
"$",
"projectName",
")",
"{",
"$",
"this",
"->",
"requireProcess",
"(",
")",
";",
"$",
"process",
"=",
"ProcessBuilder",
"::",
"create",
"(",
"[",
"'docker-compose'",
",",
... | Have docker-compose perform image builds
@param string $directory
@param string $projectName | [
"Have",
"docker",
"-",
"compose",
"perform",
"image",
"builds"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/DockerService.php#L101-L113 | train |
SIELOnline/libAcumulus | src/Invoice/Result.php | Result.getSendStatusText | protected function getSendStatusText()
{
switch ($this->sendStatus) {
case self::NotSent_WrongStatus:
$message = empty($this->sendStatusArguments)
? 'reason_not_sent_triggerCreditNoteEvent_None'
: 'reason_not_sent_wrongStatus';
break;
case self::NotSent_AlreadySent:
$message = 'reason_not_sent_alreadySent';
break;
case self::NotSent_LockedForSending:
$message = 'reason_not_sent_alreadySending';
break;
case self::NotSent_EventInvoiceCreated:
$message = 'reason_not_sent_prevented_invoiceCreated';
break;
case self::NotSent_EventInvoiceCompleted:
$message = 'reason_not_sent_prevented_invoiceCompleted';
break;
case self::NotSent_EmptyInvoice:
$message = 'reason_not_sent_empty_invoice';
break;
case self::NotSent_TriggerInvoiceCreateNotEnabled:
$message = 'reason_not_sent_not_enabled_triggerInvoiceCreate';
break;
case self::NotSent_TriggerInvoiceSentNotEnabled:
$message = 'reason_not_sent_not_enabled_triggerInvoiceSent';
break;
case self::NotSent_LocalErrors:
$message = 'reason_not_sent_local_errors';
break;
case self::NotSent_DryRun:
$message = 'reason_not_sent_dry_run';
break;
case self::Send_TestMode:
$message = 'reason_sent_testMode';
break;
case self::Send_New:
$message = empty($this->sendStatusArguments)
? 'reason_sent_new'
: 'reason_sent_new_status_change';
break;
case self::Send_LockExpired:
$message = 'reason_sent_lock_expired';
break;
case self::Send_Forced:
$message = 'reason_sent_forced';
break;
default:
$message = 'reason_unknown';
$this->sendStatusArguments = array(($this->sendStatus));
break;
}
$message = $this->t($message);
if (!empty($this->sendStatusArguments)) {
$message = vsprintf($message, $this->sendStatusArguments);
}
return $message;
} | php | protected function getSendStatusText()
{
switch ($this->sendStatus) {
case self::NotSent_WrongStatus:
$message = empty($this->sendStatusArguments)
? 'reason_not_sent_triggerCreditNoteEvent_None'
: 'reason_not_sent_wrongStatus';
break;
case self::NotSent_AlreadySent:
$message = 'reason_not_sent_alreadySent';
break;
case self::NotSent_LockedForSending:
$message = 'reason_not_sent_alreadySending';
break;
case self::NotSent_EventInvoiceCreated:
$message = 'reason_not_sent_prevented_invoiceCreated';
break;
case self::NotSent_EventInvoiceCompleted:
$message = 'reason_not_sent_prevented_invoiceCompleted';
break;
case self::NotSent_EmptyInvoice:
$message = 'reason_not_sent_empty_invoice';
break;
case self::NotSent_TriggerInvoiceCreateNotEnabled:
$message = 'reason_not_sent_not_enabled_triggerInvoiceCreate';
break;
case self::NotSent_TriggerInvoiceSentNotEnabled:
$message = 'reason_not_sent_not_enabled_triggerInvoiceSent';
break;
case self::NotSent_LocalErrors:
$message = 'reason_not_sent_local_errors';
break;
case self::NotSent_DryRun:
$message = 'reason_not_sent_dry_run';
break;
case self::Send_TestMode:
$message = 'reason_sent_testMode';
break;
case self::Send_New:
$message = empty($this->sendStatusArguments)
? 'reason_sent_new'
: 'reason_sent_new_status_change';
break;
case self::Send_LockExpired:
$message = 'reason_sent_lock_expired';
break;
case self::Send_Forced:
$message = 'reason_sent_forced';
break;
default:
$message = 'reason_unknown';
$this->sendStatusArguments = array(($this->sendStatus));
break;
}
$message = $this->t($message);
if (!empty($this->sendStatusArguments)) {
$message = vsprintf($message, $this->sendStatusArguments);
}
return $message;
} | [
"protected",
"function",
"getSendStatusText",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"sendStatus",
")",
"{",
"case",
"self",
"::",
"NotSent_WrongStatus",
":",
"$",
"message",
"=",
"empty",
"(",
"$",
"this",
"->",
"sendStatusArguments",
")",
"?",
... | Returns a translated string indicating the reason for the action taken.
@return string | [
"Returns",
"a",
"translated",
"string",
"indicating",
"the",
"reason",
"for",
"the",
"action",
"taken",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Result.php#L166-L225 | train |
SIELOnline/libAcumulus | src/Invoice/Result.php | Result.getLogText | public function getLogText($addReqResp)
{
$action = $this->getActionText();
$reason = $this->getSendStatusText();
$message = sprintf($this->t('message_invoice_reason'), $action, $reason);
if ($this->hasBeenSent() || $this->getSendStatus() === self::NotSent_LocalErrors) {
if ($this->hasBeenSent()) {
$message .= ' ' . $this->getStatusText();
}
if ($this->hasMessages()) {
$message .= "\n" . $this->getMessages(Result::Format_FormattedText);
}
if ($addReqResp === Result::AddReqResp_Always || ($addReqResp === Result::AddReqResp_WithOther && $this->hasMessages())) {
$message .= ' ' . $this->getRawRequestResponse(Result::Format_FormattedText);
}
}
return $message;
} | php | public function getLogText($addReqResp)
{
$action = $this->getActionText();
$reason = $this->getSendStatusText();
$message = sprintf($this->t('message_invoice_reason'), $action, $reason);
if ($this->hasBeenSent() || $this->getSendStatus() === self::NotSent_LocalErrors) {
if ($this->hasBeenSent()) {
$message .= ' ' . $this->getStatusText();
}
if ($this->hasMessages()) {
$message .= "\n" . $this->getMessages(Result::Format_FormattedText);
}
if ($addReqResp === Result::AddReqResp_Always || ($addReqResp === Result::AddReqResp_WithOther && $this->hasMessages())) {
$message .= ' ' . $this->getRawRequestResponse(Result::Format_FormattedText);
}
}
return $message;
} | [
"public",
"function",
"getLogText",
"(",
"$",
"addReqResp",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"getActionText",
"(",
")",
";",
"$",
"reason",
"=",
"$",
"this",
"->",
"getSendStatusText",
"(",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",... | Returns a translated sentence that can be used for logging.
The returned sentence indicated what happened and why. If the invoice was
sent or local errors prevented it being sent, then the returned string
also includes any messages (warnings, errors, or exception).
@param int $addReqResp
Whether to add the raw request and response.
One of the Result::AddReqResp_... constants
@return string | [
"Returns",
"a",
"translated",
"sentence",
"that",
"can",
"be",
"used",
"for",
"logging",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Result.php#L240-L258 | train |
SIELOnline/libAcumulus | src/OpenCart/Helpers/FormRenderer.php | FormRenderer.handleRequired | protected function handleRequired(array $field)
{
if (!empty($field['attributes']['required'])) {
if (empty($this->elementWrapperClass)) {
$this->elementWrapperClass = '';
} else {
$this->elementWrapperClass .= ' ';
}
$this->elementWrapperClass .= 'required';
}
} | php | protected function handleRequired(array $field)
{
if (!empty($field['attributes']['required'])) {
if (empty($this->elementWrapperClass)) {
$this->elementWrapperClass = '';
} else {
$this->elementWrapperClass .= ' ';
}
$this->elementWrapperClass .= 'required';
}
} | [
"protected",
"function",
"handleRequired",
"(",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
"[",
"'attributes'",
"]",
"[",
"'required'",
"]",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"elementWrapperCla... | Handles required fields.
@param array $field | [
"Handles",
"required",
"fields",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/FormRenderer.php#L57-L67 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.validateAccountFields | protected function validateAccountFields()
{
$regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/';
if (empty($this->submittedValues[Tag::ContractCode])) {
$this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_0');
} elseif (!is_numeric($this->submittedValues[Tag::ContractCode])) {
$this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_1');
} else {
// Prevent errors where a copy & paste of the contractcode from the
// welcome mail includes spaces or tabs before or after the code.
$this->submittedValues[Tag::ContractCode] = trim($this->submittedValues[Tag::ContractCode]);
}
if (empty($this->submittedValues[Tag::UserName])) {
$this->errorMessages[Tag::UserName] = $this->t('message_validate_username_0');
} elseif ($this->submittedValues[Tag::UserName] !== trim($this->submittedValues[Tag::UserName])) {
$this->warningMessages[Tag::UserName] = $this->t('message_validate_username_1');
}
if (empty($this->submittedValues[Tag::Password])) {
$this->errorMessages[Tag::Password] = $this->t('message_validate_password_0');
} elseif ($this->submittedValues[Tag::Password] !== trim($this->submittedValues[Tag::Password])) {
$this->warningMessages[Tag::Password] = $this->t('message_validate_password_1');
} elseif (strpbrk($this->submittedValues[Tag::Password], '`\'"#%&;<>\\') !== false) {
$this->warningMessages[Tag::Password] = $this->t('message_validate_password_2');
}
if (empty($this->submittedValues[Tag::EmailOnError])) {
$this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_1');
} elseif (!preg_match($regexpEmail, $this->submittedValues[Tag::EmailOnError])) {
$this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_0');
}
} | php | protected function validateAccountFields()
{
$regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/';
if (empty($this->submittedValues[Tag::ContractCode])) {
$this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_0');
} elseif (!is_numeric($this->submittedValues[Tag::ContractCode])) {
$this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_1');
} else {
// Prevent errors where a copy & paste of the contractcode from the
// welcome mail includes spaces or tabs before or after the code.
$this->submittedValues[Tag::ContractCode] = trim($this->submittedValues[Tag::ContractCode]);
}
if (empty($this->submittedValues[Tag::UserName])) {
$this->errorMessages[Tag::UserName] = $this->t('message_validate_username_0');
} elseif ($this->submittedValues[Tag::UserName] !== trim($this->submittedValues[Tag::UserName])) {
$this->warningMessages[Tag::UserName] = $this->t('message_validate_username_1');
}
if (empty($this->submittedValues[Tag::Password])) {
$this->errorMessages[Tag::Password] = $this->t('message_validate_password_0');
} elseif ($this->submittedValues[Tag::Password] !== trim($this->submittedValues[Tag::Password])) {
$this->warningMessages[Tag::Password] = $this->t('message_validate_password_1');
} elseif (strpbrk($this->submittedValues[Tag::Password], '`\'"#%&;<>\\') !== false) {
$this->warningMessages[Tag::Password] = $this->t('message_validate_password_2');
}
if (empty($this->submittedValues[Tag::EmailOnError])) {
$this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_1');
} elseif (!preg_match($regexpEmail, $this->submittedValues[Tag::EmailOnError])) {
$this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_0');
}
} | [
"protected",
"function",
"validateAccountFields",
"(",
")",
"{",
"$",
"regexpEmail",
"=",
"'/^[^@<>,; \"\\']+@([^.@ ,;]+\\.)+[^.@ ,;]+$/'",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"submittedValues",
"[",
"Tag",
"::",
"ContractCode",
"]",
")",
")",
"{",
... | Validates fields in the account settings fieldset. | [
"Validates",
"fields",
"in",
"the",
"account",
"settings",
"fieldset",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L44-L77 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.validateShopFields | protected function validateShopFields()
{
// Check if this fieldset was rendered.
if (!$this->isKey('nature_shop')) {
return;
}
// Check that required fields are filled.
if (!isset($this->submittedValues['nature_shop'])) {
$this->errorMessages['nature_shop'] = $this->t('message_validate_nature_0');
}
if (!isset($this->submittedValues['foreignVat'])) {
$this->errorMessages['foreignVat'] = $this->t('message_validate_foreign_vat_0');
}
if (!isset($this->submittedValues['vatFreeProducts'])) {
$this->errorMessages['vatFreeProducts'] = $this->t('message_validate_vat_free_products_0');
}
if (!isset($this->submittedValues['marginProducts'])) {
$this->errorMessages['marginProducts'] = $this->t('message_validate_margin_products_0');
}
// Check the foreignVat and foreignVatClasses settings.
if (isset($this->submittedValues['foreignVat']) && $this->submittedValues['foreignVat'] != PluginConfig::ForeignVat_No) {
if (empty($this->submittedValues['foreignVatClasses'])) {
$this->errorMessages['foreignVatClasses'] = $this->t('message_validate_foreign_vat_classes_0');
}
}
// Check the foreignVat and vatFreeProducts settings.
if (isset($this->submittedValues['foreignVat']) && $this->submittedValues['foreignVat'] != PluginConfig::ForeignVat_No) {
if (isset($this->submittedValues['vatFreeProducts']) && $this->submittedValues['vatFreeProducts'] == PluginConfig::VatFreeProducts_Only) {
$this->errorMessages['foreignVatClasses'] = $this->t('message_validate_vat_free_products_1');
}
}
// Check the marginProducts setting in combination with other settings.
// NOTE: it is debatable whether margin articles can be services, e.g.
// selling 2nd hand software licenses. However it is not debatable that
// margin goods can never be digital services. So the 1st validation is
// debatable and my be removed in the future, the 2nd isn't.
if (isset($this->submittedValues['nature_shop']) && isset($this->submittedValues['marginProducts'])) {
// If we only sell articles with nature Services, we cannot (also)
// sell margin goods.
if ($this->submittedValues['nature_shop'] == PluginConfig::Nature_Services && $this->submittedValues['marginProducts'] != PluginConfig::MarginProducts_No) {
$this->errorMessages['conflicting_options_1'] = $this->t('message_validate_conflicting_shop_options_2');
}
// If we only sell margin goods, the nature of all we sell is Products.
if ($this->submittedValues['marginProducts'] == PluginConfig::MarginProducts_Only && $this->submittedValues['nature_shop'] != PluginConfig::Nature_Products) {
$this->errorMessages['nature_shop_1'] = $this->t('message_validate_conflicting_shop_options_3');
}
}
} | php | protected function validateShopFields()
{
// Check if this fieldset was rendered.
if (!$this->isKey('nature_shop')) {
return;
}
// Check that required fields are filled.
if (!isset($this->submittedValues['nature_shop'])) {
$this->errorMessages['nature_shop'] = $this->t('message_validate_nature_0');
}
if (!isset($this->submittedValues['foreignVat'])) {
$this->errorMessages['foreignVat'] = $this->t('message_validate_foreign_vat_0');
}
if (!isset($this->submittedValues['vatFreeProducts'])) {
$this->errorMessages['vatFreeProducts'] = $this->t('message_validate_vat_free_products_0');
}
if (!isset($this->submittedValues['marginProducts'])) {
$this->errorMessages['marginProducts'] = $this->t('message_validate_margin_products_0');
}
// Check the foreignVat and foreignVatClasses settings.
if (isset($this->submittedValues['foreignVat']) && $this->submittedValues['foreignVat'] != PluginConfig::ForeignVat_No) {
if (empty($this->submittedValues['foreignVatClasses'])) {
$this->errorMessages['foreignVatClasses'] = $this->t('message_validate_foreign_vat_classes_0');
}
}
// Check the foreignVat and vatFreeProducts settings.
if (isset($this->submittedValues['foreignVat']) && $this->submittedValues['foreignVat'] != PluginConfig::ForeignVat_No) {
if (isset($this->submittedValues['vatFreeProducts']) && $this->submittedValues['vatFreeProducts'] == PluginConfig::VatFreeProducts_Only) {
$this->errorMessages['foreignVatClasses'] = $this->t('message_validate_vat_free_products_1');
}
}
// Check the marginProducts setting in combination with other settings.
// NOTE: it is debatable whether margin articles can be services, e.g.
// selling 2nd hand software licenses. However it is not debatable that
// margin goods can never be digital services. So the 1st validation is
// debatable and my be removed in the future, the 2nd isn't.
if (isset($this->submittedValues['nature_shop']) && isset($this->submittedValues['marginProducts'])) {
// If we only sell articles with nature Services, we cannot (also)
// sell margin goods.
if ($this->submittedValues['nature_shop'] == PluginConfig::Nature_Services && $this->submittedValues['marginProducts'] != PluginConfig::MarginProducts_No) {
$this->errorMessages['conflicting_options_1'] = $this->t('message_validate_conflicting_shop_options_2');
}
// If we only sell margin goods, the nature of all we sell is Products.
if ($this->submittedValues['marginProducts'] == PluginConfig::MarginProducts_Only && $this->submittedValues['nature_shop'] != PluginConfig::Nature_Products) {
$this->errorMessages['nature_shop_1'] = $this->t('message_validate_conflicting_shop_options_3');
}
}
} | [
"protected",
"function",
"validateShopFields",
"(",
")",
"{",
"// Check if this fieldset was rendered.",
"if",
"(",
"!",
"$",
"this",
"->",
"isKey",
"(",
"'nature_shop'",
")",
")",
"{",
"return",
";",
"}",
"// Check that required fields are filled.",
"if",
"(",
"!",... | Validates fields in the shop settings fieldset. | [
"Validates",
"fields",
"in",
"the",
"shop",
"settings",
"fieldset",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L82-L133 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getAccountFields | protected function getAccountFields()
{
return array(
Tag::ContractCode => array(
'type' => 'text',
'label' => $this->t('field_code'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::UserName => array(
'type' => 'text',
'label' => $this->t('field_username'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::Password => array(
'type' => 'password',
'label' => $this->t('field_password'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::EmailOnError => array(
'type' => 'email',
'label' => $this->t('field_emailonerror'),
'description' => $this->t('desc_emailonerror'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
);
} | php | protected function getAccountFields()
{
return array(
Tag::ContractCode => array(
'type' => 'text',
'label' => $this->t('field_code'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::UserName => array(
'type' => 'text',
'label' => $this->t('field_username'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::Password => array(
'type' => 'password',
'label' => $this->t('field_password'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
Tag::EmailOnError => array(
'type' => 'email',
'label' => $this->t('field_emailonerror'),
'description' => $this->t('desc_emailonerror'),
'attributes' => array(
'required' => true,
'size' => 20,
),
),
);
} | [
"protected",
"function",
"getAccountFields",
"(",
")",
"{",
"return",
"array",
"(",
"Tag",
"::",
"ContractCode",
"=>",
"array",
"(",
"'type'",
"=>",
"'text'",
",",
"'label'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'field_code'",
")",
",",
"'attributes'",
"=>"... | Returns the set of account related fields.
The fields returned:
- contractcode
- username
- password
- emailonerror
@return array[]
The set of account related fields. | [
"Returns",
"the",
"set",
"of",
"account",
"related",
"fields",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L237-L274 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getTriggerFields | protected function getTriggerFields()
{
$orderStatusesList = $this->getOrderStatusesList();
$fields = array(
'triggerOrderStatus' => array(
'name' => 'triggerOrderStatus[]',
'type' => 'select',
'label' => $this->t('field_triggerOrderStatus'),
'description' => $this->t('desc_triggerOrderStatus'),
'options' => $orderStatusesList,
'attributes' => array(
'multiple' => true,
'size' => min(count($orderStatusesList), 8),
),
),
'triggerInvoiceEvent' => $this->getOptionsOrHiddenField('triggerInvoiceEvent', 'radio', false),
'triggerCreditNoteEvent' => $this->getOptionsOrHiddenField('triggerCreditNoteEvent', 'radio', false),
);
return $fields;
} | php | protected function getTriggerFields()
{
$orderStatusesList = $this->getOrderStatusesList();
$fields = array(
'triggerOrderStatus' => array(
'name' => 'triggerOrderStatus[]',
'type' => 'select',
'label' => $this->t('field_triggerOrderStatus'),
'description' => $this->t('desc_triggerOrderStatus'),
'options' => $orderStatusesList,
'attributes' => array(
'multiple' => true,
'size' => min(count($orderStatusesList), 8),
),
),
'triggerInvoiceEvent' => $this->getOptionsOrHiddenField('triggerInvoiceEvent', 'radio', false),
'triggerCreditNoteEvent' => $this->getOptionsOrHiddenField('triggerCreditNoteEvent', 'radio', false),
);
return $fields;
} | [
"protected",
"function",
"getTriggerFields",
"(",
")",
"{",
"$",
"orderStatusesList",
"=",
"$",
"this",
"->",
"getOrderStatusesList",
"(",
")",
";",
"$",
"fields",
"=",
"array",
"(",
"'triggerOrderStatus'",
"=>",
"array",
"(",
"'name'",
"=>",
"'triggerOrderStatu... | Returns the set of trigger related fields.
The fields returned:
- triggerOrderStatus
- triggerInvoiceEvent
@return array[]
The set of trigger related fields. | [
"Returns",
"the",
"set",
"of",
"trigger",
"related",
"fields",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L354-L373 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getPluginFields | protected function getPluginFields()
{
return array(
'debug' => array(
'type' => 'radio',
'label' => $this->t('field_debug'),
'description' => $this->t('desc_debug'),
'options' => array(
PluginConfig::Send_SendAndMailOnError => $this->t('option_debug_1'),
PluginConfig::Send_SendAndMail => $this->t('option_debug_2'),
PluginConfig::Send_TestMode => $this->t('option_debug_3'),
),
'attributes' => array(
'required' => true,
),
),
'logLevel' => array(
'type' => 'radio',
'label' => $this->t('field_logLevel'),
'description' => $this->t('desc_logLevel'),
'options' => array(
Log::Notice => $this->t('option_logLevel_3'),
Log::Info => $this->t('option_logLevel_4'),
Log::Debug => $this->t('option_logLevel_5'),
),
'attributes' => array(
'required' => true,
),
),
);
} | php | protected function getPluginFields()
{
return array(
'debug' => array(
'type' => 'radio',
'label' => $this->t('field_debug'),
'description' => $this->t('desc_debug'),
'options' => array(
PluginConfig::Send_SendAndMailOnError => $this->t('option_debug_1'),
PluginConfig::Send_SendAndMail => $this->t('option_debug_2'),
PluginConfig::Send_TestMode => $this->t('option_debug_3'),
),
'attributes' => array(
'required' => true,
),
),
'logLevel' => array(
'type' => 'radio',
'label' => $this->t('field_logLevel'),
'description' => $this->t('desc_logLevel'),
'options' => array(
Log::Notice => $this->t('option_logLevel_3'),
Log::Info => $this->t('option_logLevel_4'),
Log::Debug => $this->t('option_logLevel_5'),
),
'attributes' => array(
'required' => true,
),
),
);
} | [
"protected",
"function",
"getPluginFields",
"(",
")",
"{",
"return",
"array",
"(",
"'debug'",
"=>",
"array",
"(",
"'type'",
"=>",
"'radio'",
",",
"'label'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'field_debug'",
")",
",",
"'description'",
"=>",
"$",
"this",
... | Returns the set of plugin related fields.
The fields returned:
- debug
- logLevel
- versionInformation
- versionInformationDesc
@return array[]
The set of plugin related fields. | [
"Returns",
"the",
"set",
"of",
"plugin",
"related",
"fields",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L439-L469 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getPaymentMethodsFieldset | protected function getPaymentMethodsFieldset(array $paymentMethods, $key, array $options)
{
$fieldset = array(
'type' => 'fieldset',
'legend' => $this->t("{$key}Fieldset"),
'description' => $this->t("desc_{$key}Fieldset"),
'fields' => array(),
);
$options[0] = $this->t('option_use_default');
foreach ($paymentMethods as $paymentMethodId => $paymentMethodLabel) {
$fieldset['fields']["{$key}[{$paymentMethodId}]"] = array(
'type' => 'select',
'label' => $paymentMethodLabel,
'options' => $options,
);
}
return $fieldset;
} | php | protected function getPaymentMethodsFieldset(array $paymentMethods, $key, array $options)
{
$fieldset = array(
'type' => 'fieldset',
'legend' => $this->t("{$key}Fieldset"),
'description' => $this->t("desc_{$key}Fieldset"),
'fields' => array(),
);
$options[0] = $this->t('option_use_default');
foreach ($paymentMethods as $paymentMethodId => $paymentMethodLabel) {
$fieldset['fields']["{$key}[{$paymentMethodId}]"] = array(
'type' => 'select',
'label' => $paymentMethodLabel,
'options' => $options,
);
}
return $fieldset;
} | [
"protected",
"function",
"getPaymentMethodsFieldset",
"(",
"array",
"$",
"paymentMethods",
",",
"$",
"key",
",",
"array",
"$",
"options",
")",
"{",
"$",
"fieldset",
"=",
"array",
"(",
"'type'",
"=>",
"'fieldset'",
",",
"'legend'",
"=>",
"$",
"this",
"->",
... | Returns a fieldset with a select per payment method.
@param array $paymentMethods
Array of payment methods (id => label)
@param string $key
Prefix of the keys to use for the different ids.
@param array $options
Options for all the selects.
@return array
The fieldset definition. | [
"Returns",
"a",
"fieldset",
"with",
"a",
"select",
"per",
"payment",
"method",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L508-L526 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getNatureOptions | protected function getNatureOptions()
{
return array(
PluginConfig::Nature_Both => $this->t('option_nature_1'),
PluginConfig::Nature_Products => $this->t('option_nature_2'),
PluginConfig::Nature_Services => $this->t('option_nature_3'),
);
} | php | protected function getNatureOptions()
{
return array(
PluginConfig::Nature_Both => $this->t('option_nature_1'),
PluginConfig::Nature_Products => $this->t('option_nature_2'),
PluginConfig::Nature_Services => $this->t('option_nature_3'),
);
} | [
"protected",
"function",
"getNatureOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"Nature_Both",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_nature_1'",
")",
",",
"PluginConfig",
"::",
"Nature_Products",
"=>",
"$",
"this",
"->",
"t",
... | Returns a list of options for the nature field.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"options",
"for",
"the",
"nature",
"field",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L547-L554 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getForeignVatOptions | protected function getForeignVatOptions()
{
return array(
PluginConfig::ForeignVat_Both => $this->t('option_foreignVat_1'),
PluginConfig::ForeignVat_No => $this->t('option_foreignVat_2'),
PluginConfig::ForeignVat_Only => $this->t('option_foreignVat_3'),
);
} | php | protected function getForeignVatOptions()
{
return array(
PluginConfig::ForeignVat_Both => $this->t('option_foreignVat_1'),
PluginConfig::ForeignVat_No => $this->t('option_foreignVat_2'),
PluginConfig::ForeignVat_Only => $this->t('option_foreignVat_3'),
);
} | [
"protected",
"function",
"getForeignVatOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"ForeignVat_Both",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_foreignVat_1'",
")",
",",
"PluginConfig",
"::",
"ForeignVat_No",
"=>",
"$",
"this",
"->",... | Returns a list of options for the foreign vat field.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"options",
"for",
"the",
"foreign",
"vat",
"field",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L563-L570 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getVatFreeProductsOptions | protected function getVatFreeProductsOptions()
{
return array(
PluginConfig::VatFreeProducts_Both => $this->t('option_vatFreeProducts_1'),
PluginConfig::VatFreeProducts_No => $this->t('option_vatFreeProducts_2'),
PluginConfig::VatFreeProducts_Only => $this->t('option_vatFreeProducts_3'),
);
} | php | protected function getVatFreeProductsOptions()
{
return array(
PluginConfig::VatFreeProducts_Both => $this->t('option_vatFreeProducts_1'),
PluginConfig::VatFreeProducts_No => $this->t('option_vatFreeProducts_2'),
PluginConfig::VatFreeProducts_Only => $this->t('option_vatFreeProducts_3'),
);
} | [
"protected",
"function",
"getVatFreeProductsOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"VatFreeProducts_Both",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_vatFreeProducts_1'",
")",
",",
"PluginConfig",
"::",
"VatFreeProducts_No",
"=>",
"$... | Returns a list of options for the vat free products field.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"options",
"for",
"the",
"vat",
"free",
"products",
"field",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L579-L586 | train |
SIELOnline/libAcumulus | src/Shop/ConfigForm.php | ConfigForm.getMarginProductsOptions | protected function getMarginProductsOptions()
{
return array(
PluginConfig::MarginProducts_Both => $this->t('option_marginProducts_1'),
PluginConfig::MarginProducts_No => $this->t('option_marginProducts_2'),
PluginConfig::MarginProducts_Only => $this->t('option_marginProducts_3'),
);
} | php | protected function getMarginProductsOptions()
{
return array(
PluginConfig::MarginProducts_Both => $this->t('option_marginProducts_1'),
PluginConfig::MarginProducts_No => $this->t('option_marginProducts_2'),
PluginConfig::MarginProducts_Only => $this->t('option_marginProducts_3'),
);
} | [
"protected",
"function",
"getMarginProductsOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"MarginProducts_Both",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_marginProducts_1'",
")",
",",
"PluginConfig",
"::",
"MarginProducts_No",
"=>",
"$",
... | Returns a list of options for the margin products field.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"options",
"for",
"the",
"margin",
"products",
"field",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/ConfigForm.php#L595-L602 | train |
ems-project/EMSCommonBundle | Storage/Service/AbstractUrlStorage.php | AbstractUrlStorage.getPath | protected function getPath(string $hash, ?string $cacheContext = null, bool $confirmed = true, string $ds = '/'): string
{
$folderName = $this->getBaseUrl();
if (!$confirmed) {
$folderName .= $ds . 'uploads';
}
//isolate cached files
if ($cacheContext) {
$folderName .= $ds . 'cache' . $ds . $cacheContext;
}
//in order to avoid a folder with a to big number of files in
if ($confirmed) {
$folderName .= $ds . substr($hash, 0, 3);
}
//create folder if missing
if (!file_exists($folderName)) {
mkdir($folderName, 0777, true);
}
return $folderName . $ds . $hash;
} | php | protected function getPath(string $hash, ?string $cacheContext = null, bool $confirmed = true, string $ds = '/'): string
{
$folderName = $this->getBaseUrl();
if (!$confirmed) {
$folderName .= $ds . 'uploads';
}
//isolate cached files
if ($cacheContext) {
$folderName .= $ds . 'cache' . $ds . $cacheContext;
}
//in order to avoid a folder with a to big number of files in
if ($confirmed) {
$folderName .= $ds . substr($hash, 0, 3);
}
//create folder if missing
if (!file_exists($folderName)) {
mkdir($folderName, 0777, true);
}
return $folderName . $ds . $hash;
} | [
"protected",
"function",
"getPath",
"(",
"string",
"$",
"hash",
",",
"?",
"string",
"$",
"cacheContext",
"=",
"null",
",",
"bool",
"$",
"confirmed",
"=",
"true",
",",
"string",
"$",
"ds",
"=",
"'/'",
")",
":",
"string",
"{",
"$",
"folderName",
"=",
"... | returns the a file path or a resource url that can be handled by file function such as fopen | [
"returns",
"the",
"a",
"file",
"path",
"or",
"a",
"resource",
"url",
"that",
"can",
"be",
"handled",
"by",
"file",
"function",
"such",
"as",
"fopen"
] | 994fce2f727ebf702d327ba4cfce53d3c75bcef5 | https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Storage/Service/AbstractUrlStorage.php#L20-L44 | train |
SIELOnline/libAcumulus | src/Shop/AcumulusEntryManager.php | AcumulusEntryManager.convertDbResultToAcumulusEntries | protected function convertDbResultToAcumulusEntries($result, $ignoreLock = true)
{
if (empty($result)) {
$result = null;
} elseif (is_object($result)) {
$result = $this->container->getAcumulusEntry($result);
if ($ignoreLock && $result->isSendLock()) {
$result = null;
}
} else {
// It's a non empty array of results.
foreach ($result as &$record) {
$record = $this->container->getAcumulusEntry($record);
if ($ignoreLock && $record->isSendLock()) {
$record = null;
}
}
array_filter($result);
if (empty($result)) {
$result = null;
} elseif (count($result) === 1) {
$result = reset($result);
}
}
return $result;
} | php | protected function convertDbResultToAcumulusEntries($result, $ignoreLock = true)
{
if (empty($result)) {
$result = null;
} elseif (is_object($result)) {
$result = $this->container->getAcumulusEntry($result);
if ($ignoreLock && $result->isSendLock()) {
$result = null;
}
} else {
// It's a non empty array of results.
foreach ($result as &$record) {
$record = $this->container->getAcumulusEntry($record);
if ($ignoreLock && $record->isSendLock()) {
$record = null;
}
}
array_filter($result);
if (empty($result)) {
$result = null;
} elseif (count($result) === 1) {
$result = reset($result);
}
}
return $result;
} | [
"protected",
"function",
"convertDbResultToAcumulusEntries",
"(",
"$",
"result",
",",
"$",
"ignoreLock",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"null",
";",
"}",
"elseif",
"(",
"is_object",
"(",
... | Converts the results of a DB query to AcumulusEntries.
@param object|array[]|object[] $result
The DB query result.
@param bool $ignoreLock
Whether to return an entry that serves as a send lock (false) or ignore
it (true)
@return \Siel\Acumulus\Shop\AcumulusEntry|\Siel\Acumulus\Shop\AcumulusEntry[]|null | [
"Converts",
"the",
"results",
"of",
"a",
"DB",
"query",
"to",
"AcumulusEntries",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntryManager.php#L78-L103 | train |
SIELOnline/libAcumulus | src/Shop/AcumulusEntryManager.php | AcumulusEntryManager.lockForSending | public function lockForSending(Source $invoiceSource)
{
return $this->insert($invoiceSource, AcumulusEntry::lockEntryId, AcumulusEntry::lockToken, $this->sqlNow());
} | php | public function lockForSending(Source $invoiceSource)
{
return $this->insert($invoiceSource, AcumulusEntry::lockEntryId, AcumulusEntry::lockToken, $this->sqlNow());
} | [
"public",
"function",
"lockForSending",
"(",
"Source",
"$",
"invoiceSource",
")",
"{",
"return",
"$",
"this",
"->",
"insert",
"(",
"$",
"invoiceSource",
",",
"AcumulusEntry",
"::",
"lockEntryId",
",",
"AcumulusEntry",
"::",
"lockToken",
",",
"$",
"this",
"->",... | Locks an invoice source for sending twice.
To prevent two processes or threads to send an invoice twice, the sending
process sets a lock on the invoiceSource by already creating an
AcumulusEntry for it before starting to send. That record will contain
some special values by which it can be recognised as a lock instead of as
a reference to a real entry in Acumulus.
@param \Siel\Acumulus\Invoice\Source $invoiceSource
The invoice source to set and acquire a lock on.
@return bool
Whether the lock was successfully acquired. | [
"Locks",
"an",
"invoice",
"source",
"for",
"sending",
"twice",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntryManager.php#L120-L123 | train |
SIELOnline/libAcumulus | src/Shop/AcumulusEntryManager.php | AcumulusEntryManager.deleteLock | public function deleteLock(Source $invoiceSource)
{
$entry = $this->getByInvoiceSource($invoiceSource, false);
if ($entry === null) {
// - The process that had the lock may have failed sending the
// invoice to Acumulus and has removed the lock (e.g. a connection
// timeout, with the timeout being longer than our lock expiry).
// - Yet another process already cleared the lock.
return AcumulusEntry::Lock_NoLongerExists;
}
if ($entry->isSendLock()) {
// The lock is still there: remove it.
$this->delete($entry);
return AcumulusEntry::Lock_Deleted;
}
// The AcumulusEntry became a real entry: apparently the process that
// had the lock, successfully finished sending the invoice after all.
return AcumulusEntry::Lock_BecameRealEntry;
} | php | public function deleteLock(Source $invoiceSource)
{
$entry = $this->getByInvoiceSource($invoiceSource, false);
if ($entry === null) {
// - The process that had the lock may have failed sending the
// invoice to Acumulus and has removed the lock (e.g. a connection
// timeout, with the timeout being longer than our lock expiry).
// - Yet another process already cleared the lock.
return AcumulusEntry::Lock_NoLongerExists;
}
if ($entry->isSendLock()) {
// The lock is still there: remove it.
$this->delete($entry);
return AcumulusEntry::Lock_Deleted;
}
// The AcumulusEntry became a real entry: apparently the process that
// had the lock, successfully finished sending the invoice after all.
return AcumulusEntry::Lock_BecameRealEntry;
} | [
"public",
"function",
"deleteLock",
"(",
"Source",
"$",
"invoiceSource",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"getByInvoiceSource",
"(",
"$",
"invoiceSource",
",",
"false",
")",
";",
"if",
"(",
"$",
"entry",
"===",
"null",
")",
"{",
"// - The ... | Deletes the lock for sending on the given invoice source.
@param Source $invoiceSource
The invoice source to delete the lock for.
@return int
One of the AcumulusEntry::Lock_... constants describing the status of
the lock. | [
"Deletes",
"the",
"lock",
"for",
"sending",
"on",
"the",
"given",
"invoice",
"source",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntryManager.php#L135-L153 | train |
SIELOnline/libAcumulus | src/Shop/AcumulusEntryManager.php | AcumulusEntryManager.save | public function save(Source $invoiceSource, $entryId, $token)
{
$now = $this->sqlNow();
$record = $this->getByInvoiceSource($invoiceSource, false);
if ($record === null) {
$result = $this->insert($invoiceSource, $entryId, $token, $now);
} else {
$result = $this->update($record, $entryId, $token, $now);
}
return $result;
} | php | public function save(Source $invoiceSource, $entryId, $token)
{
$now = $this->sqlNow();
$record = $this->getByInvoiceSource($invoiceSource, false);
if ($record === null) {
$result = $this->insert($invoiceSource, $entryId, $token, $now);
} else {
$result = $this->update($record, $entryId, $token, $now);
}
return $result;
} | [
"public",
"function",
"save",
"(",
"Source",
"$",
"invoiceSource",
",",
"$",
"entryId",
",",
"$",
"token",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"sqlNow",
"(",
")",
";",
"$",
"record",
"=",
"$",
"this",
"->",
"getByInvoiceSource",
"(",
"$",
... | Saves the Acumulus entry for the given order in the web shop's database.
This default implementation calls getByInvoiceSource() to determine
whether to subsequently call insert() or update().
So normally, a child class should implement insert() and update() and not
override this method.
@param \Siel\Acumulus\Invoice\Source $invoiceSource
The source object for which the invoice was created.
@param int|null $entryId
The Acumulus entry Id assigned to the invoice for this order.
@param string|null $token
The Acumulus token to be used to access the invoice for this order via
the Acumulus API.
@return bool
Success. | [
"Saves",
"the",
"Acumulus",
"entry",
"for",
"the",
"given",
"order",
"in",
"the",
"web",
"shop",
"s",
"database",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntryManager.php#L175-L185 | train |
SIELOnline/libAcumulus | src/Shop/AcumulusEntryManager.php | AcumulusEntryManager.deleteByEntryId | public function deleteByEntryId($entryId)
{
$entryId = (int) $entryId;
if ($entryId >= 2) {
$entry = $this->getByEntryId($entryId);
if ($entry instanceof AcumulusEntry) {
return $this->delete($entry);
}
}
return true;
} | php | public function deleteByEntryId($entryId)
{
$entryId = (int) $entryId;
if ($entryId >= 2) {
$entry = $this->getByEntryId($entryId);
if ($entry instanceof AcumulusEntry) {
return $this->delete($entry);
}
}
return true;
} | [
"public",
"function",
"deleteByEntryId",
"(",
"$",
"entryId",
")",
"{",
"$",
"entryId",
"=",
"(",
"int",
")",
"$",
"entryId",
";",
"if",
"(",
"$",
"entryId",
">=",
"2",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"getByEntryId",
"(",
"$",
"entr... | Deletes the Acumulus entry for the given entry id.
@param int $entryId
The Acumulus entry id to delete.
@return bool
Success. | [
"Deletes",
"the",
"Acumulus",
"entry",
"for",
"the",
"given",
"entry",
"id",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntryManager.php#L241-L251 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.mergeProductLines | public function mergeProductLines(array $productLines, array $taxLines)
{
$result = array();
// Key the product lines on id_order_detail, so we can easily add the
// tax lines in the 2nd loop.
foreach ($productLines as $productLine) {
$result[$productLine['id_order_detail']] = $productLine;
}
// Add the tax lines without overwriting existing entries (though in a
// consistent db the same keys should contain the same values).
foreach ($taxLines as $taxLine) {
$result[$taxLine['id_order_detail']] += $taxLine;
}
return $result;
} | php | public function mergeProductLines(array $productLines, array $taxLines)
{
$result = array();
// Key the product lines on id_order_detail, so we can easily add the
// tax lines in the 2nd loop.
foreach ($productLines as $productLine) {
$result[$productLine['id_order_detail']] = $productLine;
}
// Add the tax lines without overwriting existing entries (though in a
// consistent db the same keys should contain the same values).
foreach ($taxLines as $taxLine) {
$result[$taxLine['id_order_detail']] += $taxLine;
}
return $result;
} | [
"public",
"function",
"mergeProductLines",
"(",
"array",
"$",
"productLines",
",",
"array",
"$",
"taxLines",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// Key the product lines on id_order_detail, so we can easily add the",
"// tax lines in the 2nd loop.",
"fo... | Merges the product and tax details arrays.
@param array $productLines
@param array $taxLines
@return array | [
"Merges",
"the",
"product",
"and",
"tax",
"details",
"arrays",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L124-L138 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.getItemLine | protected function getItemLine(array $item)
{
$result = array();
$this->addPropertySource('item', $item);
$this->addProductInfo($result);
$sign = $this->invoiceSource->getSign();
// Check for cost price and margin scheme.
if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
// Margin scheme:
// - Do not put VAT on invoice: send price incl VAT as unitprice.
// - But still send the VAT rate to Acumulus.
$result[Tag::UnitPrice] = $sign * $item['unit_price_tax_incl'];
} else {
$result[Tag::UnitPrice] = $sign * $item['unit_price_tax_excl'];
$result[Meta::UnitPriceInc] = $sign * $item['unit_price_tax_incl'];
$result[Meta::LineAmount] = $sign * $item['total_price_tax_excl'];
$result[Meta::LineAmountInc] = $sign * $item['total_price_tax_incl'];
if (!Number::floatsAreEqual($item['unit_amount'], $result[Meta::UnitPriceInc] - $result[Tag::UnitPrice])) {
$result[Meta::LineDiscountVatAmount] = $item['unit_amount'] - ($result[Meta::UnitPriceInc] - $result[Tag::UnitPrice]);
}
}
$result[Tag::Quantity] = $item['product_quantity'];
// Get vat rate:
// The field 'rate' comes from order->getOrderDetailTaxes() and is only
// defined for orders and was not filled in before PS1.6.1.1. So, check
// if the field is available.
// The fields 'unit_amount' and 'total_amount' (table order_detail_tax)
// are based on the discounted product price and thus cannot be used to
// get the vat rate.
if (isset($item['rate'])) {
$result[Tag::VatRate] = $item['rate'];
$result[Meta::VatRateSource] = Creator::VatRateSource_Exact;
} else {
// Precision: 1 of the amounts, probably the prince incl tax, is
// entered by the admin and can thus be considered exact. The other
// is calculated by the system and not rounded and can thus be
// considered to have a precision better than 0.0001
$result += $this->getVatRangeTags($sign * ($item['unit_price_tax_incl'] - $item['unit_price_tax_excl']),
$sign * $item['unit_price_tax_excl'],
$this->precision, $this->precision);
}
$result += $this->getVatRateLookupMetadata($this->order->id_address_invoice, $this->getItemLineTaxRuleGroupId($item));
$result[Meta::FieldsCalculated][] = Meta::VatAmount;
$this->removePropertySource('item');
return $result;
} | php | protected function getItemLine(array $item)
{
$result = array();
$this->addPropertySource('item', $item);
$this->addProductInfo($result);
$sign = $this->invoiceSource->getSign();
// Check for cost price and margin scheme.
if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
// Margin scheme:
// - Do not put VAT on invoice: send price incl VAT as unitprice.
// - But still send the VAT rate to Acumulus.
$result[Tag::UnitPrice] = $sign * $item['unit_price_tax_incl'];
} else {
$result[Tag::UnitPrice] = $sign * $item['unit_price_tax_excl'];
$result[Meta::UnitPriceInc] = $sign * $item['unit_price_tax_incl'];
$result[Meta::LineAmount] = $sign * $item['total_price_tax_excl'];
$result[Meta::LineAmountInc] = $sign * $item['total_price_tax_incl'];
if (!Number::floatsAreEqual($item['unit_amount'], $result[Meta::UnitPriceInc] - $result[Tag::UnitPrice])) {
$result[Meta::LineDiscountVatAmount] = $item['unit_amount'] - ($result[Meta::UnitPriceInc] - $result[Tag::UnitPrice]);
}
}
$result[Tag::Quantity] = $item['product_quantity'];
// Get vat rate:
// The field 'rate' comes from order->getOrderDetailTaxes() and is only
// defined for orders and was not filled in before PS1.6.1.1. So, check
// if the field is available.
// The fields 'unit_amount' and 'total_amount' (table order_detail_tax)
// are based on the discounted product price and thus cannot be used to
// get the vat rate.
if (isset($item['rate'])) {
$result[Tag::VatRate] = $item['rate'];
$result[Meta::VatRateSource] = Creator::VatRateSource_Exact;
} else {
// Precision: 1 of the amounts, probably the prince incl tax, is
// entered by the admin and can thus be considered exact. The other
// is calculated by the system and not rounded and can thus be
// considered to have a precision better than 0.0001
$result += $this->getVatRangeTags($sign * ($item['unit_price_tax_incl'] - $item['unit_price_tax_excl']),
$sign * $item['unit_price_tax_excl'],
$this->precision, $this->precision);
}
$result += $this->getVatRateLookupMetadata($this->order->id_address_invoice, $this->getItemLineTaxRuleGroupId($item));
$result[Meta::FieldsCalculated][] = Meta::VatAmount;
$this->removePropertySource('item');
return $result;
} | [
"protected",
"function",
"getItemLine",
"(",
"array",
"$",
"item",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"addPropertySource",
"(",
"'item'",
",",
"$",
"item",
")",
";",
"$",
"this",
"->",
"addProductInfo",
"(",
"$",
... | Returns 1 item line, both for an order or credit slip.
@param array $item
An array of an OrderDetail line combined with a tax detail line OR
an array with an OrderSlipDetail line.
@return array
@throws \PrestaShopDatabaseException | [
"Returns",
"1",
"item",
"line",
"both",
"for",
"an",
"order",
"or",
"credit",
"slip",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L150-L201 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.getItemLineTaxRuleGroupId | protected function getItemLineTaxRuleGroupId(array $item)
{
if (isset($item['id_tax_rules_group'])) {
return (int) $item['id_tax_rules_group'];
} elseif (isset($item['id_tax'])) {
$query = 'select distinct id_tax_rules_group from ps_tax_rule where id_tax = ' . (int) $item['id_tax'];
$results = Db::getInstance()->executeS($query);
return count($results) === 1 ? (int) $results[0]['id_tax_rules_group'] : 0;
}
return 0;
} | php | protected function getItemLineTaxRuleGroupId(array $item)
{
if (isset($item['id_tax_rules_group'])) {
return (int) $item['id_tax_rules_group'];
} elseif (isset($item['id_tax'])) {
$query = 'select distinct id_tax_rules_group from ps_tax_rule where id_tax = ' . (int) $item['id_tax'];
$results = Db::getInstance()->executeS($query);
return count($results) === 1 ? (int) $results[0]['id_tax_rules_group'] : 0;
}
return 0;
} | [
"protected",
"function",
"getItemLineTaxRuleGroupId",
"(",
"array",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'id_tax_rules_group'",
"]",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"item",
"[",
"'id_tax_rules_group'",
"]",
";",... | Returns the tax rule group id of the product in the given order line.
@param array $item
@return int
The id of the tax rule group, or 0 if none or multiple were found.
@throws \PrestaShopDatabaseException | [
"Returns",
"the",
"tax",
"rule",
"group",
"id",
"of",
"the",
"product",
"in",
"the",
"given",
"order",
"line",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L213-L223 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.getDiscountLinesOrder | protected function getDiscountLinesOrder()
{
$result = array();
foreach ($this->order->getCartRules() as $line) {
$result[] = $this->getDiscountLineOrder($line);
}
return $result;
} | php | protected function getDiscountLinesOrder()
{
$result = array();
foreach ($this->order->getCartRules() as $line) {
$result[] = $this->getDiscountLineOrder($line);
}
return $result;
} | [
"protected",
"function",
"getDiscountLinesOrder",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"order",
"->",
"getCartRules",
"(",
")",
"as",
"$",
"line",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
... | In a Prestashop order the discount lines are specified in Order cart
rules.
@return array[] | [
"In",
"a",
"Prestashop",
"order",
"the",
"discount",
"lines",
"are",
"specified",
"in",
"Order",
"cart",
"rules",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L364-L373 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.getDiscountLinesCreditNote | protected function getDiscountLinesCreditNote()
{
$result = array();
// Get total amount credited.
/** @noinspection PhpUndefinedFieldInspection */
$creditSlipAmountInc = $this->creditSlip->total_products_tax_incl;
// Get sum of product lines.
$lines = $this->creditSlip->getOrdersSlipProducts($this->invoiceSource->getId(), $this->order);
$detailsAmountInc = array_reduce($lines, function ($sum, $item) {
$sum += $item['total_price_tax_incl'];
return $sum;
}, 0.0);
// We assume that if total < sum(details), a discount given on the
// original order has now been subtracted from the amount credited.
if (!Number::floatsAreEqual($creditSlipAmountInc, $detailsAmountInc, 0.05)
&& $creditSlipAmountInc < $detailsAmountInc
) {
// PS Error: total_products_tax_excl is not adjusted (whereas
// total_products_tax_incl is) when a discount is subtracted from
// the amount to be credited.
// So we cannot calculate the discount ex VAT ourselves.
// What we can try is the following: Get the order cart rules to see
// if 1 or all of those match the discount amount here.
$discountAmountInc = $detailsAmountInc - $creditSlipAmountInc;
$totalOrderDiscountInc = 0.0;
// Note: The sign of the entries in $orderDiscounts will be correct.
$orderDiscounts = $this->getDiscountLinesOrder();
foreach ($orderDiscounts as $key => $orderDiscount) {
if (Number::floatsAreEqual($orderDiscount[Meta::UnitPriceInc], $discountAmountInc)) {
// Return this single line.
$from = $to = $key;
break;
}
$totalOrderDiscountInc += $orderDiscount[Meta::UnitPriceInc];
if (Number::floatsAreEqual($totalOrderDiscountInc, $discountAmountInc)) {
// Return all lines up to here.
$from = 0;
$to = $key;
break;
}
}
if (isset($from) && isset($to)) {
$result = array_slice($orderDiscounts, $from, $to - $from + 1);
// Correct meta-invoice-amount.
$totalOrderDiscountEx = array_reduce($result, function ($sum, $item) {
$sum += $item[Tag::Quantity] * $item[Tag::UnitPrice];
return $sum;
}, 0.0);
$this->invoice[Tag::Customer][Tag::Invoice][Meta::InvoiceAmount] += $totalOrderDiscountEx;
} //else {
// We could not match a discount with the difference between the
// total amount credited and the sum of the products returned. A
// manual line will correct the invoice.
//}
}
return $result;
} | php | protected function getDiscountLinesCreditNote()
{
$result = array();
// Get total amount credited.
/** @noinspection PhpUndefinedFieldInspection */
$creditSlipAmountInc = $this->creditSlip->total_products_tax_incl;
// Get sum of product lines.
$lines = $this->creditSlip->getOrdersSlipProducts($this->invoiceSource->getId(), $this->order);
$detailsAmountInc = array_reduce($lines, function ($sum, $item) {
$sum += $item['total_price_tax_incl'];
return $sum;
}, 0.0);
// We assume that if total < sum(details), a discount given on the
// original order has now been subtracted from the amount credited.
if (!Number::floatsAreEqual($creditSlipAmountInc, $detailsAmountInc, 0.05)
&& $creditSlipAmountInc < $detailsAmountInc
) {
// PS Error: total_products_tax_excl is not adjusted (whereas
// total_products_tax_incl is) when a discount is subtracted from
// the amount to be credited.
// So we cannot calculate the discount ex VAT ourselves.
// What we can try is the following: Get the order cart rules to see
// if 1 or all of those match the discount amount here.
$discountAmountInc = $detailsAmountInc - $creditSlipAmountInc;
$totalOrderDiscountInc = 0.0;
// Note: The sign of the entries in $orderDiscounts will be correct.
$orderDiscounts = $this->getDiscountLinesOrder();
foreach ($orderDiscounts as $key => $orderDiscount) {
if (Number::floatsAreEqual($orderDiscount[Meta::UnitPriceInc], $discountAmountInc)) {
// Return this single line.
$from = $to = $key;
break;
}
$totalOrderDiscountInc += $orderDiscount[Meta::UnitPriceInc];
if (Number::floatsAreEqual($totalOrderDiscountInc, $discountAmountInc)) {
// Return all lines up to here.
$from = 0;
$to = $key;
break;
}
}
if (isset($from) && isset($to)) {
$result = array_slice($orderDiscounts, $from, $to - $from + 1);
// Correct meta-invoice-amount.
$totalOrderDiscountEx = array_reduce($result, function ($sum, $item) {
$sum += $item[Tag::Quantity] * $item[Tag::UnitPrice];
return $sum;
}, 0.0);
$this->invoice[Tag::Customer][Tag::Invoice][Meta::InvoiceAmount] += $totalOrderDiscountEx;
} //else {
// We could not match a discount with the difference between the
// total amount credited and the sum of the products returned. A
// manual line will correct the invoice.
//}
}
return $result;
} | [
"protected",
"function",
"getDiscountLinesCreditNote",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// Get total amount credited.",
"/** @noinspection PhpUndefinedFieldInspection */",
"$",
"creditSlipAmountInc",
"=",
"$",
"this",
"->",
"creditSlip",
"->",
... | In a Prestashop credit slip, the discounts are not visible anymore, but
can be computed by looking at the difference between the value of
total_products_tax_incl and the sum of the OrderSlipDetail amounts.
@return array[] | [
"In",
"a",
"Prestashop",
"credit",
"slip",
"the",
"discounts",
"are",
"not",
"visible",
"anymore",
"but",
"can",
"be",
"computed",
"by",
"looking",
"at",
"the",
"difference",
"between",
"the",
"value",
"of",
"total_products_tax_incl",
"and",
"the",
"sum",
"of"... | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L418-L479 | train |
SIELOnline/libAcumulus | src/PrestaShop/Invoice/Creator.php | Creator.getVatRateLookupMetadata | protected function getVatRateLookupMetadata($addressId, $taxRulesGroupId)
{
try {
$taxRulesGroup = new TaxRulesGroup($taxRulesGroupId);
$address = new Address($addressId);
$taxManager = TaxManagerFactory::getManager($address, $taxRulesGroupId);
$taxCalculator = $taxManager->getTaxCalculator();
$result = array(
Meta::VatClassId => $taxRulesGroup->id,
Meta::VatClassName => $taxRulesGroup->name,
Meta::VatRateLookup => $taxCalculator->getTotalRate(),
Meta::VatRateLookupLabel => $taxCalculator->getTaxesName(),
);
} catch (\Exception $e) {
$result = array();
}
return $result;
} | php | protected function getVatRateLookupMetadata($addressId, $taxRulesGroupId)
{
try {
$taxRulesGroup = new TaxRulesGroup($taxRulesGroupId);
$address = new Address($addressId);
$taxManager = TaxManagerFactory::getManager($address, $taxRulesGroupId);
$taxCalculator = $taxManager->getTaxCalculator();
$result = array(
Meta::VatClassId => $taxRulesGroup->id,
Meta::VatClassName => $taxRulesGroup->name,
Meta::VatRateLookup => $taxCalculator->getTotalRate(),
Meta::VatRateLookupLabel => $taxCalculator->getTaxesName(),
);
} catch (\Exception $e) {
$result = array();
}
return $result;
} | [
"protected",
"function",
"getVatRateLookupMetadata",
"(",
"$",
"addressId",
",",
"$",
"taxRulesGroupId",
")",
"{",
"try",
"{",
"$",
"taxRulesGroup",
"=",
"new",
"TaxRulesGroup",
"(",
"$",
"taxRulesGroupId",
")",
";",
"$",
"address",
"=",
"new",
"Address",
"(",... | Looks up and returns vat rate metadata.
@param int $addressId
@param int $taxRulesGroupId
@return array
An empty array or an array with keys:
- Meta::VatClassId: int
- Meta::VatClassName: string
- Meta::VatRateLookup: float
- Meta::VatRateLookupLabel: string | [
"Looks",
"up",
"and",
"returns",
"vat",
"rate",
"metadata",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L495-L512 | train |
SIELOnline/libAcumulus | src/Helpers/Number.php | Number.getDivisionRange | static public function getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision)
{
// The actual value can be half the precision lower or higher.
// To err on the save side, we take 60% of it (instead of 50%).
$numeratorHalfRange = 0.6 * (float) $numeratorPrecision;
$denominatorHalfRange = 0.6 * (float) $denominatorPrecision;
// The min values should be closer to 0 then the value.
// The max values should be further from 0 then the value.
if ($numerator < 0.0) {
$numeratorHalfRange = -$numeratorHalfRange;
}
$minNumerator = (float) $numerator - $numeratorHalfRange;
$maxNumerator = (float) $numerator + $numeratorHalfRange;
if ($denominator < 0.0) {
$denominatorHalfRange = -$denominatorHalfRange;
}
$minDenominator = (float) $denominator - $denominatorHalfRange;
$maxDenominator = (float) $denominator + $denominatorHalfRange;
// We get the min value of the division by dividing the minimum numerator by
// the maximum denominator and vice versa.
$min = $minNumerator / $maxDenominator;
$max = $maxNumerator / $minDenominator;
$calculated = $numerator / $denominator;
return array('min' => $min, 'calculated' => $calculated, 'max' => $max);
} | php | static public function getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision)
{
// The actual value can be half the precision lower or higher.
// To err on the save side, we take 60% of it (instead of 50%).
$numeratorHalfRange = 0.6 * (float) $numeratorPrecision;
$denominatorHalfRange = 0.6 * (float) $denominatorPrecision;
// The min values should be closer to 0 then the value.
// The max values should be further from 0 then the value.
if ($numerator < 0.0) {
$numeratorHalfRange = -$numeratorHalfRange;
}
$minNumerator = (float) $numerator - $numeratorHalfRange;
$maxNumerator = (float) $numerator + $numeratorHalfRange;
if ($denominator < 0.0) {
$denominatorHalfRange = -$denominatorHalfRange;
}
$minDenominator = (float) $denominator - $denominatorHalfRange;
$maxDenominator = (float) $denominator + $denominatorHalfRange;
// We get the min value of the division by dividing the minimum numerator by
// the maximum denominator and vice versa.
$min = $minNumerator / $maxDenominator;
$max = $maxNumerator / $minDenominator;
$calculated = $numerator / $denominator;
return array('min' => $min, 'calculated' => $calculated, 'max' => $max);
} | [
"static",
"public",
"function",
"getDivisionRange",
"(",
"$",
"numerator",
",",
"$",
"denominator",
",",
"$",
"numeratorPrecision",
",",
"$",
"denominatorPrecision",
")",
"{",
"// The actual value can be half the precision lower or higher.",
"// To err on the save side, we take... | Returns the range within which the result of the division should fall given
the precision range for the 2 numbers to divide.
@param float $numerator
@param float $denominator
@param float $numeratorPrecision
The precision used when rounding the number. This means that the
original numerator will not differ more than half of this in any
direction.
@param float $denominatorPrecision
The precision used when rounding the number. This means that the
original denominator will not differ more than half of this in any
direction.
@return array
Array of floats with keys min, max and calculated. | [
"Returns",
"the",
"range",
"within",
"which",
"the",
"result",
"of",
"the",
"division",
"should",
"fall",
"given",
"the",
"precision",
"range",
"for",
"the",
"2",
"numbers",
"to",
"divide",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Number.php#L40-L68 | train |
SIELOnline/libAcumulus | src/Helpers/Number.php | Number.floatsAreEqual | static public function floatsAreEqual($f1, $f2, $maxDiff = 0.005)
{
return abs((float) $f2 - (float) $f1) < $maxDiff;
} | php | static public function floatsAreEqual($f1, $f2, $maxDiff = 0.005)
{
return abs((float) $f2 - (float) $f1) < $maxDiff;
} | [
"static",
"public",
"function",
"floatsAreEqual",
"(",
"$",
"f1",
",",
"$",
"f2",
",",
"$",
"maxDiff",
"=",
"0.005",
")",
"{",
"return",
"abs",
"(",
"(",
"float",
")",
"$",
"f2",
"-",
"(",
"float",
")",
"$",
"f1",
")",
"<",
"$",
"maxDiff",
";",
... | Helper method to do a float comparison.
@param float $f1
@param float $f2
@param float $maxDiff
@return bool
True if the the floats are "equal", i.e. do not differ more than the
specified maximum difference. | [
"Helper",
"method",
"to",
"do",
"a",
"float",
"comparison",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Number.php#L81-L84 | train |
SIELOnline/libAcumulus | src/PrestaShop/Helpers/FormMapper.php | FormMapper.field | protected function field(array $field)
{
if (!empty($field['fields'])) {
$result = $this->fieldset($field);
} else {
$result = $this->element($field);
}
return $result;
} | php | protected function field(array $field)
{
if (!empty($field['fields'])) {
$result = $this->fieldset($field);
} else {
$result = $this->element($field);
}
return $result;
} | [
"protected",
"function",
"field",
"(",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"fieldset",
"(",
"$",
"field",
")",
";",
"}",
"else",
... | Maps a single field definition, possibly a fieldset.
@param array $field
Field(set) definition.
@return array | [
"Maps",
"a",
"single",
"field",
"definition",
"possibly",
"a",
"fieldset",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Helpers/FormMapper.php#L54-L62 | train |
SIELOnline/libAcumulus | src/PrestaShop/Helpers/FormMapper.php | FormMapper.fieldset | protected function fieldset(array $field)
{
$result = array(
'form' => array(
'legend' => array(
'title' => !empty($field['summary']) ? $field['summary'] : $field['legend'],
),
'input' => $this->fields($field['fields']),
),
);
// Add description at the start of the fieldset as an html element.
if (isset($field['description'])) {
array_unshift($result['form']['input'], array('type' => 'html', 'name' => $field['name'] . '_description', 'html_content' => '<div class="help-block">' . $field['description'] . '</div>'));
}
// Add icon to legend.
if (isset($field['icon'])) {
$result['form']['legend']['icon'] = $field['icon'];
}
return $result;
} | php | protected function fieldset(array $field)
{
$result = array(
'form' => array(
'legend' => array(
'title' => !empty($field['summary']) ? $field['summary'] : $field['legend'],
),
'input' => $this->fields($field['fields']),
),
);
// Add description at the start of the fieldset as an html element.
if (isset($field['description'])) {
array_unshift($result['form']['input'], array('type' => 'html', 'name' => $field['name'] . '_description', 'html_content' => '<div class="help-block">' . $field['description'] . '</div>'));
}
// Add icon to legend.
if (isset($field['icon'])) {
$result['form']['legend']['icon'] = $field['icon'];
}
return $result;
} | [
"protected",
"function",
"fieldset",
"(",
"array",
"$",
"field",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'form'",
"=>",
"array",
"(",
"'legend'",
"=>",
"array",
"(",
"'title'",
"=>",
"!",
"empty",
"(",
"$",
"field",
"[",
"'summary'",
"]",
")",
"... | Returns a mapped fieldset.
@param array $field
@return array[] | [
"Returns",
"a",
"mapped",
"fieldset",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Helpers/FormMapper.php#L71-L92 | train |
SIELOnline/libAcumulus | src/PrestaShop/Helpers/FormMapper.php | FormMapper.element | protected function element(array $field)
{
$result = array(
'type' => $this->getPrestaShopType($field['type']),
'label' => isset($field['label']) ? $field['label'] : '',
'name' => $field['name'],
'required' => isset($field['attributes']['required']) ? $field['attributes']['required'] : false,
'multiple' => isset($field['attributes']['multiple']) ? $field['attributes']['multiple'] : false,
);
if (!empty($field['attributes'])) {
$result['attributes'] = $field['attributes'];
}
if (isset($field['description'])) {
$result['desc'] = $field['description'];
}
if ($field['type'] === 'radio') {
$result['values'] = $this->getPrestaShopValues($field['name'], $field['options']);
} elseif ($field['type'] === 'checkbox') {
$result['values'] = $this->getPrestaShopOptions($field['options']);
} elseif ($field['type'] === 'select') {
$result['options'] = $this->getPrestaShopOptions($field['options']);
if ($result['multiple']) {
$result['size'] = $field['attributes']['size'];
}
}
return $result;
} | php | protected function element(array $field)
{
$result = array(
'type' => $this->getPrestaShopType($field['type']),
'label' => isset($field['label']) ? $field['label'] : '',
'name' => $field['name'],
'required' => isset($field['attributes']['required']) ? $field['attributes']['required'] : false,
'multiple' => isset($field['attributes']['multiple']) ? $field['attributes']['multiple'] : false,
);
if (!empty($field['attributes'])) {
$result['attributes'] = $field['attributes'];
}
if (isset($field['description'])) {
$result['desc'] = $field['description'];
}
if ($field['type'] === 'radio') {
$result['values'] = $this->getPrestaShopValues($field['name'], $field['options']);
} elseif ($field['type'] === 'checkbox') {
$result['values'] = $this->getPrestaShopOptions($field['options']);
} elseif ($field['type'] === 'select') {
$result['options'] = $this->getPrestaShopOptions($field['options']);
if ($result['multiple']) {
$result['size'] = $field['attributes']['size'];
}
}
return $result;
} | [
"protected",
"function",
"element",
"(",
"array",
"$",
"field",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"this",
"->",
"getPrestaShopType",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
",",
"'label'",
"=>",
"isset",
"(",
"$",
"... | Returns a mapped simple element.
@param array $field
@return array | [
"Returns",
"a",
"mapped",
"simple",
"element",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Helpers/FormMapper.php#L102-L131 | train |
SIELOnline/libAcumulus | src/Joomla/Helpers/Log.php | Log.getJoomlaSeverity | protected function getJoomlaSeverity($severity)
{
switch ($severity) {
case Log::Error:
return JLog::ERROR;
case Log::Warning:
return JLog::WARNING;
case Log::Notice:
return JLog::NOTICE;
case Log::Info:
return JLog::INFO;
case Log::Debug:
default:
return JLog::DEBUG;
}
} | php | protected function getJoomlaSeverity($severity)
{
switch ($severity) {
case Log::Error:
return JLog::ERROR;
case Log::Warning:
return JLog::WARNING;
case Log::Notice:
return JLog::NOTICE;
case Log::Info:
return JLog::INFO;
case Log::Debug:
default:
return JLog::DEBUG;
}
} | [
"protected",
"function",
"getJoomlaSeverity",
"(",
"$",
"severity",
")",
"{",
"switch",
"(",
"$",
"severity",
")",
"{",
"case",
"Log",
"::",
"Error",
":",
"return",
"JLog",
"::",
"ERROR",
";",
"case",
"Log",
"::",
"Warning",
":",
"return",
"JLog",
"::",
... | Returns the joomla equivalent of the severity.
@param int $severity
One of the constants of the base Log class.
@return int
the Joomla equivalent of the severity. | [
"Returns",
"the",
"joomla",
"equivalent",
"of",
"the",
"severity",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Joomla/Helpers/Log.php#L45-L60 | train |
ipunkt/rancherize | app/Blueprint/Infrastructure/Service/Service.php | Service.addLinksFrom | public function addLinksFrom(Service $service) {
$links = $service->getLinks();
foreach($links as $name => $link) {
if (is_numeric($name)) {
$this->addLink($link);
} else {
$this->addLink($link, $name);
}
}
$externalLinks = $service->getExternalLinks();
foreach($externalLinks as $name => $link) {
if (is_numeric($name)) {
$this->addExternalLink($link);
} else {
$this->addExternalLink($link, $name);
}
}
} | php | public function addLinksFrom(Service $service) {
$links = $service->getLinks();
foreach($links as $name => $link) {
if (is_numeric($name)) {
$this->addLink($link);
} else {
$this->addLink($link, $name);
}
}
$externalLinks = $service->getExternalLinks();
foreach($externalLinks as $name => $link) {
if (is_numeric($name)) {
$this->addExternalLink($link);
} else {
$this->addExternalLink($link, $name);
}
}
} | [
"public",
"function",
"addLinksFrom",
"(",
"Service",
"$",
"service",
")",
"{",
"$",
"links",
"=",
"$",
"service",
"->",
"getLinks",
"(",
")",
";",
"foreach",
"(",
"$",
"links",
"as",
"$",
"name",
"=>",
"$",
"link",
")",
"{",
"if",
"(",
"is_numeric",... | Add internal and external links from other service
@param Service $service | [
"Add",
"internal",
"and",
"external",
"links",
"from",
"other",
"service"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Infrastructure/Service/Service.php#L384-L403 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Base.setupClient | public function setupClient()
{
/* Return if already set */
if ($this->client)
return $this;
/* Set the options for the SOAP request */
$sslContext = array(
'ssl' => array(
'allow_self_signed' => false,
'verify_peer' => false /* Temporary fix */
)
);
$soapArguments = array(
'location' => $this->service,
'encoding' => 'UTF-8',
'cache_wsdl' => 'WSDL_CACHE_NONE',
'stream_context' => stream_context_create($sslContext)
);
/* Start a new client */
$this->client = new SoapClient($this->service, $soapArguments);
/* Client configuration */
$this->client->soap_defencoding = "utf-8";
return $this;
} | php | public function setupClient()
{
/* Return if already set */
if ($this->client)
return $this;
/* Set the options for the SOAP request */
$sslContext = array(
'ssl' => array(
'allow_self_signed' => false,
'verify_peer' => false /* Temporary fix */
)
);
$soapArguments = array(
'location' => $this->service,
'encoding' => 'UTF-8',
'cache_wsdl' => 'WSDL_CACHE_NONE',
'stream_context' => stream_context_create($sslContext)
);
/* Start a new client */
$this->client = new SoapClient($this->service, $soapArguments);
/* Client configuration */
$this->client->soap_defencoding = "utf-8";
return $this;
} | [
"public",
"function",
"setupClient",
"(",
")",
"{",
"/* Return if already set */",
"if",
"(",
"$",
"this",
"->",
"client",
")",
"return",
"$",
"this",
";",
"/* Set the options for the SOAP request */",
"$",
"sslContext",
"=",
"array",
"(",
"'ssl'",
"=>",
"array",
... | Make connection with the soap client
@since 2.1.0
@access public
@return \Icepay_Webservice_Base | [
"Make",
"connection",
"with",
"the",
"soap",
"client"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L169-L197 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Base.arrangeObject | public function arrangeObject($object, $order = array())
{
if (!is_object($object))
throw new Exception("Please provide a valid Object for the arrangeObject method");
if (!is_array($order) || empty($order))
throw new Exception("Please provide a valid orderArray for the arrangeObject method");
$obj = new stdClass();
foreach ($order as $key) {
$obj->$key = $object->$key;
}
return $obj;
} | php | public function arrangeObject($object, $order = array())
{
if (!is_object($object))
throw new Exception("Please provide a valid Object for the arrangeObject method");
if (!is_array($order) || empty($order))
throw new Exception("Please provide a valid orderArray for the arrangeObject method");
$obj = new stdClass();
foreach ($order as $key) {
$obj->$key = $object->$key;
}
return $obj;
} | [
"public",
"function",
"arrangeObject",
"(",
"$",
"object",
",",
"$",
"order",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Please provide a valid Object for the arrangeObject ... | Arrange the object in given order
@since 1.0.2
@access public
@param object $object !required
@param array $order !required
@return object $obj | [
"Arrange",
"the",
"object",
"in",
"given",
"order"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L232-L246 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Base.parseForChecksum | public function parseForChecksum($mainObject, $subObject, $arrange = false, $order = array())
{
if (!is_object($mainObject))
throw new Exception("Please provide a valid Object");
$mainObject = $mainObject;
$i = 1;
$subObject = $this->forceArray($subObject);
foreach ($subObject as $sub) {
// $sub is always an object, just a double-check
if (is_object($sub)) {
if ($arrange) {
// Arrange object in right order
$sub = $this->arrangeObject($sub, $order);
}
// Inject each value of subObject into $obj as property for checksum
foreach ($sub as $value) {
$mainObject->$i = $value;
$i++;
}
}
}
return $mainObject;
} | php | public function parseForChecksum($mainObject, $subObject, $arrange = false, $order = array())
{
if (!is_object($mainObject))
throw new Exception("Please provide a valid Object");
$mainObject = $mainObject;
$i = 1;
$subObject = $this->forceArray($subObject);
foreach ($subObject as $sub) {
// $sub is always an object, just a double-check
if (is_object($sub)) {
if ($arrange) {
// Arrange object in right order
$sub = $this->arrangeObject($sub, $order);
}
// Inject each value of subObject into $obj as property for checksum
foreach ($sub as $value) {
$mainObject->$i = $value;
$i++;
}
}
}
return $mainObject;
} | [
"public",
"function",
"parseForChecksum",
"(",
"$",
"mainObject",
",",
"$",
"subObject",
",",
"$",
"arrange",
"=",
"false",
",",
"$",
"order",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"mainObject",
")",
")",
"throw",
"... | Inserts properties of sub object into mainobject as property
@since version 1.0.2
@access public
@param object $mainObject !required
@param object $subObject !required
@param bool $arrange
@param array $order !required if $arrange == true
@return object $obj | [
"Inserts",
"properties",
"of",
"sub",
"object",
"into",
"mainobject",
"as",
"property"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L259-L288 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Base.generateChecksum | public function generateChecksum($obj = null, $secretCode = null,$isautocheckout = false)
{
$arr = array();
if ($secretCode)
array_push($arr, $secretCode);
foreach ($obj as $val) {
$insert = $val;
if (is_bool($val)) {
if ($isautocheckout) {
$insert = ($val) ? 'True' : 'False'; // autocheckout function computes boolean checksum differently (first character uppercase)
} else {
$insert = ($val) ? 'true' : 'false';
}
}
array_push($arr, $insert);
}
return sha1(implode("|", $arr));
} | php | public function generateChecksum($obj = null, $secretCode = null,$isautocheckout = false)
{
$arr = array();
if ($secretCode)
array_push($arr, $secretCode);
foreach ($obj as $val) {
$insert = $val;
if (is_bool($val)) {
if ($isautocheckout) {
$insert = ($val) ? 'True' : 'False'; // autocheckout function computes boolean checksum differently (first character uppercase)
} else {
$insert = ($val) ? 'true' : 'false';
}
}
array_push($arr, $insert);
}
return sha1(implode("|", $arr));
} | [
"public",
"function",
"generateChecksum",
"(",
"$",
"obj",
"=",
"null",
",",
"$",
"secretCode",
"=",
"null",
",",
"$",
"isautocheckout",
"=",
"false",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"secretCode",
")",
"array_push",
... | Generates the checksum
@since 2.1.0
@access public
@param object $obj
@param string $secretCode
@param bool $isautocheckout
@return string | [
"Generates",
"the",
"checksum"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L300-L321 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Base.forceArray | protected function forceArray($obj)
{
if (is_array($obj))
return $obj;
$arr = array();
array_push($arr, $obj);
return $arr;
} | php | protected function forceArray($obj)
{
if (is_array($obj))
return $obj;
$arr = array();
array_push($arr, $obj);
return $arr;
} | [
"protected",
"function",
"forceArray",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"obj",
")",
")",
"return",
"$",
"obj",
";",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"array_push",
"(",
"$",
"arr",
",",
"$",
"obj",
")",
";",
"r... | Force object into array
@since 2.1.0
@access protected
@param object $obj
@return array | [
"Force",
"object",
"into",
"array"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L331-L339 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethods.retrieveAllPaymentmethods | public function retrieveAllPaymentmethods()
{
if (isset($this->_paymentMethodsArray))
return $this;
$obj = new stdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->_merchantID;
$obj->SecretCode = $this->_secretCode;
$obj->Timestamp = $this->getTimeStamp();
// ------------------------------------------------
$obj->Checksum = $this->generateChecksum($obj);
$obj->SecretCode = null;
$this->_paymentMethods = $this->client->GetMyPaymentMethods(array('request' => $obj));
if (isset($this->_paymentMethods->GetMyPaymentMethodsResult->PaymentMethods->PaymentMethod)) {
$this->_paymentMethodsArray = $this->clean($this->_paymentMethods);
}
return $this;
} | php | public function retrieveAllPaymentmethods()
{
if (isset($this->_paymentMethodsArray))
return $this;
$obj = new stdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->_merchantID;
$obj->SecretCode = $this->_secretCode;
$obj->Timestamp = $this->getTimeStamp();
// ------------------------------------------------
$obj->Checksum = $this->generateChecksum($obj);
$obj->SecretCode = null;
$this->_paymentMethods = $this->client->GetMyPaymentMethods(array('request' => $obj));
if (isset($this->_paymentMethods->GetMyPaymentMethodsResult->PaymentMethods->PaymentMethod)) {
$this->_paymentMethodsArray = $this->clean($this->_paymentMethods);
}
return $this;
} | [
"public",
"function",
"retrieveAllPaymentmethods",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_paymentMethodsArray",
")",
")",
"return",
"$",
"this",
";",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for che... | Retrieve all payment methods
@since 2.1.0
@access public
@return \Icepay_Webservice_Paymentmethods | [
"Retrieve",
"all",
"payment",
"methods"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L366-L387 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethods.clean | protected function clean($obj)
{
$methods = array();
foreach ($this->forceArray($obj->GetMyPaymentMethodsResult->PaymentMethods->PaymentMethod) as $value) {
array_push($methods, array(
'PaymentMethodCode' => $value->PaymentMethodCode,
'Description' => $value->Description,
'Issuers' => $this->convertIssuers($this->forceArray($value->Issuers->Issuer))
)
);
};
return $methods;
} | php | protected function clean($obj)
{
$methods = array();
foreach ($this->forceArray($obj->GetMyPaymentMethodsResult->PaymentMethods->PaymentMethod) as $value) {
array_push($methods, array(
'PaymentMethodCode' => $value->PaymentMethodCode,
'Description' => $value->Description,
'Issuers' => $this->convertIssuers($this->forceArray($value->Issuers->Issuer))
)
);
};
return $methods;
} | [
"protected",
"function",
"clean",
"(",
"$",
"obj",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"forceArray",
"(",
"$",
"obj",
"->",
"GetMyPaymentMethodsResult",
"->",
"PaymentMethods",
"->",
"PaymentMethod",
")... | Return clean array
@since 2.1.0
@access protected
@param object $obj
@return array | [
"Return",
"clean",
"array"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L397-L410 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethods.saveToFile | public function saveToFile($fileName = "wsdata", $directory = "")
{
if ($directory == "")
$directory = dirname(__FILE__);
date_default_timezone_set("Europe/Paris");
$line = sprintf("Paymentmethods %s,%s\r\n", date("H:i:s", time()), $this->exportAsString());
$filename = sprintf("%s/%s.csv", $directory, $fileName);
try {
$fp = @fopen($filename, "w");
@fwrite($fp, $line);
@fclose($fp);
} catch (Exception $e) {
throw new Exception($e->getMessage());
};
return true;
} | php | public function saveToFile($fileName = "wsdata", $directory = "")
{
if ($directory == "")
$directory = dirname(__FILE__);
date_default_timezone_set("Europe/Paris");
$line = sprintf("Paymentmethods %s,%s\r\n", date("H:i:s", time()), $this->exportAsString());
$filename = sprintf("%s/%s.csv", $directory, $fileName);
try {
$fp = @fopen($filename, "w");
@fwrite($fp, $line);
@fclose($fp);
} catch (Exception $e) {
throw new Exception($e->getMessage());
};
return true;
} | [
"public",
"function",
"saveToFile",
"(",
"$",
"fileName",
"=",
"\"wsdata\"",
",",
"$",
"directory",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"directory",
"==",
"\"\"",
")",
"$",
"directory",
"=",
"dirname",
"(",
"__FILE__",
")",
";",
"date_default_timezone_s... | Save ws to File
@since 2.1.0
@access public
@param string $fileName
@param directory $directory
@return boolean
@throws Exception | [
"Save",
"ws",
"to",
"File"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L516-L534 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Filtering.loadFromFile | public function loadFromFile($fileName = "wsdata", $directory = "")
{
if ($directory == "")
$directory = dirname(__FILE__);
$filename = sprintf("%s/%s.csv", $directory, $fileName);
try {
$fp = @fopen($filename, "r");
$line = @fgets($fp);
@fclose($fp);
} catch (Exception $e) {
throw new Exception($e->getMessage());
};
if (!$line) {
throw new Exception("No data stored");
}
$arr = explode(",", $line);
$this->importFromString($arr[1]);
return $this;
} | php | public function loadFromFile($fileName = "wsdata", $directory = "")
{
if ($directory == "")
$directory = dirname(__FILE__);
$filename = sprintf("%s/%s.csv", $directory, $fileName);
try {
$fp = @fopen($filename, "r");
$line = @fgets($fp);
@fclose($fp);
} catch (Exception $e) {
throw new Exception($e->getMessage());
};
if (!$line) {
throw new Exception("No data stored");
}
$arr = explode(",", $line);
$this->importFromString($arr[1]);
return $this;
} | [
"public",
"function",
"loadFromFile",
"(",
"$",
"fileName",
"=",
"\"wsdata\"",
",",
"$",
"directory",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"directory",
"==",
"\"\"",
")",
"$",
"directory",
"=",
"dirname",
"(",
"__FILE__",
")",
";",
"$",
"filename",
"... | Read data from stored file
@since 2.1.0
@access public
@param string $fileName
@param string $directory
@return \Icepay_Webservice_Filtering
@throws Exception | [
"Read",
"data",
"from",
"stored",
"file"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L598-L620 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Filtering.isPaymentMethodAvailable | public function isPaymentMethodAvailable($pmCode) {
foreach ($this->_paymentMethodsArrayFiltered as $value) {
if ($value['PaymentMethodCode'] == $pmCode)
return true;
}
return false;
} | php | public function isPaymentMethodAvailable($pmCode) {
foreach ($this->_paymentMethodsArrayFiltered as $value) {
if ($value['PaymentMethodCode'] == $pmCode)
return true;
}
return false;
} | [
"public",
"function",
"isPaymentMethodAvailable",
"(",
"$",
"pmCode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_paymentMethodsArrayFiltered",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"[",
"'PaymentMethodCode'",
"]",
"==",
"$",
"pmCode",
")... | Check if payment method is available.
@param $pmCode
@return bool | [
"Check",
"if",
"payment",
"method",
"is",
"available",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L708-L715 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethod.selectPaymentMethodByCode | public function selectPaymentMethodByCode($name)
{
if (!isset($this->_paymentMethodsArray))
throw new Exception("No data loaded");
foreach ($this->_paymentMethodsArray as $paymentMethod) {
if ($paymentMethod["PaymentMethodCode"] == strtoupper($name)) {
$this->_methodData = $paymentMethod;
break;
}
}
return $this;
} | php | public function selectPaymentMethodByCode($name)
{
if (!isset($this->_paymentMethodsArray))
throw new Exception("No data loaded");
foreach ($this->_paymentMethodsArray as $paymentMethod) {
if ($paymentMethod["PaymentMethodCode"] == strtoupper($name)) {
$this->_methodData = $paymentMethod;
break;
}
}
return $this;
} | [
"public",
"function",
"selectPaymentMethodByCode",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_paymentMethodsArray",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"No data loaded\"",
")",
";",
"foreach",
"(",
"$",
"this",
... | Select the payment method by code
@since 2.1.0
@access public
@param string $name
@return \Icepay_Webservice_Paymentmethod
@throws Exception | [
"Select",
"the",
"payment",
"method",
"by",
"code"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L767-L778 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethod.selectIssuerByKeyword | public function selectIssuerByKeyword($name)
{
if (!isset($this->_paymentMethodsArray))
throw new Exception("No data loaded");
foreach ($this->_paymentMethodsArray as $paymentMethod) {
foreach ($paymentMethod["Issuers"] as $issuer) {
if ($issuer["IssuerKeyword"] == strtoupper($name)) {
$this->_methodData = $paymentMethod;
$this->_issuerData = $issuer;
break;
}
}
}
return $this;
} | php | public function selectIssuerByKeyword($name)
{
if (!isset($this->_paymentMethodsArray))
throw new Exception("No data loaded");
foreach ($this->_paymentMethodsArray as $paymentMethod) {
foreach ($paymentMethod["Issuers"] as $issuer) {
if ($issuer["IssuerKeyword"] == strtoupper($name)) {
$this->_methodData = $paymentMethod;
$this->_issuerData = $issuer;
break;
}
}
}
return $this;
} | [
"public",
"function",
"selectIssuerByKeyword",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_paymentMethodsArray",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"No data loaded\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->... | Select an issuer by keyword
@since 2.1.0
@access public
@param string $name
@return \Icepay_Webservice_Paymentmethod
@throws Exception | [
"Select",
"an",
"issuer",
"by",
"keyword"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L789-L803 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethod.selectCountry | public function selectCountry($country)
{
if (!isset($this->_issuerData)) {
$this->_country = $this->validateCountry($country);
return $this;
}
if (in_array($country, $this->getCountries())) {
$this->_country = $this->validateCountry($country);
return $this;
};
if (in_array("00", $this->getCountries())) {
$this->_country = "00";
};
return $this;
} | php | public function selectCountry($country)
{
if (!isset($this->_issuerData)) {
$this->_country = $this->validateCountry($country);
return $this;
}
if (in_array($country, $this->getCountries())) {
$this->_country = $this->validateCountry($country);
return $this;
};
if (in_array("00", $this->getCountries())) {
$this->_country = "00";
};
return $this;
} | [
"public",
"function",
"selectCountry",
"(",
"$",
"country",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_issuerData",
")",
")",
"{",
"$",
"this",
"->",
"_country",
"=",
"$",
"this",
"->",
"validateCountry",
"(",
"$",
"country",
")",
"... | Selects the country out of the issuer data
@since 2.1.0
@access Public
@param string $country
@return \Icepay_Webservice_Paymentmethod | [
"Selects",
"the",
"country",
"out",
"of",
"the",
"issuer",
"data"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L813-L830 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Paymentmethod.getMaximumAmount | public function getMaximumAmount()
{
if (!isset($this->_issuerData))
throw new Exception("Issuer must be selected first");
if (!isset($this->_country))
throw new Exception("Country must be selected first");
foreach ($this->_issuerData["Countries"] as $country) {
if ($this->_country == $country["CountryCode"]) {
return intval($country["MaximumAmount"]);
}
}
} | php | public function getMaximumAmount()
{
if (!isset($this->_issuerData))
throw new Exception("Issuer must be selected first");
if (!isset($this->_country))
throw new Exception("Country must be selected first");
foreach ($this->_issuerData["Countries"] as $country) {
if ($this->_country == $country["CountryCode"]) {
return intval($country["MaximumAmount"]);
}
}
} | [
"public",
"function",
"getMaximumAmount",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_issuerData",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Issuer must be selected first\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
... | Get maximum amount
@since 2.1.0
@access public
@return int
@throws Exception | [
"Get",
"maximum",
"amount"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L941-L952 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Pay.checkOut | public function checkOut(Icepay_PaymentObject_Interface_Abstract $paymentObj, $getUrlOnly = false)
{
$obj = new stdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
// ------------------------------------------------
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->Checkout(array('request' => $obj));
/* store the checksum momentarily */
$checksum = $result->CheckoutResult->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->CheckoutResult->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result->CheckoutResult))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->CheckoutResult->Checksum = $checksum;
/* Return just the payment URL if required */
if ($getUrlOnly)
return $result->CheckoutResult->PaymentScreenURL;
$transactionObj = new Icepay_TransactionObject();
$transactionObj->setData($result->CheckoutResult);
/* Default return all data */
return $transactionObj;
} | php | public function checkOut(Icepay_PaymentObject_Interface_Abstract $paymentObj, $getUrlOnly = false)
{
$obj = new stdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
// ------------------------------------------------
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->Checkout(array('request' => $obj));
/* store the checksum momentarily */
$checksum = $result->CheckoutResult->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->CheckoutResult->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result->CheckoutResult))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->CheckoutResult->Checksum = $checksum;
/* Return just the payment URL if required */
if ($getUrlOnly)
return $result->CheckoutResult->PaymentScreenURL;
$transactionObj = new Icepay_TransactionObject();
$transactionObj->setData($result->CheckoutResult);
/* Default return all data */
return $transactionObj;
} | [
"public",
"function",
"checkOut",
"(",
"Icepay_PaymentObject_Interface_Abstract",
"$",
"paymentObj",
",",
"$",
"getUrlOnly",
"=",
"false",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum ---------",
"$",
"obj",
... | The Checkout web method allows you to initialize a new payment in the ICEPAY system for ALL the
payment methods that you have access to
@since version 2.1.0
@access public
@param Icepay_PaymentObject_Interface_Abstract $paymentObj
@param bool $geturlOnly
@return array result | [
"The",
"Checkout",
"web",
"method",
"allows",
"you",
"to",
"initialize",
"a",
"new",
"payment",
"in",
"the",
"ICEPAY",
"system",
"for",
"ALL",
"the",
"payment",
"methods",
"that",
"you",
"have",
"access",
"to"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1180-L1228 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Pay.phoneCheckout | public function phoneCheckout(Icepay_PaymentObject_Interface_Abstract $paymentObj, $getUrlOnly = false)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->PhoneCheckout(array('request' => $obj));
/* store the checksum momentarily */
$checksum = $result->PhoneCheckoutResult->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->PhoneCheckoutResult->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result->PhoneCheckoutResult))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->PhoneCheckoutResult->Checksum = $checksum;
/* Return only the payment URL if required */
if ($getUrlOnly)
return $result->PhoneCheckoutResult->PaymentScreenURL;
/* Default return all data */
return (array) $result->PhoneCheckoutResult;
} | php | public function phoneCheckout(Icepay_PaymentObject_Interface_Abstract $paymentObj, $getUrlOnly = false)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->PhoneCheckout(array('request' => $obj));
/* store the checksum momentarily */
$checksum = $result->PhoneCheckoutResult->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->PhoneCheckoutResult->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result->PhoneCheckoutResult))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->PhoneCheckoutResult->Checksum = $checksum;
/* Return only the payment URL if required */
if ($getUrlOnly)
return $result->PhoneCheckoutResult->PaymentScreenURL;
/* Default return all data */
return (array) $result->PhoneCheckoutResult;
} | [
"public",
"function",
"phoneCheckout",
"(",
"Icepay_PaymentObject_Interface_Abstract",
"$",
"paymentObj",
",",
"$",
"getUrlOnly",
"=",
"false",
")",
"{",
"$",
"obj",
"=",
"new",
"StdClass",
"(",
")",
";",
"// Must be in specific order for checksum ---------",
"$",
"ob... | The PhoneCheckout web method allows you to create a phone payment in the ICEPAY system. The
main difference with the Checkout web method is the response. The response is a
PhoneCheckoutResponse object, which contains extra members such as the phone number etc., making
seamless integration possible.
@since 2.1.0
@access public
@param array $data
@param bool $geturlOnly
@return array result | [
"The",
"PhoneCheckout",
"web",
"method",
"allows",
"you",
"to",
"create",
"a",
"phone",
"payment",
"in",
"the",
"ICEPAY",
"system",
".",
"The",
"main",
"difference",
"with",
"the",
"Checkout",
"web",
"method",
"is",
"the",
"response",
".",
"The",
"response",... | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1242-L1285 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Pay.validatePhoneCode | public function validatePhoneCode($paymentID, $phoneCode)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->PhoneCode = $phoneCode;
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->ValidatePhoneCode(array('request' => $obj));
$result = $result->ValidatePhoneCodeResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
return $result->Success;
} | php | public function validatePhoneCode($paymentID, $phoneCode)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->PhoneCode = $phoneCode;
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->ValidatePhoneCode(array('request' => $obj));
$result = $result->ValidatePhoneCodeResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
return $result->Success;
} | [
"public",
"function",
"validatePhoneCode",
"(",
"$",
"paymentID",
",",
"$",
"phoneCode",
")",
"{",
"$",
"obj",
"=",
"new",
"StdClass",
"(",
")",
";",
"// Must be in specific order for checksum --------- ",
"$",
"obj",
"->",
"MerchantID",
"=",
"$",
"this",
... | The ValidatePhoneCode web method verifies the code that the end-user must provide in
order to start a phone payment.
@since 2.1.0
@access public
@param int $paymentID
@param int $phoneCode
@return bool success | [
"The",
"ValidatePhoneCode",
"web",
"method",
"verifies",
"the",
"code",
"that",
"the",
"end",
"-",
"user",
"must",
"provide",
"in",
"order",
"to",
"start",
"a",
"phone",
"payment",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1363-L1389 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Pay.validateSmsCode | public function validateSmsCode($paymentID, $smsCode)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->SmsCode = $smsCode;
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->ValidateSmsCode(array('request' => $obj));
$result = $result->ValidateSmsCodeResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
return $result->Success;
} | php | public function validateSmsCode($paymentID, $smsCode)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->SmsCode = $smsCode;
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->ValidateSmsCode(array('request' => $obj));
$result = $result->ValidateSmsCodeResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
return $result->Success;
} | [
"public",
"function",
"validateSmsCode",
"(",
"$",
"paymentID",
",",
"$",
"smsCode",
")",
"{",
"$",
"obj",
"=",
"new",
"StdClass",
"(",
")",
";",
"// Must be in specific order for checksum --------- ",
"$",
"obj",
"->",
"MerchantID",
"=",
"$",
"this",
"->... | The ValidateSmsCode web method validates the code that the end-user must provide.
@since 2.1.0
@access public
@param int $paymentID
@param int $smsCode
@return bool success | [
"The",
"ValidateSmsCode",
"web",
"method",
"validates",
"the",
"code",
"that",
"the",
"end",
"-",
"user",
"must",
"provide",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1400-L1426 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Pay.phoneDirectCheckout | public function phoneDirectCheckout(Icepay_PaymentObject_Interface_Abstract $paymentObj)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
$obj->PINCode = $this->getPinCode();
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->phoneDirectCheckout(array('request' => $obj));
$result = $result->PhoneDirectCheckoutResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
// Reverse Success and Error Description, since order must be specific for Checksum
$success = $result->Success;
$errorDescription = $result->ErrorDescription;
unset($result->Success, $result->ErrorDescription);
$result->Success = $success;
$result->ErrorDescription = $errorDescription;
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->Checksum = $checksum;
/* Default return all data */
return (array) $result;
} | php | public function phoneDirectCheckout(Icepay_PaymentObject_Interface_Abstract $paymentObj)
{
$obj = new StdClass();
// Must be in specific order for checksum ---------
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->Amount = $paymentObj->getAmount();
$obj->Country = $paymentObj->getCountry();
$obj->Currency = $paymentObj->getCurrency();
$obj->Description = $paymentObj->getDescription();
$obj->EndUserIP = $this->getIP();
$obj->Issuer = $paymentObj->getIssuer();
$obj->Language = $paymentObj->getLanguage();
$obj->OrderID = $paymentObj->getOrderID();
$obj->PaymentMethod = $paymentObj->getPaymentMethod();
$obj->Reference = $paymentObj->getReference();
$obj->URLCompleted = $this->getSuccessURL();
$obj->URLError = $this->getErrorURL();
$obj->PINCode = $this->getPinCode();
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
$result = $this->client->phoneDirectCheckout(array('request' => $obj));
$result = $result->PhoneDirectCheckoutResult;
/* store the checksum momentarily */
$checksum = $result->Checksum;
/* Replace the checksum in the data with secretCode to generate a new checksum */
$result->Checksum = $this->getSecretCode();
// Reverse Success and Error Description, since order must be specific for Checksum
$success = $result->Success;
$errorDescription = $result->ErrorDescription;
unset($result->Success, $result->ErrorDescription);
$result->Success = $success;
$result->ErrorDescription = $errorDescription;
/* Verify response data */
if ($checksum != $this->generateChecksum($result))
throw new Exception("Data could not be verified");
/* Return mister checksum */
$result->Checksum = $checksum;
/* Default return all data */
return (array) $result;
} | [
"public",
"function",
"phoneDirectCheckout",
"(",
"Icepay_PaymentObject_Interface_Abstract",
"$",
"paymentObj",
")",
"{",
"$",
"obj",
"=",
"new",
"StdClass",
"(",
")",
";",
"// Must be in specific order for checksum ---------",
"$",
"obj",
"->",
"MerchantID",
"=",
"$",
... | The phoneDirectCheckout web method allows you to initialize a new payment in the ICEPAY system
with paymentmethod Phone with Pincode
@since version 2.1.0
@access public
@param object $data
@return array result | [
"The",
"phoneDirectCheckout",
"web",
"method",
"allows",
"you",
"to",
"initialize",
"a",
"new",
"payment",
"in",
"the",
"ICEPAY",
"system",
"with",
"paymentmethod",
"Phone",
"with",
"Pincode"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1437-L1487 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Refunds.requestRefund | public function requestRefund($paymentID, $refundAmount, $refundCurrency)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->RefundAmount = $refundAmount;
$obj->RefundCurrency = $refundCurrency;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getPaymentRefunds and get response
$result = $this->client->requestRefund($obj);
$result = $result->RequestRefundResult;
$obj = new StdClass();
// Must be in specific order for checksum -------------------
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $result->Timestamp;
$obj->RefundID = $result->RefundID;
$obj->PaymentID = $paymentID;
$obj->RefundAmount = $refundAmount;
$obj->RemainingRefundAmount = $result->RemainingRefundAmount;
$obj->RefundCurrency = $refundCurrency;
// ----------------------------------------------------------
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $result;
} | php | public function requestRefund($paymentID, $refundAmount, $refundCurrency)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
$obj->RefundAmount = $refundAmount;
$obj->RefundCurrency = $refundCurrency;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getPaymentRefunds and get response
$result = $this->client->requestRefund($obj);
$result = $result->RequestRefundResult;
$obj = new StdClass();
// Must be in specific order for checksum -------------------
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $result->Timestamp;
$obj->RefundID = $result->RefundID;
$obj->PaymentID = $paymentID;
$obj->RefundAmount = $refundAmount;
$obj->RemainingRefundAmount = $result->RemainingRefundAmount;
$obj->RefundCurrency = $refundCurrency;
// ----------------------------------------------------------
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $result;
} | [
"public",
"function",
"requestRefund",
"(",
"$",
"paymentID",
",",
"$",
"refundAmount",
",",
"$",
"refundCurrency",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum --",
"$",
"obj",
"->",
"Secret",
"=",
"$... | The RequestRefund web method allows you to initiate a refund request for a payment. You can request
the entire amount to be refunded or just a part of it. If you request only a partial amount to be refunded
then you are allowed to perform refund requests for the same payment until you have reached its full
amount. After that you cannot request refunds anymore for that payment.
@since version 2.1.0
@access public
@param int $paymentID
@param int $refundAmount Amount in cents
@param string $refundCurrency | [
"The",
"RequestRefund",
"web",
"method",
"allows",
"you",
"to",
"initiate",
"a",
"refund",
"request",
"for",
"a",
"payment",
".",
"You",
"can",
"request",
"the",
"entire",
"amount",
"to",
"be",
"refunded",
"or",
"just",
"a",
"part",
"of",
"it",
".",
"If"... | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1619-L1658 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Refunds.cancelRefund | public function cancelRefund($refundID, $paymentID)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->RefundID = $refundID;
$obj->PaymentID = $paymentID;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for cancelRefunt and get response
$result = $this->client->CancelRefund($obj);
$result = $result->CancelRefundResult;
$obj->Timestamp = $result->Timestamp;
$obj->Success = $result->Success;
// Unset properties for new Checksum
unset($obj->RefundID, $obj->PaymentID, $obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $result;
} | php | public function cancelRefund($refundID, $paymentID)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->RefundID = $refundID;
$obj->PaymentID = $paymentID;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for cancelRefunt and get response
$result = $this->client->CancelRefund($obj);
$result = $result->CancelRefundResult;
$obj->Timestamp = $result->Timestamp;
$obj->Success = $result->Success;
// Unset properties for new Checksum
unset($obj->RefundID, $obj->PaymentID, $obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $result;
} | [
"public",
"function",
"cancelRefund",
"(",
"$",
"refundID",
",",
"$",
"paymentID",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum --",
"$",
"obj",
"->",
"Secret",
"=",
"$",
"this",
"->",
"getSecretCode",... | The CancelRefund web method allows you to cancel a refund request if it has not already been processed.
@since version 2.1.0
@access public
@param int $refundID
@param int $paymentID | [
"The",
"CancelRefund",
"web",
"method",
"allows",
"you",
"to",
"cancel",
"a",
"refund",
"request",
"if",
"it",
"has",
"not",
"already",
"been",
"processed",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1668-L1700 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Refunds.getPaymentRefunds | public function getPaymentRefunds($paymentID)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getPaymentRefunds and get response
$result = $this->client->getPaymentRefunds($obj);
$result = $result->GetPaymentRefundsResult;
$refunds = isset($result->Refunds->Refund) ? $result->Refunds->Refund : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($refunds)) {
// Assign all properties of the DayStatistics object as property of mainObject
$obj = $this->parseForChecksum($obj, $refunds, true, array("RefundID", "DateCreated", "RefundAmount", "RefundCurrency", "Status"));
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (!is_null($refunds)) ? $this->forceArray($refunds) : array();
} | php | public function getPaymentRefunds($paymentID)
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Secret = $this->getSecretCode();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimeStamp();
$obj->PaymentID = $paymentID;
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getPaymentRefunds and get response
$result = $this->client->getPaymentRefunds($obj);
$result = $result->GetPaymentRefundsResult;
$refunds = isset($result->Refunds->Refund) ? $result->Refunds->Refund : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($refunds)) {
// Assign all properties of the DayStatistics object as property of mainObject
$obj = $this->parseForChecksum($obj, $refunds, true, array("RefundID", "DateCreated", "RefundAmount", "RefundCurrency", "Status"));
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (!is_null($refunds)) ? $this->forceArray($refunds) : array();
} | [
"public",
"function",
"getPaymentRefunds",
"(",
"$",
"paymentID",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum --",
"$",
"obj",
"->",
"Secret",
"=",
"$",
"this",
"->",
"getSecretCode",
"(",
")",
";",
... | The GetPaymentRefunds web method allows you to query refund request information that belongs to the payment.
@since version 2.1.0
@access public
@param int $paymentID | [
"The",
"GetPaymentRefunds",
"web",
"method",
"allows",
"you",
"to",
"query",
"refund",
"request",
"information",
"that",
"belongs",
"to",
"the",
"payment",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1709-L1746 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Reporting.getMerchants | public function getMerchants()
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getMerchants and get response
$result = $this->client->getMerChants($obj);
$result = $result->GetMerchantsResult;
$merchants = isset($result->Merchants->Merchant) ? $result->Merchants->Merchant : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($merchants)) {
// Assign all properties of the Merchants object as property of mainObject
$obj = $this->parseForChecksum($obj, $merchants, true, array("MerchantID", "Description", "TestMode"));
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $merchants;
} | php | public function getMerchants()
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for getMerchants and get response
$result = $this->client->getMerChants($obj);
$result = $result->GetMerchantsResult;
$merchants = isset($result->Merchants->Merchant) ? $result->Merchants->Merchant : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($merchants)) {
// Assign all properties of the Merchants object as property of mainObject
$obj = $this->parseForChecksum($obj, $merchants, true, array("MerchantID", "Description", "TestMode"));
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$Checksum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $Checksum)
throw new Exception('Data could not be verified');
return (array) $merchants;
} | [
"public",
"function",
"getMerchants",
"(",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum --",
"$",
"obj",
"->",
"Timestamp",
"=",
"$",
"this",
"->",
"getTimeStamp",
"(",
")",
";",
"$",
"obj",
"->",
... | The getMerchant web method returns a list of merchants that belong to your ICEPAY account.
@since version 2.1.0
@access public
@return array | [
"The",
"getMerchant",
"web",
"method",
"returns",
"a",
"list",
"of",
"merchants",
"that",
"belong",
"to",
"your",
"ICEPAY",
"account",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L2174-L2210 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Reporting.getPaymentMethods | public function getPaymentMethods()
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for GetPaymentMethods and get response
$result = $this->client->GetPaymentMethods($obj);
$result = $result->GetPaymentMethodsResult;
$methods = isset($result->PaymentMethods->PaymentMethod) ? $result->PaymentMethods->PaymentMethod : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($methods)) {
// Assign all properties of the PaymentMethods object as property of mainObject
$obj = $this->parseForChecksum($obj, $methods);
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$CheckSum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $CheckSum)
throw new Exception('Data could not be verified');
return (array) $methods;
} | php | public function getPaymentMethods()
{
$obj = new stdClass();
// Must be in specific order for checksum --
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
// -----------------------------------------
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Ask for GetPaymentMethods and get response
$result = $this->client->GetPaymentMethods($obj);
$result = $result->GetPaymentMethodsResult;
$methods = isset($result->PaymentMethods->PaymentMethod) ? $result->PaymentMethods->PaymentMethod : null;
$obj->Timestamp = $result->Timestamp;
if (!is_null($methods)) {
// Assign all properties of the PaymentMethods object as property of mainObject
$obj = $this->parseForChecksum($obj, $methods);
}
// Unset properties for new Checksum
unset($obj->Checksum);
// Verify response data by making a new Checksum
$CheckSum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $CheckSum)
throw new Exception('Data could not be verified');
return (array) $methods;
} | [
"public",
"function",
"getPaymentMethods",
"(",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum --",
"$",
"obj",
"->",
"Timestamp",
"=",
"$",
"this",
"->",
"getTimeStamp",
"(",
")",
";",
"$",
"obj",
"->... | The getPaymentMethods web method returns a list of all supported payment methods by ICEPAY.
@since version 2.1.0
@access public | [
"The",
"getPaymentMethods",
"web",
"method",
"returns",
"a",
"list",
"of",
"all",
"supported",
"payment",
"methods",
"by",
"ICEPAY",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L2218-L2254 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_Reporting.searchPayments | public function searchPayments($searchOptions = array())
{
$obj = new stdClass();
// Must be in specific order for checksum ----------
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
$obj->MerchantID = null;
$obj->PaymentID = null;
$obj->OrderID = null;
$obj->Reference = null;
$obj->Description = null;
$obj->Status = null;
$obj->OrderTime1 = null;
$obj->OrderTime2 = null;
$obj->PaymentTime1 = null;
$obj->PaymentTime2 = null;
$obj->CountryCode = null;
$obj->CurrencyCode = null;
$obj->Amount = null;
$obj->PaymentMethod = null;
$obj->ConsumerAccountNumber = null;
$obj->ConsumerName = null;
$obj->ConsumerAddress = null;
$obj->ConsumerHouseNumber = null;
$obj->ConsumerPostCode = null;
$obj->ConsumerCity = null;
$obj->ConsumerCountry = null;
$obj->ConsumerEmail = null;
$obj->ConsumerPhoneNumber = null;
$obj->ConsumerIPAddress = null;
$obj->Page = (int) 1;
// ------------------------------------------------
if (!empty($searchOptions)) {
foreach ($searchOptions as $key => $filter) {
$obj->$key = $filter;
}
}
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Properties only used for the Checksum
unset($obj->PinCode);
// Ask for SearchPayments and get response
$result = $this->client->SearchPayments($obj);
$result = $result->SearchPaymentsResult;
$searchResults = isset($result->Payments->Payment) ? $result->Payments->Payment : null;
$obj = new stdClass();
$obj->Timestamp = $result->Timestamp;
$obj->SessionID = $this->getSessionID();
$obj->ReportingPinCode = $this->getPinCode();
if (!is_null($searchResults)) {
// Assign all properties of the sub object(s) as property of mainObject
$obj = $this->parseForChecksum($obj, $searchResults, true, array(
"Amount", "ConsumerAccountNumber", "ConsumerAddress", "ConsumerHouseNumber", "ConsumerName",
"ConsumerPostCode", "CountryCode", "CurrencyCode", "Duration", "MerchantID", "OrderTime",
"PaymentID", "PaymentMethod", "PaymentTime", "Status", "StatusCode", "TestMode"
));
}
// Verify response data by making a new Checksum
$CheckSum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $CheckSum)
throw new Exception('Data could not be verified');
return (array) $searchResults;
} | php | public function searchPayments($searchOptions = array())
{
$obj = new stdClass();
// Must be in specific order for checksum ----------
$obj->Timestamp = $this->getTimeStamp();
$obj->SessionID = $this->getSessionID();
$obj->PinCode = $this->getPinCode();
$obj->UserAgent = $this->getUserAgent();
$obj->MerchantID = null;
$obj->PaymentID = null;
$obj->OrderID = null;
$obj->Reference = null;
$obj->Description = null;
$obj->Status = null;
$obj->OrderTime1 = null;
$obj->OrderTime2 = null;
$obj->PaymentTime1 = null;
$obj->PaymentTime2 = null;
$obj->CountryCode = null;
$obj->CurrencyCode = null;
$obj->Amount = null;
$obj->PaymentMethod = null;
$obj->ConsumerAccountNumber = null;
$obj->ConsumerName = null;
$obj->ConsumerAddress = null;
$obj->ConsumerHouseNumber = null;
$obj->ConsumerPostCode = null;
$obj->ConsumerCity = null;
$obj->ConsumerCountry = null;
$obj->ConsumerEmail = null;
$obj->ConsumerPhoneNumber = null;
$obj->ConsumerIPAddress = null;
$obj->Page = (int) 1;
// ------------------------------------------------
if (!empty($searchOptions)) {
foreach ($searchOptions as $key => $filter) {
$obj->$key = $filter;
}
}
// Generate Checksum
$obj->Checksum = $this->generateChecksum($obj);
// Properties only used for the Checksum
unset($obj->PinCode);
// Ask for SearchPayments and get response
$result = $this->client->SearchPayments($obj);
$result = $result->SearchPaymentsResult;
$searchResults = isset($result->Payments->Payment) ? $result->Payments->Payment : null;
$obj = new stdClass();
$obj->Timestamp = $result->Timestamp;
$obj->SessionID = $this->getSessionID();
$obj->ReportingPinCode = $this->getPinCode();
if (!is_null($searchResults)) {
// Assign all properties of the sub object(s) as property of mainObject
$obj = $this->parseForChecksum($obj, $searchResults, true, array(
"Amount", "ConsumerAccountNumber", "ConsumerAddress", "ConsumerHouseNumber", "ConsumerName",
"ConsumerPostCode", "CountryCode", "CurrencyCode", "Duration", "MerchantID", "OrderTime",
"PaymentID", "PaymentMethod", "PaymentTime", "Status", "StatusCode", "TestMode"
));
}
// Verify response data by making a new Checksum
$CheckSum = $this->generateChecksum($obj);
// Compare Checksums
if ($result->Checksum != $CheckSum)
throw new Exception('Data could not be verified');
return (array) $searchResults;
} | [
"public",
"function",
"searchPayments",
"(",
"$",
"searchOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"// Must be in specific order for checksum ----------",
"$",
"obj",
"->",
"Timestamp",
"=",
"$",
"this",
"->... | The searchPayments web method allows you to search for payments linked to your ICEPAY account. There are
several filters which you can employ for a more detailed search.
@since version 2.1.0
@access public
@param array searchOptions
@return array | [
"The",
"searchPayments",
"web",
"method",
"allows",
"you",
"to",
"search",
"for",
"payments",
"linked",
"to",
"your",
"ICEPAY",
"account",
".",
"There",
"are",
"several",
"filters",
"which",
"you",
"can",
"employ",
"for",
"a",
"more",
"detailed",
"search",
"... | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L2265-L2341 | train |
ICEPAY/deprecated-i | src/icepay_api_webservice.php | Icepay_Webservice_AutoCapture.captureFull | public function captureFull($paymentID, $amount = 0, $currency = '')
{
$obj = new stdClass();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimestamp();
$obj->amount = $amount;
$obj->currency = $currency;
$obj->PaymentID = $paymentID;
// Generate checksum for the request
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
// Make the request
$request = $this->client->CaptureFull($obj);
// Fetch the result
$result = $request->CaptureFullResult;
// Store result checksum
$resultChecksum = $result->Checksum;
// Remove result checksum from object
unset($result->Checksum);
// Create result checksum
$checkSum = $this->generateChecksum($result, $this->getSecretCode());
// Compare generated checksum and result checksum
if ($resultChecksum !== $checkSum)
throw new Exception('Data could not be verified');
// Return result
return $result;
} | php | public function captureFull($paymentID, $amount = 0, $currency = '')
{
$obj = new stdClass();
$obj->MerchantID = $this->getMerchantID();
$obj->Timestamp = $this->getTimestamp();
$obj->amount = $amount;
$obj->currency = $currency;
$obj->PaymentID = $paymentID;
// Generate checksum for the request
$obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
// Make the request
$request = $this->client->CaptureFull($obj);
// Fetch the result
$result = $request->CaptureFullResult;
// Store result checksum
$resultChecksum = $result->Checksum;
// Remove result checksum from object
unset($result->Checksum);
// Create result checksum
$checkSum = $this->generateChecksum($result, $this->getSecretCode());
// Compare generated checksum and result checksum
if ($resultChecksum !== $checkSum)
throw new Exception('Data could not be verified');
// Return result
return $result;
} | [
"public",
"function",
"captureFull",
"(",
"$",
"paymentID",
",",
"$",
"amount",
"=",
"0",
",",
"$",
"currency",
"=",
"''",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"obj",
"->",
"MerchantID",
"=",
"$",
"this",
"->",
"getMerc... | Capture an authorized AfterPay payment
@since 1.0.0
@param string $paymentID
@param int $amount
@param string $currency
@return object | [
"Capture",
"an",
"authorized",
"AfterPay",
"payment"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L2376-L2410 | train |
SIELOnline/libAcumulus | src/Helpers/Token.php | Token.getObjectProperty | protected function getObjectProperty($variable, $property, array $args)
{
$value = null;
$method1 = $property;
$method2 = 'get' . ucfirst($property);
$method3 = 'get_' . $property;
if (method_exists($variable, $method1)) {
$value = call_user_func_array(array($variable, $method1), $args);
} elseif (method_exists($variable, $method2)) {
$value = call_user_func_array(array($variable, $method2), $args);
} elseif (method_exists($variable, $method3)) {
$value = call_user_func_array(array($variable, $method3), $args);
} elseif (method_exists($variable, '__get')) {
@$value = $variable->$property;
} elseif (method_exists($variable, '__call')) {
try {
$value = @call_user_func_array(array($variable, $property), $args);
} catch (Exception $e) {
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method1), $args);
} catch (Exception $e) {
}
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method2), $args);
} catch (Exception $e) {
}
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method3), $args);
} catch (Exception $e) {
}
}
}
return $value;
} | php | protected function getObjectProperty($variable, $property, array $args)
{
$value = null;
$method1 = $property;
$method2 = 'get' . ucfirst($property);
$method3 = 'get_' . $property;
if (method_exists($variable, $method1)) {
$value = call_user_func_array(array($variable, $method1), $args);
} elseif (method_exists($variable, $method2)) {
$value = call_user_func_array(array($variable, $method2), $args);
} elseif (method_exists($variable, $method3)) {
$value = call_user_func_array(array($variable, $method3), $args);
} elseif (method_exists($variable, '__get')) {
@$value = $variable->$property;
} elseif (method_exists($variable, '__call')) {
try {
$value = @call_user_func_array(array($variable, $property), $args);
} catch (Exception $e) {
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method1), $args);
} catch (Exception $e) {
}
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method2), $args);
} catch (Exception $e) {
}
}
if ($value === null || $value === '') {
try {
$value = call_user_func_array(array($variable, $method3), $args);
} catch (Exception $e) {
}
}
}
return $value;
} | [
"protected",
"function",
"getObjectProperty",
"(",
"$",
"variable",
",",
"$",
"property",
",",
"array",
"$",
"args",
")",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"method1",
"=",
"$",
"property",
";",
"$",
"method2",
"=",
"'get'",
".",
"ucfirst",
"(",... | Looks up a property in a web shop specific object.
This part is extracted into a separate method so it can be overridden
with webshop specific ways to access properties. The base implementation
will probably get the property anyway, so override mainly to prevent
notices or warnings.
@param object $variable
The variable to search for the property.
@param string $property
The property or function to get its value.
@param array $args
Optional arguments to pass if it is a function.
@return null|string
The value for the property of the given name, or null or the empty
string if not available (or the property really equals null or the
empty string). The return value may be a scalar (numeric type) that can
be converted to a string. | [
"Looks",
"up",
"a",
"property",
"in",
"a",
"web",
"shop",
"specific",
"object",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Token.php#L335-L374 | train |
SIELOnline/libAcumulus | src/Helpers/Token.php | Token.implodeValues | protected function implodeValues($glue, $values)
{
$result = '';
$hasProperty = false;
$previous = '';
foreach ($values as $value) {
if ($value['type'] === self::TypeLiteral) {
// Literal value: set aside and only add if next property value
// is not empty.
if (!empty($previous)) {
// Multiple literals after each other: treat as 1 literal
// but do glue them together.
$previous .= $glue;
}
$previous .= $value['value'];
} else { // $value['type'] === self::TypeProperty
// Property value: if it is not empty, add any previous literal
// and the property value itself. If it is empty, discard any
// previous literal value.
if (!empty($value['value'])) {
if (!empty($previous)) {
if (!empty($result)) {
$result .= $glue;
}
$result .= $previous;
}
if (!empty($result)) {
$result .= $glue;
}
$result .= $value['value'];
}
// Discard any previous literal value, used or not.
$previous = '';
// Remember that this expression has at least 1 property
$hasProperty = true;
}
}
// Add a (set of) literal value(s) that came without property or if they
// came as last value(s) and the result so far is not empty.
if (!empty($previous) && (!$hasProperty || !empty($result))) {
if (!empty($result)) {
$result .= $glue;
}
$result .= $previous;
}
return array('type' => $hasProperty ? self::TypeProperty : self::TypeLiteral ,'value' => $result);
} | php | protected function implodeValues($glue, $values)
{
$result = '';
$hasProperty = false;
$previous = '';
foreach ($values as $value) {
if ($value['type'] === self::TypeLiteral) {
// Literal value: set aside and only add if next property value
// is not empty.
if (!empty($previous)) {
// Multiple literals after each other: treat as 1 literal
// but do glue them together.
$previous .= $glue;
}
$previous .= $value['value'];
} else { // $value['type'] === self::TypeProperty
// Property value: if it is not empty, add any previous literal
// and the property value itself. If it is empty, discard any
// previous literal value.
if (!empty($value['value'])) {
if (!empty($previous)) {
if (!empty($result)) {
$result .= $glue;
}
$result .= $previous;
}
if (!empty($result)) {
$result .= $glue;
}
$result .= $value['value'];
}
// Discard any previous literal value, used or not.
$previous = '';
// Remember that this expression has at least 1 property
$hasProperty = true;
}
}
// Add a (set of) literal value(s) that came without property or if they
// came as last value(s) and the result so far is not empty.
if (!empty($previous) && (!$hasProperty || !empty($result))) {
if (!empty($result)) {
$result .= $glue;
}
$result .= $previous;
}
return array('type' => $hasProperty ? self::TypeProperty : self::TypeLiteral ,'value' => $result);
} | [
"protected",
"function",
"implodeValues",
"(",
"$",
"glue",
",",
"$",
"values",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"hasProperty",
"=",
"false",
";",
"$",
"previous",
"=",
"''",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
... | Concatenates a list of values using a glue between them.
Literal strings are only used if they are followed by a non-empty
property value. A literal string at the end is only used if the result so
far is not empty.
@param string $glue
@param array[] $values
A list of type-value pairs.
@return array
Returns a type-value pair containing as value a string representation
of all the values with the glue string between each value. | [
"Concatenates",
"a",
"list",
"of",
"values",
"using",
"a",
"glue",
"between",
"them",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Token.php#L391-L439 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.