id int32 0 241k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,200 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,201 | 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'",
"]",
";",
"}",
"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",
";",
"}"
] | 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 |
30,202 | 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",
"[",
"]",
"=",
"$",
"this",
"->",
"getDiscountLineOrder",
"(",
"$",
"line",
")",
";",
"}",
"return",
"$",
"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 |
30,203 | 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",
"->",
"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",
";",
"}"
] | 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",
"the",
"OrderSlipDetail",
"amounts",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Creator.php#L418-L479 |
30,204 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,205 | 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 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",
")",
";",
"}"
] | 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 |
30,206 | 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 |
30,207 | 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",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"element",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | 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 |
30,208 | 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'",
"]",
")",
"?",
"$",
"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",
";",
"}"
] | 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 |
30,209 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,210 | 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",
"::",
"WARNING",
";",
"case",
"Log",
"::",
"Notice",
":",
"return",
"JLog",
"::",
"NOTICE",
";",
"case",
"Log",
"::",
"Info",
":",
"return",
"JLog",
"::",
"INFO",
";",
"case",
"Log",
"::",
"Debug",
":",
"default",
":",
"return",
"JLog",
"::",
"DEBUG",
";",
"}",
"}"
] | 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 |
30,211 | 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",
"(",
"$",
"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",
")",
";",
"}",
"}",
"}"
] | 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 |
30,212 | 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",
"(",
"'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",
";",
"}"
] | 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 |
30,213 | 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 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",
";",
"}"
] | 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 |
30,214 | 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",
"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",
";",
"}"
] | 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 |
30,215 | 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",
"(",
"$",
"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",
")",
")",
";",
"}"
] | 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 |
30,216 | 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",
")",
";",
"return",
"$",
"arr",
";",
"}"
] | 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 |
30,217 | 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 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",
";",
"}"
] | 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 |
30,218 | 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",
")",
"as",
"$",
"value",
")",
"{",
"array_push",
"(",
"$",
"methods",
",",
"array",
"(",
"'PaymentMethodCode'",
"=>",
"$",
"value",
"->",
"PaymentMethodCode",
",",
"'Description'",
"=>",
"$",
"value",
"->",
"Description",
",",
"'Issuers'",
"=>",
"$",
"this",
"->",
"convertIssuers",
"(",
"$",
"this",
"->",
"forceArray",
"(",
"$",
"value",
"->",
"Issuers",
"->",
"Issuer",
")",
")",
")",
")",
";",
"}",
";",
"return",
"$",
"methods",
";",
"}"
] | 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 |
30,219 | 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_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",
";",
"}"
] | 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 |
30,220 | 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",
"=",
"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",
";",
"}"
] | 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 |
30,221 | 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",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | 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 |
30,222 | 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",
"->",
"_paymentMethodsArray",
"as",
"$",
"paymentMethod",
")",
"{",
"if",
"(",
"$",
"paymentMethod",
"[",
"\"PaymentMethodCode\"",
"]",
"==",
"strtoupper",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"_methodData",
"=",
"$",
"paymentMethod",
";",
"break",
";",
"}",
"}",
"return",
"$",
"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 |
30,223 | 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",
"->",
"_paymentMethodsArray",
"as",
"$",
"paymentMethod",
")",
"{",
"foreach",
"(",
"$",
"paymentMethod",
"[",
"\"Issuers\"",
"]",
"as",
"$",
"issuer",
")",
"{",
"if",
"(",
"$",
"issuer",
"[",
"\"IssuerKeyword\"",
"]",
"==",
"strtoupper",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"_methodData",
"=",
"$",
"paymentMethod",
";",
"$",
"this",
"->",
"_issuerData",
"=",
"$",
"issuer",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"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 |
30,224 | 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",
")",
";",
"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",
";",
"}"
] | 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 |
30,225 | 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",
"->",
"_country",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Country must be selected first\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_issuerData",
"[",
"\"Countries\"",
"]",
"as",
"$",
"country",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_country",
"==",
"$",
"country",
"[",
"\"CountryCode\"",
"]",
")",
"{",
"return",
"intval",
"(",
"$",
"country",
"[",
"\"MaximumAmount\"",
"]",
")",
";",
"}",
"}",
"}"
] | 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 |
30,226 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,227 | 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 ---------",
"$",
"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",
";",
"}"
] | 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",
"is",
"a",
"PhoneCheckoutResponse",
"object",
"which",
"contains",
"extra",
"members",
"such",
"as",
"the",
"phone",
"number",
"etc",
".",
"making",
"seamless",
"integration",
"possible",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1242-L1285 |
30,228 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,229 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,230 | 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",
"=",
"$",
"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",
";",
"}"
] | 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 |
30,231 | 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",
"=",
"$",
"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",
";",
"}"
] | 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",
"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",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_webservice.php#L1619-L1658 |
30,232 | 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",
"(",
")",
";",
"$",
"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",
";",
"}"
] | 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 |
30,233 | 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",
"(",
")",
";",
"$",
"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",
"(",
")",
";",
"}"
] | 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 |
30,234 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,235 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,236 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,237 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,238 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,239 | 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",
")",
"{",
"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",
")",
";",
"}"
] | 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 |
30,240 | ems-project/EMSCommonBundle | Helper/ArrayTool.php | ArrayTool.normalizeAndSerializeArray | public static function normalizeAndSerializeArray(array &$array, int $sort_flags = SORT_REGULAR, int $jsonEncodeOptions = 0)
{
ArrayTool::normalizeArray($array, $sort_flags);
return json_encode($array, $jsonEncodeOptions);
} | php | public static function normalizeAndSerializeArray(array &$array, int $sort_flags = SORT_REGULAR, int $jsonEncodeOptions = 0)
{
ArrayTool::normalizeArray($array, $sort_flags);
return json_encode($array, $jsonEncodeOptions);
} | [
"public",
"static",
"function",
"normalizeAndSerializeArray",
"(",
"array",
"&",
"$",
"array",
",",
"int",
"$",
"sort_flags",
"=",
"SORT_REGULAR",
",",
"int",
"$",
"jsonEncodeOptions",
"=",
"0",
")",
"{",
"ArrayTool",
"::",
"normalizeArray",
"(",
"$",
"array",
",",
"$",
"sort_flags",
")",
";",
"return",
"json_encode",
"(",
"$",
"array",
",",
"$",
"jsonEncodeOptions",
")",
";",
"}"
] | Normalize and json encode an array in order to compute it's hash
@param array $array
@param int $sort_flags
@param int $jsonEncodeOptions
@return false|string | [
"Normalize",
"and",
"json",
"encode",
"an",
"array",
"in",
"order",
"to",
"compute",
"it",
"s",
"hash"
] | 994fce2f727ebf702d327ba4cfce53d3c75bcef5 | https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Helper/ArrayTool.php#L15-L19 |
30,241 | ems-project/EMSCommonBundle | Helper/ArrayTool.php | ArrayTool.normalizeArray | public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR)
{
ksort($array, $sort_flags);
foreach ($array as $index => &$arr) {
if (is_array($arr)) {
ArrayTool::normalizeArray($arr, $sort_flags);
}
if (is_array($array[$index]) && empty($array[$index])) {
unset($array[$index]);
}
}
} | php | public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR)
{
ksort($array, $sort_flags);
foreach ($array as $index => &$arr) {
if (is_array($arr)) {
ArrayTool::normalizeArray($arr, $sort_flags);
}
if (is_array($array[$index]) && empty($array[$index])) {
unset($array[$index]);
}
}
} | [
"public",
"static",
"function",
"normalizeArray",
"(",
"array",
"&",
"$",
"array",
",",
"int",
"$",
"sort_flags",
"=",
"SORT_REGULAR",
")",
"{",
"ksort",
"(",
"$",
"array",
",",
"$",
"sort_flags",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"index",
"=>",
"&",
"$",
"arr",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"ArrayTool",
"::",
"normalizeArray",
"(",
"$",
"arr",
",",
"$",
"sort_flags",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"array",
"[",
"$",
"index",
"]",
")",
"&&",
"empty",
"(",
"$",
"array",
"[",
"$",
"index",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"}"
] | Normalize an array in order to compute it's hash
@param array $array
@param int $sort_flags | [
"Normalize",
"an",
"array",
"in",
"order",
"to",
"compute",
"it",
"s",
"hash"
] | 994fce2f727ebf702d327ba4cfce53d3c75bcef5 | https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Helper/ArrayTool.php#L27-L40 |
30,242 | SIELOnline/libAcumulus | src/Web/Result.php | Result.getStatusText | public function getStatusText()
{
switch ($this->getStatus()) {
case self::Status_Success:
return $this->t('message_response_success');
case self::Status_Notices:
return $this->t('message_response_notices');
case self::Status_Warnings:
return $this->t('message_response_warnings');
case self::Status_Errors:
return $this->t('message_response_errors');
case self::Status_Exception:
return $this->t('message_response_exception');
case null:
return $this->t('message_response_not_set');
default:
return sprintf($this->t('message_response_unknown'), $this->getStatus());
}
} | php | public function getStatusText()
{
switch ($this->getStatus()) {
case self::Status_Success:
return $this->t('message_response_success');
case self::Status_Notices:
return $this->t('message_response_notices');
case self::Status_Warnings:
return $this->t('message_response_warnings');
case self::Status_Errors:
return $this->t('message_response_errors');
case self::Status_Exception:
return $this->t('message_response_exception');
case null:
return $this->t('message_response_not_set');
default:
return sprintf($this->t('message_response_unknown'), $this->getStatus());
}
} | [
"public",
"function",
"getStatusText",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
")",
"{",
"case",
"self",
"::",
"Status_Success",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_success'",
")",
";",
"case",
"self",
"::",
"Status_Notices",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_notices'",
")",
";",
"case",
"self",
"::",
"Status_Warnings",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_warnings'",
")",
";",
"case",
"self",
"::",
"Status_Errors",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_errors'",
")",
";",
"case",
"self",
"::",
"Status_Exception",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_exception'",
")",
";",
"case",
"null",
":",
"return",
"$",
"this",
"->",
"t",
"(",
"'message_response_not_set'",
")",
";",
"default",
":",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"t",
"(",
"'message_response_unknown'",
")",
",",
"$",
"this",
"->",
"getStatus",
"(",
")",
")",
";",
"}",
"}"
] | Returns a textual representation of the status.
@return string | [
"Returns",
"a",
"textual",
"representation",
"of",
"the",
"status",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L190-L208 |
30,243 | SIELOnline/libAcumulus | src/Web/Result.php | Result.getExceptionMessage | public function getExceptionMessage()
{
$message = '';
if (($e = $this->getException()) !== null) {
$message = $e->getCode() . ': ' . $e->getMessage();
$message = $this->t('message_exception') . ' ' . $message;
}
return $message;
} | php | public function getExceptionMessage()
{
$message = '';
if (($e = $this->getException()) !== null) {
$message = $e->getCode() . ': ' . $e->getMessage();
$message = $this->t('message_exception') . ' ' . $message;
}
return $message;
} | [
"public",
"function",
"getExceptionMessage",
"(",
")",
"{",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"(",
"$",
"e",
"=",
"$",
"this",
"->",
"getException",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"message",
"=",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"t",
"(",
"'message_exception'",
")",
".",
"' '",
".",
"$",
"message",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | Returns the exception message, if an exception was set.
@return string | [
"Returns",
"the",
"exception",
"message",
"if",
"an",
"exception",
"was",
"set",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L285-L293 |
30,244 | SIELOnline/libAcumulus | src/Web/Result.php | Result.addMessages | protected function addMessages($method, array $messages)
{
// If there was exactly 1 message, it wasn't put in an array of messages.
if (array_key_exists('code', $messages)) {
$messages = array($messages);
}
foreach ($messages as $message) {
call_user_func(array($this, $method), $message);
}
return $this;
} | php | protected function addMessages($method, array $messages)
{
// If there was exactly 1 message, it wasn't put in an array of messages.
if (array_key_exists('code', $messages)) {
$messages = array($messages);
}
foreach ($messages as $message) {
call_user_func(array($this, $method), $message);
}
return $this;
} | [
"protected",
"function",
"addMessages",
"(",
"$",
"method",
",",
"array",
"$",
"messages",
")",
"{",
"// If there was exactly 1 message, it wasn't put in an array of messages.",
"if",
"(",
"array_key_exists",
"(",
"'code'",
",",
"$",
"messages",
")",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
"$",
"messages",
")",
";",
"}",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds multiple warnings to the list of warnings.
A single warning may be passed in as a 1-dimensional array.
@param string $method
@param array $messages
@return $this | [
"Adds",
"multiple",
"warnings",
"to",
"the",
"list",
"of",
"warnings",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L383-L393 |
30,245 | SIELOnline/libAcumulus | src/Web/Result.php | Result.addError | public function addError($code, $codeTag = '', $message = '')
{
return $this->addMessage($code, $codeTag, $message, $this->errors, self::Status_Errors);
} | php | public function addError($code, $codeTag = '', $message = '')
{
return $this->addMessage($code, $codeTag, $message, $this->errors, self::Status_Errors);
} | [
"public",
"function",
"addError",
"(",
"$",
"code",
",",
"$",
"codeTag",
"=",
"''",
",",
"$",
"message",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"code",
",",
"$",
"codeTag",
",",
"$",
"message",
",",
"$",
"this",
"->",
"errors",
",",
"self",
"::",
"Status_Errors",
")",
";",
"}"
] | Adds an error to the list of errors.
@param int|array $code
Error code number. Usually of type 4xx, 5xx, 6xx or 7xx (internal).
It may also be an already completed error array.
@param string $codeTag
Special code tag. Use this as a reference when communicating with
Acumulus technical support.
@param string $message
A message describing the error.
@return $this | [
"Adds",
"an",
"error",
"to",
"the",
"list",
"of",
"errors",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L409-L412 |
30,246 | SIELOnline/libAcumulus | src/Web/Result.php | Result.addNotice | public function addNotice($code, $codeTag = '', $message = '')
{
return $this->addMessage($code, $codeTag, $message, $this->notices, self::Status_Notices);
} | php | public function addNotice($code, $codeTag = '', $message = '')
{
return $this->addMessage($code, $codeTag, $message, $this->notices, self::Status_Notices);
} | [
"public",
"function",
"addNotice",
"(",
"$",
"code",
",",
"$",
"codeTag",
"=",
"''",
",",
"$",
"message",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"addMessage",
"(",
"$",
"code",
",",
"$",
"codeTag",
",",
"$",
"message",
",",
"$",
"this",
"->",
"notices",
",",
"self",
"::",
"Status_Notices",
")",
";",
"}"
] | Adds a notice to the list of notices.
@param int $code
Notice code number. Usually of type 4xx, 5xx, 6xx or 7xx (internal).
It may also be an already completed notice array.
@param string $codeTag
Special code tag. Use this as a reference when communicating with
Acumulus technical support.
@param string $message
A message describing the notice.
@return $this | [
"Adds",
"a",
"notice",
"to",
"the",
"list",
"of",
"notices",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L447-L450 |
30,247 | SIELOnline/libAcumulus | src/Web/Result.php | Result.mergeMessages | public function mergeMessages(Result $other, $errorsAsWarnings = false)
{
if ($this->getException() === null && $other->getException() !== null) {
$this->setException($other->getException());
}
if ($errorsAsWarnings) {
$this->addWarnings($other->getErrors());
} else {
$this->addErrors($other->getErrors());
}
return $this->addWarnings($other->getWarnings())->addNotices($other->getNotices());
} | php | public function mergeMessages(Result $other, $errorsAsWarnings = false)
{
if ($this->getException() === null && $other->getException() !== null) {
$this->setException($other->getException());
}
if ($errorsAsWarnings) {
$this->addWarnings($other->getErrors());
} else {
$this->addErrors($other->getErrors());
}
return $this->addWarnings($other->getWarnings())->addNotices($other->getNotices());
} | [
"public",
"function",
"mergeMessages",
"(",
"Result",
"$",
"other",
",",
"$",
"errorsAsWarnings",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getException",
"(",
")",
"===",
"null",
"&&",
"$",
"other",
"->",
"getException",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setException",
"(",
"$",
"other",
"->",
"getException",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"errorsAsWarnings",
")",
"{",
"$",
"this",
"->",
"addWarnings",
"(",
"$",
"other",
"->",
"getErrors",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addErrors",
"(",
"$",
"other",
"->",
"getErrors",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addWarnings",
"(",
"$",
"other",
"->",
"getWarnings",
"(",
")",
")",
"->",
"addNotices",
"(",
"$",
"other",
"->",
"getNotices",
"(",
")",
")",
";",
"}"
] | Merges sets of exception, error and warning messages of 2 results.
This allows to inform the user about errors and warnings that occurred
during additional API calls, e.g. querying VAT rates or deleteing old
entries.
@param \Siel\Acumulus\Web\Result $other
The other result to add the messages from.
@param bool $errorsAsWarnings
Whether errors should be merged as errors or as mere warnings because
the main result is not really influenced by these errors.
@return $this | [
"Merges",
"sets",
"of",
"exception",
"error",
"and",
"warning",
"messages",
"of",
"2",
"results",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L508-L519 |
30,248 | SIELOnline/libAcumulus | src/Web/Result.php | Result.hasMessages | public function hasMessages()
{
return !empty($this->notices) || !empty($this->warnings) || !empty($this->errors) || !empty($this->exception);
} | php | public function hasMessages()
{
return !empty($this->notices) || !empty($this->warnings) || !empty($this->errors) || !empty($this->exception);
} | [
"public",
"function",
"hasMessages",
"(",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"notices",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"warnings",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"exception",
")",
";",
"}"
] | Returns whether the result contains a warning, error or exception.
@return bool
True if the result contains at least 1 warning, error or exception,
false otherwise. | [
"Returns",
"whether",
"the",
"result",
"contains",
"a",
"warning",
"error",
"or",
"exception",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L528-L531 |
30,249 | SIELOnline/libAcumulus | src/Web/Result.php | Result.hasCode | public function hasCode($code)
{
if ($this->getException() !== null && $this->getException()->getCode() === $code) {
return true;
}
foreach ($this->getErrors() as $message) {
if ($message['code'] == $code) {
return true;
}
}
foreach ($this->getWarnings() as $message) {
if ($message['code'] == $code) {
return true;
}
}
foreach ($this->getNotices() as $message) {
if ($message['code'] == $code) {
return true;
}
}
return false;
} | php | public function hasCode($code)
{
if ($this->getException() !== null && $this->getException()->getCode() === $code) {
return true;
}
foreach ($this->getErrors() as $message) {
if ($message['code'] == $code) {
return true;
}
}
foreach ($this->getWarnings() as $message) {
if ($message['code'] == $code) {
return true;
}
}
foreach ($this->getNotices() as $message) {
if ($message['code'] == $code) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasCode",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getException",
"(",
")",
"!==",
"null",
"&&",
"$",
"this",
"->",
"getException",
"(",
")",
"->",
"getCode",
"(",
")",
"===",
"$",
"code",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getErrors",
"(",
")",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"[",
"'code'",
"]",
"==",
"$",
"code",
")",
"{",
"return",
"true",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getWarnings",
"(",
")",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"[",
"'code'",
"]",
"==",
"$",
"code",
")",
"{",
"return",
"true",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getNotices",
"(",
")",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"[",
"'code'",
"]",
"==",
"$",
"code",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether the result contains a given code.
@param int $code
@return bool
True if the result contains a given code, false otherwise. | [
"Returns",
"whether",
"the",
"result",
"contains",
"a",
"given",
"code",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L553-L578 |
30,250 | SIELOnline/libAcumulus | src/Web/Result.php | Result.hasCodeTag | public function hasCodeTag($codeTag)
{
return array_key_exists($codeTag, $this->errors) || array_key_exists($codeTag, $this->warnings) || array_key_exists($codeTag, $this->notices);
} | php | public function hasCodeTag($codeTag)
{
return array_key_exists($codeTag, $this->errors) || array_key_exists($codeTag, $this->warnings) || array_key_exists($codeTag, $this->notices);
} | [
"public",
"function",
"hasCodeTag",
"(",
"$",
"codeTag",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"codeTag",
",",
"$",
"this",
"->",
"errors",
")",
"||",
"array_key_exists",
"(",
"$",
"codeTag",
",",
"$",
"this",
"->",
"warnings",
")",
"||",
"array_key_exists",
"(",
"$",
"codeTag",
",",
"$",
"this",
"->",
"notices",
")",
";",
"}"
] | Returns whether the result contains a given codeTag.
@param string $codeTag
@return bool
True if the result contains a given codeTag, false otherwise. | [
"Returns",
"whether",
"the",
"result",
"contains",
"a",
"given",
"codeTag",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L588-L591 |
30,251 | SIELOnline/libAcumulus | src/Web/Result.php | Result.getMessages | public function getMessages($format = self::Format_Array)
{
$messages = array();
// Collect the messages.
if (($message = $this->getExceptionMessage()) !== '') {
$messages[] = $message;
}
$messages = array_merge($messages, $this->getErrors(self::Format_PlainTextArray));
$messages = array_merge($messages, $this->getWarnings(self::Format_PlainTextArray));
$messages = array_merge($messages, $this->getNotices(self::Format_PlainTextArray));
return $this->formatMessages($messages, $format);
} | php | public function getMessages($format = self::Format_Array)
{
$messages = array();
// Collect the messages.
if (($message = $this->getExceptionMessage()) !== '') {
$messages[] = $message;
}
$messages = array_merge($messages, $this->getErrors(self::Format_PlainTextArray));
$messages = array_merge($messages, $this->getWarnings(self::Format_PlainTextArray));
$messages = array_merge($messages, $this->getNotices(self::Format_PlainTextArray));
return $this->formatMessages($messages, $format);
} | [
"public",
"function",
"getMessages",
"(",
"$",
"format",
"=",
"self",
"::",
"Format_Array",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"// Collect the messages.",
"if",
"(",
"(",
"$",
"message",
"=",
"$",
"this",
"->",
"getExceptionMessage",
"(",
")",
")",
"!==",
"''",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"$",
"messages",
"=",
"array_merge",
"(",
"$",
"messages",
",",
"$",
"this",
"->",
"getErrors",
"(",
"self",
"::",
"Format_PlainTextArray",
")",
")",
";",
"$",
"messages",
"=",
"array_merge",
"(",
"$",
"messages",
",",
"$",
"this",
"->",
"getWarnings",
"(",
"self",
"::",
"Format_PlainTextArray",
")",
")",
";",
"$",
"messages",
"=",
"array_merge",
"(",
"$",
"messages",
",",
"$",
"this",
"->",
"getNotices",
"(",
"self",
"::",
"Format_PlainTextArray",
")",
")",
";",
"return",
"$",
"this",
"->",
"formatMessages",
"(",
"$",
"messages",
",",
"$",
"format",
")",
";",
"}"
] | If the result contains any errors or warnings, a list of verbose messages
is returned.
@param int $format
The format in which to return the messages:
- Result::Format_PlainTextArray: an array of strings
- Result::Format_FormattedText: a plain text string with all messages
on its own line indented by a '*'.
- Result::Format_Html: a html string with all messages in an
unordered HTML list
@return string|string[]
An string or array with textual messages that can be used to inform the
user. | [
"If",
"the",
"result",
"contains",
"any",
"errors",
"or",
"warnings",
"a",
"list",
"of",
"verbose",
"messages",
"is",
"returned",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L609-L622 |
30,252 | SIELOnline/libAcumulus | src/Web/Result.php | Result.formatMessages | protected function formatMessages($messages, $format, $type = '')
{
if ($format === self::Format_Array) {
$result = $messages;
} else {
$result = array();
foreach ($messages as $message) {
if (is_array($message)) {
$messagePart = "{$message['code']}: ";
$messagePart .= $this->t($message['message']);
if ($message['codetag']) {
$messagePart .= " ({$message['codetag']})";
}
$message = $this->t($type) . ' ' . $messagePart;
}
if ($format === self::Format_FormattedText) {
$message = "* $message\n\n";
} elseif ($format === self::Format_Html) {
$message = "<li>" . nl2br(htmlspecialchars($message, ENT_NOQUOTES)) . "</li>\n";
}
$result[] = $message;
}
if ($format === self::Format_FormattedText) {
$result = implode('', $result);
} elseif ($format === self::Format_Html) {
$result = "<ul>\n" . implode('', $result) . "</ul>\n";
}
}
return $result;
} | php | protected function formatMessages($messages, $format, $type = '')
{
if ($format === self::Format_Array) {
$result = $messages;
} else {
$result = array();
foreach ($messages as $message) {
if (is_array($message)) {
$messagePart = "{$message['code']}: ";
$messagePart .= $this->t($message['message']);
if ($message['codetag']) {
$messagePart .= " ({$message['codetag']})";
}
$message = $this->t($type) . ' ' . $messagePart;
}
if ($format === self::Format_FormattedText) {
$message = "* $message\n\n";
} elseif ($format === self::Format_Html) {
$message = "<li>" . nl2br(htmlspecialchars($message, ENT_NOQUOTES)) . "</li>\n";
}
$result[] = $message;
}
if ($format === self::Format_FormattedText) {
$result = implode('', $result);
} elseif ($format === self::Format_Html) {
$result = "<ul>\n" . implode('', $result) . "</ul>\n";
}
}
return $result;
} | [
"protected",
"function",
"formatMessages",
"(",
"$",
"messages",
",",
"$",
"format",
",",
"$",
"type",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"format",
"===",
"self",
"::",
"Format_Array",
")",
"{",
"$",
"result",
"=",
"$",
"messages",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"$",
"messagePart",
"=",
"\"{$message['code']}: \"",
";",
"$",
"messagePart",
".=",
"$",
"this",
"->",
"t",
"(",
"$",
"message",
"[",
"'message'",
"]",
")",
";",
"if",
"(",
"$",
"message",
"[",
"'codetag'",
"]",
")",
"{",
"$",
"messagePart",
".=",
"\" ({$message['codetag']})\"",
";",
"}",
"$",
"message",
"=",
"$",
"this",
"->",
"t",
"(",
"$",
"type",
")",
".",
"' '",
".",
"$",
"messagePart",
";",
"}",
"if",
"(",
"$",
"format",
"===",
"self",
"::",
"Format_FormattedText",
")",
"{",
"$",
"message",
"=",
"\"* $message\\n\\n\"",
";",
"}",
"elseif",
"(",
"$",
"format",
"===",
"self",
"::",
"Format_Html",
")",
"{",
"$",
"message",
"=",
"\"<li>\"",
".",
"nl2br",
"(",
"htmlspecialchars",
"(",
"$",
"message",
",",
"ENT_NOQUOTES",
")",
")",
".",
"\"</li>\\n\"",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"if",
"(",
"$",
"format",
"===",
"self",
"::",
"Format_FormattedText",
")",
"{",
"$",
"result",
"=",
"implode",
"(",
"''",
",",
"$",
"result",
")",
";",
"}",
"elseif",
"(",
"$",
"format",
"===",
"self",
"::",
"Format_Html",
")",
"{",
"$",
"result",
"=",
"\"<ul>\\n\"",
".",
"implode",
"(",
"''",
",",
"$",
"result",
")",
".",
"\"</ul>\\n\"",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Formats a set of messages.
@param string[] $messages
@param int $format
@param string $type
@return string|\string[] | [
"Formats",
"a",
"set",
"of",
"messages",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L634-L664 |
30,253 | SIELOnline/libAcumulus | src/Web/Result.php | Result.ApiStatus2InternalStatus | protected function ApiStatus2InternalStatus($status)
{
switch ($status) {
case Api::Success:
return self::Status_Success;
case Api::Errors:
return self::Status_Errors;
case Api::Warnings:
return self::Status_Warnings;
case Api::Exception:
default:
return self::Status_Exception;
}
} | php | protected function ApiStatus2InternalStatus($status)
{
switch ($status) {
case Api::Success:
return self::Status_Success;
case Api::Errors:
return self::Status_Errors;
case Api::Warnings:
return self::Status_Warnings;
case Api::Exception:
default:
return self::Status_Exception;
}
} | [
"protected",
"function",
"ApiStatus2InternalStatus",
"(",
"$",
"status",
")",
"{",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"Api",
"::",
"Success",
":",
"return",
"self",
"::",
"Status_Success",
";",
"case",
"Api",
"::",
"Errors",
":",
"return",
"self",
"::",
"Status_Errors",
";",
"case",
"Api",
"::",
"Warnings",
":",
"return",
"self",
"::",
"Status_Warnings",
";",
"case",
"Api",
"::",
"Exception",
":",
"default",
":",
"return",
"self",
"::",
"Status_Exception",
";",
"}",
"}"
] | Returns the corresponding internal status.
@param $status
The status as returned by the API.
@return int
The corresponding internal status. | [
"Returns",
"the",
"corresponding",
"internal",
"status",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L721-L734 |
30,254 | SIELOnline/libAcumulus | src/Web/Result.php | Result.getRawRequestResponse | public function getRawRequestResponse($format)
{
$result = '';
if ($this->getRawRequest() !== null || $this->getRawResponse() !== null) {
$messages = array();
if ($this->getRawRequest() !== null) {
$messages[] = $this->t('message_sent') . ":\n" . $this->getRawRequest();
}
if ($this->getRawResponse() !== null) {
$messages[] = $this->t('message_received') . ":\n" . $this->getRawResponse();
}
$result .= $this->formatMessages($messages, $format);
}
return $result;
} | php | public function getRawRequestResponse($format)
{
$result = '';
if ($this->getRawRequest() !== null || $this->getRawResponse() !== null) {
$messages = array();
if ($this->getRawRequest() !== null) {
$messages[] = $this->t('message_sent') . ":\n" . $this->getRawRequest();
}
if ($this->getRawResponse() !== null) {
$messages[] = $this->t('message_received') . ":\n" . $this->getRawResponse();
}
$result .= $this->formatMessages($messages, $format);
}
return $result;
} | [
"public",
"function",
"getRawRequestResponse",
"(",
"$",
"format",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getRawRequest",
"(",
")",
"!==",
"null",
"||",
"$",
"this",
"->",
"getRawResponse",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getRawRequest",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'message_sent'",
")",
".",
"\":\\n\"",
".",
"$",
"this",
"->",
"getRawRequest",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getRawResponse",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'message_received'",
")",
".",
"\":\\n\"",
".",
"$",
"this",
"->",
"getRawResponse",
"(",
")",
";",
"}",
"$",
"result",
".=",
"$",
"this",
"->",
"formatMessages",
"(",
"$",
"messages",
",",
"$",
"format",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns a string with messages for support, ie the request and response.
In html format it will be formatted in a details tag so that it is closed
by default.
@param $format
@return string | [
"Returns",
"a",
"string",
"with",
"messages",
"for",
"support",
"ie",
"the",
"request",
"and",
"response",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L801-L815 |
30,255 | SIELOnline/libAcumulus | src/Web/Result.php | Result.toLogString | public function toLogString()
{
$logParts = array();
if ($this->getStatus() !== null) {
$logParts[] = 'status=' . $this->getStatus();
}
if ($this->getRawRequest() !== null) {
$logParts[] = 'request=' . $this->getRawRequest();
}
if ($this->getRawResponse() !== null) {
$logParts[] = 'response=' . $this->getRawResponse();
}
if ($this->getException() !== null) {
$logParts[] = $this->getException()->__toString();
}
return implode('; ', $logParts);
} | php | public function toLogString()
{
$logParts = array();
if ($this->getStatus() !== null) {
$logParts[] = 'status=' . $this->getStatus();
}
if ($this->getRawRequest() !== null) {
$logParts[] = 'request=' . $this->getRawRequest();
}
if ($this->getRawResponse() !== null) {
$logParts[] = 'response=' . $this->getRawResponse();
}
if ($this->getException() !== null) {
$logParts[] = $this->getException()->__toString();
}
return implode('; ', $logParts);
} | [
"public",
"function",
"toLogString",
"(",
")",
"{",
"$",
"logParts",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"logParts",
"[",
"]",
"=",
"'status='",
".",
"$",
"this",
"->",
"getStatus",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getRawRequest",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"logParts",
"[",
"]",
"=",
"'request='",
".",
"$",
"this",
"->",
"getRawRequest",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getRawResponse",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"logParts",
"[",
"]",
"=",
"'response='",
".",
"$",
"this",
"->",
"getRawResponse",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getException",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"logParts",
"[",
"]",
"=",
"$",
"this",
"->",
"getException",
"(",
")",
"->",
"__toString",
"(",
")",
";",
"}",
"return",
"implode",
"(",
"'; '",
",",
"$",
"logParts",
")",
";",
"}"
] | Returns a string representation of the result object for logging purposes.
@return string
A string representation of the result object for logging purposes. | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"result",
"object",
"for",
"logging",
"purposes",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L823-L839 |
30,256 | SIELOnline/libAcumulus | src/Web/Result.php | Result.simplifyResponse | protected function simplifyResponse(array $response)
{
// Simplify response by removing main key (which should be the only
// remaining one).
if (!empty($this->mainResponseKey) && isset($response[$this->mainResponseKey])) {
$response = $response[$this->mainResponseKey];
if ($this->isList) {
// Remove further indirection, i.e. get value of "singular",
// which will be the first (and only) key.
$response = reset($response);
// If there was only 1 list result, it wasn't put in an array.
if (!is_array(reset($response))) {
$response = array($response);
}
}
}
return $response;
} | php | protected function simplifyResponse(array $response)
{
// Simplify response by removing main key (which should be the only
// remaining one).
if (!empty($this->mainResponseKey) && isset($response[$this->mainResponseKey])) {
$response = $response[$this->mainResponseKey];
if ($this->isList) {
// Remove further indirection, i.e. get value of "singular",
// which will be the first (and only) key.
$response = reset($response);
// If there was only 1 list result, it wasn't put in an array.
if (!is_array(reset($response))) {
$response = array($response);
}
}
}
return $response;
} | [
"protected",
"function",
"simplifyResponse",
"(",
"array",
"$",
"response",
")",
"{",
"// Simplify response by removing main key (which should be the only",
"// remaining one).",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"mainResponseKey",
")",
"&&",
"isset",
"(",
"$",
"response",
"[",
"$",
"this",
"->",
"mainResponseKey",
"]",
")",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"[",
"$",
"this",
"->",
"mainResponseKey",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isList",
")",
"{",
"// Remove further indirection, i.e. get value of \"singular\",",
"// which will be the first (and only) key.",
"$",
"response",
"=",
"reset",
"(",
"$",
"response",
")",
";",
"// If there was only 1 list result, it wasn't put in an array.",
"if",
"(",
"!",
"is_array",
"(",
"reset",
"(",
"$",
"response",
")",
")",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"$",
"response",
")",
";",
"}",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | Simplify the response by removing the main key.
@param array $response
@return array | [
"Simplify",
"the",
"response",
"by",
"removing",
"the",
"main",
"key",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L848-L866 |
30,257 | ems-project/EMSCommonBundle | Storage/Processor/Config.php | Config.isValid | public function isValid(\DateTime $lastCacheDate = null): bool
{
$publishedDateTime = $this->getLastUpdateDate();
if ($publishedDateTime && $publishedDateTime < $lastCacheDate) {
return true;
}
return null === $publishedDateTime && null !== $lastCacheDate;
} | php | public function isValid(\DateTime $lastCacheDate = null): bool
{
$publishedDateTime = $this->getLastUpdateDate();
if ($publishedDateTime && $publishedDateTime < $lastCacheDate) {
return true;
}
return null === $publishedDateTime && null !== $lastCacheDate;
} | [
"public",
"function",
"isValid",
"(",
"\\",
"DateTime",
"$",
"lastCacheDate",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"publishedDateTime",
"=",
"$",
"this",
"->",
"getLastUpdateDate",
"(",
")",
";",
"if",
"(",
"$",
"publishedDateTime",
"&&",
"$",
"publishedDateTime",
"<",
"$",
"lastCacheDate",
")",
"{",
"return",
"true",
";",
"}",
"return",
"null",
"===",
"$",
"publishedDateTime",
"&&",
"null",
"!==",
"$",
"lastCacheDate",
";",
"}"
] | Asset_config_type is optional, so _published_datetime can be null | [
"Asset_config_type",
"is",
"optional",
"so",
"_published_datetime",
"can",
"be",
"null"
] | 994fce2f727ebf702d327ba4cfce53d3c75bcef5 | https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Storage/Processor/Config.php#L57-L66 |
30,258 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.getUri | public function getUri($apiFunction)
{
$environment = $this->config->getEnvironment();
$uri = $environment['baseUri'] . '/' . $environment['apiVersion'] . '/' . $apiFunction . '.php';
return $uri;
} | php | public function getUri($apiFunction)
{
$environment = $this->config->getEnvironment();
$uri = $environment['baseUri'] . '/' . $environment['apiVersion'] . '/' . $apiFunction . '.php';
return $uri;
} | [
"public",
"function",
"getUri",
"(",
"$",
"apiFunction",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"config",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"environment",
"[",
"'baseUri'",
"]",
".",
"'/'",
".",
"$",
"environment",
"[",
"'apiVersion'",
"]",
".",
"'/'",
".",
"$",
"apiFunction",
".",
"'.php'",
";",
"return",
"$",
"uri",
";",
"}"
] | Returns the uri to the requested API call.
@param string $apiFunction
@return string
The uri to the requested API call. | [
"Returns",
"the",
"uri",
"to",
"the",
"requested",
"API",
"call",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L63-L68 |
30,259 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.callApiFunction | public function callApiFunction($apiFunction, array $message, Result $result = null)
{
if ($result === null) {
$result = $this->container->getResult();
}
$uri = $this->getUri($apiFunction);
try {
$commonMessagePart = $this->getCommonPart();
$message = array_merge($commonMessagePart, $message);
// Send message, receive response.
$result = $this->sendApiMessage($uri, $message, $result);
} catch (RuntimeException $e) {
$result->setException($e);
}
$this->log->debug('Communicator::callApiFunction() uri=%s; %s', $uri, $result->toLogString());
return $result;
} | php | public function callApiFunction($apiFunction, array $message, Result $result = null)
{
if ($result === null) {
$result = $this->container->getResult();
}
$uri = $this->getUri($apiFunction);
try {
$commonMessagePart = $this->getCommonPart();
$message = array_merge($commonMessagePart, $message);
// Send message, receive response.
$result = $this->sendApiMessage($uri, $message, $result);
} catch (RuntimeException $e) {
$result->setException($e);
}
$this->log->debug('Communicator::callApiFunction() uri=%s; %s', $uri, $result->toLogString());
return $result;
} | [
"public",
"function",
"callApiFunction",
"(",
"$",
"apiFunction",
",",
"array",
"$",
"message",
",",
"Result",
"$",
"result",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"container",
"->",
"getResult",
"(",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"this",
"->",
"getUri",
"(",
"$",
"apiFunction",
")",
";",
"try",
"{",
"$",
"commonMessagePart",
"=",
"$",
"this",
"->",
"getCommonPart",
"(",
")",
";",
"$",
"message",
"=",
"array_merge",
"(",
"$",
"commonMessagePart",
",",
"$",
"message",
")",
";",
"// Send message, receive response.",
"$",
"result",
"=",
"$",
"this",
"->",
"sendApiMessage",
"(",
"$",
"uri",
",",
"$",
"message",
",",
"$",
"result",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"$",
"result",
"->",
"setException",
"(",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Communicator::callApiFunction() uri=%s; %s'",
",",
"$",
"uri",
",",
"$",
"result",
"->",
"toLogString",
"(",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Sends a message to the given API function and returns the results.
@param string $apiFunction
The API function to invoke.
@param array $message
The values to submit.
@param \Siel\Acumulus\Web\Result $result
It is possible to already create a Result object before calling the Web
Service to store local messages. By passing this Result object these
local messages will be merged with any remote messages in the returned
Result object.
@return \Siel\Acumulus\Web\Result
A Result object containing the results. | [
"Sends",
"a",
"message",
"to",
"the",
"given",
"API",
"function",
"and",
"returns",
"the",
"results",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L86-L105 |
30,260 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.getCommonPart | protected function getCommonPart()
{
$environment = $this->config->getEnvironment();
$pluginSettings = $this->config->getPluginSettings();
// Complete message with values common to all API calls:
// - contract part
// - format part
// - environment part
$commonMessagePart = array(
'contract' => $this->config->getCredentials(),
'format' => $pluginSettings['outputFormat'],
'testmode' => $pluginSettings['debug'] === PluginConfig::Send_TestMode ? Api::TestMode_Test : Api::TestMode_Normal,
'connector' => array(
'application' => "{$environment['shopName']} {$environment['shopVersion']}",
'webkoppel' => "Acumulus {$environment['moduleVersion']}",
'development' => 'SIEL - Buro RaDer',
'remark' => "Library {$environment['libraryVersion']} - PHP {$environment['phpVersion']}",
'sourceuri' => 'https://www.siel.nl/',
),
);
return $commonMessagePart;
} | php | protected function getCommonPart()
{
$environment = $this->config->getEnvironment();
$pluginSettings = $this->config->getPluginSettings();
// Complete message with values common to all API calls:
// - contract part
// - format part
// - environment part
$commonMessagePart = array(
'contract' => $this->config->getCredentials(),
'format' => $pluginSettings['outputFormat'],
'testmode' => $pluginSettings['debug'] === PluginConfig::Send_TestMode ? Api::TestMode_Test : Api::TestMode_Normal,
'connector' => array(
'application' => "{$environment['shopName']} {$environment['shopVersion']}",
'webkoppel' => "Acumulus {$environment['moduleVersion']}",
'development' => 'SIEL - Buro RaDer',
'remark' => "Library {$environment['libraryVersion']} - PHP {$environment['phpVersion']}",
'sourceuri' => 'https://www.siel.nl/',
),
);
return $commonMessagePart;
} | [
"protected",
"function",
"getCommonPart",
"(",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"config",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"pluginSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getPluginSettings",
"(",
")",
";",
"// Complete message with values common to all API calls:",
"// - contract part",
"// - format part",
"// - environment part",
"$",
"commonMessagePart",
"=",
"array",
"(",
"'contract'",
"=>",
"$",
"this",
"->",
"config",
"->",
"getCredentials",
"(",
")",
",",
"'format'",
"=>",
"$",
"pluginSettings",
"[",
"'outputFormat'",
"]",
",",
"'testmode'",
"=>",
"$",
"pluginSettings",
"[",
"'debug'",
"]",
"===",
"PluginConfig",
"::",
"Send_TestMode",
"?",
"Api",
"::",
"TestMode_Test",
":",
"Api",
"::",
"TestMode_Normal",
",",
"'connector'",
"=>",
"array",
"(",
"'application'",
"=>",
"\"{$environment['shopName']} {$environment['shopVersion']}\"",
",",
"'webkoppel'",
"=>",
"\"Acumulus {$environment['moduleVersion']}\"",
",",
"'development'",
"=>",
"'SIEL - Buro RaDer'",
",",
"'remark'",
"=>",
"\"Library {$environment['libraryVersion']} - PHP {$environment['phpVersion']}\"",
",",
"'sourceuri'",
"=>",
"'https://www.siel.nl/'",
",",
")",
",",
")",
";",
"return",
"$",
"commonMessagePart",
";",
"}"
] | Returns the common part of each API message.
The common part consists of the following tags:
- contract
- format
- testmode
- connector
@return array
The common part of each API message. | [
"Returns",
"the",
"common",
"part",
"of",
"each",
"API",
"message",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L119-L141 |
30,261 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.sendApiMessage | protected function sendApiMessage($uri, array $message, Result $result)
{
// Convert message to XML. XML requires 1 top level tag, so add one.
// The tagname is ignored by the Acumulus WebAPI.
$message = $this->convertArrayToXml(array('myxml' => $message));
// Keep track of communication for debugging/logging at higher levels.
$result->setRawRequest($message);
$rawResponse = $this->sendHttpPost($uri, array('xmlstring' => $message), $result);
$result->setRawResponse($rawResponse);
if (empty($rawResponse)) {
// CURL may get a time-out and return an empty response without
// further error messages: Add an error to tell the user to check if
// the invoice was sent or not.
$result->addError(701, 'Empty response', '');
} elseif ($this->isHtmlResponse($result->getRawResponse())) {
// When the API is gone we might receive an html error message page.
$this->raiseHtmlReceivedError($result->getRawResponse());
} else {
// Decode the response as either json or xml.
$response = array();
$pluginSettings = $this->config->getPluginSettings();
if ($pluginSettings['outputFormat'] === 'json') {
$response = json_decode($result->getRawResponse(), true);
}
// Even if we pass <format>json</format> we might receive an XML
// response in case the XML was rejected before or during parsing.
// So if the response is null we also try to decode the response as
// XML.
if ($pluginSettings['outputFormat'] === 'xml' || $response === null) {
try {
$response = $this->convertXmlToArray($result->getRawResponse());
} catch (RuntimeException $e) {
// Not an XML response. Treat it as an json error if we were
// expecting a json response.
if ($pluginSettings['outputFormat'] === 'json') {
$this->raiseJsonError();
}
// Otherwise treat it as the XML exception that was raised.
throw $e;
}
}
$result->setResponse($response);
}
return $result;
} | php | protected function sendApiMessage($uri, array $message, Result $result)
{
// Convert message to XML. XML requires 1 top level tag, so add one.
// The tagname is ignored by the Acumulus WebAPI.
$message = $this->convertArrayToXml(array('myxml' => $message));
// Keep track of communication for debugging/logging at higher levels.
$result->setRawRequest($message);
$rawResponse = $this->sendHttpPost($uri, array('xmlstring' => $message), $result);
$result->setRawResponse($rawResponse);
if (empty($rawResponse)) {
// CURL may get a time-out and return an empty response without
// further error messages: Add an error to tell the user to check if
// the invoice was sent or not.
$result->addError(701, 'Empty response', '');
} elseif ($this->isHtmlResponse($result->getRawResponse())) {
// When the API is gone we might receive an html error message page.
$this->raiseHtmlReceivedError($result->getRawResponse());
} else {
// Decode the response as either json or xml.
$response = array();
$pluginSettings = $this->config->getPluginSettings();
if ($pluginSettings['outputFormat'] === 'json') {
$response = json_decode($result->getRawResponse(), true);
}
// Even if we pass <format>json</format> we might receive an XML
// response in case the XML was rejected before or during parsing.
// So if the response is null we also try to decode the response as
// XML.
if ($pluginSettings['outputFormat'] === 'xml' || $response === null) {
try {
$response = $this->convertXmlToArray($result->getRawResponse());
} catch (RuntimeException $e) {
// Not an XML response. Treat it as an json error if we were
// expecting a json response.
if ($pluginSettings['outputFormat'] === 'json') {
$this->raiseJsonError();
}
// Otherwise treat it as the XML exception that was raised.
throw $e;
}
}
$result->setResponse($response);
}
return $result;
} | [
"protected",
"function",
"sendApiMessage",
"(",
"$",
"uri",
",",
"array",
"$",
"message",
",",
"Result",
"$",
"result",
")",
"{",
"// Convert message to XML. XML requires 1 top level tag, so add one.",
"// The tagname is ignored by the Acumulus WebAPI.",
"$",
"message",
"=",
"$",
"this",
"->",
"convertArrayToXml",
"(",
"array",
"(",
"'myxml'",
"=>",
"$",
"message",
")",
")",
";",
"// Keep track of communication for debugging/logging at higher levels.",
"$",
"result",
"->",
"setRawRequest",
"(",
"$",
"message",
")",
";",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"sendHttpPost",
"(",
"$",
"uri",
",",
"array",
"(",
"'xmlstring'",
"=>",
"$",
"message",
")",
",",
"$",
"result",
")",
";",
"$",
"result",
"->",
"setRawResponse",
"(",
"$",
"rawResponse",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rawResponse",
")",
")",
"{",
"// CURL may get a time-out and return an empty response without",
"// further error messages: Add an error to tell the user to check if",
"// the invoice was sent or not.",
"$",
"result",
"->",
"addError",
"(",
"701",
",",
"'Empty response'",
",",
"''",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isHtmlResponse",
"(",
"$",
"result",
"->",
"getRawResponse",
"(",
")",
")",
")",
"{",
"// When the API is gone we might receive an html error message page.",
"$",
"this",
"->",
"raiseHtmlReceivedError",
"(",
"$",
"result",
"->",
"getRawResponse",
"(",
")",
")",
";",
"}",
"else",
"{",
"// Decode the response as either json or xml.",
"$",
"response",
"=",
"array",
"(",
")",
";",
"$",
"pluginSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getPluginSettings",
"(",
")",
";",
"if",
"(",
"$",
"pluginSettings",
"[",
"'outputFormat'",
"]",
"===",
"'json'",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"result",
"->",
"getRawResponse",
"(",
")",
",",
"true",
")",
";",
"}",
"// Even if we pass <format>json</format> we might receive an XML",
"// response in case the XML was rejected before or during parsing.",
"// So if the response is null we also try to decode the response as",
"// XML.",
"if",
"(",
"$",
"pluginSettings",
"[",
"'outputFormat'",
"]",
"===",
"'xml'",
"||",
"$",
"response",
"===",
"null",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"convertXmlToArray",
"(",
"$",
"result",
"->",
"getRawResponse",
"(",
")",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"// Not an XML response. Treat it as an json error if we were",
"// expecting a json response.",
"if",
"(",
"$",
"pluginSettings",
"[",
"'outputFormat'",
"]",
"===",
"'json'",
")",
"{",
"$",
"this",
"->",
"raiseJsonError",
"(",
")",
";",
"}",
"// Otherwise treat it as the XML exception that was raised.",
"throw",
"$",
"e",
";",
"}",
"}",
"$",
"result",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Sends a message to the Acumulus API and returns the answer.
Any errors during:
- conversion of the message to xml,
- communication with the Acumulus web service
- converting the answer to an array
are returned as an Exception.
Any errors (or warnings) returned in the response structure of the web
service are returned via the result value and should be handled at a
higher level.
@param string $uri
The URI of the Acumulus WebAPI call to send the message to.
@param array $message
The message to send to the Acumulus WebAPI.
@param \Siel\Acumulus\Web\Result $result
The result structure to add the results to.
@return \Siel\Acumulus\Web\Result
The result of the web service call.
@see https://www.siel.nl/acumulus/API/Basic_Response/ For the
structure of a response. | [
"Sends",
"a",
"message",
"to",
"the",
"Acumulus",
"API",
"and",
"returns",
"the",
"answer",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L169-L217 |
30,262 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.convertXmlToArray | protected function convertXmlToArray($xml)
{
// Convert the response to an array via a 3-way conversion:
// - create a simplexml object
// - convert that to json
// - convert json to array
libxml_use_internal_errors(true);
if (!($result = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA))) {
$this->raiseLibxmlError(libxml_get_errors());
}
if (!($result = json_encode($result))) {
$this->raiseJsonError();
}
if (($result = json_decode($result, true)) === null) {
$this->raiseJsonError();
}
return $result;
} | php | protected function convertXmlToArray($xml)
{
// Convert the response to an array via a 3-way conversion:
// - create a simplexml object
// - convert that to json
// - convert json to array
libxml_use_internal_errors(true);
if (!($result = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA))) {
$this->raiseLibxmlError(libxml_get_errors());
}
if (!($result = json_encode($result))) {
$this->raiseJsonError();
}
if (($result = json_decode($result, true)) === null) {
$this->raiseJsonError();
}
return $result;
} | [
"protected",
"function",
"convertXmlToArray",
"(",
"$",
"xml",
")",
"{",
"// Convert the response to an array via a 3-way conversion:",
"// - create a simplexml object",
"// - convert that to json",
"// - convert json to array",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"if",
"(",
"!",
"(",
"$",
"result",
"=",
"simplexml_load_string",
"(",
"$",
"xml",
",",
"'SimpleXMLElement'",
",",
"LIBXML_NOCDATA",
")",
")",
")",
"{",
"$",
"this",
"->",
"raiseLibxmlError",
"(",
"libxml_get_errors",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"result",
"=",
"json_encode",
"(",
"$",
"result",
")",
")",
")",
"{",
"$",
"this",
"->",
"raiseJsonError",
"(",
")",
";",
"}",
"if",
"(",
"(",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"raiseJsonError",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Converts an XML string to an array.
@param string $xml
A string containing XML.
@return array
An array representation of the XML string.
@throws \RuntimeException | [
"Converts",
"an",
"XML",
"string",
"to",
"an",
"array",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L302-L321 |
30,263 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.convertArrayToXml | protected function convertArrayToXml(array $values)
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->xmlStandalone = true;
$dom->formatOutput = true;
try {
$dom = $this->convertToDom($values, $dom);
$result = $dom->saveXML();
if (!$result) {
throw new RuntimeException('DOMDocument::saveXML failed');
}
// Backslashes get lost between here and the Acumulus API, but
// encoding them makes them get through. Solve here until the
// real error has been found and solved.
$result = str_replace('\\', '\', $result);
return $result;
} catch (\DOMException $e) {
// Convert a DOMException to a RuntimeException, so we only have to
// handle RuntimeExceptions.
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
}
} | php | protected function convertArrayToXml(array $values)
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->xmlStandalone = true;
$dom->formatOutput = true;
try {
$dom = $this->convertToDom($values, $dom);
$result = $dom->saveXML();
if (!$result) {
throw new RuntimeException('DOMDocument::saveXML failed');
}
// Backslashes get lost between here and the Acumulus API, but
// encoding them makes them get through. Solve here until the
// real error has been found and solved.
$result = str_replace('\\', '\', $result);
return $result;
} catch (\DOMException $e) {
// Convert a DOMException to a RuntimeException, so we only have to
// handle RuntimeExceptions.
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
}
} | [
"protected",
"function",
"convertArrayToXml",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"dom",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"dom",
"->",
"formatOutput",
"=",
"true",
";",
"try",
"{",
"$",
"dom",
"=",
"$",
"this",
"->",
"convertToDom",
"(",
"$",
"values",
",",
"$",
"dom",
")",
";",
"$",
"result",
"=",
"$",
"dom",
"->",
"saveXML",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'DOMDocument::saveXML failed'",
")",
";",
"}",
"// Backslashes get lost between here and the Acumulus API, but",
"// encoding them makes them get through. Solve here until the",
"// real error has been found and solved.",
"$",
"result",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'\'",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"DOMException",
"$",
"e",
")",
"{",
"// Convert a DOMException to a RuntimeException, so we only have to",
"// handle RuntimeExceptions.",
"throw",
"new",
"RuntimeException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Converts a keyed, optionally multi-level, array to XML.
Each key is converted to a tag, no attributes are used. Numeric
sub-arrays are repeated using the same key.
@param array $values
The array to convert to XML.
@return string
The XML string
@throws \RuntimeException | [
"Converts",
"a",
"keyed",
"optionally",
"multi",
"-",
"level",
"array",
"to",
"XML",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L337-L359 |
30,264 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.convertToDom | protected function convertToDom($values, $element)
{
/** @var DOMDocument $document */
static $document = null;
$isFirstElement = true;
if ($element instanceof DOMDocument) {
$document = $element;
}
if (is_array($values)) {
foreach ($values as $key => $value) {
if (is_int($key)) {
if ($isFirstElement) {
$node = $element;
$isFirstElement = false;
} else {
$node = $document->createElement($element->tagName);
$element->parentNode->appendChild($node);
}
} else {
$node = $document->createElement($key);
$element->appendChild($node);
}
$this->convertToDom($value, $node);
}
} else {
$element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values));
}
return $element;
} | php | protected function convertToDom($values, $element)
{
/** @var DOMDocument $document */
static $document = null;
$isFirstElement = true;
if ($element instanceof DOMDocument) {
$document = $element;
}
if (is_array($values)) {
foreach ($values as $key => $value) {
if (is_int($key)) {
if ($isFirstElement) {
$node = $element;
$isFirstElement = false;
} else {
$node = $document->createElement($element->tagName);
$element->parentNode->appendChild($node);
}
} else {
$node = $document->createElement($key);
$element->appendChild($node);
}
$this->convertToDom($value, $node);
}
} else {
$element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values));
}
return $element;
} | [
"protected",
"function",
"convertToDom",
"(",
"$",
"values",
",",
"$",
"element",
")",
"{",
"/** @var DOMDocument $document */",
"static",
"$",
"document",
"=",
"null",
";",
"$",
"isFirstElement",
"=",
"true",
";",
"if",
"(",
"$",
"element",
"instanceof",
"DOMDocument",
")",
"{",
"$",
"document",
"=",
"$",
"element",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"isFirstElement",
")",
"{",
"$",
"node",
"=",
"$",
"element",
";",
"$",
"isFirstElement",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"$",
"document",
"->",
"createElement",
"(",
"$",
"element",
"->",
"tagName",
")",
";",
"$",
"element",
"->",
"parentNode",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"node",
"=",
"$",
"document",
"->",
"createElement",
"(",
"$",
"key",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"this",
"->",
"convertToDom",
"(",
"$",
"value",
",",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"document",
"->",
"createTextNode",
"(",
"is_bool",
"(",
"$",
"values",
")",
"?",
"(",
"$",
"values",
"?",
"'true'",
":",
"'false'",
")",
":",
"$",
"values",
")",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Recursively converts a value to a DOMDocument|DOMElement.
@param mixed $values
A keyed array, an numerically indexed array, or a scalar type.
@param DOMDocument|DOMElement $element
The element to append the values to.
@return DOMDocument|DOMElement
@throws \DOMException | [
"Recursively",
"converts",
"a",
"value",
"to",
"a",
"DOMDocument|DOMElement",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L373-L403 |
30,265 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.raiseCurlError | protected function raiseCurlError($ch, $function)
{
$env = $this->config->getEnvironment();
$message = sprintf('%s (curl: %s): ', $function, $env['curlVersion']);
if ($ch) {
$code = curl_errno($ch);
$message .= sprintf('%d - %s', $code, curl_error($ch));
} else {
$code = 703;
$message .= 'no curl handle';
}
curl_close($ch);
throw new RuntimeException($message, $code);
} | php | protected function raiseCurlError($ch, $function)
{
$env = $this->config->getEnvironment();
$message = sprintf('%s (curl: %s): ', $function, $env['curlVersion']);
if ($ch) {
$code = curl_errno($ch);
$message .= sprintf('%d - %s', $code, curl_error($ch));
} else {
$code = 703;
$message .= 'no curl handle';
}
curl_close($ch);
throw new RuntimeException($message, $code);
} | [
"protected",
"function",
"raiseCurlError",
"(",
"$",
"ch",
",",
"$",
"function",
")",
"{",
"$",
"env",
"=",
"$",
"this",
"->",
"config",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s (curl: %s): '",
",",
"$",
"function",
",",
"$",
"env",
"[",
"'curlVersion'",
"]",
")",
";",
"if",
"(",
"$",
"ch",
")",
"{",
"$",
"code",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"$",
"message",
".=",
"sprintf",
"(",
"'%d - %s'",
",",
"$",
"code",
",",
"curl_error",
"(",
"$",
"ch",
")",
")",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"703",
";",
"$",
"message",
".=",
"'no curl handle'",
";",
"}",
"curl_close",
"(",
"$",
"ch",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"message",
",",
"$",
"code",
")",
";",
"}"
] | Adds a curl error message to the result.
@param resource|bool $ch
@param string $function | [
"Adds",
"a",
"curl",
"error",
"message",
"to",
"the",
"result",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L411-L424 |
30,266 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.raiseLibxmlError | protected function raiseLibxmlError(array $errors)
{
$messages = array();
$code = 704;
foreach ($errors as $error) {
// Overwrite our own code with the 1st code we get from libxml.
if ($code === 704) {
$code = $error->code;
}
$messages[] = sprintf('Line %d, column: %d: %s %d - %s', $error->line, $error->column, $error->level === LIBXML_ERR_WARNING ? 'warning' : 'error', $error->code, trim($error->message));
}
throw new RuntimeException(implode("\n", $messages), $code);
} | php | protected function raiseLibxmlError(array $errors)
{
$messages = array();
$code = 704;
foreach ($errors as $error) {
// Overwrite our own code with the 1st code we get from libxml.
if ($code === 704) {
$code = $error->code;
}
$messages[] = sprintf('Line %d, column: %d: %s %d - %s', $error->line, $error->column, $error->level === LIBXML_ERR_WARNING ? 'warning' : 'error', $error->code, trim($error->message));
}
throw new RuntimeException(implode("\n", $messages), $code);
} | [
"protected",
"function",
"raiseLibxmlError",
"(",
"array",
"$",
"errors",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"$",
"code",
"=",
"704",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"// Overwrite our own code with the 1st code we get from libxml.",
"if",
"(",
"$",
"code",
"===",
"704",
")",
"{",
"$",
"code",
"=",
"$",
"error",
"->",
"code",
";",
"}",
"$",
"messages",
"[",
"]",
"=",
"sprintf",
"(",
"'Line %d, column: %d: %s %d - %s'",
",",
"$",
"error",
"->",
"line",
",",
"$",
"error",
"->",
"column",
",",
"$",
"error",
"->",
"level",
"===",
"LIBXML_ERR_WARNING",
"?",
"'warning'",
":",
"'error'",
",",
"$",
"error",
"->",
"code",
",",
"trim",
"(",
"$",
"error",
"->",
"message",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"messages",
")",
",",
"$",
"code",
")",
";",
"}"
] | Adds a libxml error messages to the result.
@param LibXMLError[] $errors
@throws \RuntimeException | [
"Adds",
"a",
"libxml",
"error",
"messages",
"to",
"the",
"result",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L433-L445 |
30,267 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.raiseJsonError | protected function raiseJsonError()
{
$code = json_last_error();
switch ($code) {
case JSON_ERROR_NONE:
$message = 'No error';
break;
case JSON_ERROR_DEPTH:
$message = 'Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$message = 'Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
$message = 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$message = 'Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
$message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
$code = 705;
$message = 'Unknown error';
break;
}
$env = $this->config->getEnvironment();
$message = sprintf('json (%s): %d - %s', $env['jsonVersion'], $code, $message);
throw new RuntimeException($message, $code);
} | php | protected function raiseJsonError()
{
$code = json_last_error();
switch ($code) {
case JSON_ERROR_NONE:
$message = 'No error';
break;
case JSON_ERROR_DEPTH:
$message = 'Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$message = 'Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
$message = 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$message = 'Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
$message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
$code = 705;
$message = 'Unknown error';
break;
}
$env = $this->config->getEnvironment();
$message = sprintf('json (%s): %d - %s', $env['jsonVersion'], $code, $message);
throw new RuntimeException($message, $code);
} | [
"protected",
"function",
"raiseJsonError",
"(",
")",
"{",
"$",
"code",
"=",
"json_last_error",
"(",
")",
";",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"JSON_ERROR_NONE",
":",
"$",
"message",
"=",
"'No error'",
";",
"break",
";",
"case",
"JSON_ERROR_DEPTH",
":",
"$",
"message",
"=",
"'Maximum stack depth exceeded'",
";",
"break",
";",
"case",
"JSON_ERROR_STATE_MISMATCH",
":",
"$",
"message",
"=",
"'Underflow or the modes mismatch'",
";",
"break",
";",
"case",
"JSON_ERROR_CTRL_CHAR",
":",
"$",
"message",
"=",
"'Unexpected control character found'",
";",
"break",
";",
"case",
"JSON_ERROR_SYNTAX",
":",
"$",
"message",
"=",
"'Syntax error, malformed JSON'",
";",
"break",
";",
"case",
"JSON_ERROR_UTF8",
":",
"$",
"message",
"=",
"'Malformed UTF-8 characters, possibly incorrectly encoded'",
";",
"break",
";",
"default",
":",
"$",
"code",
"=",
"705",
";",
"$",
"message",
"=",
"'Unknown error'",
";",
"break",
";",
"}",
"$",
"env",
"=",
"$",
"this",
"->",
"config",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'json (%s): %d - %s'",
",",
"$",
"env",
"[",
"'jsonVersion'",
"]",
",",
"$",
"code",
",",
"$",
"message",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"message",
",",
"$",
"code",
")",
";",
"}"
] | Adds a json error message to the result.
@throws \RuntimeException | [
"Adds",
"a",
"json",
"error",
"message",
"to",
"the",
"result",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L452-L482 |
30,268 | SIELOnline/libAcumulus | src/Web/Communicator.php | Communicator.raiseHtmlReceivedError | protected function raiseHtmlReceivedError($response)
{
libxml_use_internal_errors(true);
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadHTML($response);
$body = $doc->getElementsByTagName('body');
if ($body->length > 0) {
$body = $body->item(0)->textContent;
} else {
$body = '';
}
throw new RuntimeException("HTML response received: $body", 702);
} | php | protected function raiseHtmlReceivedError($response)
{
libxml_use_internal_errors(true);
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadHTML($response);
$body = $doc->getElementsByTagName('body');
if ($body->length > 0) {
$body = $body->item(0)->textContent;
} else {
$body = '';
}
throw new RuntimeException("HTML response received: $body", 702);
} | [
"protected",
"function",
"raiseHtmlReceivedError",
"(",
"$",
"response",
")",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"doc",
"->",
"loadHTML",
"(",
"$",
"response",
")",
";",
"$",
"body",
"=",
"$",
"doc",
"->",
"getElementsByTagName",
"(",
"'body'",
")",
";",
"if",
"(",
"$",
"body",
"->",
"length",
">",
"0",
")",
"{",
"$",
"body",
"=",
"$",
"body",
"->",
"item",
"(",
"0",
")",
"->",
"textContent",
";",
"}",
"else",
"{",
"$",
"body",
"=",
"''",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"HTML response received: $body\"",
",",
"702",
")",
";",
"}"
] | Returns an error message containing the received HTML.
@param string $response
String containing an html document.
@trows \RuntimeException | [
"Returns",
"an",
"error",
"message",
"containing",
"the",
"received",
"HTML",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L492-L504 |
30,269 | SIELOnline/libAcumulus | src/MyWebShop/Invoice/Creator.php | Creator.getItemLine | protected function getItemLine($item)
{
$result = array();
// @todo: add property source(s) for this item line.
$this->addPropertySource('item', $item);
$this->addProductInfo($result);
$sign = $this->invoiceSource->getSign();
// @todo: add other tags and available meta tags (* = required):
// * quantity
// * unitprice and/or unitpriceinc
// * vat related tags:
// * vatrate and/or vatamount
// * vat range tags (call method getVatRangeTags()
// * vat rate source
// - meta-unitprice-recalculate: if admin enters product prices inc vat
// (which is normal) then the product price ex vat may be imprecise.
// If the exact vat rate is not yet known, it may be recalculated in
// the Completor phase.
// - line totals
// Should result in something like this:
// Check for cost price.
$productPriceEx = $sign * $item->priceEx;
$precisionEx = 0.01;
$productVat = $sign * $item->productTax;
$precisionVat = 0.01;
$productPriceInc = $sign * $item->priceInc;
$quantity = $item->quantity;
// 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] = $productPriceInc;
} else {
$result += array(
Tag::UnitPrice => $productPriceEx,
Meta::UnitPriceInc => $productPriceInc,
Meta::RecalculatePrice => $productPricesIncludeTax ? Tag::UnitPrice : Meta::UnitPriceInc,
);
}
$result[Tag::Quantity] = $quantity;
// Add tax info.
$result += $this->getVatRangeTags($productVat, $productPriceEx, $precisionVat, $precisionEx);
// @todo: remove property source(s) for this item line.
$this->removePropertySource('item');
return $result;
} | php | protected function getItemLine($item)
{
$result = array();
// @todo: add property source(s) for this item line.
$this->addPropertySource('item', $item);
$this->addProductInfo($result);
$sign = $this->invoiceSource->getSign();
// @todo: add other tags and available meta tags (* = required):
// * quantity
// * unitprice and/or unitpriceinc
// * vat related tags:
// * vatrate and/or vatamount
// * vat range tags (call method getVatRangeTags()
// * vat rate source
// - meta-unitprice-recalculate: if admin enters product prices inc vat
// (which is normal) then the product price ex vat may be imprecise.
// If the exact vat rate is not yet known, it may be recalculated in
// the Completor phase.
// - line totals
// Should result in something like this:
// Check for cost price.
$productPriceEx = $sign * $item->priceEx;
$precisionEx = 0.01;
$productVat = $sign * $item->productTax;
$precisionVat = 0.01;
$productPriceInc = $sign * $item->priceInc;
$quantity = $item->quantity;
// 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] = $productPriceInc;
} else {
$result += array(
Tag::UnitPrice => $productPriceEx,
Meta::UnitPriceInc => $productPriceInc,
Meta::RecalculatePrice => $productPricesIncludeTax ? Tag::UnitPrice : Meta::UnitPriceInc,
);
}
$result[Tag::Quantity] = $quantity;
// Add tax info.
$result += $this->getVatRangeTags($productVat, $productPriceEx, $precisionVat, $precisionEx);
// @todo: remove property source(s) for this item line.
$this->removePropertySource('item');
return $result;
} | [
"protected",
"function",
"getItemLine",
"(",
"$",
"item",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// @todo: add property source(s) for this item line.",
"$",
"this",
"->",
"addPropertySource",
"(",
"'item'",
",",
"$",
"item",
")",
";",
"$",
"this",
"->",
"addProductInfo",
"(",
"$",
"result",
")",
";",
"$",
"sign",
"=",
"$",
"this",
"->",
"invoiceSource",
"->",
"getSign",
"(",
")",
";",
"// @todo: add other tags and available meta tags (* = required):",
"// * quantity",
"// * unitprice and/or unitpriceinc",
"// * vat related tags:",
"// * vatrate and/or vatamount",
"// * vat range tags (call method getVatRangeTags()",
"// * vat rate source",
"// - meta-unitprice-recalculate: if admin enters product prices inc vat",
"// (which is normal) then the product price ex vat may be imprecise.",
"// If the exact vat rate is not yet known, it may be recalculated in",
"// the Completor phase.",
"// - line totals",
"// Should result in something like this:",
"// Check for cost price.",
"$",
"productPriceEx",
"=",
"$",
"sign",
"*",
"$",
"item",
"->",
"priceEx",
";",
"$",
"precisionEx",
"=",
"0.01",
";",
"$",
"productVat",
"=",
"$",
"sign",
"*",
"$",
"item",
"->",
"productTax",
";",
"$",
"precisionVat",
"=",
"0.01",
";",
"$",
"productPriceInc",
"=",
"$",
"sign",
"*",
"$",
"item",
"->",
"priceInc",
";",
"$",
"quantity",
"=",
"$",
"item",
"->",
"quantity",
";",
"// 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",
"]",
"=",
"$",
"productPriceInc",
";",
"}",
"else",
"{",
"$",
"result",
"+=",
"array",
"(",
"Tag",
"::",
"UnitPrice",
"=>",
"$",
"productPriceEx",
",",
"Meta",
"::",
"UnitPriceInc",
"=>",
"$",
"productPriceInc",
",",
"Meta",
"::",
"RecalculatePrice",
"=>",
"$",
"productPricesIncludeTax",
"?",
"Tag",
"::",
"UnitPrice",
":",
"Meta",
"::",
"UnitPriceInc",
",",
")",
";",
"}",
"$",
"result",
"[",
"Tag",
"::",
"Quantity",
"]",
"=",
"$",
"quantity",
";",
"// Add tax info.",
"$",
"result",
"+=",
"$",
"this",
"->",
"getVatRangeTags",
"(",
"$",
"productVat",
",",
"$",
"productPriceEx",
",",
"$",
"precisionVat",
",",
"$",
"precisionEx",
")",
";",
"// @todo: remove property source(s) for this item line.",
"$",
"this",
"->",
"removePropertySource",
"(",
"'item'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns 1 item line, be it for an order or credit slip.
@todo: specify type of this parameter
@param $item
An OrderDetail line.
@return array | [
"Returns",
"1",
"item",
"line",
"be",
"it",
"for",
"an",
"order",
"or",
"credit",
"slip",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/MyWebShop/Invoice/Creator.php#L97-L151 |
30,270 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.completeInvoiceLinesRecursive | protected function completeInvoiceLinesRecursive(array $invoice)
{
$lines = $invoice[Tag::Customer][Tag::Invoice][Tag::Line];
if ($this->completor->shouldConvertCurrency($invoice)) {
$lines = $this->convertToEuro($lines, $invoice[Tag::Customer][Tag::Invoice][Meta::CurrencyRate]);
}
// @todo: we could combine all completor phase methods of getting the
// correct vat rate:
// - possible vat rates
// - filter by range
// - filter by tax class = foreign vat (or not)
// - filter by lookup vat
// Why? addVatRateUsingLookupData() actually already does so, but will
// not work when we do have a lookup vat class but not a lookup vat
// rate.
// This would allow to combine VatRateSource_Calculated and
// VatRateSource_Completor.
// correctCalculatedVatRates() only uses vatrate, meta-vatrate-min, and
// meta-vatrate-max and may lead to more (required) data filled in, so
// should be called before completeLineRequiredData().
$lines = $this->correctCalculatedVatRates($lines);
// addVatRateToLookupLines() only uses meta-vat-rate-lookup and may lead
// to more (required) data filled in, so should be called before
// completeLineRequiredData().
$lines = $this->addVatRateUsingLookupData($lines);
$lines = $this->completeLineRequiredData($lines);
// Completing the required data may lead to new lines that contain
// calculated VAT rates and thus can be corrected with
// correctCalculatedVatRates(): call again.
$lines = $this->correctCalculatedVatRates($lines);
$invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $lines;
return $invoice;
} | php | protected function completeInvoiceLinesRecursive(array $invoice)
{
$lines = $invoice[Tag::Customer][Tag::Invoice][Tag::Line];
if ($this->completor->shouldConvertCurrency($invoice)) {
$lines = $this->convertToEuro($lines, $invoice[Tag::Customer][Tag::Invoice][Meta::CurrencyRate]);
}
// @todo: we could combine all completor phase methods of getting the
// correct vat rate:
// - possible vat rates
// - filter by range
// - filter by tax class = foreign vat (or not)
// - filter by lookup vat
// Why? addVatRateUsingLookupData() actually already does so, but will
// not work when we do have a lookup vat class but not a lookup vat
// rate.
// This would allow to combine VatRateSource_Calculated and
// VatRateSource_Completor.
// correctCalculatedVatRates() only uses vatrate, meta-vatrate-min, and
// meta-vatrate-max and may lead to more (required) data filled in, so
// should be called before completeLineRequiredData().
$lines = $this->correctCalculatedVatRates($lines);
// addVatRateToLookupLines() only uses meta-vat-rate-lookup and may lead
// to more (required) data filled in, so should be called before
// completeLineRequiredData().
$lines = $this->addVatRateUsingLookupData($lines);
$lines = $this->completeLineRequiredData($lines);
// Completing the required data may lead to new lines that contain
// calculated VAT rates and thus can be corrected with
// correctCalculatedVatRates(): call again.
$lines = $this->correctCalculatedVatRates($lines);
$invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $lines;
return $invoice;
} | [
"protected",
"function",
"completeInvoiceLinesRecursive",
"(",
"array",
"$",
"invoice",
")",
"{",
"$",
"lines",
"=",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"completor",
"->",
"shouldConvertCurrency",
"(",
"$",
"invoice",
")",
")",
"{",
"$",
"lines",
"=",
"$",
"this",
"->",
"convertToEuro",
"(",
"$",
"lines",
",",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CurrencyRate",
"]",
")",
";",
"}",
"// @todo: we could combine all completor phase methods of getting the",
"// correct vat rate:",
"// - possible vat rates",
"// - filter by range",
"// - filter by tax class = foreign vat (or not)",
"// - filter by lookup vat",
"// Why? addVatRateUsingLookupData() actually already does so, but will",
"// not work when we do have a lookup vat class but not a lookup vat",
"// rate.",
"// This would allow to combine VatRateSource_Calculated and",
"// VatRateSource_Completor.",
"// correctCalculatedVatRates() only uses vatrate, meta-vatrate-min, and",
"// meta-vatrate-max and may lead to more (required) data filled in, so",
"// should be called before completeLineRequiredData().",
"$",
"lines",
"=",
"$",
"this",
"->",
"correctCalculatedVatRates",
"(",
"$",
"lines",
")",
";",
"// addVatRateToLookupLines() only uses meta-vat-rate-lookup and may lead",
"// to more (required) data filled in, so should be called before",
"// completeLineRequiredData().",
"$",
"lines",
"=",
"$",
"this",
"->",
"addVatRateUsingLookupData",
"(",
"$",
"lines",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"completeLineRequiredData",
"(",
"$",
"lines",
")",
";",
"// Completing the required data may lead to new lines that contain",
"// calculated VAT rates and thus can be corrected with",
"// correctCalculatedVatRates(): call again.",
"$",
"lines",
"=",
"$",
"this",
"->",
"correctCalculatedVatRates",
"(",
"$",
"lines",
")",
";",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
"=",
"$",
"lines",
";",
"return",
"$",
"invoice",
";",
"}"
] | Completes the invoice lines before they are flattened.
This means that the lines have to be walked recursively.
The actions that can be done this way are those who operate on a line in
isolation and thus do not need totals, maximums or things like that.
@param array[] $invoice
The invoice with the lines to complete recursively.
@return array[]
The invoice with the completed invoice lines. | [
"Completes",
"the",
"invoice",
"lines",
"before",
"they",
"are",
"flattened",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L114-L148 |
30,271 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.completeInvoiceLines | protected function completeInvoiceLines(array $lines)
{
$lines = $this->addVatRateTo0PriceLines($lines);
$lines = $this->recalculateLineData($lines);
$lines = $this->completeLineMetaData($lines);
return $lines;
} | php | protected function completeInvoiceLines(array $lines)
{
$lines = $this->addVatRateTo0PriceLines($lines);
$lines = $this->recalculateLineData($lines);
$lines = $this->completeLineMetaData($lines);
return $lines;
} | [
"protected",
"function",
"completeInvoiceLines",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"lines",
"=",
"$",
"this",
"->",
"addVatRateTo0PriceLines",
"(",
"$",
"lines",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"recalculateLineData",
"(",
"$",
"lines",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"completeLineMetaData",
"(",
"$",
"lines",
")",
";",
"return",
"$",
"lines",
";",
"}"
] | Completes the invoice lines after they have been flattened.
@param array[] $lines
The invoice lines to complete.
@return array[]
The completed invoice lines. | [
"Completes",
"the",
"invoice",
"lines",
"after",
"they",
"have",
"been",
"flattened",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L159-L165 |
30,272 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.correctCalculatedVatRates | protected function correctCalculatedVatRates(array $lines)
{
foreach ($lines as &$line) {
if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) {
$line = $this->correctVatRateByRange($line);
}
if (!empty($line[Meta::ChildrenLines])) {
$line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]);
}
}
return $lines;
} | php | protected function correctCalculatedVatRates(array $lines)
{
foreach ($lines as &$line) {
if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) {
$line = $this->correctVatRateByRange($line);
}
if (!empty($line[Meta::ChildrenLines])) {
$line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]);
}
}
return $lines;
} | [
"protected",
"function",
"correctCalculatedVatRates",
"(",
"array",
"$",
"lines",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"&",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
")",
"&&",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"===",
"Creator",
"::",
"VatRateSource_Calculated",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"correctVatRateByRange",
"(",
"$",
"line",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
")",
")",
"{",
"$",
"line",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
"=",
"$",
"this",
"->",
"correctCalculatedVatRates",
"(",
"$",
"line",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
")",
";",
"}",
"}",
"return",
"$",
"lines",
";",
"}"
] | Corrects 'calculated' vat rates.
Tries to correct 'calculated' vat rates for rounding errors by matching
them with possible vatRates obtained from the vat lookup service.
@param array[] $lines
The invoice lines to correct.
@return array[]
The corrected invoice lines. | [
"Corrects",
"calculated",
"vat",
"rates",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L214-L225 |
30,273 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.correctVatRateByRange | public function correctVatRateByRange(array $line)
{
$line[Meta::VatRateRangeMatches] = $this->filterVatRateInfosByRange($line[Meta::VatRateMin], $line[Meta::VatRateMax]);
$vatRate = $this->getUniqueVatRate($line[Meta::VatRateRangeMatches]);
if ($vatRate === null) {
// No match at all.
unset($line[Tag::VatRate]);
if (!empty($line[Meta::StrategySplit])) {
// If this line may be split, we make it a strategy line (even
// though 2 out of the 3 fields ex, inc, and vat are known).
// This way the strategy phase may be able to correct this line.
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Strategy;
} else {
// Set vatrate to null and try to use lookup data to get a vat
// rate. It will be invalid but may be better than the "setting
// to standard 21%".
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Completor;
$this->completor->changeInvoiceToConcept('message_warning_no_vatrate', 821);
// @todo: this can also happen with exact or looked up vat rates
// add a checker in the Completor that checks all lines for
// no or an incorrect vat rate and changes the invoice into a
// concept.
}
} elseif ($vatRate === false) {
// Multiple matches: set vatrate to null and try to use lookup data.
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Completor;
} else {
// Single match: fill it in as the vat rate for this line.
$line[Tag::VatRate] = $vatRate;
$line[Meta::VatRateSource] = Completor::VatRateSource_Completor_Range;
}
return $line;
} | php | public function correctVatRateByRange(array $line)
{
$line[Meta::VatRateRangeMatches] = $this->filterVatRateInfosByRange($line[Meta::VatRateMin], $line[Meta::VatRateMax]);
$vatRate = $this->getUniqueVatRate($line[Meta::VatRateRangeMatches]);
if ($vatRate === null) {
// No match at all.
unset($line[Tag::VatRate]);
if (!empty($line[Meta::StrategySplit])) {
// If this line may be split, we make it a strategy line (even
// though 2 out of the 3 fields ex, inc, and vat are known).
// This way the strategy phase may be able to correct this line.
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Strategy;
} else {
// Set vatrate to null and try to use lookup data to get a vat
// rate. It will be invalid but may be better than the "setting
// to standard 21%".
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Completor;
$this->completor->changeInvoiceToConcept('message_warning_no_vatrate', 821);
// @todo: this can also happen with exact or looked up vat rates
// add a checker in the Completor that checks all lines for
// no or an incorrect vat rate and changes the invoice into a
// concept.
}
} elseif ($vatRate === false) {
// Multiple matches: set vatrate to null and try to use lookup data.
$line[Tag::VatRate] = null;
$line[Meta::VatRateSource] = Creator::VatRateSource_Completor;
} else {
// Single match: fill it in as the vat rate for this line.
$line[Tag::VatRate] = $vatRate;
$line[Meta::VatRateSource] = Completor::VatRateSource_Completor_Range;
}
return $line;
} | [
"public",
"function",
"correctVatRateByRange",
"(",
"array",
"$",
"line",
")",
"{",
"$",
"line",
"[",
"Meta",
"::",
"VatRateRangeMatches",
"]",
"=",
"$",
"this",
"->",
"filterVatRateInfosByRange",
"(",
"$",
"line",
"[",
"Meta",
"::",
"VatRateMin",
"]",
",",
"$",
"line",
"[",
"Meta",
"::",
"VatRateMax",
"]",
")",
";",
"$",
"vatRate",
"=",
"$",
"this",
"->",
"getUniqueVatRate",
"(",
"$",
"line",
"[",
"Meta",
"::",
"VatRateRangeMatches",
"]",
")",
";",
"if",
"(",
"$",
"vatRate",
"===",
"null",
")",
"{",
"// No match at all.",
"unset",
"(",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
"[",
"Meta",
"::",
"StrategySplit",
"]",
")",
")",
"{",
"// If this line may be split, we make it a strategy line (even",
"// though 2 out of the 3 fields ex, inc, and vat are known).",
"// This way the strategy phase may be able to correct this line.",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
"=",
"null",
";",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"=",
"Creator",
"::",
"VatRateSource_Strategy",
";",
"}",
"else",
"{",
"// Set vatrate to null and try to use lookup data to get a vat",
"// rate. It will be invalid but may be better than the \"setting",
"// to standard 21%\".",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
"=",
"null",
";",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"=",
"Creator",
"::",
"VatRateSource_Completor",
";",
"$",
"this",
"->",
"completor",
"->",
"changeInvoiceToConcept",
"(",
"'message_warning_no_vatrate'",
",",
"821",
")",
";",
"// @todo: this can also happen with exact or looked up vat rates",
"// add a checker in the Completor that checks all lines for",
"// no or an incorrect vat rate and changes the invoice into a",
"// concept.",
"}",
"}",
"elseif",
"(",
"$",
"vatRate",
"===",
"false",
")",
"{",
"// Multiple matches: set vatrate to null and try to use lookup data.",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
"=",
"null",
";",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"=",
"Creator",
"::",
"VatRateSource_Completor",
";",
"}",
"else",
"{",
"// Single match: fill it in as the vat rate for this line.",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
"=",
"$",
"vatRate",
";",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"=",
"Completor",
"::",
"VatRateSource_Completor_Range",
";",
"}",
"return",
"$",
"line",
";",
"}"
] | Checks and corrects a 'calculated' vat rate to an allowed vat rate.
The meta-vatrate-source must be Creator::VatRateSource_Calculated.
The check is done on comparing allowed vat rates with the
meta-vatrate-min and meta-vatrate-max values. If only 1 match is found
that will be used.
If multiple matches are found with all equal rates - e.g. Dutch and
Belgium 21% - the vat rate will be corrected, but the VAT Type will
remain undecided, unless the vat class could be looked up and thus used
to differentiate between national and foreign vat.
This method is public to allow a 2nd call to just this method for a
single line (a missing amount line) added after a 1st round of
correcting. Do not use unless $this->possibleVatRates has been
initialized.
@param array $line
An invoice line with a calculated vat rate.
@return array
The invoice line with a corrected vat rate. | [
"Checks",
"and",
"corrects",
"a",
"calculated",
"vat",
"rate",
"to",
"an",
"allowed",
"vat",
"rate",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L252-L289 |
30,274 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.getMaxAppearingVatRate | public static function getMaxAppearingVatRate(array $lines, &$index = 0)
{
$index = null;
$maxVatRate = -1.0;
foreach ($lines as $key => $line) {
if (isset($line[Tag::VatRate]) && (float) $line[Tag::VatRate] > $maxVatRate) {
$index = $key;
$maxVatRate = (float) $line[Tag::VatRate];
}
}
return $index !== null ? $maxVatRate : null;
} | php | public static function getMaxAppearingVatRate(array $lines, &$index = 0)
{
$index = null;
$maxVatRate = -1.0;
foreach ($lines as $key => $line) {
if (isset($line[Tag::VatRate]) && (float) $line[Tag::VatRate] > $maxVatRate) {
$index = $key;
$maxVatRate = (float) $line[Tag::VatRate];
}
}
return $index !== null ? $maxVatRate : null;
} | [
"public",
"static",
"function",
"getMaxAppearingVatRate",
"(",
"array",
"$",
"lines",
",",
"&",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"index",
"=",
"null",
";",
"$",
"maxVatRate",
"=",
"-",
"1.0",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"key",
"=>",
"$",
"line",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
")",
"&&",
"(",
"float",
")",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
">",
"$",
"maxVatRate",
")",
"{",
"$",
"index",
"=",
"$",
"key",
";",
"$",
"maxVatRate",
"=",
"(",
"float",
")",
"$",
"line",
"[",
"Tag",
"::",
"VatRate",
"]",
";",
"}",
"}",
"return",
"$",
"index",
"!==",
"null",
"?",
"$",
"maxVatRate",
":",
"null",
";",
"}"
] | Returns the maximum vat rate that appears in the given set of lines.
@param array[] $lines
The invoice lines to search.
@param int $index
If passed, the index of the max vat rate is returned via this parameter.
@return float|null
The maximum vat rate in the given set of lines or null if no vat rates
could be found. | [
"Returns",
"the",
"maximum",
"vat",
"rate",
"that",
"appears",
"in",
"the",
"given",
"set",
"of",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L547-L558 |
30,275 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.filterVatRateInfosByRange | protected function filterVatRateInfosByRange($min, $max, array $vatRateInfos = null)
{
if ($vatRateInfos === null) {
$vatRateInfos = $this->possibleVatRates;
}
$result = array();
foreach ($vatRateInfos as $vatRateInfo) {
$vatRate = is_array($vatRateInfo) ? $vatRateInfo[Tag::VatRate] : $vatRateInfo;
if ($min <= $vatRate && $vatRate <= $max) {
$result[] = $vatRateInfo;
}
}
return $result;
} | php | protected function filterVatRateInfosByRange($min, $max, array $vatRateInfos = null)
{
if ($vatRateInfos === null) {
$vatRateInfos = $this->possibleVatRates;
}
$result = array();
foreach ($vatRateInfos as $vatRateInfo) {
$vatRate = is_array($vatRateInfo) ? $vatRateInfo[Tag::VatRate] : $vatRateInfo;
if ($min <= $vatRate && $vatRate <= $max) {
$result[] = $vatRateInfo;
}
}
return $result;
} | [
"protected",
"function",
"filterVatRateInfosByRange",
"(",
"$",
"min",
",",
"$",
"max",
",",
"array",
"$",
"vatRateInfos",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"vatRateInfos",
"===",
"null",
")",
"{",
"$",
"vatRateInfos",
"=",
"$",
"this",
"->",
"possibleVatRates",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"vatRateInfos",
"as",
"$",
"vatRateInfo",
")",
"{",
"$",
"vatRate",
"=",
"is_array",
"(",
"$",
"vatRateInfo",
")",
"?",
"$",
"vatRateInfo",
"[",
"Tag",
"::",
"VatRate",
"]",
":",
"$",
"vatRateInfo",
";",
"if",
"(",
"$",
"min",
"<=",
"$",
"vatRate",
"&&",
"$",
"vatRate",
"<=",
"$",
"max",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"vatRateInfo",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the set of possible vat rates that fall in the given vat range.
@param float $min
@param float $max
@param array|null $vatRateInfos
The set of vat rate infos to filter. If not given, the property
$this->possibleVatRates is used.
@return array[]
The, possibly empty, set of vat rate infos that have a vat rate that
falls within the given vat range. | [
"Returns",
"the",
"set",
"of",
"possible",
"vat",
"rates",
"that",
"fall",
"in",
"the",
"given",
"vat",
"range",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L573-L587 |
30,276 | SIELOnline/libAcumulus | src/Invoice/CompletorInvoiceLines.php | CompletorInvoiceLines.filterVatRateInfosByVatRates | protected function filterVatRateInfosByVatRates($vatRates, array $vatRateInfos = null)
{
$vatRates = (array) $vatRates;
if ($vatRateInfos === null) {
$vatRateInfos = $this->possibleVatRates;
}
$result = array();
foreach ($vatRateInfos as $vatRateInfo) {
$vatRate = $vatRateInfo[Tag::VatRate];
foreach ($vatRates as $vatRateInfo2) {
$vatRate2 = is_array($vatRateInfo2) ? $vatRateInfo2[Tag::VatRate] : $vatRateInfo2;
if (Number::floatsAreEqual($vatRate, $vatRate2)) {
$result[] = $vatRateInfo;
}
}
}
return $result;
} | php | protected function filterVatRateInfosByVatRates($vatRates, array $vatRateInfos = null)
{
$vatRates = (array) $vatRates;
if ($vatRateInfos === null) {
$vatRateInfos = $this->possibleVatRates;
}
$result = array();
foreach ($vatRateInfos as $vatRateInfo) {
$vatRate = $vatRateInfo[Tag::VatRate];
foreach ($vatRates as $vatRateInfo2) {
$vatRate2 = is_array($vatRateInfo2) ? $vatRateInfo2[Tag::VatRate] : $vatRateInfo2;
if (Number::floatsAreEqual($vatRate, $vatRate2)) {
$result[] = $vatRateInfo;
}
}
}
return $result;
} | [
"protected",
"function",
"filterVatRateInfosByVatRates",
"(",
"$",
"vatRates",
",",
"array",
"$",
"vatRateInfos",
"=",
"null",
")",
"{",
"$",
"vatRates",
"=",
"(",
"array",
")",
"$",
"vatRates",
";",
"if",
"(",
"$",
"vatRateInfos",
"===",
"null",
")",
"{",
"$",
"vatRateInfos",
"=",
"$",
"this",
"->",
"possibleVatRates",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"vatRateInfos",
"as",
"$",
"vatRateInfo",
")",
"{",
"$",
"vatRate",
"=",
"$",
"vatRateInfo",
"[",
"Tag",
"::",
"VatRate",
"]",
";",
"foreach",
"(",
"$",
"vatRates",
"as",
"$",
"vatRateInfo2",
")",
"{",
"$",
"vatRate2",
"=",
"is_array",
"(",
"$",
"vatRateInfo2",
")",
"?",
"$",
"vatRateInfo2",
"[",
"Tag",
"::",
"VatRate",
"]",
":",
"$",
"vatRateInfo2",
";",
"if",
"(",
"Number",
"::",
"floatsAreEqual",
"(",
"$",
"vatRate",
",",
"$",
"vatRate2",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"vatRateInfo",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the subset of the vat rate infos that have a vat rate that appears within the given set of vat rates.
@param float|float[] $vatRates
The vat rate(s) to filter.
@param array|null $vatRateInfos
The set of vat rate infos to filter. If not given, the property
$this->possibleVatRates is used.
@return array[]
The, possibly empty, set of vat rate infos that have a vat rate that
appears within the set of $vatRates. | [
"Returns",
"the",
"subset",
"of",
"the",
"vat",
"rate",
"infos",
"that",
"have",
"a",
"vat",
"rate",
"that",
"appears",
"within",
"the",
"given",
"set",
"of",
"vat",
"rates",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L603-L621 |
30,277 | ipunkt/rancherize | app/Blueprint/ResourceLimit/EventListener/ServiceBuiltListener.php | ServiceBuiltListener.sidekickBuilt | public function sidekickBuilt(SidekickBuiltEvent $event) {
$service = $event->getService();
$config = $event->getConfiguration();
$this->parser->parseLimit( $service, $config );
} | php | public function sidekickBuilt(SidekickBuiltEvent $event) {
$service = $event->getService();
$config = $event->getConfiguration();
$this->parser->parseLimit( $service, $config );
} | [
"public",
"function",
"sidekickBuilt",
"(",
"SidekickBuiltEvent",
"$",
"event",
")",
"{",
"$",
"service",
"=",
"$",
"event",
"->",
"getService",
"(",
")",
";",
"$",
"config",
"=",
"$",
"event",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"parseLimit",
"(",
"$",
"service",
",",
"$",
"config",
")",
";",
"}"
] | This allows overriding the limits inherited by the main service
@param SidekickBuiltEvent $event | [
"This",
"allows",
"overriding",
"the",
"limits",
"inherited",
"by",
"the",
"main",
"service"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/ResourceLimit/EventListener/ServiceBuiltListener.php#L58-L65 |
30,278 | SIELOnline/libAcumulus | src/Config/ShopCapabilities.php | ShopCapabilities.getTokenInfo | public function getTokenInfo()
{
$result = array();
$result['invoiceSource'] = array(
'more-info' => ucfirst($this->t('invoice_source')),
'class' => '\Siel\Acumulus\Invoice\Source',
'properties' => array(
'type (' . $this->t(Source::Order) . ' ' . $this->t('or') . ' ' . $this->t(Source::CreditNote) . ')',
'id (' . $this->t('internal_id') . ')',
'reference (' . $this->t('external_id') . ')',
'date',
'status (' . $this->t('internal_not_label') . ')',
'paymentMethod (' . $this->t('internal_not_label') . ')',
'paymentStatus (1: ' . $this->t('payment_status_1') . '; 2: ' . $this->t('payment_status_2') . ')',
'paymentDate',
'countryCode',
'currency',
'invoiceReference (' . $this->t('external_id') . ')',
'invoiceDate',
),
'properties-more' => false,
);
if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result['originalInvoiceSource'] = array(
'more-info' => ucfirst($this->t('original_invoice_source')),
'properties' => array($this->t('see_invoice_source_above')),
'properties-more' => false,
);
}
$result['source'] = array_merge(array('more-info' => ucfirst($this->t('order_or_refund'))), $this->getTokenInfoSource());
if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result['refund'] = array_merge(array('more-info' => ucfirst($this->t('refund_only'))), $this->getTokenInfoRefund());
$result['order'] = array_merge(array('more-info' => ucfirst($this->t('original_order_for_refund'))), $this->getTokenInfoOrder());
$result['refundedInvoiceSource'] = array(
'more-info' => ucfirst($this->t('original_invoice_source') . ' ' . ucfirst($this->t('refund_only'))),
'properties' => array($this->t('see_invoice_source_above')),
'properties-more' => false,
);
$result['refundedOrder'] = array(
'more-info' => ucfirst($this->t('original_order_for_refund') . ' ' . ucfirst($this->t('refund_only'))),
'properties' => array($this->t('see_order_above')),
'properties-more' => false,
);
}
$result += $this->getTokenInfoShopProperties();
return $result;
} | php | public function getTokenInfo()
{
$result = array();
$result['invoiceSource'] = array(
'more-info' => ucfirst($this->t('invoice_source')),
'class' => '\Siel\Acumulus\Invoice\Source',
'properties' => array(
'type (' . $this->t(Source::Order) . ' ' . $this->t('or') . ' ' . $this->t(Source::CreditNote) . ')',
'id (' . $this->t('internal_id') . ')',
'reference (' . $this->t('external_id') . ')',
'date',
'status (' . $this->t('internal_not_label') . ')',
'paymentMethod (' . $this->t('internal_not_label') . ')',
'paymentStatus (1: ' . $this->t('payment_status_1') . '; 2: ' . $this->t('payment_status_2') . ')',
'paymentDate',
'countryCode',
'currency',
'invoiceReference (' . $this->t('external_id') . ')',
'invoiceDate',
),
'properties-more' => false,
);
if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result['originalInvoiceSource'] = array(
'more-info' => ucfirst($this->t('original_invoice_source')),
'properties' => array($this->t('see_invoice_source_above')),
'properties-more' => false,
);
}
$result['source'] = array_merge(array('more-info' => ucfirst($this->t('order_or_refund'))), $this->getTokenInfoSource());
if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result['refund'] = array_merge(array('more-info' => ucfirst($this->t('refund_only'))), $this->getTokenInfoRefund());
$result['order'] = array_merge(array('more-info' => ucfirst($this->t('original_order_for_refund'))), $this->getTokenInfoOrder());
$result['refundedInvoiceSource'] = array(
'more-info' => ucfirst($this->t('original_invoice_source') . ' ' . ucfirst($this->t('refund_only'))),
'properties' => array($this->t('see_invoice_source_above')),
'properties-more' => false,
);
$result['refundedOrder'] = array(
'more-info' => ucfirst($this->t('original_order_for_refund') . ' ' . ucfirst($this->t('refund_only'))),
'properties' => array($this->t('see_order_above')),
'properties-more' => false,
);
}
$result += $this->getTokenInfoShopProperties();
return $result;
} | [
"public",
"function",
"getTokenInfo",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"'invoiceSource'",
"]",
"=",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'invoice_source'",
")",
")",
",",
"'class'",
"=>",
"'\\Siel\\Acumulus\\Invoice\\Source'",
",",
"'properties'",
"=>",
"array",
"(",
"'type ('",
".",
"$",
"this",
"->",
"t",
"(",
"Source",
"::",
"Order",
")",
".",
"' '",
".",
"$",
"this",
"->",
"t",
"(",
"'or'",
")",
".",
"' '",
".",
"$",
"this",
"->",
"t",
"(",
"Source",
"::",
"CreditNote",
")",
".",
"')'",
",",
"'id ('",
".",
"$",
"this",
"->",
"t",
"(",
"'internal_id'",
")",
".",
"')'",
",",
"'reference ('",
".",
"$",
"this",
"->",
"t",
"(",
"'external_id'",
")",
".",
"')'",
",",
"'date'",
",",
"'status ('",
".",
"$",
"this",
"->",
"t",
"(",
"'internal_not_label'",
")",
".",
"')'",
",",
"'paymentMethod ('",
".",
"$",
"this",
"->",
"t",
"(",
"'internal_not_label'",
")",
".",
"')'",
",",
"'paymentStatus (1: '",
".",
"$",
"this",
"->",
"t",
"(",
"'payment_status_1'",
")",
".",
"'; 2: '",
".",
"$",
"this",
"->",
"t",
"(",
"'payment_status_2'",
")",
".",
"')'",
",",
"'paymentDate'",
",",
"'countryCode'",
",",
"'currency'",
",",
"'invoiceReference ('",
".",
"$",
"this",
"->",
"t",
"(",
"'external_id'",
")",
".",
"')'",
",",
"'invoiceDate'",
",",
")",
",",
"'properties-more'",
"=>",
"false",
",",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"Source",
"::",
"CreditNote",
",",
"$",
"this",
"->",
"getSupportedInvoiceSourceTypes",
"(",
")",
")",
")",
"{",
"$",
"result",
"[",
"'originalInvoiceSource'",
"]",
"=",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'original_invoice_source'",
")",
")",
",",
"'properties'",
"=>",
"array",
"(",
"$",
"this",
"->",
"t",
"(",
"'see_invoice_source_above'",
")",
")",
",",
"'properties-more'",
"=>",
"false",
",",
")",
";",
"}",
"$",
"result",
"[",
"'source'",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'order_or_refund'",
")",
")",
")",
",",
"$",
"this",
"->",
"getTokenInfoSource",
"(",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"Source",
"::",
"CreditNote",
",",
"$",
"this",
"->",
"getSupportedInvoiceSourceTypes",
"(",
")",
")",
")",
"{",
"$",
"result",
"[",
"'refund'",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'refund_only'",
")",
")",
")",
",",
"$",
"this",
"->",
"getTokenInfoRefund",
"(",
")",
")",
";",
"$",
"result",
"[",
"'order'",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'original_order_for_refund'",
")",
")",
")",
",",
"$",
"this",
"->",
"getTokenInfoOrder",
"(",
")",
")",
";",
"$",
"result",
"[",
"'refundedInvoiceSource'",
"]",
"=",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'original_invoice_source'",
")",
".",
"' '",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'refund_only'",
")",
")",
")",
",",
"'properties'",
"=>",
"array",
"(",
"$",
"this",
"->",
"t",
"(",
"'see_invoice_source_above'",
")",
")",
",",
"'properties-more'",
"=>",
"false",
",",
")",
";",
"$",
"result",
"[",
"'refundedOrder'",
"]",
"=",
"array",
"(",
"'more-info'",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'original_order_for_refund'",
")",
".",
"' '",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"'refund_only'",
")",
")",
")",
",",
"'properties'",
"=>",
"array",
"(",
"$",
"this",
"->",
"t",
"(",
"'see_order_above'",
")",
")",
",",
"'properties-more'",
"=>",
"false",
",",
")",
";",
"}",
"$",
"result",
"+=",
"$",
"this",
"->",
"getTokenInfoShopProperties",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns a list with the shop specific token info.
Many fields of an Acumulus invoice can be filled with user configured and
dynamically looked up values of properties or method return values from
webshop objects that are made available when creating the invoice. The
advanced settings form gives the user an overview of what objects,
properties and methods are available. This overview is based on the info
that this method returns.
This base implementation returns the info that is available in all
webshops. Overriding methods should add the webshop specific info, which
must at least include the "property source" 'source', being the webshop's
order or refund object or array.
This method returns an array of token infos keyed by the "property
source" name. A token info is an array that can have the following keys:
* more-info (string, optional): free text to tell the use where to look
for more info.
* class (string|string[], optional): class or array of class names where
the properties come from.
* file (string|string[], optional): file or array of file names where
the properties come from.
* table (string|string[], optional): database table or array of table names
where the properties come from.
* additional-info (string, optional): free text to give the user
additional info.
* properties (string[], required): array of property and method names
that can be used as token.
* properties-more: bool indicating if not all properties were listed and
a message indicating where to look for more properties should be shown.
It is expected that 1 of the keys class, file, or table is defined. If
class is defined, file may also be defined.
@return array[]
An array of token infos keyed by the "property source" name. | [
"Returns",
"a",
"list",
"with",
"the",
"shop",
"specific",
"token",
"info",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L128-L175 |
30,279 | SIELOnline/libAcumulus | src/Config/ShopCapabilities.php | ShopCapabilities.getSupportedInvoiceSourceTypes | public function getSupportedInvoiceSourceTypes()
{
return array(
Source::Order => ucfirst($this->t(Source::Order)),
Source::CreditNote => ucfirst($this->t(Source::CreditNote)),
);
} | php | public function getSupportedInvoiceSourceTypes()
{
return array(
Source::Order => ucfirst($this->t(Source::Order)),
Source::CreditNote => ucfirst($this->t(Source::CreditNote)),
);
} | [
"public",
"function",
"getSupportedInvoiceSourceTypes",
"(",
")",
"{",
"return",
"array",
"(",
"Source",
"::",
"Order",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"Source",
"::",
"Order",
")",
")",
",",
"Source",
"::",
"CreditNote",
"=>",
"ucfirst",
"(",
"$",
"this",
"->",
"t",
"(",
"Source",
"::",
"CreditNote",
")",
")",
",",
")",
";",
"}"
] | Returns a list of invoice source types supported by this shop.
The default implementation returns order and credit note. Override if the
specific shop does not support credit notes (or supports other types).
@return string[]
The list of supported invoice source types. The keys are the internal
{@see \Siel\Acumulus\Invoice\Source} constants, the values are
translated labels. | [
"Returns",
"a",
"list",
"of",
"invoice",
"source",
"types",
"supported",
"by",
"this",
"shop",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L242-L248 |
30,280 | SIELOnline/libAcumulus | src/Config/ShopCapabilities.php | ShopCapabilities.getTriggerCreditNoteEventOptions | public function getTriggerCreditNoteEventOptions()
{
$result = array(
PluginConfig::TriggerCreditNoteEvent_None => $this->t('option_triggerCreditNoteEvent_0'),
);
if (in_array(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result[PluginConfig::TriggerCreditNoteEvent_Create] = $this->t('option_triggerCreditNoteEvent_1');
}
return $result;
} | php | public function getTriggerCreditNoteEventOptions()
{
$result = array(
PluginConfig::TriggerCreditNoteEvent_None => $this->t('option_triggerCreditNoteEvent_0'),
);
if (in_array(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) {
$result[PluginConfig::TriggerCreditNoteEvent_Create] = $this->t('option_triggerCreditNoteEvent_1');
}
return $result;
} | [
"public",
"function",
"getTriggerCreditNoteEventOptions",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"PluginConfig",
"::",
"TriggerCreditNoteEvent_None",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_triggerCreditNoteEvent_0'",
")",
",",
")",
";",
"if",
"(",
"in_array",
"(",
"Source",
"::",
"CreditNote",
",",
"$",
"this",
"->",
"getSupportedInvoiceSourceTypes",
"(",
")",
")",
")",
"{",
"$",
"result",
"[",
"PluginConfig",
"::",
"TriggerCreditNoteEvent_Create",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'option_triggerCreditNoteEvent_1'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns an option list of credit note related events.
This list represents the shop initiated events that may trigger the
sending of a credit invoice to Acumulus.
This default implementation returns
- PluginConfig::TriggerCreditNoteEvent_None for all shops, and as only
value for shops that do not support credit notes
- PluginConfig::TriggerCreditNoteEvent_Create for shops that do support
credit notes (based on {@see getSupportedInvoiceSourceTypes()}).
@return string[]
An array of all credit note related events, with the key being the ID
for the dropdown item, 1 of the {@see \Siel\Acumulus\PluginConfig}
TriggerCreditNoteEvent_... constants, and the value being the label for
the dropdown item. | [
"Returns",
"an",
"option",
"list",
"of",
"credit",
"note",
"related",
"events",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L287-L298 |
30,281 | SIELOnline/libAcumulus | src/Config/ShopCapabilities.php | ShopCapabilities.getInvoiceNrSourceOptions | public function getInvoiceNrSourceOptions()
{
return array(
PluginConfig::InvoiceNrSource_ShopInvoice => $this->t('option_invoiceNrSource_1'),
PluginConfig::InvoiceNrSource_ShopOrder => $this->t('option_invoiceNrSource_2'),
PluginConfig::InvoiceNrSource_Acumulus => $this->t('option_invoiceNrSource_3'),
);
} | php | public function getInvoiceNrSourceOptions()
{
return array(
PluginConfig::InvoiceNrSource_ShopInvoice => $this->t('option_invoiceNrSource_1'),
PluginConfig::InvoiceNrSource_ShopOrder => $this->t('option_invoiceNrSource_2'),
PluginConfig::InvoiceNrSource_Acumulus => $this->t('option_invoiceNrSource_3'),
);
} | [
"public",
"function",
"getInvoiceNrSourceOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"InvoiceNrSource_ShopInvoice",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_invoiceNrSource_1'",
")",
",",
"PluginConfig",
"::",
"InvoiceNrSource_ShopOrder",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_invoiceNrSource_2'",
")",
",",
"PluginConfig",
"::",
"InvoiceNrSource_Acumulus",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_invoiceNrSource_3'",
")",
",",
")",
";",
"}"
] | Returns a list of valid sources that can be used as invoice number.
This may differ per shop as not all shops support invoices as a separate
entity.
Overrides should typically return a subset of the constants defined in
this base implementation, but including at least
{@see \Siel\Acumulus\PluginConfig::InvoiceNrSource_Acumulus}.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"valid",
"sources",
"that",
"can",
"be",
"used",
"as",
"invoice",
"number",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L314-L321 |
30,282 | SIELOnline/libAcumulus | src/Config/ShopCapabilities.php | ShopCapabilities.getDateToUseOptions | public function getDateToUseOptions()
{
return array(
PluginConfig::InvoiceDate_InvoiceCreate => $this->t('option_dateToUse_1'),
PluginConfig::InvoiceDate_OrderCreate => $this->t('option_dateToUse_2'),
PluginConfig::InvoiceDate_Transfer => $this->t('option_dateToUse_3'),
);
} | php | public function getDateToUseOptions()
{
return array(
PluginConfig::InvoiceDate_InvoiceCreate => $this->t('option_dateToUse_1'),
PluginConfig::InvoiceDate_OrderCreate => $this->t('option_dateToUse_2'),
PluginConfig::InvoiceDate_Transfer => $this->t('option_dateToUse_3'),
);
} | [
"public",
"function",
"getDateToUseOptions",
"(",
")",
"{",
"return",
"array",
"(",
"PluginConfig",
"::",
"InvoiceDate_InvoiceCreate",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_dateToUse_1'",
")",
",",
"PluginConfig",
"::",
"InvoiceDate_OrderCreate",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_dateToUse_2'",
")",
",",
"PluginConfig",
"::",
"InvoiceDate_Transfer",
"=>",
"$",
"this",
"->",
"t",
"(",
"'option_dateToUse_3'",
")",
",",
")",
";",
"}"
] | Returns a list of valid date sources that can be used as invoice date.
This may differ per shop as not all shops support invoices as a separate
entity.
Overrides should typically return a subset of the constants defined in
this base implementation, but including at least
{@see \Siel\Acumulus\PluginConfig::InvoiceDate_Transfer}.
@return string[]
An array keyed by the option values and having translated descriptions
as values. | [
"Returns",
"a",
"list",
"of",
"valid",
"date",
"sources",
"that",
"can",
"be",
"used",
"as",
"invoice",
"date",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L337-L344 |
30,283 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.getItemLineBeforeBookings | public function getItemLineBeforeBookings(Creator $creator, WC_Order_Item_Product $item, $product)
{
if ($product instanceof WC_Product) {
if (function_exists('is_wc_booking_product') && is_wc_booking_product($product)) {
$booking_ids = WC_Booking_Data_Store::get_booking_ids_from_order_item_id($item->get_id());
if ($booking_ids) {
// I cannot imagine multiple bookings belonging to the same
// order line, but if that occurs, only the 1st booking will
// be added as a property source.
$booking = new WC_Booking(reset($booking_ids));
$creator->addPropertySource('booking', $booking);
$resource = $booking->get_resource();
if ($resource) {
$creator->addPropertySource('resource', $resource);
}
}
}
}
} | php | public function getItemLineBeforeBookings(Creator $creator, WC_Order_Item_Product $item, $product)
{
if ($product instanceof WC_Product) {
if (function_exists('is_wc_booking_product') && is_wc_booking_product($product)) {
$booking_ids = WC_Booking_Data_Store::get_booking_ids_from_order_item_id($item->get_id());
if ($booking_ids) {
// I cannot imagine multiple bookings belonging to the same
// order line, but if that occurs, only the 1st booking will
// be added as a property source.
$booking = new WC_Booking(reset($booking_ids));
$creator->addPropertySource('booking', $booking);
$resource = $booking->get_resource();
if ($resource) {
$creator->addPropertySource('resource', $resource);
}
}
}
}
} | [
"public",
"function",
"getItemLineBeforeBookings",
"(",
"Creator",
"$",
"creator",
",",
"WC_Order_Item_Product",
"$",
"item",
",",
"$",
"product",
")",
"{",
"if",
"(",
"$",
"product",
"instanceof",
"WC_Product",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'is_wc_booking_product'",
")",
"&&",
"is_wc_booking_product",
"(",
"$",
"product",
")",
")",
"{",
"$",
"booking_ids",
"=",
"WC_Booking_Data_Store",
"::",
"get_booking_ids_from_order_item_id",
"(",
"$",
"item",
"->",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"$",
"booking_ids",
")",
"{",
"// I cannot imagine multiple bookings belonging to the same",
"// order line, but if that occurs, only the 1st booking will",
"// be added as a property source.",
"$",
"booking",
"=",
"new",
"WC_Booking",
"(",
"reset",
"(",
"$",
"booking_ids",
")",
")",
";",
"$",
"creator",
"->",
"addPropertySource",
"(",
"'booking'",
",",
"$",
"booking",
")",
";",
"$",
"resource",
"=",
"$",
"booking",
"->",
"get_resource",
"(",
")",
";",
"if",
"(",
"$",
"resource",
")",
"{",
"$",
"creator",
"->",
"addPropertySource",
"(",
"'resource'",
",",
"$",
"resource",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Support for the "WooCommerce Bookings" plugin.
Bookings are stored in a separate entity, we add that as a separate
property source, so its properties can be used.
@param \Siel\Acumulus\WooCommerce\Invoice\Creator $creator
@param WC_Order_Item_Product $item
@param WC_Product|bool $product | [
"Support",
"for",
"the",
"WooCommerce",
"Bookings",
"plugin",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L72-L90 |
30,284 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.acumulusInvoiceCreated | public function acumulusInvoiceCreated($invoice, BaseSource $invoiceSource, Result $localResult)
{
$invoice = $this->supportBundleProducts($invoice, $invoiceSource, $localResult);
$invoice = $this->supportTMExtraProductOptions($invoice, $invoiceSource, $localResult);
return $invoice;
} | php | public function acumulusInvoiceCreated($invoice, BaseSource $invoiceSource, Result $localResult)
{
$invoice = $this->supportBundleProducts($invoice, $invoiceSource, $localResult);
$invoice = $this->supportTMExtraProductOptions($invoice, $invoiceSource, $localResult);
return $invoice;
} | [
"public",
"function",
"acumulusInvoiceCreated",
"(",
"$",
"invoice",
",",
"BaseSource",
"$",
"invoiceSource",
",",
"Result",
"$",
"localResult",
")",
"{",
"$",
"invoice",
"=",
"$",
"this",
"->",
"supportBundleProducts",
"(",
"$",
"invoice",
",",
"$",
"invoiceSource",
",",
"$",
"localResult",
")",
";",
"$",
"invoice",
"=",
"$",
"this",
"->",
"supportTMExtraProductOptions",
"(",
"$",
"invoice",
",",
"$",
"invoiceSource",
",",
"$",
"localResult",
")",
";",
"return",
"$",
"invoice",
";",
"}"
] | Filter that reacts to the acumulus_invoice_created event.
@param array|null $invoice
@param \Siel\Acumulus\Invoice\Source $invoiceSource
@param \Siel\Acumulus\Invoice\Result $localResult
@return array|null | [
"Filter",
"that",
"reacts",
"to",
"the",
"acumulus_invoice_created",
"event",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L115-L120 |
30,285 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.supportBundleProducts | protected function supportBundleProducts($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult)
{
/** @var \WC_Abstract_Order $shopSource */
$shopSource = $invoiceSource->getSource();
/** @var WC_Order_Item_Product[] $items */
$items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item'));
foreach ($items as $item) {
$bundleId = $item->get_meta('_bundle_cart_key');
$bundledBy = $item->get_meta('_bundled_by');
if (!empty($bundleId) || !empty($bundledBy)) {
$line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id());
if ($line !== null) {
// Add bundle meta data.
if ( !empty($bundleId)) {
// Bundle or bundled product.
$line[Meta::BundleId] = $bundleId;
}
if ( !empty($bundledBy)) {
// Bundled products only.
$line[Meta::BundleParentId] = $bundledBy;
$line[Meta::BundleVisible] = $item->get_meta('bundled_item_hidden') !== 'yes';
}
}
}
}
$invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->groupBundles($invoice[Tag::Customer][Tag::Invoice][Tag::Line]);
return $invoice;
} | php | protected function supportBundleProducts($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult)
{
/** @var \WC_Abstract_Order $shopSource */
$shopSource = $invoiceSource->getSource();
/** @var WC_Order_Item_Product[] $items */
$items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item'));
foreach ($items as $item) {
$bundleId = $item->get_meta('_bundle_cart_key');
$bundledBy = $item->get_meta('_bundled_by');
if (!empty($bundleId) || !empty($bundledBy)) {
$line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id());
if ($line !== null) {
// Add bundle meta data.
if ( !empty($bundleId)) {
// Bundle or bundled product.
$line[Meta::BundleId] = $bundleId;
}
if ( !empty($bundledBy)) {
// Bundled products only.
$line[Meta::BundleParentId] = $bundledBy;
$line[Meta::BundleVisible] = $item->get_meta('bundled_item_hidden') !== 'yes';
}
}
}
}
$invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->groupBundles($invoice[Tag::Customer][Tag::Invoice][Tag::Line]);
return $invoice;
} | [
"protected",
"function",
"supportBundleProducts",
"(",
"$",
"invoice",
",",
"BaseSource",
"$",
"invoiceSource",
",",
"/** @noinspection PhpUnusedParameterInspection */",
"Result",
"$",
"localResult",
")",
"{",
"/** @var \\WC_Abstract_Order $shopSource */",
"$",
"shopSource",
"=",
"$",
"invoiceSource",
"->",
"getSource",
"(",
")",
";",
"/** @var WC_Order_Item_Product[] $items */",
"$",
"items",
"=",
"$",
"shopSource",
"->",
"get_items",
"(",
"apply_filters",
"(",
"'woocommerce_admin_order_item_types'",
",",
"'line_item'",
")",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"bundleId",
"=",
"$",
"item",
"->",
"get_meta",
"(",
"'_bundle_cart_key'",
")",
";",
"$",
"bundledBy",
"=",
"$",
"item",
"->",
"get_meta",
"(",
"'_bundled_by'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"bundleId",
")",
"||",
"!",
"empty",
"(",
"$",
"bundledBy",
")",
")",
"{",
"$",
"line",
"=",
"&",
"$",
"this",
"->",
"getLineByMetaId",
"(",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
",",
"$",
"item",
"->",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"$",
"line",
"!==",
"null",
")",
"{",
"// Add bundle meta data.",
"if",
"(",
"!",
"empty",
"(",
"$",
"bundleId",
")",
")",
"{",
"// Bundle or bundled product.",
"$",
"line",
"[",
"Meta",
"::",
"BundleId",
"]",
"=",
"$",
"bundleId",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"bundledBy",
")",
")",
"{",
"// Bundled products only.",
"$",
"line",
"[",
"Meta",
"::",
"BundleParentId",
"]",
"=",
"$",
"bundledBy",
";",
"$",
"line",
"[",
"Meta",
"::",
"BundleVisible",
"]",
"=",
"$",
"item",
"->",
"get_meta",
"(",
"'bundled_item_hidden'",
")",
"!==",
"'yes'",
";",
"}",
"}",
"}",
"}",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
"=",
"$",
"this",
"->",
"groupBundles",
"(",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
")",
";",
"return",
"$",
"invoice",
";",
"}"
] | Supports the "WooCommerce Bundle Products" plugin.
This method supports the woocommerce-product-bundles extension that
stores the bundle products as separate item lines below the bundle line
and uses the meta data described below to link them to each other.
This method hierarchically groups bundled products into the bundle
product and can do so multi-level.
Meta data on bundle lines:
- bundle_cart_key (hash) unique identifier.
- bundled_items (hash[]) refers to the bundle_cart_key of the bundled
products.
Meta data on bundled items:
- bundled_by (hash) refers to bundle_cart_key of the bundle line.
- bundle_cart_key (hash) unique identifier.
- bundled_item_hidden: 'yes'|'no' or absent (= 'no').
1) In a 1st pass, we first add bundle meta data to each invoice line that
represents a bundle or bundled item.
2) In a 2nd pass, we group the bundled items as children into the parent
line.
@param array|null $invoice
@param \Siel\Acumulus\Invoice\Source $invoiceSource
@param \Siel\Acumulus\Invoice\Result $localResult
@return array|null | [
"Supports",
"the",
"WooCommerce",
"Bundle",
"Products",
"plugin",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L153-L182 |
30,286 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.groupBundles | protected function groupBundles(array $itemLines)
{
$result = array();
foreach ($itemLines as &$itemLine) {
if (!empty($itemLine[Meta::BundleParentId])) {
// Find the parent, note that we expect bundle products to
// appear before their bundled products, so we can search in
// $result and have a reference to a line in $result returned!
$parent = &$this->getParentBundle($result, $itemLine[Meta::BundleParentId]);
if ($parent !== null) {
// Add the bundled product as a child to the bundle.
$parent[Meta::ChildrenLines][] = $itemLine;
} else {
// Oops: not found. Store a message in the line meta data
// and keep it as a separate line.
$itemLine[Meta::BundleParentId] .= ': not found';
$result[] = $itemLine;
}
} else {
// Not a bundled product: just add it to the result.
$result[] = $itemLine;
}
}
return $result;
} | php | protected function groupBundles(array $itemLines)
{
$result = array();
foreach ($itemLines as &$itemLine) {
if (!empty($itemLine[Meta::BundleParentId])) {
// Find the parent, note that we expect bundle products to
// appear before their bundled products, so we can search in
// $result and have a reference to a line in $result returned!
$parent = &$this->getParentBundle($result, $itemLine[Meta::BundleParentId]);
if ($parent !== null) {
// Add the bundled product as a child to the bundle.
$parent[Meta::ChildrenLines][] = $itemLine;
} else {
// Oops: not found. Store a message in the line meta data
// and keep it as a separate line.
$itemLine[Meta::BundleParentId] .= ': not found';
$result[] = $itemLine;
}
} else {
// Not a bundled product: just add it to the result.
$result[] = $itemLine;
}
}
return $result;
} | [
"protected",
"function",
"groupBundles",
"(",
"array",
"$",
"itemLines",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"itemLines",
"as",
"&",
"$",
"itemLine",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"itemLine",
"[",
"Meta",
"::",
"BundleParentId",
"]",
")",
")",
"{",
"// Find the parent, note that we expect bundle products to",
"// appear before their bundled products, so we can search in",
"// $result and have a reference to a line in $result returned!",
"$",
"parent",
"=",
"&",
"$",
"this",
"->",
"getParentBundle",
"(",
"$",
"result",
",",
"$",
"itemLine",
"[",
"Meta",
"::",
"BundleParentId",
"]",
")",
";",
"if",
"(",
"$",
"parent",
"!==",
"null",
")",
"{",
"// Add the bundled product as a child to the bundle.",
"$",
"parent",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
"[",
"]",
"=",
"$",
"itemLine",
";",
"}",
"else",
"{",
"// Oops: not found. Store a message in the line meta data",
"// and keep it as a separate line.",
"$",
"itemLine",
"[",
"Meta",
"::",
"BundleParentId",
"]",
".=",
"': not found'",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"itemLine",
";",
"}",
"}",
"else",
"{",
"// Not a bundled product: just add it to the result.",
"$",
"result",
"[",
"]",
"=",
"$",
"itemLine",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Groups bundled products into the bundle product.
@param array $itemLines
The set of invoice lines that may contain bundle lines and bundled
lines.
@return array
The set of item lines but with the lines of bundled items
hierarchically placed in their bundle line. | [
"Groups",
"bundled",
"products",
"into",
"the",
"bundle",
"product",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L206-L230 |
30,287 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.& | protected function &getParentBundle(array &$lines, $parentId)
{
foreach ($lines as &$line) {
if (!empty($line[Meta::BundleId]) && $line[Meta::BundleId] === $parentId) {
return $line;
} elseif (!empty($line[Meta::ChildrenLines])) {
// Recursively search for the parent bundle.
$parent = &$this->getParentBundle($line[Meta::ChildrenLines], $parentId);
if ($parent !== null) {
return $parent;
}
}
}
// Not found.
return null;
} | php | protected function &getParentBundle(array &$lines, $parentId)
{
foreach ($lines as &$line) {
if (!empty($line[Meta::BundleId]) && $line[Meta::BundleId] === $parentId) {
return $line;
} elseif (!empty($line[Meta::ChildrenLines])) {
// Recursively search for the parent bundle.
$parent = &$this->getParentBundle($line[Meta::ChildrenLines], $parentId);
if ($parent !== null) {
return $parent;
}
}
}
// Not found.
return null;
} | [
"protected",
"function",
"&",
"getParentBundle",
"(",
"array",
"&",
"$",
"lines",
",",
"$",
"parentId",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"&",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
"[",
"Meta",
"::",
"BundleId",
"]",
")",
"&&",
"$",
"line",
"[",
"Meta",
"::",
"BundleId",
"]",
"===",
"$",
"parentId",
")",
"{",
"return",
"$",
"line",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"line",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
")",
")",
"{",
"// Recursively search for the parent bundle.",
"$",
"parent",
"=",
"&",
"$",
"this",
"->",
"getParentBundle",
"(",
"$",
"line",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
",",
"$",
"parentId",
")",
";",
"if",
"(",
"$",
"parent",
"!==",
"null",
")",
"{",
"return",
"$",
"parent",
";",
"}",
"}",
"}",
"// Not found.",
"return",
"null",
";",
"}"
] | Searches for, and returns by reference, the parent bundle line.
@param array $lines
The lines to search for the parent bundle line.
@param $parentId
The meta-bundle-id value to search for.
@return array|null
The parent bundle line or null if not found. | [
"Searches",
"for",
"and",
"returns",
"by",
"reference",
"the",
"parent",
"bundle",
"line",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L243-L258 |
30,288 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/CreatorPluginSupport.php | CreatorPluginSupport.supportTMExtraProductOptions | protected function supportTMExtraProductOptions($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult)
{
/** @var \WC_Abstract_Order $shopSource */
$shopSource = $invoiceSource->getSource();
/** @var WC_Order_Item_Product[] $items */
$items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item'));
foreach ($items as $item) {
// If the plugin is no longer used, we may still have an order with
// products where the plugin was used. Moreover we don't use any
// function or method from the plugin, only its stored data, so we
// don'have to check for it being active, just the data being there.
if (!empty($item['tmcartepo_data'])) {
$line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id());
if ($line !== null) {
$commonTags = array(
Tag::Quantity => $line[Tag::Quantity],
Meta::VatRateSource => Creator::VatRateSource_Parent,
);
$result[Meta::ChildrenLines] = $this->getExtraProductOptionsLines($item, $commonTags);
}
}
}
return $invoice;
} | php | protected function supportTMExtraProductOptions($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult)
{
/** @var \WC_Abstract_Order $shopSource */
$shopSource = $invoiceSource->getSource();
/** @var WC_Order_Item_Product[] $items */
$items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item'));
foreach ($items as $item) {
// If the plugin is no longer used, we may still have an order with
// products where the plugin was used. Moreover we don't use any
// function or method from the plugin, only its stored data, so we
// don'have to check for it being active, just the data being there.
if (!empty($item['tmcartepo_data'])) {
$line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id());
if ($line !== null) {
$commonTags = array(
Tag::Quantity => $line[Tag::Quantity],
Meta::VatRateSource => Creator::VatRateSource_Parent,
);
$result[Meta::ChildrenLines] = $this->getExtraProductOptionsLines($item, $commonTags);
}
}
}
return $invoice;
} | [
"protected",
"function",
"supportTMExtraProductOptions",
"(",
"$",
"invoice",
",",
"BaseSource",
"$",
"invoiceSource",
",",
"/** @noinspection PhpUnusedParameterInspection */",
"Result",
"$",
"localResult",
")",
"{",
"/** @var \\WC_Abstract_Order $shopSource */",
"$",
"shopSource",
"=",
"$",
"invoiceSource",
"->",
"getSource",
"(",
")",
";",
"/** @var WC_Order_Item_Product[] $items */",
"$",
"items",
"=",
"$",
"shopSource",
"->",
"get_items",
"(",
"apply_filters",
"(",
"'woocommerce_admin_order_item_types'",
",",
"'line_item'",
")",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"// If the plugin is no longer used, we may still have an order with",
"// products where the plugin was used. Moreover we don't use any",
"// function or method from the plugin, only its stored data, so we",
"// don'have to check for it being active, just the data being there.",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'tmcartepo_data'",
"]",
")",
")",
"{",
"$",
"line",
"=",
"&",
"$",
"this",
"->",
"getLineByMetaId",
"(",
"$",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
",",
"$",
"item",
"->",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"$",
"line",
"!==",
"null",
")",
"{",
"$",
"commonTags",
"=",
"array",
"(",
"Tag",
"::",
"Quantity",
"=>",
"$",
"line",
"[",
"Tag",
"::",
"Quantity",
"]",
",",
"Meta",
"::",
"VatRateSource",
"=>",
"Creator",
"::",
"VatRateSource_Parent",
",",
")",
";",
"$",
"result",
"[",
"Meta",
"::",
"ChildrenLines",
"]",
"=",
"$",
"this",
"->",
"getExtraProductOptionsLines",
"(",
"$",
"item",
",",
"$",
"commonTags",
")",
";",
"}",
"}",
"}",
"return",
"$",
"invoice",
";",
"}"
] | Supports the "WooCommerce TM Extra Product Options" plugin.
This method supports the tm-woo-extra-product-options extension that
places its data in the meta data under keys that start wth tm_epo or
tmcartepo. We need the the tncartepo_data value as that contains the
options.
This method adds the option data as children to the invoice line.
@param array|null $invoice
@param \Siel\Acumulus\Invoice\Source $invoiceSource
@param \Siel\Acumulus\Invoice\Result $localResult
@return array|null | [
"Supports",
"the",
"WooCommerce",
"TM",
"Extra",
"Product",
"Options",
"plugin",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L276-L300 |
30,289 | dreamfactorysoftware/df-user | src/Services/User.php | User.handlesAlternateAuth | public function handlesAlternateAuth()
{
if (
config('df.alternate_auth') === true &&
!empty(array_get($this->config, 'alt_auth_db_service_id')) &&
!empty(array_get($this->config, 'alt_auth_table')) &&
!empty(array_get($this->config, 'alt_auth_username_field')) &&
!empty(array_get($this->config, 'alt_auth_password_field')) &&
!empty(array_get($this->config, 'alt_auth_email_field'))
) {
return true;
}
return false;
} | php | public function handlesAlternateAuth()
{
if (
config('df.alternate_auth') === true &&
!empty(array_get($this->config, 'alt_auth_db_service_id')) &&
!empty(array_get($this->config, 'alt_auth_table')) &&
!empty(array_get($this->config, 'alt_auth_username_field')) &&
!empty(array_get($this->config, 'alt_auth_password_field')) &&
!empty(array_get($this->config, 'alt_auth_email_field'))
) {
return true;
}
return false;
} | [
"public",
"function",
"handlesAlternateAuth",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'df.alternate_auth'",
")",
"===",
"true",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_db_service_id'",
")",
")",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_table'",
")",
")",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_username_field'",
")",
")",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_password_field'",
")",
")",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_email_field'",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks to see if the service handles alternative authentication
@return bool | [
"Checks",
"to",
"see",
"if",
"the",
"service",
"handles",
"alternative",
"authentication"
] | 06747c83f03d51693d212d948dd5d49f098192ca | https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Services/User.php#L120-L134 |
30,290 | dreamfactorysoftware/df-user | src/Services/User.php | User.getAltAuthenticator | public function getAltAuthenticator()
{
if ($this->handlesAlternateAuth()) {
$authenticator = new AlternateAuth(
array_get($this->config, 'alt_auth_db_service_id'),
array_get($this->config, 'alt_auth_table'),
array_get($this->config, 'alt_auth_username_field'),
array_get($this->config, 'alt_auth_password_field'),
array_get($this->config, 'alt_auth_email_field')
);
$authenticator->setOtherFields(array_get($this->config, 'alt_auth_other_fields'));
$authenticator->setFilters(array_get($this->config, 'alt_auth_filter'));
return $authenticator;
} else {
throw new InternalServerErrorException('No alternate authentication is configured for this service.');
}
} | php | public function getAltAuthenticator()
{
if ($this->handlesAlternateAuth()) {
$authenticator = new AlternateAuth(
array_get($this->config, 'alt_auth_db_service_id'),
array_get($this->config, 'alt_auth_table'),
array_get($this->config, 'alt_auth_username_field'),
array_get($this->config, 'alt_auth_password_field'),
array_get($this->config, 'alt_auth_email_field')
);
$authenticator->setOtherFields(array_get($this->config, 'alt_auth_other_fields'));
$authenticator->setFilters(array_get($this->config, 'alt_auth_filter'));
return $authenticator;
} else {
throw new InternalServerErrorException('No alternate authentication is configured for this service.');
}
} | [
"public",
"function",
"getAltAuthenticator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handlesAlternateAuth",
"(",
")",
")",
"{",
"$",
"authenticator",
"=",
"new",
"AlternateAuth",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_db_service_id'",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_table'",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_username_field'",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_password_field'",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_email_field'",
")",
")",
";",
"$",
"authenticator",
"->",
"setOtherFields",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_other_fields'",
")",
")",
";",
"$",
"authenticator",
"->",
"setFilters",
"(",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'alt_auth_filter'",
")",
")",
";",
"return",
"$",
"authenticator",
";",
"}",
"else",
"{",
"throw",
"new",
"InternalServerErrorException",
"(",
"'No alternate authentication is configured for this service.'",
")",
";",
"}",
"}"
] | If the service handles alternative authentication then
this method will return the alternative authenticator
@return \DreamFactory\Core\User\Components\AlternateAuth
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException | [
"If",
"the",
"service",
"handles",
"alternative",
"authentication",
"then",
"this",
"method",
"will",
"return",
"the",
"alternative",
"authenticator"
] | 06747c83f03d51693d212d948dd5d49f098192ca | https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Services/User.php#L143-L160 |
30,291 | fontis/composer-autoloader | src/app/code/community/Fontis/ComposerAutoloader/Helper/Data.php | Fontis_ComposerAutoloader_Helper_Data.getVendorDirectoryPath | public function getVendorDirectoryPath()
{
$path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path');
if (!$path) {
$path = self::DEFAULT_PATH;
}
$path = str_replace('/', DS, $path);
$path = str_replace('{{basedir}}', Mage::getBaseDir(), $path);
$path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path);
$path = rtrim($path, DS);
return realpath($path);
} | php | public function getVendorDirectoryPath()
{
$path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path');
if (!$path) {
$path = self::DEFAULT_PATH;
}
$path = str_replace('/', DS, $path);
$path = str_replace('{{basedir}}', Mage::getBaseDir(), $path);
$path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path);
$path = rtrim($path, DS);
return realpath($path);
} | [
"public",
"function",
"getVendorDirectoryPath",
"(",
")",
"{",
"$",
"path",
"=",
"(",
"string",
")",
"Mage",
"::",
"getConfig",
"(",
")",
"->",
"getNode",
"(",
"'global/composer_autoloader/path'",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"DEFAULT_PATH",
";",
"}",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
",",
"DS",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'{{basedir}}'",
",",
"Mage",
"::",
"getBaseDir",
"(",
")",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"'{{libdir}}'",
",",
"Mage",
"::",
"getBaseDir",
"(",
"'lib'",
")",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"DS",
")",
";",
"return",
"realpath",
"(",
"$",
"path",
")",
";",
"}"
] | The location of the vendor directory on the machine the site is running on.
It always comes without a trailing slash.
@return string | [
"The",
"location",
"of",
"the",
"vendor",
"directory",
"on",
"the",
"machine",
"the",
"site",
"is",
"running",
"on",
".",
"It",
"always",
"comes",
"without",
"a",
"trailing",
"slash",
"."
] | edebd4f638c3d60ce5a2329ff834c2f1048ef8be | https://github.com/fontis/composer-autoloader/blob/edebd4f638c3d60ce5a2329ff834c2f1048ef8be/src/app/code/community/Fontis/ComposerAutoloader/Helper/Data.php#L31-L43 |
30,292 | ipunkt/rancherize | app/Blueprint/Infrastructure/Volume/VolumeWriter.php | VolumeWriter.clear | public function clear(FileWriter $fileWriter) {
$fileWriter->put($this->path.'/docker-compose.yml', '');
$fileWriter->put($this->path.'/rancher-compose.yml', '');
} | php | public function clear(FileWriter $fileWriter) {
$fileWriter->put($this->path.'/docker-compose.yml', '');
$fileWriter->put($this->path.'/rancher-compose.yml', '');
} | [
"public",
"function",
"clear",
"(",
"FileWriter",
"$",
"fileWriter",
")",
"{",
"$",
"fileWriter",
"->",
"put",
"(",
"$",
"this",
"->",
"path",
".",
"'/docker-compose.yml'",
",",
"''",
")",
";",
"$",
"fileWriter",
"->",
"put",
"(",
"$",
"this",
"->",
"path",
".",
"'/rancher-compose.yml'",
",",
"''",
")",
";",
"}"
] | Clear the written files.
Necessary because the write function appends to them so if fresh files are expected they have to be cleared first
@param FileWriter $fileWriter | [
"Clear",
"the",
"written",
"files",
".",
"Necessary",
"because",
"the",
"write",
"function",
"appends",
"to",
"them",
"so",
"if",
"fresh",
"files",
"are",
"expected",
"they",
"have",
"to",
"be",
"cleared",
"first"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Infrastructure/Volume/VolumeWriter.php#L68-L71 |
30,293 | ipunkt/rancherize | app/Services/BlueprintService.php | BlueprintService.byConfiguration | public function byConfiguration(Configuration $configuration, array $flags) : Blueprint {
$blueprintName = $configuration->get('project.blueprint');
return $this->load($blueprintName, $flags);
} | php | public function byConfiguration(Configuration $configuration, array $flags) : Blueprint {
$blueprintName = $configuration->get('project.blueprint');
return $this->load($blueprintName, $flags);
} | [
"public",
"function",
"byConfiguration",
"(",
"Configuration",
"$",
"configuration",
",",
"array",
"$",
"flags",
")",
":",
"Blueprint",
"{",
"$",
"blueprintName",
"=",
"$",
"configuration",
"->",
"get",
"(",
"'project.blueprint'",
")",
";",
"return",
"$",
"this",
"->",
"load",
"(",
"$",
"blueprintName",
",",
"$",
"flags",
")",
";",
"}"
] | Retrieve the blueprint that was set in the configuration
@param Configuration $configuration
@param array $flags
@return \Rancherize\Blueprint\Blueprint | [
"Retrieve",
"the",
"blueprint",
"that",
"was",
"set",
"in",
"the",
"configuration"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/BlueprintService.php#L33-L37 |
30,294 | ipunkt/rancherize | app/Services/BlueprintService.php | BlueprintService.load | public function load(string $blueprintName, array $flags) : Blueprint {
$blueprint = $this->blueprintFactory->get($blueprintName);
foreach($flags as $name => $value)
$blueprint->setFlag($name, $value);
return $blueprint;
} | php | public function load(string $blueprintName, array $flags) : Blueprint {
$blueprint = $this->blueprintFactory->get($blueprintName);
foreach($flags as $name => $value)
$blueprint->setFlag($name, $value);
return $blueprint;
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"blueprintName",
",",
"array",
"$",
"flags",
")",
":",
"Blueprint",
"{",
"$",
"blueprint",
"=",
"$",
"this",
"->",
"blueprintFactory",
"->",
"get",
"(",
"$",
"blueprintName",
")",
";",
"foreach",
"(",
"$",
"flags",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"$",
"blueprint",
"->",
"setFlag",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"blueprint",
";",
"}"
] | Load by name
@param string $blueprintName
@param array $flags
@return \Rancherize\Blueprint\Blueprint
@internal param array $options | [
"Load",
"by",
"name"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/BlueprintService.php#L47-L54 |
30,295 | SIELOnline/libAcumulus | src/Invoice/CompletorStrategy/TryAllVatRatePermutations.php | TryAllVatRatePermutations.setVatRates | protected function setVatRates($vatType, $include0)
{
$this->vatRates = array();
foreach ($this->possibleVatRates as $vatRate) {
if ($vatRate[Tag::VatType] === $vatType) {
$this->vatRates[] = $vatRate[Tag::VatRate];
}
}
if ($include0) {
$this->vatRates[] = 0.0;
}
} | php | protected function setVatRates($vatType, $include0)
{
$this->vatRates = array();
foreach ($this->possibleVatRates as $vatRate) {
if ($vatRate[Tag::VatType] === $vatType) {
$this->vatRates[] = $vatRate[Tag::VatRate];
}
}
if ($include0) {
$this->vatRates[] = 0.0;
}
} | [
"protected",
"function",
"setVatRates",
"(",
"$",
"vatType",
",",
"$",
"include0",
")",
"{",
"$",
"this",
"->",
"vatRates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"possibleVatRates",
"as",
"$",
"vatRate",
")",
"{",
"if",
"(",
"$",
"vatRate",
"[",
"Tag",
"::",
"VatType",
"]",
"===",
"$",
"vatType",
")",
"{",
"$",
"this",
"->",
"vatRates",
"[",
"]",
"=",
"$",
"vatRate",
"[",
"Tag",
"::",
"VatRate",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"include0",
")",
"{",
"$",
"this",
"->",
"vatRates",
"[",
"]",
"=",
"0.0",
";",
"}",
"}"
] | Initializes the array of vat rates to use for this permutation.
@param float $vatType
@param bool $include0 | [
"Initializes",
"the",
"array",
"of",
"vat",
"rates",
"to",
"use",
"for",
"this",
"permutation",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategy/TryAllVatRatePermutations.php#L60-L71 |
30,296 | SIELOnline/libAcumulus | src/Invoice/CompletorStrategyLines.php | CompletorStrategyLines.completeStrategyLines | protected function completeStrategyLines()
{
if ($this->invoiceHasStrategyLine()) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true));
$isFirst = true;
$strategies = $this->getStrategyClasses();
foreach ($strategies as $strategyClass) {
/** @var CompletorStrategyBase $strategy */
$strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source);
if ($isFirst) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide();
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true));
$isFirst = false;
}
if ($strategy->apply()) {
$this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName());
if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription();
} else {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription();
}
// Allow for partial solutions: a strategy may correct only some of
// the strategy lines and leave the rest up to other strategies.
if (!$this->invoiceHasStrategyLine()) {
break;
}
}
}
}
} | php | protected function completeStrategyLines()
{
if ($this->invoiceHasStrategyLine()) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true));
$isFirst = true;
$strategies = $this->getStrategyClasses();
foreach ($strategies as $strategyClass) {
/** @var CompletorStrategyBase $strategy */
$strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source);
if ($isFirst) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide();
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true));
$isFirst = false;
}
if ($strategy->apply()) {
$this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName());
if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription();
} else {
$this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription();
}
// Allow for partial solutions: a strategy may correct only some of
// the strategy lines and leave the rest up to other strategies.
if (!$this->invoiceHasStrategyLine()) {
break;
}
}
}
}
} | [
"protected",
"function",
"completeStrategyLines",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"invoiceHasStrategyLine",
"(",
")",
")",
"{",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyInput",
"]",
"[",
"'vat-rates'",
"]",
"=",
"str_replace",
"(",
"array",
"(",
"'=>'",
",",
"' '",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
")",
",",
"array",
"(",
"'='",
")",
",",
"var_export",
"(",
"$",
"this",
"->",
"possibleVatRates",
",",
"true",
")",
")",
";",
"$",
"isFirst",
"=",
"true",
";",
"$",
"strategies",
"=",
"$",
"this",
"->",
"getStrategyClasses",
"(",
")",
";",
"foreach",
"(",
"$",
"strategies",
"as",
"$",
"strategyClass",
")",
"{",
"/** @var CompletorStrategyBase $strategy */",
"$",
"strategy",
"=",
"new",
"$",
"strategyClass",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"this",
"->",
"translator",
",",
"$",
"this",
"->",
"invoice",
",",
"$",
"this",
"->",
"possibleVatTypes",
",",
"$",
"this",
"->",
"possibleVatRates",
",",
"$",
"this",
"->",
"source",
")",
";",
"if",
"(",
"$",
"isFirst",
")",
"{",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyInput",
"]",
"[",
"'vat-2-divide'",
"]",
"=",
"$",
"strategy",
"->",
"getVat2Divide",
"(",
")",
";",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyInput",
"]",
"[",
"'vat-breakdown'",
"]",
"=",
"str_replace",
"(",
"array",
"(",
"'=>'",
",",
"' '",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
")",
",",
"array",
"(",
"'='",
")",
",",
"var_export",
"(",
"$",
"strategy",
"->",
"getVatBreakdown",
"(",
")",
",",
"true",
")",
")",
";",
"$",
"isFirst",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"strategy",
"->",
"apply",
"(",
")",
")",
"{",
"$",
"this",
"->",
"replaceLinesCompleted",
"(",
"$",
"strategy",
"->",
"getLinesCompleted",
"(",
")",
",",
"$",
"strategy",
"->",
"getReplacingLines",
"(",
")",
",",
"$",
"strategy",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyUsed",
"]",
")",
")",
"{",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyUsed",
"]",
"=",
"$",
"strategy",
"->",
"getDescription",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Meta",
"::",
"CompletorStrategyUsed",
"]",
".=",
"'; '",
".",
"$",
"strategy",
"->",
"getDescription",
"(",
")",
";",
"}",
"// Allow for partial solutions: a strategy may correct only some of",
"// the strategy lines and leave the rest up to other strategies.",
"if",
"(",
"!",
"$",
"this",
"->",
"invoiceHasStrategyLine",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"}"
] | Complete all lines that need a vat divide strategy to compute correct
values. | [
"Complete",
"all",
"lines",
"that",
"need",
"a",
"vat",
"divide",
"strategy",
"to",
"compute",
"correct",
"values",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L89-L119 |
30,297 | SIELOnline/libAcumulus | src/Invoice/CompletorStrategyLines.php | CompletorStrategyLines.invoiceHasStrategyLine | public function invoiceHasStrategyLine()
{
$result = false;
foreach ($this->invoiceLines as $line) {
if ($line[Meta::VatRateSource] === Creator::VatRateSource_Strategy) {
$result = true;
break;
}
}
return $result;
} | php | public function invoiceHasStrategyLine()
{
$result = false;
foreach ($this->invoiceLines as $line) {
if ($line[Meta::VatRateSource] === Creator::VatRateSource_Strategy) {
$result = true;
break;
}
}
return $result;
} | [
"public",
"function",
"invoiceHasStrategyLine",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"invoiceLines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"===",
"Creator",
"::",
"VatRateSource_Strategy",
")",
"{",
"$",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns whether the invoice has lines that are to be completed using a tax
divide strategy.
@return bool | [
"Returns",
"whether",
"the",
"invoice",
"has",
"lines",
"that",
"are",
"to",
"be",
"completed",
"using",
"a",
"tax",
"divide",
"strategy",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L127-L137 |
30,298 | SIELOnline/libAcumulus | src/Invoice/CompletorStrategyLines.php | CompletorStrategyLines.getStrategyClasses | protected function getStrategyClasses()
{
$result = array();
// For now hardcoded, but this can be turned into a discovery.
$namespace = '\Siel\Acumulus\Invoice\CompletorStrategy';
$result[] = "$namespace\\ApplySameVatRate";
$result[] = "$namespace\\SplitKnownDiscountLine";
$result[] = "$namespace\\SplitLine";
$result[] = "$namespace\\SplitNonMatchingLine";
$result[] = "$namespace\\TryAllVatRatePermutations";
usort($result, function($class1, $class2) {
return $class1::$tryOrder - $class2::$tryOrder;
});
return $result;
} | php | protected function getStrategyClasses()
{
$result = array();
// For now hardcoded, but this can be turned into a discovery.
$namespace = '\Siel\Acumulus\Invoice\CompletorStrategy';
$result[] = "$namespace\\ApplySameVatRate";
$result[] = "$namespace\\SplitKnownDiscountLine";
$result[] = "$namespace\\SplitLine";
$result[] = "$namespace\\SplitNonMatchingLine";
$result[] = "$namespace\\TryAllVatRatePermutations";
usort($result, function($class1, $class2) {
return $class1::$tryOrder - $class2::$tryOrder;
});
return $result;
} | [
"protected",
"function",
"getStrategyClasses",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// For now hardcoded, but this can be turned into a discovery.",
"$",
"namespace",
"=",
"'\\Siel\\Acumulus\\Invoice\\CompletorStrategy'",
";",
"$",
"result",
"[",
"]",
"=",
"\"$namespace\\\\ApplySameVatRate\"",
";",
"$",
"result",
"[",
"]",
"=",
"\"$namespace\\\\SplitKnownDiscountLine\"",
";",
"$",
"result",
"[",
"]",
"=",
"\"$namespace\\\\SplitLine\"",
";",
"$",
"result",
"[",
"]",
"=",
"\"$namespace\\\\SplitNonMatchingLine\"",
";",
"$",
"result",
"[",
"]",
"=",
"\"$namespace\\\\TryAllVatRatePermutations\"",
";",
"usort",
"(",
"$",
"result",
",",
"function",
"(",
"$",
"class1",
",",
"$",
"class2",
")",
"{",
"return",
"$",
"class1",
"::",
"$",
"tryOrder",
"-",
"$",
"class2",
"::",
"$",
"tryOrder",
";",
"}",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns a list of strategy class names.
@return string[] | [
"Returns",
"a",
"list",
"of",
"strategy",
"class",
"names",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L144-L161 |
30,299 | SIELOnline/libAcumulus | src/Invoice/CompletorStrategyLines.php | CompletorStrategyLines.replaceLinesCompleted | protected function replaceLinesCompleted(array $linesCompleted, array $completedLines, $strategyName)
{
// Remove old strategy lines that are now completed.
$lines = array();
foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as $key => $line) {
if (!in_array($key, $linesCompleted)) {
$lines[] = $line;
}
}
// And merge in the new completed ones.
foreach ($completedLines as &$completedLine) {
if ($completedLine[Meta::VatRateSource] === Creator::VatRateSource_Strategy) {
$completedLine[Meta::VatRateSource] = Completor::VatRateSource_Strategy_Completed;
$completedLine[Meta::CompletorStrategyUsed] = $strategyName;
}
}
$this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = array_merge($lines, $completedLines);
} | php | protected function replaceLinesCompleted(array $linesCompleted, array $completedLines, $strategyName)
{
// Remove old strategy lines that are now completed.
$lines = array();
foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as $key => $line) {
if (!in_array($key, $linesCompleted)) {
$lines[] = $line;
}
}
// And merge in the new completed ones.
foreach ($completedLines as &$completedLine) {
if ($completedLine[Meta::VatRateSource] === Creator::VatRateSource_Strategy) {
$completedLine[Meta::VatRateSource] = Completor::VatRateSource_Strategy_Completed;
$completedLine[Meta::CompletorStrategyUsed] = $strategyName;
}
}
$this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = array_merge($lines, $completedLines);
} | [
"protected",
"function",
"replaceLinesCompleted",
"(",
"array",
"$",
"linesCompleted",
",",
"array",
"$",
"completedLines",
",",
"$",
"strategyName",
")",
"{",
"// Remove old strategy lines that are now completed.",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
"as",
"$",
"key",
"=>",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"linesCompleted",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"}",
"// And merge in the new completed ones.",
"foreach",
"(",
"$",
"completedLines",
"as",
"&",
"$",
"completedLine",
")",
"{",
"if",
"(",
"$",
"completedLine",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"===",
"Creator",
"::",
"VatRateSource_Strategy",
")",
"{",
"$",
"completedLine",
"[",
"Meta",
"::",
"VatRateSource",
"]",
"=",
"Completor",
"::",
"VatRateSource_Strategy_Completed",
";",
"$",
"completedLine",
"[",
"Meta",
"::",
"CompletorStrategyUsed",
"]",
"=",
"$",
"strategyName",
";",
"}",
"}",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"Invoice",
"]",
"[",
"Tag",
"::",
"Line",
"]",
"=",
"array_merge",
"(",
"$",
"lines",
",",
"$",
"completedLines",
")",
";",
"}"
] | Replaces all completed strategy lines with the given completed lines.
@param int[] $linesCompleted
@param array[] $completedLines
An array of completed invoice lines to replace the strategy lines with.
@param string $strategyName | [
"Replaces",
"all",
"completed",
"strategy",
"lines",
"with",
"the",
"given",
"completed",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L171-L189 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.