repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.setCustomerNo | public function setCustomerNo($pno, $custNo, $encoding = null)
{
//Get the PNO/SSN encoding constant.
if ($encoding === null) {
$encoding = $this->getPNOEncoding();
}
$this->_checkPNO($pno, $encoding);
$this->_checkArgument($custNo, 'custNo');
$digestSecret = self::digest(
$this->colon($this->_eid, $pno, $custNo, $this->_secret)
);
$paramList = array(
$pno,
$custNo,
$this->_eid,
$digestSecret,
$encoding
);
self::printDebug('set_customer_no', $paramList);
$result = $this->xmlrpc_call('set_customer_no', $paramList);
return ($result == 'ok');
} | php | public function setCustomerNo($pno, $custNo, $encoding = null)
{
//Get the PNO/SSN encoding constant.
if ($encoding === null) {
$encoding = $this->getPNOEncoding();
}
$this->_checkPNO($pno, $encoding);
$this->_checkArgument($custNo, 'custNo');
$digestSecret = self::digest(
$this->colon($this->_eid, $pno, $custNo, $this->_secret)
);
$paramList = array(
$pno,
$custNo,
$this->_eid,
$digestSecret,
$encoding
);
self::printDebug('set_customer_no', $paramList);
$result = $this->xmlrpc_call('set_customer_no', $paramList);
return ($result == 'ok');
} | [
"public",
"function",
"setCustomerNo",
"(",
"$",
"pno",
",",
"$",
"custNo",
",",
"$",
"encoding",
"=",
"null",
")",
"{",
"//Get the PNO/SSN encoding constant.",
"if",
"(",
"$",
"encoding",
"===",
"null",
")",
"{",
"$",
"encoding",
"=",
"$",
"this",
"->",
"getPNOEncoding",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_checkPNO",
"(",
"$",
"pno",
",",
"$",
"encoding",
")",
";",
"$",
"this",
"->",
"_checkArgument",
"(",
"$",
"custNo",
",",
"'custNo'",
")",
";",
"$",
"digestSecret",
"=",
"self",
"::",
"digest",
"(",
"$",
"this",
"->",
"colon",
"(",
"$",
"this",
"->",
"_eid",
",",
"$",
"pno",
",",
"$",
"custNo",
",",
"$",
"this",
"->",
"_secret",
")",
")",
";",
"$",
"paramList",
"=",
"array",
"(",
"$",
"pno",
",",
"$",
"custNo",
",",
"$",
"this",
"->",
"_eid",
",",
"$",
"digestSecret",
",",
"$",
"encoding",
")",
";",
"self",
"::",
"printDebug",
"(",
"'set_customer_no'",
",",
"$",
"paramList",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"xmlrpc_call",
"(",
"'set_customer_no'",
",",
"$",
"paramList",
")",
";",
"return",
"(",
"$",
"result",
"==",
"'ok'",
")",
";",
"}"
] | Associates a pno with a customer number when you want to make future
purchases without a pno.
@param string $pno Social security number, Personal number, ...
@param string $custNo The customer number.
@param int $encoding {@link KlarnaEncoding PNO Encoding} constant.
@throws KlarnaException
@return bool True, if the customer number was associated with the pno. | [
"Associates",
"a",
"pno",
"with",
"a",
"customer",
"number",
"when",
"you",
"want",
"to",
"make",
"future",
"purchases",
"without",
"a",
"pno",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3157-L3183 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.removeCustomerNo | public function removeCustomerNo($custNo)
{
$this->_checkArgument($custNo, 'custNo');
$digestSecret = self::digest(
$this->colon($this->_eid, $custNo, $this->_secret)
);
$paramList = array(
$custNo,
$this->_eid,
$digestSecret
);
self::printDebug('remove_customer_no', $paramList);
$result = $this->xmlrpc_call('remove_customer_no', $paramList);
return ($result == 'ok');
} | php | public function removeCustomerNo($custNo)
{
$this->_checkArgument($custNo, 'custNo');
$digestSecret = self::digest(
$this->colon($this->_eid, $custNo, $this->_secret)
);
$paramList = array(
$custNo,
$this->_eid,
$digestSecret
);
self::printDebug('remove_customer_no', $paramList);
$result = $this->xmlrpc_call('remove_customer_no', $paramList);
return ($result == 'ok');
} | [
"public",
"function",
"removeCustomerNo",
"(",
"$",
"custNo",
")",
"{",
"$",
"this",
"->",
"_checkArgument",
"(",
"$",
"custNo",
",",
"'custNo'",
")",
";",
"$",
"digestSecret",
"=",
"self",
"::",
"digest",
"(",
"$",
"this",
"->",
"colon",
"(",
"$",
"this",
"->",
"_eid",
",",
"$",
"custNo",
",",
"$",
"this",
"->",
"_secret",
")",
")",
";",
"$",
"paramList",
"=",
"array",
"(",
"$",
"custNo",
",",
"$",
"this",
"->",
"_eid",
",",
"$",
"digestSecret",
")",
";",
"self",
"::",
"printDebug",
"(",
"'remove_customer_no'",
",",
"$",
"paramList",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"xmlrpc_call",
"(",
"'remove_customer_no'",
",",
"$",
"paramList",
")",
";",
"return",
"(",
"$",
"result",
"==",
"'ok'",
")",
";",
"}"
] | Removes a customer number from association with a pno.
@param string $custNo The customer number.
@throws KlarnaException
@return bool True, if the customer number association was removed. | [
"Removes",
"a",
"customer",
"number",
"from",
"association",
"with",
"a",
"pno",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3193-L3212 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.getPCStorage | public function getPCStorage()
{
if (isset($this->pclasses)) {
return $this->pclasses;
}
include_once 'pclasses/storage.intf.php';
$className = $this->pcStorage.'storage';
$pclassStorage = dirname(__FILE__) . "/pclasses/{$className}.class.php";
include_once $pclassStorage;
$storage = new $className;
if (!($storage instanceof PCStorage)) {
throw new Klarna_PCStorageInvalidException(
$className, $pclassStorage
);
}
return $storage;
} | php | public function getPCStorage()
{
if (isset($this->pclasses)) {
return $this->pclasses;
}
include_once 'pclasses/storage.intf.php';
$className = $this->pcStorage.'storage';
$pclassStorage = dirname(__FILE__) . "/pclasses/{$className}.class.php";
include_once $pclassStorage;
$storage = new $className;
if (!($storage instanceof PCStorage)) {
throw new Klarna_PCStorageInvalidException(
$className, $pclassStorage
);
}
return $storage;
} | [
"public",
"function",
"getPCStorage",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pclasses",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pclasses",
";",
"}",
"include_once",
"'pclasses/storage.intf.php'",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"pcStorage",
".",
"'storage'",
";",
"$",
"pclassStorage",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"\"/pclasses/{$className}.class.php\"",
";",
"include_once",
"$",
"pclassStorage",
";",
"$",
"storage",
"=",
"new",
"$",
"className",
";",
"if",
"(",
"!",
"(",
"$",
"storage",
"instanceof",
"PCStorage",
")",
")",
"{",
"throw",
"new",
"Klarna_PCStorageInvalidException",
"(",
"$",
"className",
",",
"$",
"pclassStorage",
")",
";",
"}",
"return",
"$",
"storage",
";",
"}"
] | Returns the configured PCStorage object.
@throws Exception|KlarnaException
@return PCStorage | [
"Returns",
"the",
"configured",
"PCStorage",
"object",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3220-L3239 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._fetchPClasses | private function _fetchPClasses($storage, $country, $language, $currency)
{
$digestSecret = self::digest(
$this->_eid . ":" . $currency . ":" . $this->_secret
);
$paramList = array(
$this->_eid,
$currency,
$digestSecret,
$country,
$language
);
self::printDebug('get_pclasses array', $paramList);
$result = $this->xmlrpc_call('get_pclasses', $paramList);
self::printDebug('get_pclasses result', $result);
foreach ($result as &$pclass) {
//numeric htmlentities
$pclass[1] = Klarna::num_htmlentities($pclass[1]);
//Below values are in "cents", fix them.
$pclass[3] /= 100; //divide start fee with 100
$pclass[4] /= 100; //divide invoice fee with 100
$pclass[5] /= 100; //divide interest rate with 100
$pclass[6] /= 100; //divide min amount with 100
if ($pclass[9] != '-') {
//unix timestamp instead of yyyy-mm-dd
$pclass[9] = strtotime($pclass[9]);
}
//Associate the PClass with this estore.
array_unshift($pclass, $this->_eid);
$storage->addPClass(new KlarnaPClass($pclass));
}
} | php | private function _fetchPClasses($storage, $country, $language, $currency)
{
$digestSecret = self::digest(
$this->_eid . ":" . $currency . ":" . $this->_secret
);
$paramList = array(
$this->_eid,
$currency,
$digestSecret,
$country,
$language
);
self::printDebug('get_pclasses array', $paramList);
$result = $this->xmlrpc_call('get_pclasses', $paramList);
self::printDebug('get_pclasses result', $result);
foreach ($result as &$pclass) {
//numeric htmlentities
$pclass[1] = Klarna::num_htmlentities($pclass[1]);
//Below values are in "cents", fix them.
$pclass[3] /= 100; //divide start fee with 100
$pclass[4] /= 100; //divide invoice fee with 100
$pclass[5] /= 100; //divide interest rate with 100
$pclass[6] /= 100; //divide min amount with 100
if ($pclass[9] != '-') {
//unix timestamp instead of yyyy-mm-dd
$pclass[9] = strtotime($pclass[9]);
}
//Associate the PClass with this estore.
array_unshift($pclass, $this->_eid);
$storage->addPClass(new KlarnaPClass($pclass));
}
} | [
"private",
"function",
"_fetchPClasses",
"(",
"$",
"storage",
",",
"$",
"country",
",",
"$",
"language",
",",
"$",
"currency",
")",
"{",
"$",
"digestSecret",
"=",
"self",
"::",
"digest",
"(",
"$",
"this",
"->",
"_eid",
".",
"\":\"",
".",
"$",
"currency",
".",
"\":\"",
".",
"$",
"this",
"->",
"_secret",
")",
";",
"$",
"paramList",
"=",
"array",
"(",
"$",
"this",
"->",
"_eid",
",",
"$",
"currency",
",",
"$",
"digestSecret",
",",
"$",
"country",
",",
"$",
"language",
")",
";",
"self",
"::",
"printDebug",
"(",
"'get_pclasses array'",
",",
"$",
"paramList",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"xmlrpc_call",
"(",
"'get_pclasses'",
",",
"$",
"paramList",
")",
";",
"self",
"::",
"printDebug",
"(",
"'get_pclasses result'",
",",
"$",
"result",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"&",
"$",
"pclass",
")",
"{",
"//numeric htmlentities",
"$",
"pclass",
"[",
"1",
"]",
"=",
"Klarna",
"::",
"num_htmlentities",
"(",
"$",
"pclass",
"[",
"1",
"]",
")",
";",
"//Below values are in \"cents\", fix them.",
"$",
"pclass",
"[",
"3",
"]",
"/=",
"100",
";",
"//divide start fee with 100",
"$",
"pclass",
"[",
"4",
"]",
"/=",
"100",
";",
"//divide invoice fee with 100",
"$",
"pclass",
"[",
"5",
"]",
"/=",
"100",
";",
"//divide interest rate with 100",
"$",
"pclass",
"[",
"6",
"]",
"/=",
"100",
";",
"//divide min amount with 100",
"if",
"(",
"$",
"pclass",
"[",
"9",
"]",
"!=",
"'-'",
")",
"{",
"//unix timestamp instead of yyyy-mm-dd",
"$",
"pclass",
"[",
"9",
"]",
"=",
"strtotime",
"(",
"$",
"pclass",
"[",
"9",
"]",
")",
";",
"}",
"//Associate the PClass with this estore.",
"array_unshift",
"(",
"$",
"pclass",
",",
"$",
"this",
"->",
"_eid",
")",
";",
"$",
"storage",
"->",
"addPClass",
"(",
"new",
"KlarnaPClass",
"(",
"$",
"pclass",
")",
")",
";",
"}",
"}"
] | Fetch pclasses
@param PCStorage $storage PClass Storage
@param int $country KlarnaCountry constant
@param int $language KlarnaLanguage constant
@param int $currency KlarnaCurrency constant
@return void | [
"Fetch",
"pclasses"
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3251-L3290 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.fetchPClasses | public function fetchPClasses(
$country = null, $language = null, $currency = null
) {
extract(
$this->getLocale($country, $language, $currency),
EXTR_OVERWRITE
);
$this->_checkConfig();
$pclasses = $this->getPCStorage();
try {
//Attempt to load previously stored pclasses, so they aren't
// accidentially removed.
$pclasses->load($this->pcURI);
}
catch(Exception $e) {
self::printDebug('load pclasses', $e->getMessage());
}
$this->_fetchPClasses($pclasses, $country, $language, $currency);
$pclasses->save($this->pcURI);
$this->pclasses = $pclasses;
} | php | public function fetchPClasses(
$country = null, $language = null, $currency = null
) {
extract(
$this->getLocale($country, $language, $currency),
EXTR_OVERWRITE
);
$this->_checkConfig();
$pclasses = $this->getPCStorage();
try {
//Attempt to load previously stored pclasses, so they aren't
// accidentially removed.
$pclasses->load($this->pcURI);
}
catch(Exception $e) {
self::printDebug('load pclasses', $e->getMessage());
}
$this->_fetchPClasses($pclasses, $country, $language, $currency);
$pclasses->save($this->pcURI);
$this->pclasses = $pclasses;
} | [
"public",
"function",
"fetchPClasses",
"(",
"$",
"country",
"=",
"null",
",",
"$",
"language",
"=",
"null",
",",
"$",
"currency",
"=",
"null",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"getLocale",
"(",
"$",
"country",
",",
"$",
"language",
",",
"$",
"currency",
")",
",",
"EXTR_OVERWRITE",
")",
";",
"$",
"this",
"->",
"_checkConfig",
"(",
")",
";",
"$",
"pclasses",
"=",
"$",
"this",
"->",
"getPCStorage",
"(",
")",
";",
"try",
"{",
"//Attempt to load previously stored pclasses, so they aren't",
"// accidentially removed.",
"$",
"pclasses",
"->",
"load",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"self",
"::",
"printDebug",
"(",
"'load pclasses'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"_fetchPClasses",
"(",
"$",
"pclasses",
",",
"$",
"country",
",",
"$",
"language",
",",
"$",
"currency",
")",
";",
"$",
"pclasses",
"->",
"save",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"$",
"this",
"->",
"pclasses",
"=",
"$",
"pclasses",
";",
"}"
] | Fetches the PClasses from Klarna Online.<br>
Removes the cached/stored pclasses and updates.<br>
You are only allowed to call this once, or once per update of PClasses
in KO.<br>
<b>Note</b>:<br>
If language and/or currency is null, then they will be set to mirror
the specified country.<br/>
Short codes like DE, SV or EUR can also be used instead of the constants.
@param string|int $country {@link KlarnaCountry Country} constant,
or two letter code.
@param mixed $language {@link KlarnaLanguage Language} constant,
or two letter code.
@param mixed $currency {@link KlarnaCurrency Currency} constant,
or three letter code.
@throws KlarnaException
@return void | [
"Fetches",
"the",
"PClasses",
"from",
"Klarna",
"Online",
".",
"<br",
">",
"Removes",
"the",
"cached",
"/",
"stored",
"pclasses",
"and",
"updates",
".",
"<br",
">",
"You",
"are",
"only",
"allowed",
"to",
"call",
"this",
"once",
"or",
"once",
"per",
"update",
"of",
"PClasses",
"in",
"KO",
".",
"<br",
">"
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3313-L3337 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.clearPClasses | public function clearPClasses()
{
$this->_checkConfig();
$pclasses = $this->getPCStorage();
$pclasses->clear($this->pcURI);
} | php | public function clearPClasses()
{
$this->_checkConfig();
$pclasses = $this->getPCStorage();
$pclasses->clear($this->pcURI);
} | [
"public",
"function",
"clearPClasses",
"(",
")",
"{",
"$",
"this",
"->",
"_checkConfig",
"(",
")",
";",
"$",
"pclasses",
"=",
"$",
"this",
"->",
"getPCStorage",
"(",
")",
";",
"$",
"pclasses",
"->",
"clear",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"}"
] | Removes the stored PClasses, if you need to update them.
@throws KlarnaException
@return void | [
"Removes",
"the",
"stored",
"PClasses",
"if",
"you",
"need",
"to",
"update",
"them",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3345-L3351 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.getPClasses | public function getPClasses($type = null)
{
$this->_checkConfig();
if (!$this->pclasses) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
$tmp = $this->pclasses->getPClasses(
$this->_eid, $this->_country, $type
);
$this->sortPClasses($tmp[$this->_eid]);
return $tmp[$this->_eid];
} | php | public function getPClasses($type = null)
{
$this->_checkConfig();
if (!$this->pclasses) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
$tmp = $this->pclasses->getPClasses(
$this->_eid, $this->_country, $type
);
$this->sortPClasses($tmp[$this->_eid]);
return $tmp[$this->_eid];
} | [
"public",
"function",
"getPClasses",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_checkConfig",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"pclasses",
")",
"{",
"$",
"this",
"->",
"pclasses",
"=",
"$",
"this",
"->",
"getPCStorage",
"(",
")",
";",
"$",
"this",
"->",
"pclasses",
"->",
"load",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"}",
"$",
"tmp",
"=",
"$",
"this",
"->",
"pclasses",
"->",
"getPClasses",
"(",
"$",
"this",
"->",
"_eid",
",",
"$",
"this",
"->",
"_country",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"sortPClasses",
"(",
"$",
"tmp",
"[",
"$",
"this",
"->",
"_eid",
"]",
")",
";",
"return",
"$",
"tmp",
"[",
"$",
"this",
"->",
"_eid",
"]",
";",
"}"
] | Retrieves the specified PClasses.
<b>Type can be</b>:<br>
{@link KlarnaPClass::CAMPAIGN}<br>
{@link KlarnaPClass::ACCOUNT}<br>
{@link KlarnaPClass::SPECIAL}<br>
{@link KlarnaPClass::FIXED}<br>
{@link KlarnaPClass::DELAY}<br>
{@link KlarnaPClass::MOBILE}<br>
@param int $type PClass type identifier.
@throws KlarnaException
@return array An array of PClasses. [KlarnaPClass] | [
"Retrieves",
"the",
"specified",
"PClasses",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3369-L3382 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.getAllPClasses | public function getAllPClasses()
{
if (!$this->pclasses) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
return $this->pclasses->getAllPClasses();
} | php | public function getAllPClasses()
{
if (!$this->pclasses) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
return $this->pclasses->getAllPClasses();
} | [
"public",
"function",
"getAllPClasses",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pclasses",
")",
"{",
"$",
"this",
"->",
"pclasses",
"=",
"$",
"this",
"->",
"getPCStorage",
"(",
")",
";",
"$",
"this",
"->",
"pclasses",
"->",
"load",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pclasses",
"->",
"getAllPClasses",
"(",
")",
";",
"}"
] | Retrieve a flattened array of all pclasses stored in the configured
pclass storage.
@return array | [
"Retrieve",
"a",
"flattened",
"array",
"of",
"all",
"pclasses",
"stored",
"in",
"the",
"configured",
"pclass",
"storage",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3390-L3397 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.getPClass | public function getPClass($id)
{
if (!is_numeric($id)) {
throw new Klarna_InvalidTypeException('id', 'integer');
}
$this->_checkConfig();
if (!$this->pclasses || !($this->pclasses instanceof PCStorage)) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
return $this->pclasses->getPClass(
intval($id), $this->_eid, $this->_country
);
} | php | public function getPClass($id)
{
if (!is_numeric($id)) {
throw new Klarna_InvalidTypeException('id', 'integer');
}
$this->_checkConfig();
if (!$this->pclasses || !($this->pclasses instanceof PCStorage)) {
$this->pclasses = $this->getPCStorage();
$this->pclasses->load($this->pcURI);
}
return $this->pclasses->getPClass(
intval($id), $this->_eid, $this->_country
);
} | [
"public",
"function",
"getPClass",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"'id'",
",",
"'integer'",
")",
";",
"}",
"$",
"this",
"->",
"_checkConfig",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"pclasses",
"||",
"!",
"(",
"$",
"this",
"->",
"pclasses",
"instanceof",
"PCStorage",
")",
")",
"{",
"$",
"this",
"->",
"pclasses",
"=",
"$",
"this",
"->",
"getPCStorage",
"(",
")",
";",
"$",
"this",
"->",
"pclasses",
"->",
"load",
"(",
"$",
"this",
"->",
"pcURI",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pclasses",
"->",
"getPClass",
"(",
"intval",
"(",
"$",
"id",
")",
",",
"$",
"this",
"->",
"_eid",
",",
"$",
"this",
"->",
"_country",
")",
";",
"}"
] | Returns the specified PClass.
@param int $id The PClass ID.
@return KlarnaPClass | [
"Returns",
"the",
"specified",
"PClass",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3406-L3421 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.sortPClasses | public function sortPClasses(&$array)
{
if (!is_array($array)) {
//Input is not an array!
$array = array();
return;
}
//Sort pclasses array after natural sort (natcmp)
if (!function_exists('pcCmp')) {
/**
* Comparison function
*
* @param KlarnaPClass $a object 1
* @param KlarnaPClass $b object 2
*
* @return int
*/
function pcCmp($a, $b)
{
if ($a->getDescription() == null
&& $b->getDescription() == null
) {
return 0;
} else if ($a->getDescription() == null) {
return 1;
} else if ($b->getDescription() == null) {
return -1;
} else if ($b->getType() === 2 && $a->getType() !== 2) {
return 1;
} else if ($b->getType() !== 2 && $a->getType() === 2) {
return -1;
}
return strnatcmp($a->getDescription(), $b->getDescription())*-1;
}
}
usort($array, "pcCmp");
} | php | public function sortPClasses(&$array)
{
if (!is_array($array)) {
//Input is not an array!
$array = array();
return;
}
//Sort pclasses array after natural sort (natcmp)
if (!function_exists('pcCmp')) {
/**
* Comparison function
*
* @param KlarnaPClass $a object 1
* @param KlarnaPClass $b object 2
*
* @return int
*/
function pcCmp($a, $b)
{
if ($a->getDescription() == null
&& $b->getDescription() == null
) {
return 0;
} else if ($a->getDescription() == null) {
return 1;
} else if ($b->getDescription() == null) {
return -1;
} else if ($b->getType() === 2 && $a->getType() !== 2) {
return 1;
} else if ($b->getType() !== 2 && $a->getType() === 2) {
return -1;
}
return strnatcmp($a->getDescription(), $b->getDescription())*-1;
}
}
usort($array, "pcCmp");
} | [
"public",
"function",
"sortPClasses",
"(",
"&",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"//Input is not an array!",
"$",
"array",
"=",
"array",
"(",
")",
";",
"return",
";",
"}",
"//Sort pclasses array after natural sort (natcmp)",
"if",
"(",
"!",
"function_exists",
"(",
"'pcCmp'",
")",
")",
"{",
"/**\n * Comparison function\n *\n * @param KlarnaPClass $a object 1\n * @param KlarnaPClass $b object 2\n *\n * @return int\n */",
"function",
"pcCmp",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getDescription",
"(",
")",
"==",
"null",
"&&",
"$",
"b",
"->",
"getDescription",
"(",
")",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"$",
"a",
"->",
"getDescription",
"(",
")",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"$",
"b",
"->",
"getDescription",
"(",
")",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"$",
"b",
"->",
"getType",
"(",
")",
"===",
"2",
"&&",
"$",
"a",
"->",
"getType",
"(",
")",
"!==",
"2",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"$",
"b",
"->",
"getType",
"(",
")",
"!==",
"2",
"&&",
"$",
"a",
"->",
"getType",
"(",
")",
"===",
"2",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"strnatcmp",
"(",
"$",
"a",
"->",
"getDescription",
"(",
")",
",",
"$",
"b",
"->",
"getDescription",
"(",
")",
")",
"*",
"-",
"1",
";",
"}",
"}",
"usort",
"(",
"$",
"array",
",",
"\"pcCmp\"",
")",
";",
"}"
] | Sorts the specified array of KlarnaPClasses.
@param array &$array An array of {@link KlarnaPClass PClasses}.
@return void | [
"Sorts",
"the",
"specified",
"array",
"of",
"KlarnaPClasses",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3430-L3467 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.getCheapestPClass | public function getCheapestPClass($sum, $flags)
{
if (!is_numeric($sum)) {
throw new Klarna_InvalidPriceException($sum);
}
if (!is_numeric($flags)
|| !in_array(
$flags, array(
KlarnaFlags::CHECKOUT_PAGE, KlarnaFlags::PRODUCT_PAGE)
)
) {
throw new Klarna_InvalidTypeException(
'flags',
KlarnaFlags::CHECKOUT_PAGE . ' or ' . KlarnaFlags::PRODUCT_PAGE
);
}
$lowest_pp = $lowest = false;
foreach ($this->getPClasses() as $pclass) {
$lowest_payment = KlarnaCalc::get_lowest_payment_for_account(
$pclass->getCountry()
);
if ($pclass->getType() < 2 && $sum >= $pclass->getMinAmount()) {
$minpay = KlarnaCalc::calc_monthly_cost(
$sum, $pclass, $flags
);
if ($minpay < $lowest_pp || $lowest_pp === false) {
if ($pclass->getType() == KlarnaPClass::ACCOUNT
|| $minpay >= $lowest_payment
) {
$lowest_pp = $minpay;
$lowest = $pclass;
}
}
}
}
return $lowest;
} | php | public function getCheapestPClass($sum, $flags)
{
if (!is_numeric($sum)) {
throw new Klarna_InvalidPriceException($sum);
}
if (!is_numeric($flags)
|| !in_array(
$flags, array(
KlarnaFlags::CHECKOUT_PAGE, KlarnaFlags::PRODUCT_PAGE)
)
) {
throw new Klarna_InvalidTypeException(
'flags',
KlarnaFlags::CHECKOUT_PAGE . ' or ' . KlarnaFlags::PRODUCT_PAGE
);
}
$lowest_pp = $lowest = false;
foreach ($this->getPClasses() as $pclass) {
$lowest_payment = KlarnaCalc::get_lowest_payment_for_account(
$pclass->getCountry()
);
if ($pclass->getType() < 2 && $sum >= $pclass->getMinAmount()) {
$minpay = KlarnaCalc::calc_monthly_cost(
$sum, $pclass, $flags
);
if ($minpay < $lowest_pp || $lowest_pp === false) {
if ($pclass->getType() == KlarnaPClass::ACCOUNT
|| $minpay >= $lowest_payment
) {
$lowest_pp = $minpay;
$lowest = $pclass;
}
}
}
}
return $lowest;
} | [
"public",
"function",
"getCheapestPClass",
"(",
"$",
"sum",
",",
"$",
"flags",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"sum",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidPriceException",
"(",
"$",
"sum",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"flags",
")",
"||",
"!",
"in_array",
"(",
"$",
"flags",
",",
"array",
"(",
"KlarnaFlags",
"::",
"CHECKOUT_PAGE",
",",
"KlarnaFlags",
"::",
"PRODUCT_PAGE",
")",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"'flags'",
",",
"KlarnaFlags",
"::",
"CHECKOUT_PAGE",
".",
"' or '",
".",
"KlarnaFlags",
"::",
"PRODUCT_PAGE",
")",
";",
"}",
"$",
"lowest_pp",
"=",
"$",
"lowest",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPClasses",
"(",
")",
"as",
"$",
"pclass",
")",
"{",
"$",
"lowest_payment",
"=",
"KlarnaCalc",
"::",
"get_lowest_payment_for_account",
"(",
"$",
"pclass",
"->",
"getCountry",
"(",
")",
")",
";",
"if",
"(",
"$",
"pclass",
"->",
"getType",
"(",
")",
"<",
"2",
"&&",
"$",
"sum",
">=",
"$",
"pclass",
"->",
"getMinAmount",
"(",
")",
")",
"{",
"$",
"minpay",
"=",
"KlarnaCalc",
"::",
"calc_monthly_cost",
"(",
"$",
"sum",
",",
"$",
"pclass",
",",
"$",
"flags",
")",
";",
"if",
"(",
"$",
"minpay",
"<",
"$",
"lowest_pp",
"||",
"$",
"lowest_pp",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"pclass",
"->",
"getType",
"(",
")",
"==",
"KlarnaPClass",
"::",
"ACCOUNT",
"||",
"$",
"minpay",
">=",
"$",
"lowest_payment",
")",
"{",
"$",
"lowest_pp",
"=",
"$",
"minpay",
";",
"$",
"lowest",
"=",
"$",
"pclass",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"lowest",
";",
"}"
] | Returns the cheapest, per month, PClass related to the specified sum.
<b>Note</b>: This choose the cheapest PClass for the current country.<br>
{@link Klarna::setCountry()}
<b>Flags can be</b>:<br>
{@link KlarnaFlags::CHECKOUT_PAGE}<br>
{@link KlarnaFlags::PRODUCT_PAGE}<br>
@param float $sum The product cost, or total sum of the cart.
@param int $flags Which type of page the info will be displayed on.
@throws KlarnaException
@return KlarnaPClass or false if none was found. | [
"Returns",
"the",
"cheapest",
"per",
"month",
"PClass",
"related",
"to",
"the",
"specified",
"sum",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3485-L3526 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.initCheckout | protected function initCheckout()
{
$dir = dirname(__FILE__);
//Require the CheckoutHTML interface/abstract class
include_once $dir.'/checkout/checkouthtml.intf.php';
//Iterate over all .class.php files in checkout/
foreach (glob($dir.'/checkout/*.class.php') as $checkout) {
if (!self::$debug) {
ob_start();
}
include_once $checkout;
$className = basename($checkout, '.class.php');
$cObj = new $className;
if ($cObj instanceof CheckoutHTML) {
$cObj->init($this, $this->_eid);
$this->coObjects[$className] = $cObj;
}
if (!self::$debug) {
ob_end_clean();
}
}
} | php | protected function initCheckout()
{
$dir = dirname(__FILE__);
//Require the CheckoutHTML interface/abstract class
include_once $dir.'/checkout/checkouthtml.intf.php';
//Iterate over all .class.php files in checkout/
foreach (glob($dir.'/checkout/*.class.php') as $checkout) {
if (!self::$debug) {
ob_start();
}
include_once $checkout;
$className = basename($checkout, '.class.php');
$cObj = new $className;
if ($cObj instanceof CheckoutHTML) {
$cObj->init($this, $this->_eid);
$this->coObjects[$className] = $cObj;
}
if (!self::$debug) {
ob_end_clean();
}
}
} | [
"protected",
"function",
"initCheckout",
"(",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"__FILE__",
")",
";",
"//Require the CheckoutHTML interface/abstract class",
"include_once",
"$",
"dir",
".",
"'/checkout/checkouthtml.intf.php'",
";",
"//Iterate over all .class.php files in checkout/",
"foreach",
"(",
"glob",
"(",
"$",
"dir",
".",
"'/checkout/*.class.php'",
")",
"as",
"$",
"checkout",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"debug",
")",
"{",
"ob_start",
"(",
")",
";",
"}",
"include_once",
"$",
"checkout",
";",
"$",
"className",
"=",
"basename",
"(",
"$",
"checkout",
",",
"'.class.php'",
")",
";",
"$",
"cObj",
"=",
"new",
"$",
"className",
";",
"if",
"(",
"$",
"cObj",
"instanceof",
"CheckoutHTML",
")",
"{",
"$",
"cObj",
"->",
"init",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_eid",
")",
";",
"$",
"this",
"->",
"coObjects",
"[",
"$",
"className",
"]",
"=",
"$",
"cObj",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"debug",
")",
"{",
"ob_end_clean",
"(",
")",
";",
"}",
"}",
"}"
] | Initializes the checkoutHTML objects.
@see Klarna::checkoutHTML()
@return void | [
"Initializes",
"the",
"checkoutHTML",
"objects",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3534-L3560 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.checkoutHTML | public function checkoutHTML()
{
if (empty($this->coObjects)) {
$this->initCheckout();
}
$dir = dirname(__FILE__);
//Require the CheckoutHTML interface/abstract class
include_once $dir.'/checkout/checkouthtml.intf.php';
//Iterate over all .class.php files in
$html = "\n";
foreach ($this->coObjects as $cObj) {
if (!self::$debug) {
ob_start();
}
if ($cObj instanceof CheckoutHTML) {
$html .= $cObj->toHTML() . "\n";
}
if (!self::$debug) {
ob_end_clean();
}
}
return $html;
} | php | public function checkoutHTML()
{
if (empty($this->coObjects)) {
$this->initCheckout();
}
$dir = dirname(__FILE__);
//Require the CheckoutHTML interface/abstract class
include_once $dir.'/checkout/checkouthtml.intf.php';
//Iterate over all .class.php files in
$html = "\n";
foreach ($this->coObjects as $cObj) {
if (!self::$debug) {
ob_start();
}
if ($cObj instanceof CheckoutHTML) {
$html .= $cObj->toHTML() . "\n";
}
if (!self::$debug) {
ob_end_clean();
}
}
return $html;
} | [
"public",
"function",
"checkoutHTML",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"coObjects",
")",
")",
"{",
"$",
"this",
"->",
"initCheckout",
"(",
")",
";",
"}",
"$",
"dir",
"=",
"dirname",
"(",
"__FILE__",
")",
";",
"//Require the CheckoutHTML interface/abstract class",
"include_once",
"$",
"dir",
".",
"'/checkout/checkouthtml.intf.php'",
";",
"//Iterate over all .class.php files in",
"$",
"html",
"=",
"\"\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"coObjects",
"as",
"$",
"cObj",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"debug",
")",
"{",
"ob_start",
"(",
")",
";",
"}",
"if",
"(",
"$",
"cObj",
"instanceof",
"CheckoutHTML",
")",
"{",
"$",
"html",
".=",
"$",
"cObj",
"->",
"toHTML",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"debug",
")",
"{",
"ob_end_clean",
"(",
")",
";",
"}",
"}",
"return",
"$",
"html",
";",
"}"
] | Returns the checkout page HTML from the checkout classes.
<b>Note</b>:<br>
This method uses output buffering to silence unwanted echoes.<br>
@see CheckoutHTML
@return string A HTML string. | [
"Returns",
"the",
"checkout",
"page",
"HTML",
"from",
"the",
"checkout",
"classes",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3572-L3597 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.xmlrpc_call | protected function xmlrpc_call($method, $array)
{
$this->_checkConfig();
if (!isset($method) || !is_string($method)) {
throw new Klarna_InvalidTypeException('method', 'string');
}
if ($array === null || count($array) === 0) {
throw new KlarnaException("Parameterlist is empty or null!", 50067);
}
if (self::$disableXMLRPC) {
return true;
}
try {
/*
* Disable verifypeer for CURL, so below error is avoided.
* CURL error: SSL certificate problem, verify that the CA
* cert is OK.
* Details: error:14090086:SSL
* routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
*/
$this->xmlrpc->verifypeer = false;
$timestart = microtime(true);
//Create the XMLRPC message.
$msg = new xmlrpcmsg($method);
$params = array_merge(
array(
$this->PROTO, $this->VERSION
), $array
);
$msg = new xmlrpcmsg($method);
foreach ($params as $p) {
if (!$msg->addParam(
php_xmlrpc_encode($p, array('extension_api'))
)
) {
throw new KlarnaException(
"Failed to add parameters to XMLRPC message.",
50068
);
}
}
$selectDateTime = microtime(true);
if (self::$xmlrpcDebug) {
$this->xmlrpc->setDebug(2);
}
//Save previous XML RPC client encoding settings.
$tmp_xmlrpc_defencoding = $GLOBALS['xmlrpc_defencoding'];
$tmp_xmlrpc_internalencoding = $GLOBALS['xmlrpc_internalencoding'];
//Set XML RPC client encoding settings.
$GLOBALS['xmlrpc_defencoding'] = 'ISO-8859-1';
$GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
//Send the message.
$xmlrpcresp = $this->xmlrpc->send($msg);
//Restore previous XML RPC client encoding settings.
$GLOBALS['xmlrpc_defencoding'] = $tmp_xmlrpc_defencoding;
$GLOBALS['xmlrpc_internalencoding'] = $tmp_xmlrpc_internalencoding;
//Calculate time and selectTime.
$timeend = microtime(true);
$time = (int) (($selectDateTime - $timestart) * 1000);
$selectTime = (int) (($timeend - $timestart) * 1000);
$status = $xmlrpcresp->faultCode();
if ($status !== 0) {
throw new KlarnaException($xmlrpcresp->faultString(), $status);
}
return php_xmlrpc_decode($xmlrpcresp->value());
}
catch(KlarnaException $e) {
//Otherwise it is caught below, and rethrown.
throw $e;
}
catch(Exception $e) {
throw new KlarnaException($e->getMessage(), $e->getCode());
}
} | php | protected function xmlrpc_call($method, $array)
{
$this->_checkConfig();
if (!isset($method) || !is_string($method)) {
throw new Klarna_InvalidTypeException('method', 'string');
}
if ($array === null || count($array) === 0) {
throw new KlarnaException("Parameterlist is empty or null!", 50067);
}
if (self::$disableXMLRPC) {
return true;
}
try {
/*
* Disable verifypeer for CURL, so below error is avoided.
* CURL error: SSL certificate problem, verify that the CA
* cert is OK.
* Details: error:14090086:SSL
* routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
*/
$this->xmlrpc->verifypeer = false;
$timestart = microtime(true);
//Create the XMLRPC message.
$msg = new xmlrpcmsg($method);
$params = array_merge(
array(
$this->PROTO, $this->VERSION
), $array
);
$msg = new xmlrpcmsg($method);
foreach ($params as $p) {
if (!$msg->addParam(
php_xmlrpc_encode($p, array('extension_api'))
)
) {
throw new KlarnaException(
"Failed to add parameters to XMLRPC message.",
50068
);
}
}
$selectDateTime = microtime(true);
if (self::$xmlrpcDebug) {
$this->xmlrpc->setDebug(2);
}
//Save previous XML RPC client encoding settings.
$tmp_xmlrpc_defencoding = $GLOBALS['xmlrpc_defencoding'];
$tmp_xmlrpc_internalencoding = $GLOBALS['xmlrpc_internalencoding'];
//Set XML RPC client encoding settings.
$GLOBALS['xmlrpc_defencoding'] = 'ISO-8859-1';
$GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
//Send the message.
$xmlrpcresp = $this->xmlrpc->send($msg);
//Restore previous XML RPC client encoding settings.
$GLOBALS['xmlrpc_defencoding'] = $tmp_xmlrpc_defencoding;
$GLOBALS['xmlrpc_internalencoding'] = $tmp_xmlrpc_internalencoding;
//Calculate time and selectTime.
$timeend = microtime(true);
$time = (int) (($selectDateTime - $timestart) * 1000);
$selectTime = (int) (($timeend - $timestart) * 1000);
$status = $xmlrpcresp->faultCode();
if ($status !== 0) {
throw new KlarnaException($xmlrpcresp->faultString(), $status);
}
return php_xmlrpc_decode($xmlrpcresp->value());
}
catch(KlarnaException $e) {
//Otherwise it is caught below, and rethrown.
throw $e;
}
catch(Exception $e) {
throw new KlarnaException($e->getMessage(), $e->getCode());
}
} | [
"protected",
"function",
"xmlrpc_call",
"(",
"$",
"method",
",",
"$",
"array",
")",
"{",
"$",
"this",
"->",
"_checkConfig",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"method",
")",
"||",
"!",
"is_string",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"'method'",
",",
"'string'",
")",
";",
"}",
"if",
"(",
"$",
"array",
"===",
"null",
"||",
"count",
"(",
"$",
"array",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"KlarnaException",
"(",
"\"Parameterlist is empty or null!\"",
",",
"50067",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"disableXMLRPC",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"/*\n * Disable verifypeer for CURL, so below error is avoided.\n * CURL error: SSL certificate problem, verify that the CA\n * cert is OK.\n * Details: error:14090086:SSL\n * routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)\n */",
"$",
"this",
"->",
"xmlrpc",
"->",
"verifypeer",
"=",
"false",
";",
"$",
"timestart",
"=",
"microtime",
"(",
"true",
")",
";",
"//Create the XMLRPC message.",
"$",
"msg",
"=",
"new",
"xmlrpcmsg",
"(",
"$",
"method",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"this",
"->",
"PROTO",
",",
"$",
"this",
"->",
"VERSION",
")",
",",
"$",
"array",
")",
";",
"$",
"msg",
"=",
"new",
"xmlrpcmsg",
"(",
"$",
"method",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"!",
"$",
"msg",
"->",
"addParam",
"(",
"php_xmlrpc_encode",
"(",
"$",
"p",
",",
"array",
"(",
"'extension_api'",
")",
")",
")",
")",
"{",
"throw",
"new",
"KlarnaException",
"(",
"\"Failed to add parameters to XMLRPC message.\"",
",",
"50068",
")",
";",
"}",
"}",
"$",
"selectDateTime",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"self",
"::",
"$",
"xmlrpcDebug",
")",
"{",
"$",
"this",
"->",
"xmlrpc",
"->",
"setDebug",
"(",
"2",
")",
";",
"}",
"//Save previous XML RPC client encoding settings.",
"$",
"tmp_xmlrpc_defencoding",
"=",
"$",
"GLOBALS",
"[",
"'xmlrpc_defencoding'",
"]",
";",
"$",
"tmp_xmlrpc_internalencoding",
"=",
"$",
"GLOBALS",
"[",
"'xmlrpc_internalencoding'",
"]",
";",
"//Set XML RPC client encoding settings.",
"$",
"GLOBALS",
"[",
"'xmlrpc_defencoding'",
"]",
"=",
"'ISO-8859-1'",
";",
"$",
"GLOBALS",
"[",
"'xmlrpc_internalencoding'",
"]",
"=",
"'UTF-8'",
";",
"//Send the message.",
"$",
"xmlrpcresp",
"=",
"$",
"this",
"->",
"xmlrpc",
"->",
"send",
"(",
"$",
"msg",
")",
";",
"//Restore previous XML RPC client encoding settings.",
"$",
"GLOBALS",
"[",
"'xmlrpc_defencoding'",
"]",
"=",
"$",
"tmp_xmlrpc_defencoding",
";",
"$",
"GLOBALS",
"[",
"'xmlrpc_internalencoding'",
"]",
"=",
"$",
"tmp_xmlrpc_internalencoding",
";",
"//Calculate time and selectTime.",
"$",
"timeend",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"time",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"selectDateTime",
"-",
"$",
"timestart",
")",
"*",
"1000",
")",
";",
"$",
"selectTime",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"timeend",
"-",
"$",
"timestart",
")",
"*",
"1000",
")",
";",
"$",
"status",
"=",
"$",
"xmlrpcresp",
"->",
"faultCode",
"(",
")",
";",
"if",
"(",
"$",
"status",
"!==",
"0",
")",
"{",
"throw",
"new",
"KlarnaException",
"(",
"$",
"xmlrpcresp",
"->",
"faultString",
"(",
")",
",",
"$",
"status",
")",
";",
"}",
"return",
"php_xmlrpc_decode",
"(",
"$",
"xmlrpcresp",
"->",
"value",
"(",
")",
")",
";",
"}",
"catch",
"(",
"KlarnaException",
"$",
"e",
")",
"{",
"//Otherwise it is caught below, and rethrown.",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"KlarnaException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"}"
] | Creates a XMLRPC call with specified XMLRPC method and parameters from array.
@param string $method XMLRPC method.
@param array $array XMLRPC parameters.
@throws KlarnaException
@return mixed | [
"Creates",
"a",
"XMLRPC",
"call",
"with",
"specified",
"XMLRPC",
"method",
"and",
"parameters",
"from",
"array",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3608-L3692 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.checkoutService | public function checkoutService($price, $currency, $locale, $country = null)
{
$this->_checkAmount($price);
$params = array(
'merchant_id' => $this->config['eid'],
'total_price' => $price,
'currency' => strtoupper($currency),
'locale' => strtolower($locale)
);
if ($country !== null) {
$params['country'] = $country;
}
return $this->createTransport()->send(
new CheckoutServiceRequest($this->config, $params)
);
} | php | public function checkoutService($price, $currency, $locale, $country = null)
{
$this->_checkAmount($price);
$params = array(
'merchant_id' => $this->config['eid'],
'total_price' => $price,
'currency' => strtoupper($currency),
'locale' => strtolower($locale)
);
if ($country !== null) {
$params['country'] = $country;
}
return $this->createTransport()->send(
new CheckoutServiceRequest($this->config, $params)
);
} | [
"public",
"function",
"checkoutService",
"(",
"$",
"price",
",",
"$",
"currency",
",",
"$",
"locale",
",",
"$",
"country",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_checkAmount",
"(",
"$",
"price",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'merchant_id'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'eid'",
"]",
",",
"'total_price'",
"=>",
"$",
"price",
",",
"'currency'",
"=>",
"strtoupper",
"(",
"$",
"currency",
")",
",",
"'locale'",
"=>",
"strtolower",
"(",
"$",
"locale",
")",
")",
";",
"if",
"(",
"$",
"country",
"!==",
"null",
")",
"{",
"$",
"params",
"[",
"'country'",
"]",
"=",
"$",
"country",
";",
"}",
"return",
"$",
"this",
"->",
"createTransport",
"(",
")",
"->",
"send",
"(",
"new",
"CheckoutServiceRequest",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"params",
")",
")",
";",
"}"
] | Perform a checkout service request.
@param int|float $price The total price for the checkout including VAT.
@param string $currency ISO 4217 Currency Code
@param string $locale Specify what locale is used by the checkout.
ISO 639 language and ISO 3166-1 country separated
by underscore. Example: sv_SE
@param string $country (Optional) Specify what ISO 3166-1 country to use
for fetching payment methods. If not specified
the locale country will be used.
@throws RuntimeException If the curl extension is not loaded
@return CheckoutServiceResponse Response with payment methods | [
"Perform",
"a",
"checkout",
"service",
"request",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3723-L3741 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.clear | public function clear()
{
$this->goodsList = null;
$this->comment = "";
$this->billing = null;
$this->shipping = null;
$this->shipInfo = array();
$this->extraInfo = array();
$this->bankInfo = array();
$this->incomeInfo = array();
$this->activateInfo = array();
$this->reference = "";
$this->reference_code = "";
$this->orderid[0] = "";
$this->orderid[1] = "";
$this->artNos = array();
$this->coObjects = array();
} | php | public function clear()
{
$this->goodsList = null;
$this->comment = "";
$this->billing = null;
$this->shipping = null;
$this->shipInfo = array();
$this->extraInfo = array();
$this->bankInfo = array();
$this->incomeInfo = array();
$this->activateInfo = array();
$this->reference = "";
$this->reference_code = "";
$this->orderid[0] = "";
$this->orderid[1] = "";
$this->artNos = array();
$this->coObjects = array();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"goodsList",
"=",
"null",
";",
"$",
"this",
"->",
"comment",
"=",
"\"\"",
";",
"$",
"this",
"->",
"billing",
"=",
"null",
";",
"$",
"this",
"->",
"shipping",
"=",
"null",
";",
"$",
"this",
"->",
"shipInfo",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"extraInfo",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"bankInfo",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"incomeInfo",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"activateInfo",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"reference",
"=",
"\"\"",
";",
"$",
"this",
"->",
"reference_code",
"=",
"\"\"",
";",
"$",
"this",
"->",
"orderid",
"[",
"0",
"]",
"=",
"\"\"",
";",
"$",
"this",
"->",
"orderid",
"[",
"1",
"]",
"=",
"\"\"",
";",
"$",
"this",
"->",
"artNos",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"coObjects",
"=",
"array",
"(",
")",
";",
"}"
] | Removes all relevant order/customer data from the internal structure.
@return void | [
"Removes",
"all",
"relevant",
"order",
"/",
"customer",
"data",
"from",
"the",
"internal",
"structure",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3748-L3770 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.digest | public static function digest($data, $hash = null)
{
if ($hash===null) {
$preferred = array(
'sha512',
'sha384',
'sha256',
'sha224',
'md5'
);
$hashes = array_intersect($preferred, hash_algos());
if (count($hashes) == 0) {
throw new KlarnaException(
"No available hash algorithm supported!"
);
}
$hash = array_shift($hashes);
}
self::printDebug('digest() using hash', $hash);
return base64_encode(pack("H*", hash($hash, $data)));
} | php | public static function digest($data, $hash = null)
{
if ($hash===null) {
$preferred = array(
'sha512',
'sha384',
'sha256',
'sha224',
'md5'
);
$hashes = array_intersect($preferred, hash_algos());
if (count($hashes) == 0) {
throw new KlarnaException(
"No available hash algorithm supported!"
);
}
$hash = array_shift($hashes);
}
self::printDebug('digest() using hash', $hash);
return base64_encode(pack("H*", hash($hash, $data)));
} | [
"public",
"static",
"function",
"digest",
"(",
"$",
"data",
",",
"$",
"hash",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"hash",
"===",
"null",
")",
"{",
"$",
"preferred",
"=",
"array",
"(",
"'sha512'",
",",
"'sha384'",
",",
"'sha256'",
",",
"'sha224'",
",",
"'md5'",
")",
";",
"$",
"hashes",
"=",
"array_intersect",
"(",
"$",
"preferred",
",",
"hash_algos",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"hashes",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"KlarnaException",
"(",
"\"No available hash algorithm supported!\"",
")",
";",
"}",
"$",
"hash",
"=",
"array_shift",
"(",
"$",
"hashes",
")",
";",
"}",
"self",
"::",
"printDebug",
"(",
"'digest() using hash'",
",",
"$",
"hash",
")",
";",
"return",
"base64_encode",
"(",
"pack",
"(",
"\"H*\"",
",",
"hash",
"(",
"$",
"hash",
",",
"$",
"data",
")",
")",
")",
";",
"}"
] | Creates a digest hash from the inputted string,
and the specified or the preferred hash algorithm.
@param string $data Data to be hashed.
@param string $hash hash algoritm to use
@throws KlarnaException
@return string Base64 encoded hash. | [
"Creates",
"a",
"digest",
"hash",
"from",
"the",
"inputted",
"string",
"and",
"the",
"specified",
"or",
"the",
"preferred",
"hash",
"algorithm",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3824-L3847 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.num_htmlentities | public static function num_htmlentities($str)
{
$charset = 'ISO-8859-1';
if (!self::$htmlentities) {
self::$htmlentities = array();
$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, $charset);
foreach ($table as $char => $entity) {
self::$htmlentities[$entity] = '&#' . ord($char) . ';';
}
}
return str_replace(
array_keys(
self::$htmlentities
), self::$htmlentities, htmlentities($str, ENT_COMPAT | ENT_HTML401, $charset)
);
} | php | public static function num_htmlentities($str)
{
$charset = 'ISO-8859-1';
if (!self::$htmlentities) {
self::$htmlentities = array();
$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, $charset);
foreach ($table as $char => $entity) {
self::$htmlentities[$entity] = '&#' . ord($char) . ';';
}
}
return str_replace(
array_keys(
self::$htmlentities
), self::$htmlentities, htmlentities($str, ENT_COMPAT | ENT_HTML401, $charset)
);
} | [
"public",
"static",
"function",
"num_htmlentities",
"(",
"$",
"str",
")",
"{",
"$",
"charset",
"=",
"'ISO-8859-1'",
";",
"if",
"(",
"!",
"self",
"::",
"$",
"htmlentities",
")",
"{",
"self",
"::",
"$",
"htmlentities",
"=",
"array",
"(",
")",
";",
"$",
"table",
"=",
"get_html_translation_table",
"(",
"HTML_ENTITIES",
",",
"ENT_QUOTES",
",",
"$",
"charset",
")",
";",
"foreach",
"(",
"$",
"table",
"as",
"$",
"char",
"=>",
"$",
"entity",
")",
"{",
"self",
"::",
"$",
"htmlentities",
"[",
"$",
"entity",
"]",
"=",
"'&#'",
".",
"ord",
"(",
"$",
"char",
")",
".",
"';'",
";",
"}",
"}",
"return",
"str_replace",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"htmlentities",
")",
",",
"self",
"::",
"$",
"htmlentities",
",",
"htmlentities",
"(",
"$",
"str",
",",
"ENT_COMPAT",
"|",
"ENT_HTML401",
",",
"$",
"charset",
")",
")",
";",
"}"
] | Converts special characters to numeric htmlentities.
<b>Note</b>:<br>
If supplied string is encoded with UTF-8, o umlaut ("ö") will become two
HTML entities instead of one.
@param string $str String to be converted.
@return string String converted to numeric HTML entities. | [
"Converts",
"special",
"characters",
"to",
"numeric",
"htmlentities",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3860-L3877 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.printDebug | public static function printDebug($msg, $mixed)
{
if (self::$debug) {
if (class_exists('FB', false)) {
FB::send($mixed, $msg);
} else {
echo "\n<!-- ".$msg.": \n";
print_r($mixed);
echo "\n end ".$msg." -->\n";
}
}
} | php | public static function printDebug($msg, $mixed)
{
if (self::$debug) {
if (class_exists('FB', false)) {
FB::send($mixed, $msg);
} else {
echo "\n<!-- ".$msg.": \n";
print_r($mixed);
echo "\n end ".$msg." -->\n";
}
}
} | [
"public",
"static",
"function",
"printDebug",
"(",
"$",
"msg",
",",
"$",
"mixed",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"debug",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'FB'",
",",
"false",
")",
")",
"{",
"FB",
"::",
"send",
"(",
"$",
"mixed",
",",
"$",
"msg",
")",
";",
"}",
"else",
"{",
"echo",
"\"\\n<!-- \"",
".",
"$",
"msg",
".",
"\": \\n\"",
";",
"print_r",
"(",
"$",
"mixed",
")",
";",
"echo",
"\"\\n end \"",
".",
"$",
"msg",
".",
"\" -->\\n\"",
";",
"}",
"}",
"}"
] | Prints debug information if debug is set to true.
$msg is used as header/footer in the output.
if FirePHP is available it will be used instead of
dumping the debug info into the document.
It uses print_r and encapsulates it in HTML/XML comments.
(<!-- -->)
@param string $msg Debug identifier, e.g. "my array".
@param mixed $mixed Object, type, etc, to be debugged.
@return void | [
"Prints",
"debug",
"information",
"if",
"debug",
"is",
"set",
"to",
"true",
".",
"$msg",
"is",
"used",
"as",
"header",
"/",
"footer",
"in",
"the",
"output",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3894-L3905 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkInvNo | private function _checkInvNo(&$invNo)
{
if (!isset($invNo)) {
throw new Klarna_ArgumentNotSetException("Invoice number");
}
if (!is_string($invNo)) {
$invNo = strval($invNo);
}
if (strlen($invNo) == 0) {
throw new Klarna_ArgumentNotSetException("Invoice number");
}
} | php | private function _checkInvNo(&$invNo)
{
if (!isset($invNo)) {
throw new Klarna_ArgumentNotSetException("Invoice number");
}
if (!is_string($invNo)) {
$invNo = strval($invNo);
}
if (strlen($invNo) == 0) {
throw new Klarna_ArgumentNotSetException("Invoice number");
}
} | [
"private",
"function",
"_checkInvNo",
"(",
"&",
"$",
"invNo",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"invNo",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Invoice number\"",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"invNo",
")",
")",
"{",
"$",
"invNo",
"=",
"strval",
"(",
"$",
"invNo",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"invNo",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Invoice number\"",
")",
";",
"}",
"}"
] | Checks/fixes so the invNo input is valid.
@param string &$invNo Invoice number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"invNo",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3915-L3926 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkQty | private function _checkQty(&$qty)
{
if (!isset($qty)) {
throw new Klarna_ArgumentNotSetException("Quantity");
}
if (is_numeric($qty) && !is_int($qty)) {
$qty = intval($qty);
}
if (!is_int($qty)) {
throw new Klarna_InvalidTypeException("Quantity", "integer");
}
} | php | private function _checkQty(&$qty)
{
if (!isset($qty)) {
throw new Klarna_ArgumentNotSetException("Quantity");
}
if (is_numeric($qty) && !is_int($qty)) {
$qty = intval($qty);
}
if (!is_int($qty)) {
throw new Klarna_InvalidTypeException("Quantity", "integer");
}
} | [
"private",
"function",
"_checkQty",
"(",
"&",
"$",
"qty",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"qty",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Quantity\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"qty",
")",
"&&",
"!",
"is_int",
"(",
"$",
"qty",
")",
")",
"{",
"$",
"qty",
"=",
"intval",
"(",
"$",
"qty",
")",
";",
"}",
"if",
"(",
"!",
"is_int",
"(",
"$",
"qty",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Quantity\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes so the quantity input is valid.
@param int &$qty Quantity.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"quantity",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3936-L3947 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkArtTitle | private function _checkArtTitle(&$artTitle)
{
if (!is_string($artTitle)) {
$artTitle = strval($artTitle);
}
if (!isset($artTitle) || strlen($artTitle) == 0) {
throw new Klarna_ArgumentNotSetException("artTitle", 50059);
}
} | php | private function _checkArtTitle(&$artTitle)
{
if (!is_string($artTitle)) {
$artTitle = strval($artTitle);
}
if (!isset($artTitle) || strlen($artTitle) == 0) {
throw new Klarna_ArgumentNotSetException("artTitle", 50059);
}
} | [
"private",
"function",
"_checkArtTitle",
"(",
"&",
"$",
"artTitle",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"artTitle",
")",
")",
"{",
"$",
"artTitle",
"=",
"strval",
"(",
"$",
"artTitle",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"artTitle",
")",
"||",
"strlen",
"(",
"$",
"artTitle",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"artTitle\"",
",",
"50059",
")",
";",
"}",
"}"
] | Checks/fixes so the artTitle input is valid.
@param string &$artTitle Article title.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"artTitle",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3957-L3965 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkArtNo | private function _checkArtNo(&$artNo)
{
if (is_numeric($artNo) && !is_string($artNo)) {
//Convert artNo to string if integer.
$artNo = strval($artNo);
}
if (!isset($artNo) || strlen($artNo) == 0 || (!is_string($artNo))) {
throw new Klarna_ArgumentNotSetException("artNo");
}
} | php | private function _checkArtNo(&$artNo)
{
if (is_numeric($artNo) && !is_string($artNo)) {
//Convert artNo to string if integer.
$artNo = strval($artNo);
}
if (!isset($artNo) || strlen($artNo) == 0 || (!is_string($artNo))) {
throw new Klarna_ArgumentNotSetException("artNo");
}
} | [
"private",
"function",
"_checkArtNo",
"(",
"&",
"$",
"artNo",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"artNo",
")",
"&&",
"!",
"is_string",
"(",
"$",
"artNo",
")",
")",
"{",
"//Convert artNo to string if integer.",
"$",
"artNo",
"=",
"strval",
"(",
"$",
"artNo",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"artNo",
")",
"||",
"strlen",
"(",
"$",
"artNo",
")",
"==",
"0",
"||",
"(",
"!",
"is_string",
"(",
"$",
"artNo",
")",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"artNo\"",
")",
";",
"}",
"}"
] | Checks/fixes so the artNo input is valid.
@param int|string &$artNo Article number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"artNo",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3975-L3984 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkCredNo | private function _checkCredNo(&$credNo)
{
if (!isset($credNo)) {
throw new Klarna_ArgumentNotSetException("Credit number");
}
if ($credNo === false || $credNo === null) {
$credNo = "";
}
if (!is_string($credNo)) {
$credNo = strval($credNo);
if (!is_string($credNo)) {
throw new Klarna_InvalidTypeException("Credit number", "string");
}
}
} | php | private function _checkCredNo(&$credNo)
{
if (!isset($credNo)) {
throw new Klarna_ArgumentNotSetException("Credit number");
}
if ($credNo === false || $credNo === null) {
$credNo = "";
}
if (!is_string($credNo)) {
$credNo = strval($credNo);
if (!is_string($credNo)) {
throw new Klarna_InvalidTypeException("Credit number", "string");
}
}
} | [
"private",
"function",
"_checkCredNo",
"(",
"&",
"$",
"credNo",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"credNo",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Credit number\"",
")",
";",
"}",
"if",
"(",
"$",
"credNo",
"===",
"false",
"||",
"$",
"credNo",
"===",
"null",
")",
"{",
"$",
"credNo",
"=",
"\"\"",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"credNo",
")",
")",
"{",
"$",
"credNo",
"=",
"strval",
"(",
"$",
"credNo",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"credNo",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Credit number\"",
",",
"\"string\"",
")",
";",
"}",
"}",
"}"
] | Checks/fixes so the credNo input is valid.
@param string &$credNo Credit number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"credNo",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L3994-L4009 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkInt | private function _checkInt(&$int, $field)
{
if (!isset($int)) {
throw new Klarna_ArgumentNotSetException($field);
}
if (is_numeric($int) && !is_int($int)) {
$int = intval($int);
}
if (!is_numeric($int) || !is_int($int)) {
throw new Klarna_InvalidTypeException($field, "integer");
}
} | php | private function _checkInt(&$int, $field)
{
if (!isset($int)) {
throw new Klarna_ArgumentNotSetException($field);
}
if (is_numeric($int) && !is_int($int)) {
$int = intval($int);
}
if (!is_numeric($int) || !is_int($int)) {
throw new Klarna_InvalidTypeException($field, "integer");
}
} | [
"private",
"function",
"_checkInt",
"(",
"&",
"$",
"int",
",",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"int",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"$",
"field",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"int",
")",
"&&",
"!",
"is_int",
"(",
"$",
"int",
")",
")",
"{",
"$",
"int",
"=",
"intval",
"(",
"$",
"int",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"int",
")",
"||",
"!",
"is_int",
"(",
"$",
"int",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"$",
"field",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes so the integer input is valid.
@param int &$int {@link KlarnaFlags flags} constant.
@param string $field Name of the field.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"integer",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4038-L4049 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkVAT | private function _checkVAT(&$vat)
{
if (!isset($vat)) {
throw new Klarna_ArgumentNotSetException("VAT");
}
if (is_numeric($vat) && (!is_int($vat) || !is_float($vat))) {
$vat = floatval($vat);
}
if (!is_numeric($vat) || (!is_int($vat) && !is_float($vat))) {
throw new Klarna_InvalidTypeException("VAT", "integer or float");
}
} | php | private function _checkVAT(&$vat)
{
if (!isset($vat)) {
throw new Klarna_ArgumentNotSetException("VAT");
}
if (is_numeric($vat) && (!is_int($vat) || !is_float($vat))) {
$vat = floatval($vat);
}
if (!is_numeric($vat) || (!is_int($vat) && !is_float($vat))) {
throw new Klarna_InvalidTypeException("VAT", "integer or float");
}
} | [
"private",
"function",
"_checkVAT",
"(",
"&",
"$",
"vat",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"vat",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"VAT\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"vat",
")",
"&&",
"(",
"!",
"is_int",
"(",
"$",
"vat",
")",
"||",
"!",
"is_float",
"(",
"$",
"vat",
")",
")",
")",
"{",
"$",
"vat",
"=",
"floatval",
"(",
"$",
"vat",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"vat",
")",
"||",
"(",
"!",
"is_int",
"(",
"$",
"vat",
")",
"&&",
"!",
"is_float",
"(",
"$",
"vat",
")",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"VAT\"",
",",
"\"integer or float\"",
")",
";",
"}",
"}"
] | Checks/fixes so the VAT input is valid.
@param float &$vat VAT.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"VAT",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4059-L4070 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkAmount | private function _checkAmount(&$amount)
{
if (!isset($amount)) {
throw new Klarna_ArgumentNotSetException("Amount");
}
if (is_numeric($amount)) {
$this->_fixValue($amount);
}
if (is_numeric($amount) && !is_int($amount)) {
$amount = intval($amount);
}
if (!is_numeric($amount) || !is_int($amount)) {
throw new Klarna_InvalidTypeException("amount", "integer");
}
} | php | private function _checkAmount(&$amount)
{
if (!isset($amount)) {
throw new Klarna_ArgumentNotSetException("Amount");
}
if (is_numeric($amount)) {
$this->_fixValue($amount);
}
if (is_numeric($amount) && !is_int($amount)) {
$amount = intval($amount);
}
if (!is_numeric($amount) || !is_int($amount)) {
throw new Klarna_InvalidTypeException("amount", "integer");
}
} | [
"private",
"function",
"_checkAmount",
"(",
"&",
"$",
"amount",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"amount",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Amount\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"amount",
")",
")",
"{",
"$",
"this",
"->",
"_fixValue",
"(",
"$",
"amount",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"amount",
")",
"&&",
"!",
"is_int",
"(",
"$",
"amount",
")",
")",
"{",
"$",
"amount",
"=",
"intval",
"(",
"$",
"amount",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"amount",
")",
"||",
"!",
"is_int",
"(",
"$",
"amount",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"amount\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes so the amount input is valid.
@param int &$amount Amount.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"amount",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4080-L4094 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkPrice | private function _checkPrice(&$price)
{
if (!isset($price)) {
throw new Klarna_ArgumentNotSetException("Price");
}
if (is_numeric($price)) {
$this->_fixValue($price);
}
if (is_numeric($price) && !is_int($price)) {
$price = intval($price);
}
if (!is_numeric($price) || !is_int($price)) {
throw new Klarna_InvalidTypeException("Price", "integer");
}
} | php | private function _checkPrice(&$price)
{
if (!isset($price)) {
throw new Klarna_ArgumentNotSetException("Price");
}
if (is_numeric($price)) {
$this->_fixValue($price);
}
if (is_numeric($price) && !is_int($price)) {
$price = intval($price);
}
if (!is_numeric($price) || !is_int($price)) {
throw new Klarna_InvalidTypeException("Price", "integer");
}
} | [
"private",
"function",
"_checkPrice",
"(",
"&",
"$",
"price",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"price",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Price\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"price",
")",
")",
"{",
"$",
"this",
"->",
"_fixValue",
"(",
"$",
"price",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"price",
")",
"&&",
"!",
"is_int",
"(",
"$",
"price",
")",
")",
"{",
"$",
"price",
"=",
"intval",
"(",
"$",
"price",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"price",
")",
"||",
"!",
"is_int",
"(",
"$",
"price",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Price\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes so the price input is valid.
@param int &$price Price.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"price",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4104-L4118 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkDiscount | private function _checkDiscount(&$discount)
{
if (!isset($discount)) {
throw new Klarna_ArgumentNotSetException("Discount");
}
if (is_numeric($discount)
&& (!is_int($discount) || !is_float($discount))
) {
$discount = floatval($discount);
}
if (!is_numeric($discount)
|| (!is_int($discount) && !is_float($discount))
) {
throw new Klarna_InvalidTypeException("Discount", "integer or float");
}
} | php | private function _checkDiscount(&$discount)
{
if (!isset($discount)) {
throw new Klarna_ArgumentNotSetException("Discount");
}
if (is_numeric($discount)
&& (!is_int($discount) || !is_float($discount))
) {
$discount = floatval($discount);
}
if (!is_numeric($discount)
|| (!is_int($discount) && !is_float($discount))
) {
throw new Klarna_InvalidTypeException("Discount", "integer or float");
}
} | [
"private",
"function",
"_checkDiscount",
"(",
"&",
"$",
"discount",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"discount",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Discount\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"discount",
")",
"&&",
"(",
"!",
"is_int",
"(",
"$",
"discount",
")",
"||",
"!",
"is_float",
"(",
"$",
"discount",
")",
")",
")",
"{",
"$",
"discount",
"=",
"floatval",
"(",
"$",
"discount",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"discount",
")",
"||",
"(",
"!",
"is_int",
"(",
"$",
"discount",
")",
"&&",
"!",
"is_float",
"(",
"$",
"discount",
")",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Discount\"",
",",
"\"integer or float\"",
")",
";",
"}",
"}"
] | Checks/fixes so the discount input is valid.
@param float &$discount Discount amount.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"the",
"discount",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4141-L4157 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkEstoreOrderNo | private function _checkEstoreOrderNo(&$estoreOrderNo)
{
if (!isset($estoreOrderNo)) {
throw new Klarna_ArgumentNotSetException("Order number");
}
if (!is_string($estoreOrderNo)) {
$estoreOrderNo = strval($estoreOrderNo);
if (!is_string($estoreOrderNo)) {
throw new Klarna_InvalidTypeException("Order number", "string");
}
}
} | php | private function _checkEstoreOrderNo(&$estoreOrderNo)
{
if (!isset($estoreOrderNo)) {
throw new Klarna_ArgumentNotSetException("Order number");
}
if (!is_string($estoreOrderNo)) {
$estoreOrderNo = strval($estoreOrderNo);
if (!is_string($estoreOrderNo)) {
throw new Klarna_InvalidTypeException("Order number", "string");
}
}
} | [
"private",
"function",
"_checkEstoreOrderNo",
"(",
"&",
"$",
"estoreOrderNo",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"estoreOrderNo",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Order number\"",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"estoreOrderNo",
")",
")",
"{",
"$",
"estoreOrderNo",
"=",
"strval",
"(",
"$",
"estoreOrderNo",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"estoreOrderNo",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Order number\"",
",",
"\"string\"",
")",
";",
"}",
"}",
"}"
] | Checks/fixes so that the estoreOrderNo input is valid.
@param string &$estoreOrderNo Estores order number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"that",
"the",
"estoreOrderNo",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4167-L4179 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkCountry | private function _checkCountry(&$country)
{
if (!isset($country)) {
throw new Klarna_ArgumentNotSetException("Country");
}
if (is_numeric($country) && !is_int($country)) {
$country = intval($country);
}
if (!is_numeric($country) || !is_int($country)) {
throw new Klarna_InvalidTypeException("Country", "integer");
}
} | php | private function _checkCountry(&$country)
{
if (!isset($country)) {
throw new Klarna_ArgumentNotSetException("Country");
}
if (is_numeric($country) && !is_int($country)) {
$country = intval($country);
}
if (!is_numeric($country) || !is_int($country)) {
throw new Klarna_InvalidTypeException("Country", "integer");
}
} | [
"private",
"function",
"_checkCountry",
"(",
"&",
"$",
"country",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"country",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Country\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"country",
")",
"&&",
"!",
"is_int",
"(",
"$",
"country",
")",
")",
"{",
"$",
"country",
"=",
"intval",
"(",
"$",
"country",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"country",
")",
"||",
"!",
"is_int",
"(",
"$",
"country",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Country\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes to the country input is valid.
@param int &$country {@link KlarnaCountry Country} constant.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"to",
"the",
"country",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4209-L4220 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkLanguage | private function _checkLanguage(&$language)
{
if (!isset($language)) {
throw new Klarna_ArgumentNotSetException("Language");
}
if (is_numeric($language) && !is_int($language)) {
$language = intval($language);
}
if (!is_numeric($language) || !is_int($language)) {
throw new Klarna_InvalidTypeException("Language", "integer");
}
} | php | private function _checkLanguage(&$language)
{
if (!isset($language)) {
throw new Klarna_ArgumentNotSetException("Language");
}
if (is_numeric($language) && !is_int($language)) {
$language = intval($language);
}
if (!is_numeric($language) || !is_int($language)) {
throw new Klarna_InvalidTypeException("Language", "integer");
}
} | [
"private",
"function",
"_checkLanguage",
"(",
"&",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Language\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"language",
")",
"&&",
"!",
"is_int",
"(",
"$",
"language",
")",
")",
"{",
"$",
"language",
"=",
"intval",
"(",
"$",
"language",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"language",
")",
"||",
"!",
"is_int",
"(",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Language\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes to the language input is valid.
@param int &$language {@link KlarnaLanguage Language} constant.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"to",
"the",
"language",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4230-L4241 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkCurrency | private function _checkCurrency(&$currency)
{
if (!isset($currency)) {
throw new Klarna_ArgumentNotSetException("Currency");
}
if (is_numeric($currency) && !is_int($currency)) {
$currency = intval($currency);
}
if (!is_numeric($currency) || !is_int($currency)) {
throw new Klarna_InvalidTypeException("Currency", "integer");
}
} | php | private function _checkCurrency(&$currency)
{
if (!isset($currency)) {
throw new Klarna_ArgumentNotSetException("Currency");
}
if (is_numeric($currency) && !is_int($currency)) {
$currency = intval($currency);
}
if (!is_numeric($currency) || !is_int($currency)) {
throw new Klarna_InvalidTypeException("Currency", "integer");
}
} | [
"private",
"function",
"_checkCurrency",
"(",
"&",
"$",
"currency",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"currency",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"Currency\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"currency",
")",
"&&",
"!",
"is_int",
"(",
"$",
"currency",
")",
")",
"{",
"$",
"currency",
"=",
"intval",
"(",
"$",
"currency",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"currency",
")",
"||",
"!",
"is_int",
"(",
"$",
"currency",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Currency\"",
",",
"\"integer\"",
")",
";",
"}",
"}"
] | Checks/fixes to the currency input is valid.
@param int &$currency {@link KlarnaCurrency Currency} constant.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"to",
"the",
"currency",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4251-L4262 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkNo | private function _checkNo(&$no)
{
if (!isset($no)) {
throw new Klarna_ArgumentNotSetException("no");
}
if (is_numeric($no) && !is_int($no)) {
$no = intval($no);
}
if (!is_numeric($no) || !is_int($no) || $no <= 0) {
throw new Klarna_InvalidTypeException('no', 'integer > 0');
}
} | php | private function _checkNo(&$no)
{
if (!isset($no)) {
throw new Klarna_ArgumentNotSetException("no");
}
if (is_numeric($no) && !is_int($no)) {
$no = intval($no);
}
if (!is_numeric($no) || !is_int($no) || $no <= 0) {
throw new Klarna_InvalidTypeException('no', 'integer > 0');
}
} | [
"private",
"function",
"_checkNo",
"(",
"&",
"$",
"no",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"no",
")",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"no\"",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"no",
")",
"&&",
"!",
"is_int",
"(",
"$",
"no",
")",
")",
"{",
"$",
"no",
"=",
"intval",
"(",
"$",
"no",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"no",
")",
"||",
"!",
"is_int",
"(",
"$",
"no",
")",
"||",
"$",
"no",
"<=",
"0",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"'no'",
",",
"'integer > 0'",
")",
";",
"}",
"}"
] | Checks/fixes so no/number is a valid input.
@param int &$no Number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"no",
"/",
"number",
"is",
"a",
"valid",
"input",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4272-L4283 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkRNO | private function _checkRNO(&$rno)
{
if (!is_string($rno)) {
$rno = strval($rno);
}
if (strlen($rno) == 0) {
throw new Klarna_ArgumentNotSetException("RNO");
}
} | php | private function _checkRNO(&$rno)
{
if (!is_string($rno)) {
$rno = strval($rno);
}
if (strlen($rno) == 0) {
throw new Klarna_ArgumentNotSetException("RNO");
}
} | [
"private",
"function",
"_checkRNO",
"(",
"&",
"$",
"rno",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"rno",
")",
")",
"{",
"$",
"rno",
"=",
"strval",
"(",
"$",
"rno",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"rno",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"\"RNO\"",
")",
";",
"}",
"}"
] | Checks/fixes so reservation number is a valid input.
@param string &$rno Reservation number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"reservation",
"number",
"is",
"a",
"valid",
"input",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4293-L4301 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkRef | private function _checkRef(&$reference, &$refCode)
{
if (!is_string($reference)) {
$reference = strval($reference);
if (!is_string($reference)) {
throw new Klarna_InvalidTypeException("Reference", "string");
}
}
if (!is_string($refCode)) {
$refCode = strval($refCode);
if (!is_string($refCode)) {
throw new Klarna_InvalidTypeException("Reference code", "string");
}
}
} | php | private function _checkRef(&$reference, &$refCode)
{
if (!is_string($reference)) {
$reference = strval($reference);
if (!is_string($reference)) {
throw new Klarna_InvalidTypeException("Reference", "string");
}
}
if (!is_string($refCode)) {
$refCode = strval($refCode);
if (!is_string($refCode)) {
throw new Klarna_InvalidTypeException("Reference code", "string");
}
}
} | [
"private",
"function",
"_checkRef",
"(",
"&",
"$",
"reference",
",",
"&",
"$",
"refCode",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"reference",
")",
")",
"{",
"$",
"reference",
"=",
"strval",
"(",
"$",
"reference",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"reference",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Reference\"",
",",
"\"string\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"refCode",
")",
")",
"{",
"$",
"refCode",
"=",
"strval",
"(",
"$",
"refCode",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"refCode",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"Reference code\"",
",",
"\"string\"",
")",
";",
"}",
"}",
"}"
] | Checks/fixes so that reference/refCode are valid.
@param string &$reference Reference string.
@param string &$refCode Reference code.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"that",
"reference",
"/",
"refCode",
"are",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4312-L4327 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkOCR | private function _checkOCR(&$ocr)
{
if (!is_string($ocr)) {
$ocr = strval($ocr);
if (!is_string($ocr)) {
throw new Klarna_InvalidTypeException("OCR", "string");
}
}
} | php | private function _checkOCR(&$ocr)
{
if (!is_string($ocr)) {
$ocr = strval($ocr);
if (!is_string($ocr)) {
throw new Klarna_InvalidTypeException("OCR", "string");
}
}
} | [
"private",
"function",
"_checkOCR",
"(",
"&",
"$",
"ocr",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"ocr",
")",
")",
"{",
"$",
"ocr",
"=",
"strval",
"(",
"$",
"ocr",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"ocr",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"\"OCR\"",
",",
"\"string\"",
")",
";",
"}",
"}",
"}"
] | Checks/fixes so that the OCR input is valid.
@param string &$ocr OCR number.
@throws KlarnaException
@return void | [
"Checks",
"/",
"fixes",
"so",
"that",
"the",
"OCR",
"input",
"is",
"valid",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4337-L4345 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkArgument | private function _checkArgument($argument, $name)
{
if (!is_string($argument)) {
$argument = strval($argument);
}
if (strlen($argument) == 0) {
throw new Klarna_ArgumentNotSetException($name);
}
} | php | private function _checkArgument($argument, $name)
{
if (!is_string($argument)) {
$argument = strval($argument);
}
if (strlen($argument) == 0) {
throw new Klarna_ArgumentNotSetException($name);
}
} | [
"private",
"function",
"_checkArgument",
"(",
"$",
"argument",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"argument",
")",
")",
"{",
"$",
"argument",
"=",
"strval",
"(",
"$",
"argument",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"argument",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Klarna_ArgumentNotSetException",
"(",
"$",
"name",
")",
";",
"}",
"}"
] | Check so required argument is supplied.
@param string $argument argument to check
@param string $name name of argument
@throws Klarna_ArgumentNotSetException
@return void | [
"Check",
"so",
"required",
"argument",
"is",
"supplied",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4356-L4365 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkLocale | private function _checkLocale()
{
if (!is_int($this->_country)
|| !is_int($this->_language)
|| !is_int($this->_currency)
) {
throw new Klarna_InvalidLocaleException;
}
} | php | private function _checkLocale()
{
if (!is_int($this->_country)
|| !is_int($this->_language)
|| !is_int($this->_currency)
) {
throw new Klarna_InvalidLocaleException;
}
} | [
"private",
"function",
"_checkLocale",
"(",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"_country",
")",
"||",
"!",
"is_int",
"(",
"$",
"this",
"->",
"_language",
")",
"||",
"!",
"is_int",
"(",
"$",
"this",
"->",
"_currency",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidLocaleException",
";",
"}",
"}"
] | Check so Locale settings (country, currency, language) are set.
@throws KlarnaException
@return void | [
"Check",
"so",
"Locale",
"settings",
"(",
"country",
"currency",
"language",
")",
"are",
"set",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4373-L4381 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna.setPCStorage | public function setPCStorage($pcStorage)
{
if (!($pcStorage instanceof PCStorage)) {
throw new Klarna_InvalidTypeException('pcStorage', 'PCStorage');
}
$this->pcStorage = $pcStorage->getName();
$this->pclasses = $pcStorage;
} | php | public function setPCStorage($pcStorage)
{
if (!($pcStorage instanceof PCStorage)) {
throw new Klarna_InvalidTypeException('pcStorage', 'PCStorage');
}
$this->pcStorage = $pcStorage->getName();
$this->pclasses = $pcStorage;
} | [
"public",
"function",
"setPCStorage",
"(",
"$",
"pcStorage",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"pcStorage",
"instanceof",
"PCStorage",
")",
")",
"{",
"throw",
"new",
"Klarna_InvalidTypeException",
"(",
"'pcStorage'",
",",
"'PCStorage'",
")",
";",
"}",
"$",
"this",
"->",
"pcStorage",
"=",
"$",
"pcStorage",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"pclasses",
"=",
"$",
"pcStorage",
";",
"}"
] | Set the pcStorage method used for this instance
@param PCStorage $pcStorage PCStorage implementation
@return void | [
"Set",
"the",
"pcStorage",
"method",
"used",
"for",
"this",
"instance"
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4403-L4410 |
Subscribo/klarna-invoice-sdk-wrapped | src/Klarna.php | Klarna._checkConfig | private function _checkConfig($config = null)
{
if ($config === null) {
$config = $this->config;
}
if (!($config instanceof ArrayAccess)
&& !is_array($config)
) {
throw new Klarna_IncompleteConfigurationException;
}
} | php | private function _checkConfig($config = null)
{
if ($config === null) {
$config = $this->config;
}
if (!($config instanceof ArrayAccess)
&& !is_array($config)
) {
throw new Klarna_IncompleteConfigurationException;
}
} | [
"private",
"function",
"_checkConfig",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"config",
"===",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"config",
"instanceof",
"ArrayAccess",
")",
"&&",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"throw",
"new",
"Klarna_IncompleteConfigurationException",
";",
"}",
"}"
] | Ensure the configuration is of the correct type.
@param array|ArrayAccess|null $config an optional config to validate
@return void | [
"Ensure",
"the",
"configuration",
"is",
"of",
"the",
"correct",
"type",
"."
] | train | https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/Klarna.php#L4419-L4429 |
Talesoft/tale-framework | src/Tale/Event.php | Event.removeHandler | public function removeHandler($handler)
{
if(!is_callable($handler))
throw new \InvalidArgumentException("Argument 1 of Event->addHandler needs to be a valid callback");
$i = array_search($handler, $this->_handlers, true);
if ($i !== false)
unset($this->_handlers[$i]);
return $this;
} | php | public function removeHandler($handler)
{
if(!is_callable($handler))
throw new \InvalidArgumentException("Argument 1 of Event->addHandler needs to be a valid callback");
$i = array_search($handler, $this->_handlers, true);
if ($i !== false)
unset($this->_handlers[$i]);
return $this;
} | [
"public",
"function",
"removeHandler",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"handler",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Argument 1 of Event->addHandler needs to be a valid callback\"",
")",
";",
"$",
"i",
"=",
"array_search",
"(",
"$",
"handler",
",",
"$",
"this",
"->",
"_handlers",
",",
"true",
")",
";",
"if",
"(",
"$",
"i",
"!==",
"false",
")",
"unset",
"(",
"$",
"this",
"->",
"_handlers",
"[",
"$",
"i",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes an assigned handler
This uses array_search to find the handler
@param callable $handler The handler to remove
@return $this | [
"Removes",
"an",
"assigned",
"handler"
] | train | https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Event.php#L89-L100 |
Talesoft/tale-framework | src/Tale/Event.php | Event.trigger | public function trigger(Event\Args $args = null, $reverse = false)
{
$args = $args ? $args : new Event\Args();
if ($reverse) {
for ($i = count($this->_handlers); --$i >= 0;) {
if (call_user_func_array($this->_handlers[$i], func_get_args()) === false)
break;
}
} else {
foreach ($this->_handlers as $handler) {
if (call_user_func_array($handler, func_get_args()) === false)
break;
}
}
return !$args->isDefaultPrevented();
} | php | public function trigger(Event\Args $args = null, $reverse = false)
{
$args = $args ? $args : new Event\Args();
if ($reverse) {
for ($i = count($this->_handlers); --$i >= 0;) {
if (call_user_func_array($this->_handlers[$i], func_get_args()) === false)
break;
}
} else {
foreach ($this->_handlers as $handler) {
if (call_user_func_array($handler, func_get_args()) === false)
break;
}
}
return !$args->isDefaultPrevented();
} | [
"public",
"function",
"trigger",
"(",
"Event",
"\\",
"Args",
"$",
"args",
"=",
"null",
",",
"$",
"reverse",
"=",
"false",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"?",
"$",
"args",
":",
"new",
"Event",
"\\",
"Args",
"(",
")",
";",
"if",
"(",
"$",
"reverse",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"_handlers",
")",
";",
"--",
"$",
"i",
">=",
"0",
";",
")",
"{",
"if",
"(",
"call_user_func_array",
"(",
"$",
"this",
"->",
"_handlers",
"[",
"$",
"i",
"]",
",",
"func_get_args",
"(",
")",
")",
"===",
"false",
")",
"break",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"call_user_func_array",
"(",
"$",
"handler",
",",
"func_get_args",
"(",
")",
")",
"===",
"false",
")",
"break",
";",
"}",
"}",
"return",
"!",
"$",
"args",
"->",
"isDefaultPrevented",
"(",
")",
";",
"}"
] | Triggers the event
The return value is the the negation of
isDefaultPrevented() result of the event args
If null is passed, new event args are created automatically
@param \Tale\Event\Args|null $args An argument object to pass
@param bool $reverse
@return bool | [
"Triggers",
"the",
"event"
] | train | https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Event.php#L114-L136 |
pluf/geo | src/Geo/Form/Vote.php | Geo_Form_Vote.initFields | public function initFields ($extra = array())
{
$this->tenant = $extra['tenant'];
$this->user = $extra['user'];
$this->location = $extra['location'];
if (array_key_exists('vote', $extra)) {
$this->vote = $extra['vote'];
}
$this->vote = Geo_Form_Vote::voteFactory($this->vote);
$this->fields['vote_value'] = new Pluf_Form_Field_Boolean(
array(
'required' => true,
'label' => __('vote value'),
'initial' => $this->vote->vote_value
));
$this->fields['vote_comment'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('vote comment'),
'initial' => $this->vote->vote_comment
));
} | php | public function initFields ($extra = array())
{
$this->tenant = $extra['tenant'];
$this->user = $extra['user'];
$this->location = $extra['location'];
if (array_key_exists('vote', $extra)) {
$this->vote = $extra['vote'];
}
$this->vote = Geo_Form_Vote::voteFactory($this->vote);
$this->fields['vote_value'] = new Pluf_Form_Field_Boolean(
array(
'required' => true,
'label' => __('vote value'),
'initial' => $this->vote->vote_value
));
$this->fields['vote_comment'] = new Pluf_Form_Field_Varchar(
array(
'required' => false,
'label' => __('vote comment'),
'initial' => $this->vote->vote_comment
));
} | [
"public",
"function",
"initFields",
"(",
"$",
"extra",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"tenant",
"=",
"$",
"extra",
"[",
"'tenant'",
"]",
";",
"$",
"this",
"->",
"user",
"=",
"$",
"extra",
"[",
"'user'",
"]",
";",
"$",
"this",
"->",
"location",
"=",
"$",
"extra",
"[",
"'location'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'vote'",
",",
"$",
"extra",
")",
")",
"{",
"$",
"this",
"->",
"vote",
"=",
"$",
"extra",
"[",
"'vote'",
"]",
";",
"}",
"$",
"this",
"->",
"vote",
"=",
"Geo_Form_Vote",
"::",
"voteFactory",
"(",
"$",
"this",
"->",
"vote",
")",
";",
"$",
"this",
"->",
"fields",
"[",
"'vote_value'",
"]",
"=",
"new",
"Pluf_Form_Field_Boolean",
"(",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'label'",
"=>",
"__",
"(",
"'vote value'",
")",
",",
"'initial'",
"=>",
"$",
"this",
"->",
"vote",
"->",
"vote_value",
")",
")",
";",
"$",
"this",
"->",
"fields",
"[",
"'vote_comment'",
"]",
"=",
"new",
"Pluf_Form_Field_Varchar",
"(",
"array",
"(",
"'required'",
"=>",
"false",
",",
"'label'",
"=>",
"__",
"(",
"'vote comment'",
")",
",",
"'initial'",
"=>",
"$",
"this",
"->",
"vote",
"->",
"vote_comment",
")",
")",
";",
"}"
] | مقدار دهی فیلدها.
@see Pluf_Form::initFields() | [
"مقدار",
"دهی",
"فیلدها",
"."
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Form/Vote.php#L25-L47 |
SlaxWeb/Hooks | src/Service/Definition.php | Definition.register | public function register(\Pimple\Container $container)
{
$this->define();
foreach ($this->hooks as $hookName => $hookDef) {
$hook = $container["newHook.factory"];
$hook->create($hookName, $hookDef);
$container["hooks.service"]->addHook($hook);
}
} | php | public function register(\Pimple\Container $container)
{
$this->define();
foreach ($this->hooks as $hookName => $hookDef) {
$hook = $container["newHook.factory"];
$hook->create($hookName, $hookDef);
$container["hooks.service"]->addHook($hook);
}
} | [
"public",
"function",
"register",
"(",
"\\",
"Pimple",
"\\",
"Container",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"define",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"hooks",
"as",
"$",
"hookName",
"=>",
"$",
"hookDef",
")",
"{",
"$",
"hook",
"=",
"$",
"container",
"[",
"\"newHook.factory\"",
"]",
";",
"$",
"hook",
"->",
"create",
"(",
"$",
"hookName",
",",
"$",
"hookDef",
")",
";",
"$",
"container",
"[",
"\"hooks.service\"",
"]",
"->",
"addHook",
"(",
"$",
"hook",
")",
";",
"}",
"}"
] | Register Provider
Method called by the Pimple DIC when registering. Set container to class
property and call the define method.
@param \Pimple\Container $container DIC
@return void | [
"Register",
"Provider"
] | train | https://github.com/SlaxWeb/Hooks/blob/678f4d5425c27e0dd2a61b68d59bfb2793955b91/src/Service/Definition.php#L35-L43 |
k3ssen/BaseAdminBundle | Security/AbstractVoter.php | AbstractVoter.vote | public function vote(TokenInterface $token, $subject, array $attributes)
{
// abstain vote by default in case none of the attributes are supported
$vote = self::ACCESS_ABSTAIN;
$this->token = $token;
$grantedVotes = 0;
$deniedVotes = 0;
foreach ($attributes as $attribute) {
if (!$this->supports($attribute, $subject)) {
continue;
}
$granted = $this->voteOnAttribute($attribute, $subject);
if ($granted === true) {
$vote = self::ACCESS_GRANTED;
// Using the affirmative strategy, only 1 attribute needs to be granted
if ($this->strategy === AccessDecisionManager::STRATEGY_AFFIRMATIVE) {
break;
}
$grantedVotes++;
}
if ($granted === false) {
$vote = self::ACCESS_DENIED;
// Using the unanimous strategy, only access is denied if there's any denied attribute.
if ($this->strategy === AccessDecisionManager::STRATEGY_UNANIMOUS) {
break;
}
$deniedVotes++;
}
}
$this->token = null;
// Using consensus-strategy, access is granted when there are more votes for granted than there are votes for denied
// see https://symfony.com/doc/4.2/security/voters.html#changing-the-access-decision-strategy
if ($this->strategy === AccessDecisionManager::STRATEGY_CONSENSUS) {
if ($grantedVotes > $deniedVotes) {
$vote = self::ACCESS_GRANTED;
} elseif ($deniedVotes > 0) {
$vote = self::ACCESS_DENIED;
}
}
return $vote;
} | php | public function vote(TokenInterface $token, $subject, array $attributes)
{
// abstain vote by default in case none of the attributes are supported
$vote = self::ACCESS_ABSTAIN;
$this->token = $token;
$grantedVotes = 0;
$deniedVotes = 0;
foreach ($attributes as $attribute) {
if (!$this->supports($attribute, $subject)) {
continue;
}
$granted = $this->voteOnAttribute($attribute, $subject);
if ($granted === true) {
$vote = self::ACCESS_GRANTED;
// Using the affirmative strategy, only 1 attribute needs to be granted
if ($this->strategy === AccessDecisionManager::STRATEGY_AFFIRMATIVE) {
break;
}
$grantedVotes++;
}
if ($granted === false) {
$vote = self::ACCESS_DENIED;
// Using the unanimous strategy, only access is denied if there's any denied attribute.
if ($this->strategy === AccessDecisionManager::STRATEGY_UNANIMOUS) {
break;
}
$deniedVotes++;
}
}
$this->token = null;
// Using consensus-strategy, access is granted when there are more votes for granted than there are votes for denied
// see https://symfony.com/doc/4.2/security/voters.html#changing-the-access-decision-strategy
if ($this->strategy === AccessDecisionManager::STRATEGY_CONSENSUS) {
if ($grantedVotes > $deniedVotes) {
$vote = self::ACCESS_GRANTED;
} elseif ($deniedVotes > 0) {
$vote = self::ACCESS_DENIED;
}
}
return $vote;
} | [
"public",
"function",
"vote",
"(",
"TokenInterface",
"$",
"token",
",",
"$",
"subject",
",",
"array",
"$",
"attributes",
")",
"{",
"// abstain vote by default in case none of the attributes are supported",
"$",
"vote",
"=",
"self",
"::",
"ACCESS_ABSTAIN",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"token",
";",
"$",
"grantedVotes",
"=",
"0",
";",
"$",
"deniedVotes",
"=",
"0",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"attribute",
",",
"$",
"subject",
")",
")",
"{",
"continue",
";",
"}",
"$",
"granted",
"=",
"$",
"this",
"->",
"voteOnAttribute",
"(",
"$",
"attribute",
",",
"$",
"subject",
")",
";",
"if",
"(",
"$",
"granted",
"===",
"true",
")",
"{",
"$",
"vote",
"=",
"self",
"::",
"ACCESS_GRANTED",
";",
"// Using the affirmative strategy, only 1 attribute needs to be granted",
"if",
"(",
"$",
"this",
"->",
"strategy",
"===",
"AccessDecisionManager",
"::",
"STRATEGY_AFFIRMATIVE",
")",
"{",
"break",
";",
"}",
"$",
"grantedVotes",
"++",
";",
"}",
"if",
"(",
"$",
"granted",
"===",
"false",
")",
"{",
"$",
"vote",
"=",
"self",
"::",
"ACCESS_DENIED",
";",
"// Using the unanimous strategy, only access is denied if there's any denied attribute.",
"if",
"(",
"$",
"this",
"->",
"strategy",
"===",
"AccessDecisionManager",
"::",
"STRATEGY_UNANIMOUS",
")",
"{",
"break",
";",
"}",
"$",
"deniedVotes",
"++",
";",
"}",
"}",
"$",
"this",
"->",
"token",
"=",
"null",
";",
"// Using consensus-strategy, access is granted when there are more votes for granted than there are votes for denied",
"// see https://symfony.com/doc/4.2/security/voters.html#changing-the-access-decision-strategy",
"if",
"(",
"$",
"this",
"->",
"strategy",
"===",
"AccessDecisionManager",
"::",
"STRATEGY_CONSENSUS",
")",
"{",
"if",
"(",
"$",
"grantedVotes",
">",
"$",
"deniedVotes",
")",
"{",
"$",
"vote",
"=",
"self",
"::",
"ACCESS_GRANTED",
";",
"}",
"elseif",
"(",
"$",
"deniedVotes",
">",
"0",
")",
"{",
"$",
"vote",
"=",
"self",
"::",
"ACCESS_DENIED",
";",
"}",
"}",
"return",
"$",
"vote",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/k3ssen/BaseAdminBundle/blob/d0af699b097f48d92883713eafd36ee9069460bb/Security/AbstractVoter.php#L25-L66 |
bandama-framework/bandama-framework | src/foundation/controller/Controller.php | Controller.render | public function render($view, $params = array()) {
$viewPath = $this->viewPath;
$viewPath = rtrim($viewPath, '/').'/';
extract($params);
if (is_file($view)) {
require_once($view);
} else if (is_file($viewPath.str_replace(':', '/', $view))) {
require_once($viewPath.str_replace(':', '/', $view));
} else {
echo $view;
}
} | php | public function render($view, $params = array()) {
$viewPath = $this->viewPath;
$viewPath = rtrim($viewPath, '/').'/';
extract($params);
if (is_file($view)) {
require_once($view);
} else if (is_file($viewPath.str_replace(':', '/', $view))) {
require_once($viewPath.str_replace(':', '/', $view));
} else {
echo $view;
}
} | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"viewPath",
"=",
"$",
"this",
"->",
"viewPath",
";",
"$",
"viewPath",
"=",
"rtrim",
"(",
"$",
"viewPath",
",",
"'/'",
")",
".",
"'/'",
";",
"extract",
"(",
"$",
"params",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"view",
")",
")",
"{",
"require_once",
"(",
"$",
"view",
")",
";",
"}",
"else",
"if",
"(",
"is_file",
"(",
"$",
"viewPath",
".",
"str_replace",
"(",
"':'",
",",
"'/'",
",",
"$",
"view",
")",
")",
")",
"{",
"require_once",
"(",
"$",
"viewPath",
".",
"str_replace",
"(",
"':'",
",",
"'/'",
",",
"$",
"view",
")",
")",
";",
"}",
"else",
"{",
"echo",
"$",
"view",
";",
"}",
"}"
] | Render the content of view file or text
@param string View path of view file or text
@param array View parameters
@return string | [
"Render",
"the",
"content",
"of",
"view",
"file",
"or",
"text"
] | train | https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/controller/Controller.php#L39-L50 |
PenoaksDev/Milky-Framework | src/Milky/Config/ConfigurationLoader.php | ConfigurationLoader.loadConfigurationFiles | protected static function loadConfigurationFiles( Framework $fw, Configuration $config )
{
$configPath = $fw->buildPath( '__config' );
foreach ( Finder::create()->files()->in( $configPath ) as $file )
{
$nesting = static::getConfigurationNesting( $file, $configPath );
try
{
if ( ends_with( $file->getFilename(), '.yaml' ) )
$config->set( $nesting . basename( $file->getRealPath(), '.yaml' ), Yaml::parse( file_get_contents( $file ) ) );
if ( ends_with( $file->getFilename(), '.json' ) )
$config->set( $nesting . basename( $file->getRealPath(), '.json' ), json_decode( file_get_contents( $file ) ) );
if ( ends_with( $file->getFilename(), '.php' ) && is_array( $array = include( $file->getRealPath() ) ) )
$config->set( $nesting . basename( $file->getRealPath(), '.php' ), $array );
}
catch ( \Throwable $e )
{
// TODO Pass configuration failures to the ExceptionHandler
throw new \RuntimeException( "Failed to load configuration file [" . $file->getRealPath() . "]: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() );
}
}
} | php | protected static function loadConfigurationFiles( Framework $fw, Configuration $config )
{
$configPath = $fw->buildPath( '__config' );
foreach ( Finder::create()->files()->in( $configPath ) as $file )
{
$nesting = static::getConfigurationNesting( $file, $configPath );
try
{
if ( ends_with( $file->getFilename(), '.yaml' ) )
$config->set( $nesting . basename( $file->getRealPath(), '.yaml' ), Yaml::parse( file_get_contents( $file ) ) );
if ( ends_with( $file->getFilename(), '.json' ) )
$config->set( $nesting . basename( $file->getRealPath(), '.json' ), json_decode( file_get_contents( $file ) ) );
if ( ends_with( $file->getFilename(), '.php' ) && is_array( $array = include( $file->getRealPath() ) ) )
$config->set( $nesting . basename( $file->getRealPath(), '.php' ), $array );
}
catch ( \Throwable $e )
{
// TODO Pass configuration failures to the ExceptionHandler
throw new \RuntimeException( "Failed to load configuration file [" . $file->getRealPath() . "]: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() );
}
}
} | [
"protected",
"static",
"function",
"loadConfigurationFiles",
"(",
"Framework",
"$",
"fw",
",",
"Configuration",
"$",
"config",
")",
"{",
"$",
"configPath",
"=",
"$",
"fw",
"->",
"buildPath",
"(",
"'__config'",
")",
";",
"foreach",
"(",
"Finder",
"::",
"create",
"(",
")",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"configPath",
")",
"as",
"$",
"file",
")",
"{",
"$",
"nesting",
"=",
"static",
"::",
"getConfigurationNesting",
"(",
"$",
"file",
",",
"$",
"configPath",
")",
";",
"try",
"{",
"if",
"(",
"ends_with",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'.yaml'",
")",
")",
"$",
"config",
"->",
"set",
"(",
"$",
"nesting",
".",
"basename",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"'.yaml'",
")",
",",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
";",
"if",
"(",
"ends_with",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'.json'",
")",
")",
"$",
"config",
"->",
"set",
"(",
"$",
"nesting",
".",
"basename",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"'.json'",
")",
",",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
";",
"if",
"(",
"ends_with",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'.php'",
")",
"&&",
"is_array",
"(",
"$",
"array",
"=",
"include",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
")",
")",
"$",
"config",
"->",
"set",
"(",
"$",
"nesting",
".",
"basename",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"'.php'",
")",
",",
"$",
"array",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"// TODO Pass configuration failures to the ExceptionHandler",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Failed to load configuration file [\"",
".",
"$",
"file",
"->",
"getRealPath",
"(",
")",
".",
"\"]: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\" in \"",
".",
"$",
"e",
"->",
"getFile",
"(",
")",
".",
"\" on line \"",
".",
"$",
"e",
"->",
"getLine",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Load the configuration items from all of the files.
@param Framework $fw
@param Configuration $config | [
"Load",
"the",
"configuration",
"items",
"from",
"all",
"of",
"the",
"files",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Config/ConfigurationLoader.php#L58-L82 |
PenoaksDev/Milky-Framework | src/Milky/Config/ConfigurationLoader.php | ConfigurationLoader.create | public static function create( ConfigurationBuilder $builder )
{
// TODO Currently only supports PHP files, need to add optional json and yaml support.
$configPath = Framework::fw()->buildPath( '__config' );
$configFile = $configPath . __ . $builder->key() . ".php";
if ( file_put_contents( $configFile, $builder->toPhp( true ) ) === false || !is_array( $data = include( $configFile ) ) )
{
@unlink( $configFile );
throw new FrameworkException( "Configuration error, either failed to write config file to [" . $configFile . "] or returned data is not an array." );
}
Framework::config()->set( $builder->key(), $data );
} | php | public static function create( ConfigurationBuilder $builder )
{
// TODO Currently only supports PHP files, need to add optional json and yaml support.
$configPath = Framework::fw()->buildPath( '__config' );
$configFile = $configPath . __ . $builder->key() . ".php";
if ( file_put_contents( $configFile, $builder->toPhp( true ) ) === false || !is_array( $data = include( $configFile ) ) )
{
@unlink( $configFile );
throw new FrameworkException( "Configuration error, either failed to write config file to [" . $configFile . "] or returned data is not an array." );
}
Framework::config()->set( $builder->key(), $data );
} | [
"public",
"static",
"function",
"create",
"(",
"ConfigurationBuilder",
"$",
"builder",
")",
"{",
"// TODO Currently only supports PHP files, need to add optional json and yaml support.",
"$",
"configPath",
"=",
"Framework",
"::",
"fw",
"(",
")",
"->",
"buildPath",
"(",
"'__config'",
")",
";",
"$",
"configFile",
"=",
"$",
"configPath",
".",
"__",
".",
"$",
"builder",
"->",
"key",
"(",
")",
".",
"\".php\"",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"configFile",
",",
"$",
"builder",
"->",
"toPhp",
"(",
"true",
")",
")",
"===",
"false",
"||",
"!",
"is_array",
"(",
"$",
"data",
"=",
"include",
"(",
"$",
"configFile",
")",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"configFile",
")",
";",
"throw",
"new",
"FrameworkException",
"(",
"\"Configuration error, either failed to write config file to [\"",
".",
"$",
"configFile",
".",
"\"] or returned data is not an array.\"",
")",
";",
"}",
"Framework",
"::",
"config",
"(",
")",
"->",
"set",
"(",
"$",
"builder",
"->",
"key",
"(",
")",
",",
"$",
"data",
")",
";",
"}"
] | Saves a builder to the filesystem
@param ConfigurationBuilder $builder
@throws FrameworkException | [
"Saves",
"a",
"builder",
"to",
"the",
"filesystem"
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Config/ConfigurationLoader.php#L108-L123 |
theomessin/ts-framework | src/Adapter/ServerQuery/Reply.php | Reply.fetchError | protected function fetchError($err)
{
$cells = $err->section(Teamspeak::SEPARATOR_CELL, 1, 3);
foreach ($cells->split(Teamspeak::SEPARATOR_CELL) as $pair) {
list($ident, $value) = $pair->split(Teamspeak::SEPARATOR_PAIR);
$this->err[$ident->toString()] = $value->isInt() ? $value->toInt() : $value->unescape();
}
Signal::getInstance()->emit("notifyError", $this);
if ($this->getErrorProperty("id", 0x00) != 0x00 && $this->exp) {
if ($permid = $this->getErrorProperty("failed_permid")) {
if ($permsid = key($this->con->request("permget permid=" . $permid, false)->toAssocArray("permsid"))) {
$suffix = " (failed on " . $permsid . ")";
} else {
$suffix = " (failed on " . $this->cmd->section(
Teamspeak::SEPARATOR_CELL
) . " " . $permid . "/0x" . strtoupper(dechex($permid)) . ")";
}
} elseif ($details = $this->getErrorProperty("extra_msg")) {
$suffix = " (" . trim($details) . ")";
} else {
$suffix = "";
}
throw new Ts3Exception(
$this->getErrorProperty("msg") . $suffix,
$this->getErrorProperty("id")
);
}
} | php | protected function fetchError($err)
{
$cells = $err->section(Teamspeak::SEPARATOR_CELL, 1, 3);
foreach ($cells->split(Teamspeak::SEPARATOR_CELL) as $pair) {
list($ident, $value) = $pair->split(Teamspeak::SEPARATOR_PAIR);
$this->err[$ident->toString()] = $value->isInt() ? $value->toInt() : $value->unescape();
}
Signal::getInstance()->emit("notifyError", $this);
if ($this->getErrorProperty("id", 0x00) != 0x00 && $this->exp) {
if ($permid = $this->getErrorProperty("failed_permid")) {
if ($permsid = key($this->con->request("permget permid=" . $permid, false)->toAssocArray("permsid"))) {
$suffix = " (failed on " . $permsid . ")";
} else {
$suffix = " (failed on " . $this->cmd->section(
Teamspeak::SEPARATOR_CELL
) . " " . $permid . "/0x" . strtoupper(dechex($permid)) . ")";
}
} elseif ($details = $this->getErrorProperty("extra_msg")) {
$suffix = " (" . trim($details) . ")";
} else {
$suffix = "";
}
throw new Ts3Exception(
$this->getErrorProperty("msg") . $suffix,
$this->getErrorProperty("id")
);
}
} | [
"protected",
"function",
"fetchError",
"(",
"$",
"err",
")",
"{",
"$",
"cells",
"=",
"$",
"err",
"->",
"section",
"(",
"Teamspeak",
"::",
"SEPARATOR_CELL",
",",
"1",
",",
"3",
")",
";",
"foreach",
"(",
"$",
"cells",
"->",
"split",
"(",
"Teamspeak",
"::",
"SEPARATOR_CELL",
")",
"as",
"$",
"pair",
")",
"{",
"list",
"(",
"$",
"ident",
",",
"$",
"value",
")",
"=",
"$",
"pair",
"->",
"split",
"(",
"Teamspeak",
"::",
"SEPARATOR_PAIR",
")",
";",
"$",
"this",
"->",
"err",
"[",
"$",
"ident",
"->",
"toString",
"(",
")",
"]",
"=",
"$",
"value",
"->",
"isInt",
"(",
")",
"?",
"$",
"value",
"->",
"toInt",
"(",
")",
":",
"$",
"value",
"->",
"unescape",
"(",
")",
";",
"}",
"Signal",
"::",
"getInstance",
"(",
")",
"->",
"emit",
"(",
"\"notifyError\"",
",",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getErrorProperty",
"(",
"\"id\"",
",",
"0x00",
")",
"!=",
"0x00",
"&&",
"$",
"this",
"->",
"exp",
")",
"{",
"if",
"(",
"$",
"permid",
"=",
"$",
"this",
"->",
"getErrorProperty",
"(",
"\"failed_permid\"",
")",
")",
"{",
"if",
"(",
"$",
"permsid",
"=",
"key",
"(",
"$",
"this",
"->",
"con",
"->",
"request",
"(",
"\"permget permid=\"",
".",
"$",
"permid",
",",
"false",
")",
"->",
"toAssocArray",
"(",
"\"permsid\"",
")",
")",
")",
"{",
"$",
"suffix",
"=",
"\" (failed on \"",
".",
"$",
"permsid",
".",
"\")\"",
";",
"}",
"else",
"{",
"$",
"suffix",
"=",
"\" (failed on \"",
".",
"$",
"this",
"->",
"cmd",
"->",
"section",
"(",
"Teamspeak",
"::",
"SEPARATOR_CELL",
")",
".",
"\" \"",
".",
"$",
"permid",
".",
"\"/0x\"",
".",
"strtoupper",
"(",
"dechex",
"(",
"$",
"permid",
")",
")",
".",
"\")\"",
";",
"}",
"}",
"elseif",
"(",
"$",
"details",
"=",
"$",
"this",
"->",
"getErrorProperty",
"(",
"\"extra_msg\"",
")",
")",
"{",
"$",
"suffix",
"=",
"\" (\"",
".",
"trim",
"(",
"$",
"details",
")",
".",
"\")\"",
";",
"}",
"else",
"{",
"$",
"suffix",
"=",
"\"\"",
";",
"}",
"throw",
"new",
"Ts3Exception",
"(",
"$",
"this",
"->",
"getErrorProperty",
"(",
"\"msg\"",
")",
".",
"$",
"suffix",
",",
"$",
"this",
"->",
"getErrorProperty",
"(",
"\"id\"",
")",
")",
";",
"}",
"}"
] | Parses a ServerQuery error and throws a Ts3Exception object if
there's an error.
@param StringHelper|string $err
@throws Ts3Exception
@return void | [
"Parses",
"a",
"ServerQuery",
"error",
"and",
"throws",
"a",
"Ts3Exception",
"object",
"if",
"there",
"s",
"an",
"error",
"."
] | train | https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Adapter/ServerQuery/Reply.php#L287-L319 |
theomessin/ts-framework | src/Adapter/ServerQuery/Reply.php | Reply.fetchReply | protected function fetchReply($rpl)
{
foreach ($rpl as $key => $val) {
if ($val->startsWith(Teamspeak::GREET)) {
unset($rpl[$key]);
} elseif ($val->startsWith(Teamspeak::EVENT)) {
$this->evt[] = new Event($rpl[$key], $this->con);
unset($rpl[$key]);
}
}
$this->rpl = new StringHelper(implode(Teamspeak::SEPARATOR_LIST, $rpl));
} | php | protected function fetchReply($rpl)
{
foreach ($rpl as $key => $val) {
if ($val->startsWith(Teamspeak::GREET)) {
unset($rpl[$key]);
} elseif ($val->startsWith(Teamspeak::EVENT)) {
$this->evt[] = new Event($rpl[$key], $this->con);
unset($rpl[$key]);
}
}
$this->rpl = new StringHelper(implode(Teamspeak::SEPARATOR_LIST, $rpl));
} | [
"protected",
"function",
"fetchReply",
"(",
"$",
"rpl",
")",
"{",
"foreach",
"(",
"$",
"rpl",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"->",
"startsWith",
"(",
"Teamspeak",
"::",
"GREET",
")",
")",
"{",
"unset",
"(",
"$",
"rpl",
"[",
"$",
"key",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"val",
"->",
"startsWith",
"(",
"Teamspeak",
"::",
"EVENT",
")",
")",
"{",
"$",
"this",
"->",
"evt",
"[",
"]",
"=",
"new",
"Event",
"(",
"$",
"rpl",
"[",
"$",
"key",
"]",
",",
"$",
"this",
"->",
"con",
")",
";",
"unset",
"(",
"$",
"rpl",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"rpl",
"=",
"new",
"StringHelper",
"(",
"implode",
"(",
"Teamspeak",
"::",
"SEPARATOR_LIST",
",",
"$",
"rpl",
")",
")",
";",
"}"
] | Parses a ServerQuery reply and creates a String object.
@param array $rpl
@return void | [
"Parses",
"a",
"ServerQuery",
"reply",
"and",
"creates",
"a",
"String",
"object",
"."
] | train | https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Adapter/ServerQuery/Reply.php#L327-L339 |
MasterkeyInformatica/browser-kit | Response.php | Response.getHeader | public function getHeader($header, $first = true)
{
$normalizedHeader = str_replace('-', '_', strtolower($header));
foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
if ($first) {
return is_array($value) ? (count($value) ? $value[0] : '') : $value;
}
return is_array($value) ? $value : array($value);
}
}
return $first ? null : array();
} | php | public function getHeader($header, $first = true)
{
$normalizedHeader = str_replace('-', '_', strtolower($header));
foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
if ($first) {
return is_array($value) ? (count($value) ? $value[0] : '') : $value;
}
return is_array($value) ? $value : array($value);
}
}
return $first ? null : array();
} | [
"public",
"function",
"getHeader",
"(",
"$",
"header",
",",
"$",
"first",
"=",
"true",
")",
"{",
"$",
"normalizedHeader",
"=",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"strtolower",
"(",
"$",
"header",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"strtolower",
"(",
"$",
"key",
")",
")",
"===",
"$",
"normalizedHeader",
")",
"{",
"if",
"(",
"$",
"first",
")",
"{",
"return",
"is_array",
"(",
"$",
"value",
")",
"?",
"(",
"count",
"(",
"$",
"value",
")",
"?",
"$",
"value",
"[",
"0",
"]",
":",
"''",
")",
":",
"$",
"value",
";",
"}",
"return",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"array",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"first",
"?",
"null",
":",
"array",
"(",
")",
";",
"}"
] | Gets a response header.
@param string $header The header name
@param bool $first Whether to return the first value or all header values
@return string|array The first header value if $first is true, an array of values otherwise | [
"Gets",
"a",
"response",
"header",
"."
] | train | https://github.com/MasterkeyInformatica/browser-kit/blob/fd735ad31c00af54d5c060d01218aa48308557f7/Response.php#L114-L128 |
recca0120/lodash-php | src/JString/Extensions/Chinese.php | Chinese.toNumber | public function toNumber()
{
$sum = 0;
$matches = [];
if ((bool) preg_match_all('/(?P<number>[一二三四五六七八九]+)?(?P<unit>[萬千百十])?/u', $this->subject, $matches, PREG_SET_ORDER) === false) {
return $sum;
}
$sum = 0;
foreach ((array) $matches as $token) {
$unit = empty($token['unit']) === false ? $token['unit'] : '個';
$unit = static::$numberUnits[$unit];
if (empty($token['number']) === true) {
$sum = ($sum === 0 ? 1 : $sum) * $unit;
continue;
}
$number = $token['number'];
$number = strtr($number, [
'零' => 0,
'一' => 1,
'二' => 2,
'三' => 3,
'四' => 4,
'五' => 5,
'六' => 6,
'七' => 7,
'八' => 8,
'九' => 9,
]);
if ($unit >= 10000) {
$sum = $sum * $unit;
}
$sum += ($number * $unit);
}
return $sum;
} | php | public function toNumber()
{
$sum = 0;
$matches = [];
if ((bool) preg_match_all('/(?P<number>[一二三四五六七八九]+)?(?P<unit>[萬千百十])?/u', $this->subject, $matches, PREG_SET_ORDER) === false) {
return $sum;
}
$sum = 0;
foreach ((array) $matches as $token) {
$unit = empty($token['unit']) === false ? $token['unit'] : '個';
$unit = static::$numberUnits[$unit];
if (empty($token['number']) === true) {
$sum = ($sum === 0 ? 1 : $sum) * $unit;
continue;
}
$number = $token['number'];
$number = strtr($number, [
'零' => 0,
'一' => 1,
'二' => 2,
'三' => 3,
'四' => 4,
'五' => 5,
'六' => 6,
'七' => 7,
'八' => 8,
'九' => 9,
]);
if ($unit >= 10000) {
$sum = $sum * $unit;
}
$sum += ($number * $unit);
}
return $sum;
} | [
"public",
"function",
"toNumber",
"(",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"bool",
")",
"preg_match_all",
"(",
"'/(?P<number>[一二三四五六七八九]+)?(?P<unit>[萬千百十])?/u', $this->subject, $matches",
",",
"P",
"REG_",
"SE",
"T_ORDER",
")",
"=",
"== fals",
"e",
" {",
"",
"",
"",
"",
"",
"return",
"$",
"sum",
";",
"}",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"matches",
"as",
"$",
"token",
")",
"{",
"$",
"unit",
"=",
"empty",
"(",
"$",
"token",
"[",
"'unit'",
"]",
")",
"===",
"false",
"?",
"$",
"token",
"[",
"'unit'",
"]",
":",
"'個';",
"",
"$",
"unit",
"=",
"static",
"::",
"$",
"numberUnits",
"[",
"$",
"unit",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"token",
"[",
"'number'",
"]",
")",
"===",
"true",
")",
"{",
"$",
"sum",
"=",
"(",
"$",
"sum",
"===",
"0",
"?",
"1",
":",
"$",
"sum",
")",
"*",
"$",
"unit",
";",
"continue",
";",
"}",
"$",
"number",
"=",
"$",
"token",
"[",
"'number'",
"]",
";",
"$",
"number",
"=",
"strtr",
"(",
"$",
"number",
",",
"[",
"'零' =",
" 0",
"",
"",
"'一' =",
" 1",
"",
"",
"'二' =",
" 2",
"",
"",
"'三' =",
" 3",
"",
"",
"'四' =",
" 4",
"",
"",
"'五' =",
" 5",
"",
"",
"'六' =",
" 6",
"",
"",
"'七' =",
" 7",
"",
"",
"'八' =",
" 8",
"",
"",
"'九' =",
" 9",
"",
"",
"]",
")",
";",
"if",
"(",
"$",
"unit",
">=",
"10000",
")",
"{",
"$",
"sum",
"=",
"$",
"sum",
"*",
"$",
"unit",
";",
"}",
"$",
"sum",
"+=",
"(",
"$",
"number",
"*",
"$",
"unit",
")",
";",
"}",
"return",
"$",
"sum",
";",
"}"
] | toNumber.
@return int | [
"toNumber",
"."
] | train | https://github.com/recca0120/lodash-php/blob/65f8c80accfc2b087abf6d0590a5bd9fd15b467d/src/JString/Extensions/Chinese.php#L42-L82 |
eliasis-framework/complement | src/Traits/ComplementAction.php | ComplementAction.getAction | public function getAction($state)
{
$type = self::getType('strtolower', false);
$action = self::$defaultAction[$type];
if (isset($this->states['action'])) {
$action = $this->states['action'];
}
return ($state === 'uninstalled') ? '' : $action;
} | php | public function getAction($state)
{
$type = self::getType('strtolower', false);
$action = self::$defaultAction[$type];
if (isset($this->states['action'])) {
$action = $this->states['action'];
}
return ($state === 'uninstalled') ? '' : $action;
} | [
"public",
"function",
"getAction",
"(",
"$",
"state",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"getType",
"(",
"'strtolower'",
",",
"false",
")",
";",
"$",
"action",
"=",
"self",
"::",
"$",
"defaultAction",
"[",
"$",
"type",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"states",
"[",
"'action'",
"]",
")",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"states",
"[",
"'action'",
"]",
";",
"}",
"return",
"(",
"$",
"state",
"===",
"'uninstalled'",
")",
"?",
"''",
":",
"$",
"action",
";",
"}"
] | Get complement action.
@param string $state → complement state
@uses \Eliasis\Complement\ComplementState->$states
@uses \Eliasis\Complement\Traits\ComplementHandler::getType()
@return string → complement action | [
"Get",
"complement",
"action",
"."
] | train | https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Traits/ComplementAction.php#L55-L65 |
eliasis-framework/complement | src/Traits/ComplementAction.php | ComplementAction.doAction | public function doAction($action)
{
$controller = $this->getOption('hooks-controller');
$instance = $this->getControllerInstance($controller);
if (is_object($instance) && method_exists($instance, $action)) {
$response = call_user_func([$instance, $action]);
}
$this->setAction('');
return isset($response);
} | php | public function doAction($action)
{
$controller = $this->getOption('hooks-controller');
$instance = $this->getControllerInstance($controller);
if (is_object($instance) && method_exists($instance, $action)) {
$response = call_user_func([$instance, $action]);
}
$this->setAction('');
return isset($response);
} | [
"public",
"function",
"doAction",
"(",
"$",
"action",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'hooks-controller'",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"getControllerInstance",
"(",
"$",
"controller",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"instance",
")",
"&&",
"method_exists",
"(",
"$",
"instance",
",",
"$",
"action",
")",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"[",
"$",
"instance",
",",
"$",
"action",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setAction",
"(",
"''",
")",
";",
"return",
"isset",
"(",
"$",
"response",
")",
";",
"}"
] | Execute action hook.
@param string $action → action hook to execute
@uses \Eliasis\Complement\Traits\ComplementAction::setAction()
@uses \Eliasis\Complement\Traits\ComplementHandler::getOption()
@return bool | [
"Execute",
"action",
"hook",
"."
] | train | https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Traits/ComplementAction.php#L96-L108 |
eliasis-framework/complement | src/Traits/ComplementAction.php | ComplementAction.addActions | private function addActions()
{
if (isset($this->complement['hooks'])) {
Hook::getInstance(App::getCurrentID());
return Hook::addActions($this->complement['hooks']);
}
return false;
} | php | private function addActions()
{
if (isset($this->complement['hooks'])) {
Hook::getInstance(App::getCurrentID());
return Hook::addActions($this->complement['hooks']);
}
return false;
} | [
"private",
"function",
"addActions",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"complement",
"[",
"'hooks'",
"]",
")",
")",
"{",
"Hook",
"::",
"getInstance",
"(",
"App",
"::",
"getCurrentID",
"(",
")",
")",
";",
"return",
"Hook",
"::",
"addActions",
"(",
"$",
"this",
"->",
"complement",
"[",
"'hooks'",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Add complement action hooks.
@uses \Eliasis\Framework\App::getCurrentID()
@uses \Eliasis\Complement\Complement->$complement
@uses \Josantonius\Hook\Hook::getInstance
@uses \Josantonius\Hook\Hook::addActions | [
"Add",
"complement",
"action",
"hooks",
"."
] | train | https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Traits/ComplementAction.php#L118-L127 |
eliasis-framework/complement | src/Traits/ComplementAction.php | ComplementAction.doActions | private function doActions($action)
{
$type = self::getType('strtolower', false);
Hook::getInstance(App::getCurrentID());
Hook::doAction($type . '-load');
Hook::doAction('after-loading-' . $this->complement['slug'] . '-' . $type);
if (in_array($action, self::$hooks, true)) {
$this->doAction($action);
}
} | php | private function doActions($action)
{
$type = self::getType('strtolower', false);
Hook::getInstance(App::getCurrentID());
Hook::doAction($type . '-load');
Hook::doAction('after-loading-' . $this->complement['slug'] . '-' . $type);
if (in_array($action, self::$hooks, true)) {
$this->doAction($action);
}
} | [
"private",
"function",
"doActions",
"(",
"$",
"action",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"getType",
"(",
"'strtolower'",
",",
"false",
")",
";",
"Hook",
"::",
"getInstance",
"(",
"App",
"::",
"getCurrentID",
"(",
")",
")",
";",
"Hook",
"::",
"doAction",
"(",
"$",
"type",
".",
"'-load'",
")",
";",
"Hook",
"::",
"doAction",
"(",
"'after-loading-'",
".",
"$",
"this",
"->",
"complement",
"[",
"'slug'",
"]",
".",
"'-'",
".",
"$",
"type",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"action",
",",
"self",
"::",
"$",
"hooks",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"doAction",
"(",
"$",
"action",
")",
";",
"}",
"}"
] | Execute action hooks.
@param string $action → action hook to execute
@uses \Eliasis\Framework\App::getCurrentID()
@uses \Josantonius\Hook\Hook::getInstance
@uses \Josantonius\Hook\Hook::doAction
@uses \Eliasis\Complement\Traits\ComplementHandler::getType() | [
"Execute",
"action",
"hooks",
"."
] | train | https://github.com/eliasis-framework/complement/blob/d50e92cf01600ff4573bf1761c312069044748c3/src/Traits/ComplementAction.php#L139-L150 |
MichaelJ2324/PHP-REST-Client | src/Auth/Abstracts/AbstractBasicController.php | AbstractBasicController.getAuthHeaderValue | protected function getAuthHeaderValue()
{
$value = "";
if (isset($this->credentials['username']) && isset($this->credentials['password'])){
$value = $this->credentials['username'].":".$this->credentials['password'];
$value = base64_encode($value);
}
return static::$_AUTH_TYPE." ".$value;
} | php | protected function getAuthHeaderValue()
{
$value = "";
if (isset($this->credentials['username']) && isset($this->credentials['password'])){
$value = $this->credentials['username'].":".$this->credentials['password'];
$value = base64_encode($value);
}
return static::$_AUTH_TYPE." ".$value;
} | [
"protected",
"function",
"getAuthHeaderValue",
"(",
")",
"{",
"$",
"value",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"'username'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"'password'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"credentials",
"[",
"'username'",
"]",
".",
"\":\"",
".",
"$",
"this",
"->",
"credentials",
"[",
"'password'",
"]",
";",
"$",
"value",
"=",
"base64_encode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"static",
"::",
"$",
"_AUTH_TYPE",
".",
"\" \"",
".",
"$",
"value",
";",
"}"
] | Parse the Credentials or Token to build out the Auth Header Value
@return string | [
"Parse",
"the",
"Credentials",
"or",
"Token",
"to",
"build",
"out",
"the",
"Auth",
"Header",
"Value"
] | train | https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Auth/Abstracts/AbstractBasicController.php#L34-L42 |
zhaoxianfang/tools | src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php | ResolveChildDefinitionsPass.resolveDefinition | private function resolveDefinition(ChildDefinition $definition)
{
try {
return $this->doResolveDefinition($definition);
} catch (ExceptionInterface $e) {
$r = new \ReflectionProperty($e, 'message');
$r->setAccessible(true);
$r->setValue($e, sprintf('Service "%s": %s', $this->currentId, $e->getMessage()));
throw $e;
}
} | php | private function resolveDefinition(ChildDefinition $definition)
{
try {
return $this->doResolveDefinition($definition);
} catch (ExceptionInterface $e) {
$r = new \ReflectionProperty($e, 'message');
$r->setAccessible(true);
$r->setValue($e, sprintf('Service "%s": %s', $this->currentId, $e->getMessage()));
throw $e;
}
} | [
"private",
"function",
"resolveDefinition",
"(",
"ChildDefinition",
"$",
"definition",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"doResolveDefinition",
"(",
"$",
"definition",
")",
";",
"}",
"catch",
"(",
"ExceptionInterface",
"$",
"e",
")",
"{",
"$",
"r",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"e",
",",
"'message'",
")",
";",
"$",
"r",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"r",
"->",
"setValue",
"(",
"$",
"e",
",",
"sprintf",
"(",
"'Service \"%s\": %s'",
",",
"$",
"this",
"->",
"currentId",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Resolves the definition.
@return Definition
@throws RuntimeException When the definition is invalid | [
"Resolves",
"the",
"definition",
"."
] | train | https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php#L55-L66 |
apioo/psx-validate | src/Filter/ArrayFilter.php | ArrayFilter.apply | public function apply($value)
{
$data = array();
$modified = false;
if (is_array($value)) {
foreach ($value as $key => $val) {
$result = $this->filter->apply($val);
if ($result === false) {
return false;
} elseif ($result === true) {
$data[$key] = $val;
} else {
$modified = true;
$data[$key] = $result;
}
}
} else {
return false;
}
return $modified ? $data : true;
} | php | public function apply($value)
{
$data = array();
$modified = false;
if (is_array($value)) {
foreach ($value as $key => $val) {
$result = $this->filter->apply($val);
if ($result === false) {
return false;
} elseif ($result === true) {
$data[$key] = $val;
} else {
$modified = true;
$data[$key] = $result;
}
}
} else {
return false;
}
return $modified ? $data : true;
} | [
"public",
"function",
"apply",
"(",
"$",
"value",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"modified",
"=",
"false",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"filter",
"->",
"apply",
"(",
"$",
"val",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"else",
"{",
"$",
"modified",
"=",
"true",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"modified",
"?",
"$",
"data",
":",
"true",
";",
"}"
] | Returns true if all values in $value apply to the filter. If the parent
filter has changed an value the modified array gets returned
@param mixed $value
@return boolean | [
"Returns",
"true",
"if",
"all",
"values",
"in",
"$value",
"apply",
"to",
"the",
"filter",
".",
"If",
"the",
"parent",
"filter",
"has",
"changed",
"an",
"value",
"the",
"modified",
"array",
"gets",
"returned"
] | train | https://github.com/apioo/psx-validate/blob/4860c6a2c7f7ca52d3bd6d7e6ec7d6a7ddcfd83d/src/Filter/ArrayFilter.php#L49-L73 |
randomhost/image | src/php/Text/Decorator/Generic.php | Generic.insertText | public function insertText($xPosition, $yPosition, $text)
{
return $this->text->insertText($xPosition, $yPosition, $text);
} | php | public function insertText($xPosition, $yPosition, $text)
{
return $this->text->insertText($xPosition, $yPosition, $text);
} | [
"public",
"function",
"insertText",
"(",
"$",
"xPosition",
",",
"$",
"yPosition",
",",
"$",
"text",
")",
"{",
"return",
"$",
"this",
"->",
"text",
"->",
"insertText",
"(",
"$",
"xPosition",
",",
"$",
"yPosition",
",",
"$",
"text",
")",
";",
"}"
] | Renders the given text onto the image resource, using the given coordinates.
@param int $xPosition The x-ordinate.
@param int $yPosition The y-ordinate position of the fonts baseline.
@param string $text The text string in UTF-8 encoding.
@return $this;
@throws \RuntimeException Thrown if $this->image is not a valid image
resource or the font file isn't set. | [
"Renders",
"the",
"given",
"text",
"onto",
"the",
"image",
"resource",
"using",
"the",
"given",
"coordinates",
"."
] | train | https://github.com/randomhost/image/blob/bd669ba6b50fd2bbbe50c4ef06235b111a8a30b0/src/php/Text/Decorator/Generic.php#L137-L140 |
randomhost/image | src/php/Text/Decorator/Generic.php | Generic.providesMethod | public function providesMethod($name)
{
if (method_exists($this, $name)) {
return true;
}
if ($this->text instanceof Generic) {
return $this->text->providesMethod($name);
}
return false;
} | php | public function providesMethod($name)
{
if (method_exists($this, $name)) {
return true;
}
if ($this->text instanceof Generic) {
return $this->text->providesMethod($name);
}
return false;
} | [
"public",
"function",
"providesMethod",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"text",
"instanceof",
"Generic",
")",
"{",
"return",
"$",
"this",
"->",
"text",
"->",
"providesMethod",
"(",
"$",
"name",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns if the given method is implemented by one of the decorators.
@param string $name Method name.
@return bool | [
"Returns",
"if",
"the",
"given",
"method",
"is",
"implemented",
"by",
"one",
"of",
"the",
"decorators",
"."
] | train | https://github.com/randomhost/image/blob/bd669ba6b50fd2bbbe50c4ef06235b111a8a30b0/src/php/Text/Decorator/Generic.php#L149-L158 |
waiter-coders/core | src/DB/Query.php | Query.fetchRow | public function fetchRow()
{
$this->limit = 1;
list($sql, $params) = $this->generateQuery();
return Database::connection($this->connection)->fetchRow($sql, $params);
} | php | public function fetchRow()
{
$this->limit = 1;
list($sql, $params) = $this->generateQuery();
return Database::connection($this->connection)->fetchRow($sql, $params);
} | [
"public",
"function",
"fetchRow",
"(",
")",
"{",
"$",
"this",
"->",
"limit",
"=",
"1",
";",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"generateQuery",
"(",
")",
";",
"return",
"Database",
"::",
"connection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"fetchRow",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"}"
] | /*
获取数据的相关方法 | [
"/",
"*",
"获取数据的相关方法"
] | train | https://github.com/waiter-coders/core/blob/6850fe73edede9564f29c42d78fa49c6866368ae/src/DB/Query.php#L86-L91 |
waiter-coders/core | src/DB/Query.php | Query.insert | public function insert($data)
{
$columns = implode(',', array_keys($data));
$values = implode(',', array_fill(0, count($data), '?'));
$sql = sprintf('insert into %s (%s) values (%s)', $this->mainTable, $columns, $values);
Database::connection($this->connection)->execute($sql, array_values($data));
return Database::connection($this->connection)->lastInsertId();
} | php | public function insert($data)
{
$columns = implode(',', array_keys($data));
$values = implode(',', array_fill(0, count($data), '?'));
$sql = sprintf('insert into %s (%s) values (%s)', $this->mainTable, $columns, $values);
Database::connection($this->connection)->execute($sql, array_values($data));
return Database::connection($this->connection)->lastInsertId();
} | [
"public",
"function",
"insert",
"(",
"$",
"data",
")",
"{",
"$",
"columns",
"=",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"$",
"values",
"=",
"implode",
"(",
"','",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"data",
")",
",",
"'?'",
")",
")",
";",
"$",
"sql",
"=",
"sprintf",
"(",
"'insert into %s (%s) values (%s)'",
",",
"$",
"this",
"->",
"mainTable",
",",
"$",
"columns",
",",
"$",
"values",
")",
";",
"Database",
"::",
"connection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"execute",
"(",
"$",
"sql",
",",
"array_values",
"(",
"$",
"data",
")",
")",
";",
"return",
"Database",
"::",
"connection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"lastInsertId",
"(",
")",
";",
"}"
] | /*
操作数据的相关方法 | [
"/",
"*",
"操作数据的相关方法"
] | train | https://github.com/waiter-coders/core/blob/6850fe73edede9564f29c42d78fa49c6866368ae/src/DB/Query.php#L195-L202 |
netbull/CoreBundle | DependencyInjection/NetBullCoreExtension.php | NetBullCoreExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('netbull_core.js_routes_path', $config['js_routes_path']);
$container->setParameter('netbull_core.js_type', $config['js_type']);
// Make manifest parameter optional
if (!$container->hasParameter('manifest')) {
$container->setParameter('manifest', []);
}
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
// set parameters with the default settings so they'll be available in the service definition yml
$varNames = ['minimum_input_length', 'page_limit', 'allow_clear', 'delay', 'language', 'cache'];
if (!empty($config['form_types']) && !empty($config['form_types']['ajax'])) {
foreach($varNames as $varName) {
$container->setParameter('netbull_core.form_types.ajax.' . $varName, $config['form_types']['ajax'][$varName]);
}
}
$loader->load('forms.yaml');
} | php | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('netbull_core.js_routes_path', $config['js_routes_path']);
$container->setParameter('netbull_core.js_type', $config['js_type']);
// Make manifest parameter optional
if (!$container->hasParameter('manifest')) {
$container->setParameter('manifest', []);
}
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
// set parameters with the default settings so they'll be available in the service definition yml
$varNames = ['minimum_input_length', 'page_limit', 'allow_clear', 'delay', 'language', 'cache'];
if (!empty($config['form_types']) && !empty($config['form_types']['ajax'])) {
foreach($varNames as $varName) {
$container->setParameter('netbull_core.form_types.ajax.' . $varName, $config['form_types']['ajax'][$varName]);
}
}
$loader->load('forms.yaml');
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'netbull_core.js_routes_path'",
",",
"$",
"config",
"[",
"'js_routes_path'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'netbull_core.js_type'",
",",
"$",
"config",
"[",
"'js_type'",
"]",
")",
";",
"// Make manifest parameter optional",
"if",
"(",
"!",
"$",
"container",
"->",
"hasParameter",
"(",
"'manifest'",
")",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"'manifest'",
",",
"[",
"]",
")",
";",
"}",
"$",
"loader",
"=",
"new",
"Loader",
"\\",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.yaml'",
")",
";",
"// set parameters with the default settings so they'll be available in the service definition yml",
"$",
"varNames",
"=",
"[",
"'minimum_input_length'",
",",
"'page_limit'",
",",
"'allow_clear'",
",",
"'delay'",
",",
"'language'",
",",
"'cache'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'form_types'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'form_types'",
"]",
"[",
"'ajax'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"varNames",
"as",
"$",
"varName",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"'netbull_core.form_types.ajax.'",
".",
"$",
"varName",
",",
"$",
"config",
"[",
"'form_types'",
"]",
"[",
"'ajax'",
"]",
"[",
"$",
"varName",
"]",
")",
";",
"}",
"}",
"$",
"loader",
"->",
"load",
"(",
"'forms.yaml'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/DependencyInjection/NetBullCoreExtension.php#L19-L44 |
fridge-project/dbal | src/Fridge/DBAL/Driver/AbstractDriver.php | AbstractDriver.getPlatform | public function getPlatform()
{
if ($this->platform === null) {
$this->platform = $this->createPlatform();
}
return $this->platform;
} | php | public function getPlatform()
{
if ($this->platform === null) {
$this->platform = $this->createPlatform();
}
return $this->platform;
} | [
"public",
"function",
"getPlatform",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"platform",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"platform",
"=",
"$",
"this",
"->",
"createPlatform",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"platform",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Driver/AbstractDriver.php#L48-L55 |
fridge-project/dbal | src/Fridge/DBAL/Driver/AbstractDriver.php | AbstractDriver.getSchemaManager | public function getSchemaManager(ConnectionInterface $connection)
{
if (($this->schemaManager === null) || ($this->schemaManager->getConnection() !== $connection)) {
$this->schemaManager = $this->createSchemaManager($connection);
}
return $this->schemaManager;
} | php | public function getSchemaManager(ConnectionInterface $connection)
{
if (($this->schemaManager === null) || ($this->schemaManager->getConnection() !== $connection)) {
$this->schemaManager = $this->createSchemaManager($connection);
}
return $this->schemaManager;
} | [
"public",
"function",
"getSchemaManager",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"schemaManager",
"===",
"null",
")",
"||",
"(",
"$",
"this",
"->",
"schemaManager",
"->",
"getConnection",
"(",
")",
"!==",
"$",
"connection",
")",
")",
"{",
"$",
"this",
"->",
"schemaManager",
"=",
"$",
"this",
"->",
"createSchemaManager",
"(",
"$",
"connection",
")",
";",
"}",
"return",
"$",
"this",
"->",
"schemaManager",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Driver/AbstractDriver.php#L60-L67 |
975L/ServicesBundle | Service/ServiceSlug.php | ServiceSlug.exists | public function exists(string $object, string $slug)
{
$objects = $this->em
->getRepository($object)
->findAll()
;
foreach ($objects as $object) {
if ($object->getSlug() == $slug) {
return true;
}
}
return false;
} | php | public function exists(string $object, string $slug)
{
$objects = $this->em
->getRepository($object)
->findAll()
;
foreach ($objects as $object) {
if ($object->getSlug() == $slug) {
return true;
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"string",
"$",
"object",
",",
"string",
"$",
"slug",
")",
"{",
"$",
"objects",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"object",
")",
"->",
"findAll",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"->",
"getSlug",
"(",
")",
"==",
"$",
"slug",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/975L/ServicesBundle/blob/f652a00f58b0d49489a36b4a59cda8c95b11dda5/Service/ServiceSlug.php#L44-L58 |
975L/ServicesBundle | Service/ServiceSlug.php | ServiceSlug.match | public function match(string $route, object $object, string $slug)
{
if ($slug !== $object->getSlug()) {
return
$this->router->generate($route, array(
'slug' => $object->getSlug(),
'id' => $object->getId(),
));
}
return null;
} | php | public function match(string $route, object $object, string $slug)
{
if ($slug !== $object->getSlug()) {
return
$this->router->generate($route, array(
'slug' => $object->getSlug(),
'id' => $object->getId(),
));
}
return null;
} | [
"public",
"function",
"match",
"(",
"string",
"$",
"route",
",",
"object",
"$",
"object",
",",
"string",
"$",
"slug",
")",
"{",
"if",
"(",
"$",
"slug",
"!==",
"$",
"object",
"->",
"getSlug",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"route",
",",
"array",
"(",
"'slug'",
"=>",
"$",
"object",
"->",
"getSlug",
"(",
")",
",",
"'id'",
"=>",
"$",
"object",
"->",
"getId",
"(",
")",
",",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/975L/ServicesBundle/blob/f652a00f58b0d49489a36b4a59cda8c95b11dda5/Service/ServiceSlug.php#L63-L74 |
975L/ServicesBundle | Service/ServiceSlug.php | ServiceSlug.slugify | public function slugify(string $object, string $text)
{
$slugify = new Slugify();
$slug = $slugify->slugify($text);
//Checks unicity of slug or adds incremented number
$finalSlug = $slug;
$slugExists = true;
$i = 1;
do {
$slugExists = $this->exists($object, $finalSlug);
if ($slugExists) {
$finalSlug = $slug . '-' . $i++;
}
} while (false !== $slugExists);
return $finalSlug;
} | php | public function slugify(string $object, string $text)
{
$slugify = new Slugify();
$slug = $slugify->slugify($text);
//Checks unicity of slug or adds incremented number
$finalSlug = $slug;
$slugExists = true;
$i = 1;
do {
$slugExists = $this->exists($object, $finalSlug);
if ($slugExists) {
$finalSlug = $slug . '-' . $i++;
}
} while (false !== $slugExists);
return $finalSlug;
} | [
"public",
"function",
"slugify",
"(",
"string",
"$",
"object",
",",
"string",
"$",
"text",
")",
"{",
"$",
"slugify",
"=",
"new",
"Slugify",
"(",
")",
";",
"$",
"slug",
"=",
"$",
"slugify",
"->",
"slugify",
"(",
"$",
"text",
")",
";",
"//Checks unicity of slug or adds incremented number",
"$",
"finalSlug",
"=",
"$",
"slug",
";",
"$",
"slugExists",
"=",
"true",
";",
"$",
"i",
"=",
"1",
";",
"do",
"{",
"$",
"slugExists",
"=",
"$",
"this",
"->",
"exists",
"(",
"$",
"object",
",",
"$",
"finalSlug",
")",
";",
"if",
"(",
"$",
"slugExists",
")",
"{",
"$",
"finalSlug",
"=",
"$",
"slug",
".",
"'-'",
".",
"$",
"i",
"++",
";",
"}",
"}",
"while",
"(",
"false",
"!==",
"$",
"slugExists",
")",
";",
"return",
"$",
"finalSlug",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/975L/ServicesBundle/blob/f652a00f58b0d49489a36b4a59cda8c95b11dda5/Service/ServiceSlug.php#L79-L96 |
larakit/lk-event | src/Event/Event.php | Event.notify | static function notify($event_name, $parameters = [], $subject = null, $desc = null) {
self::register($event_name, $desc);
$event = new \sfEvent($subject, $event_name, $parameters);
self::dispatcher()
->notify($event);
} | php | static function notify($event_name, $parameters = [], $subject = null, $desc = null) {
self::register($event_name, $desc);
$event = new \sfEvent($subject, $event_name, $parameters);
self::dispatcher()
->notify($event);
} | [
"static",
"function",
"notify",
"(",
"$",
"event_name",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"desc",
"=",
"null",
")",
"{",
"self",
"::",
"register",
"(",
"$",
"event_name",
",",
"$",
"desc",
")",
";",
"$",
"event",
"=",
"new",
"\\",
"sfEvent",
"(",
"$",
"subject",
",",
"$",
"event_name",
",",
"$",
"parameters",
")",
";",
"self",
"::",
"dispatcher",
"(",
")",
"->",
"notify",
"(",
"$",
"event",
")",
";",
"}"
] | Уведомляем приложение о событии
@param $event_name
@param array $parameters
@param null $subject | [
"Уведомляем",
"приложение",
"о",
"событии"
] | train | https://github.com/larakit/lk-event/blob/546221059107eccf4b53fefb9b0bef1b0dbbc58f/src/Event/Event.php#L37-L42 |
larakit/lk-event | src/Event/Event.php | Event.notifyUntil | static function notifyUntil($event_name, $parameters = [], $subject = null, $desc = null) {
self::$events[$event_name] = $desc ? $desc : $event_name;
$event = new \sfEvent($subject, $event_name, $parameters);
$event = self::dispatcher()
->notifyUntil($event);
return $event->isProcessed();
} | php | static function notifyUntil($event_name, $parameters = [], $subject = null, $desc = null) {
self::$events[$event_name] = $desc ? $desc : $event_name;
$event = new \sfEvent($subject, $event_name, $parameters);
$event = self::dispatcher()
->notifyUntil($event);
return $event->isProcessed();
} | [
"static",
"function",
"notifyUntil",
"(",
"$",
"event_name",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"desc",
"=",
"null",
")",
"{",
"self",
"::",
"$",
"events",
"[",
"$",
"event_name",
"]",
"=",
"$",
"desc",
"?",
"$",
"desc",
":",
"$",
"event_name",
";",
"$",
"event",
"=",
"new",
"\\",
"sfEvent",
"(",
"$",
"subject",
",",
"$",
"event_name",
",",
"$",
"parameters",
")",
";",
"$",
"event",
"=",
"self",
"::",
"dispatcher",
"(",
")",
"->",
"notifyUntil",
"(",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"isProcessed",
"(",
")",
";",
"}"
] | Уведомляем приложение о событии, ждем запуска хотя бы одного слушателя
Возвращаем логическое значение - был ли запущен хот я бы один слушатель
@param $event_name
@param array $parameters
@param null $subject
@return bool | [
"Уведомляем",
"приложение",
"о",
"событии",
"ждем",
"запуска",
"хотя",
"бы",
"одного",
"слушателя",
"Возвращаем",
"логическое",
"значение",
"-",
"был",
"ли",
"запущен",
"хот",
"я",
"бы",
"один",
"слушатель"
] | train | https://github.com/larakit/lk-event/blob/546221059107eccf4b53fefb9b0bef1b0dbbc58f/src/Event/Event.php#L68-L75 |
larakit/lk-event | src/Event/Event.php | Event.filter | static function filter($event_name, $default = null, $parameters = [], $subject = null, $desc = null) {
self::$events[$event_name] = $desc ? $desc : $event_name;
$event = new \sfEvent($subject, $event_name, $parameters);
self::dispatcher()
->filter($event, $default);
return $event->getReturnValue();
} | php | static function filter($event_name, $default = null, $parameters = [], $subject = null, $desc = null) {
self::$events[$event_name] = $desc ? $desc : $event_name;
$event = new \sfEvent($subject, $event_name, $parameters);
self::dispatcher()
->filter($event, $default);
return $event->getReturnValue();
} | [
"static",
"function",
"filter",
"(",
"$",
"event_name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"desc",
"=",
"null",
")",
"{",
"self",
"::",
"$",
"events",
"[",
"$",
"event_name",
"]",
"=",
"$",
"desc",
"?",
"$",
"desc",
":",
"$",
"event_name",
";",
"$",
"event",
"=",
"new",
"\\",
"sfEvent",
"(",
"$",
"subject",
",",
"$",
"event_name",
",",
"$",
"parameters",
")",
";",
"self",
"::",
"dispatcher",
"(",
")",
"->",
"filter",
"(",
"$",
"event",
",",
"$",
"default",
")",
";",
"return",
"$",
"event",
"->",
"getReturnValue",
"(",
")",
";",
"}"
] | Фильтр по событию
@param $event_name
@param null $default
@param array $parameters
@param null $subject
@return mixed | [
"Фильтр",
"по",
"событию"
] | train | https://github.com/larakit/lk-event/blob/546221059107eccf4b53fefb9b0bef1b0dbbc58f/src/Event/Event.php#L87-L94 |
ezra-obiwale/dSCore | src/Core/RESTEngine.php | RESTEngine.run | public static function run(array $config) {
static::init($config);
static::moduleIsActivated();
$cache = static::canCache();
$name = join('/', static::getUrls());
if ($cache && $out = $cache->fetch($name)) {
echo $out;
}
else {
$controller = static::getControllerClass();
$action = static::getAction();
if (!in_array($action, $controller->getActions())) {
ControllerException::invalidAction($action);
}
$params = static::getParams();
static::authenticate($controller, $action, $params);
$refMethod = new ReflectionMethod($controller, $action . 'Action');
if (count($params) < $refMethod->getNumberOfRequiredParameters()) {
ControllerException::invalidParamCount();
}
$actionRet = call_user_func_array(array($controller, $action . 'Action'), $params);
if (!is_array($actionRet)) {
ControllerException::invalidActionResult();
}
static::terminate();
header('Content-Type: application/json');
die(json_encode($actionRet));
}
} | php | public static function run(array $config) {
static::init($config);
static::moduleIsActivated();
$cache = static::canCache();
$name = join('/', static::getUrls());
if ($cache && $out = $cache->fetch($name)) {
echo $out;
}
else {
$controller = static::getControllerClass();
$action = static::getAction();
if (!in_array($action, $controller->getActions())) {
ControllerException::invalidAction($action);
}
$params = static::getParams();
static::authenticate($controller, $action, $params);
$refMethod = new ReflectionMethod($controller, $action . 'Action');
if (count($params) < $refMethod->getNumberOfRequiredParameters()) {
ControllerException::invalidParamCount();
}
$actionRet = call_user_func_array(array($controller, $action . 'Action'), $params);
if (!is_array($actionRet)) {
ControllerException::invalidActionResult();
}
static::terminate();
header('Content-Type: application/json');
die(json_encode($actionRet));
}
} | [
"public",
"static",
"function",
"run",
"(",
"array",
"$",
"config",
")",
"{",
"static",
"::",
"init",
"(",
"$",
"config",
")",
";",
"static",
"::",
"moduleIsActivated",
"(",
")",
";",
"$",
"cache",
"=",
"static",
"::",
"canCache",
"(",
")",
";",
"$",
"name",
"=",
"join",
"(",
"'/'",
",",
"static",
"::",
"getUrls",
"(",
")",
")",
";",
"if",
"(",
"$",
"cache",
"&&",
"$",
"out",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"name",
")",
")",
"{",
"echo",
"$",
"out",
";",
"}",
"else",
"{",
"$",
"controller",
"=",
"static",
"::",
"getControllerClass",
"(",
")",
";",
"$",
"action",
"=",
"static",
"::",
"getAction",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"action",
",",
"$",
"controller",
"->",
"getActions",
"(",
")",
")",
")",
"{",
"ControllerException",
"::",
"invalidAction",
"(",
"$",
"action",
")",
";",
"}",
"$",
"params",
"=",
"static",
"::",
"getParams",
"(",
")",
";",
"static",
"::",
"authenticate",
"(",
"$",
"controller",
",",
"$",
"action",
",",
"$",
"params",
")",
";",
"$",
"refMethod",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"controller",
",",
"$",
"action",
".",
"'Action'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
"<",
"$",
"refMethod",
"->",
"getNumberOfRequiredParameters",
"(",
")",
")",
"{",
"ControllerException",
"::",
"invalidParamCount",
"(",
")",
";",
"}",
"$",
"actionRet",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"controller",
",",
"$",
"action",
".",
"'Action'",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"actionRet",
")",
")",
"{",
"ControllerException",
"::",
"invalidActionResult",
"(",
")",
";",
"}",
"static",
"::",
"terminate",
"(",
")",
";",
"header",
"(",
"'Content-Type: application/json'",
")",
";",
"die",
"(",
"json_encode",
"(",
"$",
"actionRet",
")",
")",
";",
"}",
"}"
] | Starts the engine
@param array $config
@todo Check caching controller actions | [
"Starts",
"the",
"engine"
] | train | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/RESTEngine.php#L87-L120 |
netbull/CoreBundle | Twig/CoreExtension.php | CoreExtension.buildQueryInputs | public function buildQueryInputs($currentField)
{
$request = $this->requestStack->getCurrentRequest();
$fields = '';
foreach ($request->query->all() as $field => $value) {
// Exclude the current field and the PAGE parameter
if($field !== $currentField && $field !== 'page'){
$fields .= sprintf('<input type="hidden" name="%s" value="%s">', $field, $value);
}
}
return $fields;
} | php | public function buildQueryInputs($currentField)
{
$request = $this->requestStack->getCurrentRequest();
$fields = '';
foreach ($request->query->all() as $field => $value) {
// Exclude the current field and the PAGE parameter
if($field !== $currentField && $field !== 'page'){
$fields .= sprintf('<input type="hidden" name="%s" value="%s">', $field, $value);
}
}
return $fields;
} | [
"public",
"function",
"buildQueryInputs",
"(",
"$",
"currentField",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
";",
"$",
"fields",
"=",
"''",
";",
"foreach",
"(",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"// Exclude the current field and the PAGE parameter",
"if",
"(",
"$",
"field",
"!==",
"$",
"currentField",
"&&",
"$",
"field",
"!==",
"'page'",
")",
"{",
"$",
"fields",
".=",
"sprintf",
"(",
"'<input type=\"hidden\" name=\"%s\" value=\"%s\">'",
",",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"fields",
";",
"}"
] | Build Hidden fields based on the URL parameters
@param $currentField
@return string | [
"Build",
"Hidden",
"fields",
"based",
"on",
"the",
"URL",
"parameters"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Twig/CoreExtension.php#L130-L142 |
netbull/CoreBundle | Twig/CoreExtension.php | CoreExtension.inflect | public function inflect(string $string, $pluralize = 0) : string
{
return ($pluralize) ? Inflect::pluralize($string) : Inflect::singularize($string);
} | php | public function inflect(string $string, $pluralize = 0) : string
{
return ($pluralize) ? Inflect::pluralize($string) : Inflect::singularize($string);
} | [
"public",
"function",
"inflect",
"(",
"string",
"$",
"string",
",",
"$",
"pluralize",
"=",
"0",
")",
":",
"string",
"{",
"return",
"(",
"$",
"pluralize",
")",
"?",
"Inflect",
"::",
"pluralize",
"(",
"$",
"string",
")",
":",
"Inflect",
"::",
"singularize",
"(",
"$",
"string",
")",
";",
"}"
] | Pluralize or Singularize a string
@param string $string
@param int $pluralize
@return string | [
"Pluralize",
"or",
"Singularize",
"a",
"string"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Twig/CoreExtension.php#L205-L208 |
Zauberfisch/silverstripe-persistent-dataobject | src/Model/VersionedDataObjectExtension.php | VersionedDataObjectExtension.onBeforeWrite | public function onBeforeWrite() {
$isInDB = $this->owner->isInDB();
// TODO how do we handle saving of old versions?
// TODO The PageBuilder module may need to revert back to an older version of a record and continue from there
//if ($isInDB && !$this->owner->isLatestVersion(true)) {
// throw new \ValidationException("Old versions can not be written");
//}
$this->owner->setRawFieldData('VersionGroupPreviousID', $this->owner->ID);
$this->owner->setRawFieldData('ID', 0);
parent::onBeforeWrite();
} | php | public function onBeforeWrite() {
$isInDB = $this->owner->isInDB();
// TODO how do we handle saving of old versions?
// TODO The PageBuilder module may need to revert back to an older version of a record and continue from there
//if ($isInDB && !$this->owner->isLatestVersion(true)) {
// throw new \ValidationException("Old versions can not be written");
//}
$this->owner->setRawFieldData('VersionGroupPreviousID', $this->owner->ID);
$this->owner->setRawFieldData('ID', 0);
parent::onBeforeWrite();
} | [
"public",
"function",
"onBeforeWrite",
"(",
")",
"{",
"$",
"isInDB",
"=",
"$",
"this",
"->",
"owner",
"->",
"isInDB",
"(",
")",
";",
"// TODO how do we handle saving of old versions?",
"// TODO The PageBuilder module may need to revert back to an older version of a record and continue from there",
"//if ($isInDB && !$this->owner->isLatestVersion(true)) {",
"//\tthrow new \\ValidationException(\"Old versions can not be written\");",
"//}",
"$",
"this",
"->",
"owner",
"->",
"setRawFieldData",
"(",
"'VersionGroupPreviousID'",
",",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
";",
"$",
"this",
"->",
"owner",
"->",
"setRawFieldData",
"(",
"'ID'",
",",
"0",
")",
";",
"parent",
"::",
"onBeforeWrite",
"(",
")",
";",
"}"
] | } | [
"}"
] | train | https://github.com/Zauberfisch/silverstripe-persistent-dataobject/blob/ce865204bc9a0dc4ae061c97a877f748db35d7c1/src/Model/VersionedDataObjectExtension.php#L38-L48 |
lightwerk/SurfTasks | Classes/Lightwerk/SurfTasks/Task/Database/TransferTask.php | TransferTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
$credentials = $this->getCredentials($sourceNode, $deployment, $options['sourceNodeOptions'], $application);
$dumpFile = $this->getDumpFile($options['sourceNodeOptions'], $credentials);
$source = $this->getArgument($sourceNode, $dumpFile);
$credentials = $this->getCredentials($node, $deployment, $options, $application);
$dumpFile = $this->getDumpFile($options, $credentials);
$target = $this->getArgument($node, $dumpFile);
$command = 'scp -o BatchMode=\'yes\' '.$source.' '.$target;
if ($sourceNode->isLocalhost() === true) {
$this->shell->executeOrSimulate($command, $sourceNode, $deployment);
} else {
$this->shell->executeOrSimulate($command, $node, $deployment);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
$credentials = $this->getCredentials($sourceNode, $deployment, $options['sourceNodeOptions'], $application);
$dumpFile = $this->getDumpFile($options['sourceNodeOptions'], $credentials);
$source = $this->getArgument($sourceNode, $dumpFile);
$credentials = $this->getCredentials($node, $deployment, $options, $application);
$dumpFile = $this->getDumpFile($options, $credentials);
$target = $this->getArgument($node, $dumpFile);
$command = 'scp -o BatchMode=\'yes\' '.$source.' '.$target;
if ($sourceNode->isLocalhost() === true) {
$this->shell->executeOrSimulate($command, $sourceNode, $deployment);
} else {
$this->shell->executeOrSimulate($command, $node, $deployment);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"sourceNode",
"=",
"$",
"this",
"->",
"nodeFactory",
"->",
"getNodeByArray",
"(",
"$",
"options",
"[",
"'sourceNode'",
"]",
")",
";",
"$",
"credentials",
"=",
"$",
"this",
"->",
"getCredentials",
"(",
"$",
"sourceNode",
",",
"$",
"deployment",
",",
"$",
"options",
"[",
"'sourceNodeOptions'",
"]",
",",
"$",
"application",
")",
";",
"$",
"dumpFile",
"=",
"$",
"this",
"->",
"getDumpFile",
"(",
"$",
"options",
"[",
"'sourceNodeOptions'",
"]",
",",
"$",
"credentials",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"$",
"sourceNode",
",",
"$",
"dumpFile",
")",
";",
"$",
"credentials",
"=",
"$",
"this",
"->",
"getCredentials",
"(",
"$",
"node",
",",
"$",
"deployment",
",",
"$",
"options",
",",
"$",
"application",
")",
";",
"$",
"dumpFile",
"=",
"$",
"this",
"->",
"getDumpFile",
"(",
"$",
"options",
",",
"$",
"credentials",
")",
";",
"$",
"target",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"$",
"node",
",",
"$",
"dumpFile",
")",
";",
"$",
"command",
"=",
"'scp -o BatchMode=\\'yes\\' '",
".",
"$",
"source",
".",
"' '",
".",
"$",
"target",
";",
"if",
"(",
"$",
"sourceNode",
"->",
"isLocalhost",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"shell",
"->",
"executeOrSimulate",
"(",
"$",
"command",
",",
"$",
"sourceNode",
",",
"$",
"deployment",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"shell",
"->",
"executeOrSimulate",
"(",
"$",
"command",
",",
"$",
"node",
",",
"$",
"deployment",
")",
";",
"}",
"}"
] | Executes the task.
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options
@throws InvalidConfigurationException
@throws TaskExecutionException | [
"Executes",
"the",
"task",
"."
] | train | https://github.com/lightwerk/SurfTasks/blob/8a6e4c85e42c762ad6515778c3fc7e19052cd9d1/Classes/Lightwerk/SurfTasks/Task/Database/TransferTask.php#L46-L63 |
lightwerk/SurfTasks | Classes/Lightwerk/SurfTasks/Task/Database/TransferTask.php | TransferTask.getArgument | protected function getArgument(Node $node, $file)
{
if ($node->isLocalhost() === true) {
return $file;
}
$argument = '';
if ($node->hasOption('port')) {
$port = $node->getOption('port');
if (!empty($port)) {
$argument .= '-P '.$port.' ';
}
}
if ($node->hasOption('username')) {
$username = $node->getOption('username');
if (!empty($username)) {
$argument .= $username.'@';
}
}
$argument .= $node->getHostname().':';
$argument .= $file;
return $argument;
} | php | protected function getArgument(Node $node, $file)
{
if ($node->isLocalhost() === true) {
return $file;
}
$argument = '';
if ($node->hasOption('port')) {
$port = $node->getOption('port');
if (!empty($port)) {
$argument .= '-P '.$port.' ';
}
}
if ($node->hasOption('username')) {
$username = $node->getOption('username');
if (!empty($username)) {
$argument .= $username.'@';
}
}
$argument .= $node->getHostname().':';
$argument .= $file;
return $argument;
} | [
"protected",
"function",
"getArgument",
"(",
"Node",
"$",
"node",
",",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"isLocalhost",
"(",
")",
"===",
"true",
")",
"{",
"return",
"$",
"file",
";",
"}",
"$",
"argument",
"=",
"''",
";",
"if",
"(",
"$",
"node",
"->",
"hasOption",
"(",
"'port'",
")",
")",
"{",
"$",
"port",
"=",
"$",
"node",
"->",
"getOption",
"(",
"'port'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"$",
"argument",
".=",
"'-P '",
".",
"$",
"port",
".",
"' '",
";",
"}",
"}",
"if",
"(",
"$",
"node",
"->",
"hasOption",
"(",
"'username'",
")",
")",
"{",
"$",
"username",
"=",
"$",
"node",
"->",
"getOption",
"(",
"'username'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"username",
")",
")",
"{",
"$",
"argument",
".=",
"$",
"username",
".",
"'@'",
";",
"}",
"}",
"$",
"argument",
".=",
"$",
"node",
"->",
"getHostname",
"(",
")",
".",
"':'",
";",
"$",
"argument",
".=",
"$",
"file",
";",
"return",
"$",
"argument",
";",
"}"
] | @param Node $node
@param string $file
@return string | [
"@param",
"Node",
"$node",
"@param",
"string",
"$file"
] | train | https://github.com/lightwerk/SurfTasks/blob/8a6e4c85e42c762ad6515778c3fc7e19052cd9d1/Classes/Lightwerk/SurfTasks/Task/Database/TransferTask.php#L71-L95 |
romm/configuration_object | Classes/ConfigurationObjectFactory.php | ConfigurationObjectFactory.get | public function get($className, array $objectData)
{
$this->runningProcesses++;
try {
$result = $this->convertToObject($className, $objectData);
$this->runningProcesses--;
return $result;
} catch (\Exception $exception) {
$this->runningProcesses--;
throw $exception;
}
} | php | public function get($className, array $objectData)
{
$this->runningProcesses++;
try {
$result = $this->convertToObject($className, $objectData);
$this->runningProcesses--;
return $result;
} catch (\Exception $exception) {
$this->runningProcesses--;
throw $exception;
}
} | [
"public",
"function",
"get",
"(",
"$",
"className",
",",
"array",
"$",
"objectData",
")",
"{",
"$",
"this",
"->",
"runningProcesses",
"++",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"convertToObject",
"(",
"$",
"className",
",",
"$",
"objectData",
")",
";",
"$",
"this",
"->",
"runningProcesses",
"--",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"runningProcesses",
"--",
";",
"throw",
"$",
"exception",
";",
"}",
"}"
] | Returns an instance of the given configuration object name. The object is
recursively filled with the given array data.
@param string $className Name of the configuration object class. The class must implement `\Romm\ConfigurationObject\ConfigurationObjectInterface`.
@param array $objectData Data used to fill the object.
@return ConfigurationObjectInstance
@throws \Exception | [
"Returns",
"an",
"instance",
"of",
"the",
"given",
"configuration",
"object",
"name",
".",
"The",
"object",
"is",
"recursively",
"filled",
"with",
"the",
"given",
"array",
"data",
"."
] | train | https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/ConfigurationObjectFactory.php#L99-L114 |
romm/configuration_object | Classes/ConfigurationObjectFactory.php | ConfigurationObjectFactory.register | protected function register($className)
{
if (false === isset($this->configurationObjectServiceFactory[$className])) {
if (false === Core::get()->classExists($className)) {
throw new ClassNotFoundException(
'Trying to get a non-existing configuration object: "' . $className . '".',
1448886437
);
}
if (false === in_array(ConfigurationObjectInterface::class, class_implements($className))) {
throw new WrongInheritanceException(
'The configuration object class: "' . $className . '" must implement "' . ConfigurationObjectInterface::class . '".',
1448886449
);
}
/** @var ConfigurationObjectInterface $configurationObjectClassName */
$configurationObjectClassName = $className;
$serviceFactory = $configurationObjectClassName::getConfigurationObjectServices();
if (false === $serviceFactory instanceof ServiceFactory) {
throw new WrongServiceException(
'Service factory for configuration object class: "' . $className . '" must be an instance of "' . ServiceFactory::class . '".',
1448886479
);
}
/** @var ServiceFactory $serviceFactory */
$serviceFactory->initialize();
$this->configurationObjectServiceFactory[$className] = $serviceFactory;
}
return $this->configurationObjectServiceFactory[$className];
} | php | protected function register($className)
{
if (false === isset($this->configurationObjectServiceFactory[$className])) {
if (false === Core::get()->classExists($className)) {
throw new ClassNotFoundException(
'Trying to get a non-existing configuration object: "' . $className . '".',
1448886437
);
}
if (false === in_array(ConfigurationObjectInterface::class, class_implements($className))) {
throw new WrongInheritanceException(
'The configuration object class: "' . $className . '" must implement "' . ConfigurationObjectInterface::class . '".',
1448886449
);
}
/** @var ConfigurationObjectInterface $configurationObjectClassName */
$configurationObjectClassName = $className;
$serviceFactory = $configurationObjectClassName::getConfigurationObjectServices();
if (false === $serviceFactory instanceof ServiceFactory) {
throw new WrongServiceException(
'Service factory for configuration object class: "' . $className . '" must be an instance of "' . ServiceFactory::class . '".',
1448886479
);
}
/** @var ServiceFactory $serviceFactory */
$serviceFactory->initialize();
$this->configurationObjectServiceFactory[$className] = $serviceFactory;
}
return $this->configurationObjectServiceFactory[$className];
} | [
"protected",
"function",
"register",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"this",
"->",
"configurationObjectServiceFactory",
"[",
"$",
"className",
"]",
")",
")",
"{",
"if",
"(",
"false",
"===",
"Core",
"::",
"get",
"(",
")",
"->",
"classExists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"'Trying to get a non-existing configuration object: \"'",
".",
"$",
"className",
".",
"'\".'",
",",
"1448886437",
")",
";",
"}",
"if",
"(",
"false",
"===",
"in_array",
"(",
"ConfigurationObjectInterface",
"::",
"class",
",",
"class_implements",
"(",
"$",
"className",
")",
")",
")",
"{",
"throw",
"new",
"WrongInheritanceException",
"(",
"'The configuration object class: \"'",
".",
"$",
"className",
".",
"'\" must implement \"'",
".",
"ConfigurationObjectInterface",
"::",
"class",
".",
"'\".'",
",",
"1448886449",
")",
";",
"}",
"/** @var ConfigurationObjectInterface $configurationObjectClassName */",
"$",
"configurationObjectClassName",
"=",
"$",
"className",
";",
"$",
"serviceFactory",
"=",
"$",
"configurationObjectClassName",
"::",
"getConfigurationObjectServices",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"serviceFactory",
"instanceof",
"ServiceFactory",
")",
"{",
"throw",
"new",
"WrongServiceException",
"(",
"'Service factory for configuration object class: \"'",
".",
"$",
"className",
".",
"'\" must be an instance of \"'",
".",
"ServiceFactory",
"::",
"class",
".",
"'\".'",
",",
"1448886479",
")",
";",
"}",
"/** @var ServiceFactory $serviceFactory */",
"$",
"serviceFactory",
"->",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"configurationObjectServiceFactory",
"[",
"$",
"className",
"]",
"=",
"$",
"serviceFactory",
";",
"}",
"return",
"$",
"this",
"->",
"configurationObjectServiceFactory",
"[",
"$",
"className",
"]",
";",
"}"
] | Any configuration object needs to be registered before it can be used.
@param string $className Class name of the wanted configuration object.
@return ServiceFactory
@throws ClassNotFoundException
@throws WrongInheritanceException
@throws WrongServiceException | [
"Any",
"configuration",
"object",
"needs",
"to",
"be",
"registered",
"before",
"it",
"can",
"be",
"used",
"."
] | train | https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/ConfigurationObjectFactory.php#L165-L199 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.checkTableExists | private function checkTableExists($name)
{
try {
$this->client->describeTable(['TableName' => $name]);
return true;
} catch (AwsException $e) {
if ($e->getAwsErrorCode() === 'ResourceNotFoundException') {
return false;
}
throw $e;
}
} | php | private function checkTableExists($name)
{
try {
$this->client->describeTable(['TableName' => $name]);
return true;
} catch (AwsException $e) {
if ($e->getAwsErrorCode() === 'ResourceNotFoundException') {
return false;
}
throw $e;
}
} | [
"private",
"function",
"checkTableExists",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"describeTable",
"(",
"[",
"'TableName'",
"=>",
"$",
"name",
"]",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"AwsException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getAwsErrorCode",
"(",
")",
"===",
"'ResourceNotFoundException'",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] | @param string $name
@return bool
@throws AwsException | [
"@param",
"string",
"$name"
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L63-L76 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.createAllDocumentTables | public function createAllDocumentTables()
{
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || (count($class->parentClassNames) && $class->inheritanceType == ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE)) {
continue;
}
$this->createDocumentTableFor($class->name);
}
} | php | public function createAllDocumentTables()
{
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || (count($class->parentClassNames) && $class->inheritanceType == ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE)) {
continue;
}
$this->createDocumentTableFor($class->name);
}
} | [
"public",
"function",
"createAllDocumentTables",
"(",
")",
"{",
"/**\n * @var ClassMetadata $class\n */",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
"||",
"(",
"count",
"(",
"$",
"class",
"->",
"parentClassNames",
")",
"&&",
"$",
"class",
"->",
"inheritanceType",
"==",
"ClassMetadata",
"::",
"INHERITANCE_TYPE_SINGLE_TABLE",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"createDocumentTableFor",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Create all the mapped document tables in the metadata factory.
@return void | [
"Create",
"all",
"the",
"mapped",
"document",
"tables",
"in",
"the",
"metadata",
"factory",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L83-L95 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.createAllGeneratorTables | public function createAllGeneratorTables()
{
$tables = [];
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
$tables = array_merge(
$tables,
$this->getGeneratorTablesFor($class)
);
}
foreach ($tables as $tableName => $definition) {
$this->doCreateTable($tableName, $definition);
}
} | php | public function createAllGeneratorTables()
{
$tables = [];
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
$tables = array_merge(
$tables,
$this->getGeneratorTablesFor($class)
);
}
foreach ($tables as $tableName => $definition) {
$this->doCreateTable($tableName, $definition);
}
} | [
"public",
"function",
"createAllGeneratorTables",
"(",
")",
"{",
"$",
"tables",
"=",
"[",
"]",
";",
"/**\n * @var ClassMetadata $class\n */",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"$",
"tables",
"=",
"array_merge",
"(",
"$",
"tables",
",",
"$",
"this",
"->",
"getGeneratorTablesFor",
"(",
"$",
"class",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"doCreateTable",
"(",
"$",
"tableName",
",",
"$",
"definition",
")",
";",
"}",
"}"
] | Create any tables used by IncrementGenerator and/or AlnumGenerator instances
associated with document classes known to DynamoDM.
@return void | [
"Create",
"any",
"tables",
"used",
"by",
"IncrementGenerator",
"and",
"/",
"or",
"AlnumGenerator",
"instances",
"associated",
"with",
"document",
"classes",
"known",
"to",
"DynamoDM",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L103-L120 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.createDocumentTableFor | public function createDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw ODMException::cannotCreateMappedSuperclassTable($documentName);
}
$this->doCreateTable($class->getTableName(), $class->getDefinitionTable());
} | php | public function createDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw ODMException::cannotCreateMappedSuperclassTable($documentName);
}
$this->doCreateTable($class->getTableName(), $class->getDefinitionTable());
} | [
"public",
"function",
"createDocumentTableFor",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"throw",
"ODMException",
"::",
"cannotCreateMappedSuperclassTable",
"(",
"$",
"documentName",
")",
";",
"}",
"$",
"this",
"->",
"doCreateTable",
"(",
"$",
"class",
"->",
"getTableName",
"(",
")",
",",
"$",
"class",
"->",
"getDefinitionTable",
"(",
")",
")",
";",
"}"
] | Checks if the DynamoDB table for a mapped class exists, and if not creates
it.
@param string $documentName
@return void
@throws ODMException | [
"Checks",
"if",
"the",
"DynamoDB",
"table",
"for",
"a",
"mapped",
"class",
"exists",
"and",
"if",
"not",
"creates",
"it",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L143-L152 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.deleteAllDocumentTables | public function deleteAllDocumentTables()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || (count($class->parentClassNames) && $class->inheritanceType == ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE)) {
continue;
}
$this->deleteDocumentTableFor($class->name);
}
} | php | public function deleteAllDocumentTables()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || (count($class->parentClassNames) && $class->inheritanceType == ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE)) {
continue;
}
$this->deleteDocumentTableFor($class->name);
}
} | [
"public",
"function",
"deleteAllDocumentTables",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
"||",
"(",
"count",
"(",
"$",
"class",
"->",
"parentClassNames",
")",
"&&",
"$",
"class",
"->",
"inheritanceType",
"==",
"ClassMetadata",
"::",
"INHERITANCE_TYPE_SINGLE_TABLE",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"deleteDocumentTableFor",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Delete all tables for document classes known to DynamoDM.
@return void | [
"Delete",
"all",
"tables",
"for",
"document",
"classes",
"known",
"to",
"DynamoDM",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L175-L184 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.deleteAllGeneratorTables | public function deleteAllGeneratorTables()
{
$tables = [];
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
$tables = array_merge(
$tables,
$this->getGeneratorTablesFor($class)
);
}
foreach ($tables as $tableName => $definition) {
$this->doDeleteTable($tableName, $definition);
}
} | php | public function deleteAllGeneratorTables()
{
$tables = [];
/**
* @var ClassMetadata $class
*/
foreach ($this->metadataFactory->getAllMetadata() as $class) {
$tables = array_merge(
$tables,
$this->getGeneratorTablesFor($class)
);
}
foreach ($tables as $tableName => $definition) {
$this->doDeleteTable($tableName, $definition);
}
} | [
"public",
"function",
"deleteAllGeneratorTables",
"(",
")",
"{",
"$",
"tables",
"=",
"[",
"]",
";",
"/**\n * @var ClassMetadata $class\n */",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"$",
"tables",
"=",
"array_merge",
"(",
"$",
"tables",
",",
"$",
"this",
"->",
"getGeneratorTablesFor",
"(",
"$",
"class",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"doDeleteTable",
"(",
"$",
"tableName",
",",
"$",
"definition",
")",
";",
"}",
"}"
] | Delete any tables used by IncrementGenerator and/or AlnumGenerator instances
associated with document classes known to DynamoDM.
@return void | [
"Delete",
"any",
"tables",
"used",
"by",
"IncrementGenerator",
"and",
"/",
"or",
"AlnumGenerator",
"instances",
"associated",
"with",
"document",
"classes",
"known",
"to",
"DynamoDM",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L192-L209 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.deleteDocumentTableFor | public function deleteDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw ODMException::cannotDeleteMappedSuperclassTable($documentName);
}
$this->doDeleteTable($class->getTableName(), $class->getDefinitionTable());
} | php | public function deleteDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw ODMException::cannotDeleteMappedSuperclassTable($documentName);
}
$this->doDeleteTable($class->getTableName(), $class->getDefinitionTable());
} | [
"public",
"function",
"deleteDocumentTableFor",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"throw",
"ODMException",
"::",
"cannotDeleteMappedSuperclassTable",
"(",
"$",
"documentName",
")",
";",
"}",
"$",
"this",
"->",
"doDeleteTable",
"(",
"$",
"class",
"->",
"getTableName",
"(",
")",
",",
"$",
"class",
"->",
"getDefinitionTable",
"(",
")",
")",
";",
"}"
] | Checks if the DynamoDB table for a mapped class exists, and deletes it if
it does.
@param string $documentName
@return void
@throws ODMException | [
"Checks",
"if",
"the",
"DynamoDB",
"table",
"for",
"a",
"mapped",
"class",
"exists",
"and",
"deletes",
"it",
"if",
"it",
"does",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L232-L241 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.deleteGeneratorTablesFor | public function deleteGeneratorTablesFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$tables = $this->getGeneratorTablesFor($class);
foreach ($tables as $tableName => $definition) {
$this->doCreateTable($tableName, $definition);
}
} | php | public function deleteGeneratorTablesFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$tables = $this->getGeneratorTablesFor($class);
foreach ($tables as $tableName => $definition) {
$this->doCreateTable($tableName, $definition);
}
} | [
"public",
"function",
"deleteGeneratorTablesFor",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"$",
"tables",
"=",
"$",
"this",
"->",
"getGeneratorTablesFor",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"doCreateTable",
"(",
"$",
"tableName",
",",
"$",
"definition",
")",
";",
"}",
"}"
] | Creates any tables used by IncrementGenerator and/or AlnumGenerator instances
associated with the specified document class.
@param string $documentName | [
"Creates",
"any",
"tables",
"used",
"by",
"IncrementGenerator",
"and",
"/",
"or",
"AlnumGenerator",
"instances",
"associated",
"with",
"the",
"specified",
"document",
"class",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L249-L257 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.getGeneratorTablesFor | private function getGeneratorTablesFor(ClassMetadata $class)
{
$tables = [];
foreach ($class->getGeneratedProperties() as $mapping) {
if ($mapping->generator instanceof IncrementGenerator) {
$table = $mapping->generator->getTable();
if (!isset($tables[$table])) {
$tables[$table] = $mapping->generator->getTableDefinition();
}
}
}
return $tables;
} | php | private function getGeneratorTablesFor(ClassMetadata $class)
{
$tables = [];
foreach ($class->getGeneratedProperties() as $mapping) {
if ($mapping->generator instanceof IncrementGenerator) {
$table = $mapping->generator->getTable();
if (!isset($tables[$table])) {
$tables[$table] = $mapping->generator->getTableDefinition();
}
}
}
return $tables;
} | [
"private",
"function",
"getGeneratorTablesFor",
"(",
"ClassMetadata",
"$",
"class",
")",
"{",
"$",
"tables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"class",
"->",
"getGeneratedProperties",
"(",
")",
"as",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"mapping",
"->",
"generator",
"instanceof",
"IncrementGenerator",
")",
"{",
"$",
"table",
"=",
"$",
"mapping",
"->",
"generator",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tables",
"[",
"$",
"table",
"]",
")",
")",
"{",
"$",
"tables",
"[",
"$",
"table",
"]",
"=",
"$",
"mapping",
"->",
"generator",
"->",
"getTableDefinition",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"tables",
";",
"}"
] | @param ClassMetadata $class
@return array | [
"@param",
"ClassMetadata",
"$class"
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L304-L319 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.rebuildDocumentTableFor | public function rebuildDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$table = $class->getTableName();
$defintiion = $class->getDefinitionTable();
$this->doDeleteTable($table, $defintiion);
$this->doCreateTable($table, $defintiion);
} | php | public function rebuildDocumentTableFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$table = $class->getTableName();
$defintiion = $class->getDefinitionTable();
$this->doDeleteTable($table, $defintiion);
$this->doCreateTable($table, $defintiion);
} | [
"public",
"function",
"rebuildDocumentTableFor",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"$",
"table",
"=",
"$",
"class",
"->",
"getTableName",
"(",
")",
";",
"$",
"defintiion",
"=",
"$",
"class",
"->",
"getDefinitionTable",
"(",
")",
";",
"$",
"this",
"->",
"doDeleteTable",
"(",
"$",
"table",
",",
"$",
"defintiion",
")",
";",
"$",
"this",
"->",
"doCreateTable",
"(",
"$",
"table",
",",
"$",
"defintiion",
")",
";",
"}"
] | Deletes and rebuilds the DynamoDB table for a mapped class.
@param string $documentName
@return void | [
"Deletes",
"and",
"rebuilds",
"the",
"DynamoDB",
"table",
"for",
"a",
"mapped",
"class",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L328-L336 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.rebuildGeneratorTablesFor | public function rebuildGeneratorTablesFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$tables = $this->getGeneratorTablesFor($class);
foreach ($tables as $tableName => $definition) {
$this->doDeleteTable($tableName, $definition);
$this->doCreateTable($tableName, $definition);
}
} | php | public function rebuildGeneratorTablesFor($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
$tables = $this->getGeneratorTablesFor($class);
foreach ($tables as $tableName => $definition) {
$this->doDeleteTable($tableName, $definition);
$this->doCreateTable($tableName, $definition);
}
} | [
"public",
"function",
"rebuildGeneratorTablesFor",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"$",
"tables",
"=",
"$",
"this",
"->",
"getGeneratorTablesFor",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"doDeleteTable",
"(",
"$",
"tableName",
",",
"$",
"definition",
")",
";",
"$",
"this",
"->",
"doCreateTable",
"(",
"$",
"tableName",
",",
"$",
"definition",
")",
";",
"}",
"}"
] | Deletes and rebuilds any tables used by IncrementGenerator and/or AlnumGenerator
instances associated with the specified document class.
@param string $documentName | [
"Deletes",
"and",
"rebuilds",
"any",
"tables",
"used",
"by",
"IncrementGenerator",
"and",
"/",
"or",
"AlnumGenerator",
"instances",
"associated",
"with",
"the",
"specified",
"document",
"class",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L344-L353 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Schema/SchemaManager.php | SchemaManager.wait | private function wait($operation, $args)
{
$this->client->getWaiter($operation, $args)->promise()->wait();
} | php | private function wait($operation, $args)
{
$this->client->getWaiter($operation, $args)->promise()->wait();
} | [
"private",
"function",
"wait",
"(",
"$",
"operation",
",",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"getWaiter",
"(",
"$",
"operation",
",",
"$",
"args",
")",
"->",
"promise",
"(",
")",
"->",
"wait",
"(",
")",
";",
"}"
] | @param string $operation
@param array $args
@return void | [
"@param",
"string",
"$operation",
"@param",
"array",
"$args"
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Schema/SchemaManager.php#L361-L364 |
agentmedia/phine-core | src/Core/Modules/Backend/AreaForm.php | AreaForm.Init | protected function Init()
{
$this->area = new Area(Request::GetData('area'));
$this->layout= $this->area->Exists() ? $this->area->GetLayout() :
new Layout(Request::GetData('layout'));
if (!$this->area->Exists() && !$this->layout->Exists())
{
Response::Redirect(BackendRouter::ModuleUrl(new LayoutList()));
return true;
}
$this->AddNameField();
$this->AddLockedField();
$this->AddSubmit();
return parent::Init();
} | php | protected function Init()
{
$this->area = new Area(Request::GetData('area'));
$this->layout= $this->area->Exists() ? $this->area->GetLayout() :
new Layout(Request::GetData('layout'));
if (!$this->area->Exists() && !$this->layout->Exists())
{
Response::Redirect(BackendRouter::ModuleUrl(new LayoutList()));
return true;
}
$this->AddNameField();
$this->AddLockedField();
$this->AddSubmit();
return parent::Init();
} | [
"protected",
"function",
"Init",
"(",
")",
"{",
"$",
"this",
"->",
"area",
"=",
"new",
"Area",
"(",
"Request",
"::",
"GetData",
"(",
"'area'",
")",
")",
";",
"$",
"this",
"->",
"layout",
"=",
"$",
"this",
"->",
"area",
"->",
"Exists",
"(",
")",
"?",
"$",
"this",
"->",
"area",
"->",
"GetLayout",
"(",
")",
":",
"new",
"Layout",
"(",
"Request",
"::",
"GetData",
"(",
"'layout'",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"area",
"->",
"Exists",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"layout",
"->",
"Exists",
"(",
")",
")",
"{",
"Response",
"::",
"Redirect",
"(",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"LayoutList",
"(",
")",
")",
")",
";",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"AddNameField",
"(",
")",
";",
"$",
"this",
"->",
"AddLockedField",
"(",
")",
";",
"$",
"this",
"->",
"AddSubmit",
"(",
")",
";",
"return",
"parent",
"::",
"Init",
"(",
")",
";",
"}"
] | Initializes the form
@return boolean | [
"Initializes",
"the",
"form"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaForm.php#L42-L57 |
agentmedia/phine-core | src/Core/Modules/Backend/AreaForm.php | AreaForm.AddNameField | private function AddNameField()
{
$name = 'Name';
$this->AddField(Input::Text($name, $this->area->GetName()));
$this->SetRequired($name);
$this->AddValidator($name, DatabaseCount::UniqueFieldAnd($this->area, $name, $this->LayoutCondition()));
} | php | private function AddNameField()
{
$name = 'Name';
$this->AddField(Input::Text($name, $this->area->GetName()));
$this->SetRequired($name);
$this->AddValidator($name, DatabaseCount::UniqueFieldAnd($this->area, $name, $this->LayoutCondition()));
} | [
"private",
"function",
"AddNameField",
"(",
")",
"{",
"$",
"name",
"=",
"'Name'",
";",
"$",
"this",
"->",
"AddField",
"(",
"Input",
"::",
"Text",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"area",
"->",
"GetName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"SetRequired",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"AddValidator",
"(",
"$",
"name",
",",
"DatabaseCount",
"::",
"UniqueFieldAnd",
"(",
"$",
"this",
"->",
"area",
",",
"$",
"name",
",",
"$",
"this",
"->",
"LayoutCondition",
"(",
")",
")",
")",
";",
"}"
] | Adds name field to the form | [
"Adds",
"name",
"field",
"to",
"the",
"form"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaForm.php#L63-L69 |
agentmedia/phine-core | src/Core/Modules/Backend/AreaForm.php | AreaForm.AddLockedField | private function AddLockedField()
{
$name = 'Locked';
$field = new Checkbox($name);
if ($this->area->Exists() && $this->area->GetLocked())
{
$field->SetChecked();
}
$this->AddField($field);
} | php | private function AddLockedField()
{
$name = 'Locked';
$field = new Checkbox($name);
if ($this->area->Exists() && $this->area->GetLocked())
{
$field->SetChecked();
}
$this->AddField($field);
} | [
"private",
"function",
"AddLockedField",
"(",
")",
"{",
"$",
"name",
"=",
"'Locked'",
";",
"$",
"field",
"=",
"new",
"Checkbox",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"area",
"->",
"Exists",
"(",
")",
"&&",
"$",
"this",
"->",
"area",
"->",
"GetLocked",
"(",
")",
")",
"{",
"$",
"field",
"->",
"SetChecked",
"(",
")",
";",
"}",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
")",
";",
"}"
] | Adds the locked field | [
"Adds",
"the",
"locked",
"field"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaForm.php#L74-L83 |
agentmedia/phine-core | src/Core/Modules/Backend/AreaForm.php | AreaForm.LayoutCondition | private function LayoutCondition()
{
$sql = Access::SqlBuilder();
$tbl = Area::Schema()->Table();
return $sql->Equals($tbl->Field('Layout'), $sql->Value($this->layout->GetID()));
} | php | private function LayoutCondition()
{
$sql = Access::SqlBuilder();
$tbl = Area::Schema()->Table();
return $sql->Equals($tbl->Field('Layout'), $sql->Value($this->layout->GetID()));
} | [
"private",
"function",
"LayoutCondition",
"(",
")",
"{",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"tbl",
"=",
"Area",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"return",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tbl",
"->",
"Field",
"(",
"'Layout'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"this",
"->",
"layout",
"->",
"GetID",
"(",
")",
")",
")",
";",
"}"
] | Gets the layout condition for the name validator
@return \Phine\Framework\Database\Sql\Condition | [
"Gets",
"the",
"layout",
"condition",
"for",
"the",
"name",
"validator"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaForm.php#L89-L94 |
agentmedia/phine-core | src/Core/Modules/Backend/AreaForm.php | AreaForm.OnSuccess | protected function OnSuccess()
{
$this->area->SetName($this->Value('Name'));
$this->area->SetLocked((bool)$this->Value('Locked'));
$action = Action::Update();
if (!$this->area->Exists())
{
$action = Action::Create();
$this->SaveNew();
}
else
{
$this->area->Save();
}
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportAreaAction($this->area, $action);
$args = array('layout' => $this->layout->GetID());
Response::Redirect(BackendRouter::ModuleUrl(new AreaList(), $args));
} | php | protected function OnSuccess()
{
$this->area->SetName($this->Value('Name'));
$this->area->SetLocked((bool)$this->Value('Locked'));
$action = Action::Update();
if (!$this->area->Exists())
{
$action = Action::Create();
$this->SaveNew();
}
else
{
$this->area->Save();
}
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportAreaAction($this->area, $action);
$args = array('layout' => $this->layout->GetID());
Response::Redirect(BackendRouter::ModuleUrl(new AreaList(), $args));
} | [
"protected",
"function",
"OnSuccess",
"(",
")",
"{",
"$",
"this",
"->",
"area",
"->",
"SetName",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Name'",
")",
")",
";",
"$",
"this",
"->",
"area",
"->",
"SetLocked",
"(",
"(",
"bool",
")",
"$",
"this",
"->",
"Value",
"(",
"'Locked'",
")",
")",
";",
"$",
"action",
"=",
"Action",
"::",
"Update",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"area",
"->",
"Exists",
"(",
")",
")",
"{",
"$",
"action",
"=",
"Action",
"::",
"Create",
"(",
")",
";",
"$",
"this",
"->",
"SaveNew",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"area",
"->",
"Save",
"(",
")",
";",
"}",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"self",
"::",
"Guard",
"(",
")",
"->",
"GetUser",
"(",
")",
")",
";",
"$",
"logger",
"->",
"ReportAreaAction",
"(",
"$",
"this",
"->",
"area",
",",
"$",
"action",
")",
";",
"$",
"args",
"=",
"array",
"(",
"'layout'",
"=>",
"$",
"this",
"->",
"layout",
"->",
"GetID",
"(",
")",
")",
";",
"Response",
"::",
"Redirect",
"(",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"AreaList",
"(",
")",
",",
"$",
"args",
")",
")",
";",
"}"
] | Saves the area | [
"Saves",
"the",
"area"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaForm.php#L101-L119 |
picturae/php-composition-utils | src/WithEvents.php | WithEvents.subscribe | public function subscribe($eventType, $callback)
{
$callback = $this->makeEventCallback($callback);
if (!isset($this->eventList[$eventType]) || !is_array($this->eventList[$eventType])) {
$this->eventList[$eventType] = [];
}
array_push($this->eventList[$eventType], $callback);
return $callback['id'];
} | php | public function subscribe($eventType, $callback)
{
$callback = $this->makeEventCallback($callback);
if (!isset($this->eventList[$eventType]) || !is_array($this->eventList[$eventType])) {
$this->eventList[$eventType] = [];
}
array_push($this->eventList[$eventType], $callback);
return $callback['id'];
} | [
"public",
"function",
"subscribe",
"(",
"$",
"eventType",
",",
"$",
"callback",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"makeEventCallback",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
")",
"{",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
"=",
"[",
"]",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
",",
"$",
"callback",
")",
";",
"return",
"$",
"callback",
"[",
"'id'",
"]",
";",
"}"
] | Add a callback on a specific backend event.
@param string $eventType - Use constants(add your own if needed)
@param callable $callback - Execution callback.
@return string|null | [
"Add",
"a",
"callback",
"on",
"a",
"specific",
"backend",
"event",
"."
] | train | https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithEvents.php#L29-L37 |
picturae/php-composition-utils | src/WithEvents.php | WithEvents.unsubscribe | public function unsubscribe($eventType, $callbackId)
{
$success = false;
if (!isset($this->eventList[$eventType]) || !is_array($this->eventList[$eventType])) {
$this->eventList[$eventType] = array_filter(
$this->eventList[$eventType],
function ($cb) use ($callbackId) {
return $cb['id'] !== $callbackId;
}
);
$success = true;
}
return $success;
} | php | public function unsubscribe($eventType, $callbackId)
{
$success = false;
if (!isset($this->eventList[$eventType]) || !is_array($this->eventList[$eventType])) {
$this->eventList[$eventType] = array_filter(
$this->eventList[$eventType],
function ($cb) use ($callbackId) {
return $cb['id'] !== $callbackId;
}
);
$success = true;
}
return $success;
} | [
"public",
"function",
"unsubscribe",
"(",
"$",
"eventType",
",",
"$",
"callbackId",
")",
"{",
"$",
"success",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
")",
"{",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
",",
"function",
"(",
"$",
"cb",
")",
"use",
"(",
"$",
"callbackId",
")",
"{",
"return",
"$",
"cb",
"[",
"'id'",
"]",
"!==",
"$",
"callbackId",
";",
"}",
")",
";",
"$",
"success",
"=",
"true",
";",
"}",
"return",
"$",
"success",
";",
"}"
] | Remove callback by identifier.
@param string
@param string | [
"Remove",
"callback",
"by",
"identifier",
"."
] | train | https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithEvents.php#L44-L57 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.