repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mridang/pearify | src/Pearify/Utils/ComposerUtils.php | ComposerUtils.readFile | public static function readFile($package)
{
$root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))));
$path = implode(DIRECTORY_SEPARATOR, array($root, $package, 'composer.json'));
Logger::trace("Reading composer file %s", $path);
if (file_exists($path)) {
$composer = json_decode(file_get_contents($path), true);
if (array_key_exists('require', $composer) && !empty($composer['require'])) {
$directories = array($package);
Logger::trace("Checking dependencies for package %s", $package);
foreach ($composer['require'] as $requirement => $version) {
$directories = array_merge(self::readFile($requirement), $directories);
}
return $directories;
} else {
Logger::trace("Package %s has no dependencies", $package);
return array($package);
}
} else {
return array();
}
} | php | public static function readFile($package)
{
$root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))));
$path = implode(DIRECTORY_SEPARATOR, array($root, $package, 'composer.json'));
Logger::trace("Reading composer file %s", $path);
if (file_exists($path)) {
$composer = json_decode(file_get_contents($path), true);
if (array_key_exists('require', $composer) && !empty($composer['require'])) {
$directories = array($package);
Logger::trace("Checking dependencies for package %s", $package);
foreach ($composer['require'] as $requirement => $version) {
$directories = array_merge(self::readFile($requirement), $directories);
}
return $directories;
} else {
Logger::trace("Package %s has no dependencies", $package);
return array($package);
}
} else {
return array();
}
} | [
"public",
"static",
"function",
"readFile",
"(",
"$",
"package",
")",
"{",
"$",
"root",
"=",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"__FILE__",
")",
")",
")",
")",
")",
")",
";",
"$",
"path",
... | Recursively reads a package and all the child dependency packages and returns a list of
packages
@param $package string the name of the package to check
@return array the array of child package names | [
"Recursively",
"reads",
"a",
"package",
"and",
"all",
"the",
"child",
"dependency",
"packages",
"and",
"returns",
"a",
"list",
"of",
"packages"
] | 7bc0710beb4165164e07f88b456de47cad8b3002 | https://github.com/mridang/pearify/blob/7bc0710beb4165164e07f88b456de47cad8b3002/src/Pearify/Utils/ComposerUtils.php#L55-L76 | train |
ravage84/SwissPaymentSlipPdf | src/PaymentSlipPdf.php | PaymentSlipPdf.writePaymentSlipLines | protected function writePaymentSlipLines($elementName, array $element)
{
if (!is_string($elementName)) {
throw new \InvalidArgumentException('$elementName is not a string!');
}
if (!isset($element['lines'])) {
throw new \InvalidArgumentException('$element contains not "lines" key!');
}
if (!isset($element['attributes'])) {
throw new \InvalidArgumentException('$element contains not "attributes" key!');
}
$lines = $element['lines'];
$attributes = $element['attributes'];
if (!is_array($lines)) {
throw new \InvalidArgumentException('$lines is not an array!');
}
if (!is_array($attributes)) {
throw new \InvalidArgumentException('$attributes is not an array!');
}
$posX = $attributes['PosX'];
$posY = $attributes['PosY'];
$height = $attributes['Height'];
$width = $attributes['Width'];
$fontFamily = $attributes['FontFamily'];
$background = $attributes['Background'];
$fontSize = $attributes['FontSize'];
$fontColor = $attributes['FontColor'];
$lineHeight = $attributes['LineHeight'];
$textAlign = $attributes['TextAlign'];
$this->setFont($fontFamily, $fontSize, $fontColor);
if ($background != 'transparent') {
$this->setBackground($background);
$fill = true;
} else {
$fill = false;
}
foreach ($lines as $lineNr => $line) {
$this->setPosition(
$this->paymentSlip->getSlipPosX() + $posX,
$this->paymentSlip->getSlipPosY() + $posY + ($lineNr * $lineHeight)
);
$this->createCell($width, $height, $line, $textAlign, $fill);
}
return $this;
} | php | protected function writePaymentSlipLines($elementName, array $element)
{
if (!is_string($elementName)) {
throw new \InvalidArgumentException('$elementName is not a string!');
}
if (!isset($element['lines'])) {
throw new \InvalidArgumentException('$element contains not "lines" key!');
}
if (!isset($element['attributes'])) {
throw new \InvalidArgumentException('$element contains not "attributes" key!');
}
$lines = $element['lines'];
$attributes = $element['attributes'];
if (!is_array($lines)) {
throw new \InvalidArgumentException('$lines is not an array!');
}
if (!is_array($attributes)) {
throw new \InvalidArgumentException('$attributes is not an array!');
}
$posX = $attributes['PosX'];
$posY = $attributes['PosY'];
$height = $attributes['Height'];
$width = $attributes['Width'];
$fontFamily = $attributes['FontFamily'];
$background = $attributes['Background'];
$fontSize = $attributes['FontSize'];
$fontColor = $attributes['FontColor'];
$lineHeight = $attributes['LineHeight'];
$textAlign = $attributes['TextAlign'];
$this->setFont($fontFamily, $fontSize, $fontColor);
if ($background != 'transparent') {
$this->setBackground($background);
$fill = true;
} else {
$fill = false;
}
foreach ($lines as $lineNr => $line) {
$this->setPosition(
$this->paymentSlip->getSlipPosX() + $posX,
$this->paymentSlip->getSlipPosY() + $posY + ($lineNr * $lineHeight)
);
$this->createCell($width, $height, $line, $textAlign, $fill);
}
return $this;
} | [
"protected",
"function",
"writePaymentSlipLines",
"(",
"$",
"elementName",
",",
"array",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"elementName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$elementName is not a... | Write the lines of an element to the PDf
@param string $elementName The name of the element.
@param array $element The element.
@return $this The current instance for a fluent interface. | [
"Write",
"the",
"lines",
"of",
"an",
"element",
"to",
"the",
"PDf"
] | 5806366158648f1d9b0af614d24ff08d65cc43b6 | https://github.com/ravage84/SwissPaymentSlipPdf/blob/5806366158648f1d9b0af614d24ff08d65cc43b6/src/PaymentSlipPdf.php#L123-L172 | train |
ravage84/SwissPaymentSlipPdf | src/PaymentSlipPdf.php | PaymentSlipPdf.createPaymentSlip | public function createPaymentSlip(PaymentSlip $paymentSlip)
{
$this->paymentSlip = $paymentSlip;
// Place background image
if ($paymentSlip->getDisplayBackground()) {
$this->displayImage($paymentSlip->getSlipBackground());
}
$elements = $paymentSlip->getAllElements();
// Go through all elements, write each line
foreach ($elements as $elementName => $element) {
$this->writePaymentSlipLines($elementName, $element);
}
$this->paymentSlip = null;
return $this;
} | php | public function createPaymentSlip(PaymentSlip $paymentSlip)
{
$this->paymentSlip = $paymentSlip;
// Place background image
if ($paymentSlip->getDisplayBackground()) {
$this->displayImage($paymentSlip->getSlipBackground());
}
$elements = $paymentSlip->getAllElements();
// Go through all elements, write each line
foreach ($elements as $elementName => $element) {
$this->writePaymentSlipLines($elementName, $element);
}
$this->paymentSlip = null;
return $this;
} | [
"public",
"function",
"createPaymentSlip",
"(",
"PaymentSlip",
"$",
"paymentSlip",
")",
"{",
"$",
"this",
"->",
"paymentSlip",
"=",
"$",
"paymentSlip",
";",
"// Place background image",
"if",
"(",
"$",
"paymentSlip",
"->",
"getDisplayBackground",
"(",
")",
")",
... | Create a payment slip as a PDF using the PDF engine
@param PaymentSlip $paymentSlip The payment slip to create as PDF.
@return $this The current instance for a fluent interface. | [
"Create",
"a",
"payment",
"slip",
"as",
"a",
"PDF",
"using",
"the",
"PDF",
"engine"
] | 5806366158648f1d9b0af614d24ff08d65cc43b6 | https://github.com/ravage84/SwissPaymentSlipPdf/blob/5806366158648f1d9b0af614d24ff08d65cc43b6/src/PaymentSlipPdf.php#L180-L199 | train |
k-gun/oppa | src/Query/Builder.php | Builder.setTable | public function setTable(string $table): self
{
$this->table = $this->agent->escapeIdentifier($table);
return $this;
} | php | public function setTable(string $table): self
{
$this->table = $this->agent->escapeIdentifier($table);
return $this;
} | [
"public",
"function",
"setTable",
"(",
"string",
"$",
"table",
")",
":",
"self",
"{",
"$",
"this",
"->",
"table",
"=",
"$",
"this",
"->",
"agent",
"->",
"escapeIdentifier",
"(",
"$",
"table",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set table.
@param string $table
@return self | [
"Set",
"table",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L149-L154 | train |
k-gun/oppa | src/Query/Builder.php | Builder.selectMore | public function selectMore($field, string $as = null): self
{
return $this->select($field, $as, false);
} | php | public function selectMore($field, string $as = null): self
{
return $this->select($field, $as, false);
} | [
"public",
"function",
"selectMore",
"(",
"$",
"field",
",",
"string",
"$",
"as",
"=",
"null",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"select",
"(",
"$",
"field",
",",
"$",
"as",
",",
"false",
")",
";",
"}"
] | Select more.
@param string|Builder $field
@param string|null $as
@return self | [
"Select",
"more",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L227-L230 | train |
k-gun/oppa | src/Query/Builder.php | Builder.selectJsonMore | public function selectJsonMore($field, string $as, string $type = 'object'): self
{
return $this->selectJson($field, $as, $type, false);
} | php | public function selectJsonMore($field, string $as, string $type = 'object'): self
{
return $this->selectJson($field, $as, $type, false);
} | [
"public",
"function",
"selectJsonMore",
"(",
"$",
"field",
",",
"string",
"$",
"as",
",",
"string",
"$",
"type",
"=",
"'object'",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"selectJson",
"(",
"$",
"field",
",",
"$",
"as",
",",
"$",
"type",
... | Select json more.
@param string|array $field
@param string $as
@param string $type
@return self | [
"Select",
"json",
"more",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L431-L434 | train |
k-gun/oppa | src/Query/Builder.php | Builder.selectRandom | public function selectRandom($field): self
{
return $this->push('select', $this->prepareField($field))
->push('where', [[$this->sql('random() < 0.01'), '']]);
} | php | public function selectRandom($field): self
{
return $this->push('select', $this->prepareField($field))
->push('where', [[$this->sql('random() < 0.01'), '']]);
} | [
"public",
"function",
"selectRandom",
"(",
"$",
"field",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"push",
"(",
"'select'",
",",
"$",
"this",
"->",
"prepareField",
"(",
"$",
"field",
")",
")",
"->",
"push",
"(",
"'where'",
",",
"[",
"[",
... | Select random.
@param string|array|Builder $field
@return self | [
"Select",
"random",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L441-L445 | train |
k-gun/oppa | src/Query/Builder.php | Builder.joinLeft | public function joinLeft(string $to, string $as, string $on, $onParams = null): self
{
return $this->join($to, $as, $on, $onParams, 'LEFT');
} | php | public function joinLeft(string $to, string $as, string $on, $onParams = null): self
{
return $this->join($to, $as, $on, $onParams, 'LEFT');
} | [
"public",
"function",
"joinLeft",
"(",
"string",
"$",
"to",
",",
"string",
"$",
"as",
",",
"string",
"$",
"on",
",",
"$",
"onParams",
"=",
"null",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"to",
",",
"$",
"as",
",",
... | Join left.
@param string $to
@param string $as
@param string $on
@param any|null $onParams
@return self | [
"Join",
"left",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L530-L533 | train |
k-gun/oppa | src/Query/Builder.php | Builder.joinUsing | public function joinUsing(string $to, string $as, string $using, $usingParams = null, string $type = ''): self
{
return $this->push('join', sprintf('%sJOIN %s AS %s USING (%s)',
$type ? strtoupper($type) .' ' : '',
$this->prepareField($to),
$this->agent->quoteField($as),
$this->agent->prepareIdentifier($using, $usingParams))
);
} | php | public function joinUsing(string $to, string $as, string $using, $usingParams = null, string $type = ''): self
{
return $this->push('join', sprintf('%sJOIN %s AS %s USING (%s)',
$type ? strtoupper($type) .' ' : '',
$this->prepareField($to),
$this->agent->quoteField($as),
$this->agent->prepareIdentifier($using, $usingParams))
);
} | [
"public",
"function",
"joinUsing",
"(",
"string",
"$",
"to",
",",
"string",
"$",
"as",
",",
"string",
"$",
"using",
",",
"$",
"usingParams",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"pu... | Join using.
@param string $to
@param string $as
@param string $using
@param any|null $usingParams
@param string $type
@return self | [
"Join",
"using",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L557-L565 | train |
k-gun/oppa | src/Query/Builder.php | Builder.joinLeftUsing | public function joinLeftUsing(string $to, string $as, string $using, $usingParams = null): self
{
return $this->joinUsing($to, $as, $using, $usingParams, 'LEFT');
} | php | public function joinLeftUsing(string $to, string $as, string $using, $usingParams = null): self
{
return $this->joinUsing($to, $as, $using, $usingParams, 'LEFT');
} | [
"public",
"function",
"joinLeftUsing",
"(",
"string",
"$",
"to",
",",
"string",
"$",
"as",
",",
"string",
"$",
"using",
",",
"$",
"usingParams",
"=",
"null",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"joinUsing",
"(",
"$",
"to",
",",
"$",
... | Join left using.
@param string $to
@param string $as
@param string $using
@param any|null $usingParams
@return self | [
"Join",
"left",
"using",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L575-L578 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereEqual | public function whereEqual($field, $param, string $op = ''): self
{
return $this->where($this->prepareField($field) .' = ?', $param, $op);
} | php | public function whereEqual($field, $param, string $op = ''): self
{
return $this->where($this->prepareField($field) .' = ?', $param, $op);
} | [
"public",
"function",
"whereEqual",
"(",
"$",
"field",
",",
"$",
"param",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"this",
"->",
"prepareField",
"(",
"$",
"field",
")",
".",
"' = ?'... | Where equal.
@param string|array|Builder $field
@param any $param
@param string $op
@return self | [
"Where",
"equal",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L717-L720 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereNull | public function whereNull($field, string $op = ''): self
{
return $this->where($this->prepareField($field) .' IS NULL', null, $op);
} | php | public function whereNull($field, string $op = ''): self
{
return $this->where($this->prepareField($field) .' IS NULL', null, $op);
} | [
"public",
"function",
"whereNull",
"(",
"$",
"field",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"this",
"->",
"prepareField",
"(",
"$",
"field",
")",
".",
"' IS NULL'",
",",
"null",
... | Where null.
@param string|array|Builder $field
@param string $op
@return self | [
"Where",
"null",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L740-L743 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereIn | public function whereIn($field, $param, string $op = ''): self
{
$ops = ['?'];
if (is_array($param)) {
$ops = array_fill(0, count($param), '?');
}
return $this->where($this->prepareField($field) .' IN ('. join(', ', $ops) .')', $param, $op);
} | php | public function whereIn($field, $param, string $op = ''): self
{
$ops = ['?'];
if (is_array($param)) {
$ops = array_fill(0, count($param), '?');
}
return $this->where($this->prepareField($field) .' IN ('. join(', ', $ops) .')', $param, $op);
} | [
"public",
"function",
"whereIn",
"(",
"$",
"field",
",",
"$",
"param",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"$",
"ops",
"=",
"[",
"'?'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"$",
"ops",
"="... | Where in.
@param string|array|Builder $field
@param array|Builder $param
@param string $op
@return self | [
"Where",
"in",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L763-L771 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereBetween | public function whereBetween($field, array $params, string $op = ''): self
{
return $this->where($this->prepareField($field) .' BETWEEN ? AND ?', $params, $op);
} | php | public function whereBetween($field, array $params, string $op = ''): self
{
return $this->where($this->prepareField($field) .' BETWEEN ? AND ?', $params, $op);
} | [
"public",
"function",
"whereBetween",
"(",
"$",
"field",
",",
"array",
"$",
"params",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"this",
"->",
"prepareField",
"(",
"$",
"field",
")",
... | Where between.
@param string|array|Builder $field
@param array $params
@param string $op
@return self | [
"Where",
"between",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L797-L800 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereLike | public function whereLike($field, $arguments, bool $ilike = false, bool $not = false, string $op = ''): self
{
// @note to me..
// 'foo%' Anything starts with "foo"
// '%foo' Anything ends with "foo"
// '%foo%' Anything have "foo" in any position
// 'f_o%' Anything have "o" in the second position
// 'f_%_%' Anything starts with "f" and are at least 3 characters in length
// 'f%o' Anything starts with "f" and ends with "o"
$arguments = (array) $arguments;
$searchArguments = array_slice($arguments, 0, 3);
if ($arguments != null) {
// eg: (??, ['%', 'apple', '%', 'id']), (%n, ['%', 'apple', '%', 'id'])
$field = $this->agent->prepare($field, array_slice($arguments, 3));
}
$search = '';
switch (count($searchArguments)) {
case 1: // none, eg: 'apple', ['apple']
[$start, $search, $end] = ['', $searchArguments[0], ''];
break;
case 2: // start/end, eg: ['%', 'apple'], ['apple', '%']
if ($searchArguments[0] == '%') {
[$start, $search, $end] = ['%', $searchArguments[1], ''];
} elseif ($searchArguments[1] == '%') {
[$start, $search, $end] = ['', $searchArguments[0], '%'];
}
break;
case 3: // both, eg: ['%', 'apple', '%']
[$start, $search, $end] = $searchArguments;
break;
}
$search = trim((string) $search);
if ($search == '') {
throw new BuilderException('Like search cannot be empty!');
}
$not = $not ? 'NOT ' : '';
if (is_string($field) && strpos($field, '(') === false) {
$field = $this->prepareField($field, false);
}
$search = $end . $this->agent->escape($search, '%sl', false) . $start;
$where = [];
$fields = (array) $field;
if (!$ilike) {
foreach ($fields as $field) {
$where[] = sprintf("%s %sLIKE '%s'", $field, $not, $search);
}
} else {
foreach ($fields as $field) {
if ($this->agent->isMysql()) {
$where[] = sprintf("lower(%s) %sLIKE lower('%s')", $field, $not, $search);
} elseif ($this->agent->isPgsql()) {
$where[] = sprintf("%s %sILIKE '%s'", $field, $not, $search);
}
}
}
$where = count($where) > 1 ? '('. join(' OR ', $where) .')' : join(' OR ', $where);
return $this->where($where);
} | php | public function whereLike($field, $arguments, bool $ilike = false, bool $not = false, string $op = ''): self
{
// @note to me..
// 'foo%' Anything starts with "foo"
// '%foo' Anything ends with "foo"
// '%foo%' Anything have "foo" in any position
// 'f_o%' Anything have "o" in the second position
// 'f_%_%' Anything starts with "f" and are at least 3 characters in length
// 'f%o' Anything starts with "f" and ends with "o"
$arguments = (array) $arguments;
$searchArguments = array_slice($arguments, 0, 3);
if ($arguments != null) {
// eg: (??, ['%', 'apple', '%', 'id']), (%n, ['%', 'apple', '%', 'id'])
$field = $this->agent->prepare($field, array_slice($arguments, 3));
}
$search = '';
switch (count($searchArguments)) {
case 1: // none, eg: 'apple', ['apple']
[$start, $search, $end] = ['', $searchArguments[0], ''];
break;
case 2: // start/end, eg: ['%', 'apple'], ['apple', '%']
if ($searchArguments[0] == '%') {
[$start, $search, $end] = ['%', $searchArguments[1], ''];
} elseif ($searchArguments[1] == '%') {
[$start, $search, $end] = ['', $searchArguments[0], '%'];
}
break;
case 3: // both, eg: ['%', 'apple', '%']
[$start, $search, $end] = $searchArguments;
break;
}
$search = trim((string) $search);
if ($search == '') {
throw new BuilderException('Like search cannot be empty!');
}
$not = $not ? 'NOT ' : '';
if (is_string($field) && strpos($field, '(') === false) {
$field = $this->prepareField($field, false);
}
$search = $end . $this->agent->escape($search, '%sl', false) . $start;
$where = [];
$fields = (array) $field;
if (!$ilike) {
foreach ($fields as $field) {
$where[] = sprintf("%s %sLIKE '%s'", $field, $not, $search);
}
} else {
foreach ($fields as $field) {
if ($this->agent->isMysql()) {
$where[] = sprintf("lower(%s) %sLIKE lower('%s')", $field, $not, $search);
} elseif ($this->agent->isPgsql()) {
$where[] = sprintf("%s %sILIKE '%s'", $field, $not, $search);
}
}
}
$where = count($where) > 1 ? '('. join(' OR ', $where) .')' : join(' OR ', $where);
return $this->where($where);
} | [
"public",
"function",
"whereLike",
"(",
"$",
"field",
",",
"$",
"arguments",
",",
"bool",
"$",
"ilike",
"=",
"false",
",",
"bool",
"$",
"not",
"=",
"false",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"// @note to me..",
"// 'foo%' Any... | Where like.
@param string|array|Builder $field
@param string|array $arguments
@param bool $ilike
@param bool $not
@param string $op
@return self | [
"Where",
"like",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L871-L937 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereNotLike | public function whereNotLike($field, $arguments, bool $ilike = false, string $op = ''): self
{
return $this->whereLike($field, $arguments, $ilike, true, $op);
} | php | public function whereNotLike($field, $arguments, bool $ilike = false, string $op = ''): self
{
return $this->whereLike($field, $arguments, $ilike, true, $op);
} | [
"public",
"function",
"whereNotLike",
"(",
"$",
"field",
",",
"$",
"arguments",
",",
"bool",
"$",
"ilike",
"=",
"false",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"whereLike",
"(",
"$",
"field",
",",
"... | Where not like.
@param string|array|Builder $field
@param string|array $arguments
@param bool $ilike
@param string $op
@return self | [
"Where",
"not",
"like",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L947-L950 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereLikeBoth | public function whereLikeBoth($field, string $search, bool $ilike = false, bool $not = false, string $op = ''): self
{
return $this->whereLike($field, ['%', $search, '%'], $ilike, $not, $op);
} | php | public function whereLikeBoth($field, string $search, bool $ilike = false, bool $not = false, string $op = ''): self
{
return $this->whereLike($field, ['%', $search, '%'], $ilike, $not, $op);
} | [
"public",
"function",
"whereLikeBoth",
"(",
"$",
"field",
",",
"string",
"$",
"search",
",",
"bool",
"$",
"ilike",
"=",
"false",
",",
"bool",
"$",
"not",
"=",
"false",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this... | Where like both.
@param string|array|Builder $field
@param string $search
@param bool $ilike
@param bool $not
@param string $op
@return self | [
"Where",
"like",
"both",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L989-L992 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereExists | public function whereExists($query, array $queryParams = null, string $op = ''): self
{
if ($query instanceof Builder) {
$query = $query->toString();
}
if ($queryParams != null) {
$query = $this->agent->prepare($query, $queryParams);
}
return $this->where('EXISTS ('. $query .')', null, $op);
} | php | public function whereExists($query, array $queryParams = null, string $op = ''): self
{
if ($query instanceof Builder) {
$query = $query->toString();
}
if ($queryParams != null) {
$query = $this->agent->prepare($query, $queryParams);
}
return $this->where('EXISTS ('. $query .')', null, $op);
} | [
"public",
"function",
"whereExists",
"(",
"$",
"query",
",",
"array",
"$",
"queryParams",
"=",
"null",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"Builder",
")",
"{",
"$",
"query",
"=",
"$",
"... | Where exists.
@param string|Builder $query
@param array|null $queryParams
@param string $op
@return self | [
"Where",
"exists",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L1001-L1012 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereId | public function whereId(string $field, $id, string $op = ''): self
{
return $this->where('?? = ?', [$field, $id], $op);
} | php | public function whereId(string $field, $id, string $op = ''): self
{
return $this->where('?? = ?', [$field, $id], $op);
} | [
"public",
"function",
"whereId",
"(",
"string",
"$",
"field",
",",
"$",
"id",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"'?? = ?'",
",",
"[",
"$",
"field",
",",
"$",
"id",
"]",
",",
"... | Where id.
@param string $field
@param int|string $id
@param string $op
@return self | [
"Where",
"id",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L1041-L1044 | train |
k-gun/oppa | src/Query/Builder.php | Builder.whereIds | public function whereIds(string $field, array $ids, string $op = ''): self
{
return $this->where('?? IN (?)', [$field, $ids], $op);
} | php | public function whereIds(string $field, array $ids, string $op = ''): self
{
return $this->where('?? IN (?)', [$field, $ids], $op);
} | [
"public",
"function",
"whereIds",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"ids",
",",
"string",
"$",
"op",
"=",
"''",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"'?? IN (?)'",
",",
"[",
"$",
"field",
",",
"$",
"ids",
... | Where ids.
@param string $field
@param array[int|string] $ids
@param string $op
@return self | [
"Where",
"ids",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L1053-L1056 | train |
k-gun/oppa | src/Query/Builder.php | Builder.orderBy | public function orderBy($field, string $op = null): self
{
// check operator is valid
if ($op == null) {
return $this->push('orderBy', $this->prepareField($field));
}
$op = strtoupper($op);
if ($op != self::OP_ASC && $op != self::OP_DESC) {
throw new BuilderException('Available ops: ASC, DESC');
}
return $this->push('orderBy', $this->prepareField($field) .' '. $op);
} | php | public function orderBy($field, string $op = null): self
{
// check operator is valid
if ($op == null) {
return $this->push('orderBy', $this->prepareField($field));
}
$op = strtoupper($op);
if ($op != self::OP_ASC && $op != self::OP_DESC) {
throw new BuilderException('Available ops: ASC, DESC');
}
return $this->push('orderBy', $this->prepareField($field) .' '. $op);
} | [
"public",
"function",
"orderBy",
"(",
"$",
"field",
",",
"string",
"$",
"op",
"=",
"null",
")",
":",
"self",
"{",
"// check operator is valid",
"if",
"(",
"$",
"op",
"==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"push",
"(",
"'orderBy'",
",",
... | Order by.
@param string|array|Builder $field
@param string $op
@return self
@throws Oppa\Query\BuilderException | [
"Order",
"by",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L1203-L1216 | train |
k-gun/oppa | src/Query/Builder.php | Builder.prepareField | private function prepareField($field, bool $join = true)
{
if ($field == '*') {
return $field;
}
if ($field instanceof Builder || $field instanceof Sql) {
return '('. $field->toString() .')';
} elseif ($field instanceof Identifier) {
return $this->agent->escapeIdentifier($field);
}
if (is_string($field)) {
$field = Util::split(',', trim($field));
}
if (is_array($field)) {
return $this->agent->escapeIdentifier($field, $join);
}
throw new BuilderException(sprintf('String, array or Builder type fields are accepted only,'.
' %s given', gettype($field)));
} | php | private function prepareField($field, bool $join = true)
{
if ($field == '*') {
return $field;
}
if ($field instanceof Builder || $field instanceof Sql) {
return '('. $field->toString() .')';
} elseif ($field instanceof Identifier) {
return $this->agent->escapeIdentifier($field);
}
if (is_string($field)) {
$field = Util::split(',', trim($field));
}
if (is_array($field)) {
return $this->agent->escapeIdentifier($field, $join);
}
throw new BuilderException(sprintf('String, array or Builder type fields are accepted only,'.
' %s given', gettype($field)));
} | [
"private",
"function",
"prepareField",
"(",
"$",
"field",
",",
"bool",
"$",
"join",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"field",
"==",
"'*'",
")",
"{",
"return",
"$",
"field",
";",
"}",
"if",
"(",
"$",
"field",
"instanceof",
"Builder",
"||",
"$"... | Prepare field.
@param string|array|Builder $field
@param bool $join
@return string|array | [
"Prepare",
"field",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Query/Builder.php#L1663-L1685 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.sanitizeCountry | public static function sanitizeCountry($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getCountry();
}
if ($default) {
$default = Locale::sanitizeCountry($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/(?<country>[a-z]{2})$/ui", $locale, $found)) {
return $default;
}
return Text::toUpper($found['country']);
} | php | public static function sanitizeCountry($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getCountry();
}
if ($default) {
$default = Locale::sanitizeCountry($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/(?<country>[a-z]{2})$/ui", $locale, $found)) {
return $default;
}
return Text::toUpper($found['country']);
} | [
"public",
"static",
"function",
"sanitizeCountry",
"(",
"$",
"locale",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"locale",
"instanceof",
"Locale",
")",
"{",
"return",
"$",
"locale",
"->",
"getCountry",
"(",
")",
";",
"}",
"if",
"(",
... | Sanitize given country from locale.
Must be a simple locale without code set, currency or similar (e. g. "de_DE" or "de-de" or "DE").
@param string|Locale $locale
@param string|Locale $default [optional] The default locale to return if $locale is invalid
@return null|string | [
"Sanitize",
"given",
"country",
"from",
"locale",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L85-L103 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.sanitizeLanguage | public static function sanitizeLanguage($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getLanguage();
}
if ($default) {
$default = Locale::sanitizeLanguage($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/^(?<language>[a-z]{2})/ui", $locale, $found)) {
return $default;
}
return Text::toLower($found['language']);
} | php | public static function sanitizeLanguage($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getLanguage();
}
if ($default) {
$default = Locale::sanitizeLanguage($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/^(?<language>[a-z]{2})/ui", $locale, $found)) {
return $default;
}
return Text::toLower($found['language']);
} | [
"public",
"static",
"function",
"sanitizeLanguage",
"(",
"$",
"locale",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"locale",
"instanceof",
"Locale",
")",
"{",
"return",
"$",
"locale",
"->",
"getLanguage",
"(",
")",
";",
"}",
"if",
"(",... | Sanitize given language from locale.
Must be a simple locale without code set, currency or similar (e. g. "de_DE" or "de-de" or "de").
@param string|Locale $locale
@param string|Locale $default [optional] The default locale to return if $locale is invalid
@return null|string | [
"Sanitize",
"given",
"language",
"from",
"locale",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L115-L133 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.sanitizeLocale | public static function sanitizeLocale($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getLocale();
}
if ($default) {
$default = Locale::sanitizeLocale($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/^" . Locale::REGEX_LOCALE . "$/ui", $locale, $found)) {
return $default;
}
$found['language'] = Text::toLower($found['language']);
$found['country'] = Text::toUpper($found['country']);
return sprintf("%s_%s", $found['language'], $found['country']);
} | php | public static function sanitizeLocale($locale, $default = null)
{
if ($locale instanceof Locale) {
return $locale->getLocale();
}
if ($default) {
$default = Locale::sanitizeLocale($default, null);
}
$locale = (string) $locale;
$locale = trim($locale);
if (!$locale || !preg_match("/^" . Locale::REGEX_LOCALE . "$/ui", $locale, $found)) {
return $default;
}
$found['language'] = Text::toLower($found['language']);
$found['country'] = Text::toUpper($found['country']);
return sprintf("%s_%s", $found['language'], $found['country']);
} | [
"public",
"static",
"function",
"sanitizeLocale",
"(",
"$",
"locale",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"locale",
"instanceof",
"Locale",
")",
"{",
"return",
"$",
"locale",
"->",
"getLocale",
"(",
")",
";",
"}",
"if",
"(",
"... | Sanitize given locale.
Must be a simple locale without code set, currency or similar (e. g. "de_DE" or "de-de").
@param string|Locale $locale
@param string|Locale $default [optional] The default locale to return if $locale is invalid
@return null|string | [
"Sanitize",
"given",
"locale",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L145-L166 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.getCountryName | public function getCountryName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayRegion($this->locale, $inLocale);
} | php | public function getCountryName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayRegion($this->locale, $inLocale);
} | [
"public",
"function",
"getCountryName",
"(",
"$",
"inLocale",
"=",
"null",
")",
"{",
"$",
"inLocale",
"=",
"Locale",
"::",
"sanitizeLocale",
"(",
"$",
"inLocale",
",",
"$",
"this",
"->",
"locale",
")",
";",
"return",
"\\",
"Locale",
"::",
"getDisplayRegion... | Get country name.
If param $inLocale is not set the result will be in the local original language.
@param Locale|string $inLocale [optional] Set the locale to display value in.
@return string | [
"Get",
"country",
"name",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L191-L196 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.getCountryNameFor | public function getCountryNameFor($locale, $inLocale = null)
{
$locale = '_' . Locale::sanitizeCountry($locale);
$inLocale = Locale::sanitizeLanguage($inLocale, $this->locale);
return \Locale::getDisplayRegion($locale, $inLocale);
} | php | public function getCountryNameFor($locale, $inLocale = null)
{
$locale = '_' . Locale::sanitizeCountry($locale);
$inLocale = Locale::sanitizeLanguage($inLocale, $this->locale);
return \Locale::getDisplayRegion($locale, $inLocale);
} | [
"public",
"function",
"getCountryNameFor",
"(",
"$",
"locale",
",",
"$",
"inLocale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"'_'",
".",
"Locale",
"::",
"sanitizeCountry",
"(",
"$",
"locale",
")",
";",
"$",
"inLocale",
"=",
"Locale",
"::",
"sanitizeLa... | Get country name for specified locale or country-code.
If param $inLocale is not set the result will be in the local original language.
@param Locale|string $locale Locale (or locale part "country") to get name for.
@param Locale|string $inLocale [optional] Set the locale to display value in.
@return string | [
"Get",
"country",
"name",
"for",
"specified",
"locale",
"or",
"country",
"-",
"code",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L208-L214 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.getLanguageName | public function getLanguageName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayLanguage($this->locale, $inLocale);
} | php | public function getLanguageName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayLanguage($this->locale, $inLocale);
} | [
"public",
"function",
"getLanguageName",
"(",
"$",
"inLocale",
"=",
"null",
")",
"{",
"$",
"inLocale",
"=",
"Locale",
"::",
"sanitizeLocale",
"(",
"$",
"inLocale",
",",
"$",
"this",
"->",
"locale",
")",
";",
"return",
"\\",
"Locale",
"::",
"getDisplayLangu... | Get language name.
If param $inLocale is not set the result will be in the local original language.
@param Locale|string $inLocale [optional] Set the locale to display value in.
@return string | [
"Get",
"language",
"name",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L239-L244 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.getLanguageNameFor | public function getLanguageNameFor($locale, $inLocale = null)
{
$locale = Locale::sanitizeLanguage($locale) . '_';
$inLocale = Locale::sanitizeLanguage($inLocale, $this->locale);
return \Locale::getDisplayLanguage($locale, $inLocale);
} | php | public function getLanguageNameFor($locale, $inLocale = null)
{
$locale = Locale::sanitizeLanguage($locale) . '_';
$inLocale = Locale::sanitizeLanguage($inLocale, $this->locale);
return \Locale::getDisplayLanguage($locale, $inLocale);
} | [
"public",
"function",
"getLanguageNameFor",
"(",
"$",
"locale",
",",
"$",
"inLocale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"Locale",
"::",
"sanitizeLanguage",
"(",
"$",
"locale",
")",
".",
"'_'",
";",
"$",
"inLocale",
"=",
"Locale",
"::",
"sanitize... | Get language name for specified locale or language-code.
If param $inLocale is not set the result will be in the local original language.
@param Locale|string $locale Locale (or locale part "language") to get name for.
@param Locale|string $inLocale [optional] Set the locale to display value in.
@return string | [
"Get",
"language",
"name",
"for",
"specified",
"locale",
"or",
"language",
"-",
"code",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L256-L262 | train |
ansas/php-component | src/Component/Locale/Locale.php | Locale.getLocaleName | public function getLocaleName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayName($this->locale, $inLocale);
} | php | public function getLocaleName($inLocale = null)
{
$inLocale = Locale::sanitizeLocale($inLocale, $this->locale);
return \Locale::getDisplayName($this->locale, $inLocale);
} | [
"public",
"function",
"getLocaleName",
"(",
"$",
"inLocale",
"=",
"null",
")",
"{",
"$",
"inLocale",
"=",
"Locale",
"::",
"sanitizeLocale",
"(",
"$",
"inLocale",
",",
"$",
"this",
"->",
"locale",
")",
";",
"return",
"\\",
"Locale",
"::",
"getDisplayName",
... | Get locale name.
If param $inLocale is not set the result will be in the local original language.
@param Locale|string $inLocale [optional] Set the locale to display value in.
@return string | [
"Get",
"locale",
"name",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Locale/Locale.php#L285-L290 | train |
dazzle-php/throwable | src/Throwable/Exception.php | Exception.toStackTrace | public static function toStackTrace($ex)
{
$list = [];
for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
{
$list = array_merge($stack['trace'], $list);
}
return $list;
} | php | public static function toStackTrace($ex)
{
$list = [];
for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
{
$list = array_merge($stack['trace'], $list);
}
return $list;
} | [
"public",
"static",
"function",
"toStackTrace",
"(",
"$",
"ex",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"stack",
"=",
"Throwable",
"::",
"getThrowableStack",
"(",
"$",
"ex",
")",
";",
"$",
"stack",
"!==",
"null",
";",
"$",
"stac... | Return Exception stack trace in array format.
@param \Error|\Exception $ex
@return string[] | [
"Return",
"Exception",
"stack",
"trace",
"in",
"array",
"format",
"."
] | daeec7b8857763765db686412886831704720bd0 | https://github.com/dazzle-php/throwable/blob/daeec7b8857763765db686412886831704720bd0/src/Throwable/Exception.php#L79-L88 | train |
dazzle-php/throwable | src/Throwable/Exception.php | Exception.toThrowableTrace | public static function toThrowableTrace($ex)
{
$list = [];
for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
{
$list[] = Throwable::parseThrowableMessage($stack);
}
return array_reverse($list);
} | php | public static function toThrowableTrace($ex)
{
$list = [];
for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
{
$list[] = Throwable::parseThrowableMessage($stack);
}
return array_reverse($list);
} | [
"public",
"static",
"function",
"toThrowableTrace",
"(",
"$",
"ex",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"stack",
"=",
"Throwable",
"::",
"getThrowableStack",
"(",
"$",
"ex",
")",
";",
"$",
"stack",
"!==",
"null",
";",
"$",
"... | Return Exception throwable trace in array format.
@param \Error|\Exception $ex
@return string[] | [
"Return",
"Exception",
"throwable",
"trace",
"in",
"array",
"format",
"."
] | daeec7b8857763765db686412886831704720bd0 | https://github.com/dazzle-php/throwable/blob/daeec7b8857763765db686412886831704720bd0/src/Throwable/Exception.php#L96-L105 | train |
dazzle-php/throwable | src/Throwable/Exception.php | Exception.toStackString | public static function toStackString($ex)
{
$stack = [];
$i = 0;
$trace = static::toStackTrace($ex);
$pad = strlen(count($trace)) > 2 ?: 2;
foreach ($trace as $element)
{
$stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
++$i;
}
return implode("\n", $stack);
} | php | public static function toStackString($ex)
{
$stack = [];
$i = 0;
$trace = static::toStackTrace($ex);
$pad = strlen(count($trace)) > 2 ?: 2;
foreach ($trace as $element)
{
$stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
++$i;
}
return implode("\n", $stack);
} | [
"public",
"static",
"function",
"toStackString",
"(",
"$",
"ex",
")",
"{",
"$",
"stack",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"$",
"trace",
"=",
"static",
"::",
"toStackTrace",
"(",
"$",
"ex",
")",
";",
"$",
"pad",
"=",
"strlen",
"(",
"... | Return Exception stack trace in string format.
@param \Error|\Exception $ex
@return string | [
"Return",
"Exception",
"stack",
"trace",
"in",
"string",
"format",
"."
] | daeec7b8857763765db686412886831704720bd0 | https://github.com/dazzle-php/throwable/blob/daeec7b8857763765db686412886831704720bd0/src/Throwable/Exception.php#L113-L127 | train |
dazzle-php/throwable | src/Throwable/Exception.php | Exception.toThrowableString | public static function toThrowableString($ex)
{
$stack = [];
$i = 0;
$trace = static::toThrowableTrace($ex);
$pad = strlen(count($trace)) > 2 ?: 2;
foreach ($trace as $element)
{
$stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
++$i;
}
return implode("\n", $stack);
} | php | public static function toThrowableString($ex)
{
$stack = [];
$i = 0;
$trace = static::toThrowableTrace($ex);
$pad = strlen(count($trace)) > 2 ?: 2;
foreach ($trace as $element)
{
$stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
++$i;
}
return implode("\n", $stack);
} | [
"public",
"static",
"function",
"toThrowableString",
"(",
"$",
"ex",
")",
"{",
"$",
"stack",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"$",
"trace",
"=",
"static",
"::",
"toThrowableTrace",
"(",
"$",
"ex",
")",
";",
"$",
"pad",
"=",
"strlen",
... | Return Exception throwable trace in string format.
@param \Error|\Exception $ex
@return string | [
"Return",
"Exception",
"throwable",
"trace",
"in",
"string",
"format",
"."
] | daeec7b8857763765db686412886831704720bd0 | https://github.com/dazzle-php/throwable/blob/daeec7b8857763765db686412886831704720bd0/src/Throwable/Exception.php#L135-L149 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalMapRatings/Plugin/MapRatings.php | MapRatings.loadRatings | private function loadRatings(Map $map)
{
try {
$this->mapRatingsService->load($map);
} catch (PropelException $e) {
$this->logger->error("error loading map ratings", ["exception" => $e]);
}
} | php | private function loadRatings(Map $map)
{
try {
$this->mapRatingsService->load($map);
} catch (PropelException $e) {
$this->logger->error("error loading map ratings", ["exception" => $e]);
}
} | [
"private",
"function",
"loadRatings",
"(",
"Map",
"$",
"map",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"mapRatingsService",
"->",
"load",
"(",
"$",
"map",
")",
";",
"}",
"catch",
"(",
"PropelException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger"... | helper function to load mapratings for current map
@param Map $map | [
"helper",
"function",
"to",
"load",
"mapratings",
"for",
"current",
"map"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalMapRatings/Plugin/MapRatings.php#L100-L107 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/DependencyInjection/Compiler/GameTitleFetchPass.php | GameTitleFetchPass.fetchDataFromRemote | protected function fetchDataFromRemote(Filesystem $fileSytem, ContainerBuilder $container)
{
$curl = new Curl();
$curl->setUrl("https://mp-expansion.com/api/maniaplanet/toZto");
$curl->run();
if ($curl->getCurlInfo()['http_code'] == 200) {
$fileSytem->put(self::MAPPINGS_FILE, $curl->getResponse());
} else {
echo "Can't fetch title mappings from expansion website!\n";
}
} | php | protected function fetchDataFromRemote(Filesystem $fileSytem, ContainerBuilder $container)
{
$curl = new Curl();
$curl->setUrl("https://mp-expansion.com/api/maniaplanet/toZto");
$curl->run();
if ($curl->getCurlInfo()['http_code'] == 200) {
$fileSytem->put(self::MAPPINGS_FILE, $curl->getResponse());
} else {
echo "Can't fetch title mappings from expansion website!\n";
}
} | [
"protected",
"function",
"fetchDataFromRemote",
"(",
"Filesystem",
"$",
"fileSytem",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"curl",
"=",
"new",
"Curl",
"(",
")",
";",
"$",
"curl",
"->",
"setUrl",
"(",
"\"https://mp-expansion.com/api/maniaplanet/... | Fetch title information from eXp api.
@param Filesystem $fileSytem
@param ContainerBuilder $container
@throws \Exception | [
"Fetch",
"title",
"information",
"from",
"eXp",
"api",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/DependencyInjection/Compiler/GameTitleFetchPass.php#L57-L67 | train |
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3 | Soql/Parser/QueryParser.php | QueryParser.parseFunctionArgument | private function parseFunctionArgument($funcName, $context)
{
try
{
return $this->parsePrimitiveValue();
}
catch(\Exception $e)
{
$name = $this->tokenizer->getTokenValue();
if($name)
{
// ADVANCE
$this->tokenizer->readNextToken();
// NESTED FUNCTION
if($this->tokenizer->is(TokenType::LEFT_PAREN))
{
return $this->parseFunctionExpression($name, $context);
}
// ARBITRARY IDENTIFIER, e.g. SOQL NAME
return new AST\SoqlName($name);
}
throw $e;
}
} | php | private function parseFunctionArgument($funcName, $context)
{
try
{
return $this->parsePrimitiveValue();
}
catch(\Exception $e)
{
$name = $this->tokenizer->getTokenValue();
if($name)
{
// ADVANCE
$this->tokenizer->readNextToken();
// NESTED FUNCTION
if($this->tokenizer->is(TokenType::LEFT_PAREN))
{
return $this->parseFunctionExpression($name, $context);
}
// ARBITRARY IDENTIFIER, e.g. SOQL NAME
return new AST\SoqlName($name);
}
throw $e;
}
} | [
"private",
"function",
"parseFunctionArgument",
"(",
"$",
"funcName",
",",
"$",
"context",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"parsePrimitiveValue",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"name",
"... | Parses a single function argument. Can be expression or
function by itself.
@param string $funcName
@param int $context
@throws \Exception
@return Functions\SoqlFunctionInterface|AST\SoqlName | [
"Parses",
"a",
"single",
"function",
"argument",
".",
"Can",
"be",
"expression",
"or",
"function",
"by",
"itself",
"."
] | 7fd3194eb3155f019e34439e586e6baf6cbb202f | https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Soql/Parser/QueryParser.php#L1570-L1596 | train |
joshiausdemwald/Force.com-Toolkit-for-PHP-5.3 | Soql/Parser/QueryParser.php | QueryParser.parseOrderByField | private function parseOrderByField()
{
$retVal = null;
$fieldName = $this->tokenizer->getTokenValue();
$this->tokenizer->expect(TokenType::EXPRESSION);
if($this->tokenizer->is(TokenType::LEFT_PAREN))
{
$retVal = new AST\OrderByFunction($this->parseFunctionExpression($fieldName, Functions\SoqlFunctionInterface::CONTEXT_ORDER_BY));
}
else
{
$retVal = new AST\OrderByField($fieldName);
}
// ASC/DESC
if($this->tokenizer->isKeyword('asc'))
{
$retVal->setDirection(AST\OrderByField::DIRECTION_ASC);
$this->tokenizer->readNextToken();
}
elseif($this->tokenizer->isKeyword('desc'))
{
$retVal->setDirection(AST\OrderByField::DIRECTION_DESC);
$this->tokenizer->readNextToken();
}
if($this->tokenizer->isKeyword('NULLS'))
{
$this->tokenizer->readNextToken();
if($this->tokenizer->isKeyword('last'))
{
$retVal->setNulls(AST\OrderByField::NULLS_LAST);
}
elseif($this->tokenizer->isKeyword('first'))
{
$retVal->setNulls(AST\OrderByField::NULLS_FIRST);
}
else
{
throw new ParseException(sprintf('Unexpected "%s"', $this->tokenizer->getTokenValue()), $this->tokenizer->getLine(), $this->tokenizer->getLinePos(), $this->tokenizer->getInput());
}
$this->tokenizer->expect(TokenType::KEYWORD);
}
return $retVal;
} | php | private function parseOrderByField()
{
$retVal = null;
$fieldName = $this->tokenizer->getTokenValue();
$this->tokenizer->expect(TokenType::EXPRESSION);
if($this->tokenizer->is(TokenType::LEFT_PAREN))
{
$retVal = new AST\OrderByFunction($this->parseFunctionExpression($fieldName, Functions\SoqlFunctionInterface::CONTEXT_ORDER_BY));
}
else
{
$retVal = new AST\OrderByField($fieldName);
}
// ASC/DESC
if($this->tokenizer->isKeyword('asc'))
{
$retVal->setDirection(AST\OrderByField::DIRECTION_ASC);
$this->tokenizer->readNextToken();
}
elseif($this->tokenizer->isKeyword('desc'))
{
$retVal->setDirection(AST\OrderByField::DIRECTION_DESC);
$this->tokenizer->readNextToken();
}
if($this->tokenizer->isKeyword('NULLS'))
{
$this->tokenizer->readNextToken();
if($this->tokenizer->isKeyword('last'))
{
$retVal->setNulls(AST\OrderByField::NULLS_LAST);
}
elseif($this->tokenizer->isKeyword('first'))
{
$retVal->setNulls(AST\OrderByField::NULLS_FIRST);
}
else
{
throw new ParseException(sprintf('Unexpected "%s"', $this->tokenizer->getTokenValue()), $this->tokenizer->getLine(), $this->tokenizer->getLinePos(), $this->tokenizer->getInput());
}
$this->tokenizer->expect(TokenType::KEYWORD);
}
return $retVal;
} | [
"private",
"function",
"parseOrderByField",
"(",
")",
"{",
"$",
"retVal",
"=",
"null",
";",
"$",
"fieldName",
"=",
"$",
"this",
"->",
"tokenizer",
"->",
"getTokenValue",
"(",
")",
";",
"$",
"this",
"->",
"tokenizer",
"->",
"expect",
"(",
"TokenType",
"::... | ORDER BY fieldExpression ASC | DESC ? NULLS FIRST | LAST ?
@throws ParseException
@return SortableInterface | [
"ORDER",
"BY",
"fieldExpression",
"ASC",
"|",
"DESC",
"?",
"NULLS",
"FIRST",
"|",
"LAST",
"?"
] | 7fd3194eb3155f019e34439e586e6baf6cbb202f | https://github.com/joshiausdemwald/Force.com-Toolkit-for-PHP-5.3/blob/7fd3194eb3155f019e34439e586e6baf6cbb202f/Soql/Parser/QueryParser.php#L1742-L1793 | train |
wa0x6e/Monolog-Init | src/MonologInit/MonologInit.php | MonologInit.createLoggerInstance | protected function createLoggerInstance($handler, $target)
{
$handlerClassName = $handler . 'Handler';
if (class_exists('\Monolog\Logger') && class_exists('\Monolog\Handler\\' . $handlerClassName)) {
if (null !== $handlerInstance = $this->createHandlerInstance($handlerClassName, $target)) {
$this->instance = new \Monolog\Logger('main');
$this->instance->pushHandler($handlerInstance);
}
$this->handler = $handler;
$this->target = $target;
}
} | php | protected function createLoggerInstance($handler, $target)
{
$handlerClassName = $handler . 'Handler';
if (class_exists('\Monolog\Logger') && class_exists('\Monolog\Handler\\' . $handlerClassName)) {
if (null !== $handlerInstance = $this->createHandlerInstance($handlerClassName, $target)) {
$this->instance = new \Monolog\Logger('main');
$this->instance->pushHandler($handlerInstance);
}
$this->handler = $handler;
$this->target = $target;
}
} | [
"protected",
"function",
"createLoggerInstance",
"(",
"$",
"handler",
",",
"$",
"target",
")",
"{",
"$",
"handlerClassName",
"=",
"$",
"handler",
".",
"'Handler'",
";",
"if",
"(",
"class_exists",
"(",
"'\\Monolog\\Logger'",
")",
"&&",
"class_exists",
"(",
"'\\... | Create a Monolog\Logger instance and attach a handler
@param string $handler Name of the handler, without the "Handler" part
@param string $target Comma separated list of arguments to pass to the handler
@return void | [
"Create",
"a",
"Monolog",
"\\",
"Logger",
"instance",
"and",
"attach",
"a",
"handler"
] | 026080034da41dcfe015a7da6ca8cd6f3960eabb | https://github.com/wa0x6e/Monolog-Init/blob/026080034da41dcfe015a7da6ca8cd6f3960eabb/src/MonologInit/MonologInit.php#L58-L71 | train |
wa0x6e/Monolog-Init | src/MonologInit/MonologInit.php | MonologInit.createHandlerInstance | protected function createHandlerInstance($className, $handlerArgs)
{
if (method_exists($this, 'init' . $className)) {
return call_user_func(array($this, 'init' . $className), explode(',', $handlerArgs));
} else {
return null;
}
} | php | protected function createHandlerInstance($className, $handlerArgs)
{
if (method_exists($this, 'init' . $className)) {
return call_user_func(array($this, 'init' . $className), explode(',', $handlerArgs));
} else {
return null;
}
} | [
"protected",
"function",
"createHandlerInstance",
"(",
"$",
"className",
",",
"$",
"handlerArgs",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'init'",
".",
"$",
"className",
")",
")",
"{",
"return",
"call_user_func",
"(",
"array",
"(",
"$... | Create an Monolog Handler instance
@param string $className Monolog handler classname
@param string $handlerArgs Comma separated list of arguments to pass to the handler
@return Monolog\Handler instance if successfull, null otherwise | [
"Create",
"an",
"Monolog",
"Handler",
"instance"
] | 026080034da41dcfe015a7da6ca8cd6f3960eabb | https://github.com/wa0x6e/Monolog-Init/blob/026080034da41dcfe015a7da6ca8cd6f3960eabb/src/MonologInit/MonologInit.php#L80-L87 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/Maps/Model/Base/Mxmap.php | Mxmap.setMap | public function setMap(ChildMap $v = null)
{
if ($v === null) {
$this->setTrackuid(NULL);
} else {
$this->setTrackuid($v->getMapuid());
}
$this->aMap = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildMap object, it will not be re-added.
if ($v !== null) {
$v->addMxmap($this);
}
return $this;
} | php | public function setMap(ChildMap $v = null)
{
if ($v === null) {
$this->setTrackuid(NULL);
} else {
$this->setTrackuid($v->getMapuid());
}
$this->aMap = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildMap object, it will not be re-added.
if ($v !== null) {
$v->addMxmap($this);
}
return $this;
} | [
"public",
"function",
"setMap",
"(",
"ChildMap",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setTrackuid",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setTrackuid",
"(",
"$",... | Declares an association between this object and a ChildMap object.
@param ChildMap $v
@return $this|\eXpansion\Bundle\Maps\Model\Mxmap The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildMap",
"object",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Maps/Model/Base/Mxmap.php#L3356-L3374 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/Maps/Model/Base/Mxmap.php | Mxmap.getMap | public function getMap(ConnectionInterface $con = null)
{
if ($this->aMap === null && (($this->trackuid !== "" && $this->trackuid !== null))) {
$this->aMap = ChildMapQuery::create()
->filterByMxmap($this) // here
->findOne($con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aMap->addMxmaps($this);
*/
}
return $this->aMap;
} | php | public function getMap(ConnectionInterface $con = null)
{
if ($this->aMap === null && (($this->trackuid !== "" && $this->trackuid !== null))) {
$this->aMap = ChildMapQuery::create()
->filterByMxmap($this) // here
->findOne($con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aMap->addMxmaps($this);
*/
}
return $this->aMap;
} | [
"public",
"function",
"getMap",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aMap",
"===",
"null",
"&&",
"(",
"(",
"$",
"this",
"->",
"trackuid",
"!==",
"\"\"",
"&&",
"$",
"this",
"->",
"trackuid",
"!=... | Get the associated ChildMap object
@param ConnectionInterface $con Optional Connection object.
@return ChildMap The associated ChildMap object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildMap",
"object"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Maps/Model/Base/Mxmap.php#L3384-L3400 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Requester.php | Requester.get_content_type | public function get_content_type() {
$headers = wp_remote_retrieve_headers( $this->response );
if ( ! $headers ) {
return;
}
if ( ! is_object( $headers ) || ! method_exists( $headers, 'offsetGet' ) ) {
return;
}
return $headers->offsetGet( 'content-type' );
} | php | public function get_content_type() {
$headers = wp_remote_retrieve_headers( $this->response );
if ( ! $headers ) {
return;
}
if ( ! is_object( $headers ) || ! method_exists( $headers, 'offsetGet' ) ) {
return;
}
return $headers->offsetGet( 'content-type' );
} | [
"public",
"function",
"get_content_type",
"(",
")",
"{",
"$",
"headers",
"=",
"wp_remote_retrieve_headers",
"(",
"$",
"this",
"->",
"response",
")",
";",
"if",
"(",
"!",
"$",
"headers",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$... | Return content type of the page you want to blog card
@return string | [
"Return",
"content",
"type",
"of",
"the",
"page",
"you",
"want",
"to",
"blog",
"card"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Requester.php#L95-L106 | train |
inc2734/wp-oembed-blog-card | src/App/Model/Requester.php | Requester.get_content | public function get_content() {
$content = wp_remote_retrieve_body( $this->response );
if ( empty( $content ) ) {
return;
}
return $this->_encode( $content );
} | php | public function get_content() {
$content = wp_remote_retrieve_body( $this->response );
if ( empty( $content ) ) {
return;
}
return $this->_encode( $content );
} | [
"public",
"function",
"get_content",
"(",
")",
"{",
"$",
"content",
"=",
"wp_remote_retrieve_body",
"(",
"$",
"this",
"->",
"response",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
... | Return response body
@return string | [
"Return",
"response",
"body"
] | 4882994152f9003db9c68517a53090cbef13ff4d | https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/Model/Requester.php#L113-L121 | train |
ivopetkov/object-storage | src/ObjectStorage.php | ObjectStorage.executeCommand | private function executeCommand(array $parameters, string $command)
{
foreach ($parameters as $index => $object) {
$parameters[$index]['command'] = $command;
}
$result = $this->execute($parameters);
if (isset($index)) {
unset($index);
}
if (isset($object)) {
unset($object);
}
unset($parameters);
unset($command);
return $result;
} | php | private function executeCommand(array $parameters, string $command)
{
foreach ($parameters as $index => $object) {
$parameters[$index]['command'] = $command;
}
$result = $this->execute($parameters);
if (isset($index)) {
unset($index);
}
if (isset($object)) {
unset($object);
}
unset($parameters);
unset($command);
return $result;
} | [
"private",
"function",
"executeCommand",
"(",
"array",
"$",
"parameters",
",",
"string",
"$",
"command",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"index",
"=>",
"$",
"object",
")",
"{",
"$",
"parameters",
"[",
"$",
"index",
"]",
"[",
"'c... | Executes single command.
@param array $parameters The command parameters.
@param string $command The command name.
@return mixed
@throws \IvoPetkov\ObjectStorage\ErrorException
@throws \IvoPetkov\ObjectStorage\ObjectLockedException | [
"Executes",
"single",
"command",
"."
] | f395d8c514b62e84fda620d548bb15d446fe2f5d | https://github.com/ivopetkov/object-storage/blob/f395d8c514b62e84fda620d548bb15d446fe2f5d/src/ObjectStorage.php#L199-L214 | train |
ivopetkov/object-storage | src/ObjectStorage.php | ObjectStorage.validate | public function validate($key): bool
{
if (!is_string($key) || strlen($key) === 0 || $key === '.' || $key === '..' || strpos($key, '/../') !== false || strpos($key, '/./') !== false || strpos($key, '/') === 0 || strpos($key, './') === 0 || strpos($key, '../') === 0 || substr($key, -2) === '/.' || substr($key, -3) === '/..' || substr($key, -1) === '/') {
return false;
}
return preg_match("/^[a-z0-9\.\/\-\_]*$/", $key) === 1;
} | php | public function validate($key): bool
{
if (!is_string($key) || strlen($key) === 0 || $key === '.' || $key === '..' || strpos($key, '/../') !== false || strpos($key, '/./') !== false || strpos($key, '/') === 0 || strpos($key, './') === 0 || strpos($key, '../') === 0 || substr($key, -2) === '/.' || substr($key, -3) === '/..' || substr($key, -1) === '/') {
return false;
}
return preg_match("/^[a-z0-9\.\/\-\_]*$/", $key) === 1;
} | [
"public",
"function",
"validate",
"(",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
"||",
"strlen",
"(",
"$",
"key",
")",
"===",
"0",
"||",
"$",
"key",
"===",
"'.'",
"||",
"$",
"key",
"===",
"'..'",
"||"... | Checks whether the key specified is valid.
@param string $key The key to check.
@return boolean TRUE if the key is valid, FALSE otherwise. | [
"Checks",
"whether",
"the",
"key",
"specified",
"is",
"valid",
"."
] | f395d8c514b62e84fda620d548bb15d446fe2f5d | https://github.com/ivopetkov/object-storage/blob/f395d8c514b62e84fda620d548bb15d446fe2f5d/src/ObjectStorage.php#L222-L228 | train |
ivopetkov/object-storage | src/ObjectStorage.php | ObjectStorage.createFileDirIfNotExists | private function createFileDirIfNotExists(string $filename): bool
{
$pathinfo = pathinfo($filename);
if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') {
if (is_dir($pathinfo['dirname'])) {
return true;
} elseif (is_file($pathinfo['dirname'])) {
return false;
} else {
return $this->createDirIfNotExists($pathinfo['dirname']);
}
}
return false;
} | php | private function createFileDirIfNotExists(string $filename): bool
{
$pathinfo = pathinfo($filename);
if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') {
if (is_dir($pathinfo['dirname'])) {
return true;
} elseif (is_file($pathinfo['dirname'])) {
return false;
} else {
return $this->createDirIfNotExists($pathinfo['dirname']);
}
}
return false;
} | [
"private",
"function",
"createFileDirIfNotExists",
"(",
"string",
"$",
"filename",
")",
":",
"bool",
"{",
"$",
"pathinfo",
"=",
"pathinfo",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"pathinfo",
"[",
"'dirname'",
"]",
")",
"&&",
"$",
... | Creates the directory of the file specified.
@param string $filename The filename.
@return boolean TRUE if successful, FALSE otherwise.
@throws \IvoPetkov\ObjectStorage\ErrorException | [
"Creates",
"the",
"directory",
"of",
"the",
"file",
"specified",
"."
] | f395d8c514b62e84fda620d548bb15d446fe2f5d | https://github.com/ivopetkov/object-storage/blob/f395d8c514b62e84fda620d548bb15d446fe2f5d/src/ObjectStorage.php#L997-L1010 | train |
ivopetkov/object-storage | src/ObjectStorage.php | ObjectStorage.createDirIfNotExists | private function createDirIfNotExists(string $dir): bool
{
if (!is_dir($dir)) {
try {
set_error_handler(function($errno, $errstr, $errfile, $errline) {
restore_error_handler();
throw new \IvoPetkov\ObjectStorage\ErrorException($errstr, 0, $errno, $errfile, $errline);
});
$result = mkdir($dir, 0777, true);
restore_error_handler();
return (bool) $result;
} catch (\IvoPetkov\ObjectStorage\ErrorException $e) {
if ($e->getMessage() !== 'mkdir(): File exists') { // The directory may be just created in other process.
throw $e;
}
}
}
return true;
} | php | private function createDirIfNotExists(string $dir): bool
{
if (!is_dir($dir)) {
try {
set_error_handler(function($errno, $errstr, $errfile, $errline) {
restore_error_handler();
throw new \IvoPetkov\ObjectStorage\ErrorException($errstr, 0, $errno, $errfile, $errline);
});
$result = mkdir($dir, 0777, true);
restore_error_handler();
return (bool) $result;
} catch (\IvoPetkov\ObjectStorage\ErrorException $e) {
if ($e->getMessage() !== 'mkdir(): File exists') { // The directory may be just created in other process.
throw $e;
}
}
}
return true;
} | [
"private",
"function",
"createDirIfNotExists",
"(",
"string",
"$",
"dir",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"try",
"{",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"... | Creates a directory if not existent.
@param string $dir The directory name.
@return boolean TRUE if successful, FALSE otherwise.
@throws \IvoPetkov\ObjectStorage\ErrorException | [
"Creates",
"a",
"directory",
"if",
"not",
"existent",
"."
] | f395d8c514b62e84fda620d548bb15d446fe2f5d | https://github.com/ivopetkov/object-storage/blob/f395d8c514b62e84fda620d548bb15d446fe2f5d/src/ObjectStorage.php#L1019-L1037 | train |
ivopetkov/object-storage | src/ObjectStorage.php | ObjectStorage.getFiles | private function getFiles(string $dir, bool $recursive = false, $limit = null): array
{
if ($limit === 0) {
return [];
}
$result = [];
if (is_dir($dir)) {
$list = scandir($dir);
if (is_array($list)) {
foreach ($list as $filename) {
if ($filename != '.' && $filename != '..') {
if (is_dir($dir . $filename)) {
if ($recursive === true) {
$dirResult = $this->getFiles($dir . $filename . '/', true, $limit !== null ? ($limit - sizeof($result)) : null);
if (!empty($dirResult)) {
foreach ($dirResult as $index => $value) {
$dirResult[$index] = $filename . '/' . $value;
}
$result = array_merge($result, $dirResult);
}
}
} else {
$result[] = $filename;
if ($limit !== null && $limit === sizeof($result)) {
break;
}
}
}
}
}
}
return $result;
} | php | private function getFiles(string $dir, bool $recursive = false, $limit = null): array
{
if ($limit === 0) {
return [];
}
$result = [];
if (is_dir($dir)) {
$list = scandir($dir);
if (is_array($list)) {
foreach ($list as $filename) {
if ($filename != '.' && $filename != '..') {
if (is_dir($dir . $filename)) {
if ($recursive === true) {
$dirResult = $this->getFiles($dir . $filename . '/', true, $limit !== null ? ($limit - sizeof($result)) : null);
if (!empty($dirResult)) {
foreach ($dirResult as $index => $value) {
$dirResult[$index] = $filename . '/' . $value;
}
$result = array_merge($result, $dirResult);
}
}
} else {
$result[] = $filename;
if ($limit !== null && $limit === sizeof($result)) {
break;
}
}
}
}
}
}
return $result;
} | [
"private",
"function",
"getFiles",
"(",
"string",
"$",
"dir",
",",
"bool",
"$",
"recursive",
"=",
"false",
",",
"$",
"limit",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"$",
"limit",
"===",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
... | Returns list of files in the directory specified.
@param string $dir The directory name.
@param boolean $recursive If TRUE all files in subdirectories will be returned too.
@param int|null $limit Maximum number of files to return.
@return array An array containing list of all files in the directory specified. | [
"Returns",
"list",
"of",
"files",
"in",
"the",
"directory",
"specified",
"."
] | f395d8c514b62e84fda620d548bb15d446fe2f5d | https://github.com/ivopetkov/object-storage/blob/f395d8c514b62e84fda620d548bb15d446fe2f5d/src/ObjectStorage.php#L1047-L1079 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameTrackmania/DataProviders/ScriptBaseRounds/RaceDataProvider.php | RaceDataProvider.isCompatible | public function isCompatible(Map $map): bool
{
if (!$map->lapRace) {
return false;
}
$nbLaps = 1;
if ($map->lapRace) {
$nbLaps = $map->nbLaps;
}
$scriptSettings = $this->gameDataStorage->getScriptOptions();
if ($scriptSettings['S_ForceLapsNb'] != -1) {
$nbLaps = $scriptSettings['S_ForceLapsNb'];
}
// If rounds is configured to be single laps then no need for race data. lap is sufficient.
return $nbLaps > 1; } | php | public function isCompatible(Map $map): bool
{
if (!$map->lapRace) {
return false;
}
$nbLaps = 1;
if ($map->lapRace) {
$nbLaps = $map->nbLaps;
}
$scriptSettings = $this->gameDataStorage->getScriptOptions();
if ($scriptSettings['S_ForceLapsNb'] != -1) {
$nbLaps = $scriptSettings['S_ForceLapsNb'];
}
// If rounds is configured to be single laps then no need for race data. lap is sufficient.
return $nbLaps > 1; } | [
"public",
"function",
"isCompatible",
"(",
"Map",
"$",
"map",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"map",
"->",
"lapRace",
")",
"{",
"return",
"false",
";",
"}",
"$",
"nbLaps",
"=",
"1",
";",
"if",
"(",
"$",
"map",
"->",
"lapRace",
")",
... | Check if data provider is compatible with current situation.
@return bool | [
"Check",
"if",
"data",
"provider",
"is",
"compatible",
"with",
"current",
"situation",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameTrackmania/DataProviders/ScriptBaseRounds/RaceDataProvider.php#L23-L40 | train |
phug-php/renderer | src/Phug/Renderer.php | Renderer.compile | public function compile($string, $filename = null)
{
$compiler = $this->getCompiler();
$this->setDebugString($string);
$this->setDebugFile($filename);
$this->setDebugFormatter($compiler->getFormatter());
return $compiler->compile($string, $filename);
} | php | public function compile($string, $filename = null)
{
$compiler = $this->getCompiler();
$this->setDebugString($string);
$this->setDebugFile($filename);
$this->setDebugFormatter($compiler->getFormatter());
return $compiler->compile($string, $filename);
} | [
"public",
"function",
"compile",
"(",
"$",
"string",
",",
"$",
"filename",
"=",
"null",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"getCompiler",
"(",
")",
";",
"$",
"this",
"->",
"setDebugString",
"(",
"$",
"string",
")",
";",
"$",
"this",
... | Compile a pug template string into a PHP string.
@param string $string pug input string
@param string $filename optional file path of the given template
@return string | [
"Compile",
"a",
"pug",
"template",
"string",
"into",
"a",
"PHP",
"string",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer.php#L66-L75 | train |
phug-php/renderer | src/Phug/Renderer.php | Renderer.compileFile | public function compileFile($path)
{
$compiler = $this->getCompiler();
$this->setDebugFile($path);
$this->setDebugFormatter($compiler->getFormatter());
return $compiler->compileFile($path);
} | php | public function compileFile($path)
{
$compiler = $this->getCompiler();
$this->setDebugFile($path);
$this->setDebugFormatter($compiler->getFormatter());
return $compiler->compileFile($path);
} | [
"public",
"function",
"compileFile",
"(",
"$",
"path",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"getCompiler",
"(",
")",
";",
"$",
"this",
"->",
"setDebugFile",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"setDebugFormatter",
"(",
"$",
"... | Compile a pug template file into a PHP string.
@param string $path pug input file
@return string | [
"Compile",
"a",
"pug",
"template",
"file",
"into",
"a",
"PHP",
"string",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer.php#L84-L92 | train |
phug-php/renderer | src/Phug/Renderer.php | Renderer.renderAndWriteFile | public function renderAndWriteFile($inputFile, $outputFile, array $parameters = [])
{
$outputDirectory = dirname($outputFile);
if (!file_exists($outputDirectory) && !@mkdir($outputDirectory, 0777, true)) {
return false;
}
return is_int($this->getNewSandBox(function () use ($outputFile, $inputFile, $parameters) {
return file_put_contents($outputFile, $this->renderFile($inputFile, $parameters));
})->getResult());
} | php | public function renderAndWriteFile($inputFile, $outputFile, array $parameters = [])
{
$outputDirectory = dirname($outputFile);
if (!file_exists($outputDirectory) && !@mkdir($outputDirectory, 0777, true)) {
return false;
}
return is_int($this->getNewSandBox(function () use ($outputFile, $inputFile, $parameters) {
return file_put_contents($outputFile, $this->renderFile($inputFile, $parameters));
})->getResult());
} | [
"public",
"function",
"renderAndWriteFile",
"(",
"$",
"inputFile",
",",
"$",
"outputFile",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"outputDirectory",
"=",
"dirname",
"(",
"$",
"outputFile",
")",
";",
"if",
"(",
"!",
"file_exists",
... | Render a pug file and dump it into a file.
Return true if the render and the writing succeeded.
@param string $inputFile input file (Pug file)
@param string $outputFile output file (typically the HTML/XML file)
@param array $parameters local variables
@return bool | [
"Render",
"a",
"pug",
"file",
"and",
"dump",
"it",
"into",
"a",
"file",
".",
"Return",
"true",
"if",
"the",
"render",
"and",
"the",
"writing",
"succeeded",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer.php#L151-L162 | train |
phug-php/renderer | src/Phug/Renderer.php | Renderer.renderDirectory | public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
{
if (is_array($destination)) {
$parameters = $destination;
$destination = null;
} elseif (is_array($extension)) {
$parameters = $extension;
$extension = '.html';
}
if (!$destination) {
$destination = $path;
}
$path = realpath($path);
$destination = realpath($destination);
$success = 0;
$errors = 0;
if ($path && $destination) {
$path = rtrim($path, '/\\');
$destination = rtrim($destination, '/\\');
$length = mb_strlen($path);
foreach ($this->scanDirectory($path) as $file) {
$relativeDirectory = trim(mb_substr(dirname($file), $length), '//\\');
$filename = pathinfo($file, PATHINFO_FILENAME);
$outputDirectory = $destination.DIRECTORY_SEPARATOR.$relativeDirectory;
$counter = $this->renderAndWriteFile(
$file,
$outputDirectory.DIRECTORY_SEPARATOR.$filename.$extension,
$parameters
) ? 'success' : 'errors';
$$counter++;
}
}
return [$success, $errors];
} | php | public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
{
if (is_array($destination)) {
$parameters = $destination;
$destination = null;
} elseif (is_array($extension)) {
$parameters = $extension;
$extension = '.html';
}
if (!$destination) {
$destination = $path;
}
$path = realpath($path);
$destination = realpath($destination);
$success = 0;
$errors = 0;
if ($path && $destination) {
$path = rtrim($path, '/\\');
$destination = rtrim($destination, '/\\');
$length = mb_strlen($path);
foreach ($this->scanDirectory($path) as $file) {
$relativeDirectory = trim(mb_substr(dirname($file), $length), '//\\');
$filename = pathinfo($file, PATHINFO_FILENAME);
$outputDirectory = $destination.DIRECTORY_SEPARATOR.$relativeDirectory;
$counter = $this->renderAndWriteFile(
$file,
$outputDirectory.DIRECTORY_SEPARATOR.$filename.$extension,
$parameters
) ? 'success' : 'errors';
$$counter++;
}
}
return [$success, $errors];
} | [
"public",
"function",
"renderDirectory",
"(",
"$",
"path",
",",
"$",
"destination",
"=",
"null",
",",
"$",
"extension",
"=",
"'.html'",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"destination",
")",
")",
... | Render all pug template files in an input directory and output in an other or the same directory.
Return an array with success count and error count.
@param string $path pug input directory containing pug files
@param string $destination pug output directory (optional)
@param string $extension file extension (optional, .html by default)
@param string|array $parameters parameters (values for variables used in the template) (optional)
@return array | [
"Render",
"all",
"pug",
"template",
"files",
"in",
"an",
"input",
"directory",
"and",
"output",
"in",
"an",
"other",
"or",
"the",
"same",
"directory",
".",
"Return",
"an",
"array",
"with",
"success",
"count",
"and",
"error",
"count",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer.php#L175-L210 | train |
BenGorUser/UserBundle | src/BenGorUser/UserBundle/DependencyInjection/BenGorUserExtension.php | BenGorUserExtension.loadCommands | private function loadCommands(ContainerBuilder $container, $user)
{
$container->setDefinition(
'bengor.user.command.create_' . $user . '_command',
(new Definition(CreateUserCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.change_' . $user . '_password_command',
(new Definition(ChangePasswordCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.purge_outdated_' . $user . '_invitation_tokens_command',
(new Definition(PurgeOutdatedInvitationTokensCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.purge_outdated_' . $user . '_remember_password_tokens_command',
(new Definition(PurgeOutdatedRememberPasswordTokensCommand::class))->addTag('console.command')
);
} | php | private function loadCommands(ContainerBuilder $container, $user)
{
$container->setDefinition(
'bengor.user.command.create_' . $user . '_command',
(new Definition(CreateUserCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.change_' . $user . '_password_command',
(new Definition(ChangePasswordCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.purge_outdated_' . $user . '_invitation_tokens_command',
(new Definition(PurgeOutdatedInvitationTokensCommand::class))->addTag('console.command')
);
$container->setDefinition(
'bengor.user.command.purge_outdated_' . $user . '_remember_password_tokens_command',
(new Definition(PurgeOutdatedRememberPasswordTokensCommand::class))->addTag('console.command')
);
} | [
"private",
"function",
"loadCommands",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"user",
")",
"{",
"$",
"container",
"->",
"setDefinition",
"(",
"'bengor.user.command.create_'",
".",
"$",
"user",
".",
"'_command'",
",",
"(",
"new",
"Definition",
"(",
... | Loads commands as a service inside Symfony console.
@param ContainerBuilder $container The container
@param string $user The user name | [
"Loads",
"commands",
"as",
"a",
"service",
"inside",
"Symfony",
"console",
"."
] | a6d0173496c269a6c80e1319d42eaed4b3bbbd4a | https://github.com/BenGorUser/UserBundle/blob/a6d0173496c269a6c80e1319d42eaed4b3bbbd4a/src/BenGorUser/UserBundle/DependencyInjection/BenGorUserExtension.php#L57-L78 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php | Smarty_CacheResource_Mysql.fetch | protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
{
$this->fetch->execute(array('id' => $id));
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$content = $row['content'];
$mtime = strtotime($row['modified']);
} else {
$content = null;
$mtime = null;
}
} | php | protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
{
$this->fetch->execute(array('id' => $id));
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$content = $row['content'];
$mtime = strtotime($row['modified']);
} else {
$content = null;
$mtime = null;
}
} | [
"protected",
"function",
"fetch",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"&",
"$",
"content",
",",
"&",
"$",
"mtime",
")",
"{",
"$",
"this",
"->",
"fetch",
"->",
"execute",
"(",
"array",
"(",
"'id'",
... | fetch cached content and its modification time from data source
@param string $id unique cache content identifier
@param string $name template name
@param string $cache_id cache id
@param string $compile_id compile id
@param string $content cached content
@param integer $mtime cache modification timestamp (epoch)
@return void | [
"fetch",
"cached",
"content",
"and",
"its",
"modification",
"time",
"from",
"data",
"source"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php#L59-L71 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php | Smarty_CacheResource_Mysql.fetchTimestamp | protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
{
$this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor();
return $mtime;
} | php | protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
{
$this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor();
return $mtime;
} | [
"protected",
"function",
"fetchTimestamp",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
")",
"{",
"$",
"this",
"->",
"fetchTimestamp",
"->",
"execute",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"$",... | Fetch cached content's modification timestamp from data source
@note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
@param string $id unique cache content identifier
@param string $name template name
@param string $cache_id cache id
@param string $compile_id compile id
@return integer|boolean timestamp (epoch) the template was modified, or false if not found | [
"Fetch",
"cached",
"content",
"s",
"modification",
"timestamp",
"from",
"data",
"source"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php#L85-L92 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php | Smarty_CacheResource_Mysql.save | protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(array(
'id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,
));
return !!$this->save->rowCount();
} | php | protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(array(
'id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,
));
return !!$this->save->rowCount();
} | [
"protected",
"function",
"save",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"$",
"exp_time",
",",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"save",
"->",
"execute",
"(",
"array",
"(",
"'id'",
"=>",
"$",
... | Save content to cache
@param string $id unique cache content identifier
@param string $name template name
@param string $cache_id cache id
@param string $compile_id compile id
@param integer|null $exp_time seconds till expiration time in seconds or null
@param string $content content to cache
@return boolean success | [
"Save",
"content",
"to",
"cache"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php#L106-L117 | train |
lukefor/Laravel4-SmartyView | src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php | Smarty_CacheResource_Mysql.delete | protected function delete($name, $cache_id, $compile_id, $exp_time)
{
// delete the whole cache
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache');
return - 1;
}
// build the filter
$where = array();
// equal test name
if ($name !== null) {
$where[] = 'name = ' . $this->db->quote($name);
}
// equal test compile_id
if ($compile_id !== null) {
$where[] = 'compile_id = ' . $this->db->quote($compile_id);
}
// range test expiration time
if ($exp_time !== null) {
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
return $query->rowCount();
} | php | protected function delete($name, $cache_id, $compile_id, $exp_time)
{
// delete the whole cache
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache');
return - 1;
}
// build the filter
$where = array();
// equal test name
if ($name !== null) {
$where[] = 'name = ' . $this->db->quote($name);
}
// equal test compile_id
if ($compile_id !== null) {
$where[] = 'compile_id = ' . $this->db->quote($compile_id);
}
// range test expiration time
if ($exp_time !== null) {
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
return $query->rowCount();
} | [
"protected",
"function",
"delete",
"(",
"$",
"name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"$",
"exp_time",
")",
"{",
"// delete the whole cache",
"if",
"(",
"$",
"name",
"===",
"null",
"&&",
"$",
"cache_id",
"===",
"null",
"&&",
"$",
"compi... | Delete content from cache
@param string $name template name
@param string $cache_id cache id
@param string $compile_id compile id
@param integer|null $exp_time seconds till expiration or null
@return integer number of deleted caches | [
"Delete",
"content",
"from",
"cache"
] | cb3a9bfae805e787cff179b3e41f1a9ad65b389e | https://github.com/lukefor/Laravel4-SmartyView/blob/cb3a9bfae805e787cff179b3e41f1a9ad65b389e/src/Dark/SmartyView/Smarty/demo/plugins/cacheresource.mysql.php#L129-L161 | train |
JBZoo/Html | src/Render/Iframe.php | Iframe.render | public function render($src, $class = '', $id = '', array $attrs = array())
{
$attrs = array_merge(array(
'frameborder' => 0,
'content' => null,
'tag' => 'iframe',
'src' => Str::trim($src)
), $attrs);
$attrs = $this->_cleanAttrs($attrs);
$content = $attrs['content'];
unset($attrs['content']);
return Html::_('tag')->render($content, Str::trim($class), Str::trim($id), $attrs);
} | php | public function render($src, $class = '', $id = '', array $attrs = array())
{
$attrs = array_merge(array(
'frameborder' => 0,
'content' => null,
'tag' => 'iframe',
'src' => Str::trim($src)
), $attrs);
$attrs = $this->_cleanAttrs($attrs);
$content = $attrs['content'];
unset($attrs['content']);
return Html::_('tag')->render($content, Str::trim($class), Str::trim($id), $attrs);
} | [
"public",
"function",
"render",
"(",
"$",
"src",
",",
"$",
"class",
"=",
"''",
",",
"$",
"id",
"=",
"''",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attrs",
"=",
"array_merge",
"(",
"array",
"(",
"'frameborder'",
"=>",
"0... | Create iframe.
@param string $src
@param string $class
@param string $id
@param array $attrs
@return string | [
"Create",
"iframe",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Iframe.php#L47-L61 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/WidgetBestCheckpoints/Plugins/BestCheckpoints.php | BestCheckpoints.onLocalRecordsLoaded | public function onLocalRecordsLoaded($records, BaseRecords $baseRecords)
{
if (!$this->checkRecordPlugin($baseRecords)) {
return;
}
if (count($records) > 0) {
$this->updater->setLocalRecord($records[0]->getPlayer()->getNickname(), $records[0]->getCheckpoints());
} else {
$this->updater->setLocalRecord("-", []);
}
} | php | public function onLocalRecordsLoaded($records, BaseRecords $baseRecords)
{
if (!$this->checkRecordPlugin($baseRecords)) {
return;
}
if (count($records) > 0) {
$this->updater->setLocalRecord($records[0]->getPlayer()->getNickname(), $records[0]->getCheckpoints());
} else {
$this->updater->setLocalRecord("-", []);
}
} | [
"public",
"function",
"onLocalRecordsLoaded",
"(",
"$",
"records",
",",
"BaseRecords",
"$",
"baseRecords",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkRecordPlugin",
"(",
"$",
"baseRecords",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"count",
"... | Called when local records are loaded.
@param Record[] $records | [
"Called",
"when",
"local",
"records",
"are",
"loaded",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/WidgetBestCheckpoints/Plugins/BestCheckpoints.php#L90-L101 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.formatStackOperationOptions | public function formatStackOperationOptions(array $settings)
{
$data = [];
foreach ($settings as $name => $value) {
$data[] = $name.':'.$value;
}
return implode(' | ', $data);
} | php | public function formatStackOperationOptions(array $settings)
{
$data = [];
foreach ($settings as $name => $value) {
$data[] = $name.':'.$value;
}
return implode(' | ', $data);
} | [
"public",
"function",
"formatStackOperationOptions",
"(",
"array",
"$",
"settings",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"name",
... | Build a string representation for the StackOperation's options attribute.
@param array $settings
@return string | [
"Build",
"a",
"string",
"representation",
"for",
"the",
"StackOperation",
"s",
"options",
"attribute",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L27-L36 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.outputImageInfo | public function outputImageInfo(SourceImage $sourceImage, OutputInterface $output)
{
$output->writeln([
' Hash: <info>'.$sourceImage->hash.'</info>',
' Organization: <info>'.$sourceImage->organization.'</info>',
' Name: <info>'.$sourceImage->name.'</info>',
' Size: <info>'.$sourceImage->size.'</info>',
' Format: <info>'.$sourceImage->format.'</info>',
' Created: <info>'.$sourceImage->created->format('Y-m-d H:i:s').'</info>',
' Dimensions: <info>'.$sourceImage->width.'x'.$sourceImage->height.'</info>',
]);
if ($output->isVerbose()) {
$output->writeln(' BinaryHash: <info>'.$sourceImage->binaryHash.'</info>');
}
if (!empty($sourceImage->dynamicMetadata)) {
if (!$output->isVerbose()) {
$metaNames = array_keys($sourceImage->dynamicMetadata);
$output->writeln(' DynamicMetadatas ('.\count($metaNames).'): '.implode(', ', $metaNames));
} else {
$output->writeln(' DynamicMetadatas:');
/** @var DynamicMetadataInterface $meta */
foreach ($sourceImage->dynamicMetadata as $name => $meta) {
$output->writeln(' - <info>'.$name.'</info> '.$this->formatDynamicMetadata($meta));
}
}
}
} | php | public function outputImageInfo(SourceImage $sourceImage, OutputInterface $output)
{
$output->writeln([
' Hash: <info>'.$sourceImage->hash.'</info>',
' Organization: <info>'.$sourceImage->organization.'</info>',
' Name: <info>'.$sourceImage->name.'</info>',
' Size: <info>'.$sourceImage->size.'</info>',
' Format: <info>'.$sourceImage->format.'</info>',
' Created: <info>'.$sourceImage->created->format('Y-m-d H:i:s').'</info>',
' Dimensions: <info>'.$sourceImage->width.'x'.$sourceImage->height.'</info>',
]);
if ($output->isVerbose()) {
$output->writeln(' BinaryHash: <info>'.$sourceImage->binaryHash.'</info>');
}
if (!empty($sourceImage->dynamicMetadata)) {
if (!$output->isVerbose()) {
$metaNames = array_keys($sourceImage->dynamicMetadata);
$output->writeln(' DynamicMetadatas ('.\count($metaNames).'): '.implode(', ', $metaNames));
} else {
$output->writeln(' DynamicMetadatas:');
/** @var DynamicMetadataInterface $meta */
foreach ($sourceImage->dynamicMetadata as $name => $meta) {
$output->writeln(' - <info>'.$name.'</info> '.$this->formatDynamicMetadata($meta));
}
}
}
} | [
"public",
"function",
"outputImageInfo",
"(",
"SourceImage",
"$",
"sourceImage",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"[",
"' Hash: <info>'",
".",
"$",
"sourceImage",
"->",
"hash",
".",
"'</info>'",
",",
"' Or... | Print information about a source image from rokka.
@param SourceImage $sourceImage
@param OutputInterface $output | [
"Print",
"information",
"about",
"a",
"source",
"image",
"from",
"rokka",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L44-L72 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.outputOrganizationInfo | public function outputOrganizationInfo(Organization $org, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$org->getId().'</info>',
' Name: <info>'.$org->getName().'</info>',
' Display Name: <info>'.$org->getDisplayName().'</info>',
' Billing eMail: <info>'.$org->getBillingEmail().'</info>',
]);
} | php | public function outputOrganizationInfo(Organization $org, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$org->getId().'</info>',
' Name: <info>'.$org->getName().'</info>',
' Display Name: <info>'.$org->getDisplayName().'</info>',
' Billing eMail: <info>'.$org->getBillingEmail().'</info>',
]);
} | [
"public",
"function",
"outputOrganizationInfo",
"(",
"Organization",
"$",
"org",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"[",
"' ID: <info>'",
".",
"$",
"org",
"->",
"getId",
"(",
")",
".",
"'</info>'",
",",
"... | Print information about a rokka organization.
@param Organization $org
@param OutputInterface $output | [
"Print",
"information",
"about",
"a",
"rokka",
"organization",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L80-L88 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.outputOrganizationMembershipInfo | public function outputOrganizationMembershipInfo(Membership $membership, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$membership->userId.'</info>',
' Roles: <info>'.json_encode($membership->roles).'</info>',
' Active: <info>'.($membership->active ? 'True' : 'False').'</info>',
' Last Access: <info>'.$membership->lastAccess->format('c').'</info>',
]);
} | php | public function outputOrganizationMembershipInfo(Membership $membership, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$membership->userId.'</info>',
' Roles: <info>'.json_encode($membership->roles).'</info>',
' Active: <info>'.($membership->active ? 'True' : 'False').'</info>',
' Last Access: <info>'.$membership->lastAccess->format('c').'</info>',
]);
} | [
"public",
"function",
"outputOrganizationMembershipInfo",
"(",
"Membership",
"$",
"membership",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"[",
"' ID: <info>'",
".",
"$",
"membership",
"->",
"userId",
".",
"'</info>'",
... | Print information about an organization membership.
@param Membership $membership
@param OutputInterface $output | [
"Print",
"information",
"about",
"an",
"organization",
"membership",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L96-L104 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.outputStackInfo | public function outputStackInfo(Stack $stack, OutputInterface $output)
{
$output->writeln(' Name: <info>'.$stack->getName().'</info>');
$output->writeln(' Created: <info>'.$stack->getCreated()->format('Y-m-d H:i:s').'</info>');
$operations = $stack->getStackOperations();
if (!empty($operations)) {
$output->writeln(' Operations:');
foreach ($stack->getStackOperations() as $operation) {
$output->write(' '.$operation->name.': ');
$output->writeln($this->formatStackOperationOptions($operation->options));
}
}
$options = $stack->getStackOptions();
if (!empty($options)) {
$output->writeln(' Options:');
foreach ($stack->getStackOptions() as $name => $value) {
$output->write(' '.$name.': ');
$output->writeln('<info>'.$value.'</info>');
}
}
} | php | public function outputStackInfo(Stack $stack, OutputInterface $output)
{
$output->writeln(' Name: <info>'.$stack->getName().'</info>');
$output->writeln(' Created: <info>'.$stack->getCreated()->format('Y-m-d H:i:s').'</info>');
$operations = $stack->getStackOperations();
if (!empty($operations)) {
$output->writeln(' Operations:');
foreach ($stack->getStackOperations() as $operation) {
$output->write(' '.$operation->name.': ');
$output->writeln($this->formatStackOperationOptions($operation->options));
}
}
$options = $stack->getStackOptions();
if (!empty($options)) {
$output->writeln(' Options:');
foreach ($stack->getStackOptions() as $name => $value) {
$output->write(' '.$name.': ');
$output->writeln('<info>'.$value.'</info>');
}
}
} | [
"public",
"function",
"outputStackInfo",
"(",
"Stack",
"$",
"stack",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"' Name: <info>'",
".",
"$",
"stack",
"->",
"getName",
"(",
")",
".",
"'</info>'",
")",
";",
"$",
... | Print information about a rokka stack.
@param Stack $stack
@param OutputInterface $output | [
"Print",
"information",
"about",
"a",
"rokka",
"stack",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L112-L135 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.outputUserInfo | public function outputUserInfo(User $user, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$user->getId().'</info>',
' eMail: <info>'.$user->getEmail().'</info>',
' API-Key: <info>'.$user->getApiKey().'</info>',
]);
} | php | public function outputUserInfo(User $user, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$user->getId().'</info>',
' eMail: <info>'.$user->getEmail().'</info>',
' API-Key: <info>'.$user->getApiKey().'</info>',
]);
} | [
"public",
"function",
"outputUserInfo",
"(",
"User",
"$",
"user",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"[",
"' ID: <info>'",
".",
"$",
"user",
"->",
"getId",
"(",
")",
".",
"'</info>'",
",",
"' eMail: <inf... | Print information about a rokka user.
@param User $user
@param OutputInterface $output | [
"Print",
"information",
"about",
"a",
"rokka",
"user",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L143-L150 | train |
rokka-io/rokka-client-php-cli | src/RokkaFormatter.php | RokkaFormatter.formatDynamicMetadata | private function formatDynamicMetadata(DynamicMetadataInterface $metadata)
{
$info = null;
switch ($metadata::getName()) {
case SubjectArea::getName():
$data = [];
/* @var SubjectArea $metadata */
foreach (['x', 'y', 'width', 'height'] as $property) {
$data[] = $property.':'.$metadata->$property;
}
$info = implode('|', $data);
break;
}
return $info;
} | php | private function formatDynamicMetadata(DynamicMetadataInterface $metadata)
{
$info = null;
switch ($metadata::getName()) {
case SubjectArea::getName():
$data = [];
/* @var SubjectArea $metadata */
foreach (['x', 'y', 'width', 'height'] as $property) {
$data[] = $property.':'.$metadata->$property;
}
$info = implode('|', $data);
break;
}
return $info;
} | [
"private",
"function",
"formatDynamicMetadata",
"(",
"DynamicMetadataInterface",
"$",
"metadata",
")",
"{",
"$",
"info",
"=",
"null",
";",
"switch",
"(",
"$",
"metadata",
"::",
"getName",
"(",
")",
")",
"{",
"case",
"SubjectArea",
"::",
"getName",
"(",
")",
... | Convert dynamic metadata information to a string.
@param DynamicMetadataInterface $metadata
@return string | [
"Convert",
"dynamic",
"metadata",
"information",
"to",
"a",
"string",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/RokkaFormatter.php#L159-L175 | train |
k-gun/oppa | src/Link/Link.php | Link.attachAgent | private function attachAgent(): void
{
$this->agentName = strtolower((string) $this->config['agent']);
switch ($this->agentName) {
case self::AGENT_MYSQL:
$this->agent = new Mysql($this->config);
break;
case self::AGENT_PGSQL:
$this->agent = new Pgsql($this->config);
break;
default:
throw new LinkException("Sorry, but '{$this->agentName}' agent not implemented!");
}
} | php | private function attachAgent(): void
{
$this->agentName = strtolower((string) $this->config['agent']);
switch ($this->agentName) {
case self::AGENT_MYSQL:
$this->agent = new Mysql($this->config);
break;
case self::AGENT_PGSQL:
$this->agent = new Pgsql($this->config);
break;
default:
throw new LinkException("Sorry, but '{$this->agentName}' agent not implemented!");
}
} | [
"private",
"function",
"attachAgent",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"agentName",
"=",
"strtolower",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"config",
"[",
"'agent'",
"]",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"agentName",
"... | Attach agent.
@return void
@throws \RuntimeException | [
"Attach",
"agent",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Link/Link.php#L202-L215 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/Sample.php | Sample.actionCreateObject | protected function actionCreateObject()
{
$blockCenter = new XmlBlockCollection($this->_myWords->Value("OBJECT"), BlockPosition::Center);
$breakLine = new XmlnukeBreakLine();
$firstParagraph = new XmlParagraphCollection();
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT1")));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT2"), true, true, true, true));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT3")));
$secondParagraph = new XmlParagraphCollection();
$secondParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT4")));
$secondParagraph->addXmlnukeObject($breakLine);
$secondParagraph->addXmlnukeObject($breakLine);
$xmlnukeImage = new XmlnukeImage("common/imgs/logo_xmlnuke.gif");
$link = new XmlAnchorCollection("engine:xmlnuke", "");
$link->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("CLICK")." -->"));
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject($xmlnukeImage);
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject(new XmlnukeText(" -- ".$this->_myWords->Value("CLICK")));
$secondParagraph->addXmlnukeObject($link);
$secondParagraph->addXmlnukeObject($breakLine);
$thirdParagraph = new XmlParagraphCollection();
$arrayOptions = array();
$arrayOptions["OPTION1"] = $this->_myWords->Value("OPTIONTEST1");
$arrayOptions["OPTION2"] = $this->_myWords->Value("OPTIONTEST2");
$arrayOptions["OPTION3"] = $this->_myWords->Value("OPTIONTEST3");
$arrayOptions["OPTION4"] = $this->_myWords->Value("OPTIONTEST4");
$thirdParagraph->addXmlnukeObject(new XmlEasyList(EasyListType::UNORDEREDLIST, "name", "caption", $arrayOptions, "OP3"));
$blockCenter->addXmlnukeObject($firstParagraph);
$blockCenter->addXmlnukeObject($secondParagraph);
$blockCenter->addXmlnukeObject($thirdParagraph);
$blockLeft = new XmlBlockCollection($this->_myWords->Value("BLOCKLEFT"), BlockPosition::Left);
$blockLeft->addXmlnukeObject($firstParagraph);
$blockRight = new XmlBlockCollection($this->_myWords->Value("BLOCKRIGHT"), BlockPosition::Right);
$blockRight->addXmlnukeObject($firstParagraph);
$this->_document->addXmlnukeObject($blockCenter);
$this->_document->addXmlnukeObject($blockLeft);
$this->_document->addXmlnukeObject($blockRight);
} | php | protected function actionCreateObject()
{
$blockCenter = new XmlBlockCollection($this->_myWords->Value("OBJECT"), BlockPosition::Center);
$breakLine = new XmlnukeBreakLine();
$firstParagraph = new XmlParagraphCollection();
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT1")));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT2"), true, true, true, true));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT3")));
$secondParagraph = new XmlParagraphCollection();
$secondParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT4")));
$secondParagraph->addXmlnukeObject($breakLine);
$secondParagraph->addXmlnukeObject($breakLine);
$xmlnukeImage = new XmlnukeImage("common/imgs/logo_xmlnuke.gif");
$link = new XmlAnchorCollection("engine:xmlnuke", "");
$link->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("CLICK")." -->"));
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject($xmlnukeImage);
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject(new XmlnukeText(" -- ".$this->_myWords->Value("CLICK")));
$secondParagraph->addXmlnukeObject($link);
$secondParagraph->addXmlnukeObject($breakLine);
$thirdParagraph = new XmlParagraphCollection();
$arrayOptions = array();
$arrayOptions["OPTION1"] = $this->_myWords->Value("OPTIONTEST1");
$arrayOptions["OPTION2"] = $this->_myWords->Value("OPTIONTEST2");
$arrayOptions["OPTION3"] = $this->_myWords->Value("OPTIONTEST3");
$arrayOptions["OPTION4"] = $this->_myWords->Value("OPTIONTEST4");
$thirdParagraph->addXmlnukeObject(new XmlEasyList(EasyListType::UNORDEREDLIST, "name", "caption", $arrayOptions, "OP3"));
$blockCenter->addXmlnukeObject($firstParagraph);
$blockCenter->addXmlnukeObject($secondParagraph);
$blockCenter->addXmlnukeObject($thirdParagraph);
$blockLeft = new XmlBlockCollection($this->_myWords->Value("BLOCKLEFT"), BlockPosition::Left);
$blockLeft->addXmlnukeObject($firstParagraph);
$blockRight = new XmlBlockCollection($this->_myWords->Value("BLOCKRIGHT"), BlockPosition::Right);
$blockRight->addXmlnukeObject($firstParagraph);
$this->_document->addXmlnukeObject($blockCenter);
$this->_document->addXmlnukeObject($blockLeft);
$this->_document->addXmlnukeObject($blockRight);
} | [
"protected",
"function",
"actionCreateObject",
"(",
")",
"{",
"$",
"blockCenter",
"=",
"new",
"XmlBlockCollection",
"(",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"OBJECT\"",
")",
",",
"BlockPosition",
"::",
"Center",
")",
";",
"$",
"breakLine",
"... | Show the Create Object Exemple | [
"Show",
"the",
"Create",
"Object",
"Exemple"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/Sample.php#L323-L372 | train |
kenarkose/Ownable | src/Ownable.php | Ownable.isOwnedBy | public function isOwnedBy(Model $owner)
{
if ( ! $this->hasOwner())
{
return false;
}
return ($owner->getKey() === $this->owner->getKey());
} | php | public function isOwnedBy(Model $owner)
{
if ( ! $this->hasOwner())
{
return false;
}
return ($owner->getKey() === $this->owner->getKey());
} | [
"public",
"function",
"isOwnedBy",
"(",
"Model",
"$",
"owner",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOwner",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"owner",
"->",
"getKey",
"(",
")",
"===",
"$",
"this",
"-... | Checks if the given is the owner
@param Model $owner
@return bool | [
"Checks",
"if",
"the",
"given",
"is",
"the",
"owner"
] | 6b5d9b24e84a60ba8cfa319eaee4270d93e87298 | https://github.com/kenarkose/Ownable/blob/6b5d9b24e84a60ba8cfa319eaee4270d93e87298/src/Ownable.php#L123-L131 | train |
Corviz/framework | src/Routing/Map.php | Map.getCurrentRoute | public static function getCurrentRoute()
{
$current = null;
$request = Request::current();
$routeStr = $request->getRouteStr();
$method = $request->getMethod();
//Search for the route
foreach (self::$routes as $route) {
//Check the method
if (!in_array($method, $route['methods'])) {
continue;
}
//Check number of slashes
if (
substr_count($route['route'], '/')
!= substr_count($routeStr, '/')
) {
continue;
}
//Checks the route string
if (
ParametrizedString
::make($route['route'])
->matches($routeStr)
) {
$current = $route;
break;
}
}
return $current;
} | php | public static function getCurrentRoute()
{
$current = null;
$request = Request::current();
$routeStr = $request->getRouteStr();
$method = $request->getMethod();
//Search for the route
foreach (self::$routes as $route) {
//Check the method
if (!in_array($method, $route['methods'])) {
continue;
}
//Check number of slashes
if (
substr_count($route['route'], '/')
!= substr_count($routeStr, '/')
) {
continue;
}
//Checks the route string
if (
ParametrizedString
::make($route['route'])
->matches($routeStr)
) {
$current = $route;
break;
}
}
return $current;
} | [
"public",
"static",
"function",
"getCurrentRoute",
"(",
")",
"{",
"$",
"current",
"=",
"null",
";",
"$",
"request",
"=",
"Request",
"::",
"current",
"(",
")",
";",
"$",
"routeStr",
"=",
"$",
"request",
"->",
"getRouteStr",
"(",
")",
";",
"$",
"method",... | Search for the route that matches the current
request. If not found, returns NULL.
@return array|null | [
"Search",
"for",
"the",
"route",
"that",
"matches",
"the",
"current",
"request",
".",
"If",
"not",
"found",
"returns",
"NULL",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Map.php#L36-L70 | train |
bytic/goutte-phantomjs-bridge | src/Clients/PhantomJs/ResponseFormatter.php | ResponseFormatter.format | public static function format($phantomJsResponse)
{
$response = new Response(
$phantomJsResponse->getStatus(),
$phantomJsResponse->getHeaders(),
$phantomJsResponse->getContent()
);
return $response;
} | php | public static function format($phantomJsResponse)
{
$response = new Response(
$phantomJsResponse->getStatus(),
$phantomJsResponse->getHeaders(),
$phantomJsResponse->getContent()
);
return $response;
} | [
"public",
"static",
"function",
"format",
"(",
"$",
"phantomJsResponse",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"phantomJsResponse",
"->",
"getStatus",
"(",
")",
",",
"$",
"phantomJsResponse",
"->",
"getHeaders",
"(",
")",
",",
"$",
"... | ResponseBridge constructor.
@param \JonnyW\PhantomJs\Http\Response|\JonnyW\PhantomJs\Http\ResponseInterface $phantomJsResponse
@return Response | [
"ResponseBridge",
"constructor",
"."
] | 03b2021598ea7edf71c9dcb04bf530982a525f75 | https://github.com/bytic/goutte-phantomjs-bridge/blob/03b2021598ea7edf71c9dcb04bf530982a525f75/src/Clients/PhantomJs/ResponseFormatter.php#L19-L27 | train |
narrowspark/mimetypes | src/MimeTypeFileBinaryGuesser.php | MimeTypeFileBinaryGuesser.guess | public static function guess(string $path, string $cmd = null): ?string
{
if (! \is_file($path)) {
throw new FileNotFoundException($path);
}
if (! \is_readable($path)) {
throw new AccessDeniedException($path);
}
if ($cmd === null) {
$cmd = 'file -b --mime %s';
if (\stripos(\PHP_OS, 'win') !== 0) {
$cmd .= ' 2>/dev/null';
}
}
\ob_start();
// need to use --mime instead of -i.
\passthru(\sprintf($cmd, \escapeshellarg($path)), $return);
if ($return > 0) {
\ob_end_clean();
return null;
}
$type = \trim((string) \ob_get_clean());
if (\preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match) === false) {
// it's not a type, but an error message
return null;
}
return $match[1];
} | php | public static function guess(string $path, string $cmd = null): ?string
{
if (! \is_file($path)) {
throw new FileNotFoundException($path);
}
if (! \is_readable($path)) {
throw new AccessDeniedException($path);
}
if ($cmd === null) {
$cmd = 'file -b --mime %s';
if (\stripos(\PHP_OS, 'win') !== 0) {
$cmd .= ' 2>/dev/null';
}
}
\ob_start();
// need to use --mime instead of -i.
\passthru(\sprintf($cmd, \escapeshellarg($path)), $return);
if ($return > 0) {
\ob_end_clean();
return null;
}
$type = \trim((string) \ob_get_clean());
if (\preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match) === false) {
// it's not a type, but an error message
return null;
}
return $match[1];
} | [
"public",
"static",
"function",
"guess",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"cmd",
"=",
"null",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"\\",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",... | Guesses the mime type with the binary "file".
@param string $path
@param string $cmd the command to run to get the mime type of a file.
The $cmd pattern must contain a "%s" string that will be replaced
with the file name to guess.
The command output must start with the mime type of the file.
Like: text/plain; charset=us-ascii
@throws \Narrowspark\MimeType\Exception\AccessDeniedException If the file could not be read
@return null|string | [
"Guesses",
"the",
"mime",
"type",
"with",
"the",
"binary",
"file",
"."
] | 3ce9277e7e93edb04b269bc3e37181e2e51ce0ac | https://github.com/narrowspark/mimetypes/blob/3ce9277e7e93edb04b269bc3e37181e2e51ce0ac/src/MimeTypeFileBinaryGuesser.php#L57-L94 | train |
williamdes/mariadb-mysql-kbs | src/SlimData.php | SlimData.addVariable | public function addVariable(string $name, ?string $type, ?bool $dynamic): KBEntry
{
$kbe = new KBEntry($name, $type, $dynamic);
$this->vars[] = $kbe;
return $kbe;
} | php | public function addVariable(string $name, ?string $type, ?bool $dynamic): KBEntry
{
$kbe = new KBEntry($name, $type, $dynamic);
$this->vars[] = $kbe;
return $kbe;
} | [
"public",
"function",
"addVariable",
"(",
"string",
"$",
"name",
",",
"?",
"string",
"$",
"type",
",",
"?",
"bool",
"$",
"dynamic",
")",
":",
"KBEntry",
"{",
"$",
"kbe",
"=",
"new",
"KBEntry",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"dynamic"... | Add a variable
@param string $name The name
@param string|null $type The type
@param bool|null $dynamic Is dynamic
@return KBEntry The newly created KBEntry | [
"Add",
"a",
"variable"
] | c5cafc66b59aee56e0db8ca42a0ddb8e0fc14f7e | https://github.com/williamdes/mariadb-mysql-kbs/blob/c5cafc66b59aee56e0db8ca42a0ddb8e0fc14f7e/src/SlimData.php#L89-L94 | train |
mrclay/UserlandSession | src/UserlandSession/SessionBuilder.php | SessionBuilder.build | public function build()
{
if ($this->handler) {
$handler = $this->handler;
} elseif ($this->pdo || $this->dbCredentials) {
$options = $this->dbCredentials;
$options['table'] = $this->table;
if ($this->pdo) {
$options['pdo'] = $this->pdo;
}
$handler = new PdoHandler($options);
} else {
$handler = new FileHandler($this->locking);
}
return new Session($handler, $this->name, $this->savePath, $this->serializer);
} | php | public function build()
{
if ($this->handler) {
$handler = $this->handler;
} elseif ($this->pdo || $this->dbCredentials) {
$options = $this->dbCredentials;
$options['table'] = $this->table;
if ($this->pdo) {
$options['pdo'] = $this->pdo;
}
$handler = new PdoHandler($options);
} else {
$handler = new FileHandler($this->locking);
}
return new Session($handler, $this->name, $this->savePath, $this->serializer);
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"handler",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"pdo",
"||",
"$",
"this",
"->",
"dbCredentials",
")",
... | Create a new session with the appropriate storage handler
@return Session | [
"Create",
"a",
"new",
"session",
"with",
"the",
"appropriate",
"storage",
"handler"
] | deabb1b487294efbd0bcb79ca83e6dab56036e45 | https://github.com/mrclay/UserlandSession/blob/deabb1b487294efbd0bcb79ca83e6dab56036e45/src/UserlandSession/SessionBuilder.php#L138-L153 | train |
pauci/cqrs | src/Domain/Message/Metadata.php | Metadata.mergedWith | public function mergedWith(Metadata $additionalMetadata): self
{
$values = array_merge($this->values, $additionalMetadata->values);
if ($values === $this->values) {
return $this;
}
return new static($values);
} | php | public function mergedWith(Metadata $additionalMetadata): self
{
$values = array_merge($this->values, $additionalMetadata->values);
if ($values === $this->values) {
return $this;
}
return new static($values);
} | [
"public",
"function",
"mergedWith",
"(",
"Metadata",
"$",
"additionalMetadata",
")",
":",
"self",
"{",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"additionalMetadata",
"->",
"values",
")",
";",
"if",
"(",
"$",
"values",
... | Returns a Metadata instance containing values of this, combined with the given additionalMetadata.
If any entries have identical keys, the values from the additionalMetadata will take precedence.
@param Metadata $additionalMetadata
@return self | [
"Returns",
"a",
"Metadata",
"instance",
"containing",
"values",
"of",
"this",
"combined",
"with",
"the",
"given",
"additionalMetadata",
".",
"If",
"any",
"entries",
"have",
"identical",
"keys",
"the",
"values",
"from",
"the",
"additionalMetadata",
"will",
"take",
... | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/Domain/Message/Metadata.php#L169-L178 | train |
pauci/cqrs | src/Domain/Message/Metadata.php | Metadata.withoutKeys | public function withoutKeys(array $keys): self
{
$values = array_diff_key($this->values, array_flip($keys));
if ($values === $this->values) {
return $this;
}
return new static($values);
} | php | public function withoutKeys(array $keys): self
{
$values = array_diff_key($this->values, array_flip($keys));
if ($values === $this->values) {
return $this;
}
return new static($values);
} | [
"public",
"function",
"withoutKeys",
"(",
"array",
"$",
"keys",
")",
":",
"self",
"{",
"$",
"values",
"=",
"array_diff_key",
"(",
"$",
"this",
"->",
"values",
",",
"array_flip",
"(",
"$",
"keys",
")",
")",
";",
"if",
"(",
"$",
"values",
"===",
"$",
... | Returns a Metadata instance with the items with given keys removed. Keys for which there is no
assigned value are ignored.
This Metadata instance is not influenced by this operation.
@param array $keys
@return self | [
"Returns",
"a",
"Metadata",
"instance",
"with",
"the",
"items",
"with",
"given",
"keys",
"removed",
".",
"Keys",
"for",
"which",
"there",
"is",
"no",
"assigned",
"value",
"are",
"ignored",
"."
] | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/Domain/Message/Metadata.php#L189-L198 | train |
ansas/php-component | src/Util/Number.php | Number.toReadableSize | public static function toReadableSize($bytes, $decimals = 1, $system = 'metric')
{
$mod = ($system === 'binary') ? 1024 : 1000;
$units = [
'binary' => [
'B',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB',
],
'metric' => [
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
],
];
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f %s", $bytes / pow($mod, $factor), $units[$system][$factor]);
} | php | public static function toReadableSize($bytes, $decimals = 1, $system = 'metric')
{
$mod = ($system === 'binary') ? 1024 : 1000;
$units = [
'binary' => [
'B',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB',
],
'metric' => [
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
],
];
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f %s", $bytes / pow($mod, $factor), $units[$system][$factor]);
} | [
"public",
"static",
"function",
"toReadableSize",
"(",
"$",
"bytes",
",",
"$",
"decimals",
"=",
"1",
",",
"$",
"system",
"=",
"'metric'",
")",
"{",
"$",
"mod",
"=",
"(",
"$",
"system",
"===",
"'binary'",
")",
"?",
"1024",
":",
"1000",
";",
"$",
"un... | Convert to readable size.
@param int $bytes
@param int $decimals [optional]
@param string $system [optional] binary | metric
@return string | [
"Convert",
"to",
"readable",
"size",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Number.php#L30-L62 | train |
ansas/php-component | src/Util/Number.php | Number.toReadableTime | public static function toReadableTime($time, $decimals = 3)
{
$decimals = (int) $decimals;
$unit = 'sec';
return sprintf("%.{$decimals}f %s", $time, $unit);
} | php | public static function toReadableTime($time, $decimals = 3)
{
$decimals = (int) $decimals;
$unit = 'sec';
return sprintf("%.{$decimals}f %s", $time, $unit);
} | [
"public",
"static",
"function",
"toReadableTime",
"(",
"$",
"time",
",",
"$",
"decimals",
"=",
"3",
")",
"{",
"$",
"decimals",
"=",
"(",
"int",
")",
"$",
"decimals",
";",
"$",
"unit",
"=",
"'sec'",
";",
"return",
"sprintf",
"(",
"\"%.{$decimals}f %s\"",
... | Convert to readable time.
@param float $time
@param int $decimals [optional]
@return string | [
"Convert",
"to",
"readable",
"time",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Number.php#L73-L79 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/Players/Plugins/Gui/PlayersWindow.php | PlayersWindow.getIgnoredStatus | private function getIgnoredStatus($login)
{
try {
$ignoreList = $this->factory->getConnection()->getIgnoreList();
foreach ($ignoreList as $player) {
if ($player->login === $login) {
return true;
}
}
return false;
} catch (\Exception $e) {
return false;
}
} | php | private function getIgnoredStatus($login)
{
try {
$ignoreList = $this->factory->getConnection()->getIgnoreList();
foreach ($ignoreList as $player) {
if ($player->login === $login) {
return true;
}
}
return false;
} catch (\Exception $e) {
return false;
}
} | [
"private",
"function",
"getIgnoredStatus",
"(",
"$",
"login",
")",
"{",
"try",
"{",
"$",
"ignoreList",
"=",
"$",
"this",
"->",
"factory",
"->",
"getConnection",
"(",
")",
"->",
"getIgnoreList",
"(",
")",
";",
"foreach",
"(",
"$",
"ignoreList",
"as",
"$",... | Get ignore status for a player;
@param string $login
@return bool | [
"Get",
"ignore",
"status",
"for",
"a",
"player",
";"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Players/Plugins/Gui/PlayersWindow.php#L466-L480 | train |
JBZoo/Html | src/Render/Hidden.php | Hidden.group | public function group(array $fields)
{
$output = array();
foreach ($fields as $name => $data) {
if (is_array($data)) {
list($data, $value, $class, $id) = $this->_findMainAttr($data);
$output[] = $this->render($name, $value, $class, $id, $data);
} else {
$output[] = $this->render($name, $data);
}
}
return implode(PHP_EOL, $output);
} | php | public function group(array $fields)
{
$output = array();
foreach ($fields as $name => $data) {
if (is_array($data)) {
list($data, $value, $class, $id) = $this->_findMainAttr($data);
$output[] = $this->render($name, $value, $class, $id, $data);
} else {
$output[] = $this->render($name, $data);
}
}
return implode(PHP_EOL, $output);
} | [
"public",
"function",
"group",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
... | Create group hidden inputs.
@param array $fields
@return string | [
"Create",
"group",
"hidden",
"inputs",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Hidden.php#L41-L54 | train |
TheBnl/event-tickets | code/tasks/MigrateUserFieldsTask.php | MigrateUserFieldsTask.migrateFields | private function migrateFields()
{
if ($attendeeFields = AttendeeExtraField::get()) {
foreach ($attendeeFields as $attendeeField) {
$this->findOrMakeUserFieldFor($attendeeField);
}
}
} | php | private function migrateFields()
{
if ($attendeeFields = AttendeeExtraField::get()) {
foreach ($attendeeFields as $attendeeField) {
$this->findOrMakeUserFieldFor($attendeeField);
}
}
} | [
"private",
"function",
"migrateFields",
"(",
")",
"{",
"if",
"(",
"$",
"attendeeFields",
"=",
"AttendeeExtraField",
"::",
"get",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"attendeeFields",
"as",
"$",
"attendeeField",
")",
"{",
"$",
"this",
"->",
"findOrMake... | Migrate the AttendeeExtraFields to UserFields | [
"Migrate",
"the",
"AttendeeExtraFields",
"to",
"UserFields"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateUserFieldsTask.php#L53-L60 | train |
TheBnl/event-tickets | code/tasks/MigrateUserFieldsTask.php | MigrateUserFieldsTask.findOrMakeUserFieldFor | private function findOrMakeUserFieldFor(AttendeeExtraField $attendeeField)
{
if (!$field = $this->getUserFields()->byID($attendeeField->ID)) {
/** @var UserField $field */
$class = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field = $class::create();
}
$field->ClassName = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field->ID = $attendeeField->ID;
$field->Name = $attendeeField->FieldName;
$field->Title = $attendeeField->Title;
$field->Default = $attendeeField->DefaultValue;
$field->ExtraClass = $attendeeField->ExtraClass;
$field->Required = $attendeeField->Required;
$field->Editable = $attendeeField->Editable;
$field->EventID = $attendeeField->EventID;
$field->Sort = $attendeeField->Sort;
if ($attendeeField->Options()->exists() && $field->ClassName === 'UserOptionSetField') {
/** @var \UserOptionSetField $field */
/** @var AttendeeExtraFieldOption $attendeeOption */
foreach ($attendeeField->Options() as $option) {
$field->Options()->add($this->findOrMakeUserOptionFor($option));
echo "[{$field->ID}] Added AttendeeExtraFieldOption as UserFieldOption\n";
}
}
$field->write();
echo "[{$field->ID}] Migrated AttendeeExtraField to $field->ClassName\n";
} | php | private function findOrMakeUserFieldFor(AttendeeExtraField $attendeeField)
{
if (!$field = $this->getUserFields()->byID($attendeeField->ID)) {
/** @var UserField $field */
$class = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field = $class::create();
}
$field->ClassName = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field->ID = $attendeeField->ID;
$field->Name = $attendeeField->FieldName;
$field->Title = $attendeeField->Title;
$field->Default = $attendeeField->DefaultValue;
$field->ExtraClass = $attendeeField->ExtraClass;
$field->Required = $attendeeField->Required;
$field->Editable = $attendeeField->Editable;
$field->EventID = $attendeeField->EventID;
$field->Sort = $attendeeField->Sort;
if ($attendeeField->Options()->exists() && $field->ClassName === 'UserOptionSetField') {
/** @var \UserOptionSetField $field */
/** @var AttendeeExtraFieldOption $attendeeOption */
foreach ($attendeeField->Options() as $option) {
$field->Options()->add($this->findOrMakeUserOptionFor($option));
echo "[{$field->ID}] Added AttendeeExtraFieldOption as UserFieldOption\n";
}
}
$field->write();
echo "[{$field->ID}] Migrated AttendeeExtraField to $field->ClassName\n";
} | [
"private",
"function",
"findOrMakeUserFieldFor",
"(",
"AttendeeExtraField",
"$",
"attendeeField",
")",
"{",
"if",
"(",
"!",
"$",
"field",
"=",
"$",
"this",
"->",
"getUserFields",
"(",
")",
"->",
"byID",
"(",
"$",
"attendeeField",
"->",
"ID",
")",
")",
"{",... | Make a new UserField based on the given AttendeeExtraField
@param AttendeeExtraField $attendeeField | [
"Make",
"a",
"new",
"UserField",
"based",
"on",
"the",
"given",
"AttendeeExtraField"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateUserFieldsTask.php#L67-L97 | train |
TheBnl/event-tickets | code/tasks/MigrateUserFieldsTask.php | MigrateUserFieldsTask.findOrMakeUserOptionFor | private function findOrMakeUserOptionFor(AttendeeExtraFieldOption $attendeeOption)
{
if (!$option = $this->getUserFieldOption()->byID($attendeeOption->ID)) {
$option = UserFieldOption::create();
}
$option->ID = $attendeeOption->ID;
$option->Title = $attendeeOption->Title;
$option->Default = $attendeeOption->Default;
$option->Sort = $attendeeOption->Sort;
return $option;
} | php | private function findOrMakeUserOptionFor(AttendeeExtraFieldOption $attendeeOption)
{
if (!$option = $this->getUserFieldOption()->byID($attendeeOption->ID)) {
$option = UserFieldOption::create();
}
$option->ID = $attendeeOption->ID;
$option->Title = $attendeeOption->Title;
$option->Default = $attendeeOption->Default;
$option->Sort = $attendeeOption->Sort;
return $option;
} | [
"private",
"function",
"findOrMakeUserOptionFor",
"(",
"AttendeeExtraFieldOption",
"$",
"attendeeOption",
")",
"{",
"if",
"(",
"!",
"$",
"option",
"=",
"$",
"this",
"->",
"getUserFieldOption",
"(",
")",
"->",
"byID",
"(",
"$",
"attendeeOption",
"->",
"ID",
")"... | Find or make an option based on the given AttendeeExtraFieldOption
@param AttendeeExtraFieldOption $attendeeOption
@return \DataObject|UserFieldOption | [
"Find",
"or",
"make",
"an",
"option",
"based",
"on",
"the",
"given",
"AttendeeExtraFieldOption"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateUserFieldsTask.php#L106-L117 | train |
TheBnl/event-tickets | code/tasks/MigrateUserFieldsTask.php | MigrateUserFieldsTask.mapFieldType | private static function mapFieldType($type, $name = null)
{
$types = array(
'TextField' => 'UserTextField',
'EmailField' => 'UserEmailField',
'CheckboxField' => 'UserCheckboxField',
'OptionsetField' => 'UserOptionSetField'
);
$currentDefaults = Attendee::config()->get('default_fields');
if ($currentDefaults && key_exists($name, $currentDefaults)) {
return $currentDefaults[$name]['FieldType'];
} else {
return $types[$type];
}
} | php | private static function mapFieldType($type, $name = null)
{
$types = array(
'TextField' => 'UserTextField',
'EmailField' => 'UserEmailField',
'CheckboxField' => 'UserCheckboxField',
'OptionsetField' => 'UserOptionSetField'
);
$currentDefaults = Attendee::config()->get('default_fields');
if ($currentDefaults && key_exists($name, $currentDefaults)) {
return $currentDefaults[$name]['FieldType'];
} else {
return $types[$type];
}
} | [
"private",
"static",
"function",
"mapFieldType",
"(",
"$",
"type",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"types",
"=",
"array",
"(",
"'TextField'",
"=>",
"'UserTextField'",
",",
"'EmailField'",
"=>",
"'UserEmailField'",
",",
"'CheckboxField'",
"=>",
... | Map the given field type to one of the available class names
Also looks into the current mapping if the field has a new type
@param $type
@param null $name
@return string | [
"Map",
"the",
"given",
"field",
"type",
"to",
"one",
"of",
"the",
"available",
"class",
"names",
"Also",
"looks",
"into",
"the",
"current",
"mapping",
"if",
"the",
"field",
"has",
"a",
"new",
"type"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateUserFieldsTask.php#L128-L144 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/VoteManager/Services/VoteService.php | VoteService.update | public function update()
{
if ($this->currentVote) {
$vote = $this->currentVote->getCurrentVote();
$this->currentVote->update(time());
switch ($vote->getStatus()) {
case Vote::STATUS_CANCEL:
$this->dispatcher->dispatch("votemanager.votecancelled",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_FAILED:
$this->dispatcher->dispatch("votemanager.votefailed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_PASSED:
$this->dispatcher->dispatch("votemanager.votepassed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
}
}
} | php | public function update()
{
if ($this->currentVote) {
$vote = $this->currentVote->getCurrentVote();
$this->currentVote->update(time());
switch ($vote->getStatus()) {
case Vote::STATUS_CANCEL:
$this->dispatcher->dispatch("votemanager.votecancelled",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_FAILED:
$this->dispatcher->dispatch("votemanager.votefailed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_PASSED:
$this->dispatcher->dispatch("votemanager.votepassed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
}
}
} | [
"public",
"function",
"update",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentVote",
")",
"{",
"$",
"vote",
"=",
"$",
"this",
"->",
"currentVote",
"->",
"getCurrentVote",
"(",
")",
";",
"$",
"this",
"->",
"currentVote",
"->",
"update",
"(",
"t... | Update the status of the vote. | [
"Update",
"the",
"status",
"of",
"the",
"vote",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Services/VoteService.php#L101-L128 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/VoteManager/Services/VoteService.php | VoteService.startVote | public function startVote(Player $player, $typeCode, $params)
{
if ($this->getCurrentVote() !== null) {
$this->chatNotification->sendMessage("expansion_votemanager.error.in_progress");
return;
}
if (isset($this->voteMapping[$typeCode])) {
$typeCode = $this->voteMapping[$typeCode];
}
if (!isset($this->votePlugins[$typeCode])) {
// no vote-plugin found for native vote, so return silently
return;
}
$this->currentVote = $this->votePlugins[$typeCode];
$this->currentVote->start($player, $params);
$this->factory->getConnection()->cancelVote();
$this->dispatcher->dispatch(
"votemanager.votenew",
[$player, $this->currentVote->getCode(), $this->currentVote->getCurrentVote()]
);
} | php | public function startVote(Player $player, $typeCode, $params)
{
if ($this->getCurrentVote() !== null) {
$this->chatNotification->sendMessage("expansion_votemanager.error.in_progress");
return;
}
if (isset($this->voteMapping[$typeCode])) {
$typeCode = $this->voteMapping[$typeCode];
}
if (!isset($this->votePlugins[$typeCode])) {
// no vote-plugin found for native vote, so return silently
return;
}
$this->currentVote = $this->votePlugins[$typeCode];
$this->currentVote->start($player, $params);
$this->factory->getConnection()->cancelVote();
$this->dispatcher->dispatch(
"votemanager.votenew",
[$player, $this->currentVote->getCode(), $this->currentVote->getCurrentVote()]
);
} | [
"public",
"function",
"startVote",
"(",
"Player",
"$",
"player",
",",
"$",
"typeCode",
",",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCurrentVote",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"chatNotification",
"->",
"sendMe... | Start a vote.
@param Player $player
@param string $typeCode
@param array $params | [
"Start",
"a",
"vote",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Services/VoteService.php#L172-L196 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Repositories/JournalEntry/EloquentJournalEntry.php | EloquentJournalEntry.byAccountIds | public function byAccountIds($ids, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->JournalEntry->setConnection($databaseConnectionName)->whereIn('account_id', $ids)->get();
} | php | public function byAccountIds($ids, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->JournalEntry->setConnection($databaseConnectionName)->whereIn('account_id', $ids)->get();
} | [
"public",
"function",
"byAccountIds",
"(",
"$",
"ids",
",",
"$",
"databaseConnectionName",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"databaseConnectionName",
")",
")",
"{",
"$",
"databaseConnectionName",
"=",
"$",
"this",
"->",
"databaseConnectionN... | Get journal entries by account ids
@param int $id Journal Voucher id
@return integer | [
"Get",
"journal",
"entries",
"by",
"account",
"ids"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/JournalEntry/EloquentJournalEntry.php#L99-L107 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Repositories/JournalEntry/EloquentJournalEntry.php | EloquentJournalEntry.getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear | public function getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear($plBsCategory, $organizationId, $fiscalYearId, $databaseConnectionName = null)
{
// $this->DB->connection()->enableQueryLog();
// $Entries = $this->DB->table('ACCT_Journal_Entry AS je')
// ->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
// ->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
// ->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')
// ->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
// ->where('jv.status', '=', 'B')
// ->where('jv.organization_id', '=', $organizationId)
// ->where('p.fiscal_year_id', '=', $fiscalYearId)
// // ->where('c.is_group', '=', 0)
// ->where('at.pl_bs_category', '=', $plBsCategory)
// ->whereNull('je.deleted_at')
// ->whereNull('jv.deleted_at')
// // ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'),
// // $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// )
// )->get();
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->DB->connection($databaseConnectionName)
->table('ACCT_Journal_Entry AS je')
->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
->join('ACCT_Account AS c', 'c.id', '=', 'je.account_id')
->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
->where('jv.organization_id', '=', $organizationId)
->where('p.fiscal_year_id', '=', $fiscalYearId)
->where('jv.status', '=', 'B')
->whereIn('at.pl_bs_category', $plBsCategory)
->whereNull('je.deleted_at')
->whereNull('jv.deleted_at')
->groupBy('je.cost_center_id', 'je.account_id', 'c.balance_type')
->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'), 'je.cost_center_id', 'je.account_id', 'c.balance_type'))
->get();
// var_dump($this->DB->getQueryLog(), $Entries);die();
} | php | public function getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear($plBsCategory, $organizationId, $fiscalYearId, $databaseConnectionName = null)
{
// $this->DB->connection()->enableQueryLog();
// $Entries = $this->DB->table('ACCT_Journal_Entry AS je')
// ->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
// ->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
// ->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')
// ->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
// ->where('jv.status', '=', 'B')
// ->where('jv.organization_id', '=', $organizationId)
// ->where('p.fiscal_year_id', '=', $fiscalYearId)
// // ->where('c.is_group', '=', 0)
// ->where('at.pl_bs_category', '=', $plBsCategory)
// ->whereNull('je.deleted_at')
// ->whereNull('jv.deleted_at')
// // ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'),
// // $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// )
// )->get();
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->DB->connection($databaseConnectionName)
->table('ACCT_Journal_Entry AS je')
->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
->join('ACCT_Account AS c', 'c.id', '=', 'je.account_id')
->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
->where('jv.organization_id', '=', $organizationId)
->where('p.fiscal_year_id', '=', $fiscalYearId)
->where('jv.status', '=', 'B')
->whereIn('at.pl_bs_category', $plBsCategory)
->whereNull('je.deleted_at')
->whereNull('jv.deleted_at')
->groupBy('je.cost_center_id', 'je.account_id', 'c.balance_type')
->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'), 'je.cost_center_id', 'je.account_id', 'c.balance_type'))
->get();
// var_dump($this->DB->getQueryLog(), $Entries);die();
} | [
"public",
"function",
"getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear",
"(",
"$",
"plBsCategory",
",",
"$",
"organizationId",
",",
"$",
"fiscalYearId",
",",
"$",
"databaseConnectionName",
"=",
"null",
")",
"{",
"// $this->DB->connection()->enableQueryLog();... | Get the credit sum of all entries of a journal voucher
@param int $id Journal Voucher id
@return array of stdClass | [
"Get",
"the",
"credit",
"sum",
"of",
"all",
"entries",
"of",
"a",
"journal",
"voucher"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/JournalEntry/EloquentJournalEntry.php#L150-L196 | train |
JBZoo/Html | src/ButtonAbstract.php | ButtonAbstract._getBtnClasses | protected function _getBtnClasses(array $attrs = array())
{
if (Arr::key('button', $attrs)) {
$classes = array($this->_btm);
foreach ((array) $attrs['button'] as $btn) {
$classes[] = $this->_btm . '-' . $btn;
}
$attrs = $this->_mergeAttr($attrs, implode(' ', $classes));
unset($attrs['button']);
}
return $attrs;
} | php | protected function _getBtnClasses(array $attrs = array())
{
if (Arr::key('button', $attrs)) {
$classes = array($this->_btm);
foreach ((array) $attrs['button'] as $btn) {
$classes[] = $this->_btm . '-' . $btn;
}
$attrs = $this->_mergeAttr($attrs, implode(' ', $classes));
unset($attrs['button']);
}
return $attrs;
} | [
"protected",
"function",
"_getBtnClasses",
"(",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'button'",
",",
"$",
"attrs",
")",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"$",
"this",
"->",
"_btm",... | Create button classes.
@param array $attrs
@return array | [
"Create",
"button",
"classes",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/ButtonAbstract.php#L60-L73 | train |
inc2734/wp-view-controller | src/App/Config.php | Config.get | public static function get( $key = null ) {
$path = apply_filters(
'inc2734_view_controller_config_path',
untrailingslashit( __DIR__ ) . '/../config/config.php'
);
if ( ! file_exists( $path ) ) {
return;
}
$config = include( $path );
if ( is_null( $key ) ) {
return $config;
}
if ( ! isset( $config[ $key ] ) ) {
return;
}
return $config[ $key ];
} | php | public static function get( $key = null ) {
$path = apply_filters(
'inc2734_view_controller_config_path',
untrailingslashit( __DIR__ ) . '/../config/config.php'
);
if ( ! file_exists( $path ) ) {
return;
}
$config = include( $path );
if ( is_null( $key ) ) {
return $config;
}
if ( ! isset( $config[ $key ] ) ) {
return;
}
return $config[ $key ];
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"apply_filters",
"(",
"'inc2734_view_controller_config_path'",
",",
"untrailingslashit",
"(",
"__DIR__",
")",
".",
"'/../config/config.php'",
")",
";",
"if",
"(",
... | Getting config value
@param string $key the key of the config
@return mixed | [
"Getting",
"config",
"value"
] | d146b7dce51fead749f83b48fc49d1386e676bae | https://github.com/inc2734/wp-view-controller/blob/d146b7dce51fead749f83b48fc49d1386e676bae/src/App/Config.php#L18-L39 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Plugins/BaseRecords.php | BaseRecords.startMap | public function startMap($map, $nbLaps)
{
// Load firs X records for this map.
$this->recordsHandler->loadForMap($map->uId, $nbLaps);
// Load time information for remaining players.
$this->recordsHandler->loadForPlayers($map->uId, $nbLaps, $this->allPlayersGroup->getLogins());
// Let others know that records information is now available.
$this->dispatchEvent(['event' => 'loaded', 'records' => $this->recordsHandler->getRecords()]);
} | php | public function startMap($map, $nbLaps)
{
// Load firs X records for this map.
$this->recordsHandler->loadForMap($map->uId, $nbLaps);
// Load time information for remaining players.
$this->recordsHandler->loadForPlayers($map->uId, $nbLaps, $this->allPlayersGroup->getLogins());
// Let others know that records information is now available.
$this->dispatchEvent(['event' => 'loaded', 'records' => $this->recordsHandler->getRecords()]);
} | [
"public",
"function",
"startMap",
"(",
"$",
"map",
",",
"$",
"nbLaps",
")",
"{",
"// Load firs X records for this map.",
"$",
"this",
"->",
"recordsHandler",
"->",
"loadForMap",
"(",
"$",
"map",
"->",
"uId",
",",
"$",
"nbLaps",
")",
";",
"// Load time informat... | Start plugin for a certain map.
@param Map $map
@param int $nbLaps
@throws \Propel\Runtime\Exception\PropelException | [
"Start",
"plugin",
"for",
"a",
"certain",
"map",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Plugins/BaseRecords.php#L130-L140 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Plugins/BaseRecords.php | BaseRecords.dispatchEvent | public function dispatchEvent($eventData)
{
$event = $this->eventPrefix.'.'.$eventData['event'];
unset($eventData['event']);
$eventData[RecordHandler::COL_PLUGIN] = $this;
$this->dispatcher->dispatch($event, [$eventData]);
} | php | public function dispatchEvent($eventData)
{
$event = $this->eventPrefix.'.'.$eventData['event'];
unset($eventData['event']);
$eventData[RecordHandler::COL_PLUGIN] = $this;
$this->dispatcher->dispatch($event, [$eventData]);
} | [
"public",
"function",
"dispatchEvent",
"(",
"$",
"eventData",
")",
"{",
"$",
"event",
"=",
"$",
"this",
"->",
"eventPrefix",
".",
"'.'",
".",
"$",
"eventData",
"[",
"'event'",
"]",
";",
"unset",
"(",
"$",
"eventData",
"[",
"'event'",
"]",
")",
";",
"... | Dispatch a record event.
@param $eventData | [
"Dispatch",
"a",
"record",
"event",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Plugins/BaseRecords.php#L241-L248 | train |
pauci/cqrs | src/Domain/Model/AggregateRootTrait.php | AggregateRootTrait.registerEvent | protected function registerEvent($payload, $metadata = null)
{
if ($payload instanceof AbstractDomainEvent && null === $payload->aggregateId) {
$payload->setAggregateId($this->getId());
}
return $this->getEventContainer()
->addEvent($payload, $metadata);
} | php | protected function registerEvent($payload, $metadata = null)
{
if ($payload instanceof AbstractDomainEvent && null === $payload->aggregateId) {
$payload->setAggregateId($this->getId());
}
return $this->getEventContainer()
->addEvent($payload, $metadata);
} | [
"protected",
"function",
"registerEvent",
"(",
"$",
"payload",
",",
"$",
"metadata",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"payload",
"instanceof",
"AbstractDomainEvent",
"&&",
"null",
"===",
"$",
"payload",
"->",
"aggregateId",
")",
"{",
"$",
"payload",
... | Registers an event to be published when the aggregate is saved, containing the given payload and optional
metadata.
@param object $payload
@param Metadata|array $metadata
@return DomainEventMessageInterface | [
"Registers",
"an",
"event",
"to",
"be",
"published",
"when",
"the",
"aggregate",
"is",
"saved",
"containing",
"the",
"given",
"payload",
"and",
"optional",
"metadata",
"."
] | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/Domain/Model/AggregateRootTrait.php#L38-L46 | train |
CottaCush/yii2-widgets | src/Assets/AssetBundle.php | AssetBundle.registerAssetFiles | public function registerAssetFiles($view)
{
if (YII_ENV_PROD) {
if (!empty($this->productionJs)) {
$this->js = $this->productionJs;
}
if (!empty($this->productionCss)) {
$this->css = $this->productionCss;
}
}
parent::registerAssetFiles($view);
} | php | public function registerAssetFiles($view)
{
if (YII_ENV_PROD) {
if (!empty($this->productionJs)) {
$this->js = $this->productionJs;
}
if (!empty($this->productionCss)) {
$this->css = $this->productionCss;
}
}
parent::registerAssetFiles($view);
} | [
"public",
"function",
"registerAssetFiles",
"(",
"$",
"view",
")",
"{",
"if",
"(",
"YII_ENV_PROD",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"productionJs",
")",
")",
"{",
"$",
"this",
"->",
"js",
"=",
"$",
"this",
"->",
"productionJ... | Registers the CSS and JS files with the given view.
In production environments, make use of the production asset files if they are provided
@param \yii\web\View $view the view that the asset files are to be registered with. | [
"Registers",
"the",
"CSS",
"and",
"JS",
"files",
"with",
"the",
"given",
"view",
".",
"In",
"production",
"environments",
"make",
"use",
"of",
"the",
"production",
"asset",
"files",
"if",
"they",
"are",
"provided"
] | e13c09e8d78e3a01b3d64cdb53abba9d41db6277 | https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Assets/AssetBundle.php#L31-L42 | train |
ansas/php-component | src/Component/File/FtpClient.php | FtpClient.login | public function login(string $user, string $password, $attempts = 1, $sleepBetweenAttempts = 5)
{
if (!@ftp_login($this->ftp, $user, $password)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->login($user, $password, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot login to host %s", $this->host));
}
return $this;
} | php | public function login(string $user, string $password, $attempts = 1, $sleepBetweenAttempts = 5)
{
if (!@ftp_login($this->ftp, $user, $password)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->login($user, $password, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot login to host %s", $this->host));
}
return $this;
} | [
"public",
"function",
"login",
"(",
"string",
"$",
"user",
",",
"string",
"$",
"password",
",",
"$",
"attempts",
"=",
"1",
",",
"$",
"sleepBetweenAttempts",
"=",
"5",
")",
"{",
"if",
"(",
"!",
"@",
"ftp_login",
"(",
"$",
"this",
"->",
"ftp",
",",
"... | Login to server.
@param string $user
@param string $password
@param int $attempts [optional] Number of retries in case of error.
@param int $sleepBetweenAttempts [optional] Sleep time in seconds between attempts.
@return $this
@throws Exception | [
"Login",
"to",
"server",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L70-L83 | train |
ansas/php-component | src/Component/File/FtpClient.php | FtpClient.listFilesRaw | public function listFilesRaw(string $dir = ".", int $attempts = 5, int $sleepBetweenAttempts = 5)
{
$total = @ftp_rawlist($this->ftp, $dir);
if ($total === false) {
// Check if tries left call method again
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->listFilesRaw($dir, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot list files in %s", $dir));
}
$columnMap = [
"permissions",
"number",
"owner",
"group",
"size",
"month",
"day",
"year",
"name",
];
$monthMap = [
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Sept' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12',
];
$files = [];
foreach ($total as $rawString) {
$data = [];
$rawList = preg_split("/\s*/", $rawString, -1, PREG_SPLIT_NO_EMPTY);
foreach ($rawList as $col => $value) {
if ($col > 8) { // Filename with spaces
$data[$columnMap[8]] .= " " . $value;
continue;
}
$data[$columnMap[$col]] = $value;
}
$data['month'] = $monthMap[$data['month']];
$data['time'] = "00:00";
if (strpos($data['year'], ':') !== false) {
$data['time'] = $data['year'];
if ((int) $data['month'] > (int) date('m')) {
$data['year'] = date('Y', time() - 60 * 60 * 24 * 365);
} else {
$data['year'] = date('Y');
}
}
$files[] = $data;
}
return $files;
} | php | public function listFilesRaw(string $dir = ".", int $attempts = 5, int $sleepBetweenAttempts = 5)
{
$total = @ftp_rawlist($this->ftp, $dir);
if ($total === false) {
// Check if tries left call method again
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->listFilesRaw($dir, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot list files in %s", $dir));
}
$columnMap = [
"permissions",
"number",
"owner",
"group",
"size",
"month",
"day",
"year",
"name",
];
$monthMap = [
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Sept' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12',
];
$files = [];
foreach ($total as $rawString) {
$data = [];
$rawList = preg_split("/\s*/", $rawString, -1, PREG_SPLIT_NO_EMPTY);
foreach ($rawList as $col => $value) {
if ($col > 8) { // Filename with spaces
$data[$columnMap[8]] .= " " . $value;
continue;
}
$data[$columnMap[$col]] = $value;
}
$data['month'] = $monthMap[$data['month']];
$data['time'] = "00:00";
if (strpos($data['year'], ':') !== false) {
$data['time'] = $data['year'];
if ((int) $data['month'] > (int) date('m')) {
$data['year'] = date('Y', time() - 60 * 60 * 24 * 365);
} else {
$data['year'] = date('Y');
}
}
$files[] = $data;
}
return $files;
} | [
"public",
"function",
"listFilesRaw",
"(",
"string",
"$",
"dir",
"=",
"\".\"",
",",
"int",
"$",
"attempts",
"=",
"5",
",",
"int",
"$",
"sleepBetweenAttempts",
"=",
"5",
")",
"{",
"$",
"total",
"=",
"@",
"ftp_rawlist",
"(",
"$",
"this",
"->",
"ftp",
"... | Get raw data of files in directory on ftp-server.
@param string $dir [optional] Directory to search in.
@param int $attempts [optional] Number of retries in case of error.
@param int $sleepBetweenAttempts [optional] Sleep time in seconds between attempts.
@return array
@throws Exception | [
"Get",
"raw",
"data",
"of",
"files",
"in",
"directory",
"on",
"ftp",
"-",
"server",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L192-L264 | train |
ansas/php-component | src/Component/File/FtpClient.php | FtpClient.get | public function get(
string $remoteFile, string $localFile = null, int $mode = FTP_BINARY, int $attempts = 1,
int $sleepBetweenAttempts = 5
) {
if (!$localFile) {
$localFile = $remoteFile;
}
if (!@ftp_get($this->ftp, $localFile, $remoteFile, $mode)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->get($remoteFile, $localFile, $mode, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot copy file from %s to %s", $remoteFile, $localFile));
}
return $this;
} | php | public function get(
string $remoteFile, string $localFile = null, int $mode = FTP_BINARY, int $attempts = 1,
int $sleepBetweenAttempts = 5
) {
if (!$localFile) {
$localFile = $remoteFile;
}
if (!@ftp_get($this->ftp, $localFile, $remoteFile, $mode)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->get($remoteFile, $localFile, $mode, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot copy file from %s to %s", $remoteFile, $localFile));
}
return $this;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"remoteFile",
",",
"string",
"$",
"localFile",
"=",
"null",
",",
"int",
"$",
"mode",
"=",
"FTP_BINARY",
",",
"int",
"$",
"attempts",
"=",
"1",
",",
"int",
"$",
"sleepBetweenAttempts",
"=",
"5",
")",
"{",... | Get a file from ftp-server.
@param string|null $remoteFile Remote file path.
@param string $localFile [optional] Local file path, default: $remoteFile.
@param int $mode [optional] Transfer mode, allowed: FTP_ASCII or FTP_BINARY
@param int $attempts [optional] Number of retries in case of error.
@param int $sleepBetweenAttempts [optional] Sleep time in seconds between attempts.
@return $this
@throws Exception | [
"Get",
"a",
"file",
"from",
"ftp",
"-",
"server",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L278-L297 | train |
ansas/php-component | src/Component/File/FtpClient.php | FtpClient.fget | public function fget(string $remoteFile, $handle, int $resumePos = 0)
{
if (!@ftp_fget($this->ftp, $handle, $remoteFile, FTP_BINARY, $resumePos)) {
throw new Exception("Cannot write in file handle");
}
return $this;
} | php | public function fget(string $remoteFile, $handle, int $resumePos = 0)
{
if (!@ftp_fget($this->ftp, $handle, $remoteFile, FTP_BINARY, $resumePos)) {
throw new Exception("Cannot write in file handle");
}
return $this;
} | [
"public",
"function",
"fget",
"(",
"string",
"$",
"remoteFile",
",",
"$",
"handle",
",",
"int",
"$",
"resumePos",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"@",
"ftp_fget",
"(",
"$",
"this",
"->",
"ftp",
",",
"$",
"handle",
",",
"$",
"remoteFile",
",",
... | Get a file from ftp-server and write it directly into file.
@param string $remoteFile Remote file path.
@param mixed $handle File handle.
@param int $resumePos [optional] Start or resume position in file.
@return $this
@throws Exception | [
"Get",
"a",
"file",
"from",
"ftp",
"-",
"server",
"and",
"write",
"it",
"directly",
"into",
"file",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L309-L316 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.