repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_physcial_fone_fax | protected function create_physcial_fone_fax($addr_node, $number, $fone_fax='telephoneNumber')
{
$c = $this->addChild($addr_node, 'physical');
$c = $this->addChild($c, 'addressPart', $number);
$c->setAttribute('type', $fone_fax);
} | php | protected function create_physcial_fone_fax($addr_node, $number, $fone_fax='telephoneNumber')
{
$c = $this->addChild($addr_node, 'physical');
$c = $this->addChild($c, 'addressPart', $number);
$c->setAttribute('type', $fone_fax);
} | [
"protected",
"function",
"create_physcial_fone_fax",
"(",
"$",
"addr_node",
",",
"$",
"number",
",",
"$",
"fone_fax",
"=",
"'telephoneNumber'",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"addr_node",
",",
"'physical'",
")",
";",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"c",
",",
"'addressPart'",
",",
"$",
"number",
")",
";",
"$",
"c",
"->",
"setAttribute",
"(",
"'type'",
",",
"$",
"fone_fax",
")",
";",
"}"
] | Physical node is a holder node for phone or fax nodes.
\param $addr_node Type: DOMelement. Address node created before to which the new phiscial->addressPart will be attached.
\param $number Type: string. Telephone or fax number as a string.
\param $fone_fax Type: string. Either telehoneNumber or faxNumber. | [
"Physical",
"node",
"is",
"a",
"holder",
"node",
"for",
"phone",
"or",
"fax",
"nodes",
".",
"\\",
"param",
"$addr_node",
"Type",
":",
"DOMelement",
".",
"Address",
"node",
"created",
"before",
"to",
"which",
"the",
"new",
"phiscial",
"-",
">",
"addressPart",
"will",
"be",
"attached",
".",
"\\",
"param",
"$number",
"Type",
":",
"string",
".",
"Telephone",
"or",
"fax",
"number",
"as",
"a",
"string",
".",
"\\",
"param",
"$fone_fax",
"Type",
":",
"string",
".",
"Either",
"telehoneNumber",
"or",
"faxNumber",
"."
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L236-L241 |
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_physcial_addr_txt | protected function create_physcial_addr_txt($addr_node, $txt_addr, $phys_type='streetAddress')
{
$c = $this->addChild($addr_node, 'physical');
$c->setAttribute('type', $phys_type);
$c = $this->addChild($c, 'addressPart', $txt_addr);
$c->setAttribute('type', 'text');
} | php | protected function create_physcial_addr_txt($addr_node, $txt_addr, $phys_type='streetAddress')
{
$c = $this->addChild($addr_node, 'physical');
$c->setAttribute('type', $phys_type);
$c = $this->addChild($c, 'addressPart', $txt_addr);
$c->setAttribute('type', 'text');
} | [
"protected",
"function",
"create_physcial_addr_txt",
"(",
"$",
"addr_node",
",",
"$",
"txt_addr",
",",
"$",
"phys_type",
"=",
"'streetAddress'",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"addr_node",
",",
"'physical'",
")",
";",
"$",
"c",
"->",
"setAttribute",
"(",
"'type'",
",",
"$",
"phys_type",
")",
";",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"c",
",",
"'addressPart'",
",",
"$",
"txt_addr",
")",
";",
"$",
"c",
"->",
"setAttribute",
"(",
"'type'",
",",
"'text'",
")",
";",
"}"
] | create address node under location node, either streetAddress or postalAddress.
But they are in text (one block) format.
\param $addr_node Type: DOMelement. Address node created before to which the new phiscial->addressPart will be attached.
\param $txt_addr string, full street address in text block format
\param $phys_type string, default is 'streetAddress', can be 'postalAddress' | [
"create",
"address",
"node",
"under",
"location",
"node",
"either",
"streetAddress",
"or",
"postalAddress",
".",
"But",
"they",
"are",
"in",
"text",
"(",
"one",
"block",
")",
"format",
".",
"\\",
"param",
"$addr_node",
"Type",
":",
"DOMelement",
".",
"Address",
"node",
"created",
"before",
"to",
"which",
"the",
"new",
"phiscial",
"-",
">",
"addressPart",
"will",
"be",
"attached",
".",
"\\",
"param",
"$txt_addr",
"string",
"full",
"street",
"address",
"in",
"text",
"block",
"format",
"\\",
"param",
"$phys_type",
"string",
"default",
"is",
"streetAddress",
"can",
"be",
"postalAddress"
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L249-L255 |
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_spatial_node | protected function create_spatial_node($location_node, $value = '138.6396,-34.97063', $sp_type = 'kmlPolyCoords')
{
$c = $this->addChild($location_node, 'spatial', $value);
$c->setAttribute('type', $sp_type);
} | php | protected function create_spatial_node($location_node, $value = '138.6396,-34.97063', $sp_type = 'kmlPolyCoords')
{
$c = $this->addChild($location_node, 'spatial', $value);
$c->setAttribute('type', $sp_type);
} | [
"protected",
"function",
"create_spatial_node",
"(",
"$",
"location_node",
",",
"$",
"value",
"=",
"'138.6396,-34.97063'",
",",
"$",
"sp_type",
"=",
"'kmlPolyCoords'",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"location_node",
",",
"'spatial'",
",",
"$",
"value",
")",
";",
"$",
"c",
"->",
"setAttribute",
"(",
"'type'",
",",
"$",
"sp_type",
")",
";",
"}"
] | Create spatial node under a location node.
\param $location_node Type: DOMElement. Location node where spatial node is being added to.
\param $value Type: string. The value of spatial information. Default is local latitude and longitude.
\param $sp_type Type: string. Type of spaitial informaion. Default is kmlPolyCoords. | [
"Create",
"spatial",
"node",
"under",
"a",
"location",
"node",
".",
"\\",
"param",
"$location_node",
"Type",
":",
"DOMElement",
".",
"Location",
"node",
"where",
"spatial",
"node",
"is",
"being",
"added",
"to",
".",
"\\",
"param",
"$value",
"Type",
":",
"string",
".",
"The",
"value",
"of",
"spatial",
"information",
".",
"Default",
"is",
"local",
"latitude",
"and",
"longitude",
".",
"\\",
"param",
"$sp_type",
"Type",
":",
"string",
".",
"Type",
"of",
"spaitial",
"informaion",
".",
"Default",
"is",
"kmlPolyCoords",
"."
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L262-L266 |
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_coverage_tempo | protected function create_coverage_tempo($values)
{
// Non array is not acceptable.
if (!is_array($values)) {
throw new Exception('The input of temporal coverage has to be an array of arraies with keys.');
}
$c = $this->addChild($this->working_node, 'coverage');
$t = $this->addChild($c, 'temporal');
foreach ($values as $value) {
$this->create_coverage_tempo_date($t, $value);
}
} | php | protected function create_coverage_tempo($values)
{
// Non array is not acceptable.
if (!is_array($values)) {
throw new Exception('The input of temporal coverage has to be an array of arraies with keys.');
}
$c = $this->addChild($this->working_node, 'coverage');
$t = $this->addChild($c, 'temporal');
foreach ($values as $value) {
$this->create_coverage_tempo_date($t, $value);
}
} | [
"protected",
"function",
"create_coverage_tempo",
"(",
"$",
"values",
")",
"{",
"// Non array is not acceptable.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The input of temporal coverage has to be an array of arraies with keys.'",
")",
";",
"}",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"this",
"->",
"working_node",
",",
"'coverage'",
")",
";",
"$",
"t",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"c",
",",
"'temporal'",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"create_coverage_tempo_date",
"(",
"$",
"t",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Create temporal coverage node for collection or activity records.
\param $values Type: 2-D array. The values of temporal coverage. It can has maximal two elements: one from 'dateFrom' and another for 'dateTo'.
Either can be ommited according to RIF-CS schema. Each element of $values is an array and has keys: date, type and format.
['date'] is a string represents date. It has to be in W3CDTF or UTC format.
['type'] has to be either 'dateFrom' or 'dateTo'.
['format'] is optional and its default is 'W3CDTF'. UTC format requires date has to be in UTC: dateTtimeZ.
It throws an exception if the input parameter is not an array. | [
"Create",
"temporal",
"coverage",
"node",
"for",
"collection",
"or",
"activity",
"records",
".",
"\\",
"param",
"$values",
"Type",
":",
"2",
"-",
"D",
"array",
".",
"The",
"values",
"of",
"temporal",
"coverage",
".",
"It",
"can",
"has",
"maximal",
"two",
"elements",
":",
"one",
"from",
"dateFrom",
"and",
"another",
"for",
"dateTo",
".",
"Either",
"can",
"be",
"ommited",
"according",
"to",
"RIF",
"-",
"CS",
"schema",
".",
"Each",
"element",
"of",
"$values",
"is",
"an",
"array",
"and",
"has",
"keys",
":",
"date",
"type",
"and",
"format",
".",
"[",
"date",
"]",
"is",
"a",
"string",
"represents",
"date",
".",
"It",
"has",
"to",
"be",
"in",
"W3CDTF",
"or",
"UTC",
"format",
".",
"[",
"type",
"]",
"has",
"to",
"be",
"either",
"dateFrom",
"or",
"dateTo",
".",
"[",
"format",
"]",
"is",
"optional",
"and",
"its",
"default",
"is",
"W3CDTF",
".",
"UTC",
"format",
"requires",
"date",
"has",
"to",
"be",
"in",
"UTC",
":",
"dateTtimeZ",
".",
"It",
"throws",
"an",
"exception",
"if",
"the",
"input",
"parameter",
"is",
"not",
"an",
"array",
"."
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L276-L287 |
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_coverage_tempo_date | private function create_coverage_tempo_date($t, $value)
{
if (!is_array($value)) {
throw new Exception('The input of temporal coverage has to be an array with keys.');
}
$d = $this->addChild($t, 'date', $value['date']);
$d->setAttribute('type', $value['type']);
if (isset($value['format'])) {
$d->setAttribute('dateFormat', $value['format']);
} else {
$d->setAttribute('dateFormat', 'W3CDTF');
}
} | php | private function create_coverage_tempo_date($t, $value)
{
if (!is_array($value)) {
throw new Exception('The input of temporal coverage has to be an array with keys.');
}
$d = $this->addChild($t, 'date', $value['date']);
$d->setAttribute('type', $value['type']);
if (isset($value['format'])) {
$d->setAttribute('dateFormat', $value['format']);
} else {
$d->setAttribute('dateFormat', 'W3CDTF');
}
} | [
"private",
"function",
"create_coverage_tempo_date",
"(",
"$",
"t",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The input of temporal coverage has to be an array with keys.'",
")",
";",
"}",
"$",
"d",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"t",
",",
"'date'",
",",
"$",
"value",
"[",
"'date'",
"]",
")",
";",
"$",
"d",
"->",
"setAttribute",
"(",
"'type'",
",",
"$",
"value",
"[",
"'type'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"d",
"->",
"setAttribute",
"(",
"'dateFormat'",
",",
"$",
"value",
"[",
"'format'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"d",
"->",
"setAttribute",
"(",
"'dateFormat'",
",",
"'W3CDTF'",
")",
";",
"}",
"}"
] | Create temporal coverage node for collection or activity records.
\param $t Type: DOMElement. The \<coverage\>\<temporal/\>\</coverage\> node to which \<date\> nodes will be attached to.
\param $value Type: array. The value of temporal coverage. It has maxmimal three elements with keys: type, date and format.
It throws an exception if the input parameter is not an array.
\see create_coverage_tempo | [
"Create",
"temporal",
"coverage",
"node",
"for",
"collection",
"or",
"activity",
"records",
".",
"\\",
"param",
"$t",
"Type",
":",
"DOMElement",
".",
"The",
"\\",
"<coverage",
"\\",
">",
"\\",
"<temporal",
"/",
"\\",
">",
"\\",
"<",
"/",
"coverage",
"\\",
">",
"node",
"to",
"which",
"\\",
"<date",
"\\",
">",
"nodes",
"will",
"be",
"attached",
"to",
".",
"\\",
"param",
"$value",
"Type",
":",
"array",
".",
"The",
"value",
"of",
"temporal",
"coverage",
".",
"It",
"has",
"maxmimal",
"three",
"elements",
"with",
"keys",
":",
"type",
"date",
"and",
"format",
".",
"It",
"throws",
"an",
"exception",
"if",
"the",
"input",
"parameter",
"is",
"not",
"an",
"array",
".",
"\\",
"see",
"create_coverage_tempo"
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L295-L307 |
fccn/oai-pmh-core | src/schemas/ands_oai.php | ANDS_OAI.create_subject_node | protected function create_subject_node($value, $subject_type = 'anzsrc-for')
{
if (empty($value)) {
return;
}
$c = $this->addChild($this->working_node, 'subject', $value);
$c->setAttribute('type', $subject_type);
} | php | protected function create_subject_node($value, $subject_type = 'anzsrc-for')
{
if (empty($value)) {
return;
}
$c = $this->addChild($this->working_node, 'subject', $value);
$c->setAttribute('type', $subject_type);
} | [
"protected",
"function",
"create_subject_node",
"(",
"$",
"value",
",",
"$",
"subject_type",
"=",
"'anzsrc-for'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"$",
"c",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"this",
"->",
"working_node",
",",
"'subject'",
",",
"$",
"value",
")",
";",
"$",
"c",
"->",
"setAttribute",
"(",
"'type'",
",",
"$",
"subject_type",
")",
";",
"}"
] | Create a subject node for a researcher, project, project, etc
\param $value Type: string. A string representing the new namePart.
\param $subject_type Type: string. A string representing the type of subject. The default value is anzsrc-for. | [
"Create",
"a",
"subject",
"node",
"for",
"a",
"researcher",
"project",
"project",
"etc",
"\\",
"param",
"$value",
"Type",
":",
"string",
".",
"A",
"string",
"representing",
"the",
"new",
"namePart",
".",
"\\",
"param",
"$subject_type",
"Type",
":",
"string",
".",
"A",
"string",
"representing",
"the",
"type",
"of",
"subject",
".",
"The",
"default",
"value",
"is",
"anzsrc",
"-",
"for",
"."
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L313-L320 |
infinity-next/sleuth | src/Detectives/ImageGDDetective.php | ImageGDDetective.leadGIF | protected function leadGIF()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_GIF;
if ($exif)
{
return $this->closeCase("gif", "image/gif");
}
return null;
} | php | protected function leadGIF()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_GIF;
if ($exif)
{
return $this->closeCase("gif", "image/gif");
}
return null;
} | [
"protected",
"function",
"leadGIF",
"(",
")",
"{",
"$",
"exif",
"=",
"exif_imagetype",
"(",
"$",
"this",
"->",
"file",
")",
"===",
"IMAGETYPE_GIF",
";",
"if",
"(",
"$",
"exif",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"gif\"",
",",
"\"image/gif\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if thise file is a GIF.
@return boolean|null | [
"Checks",
"if",
"thise",
"file",
"is",
"a",
"GIF",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L15-L25 |
infinity-next/sleuth | src/Detectives/ImageGDDetective.php | ImageGDDetective.leadJPG | protected function leadJPG()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_JPEG;
if ($exif)
{
return $this->closeCase("jpg", "image/jpg");
}
return null;
} | php | protected function leadJPG()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_JPEG;
if ($exif)
{
return $this->closeCase("jpg", "image/jpg");
}
return null;
} | [
"protected",
"function",
"leadJPG",
"(",
")",
"{",
"$",
"exif",
"=",
"exif_imagetype",
"(",
"$",
"this",
"->",
"file",
")",
"===",
"IMAGETYPE_JPEG",
";",
"if",
"(",
"$",
"exif",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"jpg\"",
",",
"\"image/jpg\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if thise file is a JPG.
@return boolean|null | [
"Checks",
"if",
"thise",
"file",
"is",
"a",
"JPG",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L32-L42 |
infinity-next/sleuth | src/Detectives/ImageGDDetective.php | ImageGDDetective.leadPNG | protected function leadPNG()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_PNG;
if ($exif)
{
return $this->closeCase("png", "image/png");
}
return null;
} | php | protected function leadPNG()
{
$exif = exif_imagetype($this->file) === IMAGETYPE_PNG;
if ($exif)
{
return $this->closeCase("png", "image/png");
}
return null;
} | [
"protected",
"function",
"leadPNG",
"(",
")",
"{",
"$",
"exif",
"=",
"exif_imagetype",
"(",
"$",
"this",
"->",
"file",
")",
"===",
"IMAGETYPE_PNG",
";",
"if",
"(",
"$",
"exif",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"png\"",
",",
"\"image/png\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if thise file is a PNG.
@return boolean|null | [
"Checks",
"if",
"thise",
"file",
"is",
"a",
"PNG",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L49-L59 |
infinity-next/sleuth | src/Detectives/ImageGDDetective.php | ImageGDDetective.leadSWF | protected function leadSWF()
{
$exif = exif_imagetype($this->file);
$flash = ($exif === IMAGETYPE_SWF || $exif === IMAGETYPE_SWC);
if ($exif)
{
return $this->closeCase("swf", "application/x-shockwave-flash");
}
return null;
} | php | protected function leadSWF()
{
$exif = exif_imagetype($this->file);
$flash = ($exif === IMAGETYPE_SWF || $exif === IMAGETYPE_SWC);
if ($exif)
{
return $this->closeCase("swf", "application/x-shockwave-flash");
}
return null;
} | [
"protected",
"function",
"leadSWF",
"(",
")",
"{",
"$",
"exif",
"=",
"exif_imagetype",
"(",
"$",
"this",
"->",
"file",
")",
";",
"$",
"flash",
"=",
"(",
"$",
"exif",
"===",
"IMAGETYPE_SWF",
"||",
"$",
"exif",
"===",
"IMAGETYPE_SWC",
")",
";",
"if",
"(",
"$",
"exif",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"swf\"",
",",
"\"application/x-shockwave-flash\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a SWF.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"SWF",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L66-L77 |
accompli/chrono | src/Repository.php | Repository.getAdapter | public function getAdapter()
{
if ($this->repositoryAdapter instanceof AdapterInterface) {
return $this->repositoryAdapter;
}
foreach ($this->adapters as $adapterClass) {
if (class_exists($adapterClass) === false || in_array('Accompli\Chrono\Adapter\AdapterInterface', class_implements($adapterClass)) === false) {
continue;
}
$adapter = new $adapterClass($this->repositoryUrl, $this->repositoryDirectory, $this->processExecutor);
if ($adapter->supportsRepository()) {
return $adapter;
}
}
} | php | public function getAdapter()
{
if ($this->repositoryAdapter instanceof AdapterInterface) {
return $this->repositoryAdapter;
}
foreach ($this->adapters as $adapterClass) {
if (class_exists($adapterClass) === false || in_array('Accompli\Chrono\Adapter\AdapterInterface', class_implements($adapterClass)) === false) {
continue;
}
$adapter = new $adapterClass($this->repositoryUrl, $this->repositoryDirectory, $this->processExecutor);
if ($adapter->supportsRepository()) {
return $adapter;
}
}
} | [
"public",
"function",
"getAdapter",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"repositoryAdapter",
"instanceof",
"AdapterInterface",
")",
"{",
"return",
"$",
"this",
"->",
"repositoryAdapter",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"adapters",
"as",
"$",
"adapterClass",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"adapterClass",
")",
"===",
"false",
"||",
"in_array",
"(",
"'Accompli\\Chrono\\Adapter\\AdapterInterface'",
",",
"class_implements",
"(",
"$",
"adapterClass",
")",
")",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"adapter",
"=",
"new",
"$",
"adapterClass",
"(",
"$",
"this",
"->",
"repositoryUrl",
",",
"$",
"this",
"->",
"repositoryDirectory",
",",
"$",
"this",
"->",
"processExecutor",
")",
";",
"if",
"(",
"$",
"adapter",
"->",
"supportsRepository",
"(",
")",
")",
"{",
"return",
"$",
"adapter",
";",
"}",
"}",
"}"
] | Returns the supported adapter for the repository.
@return AdapterInterface|null | [
"Returns",
"the",
"supported",
"adapter",
"for",
"the",
"repository",
"."
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Repository.php#L95-L111 |
accompli/chrono | src/Repository.php | Repository.initialize | private function initialize()
{
$adapter = $this->getAdapter();
if (($adapter instanceof AdapterInterface) === false) {
throw new InvalidArgumentException(sprintf('No adapter found to handle VCS repository "%s".', $this->repositoryUrl));
}
$this->repositoryAdapter = $adapter;
} | php | private function initialize()
{
$adapter = $this->getAdapter();
if (($adapter instanceof AdapterInterface) === false) {
throw new InvalidArgumentException(sprintf('No adapter found to handle VCS repository "%s".', $this->repositoryUrl));
}
$this->repositoryAdapter = $adapter;
} | [
"private",
"function",
"initialize",
"(",
")",
"{",
"$",
"adapter",
"=",
"$",
"this",
"->",
"getAdapter",
"(",
")",
";",
"if",
"(",
"(",
"$",
"adapter",
"instanceof",
"AdapterInterface",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'No adapter found to handle VCS repository \"%s\".'",
",",
"$",
"this",
"->",
"repositoryUrl",
")",
")",
";",
"}",
"$",
"this",
"->",
"repositoryAdapter",
"=",
"$",
"adapter",
";",
"}"
] | Initializes the repository (adapter).
@throws InvalidArgumentException | [
"Initializes",
"the",
"repository",
"(",
"adapter",
")",
"."
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Repository.php#L138-L146 |
ajgarlag/AjglSessionConcurrency | src/Http/EventListener/RefreshSessionRegistryLastUsedListener.php | RefreshSessionRegistryLastUsedListener.onKernelTerminate | public function onKernelTerminate(PostResponseEvent $event)
{
if (!$event->getRequest()->hasSession()) {
return;
}
$session = $event->getRequest()->getSession();
$this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed());
} | php | public function onKernelTerminate(PostResponseEvent $event)
{
if (!$event->getRequest()->hasSession()) {
return;
}
$session = $event->getRequest()->getSession();
$this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed());
} | [
"public",
"function",
"onKernelTerminate",
"(",
"PostResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"hasSession",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"session",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
";",
"$",
"this",
"->",
"registry",
"->",
"refreshLastUsed",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
",",
"$",
"session",
"->",
"getMetadataBag",
"(",
")",
"->",
"getLastUsed",
"(",
")",
")",
";",
"}"
] | Refresh the last used timestamp for the given session if registered.
@param PostResponseEvent $event | [
"Refresh",
"the",
"last",
"used",
"timestamp",
"for",
"the",
"given",
"session",
"if",
"registered",
"."
] | train | https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/EventListener/RefreshSessionRegistryLastUsedListener.php#L41-L50 |
surebert/surebert-framework | src/sb/SSH2/Shell.php | Shell.create | public function create($term_type='xterm', $env=null, $width=80, $height=24, $width_height_type='')
{
$width_height_type = $width_height_type ? $width_height_type : SSH2_TERM_UNIT_CHARS;
$this->shell = @ssh2_shell($this->connection, $term_type, $env, $width, $height, $width_height_type);
stream_set_blocking($this->shell, true);
if(!$this->shell){
throw new \Exception('Cannot create shell');
}
return $this->shell;
} | php | public function create($term_type='xterm', $env=null, $width=80, $height=24, $width_height_type='')
{
$width_height_type = $width_height_type ? $width_height_type : SSH2_TERM_UNIT_CHARS;
$this->shell = @ssh2_shell($this->connection, $term_type, $env, $width, $height, $width_height_type);
stream_set_blocking($this->shell, true);
if(!$this->shell){
throw new \Exception('Cannot create shell');
}
return $this->shell;
} | [
"public",
"function",
"create",
"(",
"$",
"term_type",
"=",
"'xterm'",
",",
"$",
"env",
"=",
"null",
",",
"$",
"width",
"=",
"80",
",",
"$",
"height",
"=",
"24",
",",
"$",
"width_height_type",
"=",
"''",
")",
"{",
"$",
"width_height_type",
"=",
"$",
"width_height_type",
"?",
"$",
"width_height_type",
":",
"SSH2_TERM_UNIT_CHARS",
";",
"$",
"this",
"->",
"shell",
"=",
"@",
"ssh2_shell",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"term_type",
",",
"$",
"env",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"width_height_type",
")",
";",
"stream_set_blocking",
"(",
"$",
"this",
"->",
"shell",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"shell",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot create shell'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"shell",
";",
"}"
] | Opens a shell at the remote end and allocate a stream for it.
@param string $term_type hould correspond to one of the entries in the target system's /etc/termcap file. e.g. xterm, vt102
@param array $env may be passed as an associative array of name/value pairs to set in the target environment
@param integer $width Width of the virtual terminal.
@param integer $height Height of the virtual terminal.
@param constant $width_height_type SSH2_TERM_UNIT_CHARS or SSH2_TERM_UNIT_PIXELS
@return sb_SSH2_Shell | [
"Opens",
"a",
"shell",
"at",
"the",
"remote",
"end",
"and",
"allocate",
"a",
"stream",
"for",
"it",
".",
"@param",
"string",
"$term_type",
"hould",
"correspond",
"to",
"one",
"of",
"the",
"entries",
"in",
"the",
"target",
"system",
"s",
"/",
"etc",
"/",
"termcap",
"file",
".",
"e",
".",
"g",
".",
"xterm",
"vt102",
"@param",
"array",
"$env",
"may",
"be",
"passed",
"as",
"an",
"associative",
"array",
"of",
"name",
"/",
"value",
"pairs",
"to",
"set",
"in",
"the",
"target",
"environment",
"@param",
"integer",
"$width",
"Width",
"of",
"the",
"virtual",
"terminal",
".",
"@param",
"integer",
"$height",
"Height",
"of",
"the",
"virtual",
"terminal",
".",
"@param",
"constant",
"$width_height_type",
"SSH2_TERM_UNIT_CHARS",
"or",
"SSH2_TERM_UNIT_PIXELS"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SSH2/Shell.php#L36-L48 |
surebert/surebert-framework | src/sb/SSH2/Shell.php | Shell.exec | public function exec($command, $timeout=30, $with_login_env=true)
{
stream_set_timeout($this->shell, $timeout);
if($with_login_env){
$command = 'bash -l '.$command;
}
return fwrite($this->shell, $command.PHP_EOL);
} | php | public function exec($command, $timeout=30, $with_login_env=true)
{
stream_set_timeout($this->shell, $timeout);
if($with_login_env){
$command = 'bash -l '.$command;
}
return fwrite($this->shell, $command.PHP_EOL);
} | [
"public",
"function",
"exec",
"(",
"$",
"command",
",",
"$",
"timeout",
"=",
"30",
",",
"$",
"with_login_env",
"=",
"true",
")",
"{",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"shell",
",",
"$",
"timeout",
")",
";",
"if",
"(",
"$",
"with_login_env",
")",
"{",
"$",
"command",
"=",
"'bash -l '",
".",
"$",
"command",
";",
"}",
"return",
"fwrite",
"(",
"$",
"this",
"->",
"shell",
",",
"$",
"command",
".",
"PHP_EOL",
")",
";",
"}"
] | Execute a command on the interactive shell
@param string $command The command to exec
@param boolean $with_login_env o run a shell script with all the variables that you would have when logged in interactively
@return boolean | [
"Execute",
"a",
"command",
"on",
"the",
"interactive",
"shell"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SSH2/Shell.php#L56-L64 |
oroinc/OroLayoutComponent | ExpressionLanguage/Encoder/ExpressionEncoderRegistry.php | ExpressionEncoderRegistry.get | public function get($format)
{
if (!array_key_exists($format, $this->encoders)) {
throw new \RuntimeException(
sprintf('The expression encoder for "%s" formatting was not found.', $format)
);
}
return $this->encoders[$format];
} | php | public function get($format)
{
if (!array_key_exists($format, $this->encoders)) {
throw new \RuntimeException(
sprintf('The expression encoder for "%s" formatting was not found.', $format)
);
}
return $this->encoders[$format];
} | [
"public",
"function",
"get",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"format",
",",
"$",
"this",
"->",
"encoders",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The expression encoder for \"%s\" formatting was not found.'",
",",
"$",
"format",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"encoders",
"[",
"$",
"format",
"]",
";",
"}"
] | Returns the encoder for the given format
@param string $format
@return ExpressionEncoderInterface
@throws \RuntimeException if the appropriate encoder does not exist | [
"Returns",
"the",
"encoder",
"for",
"the",
"given",
"format"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ExpressionLanguage/Encoder/ExpressionEncoderRegistry.php#L27-L36 |
mothership-ec/composer | src/Composer/Repository/Vcs/HgDriver.php | HgDriver.getComposerInformation | public function getComposerInformation($identifier)
{
if (!isset($this->infoCache[$identifier])) {
$this->process->execute(sprintf('hg cat -r %s composer.json', ProcessExecutor::escape($identifier)), $composer, $this->repoDir);
if (!trim($composer)) {
return;
}
$composer = JsonFile::parseJson($composer, $identifier);
if (empty($composer['time'])) {
$this->process->execute(sprintf('hg log --template "{date|rfc3339date}" -r %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir);
$date = new \DateTime(trim($output), new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s');
}
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | php | public function getComposerInformation($identifier)
{
if (!isset($this->infoCache[$identifier])) {
$this->process->execute(sprintf('hg cat -r %s composer.json', ProcessExecutor::escape($identifier)), $composer, $this->repoDir);
if (!trim($composer)) {
return;
}
$composer = JsonFile::parseJson($composer, $identifier);
if (empty($composer['time'])) {
$this->process->execute(sprintf('hg log --template "{date|rfc3339date}" -r %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir);
$date = new \DateTime(trim($output), new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s');
}
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | [
"public",
"function",
"getComposerInformation",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"this",
"->",
"process",
"->",
"execute",
"(",
"sprintf",
"(",
"'hg cat -r %s composer.json'",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"identifier",
")",
")",
",",
"$",
"composer",
",",
"$",
"this",
"->",
"repoDir",
")",
";",
"if",
"(",
"!",
"trim",
"(",
"$",
"composer",
")",
")",
"{",
"return",
";",
"}",
"$",
"composer",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"composer",
",",
"$",
"identifier",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"composer",
"[",
"'time'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"process",
"->",
"execute",
"(",
"sprintf",
"(",
"'hg log --template \"{date|rfc3339date}\" -r %s'",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"identifier",
")",
")",
",",
"$",
"output",
",",
"$",
"this",
"->",
"repoDir",
")",
";",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"trim",
"(",
"$",
"output",
")",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"composer",
"[",
"'time'",
"]",
"=",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
"=",
"$",
"composer",
";",
"}",
"return",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/HgDriver.php#L116-L136 |
arndtteunissen/column-layout | Classes/DataProcessing/HydrateFlexFormConfig.php | HydrateFlexFormConfig.process | public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
if (empty($processorConfiguration['field']) || !isset($processedData['data'][$processorConfiguration['field']])) {
return $processedData;
}
$flexFormData = ColumnLayoutUtility::hydrateLayoutConfigFlexFormData(
$processedData['data'][$processorConfiguration['field']]
);
$as = $cObj->stdWrapValue('as', $processorConfiguration, 'column_layout');
$processedData[$as] = $flexFormData;
return $processedData;
} | php | public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
if (empty($processorConfiguration['field']) || !isset($processedData['data'][$processorConfiguration['field']])) {
return $processedData;
}
$flexFormData = ColumnLayoutUtility::hydrateLayoutConfigFlexFormData(
$processedData['data'][$processorConfiguration['field']]
);
$as = $cObj->stdWrapValue('as', $processorConfiguration, 'column_layout');
$processedData[$as] = $flexFormData;
return $processedData;
} | [
"public",
"function",
"process",
"(",
"ContentObjectRenderer",
"$",
"cObj",
",",
"array",
"$",
"contentObjectConfiguration",
",",
"array",
"$",
"processorConfiguration",
",",
"array",
"$",
"processedData",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"processorConfiguration",
"[",
"'field'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"processedData",
"[",
"'data'",
"]",
"[",
"$",
"processorConfiguration",
"[",
"'field'",
"]",
"]",
")",
")",
"{",
"return",
"$",
"processedData",
";",
"}",
"$",
"flexFormData",
"=",
"ColumnLayoutUtility",
"::",
"hydrateLayoutConfigFlexFormData",
"(",
"$",
"processedData",
"[",
"'data'",
"]",
"[",
"$",
"processorConfiguration",
"[",
"'field'",
"]",
"]",
")",
";",
"$",
"as",
"=",
"$",
"cObj",
"->",
"stdWrapValue",
"(",
"'as'",
",",
"$",
"processorConfiguration",
",",
"'column_layout'",
")",
";",
"$",
"processedData",
"[",
"$",
"as",
"]",
"=",
"$",
"flexFormData",
";",
"return",
"$",
"processedData",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/DataProcessing/HydrateFlexFormConfig.php#L23-L41 |
dstuecken/notify | src/Handler/SmartyHandler.php | SmartyHandler.handle | public function handle(NotificationInterface $notification, $level)
{
if ($notification instanceof AttributeAwareInterface)
{
$options = $notification->attributes();
}
else
{
$options = [];
}
if ($notification instanceof TitleAwareInterface)
{
$options['header'] = $notification->title();
}
$variable = [
'message' => $notification->message(),
'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD,
'options' => $options
];
$current = $this->smarty->getTemplateVars($this->var);
if (!$current)
{
$this->smarty->assign($this->var, [$variable]);
}
else
{
$this->smarty->append($this->var, $variable);
}
return true;
} | php | public function handle(NotificationInterface $notification, $level)
{
if ($notification instanceof AttributeAwareInterface)
{
$options = $notification->attributes();
}
else
{
$options = [];
}
if ($notification instanceof TitleAwareInterface)
{
$options['header'] = $notification->title();
}
$variable = [
'message' => $notification->message(),
'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD,
'options' => $options
];
$current = $this->smarty->getTemplateVars($this->var);
if (!$current)
{
$this->smarty->assign($this->var, [$variable]);
}
else
{
$this->smarty->append($this->var, $variable);
}
return true;
} | [
"public",
"function",
"handle",
"(",
"NotificationInterface",
"$",
"notification",
",",
"$",
"level",
")",
"{",
"if",
"(",
"$",
"notification",
"instanceof",
"AttributeAwareInterface",
")",
"{",
"$",
"options",
"=",
"$",
"notification",
"->",
"attributes",
"(",
")",
";",
"}",
"else",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"notification",
"instanceof",
"TitleAwareInterface",
")",
"{",
"$",
"options",
"[",
"'header'",
"]",
"=",
"$",
"notification",
"->",
"title",
"(",
")",
";",
"}",
"$",
"variable",
"=",
"[",
"'message'",
"=>",
"$",
"notification",
"->",
"message",
"(",
")",
",",
"'type'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"levelMapping",
"[",
"$",
"level",
"]",
")",
"?",
"$",
"this",
"->",
"levelMapping",
"[",
"$",
"level",
"]",
":",
"self",
"::",
"STANDARD",
",",
"'options'",
"=>",
"$",
"options",
"]",
";",
"$",
"current",
"=",
"$",
"this",
"->",
"smarty",
"->",
"getTemplateVars",
"(",
"$",
"this",
"->",
"var",
")",
";",
"if",
"(",
"!",
"$",
"current",
")",
"{",
"$",
"this",
"->",
"smarty",
"->",
"assign",
"(",
"$",
"this",
"->",
"var",
",",
"[",
"$",
"variable",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"smarty",
"->",
"append",
"(",
"$",
"this",
"->",
"var",
",",
"$",
"variable",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Handle a notification.
@return boolean | [
"Handle",
"a",
"notification",
"."
] | train | https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/Handler/SmartyHandler.php#L34-L68 |
SporkCode/Spork | src/Filter/AbstractFilter.php | AbstractFilter.inline | public static function inline($value, $options = array())
{
$filter = new static();
$filter->setOptions($options);
return $filter->filter($value);
} | php | public static function inline($value, $options = array())
{
$filter = new static();
$filter->setOptions($options);
return $filter->filter($value);
} | [
"public",
"static",
"function",
"inline",
"(",
"$",
"value",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"new",
"static",
"(",
")",
";",
"$",
"filter",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"return",
"$",
"filter",
"->",
"filter",
"(",
"$",
"value",
")",
";",
"}"
] | Static function to execute filter
@param int $value
@param array $options
@return mixed | [
"Static",
"function",
"to",
"execute",
"filter"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Filter/AbstractFilter.php#L24-L29 |
surebert/surebert-framework | src/sb/Strings.php | Strings.cleanFileName | public static function cleanFileName($str)
{
preg_match('~\.\w{1,4}$~', $str, $ext);
$str = preg_replace('~\.\w{1,4}$~', '', $str);
return str_replace(Array(' ', '.', '-'), "_", $str).$ext[0];
} | php | public static function cleanFileName($str)
{
preg_match('~\.\w{1,4}$~', $str, $ext);
$str = preg_replace('~\.\w{1,4}$~', '', $str);
return str_replace(Array(' ', '.', '-'), "_", $str).$ext[0];
} | [
"public",
"static",
"function",
"cleanFileName",
"(",
"$",
"str",
")",
"{",
"preg_match",
"(",
"'~\\.\\w{1,4}$~'",
",",
"$",
"str",
",",
"$",
"ext",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"'~\\.\\w{1,4}$~'",
",",
"''",
",",
"$",
"str",
")",
";",
"return",
"str_replace",
"(",
"Array",
"(",
"' '",
",",
"'.'",
",",
"'-'",
")",
",",
"\"_\"",
",",
"$",
"str",
")",
".",
"$",
"ext",
"[",
"0",
"]",
";",
"}"
] | Cleans up file names and removes extraneous spaces, symbols, etc
@author [email protected]
@param string $str
@return string | [
"Cleans",
"up",
"file",
"names",
"and",
"removes",
"extraneous",
"spaces",
"symbols",
"etc"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L46-L53 |
surebert/surebert-framework | src/sb/Strings.php | Strings.stripMicrosoftChars | public static function stripMicrosoftChars($str)
{
$chars=array(
chr(133) => '...', //dot dot dot elipsis
chr(145) => "'", //curly left single quotes
chr(146) => "'", //curly right single quotes
chr(147) => '"', //curly left double quotes
chr(148) => '"', //curly right double quotes
chr(149) => '*', //bullet char
chr(150) => '-', //en dash
chr(151) => '-', //em dash,
//mac word roman charset
chr(165) => '*', //bullet char
chr(201) => '...', //elipsis
chr(208) => '-', //en-dash
chr(209) => '-', //em-dash
chr(210) => '"', //curly left double quotes
chr(211) => '"', //curly right double quotes
chr(212) => '\'', //curly left single quote
chr(213) => '\'', //curly right single quotes
);
return strtr($str, $chars);
} | php | public static function stripMicrosoftChars($str)
{
$chars=array(
chr(133) => '...', //dot dot dot elipsis
chr(145) => "'", //curly left single quotes
chr(146) => "'", //curly right single quotes
chr(147) => '"', //curly left double quotes
chr(148) => '"', //curly right double quotes
chr(149) => '*', //bullet char
chr(150) => '-', //en dash
chr(151) => '-', //em dash,
//mac word roman charset
chr(165) => '*', //bullet char
chr(201) => '...', //elipsis
chr(208) => '-', //en-dash
chr(209) => '-', //em-dash
chr(210) => '"', //curly left double quotes
chr(211) => '"', //curly right double quotes
chr(212) => '\'', //curly left single quote
chr(213) => '\'', //curly right single quotes
);
return strtr($str, $chars);
} | [
"public",
"static",
"function",
"stripMicrosoftChars",
"(",
"$",
"str",
")",
"{",
"$",
"chars",
"=",
"array",
"(",
"chr",
"(",
"133",
")",
"=>",
"'...'",
",",
"//dot dot dot elipsis",
"chr",
"(",
"145",
")",
"=>",
"\"'\"",
",",
"//curly left single quotes",
"chr",
"(",
"146",
")",
"=>",
"\"'\"",
",",
"//curly right single quotes",
"chr",
"(",
"147",
")",
"=>",
"'\"'",
",",
"//curly left double quotes",
"chr",
"(",
"148",
")",
"=>",
"'\"'",
",",
"//curly right double quotes",
"chr",
"(",
"149",
")",
"=>",
"'*'",
",",
"//bullet char",
"chr",
"(",
"150",
")",
"=>",
"'-'",
",",
"//en dash",
"chr",
"(",
"151",
")",
"=>",
"'-'",
",",
"//em dash,",
"//mac word roman charset",
"chr",
"(",
"165",
")",
"=>",
"'*'",
",",
"//bullet char",
"chr",
"(",
"201",
")",
"=>",
"'...'",
",",
"//elipsis",
"chr",
"(",
"208",
")",
"=>",
"'-'",
",",
"//en-dash",
"chr",
"(",
"209",
")",
"=>",
"'-'",
",",
"//em-dash",
"chr",
"(",
"210",
")",
"=>",
"'\"'",
",",
"//curly left double quotes",
"chr",
"(",
"211",
")",
"=>",
"'\"'",
",",
"//curly right double quotes",
"chr",
"(",
"212",
")",
"=>",
"'\\''",
",",
"//curly left single quote",
"chr",
"(",
"213",
")",
"=>",
"'\\''",
",",
"//curly right single quotes",
")",
";",
"return",
"strtr",
"(",
"$",
"str",
",",
"$",
"chars",
")",
";",
"}"
] | Removes microsoft characters and replace them with their ascii counterparts
@author [email protected]
@param string $str
@return string | [
"Removes",
"microsoft",
"characters",
"and",
"replace",
"them",
"with",
"their",
"ascii",
"counterparts"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L74-L101 |
surebert/surebert-framework | src/sb/Strings.php | Strings.unicodeUrldecode | public static function unicodeUrldecode($str)
{
preg_match_all('/%u([[:alnum:]]{4})/', $str, $matches);
foreach ($matches[1] as $uniord){
$str = str_replace('%u'.$uniord, '&#x' . $uniord . ';', $str);
}
return urldecode($str);
} | php | public static function unicodeUrldecode($str)
{
preg_match_all('/%u([[:alnum:]]{4})/', $str, $matches);
foreach ($matches[1] as $uniord){
$str = str_replace('%u'.$uniord, '&#x' . $uniord . ';', $str);
}
return urldecode($str);
} | [
"public",
"static",
"function",
"unicodeUrldecode",
"(",
"$",
"str",
")",
"{",
"preg_match_all",
"(",
"'/%u([[:alnum:]]{4})/'",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"uniord",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"'%u'",
".",
"$",
"uniord",
",",
"'&#x'",
".",
"$",
"uniord",
".",
"';'",
",",
"$",
"str",
")",
";",
"}",
"return",
"urldecode",
"(",
"$",
"str",
")",
";",
"}"
] | replaces unicode characters with ascii in unicode encoded urls e.g.from ajax calls
@author [email protected]
@param string $str
@return string | [
"replaces",
"unicode",
"characters",
"with",
"ascii",
"in",
"unicode",
"encoded",
"urls",
"e",
".",
"g",
".",
"from",
"ajax",
"calls"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L110-L119 |
surebert/surebert-framework | src/sb/Strings.php | Strings.truncate | public static function truncate($str, $maxlength=20)
{
if(strlen($str) > $maxlength){
$str = substr($str, 0, $maxlength-3).'...';
}
return $str;
} | php | public static function truncate($str, $maxlength=20)
{
if(strlen($str) > $maxlength){
$str = substr($str, 0, $maxlength-3).'...';
}
return $str;
} | [
"public",
"static",
"function",
"truncate",
"(",
"$",
"str",
",",
"$",
"maxlength",
"=",
"20",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"str",
")",
">",
"$",
"maxlength",
")",
"{",
"$",
"str",
"=",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"$",
"maxlength",
"-",
"3",
")",
".",
"'...'",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Truncates a string to a certain length and right padswith ...
@param string $str
@param integer $maxlength The maximum length, keep in mind that the ... counts as three chars
@return string | [
"Truncates",
"a",
"string",
"to",
"a",
"certain",
"length",
"and",
"right",
"padswith",
"..."
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L142-L150 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php | ToLatexCommand.getConverter | protected function getConverter(InputInterface $input)
{
/** @var ToLatexInterface $converter */
$converter = parent::getConverter($input);
$this->configureConverterFromInputOptions($converter, $input);
return $converter;
} | php | protected function getConverter(InputInterface $input)
{
/** @var ToLatexInterface $converter */
$converter = parent::getConverter($input);
$this->configureConverterFromInputOptions($converter, $input);
return $converter;
} | [
"protected",
"function",
"getConverter",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"/** @var ToLatexInterface $converter */",
"$",
"converter",
"=",
"parent",
"::",
"getConverter",
"(",
"$",
"input",
")",
";",
"$",
"this",
"->",
"configureConverterFromInputOptions",
"(",
"$",
"converter",
",",
"$",
"input",
")",
";",
"return",
"$",
"converter",
";",
"}"
] | Returns and configures the converter for this operation.
This method overrides the parent getConverter method and invokes the
configureConverterFromInputOptions() method to set the options coming
from the Input object.
@param InputInterface $input
@see BaseConvertCommand::getConverter() for the basic functionality.
@return \phpDocumentor\Plugin\Scrybe\Converter\ConverterInterface | [
"Returns",
"and",
"configures",
"the",
"converter",
"for",
"this",
"operation",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php#L78-L85 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.__isset | public function __isset( $name )
{
switch ( $name )
{
case 'contentDisposition':
case 'size':
return isset( $this->properties[$name] );
case "headers":
return isset( $this->headers );
default:
return false;
}
} | php | public function __isset( $name )
{
switch ( $name )
{
case 'contentDisposition':
case 'size':
return isset( $this->properties[$name] );
case "headers":
return isset( $this->headers );
default:
return false;
}
} | [
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'contentDisposition'",
":",
"case",
"'size'",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"name",
"]",
")",
";",
"case",
"\"headers\"",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] | Returns true if the property $name is set, otherwise false.
@param string $name
@return bool
@ignore | [
"Returns",
"true",
"if",
"the",
"property",
"$name",
"is",
"set",
"otherwise",
"false",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L138-L152 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.getHeader | public function getHeader( $name, $returnAllValues = false )
{
if ( isset( $this->headers[$name] ) )
{
if ( $returnAllValues === true )
{
return $this->headers[$name];
}
else if ( is_array( $this->headers[$name] ) )
{
// return only the first value in order to not break compatibility
// see issue #14257
return $this->headers[$name][0];
}
else
{
return $this->headers[$name];
}
}
return '';
} | php | public function getHeader( $name, $returnAllValues = false )
{
if ( isset( $this->headers[$name] ) )
{
if ( $returnAllValues === true )
{
return $this->headers[$name];
}
else if ( is_array( $this->headers[$name] ) )
{
// return only the first value in order to not break compatibility
// see issue #14257
return $this->headers[$name][0];
}
else
{
return $this->headers[$name];
}
}
return '';
} | [
"public",
"function",
"getHeader",
"(",
"$",
"name",
",",
"$",
"returnAllValues",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"returnAllValues",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// return only the first value in order to not break compatibility",
"// see issue #14257",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"''",
";",
"}"
] | Returns the RAW value of the header $name.
Returns an empty string if the header is not found.
Getting headers is case insensitive. Getting the header
'Message-Id' will match both 'Message-ID' and 'MESSAGE-ID'
as well as 'Message-Id'.
The raw value is MIME-encoded, so if you want to decode it,
use {@link ezcMailTools::mimeDecode()} or implement your own
MIME-decoding function.
If $returnAllValues is true, the function will return all
the values of the header $name from the mail in an array. If
it is false it will return only the first value as a string
if there are multiple values present in the mail.
@param string $name
@param bool $returnAllValues
@return mixed | [
"Returns",
"the",
"RAW",
"value",
"of",
"the",
"header",
"$name",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L175-L195 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.setHeader | public function setHeader( $name, $value, $charset = 'us-ascii' )
{
$this->headers[$name] = $value;
$this->setHeaderCharset( $name, $charset );
} | php | public function setHeader( $name, $value, $charset = 'us-ascii' )
{
$this->headers[$name] = $value;
$this->setHeaderCharset( $name, $charset );
} | [
"public",
"function",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"charset",
"=",
"'us-ascii'",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setHeaderCharset",
"(",
"$",
"name",
",",
"$",
"charset",
")",
";",
"}"
] | Sets the header $name to the value $value and its charset to $charset.
If the header is already set it will override the old value.
Headers set should be folded at 76 or 998 characters according to
the folding rules described in RFC 2822.
If $charset is specified, it is associated with the header $name. It
defaults to 'us-ascii' if not specified. The text in $value is encoded
with $charset after calling generateHeaders().
Note: The header Content-Disposition will be overwritten by the
contents of the contentsDisposition property if set.
@see generateHeaders()
@param string $name
@param string $value
@param string $charset | [
"Sets",
"the",
"header",
"$name",
"to",
"the",
"value",
"$value",
"and",
"its",
"charset",
"to",
"$charset",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L218-L222 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.setHeaders | public function setHeaders( array $headers )
{
foreach ( $headers as $key => $value )
{
if ( is_array( $value ) )
{
$this->headers[$key] = $value[0];
$charset = isset( $value[1] ) ? $value[1] : 'us-ascii';
$this->setHeaderCharset( $key, $charset );
}
else
{
$this->headers[$key] = $value;
$this->setHeaderCharset( $key );
}
}
} | php | public function setHeaders( array $headers )
{
foreach ( $headers as $key => $value )
{
if ( is_array( $value ) )
{
$this->headers[$key] = $value[0];
$charset = isset( $value[1] ) ? $value[1] : 'us-ascii';
$this->setHeaderCharset( $key, $charset );
}
else
{
$this->headers[$key] = $value;
$this->setHeaderCharset( $key );
}
}
} | [
"public",
"function",
"setHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"$",
"charset",
"=",
"isset",
"(",
"$",
"value",
"[",
"1",
"]",
")",
"?",
"$",
"value",
"[",
"1",
"]",
":",
"'us-ascii'",
";",
"$",
"this",
"->",
"setHeaderCharset",
"(",
"$",
"key",
",",
"$",
"charset",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setHeaderCharset",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}"
] | Adds the headers $headers.
The headers specified in the associative array $headers will overwrite
any existing header values.
The array $headers can have one of these 2 forms:
- array( header_name => header_value ) - by default the 'us-ascii' charset
will be associated with all headers
- array( header_name => array( header_value, header_charset ) ) - if
header_charset is missing it will default to 'us-ascii'
Headers set should be folded at 76 or 998 characters according to
the folding rules described in RFC 2822.
@param array(string=>mixed) $headers | [
"Adds",
"the",
"headers",
"$headers",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L241-L257 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.generateHeaders | public function generateHeaders()
{
// set content disposition header
if ( $this->contentDisposition !== null &&
( $this->contentDisposition instanceof ezcMailContentDispositionHeader ) )
{
$cdHeader = $this->contentDisposition;
$cd = "{$cdHeader->disposition}";
if ( $cdHeader->fileName !== null )
{
$fileInfo = null;
if ( $cdHeader->fileNameCharSet !== null )
{
$fileInfo .= "*0*=\"{$cdHeader->fileNameCharSet}";
if ( $cdHeader->fileNameLanguage !== null )
{
$fileInfo .= "'{$cdHeader->fileNameLanguage}'";
}
else
{
// RFC 2184: the single quote delimiters MUST be present
// even when one of the field values is omitted
$fileInfo .= "''";
}
}
if ( $fileInfo !== null )
{
$cd .= "; filename{$fileInfo}{$cdHeader->fileName}\"";
}
else
{
$cd .= "; filename=\"{$cdHeader->fileName}\"";
}
}
if ( $cdHeader->creationDate !== null )
{
$cd .= "; creation-date=\"{$cdHeader->creationDate}\"";
}
if ( $cdHeader->modificationDate !== null )
{
$cd .= "; modification-date=\"{$cdHeader->modificationDate}\"";
}
if ( $cdHeader->readDate !== null )
{
$cd .= "; read-date=\"{$cdHeader->readDate}\"";
}
if ( $cdHeader->size !== null )
{
$cd .= "; size={$cdHeader->size}";
}
foreach ( $cdHeader->additionalParameters as $addKey => $addValue )
{
$cd .="; {$addKey}=\"{$addValue}\"";
}
$this->setHeader( 'Content-Disposition', $cd );
}
// generate headers
$text = "";
foreach ( $this->headers->getCaseSensitiveArray() as $header => $value )
{
if ( is_array( $value ) )
{
$value = $value[0];
}
// here we encode every header, even the ones that we don't add to
// the header set directly. We do that so that transports sill see
// all the encoded headers which they then can use accordingly.
$charset = $this->getHeaderCharset( $header );
switch ( strtolower( $charset ) )
{
case 'us-ascii':
$value = ezcMailHeaderFolder::foldAny( $value );
break;
case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4':
case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8':
case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12':
case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16':
case 'windows-1250': case 'windows-1251': case 'windows-1252':
case 'utf-8':
if ( strpbrk( $value, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false )
{
$value = ezcMailHeaderFolder::foldAny( $value );
break;
}
// break intentionally missing
default:
$preferences = array(
'input-charset' => $charset,
'output-charset' => $charset,
'line-length' => ezcMailHeaderFolder::getLimit(),
'scheme' => 'Q',
'line-break-chars' => ezcMailTools::lineBreak()
);
$value = iconv_mime_encode( 'dummy', $value, $preferences );
$value = substr( $value, 7 ); // "dummy: " + 1
// just to keep compatibility with code which might read
// the headers after generateHeaders() has been called
$this->setHeader( $header, $value, $charset );
break;
}
if ( in_array( strtolower( $header ), $this->excludeHeaders ) === false )
{
$text .= "$header: $value" . ezcMailTools::lineBreak();
}
}
return $text;
} | php | public function generateHeaders()
{
// set content disposition header
if ( $this->contentDisposition !== null &&
( $this->contentDisposition instanceof ezcMailContentDispositionHeader ) )
{
$cdHeader = $this->contentDisposition;
$cd = "{$cdHeader->disposition}";
if ( $cdHeader->fileName !== null )
{
$fileInfo = null;
if ( $cdHeader->fileNameCharSet !== null )
{
$fileInfo .= "*0*=\"{$cdHeader->fileNameCharSet}";
if ( $cdHeader->fileNameLanguage !== null )
{
$fileInfo .= "'{$cdHeader->fileNameLanguage}'";
}
else
{
// RFC 2184: the single quote delimiters MUST be present
// even when one of the field values is omitted
$fileInfo .= "''";
}
}
if ( $fileInfo !== null )
{
$cd .= "; filename{$fileInfo}{$cdHeader->fileName}\"";
}
else
{
$cd .= "; filename=\"{$cdHeader->fileName}\"";
}
}
if ( $cdHeader->creationDate !== null )
{
$cd .= "; creation-date=\"{$cdHeader->creationDate}\"";
}
if ( $cdHeader->modificationDate !== null )
{
$cd .= "; modification-date=\"{$cdHeader->modificationDate}\"";
}
if ( $cdHeader->readDate !== null )
{
$cd .= "; read-date=\"{$cdHeader->readDate}\"";
}
if ( $cdHeader->size !== null )
{
$cd .= "; size={$cdHeader->size}";
}
foreach ( $cdHeader->additionalParameters as $addKey => $addValue )
{
$cd .="; {$addKey}=\"{$addValue}\"";
}
$this->setHeader( 'Content-Disposition', $cd );
}
// generate headers
$text = "";
foreach ( $this->headers->getCaseSensitiveArray() as $header => $value )
{
if ( is_array( $value ) )
{
$value = $value[0];
}
// here we encode every header, even the ones that we don't add to
// the header set directly. We do that so that transports sill see
// all the encoded headers which they then can use accordingly.
$charset = $this->getHeaderCharset( $header );
switch ( strtolower( $charset ) )
{
case 'us-ascii':
$value = ezcMailHeaderFolder::foldAny( $value );
break;
case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4':
case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8':
case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12':
case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16':
case 'windows-1250': case 'windows-1251': case 'windows-1252':
case 'utf-8':
if ( strpbrk( $value, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false )
{
$value = ezcMailHeaderFolder::foldAny( $value );
break;
}
// break intentionally missing
default:
$preferences = array(
'input-charset' => $charset,
'output-charset' => $charset,
'line-length' => ezcMailHeaderFolder::getLimit(),
'scheme' => 'Q',
'line-break-chars' => ezcMailTools::lineBreak()
);
$value = iconv_mime_encode( 'dummy', $value, $preferences );
$value = substr( $value, 7 ); // "dummy: " + 1
// just to keep compatibility with code which might read
// the headers after generateHeaders() has been called
$this->setHeader( $header, $value, $charset );
break;
}
if ( in_array( strtolower( $header ), $this->excludeHeaders ) === false )
{
$text .= "$header: $value" . ezcMailTools::lineBreak();
}
}
return $text;
} | [
"public",
"function",
"generateHeaders",
"(",
")",
"{",
"// set content disposition header",
"if",
"(",
"$",
"this",
"->",
"contentDisposition",
"!==",
"null",
"&&",
"(",
"$",
"this",
"->",
"contentDisposition",
"instanceof",
"ezcMailContentDispositionHeader",
")",
")",
"{",
"$",
"cdHeader",
"=",
"$",
"this",
"->",
"contentDisposition",
";",
"$",
"cd",
"=",
"\"{$cdHeader->disposition}\"",
";",
"if",
"(",
"$",
"cdHeader",
"->",
"fileName",
"!==",
"null",
")",
"{",
"$",
"fileInfo",
"=",
"null",
";",
"if",
"(",
"$",
"cdHeader",
"->",
"fileNameCharSet",
"!==",
"null",
")",
"{",
"$",
"fileInfo",
".=",
"\"*0*=\\\"{$cdHeader->fileNameCharSet}\"",
";",
"if",
"(",
"$",
"cdHeader",
"->",
"fileNameLanguage",
"!==",
"null",
")",
"{",
"$",
"fileInfo",
".=",
"\"'{$cdHeader->fileNameLanguage}'\"",
";",
"}",
"else",
"{",
"// RFC 2184: the single quote delimiters MUST be present",
"// even when one of the field values is omitted",
"$",
"fileInfo",
".=",
"\"''\"",
";",
"}",
"}",
"if",
"(",
"$",
"fileInfo",
"!==",
"null",
")",
"{",
"$",
"cd",
".=",
"\"; filename{$fileInfo}{$cdHeader->fileName}\\\"\"",
";",
"}",
"else",
"{",
"$",
"cd",
".=",
"\"; filename=\\\"{$cdHeader->fileName}\\\"\"",
";",
"}",
"}",
"if",
"(",
"$",
"cdHeader",
"->",
"creationDate",
"!==",
"null",
")",
"{",
"$",
"cd",
".=",
"\"; creation-date=\\\"{$cdHeader->creationDate}\\\"\"",
";",
"}",
"if",
"(",
"$",
"cdHeader",
"->",
"modificationDate",
"!==",
"null",
")",
"{",
"$",
"cd",
".=",
"\"; modification-date=\\\"{$cdHeader->modificationDate}\\\"\"",
";",
"}",
"if",
"(",
"$",
"cdHeader",
"->",
"readDate",
"!==",
"null",
")",
"{",
"$",
"cd",
".=",
"\"; read-date=\\\"{$cdHeader->readDate}\\\"\"",
";",
"}",
"if",
"(",
"$",
"cdHeader",
"->",
"size",
"!==",
"null",
")",
"{",
"$",
"cd",
".=",
"\"; size={$cdHeader->size}\"",
";",
"}",
"foreach",
"(",
"$",
"cdHeader",
"->",
"additionalParameters",
"as",
"$",
"addKey",
"=>",
"$",
"addValue",
")",
"{",
"$",
"cd",
".=",
"\"; {$addKey}=\\\"{$addValue}\\\"\"",
";",
"}",
"$",
"this",
"->",
"setHeader",
"(",
"'Content-Disposition'",
",",
"$",
"cd",
")",
";",
"}",
"// generate headers",
"$",
"text",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"->",
"getCaseSensitiveArray",
"(",
")",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"// here we encode every header, even the ones that we don't add to",
"// the header set directly. We do that so that transports sill see",
"// all the encoded headers which they then can use accordingly.",
"$",
"charset",
"=",
"$",
"this",
"->",
"getHeaderCharset",
"(",
"$",
"header",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"charset",
")",
")",
"{",
"case",
"'us-ascii'",
":",
"$",
"value",
"=",
"ezcMailHeaderFolder",
"::",
"foldAny",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'iso-8859-1'",
":",
"case",
"'iso-8859-2'",
":",
"case",
"'iso-8859-3'",
":",
"case",
"'iso-8859-4'",
":",
"case",
"'iso-8859-5'",
":",
"case",
"'iso-8859-6'",
":",
"case",
"'iso-8859-7'",
":",
"case",
"'iso-8859-8'",
":",
"case",
"'iso-8859-9'",
":",
"case",
"'iso-8859-10'",
":",
"case",
"'iso-8859-11'",
":",
"case",
"'iso-8859-12'",
":",
"case",
"'iso-8859-13'",
":",
"case",
"'iso-8859-14'",
":",
"case",
"'iso-8859-15'",
":",
"case",
"'iso-8859-16'",
":",
"case",
"'windows-1250'",
":",
"case",
"'windows-1251'",
":",
"case",
"'windows-1252'",
":",
"case",
"'utf-8'",
":",
"if",
"(",
"strpbrk",
"(",
"$",
"value",
",",
"\"\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff\"",
")",
"===",
"false",
")",
"{",
"$",
"value",
"=",
"ezcMailHeaderFolder",
"::",
"foldAny",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// break intentionally missing",
"default",
":",
"$",
"preferences",
"=",
"array",
"(",
"'input-charset'",
"=>",
"$",
"charset",
",",
"'output-charset'",
"=>",
"$",
"charset",
",",
"'line-length'",
"=>",
"ezcMailHeaderFolder",
"::",
"getLimit",
"(",
")",
",",
"'scheme'",
"=>",
"'Q'",
",",
"'line-break-chars'",
"=>",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
")",
";",
"$",
"value",
"=",
"iconv_mime_encode",
"(",
"'dummy'",
",",
"$",
"value",
",",
"$",
"preferences",
")",
";",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"7",
")",
";",
"// \"dummy: \" + 1",
"// just to keep compatibility with code which might read",
"// the headers after generateHeaders() has been called",
"$",
"this",
"->",
"setHeader",
"(",
"$",
"header",
",",
"$",
"value",
",",
"$",
"charset",
")",
";",
"break",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"header",
")",
",",
"$",
"this",
"->",
"excludeHeaders",
")",
"===",
"false",
")",
"{",
"$",
"text",
".=",
"\"$header: $value\"",
".",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"}",
"}",
"return",
"$",
"text",
";",
"}"
] | Returns the headers set for this part as a RFC 822 string.
Each header is separated by a line break.
This method does not add the required two lines of space
to separate the headers from the body of the part.
It also encodes the headers (with the 'Q' encoding) if the charset
associated with the header is different than 'us-ascii' or if it
contains characters not allowed in mail headers.
This function is called automatically by generate() and
subclasses can override this method if they wish to set additional
headers when the mail is generated.
@see setHeader()
@return string | [
"Returns",
"the",
"headers",
"set",
"for",
"this",
"part",
"as",
"a",
"RFC",
"822",
"string",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L278-L397 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php | ezcMailPart.appendExcludeHeaders | public function appendExcludeHeaders( array $headers )
{
$lowerCaseHeaders = array();
foreach ( $headers as $header )
{
$lowerCaseHeaders[] = strtolower( $header );
}
$this->excludeHeaders = array_merge( $this->excludeHeaders, $lowerCaseHeaders );
} | php | public function appendExcludeHeaders( array $headers )
{
$lowerCaseHeaders = array();
foreach ( $headers as $header )
{
$lowerCaseHeaders[] = strtolower( $header );
}
$this->excludeHeaders = array_merge( $this->excludeHeaders, $lowerCaseHeaders );
} | [
"public",
"function",
"appendExcludeHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"lowerCaseHeaders",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"$",
"lowerCaseHeaders",
"[",
"]",
"=",
"strtolower",
"(",
"$",
"header",
")",
";",
"}",
"$",
"this",
"->",
"excludeHeaders",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"excludeHeaders",
",",
"$",
"lowerCaseHeaders",
")",
";",
"}"
] | The array $headers will be excluded when the headers are generated.
@see generateHeaders()
@param array(string) $headers | [
"The",
"array",
"$headers",
"will",
"be",
"excluded",
"when",
"the",
"headers",
"are",
"generated",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L406-L414 |
InactiveProjects/limoncello-illuminate | app/Database/Factories/Runner.php | Runner.run | public function run()
{
foreach ($this->factoryClasses as $modelClass => $factoryClass) {
/** @var ModelFactory $instance */
$instance = new $factoryClass;
$this->registry->define($modelClass, $instance->getDefinition());
}
} | php | public function run()
{
foreach ($this->factoryClasses as $modelClass => $factoryClass) {
/** @var ModelFactory $instance */
$instance = new $factoryClass;
$this->registry->define($modelClass, $instance->getDefinition());
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"factoryClasses",
"as",
"$",
"modelClass",
"=>",
"$",
"factoryClass",
")",
"{",
"/** @var ModelFactory $instance */",
"$",
"instance",
"=",
"new",
"$",
"factoryClass",
";",
"$",
"this",
"->",
"registry",
"->",
"define",
"(",
"$",
"modelClass",
",",
"$",
"instance",
"->",
"getDefinition",
"(",
")",
")",
";",
"}",
"}"
] | @return void
@SuppressWarnings(PHPMD.ExcessiveMethodLength) | [
"@return",
"void"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Factories/Runner.php#L49-L56 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.deleteDirectory | public function deleteDirectory(string $path, bool $withFiles = false)
{
if( $path == '*' )
$this->abort('Can not delete "*", please specify folder or file.');
$files = glob($path . '/*');
foreach ( $files as $file ) {
if( is_file($file) && ! $withFiles ) return;
is_dir($file) ? $this->deleteDirectory($file, $withFiles) : unlink($file);
}
if( is_dir($path) )
try {
rmdir($path);
$this->info('Deleting folder: ' . $path);
} catch ( \Exception $e ) {
$this->comment('Can not delete ' . $path . ', it might contain hidden files, such as .gitignore');
}
} | php | public function deleteDirectory(string $path, bool $withFiles = false)
{
if( $path == '*' )
$this->abort('Can not delete "*", please specify folder or file.');
$files = glob($path . '/*');
foreach ( $files as $file ) {
if( is_file($file) && ! $withFiles ) return;
is_dir($file) ? $this->deleteDirectory($file, $withFiles) : unlink($file);
}
if( is_dir($path) )
try {
rmdir($path);
$this->info('Deleting folder: ' . $path);
} catch ( \Exception $e ) {
$this->comment('Can not delete ' . $path . ', it might contain hidden files, such as .gitignore');
}
} | [
"public",
"function",
"deleteDirectory",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"withFiles",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"path",
"==",
"'*'",
")",
"$",
"this",
"->",
"abort",
"(",
"'Can not delete \"*\", please specify folder or file.'",
")",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"path",
".",
"'/*'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
"&&",
"!",
"$",
"withFiles",
")",
"return",
";",
"is_dir",
"(",
"$",
"file",
")",
"?",
"$",
"this",
"->",
"deleteDirectory",
"(",
"$",
"file",
",",
"$",
"withFiles",
")",
":",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"try",
"{",
"rmdir",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Deleting folder: '",
".",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"'Can not delete '",
".",
"$",
"path",
".",
"', it might contain hidden files, such as .gitignore'",
")",
";",
"}",
"}"
] | Deleting existing folder
@param string $path
@param bool $withFiles | [
"Deleting",
"existing",
"folder"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L47-L65 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.createFileFromTemplate | public function createFileFromTemplate(array $configuration)
{
$destination = $configuration['destination'];
$templateDestination = $configuration['templateDestination'];
if( $destination[0] == '/' )
$preserveSlash = '/';
else
$preserveSlash = '';
if( ! isset($destination) )
$this->error('File creation failed, destination not set');
if( ! isset($templateDestination) )
$this->error('File creation failed, template destination not set');
$destination = str_replace('\\', '/', $destination);
$template = file_get_contents($templateDestination);
if( isset($configuration['content']) )
$template = replaceBrackets($template, $configuration['content']);
$directory = array_filter(explode('/', $destination));
array_pop($directory);
$directory = $preserveSlash . implode('/', $directory);
$this->createDirectory($directory);
file_put_contents($destination, $template);
$this->info('Created: ' . $destination);
} | php | public function createFileFromTemplate(array $configuration)
{
$destination = $configuration['destination'];
$templateDestination = $configuration['templateDestination'];
if( $destination[0] == '/' )
$preserveSlash = '/';
else
$preserveSlash = '';
if( ! isset($destination) )
$this->error('File creation failed, destination not set');
if( ! isset($templateDestination) )
$this->error('File creation failed, template destination not set');
$destination = str_replace('\\', '/', $destination);
$template = file_get_contents($templateDestination);
if( isset($configuration['content']) )
$template = replaceBrackets($template, $configuration['content']);
$directory = array_filter(explode('/', $destination));
array_pop($directory);
$directory = $preserveSlash . implode('/', $directory);
$this->createDirectory($directory);
file_put_contents($destination, $template);
$this->info('Created: ' . $destination);
} | [
"public",
"function",
"createFileFromTemplate",
"(",
"array",
"$",
"configuration",
")",
"{",
"$",
"destination",
"=",
"$",
"configuration",
"[",
"'destination'",
"]",
";",
"$",
"templateDestination",
"=",
"$",
"configuration",
"[",
"'templateDestination'",
"]",
";",
"if",
"(",
"$",
"destination",
"[",
"0",
"]",
"==",
"'/'",
")",
"$",
"preserveSlash",
"=",
"'/'",
";",
"else",
"$",
"preserveSlash",
"=",
"''",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"destination",
")",
")",
"$",
"this",
"->",
"error",
"(",
"'File creation failed, destination not set'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"templateDestination",
")",
")",
"$",
"this",
"->",
"error",
"(",
"'File creation failed, template destination not set'",
")",
";",
"$",
"destination",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"destination",
")",
";",
"$",
"template",
"=",
"file_get_contents",
"(",
"$",
"templateDestination",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"configuration",
"[",
"'content'",
"]",
")",
")",
"$",
"template",
"=",
"replaceBrackets",
"(",
"$",
"template",
",",
"$",
"configuration",
"[",
"'content'",
"]",
")",
";",
"$",
"directory",
"=",
"array_filter",
"(",
"explode",
"(",
"'/'",
",",
"$",
"destination",
")",
")",
";",
"array_pop",
"(",
"$",
"directory",
")",
";",
"$",
"directory",
"=",
"$",
"preserveSlash",
".",
"implode",
"(",
"'/'",
",",
"$",
"directory",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"directory",
")",
";",
"file_put_contents",
"(",
"$",
"destination",
",",
"$",
"template",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Created: '",
".",
"$",
"destination",
")",
";",
"}"
] | Replace file
@param $configuration
@internal param $destination
@internal param $templateDestination
@internal param array $content | [
"Replace",
"file"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L74-L105 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.getToReplace | public function getToReplace(array $ignoreSymbols): array
{
if( empty($ignoreSymbols) )
return $this->toReplace;
return array_diff($this->toReplace, $ignoreSymbols);
} | php | public function getToReplace(array $ignoreSymbols): array
{
if( empty($ignoreSymbols) )
return $this->toReplace;
return array_diff($this->toReplace, $ignoreSymbols);
} | [
"public",
"function",
"getToReplace",
"(",
"array",
"$",
"ignoreSymbols",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"ignoreSymbols",
")",
")",
"return",
"$",
"this",
"->",
"toReplace",
";",
"return",
"array_diff",
"(",
"$",
"this",
"->",
"toReplace",
",",
"$",
"ignoreSymbols",
")",
";",
"}"
] | Get replaceable symbols
@param array $ignoreSymbols
@return array | [
"Get",
"replaceable",
"symbols"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L113-L119 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.stringWithUnderscore | protected function stringWithUnderscore(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '_', trim($string, '/'));
} | php | protected function stringWithUnderscore(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '_', trim($string, '/'));
} | [
"protected",
"function",
"stringWithUnderscore",
"(",
"string",
"$",
"string",
",",
"array",
"$",
"ignoreToReplace",
"=",
"[",
"]",
")",
"{",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"getToReplace",
"(",
"$",
"ignoreToReplace",
")",
",",
"'_'",
",",
"trim",
"(",
"$",
"string",
",",
"'/'",
")",
")",
";",
"}"
] | Get string in underscore
@param string $string
@param array $ignoreToReplace
@return mixed | [
"Get",
"string",
"in",
"underscore"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L151-L154 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.stringWithDash | protected function stringWithDash(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '-', trim($string, '/'));
} | php | protected function stringWithDash(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '-', trim($string, '/'));
} | [
"protected",
"function",
"stringWithDash",
"(",
"string",
"$",
"string",
",",
"array",
"$",
"ignoreToReplace",
"=",
"[",
"]",
")",
"{",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"getToReplace",
"(",
"$",
"ignoreToReplace",
")",
",",
"'-'",
",",
"trim",
"(",
"$",
"string",
",",
"'/'",
")",
")",
";",
"}"
] | Get string in dash
@param string $string
@param array $ignoreToReplace
@return mixed | [
"Get",
"string",
"in",
"dash"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L163-L166 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.stringOnly | protected function stringOnly(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '', trim($string, '/'));
} | php | protected function stringOnly(string $string, array $ignoreToReplace = [])
{
return str_replace($this->getToReplace($ignoreToReplace), '', trim($string, '/'));
} | [
"protected",
"function",
"stringOnly",
"(",
"string",
"$",
"string",
",",
"array",
"$",
"ignoreToReplace",
"=",
"[",
"]",
")",
"{",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"getToReplace",
"(",
"$",
"ignoreToReplace",
")",
",",
"''",
",",
"trim",
"(",
"$",
"string",
",",
"'/'",
")",
")",
";",
"}"
] | Remove all items from string
@param string $string
@param array $ignoreToReplace
@return mixed | [
"Remove",
"all",
"items",
"from",
"string"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L175-L178 |
interactivesolutions/honeycomb-core | src/commands/HCCommand.php | HCCommand.getConfigFiles | protected function getConfigFiles()
{
$file = new Filesystem();
$projectFiles = $file->glob(app_path('honeycomb/config.json'));
$packageFiles = $file->glob(__DIR__ . '/../../../../*/*/*/*/honeycomb/config.json');
return array_merge($packageFiles, $projectFiles);
} | php | protected function getConfigFiles()
{
$file = new Filesystem();
$projectFiles = $file->glob(app_path('honeycomb/config.json'));
$packageFiles = $file->glob(__DIR__ . '/../../../../*/*/*/*/honeycomb/config.json');
return array_merge($packageFiles, $projectFiles);
} | [
"protected",
"function",
"getConfigFiles",
"(",
")",
"{",
"$",
"file",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"projectFiles",
"=",
"$",
"file",
"->",
"glob",
"(",
"app_path",
"(",
"'honeycomb/config.json'",
")",
")",
";",
"$",
"packageFiles",
"=",
"$",
"file",
"->",
"glob",
"(",
"__DIR__",
".",
"'/../../../../*/*/*/*/honeycomb/config.json'",
")",
";",
"return",
"array_merge",
"(",
"$",
"packageFiles",
",",
"$",
"projectFiles",
")",
";",
"}"
] | Scan folders for honeycomb configuration files
@return array | [
"Scan",
"folders",
"for",
"honeycomb",
"configuration",
"files"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L205-L213 |
oroinc/OroLayoutComponent | Block/Type/Options.php | Options.get | public function get($offset, $shouldBeEvaluated = true)
{
if (array_key_exists($offset, $this->options)) {
$option = $this->options[$offset];
if ($shouldBeEvaluated && $option instanceof Expression) {
throw new \InvalidArgumentException(
sprintf(
'Option "%s" value should be evaluated. It is currently '.
'an ExpressionLanguage component object.',
$offset
)
);
}
return $option;
}
throw new \OutOfBoundsException(sprintf('Argument "%s" not found.', $offset));
} | php | public function get($offset, $shouldBeEvaluated = true)
{
if (array_key_exists($offset, $this->options)) {
$option = $this->options[$offset];
if ($shouldBeEvaluated && $option instanceof Expression) {
throw new \InvalidArgumentException(
sprintf(
'Option "%s" value should be evaluated. It is currently '.
'an ExpressionLanguage component object.',
$offset
)
);
}
return $option;
}
throw new \OutOfBoundsException(sprintf('Argument "%s" not found.', $offset));
} | [
"public",
"function",
"get",
"(",
"$",
"offset",
",",
"$",
"shouldBeEvaluated",
"=",
"true",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"offset",
"]",
";",
"if",
"(",
"$",
"shouldBeEvaluated",
"&&",
"$",
"option",
"instanceof",
"Expression",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Option \"%s\" value should be evaluated. It is currently '",
".",
"'an ExpressionLanguage component object.'",
",",
"$",
"offset",
")",
")",
";",
"}",
"return",
"$",
"option",
";",
"}",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'Argument \"%s\" not found.'",
",",
"$",
"offset",
")",
")",
";",
"}"
] | @param string $offset
@param boolean $shouldBeEvaluated
@return mixed
@throws \OutOfBoundsException | [
"@param",
"string",
"$offset",
"@param",
"boolean",
"$shouldBeEvaluated"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Block/Type/Options.php#L28-L45 |
oroinc/OroLayoutComponent | Block/Type/Options.php | Options.offsetSet | public function offsetSet($offset, $value)
{
if (is_array($value)) {
$value = new self($value);
}
if ($offset === null) {
$this->options[] = $value;
} else {
$this->options[$offset] = $value;
}
} | php | public function offsetSet($offset, $value)
{
if (is_array($value)) {
$value = new self($value);
}
if ($offset === null) {
$this->options[] = $value;
} else {
$this->options[$offset] = $value;
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"new",
"self",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"offset",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Block/Type/Options.php#L66-L76 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/EntityBase4.php | EntityBase4.getUseLines | public function getUseLines()
{
$lines = [];
$lines = array_merge($lines, $this->getUseLinesSymfony2Part());
$lines[] = 'use Doctrine\ORM\Mapping as ORM;';
$useArrayCollection = false;
foreach ($this->getEntity()->getAttributes() as $attr) {
if (null !== $attr->getForeign() && 'array' === $attr->getType()) {
$useArrayCollection = true;
break;
}
}
if ($useArrayCollection) {
$lines[] = 'use Doctrine\\Common\\Collections\\ArrayCollection;';
}
$lines = array_merge($lines, $this->getUseLinesUserAdditionsPart());
return $lines;
} | php | public function getUseLines()
{
$lines = [];
$lines = array_merge($lines, $this->getUseLinesSymfony2Part());
$lines[] = 'use Doctrine\ORM\Mapping as ORM;';
$useArrayCollection = false;
foreach ($this->getEntity()->getAttributes() as $attr) {
if (null !== $attr->getForeign() && 'array' === $attr->getType()) {
$useArrayCollection = true;
break;
}
}
if ($useArrayCollection) {
$lines[] = 'use Doctrine\\Common\\Collections\\ArrayCollection;';
}
$lines = array_merge($lines, $this->getUseLinesUserAdditionsPart());
return $lines;
} | [
"public",
"function",
"getUseLines",
"(",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"=",
"array_merge",
"(",
"$",
"lines",
",",
"$",
"this",
"->",
"getUseLinesSymfony2Part",
"(",
")",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"'use Doctrine\\ORM\\Mapping as ORM;'",
";",
"$",
"useArrayCollection",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attr",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"attr",
"->",
"getForeign",
"(",
")",
"&&",
"'array'",
"===",
"$",
"attr",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"useArrayCollection",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"useArrayCollection",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"'use Doctrine\\\\Common\\\\Collections\\\\ArrayCollection;'",
";",
"}",
"$",
"lines",
"=",
"array_merge",
"(",
"$",
"lines",
",",
"$",
"this",
"->",
"getUseLinesUserAdditionsPart",
"(",
")",
")",
";",
"return",
"$",
"lines",
";",
"}"
] | <user-additions part="otherMethods"> | [
"<user",
"-",
"additions",
"part",
"=",
"otherMethods",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/EntityBase4.php#L42-L67 |
vuer/token | src/Providers/TokenServiceProvider.php | TokenServiceProvider.boot | public function boot()
{
if (!class_exists('CreateTokensTable')) {
// Publish the migration
$timestamp = date('Y_m_d_His', time());
$this->publishes([
__DIR__ . '/../../database/migrations/create_tokens_table.php.stub' => database_path('migrations/' . $timestamp . '_create_tokens_table.php'),
], 'migrations');
}
} | php | public function boot()
{
if (!class_exists('CreateTokensTable')) {
// Publish the migration
$timestamp = date('Y_m_d_His', time());
$this->publishes([
__DIR__ . '/../../database/migrations/create_tokens_table.php.stub' => database_path('migrations/' . $timestamp . '_create_tokens_table.php'),
], 'migrations');
}
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'CreateTokensTable'",
")",
")",
"{",
"// Publish the migration",
"$",
"timestamp",
"=",
"date",
"(",
"'Y_m_d_His'",
",",
"time",
"(",
")",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../../database/migrations/create_tokens_table.php.stub'",
"=>",
"database_path",
"(",
"'migrations/'",
".",
"$",
"timestamp",
".",
"'_create_tokens_table.php'",
")",
",",
"]",
",",
"'migrations'",
")",
";",
"}",
"}"
] | Bootstrap the application services.
@return void | [
"Bootstrap",
"the",
"application",
"services",
"."
] | train | https://github.com/vuer/token/blob/096ba1820c850d5e29062a304bdc399789388714/src/Providers/TokenServiceProvider.php#L14-L23 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iShouldGetALogEntry | public function iShouldGetALogEntry($string)
{
$found = false;
foreach (explode("\n", $this->getOutput()) as $line) {
if (trim($line) == $string) {
$found = true;
}
}
if (!$found) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | php | public function iShouldGetALogEntry($string)
{
$found = false;
foreach (explode("\n", $this->getOutput()) as $line) {
if (trim($line) == $string) {
$found = true;
}
}
if (!$found) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | [
"public",
"function",
"iShouldGetALogEntry",
"(",
"$",
"string",
")",
"{",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"line",
")",
"==",
"$",
"string",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Actual output is:\\n\"",
".",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
";",
"}",
"}"
] | Verifies whether one of the log entries is the same as the given.
Please note that this method exactly checks the given except for leading
and trailing spaces and control characters; those are stripped first.
@param string $string
@Then /^I should get a log entry "([^"]*)"$/
@throws \Exception if the condition is not fulfilled
@return void | [
"Verifies",
"whether",
"one",
"of",
"the",
"log",
"entries",
"is",
"the",
"same",
"as",
"the",
"given",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L84-L98 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iShouldGetALogEntryContaining | public function iShouldGetALogEntryContaining($string)
{
$found = false;
foreach (explode("\n", $this->getOutput()) as $line) {
if (strpos(trim($line), $string) !== false) {
$found = true;
}
}
if (!$found) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | php | public function iShouldGetALogEntryContaining($string)
{
$found = false;
foreach (explode("\n", $this->getOutput()) as $line) {
if (strpos(trim($line), $string) !== false) {
$found = true;
}
}
if (!$found) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | [
"public",
"function",
"iShouldGetALogEntryContaining",
"(",
"$",
"string",
")",
"{",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"trim",
"(",
"$",
"line",
")",
",",
"$",
"string",
")",
"!==",
"false",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Actual output is:\\n\"",
".",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
";",
"}",
"}"
] | Verifies whether a log entry contains the given substring.
@param string $string
@Then /^I should get a log entry containing "([^"]*)"$/
@throws \Exception if the condition is not fulfilled
@return void | [
"Verifies",
"whether",
"a",
"log",
"entry",
"contains",
"the",
"given",
"substring",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L138-L152 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iRunPhpdoc | public function iRunPhpdoc($argumentsString = '')
{
$argumentsString .= ' --template=xml';
$argumentsString = strtr($argumentsString, array('\'' => '"'));
// the app is always run in debug mode to catch debug information and collect the AST that is written to disk
$this->process->setCommandLine(
sprintf('%s %s %s', 'php', escapeshellarg($this->binaryPath), $argumentsString . ' -vvv')
);
$this->process->start();
$this->process->wait();
} | php | public function iRunPhpdoc($argumentsString = '')
{
$argumentsString .= ' --template=xml';
$argumentsString = strtr($argumentsString, array('\'' => '"'));
// the app is always run in debug mode to catch debug information and collect the AST that is written to disk
$this->process->setCommandLine(
sprintf('%s %s %s', 'php', escapeshellarg($this->binaryPath), $argumentsString . ' -vvv')
);
$this->process->start();
$this->process->wait();
} | [
"public",
"function",
"iRunPhpdoc",
"(",
"$",
"argumentsString",
"=",
"''",
")",
"{",
"$",
"argumentsString",
".=",
"' --template=xml'",
";",
"$",
"argumentsString",
"=",
"strtr",
"(",
"$",
"argumentsString",
",",
"array",
"(",
"'\\''",
"=>",
"'\"'",
")",
")",
";",
"// the app is always run in debug mode to catch debug information and collect the AST that is written to disk",
"$",
"this",
"->",
"process",
"->",
"setCommandLine",
"(",
"sprintf",
"(",
"'%s %s %s'",
",",
"'php'",
",",
"escapeshellarg",
"(",
"$",
"this",
"->",
"binaryPath",
")",
",",
"$",
"argumentsString",
".",
"' -vvv'",
")",
")",
";",
"$",
"this",
"->",
"process",
"->",
"start",
"(",
")",
";",
"$",
"this",
"->",
"process",
"->",
"wait",
"(",
")",
";",
"}"
] | @When /^I run "phpdoc(?: ((?:\"|[^"])*))?"$/
@param string $argumentsString | [
"@When",
"/",
"^I",
"run",
"phpdoc",
"(",
"?",
":",
"((",
"?",
":",
"\\",
"|",
"[",
"^",
"]",
")",
"*",
"))",
"?",
"$",
"/"
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L235-L246 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iRunPhpDocumentorAgainstTheFile | public function iRunPhpDocumentorAgainstTheFile($file_path)
{
$tmp = self::getTmpFolder();
$fullPath = __DIR__ . '/../../' . $file_path;
$this->iRunPhpdoc("-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force");
} | php | public function iRunPhpDocumentorAgainstTheFile($file_path)
{
$tmp = self::getTmpFolder();
$fullPath = __DIR__ . '/../../' . $file_path;
$this->iRunPhpdoc("-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force");
} | [
"public",
"function",
"iRunPhpDocumentorAgainstTheFile",
"(",
"$",
"file_path",
")",
"{",
"$",
"tmp",
"=",
"self",
"::",
"getTmpFolder",
"(",
")",
";",
"$",
"fullPath",
"=",
"__DIR__",
".",
"'/../../'",
".",
"$",
"file_path",
";",
"$",
"this",
"->",
"iRunPhpdoc",
"(",
"\"-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force\"",
")",
";",
"}"
] | Runs phpDocumentor with only the file that is provided in this command.
The configuration is explicitly disabled to prevent tainting via
the configuration.
@param string $file_path
@When /^I run phpDocumentor against the file "([^"]*)"$/
@return void | [
"Runs",
"phpDocumentor",
"with",
"only",
"the",
"file",
"that",
"is",
"provided",
"in",
"this",
"command",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L276-L281 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iRunPhpDocumentorWith | public function iRunPhpDocumentorWith(PyStringNode $code, $extraParameters = '')
{
$tmp = self::getTmpFolder();
$file = tempnam($tmp, 'pdb');
file_put_contents($file, $code);
$this->iRunPhpdoc("-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters");
unlink($file);
} | php | public function iRunPhpDocumentorWith(PyStringNode $code, $extraParameters = '')
{
$tmp = self::getTmpFolder();
$file = tempnam($tmp, 'pdb');
file_put_contents($file, $code);
$this->iRunPhpdoc("-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters");
unlink($file);
} | [
"public",
"function",
"iRunPhpDocumentorWith",
"(",
"PyStringNode",
"$",
"code",
",",
"$",
"extraParameters",
"=",
"''",
")",
"{",
"$",
"tmp",
"=",
"self",
"::",
"getTmpFolder",
"(",
")",
";",
"$",
"file",
"=",
"tempnam",
"(",
"$",
"tmp",
",",
"'pdb'",
")",
";",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"code",
")",
";",
"$",
"this",
"->",
"iRunPhpdoc",
"(",
"\"-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters\"",
")",
";",
"unlink",
"(",
"$",
"file",
")",
";",
"}"
] | Parses the given PHP code with phpDocumentor.
@param PyStringNode $code
@When /^I run phpDocumentor with:$/
@return void | [
"Parses",
"the",
"given",
"PHP",
"code",
"with",
"phpDocumentor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L292-L299 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.iShouldGet | public function iShouldGet(PyStringNode $string)
{
if ($this->getOutput() != trim($string->getRaw())) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | php | public function iShouldGet(PyStringNode $string)
{
if ($this->getOutput() != trim($string->getRaw())) {
throw new \Exception(
"Actual output is:\n" . $this->getOutput()
);
}
} | [
"public",
"function",
"iShouldGet",
"(",
"PyStringNode",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getOutput",
"(",
")",
"!=",
"trim",
"(",
"$",
"string",
"->",
"getRaw",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Actual output is:\\n\"",
".",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
";",
"}",
"}"
] | Verifies whether the output of an iRun When is equal to the given.
@param PyStringNode $string
@Then /^I should get:$/
@throws \Exception if the condition is not fulfilled
@return void | [
"Verifies",
"whether",
"the",
"output",
"of",
"an",
"iRun",
"When",
"is",
"equal",
"to",
"the",
"given",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L355-L362 |
heidelpay/PhpDoc | features/bootstrap/FeatureContext.php | FeatureContext.theExitCodeShouldBeZero | public function theExitCodeShouldBeZero()
{
if ($this->getReturnCode() != 0) {
throw new \Exception(
'Return code was ' . $this->getReturnCode() . ' with output '
.$this->getOutput() . $this->process->getOutput()
);
}
} | php | public function theExitCodeShouldBeZero()
{
if ($this->getReturnCode() != 0) {
throw new \Exception(
'Return code was ' . $this->getReturnCode() . ' with output '
.$this->getOutput() . $this->process->getOutput()
);
}
} | [
"public",
"function",
"theExitCodeShouldBeZero",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getReturnCode",
"(",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Return code was '",
".",
"$",
"this",
"->",
"getReturnCode",
"(",
")",
".",
"' with output '",
".",
"$",
"this",
"->",
"getOutput",
"(",
")",
".",
"$",
"this",
"->",
"process",
"->",
"getOutput",
"(",
")",
")",
";",
"}",
"}"
] | Verifies whether the return code was 0 and thus execution was a success.
@Then /^the exit code should be zero$/
@throws \Exception if the condition is not fulfilled
@return void | [
"Verifies",
"whether",
"the",
"return",
"code",
"was",
"0",
"and",
"thus",
"execution",
"was",
"a",
"success",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L373-L381 |
hametuha/wpametu | src/WPametu/UI/Field/TokenInputPost.php | TokenInputPost.get_data | protected function get_data( \WP_Post $post ){
switch( $this->field ){
case 'post_meta':
return get_posts([
'posts__in' => explode(',', get_post_meta($post->ID, $this->name, true)),
'post_type' => $this->post_type,
'author' => $post->post_author,
'suppress_filters' => false,
]);
break;
default:
if( $post->post_parent ){
return get_posts([
'p' => $post->post_parent,
'post_type' => $this->post_type,
'author' => $post->post_author,
'suppress_filters' => false,
'post_status' => array('publish', 'future', 'pending', 'draft', 'private')
]);
}else{
return [];
}
break;
}
} | php | protected function get_data( \WP_Post $post ){
switch( $this->field ){
case 'post_meta':
return get_posts([
'posts__in' => explode(',', get_post_meta($post->ID, $this->name, true)),
'post_type' => $this->post_type,
'author' => $post->post_author,
'suppress_filters' => false,
]);
break;
default:
if( $post->post_parent ){
return get_posts([
'p' => $post->post_parent,
'post_type' => $this->post_type,
'author' => $post->post_author,
'suppress_filters' => false,
'post_status' => array('publish', 'future', 'pending', 'draft', 'private')
]);
}else{
return [];
}
break;
}
} | [
"protected",
"function",
"get_data",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"field",
")",
"{",
"case",
"'post_meta'",
":",
"return",
"get_posts",
"(",
"[",
"'posts__in'",
"=>",
"explode",
"(",
"','",
",",
"get_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"$",
"this",
"->",
"name",
",",
"true",
")",
")",
",",
"'post_type'",
"=>",
"$",
"this",
"->",
"post_type",
",",
"'author'",
"=>",
"$",
"post",
"->",
"post_author",
",",
"'suppress_filters'",
"=>",
"false",
",",
"]",
")",
";",
"break",
";",
"default",
":",
"if",
"(",
"$",
"post",
"->",
"post_parent",
")",
"{",
"return",
"get_posts",
"(",
"[",
"'p'",
"=>",
"$",
"post",
"->",
"post_parent",
",",
"'post_type'",
"=>",
"$",
"this",
"->",
"post_type",
",",
"'author'",
"=>",
"$",
"post",
"->",
"post_author",
",",
"'suppress_filters'",
"=>",
"false",
",",
"'post_status'",
"=>",
"array",
"(",
"'publish'",
",",
"'future'",
",",
"'pending'",
",",
"'draft'",
",",
"'private'",
")",
"]",
")",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"break",
";",
"}",
"}"
] | Get saved data
@param \WP_Post $post
@return array|mixed | [
"Get",
"saved",
"data"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L34-L58 |
hametuha/wpametu | src/WPametu/UI/Field/TokenInputPost.php | TokenInputPost.save | protected function save($value, \WP_Post $post = null){
switch( $this->field ){
case 'post_meta':
update_post_meta($post->ID, $this->name, $value);
break;
default:
$post_id = intval($value);
// TODO: Reconsider updating post row logic
/** @var \wpdb $wpdb */
global $wpdb;
$wpdb->update($wpdb->posts, ['post_parent' => $post_id], ['ID' => $post->ID], ['%d'], ['%d']);
clean_post_cache($post);
break;
}
} | php | protected function save($value, \WP_Post $post = null){
switch( $this->field ){
case 'post_meta':
update_post_meta($post->ID, $this->name, $value);
break;
default:
$post_id = intval($value);
// TODO: Reconsider updating post row logic
/** @var \wpdb $wpdb */
global $wpdb;
$wpdb->update($wpdb->posts, ['post_parent' => $post_id], ['ID' => $post->ID], ['%d'], ['%d']);
clean_post_cache($post);
break;
}
} | [
"protected",
"function",
"save",
"(",
"$",
"value",
",",
"\\",
"WP_Post",
"$",
"post",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"field",
")",
"{",
"case",
"'post_meta'",
":",
"update_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"$",
"this",
"->",
"name",
",",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"$",
"post_id",
"=",
"intval",
"(",
"$",
"value",
")",
";",
"// TODO: Reconsider updating post row logic",
"/** @var \\wpdb $wpdb */",
"global",
"$",
"wpdb",
";",
"$",
"wpdb",
"->",
"update",
"(",
"$",
"wpdb",
"->",
"posts",
",",
"[",
"'post_parent'",
"=>",
"$",
"post_id",
"]",
",",
"[",
"'ID'",
"=>",
"$",
"post",
"->",
"ID",
"]",
",",
"[",
"'%d'",
"]",
",",
"[",
"'%d'",
"]",
")",
";",
"clean_post_cache",
"(",
"$",
"post",
")",
";",
"break",
";",
"}",
"}"
] | Save post data
@param mixed $value
@param \WP_Post $post | [
"Save",
"post",
"data"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L67-L81 |
hametuha/wpametu | src/WPametu/UI/Field/TokenInputPost.php | TokenInputPost.get_required | protected function get_required( \WP_Post $post = null){
if( current_user_can('edit_posts') ){
$url = admin_url('post-new.php?post_type='.$this->post_type);
$post_type_obj = get_post_type_object($this->post_type);
$tip = esc_html(sprintf($this->__('Add new %s'), $post_type_obj->labels->name));
$input = <<<HTML
<a href="{$url}" data-tooltip-title="{$tip}"><i class="dashicons dashicons-plus-alt"></i></a>
HTML;
return $input.parent::get_required($post);
}else{
return parent::get_required($post);
}
} | php | protected function get_required( \WP_Post $post = null){
if( current_user_can('edit_posts') ){
$url = admin_url('post-new.php?post_type='.$this->post_type);
$post_type_obj = get_post_type_object($this->post_type);
$tip = esc_html(sprintf($this->__('Add new %s'), $post_type_obj->labels->name));
$input = <<<HTML
<a href="{$url}" data-tooltip-title="{$tip}"><i class="dashicons dashicons-plus-alt"></i></a>
HTML;
return $input.parent::get_required($post);
}else{
return parent::get_required($post);
}
} | [
"protected",
"function",
"get_required",
"(",
"\\",
"WP_Post",
"$",
"post",
"=",
"null",
")",
"{",
"if",
"(",
"current_user_can",
"(",
"'edit_posts'",
")",
")",
"{",
"$",
"url",
"=",
"admin_url",
"(",
"'post-new.php?post_type='",
".",
"$",
"this",
"->",
"post_type",
")",
";",
"$",
"post_type_obj",
"=",
"get_post_type_object",
"(",
"$",
"this",
"->",
"post_type",
")",
";",
"$",
"tip",
"=",
"esc_html",
"(",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add new %s'",
")",
",",
"$",
"post_type_obj",
"->",
"labels",
"->",
"name",
")",
")",
";",
"$",
"input",
"=",
" <<<HTML\n<a href=\"{$url}\" data-tooltip-title=\"{$tip}\"><i class=\"dashicons dashicons-plus-alt\"></i></a>\nHTML",
";",
"return",
"$",
"input",
".",
"parent",
"::",
"get_required",
"(",
"$",
"post",
")",
";",
"}",
"else",
"{",
"return",
"parent",
"::",
"get_required",
"(",
"$",
"post",
")",
";",
"}",
"}"
] | Add button before requried
@param \WP_Post $post
@return string | [
"Add",
"button",
"before",
"requried"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L89-L102 |
hametuha/wpametu | src/WPametu/UI/Field/TokenInputPost.php | TokenInputPost.get_prepopulates | protected function get_prepopulates($data){
$json = [];
foreach( $data as $post ){
$json[] = [
'id' => $post->ID,
'name' => $post->post_title,
];
}
return $json;
} | php | protected function get_prepopulates($data){
$json = [];
foreach( $data as $post ){
$json[] = [
'id' => $post->ID,
'name' => $post->post_title,
];
}
return $json;
} | [
"protected",
"function",
"get_prepopulates",
"(",
"$",
"data",
")",
"{",
"$",
"json",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"post",
")",
"{",
"$",
"json",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"post",
"->",
"ID",
",",
"'name'",
"=>",
"$",
"post",
"->",
"post_title",
",",
"]",
";",
"}",
"return",
"$",
"json",
";",
"}"
] | Get prepopulated data
@param array $data
@return array | [
"Get",
"prepopulated",
"data"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L110-L119 |
eghojansu/moe | src/tools/Web.php | Web.mime | function mime($file) {
if (preg_match('/\w+$/',$file,$ext)) {
$map=array(
'au'=>'audio/basic',
'avi'=>'video/avi',
'bmp'=>'image/bmp',
'bz2'=>'application/x-bzip2',
'css'=>'text/css',
'dtd'=>'application/xml-dtd',
'doc'=>'application/msword',
'gif'=>'image/gif',
'gz'=>'application/x-gzip',
'hqx'=>'application/mac-binhex40',
'html?'=>'text/html',
'jar'=>'application/java-archive',
'jpe?g'=>'image/jpeg',
'js'=>'application/x-javascript',
'midi'=>'audio/x-midi',
'mp3'=>'audio/mpeg',
'mpe?g'=>'video/mpeg',
'ogg'=>'audio/vorbis',
'pdf'=>'application/pdf',
'png'=>'image/png',
'ppt'=>'application/vnd.ms-powerpoint',
'ps'=>'application/postscript',
'qt'=>'video/quicktime',
'ram?'=>'audio/x-pn-realaudio',
'rdf'=>'application/rdf',
'rtf'=>'application/rtf',
'sgml?'=>'text/sgml',
'sit'=>'application/x-stuffit',
'svg'=>'image/svg+xml',
'swf'=>'application/x-shockwave-flash',
'tgz'=>'application/x-tar',
'tiff'=>'image/tiff',
'txt'=>'text/plain',
'wav'=>'audio/wav',
'xls'=>'application/vnd.ms-excel',
'xml'=>'application/xml',
'zip'=>'application/x-zip-compressed'
);
foreach ($map as $key=>$val)
if (preg_match('/'.$key.'/',strtolower($ext[0])))
return $val;
}
return 'application/octet-stream';
} | php | function mime($file) {
if (preg_match('/\w+$/',$file,$ext)) {
$map=array(
'au'=>'audio/basic',
'avi'=>'video/avi',
'bmp'=>'image/bmp',
'bz2'=>'application/x-bzip2',
'css'=>'text/css',
'dtd'=>'application/xml-dtd',
'doc'=>'application/msword',
'gif'=>'image/gif',
'gz'=>'application/x-gzip',
'hqx'=>'application/mac-binhex40',
'html?'=>'text/html',
'jar'=>'application/java-archive',
'jpe?g'=>'image/jpeg',
'js'=>'application/x-javascript',
'midi'=>'audio/x-midi',
'mp3'=>'audio/mpeg',
'mpe?g'=>'video/mpeg',
'ogg'=>'audio/vorbis',
'pdf'=>'application/pdf',
'png'=>'image/png',
'ppt'=>'application/vnd.ms-powerpoint',
'ps'=>'application/postscript',
'qt'=>'video/quicktime',
'ram?'=>'audio/x-pn-realaudio',
'rdf'=>'application/rdf',
'rtf'=>'application/rtf',
'sgml?'=>'text/sgml',
'sit'=>'application/x-stuffit',
'svg'=>'image/svg+xml',
'swf'=>'application/x-shockwave-flash',
'tgz'=>'application/x-tar',
'tiff'=>'image/tiff',
'txt'=>'text/plain',
'wav'=>'audio/wav',
'xls'=>'application/vnd.ms-excel',
'xml'=>'application/xml',
'zip'=>'application/x-zip-compressed'
);
foreach ($map as $key=>$val)
if (preg_match('/'.$key.'/',strtolower($ext[0])))
return $val;
}
return 'application/octet-stream';
} | [
"function",
"mime",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\w+$/'",
",",
"$",
"file",
",",
"$",
"ext",
")",
")",
"{",
"$",
"map",
"=",
"array",
"(",
"'au'",
"=>",
"'audio/basic'",
",",
"'avi'",
"=>",
"'video/avi'",
",",
"'bmp'",
"=>",
"'image/bmp'",
",",
"'bz2'",
"=>",
"'application/x-bzip2'",
",",
"'css'",
"=>",
"'text/css'",
",",
"'dtd'",
"=>",
"'application/xml-dtd'",
",",
"'doc'",
"=>",
"'application/msword'",
",",
"'gif'",
"=>",
"'image/gif'",
",",
"'gz'",
"=>",
"'application/x-gzip'",
",",
"'hqx'",
"=>",
"'application/mac-binhex40'",
",",
"'html?'",
"=>",
"'text/html'",
",",
"'jar'",
"=>",
"'application/java-archive'",
",",
"'jpe?g'",
"=>",
"'image/jpeg'",
",",
"'js'",
"=>",
"'application/x-javascript'",
",",
"'midi'",
"=>",
"'audio/x-midi'",
",",
"'mp3'",
"=>",
"'audio/mpeg'",
",",
"'mpe?g'",
"=>",
"'video/mpeg'",
",",
"'ogg'",
"=>",
"'audio/vorbis'",
",",
"'pdf'",
"=>",
"'application/pdf'",
",",
"'png'",
"=>",
"'image/png'",
",",
"'ppt'",
"=>",
"'application/vnd.ms-powerpoint'",
",",
"'ps'",
"=>",
"'application/postscript'",
",",
"'qt'",
"=>",
"'video/quicktime'",
",",
"'ram?'",
"=>",
"'audio/x-pn-realaudio'",
",",
"'rdf'",
"=>",
"'application/rdf'",
",",
"'rtf'",
"=>",
"'application/rtf'",
",",
"'sgml?'",
"=>",
"'text/sgml'",
",",
"'sit'",
"=>",
"'application/x-stuffit'",
",",
"'svg'",
"=>",
"'image/svg+xml'",
",",
"'swf'",
"=>",
"'application/x-shockwave-flash'",
",",
"'tgz'",
"=>",
"'application/x-tar'",
",",
"'tiff'",
"=>",
"'image/tiff'",
",",
"'txt'",
"=>",
"'text/plain'",
",",
"'wav'",
"=>",
"'audio/wav'",
",",
"'xls'",
"=>",
"'application/vnd.ms-excel'",
",",
"'xml'",
"=>",
"'application/xml'",
",",
"'zip'",
"=>",
"'application/x-zip-compressed'",
")",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"if",
"(",
"preg_match",
"(",
"'/'",
".",
"$",
"key",
".",
"'/'",
",",
"strtolower",
"(",
"$",
"ext",
"[",
"0",
"]",
")",
")",
")",
"return",
"$",
"val",
";",
"}",
"return",
"'application/octet-stream'",
";",
"}"
] | Detect MIME type using file extension
@return string
@param $file string | [
"Detect",
"MIME",
"type",
"using",
"file",
"extension"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L26-L72 |
eghojansu/moe | src/tools/Web.php | Web.send | function send($file,$mime=NULL,$kbps=0,$force=TRUE) {
if (!is_file($file))
return FALSE;
$size=filesize($file);
if (PHP_SAPI!='cli') {
header('Content-Type: '.($mime?:$this->mime($file)));
if ($force)
header('Content-Disposition: attachment; '.
'filename='.var_export(basename($file),TRUE));
header('Accept-Ranges: bytes');
header('Content-Length: '.$size);
header('X-Powered-By: '.Base::instance()->get('PACKAGE'));
}
$ctr=0;
$handle=fopen($file,'rb');
$start=microtime(TRUE);
while (!feof($handle) &&
($info=stream_get_meta_data($handle)) &&
!$info['timed_out'] && !connection_aborted()) {
if ($kbps) {
// Throttle output
$ctr++;
if ($ctr/$kbps>$elapsed=microtime(TRUE)-$start)
usleep(1e6*($ctr/$kbps-$elapsed));
}
// Send 1KiB and reset timer
echo fread($handle,1024);
}
fclose($handle);
return $size;
} | php | function send($file,$mime=NULL,$kbps=0,$force=TRUE) {
if (!is_file($file))
return FALSE;
$size=filesize($file);
if (PHP_SAPI!='cli') {
header('Content-Type: '.($mime?:$this->mime($file)));
if ($force)
header('Content-Disposition: attachment; '.
'filename='.var_export(basename($file),TRUE));
header('Accept-Ranges: bytes');
header('Content-Length: '.$size);
header('X-Powered-By: '.Base::instance()->get('PACKAGE'));
}
$ctr=0;
$handle=fopen($file,'rb');
$start=microtime(TRUE);
while (!feof($handle) &&
($info=stream_get_meta_data($handle)) &&
!$info['timed_out'] && !connection_aborted()) {
if ($kbps) {
// Throttle output
$ctr++;
if ($ctr/$kbps>$elapsed=microtime(TRUE)-$start)
usleep(1e6*($ctr/$kbps-$elapsed));
}
// Send 1KiB and reset timer
echo fread($handle,1024);
}
fclose($handle);
return $size;
} | [
"function",
"send",
"(",
"$",
"file",
",",
"$",
"mime",
"=",
"NULL",
",",
"$",
"kbps",
"=",
"0",
",",
"$",
"force",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"return",
"FALSE",
";",
"$",
"size",
"=",
"filesize",
"(",
"$",
"file",
")",
";",
"if",
"(",
"PHP_SAPI",
"!=",
"'cli'",
")",
"{",
"header",
"(",
"'Content-Type: '",
".",
"(",
"$",
"mime",
"?",
":",
"$",
"this",
"->",
"mime",
"(",
"$",
"file",
")",
")",
")",
";",
"if",
"(",
"$",
"force",
")",
"header",
"(",
"'Content-Disposition: attachment; '",
".",
"'filename='",
".",
"var_export",
"(",
"basename",
"(",
"$",
"file",
")",
",",
"TRUE",
")",
")",
";",
"header",
"(",
"'Accept-Ranges: bytes'",
")",
";",
"header",
"(",
"'Content-Length: '",
".",
"$",
"size",
")",
";",
"header",
"(",
"'X-Powered-By: '",
".",
"Base",
"::",
"instance",
"(",
")",
"->",
"get",
"(",
"'PACKAGE'",
")",
")",
";",
"}",
"$",
"ctr",
"=",
"0",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"file",
",",
"'rb'",
")",
";",
"$",
"start",
"=",
"microtime",
"(",
"TRUE",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"handle",
")",
"&&",
"(",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"handle",
")",
")",
"&&",
"!",
"$",
"info",
"[",
"'timed_out'",
"]",
"&&",
"!",
"connection_aborted",
"(",
")",
")",
"{",
"if",
"(",
"$",
"kbps",
")",
"{",
"// Throttle output",
"$",
"ctr",
"++",
";",
"if",
"(",
"$",
"ctr",
"/",
"$",
"kbps",
">",
"$",
"elapsed",
"=",
"microtime",
"(",
"TRUE",
")",
"-",
"$",
"start",
")",
"usleep",
"(",
"1e6",
"*",
"(",
"$",
"ctr",
"/",
"$",
"kbps",
"-",
"$",
"elapsed",
")",
")",
";",
"}",
"// Send 1KiB and reset timer",
"echo",
"fread",
"(",
"$",
"handle",
",",
"1024",
")",
";",
"}",
"fclose",
"(",
"$",
"handle",
")",
";",
"return",
"$",
"size",
";",
"}"
] | Transmit file to HTTP client; Return file size if successful,
FALSE otherwise
@return int|FALSE
@param $file string
@param $mime string
@param $kbps int
@param $force bool | [
"Transmit",
"file",
"to",
"HTTP",
"client",
";",
"Return",
"file",
"size",
"if",
"successful",
"FALSE",
"otherwise"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L114-L144 |
eghojansu/moe | src/tools/Web.php | Web._curl | protected function _curl($url,$options) {
$curl=curl_init($url);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,
$options['follow_location']);
curl_setopt($curl,CURLOPT_MAXREDIRS,
$options['max_redirects']);
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,$options['method']);
if (isset($options['header']))
curl_setopt($curl,CURLOPT_HTTPHEADER,$options['header']);
if (isset($options['content']))
curl_setopt($curl,CURLOPT_POSTFIELDS,$options['content']);
curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
$timeout=isset($options['timeout'])?
$options['timeout']:
ini_get('default_socket_timeout');
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($curl,CURLOPT_TIMEOUT,$timeout);
$headers=array();
curl_setopt($curl,CURLOPT_HEADERFUNCTION,
// Callback for response headers
function($curl,$line) use(&$headers) {
if ($trim=trim($line))
$headers[]=$trim;
return strlen($line);
}
);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
ob_start();
curl_exec($curl);
curl_close($curl);
$body=ob_get_clean();
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'cURL',
'cached'=>FALSE
);
} | php | protected function _curl($url,$options) {
$curl=curl_init($url);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,
$options['follow_location']);
curl_setopt($curl,CURLOPT_MAXREDIRS,
$options['max_redirects']);
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,$options['method']);
if (isset($options['header']))
curl_setopt($curl,CURLOPT_HTTPHEADER,$options['header']);
if (isset($options['content']))
curl_setopt($curl,CURLOPT_POSTFIELDS,$options['content']);
curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
$timeout=isset($options['timeout'])?
$options['timeout']:
ini_get('default_socket_timeout');
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($curl,CURLOPT_TIMEOUT,$timeout);
$headers=array();
curl_setopt($curl,CURLOPT_HEADERFUNCTION,
// Callback for response headers
function($curl,$line) use(&$headers) {
if ($trim=trim($line))
$headers[]=$trim;
return strlen($line);
}
);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
ob_start();
curl_exec($curl);
curl_close($curl);
$body=ob_get_clean();
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'cURL',
'cached'=>FALSE
);
} | [
"protected",
"function",
"_curl",
"(",
"$",
"url",
",",
"$",
"options",
")",
"{",
"$",
"curl",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"$",
"options",
"[",
"'follow_location'",
"]",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_MAXREDIRS",
",",
"$",
"options",
"[",
"'max_redirects'",
"]",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"options",
"[",
"'method'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'header'",
"]",
")",
")",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"options",
"[",
"'header'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'content'",
"]",
")",
")",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"options",
"[",
"'content'",
"]",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_ENCODING",
",",
"'gzip,deflate'",
")",
";",
"$",
"timeout",
"=",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"options",
"[",
"'timeout'",
"]",
":",
"ini_get",
"(",
"'default_socket_timeout'",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"$",
"timeout",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_TIMEOUT",
",",
"$",
"timeout",
")",
";",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HEADERFUNCTION",
",",
"// Callback for response headers",
"function",
"(",
"$",
"curl",
",",
"$",
"line",
")",
"use",
"(",
"&",
"$",
"headers",
")",
"{",
"if",
"(",
"$",
"trim",
"=",
"trim",
"(",
"$",
"line",
")",
")",
"$",
"headers",
"[",
"]",
"=",
"$",
"trim",
";",
"return",
"strlen",
"(",
"$",
"line",
")",
";",
"}",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"FALSE",
")",
";",
"ob_start",
"(",
")",
";",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"$",
"body",
"=",
"ob_get_clean",
"(",
")",
";",
"return",
"array",
"(",
"'body'",
"=>",
"$",
"body",
",",
"'headers'",
"=>",
"$",
"headers",
",",
"'engine'",
"=>",
"'cURL'",
",",
"'cached'",
"=>",
"FALSE",
")",
";",
"}"
] | HTTP request via cURL
@return array
@param $url string
@param $options array | [
"HTTP",
"request",
"via",
"cURL"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L246-L283 |
eghojansu/moe | src/tools/Web.php | Web._stream | protected function _stream($url,$options) {
$eol="\r\n";
$options['header']=implode($eol,$options['header']);
$body=@file_get_contents($url,FALSE,
stream_context_create(array('http'=>$options)));
$headers=isset($http_response_header)?
$http_response_header:array();
$match=NULL;
foreach ($headers as $header)
if (preg_match('/Content-Encoding: (.+)/',$header,$match))
break;
if ($match)
switch ($match[1]) {
case 'gzip':
$body=gzdecode($body);
break;
case 'deflate':
$body=gzuncompress($body);
break;
}
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'stream',
'cached'=>FALSE
);
} | php | protected function _stream($url,$options) {
$eol="\r\n";
$options['header']=implode($eol,$options['header']);
$body=@file_get_contents($url,FALSE,
stream_context_create(array('http'=>$options)));
$headers=isset($http_response_header)?
$http_response_header:array();
$match=NULL;
foreach ($headers as $header)
if (preg_match('/Content-Encoding: (.+)/',$header,$match))
break;
if ($match)
switch ($match[1]) {
case 'gzip':
$body=gzdecode($body);
break;
case 'deflate':
$body=gzuncompress($body);
break;
}
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'stream',
'cached'=>FALSE
);
} | [
"protected",
"function",
"_stream",
"(",
"$",
"url",
",",
"$",
"options",
")",
"{",
"$",
"eol",
"=",
"\"\\r\\n\"",
";",
"$",
"options",
"[",
"'header'",
"]",
"=",
"implode",
"(",
"$",
"eol",
",",
"$",
"options",
"[",
"'header'",
"]",
")",
";",
"$",
"body",
"=",
"@",
"file_get_contents",
"(",
"$",
"url",
",",
"FALSE",
",",
"stream_context_create",
"(",
"array",
"(",
"'http'",
"=>",
"$",
"options",
")",
")",
")",
";",
"$",
"headers",
"=",
"isset",
"(",
"$",
"http_response_header",
")",
"?",
"$",
"http_response_header",
":",
"array",
"(",
")",
";",
"$",
"match",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"if",
"(",
"preg_match",
"(",
"'/Content-Encoding: (.+)/'",
",",
"$",
"header",
",",
"$",
"match",
")",
")",
"break",
";",
"if",
"(",
"$",
"match",
")",
"switch",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"{",
"case",
"'gzip'",
":",
"$",
"body",
"=",
"gzdecode",
"(",
"$",
"body",
")",
";",
"break",
";",
"case",
"'deflate'",
":",
"$",
"body",
"=",
"gzuncompress",
"(",
"$",
"body",
")",
";",
"break",
";",
"}",
"return",
"array",
"(",
"'body'",
"=>",
"$",
"body",
",",
"'headers'",
"=>",
"$",
"headers",
",",
"'engine'",
"=>",
"'stream'",
",",
"'cached'",
"=>",
"FALSE",
")",
";",
"}"
] | HTTP request via PHP stream wrapper
@return array
@param $url string
@param $options array | [
"HTTP",
"request",
"via",
"PHP",
"stream",
"wrapper"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L291-L317 |
eghojansu/moe | src/tools/Web.php | Web._socket | protected function _socket($url,$options) {
$eol="\r\n";
$headers=array();
$body='';
$parts=parse_url($url);
$empty=empty($parts['port']);
if ($parts['scheme']=='https') {
$parts['host']='ssl://'.$parts['host'];
if ($empty)
$parts['port']=443;
}
elseif ($empty)
$parts['port']=80;
if (empty($parts['path']))
$parts['path']='/';
if (empty($parts['query']))
$parts['query']='';
$socket=@fsockopen($parts['host'],$parts['port']);
if (!$socket)
return FALSE;
stream_set_blocking($socket,TRUE);
stream_set_timeout($socket,$options['timeout']);
fputs($socket,$options['method'].' '.$parts['path'].
($parts['query']?('?'.$parts['query']):'').' HTTP/1.0'.$eol
);
fputs($socket,implode($eol,$options['header']).$eol.$eol);
if (isset($options['content']))
fputs($socket,$options['content'].$eol);
// Get response
$content='';
while (!feof($socket) &&
($info=stream_get_meta_data($socket)) &&
!$info['timed_out'] && !connection_aborted() &&
$str=fgets($socket,4096))
$content.=$str;
fclose($socket);
$html=explode($eol.$eol,$content,2);
$body=isset($html[1])?$html[1]:'';
$headers=array_merge($headers,$current=explode($eol,$html[0]));
$match=NULL;
foreach ($current as $header)
if (preg_match('/Content-Encoding: (.+)/',$header,$match))
break;
if ($match)
switch ($match[1]) {
case 'gzip':
$body=gzdecode($body);
break;
case 'deflate':
$body=gzuncompress($body);
break;
}
if ($options['follow_location'] &&
preg_match('/Location: (.+?)'.preg_quote($eol).'/',
$html[0],$loc)) {
$options['max_redirects']--;
return $this->request($loc[1],$options);
}
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'socket',
'cached'=>FALSE
);
} | php | protected function _socket($url,$options) {
$eol="\r\n";
$headers=array();
$body='';
$parts=parse_url($url);
$empty=empty($parts['port']);
if ($parts['scheme']=='https') {
$parts['host']='ssl://'.$parts['host'];
if ($empty)
$parts['port']=443;
}
elseif ($empty)
$parts['port']=80;
if (empty($parts['path']))
$parts['path']='/';
if (empty($parts['query']))
$parts['query']='';
$socket=@fsockopen($parts['host'],$parts['port']);
if (!$socket)
return FALSE;
stream_set_blocking($socket,TRUE);
stream_set_timeout($socket,$options['timeout']);
fputs($socket,$options['method'].' '.$parts['path'].
($parts['query']?('?'.$parts['query']):'').' HTTP/1.0'.$eol
);
fputs($socket,implode($eol,$options['header']).$eol.$eol);
if (isset($options['content']))
fputs($socket,$options['content'].$eol);
// Get response
$content='';
while (!feof($socket) &&
($info=stream_get_meta_data($socket)) &&
!$info['timed_out'] && !connection_aborted() &&
$str=fgets($socket,4096))
$content.=$str;
fclose($socket);
$html=explode($eol.$eol,$content,2);
$body=isset($html[1])?$html[1]:'';
$headers=array_merge($headers,$current=explode($eol,$html[0]));
$match=NULL;
foreach ($current as $header)
if (preg_match('/Content-Encoding: (.+)/',$header,$match))
break;
if ($match)
switch ($match[1]) {
case 'gzip':
$body=gzdecode($body);
break;
case 'deflate':
$body=gzuncompress($body);
break;
}
if ($options['follow_location'] &&
preg_match('/Location: (.+?)'.preg_quote($eol).'/',
$html[0],$loc)) {
$options['max_redirects']--;
return $this->request($loc[1],$options);
}
return array(
'body'=>$body,
'headers'=>$headers,
'engine'=>'socket',
'cached'=>FALSE
);
} | [
"protected",
"function",
"_socket",
"(",
"$",
"url",
",",
"$",
"options",
")",
"{",
"$",
"eol",
"=",
"\"\\r\\n\"",
";",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"body",
"=",
"''",
";",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"empty",
"=",
"empty",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
";",
"if",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
"==",
"'https'",
")",
"{",
"$",
"parts",
"[",
"'host'",
"]",
"=",
"'ssl://'",
".",
"$",
"parts",
"[",
"'host'",
"]",
";",
"if",
"(",
"$",
"empty",
")",
"$",
"parts",
"[",
"'port'",
"]",
"=",
"443",
";",
"}",
"elseif",
"(",
"$",
"empty",
")",
"$",
"parts",
"[",
"'port'",
"]",
"=",
"80",
";",
"if",
"(",
"empty",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
")",
"$",
"parts",
"[",
"'path'",
"]",
"=",
"'/'",
";",
"if",
"(",
"empty",
"(",
"$",
"parts",
"[",
"'query'",
"]",
")",
")",
"$",
"parts",
"[",
"'query'",
"]",
"=",
"''",
";",
"$",
"socket",
"=",
"@",
"fsockopen",
"(",
"$",
"parts",
"[",
"'host'",
"]",
",",
"$",
"parts",
"[",
"'port'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"socket",
")",
"return",
"FALSE",
";",
"stream_set_blocking",
"(",
"$",
"socket",
",",
"TRUE",
")",
";",
"stream_set_timeout",
"(",
"$",
"socket",
",",
"$",
"options",
"[",
"'timeout'",
"]",
")",
";",
"fputs",
"(",
"$",
"socket",
",",
"$",
"options",
"[",
"'method'",
"]",
".",
"' '",
".",
"$",
"parts",
"[",
"'path'",
"]",
".",
"(",
"$",
"parts",
"[",
"'query'",
"]",
"?",
"(",
"'?'",
".",
"$",
"parts",
"[",
"'query'",
"]",
")",
":",
"''",
")",
".",
"' HTTP/1.0'",
".",
"$",
"eol",
")",
";",
"fputs",
"(",
"$",
"socket",
",",
"implode",
"(",
"$",
"eol",
",",
"$",
"options",
"[",
"'header'",
"]",
")",
".",
"$",
"eol",
".",
"$",
"eol",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'content'",
"]",
")",
")",
"fputs",
"(",
"$",
"socket",
",",
"$",
"options",
"[",
"'content'",
"]",
".",
"$",
"eol",
")",
";",
"// Get response",
"$",
"content",
"=",
"''",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"socket",
")",
"&&",
"(",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"socket",
")",
")",
"&&",
"!",
"$",
"info",
"[",
"'timed_out'",
"]",
"&&",
"!",
"connection_aborted",
"(",
")",
"&&",
"$",
"str",
"=",
"fgets",
"(",
"$",
"socket",
",",
"4096",
")",
")",
"$",
"content",
".=",
"$",
"str",
";",
"fclose",
"(",
"$",
"socket",
")",
";",
"$",
"html",
"=",
"explode",
"(",
"$",
"eol",
".",
"$",
"eol",
",",
"$",
"content",
",",
"2",
")",
";",
"$",
"body",
"=",
"isset",
"(",
"$",
"html",
"[",
"1",
"]",
")",
"?",
"$",
"html",
"[",
"1",
"]",
":",
"''",
";",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"headers",
",",
"$",
"current",
"=",
"explode",
"(",
"$",
"eol",
",",
"$",
"html",
"[",
"0",
"]",
")",
")",
";",
"$",
"match",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"current",
"as",
"$",
"header",
")",
"if",
"(",
"preg_match",
"(",
"'/Content-Encoding: (.+)/'",
",",
"$",
"header",
",",
"$",
"match",
")",
")",
"break",
";",
"if",
"(",
"$",
"match",
")",
"switch",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"{",
"case",
"'gzip'",
":",
"$",
"body",
"=",
"gzdecode",
"(",
"$",
"body",
")",
";",
"break",
";",
"case",
"'deflate'",
":",
"$",
"body",
"=",
"gzuncompress",
"(",
"$",
"body",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'follow_location'",
"]",
"&&",
"preg_match",
"(",
"'/Location: (.+?)'",
".",
"preg_quote",
"(",
"$",
"eol",
")",
".",
"'/'",
",",
"$",
"html",
"[",
"0",
"]",
",",
"$",
"loc",
")",
")",
"{",
"$",
"options",
"[",
"'max_redirects'",
"]",
"--",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"loc",
"[",
"1",
"]",
",",
"$",
"options",
")",
";",
"}",
"return",
"array",
"(",
"'body'",
"=>",
"$",
"body",
",",
"'headers'",
"=>",
"$",
"headers",
",",
"'engine'",
"=>",
"'socket'",
",",
"'cached'",
"=>",
"FALSE",
")",
";",
"}"
] | HTTP request via low-level TCP/IP socket
@return array
@param $url string
@param $options array | [
"HTTP",
"request",
"via",
"low",
"-",
"level",
"TCP",
"/",
"IP",
"socket"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L325-L389 |
eghojansu/moe | src/tools/Web.php | Web.slug | function slug($text) {
return trim(strtolower(preg_replace('/([^\pL\pN])+/u','-',
trim(strtr(str_replace('\'','',$text),
array(
'Ǎ'=>'A','А'=>'A','Ā'=>'A','Ă'=>'A','Ą'=>'A','Å'=>'A',
'Ǻ'=>'A','Ä'=>'Ae','Á'=>'A','À'=>'A','Ã'=>'A','Â'=>'A',
'Æ'=>'AE','Ǽ'=>'AE','Б'=>'B','Ç'=>'C','Ć'=>'C','Ĉ'=>'C',
'Č'=>'C','Ċ'=>'C','Ц'=>'C','Ч'=>'Ch','Ð'=>'Dj','Đ'=>'Dj',
'Ď'=>'Dj','Д'=>'Dj','É'=>'E','Ę'=>'E','Ё'=>'E','Ė'=>'E',
'Ê'=>'E','Ě'=>'E','Ē'=>'E','È'=>'E','Е'=>'E','Э'=>'E',
'Ë'=>'E','Ĕ'=>'E','Ф'=>'F','Г'=>'G','Ģ'=>'G','Ġ'=>'G',
'Ĝ'=>'G','Ğ'=>'G','Х'=>'H','Ĥ'=>'H','Ħ'=>'H','Ï'=>'I',
'Ĭ'=>'I','İ'=>'I','Į'=>'I','Ī'=>'I','Í'=>'I','Ì'=>'I',
'И'=>'I','Ǐ'=>'I','Ĩ'=>'I','Î'=>'I','IJ'=>'IJ','Ĵ'=>'J',
'Й'=>'J','Я'=>'Ja','Ю'=>'Ju','К'=>'K','Ķ'=>'K','Ĺ'=>'L',
'Л'=>'L','Ł'=>'L','Ŀ'=>'L','Ļ'=>'L','Ľ'=>'L','М'=>'M',
'Н'=>'N','Ń'=>'N','Ñ'=>'N','Ņ'=>'N','Ň'=>'N','Ō'=>'O',
'О'=>'O','Ǿ'=>'O','Ǒ'=>'O','Ơ'=>'O','Ŏ'=>'O','Ő'=>'O',
'Ø'=>'O','Ö'=>'Oe','Õ'=>'O','Ó'=>'O','Ò'=>'O','Ô'=>'O',
'Œ'=>'OE','П'=>'P','Ŗ'=>'R','Р'=>'R','Ř'=>'R','Ŕ'=>'R',
'Ŝ'=>'S','Ş'=>'S','Š'=>'S','Ș'=>'S','Ś'=>'S','С'=>'S',
'Ш'=>'Sh','Щ'=>'Shch','Ť'=>'T','Ŧ'=>'T','Ţ'=>'T','Ț'=>'T',
'Т'=>'T','Ů'=>'U','Ű'=>'U','Ŭ'=>'U','Ũ'=>'U','Ų'=>'U',
'Ū'=>'U','Ǜ'=>'U','Ǚ'=>'U','Ù'=>'U','Ú'=>'U','Ü'=>'Ue',
'Ǘ'=>'U','Ǖ'=>'U','У'=>'U','Ư'=>'U','Ǔ'=>'U','Û'=>'U',
'В'=>'V','Ŵ'=>'W','Ы'=>'Y','Ŷ'=>'Y','Ý'=>'Y','Ÿ'=>'Y',
'Ź'=>'Z','З'=>'Z','Ż'=>'Z','Ž'=>'Z','Ж'=>'Zh','á'=>'a',
'ă'=>'a','â'=>'a','à'=>'a','ā'=>'a','ǻ'=>'a','å'=>'a',
'ä'=>'ae','ą'=>'a','ǎ'=>'a','ã'=>'a','а'=>'a','ª'=>'a',
'æ'=>'ae','ǽ'=>'ae','б'=>'b','č'=>'c','ç'=>'c','ц'=>'c',
'ċ'=>'c','ĉ'=>'c','ć'=>'c','ч'=>'ch','ð'=>'dj','ď'=>'dj',
'д'=>'dj','đ'=>'dj','э'=>'e','é'=>'e','ё'=>'e','ë'=>'e',
'ê'=>'e','е'=>'e','ĕ'=>'e','è'=>'e','ę'=>'e','ě'=>'e',
'ė'=>'e','ē'=>'e','ƒ'=>'f','ф'=>'f','ġ'=>'g','ĝ'=>'g',
'ğ'=>'g','г'=>'g','ģ'=>'g','х'=>'h','ĥ'=>'h','ħ'=>'h',
'ǐ'=>'i','ĭ'=>'i','и'=>'i','ī'=>'i','ĩ'=>'i','į'=>'i',
'ı'=>'i','ì'=>'i','î'=>'i','í'=>'i','ï'=>'i','ij'=>'ij',
'ĵ'=>'j','й'=>'j','я'=>'ja','ю'=>'ju','ķ'=>'k','к'=>'k',
'ľ'=>'l','ł'=>'l','ŀ'=>'l','ĺ'=>'l','ļ'=>'l','л'=>'l',
'м'=>'m','ņ'=>'n','ñ'=>'n','ń'=>'n','н'=>'n','ň'=>'n',
'ʼn'=>'n','ó'=>'o','ò'=>'o','ǒ'=>'o','ő'=>'o','о'=>'o',
'ō'=>'o','º'=>'o','ơ'=>'o','ŏ'=>'o','ô'=>'o','ö'=>'oe',
'õ'=>'o','ø'=>'o','ǿ'=>'o','œ'=>'oe','п'=>'p','р'=>'r',
'ř'=>'r','ŕ'=>'r','ŗ'=>'r','ſ'=>'s','ŝ'=>'s','ș'=>'s',
'š'=>'s','ś'=>'s','с'=>'s','ş'=>'s','ш'=>'sh','щ'=>'shch',
'ß'=>'ss','ţ'=>'t','т'=>'t','ŧ'=>'t','ť'=>'t','ț'=>'t',
'у'=>'u','ǘ'=>'u','ŭ'=>'u','û'=>'u','ú'=>'u','ų'=>'u',
'ù'=>'u','ű'=>'u','ů'=>'u','ư'=>'u','ū'=>'u','ǚ'=>'u',
'ǜ'=>'u','ǔ'=>'u','ǖ'=>'u','ũ'=>'u','ü'=>'ue','в'=>'v',
'ŵ'=>'w','ы'=>'y','ÿ'=>'y','ý'=>'y','ŷ'=>'y','ź'=>'z',
'ž'=>'z','з'=>'z','ż'=>'z','ж'=>'zh'
)+Base::instance()->get('DIACRITICS'))))),'-');
} | php | function slug($text) {
return trim(strtolower(preg_replace('/([^\pL\pN])+/u','-',
trim(strtr(str_replace('\'','',$text),
array(
'Ǎ'=>'A','А'=>'A','Ā'=>'A','Ă'=>'A','Ą'=>'A','Å'=>'A',
'Ǻ'=>'A','Ä'=>'Ae','Á'=>'A','À'=>'A','Ã'=>'A','Â'=>'A',
'Æ'=>'AE','Ǽ'=>'AE','Б'=>'B','Ç'=>'C','Ć'=>'C','Ĉ'=>'C',
'Č'=>'C','Ċ'=>'C','Ц'=>'C','Ч'=>'Ch','Ð'=>'Dj','Đ'=>'Dj',
'Ď'=>'Dj','Д'=>'Dj','É'=>'E','Ę'=>'E','Ё'=>'E','Ė'=>'E',
'Ê'=>'E','Ě'=>'E','Ē'=>'E','È'=>'E','Е'=>'E','Э'=>'E',
'Ë'=>'E','Ĕ'=>'E','Ф'=>'F','Г'=>'G','Ģ'=>'G','Ġ'=>'G',
'Ĝ'=>'G','Ğ'=>'G','Х'=>'H','Ĥ'=>'H','Ħ'=>'H','Ï'=>'I',
'Ĭ'=>'I','İ'=>'I','Į'=>'I','Ī'=>'I','Í'=>'I','Ì'=>'I',
'И'=>'I','Ǐ'=>'I','Ĩ'=>'I','Î'=>'I','IJ'=>'IJ','Ĵ'=>'J',
'Й'=>'J','Я'=>'Ja','Ю'=>'Ju','К'=>'K','Ķ'=>'K','Ĺ'=>'L',
'Л'=>'L','Ł'=>'L','Ŀ'=>'L','Ļ'=>'L','Ľ'=>'L','М'=>'M',
'Н'=>'N','Ń'=>'N','Ñ'=>'N','Ņ'=>'N','Ň'=>'N','Ō'=>'O',
'О'=>'O','Ǿ'=>'O','Ǒ'=>'O','Ơ'=>'O','Ŏ'=>'O','Ő'=>'O',
'Ø'=>'O','Ö'=>'Oe','Õ'=>'O','Ó'=>'O','Ò'=>'O','Ô'=>'O',
'Œ'=>'OE','П'=>'P','Ŗ'=>'R','Р'=>'R','Ř'=>'R','Ŕ'=>'R',
'Ŝ'=>'S','Ş'=>'S','Š'=>'S','Ș'=>'S','Ś'=>'S','С'=>'S',
'Ш'=>'Sh','Щ'=>'Shch','Ť'=>'T','Ŧ'=>'T','Ţ'=>'T','Ț'=>'T',
'Т'=>'T','Ů'=>'U','Ű'=>'U','Ŭ'=>'U','Ũ'=>'U','Ų'=>'U',
'Ū'=>'U','Ǜ'=>'U','Ǚ'=>'U','Ù'=>'U','Ú'=>'U','Ü'=>'Ue',
'Ǘ'=>'U','Ǖ'=>'U','У'=>'U','Ư'=>'U','Ǔ'=>'U','Û'=>'U',
'В'=>'V','Ŵ'=>'W','Ы'=>'Y','Ŷ'=>'Y','Ý'=>'Y','Ÿ'=>'Y',
'Ź'=>'Z','З'=>'Z','Ż'=>'Z','Ž'=>'Z','Ж'=>'Zh','á'=>'a',
'ă'=>'a','â'=>'a','à'=>'a','ā'=>'a','ǻ'=>'a','å'=>'a',
'ä'=>'ae','ą'=>'a','ǎ'=>'a','ã'=>'a','а'=>'a','ª'=>'a',
'æ'=>'ae','ǽ'=>'ae','б'=>'b','č'=>'c','ç'=>'c','ц'=>'c',
'ċ'=>'c','ĉ'=>'c','ć'=>'c','ч'=>'ch','ð'=>'dj','ď'=>'dj',
'д'=>'dj','đ'=>'dj','э'=>'e','é'=>'e','ё'=>'e','ë'=>'e',
'ê'=>'e','е'=>'e','ĕ'=>'e','è'=>'e','ę'=>'e','ě'=>'e',
'ė'=>'e','ē'=>'e','ƒ'=>'f','ф'=>'f','ġ'=>'g','ĝ'=>'g',
'ğ'=>'g','г'=>'g','ģ'=>'g','х'=>'h','ĥ'=>'h','ħ'=>'h',
'ǐ'=>'i','ĭ'=>'i','и'=>'i','ī'=>'i','ĩ'=>'i','į'=>'i',
'ı'=>'i','ì'=>'i','î'=>'i','í'=>'i','ï'=>'i','ij'=>'ij',
'ĵ'=>'j','й'=>'j','я'=>'ja','ю'=>'ju','ķ'=>'k','к'=>'k',
'ľ'=>'l','ł'=>'l','ŀ'=>'l','ĺ'=>'l','ļ'=>'l','л'=>'l',
'м'=>'m','ņ'=>'n','ñ'=>'n','ń'=>'n','н'=>'n','ň'=>'n',
'ʼn'=>'n','ó'=>'o','ò'=>'o','ǒ'=>'o','ő'=>'o','о'=>'o',
'ō'=>'o','º'=>'o','ơ'=>'o','ŏ'=>'o','ô'=>'o','ö'=>'oe',
'õ'=>'o','ø'=>'o','ǿ'=>'o','œ'=>'oe','п'=>'p','р'=>'r',
'ř'=>'r','ŕ'=>'r','ŗ'=>'r','ſ'=>'s','ŝ'=>'s','ș'=>'s',
'š'=>'s','ś'=>'s','с'=>'s','ş'=>'s','ш'=>'sh','щ'=>'shch',
'ß'=>'ss','ţ'=>'t','т'=>'t','ŧ'=>'t','ť'=>'t','ț'=>'t',
'у'=>'u','ǘ'=>'u','ŭ'=>'u','û'=>'u','ú'=>'u','ų'=>'u',
'ù'=>'u','ű'=>'u','ů'=>'u','ư'=>'u','ū'=>'u','ǚ'=>'u',
'ǜ'=>'u','ǔ'=>'u','ǖ'=>'u','ũ'=>'u','ü'=>'ue','в'=>'v',
'ŵ'=>'w','ы'=>'y','ÿ'=>'y','ý'=>'y','ŷ'=>'y','ź'=>'z',
'ž'=>'z','з'=>'z','ż'=>'z','ж'=>'zh'
)+Base::instance()->get('DIACRITICS'))))),'-');
} | [
"function",
"slug",
"(",
"$",
"text",
")",
"{",
"return",
"trim",
"(",
"strtolower",
"(",
"preg_replace",
"(",
"'/([^\\pL\\pN])+/u'",
",",
"'-'",
",",
"trim",
"(",
"strtr",
"(",
"str_replace",
"(",
"'\\''",
",",
"''",
",",
"$",
"text",
")",
",",
"array",
"(",
"'Ǎ'=",
">'",
"A',",
"'",
"А'=>",
"'A",
"','",
"Ā",
"'=>'",
"A'",
",'Ă",
"'",
"=>'A",
"',",
"'Ą'",
"=",
">'A'",
",'",
"Å'=",
">",
"'A',",
"",
"",
"",
"'Ǻ'=",
">'",
"A',",
"'",
"Ä'=>",
"'A",
"e','",
"Á",
"'=>'",
"A'",
",'À",
"'",
"=>'A",
"',",
"'Ã'",
"=",
">'A'",
",'",
"Â'=",
">",
"'A',",
"",
"",
"",
"'Æ'=",
">'",
"AE',",
"'",
"Ǽ'=>",
"'A",
"E','",
"Б",
"'=>'",
"B'",
",'Ç",
"'",
"=>'C",
"',",
"'Ć'",
"=",
">'C'",
",'",
"Ĉ'=",
">",
"'C',",
"",
"",
"",
"'Č'=",
">'",
"C',",
"'",
"Ċ'=>",
"'C",
"','",
"Ц",
"'=>'",
"C'",
",'Ч",
"'",
"=>'C",
"h'",
",'Ð'",
"=",
">'Dj",
"',",
"'Đ'=",
">",
"'Dj'",
",",
"",
"",
"'Ď'=",
">'",
"Dj',",
"'",
"Д'=>",
"'D",
"j','",
"É",
"'=>'",
"E'",
",'Ę",
"'",
"=>'E",
"',",
"'Ё'",
"=",
">'E'",
",'",
"Ė'=",
">",
"'E',",
"",
"",
"",
"'Ê'=",
">'",
"E',",
"'",
"Ě'=>",
"'E",
"','",
"Ē",
"'=>'",
"E'",
",'È",
"'",
"=>'E",
"',",
"'Е'",
"=",
">'E'",
",'",
"Э'=",
">",
"'E',",
"",
"",
"",
"'Ë'=",
">'",
"E',",
"'",
"Ĕ'=>",
"'E",
"','",
"Ф",
"'=>'",
"F'",
",'Г",
"'",
"=>'G",
"',",
"'Ģ'",
"=",
">'G'",
",'",
"Ġ'=",
">",
"'G',",
"",
"",
"",
"'Ĝ'=",
">'",
"G',",
"'",
"Ğ'=>",
"'G",
"','",
"Х",
"'=>'",
"H'",
",'Ĥ",
"'",
"=>'H",
"',",
"'Ħ'",
"=",
">'H'",
",'",
"Ï'=",
">",
"'I',",
"",
"",
"",
"'Ĭ'=",
">'",
"I',",
"'",
"İ'=>",
"'I",
"','",
"Į",
"'=>'",
"I'",
",'Ī",
"'",
"=>'I",
"',",
"'Í'",
"=",
">'I'",
",'",
"Ì'=",
">",
"'I',",
"",
"",
"",
"'И'=",
">'",
"I',",
"'",
"Ǐ'=>",
"'I",
"','",
"Ĩ",
"'=>'",
"I'",
",'Î",
"'",
"=>'I",
"',",
"'IJ'",
"=",
">'IJ",
"',",
"'Ĵ'=",
">",
"'J',",
"",
"",
"",
"'Й'=",
">'",
"J',",
"'",
"Я'=>",
"'J",
"a','",
"Ю",
"'=>'",
"Ju",
"','К",
"'",
"=>'K",
"',",
"'Ķ'",
"=",
">'K'",
",'",
"Ĺ'=",
">",
"'L',",
"",
"",
"",
"'Л'=",
">'",
"L',",
"'",
"Ł'=>",
"'L",
"','",
"Ŀ",
"'=>'",
"L'",
",'Ļ",
"'",
"=>'L",
"',",
"'Ľ'",
"=",
">'L'",
",'",
"М'=",
">",
"'M',",
"",
"",
"",
"'Н'=",
">'",
"N',",
"'",
"Ń'=>",
"'N",
"','",
"Ñ",
"'=>'",
"N'",
",'Ņ",
"'",
"=>'N",
"',",
"'Ň'",
"=",
">'N'",
",'",
"Ō'=",
">",
"'O',",
"",
"",
"",
"'О'=",
">'",
"O',",
"'",
"Ǿ'=>",
"'O",
"','",
"Ǒ",
"'=>'",
"O'",
",'Ơ",
"'",
"=>'O",
"',",
"'Ŏ'",
"=",
">'O'",
",'",
"Ő'=",
">",
"'O',",
"",
"",
"",
"'Ø'=",
">'",
"O',",
"'",
"Ö'=>",
"'O",
"e','",
"Õ",
"'=>'",
"O'",
",'Ó",
"'",
"=>'O",
"',",
"'Ò'",
"=",
">'O'",
",'",
"Ô'=",
">",
"'O',",
"",
"",
"",
"'Œ'=",
">'",
"OE',",
"'",
"П'=>",
"'P",
"','",
"Ŗ",
"'=>'",
"R'",
",'Р",
"'",
"=>'R",
"',",
"'Ř'",
"=",
">'R'",
",'",
"Ŕ'=",
">",
"'R',",
"",
"",
"",
"'Ŝ'=",
">'",
"S',",
"'",
"Ş'=>",
"'S",
"','",
"Š",
"'=>'",
"S'",
",'Ș",
"'",
"=>'S",
"',",
"'Ś'",
"=",
">'S'",
",'",
"С'=",
">",
"'S',",
"",
"",
"",
"'Ш'=",
">'",
"Sh',",
"'",
"Щ'=>",
"'S",
"hch','",
"Ť",
"'=>'",
"T'",
",'Ŧ",
"'",
"=>'T",
"',",
"'Ţ'",
"=",
">'T'",
",'",
"Ț'=",
">",
"'T',",
"",
"",
"",
"'Т'=",
">'",
"T',",
"'",
"Ů'=>",
"'U",
"','",
"Ű",
"'=>'",
"U'",
",'Ŭ",
"'",
"=>'U",
"',",
"'Ũ'",
"=",
">'U'",
",'",
"Ų'=",
">",
"'U',",
"",
"",
"",
"'Ū'=",
">'",
"U',",
"'",
"Ǜ'=>",
"'U",
"','",
"Ǚ",
"'=>'",
"U'",
",'Ù",
"'",
"=>'U",
"',",
"'Ú'",
"=",
">'U'",
",'",
"Ü'=",
">",
"'Ue'",
",",
"",
"",
"'Ǘ'=",
">'",
"U',",
"'",
"Ǖ'=>",
"'U",
"','",
"У",
"'=>'",
"U'",
",'Ư",
"'",
"=>'U",
"',",
"'Ǔ'",
"=",
">'U'",
",'",
"Û'=",
">",
"'U',",
"",
"",
"",
"'В'=",
">'",
"V',",
"'",
"Ŵ'=>",
"'W",
"','",
"Ы",
"'=>'",
"Y'",
",'Ŷ",
"'",
"=>'Y",
"',",
"'Ý'",
"=",
">'Y'",
",'",
"Ÿ'=",
">",
"'Y',",
"",
"",
"",
"'Ź'=",
">'",
"Z',",
"'",
"З'=>",
"'Z",
"','",
"Ż",
"'=>'",
"Z'",
",'Ž",
"'",
"=>'Z",
"',",
"'Ж'",
"=",
">'Zh",
"',",
"'á'=",
">",
"'a',",
"",
"",
"",
"'ă'=",
">'",
"a',",
"'",
"â'=>",
"'a",
"','",
"à",
"'=>'",
"a'",
",'ā",
"'",
"=>'a",
"',",
"'ǻ'",
"=",
">'a'",
",'",
"å'=",
">",
"'a',",
"",
"",
"",
"'ä'=",
">'",
"ae',",
"'",
"ą'=>",
"'a",
"','",
"ǎ",
"'=>'",
"a'",
",'ã",
"'",
"=>'a",
"',",
"'а'",
"=",
">'a'",
",'",
"ª'=",
">",
"'a',",
"",
"",
"",
"'æ'=",
">'",
"ae',",
"'",
"ǽ'=>",
"'a",
"e','",
"б",
"'=>'",
"b'",
",'č",
"'",
"=>'c",
"',",
"'ç'",
"=",
">'c'",
",'",
"ц'=",
">",
"'c',",
"",
"",
"",
"'ċ'=",
">'",
"c',",
"'",
"ĉ'=>",
"'c",
"','",
"ć",
"'=>'",
"c'",
",'ч",
"'",
"=>'c",
"h'",
",'ð'",
"=",
">'dj",
"',",
"'ď'=",
">",
"'dj'",
",",
"",
"",
"'д'=",
">'",
"dj',",
"'",
"đ'=>",
"'d",
"j','",
"э",
"'=>'",
"e'",
",'é",
"'",
"=>'e",
"',",
"'ё'",
"=",
">'e'",
",'",
"ë'=",
">",
"'e',",
"",
"",
"",
"'ê'=",
">'",
"e',",
"'",
"е'=>",
"'e",
"','",
"ĕ",
"'=>'",
"e'",
",'è",
"'",
"=>'e",
"',",
"'ę'",
"=",
">'e'",
",'",
"ě'=",
">",
"'e',",
"",
"",
"",
"'ė'=",
">'",
"e',",
"'",
"ē'=>",
"'e",
"','",
"ƒ",
"'=>'",
"f'",
",'ф",
"'",
"=>'f",
"',",
"'ġ'",
"=",
">'g'",
",'",
"ĝ'=",
">",
"'g',",
"",
"",
"",
"'ğ'=",
">'",
"g',",
"'",
"г'=>",
"'g",
"','",
"ģ",
"'=>'",
"g'",
",'х",
"'",
"=>'h",
"',",
"'ĥ'",
"=",
">'h'",
",'",
"ħ'=",
">",
"'h',",
"",
"",
"",
"'ǐ'=",
">'",
"i',",
"'",
"ĭ'=>",
"'i",
"','",
"и",
"'=>'",
"i'",
",'ī",
"'",
"=>'i",
"',",
"'ĩ'",
"=",
">'i'",
",'",
"į'=",
">",
"'i',",
"",
"",
"",
"'ı'=",
">'",
"i',",
"'",
"ì'=>",
"'i",
"','",
"î",
"'=>'",
"i'",
",'í",
"'",
"=>'i",
"',",
"'ï'",
"=",
">'i'",
",'",
"ij'=",
">",
"'ij'",
",",
"",
"",
"'ĵ'=",
">'",
"j',",
"'",
"й'=>",
"'j",
"','",
"я",
"'=>'",
"ja",
"','ю",
"'",
"=>'j",
"u'",
",'ķ'",
"=",
">'k'",
",'",
"к'=",
">",
"'k',",
"",
"",
"",
"'ľ'=",
">'",
"l',",
"'",
"ł'=>",
"'l",
"','",
"ŀ",
"'=>'",
"l'",
",'ĺ",
"'",
"=>'l",
"',",
"'ļ'",
"=",
">'l'",
",'",
"л'=",
">",
"'l',",
"",
"",
"",
"'м'=",
">'",
"m',",
"'",
"ņ'=>",
"'n",
"','",
"ñ",
"'=>'",
"n'",
",'ń",
"'",
"=>'n",
"',",
"'н'",
"=",
">'n'",
",'",
"ň'=",
">",
"'n',",
"",
"",
"",
"'ʼn'=",
">'",
"n',",
"'",
"ó'=>",
"'o",
"','",
"ò",
"'=>'",
"o'",
",'ǒ",
"'",
"=>'o",
"',",
"'ő'",
"=",
">'o'",
",'",
"о'=",
">",
"'o',",
"",
"",
"",
"'ō'=",
">'",
"o',",
"'",
"º'=>",
"'o",
"','",
"ơ",
"'=>'",
"o'",
",'ŏ",
"'",
"=>'o",
"',",
"'ô'",
"=",
">'o'",
",'",
"ö'=",
">",
"'oe'",
",",
"",
"",
"'õ'=",
">'",
"o',",
"'",
"ø'=>",
"'o",
"','",
"ǿ",
"'=>'",
"o'",
",'œ",
"'",
"=>'o",
"e'",
",'п'",
"=",
">'p'",
",'",
"р'=",
">",
"'r',",
"",
"",
"",
"'ř'=",
">'",
"r',",
"'",
"ŕ'=>",
"'r",
"','",
"ŗ",
"'=>'",
"r'",
",'ſ",
"'",
"=>'s",
"',",
"'ŝ'",
"=",
">'s'",
",'",
"ș'=",
">",
"'s',",
"",
"",
"",
"'š'=",
">'",
"s',",
"'",
"ś'=>",
"'s",
"','",
"с",
"'=>'",
"s'",
",'ş",
"'",
"=>'s",
"',",
"'ш'",
"=",
">'sh",
"',",
"'щ'=",
">",
"'shc",
"h'",
",",
"",
"'ß'=",
">'",
"ss',",
"'",
"ţ'=>",
"'t",
"','",
"т",
"'=>'",
"t'",
",'ŧ",
"'",
"=>'t",
"',",
"'ť'",
"=",
">'t'",
",'",
"ț'=",
">",
"'t',",
"",
"",
"",
"'у'=",
">'",
"u',",
"'",
"ǘ'=>",
"'u",
"','",
"ŭ",
"'=>'",
"u'",
",'û",
"'",
"=>'u",
"',",
"'ú'",
"=",
">'u'",
",'",
"ų'=",
">",
"'u',",
"",
"",
"",
"'ù'=",
">'",
"u',",
"'",
"ű'=>",
"'u",
"','",
"ů",
"'=>'",
"u'",
",'ư",
"'",
"=>'u",
"',",
"'ū'",
"=",
">'u'",
",'",
"ǚ'=",
">",
"'u',",
"",
"",
"",
"'ǜ'=",
">'",
"u',",
"'",
"ǔ'=>",
"'u",
"','",
"ǖ",
"'=>'",
"u'",
",'ũ",
"'",
"=>'u",
"',",
"'ü'",
"=",
">'ue",
"',",
"'в'=",
">",
"'v',",
"",
"",
"",
"'ŵ'=",
">'",
"w',",
"'",
"ы'=>",
"'y",
"','",
"ÿ",
"'=>'",
"y'",
",'ý",
"'",
"=>'y",
"',",
"'ŷ'",
"=",
">'y'",
",'",
"ź'=",
">",
"'z',",
"",
"",
"",
"'ž'=",
">'",
"z',",
"'",
"з'=>",
"'z",
"','",
"ż",
"'=>'",
"z'",
",'ж",
"'",
"=>'z",
"h'",
"",
")",
"+",
"Base",
"::",
"instance",
"(",
")",
"->",
"get",
"(",
"'DIACRITICS'",
")",
")",
")",
")",
")",
",",
"'-'",
")",
";",
"}"
] | Return a URL/filesystem-friendly version of string
@return string
@param $text string | [
"Return",
"a",
"URL",
"/",
"filesystem",
"-",
"friendly",
"version",
"of",
"string"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L724-L776 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.isValid | public function isValid(Token $token = null)
{
return !is_null($token) && $token->getType() == $this->config['type'] && $this->checkObfuscatePart($token);
} | php | public function isValid(Token $token = null)
{
return !is_null($token) && $token->getType() == $this->config['type'] && $this->checkObfuscatePart($token);
} | [
"public",
"function",
"isValid",
"(",
"Token",
"$",
"token",
"=",
"null",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"token",
")",
"&&",
"$",
"token",
"->",
"getType",
"(",
")",
"==",
"$",
"this",
"->",
"config",
"[",
"'type'",
"]",
"&&",
"$",
"this",
"->",
"checkObfuscatePart",
"(",
"$",
"token",
")",
";",
"}"
] | /*!
check if specified Token is a valid token
@method isValid
@public
@param MetaTech\PwsAtuh\Token $token
@return bool | [
"/",
"*",
"!",
"check",
"if",
"specified",
"Token",
"is",
"a",
"valid",
"token"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L55-L58 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.sign | public function sign($dtime, $login, $key, $length=null)
{
$str = Tool::concat($this->config['hash']['sep'], [$dtime, $login, $this->getUserSalt($login), $key]);
return substr(hash($this->config['hash']['algo'], $str), is_null($length) ? - $this->config['hash']['length'] : - $length);
} | php | public function sign($dtime, $login, $key, $length=null)
{
$str = Tool::concat($this->config['hash']['sep'], [$dtime, $login, $this->getUserSalt($login), $key]);
return substr(hash($this->config['hash']['algo'], $str), is_null($length) ? - $this->config['hash']['length'] : - $length);
} | [
"public",
"function",
"sign",
"(",
"$",
"dtime",
",",
"$",
"login",
",",
"$",
"key",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"str",
"=",
"Tool",
"::",
"concat",
"(",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'sep'",
"]",
",",
"[",
"$",
"dtime",
",",
"$",
"login",
",",
"$",
"this",
"->",
"getUserSalt",
"(",
"$",
"login",
")",
",",
"$",
"key",
"]",
")",
";",
"return",
"substr",
"(",
"hash",
"(",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'algo'",
"]",
",",
"$",
"str",
")",
",",
"is_null",
"(",
"$",
"length",
")",
"?",
"-",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'length'",
"]",
":",
"-",
"$",
"length",
")",
";",
"}"
] | /*!
generate a unique signature at given time for specifyed user
@method sign
@public
@param str $dtime given time in sqldatetime format
@param str $login the user login
@param str $key the user key
@return str | [
"/",
"*",
"!",
"generate",
"a",
"unique",
"signature",
"at",
"given",
"time",
"for",
"specifyed",
"user"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L70-L74 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.getUserSalt | public function getUserSalt($login)
{
return substr(
hash(self::DEFAULT_ALGO, $login . $this->config['salt']['common']),
$this->config['salt']['user.index'],
$this->config['salt']['user.length']
);
} | php | public function getUserSalt($login)
{
return substr(
hash(self::DEFAULT_ALGO, $login . $this->config['salt']['common']),
$this->config['salt']['user.index'],
$this->config['salt']['user.length']
);
} | [
"public",
"function",
"getUserSalt",
"(",
"$",
"login",
")",
"{",
"return",
"substr",
"(",
"hash",
"(",
"self",
"::",
"DEFAULT_ALGO",
",",
"$",
"login",
".",
"$",
"this",
"->",
"config",
"[",
"'salt'",
"]",
"[",
"'common'",
"]",
")",
",",
"$",
"this",
"->",
"config",
"[",
"'salt'",
"]",
"[",
"'user.index'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'salt'",
"]",
"[",
"'user.length'",
"]",
")",
";",
"}"
] | /*!
generate the salt for a specific user
@method getUserSalt
@public
@param str $login the user login
@return str | [
"/",
"*",
"!",
"generate",
"the",
"salt",
"for",
"a",
"specific",
"user"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L84-L91 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.obfuscate | private function obfuscate($data, $date)
{
return substr(
hash(self::DEFAULT_ALGO, $date . $data . $this->config['salt']['common']),
- $this->config['hash']['session.index']
);
} | php | private function obfuscate($data, $date)
{
return substr(
hash(self::DEFAULT_ALGO, $date . $data . $this->config['salt']['common']),
- $this->config['hash']['session.index']
);
} | [
"private",
"function",
"obfuscate",
"(",
"$",
"data",
",",
"$",
"date",
")",
"{",
"return",
"substr",
"(",
"hash",
"(",
"self",
"::",
"DEFAULT_ALGO",
",",
"$",
"date",
".",
"$",
"data",
".",
"$",
"this",
"->",
"config",
"[",
"'salt'",
"]",
"[",
"'common'",
"]",
")",
",",
"-",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'session.index'",
"]",
")",
";",
"}"
] | /*!
generate noise to obfuscate token
@method obfuscate
@orivate
@param str $data
@return str | [
"/",
"*",
"!",
"generate",
"noise",
"to",
"obfuscate",
"token"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L101-L107 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.checkObfuscatePart | public function checkObfuscatePart(Token $token)
{
$tokenValue = $token->getValue();
return substr($tokenValue, 0, $this->config['hash']['session.index']) == $this->obfuscate($this->deobfuscate($tokenValue), $token->getDate());
} | php | public function checkObfuscatePart(Token $token)
{
$tokenValue = $token->getValue();
return substr($tokenValue, 0, $this->config['hash']['session.index']) == $this->obfuscate($this->deobfuscate($tokenValue), $token->getDate());
} | [
"public",
"function",
"checkObfuscatePart",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"tokenValue",
"=",
"$",
"token",
"->",
"getValue",
"(",
")",
";",
"return",
"substr",
"(",
"$",
"tokenValue",
",",
"0",
",",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'session.index'",
"]",
")",
"==",
"$",
"this",
"->",
"obfuscate",
"(",
"$",
"this",
"->",
"deobfuscate",
"(",
"$",
"tokenValue",
")",
",",
"$",
"token",
"->",
"getDate",
"(",
")",
")",
";",
"}"
] | /*!
check valid noise obfuscation
@method checkObfuscatePart
@public
@param MetaTech\PwsAtuh\Token $token
@return bool | [
"/",
"*",
"!",
"check",
"valid",
"noise",
"obfuscation"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L139-L143 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.check | public function check(Token $token = null, $login = '')
{
return !is_null($token) && !empty($login) && $this->deobfuscate($token->getValue()) == $this->sign($token->getDate(), $login, $token->getIdent());
} | php | public function check(Token $token = null, $login = '')
{
return !is_null($token) && !empty($login) && $this->deobfuscate($token->getValue()) == $this->sign($token->getDate(), $login, $token->getIdent());
} | [
"public",
"function",
"check",
"(",
"Token",
"$",
"token",
"=",
"null",
",",
"$",
"login",
"=",
"''",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"token",
")",
"&&",
"!",
"empty",
"(",
"$",
"login",
")",
"&&",
"$",
"this",
"->",
"deobfuscate",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
")",
"==",
"$",
"this",
"->",
"sign",
"(",
"$",
"token",
"->",
"getDate",
"(",
")",
",",
"$",
"login",
",",
"$",
"token",
"->",
"getIdent",
"(",
")",
")",
";",
"}"
] | /*!
check validity of Token
@mehtod check
@public
@param MetaTech\PwsAtuh\Token $token
@param str $login
@return bool | [
"/",
"*",
"!",
"check",
"validity",
"of",
"Token"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L178-L181 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.generateNoise | public function generateNoise($data)
{
return substr(hash(self::DEFAULT_ALGO, str_shuffle($data)), - $this->config['hash']['noise.length']);
} | php | public function generateNoise($data)
{
return substr(hash(self::DEFAULT_ALGO, str_shuffle($data)), - $this->config['hash']['noise.length']);
} | [
"public",
"function",
"generateNoise",
"(",
"$",
"data",
")",
"{",
"return",
"substr",
"(",
"hash",
"(",
"self",
"::",
"DEFAULT_ALGO",
",",
"str_shuffle",
"(",
"$",
"data",
")",
")",
",",
"-",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'noise.length'",
"]",
")",
";",
"}"
] | /*!
@method generateNoise
@public
@param str $data
@return str | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L189-L192 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.generateToken | public function generateToken($login, $key, $sessid=null)
{
$date = Tool::now();
$sessid = is_null($sessid) ? $this->sign($date, $login, $key) : $sessid;
$dt = $this->formatDate($date);
$tokenValue = $this->obfuscate($sessid, $date) . $sessid;
$noise = $this->generateNoise($tokenValue);
return new Token($this->config['type'], $key, $date, $tokenValue, $noise);
} | php | public function generateToken($login, $key, $sessid=null)
{
$date = Tool::now();
$sessid = is_null($sessid) ? $this->sign($date, $login, $key) : $sessid;
$dt = $this->formatDate($date);
$tokenValue = $this->obfuscate($sessid, $date) . $sessid;
$noise = $this->generateNoise($tokenValue);
return new Token($this->config['type'], $key, $date, $tokenValue, $noise);
} | [
"public",
"function",
"generateToken",
"(",
"$",
"login",
",",
"$",
"key",
",",
"$",
"sessid",
"=",
"null",
")",
"{",
"$",
"date",
"=",
"Tool",
"::",
"now",
"(",
")",
";",
"$",
"sessid",
"=",
"is_null",
"(",
"$",
"sessid",
")",
"?",
"$",
"this",
"->",
"sign",
"(",
"$",
"date",
",",
"$",
"login",
",",
"$",
"key",
")",
":",
"$",
"sessid",
";",
"$",
"dt",
"=",
"$",
"this",
"->",
"formatDate",
"(",
"$",
"date",
")",
";",
"$",
"tokenValue",
"=",
"$",
"this",
"->",
"obfuscate",
"(",
"$",
"sessid",
",",
"$",
"date",
")",
".",
"$",
"sessid",
";",
"$",
"noise",
"=",
"$",
"this",
"->",
"generateNoise",
"(",
"$",
"tokenValue",
")",
";",
"return",
"new",
"Token",
"(",
"$",
"this",
"->",
"config",
"[",
"'type'",
"]",
",",
"$",
"key",
",",
"$",
"date",
",",
"$",
"tokenValue",
",",
"$",
"noise",
")",
";",
"}"
] | /*!
@method generateToken
@public
@param str $login
@param str $key
@param str $sessid|null
@return MetaTech\PwsAuth\Token | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L202-L210 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.generateResponseHeader | public function generateResponseHeader(Token $token)
{
return hash(
self::DEFAULT_ALGO,
$this->formatDate($token->getDate()) . $this->getUserSalt('') . $token->getValue()
);
} | php | public function generateResponseHeader(Token $token)
{
return hash(
self::DEFAULT_ALGO,
$this->formatDate($token->getDate()) . $this->getUserSalt('') . $token->getValue()
);
} | [
"public",
"function",
"generateResponseHeader",
"(",
"Token",
"$",
"token",
")",
"{",
"return",
"hash",
"(",
"self",
"::",
"DEFAULT_ALGO",
",",
"$",
"this",
"->",
"formatDate",
"(",
"$",
"token",
"->",
"getDate",
"(",
")",
")",
".",
"$",
"this",
"->",
"getUserSalt",
"(",
"''",
")",
".",
"$",
"token",
"->",
"getValue",
"(",
")",
")",
";",
"}"
] | /*!
@method generateResponseHeader
@public
@param MetaTech\PwsAuth\Token $token
@return str | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L218-L224 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.generateHeader | public function generateHeader($login, $key, $sessid=null)
{
$token = $this->generateToken($login, $key, $sessid);
$ndate = $this->formatDate($token->getDate());
return array(
$this->config['header']['auth'] .': ' . $token->getType() . ' ' . $ndate . $token->getValue() . $token->getNoise(),
$this->config['header']['ident'].': ' . $token->getIdent()
);
} | php | public function generateHeader($login, $key, $sessid=null)
{
$token = $this->generateToken($login, $key, $sessid);
$ndate = $this->formatDate($token->getDate());
return array(
$this->config['header']['auth'] .': ' . $token->getType() . ' ' . $ndate . $token->getValue() . $token->getNoise(),
$this->config['header']['ident'].': ' . $token->getIdent()
);
} | [
"public",
"function",
"generateHeader",
"(",
"$",
"login",
",",
"$",
"key",
",",
"$",
"sessid",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"generateToken",
"(",
"$",
"login",
",",
"$",
"key",
",",
"$",
"sessid",
")",
";",
"$",
"ndate",
"=",
"$",
"this",
"->",
"formatDate",
"(",
"$",
"token",
"->",
"getDate",
"(",
")",
")",
";",
"return",
"array",
"(",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'auth'",
"]",
".",
"': '",
".",
"$",
"token",
"->",
"getType",
"(",
")",
".",
"' '",
".",
"$",
"ndate",
".",
"$",
"token",
"->",
"getValue",
"(",
")",
".",
"$",
"token",
"->",
"getNoise",
"(",
")",
",",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'ident'",
"]",
".",
"': '",
".",
"$",
"token",
"->",
"getIdent",
"(",
")",
")",
";",
"}"
] | /*!
@method generateHeader
@public
@param str $login
@param str $key
@param str $sessid
@return [] | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L245-L253 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.generatePostVars | public function generatePostVars($login, $key, $tokenName='apitkn', $keyName='apikey')
{
$token = $this->generateToken($login, $key, null);
$ndate = $this->formatDate($token->getDate());
return array(
$tokenName => $ndate . $token->getValue() . $token->getNoise(),
$keyName => $key
);
} | php | public function generatePostVars($login, $key, $tokenName='apitkn', $keyName='apikey')
{
$token = $this->generateToken($login, $key, null);
$ndate = $this->formatDate($token->getDate());
return array(
$tokenName => $ndate . $token->getValue() . $token->getNoise(),
$keyName => $key
);
} | [
"public",
"function",
"generatePostVars",
"(",
"$",
"login",
",",
"$",
"key",
",",
"$",
"tokenName",
"=",
"'apitkn'",
",",
"$",
"keyName",
"=",
"'apikey'",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"generateToken",
"(",
"$",
"login",
",",
"$",
"key",
",",
"null",
")",
";",
"$",
"ndate",
"=",
"$",
"this",
"->",
"formatDate",
"(",
"$",
"token",
"->",
"getDate",
"(",
")",
")",
";",
"return",
"array",
"(",
"$",
"tokenName",
"=>",
"$",
"ndate",
".",
"$",
"token",
"->",
"getValue",
"(",
")",
".",
"$",
"token",
"->",
"getNoise",
"(",
")",
",",
"$",
"keyName",
"=>",
"$",
"key",
")",
";",
"}"
] | /*!
@method generatePostVars
@public
@param str $login
@param str $key
@param str $tokenName
@param str $keyName
@return [] | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L264-L272 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.getTokenFromString | public function getTokenFromString($noisedToken, $key)
{
$date = substr($noisedToken, 0, self::DATE_LENGTH);
$tokenValue = substr($noisedToken, self::DATE_LENGTH, -$this->config['hash']['noise.length']);
$noise = substr($noisedToken, -$this->config['hash']['noise.length']);
return new Token($this->config['type'], $key, $this->unformatDate($date), $tokenValue, $noise);
} | php | public function getTokenFromString($noisedToken, $key)
{
$date = substr($noisedToken, 0, self::DATE_LENGTH);
$tokenValue = substr($noisedToken, self::DATE_LENGTH, -$this->config['hash']['noise.length']);
$noise = substr($noisedToken, -$this->config['hash']['noise.length']);
return new Token($this->config['type'], $key, $this->unformatDate($date), $tokenValue, $noise);
} | [
"public",
"function",
"getTokenFromString",
"(",
"$",
"noisedToken",
",",
"$",
"key",
")",
"{",
"$",
"date",
"=",
"substr",
"(",
"$",
"noisedToken",
",",
"0",
",",
"self",
"::",
"DATE_LENGTH",
")",
";",
"$",
"tokenValue",
"=",
"substr",
"(",
"$",
"noisedToken",
",",
"self",
"::",
"DATE_LENGTH",
",",
"-",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'noise.length'",
"]",
")",
";",
"$",
"noise",
"=",
"substr",
"(",
"$",
"noisedToken",
",",
"-",
"$",
"this",
"->",
"config",
"[",
"'hash'",
"]",
"[",
"'noise.length'",
"]",
")",
";",
"return",
"new",
"Token",
"(",
"$",
"this",
"->",
"config",
"[",
"'type'",
"]",
",",
"$",
"key",
",",
"$",
"this",
"->",
"unformatDate",
"(",
"$",
"date",
")",
",",
"$",
"tokenValue",
",",
"$",
"noise",
")",
";",
"}"
] | /*!
get token from specified $noisedToken for specified key.
@method getTokenFromString
@public
@param str $noisedToken
@param str $key
@return MetaTech\PwsAuth\Token | [
"/",
"*",
"!",
"get",
"token",
"from",
"specified",
"$noisedToken",
"for",
"specified",
"key",
"."
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L283-L289 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.getToken | public function getToken($headers = null)
{
$token = null;
try {
if (is_null($headers)) {
if (!function_exists('apache_request_headers()')) {
function apache_request_headers()
{
foreach($_SERVER as $key=>$value) {
if (substr($key,0,5)=="HTTP_") {
$key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
}
$out[$key]=$value;
}
return $out;
}
}
$headers = apache_request_headers();
}
if (isset($headers[$this->config['header']['auth']]) && isset($headers[$this->config['header']['ident']])) {
$tokenValue = $headers[$this->config['header']['auth']];
$ident = $headers[$this->config['header']['ident']];
if (preg_match('/(?P<type>[a-z\d]+) (?P<noised>.*)/i', $tokenValue, $rs)) {
$token = $this->getTokenFromString($rs['noised'], $ident);
if ($token->getType() != $rs['type']) {
throw new \Exception('wrong type');
}
}
}
else {
throw new \Exception('missing required headers');
}
}
catch(\Exception $e) {
throw new AuthenticateException("invalid authentication protocol : ".$e->getMessage());
}
return $token;
} | php | public function getToken($headers = null)
{
$token = null;
try {
if (is_null($headers)) {
if (!function_exists('apache_request_headers()')) {
function apache_request_headers()
{
foreach($_SERVER as $key=>$value) {
if (substr($key,0,5)=="HTTP_") {
$key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
}
$out[$key]=$value;
}
return $out;
}
}
$headers = apache_request_headers();
}
if (isset($headers[$this->config['header']['auth']]) && isset($headers[$this->config['header']['ident']])) {
$tokenValue = $headers[$this->config['header']['auth']];
$ident = $headers[$this->config['header']['ident']];
if (preg_match('/(?P<type>[a-z\d]+) (?P<noised>.*)/i', $tokenValue, $rs)) {
$token = $this->getTokenFromString($rs['noised'], $ident);
if ($token->getType() != $rs['type']) {
throw new \Exception('wrong type');
}
}
}
else {
throw new \Exception('missing required headers');
}
}
catch(\Exception $e) {
throw new AuthenticateException("invalid authentication protocol : ".$e->getMessage());
}
return $token;
} | [
"public",
"function",
"getToken",
"(",
"$",
"headers",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"is_null",
"(",
"$",
"headers",
")",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'apache_request_headers()'",
")",
")",
"{",
"function",
"apache_request_headers",
"(",
")",
"{",
"foreach",
"(",
"$",
"_SERVER",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"5",
")",
"==",
"\"HTTP_\"",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"-\"",
",",
"ucwords",
"(",
"strtolower",
"(",
"str_replace",
"(",
"\"_\"",
",",
"\" \"",
",",
"substr",
"(",
"$",
"key",
",",
"5",
")",
")",
")",
")",
")",
";",
"}",
"$",
"out",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"out",
";",
"}",
"}",
"$",
"headers",
"=",
"apache_request_headers",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'auth'",
"]",
"]",
")",
"&&",
"isset",
"(",
"$",
"headers",
"[",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'ident'",
"]",
"]",
")",
")",
"{",
"$",
"tokenValue",
"=",
"$",
"headers",
"[",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'auth'",
"]",
"]",
";",
"$",
"ident",
"=",
"$",
"headers",
"[",
"$",
"this",
"->",
"config",
"[",
"'header'",
"]",
"[",
"'ident'",
"]",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/(?P<type>[a-z\\d]+) (?P<noised>.*)/i'",
",",
"$",
"tokenValue",
",",
"$",
"rs",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getTokenFromString",
"(",
"$",
"rs",
"[",
"'noised'",
"]",
",",
"$",
"ident",
")",
";",
"if",
"(",
"$",
"token",
"->",
"getType",
"(",
")",
"!=",
"$",
"rs",
"[",
"'type'",
"]",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'wrong type'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'missing required headers'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"AuthenticateException",
"(",
"\"invalid authentication protocol : \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"token",
";",
"}"
] | /*!
get token from specified $header or request headers.
@method getToken
@public
@param [assoc] $headers
@throw MetaTech\PwsAuth\AuthenticateException
@return MetaTech\PwsAuth\Token | [
"/",
"*",
"!",
"get",
"token",
"from",
"specified",
"$header",
"or",
"request",
"headers",
"."
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L300-L337 |
meta-tech/pws-auth | src/MetaTech/PwsAuth/Authenticator.php | Authenticator.readHeader | public function readHeader($arrHeaders)
{
$headers = [];
if (is_array($arrHeaders)) {
foreach($arrHeaders as $h) {
$rs = preg_split('/:/', $h);
if (count($rs)==2) {
$headers[$rs[0]] = trim($rs[1]);
}
}
}
return $headers;
} | php | public function readHeader($arrHeaders)
{
$headers = [];
if (is_array($arrHeaders)) {
foreach($arrHeaders as $h) {
$rs = preg_split('/:/', $h);
if (count($rs)==2) {
$headers[$rs[0]] = trim($rs[1]);
}
}
}
return $headers;
} | [
"public",
"function",
"readHeader",
"(",
"$",
"arrHeaders",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"arrHeaders",
")",
")",
"{",
"foreach",
"(",
"$",
"arrHeaders",
"as",
"$",
"h",
")",
"{",
"$",
"rs",
"=",
"preg_split",
"(",
"'/:/'",
",",
"$",
"h",
")",
";",
"if",
"(",
"count",
"(",
"$",
"rs",
")",
"==",
"2",
")",
"{",
"$",
"headers",
"[",
"$",
"rs",
"[",
"0",
"]",
"]",
"=",
"trim",
"(",
"$",
"rs",
"[",
"1",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] | /*!
read header generate by generateHeader
@method readHeader
@public
@param [str] $arrHeaders
@return [assoc] | [
"/",
"*",
"!",
"read",
"header",
"generate",
"by",
"generateHeader"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/PwsAuth/Authenticator.php#L347-L359 |
oploshka/Reform | src/Reform.php | Reform.item | public function item($item = NULL, $validate = array() ){
// проверим данные на существование
if( $item === NULL ) { return NULL; }
if( !is_array($validate) ) { return NULL; }
if( !isset($validate['type']) ) { return NULL; }
if( !is_string($validate['type']) ) { return NULL; }
if(!isset($this->reformMethods[ $validate['type'] ])){ return NULL; }
//
$ValidateClassName = $this->reformMethods[ $validate['type'] ];
$useClass = new $ValidateClassName();
// проверим реализует ли класс наш интерфейс
if ( !($useClass instanceof \Oploshka\Reform\ReformItemInterface ) ) { return NULL; }
$_validate = $validate['validate'] ?? [];
return $useClass::validate($item, $_validate, $this);
} | php | public function item($item = NULL, $validate = array() ){
// проверим данные на существование
if( $item === NULL ) { return NULL; }
if( !is_array($validate) ) { return NULL; }
if( !isset($validate['type']) ) { return NULL; }
if( !is_string($validate['type']) ) { return NULL; }
if(!isset($this->reformMethods[ $validate['type'] ])){ return NULL; }
//
$ValidateClassName = $this->reformMethods[ $validate['type'] ];
$useClass = new $ValidateClassName();
// проверим реализует ли класс наш интерфейс
if ( !($useClass instanceof \Oploshka\Reform\ReformItemInterface ) ) { return NULL; }
$_validate = $validate['validate'] ?? [];
return $useClass::validate($item, $_validate, $this);
} | [
"public",
"function",
"item",
"(",
"$",
"item",
"=",
"NULL",
",",
"$",
"validate",
"=",
"array",
"(",
")",
")",
"{",
"// проверим данные на существование",
"if",
"(",
"$",
"item",
"===",
"NULL",
")",
"{",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"validate",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"validate",
"[",
"'type'",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"validate",
"[",
"'type'",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"reformMethods",
"[",
"$",
"validate",
"[",
"'type'",
"]",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"//",
"$",
"ValidateClassName",
"=",
"$",
"this",
"->",
"reformMethods",
"[",
"$",
"validate",
"[",
"'type'",
"]",
"]",
";",
"$",
"useClass",
"=",
"new",
"$",
"ValidateClassName",
"(",
")",
";",
"// проверим реализует ли класс наш интерфейс",
"if",
"(",
"!",
"(",
"$",
"useClass",
"instanceof",
"\\",
"Oploshka",
"\\",
"Reform",
"\\",
"ReformItemInterface",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"_validate",
"=",
"$",
"validate",
"[",
"'validate'",
"]",
"??",
"[",
"]",
";",
"return",
"$",
"useClass",
"::",
"validate",
"(",
"$",
"item",
",",
"$",
"_validate",
",",
"$",
"this",
")",
";",
"}"
] | /*
Функция валидации переменной | [
"/",
"*",
"Функция",
"валидации",
"переменной"
] | train | https://github.com/oploshka/Reform/blob/1a03ab34dc01bd0a6664eea891d541065504e812/src/Reform.php#L34-L49 |
nabab/bbn | src/bbn/models/tts/dbconfig.php | dbconfig._init_class_cfg | private function _init_class_cfg(array $cfg = []){
$cfg = bbn\x::merge_arrays(self::$_defaults, $cfg);
if ( !isset($cfg['tables'], $cfg['table'], $cfg['arch']) ){
die('The class '.\get_class($this).' is not configured properly to work with trait dbconfig');
}
$this->class_table = $cfg['table'];
// We completely replace the table structure, no merge
foreach ( $cfg['arch'] as $t => $a ){
if ( $cfg['tables'][$t] === $cfg['table'] ){
$this->class_table_index = $t;
}
}
/*
* The selection comprises the defined fields of the users table
* Plus a bunch of user-defined additional fields in the same table
*/
$this->fields = $cfg['arch'][$this->class_table_index];
$this->class_cfg = $cfg;
return $this;
} | php | private function _init_class_cfg(array $cfg = []){
$cfg = bbn\x::merge_arrays(self::$_defaults, $cfg);
if ( !isset($cfg['tables'], $cfg['table'], $cfg['arch']) ){
die('The class '.\get_class($this).' is not configured properly to work with trait dbconfig');
}
$this->class_table = $cfg['table'];
// We completely replace the table structure, no merge
foreach ( $cfg['arch'] as $t => $a ){
if ( $cfg['tables'][$t] === $cfg['table'] ){
$this->class_table_index = $t;
}
}
/*
* The selection comprises the defined fields of the users table
* Plus a bunch of user-defined additional fields in the same table
*/
$this->fields = $cfg['arch'][$this->class_table_index];
$this->class_cfg = $cfg;
return $this;
} | [
"private",
"function",
"_init_class_cfg",
"(",
"array",
"$",
"cfg",
"=",
"[",
"]",
")",
"{",
"$",
"cfg",
"=",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"self",
"::",
"$",
"_defaults",
",",
"$",
"cfg",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cfg",
"[",
"'tables'",
"]",
",",
"$",
"cfg",
"[",
"'table'",
"]",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
")",
")",
"{",
"die",
"(",
"'The class '",
".",
"\\",
"get_class",
"(",
"$",
"this",
")",
".",
"' is not configured properly to work with trait dbconfig'",
")",
";",
"}",
"$",
"this",
"->",
"class_table",
"=",
"$",
"cfg",
"[",
"'table'",
"]",
";",
"// We completely replace the table structure, no merge",
"foreach",
"(",
"$",
"cfg",
"[",
"'arch'",
"]",
"as",
"$",
"t",
"=>",
"$",
"a",
")",
"{",
"if",
"(",
"$",
"cfg",
"[",
"'tables'",
"]",
"[",
"$",
"t",
"]",
"===",
"$",
"cfg",
"[",
"'table'",
"]",
")",
"{",
"$",
"this",
"->",
"class_table_index",
"=",
"$",
"t",
";",
"}",
"}",
"/*\n * The selection comprises the defined fields of the users table\n * Plus a bunch of user-defined additional fields in the same table\n */",
"$",
"this",
"->",
"fields",
"=",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"$",
"this",
"->",
"class_table_index",
"]",
";",
"$",
"this",
"->",
"class_cfg",
"=",
"$",
"cfg",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the class configuration as defined in $this->_defaults
@param array $cfg
@return $this | [
"Sets",
"the",
"class",
"configuration",
"as",
"defined",
"in",
"$this",
"-",
">",
"_defaults"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/models/tts/dbconfig.php#L32-L53 |
php-lug/lug | src/Component/Behat/Dictionary/PurgerDictionary.php | PurgerDictionary.getPurger | public function getPurger($driver, $manager)
{
if (isset($this->purgerCache[$hash = sha1($driver.'.'.$manager)])) {
return $this->purgerCache[$hash];
}
$manager = $this->getService($manager);
return $this->purgerCache[$hash] = $driver === ResourceInterface::DRIVER_DOCTRINE_MONGODB
? new MongoDBPurger($manager)
: new ORMPurger($manager);
} | php | public function getPurger($driver, $manager)
{
if (isset($this->purgerCache[$hash = sha1($driver.'.'.$manager)])) {
return $this->purgerCache[$hash];
}
$manager = $this->getService($manager);
return $this->purgerCache[$hash] = $driver === ResourceInterface::DRIVER_DOCTRINE_MONGODB
? new MongoDBPurger($manager)
: new ORMPurger($manager);
} | [
"public",
"function",
"getPurger",
"(",
"$",
"driver",
",",
"$",
"manager",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"purgerCache",
"[",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"driver",
".",
"'.'",
".",
"$",
"manager",
")",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"purgerCache",
"[",
"$",
"hash",
"]",
";",
"}",
"$",
"manager",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"manager",
")",
";",
"return",
"$",
"this",
"->",
"purgerCache",
"[",
"$",
"hash",
"]",
"=",
"$",
"driver",
"===",
"ResourceInterface",
"::",
"DRIVER_DOCTRINE_MONGODB",
"?",
"new",
"MongoDBPurger",
"(",
"$",
"manager",
")",
":",
"new",
"ORMPurger",
"(",
"$",
"manager",
")",
";",
"}"
] | @param string $driver
@param string $manager
@return PurgerInterface | [
"@param",
"string",
"$driver",
"@param",
"string",
"$manager"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Dictionary/PurgerDictionary.php#L56-L67 |
primipilus/fileinfo | src/FileInfo.php | FileInfo.equals | public function equals(FileInfo $info) : bool
{
return $this->_size === $info->size && $this->_sha1 === $info->sha1 && $this->_md5 === $info->md5;
} | php | public function equals(FileInfo $info) : bool
{
return $this->_size === $info->size && $this->_sha1 === $info->sha1 && $this->_md5 === $info->md5;
} | [
"public",
"function",
"equals",
"(",
"FileInfo",
"$",
"info",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"_size",
"===",
"$",
"info",
"->",
"size",
"&&",
"$",
"this",
"->",
"_sha1",
"===",
"$",
"info",
"->",
"sha1",
"&&",
"$",
"this",
"->",
"_md5",
"===",
"$",
"info",
"->",
"md5",
";",
"}"
] | @param FileInfo $info
@return bool | [
"@param",
"FileInfo",
"$info"
] | train | https://github.com/primipilus/fileinfo/blob/734fd25b3dfd3b0706f9ef07499663578c0fa56e/src/FileInfo.php#L171-L174 |
bariew/yii2-i18n-cms-module | controllers/MessageController.php | MessageController.actionIndex | public function actionIndex()
{
$searchModel = new MessageSearch;
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
return $this->render('index', compact('dataProvider', 'searchModel'));
} | php | public function actionIndex()
{
$searchModel = new MessageSearch;
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
return $this->render('index', compact('dataProvider', 'searchModel'));
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"new",
"MessageSearch",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"compact",
"(",
"'dataProvider'",
",",
"'searchModel'",
")",
")",
";",
"}"
] | Lists all Message models.
@return mixed | [
"Lists",
"all",
"Message",
"models",
"."
] | train | https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/controllers/MessageController.php#L29-L34 |
bariew/yii2-i18n-cms-module | controllers/MessageController.php | MessageController.actionFastUpdate | public function actionFastUpdate($id)
{
Message::updateAll(
['translation' => Yii::$app->request->post('translation')],
['id' => $id, 'language' => Yii::$app->request->post('language')]
);
} | php | public function actionFastUpdate($id)
{
Message::updateAll(
['translation' => Yii::$app->request->post('translation')],
['id' => $id, 'language' => Yii::$app->request->post('language')]
);
} | [
"public",
"function",
"actionFastUpdate",
"(",
"$",
"id",
")",
"{",
"Message",
"::",
"updateAll",
"(",
"[",
"'translation'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'translation'",
")",
"]",
",",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'language'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'language'",
")",
"]",
")",
";",
"}"
] | Fast translation update.
@param int $id
@return string | [
"Fast",
"translation",
"update",
"."
] | train | https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/controllers/MessageController.php#L42-L48 |
thienhungho/yii2-product-management | src/modules/ProductManageForCustomer/controllers/ProductController.php | ProductController.actionIndex | public function actionIndex($slug = 'product')
{
if (!is_product_type_slug($slug)) {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
$product_type = ProductType::find()
->where(['slug' => $slug])
->one();
$searchModel = new ProductSearch();
$queryParams = request()->queryParams;
$queryParams['ProductSearch']['product_type'] = $product_type->name;
$dataProvider = $searchModel->search($queryParams);
$dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
view()->title = t('app', $product_type->name);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'product_type' => $product_type,
]);
} | php | public function actionIndex($slug = 'product')
{
if (!is_product_type_slug($slug)) {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
$product_type = ProductType::find()
->where(['slug' => $slug])
->one();
$searchModel = new ProductSearch();
$queryParams = request()->queryParams;
$queryParams['ProductSearch']['product_type'] = $product_type->name;
$dataProvider = $searchModel->search($queryParams);
$dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
view()->title = t('app', $product_type->name);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'product_type' => $product_type,
]);
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"slug",
"=",
"'product'",
")",
"{",
"if",
"(",
"!",
"is_product_type_slug",
"(",
"$",
"slug",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"t",
"(",
"'app'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"$",
"product_type",
"=",
"ProductType",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'slug'",
"=>",
"$",
"slug",
"]",
")",
"->",
"one",
"(",
")",
";",
"$",
"searchModel",
"=",
"new",
"ProductSearch",
"(",
")",
";",
"$",
"queryParams",
"=",
"request",
"(",
")",
"->",
"queryParams",
";",
"$",
"queryParams",
"[",
"'ProductSearch'",
"]",
"[",
"'product_type'",
"]",
"=",
"$",
"product_type",
"->",
"name",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"$",
"queryParams",
")",
";",
"$",
"dataProvider",
"->",
"sort",
"->",
"defaultOrder",
"=",
"[",
"'id'",
"=>",
"SORT_DESC",
"]",
";",
"view",
"(",
")",
"->",
"title",
"=",
"t",
"(",
"'app'",
",",
"$",
"product_type",
"->",
"name",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'product_type'",
"=>",
"$",
"product_type",
",",
"]",
")",
";",
"}"
] | @param string $slug
@return string
@throws NotFoundHttpException | [
"@param",
"string",
"$slug"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManageForCustomer/controllers/ProductController.php#L37-L57 |
thienhungho/yii2-product-management | src/modules/ProductManageForCustomer/controllers/ProductController.php | ProductController.actionView | public function actionView($id)
{
$model = $this->findModel($id);
$providerCart = new \yii\data\ArrayDataProvider([
'allModels' => $model->carts,
]);
$providerOrderItem = new \yii\data\ArrayDataProvider([
'allModels' => $model->orderItems,
]);
return $this->render('view', [
'model' => $this->findModel($id),
'providerCart' => $providerCart,
'providerOrderItem' => $providerOrderItem,
]);
} | php | public function actionView($id)
{
$model = $this->findModel($id);
$providerCart = new \yii\data\ArrayDataProvider([
'allModels' => $model->carts,
]);
$providerOrderItem = new \yii\data\ArrayDataProvider([
'allModels' => $model->orderItems,
]);
return $this->render('view', [
'model' => $this->findModel($id),
'providerCart' => $providerCart,
'providerOrderItem' => $providerOrderItem,
]);
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"providerCart",
"=",
"new",
"\\",
"yii",
"\\",
"data",
"\\",
"ArrayDataProvider",
"(",
"[",
"'allModels'",
"=>",
"$",
"model",
"->",
"carts",
",",
"]",
")",
";",
"$",
"providerOrderItem",
"=",
"new",
"\\",
"yii",
"\\",
"data",
"\\",
"ArrayDataProvider",
"(",
"[",
"'allModels'",
"=>",
"$",
"model",
"->",
"orderItems",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'view'",
",",
"[",
"'model'",
"=>",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
",",
"'providerCart'",
"=>",
"$",
"providerCart",
",",
"'providerOrderItem'",
"=>",
"$",
"providerOrderItem",
",",
"]",
")",
";",
"}"
] | @param $id
@return string
@throws NotFoundHttpException | [
"@param",
"$id"
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManageForCustomer/controllers/ProductController.php#L65-L80 |
thienhungho/yii2-product-management | src/modules/ProductManageForCustomer/controllers/ProductController.php | ProductController.findModel | protected function findModel($id)
{
if (($model = Product::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
} | php | protected function findModel($id)
{
if (($model = Product::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
}
} | [
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"(",
"$",
"model",
"=",
"Product",
"::",
"findOne",
"(",
"$",
"id",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"t",
"(",
"'app'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"}"
] | Finds the Product model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param integer $id
@return Product the loaded model
@throws NotFoundHttpException if the model cannot be found | [
"Finds",
"the",
"Product",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
] | train | https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManageForCustomer/controllers/ProductController.php#L155-L162 |
PayBreak/foundation | src/Decision/Condition/EqualCondition.php | EqualCondition.checkCondition | public function checkCondition(Value $value)
{
if ($this->compareType($value) && $value->getValue() == $this->getValue()->getValue()) {
return true;
}
return false;
} | php | public function checkCondition(Value $value)
{
if ($this->compareType($value) && $value->getValue() == $this->getValue()->getValue()) {
return true;
}
return false;
} | [
"public",
"function",
"checkCondition",
"(",
"Value",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compareType",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"->",
"getValue",
"(",
")",
"==",
"$",
"this",
"->",
"getValue",
"(",
")",
"->",
"getValue",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Test Value against Condition
@param Value $value
@return bool | [
"Test",
"Value",
"against",
"Condition"
] | train | https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Condition/EqualCondition.php#L41-L48 |
php-lug/lug | src/Bundle/LocaleBundle/Context/LocaleContext.php | LocaleContext.getLocales | public function getLocales()
{
if (($request = $this->requestStack->getMasterRequest()) === null) {
return [$this->localeProvider->getDefaultLocale()->getCode()];
}
$locales = [];
if ($this->parameterResolver->resolveApi()) {
$locales = $this->parseAcceptLanguage($request);
}
if (empty($locales)) {
$locales = [$request->getLocale()];
}
return $locales;
} | php | public function getLocales()
{
if (($request = $this->requestStack->getMasterRequest()) === null) {
return [$this->localeProvider->getDefaultLocale()->getCode()];
}
$locales = [];
if ($this->parameterResolver->resolveApi()) {
$locales = $this->parseAcceptLanguage($request);
}
if (empty($locales)) {
$locales = [$request->getLocale()];
}
return $locales;
} | [
"public",
"function",
"getLocales",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
")",
"===",
"null",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"localeProvider",
"->",
"getDefaultLocale",
"(",
")",
"->",
"getCode",
"(",
")",
"]",
";",
"}",
"$",
"locales",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveApi",
"(",
")",
")",
"{",
"$",
"locales",
"=",
"$",
"this",
"->",
"parseAcceptLanguage",
"(",
"$",
"request",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"locales",
")",
")",
"{",
"$",
"locales",
"=",
"[",
"$",
"request",
"->",
"getLocale",
"(",
")",
"]",
";",
"}",
"return",
"$",
"locales",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/LocaleBundle/Context/LocaleContext.php#L68-L85 |
php-lug/lug | src/Bundle/LocaleBundle/Context/LocaleContext.php | LocaleContext.parseAcceptLanguage | private function parseAcceptLanguage(Request $request)
{
$locales = [];
$acceptLanguage = trim($request->headers->get('Accept-Language'));
if (!empty($acceptLanguage)) {
$locales = array_map(function (AcceptLanguage $acceptLanguage) {
return $acceptLanguage->getType();
}, $this->localeNegotiator->parse($acceptLanguage));
}
return $locales;
} | php | private function parseAcceptLanguage(Request $request)
{
$locales = [];
$acceptLanguage = trim($request->headers->get('Accept-Language'));
if (!empty($acceptLanguage)) {
$locales = array_map(function (AcceptLanguage $acceptLanguage) {
return $acceptLanguage->getType();
}, $this->localeNegotiator->parse($acceptLanguage));
}
return $locales;
} | [
"private",
"function",
"parseAcceptLanguage",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"locales",
"=",
"[",
"]",
";",
"$",
"acceptLanguage",
"=",
"trim",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'Accept-Language'",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"acceptLanguage",
")",
")",
"{",
"$",
"locales",
"=",
"array_map",
"(",
"function",
"(",
"AcceptLanguage",
"$",
"acceptLanguage",
")",
"{",
"return",
"$",
"acceptLanguage",
"->",
"getType",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"localeNegotiator",
"->",
"parse",
"(",
"$",
"acceptLanguage",
")",
")",
";",
"}",
"return",
"$",
"locales",
";",
"}"
] | @param Request $request
@return string[] | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/LocaleBundle/Context/LocaleContext.php#L92-L104 |
mothership-ec/composer | src/Composer/Repository/Pear/BaseChannelReader.php | BaseChannelReader.requestXml | protected function requestXml($origin, $path)
{
// http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors.
$xml = simplexml_load_string($this->requestContent($origin, $path), "SimpleXMLElement", LIBXML_NOERROR);
if (false == $xml) {
$url = rtrim($origin, '/') . '/' . ltrim($path, '/');
throw new \UnexpectedValueException(sprintf('The PEAR channel at ' . $origin . ' is broken. (Invalid XML at file `%s`)', $path));
}
return $xml;
} | php | protected function requestXml($origin, $path)
{
// http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors.
$xml = simplexml_load_string($this->requestContent($origin, $path), "SimpleXMLElement", LIBXML_NOERROR);
if (false == $xml) {
$url = rtrim($origin, '/') . '/' . ltrim($path, '/');
throw new \UnexpectedValueException(sprintf('The PEAR channel at ' . $origin . ' is broken. (Invalid XML at file `%s`)', $path));
}
return $xml;
} | [
"protected",
"function",
"requestXml",
"(",
"$",
"origin",
",",
"$",
"path",
")",
"{",
"// http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors.",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"this",
"->",
"requestContent",
"(",
"$",
"origin",
",",
"$",
"path",
")",
",",
"\"SimpleXMLElement\"",
",",
"LIBXML_NOERROR",
")",
";",
"if",
"(",
"false",
"==",
"$",
"xml",
")",
"{",
"$",
"url",
"=",
"rtrim",
"(",
"$",
"origin",
",",
"'/'",
")",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'The PEAR channel at '",
".",
"$",
"origin",
".",
"' is broken. (Invalid XML at file `%s`)'",
",",
"$",
"path",
")",
")",
";",
"}",
"return",
"$",
"xml",
";",
"}"
] | Read xml content from remote filesystem
@param $origin string server
@param $path string relative path to content
@throws \UnexpectedValueException
@return \SimpleXMLElement | [
"Read",
"xml",
"content",
"from",
"remote",
"filesystem"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Pear/BaseChannelReader.php#L71-L82 |
ezsystems/ezcomments-ls-extension | classes/ezcomformtool.php | ezcomFormTool.setFieldValue | protected function setFieldValue( $field, $fieldPostName )
{
$http = eZHTTPTool::instance();
if( $http->hasPostVariable( $fieldPostName ) )
{
$this->fieldValues[$field] = $http->postVariable( $fieldPostName );
}
} | php | protected function setFieldValue( $field, $fieldPostName )
{
$http = eZHTTPTool::instance();
if( $http->hasPostVariable( $fieldPostName ) )
{
$this->fieldValues[$field] = $http->postVariable( $fieldPostName );
}
} | [
"protected",
"function",
"setFieldValue",
"(",
"$",
"field",
",",
"$",
"fieldPostName",
")",
"{",
"$",
"http",
"=",
"eZHTTPTool",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"http",
"->",
"hasPostVariable",
"(",
"$",
"fieldPostName",
")",
")",
"{",
"$",
"this",
"->",
"fieldValues",
"[",
"$",
"field",
"]",
"=",
"$",
"http",
"->",
"postVariable",
"(",
"$",
"fieldPostName",
")",
";",
"}",
"}"
] | Adjust field if needed. The adjusted value is inside $this->fieldValues
@param string $field field identifier | [
"Adjust",
"field",
"if",
"needed",
".",
"The",
"adjusted",
"value",
"is",
"inside",
"$this",
"-",
">",
"fieldValues"
] | train | https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomformtool.php#L61-L68 |
ezsystems/ezcomments-ls-extension | classes/ezcomformtool.php | ezcomFormTool.checkVars | public function checkVars()
{
$http = eZHTTPTool::instance();
$user = eZUser::currentUser();
$isAnon = $user->isAnonymous();
$status = true;
foreach ( $this->fields as $field => $fieldSetup )
{
$fieldPostName = $fieldSetup[self::VARNAME];
$this->setFieldValue( $field, $fieldPostName );
if( !$this->isVariableRequired( $field ) )
{
continue;
}
else
{
$fieldRequired = $fieldSetup[self::REQUIRED] == 'true' ? true : false;
$fieldExists = $http->hasPostVariable( $fieldPostName );
if ( $fieldRequired && !$fieldExists )
{
$status = false;
$this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add',
'%1 is missing.',
null,
array( $field ) );
continue;
}
else if ( $fieldExists )
{
$val = $http->postVariable( $fieldPostName );
// only check the empty value when the field is required. In other cases, still validate field if it has value
if ( $fieldRequired && empty( $val ) )
{
$status = false;
$this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add',
'The field [%1] is empty.',
null,
array( $field ) );
continue;
}
else
{
$validationResult = $this->validateField( $field, $val );
if ( $validationResult !== true )
{
$status = false;
$this->validationMessage[$field] = $validationResult;
continue;
}
}
}
}
}
$this->validationStatus = $status;
return $status;
} | php | public function checkVars()
{
$http = eZHTTPTool::instance();
$user = eZUser::currentUser();
$isAnon = $user->isAnonymous();
$status = true;
foreach ( $this->fields as $field => $fieldSetup )
{
$fieldPostName = $fieldSetup[self::VARNAME];
$this->setFieldValue( $field, $fieldPostName );
if( !$this->isVariableRequired( $field ) )
{
continue;
}
else
{
$fieldRequired = $fieldSetup[self::REQUIRED] == 'true' ? true : false;
$fieldExists = $http->hasPostVariable( $fieldPostName );
if ( $fieldRequired && !$fieldExists )
{
$status = false;
$this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add',
'%1 is missing.',
null,
array( $field ) );
continue;
}
else if ( $fieldExists )
{
$val = $http->postVariable( $fieldPostName );
// only check the empty value when the field is required. In other cases, still validate field if it has value
if ( $fieldRequired && empty( $val ) )
{
$status = false;
$this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add',
'The field [%1] is empty.',
null,
array( $field ) );
continue;
}
else
{
$validationResult = $this->validateField( $field, $val );
if ( $validationResult !== true )
{
$status = false;
$this->validationMessage[$field] = $validationResult;
continue;
}
}
}
}
}
$this->validationStatus = $status;
return $status;
} | [
"public",
"function",
"checkVars",
"(",
")",
"{",
"$",
"http",
"=",
"eZHTTPTool",
"::",
"instance",
"(",
")",
";",
"$",
"user",
"=",
"eZUser",
"::",
"currentUser",
"(",
")",
";",
"$",
"isAnon",
"=",
"$",
"user",
"->",
"isAnonymous",
"(",
")",
";",
"$",
"status",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
"=>",
"$",
"fieldSetup",
")",
"{",
"$",
"fieldPostName",
"=",
"$",
"fieldSetup",
"[",
"self",
"::",
"VARNAME",
"]",
";",
"$",
"this",
"->",
"setFieldValue",
"(",
"$",
"field",
",",
"$",
"fieldPostName",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isVariableRequired",
"(",
"$",
"field",
")",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"$",
"fieldRequired",
"=",
"$",
"fieldSetup",
"[",
"self",
"::",
"REQUIRED",
"]",
"==",
"'true'",
"?",
"true",
":",
"false",
";",
"$",
"fieldExists",
"=",
"$",
"http",
"->",
"hasPostVariable",
"(",
"$",
"fieldPostName",
")",
";",
"if",
"(",
"$",
"fieldRequired",
"&&",
"!",
"$",
"fieldExists",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"this",
"->",
"validationMessage",
"[",
"$",
"field",
"]",
"=",
"ezpI18n",
"::",
"tr",
"(",
"'ezcomments/comment/add'",
",",
"'%1 is missing.'",
",",
"null",
",",
"array",
"(",
"$",
"field",
")",
")",
";",
"continue",
";",
"}",
"else",
"if",
"(",
"$",
"fieldExists",
")",
"{",
"$",
"val",
"=",
"$",
"http",
"->",
"postVariable",
"(",
"$",
"fieldPostName",
")",
";",
"// only check the empty value when the field is required. In other cases, still validate field if it has value",
"if",
"(",
"$",
"fieldRequired",
"&&",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"this",
"->",
"validationMessage",
"[",
"$",
"field",
"]",
"=",
"ezpI18n",
"::",
"tr",
"(",
"'ezcomments/comment/add'",
",",
"'The field [%1] is empty.'",
",",
"null",
",",
"array",
"(",
"$",
"field",
")",
")",
";",
"continue",
";",
"}",
"else",
"{",
"$",
"validationResult",
"=",
"$",
"this",
"->",
"validateField",
"(",
"$",
"field",
",",
"$",
"val",
")",
";",
"if",
"(",
"$",
"validationResult",
"!==",
"true",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"this",
"->",
"validationMessage",
"[",
"$",
"field",
"]",
"=",
"$",
"validationResult",
";",
"continue",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"validationStatus",
"=",
"$",
"status",
";",
"return",
"$",
"status",
";",
"}"
] | check variable from client | [
"check",
"variable",
"from",
"client"
] | train | https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomformtool.php#L73-L130 |
ezsystems/ezcomments-ls-extension | classes/ezcomformtool.php | ezcomFormTool.fillObject | public function fillObject( $comment, $fieldNames = null )
{
$filledFields = $this->fields;
if ( !is_null( $fieldNames ) && is_array( $fieldNames ) )
{
$filledFields = array();
foreach ( $fieldNames as $fieldName )
{
$filledFields[$fieldName] = $this->fields[$fieldName];
}
}
foreach ( $filledFields as $field => $fieldSetup )
{
$attributeName = $fieldSetup[self::ATTRIBUTENAME];
if ( !is_null( $attributeName ) )
{
$fieldValue = $this->fieldValues[$field];
$comment->setAttribute( $attributeName, $fieldValue );
}
}
} | php | public function fillObject( $comment, $fieldNames = null )
{
$filledFields = $this->fields;
if ( !is_null( $fieldNames ) && is_array( $fieldNames ) )
{
$filledFields = array();
foreach ( $fieldNames as $fieldName )
{
$filledFields[$fieldName] = $this->fields[$fieldName];
}
}
foreach ( $filledFields as $field => $fieldSetup )
{
$attributeName = $fieldSetup[self::ATTRIBUTENAME];
if ( !is_null( $attributeName ) )
{
$fieldValue = $this->fieldValues[$field];
$comment->setAttribute( $attributeName, $fieldValue );
}
}
} | [
"public",
"function",
"fillObject",
"(",
"$",
"comment",
",",
"$",
"fieldNames",
"=",
"null",
")",
"{",
"$",
"filledFields",
"=",
"$",
"this",
"->",
"fields",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"fieldNames",
")",
"&&",
"is_array",
"(",
"$",
"fieldNames",
")",
")",
"{",
"$",
"filledFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldNames",
"as",
"$",
"fieldName",
")",
"{",
"$",
"filledFields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
";",
"}",
"}",
"foreach",
"(",
"$",
"filledFields",
"as",
"$",
"field",
"=>",
"$",
"fieldSetup",
")",
"{",
"$",
"attributeName",
"=",
"$",
"fieldSetup",
"[",
"self",
"::",
"ATTRIBUTENAME",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"attributeName",
")",
")",
"{",
"$",
"fieldValue",
"=",
"$",
"this",
"->",
"fieldValues",
"[",
"$",
"field",
"]",
";",
"$",
"comment",
"->",
"setAttribute",
"(",
"$",
"attributeName",
",",
"$",
"fieldValue",
")",
";",
"}",
"}",
"}"
] | Fill field to comment object
@param $comment ezcomcomment persistent object
@param $fieldNames field name array selected to be filled into comment
@return | [
"Fill",
"field",
"to",
"comment",
"object"
] | train | https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomformtool.php#L138-L158 |
mmanos/laravel-casset | src/Mmanos/Casset/CassetServiceProvider.php | CassetServiceProvider.boot | public function boot()
{
$this->package('mmanos/laravel-casset');
if ($route = Config::get('laravel-casset::route')) {
Route::get(trim($route, '/') . '/{type}', 'Mmanos\Casset\CassetController@getIndex');
}
} | php | public function boot()
{
$this->package('mmanos/laravel-casset');
if ($route = Config::get('laravel-casset::route')) {
Route::get(trim($route, '/') . '/{type}', 'Mmanos\Casset\CassetController@getIndex');
}
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"package",
"(",
"'mmanos/laravel-casset'",
")",
";",
"if",
"(",
"$",
"route",
"=",
"Config",
"::",
"get",
"(",
"'laravel-casset::route'",
")",
")",
"{",
"Route",
"::",
"get",
"(",
"trim",
"(",
"$",
"route",
",",
"'/'",
")",
".",
"'/{type}'",
",",
"'Mmanos\\Casset\\CassetController@getIndex'",
")",
";",
"}",
"}"
] | Bootstrap the application events.
@return void | [
"Bootstrap",
"the",
"application",
"events",
"."
] | train | https://github.com/mmanos/laravel-casset/blob/0f7db71211c1daa99bde30afa41da2692a39b81c/src/Mmanos/Casset/CassetServiceProvider.php#L21-L28 |
simbiosis-group/yii2-helper | actions/ListAction.php | ListAction.run | public function run()
{
Url::remember();
$dataProvider = $this->searchModel->singleSearch(Yii::$app->request->queryParams, $this->query);
return $this->controller->render($this->view, array_merge([
'searchModel' => $this->searchModel,
'dataProvider' => $dataProvider,
], $this->params));
} | php | public function run()
{
Url::remember();
$dataProvider = $this->searchModel->singleSearch(Yii::$app->request->queryParams, $this->query);
return $this->controller->render($this->view, array_merge([
'searchModel' => $this->searchModel,
'dataProvider' => $dataProvider,
], $this->params));
} | [
"public",
"function",
"run",
"(",
")",
"{",
"Url",
"::",
"remember",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"searchModel",
"->",
"singleSearch",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
",",
"$",
"this",
"->",
"query",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"render",
"(",
"$",
"this",
"->",
"view",
",",
"array_merge",
"(",
"[",
"'searchModel'",
"=>",
"$",
"this",
"->",
"searchModel",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"]",
",",
"$",
"this",
"->",
"params",
")",
")",
";",
"}"
] | Runs the action
@return string Return the result | [
"Runs",
"the",
"action"
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/ListAction.php#L57-L66 |
JBZoo/Assets | src/Asset/CssCode.php | CssCode.load | public function load(array $filters = [])
{
$source = Str::trim($this->_source, true);
if (stripos($source, '<style') === 0) {
if (preg_match('#<style.*?>(.*?)</style>#ius', $source, $matches)) {
$source = $matches[1];
}
}
return [$this->_type, $source];
} | php | public function load(array $filters = [])
{
$source = Str::trim($this->_source, true);
if (stripos($source, '<style') === 0) {
if (preg_match('#<style.*?>(.*?)</style>#ius', $source, $matches)) {
$source = $matches[1];
}
}
return [$this->_type, $source];
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"source",
"=",
"Str",
"::",
"trim",
"(",
"$",
"this",
"->",
"_source",
",",
"true",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"source",
",",
"'<style'",
")",
"===",
"0",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#<style.*?>(.*?)</style>#ius'",
",",
"$",
"source",
",",
"$",
"matches",
")",
")",
"{",
"$",
"source",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"[",
"$",
"this",
"->",
"_type",
",",
"$",
"source",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Asset/CssCode.php#L31-L42 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/EventMapping.php | EventMapping.addListenerForEvent | public function addListenerForEvent($eventClassName, $listener)
{
if (FALSE === array_key_exists($eventClassName, $this->eventMap))
{
$this->eventMap[$eventClassName] = [];
}
$this->eventMap[$eventClassName][] = $listener;
} | php | public function addListenerForEvent($eventClassName, $listener)
{
if (FALSE === array_key_exists($eventClassName, $this->eventMap))
{
$this->eventMap[$eventClassName] = [];
}
$this->eventMap[$eventClassName][] = $listener;
} | [
"public",
"function",
"addListenerForEvent",
"(",
"$",
"eventClassName",
",",
"$",
"listener",
")",
"{",
"if",
"(",
"FALSE",
"===",
"array_key_exists",
"(",
"$",
"eventClassName",
",",
"$",
"this",
"->",
"eventMap",
")",
")",
"{",
"$",
"this",
"->",
"eventMap",
"[",
"$",
"eventClassName",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"eventMap",
"[",
"$",
"eventClassName",
"]",
"[",
"]",
"=",
"$",
"listener",
";",
"}"
] | Adds a new listener for an event.
@param string $eventClassName The event class name.
@param callable $listener Any kind of callable.
@return void | [
"Adds",
"a",
"new",
"listener",
"for",
"an",
"event",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/EventMapping.php#L46-L53 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/EventMapping.php | EventMapping.getListenersForEvent | public function getListenersForEvent($eventClassName)
{
if (FALSE === array_key_exists($eventClassName, $this->eventMap))
{
return [];
}
return $this->eventMap[$eventClassName];
} | php | public function getListenersForEvent($eventClassName)
{
if (FALSE === array_key_exists($eventClassName, $this->eventMap))
{
return [];
}
return $this->eventMap[$eventClassName];
} | [
"public",
"function",
"getListenersForEvent",
"(",
"$",
"eventClassName",
")",
"{",
"if",
"(",
"FALSE",
"===",
"array_key_exists",
"(",
"$",
"eventClassName",
",",
"$",
"this",
"->",
"eventMap",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"eventMap",
"[",
"$",
"eventClassName",
"]",
";",
"}"
] | Gets all listeners for an event.
@param string $eventClassName The event class name.
@return array An array of callables. | [
"Gets",
"all",
"listeners",
"for",
"an",
"event",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/EventMapping.php#L63-L70 |
jasny/controller | src/Controller/View.php | View.view | public function view($name, array $context = [])
{
$context += ['current_url' => $this->getRequest()->getUri()];
if (method_exists($this, 'flash')) {
$context += ['flash' => $this->flash()];
}
$response = $this->getViewer()->render($this->getResponse(), $name, $context);
$this->setResponse($response);
} | php | public function view($name, array $context = [])
{
$context += ['current_url' => $this->getRequest()->getUri()];
if (method_exists($this, 'flash')) {
$context += ['flash' => $this->flash()];
}
$response = $this->getViewer()->render($this->getResponse(), $name, $context);
$this->setResponse($response);
} | [
"public",
"function",
"view",
"(",
"$",
"name",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"context",
"+=",
"[",
"'current_url'",
"=>",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getUri",
"(",
")",
"]",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'flash'",
")",
")",
"{",
"$",
"context",
"+=",
"[",
"'flash'",
"=>",
"$",
"this",
"->",
"flash",
"(",
")",
"]",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"getViewer",
"(",
")",
"->",
"render",
"(",
"$",
"this",
"->",
"getResponse",
"(",
")",
",",
"$",
"name",
",",
"$",
"context",
")",
";",
"$",
"this",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"}"
] | View rendered template
@param string $name Template name
@param array $context Template context | [
"View",
"rendered",
"template"
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/View.php#L83-L94 |
chubbyphp/chubbyphp-negotiation | src/AcceptNegotiator.php | AcceptNegotiator.aggregatedValues | private function aggregatedValues(string $header): array
{
$values = [];
foreach (explode(',', $header) as $headerValue) {
$headerValueParts = explode(';', $headerValue);
$mediaType = trim(array_shift($headerValueParts));
$attributes = [];
foreach ($headerValueParts as $attribute) {
list($attributeKey, $attributeValue) = explode('=', $attribute);
$attributes[trim($attributeKey)] = trim($attributeValue);
}
if (!isset($attributes['q'])) {
$attributes['q'] = '1.0';
}
$values[$mediaType] = $attributes;
}
uasort($values, function (array $a, array $b) {
return $b['q'] <=> $a['q'];
});
return $values;
} | php | private function aggregatedValues(string $header): array
{
$values = [];
foreach (explode(',', $header) as $headerValue) {
$headerValueParts = explode(';', $headerValue);
$mediaType = trim(array_shift($headerValueParts));
$attributes = [];
foreach ($headerValueParts as $attribute) {
list($attributeKey, $attributeValue) = explode('=', $attribute);
$attributes[trim($attributeKey)] = trim($attributeValue);
}
if (!isset($attributes['q'])) {
$attributes['q'] = '1.0';
}
$values[$mediaType] = $attributes;
}
uasort($values, function (array $a, array $b) {
return $b['q'] <=> $a['q'];
});
return $values;
} | [
"private",
"function",
"aggregatedValues",
"(",
"string",
"$",
"header",
")",
":",
"array",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"header",
")",
"as",
"$",
"headerValue",
")",
"{",
"$",
"headerValueParts",
"=",
"explode",
"(",
"';'",
",",
"$",
"headerValue",
")",
";",
"$",
"mediaType",
"=",
"trim",
"(",
"array_shift",
"(",
"$",
"headerValueParts",
")",
")",
";",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headerValueParts",
"as",
"$",
"attribute",
")",
"{",
"list",
"(",
"$",
"attributeKey",
",",
"$",
"attributeValue",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"attribute",
")",
";",
"$",
"attributes",
"[",
"trim",
"(",
"$",
"attributeKey",
")",
"]",
"=",
"trim",
"(",
"$",
"attributeValue",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'q'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'q'",
"]",
"=",
"'1.0'",
";",
"}",
"$",
"values",
"[",
"$",
"mediaType",
"]",
"=",
"$",
"attributes",
";",
"}",
"uasort",
"(",
"$",
"values",
",",
"function",
"(",
"array",
"$",
"a",
",",
"array",
"$",
"b",
")",
"{",
"return",
"$",
"b",
"[",
"'q'",
"]",
"<=>",
"$",
"a",
"[",
"'q'",
"]",
";",
"}",
")",
";",
"return",
"$",
"values",
";",
"}"
] | @param string $header
@return array | [
"@param",
"string",
"$header"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptNegotiator.php#L60-L84 |
chubbyphp/chubbyphp-negotiation | src/AcceptNegotiator.php | AcceptNegotiator.compareAgainstSupportedMediaTypes | private function compareAgainstSupportedMediaTypes(array $aggregatedValues)
{
if (null !== $negotiatedValue = $this->exactCompareAgainstSupportedMediaTypes($aggregatedValues)) {
return $negotiatedValue;
}
if (null !== $negotiatedValue = $this->typeCompareAgainstSupportedMediaTypes($aggregatedValues)) {
return $negotiatedValue;
}
if (isset($aggregatedValues['*/*'])) {
return new NegotiatedValue(reset($this->supportedMediaTypes), $aggregatedValues['*/*']);
}
return null;
} | php | private function compareAgainstSupportedMediaTypes(array $aggregatedValues)
{
if (null !== $negotiatedValue = $this->exactCompareAgainstSupportedMediaTypes($aggregatedValues)) {
return $negotiatedValue;
}
if (null !== $negotiatedValue = $this->typeCompareAgainstSupportedMediaTypes($aggregatedValues)) {
return $negotiatedValue;
}
if (isset($aggregatedValues['*/*'])) {
return new NegotiatedValue(reset($this->supportedMediaTypes), $aggregatedValues['*/*']);
}
return null;
} | [
"private",
"function",
"compareAgainstSupportedMediaTypes",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"negotiatedValue",
"=",
"$",
"this",
"->",
"exactCompareAgainstSupportedMediaTypes",
"(",
"$",
"aggregatedValues",
")",
")",
"{",
"return",
"$",
"negotiatedValue",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"negotiatedValue",
"=",
"$",
"this",
"->",
"typeCompareAgainstSupportedMediaTypes",
"(",
"$",
"aggregatedValues",
")",
")",
"{",
"return",
"$",
"negotiatedValue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"aggregatedValues",
"[",
"'*/*'",
"]",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"reset",
"(",
"$",
"this",
"->",
"supportedMediaTypes",
")",
",",
"$",
"aggregatedValues",
"[",
"'*/*'",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptNegotiator.php#L91-L106 |
chubbyphp/chubbyphp-negotiation | src/AcceptNegotiator.php | AcceptNegotiator.exactCompareAgainstSupportedMediaTypes | private function exactCompareAgainstSupportedMediaTypes(array $aggregatedValues)
{
foreach ($aggregatedValues as $mediaType => $attributes) {
if ('*/*' === $mediaType) {
continue;
}
if (in_array($mediaType, $this->supportedMediaTypes, true)) {
return new NegotiatedValue($mediaType, $attributes);
}
}
return null;
} | php | private function exactCompareAgainstSupportedMediaTypes(array $aggregatedValues)
{
foreach ($aggregatedValues as $mediaType => $attributes) {
if ('*/*' === $mediaType) {
continue;
}
if (in_array($mediaType, $this->supportedMediaTypes, true)) {
return new NegotiatedValue($mediaType, $attributes);
}
}
return null;
} | [
"private",
"function",
"exactCompareAgainstSupportedMediaTypes",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"foreach",
"(",
"$",
"aggregatedValues",
"as",
"$",
"mediaType",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"'*/*'",
"===",
"$",
"mediaType",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"mediaType",
",",
"$",
"this",
"->",
"supportedMediaTypes",
",",
"true",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"$",
"mediaType",
",",
"$",
"attributes",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptNegotiator.php#L113-L126 |
chubbyphp/chubbyphp-negotiation | src/AcceptNegotiator.php | AcceptNegotiator.typeCompareAgainstSupportedMediaTypes | private function typeCompareAgainstSupportedMediaTypes(array $aggregatedValues)
{
foreach ($aggregatedValues as $mediaType => $attributes) {
if ('*/*' === $mediaType) {
continue;
}
$mediaTypeParts = explode('/', $mediaType);
if (2 !== count($mediaTypeParts)) {
continue; // skip invalid value
}
list($type, $subType) = $mediaTypeParts;
if ('*' === $type || '*' !== $subType) {
continue; // skip invalid value
}
foreach ($this->supportedMediaTypes as $supportedMediaType) {
if (1 === preg_match('/^'.preg_quote($type).'\/.+$/', $supportedMediaType)) {
return new NegotiatedValue($supportedMediaType, $attributes);
}
}
}
return null;
} | php | private function typeCompareAgainstSupportedMediaTypes(array $aggregatedValues)
{
foreach ($aggregatedValues as $mediaType => $attributes) {
if ('*/*' === $mediaType) {
continue;
}
$mediaTypeParts = explode('/', $mediaType);
if (2 !== count($mediaTypeParts)) {
continue; // skip invalid value
}
list($type, $subType) = $mediaTypeParts;
if ('*' === $type || '*' !== $subType) {
continue; // skip invalid value
}
foreach ($this->supportedMediaTypes as $supportedMediaType) {
if (1 === preg_match('/^'.preg_quote($type).'\/.+$/', $supportedMediaType)) {
return new NegotiatedValue($supportedMediaType, $attributes);
}
}
}
return null;
} | [
"private",
"function",
"typeCompareAgainstSupportedMediaTypes",
"(",
"array",
"$",
"aggregatedValues",
")",
"{",
"foreach",
"(",
"$",
"aggregatedValues",
"as",
"$",
"mediaType",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"'*/*'",
"===",
"$",
"mediaType",
")",
"{",
"continue",
";",
"}",
"$",
"mediaTypeParts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"mediaType",
")",
";",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"mediaTypeParts",
")",
")",
"{",
"continue",
";",
"// skip invalid value",
"}",
"list",
"(",
"$",
"type",
",",
"$",
"subType",
")",
"=",
"$",
"mediaTypeParts",
";",
"if",
"(",
"'*'",
"===",
"$",
"type",
"||",
"'*'",
"!==",
"$",
"subType",
")",
"{",
"continue",
";",
"// skip invalid value",
"}",
"foreach",
"(",
"$",
"this",
"->",
"supportedMediaTypes",
"as",
"$",
"supportedMediaType",
")",
"{",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/^'",
".",
"preg_quote",
"(",
"$",
"type",
")",
".",
"'\\/.+$/'",
",",
"$",
"supportedMediaType",
")",
")",
"{",
"return",
"new",
"NegotiatedValue",
"(",
"$",
"supportedMediaType",
",",
"$",
"attributes",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | @param array $aggregatedValues
@return NegotiatedValueInterface|null | [
"@param",
"array",
"$aggregatedValues"
] | train | https://github.com/chubbyphp/chubbyphp-negotiation/blob/f4f8a10f2f067ecd868db9177c81f00428c42049/src/AcceptNegotiator.php#L133-L159 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.