id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,900 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.setDefaults | protected function setDefaults($sets = array())
{
foreach ($sets as $set) {
foreach ($set as $field => $fieldParams) {
if ($fieldParams['type'] == 'single' && isset($fieldParams['default'])) {
$this->fieldData[$field] = $fieldParams['default'];
}
}
}
} | php | protected function setDefaults($sets = array())
{
foreach ($sets as $set) {
foreach ($set as $field => $fieldParams) {
if ($fieldParams['type'] == 'single' && isset($fieldParams['default'])) {
$this->fieldData[$field] = $fieldParams['default'];
}
}
}
} | [
"protected",
"function",
"setDefaults",
"(",
"$",
"sets",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"sets",
"as",
"$",
"set",
")",
"{",
"foreach",
"(",
"$",
"set",
"as",
"$",
"field",
"=>",
"$",
"fieldParams",
")",
"{",
"if",
"(",
"$",
"fieldParams",
"[",
"'type'",
"]",
"==",
"'single'",
"&&",
"isset",
"(",
"$",
"fieldParams",
"[",
"'default'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"field",
"]",
"=",
"$",
"fieldParams",
"[",
"'default'",
"]",
";",
"}",
"}",
"}",
"}"
] | Sets default value for a field
@param array $sets Array of fields and its parameters
@return void | [
"Sets",
"default",
"value",
"for",
"a",
"field"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L204-L213 |
28,901 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.checkRequired | protected function checkRequired()
{
$missing = array();
foreach ($this->validFields as $field => $params) {
if (isset($params['required']) && $params['required']) {
if ($params['type'] == "single") {
if (!isset($this->formData[$field])) {
$missing[] = $field;
$this->errorMessage[] = 'Missing field: ' . $field;
}
} elseif ($params['type'] == "product") {
foreach ($this->products as $prod) {
$paramName = $params['paramName'];
if (!isset($prod[$paramName])) {
$missing[] = $field;
$this->errorMessage[] = 'Missing field: ' . $field;
}
}
}
}
}
$this->missing = $missing;
return true;
} | php | protected function checkRequired()
{
$missing = array();
foreach ($this->validFields as $field => $params) {
if (isset($params['required']) && $params['required']) {
if ($params['type'] == "single") {
if (!isset($this->formData[$field])) {
$missing[] = $field;
$this->errorMessage[] = 'Missing field: ' . $field;
}
} elseif ($params['type'] == "product") {
foreach ($this->products as $prod) {
$paramName = $params['paramName'];
if (!isset($prod[$paramName])) {
$missing[] = $field;
$this->errorMessage[] = 'Missing field: ' . $field;
}
}
}
}
}
$this->missing = $missing;
return true;
} | [
"protected",
"function",
"checkRequired",
"(",
")",
"{",
"$",
"missing",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"validFields",
"as",
"$",
"field",
"=>",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'required'",
"]",
")",
"&&",
"$",
"params",
"[",
"'required'",
"]",
")",
"{",
"if",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"single\"",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"formData",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"missing",
"[",
"]",
"=",
"$",
"field",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'Missing field: '",
".",
"$",
"field",
";",
"}",
"}",
"elseif",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"product\"",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"products",
"as",
"$",
"prod",
")",
"{",
"$",
"paramName",
"=",
"$",
"params",
"[",
"'paramName'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"prod",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"$",
"missing",
"[",
"]",
"=",
"$",
"field",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'Missing field: '",
".",
"$",
"field",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"missing",
"=",
"$",
"missing",
";",
"return",
"true",
";",
"}"
] | Checks if all required fields are set.
Returns true or the array of missing fields list
@return boolean | [
"Checks",
"if",
"all",
"required",
"fields",
"are",
"set",
".",
"Returns",
"true",
"or",
"the",
"array",
"of",
"missing",
"fields",
"list"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L222-L245 |
28,902 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.getField | public function getField($fieldName = '')
{
if (isset($this->fieldData[$fieldName])) {
return $this->fieldData[$fieldName];
}
$this->debugMessage[] = 'GET FIELD: Missing field name in getField: ' . $fieldName;
return false;
} | php | public function getField($fieldName = '')
{
if (isset($this->fieldData[$fieldName])) {
return $this->fieldData[$fieldName];
}
$this->debugMessage[] = 'GET FIELD: Missing field name in getField: ' . $fieldName;
return false;
} | [
"public",
"function",
"getField",
"(",
"$",
"fieldName",
"=",
"''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"fieldName",
"]",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'GET FIELD: Missing field name in getField: '",
".",
"$",
"fieldName",
";",
"return",
"false",
";",
"}"
] | Getter method for fields
@param string $fieldName Name of the field
@return array Data of field | [
"Getter",
"method",
"for",
"fields"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L255-L262 |
28,903 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.setField | public function setField($fieldName = '', $fieldValue = '')
{
if (in_array($fieldName, array_keys($this->validFields))) {
$this->fieldData[$fieldName] = $this->cleanString($fieldValue);
if ($fieldName == 'LU_ENABLE_TOKEN') {
if ($fieldValue) {
$this->fieldData['LU_TOKEN_TYPE'] = 'PAY_BY_CLICK';
}
}
return true;
}
$this->debugMessage[] = 'SET FIELD: Invalid field in setField: ' . $fieldName;
return false;
} | php | public function setField($fieldName = '', $fieldValue = '')
{
if (in_array($fieldName, array_keys($this->validFields))) {
$this->fieldData[$fieldName] = $this->cleanString($fieldValue);
if ($fieldName == 'LU_ENABLE_TOKEN') {
if ($fieldValue) {
$this->fieldData['LU_TOKEN_TYPE'] = 'PAY_BY_CLICK';
}
}
return true;
}
$this->debugMessage[] = 'SET FIELD: Invalid field in setField: ' . $fieldName;
return false;
} | [
"public",
"function",
"setField",
"(",
"$",
"fieldName",
"=",
"''",
",",
"$",
"fieldValue",
"=",
"''",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fieldName",
",",
"array_keys",
"(",
"$",
"this",
"->",
"validFields",
")",
")",
")",
"{",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"cleanString",
"(",
"$",
"fieldValue",
")",
";",
"if",
"(",
"$",
"fieldName",
"==",
"'LU_ENABLE_TOKEN'",
")",
"{",
"if",
"(",
"$",
"fieldValue",
")",
"{",
"$",
"this",
"->",
"fieldData",
"[",
"'LU_TOKEN_TYPE'",
"]",
"=",
"'PAY_BY_CLICK'",
";",
"}",
"}",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'SET FIELD: Invalid field in setField: '",
".",
"$",
"fieldName",
";",
"return",
"false",
";",
"}"
] | Setter method for fields
@param string $fieldName Name of the field to be set
@param imxed $fieldValue Value of the field to be set
@return boolean | [
"Setter",
"method",
"for",
"fields"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L273-L286 |
28,904 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.prepareFields | protected function prepareFields($hashName = '')
{
if (!is_string($hashName)) {
$this->errorMessage[] = 'PREPARE: Hash name is not string!';
return false;
}
$this->setHashData();
$this->setFormData();
if ($this->hashData) {
$this->formData[$hashName] = $this->createHashString($this->hashData);
}
$this->checkRequired();
if (count($this->missing) == 0) {
return true;
}
$this->debugMessage[] = 'PREPARE: Missing required fields';
$this->errorMessage[] = 'PREPARE: Missing required fields';
return false;
} | php | protected function prepareFields($hashName = '')
{
if (!is_string($hashName)) {
$this->errorMessage[] = 'PREPARE: Hash name is not string!';
return false;
}
$this->setHashData();
$this->setFormData();
if ($this->hashData) {
$this->formData[$hashName] = $this->createHashString($this->hashData);
}
$this->checkRequired();
if (count($this->missing) == 0) {
return true;
}
$this->debugMessage[] = 'PREPARE: Missing required fields';
$this->errorMessage[] = 'PREPARE: Missing required fields';
return false;
} | [
"protected",
"function",
"prepareFields",
"(",
"$",
"hashName",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"hashName",
")",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'PREPARE: Hash name is not string!'",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setHashData",
"(",
")",
";",
"$",
"this",
"->",
"setFormData",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hashData",
")",
"{",
"$",
"this",
"->",
"formData",
"[",
"$",
"hashName",
"]",
"=",
"$",
"this",
"->",
"createHashString",
"(",
"$",
"this",
"->",
"hashData",
")",
";",
"}",
"$",
"this",
"->",
"checkRequired",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"missing",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'PREPARE: Missing required fields'",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'PREPARE: Missing required fields'",
";",
"return",
"false",
";",
"}"
] | Finalizes and prepares fields for sending
@param string $hashName Name of the field containing HMAC HASH code
@return boolean | [
"Finalizes",
"and",
"prepares",
"fields",
"for",
"sending"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L321-L339 |
28,905 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.setHashData | protected function setHashData()
{
foreach ($this->hashFields as $field) {
$params = $this->validFields[$field];
if ($params['type'] == "single") {
if (isset($this->fieldData[$field])) {
$this->hashData[] = $this->fieldData[$field];
}
} elseif ($params['type'] == "product") {
foreach ($this->products as $product) {
if (isset($product[$params["paramName"]])) {
$this->hashData[] = $product[$params["paramName"]];
}
}
}
}
} | php | protected function setHashData()
{
foreach ($this->hashFields as $field) {
$params = $this->validFields[$field];
if ($params['type'] == "single") {
if (isset($this->fieldData[$field])) {
$this->hashData[] = $this->fieldData[$field];
}
} elseif ($params['type'] == "product") {
foreach ($this->products as $product) {
if (isset($product[$params["paramName"]])) {
$this->hashData[] = $product[$params["paramName"]];
}
}
}
}
} | [
"protected",
"function",
"setHashData",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"hashFields",
"as",
"$",
"field",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"validFields",
"[",
"$",
"field",
"]",
";",
"if",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"single\"",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"this",
"->",
"hashData",
"[",
"]",
"=",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"product\"",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"products",
"as",
"$",
"product",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"product",
"[",
"$",
"params",
"[",
"\"paramName\"",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"hashData",
"[",
"]",
"=",
"$",
"product",
"[",
"$",
"params",
"[",
"\"paramName\"",
"]",
"]",
";",
"}",
"}",
"}",
"}",
"}"
] | Set hash data by hashFields
@return void | [
"Set",
"hash",
"data",
"by",
"hashFields"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L347-L363 |
28,906 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.setFormData | protected function setFormData()
{
foreach ($this->validFields as $field => $params) {
if (isset($params["rename"])) {
$field = $params["rename"];
}
if ($params['type'] == "single") {
if (isset($this->fieldData[$field])) {
$this->formData[$field] = $this->fieldData[$field];
}
} elseif ($params['type'] == "product") {
if (!isset($this->formData[$field])) {
$this->formData[$field] = array();
}
foreach ($this->products as $num => $product) {
if (isset($product[$params["paramName"]])) {
$this->formData[$field][$num] = $product[$params["paramName"]];
}
}
}
}
} | php | protected function setFormData()
{
foreach ($this->validFields as $field => $params) {
if (isset($params["rename"])) {
$field = $params["rename"];
}
if ($params['type'] == "single") {
if (isset($this->fieldData[$field])) {
$this->formData[$field] = $this->fieldData[$field];
}
} elseif ($params['type'] == "product") {
if (!isset($this->formData[$field])) {
$this->formData[$field] = array();
}
foreach ($this->products as $num => $product) {
if (isset($product[$params["paramName"]])) {
$this->formData[$field][$num] = $product[$params["paramName"]];
}
}
}
}
} | [
"protected",
"function",
"setFormData",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"validFields",
"as",
"$",
"field",
"=>",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"\"rename\"",
"]",
")",
")",
"{",
"$",
"field",
"=",
"$",
"params",
"[",
"\"rename\"",
"]",
";",
"}",
"if",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"single\"",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"this",
"->",
"formData",
"[",
"$",
"field",
"]",
"=",
"$",
"this",
"->",
"fieldData",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"params",
"[",
"'type'",
"]",
"==",
"\"product\"",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"formData",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"this",
"->",
"formData",
"[",
"$",
"field",
"]",
"=",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"products",
"as",
"$",
"num",
"=>",
"$",
"product",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"product",
"[",
"$",
"params",
"[",
"\"paramName\"",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"formData",
"[",
"$",
"field",
"]",
"[",
"$",
"num",
"]",
"=",
"$",
"product",
"[",
"$",
"params",
"[",
"\"paramName\"",
"]",
"]",
";",
"}",
"}",
"}",
"}",
"}"
] | Set form data by validFields
@return void | [
"Set",
"form",
"data",
"by",
"validFields"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L371-L392 |
28,907 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.processResponse | public function processResponse($resp = '')
{
preg_match_all("/<EPAYMENT>(.*?)<\/EPAYMENT>/", $resp, $matches);
$data = explode("|", $matches[1][0]);
if (is_array($data)) {
if (count($data) > 0) {
$counter = 1;
foreach ($data as $dataValue) {
$this->debugMessage[] = 'EPAYMENT_ELEMENT_' . $counter .': ' . $dataValue;
$counter++;
}
}
}
return $this->nameData($data);
} | php | public function processResponse($resp = '')
{
preg_match_all("/<EPAYMENT>(.*?)<\/EPAYMENT>/", $resp, $matches);
$data = explode("|", $matches[1][0]);
if (is_array($data)) {
if (count($data) > 0) {
$counter = 1;
foreach ($data as $dataValue) {
$this->debugMessage[] = 'EPAYMENT_ELEMENT_' . $counter .': ' . $dataValue;
$counter++;
}
}
}
return $this->nameData($data);
} | [
"public",
"function",
"processResponse",
"(",
"$",
"resp",
"=",
"''",
")",
"{",
"preg_match_all",
"(",
"\"/<EPAYMENT>(.*?)<\\/EPAYMENT>/\"",
",",
"$",
"resp",
",",
"$",
"matches",
")",
";",
"$",
"data",
"=",
"explode",
"(",
"\"|\"",
",",
"$",
"matches",
"[",
"1",
"]",
"[",
"0",
"]",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
">",
"0",
")",
"{",
"$",
"counter",
"=",
"1",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataValue",
")",
"{",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'EPAYMENT_ELEMENT_'",
".",
"$",
"counter",
".",
"': '",
".",
"$",
"dataValue",
";",
"$",
"counter",
"++",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"nameData",
"(",
"$",
"data",
")",
";",
"}"
] | Finds and processes validation response from HTTP response
@param string $resp HTTP response
@return array Data | [
"Finds",
"and",
"processes",
"validation",
"response",
"from",
"HTTP",
"response"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L402-L416 |
28,908 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.checkResponseHash | public function checkResponseHash($resp = array())
{
$hash = 'N/A';
if (isset($resp['ORDER_HASH'])) {
$hash = $resp['ORDER_HASH'];
}
elseif (isset($resp['hash'])) {
$hash = $resp['hash'];
}
array_pop($resp);
$calculated = $this->createHashString($resp);
$this->debugMessage[] = 'HASH ctrl: ' . $hash;
$this->debugMessage[] = 'HASH calculated: ' . $calculated;
if ($hash == $calculated) {
$this->debugMessage[] = 'HASH CHECK: ' . 'Successful';
return true;
}
$this->errorMessage[] = 'HASH ctrl: ' . $hash;
$this->errorMessage[] = 'HASH calculated: ' . $calculated;
$this->errorMessage[] = 'HASH CHECK: ' . 'Fail';
$this->debugMessage[] = 'HASH CHECK: ' . 'Fail';
return false;
} | php | public function checkResponseHash($resp = array())
{
$hash = 'N/A';
if (isset($resp['ORDER_HASH'])) {
$hash = $resp['ORDER_HASH'];
}
elseif (isset($resp['hash'])) {
$hash = $resp['hash'];
}
array_pop($resp);
$calculated = $this->createHashString($resp);
$this->debugMessage[] = 'HASH ctrl: ' . $hash;
$this->debugMessage[] = 'HASH calculated: ' . $calculated;
if ($hash == $calculated) {
$this->debugMessage[] = 'HASH CHECK: ' . 'Successful';
return true;
}
$this->errorMessage[] = 'HASH ctrl: ' . $hash;
$this->errorMessage[] = 'HASH calculated: ' . $calculated;
$this->errorMessage[] = 'HASH CHECK: ' . 'Fail';
$this->debugMessage[] = 'HASH CHECK: ' . 'Fail';
return false;
} | [
"public",
"function",
"checkResponseHash",
"(",
"$",
"resp",
"=",
"array",
"(",
")",
")",
"{",
"$",
"hash",
"=",
"'N/A'",
";",
"if",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'ORDER_HASH'",
"]",
")",
")",
"{",
"$",
"hash",
"=",
"$",
"resp",
"[",
"'ORDER_HASH'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'hash'",
"]",
")",
")",
"{",
"$",
"hash",
"=",
"$",
"resp",
"[",
"'hash'",
"]",
";",
"}",
"array_pop",
"(",
"$",
"resp",
")",
";",
"$",
"calculated",
"=",
"$",
"this",
"->",
"createHashString",
"(",
"$",
"resp",
")",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'HASH ctrl: '",
".",
"$",
"hash",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'HASH calculated: '",
".",
"$",
"calculated",
";",
"if",
"(",
"$",
"hash",
"==",
"$",
"calculated",
")",
"{",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'HASH CHECK: '",
".",
"'Successful'",
";",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'HASH ctrl: '",
".",
"$",
"hash",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'HASH calculated: '",
".",
"$",
"calculated",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'HASH CHECK: '",
".",
"'Fail'",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'HASH CHECK: '",
".",
"'Fail'",
";",
"return",
"false",
";",
"}"
] | Validates HASH code of the response
@param array $resp Array with the response data
@return boolean | [
"Validates",
"HASH",
"code",
"of",
"the",
"response"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L426-L449 |
28,909 | netgen/site-bundle | bundle/DependencyInjection/Compiler/XmlTextFieldTypePass.php | XmlTextFieldTypePass.process | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.fieldType.ezxmltext.converter.embedToHtml5')) {
$container
->findDefinition('ezpublish.fieldType.ezxmltext.converter.embedToHtml5')
->setClass(EmbedToHtml5::class)
->addMethodCall('setSite', [new Reference('netgen.ezplatform_site.site')]);
}
} | php | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.fieldType.ezxmltext.converter.embedToHtml5')) {
$container
->findDefinition('ezpublish.fieldType.ezxmltext.converter.embedToHtml5')
->setClass(EmbedToHtml5::class)
->addMethodCall('setSite', [new Reference('netgen.ezplatform_site.site')]);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"$",
"container",
"->",
"has",
"(",
"'ezpublish.fieldType.ezxmltext.converter.embedToHtml5'",
")",
")",
"{",
"$",
"container",
"->",
"findDefinition",
"(",
"'ezpublish.fieldType.ezxmltext.converter.embedToHtml5'",
")",
"->",
"setClass",
"(",
"EmbedToHtml5",
"::",
"class",
")",
"->",
"addMethodCall",
"(",
"'setSite'",
",",
"[",
"new",
"Reference",
"(",
"'netgen.ezplatform_site.site'",
")",
"]",
")",
";",
"}",
"}"
] | Overrides EmbedToHtml5 ezxmltext converter with own implementation. | [
"Overrides",
"EmbedToHtml5",
"ezxmltext",
"converter",
"with",
"own",
"implementation",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/DependencyInjection/Compiler/XmlTextFieldTypePass.php#L17-L25 |
28,910 | netgen/site-bundle | bundle/Pagerfanta/View/SiteView.php | SiteView.calculateEndPageForStartPageUnderflow | protected function calculateEndPageForStartPageUnderflow(int $startPage, int $endPage, int $nbPages): int
{
return min($endPage + (1 - $startPage), $nbPages);
} | php | protected function calculateEndPageForStartPageUnderflow(int $startPage, int $endPage, int $nbPages): int
{
return min($endPage + (1 - $startPage), $nbPages);
} | [
"protected",
"function",
"calculateEndPageForStartPageUnderflow",
"(",
"int",
"$",
"startPage",
",",
"int",
"$",
"endPage",
",",
"int",
"$",
"nbPages",
")",
":",
"int",
"{",
"return",
"min",
"(",
"$",
"endPage",
"+",
"(",
"1",
"-",
"$",
"startPage",
")",
",",
"$",
"nbPages",
")",
";",
"}"
] | Calculates the end page when start page is underflowed. | [
"Calculates",
"the",
"end",
"page",
"when",
"start",
"page",
"is",
"underflowed",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Pagerfanta/View/SiteView.php#L139-L142 |
28,911 | netgen/site-bundle | bundle/Pagerfanta/View/SiteView.php | SiteView.calculateStartPageForEndPageOverflow | protected function calculateStartPageForEndPageOverflow(int $startPage, int $endPage, int $nbPages): int
{
return max($startPage - ($endPage - $nbPages), 1);
} | php | protected function calculateStartPageForEndPageOverflow(int $startPage, int $endPage, int $nbPages): int
{
return max($startPage - ($endPage - $nbPages), 1);
} | [
"protected",
"function",
"calculateStartPageForEndPageOverflow",
"(",
"int",
"$",
"startPage",
",",
"int",
"$",
"endPage",
",",
"int",
"$",
"nbPages",
")",
":",
"int",
"{",
"return",
"max",
"(",
"$",
"startPage",
"-",
"(",
"$",
"endPage",
"-",
"$",
"nbPages",
")",
",",
"1",
")",
";",
"}"
] | Calculates the start page when end page is overflowed. | [
"Calculates",
"the",
"start",
"page",
"when",
"end",
"page",
"is",
"overflowed",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Pagerfanta/View/SiteView.php#L147-L150 |
28,912 | netgen/site-bundle | bundle/Pagerfanta/View/SiteView.php | SiteView.getPages | protected function getPages(): array
{
$pages = [];
$pages['previous_page'] = $this->pagerfanta->hasPreviousPage() ?
$this->generateUrl($this->pagerfanta->getPreviousPage()) :
false;
$pages['first_page'] = $this->startPage > 1 ? $this->generateUrl(1) : false;
$pages['mobile_first_page'] = $this->pagerfanta->getCurrentPage() > 2 ? $this->generateUrl(1) : false;
$pages['second_page'] = $this->startPage === 3 ? $this->generateUrl(2) : false;
$pages['separator_before'] = $this->startPage > 3;
$middlePages = [];
for ($i = $this->startPage, $end = $this->endPage; $i <= $end; ++$i) {
$middlePages[$i] = $this->generateUrl($i);
}
$pages['middle_pages'] = $middlePages;
$pages['separator_after'] = $this->endPage < $this->pagerfanta->getNbPages() - 2;
$pages['second_to_last_page'] = $this->endPage === $this->pagerfanta->getNbPages() - 2 ?
$this->generateUrl($this->pagerfanta->getNbPages() - 1) :
false;
$pages['last_page'] = $this->pagerfanta->getNbPages() > $this->endPage ?
$this->generateUrl($this->pagerfanta->getNbPages()) :
false;
$pages['mobile_last_page'] = $this->pagerfanta->getCurrentPage() < $this->pagerfanta->getNbPages() - 1 ?
$this->generateUrl($this->pagerfanta->getNbPages()) :
false;
$pages['next_page'] = $this->pagerfanta->hasNextPage() ?
$this->generateUrl($this->pagerfanta->getNextPage()) :
false;
return $pages;
} | php | protected function getPages(): array
{
$pages = [];
$pages['previous_page'] = $this->pagerfanta->hasPreviousPage() ?
$this->generateUrl($this->pagerfanta->getPreviousPage()) :
false;
$pages['first_page'] = $this->startPage > 1 ? $this->generateUrl(1) : false;
$pages['mobile_first_page'] = $this->pagerfanta->getCurrentPage() > 2 ? $this->generateUrl(1) : false;
$pages['second_page'] = $this->startPage === 3 ? $this->generateUrl(2) : false;
$pages['separator_before'] = $this->startPage > 3;
$middlePages = [];
for ($i = $this->startPage, $end = $this->endPage; $i <= $end; ++$i) {
$middlePages[$i] = $this->generateUrl($i);
}
$pages['middle_pages'] = $middlePages;
$pages['separator_after'] = $this->endPage < $this->pagerfanta->getNbPages() - 2;
$pages['second_to_last_page'] = $this->endPage === $this->pagerfanta->getNbPages() - 2 ?
$this->generateUrl($this->pagerfanta->getNbPages() - 1) :
false;
$pages['last_page'] = $this->pagerfanta->getNbPages() > $this->endPage ?
$this->generateUrl($this->pagerfanta->getNbPages()) :
false;
$pages['mobile_last_page'] = $this->pagerfanta->getCurrentPage() < $this->pagerfanta->getNbPages() - 1 ?
$this->generateUrl($this->pagerfanta->getNbPages()) :
false;
$pages['next_page'] = $this->pagerfanta->hasNextPage() ?
$this->generateUrl($this->pagerfanta->getNextPage()) :
false;
return $pages;
} | [
"protected",
"function",
"getPages",
"(",
")",
":",
"array",
"{",
"$",
"pages",
"=",
"[",
"]",
";",
"$",
"pages",
"[",
"'previous_page'",
"]",
"=",
"$",
"this",
"->",
"pagerfanta",
"->",
"hasPreviousPage",
"(",
")",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"pagerfanta",
"->",
"getPreviousPage",
"(",
")",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'first_page'",
"]",
"=",
"$",
"this",
"->",
"startPage",
">",
"1",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"1",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'mobile_first_page'",
"]",
"=",
"$",
"this",
"->",
"pagerfanta",
"->",
"getCurrentPage",
"(",
")",
">",
"2",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"1",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'second_page'",
"]",
"=",
"$",
"this",
"->",
"startPage",
"===",
"3",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"2",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'separator_before'",
"]",
"=",
"$",
"this",
"->",
"startPage",
">",
"3",
";",
"$",
"middlePages",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"startPage",
",",
"$",
"end",
"=",
"$",
"this",
"->",
"endPage",
";",
"$",
"i",
"<=",
"$",
"end",
";",
"++",
"$",
"i",
")",
"{",
"$",
"middlePages",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"i",
")",
";",
"}",
"$",
"pages",
"[",
"'middle_pages'",
"]",
"=",
"$",
"middlePages",
";",
"$",
"pages",
"[",
"'separator_after'",
"]",
"=",
"$",
"this",
"->",
"endPage",
"<",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
"-",
"2",
";",
"$",
"pages",
"[",
"'second_to_last_page'",
"]",
"=",
"$",
"this",
"->",
"endPage",
"===",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
"-",
"2",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
"-",
"1",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'last_page'",
"]",
"=",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
">",
"$",
"this",
"->",
"endPage",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'mobile_last_page'",
"]",
"=",
"$",
"this",
"->",
"pagerfanta",
"->",
"getCurrentPage",
"(",
")",
"<",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
"-",
"1",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNbPages",
"(",
")",
")",
":",
"false",
";",
"$",
"pages",
"[",
"'next_page'",
"]",
"=",
"$",
"this",
"->",
"pagerfanta",
"->",
"hasNextPage",
"(",
")",
"?",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"pagerfanta",
"->",
"getNextPage",
"(",
")",
")",
":",
"false",
";",
"return",
"$",
"pages",
";",
"}"
] | Returns the list of all pages that need to be displayed. | [
"Returns",
"the",
"list",
"of",
"all",
"pages",
"that",
"need",
"to",
"be",
"displayed",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Pagerfanta/View/SiteView.php#L155-L196 |
28,913 | netgen/site-bundle | bundle/Pagerfanta/View/SiteView.php | SiteView.generateUrl | protected function generateUrl(int $page): string
{
$routeGenerator = $this->routeGenerator;
// We use trim here because Pagerfanta (or Symfony?) adds an extra '?'
// at the end of page when there are no other query params
return trim($routeGenerator($page), '?');
} | php | protected function generateUrl(int $page): string
{
$routeGenerator = $this->routeGenerator;
// We use trim here because Pagerfanta (or Symfony?) adds an extra '?'
// at the end of page when there are no other query params
return trim($routeGenerator($page), '?');
} | [
"protected",
"function",
"generateUrl",
"(",
"int",
"$",
"page",
")",
":",
"string",
"{",
"$",
"routeGenerator",
"=",
"$",
"this",
"->",
"routeGenerator",
";",
"// We use trim here because Pagerfanta (or Symfony?) adds an extra '?'",
"// at the end of page when there are no other query params",
"return",
"trim",
"(",
"$",
"routeGenerator",
"(",
"$",
"page",
")",
",",
"'?'",
")",
";",
"}"
] | Generates the URL based on provided page. | [
"Generates",
"the",
"URL",
"based",
"on",
"provided",
"page",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Pagerfanta/View/SiteView.php#L201-L208 |
28,914 | netgen/site-bundle | bundle/Controller/DownloadController.php | DownloadController.downloadFile | public function downloadFile(Request $request, $contentId, $fieldId, $isInline = false): BinaryStreamResponse
{
$content = $this->getSite()->getLoadService()->loadContent(
$contentId,
$request->query->get('version'),
$request->query->get('inLanguage')
);
if (!$content->hasFieldById($fieldId) || $content->getFieldById($fieldId)->isEmpty()) {
throw new NotFoundHttpException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
$binaryFieldValue = $content->getFieldById($fieldId)->value;
if ($binaryFieldValue instanceof BinaryBaseValue) {
$ioService = $this->ioFileService;
$binaryFile = $this->ioFileService->loadBinaryFile($binaryFieldValue->id);
} elseif ($binaryFieldValue instanceof ImageValue) {
$ioService = $this->ioImageService;
$binaryFile = $this->ioImageService->loadBinaryFile($binaryFieldValue->id);
} else {
throw new NotFoundHttpException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
$response = new BinaryStreamResponse($binaryFile, $ioService);
$response->setContentDisposition(
(bool) $isInline ? ResponseHeaderBag::DISPOSITION_INLINE :
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
str_replace(['/', '\\'], '', $binaryFieldValue->fileName),
'file'
);
if (!$request->headers->has('Range')) {
$downloadEvent = new DownloadEvent(
$contentId,
$fieldId,
$content->contentInfo->currentVersionNo,
$response
);
$this->dispatcher->dispatch(SiteEvents::CONTENT_DOWNLOAD, $downloadEvent);
}
return $response;
} | php | public function downloadFile(Request $request, $contentId, $fieldId, $isInline = false): BinaryStreamResponse
{
$content = $this->getSite()->getLoadService()->loadContent(
$contentId,
$request->query->get('version'),
$request->query->get('inLanguage')
);
if (!$content->hasFieldById($fieldId) || $content->getFieldById($fieldId)->isEmpty()) {
throw new NotFoundHttpException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
$binaryFieldValue = $content->getFieldById($fieldId)->value;
if ($binaryFieldValue instanceof BinaryBaseValue) {
$ioService = $this->ioFileService;
$binaryFile = $this->ioFileService->loadBinaryFile($binaryFieldValue->id);
} elseif ($binaryFieldValue instanceof ImageValue) {
$ioService = $this->ioImageService;
$binaryFile = $this->ioImageService->loadBinaryFile($binaryFieldValue->id);
} else {
throw new NotFoundHttpException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
$response = new BinaryStreamResponse($binaryFile, $ioService);
$response->setContentDisposition(
(bool) $isInline ? ResponseHeaderBag::DISPOSITION_INLINE :
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
str_replace(['/', '\\'], '', $binaryFieldValue->fileName),
'file'
);
if (!$request->headers->has('Range')) {
$downloadEvent = new DownloadEvent(
$contentId,
$fieldId,
$content->contentInfo->currentVersionNo,
$response
);
$this->dispatcher->dispatch(SiteEvents::CONTENT_DOWNLOAD, $downloadEvent);
}
return $response;
} | [
"public",
"function",
"downloadFile",
"(",
"Request",
"$",
"request",
",",
"$",
"contentId",
",",
"$",
"fieldId",
",",
"$",
"isInline",
"=",
"false",
")",
":",
"BinaryStreamResponse",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getSite",
"(",
")",
"->",
"getLoadService",
"(",
")",
"->",
"loadContent",
"(",
"$",
"contentId",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'version'",
")",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'inLanguage'",
")",
")",
";",
"if",
"(",
"!",
"$",
"content",
"->",
"hasFieldById",
"(",
"$",
"fieldId",
")",
"||",
"$",
"content",
"->",
"getFieldById",
"(",
"$",
"fieldId",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"'download.file_not_found'",
",",
"[",
"]",
",",
"'ngsite'",
")",
")",
";",
"}",
"$",
"binaryFieldValue",
"=",
"$",
"content",
"->",
"getFieldById",
"(",
"$",
"fieldId",
")",
"->",
"value",
";",
"if",
"(",
"$",
"binaryFieldValue",
"instanceof",
"BinaryBaseValue",
")",
"{",
"$",
"ioService",
"=",
"$",
"this",
"->",
"ioFileService",
";",
"$",
"binaryFile",
"=",
"$",
"this",
"->",
"ioFileService",
"->",
"loadBinaryFile",
"(",
"$",
"binaryFieldValue",
"->",
"id",
")",
";",
"}",
"elseif",
"(",
"$",
"binaryFieldValue",
"instanceof",
"ImageValue",
")",
"{",
"$",
"ioService",
"=",
"$",
"this",
"->",
"ioImageService",
";",
"$",
"binaryFile",
"=",
"$",
"this",
"->",
"ioImageService",
"->",
"loadBinaryFile",
"(",
"$",
"binaryFieldValue",
"->",
"id",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"'download.file_not_found'",
",",
"[",
"]",
",",
"'ngsite'",
")",
")",
";",
"}",
"$",
"response",
"=",
"new",
"BinaryStreamResponse",
"(",
"$",
"binaryFile",
",",
"$",
"ioService",
")",
";",
"$",
"response",
"->",
"setContentDisposition",
"(",
"(",
"bool",
")",
"$",
"isInline",
"?",
"ResponseHeaderBag",
"::",
"DISPOSITION_INLINE",
":",
"ResponseHeaderBag",
"::",
"DISPOSITION_ATTACHMENT",
",",
"str_replace",
"(",
"[",
"'/'",
",",
"'\\\\'",
"]",
",",
"''",
",",
"$",
"binaryFieldValue",
"->",
"fileName",
")",
",",
"'file'",
")",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"'Range'",
")",
")",
"{",
"$",
"downloadEvent",
"=",
"new",
"DownloadEvent",
"(",
"$",
"contentId",
",",
"$",
"fieldId",
",",
"$",
"content",
"->",
"contentInfo",
"->",
"currentVersionNo",
",",
"$",
"response",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"CONTENT_DOWNLOAD",
",",
"$",
"downloadEvent",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Downloads the binary file specified by content ID and field ID.
Assumes that the file is locally stored
Dispatch \Netgen\Bundle\SiteBundle\Event\SiteEvents::CONTENT_DOWNLOAD only once
@param \Symfony\Component\HttpFoundation\Request $request
@param mixed $contentId
@param mixed $fieldId
@param bool $isInline
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If file or image does not exist
@return \eZ\Bundle\EzPublishIOBundle\BinaryStreamResponse | [
"Downloads",
"the",
"binary",
"file",
"specified",
"by",
"content",
"ID",
"and",
"field",
"ID",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/DownloadController.php#L69-L117 |
28,915 | smartboxgroup/integration-framework-bundle | Components/WebService/Soap/AbstractSoapConfigurableProducer.php | AbstractSoapConfigurableProducer.throwRecoverableSoapFaultException | protected function throwRecoverableSoapFaultException($message, $code = 0, $previousException = null)
{
/* @var \SoapClient $soapClient */
$exception = new RecoverableSoapException(
$message,
null,
null,
null,
null,
$code,
$previousException
);
$exception->setShowExternalSystemErrorMessage(true);
$exception->setExternalSystemName($this->getName());
throw $exception;
} | php | protected function throwRecoverableSoapFaultException($message, $code = 0, $previousException = null)
{
/* @var \SoapClient $soapClient */
$exception = new RecoverableSoapException(
$message,
null,
null,
null,
null,
$code,
$previousException
);
$exception->setShowExternalSystemErrorMessage(true);
$exception->setExternalSystemName($this->getName());
throw $exception;
} | [
"protected",
"function",
"throwRecoverableSoapFaultException",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"0",
",",
"$",
"previousException",
"=",
"null",
")",
"{",
"/* @var \\SoapClient $soapClient */",
"$",
"exception",
"=",
"new",
"RecoverableSoapException",
"(",
"$",
"message",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"code",
",",
"$",
"previousException",
")",
";",
"$",
"exception",
"->",
"setShowExternalSystemErrorMessage",
"(",
"true",
")",
";",
"$",
"exception",
"->",
"setExternalSystemName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"throw",
"$",
"exception",
";",
"}"
] | Throw a RecoverableSoapFault when SoapClient construct failed.
@param \SoapClient $soapClient
@param int $code
@param null $previousException
@throws \Smartbox\Integration\FrameworkBundle\Components\WebService\Soap\Exceptions\RecoverableSoapException | [
"Throw",
"a",
"RecoverableSoapFault",
"when",
"SoapClient",
"construct",
"failed",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/WebService/Soap/AbstractSoapConfigurableProducer.php#L230-L246 |
28,916 | netgen/site-bundle | bundle/Controller/SearchController.php | SearchController.search | public function search(Request $request): Response
{
$configResolver = $this->getConfigResolver();
$queryType = $this->getQueryTypeRegistry()->getQueryType('NetgenSite:Search');
$searchText = trim($request->query->get('searchText', ''));
if (empty($searchText)) {
return $this->render(
$configResolver->getParameter('template.search', 'ngsite'),
[
'search_text' => '',
'pager' => null,
]
);
}
$pager = new Pagerfanta(
new FindAdapter(
$queryType->getQuery(['search_text' => $searchText]),
$this->getSite()->getFindService()
)
);
$pager->setNormalizeOutOfRangePages(true);
$pager->setMaxPerPage((int) $configResolver->getParameter('search.default_limit', 'ngsite'));
$currentPage = $request->query->getInt('page', 1);
$pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);
return $this->render(
$configResolver->getParameter('template.search', 'ngsite'),
[
'search_text' => $searchText,
'pager' => $pager,
]
);
} | php | public function search(Request $request): Response
{
$configResolver = $this->getConfigResolver();
$queryType = $this->getQueryTypeRegistry()->getQueryType('NetgenSite:Search');
$searchText = trim($request->query->get('searchText', ''));
if (empty($searchText)) {
return $this->render(
$configResolver->getParameter('template.search', 'ngsite'),
[
'search_text' => '',
'pager' => null,
]
);
}
$pager = new Pagerfanta(
new FindAdapter(
$queryType->getQuery(['search_text' => $searchText]),
$this->getSite()->getFindService()
)
);
$pager->setNormalizeOutOfRangePages(true);
$pager->setMaxPerPage((int) $configResolver->getParameter('search.default_limit', 'ngsite'));
$currentPage = $request->query->getInt('page', 1);
$pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);
return $this->render(
$configResolver->getParameter('template.search', 'ngsite'),
[
'search_text' => $searchText,
'pager' => $pager,
]
);
} | [
"public",
"function",
"search",
"(",
"Request",
"$",
"request",
")",
":",
"Response",
"{",
"$",
"configResolver",
"=",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
";",
"$",
"queryType",
"=",
"$",
"this",
"->",
"getQueryTypeRegistry",
"(",
")",
"->",
"getQueryType",
"(",
"'NetgenSite:Search'",
")",
";",
"$",
"searchText",
"=",
"trim",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'searchText'",
",",
"''",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"searchText",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"configResolver",
"->",
"getParameter",
"(",
"'template.search'",
",",
"'ngsite'",
")",
",",
"[",
"'search_text'",
"=>",
"''",
",",
"'pager'",
"=>",
"null",
",",
"]",
")",
";",
"}",
"$",
"pager",
"=",
"new",
"Pagerfanta",
"(",
"new",
"FindAdapter",
"(",
"$",
"queryType",
"->",
"getQuery",
"(",
"[",
"'search_text'",
"=>",
"$",
"searchText",
"]",
")",
",",
"$",
"this",
"->",
"getSite",
"(",
")",
"->",
"getFindService",
"(",
")",
")",
")",
";",
"$",
"pager",
"->",
"setNormalizeOutOfRangePages",
"(",
"true",
")",
";",
"$",
"pager",
"->",
"setMaxPerPage",
"(",
"(",
"int",
")",
"$",
"configResolver",
"->",
"getParameter",
"(",
"'search.default_limit'",
",",
"'ngsite'",
")",
")",
";",
"$",
"currentPage",
"=",
"$",
"request",
"->",
"query",
"->",
"getInt",
"(",
"'page'",
",",
"1",
")",
";",
"$",
"pager",
"->",
"setCurrentPage",
"(",
"$",
"currentPage",
">",
"0",
"?",
"$",
"currentPage",
":",
"1",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"configResolver",
"->",
"getParameter",
"(",
"'template.search'",
",",
"'ngsite'",
")",
",",
"[",
"'search_text'",
"=>",
"$",
"searchText",
",",
"'pager'",
"=>",
"$",
"pager",
",",
"]",
")",
";",
"}"
] | Action for displaying the results of full text search. | [
"Action",
"for",
"displaying",
"the",
"results",
"of",
"full",
"text",
"search",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/SearchController.php#L17-L54 |
28,917 | nilportugues/php-api-transformer | src/Transformer/Transformer.php | Transformer.recursiveSetKeysToUnderScore | protected function recursiveSetKeysToUnderScore(array &$array)
{
$newArray = [];
foreach ($array as $key => &$value) {
$underscoreKey = RecursiveFormatterHelper::camelCaseToUnderscore($key);
$newArray[$underscoreKey] = $value;
if (\is_array($value)) {
$this->recursiveSetKeysToUnderScore($newArray[$underscoreKey]);
}
}
$array = $newArray;
} | php | protected function recursiveSetKeysToUnderScore(array &$array)
{
$newArray = [];
foreach ($array as $key => &$value) {
$underscoreKey = RecursiveFormatterHelper::camelCaseToUnderscore($key);
$newArray[$underscoreKey] = $value;
if (\is_array($value)) {
$this->recursiveSetKeysToUnderScore($newArray[$underscoreKey]);
}
}
$array = $newArray;
} | [
"protected",
"function",
"recursiveSetKeysToUnderScore",
"(",
"array",
"&",
"$",
"array",
")",
"{",
"$",
"newArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"$",
"underscoreKey",
"=",
"RecursiveFormatterHelper",
"::",
"camelCaseToUnderscore",
"(",
"$",
"key",
")",
";",
"$",
"newArray",
"[",
"$",
"underscoreKey",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"recursiveSetKeysToUnderScore",
"(",
"$",
"newArray",
"[",
"$",
"underscoreKey",
"]",
")",
";",
"}",
"}",
"$",
"array",
"=",
"$",
"newArray",
";",
"}"
] | Changes all array keys to under_score format using recursion.
@param array $array | [
"Changes",
"all",
"array",
"keys",
"to",
"under_score",
"format",
"using",
"recursion",
"."
] | a9f20fbe1580d98e3d462a0ebe13fb7595cbd683 | https://github.com/nilportugues/php-api-transformer/blob/a9f20fbe1580d98e3d462a0ebe13fb7595cbd683/src/Transformer/Transformer.php#L125-L137 |
28,918 | smartboxgroup/integration-framework-bundle | Core/Processors/Routing/ContentRouter.php | ContentRouter.doProcess | protected function doProcess(Exchange $exchange, SerializableArray $processingContext)
{
$evaluator = $this->getEvaluator();
foreach ($this->clauses as $clause) {
if ($evaluator->evaluateWithExchange($clause->getCondition(), $exchange)) {
$exchange->getItinerary()->prepend($clause->getItinerary());
$processingContext->set(self::CONDITION_MATCHED, $clause->getCondition());
return true;
}
}
if ($this->fallbackItinerary) {
$exchange->getItinerary()->prepend($this->fallbackItinerary);
$processingContext->set(self::CONDITION_MATCHED, 'fallback itinerary');
return true;
}
return false;
} | php | protected function doProcess(Exchange $exchange, SerializableArray $processingContext)
{
$evaluator = $this->getEvaluator();
foreach ($this->clauses as $clause) {
if ($evaluator->evaluateWithExchange($clause->getCondition(), $exchange)) {
$exchange->getItinerary()->prepend($clause->getItinerary());
$processingContext->set(self::CONDITION_MATCHED, $clause->getCondition());
return true;
}
}
if ($this->fallbackItinerary) {
$exchange->getItinerary()->prepend($this->fallbackItinerary);
$processingContext->set(self::CONDITION_MATCHED, 'fallback itinerary');
return true;
}
return false;
} | [
"protected",
"function",
"doProcess",
"(",
"Exchange",
"$",
"exchange",
",",
"SerializableArray",
"$",
"processingContext",
")",
"{",
"$",
"evaluator",
"=",
"$",
"this",
"->",
"getEvaluator",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"clauses",
"as",
"$",
"clause",
")",
"{",
"if",
"(",
"$",
"evaluator",
"->",
"evaluateWithExchange",
"(",
"$",
"clause",
"->",
"getCondition",
"(",
")",
",",
"$",
"exchange",
")",
")",
"{",
"$",
"exchange",
"->",
"getItinerary",
"(",
")",
"->",
"prepend",
"(",
"$",
"clause",
"->",
"getItinerary",
"(",
")",
")",
";",
"$",
"processingContext",
"->",
"set",
"(",
"self",
"::",
"CONDITION_MATCHED",
",",
"$",
"clause",
"->",
"getCondition",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"fallbackItinerary",
")",
"{",
"$",
"exchange",
"->",
"getItinerary",
"(",
")",
"->",
"prepend",
"(",
"$",
"this",
"->",
"fallbackItinerary",
")",
";",
"$",
"processingContext",
"->",
"set",
"(",
"self",
"::",
"CONDITION_MATCHED",
",",
"'fallback itinerary'",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | The content router will evaluate the list of when clauses for the given exchange until one of them returns true,
then the itinerary of the exchange will be updated with the one specified for the when clause.
In case that no when clause matches, if there is a fallbackItinerary defined, the exchange will be updated with it,
otherwise nothing will happen.
todo: Check what should be the behaviour when no when clause is matched and no fallbackItinerary is defined
@param Exchange $exchange
@return bool | [
"The",
"content",
"router",
"will",
"evaluate",
"the",
"list",
"of",
"when",
"clauses",
"for",
"the",
"given",
"exchange",
"until",
"one",
"of",
"them",
"returns",
"true",
"then",
"the",
"itinerary",
"of",
"the",
"exchange",
"will",
"be",
"updated",
"with",
"the",
"one",
"specified",
"for",
"the",
"when",
"clause",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Processors/Routing/ContentRouter.php#L63-L84 |
28,919 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.getFilters | protected function getFilters()
{
$filters = array_diff(get_class_methods($this), [
'__construct', '__call', 'apply', 'getFilters', 'getSearchables', 'getSortables', 'buildSearch', 'buildSql'
]);
$filters = array_merge($filters, array_map(function ($searchable, $key) {
return is_array($searchable) ? $key : $searchable;
}, $this->searchables, array_keys($this->searchables)));
return array_only($this->request->query(), $filters);
} | php | protected function getFilters()
{
$filters = array_diff(get_class_methods($this), [
'__construct', '__call', 'apply', 'getFilters', 'getSearchables', 'getSortables', 'buildSearch', 'buildSql'
]);
$filters = array_merge($filters, array_map(function ($searchable, $key) {
return is_array($searchable) ? $key : $searchable;
}, $this->searchables, array_keys($this->searchables)));
return array_only($this->request->query(), $filters);
} | [
"protected",
"function",
"getFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"array_diff",
"(",
"get_class_methods",
"(",
"$",
"this",
")",
",",
"[",
"'__construct'",
",",
"'__call'",
",",
"'apply'",
",",
"'getFilters'",
",",
"'getSearchables'",
",",
"'getSortables'",
",",
"'buildSearch'",
",",
"'buildSql'",
"]",
")",
";",
"$",
"filters",
"=",
"array_merge",
"(",
"$",
"filters",
",",
"array_map",
"(",
"function",
"(",
"$",
"searchable",
",",
"$",
"key",
")",
"{",
"return",
"is_array",
"(",
"$",
"searchable",
")",
"?",
"$",
"key",
":",
"$",
"searchable",
";",
"}",
",",
"$",
"this",
"->",
"searchables",
",",
"array_keys",
"(",
"$",
"this",
"->",
"searchables",
")",
")",
")",
";",
"return",
"array_only",
"(",
"$",
"this",
"->",
"request",
"->",
"query",
"(",
")",
",",
"$",
"filters",
")",
";",
"}"
] | Fetch all relevant filters from the request.
@return array | [
"Fetch",
"all",
"relevant",
"filters",
"from",
"the",
"request",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L63-L73 |
28,920 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.buildSearch | protected function buildSearch($query, $searchables, $value)
{
foreach ($searchables as $key => $searchable) {
if (is_array($searchable)) {
$query->orWhereHas($key, function (Builder $query) use($searchable, $value) {
$query->where(function (Builder $query) use($searchable, $value) {
$this->buildSearch($query, $searchable, $value);
});
});
} else {
if ($query->getConnection()->getDriverName() == 'pgsql')
$query->orWhere($query->qualifyColumn($searchable), 'ilike', '%'.str_replace(' ', '%', $value).'%');
else
$query->orWhere($query->qualifyColumn($searchable), 'like', '%'.str_replace(' ', '%', $value).'%');
}
}
} | php | protected function buildSearch($query, $searchables, $value)
{
foreach ($searchables as $key => $searchable) {
if (is_array($searchable)) {
$query->orWhereHas($key, function (Builder $query) use($searchable, $value) {
$query->where(function (Builder $query) use($searchable, $value) {
$this->buildSearch($query, $searchable, $value);
});
});
} else {
if ($query->getConnection()->getDriverName() == 'pgsql')
$query->orWhere($query->qualifyColumn($searchable), 'ilike', '%'.str_replace(' ', '%', $value).'%');
else
$query->orWhere($query->qualifyColumn($searchable), 'like', '%'.str_replace(' ', '%', $value).'%');
}
}
} | [
"protected",
"function",
"buildSearch",
"(",
"$",
"query",
",",
"$",
"searchables",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"searchables",
"as",
"$",
"key",
"=>",
"$",
"searchable",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"searchable",
")",
")",
"{",
"$",
"query",
"->",
"orWhereHas",
"(",
"$",
"key",
",",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"searchable",
",",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"searchable",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"buildSearch",
"(",
"$",
"query",
",",
"$",
"searchable",
",",
"$",
"value",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"query",
"->",
"getConnection",
"(",
")",
"->",
"getDriverName",
"(",
")",
"==",
"'pgsql'",
")",
"$",
"query",
"->",
"orWhere",
"(",
"$",
"query",
"->",
"qualifyColumn",
"(",
"$",
"searchable",
")",
",",
"'ilike'",
",",
"'%'",
".",
"str_replace",
"(",
"' '",
",",
"'%'",
",",
"$",
"value",
")",
".",
"'%'",
")",
";",
"else",
"$",
"query",
"->",
"orWhere",
"(",
"$",
"query",
"->",
"qualifyColumn",
"(",
"$",
"searchable",
")",
",",
"'like'",
",",
"'%'",
".",
"str_replace",
"(",
"' '",
",",
"'%'",
",",
"$",
"value",
")",
".",
"'%'",
")",
";",
"}",
"}",
"}"
] | Recursive Build Search
@param \Illuminate\Database\Eloquent\Builder $query
@param array|string $searchables
@param string $value | [
"Recursive",
"Build",
"Search"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L112-L128 |
28,921 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.per_page | public function per_page($value)
{
$validator = validator([ 'value' => $value ], [ 'value' => 'numeric|min:1|max:1000' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($value) {
$model = $query->getModel();
$model->setPerPage($value);
$query->setModel($model);
});
} | php | public function per_page($value)
{
$validator = validator([ 'value' => $value ], [ 'value' => 'numeric|min:1|max:1000' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($value) {
$model = $query->getModel();
$model->setPerPage($value);
$query->setModel($model);
});
} | [
"public",
"function",
"per_page",
"(",
"$",
"value",
")",
"{",
"$",
"validator",
"=",
"validator",
"(",
"[",
"'value'",
"=>",
"$",
"value",
"]",
",",
"[",
"'value'",
"=>",
"'numeric|min:1|max:1000'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"builder",
"->",
"when",
"(",
"!",
"$",
"validator",
"->",
"fails",
"(",
")",
",",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"value",
")",
"{",
"$",
"model",
"=",
"$",
"query",
"->",
"getModel",
"(",
")",
";",
"$",
"model",
"->",
"setPerPage",
"(",
"$",
"value",
")",
";",
"$",
"query",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"}",
")",
";",
"}"
] | Total per page on pagination
@param int $value
@return \Illuminate\Database\Eloquent\Builder | [
"Total",
"per",
"page",
"on",
"pagination"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L212-L220 |
28,922 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.keys | public function keys($values)
{
$keys = explode(',', $values);
$model = $this->builder->getModel();
$validator = validator([ 'values' => $keys ], [ 'values.*' => 'exists:'.$model->getTable().','.$model->getKeyName() ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($keys) {
$query->whereKey($keys);
});
} | php | public function keys($values)
{
$keys = explode(',', $values);
$model = $this->builder->getModel();
$validator = validator([ 'values' => $keys ], [ 'values.*' => 'exists:'.$model->getTable().','.$model->getKeyName() ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($keys) {
$query->whereKey($keys);
});
} | [
"public",
"function",
"keys",
"(",
"$",
"values",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"','",
",",
"$",
"values",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"builder",
"->",
"getModel",
"(",
")",
";",
"$",
"validator",
"=",
"validator",
"(",
"[",
"'values'",
"=>",
"$",
"keys",
"]",
",",
"[",
"'values.*'",
"=>",
"'exists:'",
".",
"$",
"model",
"->",
"getTable",
"(",
")",
".",
"','",
".",
"$",
"model",
"->",
"getKeyName",
"(",
")",
"]",
")",
";",
"return",
"$",
"this",
"->",
"builder",
"->",
"when",
"(",
"!",
"$",
"validator",
"->",
"fails",
"(",
")",
",",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"keys",
")",
"{",
"$",
"query",
"->",
"whereKey",
"(",
"$",
"keys",
")",
";",
"}",
")",
";",
"}"
] | Get collection of resources by keys
@param string $values
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"collection",
"of",
"resources",
"by",
"keys"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L227-L235 |
28,923 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.has | public function has($values)
{
$hases = explode(',', $values);
$model = $this->builder->getModel();
$hases = collect($hases)->filter(function ($has) use($model) {
if (str_contains($has, '.')) return ($model->{explode('.', $has)[0]}() instanceof Relation);
return ($model->{$has}() instanceof Relation);
})->toArray();
$validator = validator([ 'values' => $hases ], [ 'values' => 'array|min:1' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($hases) {
foreach ($hases as $has) {
$query->has($has);
}
});
} | php | public function has($values)
{
$hases = explode(',', $values);
$model = $this->builder->getModel();
$hases = collect($hases)->filter(function ($has) use($model) {
if (str_contains($has, '.')) return ($model->{explode('.', $has)[0]}() instanceof Relation);
return ($model->{$has}() instanceof Relation);
})->toArray();
$validator = validator([ 'values' => $hases ], [ 'values' => 'array|min:1' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($hases) {
foreach ($hases as $has) {
$query->has($has);
}
});
} | [
"public",
"function",
"has",
"(",
"$",
"values",
")",
"{",
"$",
"hases",
"=",
"explode",
"(",
"','",
",",
"$",
"values",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"builder",
"->",
"getModel",
"(",
")",
";",
"$",
"hases",
"=",
"collect",
"(",
"$",
"hases",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"has",
")",
"use",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"has",
",",
"'.'",
")",
")",
"return",
"(",
"$",
"model",
"->",
"{",
"explode",
"(",
"'.'",
",",
"$",
"has",
")",
"[",
"0",
"]",
"}",
"(",
")",
"instanceof",
"Relation",
")",
";",
"return",
"(",
"$",
"model",
"->",
"{",
"$",
"has",
"}",
"(",
")",
"instanceof",
"Relation",
")",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"validator",
"=",
"validator",
"(",
"[",
"'values'",
"=>",
"$",
"hases",
"]",
",",
"[",
"'values'",
"=>",
"'array|min:1'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"builder",
"->",
"when",
"(",
"!",
"$",
"validator",
"->",
"fails",
"(",
")",
",",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"hases",
")",
"{",
"foreach",
"(",
"$",
"hases",
"as",
"$",
"has",
")",
"{",
"$",
"query",
"->",
"has",
"(",
"$",
"has",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get collection of resources by has relation
@param string $values
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"collection",
"of",
"resources",
"by",
"has",
"relation"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L314-L328 |
28,924 | Atnic/laravel-generator | app/Filters/BaseFilter.php | BaseFilter.doesnt_have | public function doesnt_have($values)
{
$doesnt_haves = explode(',', $values);
$model = $this->builder->getModel();
$doesnt_haves = collect($doesnt_haves)->filter(function ($doesnt_have) use($model) {
if (str_contains($doesnt_have, '.')) return ($model->{explode('.', $doesnt_have)[0]}() instanceof Relation);
return ($model->{$doesnt_have}() instanceof Relation);
})->toArray();
$validator = validator([ 'values' => $doesnt_haves ], [ 'values' => 'array|min:1' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($doesnt_haves) {
foreach ($doesnt_haves as $doesnt_have) {
$query->doesntHave($doesnt_have);
}
});
} | php | public function doesnt_have($values)
{
$doesnt_haves = explode(',', $values);
$model = $this->builder->getModel();
$doesnt_haves = collect($doesnt_haves)->filter(function ($doesnt_have) use($model) {
if (str_contains($doesnt_have, '.')) return ($model->{explode('.', $doesnt_have)[0]}() instanceof Relation);
return ($model->{$doesnt_have}() instanceof Relation);
})->toArray();
$validator = validator([ 'values' => $doesnt_haves ], [ 'values' => 'array|min:1' ]);
return $this->builder->when(!$validator->fails(), function (Builder $query) use($doesnt_haves) {
foreach ($doesnt_haves as $doesnt_have) {
$query->doesntHave($doesnt_have);
}
});
} | [
"public",
"function",
"doesnt_have",
"(",
"$",
"values",
")",
"{",
"$",
"doesnt_haves",
"=",
"explode",
"(",
"','",
",",
"$",
"values",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"builder",
"->",
"getModel",
"(",
")",
";",
"$",
"doesnt_haves",
"=",
"collect",
"(",
"$",
"doesnt_haves",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"doesnt_have",
")",
"use",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"doesnt_have",
",",
"'.'",
")",
")",
"return",
"(",
"$",
"model",
"->",
"{",
"explode",
"(",
"'.'",
",",
"$",
"doesnt_have",
")",
"[",
"0",
"]",
"}",
"(",
")",
"instanceof",
"Relation",
")",
";",
"return",
"(",
"$",
"model",
"->",
"{",
"$",
"doesnt_have",
"}",
"(",
")",
"instanceof",
"Relation",
")",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"validator",
"=",
"validator",
"(",
"[",
"'values'",
"=>",
"$",
"doesnt_haves",
"]",
",",
"[",
"'values'",
"=>",
"'array|min:1'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"builder",
"->",
"when",
"(",
"!",
"$",
"validator",
"->",
"fails",
"(",
")",
",",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"doesnt_haves",
")",
"{",
"foreach",
"(",
"$",
"doesnt_haves",
"as",
"$",
"doesnt_have",
")",
"{",
"$",
"query",
"->",
"doesntHave",
"(",
"$",
"doesnt_have",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get collection of resources by doesnt_have relation
@param string $values
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"collection",
"of",
"resources",
"by",
"doesnt_have",
"relation"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Filters/BaseFilter.php#L336-L350 |
28,925 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.getResource | public function getResource(
$uri = "",
$headers = []
) {
// Set headers
$options = ['http_errors' => false, 'headers' => $headers];
// Send the request.
return $this->client->request(
'GET',
$uri,
$options
);
} | php | public function getResource(
$uri = "",
$headers = []
) {
// Set headers
$options = ['http_errors' => false, 'headers' => $headers];
// Send the request.
return $this->client->request(
'GET',
$uri,
$options
);
} | [
"public",
"function",
"getResource",
"(",
"$",
"uri",
"=",
"\"\"",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"// Set headers",
"$",
"options",
"=",
"[",
"'http_errors'",
"=>",
"false",
",",
"'headers'",
"=>",
"$",
"headers",
"]",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"uri",
",",
"$",
"options",
")",
";",
"}"
] | Gets a Fedora resource.
@param string $uri Resource URI
@param array $headers HTTP Headers
@return ResponseInterface | [
"Gets",
"a",
"Fedora",
"resource",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L70-L83 |
28,926 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.createResource | public function createResource(
$uri = "",
$content = null,
$headers = []
) {
$options = ['http_errors' => false];
// Set content.
$options['body'] = $content;
// Set headers.
$options['headers'] = $headers;
return $this->client->request(
'POST',
$uri,
$options
);
} | php | public function createResource(
$uri = "",
$content = null,
$headers = []
) {
$options = ['http_errors' => false];
// Set content.
$options['body'] = $content;
// Set headers.
$options['headers'] = $headers;
return $this->client->request(
'POST',
$uri,
$options
);
} | [
"public",
"function",
"createResource",
"(",
"$",
"uri",
"=",
"\"\"",
",",
"$",
"content",
"=",
"null",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'http_errors'",
"=>",
"false",
"]",
";",
"// Set content.",
"$",
"options",
"[",
"'body'",
"]",
"=",
"$",
"content",
";",
"// Set headers.",
"$",
"options",
"[",
"'headers'",
"]",
"=",
"$",
"headers",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"$",
"uri",
",",
"$",
"options",
")",
";",
"}"
] | Creates a new resource in Fedora.
@param string $uri Resource URI
@param string $content String or binary content
@param array $headers HTTP Headers
@return ResponseInterface | [
"Creates",
"a",
"new",
"resource",
"in",
"Fedora",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L134-L152 |
28,927 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.modifyResource | public function modifyResource(
$uri,
$sparql = "",
$headers = []
) {
$options = ['http_errors' => false];
// Set content.
$options['body'] = $sparql;
// Set headers.
$options['headers'] = $headers;
$options['headers']['content-type'] = 'application/sparql-update';
return $this->client->request(
'PATCH',
$uri,
$options
);
} | php | public function modifyResource(
$uri,
$sparql = "",
$headers = []
) {
$options = ['http_errors' => false];
// Set content.
$options['body'] = $sparql;
// Set headers.
$options['headers'] = $headers;
$options['headers']['content-type'] = 'application/sparql-update';
return $this->client->request(
'PATCH',
$uri,
$options
);
} | [
"public",
"function",
"modifyResource",
"(",
"$",
"uri",
",",
"$",
"sparql",
"=",
"\"\"",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'http_errors'",
"=>",
"false",
"]",
";",
"// Set content.",
"$",
"options",
"[",
"'body'",
"]",
"=",
"$",
"sparql",
";",
"// Set headers.",
"$",
"options",
"[",
"'headers'",
"]",
"=",
"$",
"headers",
";",
"$",
"options",
"[",
"'headers'",
"]",
"[",
"'content-type'",
"]",
"=",
"'application/sparql-update'",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'PATCH'",
",",
"$",
"uri",
",",
"$",
"options",
")",
";",
"}"
] | Modifies a resource using a SPARQL Update query.
@param string $uri Resource URI
@param string $sparql SPARQL Update query
@param array $headers HTTP Headers
@return ResponseInterface | [
"Modifies",
"a",
"resource",
"using",
"a",
"SPARQL",
"Update",
"query",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L192-L211 |
28,928 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.deleteResource | public function deleteResource(
$uri = '',
$headers = []
) {
$options = ['http_errors' => false, 'headers' => $headers];
return $this->client->request(
'DELETE',
$uri,
$options
);
} | php | public function deleteResource(
$uri = '',
$headers = []
) {
$options = ['http_errors' => false, 'headers' => $headers];
return $this->client->request(
'DELETE',
$uri,
$options
);
} | [
"public",
"function",
"deleteResource",
"(",
"$",
"uri",
"=",
"''",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'http_errors'",
"=>",
"false",
",",
"'headers'",
"=>",
"$",
"headers",
"]",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"uri",
",",
"$",
"options",
")",
";",
"}"
] | Issues a DELETE request to Fedora.
@param string $uri Resource URI
@param array $headers HTTP Headers
@return ResponseInterface | [
"Issues",
"a",
"DELETE",
"request",
"to",
"Fedora",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L221-L232 |
28,929 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.saveGraph | public function saveGraph(
\EasyRdf_Graph $graph,
$uri = '',
$headers = []
) {
// Serialze the rdf.
$turtle = $graph->serialise('turtle');
// Checksum it.
$checksum_value = sha1($turtle);
// Set headers.
$headers['Content-Type'] = 'text/turtle';
$headers['digest'] = 'sha1=' . $checksum_value;
// Save it.
return $this->saveResource($uri, $turtle, $headers);
} | php | public function saveGraph(
\EasyRdf_Graph $graph,
$uri = '',
$headers = []
) {
// Serialze the rdf.
$turtle = $graph->serialise('turtle');
// Checksum it.
$checksum_value = sha1($turtle);
// Set headers.
$headers['Content-Type'] = 'text/turtle';
$headers['digest'] = 'sha1=' . $checksum_value;
// Save it.
return $this->saveResource($uri, $turtle, $headers);
} | [
"public",
"function",
"saveGraph",
"(",
"\\",
"EasyRdf_Graph",
"$",
"graph",
",",
"$",
"uri",
"=",
"''",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"// Serialze the rdf.",
"$",
"turtle",
"=",
"$",
"graph",
"->",
"serialise",
"(",
"'turtle'",
")",
";",
"// Checksum it.",
"$",
"checksum_value",
"=",
"sha1",
"(",
"$",
"turtle",
")",
";",
"// Set headers.",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'text/turtle'",
";",
"$",
"headers",
"[",
"'digest'",
"]",
"=",
"'sha1='",
".",
"$",
"checksum_value",
";",
"// Save it.",
"return",
"$",
"this",
"->",
"saveResource",
"(",
"$",
"uri",
",",
"$",
"turtle",
",",
"$",
"headers",
")",
";",
"}"
] | Saves RDF in Fedora.
@param EasyRdf_Resource $graph Graph to save
@param string $uri Resource URI
@param array $headers HTTP Headers
@return ResponseInterface | [
"Saves",
"RDF",
"in",
"Fedora",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L243-L260 |
28,930 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.createGraph | public function createGraph(
\EasyRdf_Graph $graph,
$uri = '',
$headers = []
) {
// Serialze the rdf.
$turtle = $graph->serialise('turtle');
// Checksum it.
$checksum_value = sha1($turtle);
// Set headers.
$headers['Content-Type'] = 'text/turtle';
$headers['digest'] = 'sha1=' . $checksum_value;
// Save it.
return $this->createResource($uri, $turtle, $headers);
} | php | public function createGraph(
\EasyRdf_Graph $graph,
$uri = '',
$headers = []
) {
// Serialze the rdf.
$turtle = $graph->serialise('turtle');
// Checksum it.
$checksum_value = sha1($turtle);
// Set headers.
$headers['Content-Type'] = 'text/turtle';
$headers['digest'] = 'sha1=' . $checksum_value;
// Save it.
return $this->createResource($uri, $turtle, $headers);
} | [
"public",
"function",
"createGraph",
"(",
"\\",
"EasyRdf_Graph",
"$",
"graph",
",",
"$",
"uri",
"=",
"''",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"// Serialze the rdf.",
"$",
"turtle",
"=",
"$",
"graph",
"->",
"serialise",
"(",
"'turtle'",
")",
";",
"// Checksum it.",
"$",
"checksum_value",
"=",
"sha1",
"(",
"$",
"turtle",
")",
";",
"// Set headers.",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'text/turtle'",
";",
"$",
"headers",
"[",
"'digest'",
"]",
"=",
"'sha1='",
".",
"$",
"checksum_value",
";",
"// Save it.",
"return",
"$",
"this",
"->",
"createResource",
"(",
"$",
"uri",
",",
"$",
"turtle",
",",
"$",
"headers",
")",
";",
"}"
] | Creates RDF in Fedora.
@param EasyRdf_Resource $graph Graph to save
@param string $uri Resource URI
@param array $headers HTTP Headers
@return ResponseInterface | [
"Creates",
"RDF",
"in",
"Fedora",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L271-L288 |
28,931 | Islandora-CLAW/chullo | src/FedoraApi.php | FedoraApi.getGraph | public function getGraph(ResponseInterface $response)
{
// Extract rdf as response body and return Easy_RDF Graph object.
$rdf = $response->getBody()->getContents();
$graph = new \EasyRdf_Graph();
if (!empty($rdf)) {
$graph->parse($rdf, 'jsonld');
}
return $graph;
} | php | public function getGraph(ResponseInterface $response)
{
// Extract rdf as response body and return Easy_RDF Graph object.
$rdf = $response->getBody()->getContents();
$graph = new \EasyRdf_Graph();
if (!empty($rdf)) {
$graph->parse($rdf, 'jsonld');
}
return $graph;
} | [
"public",
"function",
"getGraph",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"// Extract rdf as response body and return Easy_RDF Graph object.",
"$",
"rdf",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"$",
"graph",
"=",
"new",
"\\",
"EasyRdf_Graph",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rdf",
")",
")",
"{",
"$",
"graph",
"->",
"parse",
"(",
"$",
"rdf",
",",
"'jsonld'",
")",
";",
"}",
"return",
"$",
"graph",
";",
"}"
] | Gets RDF in Fedora.
@param ResponseInterface $request Response received
@return \EasyRdf_Graph | [
"Gets",
"RDF",
"in",
"Fedora",
"."
] | fc60e9c271c4f83290b3a98ad46825a7e418d51e | https://github.com/Islandora-CLAW/chullo/blob/fc60e9c271c4f83290b3a98ad46825a7e418d51e/src/FedoraApi.php#L298-L307 |
28,932 | netgen/site-bundle | bundle/Composer/ScriptHandler.php | ScriptHandler.installProjectSymlinks | public static function installProjectSymlinks(Event $event): void
{
$options = self::getOptions($event);
$consoleDir = static::getConsoleDir($event, 'install project symlinks');
static::executeCommand($event, $consoleDir, 'ngsite:symlink:project', $options['process-timeout']);
} | php | public static function installProjectSymlinks(Event $event): void
{
$options = self::getOptions($event);
$consoleDir = static::getConsoleDir($event, 'install project symlinks');
static::executeCommand($event, $consoleDir, 'ngsite:symlink:project', $options['process-timeout']);
} | [
"public",
"static",
"function",
"installProjectSymlinks",
"(",
"Event",
"$",
"event",
")",
":",
"void",
"{",
"$",
"options",
"=",
"self",
"::",
"getOptions",
"(",
"$",
"event",
")",
";",
"$",
"consoleDir",
"=",
"static",
"::",
"getConsoleDir",
"(",
"$",
"event",
",",
"'install project symlinks'",
")",
";",
"static",
"::",
"executeCommand",
"(",
"$",
"event",
",",
"$",
"consoleDir",
",",
"'ngsite:symlink:project'",
",",
"$",
"options",
"[",
"'process-timeout'",
"]",
")",
";",
"}"
] | Symlinks various project files and folders to their proper locations. | [
"Symlinks",
"various",
"project",
"files",
"and",
"folders",
"to",
"their",
"proper",
"locations",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Composer/ScriptHandler.php#L15-L21 |
28,933 | smartboxgroup/integration-framework-bundle | Tools/Evaluator/ApcuParserCache.php | ApcuParserCache.fetch | public function fetch($key)
{
if(extension_loaded('apcu') && function_exists('apcu_fetch')) {
$cached = apcu_fetch($key);
if (!$cached) {
return null;
}
return $cached;
}else{
return null;
}
} | php | public function fetch($key)
{
if(extension_loaded('apcu') && function_exists('apcu_fetch')) {
$cached = apcu_fetch($key);
if (!$cached) {
return null;
}
return $cached;
}else{
return null;
}
} | [
"public",
"function",
"fetch",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"'apcu'",
")",
"&&",
"function_exists",
"(",
"'apcu_fetch'",
")",
")",
"{",
"$",
"cached",
"=",
"apcu_fetch",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"cached",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"cached",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Fetches an expression from the cache.
@param string $key The cache key
@return ParsedExpression|null | [
"Fetches",
"an",
"expression",
"from",
"the",
"cache",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Tools/Evaluator/ApcuParserCache.php#L31-L44 |
28,934 | spiral/tokenizer | src/Tokenizer.php | Tokenizer.getTokens | public static function getTokens(string $filename): array
{
$tokens = token_get_all(file_get_contents($filename));
$line = 0;
foreach ($tokens as &$token) {
if (isset($token[self::LINE])) {
$line = $token[self::LINE];
}
if (!is_array($token)) {
$token = [$token, $token, $line];
}
unset($token);
}
return $tokens;
} | php | public static function getTokens(string $filename): array
{
$tokens = token_get_all(file_get_contents($filename));
$line = 0;
foreach ($tokens as &$token) {
if (isset($token[self::LINE])) {
$line = $token[self::LINE];
}
if (!is_array($token)) {
$token = [$token, $token, $line];
}
unset($token);
}
return $tokens;
} | [
"public",
"static",
"function",
"getTokens",
"(",
"string",
"$",
"filename",
")",
":",
"array",
"{",
"$",
"tokens",
"=",
"token_get_all",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
";",
"$",
"line",
"=",
"0",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"&",
"$",
"token",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"token",
"[",
"self",
"::",
"LINE",
"]",
")",
")",
"{",
"$",
"line",
"=",
"$",
"token",
"[",
"self",
"::",
"LINE",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"token",
")",
")",
"{",
"$",
"token",
"=",
"[",
"$",
"token",
",",
"$",
"token",
",",
"$",
"line",
"]",
";",
"}",
"unset",
"(",
"$",
"token",
")",
";",
"}",
"return",
"$",
"tokens",
";",
"}"
] | Get all tokes for specific file.
@param string $filename
@return array | [
"Get",
"all",
"tokes",
"for",
"specific",
"file",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Tokenizer.php#L92-L110 |
28,935 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.importSchema | protected function importSchema(array $cache)
{
list($this->hasIncludes, $this->declarations, $this->functions, $this->namespaces) = $cache;
} | php | protected function importSchema(array $cache)
{
list($this->hasIncludes, $this->declarations, $this->functions, $this->namespaces) = $cache;
} | [
"protected",
"function",
"importSchema",
"(",
"array",
"$",
"cache",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"hasIncludes",
",",
"$",
"this",
"->",
"declarations",
",",
"$",
"this",
"->",
"functions",
",",
"$",
"this",
"->",
"namespaces",
")",
"=",
"$",
"cache",
";",
"}"
] | Import cached reflection schema.
@param array $cache | [
"Import",
"cached",
"reflection",
"schema",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L254-L257 |
28,936 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.locateDeclarations | protected function locateDeclarations()
{
foreach ($this->getTokens() as $tokenID => $token) {
if (!in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
continue;
}
switch ($token[self::TOKEN_TYPE]) {
case T_NAMESPACE:
$this->registerNamespace($tokenID);
break;
case T_USE:
$this->registerUse($tokenID);
break;
case T_FUNCTION:
$this->registerFunction($tokenID);
break;
case T_CLASS:
case T_TRAIT:
case T_INTERFACE:
if ($this->isClassNameConst($tokenID)) {
//PHP5.5 ClassName::class constant
continue 2;
}
$this->registerDeclaration($tokenID, $token[self::TOKEN_TYPE]);
break;
case T_INCLUDE:
case T_INCLUDE_ONCE:
case T_REQUIRE:
case T_REQUIRE_ONCE:
$this->hasIncludes = true;
}
}
//Dropping empty namespace
if (isset($this->namespaces[''])) {
$this->namespaces['\\'] = $this->namespaces[''];
unset($this->namespaces['']);
}
} | php | protected function locateDeclarations()
{
foreach ($this->getTokens() as $tokenID => $token) {
if (!in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
continue;
}
switch ($token[self::TOKEN_TYPE]) {
case T_NAMESPACE:
$this->registerNamespace($tokenID);
break;
case T_USE:
$this->registerUse($tokenID);
break;
case T_FUNCTION:
$this->registerFunction($tokenID);
break;
case T_CLASS:
case T_TRAIT:
case T_INTERFACE:
if ($this->isClassNameConst($tokenID)) {
//PHP5.5 ClassName::class constant
continue 2;
}
$this->registerDeclaration($tokenID, $token[self::TOKEN_TYPE]);
break;
case T_INCLUDE:
case T_INCLUDE_ONCE:
case T_REQUIRE:
case T_REQUIRE_ONCE:
$this->hasIncludes = true;
}
}
//Dropping empty namespace
if (isset($this->namespaces[''])) {
$this->namespaces['\\'] = $this->namespaces[''];
unset($this->namespaces['']);
}
} | [
"protected",
"function",
"locateDeclarations",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getTokens",
"(",
")",
"as",
"$",
"tokenID",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"token",
"[",
"self",
"::",
"TOKEN_TYPE",
"]",
",",
"self",
"::",
"$",
"processTokens",
")",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"$",
"token",
"[",
"self",
"::",
"TOKEN_TYPE",
"]",
")",
"{",
"case",
"T_NAMESPACE",
":",
"$",
"this",
"->",
"registerNamespace",
"(",
"$",
"tokenID",
")",
";",
"break",
";",
"case",
"T_USE",
":",
"$",
"this",
"->",
"registerUse",
"(",
"$",
"tokenID",
")",
";",
"break",
";",
"case",
"T_FUNCTION",
":",
"$",
"this",
"->",
"registerFunction",
"(",
"$",
"tokenID",
")",
";",
"break",
";",
"case",
"T_CLASS",
":",
"case",
"T_TRAIT",
":",
"case",
"T_INTERFACE",
":",
"if",
"(",
"$",
"this",
"->",
"isClassNameConst",
"(",
"$",
"tokenID",
")",
")",
"{",
"//PHP5.5 ClassName::class constant",
"continue",
"2",
";",
"}",
"$",
"this",
"->",
"registerDeclaration",
"(",
"$",
"tokenID",
",",
"$",
"token",
"[",
"self",
"::",
"TOKEN_TYPE",
"]",
")",
";",
"break",
";",
"case",
"T_INCLUDE",
":",
"case",
"T_INCLUDE_ONCE",
":",
"case",
"T_REQUIRE",
":",
"case",
"T_REQUIRE_ONCE",
":",
"$",
"this",
"->",
"hasIncludes",
"=",
"true",
";",
"}",
"}",
"//Dropping empty namespace",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"namespaces",
"[",
"''",
"]",
")",
")",
"{",
"$",
"this",
"->",
"namespaces",
"[",
"'\\\\'",
"]",
"=",
"$",
"this",
"->",
"namespaces",
"[",
"''",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"namespaces",
"[",
"''",
"]",
")",
";",
"}",
"}"
] | Locate every class, interface, trait or function definition. | [
"Locate",
"every",
"class",
"interface",
"trait",
"or",
"function",
"definition",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L262-L306 |
28,937 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.registerNamespace | private function registerNamespace(int $tokenID)
{
$namespace = '';
$localID = $tokenID + 1;
do {
$token = $this->tokens[$localID++];
if ($token[self::TOKEN_CODE] == '{') {
break;
}
$namespace .= $token[self::TOKEN_CODE];
} while (
isset($this->tokens[$localID])
&& $this->tokens[$localID][self::TOKEN_CODE] != '{'
&& $this->tokens[$localID][self::TOKEN_CODE] != ';'
);
//Whitespaces
$namespace = trim($namespace);
$uses = [];
if (isset($this->namespaces[$namespace])) {
$uses = $this->namespaces[$namespace];
}
if ($this->tokens[$localID][self::TOKEN_CODE] == ';') {
$endingID = count($this->tokens) - 1;
} else {
$endingID = $this->endingToken($tokenID);
}
$this->namespaces[$namespace] = [
self::O_TOKEN => $tokenID,
self::C_TOKEN => $endingID,
self::N_USES => $uses,
];
} | php | private function registerNamespace(int $tokenID)
{
$namespace = '';
$localID = $tokenID + 1;
do {
$token = $this->tokens[$localID++];
if ($token[self::TOKEN_CODE] == '{') {
break;
}
$namespace .= $token[self::TOKEN_CODE];
} while (
isset($this->tokens[$localID])
&& $this->tokens[$localID][self::TOKEN_CODE] != '{'
&& $this->tokens[$localID][self::TOKEN_CODE] != ';'
);
//Whitespaces
$namespace = trim($namespace);
$uses = [];
if (isset($this->namespaces[$namespace])) {
$uses = $this->namespaces[$namespace];
}
if ($this->tokens[$localID][self::TOKEN_CODE] == ';') {
$endingID = count($this->tokens) - 1;
} else {
$endingID = $this->endingToken($tokenID);
}
$this->namespaces[$namespace] = [
self::O_TOKEN => $tokenID,
self::C_TOKEN => $endingID,
self::N_USES => $uses,
];
} | [
"private",
"function",
"registerNamespace",
"(",
"int",
"$",
"tokenID",
")",
"{",
"$",
"namespace",
"=",
"''",
";",
"$",
"localID",
"=",
"$",
"tokenID",
"+",
"1",
";",
"do",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"++",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"==",
"'{'",
")",
"{",
"break",
";",
"}",
"$",
"namespace",
".=",
"$",
"token",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
";",
"}",
"while",
"(",
"isset",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
")",
"&&",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"!=",
"'{'",
"&&",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"!=",
"';'",
")",
";",
"//Whitespaces",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
")",
";",
"$",
"uses",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"uses",
"=",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespace",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"==",
"';'",
")",
"{",
"$",
"endingID",
"=",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"endingID",
"=",
"$",
"this",
"->",
"endingToken",
"(",
"$",
"tokenID",
")",
";",
"}",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespace",
"]",
"=",
"[",
"self",
"::",
"O_TOKEN",
"=>",
"$",
"tokenID",
",",
"self",
"::",
"C_TOKEN",
"=>",
"$",
"endingID",
",",
"self",
"::",
"N_USES",
"=>",
"$",
"uses",
",",
"]",
";",
"}"
] | Handle namespace declaration.
@param int $tokenID | [
"Handle",
"namespace",
"declaration",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L313-L350 |
28,938 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.registerDeclaration | private function registerDeclaration(int $tokenID, int $tokenType)
{
$localID = $tokenID + 1;
while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
++$localID;
}
$name = $this->tokens[$localID][self::TOKEN_CODE];
if (!empty($namespace = $this->activeNamespace($tokenID))) {
$name = $namespace . self::NS_SEPARATOR . $name;
}
$this->declarations[token_name($tokenType)][$name] = [
self::O_TOKEN => $tokenID,
self::C_TOKEN => $this->endingToken($tokenID),
];
} | php | private function registerDeclaration(int $tokenID, int $tokenType)
{
$localID = $tokenID + 1;
while ($this->tokens[$localID][self::TOKEN_TYPE] != T_STRING) {
++$localID;
}
$name = $this->tokens[$localID][self::TOKEN_CODE];
if (!empty($namespace = $this->activeNamespace($tokenID))) {
$name = $namespace . self::NS_SEPARATOR . $name;
}
$this->declarations[token_name($tokenType)][$name] = [
self::O_TOKEN => $tokenID,
self::C_TOKEN => $this->endingToken($tokenID),
];
} | [
"private",
"function",
"registerDeclaration",
"(",
"int",
"$",
"tokenID",
",",
"int",
"$",
"tokenType",
")",
"{",
"$",
"localID",
"=",
"$",
"tokenID",
"+",
"1",
";",
"while",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
"[",
"self",
"::",
"TOKEN_TYPE",
"]",
"!=",
"T_STRING",
")",
"{",
"++",
"$",
"localID",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespace",
"=",
"$",
"this",
"->",
"activeNamespace",
"(",
"$",
"tokenID",
")",
")",
")",
"{",
"$",
"name",
"=",
"$",
"namespace",
".",
"self",
"::",
"NS_SEPARATOR",
".",
"$",
"name",
";",
"}",
"$",
"this",
"->",
"declarations",
"[",
"token_name",
"(",
"$",
"tokenType",
")",
"]",
"[",
"$",
"name",
"]",
"=",
"[",
"self",
"::",
"O_TOKEN",
"=>",
"$",
"tokenID",
",",
"self",
"::",
"C_TOKEN",
"=>",
"$",
"this",
"->",
"endingToken",
"(",
"$",
"tokenID",
")",
",",
"]",
";",
"}"
] | Handle declaration of class, trait of interface. Declaration will be stored under it's token
type in declarations array.
@param int $tokenID
@param int $tokenType | [
"Handle",
"declaration",
"of",
"class",
"trait",
"of",
"interface",
".",
"Declaration",
"will",
"be",
"stored",
"under",
"it",
"s",
"token",
"type",
"in",
"declarations",
"array",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L424-L440 |
28,939 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.registerInvocation | private function registerInvocation(
int $invocationID,
int $argumentsID,
int $endID,
array $arguments,
int $invocationLevel
) {
//Nested invocations
$this->locateInvocations($arguments, $invocationLevel + 1);
list($class, $operator, $name) = $this->fetchContext($invocationID, $argumentsID);
if (!empty($operator) && empty($class)) {
//Non detectable
return;
}
$this->invocations[] = new ReflectionInvocation(
$this->filename,
$this->lineNumber($invocationID),
$class,
$operator,
$name,
ReflectionArgument::locateArguments($arguments),
$this->getSource($invocationID, $endID),
$invocationLevel
);
} | php | private function registerInvocation(
int $invocationID,
int $argumentsID,
int $endID,
array $arguments,
int $invocationLevel
) {
//Nested invocations
$this->locateInvocations($arguments, $invocationLevel + 1);
list($class, $operator, $name) = $this->fetchContext($invocationID, $argumentsID);
if (!empty($operator) && empty($class)) {
//Non detectable
return;
}
$this->invocations[] = new ReflectionInvocation(
$this->filename,
$this->lineNumber($invocationID),
$class,
$operator,
$name,
ReflectionArgument::locateArguments($arguments),
$this->getSource($invocationID, $endID),
$invocationLevel
);
} | [
"private",
"function",
"registerInvocation",
"(",
"int",
"$",
"invocationID",
",",
"int",
"$",
"argumentsID",
",",
"int",
"$",
"endID",
",",
"array",
"$",
"arguments",
",",
"int",
"$",
"invocationLevel",
")",
"{",
"//Nested invocations",
"$",
"this",
"->",
"locateInvocations",
"(",
"$",
"arguments",
",",
"$",
"invocationLevel",
"+",
"1",
")",
";",
"list",
"(",
"$",
"class",
",",
"$",
"operator",
",",
"$",
"name",
")",
"=",
"$",
"this",
"->",
"fetchContext",
"(",
"$",
"invocationID",
",",
"$",
"argumentsID",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"operator",
")",
"&&",
"empty",
"(",
"$",
"class",
")",
")",
"{",
"//Non detectable",
"return",
";",
"}",
"$",
"this",
"->",
"invocations",
"[",
"]",
"=",
"new",
"ReflectionInvocation",
"(",
"$",
"this",
"->",
"filename",
",",
"$",
"this",
"->",
"lineNumber",
"(",
"$",
"invocationID",
")",
",",
"$",
"class",
",",
"$",
"operator",
",",
"$",
"name",
",",
"ReflectionArgument",
"::",
"locateArguments",
"(",
"$",
"arguments",
")",
",",
"$",
"this",
"->",
"getSource",
"(",
"$",
"invocationID",
",",
"$",
"endID",
")",
",",
"$",
"invocationLevel",
")",
";",
"}"
] | Registering invocation.
@param int $invocationID
@param int $argumentsID
@param int $endID
@param array $arguments
@param int $invocationLevel | [
"Registering",
"invocation",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L591-L618 |
28,940 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.fetchContext | private function fetchContext(int $invocationTID, int $argumentsTID): array
{
$class = $operator = '';
$name = trim($this->getSource($invocationTID, $argumentsTID), '( ');
//Let's try to fetch all information we need
if (strpos($name, '->') !== false) {
$operator = '->';
} elseif (strpos($name, '::') !== false) {
$operator = '::';
}
if (!empty($operator)) {
list($class, $name) = explode($operator, $name);
//We now have to clarify class name
if (in_array($class, ['self', 'static', '$this'])) {
$class = $this->activeDeclaration($invocationTID);
}
}
return [$class, $operator, $name];
} | php | private function fetchContext(int $invocationTID, int $argumentsTID): array
{
$class = $operator = '';
$name = trim($this->getSource($invocationTID, $argumentsTID), '( ');
//Let's try to fetch all information we need
if (strpos($name, '->') !== false) {
$operator = '->';
} elseif (strpos($name, '::') !== false) {
$operator = '::';
}
if (!empty($operator)) {
list($class, $name) = explode($operator, $name);
//We now have to clarify class name
if (in_array($class, ['self', 'static', '$this'])) {
$class = $this->activeDeclaration($invocationTID);
}
}
return [$class, $operator, $name];
} | [
"private",
"function",
"fetchContext",
"(",
"int",
"$",
"invocationTID",
",",
"int",
"$",
"argumentsTID",
")",
":",
"array",
"{",
"$",
"class",
"=",
"$",
"operator",
"=",
"''",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"this",
"->",
"getSource",
"(",
"$",
"invocationTID",
",",
"$",
"argumentsTID",
")",
",",
"'( '",
")",
";",
"//Let's try to fetch all information we need",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'->'",
")",
"!==",
"false",
")",
"{",
"$",
"operator",
"=",
"'->'",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"name",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"operator",
"=",
"'::'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"operator",
")",
")",
"{",
"list",
"(",
"$",
"class",
",",
"$",
"name",
")",
"=",
"explode",
"(",
"$",
"operator",
",",
"$",
"name",
")",
";",
"//We now have to clarify class name",
"if",
"(",
"in_array",
"(",
"$",
"class",
",",
"[",
"'self'",
",",
"'static'",
",",
"'$this'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"activeDeclaration",
"(",
"$",
"invocationTID",
")",
";",
"}",
"}",
"return",
"[",
"$",
"class",
",",
"$",
"operator",
",",
"$",
"name",
"]",
";",
"}"
] | Fetching invocation context.
@param int $invocationTID
@param int $argumentsTID
@return array | [
"Fetching",
"invocation",
"context",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L628-L650 |
28,941 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.activeDeclaration | private function activeDeclaration(int $tokenID): string
{
foreach ($this->declarations as $declarations) {
foreach ($declarations as $name => $position) {
if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
return $name;
}
}
}
//Can not be detected
return '';
} | php | private function activeDeclaration(int $tokenID): string
{
foreach ($this->declarations as $declarations) {
foreach ($declarations as $name => $position) {
if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
return $name;
}
}
}
//Can not be detected
return '';
} | [
"private",
"function",
"activeDeclaration",
"(",
"int",
"$",
"tokenID",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"declarations",
"as",
"$",
"declarations",
")",
"{",
"foreach",
"(",
"$",
"declarations",
"as",
"$",
"name",
"=>",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"tokenID",
">=",
"$",
"position",
"[",
"self",
"::",
"O_TOKEN",
"]",
"&&",
"$",
"tokenID",
"<=",
"$",
"position",
"[",
"self",
"::",
"C_TOKEN",
"]",
")",
"{",
"return",
"$",
"name",
";",
"}",
"}",
"}",
"//Can not be detected",
"return",
"''",
";",
"}"
] | Get declaration which is active in given token position.
@param int $tokenID
@return string|null | [
"Get",
"declaration",
"which",
"is",
"active",
"in",
"given",
"token",
"position",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L659-L671 |
28,942 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.activeNamespace | private function activeNamespace(int $tokenID): string
{
foreach ($this->namespaces as $namespace => $position) {
if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
return $namespace;
}
}
//Seems like no namespace declaration
$this->namespaces[''] = [
self::O_TOKEN => 0,
self::C_TOKEN => count($this->tokens),
self::N_USES => [],
];
return '';
} | php | private function activeNamespace(int $tokenID): string
{
foreach ($this->namespaces as $namespace => $position) {
if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
return $namespace;
}
}
//Seems like no namespace declaration
$this->namespaces[''] = [
self::O_TOKEN => 0,
self::C_TOKEN => count($this->tokens),
self::N_USES => [],
];
return '';
} | [
"private",
"function",
"activeNamespace",
"(",
"int",
"$",
"tokenID",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
"=>",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"tokenID",
">=",
"$",
"position",
"[",
"self",
"::",
"O_TOKEN",
"]",
"&&",
"$",
"tokenID",
"<=",
"$",
"position",
"[",
"self",
"::",
"C_TOKEN",
"]",
")",
"{",
"return",
"$",
"namespace",
";",
"}",
"}",
"//Seems like no namespace declaration",
"$",
"this",
"->",
"namespaces",
"[",
"''",
"]",
"=",
"[",
"self",
"::",
"O_TOKEN",
"=>",
"0",
",",
"self",
"::",
"C_TOKEN",
"=>",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
",",
"self",
"::",
"N_USES",
"=>",
"[",
"]",
",",
"]",
";",
"return",
"''",
";",
"}"
] | Get namespace name active at specified token position.
@param int $tokenID
@return string | [
"Get",
"namespace",
"name",
"active",
"at",
"specified",
"token",
"position",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L680-L696 |
28,943 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.endingToken | private function endingToken(int $tokenID): int
{
$level = null;
for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
$token = $this->tokens[$localID];
if ($token[self::TOKEN_CODE] == '{') {
++$level;
continue;
}
if ($token[self::TOKEN_CODE] == '}') {
--$level;
}
if ($level === 0) {
break;
}
}
return $localID;
} | php | private function endingToken(int $tokenID): int
{
$level = null;
for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
$token = $this->tokens[$localID];
if ($token[self::TOKEN_CODE] == '{') {
++$level;
continue;
}
if ($token[self::TOKEN_CODE] == '}') {
--$level;
}
if ($level === 0) {
break;
}
}
return $localID;
} | [
"private",
"function",
"endingToken",
"(",
"int",
"$",
"tokenID",
")",
":",
"int",
"{",
"$",
"level",
"=",
"null",
";",
"for",
"(",
"$",
"localID",
"=",
"$",
"tokenID",
";",
"$",
"localID",
"<",
"$",
"this",
"->",
"countTokens",
";",
"++",
"$",
"localID",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"tokens",
"[",
"$",
"localID",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"==",
"'{'",
")",
"{",
"++",
"$",
"level",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"token",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
"==",
"'}'",
")",
"{",
"--",
"$",
"level",
";",
"}",
"if",
"(",
"$",
"level",
"===",
"0",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"localID",
";",
"}"
] | Find token ID of ending brace.
@param int $tokenID
@return int | [
"Find",
"token",
"ID",
"of",
"ending",
"brace",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L705-L725 |
28,944 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.lineNumber | private function lineNumber(int $tokenID): int
{
while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
--$tokenID;
}
return $this->tokens[$tokenID][self::TOKEN_LINE];
} | php | private function lineNumber(int $tokenID): int
{
while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
--$tokenID;
}
return $this->tokens[$tokenID][self::TOKEN_LINE];
} | [
"private",
"function",
"lineNumber",
"(",
"int",
"$",
"tokenID",
")",
":",
"int",
"{",
"while",
"(",
"empty",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"tokenID",
"]",
"[",
"self",
"::",
"TOKEN_LINE",
"]",
")",
")",
"{",
"--",
"$",
"tokenID",
";",
"}",
"return",
"$",
"this",
"->",
"tokens",
"[",
"$",
"tokenID",
"]",
"[",
"self",
"::",
"TOKEN_LINE",
"]",
";",
"}"
] | Get line number associated with token.
@param int $tokenID
@return int | [
"Get",
"line",
"number",
"associated",
"with",
"token",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L734-L741 |
28,945 | spiral/tokenizer | src/Reflection/ReflectionFile.php | ReflectionFile.getSource | private function getSource(int $startID, int $endID): string
{
$result = '';
for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
//Collecting function usage src
$result .= $this->tokens[$tokenID][self::TOKEN_CODE];
}
return $result;
} | php | private function getSource(int $startID, int $endID): string
{
$result = '';
for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
//Collecting function usage src
$result .= $this->tokens[$tokenID][self::TOKEN_CODE];
}
return $result;
} | [
"private",
"function",
"getSource",
"(",
"int",
"$",
"startID",
",",
"int",
"$",
"endID",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"for",
"(",
"$",
"tokenID",
"=",
"$",
"startID",
";",
"$",
"tokenID",
"<=",
"$",
"endID",
";",
"++",
"$",
"tokenID",
")",
"{",
"//Collecting function usage src",
"$",
"result",
".=",
"$",
"this",
"->",
"tokens",
"[",
"$",
"tokenID",
"]",
"[",
"self",
"::",
"TOKEN_CODE",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get src located between two tokens.
@param int $startID
@param int $endID
@return string | [
"Get",
"src",
"located",
"between",
"two",
"tokens",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L751-L760 |
28,946 | spiral/tokenizer | src/Reflection/ReflectionArgument.php | ReflectionArgument.createArgument | private static function createArgument(array $definition): ReflectionArgument
{
$result = new static(self::EXPRESSION, $definition['value']);
if (count($definition['tokens']) == 1) {
//If argument represent by one token we can try to resolve it's type more precisely
switch ($definition['tokens'][0][0]) {
case T_VARIABLE:
$result->type = self::VARIABLE;
break;
case T_LNUMBER:
case T_DNUMBER:
$result->type = self::CONSTANT;
break;
case T_CONSTANT_ENCAPSED_STRING:
$result->type = self::STRING;
break;
}
}
return $result;
} | php | private static function createArgument(array $definition): ReflectionArgument
{
$result = new static(self::EXPRESSION, $definition['value']);
if (count($definition['tokens']) == 1) {
//If argument represent by one token we can try to resolve it's type more precisely
switch ($definition['tokens'][0][0]) {
case T_VARIABLE:
$result->type = self::VARIABLE;
break;
case T_LNUMBER:
case T_DNUMBER:
$result->type = self::CONSTANT;
break;
case T_CONSTANT_ENCAPSED_STRING:
$result->type = self::STRING;
break;
}
}
return $result;
} | [
"private",
"static",
"function",
"createArgument",
"(",
"array",
"$",
"definition",
")",
":",
"ReflectionArgument",
"{",
"$",
"result",
"=",
"new",
"static",
"(",
"self",
"::",
"EXPRESSION",
",",
"$",
"definition",
"[",
"'value'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"definition",
"[",
"'tokens'",
"]",
")",
"==",
"1",
")",
"{",
"//If argument represent by one token we can try to resolve it's type more precisely",
"switch",
"(",
"$",
"definition",
"[",
"'tokens'",
"]",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"{",
"case",
"T_VARIABLE",
":",
"$",
"result",
"->",
"type",
"=",
"self",
"::",
"VARIABLE",
";",
"break",
";",
"case",
"T_LNUMBER",
":",
"case",
"T_DNUMBER",
":",
"$",
"result",
"->",
"type",
"=",
"self",
"::",
"CONSTANT",
";",
"break",
";",
"case",
"T_CONSTANT_ENCAPSED_STRING",
":",
"$",
"result",
"->",
"type",
"=",
"self",
"::",
"STRING",
";",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Create Argument reflection using token definition. Internal method.
@see locateArguments
@param array $definition
@return self | [
"Create",
"Argument",
"reflection",
"using",
"token",
"definition",
".",
"Internal",
"method",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionArgument.php#L152-L173 |
28,947 | spiral/tokenizer | src/AbstractLocator.php | AbstractLocator.availableReflections | protected function availableReflections(): \Generator
{
/**
* @var SplFileInfo
*/
foreach ($this->finder->getIterator() as $file) {
$reflection = new ReflectionFile((string)$file);
if ($reflection->hasIncludes()) {
//We are not analyzing files which has includes, it's not safe to require such reflections
$this->getLogger()->warning(
sprintf("File `%s` has includes and excluded from analysis", $file),
compact('file')
);
continue;
}
/*
* @var ReflectionFile $reflection
*/
yield $reflection;
}
} | php | protected function availableReflections(): \Generator
{
/**
* @var SplFileInfo
*/
foreach ($this->finder->getIterator() as $file) {
$reflection = new ReflectionFile((string)$file);
if ($reflection->hasIncludes()) {
//We are not analyzing files which has includes, it's not safe to require such reflections
$this->getLogger()->warning(
sprintf("File `%s` has includes and excluded from analysis", $file),
compact('file')
);
continue;
}
/*
* @var ReflectionFile $reflection
*/
yield $reflection;
}
} | [
"protected",
"function",
"availableReflections",
"(",
")",
":",
"\\",
"Generator",
"{",
"/**\n * @var SplFileInfo\n */",
"foreach",
"(",
"$",
"this",
"->",
"finder",
"->",
"getIterator",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionFile",
"(",
"(",
"string",
")",
"$",
"file",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"hasIncludes",
"(",
")",
")",
"{",
"//We are not analyzing files which has includes, it's not safe to require such reflections",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"warning",
"(",
"sprintf",
"(",
"\"File `%s` has includes and excluded from analysis\"",
",",
"$",
"file",
")",
",",
"compact",
"(",
"'file'",
")",
")",
";",
"continue",
";",
"}",
"/*\n * @var ReflectionFile $reflection\n */",
"yield",
"$",
"reflection",
";",
"}",
"}"
] | Available file reflections. Generator.
@return ReflectionFile[]|\Generator | [
"Available",
"file",
"reflections",
".",
"Generator",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/AbstractLocator.php#L44-L67 |
28,948 | spiral/tokenizer | src/AbstractLocator.php | AbstractLocator.classReflection | protected function classReflection(string $class): \ReflectionClass
{
$loader = function ($class) {
if ($class == LocatorException::class) {
return;
}
throw new LocatorException("Class '{$class}' can not be loaded");
};
//To suspend class dependency exception
spl_autoload_register($loader);
try {
//In some cases reflection can thrown an exception if class invalid or can not be loaded,
//we are going to handle such exception and convert it soft exception
return new \ReflectionClass($class);
} catch (\Throwable $e) {
if ($e instanceof LocatorException && $e->getPrevious() != null) {
$e = $e->getPrevious();
}
$this->getLogger()->error(
sprintf(
"%s: %s in %s:%s",
$class,
$e->getMessage(),
$e->getFile(),
$e->getLine()
),
['error' => $e]
);
throw new LocatorException($e->getMessage(), $e->getCode(), $e);
} finally {
spl_autoload_unregister($loader);
}
} | php | protected function classReflection(string $class): \ReflectionClass
{
$loader = function ($class) {
if ($class == LocatorException::class) {
return;
}
throw new LocatorException("Class '{$class}' can not be loaded");
};
//To suspend class dependency exception
spl_autoload_register($loader);
try {
//In some cases reflection can thrown an exception if class invalid or can not be loaded,
//we are going to handle such exception and convert it soft exception
return new \ReflectionClass($class);
} catch (\Throwable $e) {
if ($e instanceof LocatorException && $e->getPrevious() != null) {
$e = $e->getPrevious();
}
$this->getLogger()->error(
sprintf(
"%s: %s in %s:%s",
$class,
$e->getMessage(),
$e->getFile(),
$e->getLine()
),
['error' => $e]
);
throw new LocatorException($e->getMessage(), $e->getCode(), $e);
} finally {
spl_autoload_unregister($loader);
}
} | [
"protected",
"function",
"classReflection",
"(",
"string",
"$",
"class",
")",
":",
"\\",
"ReflectionClass",
"{",
"$",
"loader",
"=",
"function",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"==",
"LocatorException",
"::",
"class",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"LocatorException",
"(",
"\"Class '{$class}' can not be loaded\"",
")",
";",
"}",
";",
"//To suspend class dependency exception",
"spl_autoload_register",
"(",
"$",
"loader",
")",
";",
"try",
"{",
"//In some cases reflection can thrown an exception if class invalid or can not be loaded,",
"//we are going to handle such exception and convert it soft exception",
"return",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"LocatorException",
"&&",
"$",
"e",
"->",
"getPrevious",
"(",
")",
"!=",
"null",
")",
"{",
"$",
"e",
"=",
"$",
"e",
"->",
"getPrevious",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"error",
"(",
"sprintf",
"(",
"\"%s: %s in %s:%s\"",
",",
"$",
"class",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"$",
"e",
"->",
"getLine",
"(",
")",
")",
",",
"[",
"'error'",
"=>",
"$",
"e",
"]",
")",
";",
"throw",
"new",
"LocatorException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"finally",
"{",
"spl_autoload_unregister",
"(",
"$",
"loader",
")",
";",
"}",
"}"
] | Safely get class reflection, class loading errors will be blocked and reflection will be
excluded from analysis.
@param string $class
@return \ReflectionClass | [
"Safely",
"get",
"class",
"reflection",
"class",
"loading",
"errors",
"will",
"be",
"blocked",
"and",
"reflection",
"will",
"be",
"excluded",
"from",
"analysis",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/AbstractLocator.php#L77-L114 |
28,949 | spiral/tokenizer | src/InvocationLocator.php | InvocationLocator.availableInvocations | protected function availableInvocations(string $signature = ''): \Generator
{
$signature = strtolower(trim($signature, '\\'));
foreach ($this->availableReflections() as $reflection) {
foreach ($reflection->getInvocations() as $invocation) {
if (
!empty($signature)
&& strtolower(trim($invocation->getName(), '\\')) != $signature
) {
continue;
}
yield $invocation;
}
}
} | php | protected function availableInvocations(string $signature = ''): \Generator
{
$signature = strtolower(trim($signature, '\\'));
foreach ($this->availableReflections() as $reflection) {
foreach ($reflection->getInvocations() as $invocation) {
if (
!empty($signature)
&& strtolower(trim($invocation->getName(), '\\')) != $signature
) {
continue;
}
yield $invocation;
}
}
} | [
"protected",
"function",
"availableInvocations",
"(",
"string",
"$",
"signature",
"=",
"''",
")",
":",
"\\",
"Generator",
"{",
"$",
"signature",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"signature",
",",
"'\\\\'",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"availableReflections",
"(",
")",
"as",
"$",
"reflection",
")",
"{",
"foreach",
"(",
"$",
"reflection",
"->",
"getInvocations",
"(",
")",
"as",
"$",
"invocation",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"signature",
")",
"&&",
"strtolower",
"(",
"trim",
"(",
"$",
"invocation",
"->",
"getName",
"(",
")",
",",
"'\\\\'",
")",
")",
"!=",
"$",
"signature",
")",
"{",
"continue",
";",
"}",
"yield",
"$",
"invocation",
";",
"}",
"}",
"}"
] | Invocations available in finder scope.
@param string $signature Method or function signature (name), for pre-filtering.
@return ReflectionInvocation[]|\Generator | [
"Invocations",
"available",
"in",
"finder",
"scope",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/InvocationLocator.php#L43-L58 |
28,950 | spiral/tokenizer | src/ClassLocator.php | ClassLocator.availableClasses | protected function availableClasses(): array
{
$classes = [];
foreach ($this->availableReflections() as $reflection) {
$classes = array_merge($classes, $reflection->getClasses());
}
return $classes;
} | php | protected function availableClasses(): array
{
$classes = [];
foreach ($this->availableReflections() as $reflection) {
$classes = array_merge($classes, $reflection->getClasses());
}
return $classes;
} | [
"protected",
"function",
"availableClasses",
"(",
")",
":",
"array",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"availableReflections",
"(",
")",
"as",
"$",
"reflection",
")",
"{",
"$",
"classes",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"reflection",
"->",
"getClasses",
"(",
")",
")",
";",
"}",
"return",
"$",
"classes",
";",
"}"
] | Classes available in finder scope.
@return array | [
"Classes",
"available",
"in",
"finder",
"scope",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/ClassLocator.php#L51-L60 |
28,951 | spiral/tokenizer | src/ClassLocator.php | ClassLocator.isTargeted | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool
{
if (empty($target)) {
return true;
}
if (!$target->isTrait()) {
//Target is interface or class
return $class->isSubclassOf($target) || $class->getName() == $target->getName();
}
//Checking using traits
return in_array($target->getName(), $this->fetchTraits($class->getName()));
} | php | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool
{
if (empty($target)) {
return true;
}
if (!$target->isTrait()) {
//Target is interface or class
return $class->isSubclassOf($target) || $class->getName() == $target->getName();
}
//Checking using traits
return in_array($target->getName(), $this->fetchTraits($class->getName()));
} | [
"protected",
"function",
"isTargeted",
"(",
"\\",
"ReflectionClass",
"$",
"class",
",",
"\\",
"ReflectionClass",
"$",
"target",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"target",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"target",
"->",
"isTrait",
"(",
")",
")",
"{",
"//Target is interface or class",
"return",
"$",
"class",
"->",
"isSubclassOf",
"(",
"$",
"target",
")",
"||",
"$",
"class",
"->",
"getName",
"(",
")",
"==",
"$",
"target",
"->",
"getName",
"(",
")",
";",
"}",
"//Checking using traits",
"return",
"in_array",
"(",
"$",
"target",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"fetchTraits",
"(",
"$",
"class",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | Check if given class targeted by locator.
@param \ReflectionClass $class
@param \ReflectionClass|null $target
@return bool | [
"Check",
"if",
"given",
"class",
"targeted",
"by",
"locator",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/ClassLocator.php#L69-L82 |
28,952 | spiral/tokenizer | src/Isolator.php | Isolator.isolatePHP | public function isolatePHP(string $source): string
{
$phpBlock = false;
$isolated = '';
foreach (token_get_all($source) as $token) {
if ($this->isOpenTag($token)) {
$phpBlock = $token[1];
continue;
}
if ($this->isCloseTag($token)) {
$blockID = $this->uniqueID();
$this->phpBlocks[$blockID] = $phpBlock . $token[1];
$isolated .= $this->placeholder($blockID);
$phpBlock = '';
continue;
}
$tokenContent = is_array($token) ? $token[1] : $token;
if (!empty($phpBlock)) {
$phpBlock .= $tokenContent;
} else {
$isolated .= $tokenContent;
}
}
return $isolated;
} | php | public function isolatePHP(string $source): string
{
$phpBlock = false;
$isolated = '';
foreach (token_get_all($source) as $token) {
if ($this->isOpenTag($token)) {
$phpBlock = $token[1];
continue;
}
if ($this->isCloseTag($token)) {
$blockID = $this->uniqueID();
$this->phpBlocks[$blockID] = $phpBlock . $token[1];
$isolated .= $this->placeholder($blockID);
$phpBlock = '';
continue;
}
$tokenContent = is_array($token) ? $token[1] : $token;
if (!empty($phpBlock)) {
$phpBlock .= $tokenContent;
} else {
$isolated .= $tokenContent;
}
}
return $isolated;
} | [
"public",
"function",
"isolatePHP",
"(",
"string",
"$",
"source",
")",
":",
"string",
"{",
"$",
"phpBlock",
"=",
"false",
";",
"$",
"isolated",
"=",
"''",
";",
"foreach",
"(",
"token_get_all",
"(",
"$",
"source",
")",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOpenTag",
"(",
"$",
"token",
")",
")",
"{",
"$",
"phpBlock",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isCloseTag",
"(",
"$",
"token",
")",
")",
"{",
"$",
"blockID",
"=",
"$",
"this",
"->",
"uniqueID",
"(",
")",
";",
"$",
"this",
"->",
"phpBlocks",
"[",
"$",
"blockID",
"]",
"=",
"$",
"phpBlock",
".",
"$",
"token",
"[",
"1",
"]",
";",
"$",
"isolated",
".=",
"$",
"this",
"->",
"placeholder",
"(",
"$",
"blockID",
")",
";",
"$",
"phpBlock",
"=",
"''",
";",
"continue",
";",
"}",
"$",
"tokenContent",
"=",
"is_array",
"(",
"$",
"token",
")",
"?",
"$",
"token",
"[",
"1",
"]",
":",
"$",
"token",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"phpBlock",
")",
")",
"{",
"$",
"phpBlock",
".=",
"$",
"tokenContent",
";",
"}",
"else",
"{",
"$",
"isolated",
".=",
"$",
"tokenContent",
";",
"}",
"}",
"return",
"$",
"isolated",
";",
"}"
] | Isolates all returned PHP blocks with a defined pattern. Method uses
token_get_all function. Resulted src have all php blocks replaced
with non executable placeholder.
@param string $source
@return string | [
"Isolates",
"all",
"returned",
"PHP",
"blocks",
"with",
"a",
"defined",
"pattern",
".",
"Method",
"uses",
"token_get_all",
"function",
".",
"Resulted",
"src",
"have",
"all",
"php",
"blocks",
"replaced",
"with",
"non",
"executable",
"placeholder",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Isolator.php#L64-L97 |
28,953 | spiral/tokenizer | src/Isolator.php | Isolator.setBlock | public function setBlock(string $blockID, string $source): Isolator
{
if (!isset($this->phpBlocks[$blockID])) {
throw new IsolatorException("Undefined block {$blockID}");
}
$this->phpBlocks[$blockID] = $source;
return $this;
} | php | public function setBlock(string $blockID, string $source): Isolator
{
if (!isset($this->phpBlocks[$blockID])) {
throw new IsolatorException("Undefined block {$blockID}");
}
$this->phpBlocks[$blockID] = $source;
return $this;
} | [
"public",
"function",
"setBlock",
"(",
"string",
"$",
"blockID",
",",
"string",
"$",
"source",
")",
":",
"Isolator",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"phpBlocks",
"[",
"$",
"blockID",
"]",
")",
")",
"{",
"throw",
"new",
"IsolatorException",
"(",
"\"Undefined block {$blockID}\"",
")",
";",
"}",
"$",
"this",
"->",
"phpBlocks",
"[",
"$",
"blockID",
"]",
"=",
"$",
"source",
";",
"return",
"$",
"this",
";",
"}"
] | Set block content by id.
@param string $blockID
@param string $source
@return self
@throws IsolatorException | [
"Set",
"block",
"content",
"by",
"id",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Isolator.php#L109-L118 |
28,954 | spiral/tokenizer | src/Reflection/ReflectionInvocation.php | ReflectionInvocation.getArgument | public function getArgument(int $index): ReflectionArgument
{
if (!isset($this->arguments[$index])) {
throw new ReflectionException("No such argument with index '{$index}'");
}
return $this->arguments[$index];
} | php | public function getArgument(int $index): ReflectionArgument
{
if (!isset($this->arguments[$index])) {
throw new ReflectionException("No such argument with index '{$index}'");
}
return $this->arguments[$index];
} | [
"public",
"function",
"getArgument",
"(",
"int",
"$",
"index",
")",
":",
"ReflectionArgument",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"ReflectionException",
"(",
"\"No such argument with index '{$index}'\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"arguments",
"[",
"$",
"index",
"]",
";",
"}"
] | Get call argument by it's position.
@param int $index
@return ReflectionArgument|null | [
"Get",
"call",
"argument",
"by",
"it",
"s",
"position",
"."
] | aca11410e183d4c4a6c0f858ba87bf072c4eb925 | https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionInvocation.php#L178-L185 |
28,955 | prologuephp/alerts | src/AlertsMessageBag.php | AlertsMessageBag.flush | public function flush($withSession = true)
{
$this->messages = [];
if($withSession) {
$this->session->forget($this->getSessionKey());
}
return $this;
} | php | public function flush($withSession = true)
{
$this->messages = [];
if($withSession) {
$this->session->forget($this->getSessionKey());
}
return $this;
} | [
"public",
"function",
"flush",
"(",
"$",
"withSession",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"messages",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"withSession",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"forget",
"(",
"$",
"this",
"->",
"getSessionKey",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Deletes all messages.
@param bool $withSession
@return \Prologue\Alerts\AlertsMessageBag | [
"Deletes",
"all",
"messages",
"."
] | d88244729b0109308136cbafe45f11095c7ee0b0 | https://github.com/prologuephp/alerts/blob/d88244729b0109308136cbafe45f11095c7ee0b0/src/AlertsMessageBag.php#L95-L104 |
28,956 | timble/kodekit | code/controller/behavior/persistable.php | ControllerBehaviorPersistable._getStateKey | protected function _getStateKey(ControllerContext $context)
{
$view = $this->getView()->getIdentifier();
$layout = $this->getView()->getLayout();
$model = $this->getModel()->getIdentifier();
return $view.'.'.$layout.'.'.$model.'.'.$context->action;
} | php | protected function _getStateKey(ControllerContext $context)
{
$view = $this->getView()->getIdentifier();
$layout = $this->getView()->getLayout();
$model = $this->getModel()->getIdentifier();
return $view.'.'.$layout.'.'.$model.'.'.$context->action;
} | [
"protected",
"function",
"_getStateKey",
"(",
"ControllerContext",
"$",
"context",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"layout",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"getLayout",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"return",
"$",
"view",
".",
"'.'",
".",
"$",
"layout",
".",
"'.'",
".",
"$",
"model",
".",
"'.'",
".",
"$",
"context",
"->",
"action",
";",
"}"
] | Returns a key based on the context to persist state values
@param ControllerContext $context The active controller context
@return string | [
"Returns",
"a",
"key",
"based",
"on",
"the",
"context",
"to",
"persist",
"state",
"values"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/persistable.php#L46-L53 |
28,957 | timble/kodekit | code/controller/behavior/persistable.php | ControllerBehaviorPersistable._beforeBrowse | protected function _beforeBrowse(ControllerContextModel $context)
{
$query = $context->getRequest()->query;
$query->add((array) $context->user->get($this->_getStateKey($context)));
$this->getModel()->getState()->setValues($query->toArray());
} | php | protected function _beforeBrowse(ControllerContextModel $context)
{
$query = $context->getRequest()->query;
$query->add((array) $context->user->get($this->_getStateKey($context)));
$this->getModel()->getState()->setValues($query->toArray());
} | [
"protected",
"function",
"_beforeBrowse",
"(",
"ControllerContextModel",
"$",
"context",
")",
"{",
"$",
"query",
"=",
"$",
"context",
"->",
"getRequest",
"(",
")",
"->",
"query",
";",
"$",
"query",
"->",
"add",
"(",
"(",
"array",
")",
"$",
"context",
"->",
"user",
"->",
"get",
"(",
"$",
"this",
"->",
"_getStateKey",
"(",
"$",
"context",
")",
")",
")",
";",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getState",
"(",
")",
"->",
"setValues",
"(",
"$",
"query",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] | Load the model state from the request
This functions merges the request information with any model state information that was saved in the session and
returns the result.
@param ControllerContextModel $context The active controller context
@return void | [
"Load",
"the",
"model",
"state",
"from",
"the",
"request"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/persistable.php#L64-L71 |
28,958 | timble/kodekit | code/class/registry/registry.php | ClassRegistry.getLocator | public function getLocator($class)
{
$result = false;
if(!false == $pos = strrpos($class, '\\'))
{
$namespace = substr($class, 0, $pos);
if(isset($this->_namespaces[$namespace])) {
$result = $this->_namespaces[$namespace];
}
}
return $result;
} | php | public function getLocator($class)
{
$result = false;
if(!false == $pos = strrpos($class, '\\'))
{
$namespace = substr($class, 0, $pos);
if(isset($this->_namespaces[$namespace])) {
$result = $this->_namespaces[$namespace];
}
}
return $result;
} | [
"public",
"function",
"getLocator",
"(",
"$",
"class",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"false",
"==",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"$",
"pos",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_namespaces",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_namespaces",
"[",
"$",
"namespace",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get a specific locator from the class namespace
@return string|false The name of the locator or FALSE if no locator could be found | [
"Get",
"a",
"specific",
"locator",
"from",
"the",
"class",
"namespace"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/registry.php#L143-L157 |
28,959 | timble/kodekit | code/class/registry/registry.php | ClassRegistry.setLocator | public function setLocator($class, $locator)
{
if(!false == $pos = strrpos($class, '\\'))
{
$namespace = substr($class, 0, $pos);
$this->_namespaces[$namespace] = $locator;
}
return $this;
} | php | public function setLocator($class, $locator)
{
if(!false == $pos = strrpos($class, '\\'))
{
$namespace = substr($class, 0, $pos);
$this->_namespaces[$namespace] = $locator;
}
return $this;
} | [
"public",
"function",
"setLocator",
"(",
"$",
"class",
",",
"$",
"locator",
")",
"{",
"if",
"(",
"!",
"false",
"==",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"this",
"->",
"_namespaces",
"[",
"$",
"namespace",
"]",
"=",
"$",
"locator",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set a specific locator based on a class namespace
@return ClassRegistry | [
"Set",
"a",
"specific",
"locator",
"based",
"on",
"a",
"class",
"namespace"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/registry.php#L164-L173 |
28,960 | timble/kodekit | code/filesystem/stream/iterator/chunked.php | FilesystemStreamIteratorChunked.seek | public function seek($position)
{
if ($position > $this->count()) {
throw new \OutOfBoundsException('Invalid seek position ('.$position.')');
}
$chunk_size = $this->getChunkSize();
$position = $chunk_size * $position;
$this->getInnerIterator()->seek($position);
} | php | public function seek($position)
{
if ($position > $this->count()) {
throw new \OutOfBoundsException('Invalid seek position ('.$position.')');
}
$chunk_size = $this->getChunkSize();
$position = $chunk_size * $position;
$this->getInnerIterator()->seek($position);
} | [
"public",
"function",
"seek",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
">",
"$",
"this",
"->",
"count",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Invalid seek position ('",
".",
"$",
"position",
".",
"')'",
")",
";",
"}",
"$",
"chunk_size",
"=",
"$",
"this",
"->",
"getChunkSize",
"(",
")",
";",
"$",
"position",
"=",
"$",
"chunk_size",
"*",
"$",
"position",
";",
"$",
"this",
"->",
"getInnerIterator",
"(",
")",
"->",
"seek",
"(",
"$",
"position",
")",
";",
"}"
] | Seeks to a given chunk position in the stream
@param int $position
@throws \OutOfBoundsException If the position is not seekable.
@return void | [
"Seeks",
"to",
"a",
"given",
"chunk",
"position",
"in",
"the",
"stream"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/stream/iterator/chunked.php#L46-L56 |
28,961 | timble/kodekit | code/template/helper/grid.php | TemplateHelperGrid.checkbox | public function checkbox($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null,
'attribs' => array()
))->append(array(
'column' => $config->entity->getIdentityKey()
));
if($config->entity->isLockable() && $config->entity->isLocked())
{
$html = $this->createHelper('behavior')->tooltip();
$html .= '<span class="k-icon-lock-locked"
data-k-tooltip
title="'.$this->createHelper('grid')->lock_message(array('entity' => $config->entity)).'">
</span>';
}
else
{
$column = $config->column;
$value = StringEscaper::attr($config->entity->{$column});
$attribs = $this->buildAttributes($config->attribs);
$html = '<input type="checkbox" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />';
$html = sprintf($html, $column, $value, $attribs);
}
return $html;
} | php | public function checkbox($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null,
'attribs' => array()
))->append(array(
'column' => $config->entity->getIdentityKey()
));
if($config->entity->isLockable() && $config->entity->isLocked())
{
$html = $this->createHelper('behavior')->tooltip();
$html .= '<span class="k-icon-lock-locked"
data-k-tooltip
title="'.$this->createHelper('grid')->lock_message(array('entity' => $config->entity)).'">
</span>';
}
else
{
$column = $config->column;
$value = StringEscaper::attr($config->entity->{$column});
$attribs = $this->buildAttributes($config->attribs);
$html = '<input type="checkbox" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />';
$html = sprintf($html, $column, $value, $attribs);
}
return $html;
} | [
"public",
"function",
"checkbox",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"ObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'entity'",
"=>",
"null",
",",
"'attribs'",
"=>",
"array",
"(",
")",
")",
")",
"->",
"append",
"(",
"array",
"(",
"'column'",
"=>",
"$",
"config",
"->",
"entity",
"->",
"getIdentityKey",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"config",
"->",
"entity",
"->",
"isLockable",
"(",
")",
"&&",
"$",
"config",
"->",
"entity",
"->",
"isLocked",
"(",
")",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"createHelper",
"(",
"'behavior'",
")",
"->",
"tooltip",
"(",
")",
";",
"$",
"html",
".=",
"'<span class=\"k-icon-lock-locked\"\n data-k-tooltip\n title=\"'",
".",
"$",
"this",
"->",
"createHelper",
"(",
"'grid'",
")",
"->",
"lock_message",
"(",
"array",
"(",
"'entity'",
"=>",
"$",
"config",
"->",
"entity",
")",
")",
".",
"'\">\n </span>'",
";",
"}",
"else",
"{",
"$",
"column",
"=",
"$",
"config",
"->",
"column",
";",
"$",
"value",
"=",
"StringEscaper",
"::",
"attr",
"(",
"$",
"config",
"->",
"entity",
"->",
"{",
"$",
"column",
"}",
")",
";",
"$",
"attribs",
"=",
"$",
"this",
"->",
"buildAttributes",
"(",
"$",
"config",
"->",
"attribs",
")",
";",
"$",
"html",
"=",
"'<input type=\"checkbox\" class=\"k-js-grid-checkbox\" name=\"%s[]\" value=\"%s\" %s />'",
";",
"$",
"html",
"=",
"sprintf",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"value",
",",
"$",
"attribs",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Render a checkbox field
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"a",
"checkbox",
"field"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L61-L91 |
28,962 | timble/kodekit | code/template/helper/grid.php | TemplateHelperGrid.enable | public function enable($config = array())
{
$translator = $this->getObject('translator');
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'enabled',
'clickable' => true
))->append(array(
'enabled' => (bool) $config->entity->{$config->field},
'data' => array($config->field => $config->entity->{$config->field} ? 0 : 1),
))->append(array(
'alt' => $config->enabled ? $translator->translate('Enabled') : $translator->translate('Disabled'),
'tooltip' => $config->enabled ? $translator->translate('Disable Item') : $translator->translate('Enable Item'),
'color' => $config->enabled ? '#468847' : '#b94a48',
'icon' => $config->enabled ? 'enabled' : 'disabled',
));
$class = $config->enabled ? 'k-table__item--state-published' : 'k-table__item--state-unpublished';
$tooltip = '';
if ($config->clickable)
{
$data = htmlentities(json_encode($config->data->toArray()));
$tooltip = 'data-k-tooltip=\'{"container":".k-ui-container","delay":{"show":500,"hide":50}}\'
style="cursor: pointer"
data-action="edit"
data-data="'.$data.'"
data-original-title="'.$config->tooltip.'"';
}
$html = '<span class="k-table__item--state '.$class.'" '.$tooltip.'>'.$config->alt.'</span>';
$html .= $this->createHelper('behavior')->tooltip();
return $html;
} | php | public function enable($config = array())
{
$translator = $this->getObject('translator');
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'enabled',
'clickable' => true
))->append(array(
'enabled' => (bool) $config->entity->{$config->field},
'data' => array($config->field => $config->entity->{$config->field} ? 0 : 1),
))->append(array(
'alt' => $config->enabled ? $translator->translate('Enabled') : $translator->translate('Disabled'),
'tooltip' => $config->enabled ? $translator->translate('Disable Item') : $translator->translate('Enable Item'),
'color' => $config->enabled ? '#468847' : '#b94a48',
'icon' => $config->enabled ? 'enabled' : 'disabled',
));
$class = $config->enabled ? 'k-table__item--state-published' : 'k-table__item--state-unpublished';
$tooltip = '';
if ($config->clickable)
{
$data = htmlentities(json_encode($config->data->toArray()));
$tooltip = 'data-k-tooltip=\'{"container":".k-ui-container","delay":{"show":500,"hide":50}}\'
style="cursor: pointer"
data-action="edit"
data-data="'.$data.'"
data-original-title="'.$config->tooltip.'"';
}
$html = '<span class="k-table__item--state '.$class.'" '.$tooltip.'>'.$config->alt.'</span>';
$html .= $this->createHelper('behavior')->tooltip();
return $html;
} | [
"public",
"function",
"enable",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
";",
"$",
"config",
"=",
"new",
"ObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'entity'",
"=>",
"null",
",",
"'field'",
"=>",
"'enabled'",
",",
"'clickable'",
"=>",
"true",
")",
")",
"->",
"append",
"(",
"array",
"(",
"'enabled'",
"=>",
"(",
"bool",
")",
"$",
"config",
"->",
"entity",
"->",
"{",
"$",
"config",
"->",
"field",
"}",
",",
"'data'",
"=>",
"array",
"(",
"$",
"config",
"->",
"field",
"=>",
"$",
"config",
"->",
"entity",
"->",
"{",
"$",
"config",
"->",
"field",
"}",
"?",
"0",
":",
"1",
")",
",",
")",
")",
"->",
"append",
"(",
"array",
"(",
"'alt'",
"=>",
"$",
"config",
"->",
"enabled",
"?",
"$",
"translator",
"->",
"translate",
"(",
"'Enabled'",
")",
":",
"$",
"translator",
"->",
"translate",
"(",
"'Disabled'",
")",
",",
"'tooltip'",
"=>",
"$",
"config",
"->",
"enabled",
"?",
"$",
"translator",
"->",
"translate",
"(",
"'Disable Item'",
")",
":",
"$",
"translator",
"->",
"translate",
"(",
"'Enable Item'",
")",
",",
"'color'",
"=>",
"$",
"config",
"->",
"enabled",
"?",
"'#468847'",
":",
"'#b94a48'",
",",
"'icon'",
"=>",
"$",
"config",
"->",
"enabled",
"?",
"'enabled'",
":",
"'disabled'",
",",
")",
")",
";",
"$",
"class",
"=",
"$",
"config",
"->",
"enabled",
"?",
"'k-table__item--state-published'",
":",
"'k-table__item--state-unpublished'",
";",
"$",
"tooltip",
"=",
"''",
";",
"if",
"(",
"$",
"config",
"->",
"clickable",
")",
"{",
"$",
"data",
"=",
"htmlentities",
"(",
"json_encode",
"(",
"$",
"config",
"->",
"data",
"->",
"toArray",
"(",
")",
")",
")",
";",
"$",
"tooltip",
"=",
"'data-k-tooltip=\\'{\"container\":\".k-ui-container\",\"delay\":{\"show\":500,\"hide\":50}}\\'\n style=\"cursor: pointer\"\n data-action=\"edit\" \n data-data=\"'",
".",
"$",
"data",
".",
"'\" \n data-original-title=\"'",
".",
"$",
"config",
"->",
"tooltip",
".",
"'\"'",
";",
"}",
"$",
"html",
"=",
"'<span class=\"k-table__item--state '",
".",
"$",
"class",
".",
"'\" '",
".",
"$",
"tooltip",
".",
"'>'",
".",
"$",
"config",
"->",
"alt",
".",
"'</span>'",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"createHelper",
"(",
"'behavior'",
")",
"->",
"tooltip",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Render an enable field
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"an",
"enable",
"field"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L265-L302 |
28,963 | timble/kodekit | code/template/helper/grid.php | TemplateHelperGrid.lock_message | public function lock_message($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null
));
if (!($config->entity instanceof ModelEntityInterface)) {
throw new \UnexpectedValueException('$config->entity should be a ModelEntityInterface instance');
}
$entity = $config->entity;
$message = '';
if($entity->isLockable() && $entity->isLocked())
{
$user = $entity->getLocker();
$date = $this->getObject('date', array('date' => $entity->locked_on));
$message = $this->getObject('translator')->translate(
'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize())
);
}
return $message;
} | php | public function lock_message($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
'entity' => null
));
if (!($config->entity instanceof ModelEntityInterface)) {
throw new \UnexpectedValueException('$config->entity should be a ModelEntityInterface instance');
}
$entity = $config->entity;
$message = '';
if($entity->isLockable() && $entity->isLocked())
{
$user = $entity->getLocker();
$date = $this->getObject('date', array('date' => $entity->locked_on));
$message = $this->getObject('translator')->translate(
'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize())
);
}
return $message;
} | [
"public",
"function",
"lock_message",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"ObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'entity'",
"=>",
"null",
")",
")",
";",
"if",
"(",
"!",
"(",
"$",
"config",
"->",
"entity",
"instanceof",
"ModelEntityInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'$config->entity should be a ModelEntityInterface instance'",
")",
";",
"}",
"$",
"entity",
"=",
"$",
"config",
"->",
"entity",
";",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"$",
"entity",
"->",
"isLockable",
"(",
")",
"&&",
"$",
"entity",
"->",
"isLocked",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
"entity",
"->",
"getLocker",
"(",
")",
";",
"$",
"date",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'date'",
",",
"array",
"(",
"'date'",
"=>",
"$",
"entity",
"->",
"locked_on",
")",
")",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
"->",
"translate",
"(",
"'Locked by {name} {date}'",
",",
"array",
"(",
"'name'",
"=>",
"$",
"user",
"->",
"getName",
"(",
")",
",",
"'date'",
"=>",
"$",
"date",
"->",
"humanize",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | Get the locked information
@param array|ObjectConfig $config An optional configuration array.
@throws \UnexpectedValueException
@return string The locked by "name" "date" message | [
"Get",
"the",
"locked",
"information"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L338-L363 |
28,964 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.isValidIsbn | public function isValidIsbn(string $isbn) : bool
{
return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn);
} | php | public function isValidIsbn(string $isbn) : bool
{
return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn);
} | [
"public",
"function",
"isValidIsbn",
"(",
"string",
"$",
"isbn",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"isValidIsbn10",
"(",
"$",
"isbn",
")",
"||",
"$",
"this",
"->",
"isValidIsbn13",
"(",
"$",
"isbn",
")",
";",
"}"
] | Returns whether the given ISBN is a valid ISBN-10 or ISBN-13.
@param string $isbn The unformatted ISBN.
@return bool | [
"Returns",
"whether",
"the",
"given",
"ISBN",
"is",
"a",
"valid",
"ISBN",
"-",
"10",
"or",
"ISBN",
"-",
"13",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L39-L42 |
28,965 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.isValidIsbn10 | public function isValidIsbn10(string $isbn) : bool
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
return false;
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) {
return false;
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
return false;
}
}
return true;
} | php | public function isValidIsbn10(string $isbn) : bool
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
return false;
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) {
return false;
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
return false;
}
}
return true;
} | [
"public",
"function",
"isValidIsbn10",
"(",
"string",
"$",
"isbn",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanupBeforeValidate",
")",
"{",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ASCII",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"isbn",
"=",
"preg_replace",
"(",
"Internal",
"\\",
"Regexp",
"::",
"NON_ALNUM",
",",
"''",
",",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"strtoupper",
"(",
"$",
"isbn",
")",
";",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN10",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit10",
"(",
"$",
"isbn",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns whether the given ISBN is a valid ISBN-10.
@param string $isbn The unformatted ISBN.
@return bool | [
"Returns",
"whether",
"the",
"given",
"ISBN",
"is",
"a",
"valid",
"ISBN",
"-",
"10",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L51-L74 |
28,966 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.isValidIsbn13 | public function isValidIsbn13(string $isbn) : bool
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
return false;
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) {
return false;
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
return false;
}
}
return true;
} | php | public function isValidIsbn13(string $isbn) : bool
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
return false;
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) {
return false;
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
return false;
}
}
return true;
} | [
"public",
"function",
"isValidIsbn13",
"(",
"string",
"$",
"isbn",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanupBeforeValidate",
")",
"{",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ASCII",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"isbn",
"=",
"preg_replace",
"(",
"Internal",
"\\",
"Regexp",
"::",
"NON_ALNUM",
",",
"''",
",",
"$",
"isbn",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN13",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit13",
"(",
"$",
"isbn",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns whether the given ISBN is a valid ISBN-13.
@param string $isbn The unformatted ISBN.
@return bool | [
"Returns",
"whether",
"the",
"given",
"ISBN",
"is",
"a",
"valid",
"ISBN",
"-",
"13",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L83-L104 |
28,967 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.convertIsbn10to13 | public function convertIsbn10to13(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\Converter::convertIsbn10to13($isbn);
} | php | public function convertIsbn10to13(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\Converter::convertIsbn10to13($isbn);
} | [
"public",
"function",
"convertIsbn10to13",
"(",
"string",
"$",
"isbn",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanupBeforeValidate",
")",
"{",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ASCII",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"preg_replace",
"(",
"Internal",
"\\",
"Regexp",
"::",
"NON_ALNUM",
",",
"''",
",",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"strtoupper",
"(",
"$",
"isbn",
")",
";",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN10",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit10",
"(",
"$",
"isbn",
")",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"}",
"return",
"Internal",
"\\",
"Converter",
"::",
"convertIsbn10to13",
"(",
"$",
"isbn",
")",
";",
"}"
] | Converts an ISBN-10 to an ISBN-13.
@param string $isbn The ISBN-10 to convert.
@return string The converted, unformatted ISBN-13.
@throws Exception\InvalidIsbnException If the ISBN is not a valid ISBN-10. | [
"Converts",
"an",
"ISBN",
"-",
"10",
"to",
"an",
"ISBN",
"-",
"13",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L115-L138 |
28,968 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.convertIsbn13to10 | public function convertIsbn13to10(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\Converter::convertIsbn13to10($isbn);
} | php | public function convertIsbn13to10(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\Converter::convertIsbn13to10($isbn);
} | [
"public",
"function",
"convertIsbn13to10",
"(",
"string",
"$",
"isbn",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanupBeforeValidate",
")",
"{",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ASCII",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"preg_replace",
"(",
"Internal",
"\\",
"Regexp",
"::",
"NON_ALNUM",
",",
"''",
",",
"$",
"isbn",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN13",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit13",
"(",
"$",
"isbn",
")",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"}",
"return",
"Internal",
"\\",
"Converter",
"::",
"convertIsbn13to10",
"(",
"$",
"isbn",
")",
";",
"}"
] | Converts an ISBN-13 to an ISBN-10.
Only ISBN-13 numbers starting with 978 can be converted to an ISBN-10.
If the input ISBN is a valid ISBN-13 but does not start with 978, an exception is thrown.
@param string $isbn The ISBN-13 to convert.
@return string The converted, unformatted ISBN-10.
@throws Exception\InvalidIsbnException If the ISBN is not a valid ISBN-13.
@throws Exception\IsbnNotConvertibleException If the ISBN cannot be converted. | [
"Converts",
"an",
"ISBN",
"-",
"13",
"to",
"an",
"ISBN",
"-",
"10",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L153-L174 |
28,969 | nicebooks-com/isbn | src/IsbnTools.php | IsbnTools.format | public function format(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 1) {
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\RangeService::format($isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 1) {
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\RangeService::format($isbn);
}
throw Exception\InvalidIsbnException::forIsbn($isbn);
} | php | public function format(string $isbn) : string
{
if ($this->cleanupBeforeValidate) {
if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
$isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
}
if (preg_match(Internal\Regexp::ISBN13, $isbn) === 1) {
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\RangeService::format($isbn);
}
$isbn = strtoupper($isbn);
if (preg_match(Internal\Regexp::ISBN10, $isbn) === 1) {
if ($this->validateCheckDigit) {
if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
throw Exception\InvalidIsbnException::forIsbn($isbn);
}
}
return Internal\RangeService::format($isbn);
}
throw Exception\InvalidIsbnException::forIsbn($isbn);
} | [
"public",
"function",
"format",
"(",
"string",
"$",
"isbn",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanupBeforeValidate",
")",
"{",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ASCII",
",",
"$",
"isbn",
")",
"===",
"0",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"preg_replace",
"(",
"Internal",
"\\",
"Regexp",
"::",
"NON_ALNUM",
",",
"''",
",",
"$",
"isbn",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN13",
",",
"$",
"isbn",
")",
"===",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit13",
"(",
"$",
"isbn",
")",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"}",
"return",
"Internal",
"\\",
"RangeService",
"::",
"format",
"(",
"$",
"isbn",
")",
";",
"}",
"$",
"isbn",
"=",
"strtoupper",
"(",
"$",
"isbn",
")",
";",
"if",
"(",
"preg_match",
"(",
"Internal",
"\\",
"Regexp",
"::",
"ISBN10",
",",
"$",
"isbn",
")",
"===",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateCheckDigit",
")",
"{",
"if",
"(",
"!",
"Internal",
"\\",
"CheckDigit",
"::",
"validateCheckDigit10",
"(",
"$",
"isbn",
")",
")",
"{",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}",
"}",
"return",
"Internal",
"\\",
"RangeService",
"::",
"format",
"(",
"$",
"isbn",
")",
";",
"}",
"throw",
"Exception",
"\\",
"InvalidIsbnException",
"::",
"forIsbn",
"(",
"$",
"isbn",
")",
";",
"}"
] | Formats an ISBN number.
@param string $isbn The ISBN-10 or ISBN-13 number.
@return string The formatted ISBN number.
@throws Exception\InvalidIsbnException If the ISBN is not valid. | [
"Formats",
"an",
"ISBN",
"number",
"."
] | f5ceb662e517b21e30c9dfa53c4d74823849232d | https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L185-L218 |
28,970 | timble/kodekit | code/model/behavior/paginatable.php | ModelBehaviorPaginatable.getPaginator | public function getPaginator()
{
$paginator = new ModelPaginator(array(
'offset' => (int)$this->getState()->offset,
'limit' => (int)$this->getState()->limit,
'total' => (int)$this->count(),
));
return $paginator;
} | php | public function getPaginator()
{
$paginator = new ModelPaginator(array(
'offset' => (int)$this->getState()->offset,
'limit' => (int)$this->getState()->limit,
'total' => (int)$this->count(),
));
return $paginator;
} | [
"public",
"function",
"getPaginator",
"(",
")",
"{",
"$",
"paginator",
"=",
"new",
"ModelPaginator",
"(",
"array",
"(",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"this",
"->",
"getState",
"(",
")",
"->",
"offset",
",",
"'limit'",
"=>",
"(",
"int",
")",
"$",
"this",
"->",
"getState",
"(",
")",
"->",
"limit",
",",
"'total'",
"=>",
"(",
"int",
")",
"$",
"this",
"->",
"count",
"(",
")",
",",
")",
")",
";",
"return",
"$",
"paginator",
";",
"}"
] | Get the model paginator object
@return ModelPaginator The model paginator object | [
"Get",
"the",
"model",
"paginator",
"object"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/model/behavior/paginatable.php#L39-L48 |
28,971 | timble/kodekit | code/filter/factory.php | FilterFactory.createFilter | public function createFilter($filter, $config = array())
{
if(is_string($filter) && strpos($filter, '.') === false )
{
$identifier = $this->getIdentifier()->toArray();
$identifier['name'] = $filter;
}
else $identifier = $filter;
$filter = $this->getObject($identifier, $config);
//Check the filter interface
if(!($filter instanceof FilterInterface)) {
throw new \UnexpectedValueException('Filter:'.get_class($filter).' does not implement FilterInterface');
}
return $filter;
} | php | public function createFilter($filter, $config = array())
{
if(is_string($filter) && strpos($filter, '.') === false )
{
$identifier = $this->getIdentifier()->toArray();
$identifier['name'] = $filter;
}
else $identifier = $filter;
$filter = $this->getObject($identifier, $config);
//Check the filter interface
if(!($filter instanceof FilterInterface)) {
throw new \UnexpectedValueException('Filter:'.get_class($filter).' does not implement FilterInterface');
}
return $filter;
} | [
"public",
"function",
"createFilter",
"(",
"$",
"filter",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"filter",
")",
"&&",
"strpos",
"(",
"$",
"filter",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"identifier",
"[",
"'name'",
"]",
"=",
"$",
"filter",
";",
"}",
"else",
"$",
"identifier",
"=",
"$",
"filter",
";",
"$",
"filter",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"identifier",
",",
"$",
"config",
")",
";",
"//Check the filter interface",
"if",
"(",
"!",
"(",
"$",
"filter",
"instanceof",
"FilterInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Filter:'",
".",
"get_class",
"(",
"$",
"filter",
")",
".",
"' does not implement FilterInterface'",
")",
";",
"}",
"return",
"$",
"filter",
";",
"}"
] | Factory method for Filter classes.
If the filter is not an identifier this function will create it directly instead of going through the Object
identification process.
@param string $filter Filter identifier
@param object|array $config An optional ObjectConfig object with configuration options
@throws \UnexpectedValueException When the filter does not implement FilterInterface
@return FilterInterface | [
"Factory",
"method",
"for",
"Filter",
"classes",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filter/factory.php#L56-L73 |
28,972 | rosasurfer/ministruts | src/monitor/ChainedDependency.php | ChainedDependency.isValid | public function isValid() {
if ($this->type == 'AND') {
foreach ($this->dependencies as $dependency) {
if (!$dependency->isValid())
return false;
}
return true;
}
if ($this->type == 'OR' ) {
foreach ($this->dependencies as $dependency) {
if ($dependency->isValid())
return true;
}
return false;
}
throw new RuntimeException('Unreachable code reached');
} | php | public function isValid() {
if ($this->type == 'AND') {
foreach ($this->dependencies as $dependency) {
if (!$dependency->isValid())
return false;
}
return true;
}
if ($this->type == 'OR' ) {
foreach ($this->dependencies as $dependency) {
if ($dependency->isValid())
return true;
}
return false;
}
throw new RuntimeException('Unreachable code reached');
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'AND'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"$",
"dependency",
"->",
"isValid",
"(",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'OR'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"$",
"dependency",
"->",
"isValid",
"(",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'Unreachable code reached'",
")",
";",
"}"
] | Ob das zu ueberwachende Ereignis oder der Zustandswechsel eingetreten sind oder nicht.
@return bool - TRUE, wenn die Abhaengigkeit weiterhin erfuellt ist.
FALSE, wenn der Zustandswechsel eingetreten ist und die Abhaengigkeit nicht mehr erfuellt ist. | [
"Ob",
"das",
"zu",
"ueberwachende",
"Ereignis",
"oder",
"der",
"Zustandswechsel",
"eingetreten",
"sind",
"oder",
"nicht",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/monitor/ChainedDependency.php#L93-L111 |
28,973 | timble/kodekit | code/filesystem/locator/factory.php | FilesystemLocatorFactory.createLocator | public function createLocator($path, array $config = array())
{
$scheme = parse_url($path, PHP_URL_SCHEME);
//If no scheme is specified fall back to file:// locator
$name = !empty($scheme) ? $scheme : 'file';
//If a windows drive letter is passed use file:// locator
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
if(preg_match('#^[a-z]{1}$#i', $name)) {
$name = 'file';
}
}
//Locator not supported
if(!in_array($name, $this->getLocators()))
{
throw new \RuntimeException(sprintf(
'Unable to find the filesystem locator "%s" - did you forget to register it ?', $name
));
}
//Create the locator
$identifier = $this->getLocator($name);
$locator = $this->getObject($identifier, $config);
if(!$locator instanceof FilesystemLocatorInterface)
{
throw new \UnexpectedValueException(
'Locator: '.get_class($locator).' does not implement FilesystemLocatorInterface'
);
}
return $locator;
} | php | public function createLocator($path, array $config = array())
{
$scheme = parse_url($path, PHP_URL_SCHEME);
//If no scheme is specified fall back to file:// locator
$name = !empty($scheme) ? $scheme : 'file';
//If a windows drive letter is passed use file:// locator
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
if(preg_match('#^[a-z]{1}$#i', $name)) {
$name = 'file';
}
}
//Locator not supported
if(!in_array($name, $this->getLocators()))
{
throw new \RuntimeException(sprintf(
'Unable to find the filesystem locator "%s" - did you forget to register it ?', $name
));
}
//Create the locator
$identifier = $this->getLocator($name);
$locator = $this->getObject($identifier, $config);
if(!$locator instanceof FilesystemLocatorInterface)
{
throw new \UnexpectedValueException(
'Locator: '.get_class($locator).' does not implement FilesystemLocatorInterface'
);
}
return $locator;
} | [
"public",
"function",
"createLocator",
"(",
"$",
"path",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"scheme",
"=",
"parse_url",
"(",
"$",
"path",
",",
"PHP_URL_SCHEME",
")",
";",
"//If no scheme is specified fall back to file:// locator",
"$",
"name",
"=",
"!",
"empty",
"(",
"$",
"scheme",
")",
"?",
"$",
"scheme",
":",
"'file'",
";",
"//If a windows drive letter is passed use file:// locator",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"===",
"'WIN'",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^[a-z]{1}$#i'",
",",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"'file'",
";",
"}",
"}",
"//Locator not supported",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getLocators",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to find the filesystem locator \"%s\" - did you forget to register it ?'",
",",
"$",
"name",
")",
")",
";",
"}",
"//Create the locator",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getLocator",
"(",
"$",
"name",
")",
";",
"$",
"locator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"identifier",
",",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"locator",
"instanceof",
"FilesystemLocatorInterface",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Locator: '",
".",
"get_class",
"(",
"$",
"locator",
")",
".",
"' does not implement FilesystemLocatorInterface'",
")",
";",
"}",
"return",
"$",
"locator",
";",
"}"
] | Create a locator
Note that only URLs delimited by "://"" and ":" are supported, ":/" while technically valid URLs, are not.
If no locator is registered for the specific scheme a exception will be thrown.
@param string $path The locator path
@param array $config An optional associative array of configuration options
@throws \InvalidArgumentException If the path is not valid
@throws \RuntimeException If the locator isn't registered
@throws \UnexpectedValueException If the locator object doesn't implement the FilesystemLocatorInterface
@return FilesystemLocatorInterface | [
"Create",
"a",
"locator"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/factory.php#L74-L109 |
28,974 | timble/kodekit | code/object/abstract.php | ObjectAbstract.inherits | public function inherits($class)
{
if ($this instanceof $class) {
return true;
}
$objects = array_values($this->__mixed_methods);
foreach($objects as $object)
{
if($object instanceof $class) {
return true;
}
}
return false;
} | php | public function inherits($class)
{
if ($this instanceof $class) {
return true;
}
$objects = array_values($this->__mixed_methods);
foreach($objects as $object)
{
if($object instanceof $class) {
return true;
}
}
return false;
} | [
"public",
"function",
"inherits",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"instanceof",
"$",
"class",
")",
"{",
"return",
"true",
";",
"}",
"$",
"objects",
"=",
"array_values",
"(",
"$",
"this",
"->",
"__mixed_methods",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"$",
"class",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if the object or one of its mixins inherits from a class.
@param string|object The class to check
@return boolean Returns TRUE if the object inherits from the class | [
"Checks",
"if",
"the",
"object",
"or",
"one",
"of",
"its",
"mixins",
"inherits",
"from",
"a",
"class",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/abstract.php#L234-L250 |
28,975 | timble/kodekit | code/controller/toolbar/iterator/recursive.php | ControllerToolbarIteratorRecursive._createInnerIterator | protected static function _createInnerIterator(ControllerToolbarInterface $toolbar)
{
$iterator = new \RecursiveArrayIterator($toolbar->getIterator());
$iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY);
return $iterator;
} | php | protected static function _createInnerIterator(ControllerToolbarInterface $toolbar)
{
$iterator = new \RecursiveArrayIterator($toolbar->getIterator());
$iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY);
return $iterator;
} | [
"protected",
"static",
"function",
"_createInnerIterator",
"(",
"ControllerToolbarInterface",
"$",
"toolbar",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveArrayIterator",
"(",
"$",
"toolbar",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveCachingIterator",
"(",
"$",
"iterator",
",",
"\\",
"CachingIterator",
"::",
"TOSTRING_USE_KEY",
")",
";",
"return",
"$",
"iterator",
";",
"}"
] | Create a recursive iterator from a toolbar
@param ControllerToolbarInterface $toolbar
@return \RecursiveIterator | [
"Create",
"a",
"recursive",
"iterator",
"from",
"a",
"toolbar"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/toolbar/iterator/recursive.php#L86-L92 |
28,976 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.getImplementation | final public static function getImplementation($class) {
if (!is_a($class, __CLASS__, $allowString=true)) {
if (!is_class($class)) throw new ClassNotFoundException('Class not found: '.$class );
throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class);
}
/** @var self $dao */
$dao = self::getInstance($class);
return $dao;
} | php | final public static function getImplementation($class) {
if (!is_a($class, __CLASS__, $allowString=true)) {
if (!is_class($class)) throw new ClassNotFoundException('Class not found: '.$class );
throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class);
}
/** @var self $dao */
$dao = self::getInstance($class);
return $dao;
} | [
"final",
"public",
"static",
"function",
"getImplementation",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"class",
",",
"__CLASS__",
",",
"$",
"allowString",
"=",
"true",
")",
")",
"{",
"if",
"(",
"!",
"is_class",
"(",
"$",
"class",
")",
")",
"throw",
"new",
"ClassNotFoundException",
"(",
"'Class not found: '",
".",
"$",
"class",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Not a '",
".",
"__CLASS__",
".",
"' subclass: '",
".",
"$",
"class",
")",
";",
"}",
"/** @var self $dao */",
"$",
"dao",
"=",
"self",
"::",
"getInstance",
"(",
"$",
"class",
")",
";",
"return",
"$",
"dao",
";",
"}"
] | Get the specified DAO implementation.
@param string $class - DAO class name
@return self | [
"Get",
"the",
"specified",
"DAO",
"implementation",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L44-L52 |
28,977 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.findAll | public function findAll($query = null) {
if ($query === null) {
$mapping = $this->getMapping();
$table = $this->escapeIdentifier($mapping['table']);
$query = 'select * from '.$table;
}
return $this->getWorker()->findAll($query);
} | php | public function findAll($query = null) {
if ($query === null) {
$mapping = $this->getMapping();
$table = $this->escapeIdentifier($mapping['table']);
$query = 'select * from '.$table;
}
return $this->getWorker()->findAll($query);
} | [
"public",
"function",
"findAll",
"(",
"$",
"query",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"query",
"===",
"null",
")",
"{",
"$",
"mapping",
"=",
"$",
"this",
"->",
"getMapping",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"mapping",
"[",
"'table'",
"]",
")",
";",
"$",
"query",
"=",
"'select * from '",
".",
"$",
"table",
";",
"}",
"return",
"$",
"this",
"->",
"getWorker",
"(",
")",
"->",
"findAll",
"(",
"$",
"query",
")",
";",
"}"
] | Find all matching records and convert them to instances of the entity class.
@param string $query [optional] - SQL query with optional ORM syntax; without a query all instances are returned
@return PersistableObject[] | [
"Find",
"all",
"matching",
"records",
"and",
"convert",
"them",
"to",
"instances",
"of",
"the",
"entity",
"class",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L88-L95 |
28,978 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.get | public function get($query, $allowMany = false) {
$result = $this->find($query, $allowMany);
if (!$result)
throw new NoSuchRecordException($query);
return $result;
} | php | public function get($query, $allowMany = false) {
$result = $this->find($query, $allowMany);
if (!$result)
throw new NoSuchRecordException($query);
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"query",
",",
"$",
"allowMany",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"query",
",",
"$",
"allowMany",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"throw",
"new",
"NoSuchRecordException",
"(",
"$",
"query",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Get a single matching record and convert it to an instance of the entity class.
@param string $query - SQL query with optional ORM syntax
@param bool $allowMany [optional] - whether the query is allowed to return a multi-row result (default: no)
@return PersistableObject
@throws NoSuchRecordException if the query returned no rows
@throws MultipleRecordsException if the query returned multiple rows and $allowMany was not set to TRUE | [
"Get",
"a",
"single",
"matching",
"record",
"and",
"convert",
"it",
"to",
"an",
"instance",
"of",
"the",
"entity",
"class",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L109-L114 |
28,979 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.transaction | public function transaction(\Closure $task) {
try {
$this->db()->begin();
$result = $task();
$this->db()->commit();
return $result;
}
catch (\Exception $ex) {
$this->db()->rollback();
throw $ex;
}
} | php | public function transaction(\Closure $task) {
try {
$this->db()->begin();
$result = $task();
$this->db()->commit();
return $result;
}
catch (\Exception $ex) {
$this->db()->rollback();
throw $ex;
}
} | [
"public",
"function",
"transaction",
"(",
"\\",
"Closure",
"$",
"task",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"begin",
"(",
")",
";",
"$",
"result",
"=",
"$",
"task",
"(",
")",
";",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"ex",
";",
"}",
"}"
] | Execute a task in a transactional way. The transaction is automatically committed or rolled back.
A nested transaction is executed in the context of the nesting transaction.
@param \Closure $task - task to execute (an anonymous function is implicitly casted)
@return mixed - the task's return value (if any) | [
"Execute",
"a",
"task",
"in",
"a",
"transactional",
"way",
".",
"The",
"transaction",
"is",
"automatically",
"committed",
"or",
"rolled",
"back",
".",
"A",
"nested",
"transaction",
"is",
"executed",
"in",
"the",
"context",
"of",
"the",
"nesting",
"transaction",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L168-L179 |
28,980 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.getEntityMapping | public function getEntityMapping() {
if (!$this->entityMapping) {
$this->entityMapping = new EntityMapping($this->getMapping());
}
return $this->entityMapping;
} | php | public function getEntityMapping() {
if (!$this->entityMapping) {
$this->entityMapping = new EntityMapping($this->getMapping());
}
return $this->entityMapping;
} | [
"public",
"function",
"getEntityMapping",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entityMapping",
")",
"{",
"$",
"this",
"->",
"entityMapping",
"=",
"new",
"EntityMapping",
"(",
"$",
"this",
"->",
"getMapping",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"entityMapping",
";",
"}"
] | Return the object-oriented data mapping of the DAO's entity.
@return EntityMapping | [
"Return",
"the",
"object",
"-",
"oriented",
"data",
"mapping",
"of",
"the",
"DAO",
"s",
"entity",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L286-L291 |
28,981 | rosasurfer/ministruts | src/db/orm/DAO.php | DAO.db | final public function db() {
if (!$this->connector) {
$this->connector = $this->getWorker()->getConnector();
}
return $this->connector;
} | php | final public function db() {
if (!$this->connector) {
$this->connector = $this->getWorker()->getConnector();
}
return $this->connector;
} | [
"final",
"public",
"function",
"db",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connector",
")",
"{",
"$",
"this",
"->",
"connector",
"=",
"$",
"this",
"->",
"getWorker",
"(",
")",
"->",
"getConnector",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connector",
";",
"}"
] | Return the database adapter used for the DAO's entity.
@return IConnector | [
"Return",
"the",
"database",
"adapter",
"used",
"for",
"the",
"DAO",
"s",
"entity",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L309-L314 |
28,982 | hakito/PHP-Stuzza-EPS-BankTransfer | src/TransferInitiatorDetails.php | TransferInitiatorDetails.SetExpirationMinutes | public function SetExpirationMinutes($minutes)
{
if ($minutes < 5 || $minutes > 60)
throw new \InvalidArgumentException('Expiration minutes value of "' . $minutes . '" is not between 5 and 60.');
$expires = new \DateTime();
$expires->add(new \DateInterval('PT' . $minutes . 'M'));
$this->ExpirationTime = $expires->format(DATE_RFC3339);
} | php | public function SetExpirationMinutes($minutes)
{
if ($minutes < 5 || $minutes > 60)
throw new \InvalidArgumentException('Expiration minutes value of "' . $minutes . '" is not between 5 and 60.');
$expires = new \DateTime();
$expires->add(new \DateInterval('PT' . $minutes . 'M'));
$this->ExpirationTime = $expires->format(DATE_RFC3339);
} | [
"public",
"function",
"SetExpirationMinutes",
"(",
"$",
"minutes",
")",
"{",
"if",
"(",
"$",
"minutes",
"<",
"5",
"||",
"$",
"minutes",
">",
"60",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expiration minutes value of \"'",
".",
"$",
"minutes",
".",
"'\" is not between 5 and 60.'",
")",
";",
"$",
"expires",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"expires",
"->",
"add",
"(",
"new",
"\\",
"DateInterval",
"(",
"'PT'",
".",
"$",
"minutes",
".",
"'M'",
")",
")",
";",
"$",
"this",
"->",
"ExpirationTime",
"=",
"$",
"expires",
"->",
"format",
"(",
"DATE_RFC3339",
")",
";",
"}"
] | Sets ExpirationTime by adding given amount of minutes to the current
timestamp.
@param int $minutes Must be between 5 and 60
@throws \InvalidArgumentException if minutes not between 5 and 60 | [
"Sets",
"ExpirationTime",
"by",
"adding",
"given",
"amount",
"of",
"minutes",
"to",
"the",
"current",
"timestamp",
"."
] | c2af496ecf4b9f095447a7b9f5c02d20924252bd | https://github.com/hakito/PHP-Stuzza-EPS-BankTransfer/blob/c2af496ecf4b9f095447a7b9f5c02d20924252bd/src/TransferInitiatorDetails.php#L135-L143 |
28,983 | timble/kodekit | code/dispatcher/behavior/decoratable.php | DispatcherBehaviorDecoratable.addDecorator | public function addDecorator($identifier, $prepend = false)
{
if($prepend) {
array_unshift($this->__decorators, $identifier);
} else {
array_push($this->__decorators, $identifier);
}
return $this;
} | php | public function addDecorator($identifier, $prepend = false)
{
if($prepend) {
array_unshift($this->__decorators, $identifier);
} else {
array_push($this->__decorators, $identifier);
}
return $this;
} | [
"public",
"function",
"addDecorator",
"(",
"$",
"identifier",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"__decorators",
",",
"$",
"identifier",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"__decorators",
",",
"$",
"identifier",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a decorator
@param string $identifier The decorator identifier
@param bool $prepend If true, the decorator will be prepended instead of appended.
@return DispatcherBehaviorDecoratable | [
"Add",
"a",
"decorator"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/decoratable.php#L89-L98 |
28,984 | timble/kodekit | code/dispatcher/behavior/decoratable.php | DispatcherBehaviorDecoratable._beforeSend | protected function _beforeSend(DispatcherContext $context)
{
$response = $context->getResponse();
if(!$response->isDownloadable())
{
foreach ($this->getDecorators() as $decorator)
{
//Get the decorator
$config = array('response' => array('content' => $response->getContent()));
$controller = $this->getObject($decorator, $config);
if(!$controller instanceof ControllerViewable)
{
throw new \UnexpectedValueException(
'Decorator '.get_class($controller).' does not implement ControllerViewable'
);
}
//Set the view
$parameters = array(
'language' => $this->getLanguage(),
);
if($response->isError()) {
$parameters['status'] = $response->getStatusCode();
} else {
$parameters['component'] = $this->getController()->getIdentifier()->package;
}
$controller->getView()
->setParameters($parameters)
->getTemplate()->addFilter('decorator');
//Set the response
$response->setContent($controller->render());
}
}
} | php | protected function _beforeSend(DispatcherContext $context)
{
$response = $context->getResponse();
if(!$response->isDownloadable())
{
foreach ($this->getDecorators() as $decorator)
{
//Get the decorator
$config = array('response' => array('content' => $response->getContent()));
$controller = $this->getObject($decorator, $config);
if(!$controller instanceof ControllerViewable)
{
throw new \UnexpectedValueException(
'Decorator '.get_class($controller).' does not implement ControllerViewable'
);
}
//Set the view
$parameters = array(
'language' => $this->getLanguage(),
);
if($response->isError()) {
$parameters['status'] = $response->getStatusCode();
} else {
$parameters['component'] = $this->getController()->getIdentifier()->package;
}
$controller->getView()
->setParameters($parameters)
->getTemplate()->addFilter('decorator');
//Set the response
$response->setContent($controller->render());
}
}
} | [
"protected",
"function",
"_beforeSend",
"(",
"DispatcherContext",
"$",
"context",
")",
"{",
"$",
"response",
"=",
"$",
"context",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"!",
"$",
"response",
"->",
"isDownloadable",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDecorators",
"(",
")",
"as",
"$",
"decorator",
")",
"{",
"//Get the decorator",
"$",
"config",
"=",
"array",
"(",
"'response'",
"=>",
"array",
"(",
"'content'",
"=>",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"decorator",
",",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"controller",
"instanceof",
"ControllerViewable",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Decorator '",
".",
"get_class",
"(",
"$",
"controller",
")",
".",
"' does not implement ControllerViewable'",
")",
";",
"}",
"//Set the view",
"$",
"parameters",
"=",
"array",
"(",
"'language'",
"=>",
"$",
"this",
"->",
"getLanguage",
"(",
")",
",",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'status'",
"]",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"}",
"else",
"{",
"$",
"parameters",
"[",
"'component'",
"]",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"package",
";",
"}",
"$",
"controller",
"->",
"getView",
"(",
")",
"->",
"setParameters",
"(",
"$",
"parameters",
")",
"->",
"getTemplate",
"(",
")",
"->",
"addFilter",
"(",
"'decorator'",
")",
";",
"//Set the response",
"$",
"response",
"->",
"setContent",
"(",
"$",
"controller",
"->",
"render",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Render the decorators
This method will also add the 'decorator' filter to the view and add following default parameters
- component: The name of the component being dispatched
- language: The language of the response
- status: The status code of the response
@param DispatcherContext $context The active command context
@return void | [
"Render",
"the",
"decorators"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/decoratable.php#L122-L160 |
28,985 | timble/kodekit | code/filesystem/locator/component.php | FilesystemLocatorComponent.getPathTemplates | public function getPathTemplates($url)
{
$templates = parent::getPathTemplates($url);
foreach($templates as $key => $template)
{
//Qualify relative path
if(substr($template, 0, 1) !== '/')
{
$bootstrapper = $this->getObject('object.bootstrapper');
unset($templates[$key]);
$info = $this->parseUrl($url);
$paths = $bootstrapper->getComponentPaths($info['package'], $info['domain']);
$inserts = array();
foreach ($paths as $path) {
$inserts[] = $path . '/'. $template;
}
//Insert the paths at the right position in the array
array_splice( $templates, $key, 0, $inserts);
}
}
return $templates;
} | php | public function getPathTemplates($url)
{
$templates = parent::getPathTemplates($url);
foreach($templates as $key => $template)
{
//Qualify relative path
if(substr($template, 0, 1) !== '/')
{
$bootstrapper = $this->getObject('object.bootstrapper');
unset($templates[$key]);
$info = $this->parseUrl($url);
$paths = $bootstrapper->getComponentPaths($info['package'], $info['domain']);
$inserts = array();
foreach ($paths as $path) {
$inserts[] = $path . '/'. $template;
}
//Insert the paths at the right position in the array
array_splice( $templates, $key, 0, $inserts);
}
}
return $templates;
} | [
"public",
"function",
"getPathTemplates",
"(",
"$",
"url",
")",
"{",
"$",
"templates",
"=",
"parent",
"::",
"getPathTemplates",
"(",
"$",
"url",
")",
";",
"foreach",
"(",
"$",
"templates",
"as",
"$",
"key",
"=>",
"$",
"template",
")",
"{",
"//Qualify relative path",
"if",
"(",
"substr",
"(",
"$",
"template",
",",
"0",
",",
"1",
")",
"!==",
"'/'",
")",
"{",
"$",
"bootstrapper",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'object.bootstrapper'",
")",
";",
"unset",
"(",
"$",
"templates",
"[",
"$",
"key",
"]",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"url",
")",
";",
"$",
"paths",
"=",
"$",
"bootstrapper",
"->",
"getComponentPaths",
"(",
"$",
"info",
"[",
"'package'",
"]",
",",
"$",
"info",
"[",
"'domain'",
"]",
")",
";",
"$",
"inserts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"inserts",
"[",
"]",
"=",
"$",
"path",
".",
"'/'",
".",
"$",
"template",
";",
"}",
"//Insert the paths at the right position in the array",
"array_splice",
"(",
"$",
"templates",
",",
"$",
"key",
",",
"0",
",",
"$",
"inserts",
")",
";",
"}",
"}",
"return",
"$",
"templates",
";",
"}"
] | Get the list of path templates
This method will qualify relative url's (url not starting with '/') by prepending the component base
path to the url. If the component has additional paths a template path for each will be inserted in
FIFO order.
@param string $url The language url
@return array The path templates | [
"Get",
"the",
"list",
"of",
"path",
"templates"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/component.php#L74-L101 |
28,986 | rosasurfer/ministruts | src/monitor/Dependency.php | Dependency.setMinValidity | public function setMinValidity($time) {
if (!is_int($time)) throw new IllegalTypeException('Illegal type of parameter $time: '.gettype($time));
if ($time < 0) throw new InvalidArgumentException('Invalid argument $time: '.$time);
$this->minValidity = $time;
return $this;
} | php | public function setMinValidity($time) {
if (!is_int($time)) throw new IllegalTypeException('Illegal type of parameter $time: '.gettype($time));
if ($time < 0) throw new InvalidArgumentException('Invalid argument $time: '.$time);
$this->minValidity = $time;
return $this;
} | [
"public",
"function",
"setMinValidity",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"time",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $time: '",
".",
"gettype",
"(",
"$",
"time",
")",
")",
";",
"if",
"(",
"$",
"time",
"<",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $time: '",
".",
"$",
"time",
")",
";",
"$",
"this",
"->",
"minValidity",
"=",
"$",
"time",
";",
"return",
"$",
"this",
";",
"}"
] | Setzt die Mindestgueltigkeit dieser Abhaengigkeit.
@param int $time - Mindestgueltigkeit in Sekunden
@return Dependency | [
"Setzt",
"die",
"Mindestgueltigkeit",
"dieser",
"Abhaengigkeit",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/monitor/Dependency.php#L103-L110 |
28,987 | timble/kodekit | code/command/callback/abstract.php | CommandCallbackAbstract.removeCommandCallback | public function removeCommandCallback($command, $method)
{
$command = strtolower($command);
if (isset($this->__command_callbacks[$command]) )
{
if($method instanceof \Closure) {
$index = spl_object_hash($method);
} else {
$index = $method;
}
unset($this->__command_callbacks[$command][$index]);
}
return $this;
} | php | public function removeCommandCallback($command, $method)
{
$command = strtolower($command);
if (isset($this->__command_callbacks[$command]) )
{
if($method instanceof \Closure) {
$index = spl_object_hash($method);
} else {
$index = $method;
}
unset($this->__command_callbacks[$command][$index]);
}
return $this;
} | [
"public",
"function",
"removeCommandCallback",
"(",
"$",
"command",
",",
"$",
"method",
")",
"{",
"$",
"command",
"=",
"strtolower",
"(",
"$",
"command",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__command_callbacks",
"[",
"$",
"command",
"]",
")",
")",
"{",
"if",
"(",
"$",
"method",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"index",
"=",
"spl_object_hash",
"(",
"$",
"method",
")",
";",
"}",
"else",
"{",
"$",
"index",
"=",
"$",
"method",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"__command_callbacks",
"[",
"$",
"command",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove a callback
@param string $command The command to unregister the handler from
@param string|\Closure $method The name of the method or a Closure object to unregister
@return CommandCallbackAbstract | [
"Remove",
"a",
"callback"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/callback/abstract.php#L167-L183 |
28,988 | locomotivemtl/charcoal-core | src/Charcoal/Model/DescribableTrait.php | DescribableTrait.loadMetadata | public function loadMetadata($metadataIdent = null)
{
if ($metadataIdent === null) {
$metadataIdent = $this->metadataIdent();
}
$metadata = $this->metadataLoader()->load($metadataIdent, $this->metadataClass());
$this->setMetadata($metadata);
return $metadata;
} | php | public function loadMetadata($metadataIdent = null)
{
if ($metadataIdent === null) {
$metadataIdent = $this->metadataIdent();
}
$metadata = $this->metadataLoader()->load($metadataIdent, $this->metadataClass());
$this->setMetadata($metadata);
return $metadata;
} | [
"public",
"function",
"loadMetadata",
"(",
"$",
"metadataIdent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"metadataIdent",
"===",
"null",
")",
"{",
"$",
"metadataIdent",
"=",
"$",
"this",
"->",
"metadataIdent",
"(",
")",
";",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"metadataLoader",
"(",
")",
"->",
"load",
"(",
"$",
"metadataIdent",
",",
"$",
"this",
"->",
"metadataClass",
"(",
")",
")",
";",
"$",
"this",
"->",
"setMetadata",
"(",
"$",
"metadata",
")",
";",
"return",
"$",
"metadata",
";",
"}"
] | Load a metadata file and store it as a static var.
Use a `MetadataLoader` object and the object's metadataIdent
to load the metadata content (typically from the filesystem, as json).
@param string $metadataIdent Optional ident. If none is provided then it will use the auto-genereated one.
@return MetadataInterface | [
"Load",
"a",
"metadata",
"file",
"and",
"store",
"it",
"as",
"a",
"static",
"var",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/DescribableTrait.php#L85-L95 |
28,989 | locomotivemtl/charcoal-core | src/Charcoal/Model/DescribableTrait.php | DescribableTrait.metadataIdent | public function metadataIdent()
{
if ($this->metadataIdent === null) {
$this->metadataIdent = $this->generateMetadataIdent();
}
return $this->metadataIdent;
} | php | public function metadataIdent()
{
if ($this->metadataIdent === null) {
$this->metadataIdent = $this->generateMetadataIdent();
}
return $this->metadataIdent;
} | [
"public",
"function",
"metadataIdent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"metadataIdent",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"metadataIdent",
"=",
"$",
"this",
"->",
"generateMetadataIdent",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"metadataIdent",
";",
"}"
] | Get the metadata ident, or generate it from class name if it was not set explicitly.
@return string | [
"Get",
"the",
"metadata",
"ident",
"or",
"generate",
"it",
"from",
"class",
"name",
"if",
"it",
"was",
"not",
"set",
"explicitly",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/DescribableTrait.php#L112-L118 |
28,990 | rosasurfer/ministruts | src/net/NetTools.php | NetTools.getHostByAddress | public static function getHostByAddress($ipAddress) {
if (!is_string($ipAddress)) throw new IllegalTypeException('Illegal type of parameter $ipAddress: '.gettype($ipAddress));
if ($ipAddress == '') throw new InvalidArgumentException('Invalid argument $ipAddress: "'.$ipAddress.'"');
$result = gethostbyaddr($ipAddress);
if ($result==='localhost' && !strStartsWith($ipAddress, '127.'))
$result = $ipAddress;
return $result;
} | php | public static function getHostByAddress($ipAddress) {
if (!is_string($ipAddress)) throw new IllegalTypeException('Illegal type of parameter $ipAddress: '.gettype($ipAddress));
if ($ipAddress == '') throw new InvalidArgumentException('Invalid argument $ipAddress: "'.$ipAddress.'"');
$result = gethostbyaddr($ipAddress);
if ($result==='localhost' && !strStartsWith($ipAddress, '127.'))
$result = $ipAddress;
return $result;
} | [
"public",
"static",
"function",
"getHostByAddress",
"(",
"$",
"ipAddress",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"ipAddress",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $ipAddress: '",
".",
"gettype",
"(",
"$",
"ipAddress",
")",
")",
";",
"if",
"(",
"$",
"ipAddress",
"==",
"''",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $ipAddress: \"'",
".",
"$",
"ipAddress",
".",
"'\"'",
")",
";",
"$",
"result",
"=",
"gethostbyaddr",
"(",
"$",
"ipAddress",
")",
";",
"if",
"(",
"$",
"result",
"===",
"'localhost'",
"&&",
"!",
"strStartsWith",
"(",
"$",
"ipAddress",
",",
"'127.'",
")",
")",
"$",
"result",
"=",
"$",
"ipAddress",
";",
"return",
"$",
"result",
";",
"}"
] | Return the host name of the Internet host specified by a given IP address. Additionally checks the result returned
by the built-in PHP function for plausibility.
@param string $ipAddress - the host IP address
@return string|bool - the host name on success, the unmodified IP address on failure, or FALSE on malformed input | [
"Return",
"the",
"host",
"name",
"of",
"the",
"Internet",
"host",
"specified",
"by",
"a",
"given",
"IP",
"address",
".",
"Additionally",
"checks",
"the",
"result",
"returned",
"by",
"the",
"built",
"-",
"in",
"PHP",
"function",
"for",
"plausibility",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/NetTools.php#L27-L37 |
28,991 | rosasurfer/ministruts | src/net/NetTools.php | NetTools.getHostByName | public static function getHostByName($name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if ($name == '') throw new InvalidArgumentException('Invalid argument $name: "'.$name.'"');
return \gethostbyname($name);
} | php | public static function getHostByName($name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if ($name == '') throw new InvalidArgumentException('Invalid argument $name: "'.$name.'"');
return \gethostbyname($name);
} | [
"public",
"static",
"function",
"getHostByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"$",
"name",
"==",
"''",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $name: \"'",
".",
"$",
"name",
".",
"'\"'",
")",
";",
"return",
"\\",
"gethostbyname",
"(",
"$",
"name",
")",
";",
"}"
] | Gibt die IP-Adresse eines Hostnamens zurueck.
@param string $name - Hostname
@return string - IP-Adresse oder der originale Hostname, wenn dieser nicht aufgeloest werden kann | [
"Gibt",
"die",
"IP",
"-",
"Adresse",
"eines",
"Hostnamens",
"zurueck",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/NetTools.php#L47-L52 |
28,992 | rosasurfer/ministruts | etc/phpstan/DynamicReturnType.php | DynamicReturnType.isMethodSupported | public function isMethodSupported(MethodReflection $methodReflection) : bool {
if (!static::$methodNames) throw new RuntimeException('The class property '.static::class.'::$methodNames must be defined.');
return in_array($methodReflection->getName(), static::$methodNames);
} | php | public function isMethodSupported(MethodReflection $methodReflection) : bool {
if (!static::$methodNames) throw new RuntimeException('The class property '.static::class.'::$methodNames must be defined.');
return in_array($methodReflection->getName(), static::$methodNames);
} | [
"public",
"function",
"isMethodSupported",
"(",
"MethodReflection",
"$",
"methodReflection",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"methodNames",
")",
"throw",
"new",
"RuntimeException",
"(",
"'The class property '",
".",
"static",
"::",
"class",
".",
"'::$methodNames must be defined.'",
")",
";",
"return",
"in_array",
"(",
"$",
"methodReflection",
"->",
"getName",
"(",
")",
",",
"static",
"::",
"$",
"methodNames",
")",
";",
"}"
] | Whether the named instance method returns dynamic types.
@return bool | [
"Whether",
"the",
"named",
"instance",
"method",
"returns",
"dynamic",
"types",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L45-L48 |
28,993 | rosasurfer/ministruts | etc/phpstan/DynamicReturnType.php | DynamicReturnType.isStaticMethodSupported | public function isStaticMethodSupported(MethodReflection $methodReflection) : bool {
if (!static::$methodNames) throw new RuntimeException('The class constant '.static::class.'::$methodNames must be defined.');
return in_array($methodReflection->getName(), static::$methodNames);
} | php | public function isStaticMethodSupported(MethodReflection $methodReflection) : bool {
if (!static::$methodNames) throw new RuntimeException('The class constant '.static::class.'::$methodNames must be defined.');
return in_array($methodReflection->getName(), static::$methodNames);
} | [
"public",
"function",
"isStaticMethodSupported",
"(",
"MethodReflection",
"$",
"methodReflection",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"methodNames",
")",
"throw",
"new",
"RuntimeException",
"(",
"'The class constant '",
".",
"static",
"::",
"class",
".",
"'::$methodNames must be defined.'",
")",
";",
"return",
"in_array",
"(",
"$",
"methodReflection",
"->",
"getName",
"(",
")",
",",
"static",
"::",
"$",
"methodNames",
")",
";",
"}"
] | Whether the named static method returns dynamic types.
@return bool | [
"Whether",
"the",
"named",
"static",
"method",
"returns",
"dynamic",
"types",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L56-L59 |
28,994 | rosasurfer/ministruts | etc/phpstan/DynamicReturnType.php | DynamicReturnType.getScopeDescription | protected function getScopeDescription(Scope $scope) : string {
if ($scope->isInClass()) {
$description = $scope->getClassReflection()->getName();
if ($scope->getFunctionName()) $description .= '::'.$scope->getFunctionName().'()';
if ($scope->isInAnonymousFunction()) $description .= '{closure}';
return $description;
}
if ($scope->getFunctionName()) {
$description = $scope->getFunctionName().'()';
if ($scope->isInAnonymousFunction()) $description .= '{closure}';
return $description;
}
$description = $scope->isInAnonymousFunction() ? '{closure}' : '{main}';
$description = trim($scope->getNamespace().'\\'.$description, '\\');
return $description;
} | php | protected function getScopeDescription(Scope $scope) : string {
if ($scope->isInClass()) {
$description = $scope->getClassReflection()->getName();
if ($scope->getFunctionName()) $description .= '::'.$scope->getFunctionName().'()';
if ($scope->isInAnonymousFunction()) $description .= '{closure}';
return $description;
}
if ($scope->getFunctionName()) {
$description = $scope->getFunctionName().'()';
if ($scope->isInAnonymousFunction()) $description .= '{closure}';
return $description;
}
$description = $scope->isInAnonymousFunction() ? '{closure}' : '{main}';
$description = trim($scope->getNamespace().'\\'.$description, '\\');
return $description;
} | [
"protected",
"function",
"getScopeDescription",
"(",
"Scope",
"$",
"scope",
")",
":",
"string",
"{",
"if",
"(",
"$",
"scope",
"->",
"isInClass",
"(",
")",
")",
"{",
"$",
"description",
"=",
"$",
"scope",
"->",
"getClassReflection",
"(",
")",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"scope",
"->",
"getFunctionName",
"(",
")",
")",
"$",
"description",
".=",
"'::'",
".",
"$",
"scope",
"->",
"getFunctionName",
"(",
")",
".",
"'()'",
";",
"if",
"(",
"$",
"scope",
"->",
"isInAnonymousFunction",
"(",
")",
")",
"$",
"description",
".=",
"'{closure}'",
";",
"return",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"scope",
"->",
"getFunctionName",
"(",
")",
")",
"{",
"$",
"description",
"=",
"$",
"scope",
"->",
"getFunctionName",
"(",
")",
".",
"'()'",
";",
"if",
"(",
"$",
"scope",
"->",
"isInAnonymousFunction",
"(",
")",
")",
"$",
"description",
".=",
"'{closure}'",
";",
"return",
"$",
"description",
";",
"}",
"$",
"description",
"=",
"$",
"scope",
"->",
"isInAnonymousFunction",
"(",
")",
"?",
"'{closure}'",
":",
"'{main}'",
";",
"$",
"description",
"=",
"trim",
"(",
"$",
"scope",
"->",
"getNamespace",
"(",
")",
".",
"'\\\\'",
".",
"$",
"description",
",",
"'\\\\'",
")",
";",
"return",
"$",
"description",
";",
"}"
] | Return a description of the passed scope.
@param Scope $scope
@return string - scope description | [
"Return",
"a",
"description",
"of",
"the",
"passed",
"scope",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L69-L86 |
28,995 | rosasurfer/ministruts | src/ministruts/FrontController.php | FrontController.me | public static function me() {
if (CLI) throw new IllegalStateException('Can not use '.static::class.' in this context.');
$cache = Cache::me();
// cache hit?
$controller = $cache->get(static::class);
if (!$controller) {
// synchronize parsing of the struts-config.xml // TODO: Don't lock on the config file because it can block
// $lock = new FileLock($configFile); // concurrent reads, see Todo-File at locking.
// //
// $controller = $cache->get($class); // re-check after the lock is aquired
if (!$controller) {
$controller = self::getInstance(static::class);
$configDir = self::di('config')['app.dir.config'];
$configFile = str_replace('\\', '/', $configDir.'/struts-config.xml');
$dependency = FileDependency::create($configFile);
if (!WINDOWS && !LOCALHOST) // distinction dev/production? TODO: non-sense
$dependency->setMinValidity(1 * MINUTE);
// ...and cache it with a FileDependency
$cache->set(static::class, $controller, Cache::EXPIRES_NEVER, $dependency);
}
//$lock->release();
}
return $controller;
} | php | public static function me() {
if (CLI) throw new IllegalStateException('Can not use '.static::class.' in this context.');
$cache = Cache::me();
// cache hit?
$controller = $cache->get(static::class);
if (!$controller) {
// synchronize parsing of the struts-config.xml // TODO: Don't lock on the config file because it can block
// $lock = new FileLock($configFile); // concurrent reads, see Todo-File at locking.
// //
// $controller = $cache->get($class); // re-check after the lock is aquired
if (!$controller) {
$controller = self::getInstance(static::class);
$configDir = self::di('config')['app.dir.config'];
$configFile = str_replace('\\', '/', $configDir.'/struts-config.xml');
$dependency = FileDependency::create($configFile);
if (!WINDOWS && !LOCALHOST) // distinction dev/production? TODO: non-sense
$dependency->setMinValidity(1 * MINUTE);
// ...and cache it with a FileDependency
$cache->set(static::class, $controller, Cache::EXPIRES_NEVER, $dependency);
}
//$lock->release();
}
return $controller;
} | [
"public",
"static",
"function",
"me",
"(",
")",
"{",
"if",
"(",
"CLI",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Can not use '",
".",
"static",
"::",
"class",
".",
"' in this context.'",
")",
";",
"$",
"cache",
"=",
"Cache",
"::",
"me",
"(",
")",
";",
"// cache hit?",
"$",
"controller",
"=",
"$",
"cache",
"->",
"get",
"(",
"static",
"::",
"class",
")",
";",
"if",
"(",
"!",
"$",
"controller",
")",
"{",
"// synchronize parsing of the struts-config.xml // TODO: Don't lock on the config file because it can block",
"// $lock = new FileLock($configFile); // concurrent reads, see Todo-File at locking.",
"// //",
"// $controller = $cache->get($class); // re-check after the lock is aquired",
"if",
"(",
"!",
"$",
"controller",
")",
"{",
"$",
"controller",
"=",
"self",
"::",
"getInstance",
"(",
"static",
"::",
"class",
")",
";",
"$",
"configDir",
"=",
"self",
"::",
"di",
"(",
"'config'",
")",
"[",
"'app.dir.config'",
"]",
";",
"$",
"configFile",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"configDir",
".",
"'/struts-config.xml'",
")",
";",
"$",
"dependency",
"=",
"FileDependency",
"::",
"create",
"(",
"$",
"configFile",
")",
";",
"if",
"(",
"!",
"WINDOWS",
"&&",
"!",
"LOCALHOST",
")",
"// distinction dev/production? TODO: non-sense",
"$",
"dependency",
"->",
"setMinValidity",
"(",
"1",
"*",
"MINUTE",
")",
";",
"// ...and cache it with a FileDependency",
"$",
"cache",
"->",
"set",
"(",
"static",
"::",
"class",
",",
"$",
"controller",
",",
"Cache",
"::",
"EXPIRES_NEVER",
",",
"$",
"dependency",
")",
";",
"}",
"//$lock->release();",
"}",
"return",
"$",
"controller",
";",
"}"
] | Return the singleton instance of this class. The instance might be loaded from a cache.
@return static | [
"Return",
"the",
"singleton",
"instance",
"of",
"this",
"class",
".",
"The",
"instance",
"might",
"be",
"loaded",
"from",
"a",
"cache",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/FrontController.php#L41-L69 |
28,996 | rosasurfer/ministruts | src/ministruts/FrontController.php | FrontController.processRequest | public static function processRequest(array $options = []) {
$controller = self::me();
$request = Request::me();
$response = Response::me();
// select Module
$prefix = $controller->getModulePrefix($request);
$module = $controller->modules[$prefix];
$request->setAttribute(MODULE_KEY, $module);
// get RequestProcessor
$processor = $controller->getRequestProcessor($module, $options);
// process Request
$processor->process($request, $response);
return $response;
} | php | public static function processRequest(array $options = []) {
$controller = self::me();
$request = Request::me();
$response = Response::me();
// select Module
$prefix = $controller->getModulePrefix($request);
$module = $controller->modules[$prefix];
$request->setAttribute(MODULE_KEY, $module);
// get RequestProcessor
$processor = $controller->getRequestProcessor($module, $options);
// process Request
$processor->process($request, $response);
return $response;
} | [
"public",
"static",
"function",
"processRequest",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"controller",
"=",
"self",
"::",
"me",
"(",
")",
";",
"$",
"request",
"=",
"Request",
"::",
"me",
"(",
")",
";",
"$",
"response",
"=",
"Response",
"::",
"me",
"(",
")",
";",
"// select Module",
"$",
"prefix",
"=",
"$",
"controller",
"->",
"getModulePrefix",
"(",
"$",
"request",
")",
";",
"$",
"module",
"=",
"$",
"controller",
"->",
"modules",
"[",
"$",
"prefix",
"]",
";",
"$",
"request",
"->",
"setAttribute",
"(",
"MODULE_KEY",
",",
"$",
"module",
")",
";",
"// get RequestProcessor",
"$",
"processor",
"=",
"$",
"controller",
"->",
"getRequestProcessor",
"(",
"$",
"module",
",",
"$",
"options",
")",
";",
"// process Request",
"$",
"processor",
"->",
"process",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Process the current HTTP request.
@param array $options [optional] - runtime options (default: none)
@return Response - respone wrapper | [
"Process",
"the",
"current",
"HTTP",
"request",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/FrontController.php#L124-L141 |
28,997 | deArcane/framework | src/Debugger/Blueprints/File/File.php | File.offsetGet | public function offsetGet($i){
$j = $i - 1; // becouse we counting lines form 0 not 1.
if( !isIndex($this->lines,$j) ){
(new Report('Blueprints/File/CantFindLine'))->stop();
}
// Add mark and sort all marks.
$this->marks[] = $j;
sort($this->marks);
return $this->lines[$j];
} | php | public function offsetGet($i){
$j = $i - 1; // becouse we counting lines form 0 not 1.
if( !isIndex($this->lines,$j) ){
(new Report('Blueprints/File/CantFindLine'))->stop();
}
// Add mark and sort all marks.
$this->marks[] = $j;
sort($this->marks);
return $this->lines[$j];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"i",
")",
"{",
"$",
"j",
"=",
"$",
"i",
"-",
"1",
";",
"// becouse we counting lines form 0 not 1.",
"if",
"(",
"!",
"isIndex",
"(",
"$",
"this",
"->",
"lines",
",",
"$",
"j",
")",
")",
"{",
"(",
"new",
"Report",
"(",
"'Blueprints/File/CantFindLine'",
")",
")",
"->",
"stop",
"(",
")",
";",
"}",
"// Add mark and sort all marks.",
"$",
"this",
"->",
"marks",
"[",
"]",
"=",
"$",
"j",
";",
"sort",
"(",
"$",
"this",
"->",
"marks",
")",
";",
"return",
"$",
"this",
"->",
"lines",
"[",
"$",
"j",
"]",
";",
"}"
] | ArrayAccess interface. | [
"ArrayAccess",
"interface",
"."
] | 468da43678119f8c9e3f67183b5bec727c436404 | https://github.com/deArcane/framework/blob/468da43678119f8c9e3f67183b5bec727c436404/src/Debugger/Blueprints/File/File.php#L143-L152 |
28,998 | rosasurfer/ministruts | src/Application.php | Application.configurePhp | protected function configurePhp() {
$memoryWarnLimit = php_byte_value(self::$defaultConfig->get('log.warn.memory_limit', 0));
if ($memoryWarnLimit > 0) {
register_shutdown_function(function() use ($memoryWarnLimit) {
$usedBytes = memory_get_peak_usage($real=true);
if ($usedBytes > $memoryWarnLimit) {
Logger::log('Memory consumption exceeded '.prettyBytes($memoryWarnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]);
}
});
}
/*
ini_set('arg_separator.output' , '&' );
ini_set('auto_detect_line_endings', 1 );
ini_set('default_mimetype' , 'text/html' );
ini_set('default_charset' , 'UTF-8' );
ini_set('ignore_repeated_errors' , 0 );
ini_set('ignore_repeated_source' , 0 );
ini_set('ignore_user_abort' , 1 );
ini_set('display_errors' , (int)(CLI || LOCALHOST));
ini_set('display_startup_errors' , (int)(CLI || LOCALHOST));
ini_set('log_errors' , 1 );
ini_set('log_errors_max_len' , 0 );
ini_set('track_errors' , 1 );
ini_set('html_errors' , 0 );
ini_set('session.use_cookies' , 1 );
ini_set('session.use_trans_sid' , 0 );
ini_set('session.cookie_httponly' , 1 );
ini_set('session.referer_check' , '' );
ini_set('zend.detect_unicode' , 1 ); // BOM header recognition
*/
} | php | protected function configurePhp() {
$memoryWarnLimit = php_byte_value(self::$defaultConfig->get('log.warn.memory_limit', 0));
if ($memoryWarnLimit > 0) {
register_shutdown_function(function() use ($memoryWarnLimit) {
$usedBytes = memory_get_peak_usage($real=true);
if ($usedBytes > $memoryWarnLimit) {
Logger::log('Memory consumption exceeded '.prettyBytes($memoryWarnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]);
}
});
}
/*
ini_set('arg_separator.output' , '&' );
ini_set('auto_detect_line_endings', 1 );
ini_set('default_mimetype' , 'text/html' );
ini_set('default_charset' , 'UTF-8' );
ini_set('ignore_repeated_errors' , 0 );
ini_set('ignore_repeated_source' , 0 );
ini_set('ignore_user_abort' , 1 );
ini_set('display_errors' , (int)(CLI || LOCALHOST));
ini_set('display_startup_errors' , (int)(CLI || LOCALHOST));
ini_set('log_errors' , 1 );
ini_set('log_errors_max_len' , 0 );
ini_set('track_errors' , 1 );
ini_set('html_errors' , 0 );
ini_set('session.use_cookies' , 1 );
ini_set('session.use_trans_sid' , 0 );
ini_set('session.cookie_httponly' , 1 );
ini_set('session.referer_check' , '' );
ini_set('zend.detect_unicode' , 1 ); // BOM header recognition
*/
} | [
"protected",
"function",
"configurePhp",
"(",
")",
"{",
"$",
"memoryWarnLimit",
"=",
"php_byte_value",
"(",
"self",
"::",
"$",
"defaultConfig",
"->",
"get",
"(",
"'log.warn.memory_limit'",
",",
"0",
")",
")",
";",
"if",
"(",
"$",
"memoryWarnLimit",
">",
"0",
")",
"{",
"register_shutdown_function",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"memoryWarnLimit",
")",
"{",
"$",
"usedBytes",
"=",
"memory_get_peak_usage",
"(",
"$",
"real",
"=",
"true",
")",
";",
"if",
"(",
"$",
"usedBytes",
">",
"$",
"memoryWarnLimit",
")",
"{",
"Logger",
"::",
"log",
"(",
"'Memory consumption exceeded '",
".",
"prettyBytes",
"(",
"$",
"memoryWarnLimit",
")",
".",
"' (peak usage: '",
".",
"prettyBytes",
"(",
"$",
"usedBytes",
")",
".",
"')'",
",",
"L_WARN",
",",
"[",
"'class'",
"=>",
"__CLASS__",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"/*\n ini_set('arg_separator.output' , '&' );\n ini_set('auto_detect_line_endings', 1 );\n ini_set('default_mimetype' , 'text/html' );\n ini_set('default_charset' , 'UTF-8' );\n ini_set('ignore_repeated_errors' , 0 );\n ini_set('ignore_repeated_source' , 0 );\n ini_set('ignore_user_abort' , 1 );\n ini_set('display_errors' , (int)(CLI || LOCALHOST));\n ini_set('display_startup_errors' , (int)(CLI || LOCALHOST));\n ini_set('log_errors' , 1 );\n ini_set('log_errors_max_len' , 0 );\n ini_set('track_errors' , 1 );\n ini_set('html_errors' , 0 );\n ini_set('session.use_cookies' , 1 );\n ini_set('session.use_trans_sid' , 0 );\n ini_set('session.cookie_httponly' , 1 );\n ini_set('session.referer_check' , '' );\n ini_set('zend.detect_unicode' , 1 ); // BOM header recognition\n */",
"}"
] | Update the PHP configuration with user defined settings. | [
"Update",
"the",
"PHP",
"configuration",
"with",
"user",
"defined",
"settings",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L216-L246 |
28,999 | rosasurfer/ministruts | src/Application.php | Application.setupErrorHandling | protected function setupErrorHandling($value) {
$mode = ErrorHandler::THROW_EXCEPTIONS; // default
if (is_string($value)) {
$value = strtolower($value);
if ($value == 'weak' ) $mode = ErrorHandler::LOG_ERRORS;
else if ($value == 'ignore') $mode = 0;
}
$mode && ErrorHandler::setupErrorHandling($mode);
} | php | protected function setupErrorHandling($value) {
$mode = ErrorHandler::THROW_EXCEPTIONS; // default
if (is_string($value)) {
$value = strtolower($value);
if ($value == 'weak' ) $mode = ErrorHandler::LOG_ERRORS;
else if ($value == 'ignore') $mode = 0;
}
$mode && ErrorHandler::setupErrorHandling($mode);
} | [
"protected",
"function",
"setupErrorHandling",
"(",
"$",
"value",
")",
"{",
"$",
"mode",
"=",
"ErrorHandler",
"::",
"THROW_EXCEPTIONS",
";",
"// default",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"==",
"'weak'",
")",
"$",
"mode",
"=",
"ErrorHandler",
"::",
"LOG_ERRORS",
";",
"else",
"if",
"(",
"$",
"value",
"==",
"'ignore'",
")",
"$",
"mode",
"=",
"0",
";",
"}",
"$",
"mode",
"&&",
"ErrorHandler",
"::",
"setupErrorHandling",
"(",
"$",
"mode",
")",
";",
"}"
] | Setup the application's error handling.
@param string $value - configuration value as passed to the framework loader | [
"Setup",
"the",
"application",
"s",
"error",
"handling",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L331-L340 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.