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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.extract | public function extract()
{
if (! $this->valid()) {
return false;
}
$value = $this->current();
$this->nextAndRemove();
return $value;
} | php | public function extract()
{
if (! $this->valid()) {
return false;
}
$value = $this->current();
$this->nextAndRemove();
return $value;
} | [
"public",
"function",
"extract",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"$",
"this",
"->",
"nextAndRemove",
"(",
... | Extract an element in the queue according to the priority and the
order of insertion
@return mixed | [
"Extract",
"an",
"element",
"in",
"the",
"queue",
"according",
"to",
"the",
"priority",
"and",
"the",
"order",
"of",
"insertion"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L110-L118 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.current | public function current()
{
switch ($this->extractFlag) {
case self::EXTR_DATA:
return current($this->values[$this->maxPriority]);
case self::EXTR_PRIORITY:
return $this->maxPriority;
case self::EXTR_BOTH:
return [
'data' => current($this->values[$this->maxPriority]),
'priority' => $this->maxPriority
];
}
} | php | public function current()
{
switch ($this->extractFlag) {
case self::EXTR_DATA:
return current($this->values[$this->maxPriority]);
case self::EXTR_PRIORITY:
return $this->maxPriority;
case self::EXTR_BOTH:
return [
'data' => current($this->values[$this->maxPriority]),
'priority' => $this->maxPriority
];
}
} | [
"public",
"function",
"current",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"extractFlag",
")",
"{",
"case",
"self",
"::",
"EXTR_DATA",
":",
"return",
"current",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"this",
"->",
"maxPriority",
"]",
")",
... | Get the current element in the queue
@return mixed | [
"Get",
"the",
"current",
"element",
"in",
"the",
"queue"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L163-L176 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.nextAndRemove | protected function nextAndRemove()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->priorities[$this->maxPriority]);
unset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$this->subIndex = -1;
}
++$this->index;
++$this->subIndex;
--$this->count;
} | php | protected function nextAndRemove()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->priorities[$this->maxPriority]);
unset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$this->subIndex = -1;
}
++$this->index;
++$this->subIndex;
--$this->count;
} | [
"protected",
"function",
"nextAndRemove",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"next",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"this",
"->",
"maxPriority",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"priorities",
"[",
"$",
"this",
... | Set the iterator pointer to the next element in the queue
removing the previous element | [
"Set",
"the",
"iterator",
"pointer",
"to",
"the",
"next",
"element",
"in",
"the",
"queue",
"removing",
"the",
"previous",
"element"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L192-L203 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.next | public function next()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->subPriorities[$this->maxPriority]);
reset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->subPriorities) ? 0 : max($this->subPriorities);
$this->subIndex = -1;
}
++$this->index;
++$this->subIndex;
} | php | public function next()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->subPriorities[$this->maxPriority]);
reset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->subPriorities) ? 0 : max($this->subPriorities);
$this->subIndex = -1;
}
++$this->index;
++$this->subIndex;
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"next",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"this",
"->",
"maxPriority",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"subPriorities",
"[",
"$",
"this",
"->",
... | Set the iterator pointer to the next element in the queue
without removing the previous element | [
"Set",
"the",
"iterator",
"pointer",
"to",
"the",
"next",
"element",
"in",
"the",
"queue",
"without",
"removing",
"the",
"previous",
"element"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L209-L219 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.rewind | public function rewind()
{
$this->subPriorities = $this->priorities;
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$this->index = 0;
$this->subIndex = 0;
} | php | public function rewind()
{
$this->subPriorities = $this->priorities;
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$this->index = 0;
$this->subIndex = 0;
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"$",
"this",
"->",
"subPriorities",
"=",
"$",
"this",
"->",
"priorities",
";",
"$",
"this",
"->",
"maxPriority",
"=",
"empty",
"(",
"$",
"this",
"->",
"priorities",
")",
"?",
"0",
":",
"max",
"(",
"$",
... | Rewind the current iterator | [
"Rewind",
"the",
"current",
"iterator"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L234-L240 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php | FastPriorityQueue.setExtractFlags | public function setExtractFlags($flag)
{
switch ($flag) {
case self::EXTR_DATA:
case self::EXTR_PRIORITY:
case self::EXTR_BOTH:
$this->extractFlag = $flag;
break;
default:
throw new Exception\InvalidArgumentException("The extract flag specified is not valid");
}
} | php | public function setExtractFlags($flag)
{
switch ($flag) {
case self::EXTR_DATA:
case self::EXTR_PRIORITY:
case self::EXTR_BOTH:
$this->extractFlag = $flag;
break;
default:
throw new Exception\InvalidArgumentException("The extract flag specified is not valid");
}
} | [
"public",
"function",
"setExtractFlags",
"(",
"$",
"flag",
")",
"{",
"switch",
"(",
"$",
"flag",
")",
"{",
"case",
"self",
"::",
"EXTR_DATA",
":",
"case",
"self",
"::",
"EXTR_PRIORITY",
":",
"case",
"self",
"::",
"EXTR_BOTH",
":",
"$",
"this",
"->",
"e... | Set the extract flag
@param integer $flag | [
"Set",
"the",
"extract",
"flag"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L294-L305 | train |
phramework/util | src/Request.php | Request.getIPAddress | public static function getIPAddress()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
///to check ip is pass from proxy
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
}
return null;
} | php | public static function getIPAddress()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
///to check ip is pass from proxy
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
}
return null;
} | [
"public",
"static",
"function",
"getIPAddress",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"_S... | Get the ip address of the client
@return string|null Returns fails on failure | [
"Get",
"the",
"ip",
"address",
"of",
"the",
"client"
] | 09202b9962a9a07e2a31b0c9eff90ece1d6bd3ca | https://github.com/phramework/util/blob/09202b9962a9a07e2a31b0c9eff90ece1d6bd3ca/src/Request.php#L58-L70 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getOffensivenessOfWeaponlike | public function getOffensivenessOfWeaponlike(WeaponlikeCode $weaponlikeCode): int
{
return $this->tables->getWeaponlikeTableByWeaponlikeCode($weaponlikeCode)->getOffensivenessOf($weaponlikeCode);
} | php | public function getOffensivenessOfWeaponlike(WeaponlikeCode $weaponlikeCode): int
{
return $this->tables->getWeaponlikeTableByWeaponlikeCode($weaponlikeCode)->getOffensivenessOf($weaponlikeCode);
} | [
"public",
"function",
"getOffensivenessOfWeaponlike",
"(",
"WeaponlikeCode",
"$",
"weaponlikeCode",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"tables",
"->",
"getWeaponlikeTableByWeaponlikeCode",
"(",
"$",
"weaponlikeCode",
")",
"->",
"getOffensivenessOf",
"(... | Even shield can be used as weapon, just quite ineffective.
@param WeaponlikeCode $weaponlikeCode
@return int
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike | [
"Even",
"shield",
"can",
"be",
"used",
"as",
"weapon",
"just",
"quite",
"ineffective",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L142-L145 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.canHoldItByTwoHands | public function canHoldItByTwoHands(WeaponlikeCode $weaponToHoldByTwoHands): bool
{
return
// shooting weapons are two-handed (except mini-crossbow), projectiles are not
$this->isTwoHandedOnly($weaponToHoldByTwoHands) // the weapon is explicitly two-handed
// or it is melee weapon with length at least 1 (see PPH page 92 right column)
|| ($weaponToHoldByTwoHands->isMelee() && $this->getLengthOfWeaponOrShield($weaponToHoldByTwoHands) >= 1);
} | php | public function canHoldItByTwoHands(WeaponlikeCode $weaponToHoldByTwoHands): bool
{
return
// shooting weapons are two-handed (except mini-crossbow), projectiles are not
$this->isTwoHandedOnly($weaponToHoldByTwoHands) // the weapon is explicitly two-handed
// or it is melee weapon with length at least 1 (see PPH page 92 right column)
|| ($weaponToHoldByTwoHands->isMelee() && $this->getLengthOfWeaponOrShield($weaponToHoldByTwoHands) >= 1);
} | [
"public",
"function",
"canHoldItByTwoHands",
"(",
"WeaponlikeCode",
"$",
"weaponToHoldByTwoHands",
")",
":",
"bool",
"{",
"return",
"// shooting weapons are two-handed (except mini-crossbow), projectiles are not",
"$",
"this",
"->",
"isTwoHandedOnly",
"(",
"$",
"weaponToHoldByT... | Not all weapons can be hold by two hands - some of them are simply so small so it is not possible or highly
ineffective.
@param WeaponlikeCode $weaponToHoldByTwoHands
@return bool
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike | [
"Not",
"all",
"weapons",
"can",
"be",
"hold",
"by",
"two",
"hands",
"-",
"some",
"of",
"them",
"are",
"simply",
"so",
"small",
"so",
"it",
"is",
"not",
"possible",
"or",
"highly",
"ineffective",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L201-L208 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getMissingStrengthForArmament | public function getMissingStrengthForArmament(
ArmamentCode $armamentCode,
Strength $currentStrength,
Size $bodySize
): int
{
$requiredStrength = $this->tables->getArmamentsTableByArmamentCode($armamentCode)->getRequiredStrengthOf($armamentCode);
if ($requiredStrength === false) { // no strength is required, like for a hand
return 0;
}
$missingStrength = $requiredStrength - $currentStrength->getValue();
if ($armamentCode instanceof ArmorCode) {
// only armor weight is related to body size
$missingStrength += $bodySize->getValue();
}
if ($missingStrength < 0) {
// missing strength can not be negative, of course
return 0;
}
return $missingStrength;
} | php | public function getMissingStrengthForArmament(
ArmamentCode $armamentCode,
Strength $currentStrength,
Size $bodySize
): int
{
$requiredStrength = $this->tables->getArmamentsTableByArmamentCode($armamentCode)->getRequiredStrengthOf($armamentCode);
if ($requiredStrength === false) { // no strength is required, like for a hand
return 0;
}
$missingStrength = $requiredStrength - $currentStrength->getValue();
if ($armamentCode instanceof ArmorCode) {
// only armor weight is related to body size
$missingStrength += $bodySize->getValue();
}
if ($missingStrength < 0) {
// missing strength can not be negative, of course
return 0;
}
return $missingStrength;
} | [
"public",
"function",
"getMissingStrengthForArmament",
"(",
"ArmamentCode",
"$",
"armamentCode",
",",
"Strength",
"$",
"currentStrength",
",",
"Size",
"$",
"bodySize",
")",
":",
"int",
"{",
"$",
"requiredStrength",
"=",
"$",
"this",
"->",
"tables",
"->",
"getArm... | See PPH page 91, right column
@param ArmamentCode $armamentCode
@param Size $bodySize
@param Strength $currentStrength
@return int positive number
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament | [
"See",
"PPH",
"page",
"91",
"right",
"column"
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L378-L399 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getAttackNumberModifierByDistance | public function getAttackNumberModifierByDistance(
Distance $targetDistance,
EncounterRange $currentEncounterRange,
MaximalRange $currentMaximalRange
): int
{
if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact
throw new DistanceIsOutOfMaximalRange(
"Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)"
. " is out of maximal range {$currentMaximalRange}"
. ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)'
);
}
if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) {
throw new EncounterRangeCanNotBeGreaterThanMaximalRange(
"Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}"
);
}
$attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable()
->getAttackNumberModifierByDistance($targetDistance);
if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact
$attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative
}
return $attackNumberModifier;
} | php | public function getAttackNumberModifierByDistance(
Distance $targetDistance,
EncounterRange $currentEncounterRange,
MaximalRange $currentMaximalRange
): int
{
if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact
throw new DistanceIsOutOfMaximalRange(
"Given distance {$targetDistance->getBonus()} ({$targetDistance->getMeters()} meters)"
. " is out of maximal range {$currentMaximalRange}"
. ' (' . $currentMaximalRange->getInMeters($this->tables) . ' meters)'
);
}
if ($currentEncounterRange->getValue() > $currentMaximalRange->getValue()) {
throw new EncounterRangeCanNotBeGreaterThanMaximalRange(
"Got encounter range {$currentEncounterRange} greater than given maximal range {$currentMaximalRange}"
);
}
$attackNumberModifier = $this->tables->getAttackNumberByContinuousDistanceTable()
->getAttackNumberModifierByDistance($targetDistance);
if ($targetDistance->getBonus()->getValue() > $currentEncounterRange->getValue()) { // comparing distance bonuses in fact
$attackNumberModifier += $currentEncounterRange->getValue() - $targetDistance->getBonus()->getValue(); // always negative
}
return $attackNumberModifier;
} | [
"public",
"function",
"getAttackNumberModifierByDistance",
"(",
"Distance",
"$",
"targetDistance",
",",
"EncounterRange",
"$",
"currentEncounterRange",
",",
"MaximalRange",
"$",
"currentMaximalRange",
")",
":",
"int",
"{",
"if",
"(",
"$",
"targetDistance",
"->",
"getB... | Distance modifier can be solved very roughly by a simple table or more precisely with continual values by a
calculation. This uses that calculation. See PPH page 104 left column.
@param EncounterRange $currentEncounterRange
@param Distance $targetDistance
@param MaximalRange $currentMaximalRange
@return int
@throws \DrdPlus\Tables\Armaments\Exceptions\DistanceIsOutOfMaximalRange
@throws \DrdPlus\Tables\Armaments\Exceptions\EncounterRangeCanNotBeGreaterThanMaximalRange
@throws \DrdPlus\Tables\Combat\Attacks\Exceptions\DistanceOutOfKnownValues | [
"Distance",
"modifier",
"can",
"be",
"solved",
"very",
"roughly",
"by",
"a",
"simple",
"table",
"or",
"more",
"precisely",
"with",
"continual",
"values",
"by",
"a",
"calculation",
".",
"This",
"uses",
"that",
"calculation",
".",
"See",
"PPH",
"page",
"104",
... | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L455-L480 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getLoadingInRoundsByStrengthWithRangedWeapon | public function getLoadingInRoundsByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRounds(
$this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0))
);
} | php | public function getLoadingInRoundsByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRounds(
$this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0))
);
} | [
"public",
"function",
"getLoadingInRoundsByStrengthWithRangedWeapon",
"(",
"RangedWeaponCode",
"$",
"rangedWeaponCode",
",",
"Strength",
"$",
"currentStrength",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"tables",
"->",
"getRangedWeaponStrengthSanctionsTable",
"("... | The final number of rounds needed to load a weapon.
@param RangedWeaponCode $rangedWeaponCode
@param Strength $currentStrength
@return int
@throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength | [
"The",
"final",
"number",
"of",
"rounds",
"needed",
"to",
"load",
"a",
"weapon",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L551-L559 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getLoadingInRoundsMalusByStrengthWithRangedWeapon | public function getLoadingInRoundsMalusByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRoundsSanction(
$this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0))
);
} | php | public function getLoadingInRoundsMalusByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRoundsSanction(
$this->getMissingStrengthForArmament($rangedWeaponCode, $currentStrength, Size::getIt(0))
);
} | [
"public",
"function",
"getLoadingInRoundsMalusByStrengthWithRangedWeapon",
"(",
"RangedWeaponCode",
"$",
"rangedWeaponCode",
",",
"Strength",
"$",
"currentStrength",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"tables",
"->",
"getRangedWeaponStrengthSanctionsTable",
... | The relative number of rounds as a malus to standard number of rounds needed to load a weapon.
@param RangedWeaponCode $rangedWeaponCode
@param Strength $currentStrength
@return int
@throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength | [
"The",
"relative",
"number",
"of",
"rounds",
"as",
"a",
"malus",
"to",
"standard",
"number",
"of",
"rounds",
"needed",
"to",
"load",
"a",
"weapon",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L569-L577 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getEncounterRangeWithWeaponlike | public function getEncounterRangeWithWeaponlike(
WeaponlikeCode $weaponlikeCode,
Strength $currentStrength,
Speed $currentSpeed
): EncounterRange
{
if (!($weaponlikeCode instanceof RangedWeaponCode)) {
/** note: melee weapon length in meters is half of weapon length, see PPH page 85 right column */
return EncounterRange::getIt(0);
}
$encounterRange = $this->getRangeOfRangedWeapon($weaponlikeCode);
$encounterRange += $this->getEncounterRangeMalusByStrength($weaponlikeCode, $currentStrength);
$encounterRange += $this->getEncounterRangeBonusByStrength($weaponlikeCode, $currentStrength);
$encounterRange += $this->getEncounterRangeBonusBySpeed($weaponlikeCode, $currentSpeed);
return EncounterRange::getIt($encounterRange);
} | php | public function getEncounterRangeWithWeaponlike(
WeaponlikeCode $weaponlikeCode,
Strength $currentStrength,
Speed $currentSpeed
): EncounterRange
{
if (!($weaponlikeCode instanceof RangedWeaponCode)) {
/** note: melee weapon length in meters is half of weapon length, see PPH page 85 right column */
return EncounterRange::getIt(0);
}
$encounterRange = $this->getRangeOfRangedWeapon($weaponlikeCode);
$encounterRange += $this->getEncounterRangeMalusByStrength($weaponlikeCode, $currentStrength);
$encounterRange += $this->getEncounterRangeBonusByStrength($weaponlikeCode, $currentStrength);
$encounterRange += $this->getEncounterRangeBonusBySpeed($weaponlikeCode, $currentSpeed);
return EncounterRange::getIt($encounterRange);
} | [
"public",
"function",
"getEncounterRangeWithWeaponlike",
"(",
"WeaponlikeCode",
"$",
"weaponlikeCode",
",",
"Strength",
"$",
"currentStrength",
",",
"Speed",
"$",
"currentSpeed",
")",
":",
"EncounterRange",
"{",
"if",
"(",
"!",
"(",
"$",
"weaponlikeCode",
"instanceo... | Gives bonus to range of a weapon, which can be turned into meters.
@param WeaponlikeCode $weaponlikeCode
@param Strength $currentStrength
@param Speed $currentSpeed
@return EncounterRange
@throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownRangedWeapon
@throws \DrdPlus\Tables\Armaments\Weapons\Ranged\Exceptions\UnknownBow | [
"Gives",
"bonus",
"to",
"range",
"of",
"a",
"weapon",
"which",
"can",
"be",
"turned",
"into",
"meters",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L591-L607 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getProtectiveArmamentRestrictionForSkillRank | public function getProtectiveArmamentRestrictionForSkillRank(
ProtectiveArmamentCode $protectiveArmamentCode,
PositiveInteger $protectiveArmamentSkillRank
): int
{
$restriction = $this->getRestrictionOfProtectiveArmament($protectiveArmamentCode)
+ $this->getProtectiveArmamentRestrictionBonusForSkillRank($protectiveArmamentCode, $protectiveArmamentSkillRank);
if ($restriction > 0) {
return 0; // can not turn into bonus
}
return $restriction;
} | php | public function getProtectiveArmamentRestrictionForSkillRank(
ProtectiveArmamentCode $protectiveArmamentCode,
PositiveInteger $protectiveArmamentSkillRank
): int
{
$restriction = $this->getRestrictionOfProtectiveArmament($protectiveArmamentCode)
+ $this->getProtectiveArmamentRestrictionBonusForSkillRank($protectiveArmamentCode, $protectiveArmamentSkillRank);
if ($restriction > 0) {
return 0; // can not turn into bonus
}
return $restriction;
} | [
"public",
"function",
"getProtectiveArmamentRestrictionForSkillRank",
"(",
"ProtectiveArmamentCode",
"$",
"protectiveArmamentCode",
",",
"PositiveInteger",
"$",
"protectiveArmamentSkillRank",
")",
":",
"int",
"{",
"$",
"restriction",
"=",
"$",
"this",
"->",
"getRestrictionO... | Restriction is Fight number malus.
@param ProtectiveArmamentCode $protectiveArmamentCode
@param PositiveInteger $protectiveArmamentSkillRank
@return int
@throws \DrdPlus\Tables\Armaments\Partials\Exceptions\UnexpectedSkillRank
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownProtectiveArmament | [
"Restriction",
"is",
"Fight",
"number",
"malus",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L843-L855 | train |
drdplusinfo/drdplus-armourer | DrdPlus/Armourer/Armourer.php | Armourer.getBaseOfWoundsUsingWeaponlike | public function getBaseOfWoundsUsingWeaponlike(WeaponlikeCode $weaponlikeCode, Strength $currentStrength): int
{
// weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column
$baseOfWounds = $this->tables->getBaseOfWoundsTable()->getBaseOfWounds(
$this->getApplicableStrength($weaponlikeCode, $currentStrength),
new IntegerObject($this->getWoundsOfWeaponlike($weaponlikeCode))
);
$baseOfWounds += $this->getBaseOfWoundsMalusByStrengthWithWeaponlike($weaponlikeCode, $currentStrength);
return $baseOfWounds;
} | php | public function getBaseOfWoundsUsingWeaponlike(WeaponlikeCode $weaponlikeCode, Strength $currentStrength): int
{
// weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column
$baseOfWounds = $this->tables->getBaseOfWoundsTable()->getBaseOfWounds(
$this->getApplicableStrength($weaponlikeCode, $currentStrength),
new IntegerObject($this->getWoundsOfWeaponlike($weaponlikeCode))
);
$baseOfWounds += $this->getBaseOfWoundsMalusByStrengthWithWeaponlike($weaponlikeCode, $currentStrength);
return $baseOfWounds;
} | [
"public",
"function",
"getBaseOfWoundsUsingWeaponlike",
"(",
"WeaponlikeCode",
"$",
"weaponlikeCode",
",",
"Strength",
"$",
"currentStrength",
")",
":",
"int",
"{",
"// weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column",
"$",
"base... | Gives base of wound with a weapon and user strength.
@param WeaponlikeCode $weaponlikeCode
@param Strength $currentStrength
@return int
@throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownRangedWeapon
@throws \DrdPlus\Tables\Armaments\Exceptions\UnknownMeleeWeaponlike
@throws \DrdPlus\Tables\Armaments\Weapons\Ranged\Exceptions\UnknownBow | [
"Gives",
"base",
"of",
"wound",
"with",
"a",
"weapon",
"and",
"user",
"strength",
"."
] | c2b8e2349881d4edb433689c5edba0810a32c6d8 | https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L872-L882 | train |
zugoripls/laravel-framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.callQueueMethodOnHandler | protected function callQueueMethodOnHandler($class, $method, $arguments)
{
$handler = (new ReflectionClass($class))->newInstanceWithoutConstructor();
$handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [
'class' => $class, 'method' => $method, 'data' => serialize($arguments),
]);
} | php | protected function callQueueMethodOnHandler($class, $method, $arguments)
{
$handler = (new ReflectionClass($class))->newInstanceWithoutConstructor();
$handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [
'class' => $class, 'method' => $method, 'data' => serialize($arguments),
]);
} | [
"protected",
"function",
"callQueueMethodOnHandler",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"$",
"handler",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
")",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";"... | Call the queue method on the handler class.
@param string $class
@param string $method
@param array $arguments
@return void | [
"Call",
"the",
"queue",
"method",
"on",
"the",
"handler",
"class",
"."
] | 90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655 | https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Events/Dispatcher.php#L430-L437 | train |
SocietyCMS/Core | Console/Installers/Scripts/AdminUserInstaller.php | AdminUserInstaller.createFirstUser | protected function createFirstUser()
{
$info = [
'first_name' => $this->askForFirstName(),
'last_name' => $this->askForLastName(),
'email' => $this->askForEmail(),
'password' => $this->askForPassword(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
$this->application->make('Modules\User\Repositories\UserRepository')->createWithRoles(
$info,
$this->getAdminRole()
);
$this->command->info('Admin account created!');
} | php | protected function createFirstUser()
{
$info = [
'first_name' => $this->askForFirstName(),
'last_name' => $this->askForLastName(),
'email' => $this->askForEmail(),
'password' => $this->askForPassword(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
$this->application->make('Modules\User\Repositories\UserRepository')->createWithRoles(
$info,
$this->getAdminRole()
);
$this->command->info('Admin account created!');
} | [
"protected",
"function",
"createFirstUser",
"(",
")",
"{",
"$",
"info",
"=",
"[",
"'first_name'",
"=>",
"$",
"this",
"->",
"askForFirstName",
"(",
")",
",",
"'last_name'",
"=>",
"$",
"this",
"->",
"askForLastName",
"(",
")",
",",
"'email'",
"=>",
"$",
"t... | Create a first admin user.
@param $adminRoleId | [
"Create",
"a",
"first",
"admin",
"user",
"."
] | fb6be1b1dd46c89a976c02feb998e9af01ddca54 | https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Console/Installers/Scripts/AdminUserInstaller.php#L78-L95 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.getInstallScript | public function getInstallScript()
{
if (! $this->installScript) {
$installClass = $this->installNamespace.'Install';
if (! class_exists($installClass)) {
$message = sprintf('No install class found at %s. Nothing to do.', $installClass);
throw new RuntimeException($message);
}
$installScript = new $installClass;
$this->installScript = $installScript;
}
return $this->installScript;
} | php | public function getInstallScript()
{
if (! $this->installScript) {
$installClass = $this->installNamespace.'Install';
if (! class_exists($installClass)) {
$message = sprintf('No install class found at %s. Nothing to do.', $installClass);
throw new RuntimeException($message);
}
$installScript = new $installClass;
$this->installScript = $installScript;
}
return $this->installScript;
} | [
"public",
"function",
"getInstallScript",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"installScript",
")",
"{",
"$",
"installClass",
"=",
"$",
"this",
"->",
"installNamespace",
".",
"'Install'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"inst... | Get install script
Use injected script if it exist, otherwise instantiate the default.
@return AbstractInstall
@throws RuntimeException If the install class cannot be found | [
"Get",
"install",
"script"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L113-L130 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.hasTablesOrViews | protected function hasTablesOrViews()
{
$tables = $this->db->query('SHOW TABLES', DbAdapter::QUERY_MODE_EXECUTE);
return (bool) count($tables);
} | php | protected function hasTablesOrViews()
{
$tables = $this->db->query('SHOW TABLES', DbAdapter::QUERY_MODE_EXECUTE);
return (bool) count($tables);
} | [
"protected",
"function",
"hasTablesOrViews",
"(",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SHOW TABLES'",
",",
"DbAdapter",
"::",
"QUERY_MODE_EXECUTE",
")",
";",
"return",
"(",
"bool",
")",
"count",
"(",
"$",
"tables",
... | Checks for existing tables in the database
@return boolean Whether or not there are existing tables | [
"Checks",
"for",
"existing",
"tables",
"in",
"the",
"database"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L180-L185 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.dropTables | protected function dropTables()
{
$tables = $this->db->query(
'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "BASE_TABLE"',
DbAdapter::QUERY_MODE_EXECUTE
);
// Disable foreign key checks -- we are wiping the database on purpose
$this->db->query(
'SET FOREIGN_KEY_CHECKS = 0',
DbAdapter::QUERY_MODE_EXECUTE
);
foreach ($tables as $table) {
$this->db->query(
'DROP TABLE '.reset($table),
DbAdapter::QUERY_MODE_EXECUTE
);
}
// Re-enable foreign key checks
$this->db->query(
'SET FOREIGN_KEY_CHECKS = 1',
DbAdapter::QUERY_MODE_EXECUTE
);
} | php | protected function dropTables()
{
$tables = $this->db->query(
'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "BASE_TABLE"',
DbAdapter::QUERY_MODE_EXECUTE
);
// Disable foreign key checks -- we are wiping the database on purpose
$this->db->query(
'SET FOREIGN_KEY_CHECKS = 0',
DbAdapter::QUERY_MODE_EXECUTE
);
foreach ($tables as $table) {
$this->db->query(
'DROP TABLE '.reset($table),
DbAdapter::QUERY_MODE_EXECUTE
);
}
// Re-enable foreign key checks
$this->db->query(
'SET FOREIGN_KEY_CHECKS = 1',
DbAdapter::QUERY_MODE_EXECUTE
);
} | [
"protected",
"function",
"dropTables",
"(",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SHOW FULL TABLES WHERE TABLE_TYPE LIKE \"BASE_TABLE\"'",
",",
"DbAdapter",
"::",
"QUERY_MODE_EXECUTE",
")",
";",
"// Disable foreign key checks -- we... | Drop all tables from the database | [
"Drop",
"all",
"tables",
"from",
"the",
"database"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L190-L215 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.dropViews | protected function dropViews()
{
$views = $this->db->query(
'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "VIEW"',
DbAdapter::QUERY_MODE_EXECUTE
);
foreach ($views as $view) {
$this->db->query(
'DROP VIEW '.reset($view),
DbAdapter::QUERY_MODE_EXECUTE
);
}
} | php | protected function dropViews()
{
$views = $this->db->query(
'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "VIEW"',
DbAdapter::QUERY_MODE_EXECUTE
);
foreach ($views as $view) {
$this->db->query(
'DROP VIEW '.reset($view),
DbAdapter::QUERY_MODE_EXECUTE
);
}
} | [
"protected",
"function",
"dropViews",
"(",
")",
"{",
"$",
"views",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SHOW FULL TABLES WHERE TABLE_TYPE LIKE \"VIEW\"'",
",",
"DbAdapter",
"::",
"QUERY_MODE_EXECUTE",
")",
";",
"foreach",
"(",
"$",
"views",
"as",
... | Drop all views from the database | [
"Drop",
"all",
"views",
"from",
"the",
"database"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L220-L233 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.install | protected function install(AbstractInstall $installScript, OutputInterface $output)
{
$dataPath = DATADIR;
$output->writeln(' Installing App...');
// Install the database structure
$this->runSql(
$dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE,
' Creating initial database schema',
sprintf(' Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE),
$output
);
// Install the database data
$this->runSql(
$dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE,
' Inserting initial data',
sprintf(' Database data file %s not found', GenerateInstallCommand::DATA_FILE),
$output
);
$output->writeln(' Running install script');
$installScript->execute($this->db);
$output->write([' Install completed!', ''], true);
} | php | protected function install(AbstractInstall $installScript, OutputInterface $output)
{
$dataPath = DATADIR;
$output->writeln(' Installing App...');
// Install the database structure
$this->runSql(
$dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE,
' Creating initial database schema',
sprintf(' Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE),
$output
);
// Install the database data
$this->runSql(
$dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE,
' Inserting initial data',
sprintf(' Database data file %s not found', GenerateInstallCommand::DATA_FILE),
$output
);
$output->writeln(' Running install script');
$installScript->execute($this->db);
$output->write([' Install completed!', ''], true);
} | [
"protected",
"function",
"install",
"(",
"AbstractInstall",
"$",
"installScript",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"dataPath",
"=",
"DATADIR",
";",
"$",
"output",
"->",
"writeln",
"(",
"' Installing App...'",
")",
";",
"// Install the databas... | Install fresh version of the database from db_structure and db_data files
@param AbstractInstall $installScript
@param OutputInterface $output Command line output interface | [
"Install",
"fresh",
"version",
"of",
"the",
"database",
"from",
"db_structure",
"and",
"db_data",
"files"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L241-L268 | train |
synapsestudios/synapse-base | src/Synapse/Install/RunInstallCommand.php | RunInstallCommand.runSql | protected function runSql($file, $message, $notFoundMessage, $output)
{
if (! is_file($file)) {
$output->writeln($notFoundMessage);
return;
}
$output->writeln($message);
$dataSql = file_get_contents($file);
// Split the sql file on new lines and insert into the database one line at a time
foreach (preg_split('/;\s*\n/', $dataSql) as $command) {
try {
$query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE);
} catch (Database_Exception $e) {
if ($e->getCode() !== 1065) { // empty query
throw $e;
}
}
}
} | php | protected function runSql($file, $message, $notFoundMessage, $output)
{
if (! is_file($file)) {
$output->writeln($notFoundMessage);
return;
}
$output->writeln($message);
$dataSql = file_get_contents($file);
// Split the sql file on new lines and insert into the database one line at a time
foreach (preg_split('/;\s*\n/', $dataSql) as $command) {
try {
$query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE);
} catch (Database_Exception $e) {
if ($e->getCode() !== 1065) { // empty query
throw $e;
}
}
}
} | [
"protected",
"function",
"runSql",
"(",
"$",
"file",
",",
"$",
"message",
",",
"$",
"notFoundMessage",
",",
"$",
"output",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"$",
"notFoundMessag... | Given a filepath to a SQL file, load it and run the SQL statements inside
@param string $file Path to SQL file
@param string $message Message to output to the console if the file exists
@param string $notFoundMessage Message to output to the console if the file does not exist | [
"Given",
"a",
"filepath",
"to",
"a",
"SQL",
"file",
"load",
"it",
"and",
"run",
"the",
"SQL",
"statements",
"inside"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L277-L299 | train |
cityware/city-snmp | src/MIBS/Extreme/SwMonitor/Memory.php | Memory.percentUsage | public function percentUsage()
{
$total = $this->systemTotal();
$free = $this->systemFree();
$usage = [];
foreach( $total as $slotId => $amount ) {
$usage[ $slotId ] = intval( ceil( ( ( $amount - $free[ $slotId ] ) * 100 ) / $amount ) );
}
return $usage;
} | php | public function percentUsage()
{
$total = $this->systemTotal();
$free = $this->systemFree();
$usage = [];
foreach( $total as $slotId => $amount ) {
$usage[ $slotId ] = intval( ceil( ( ( $amount - $free[ $slotId ] ) * 100 ) / $amount ) );
}
return $usage;
} | [
"public",
"function",
"percentUsage",
"(",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"systemTotal",
"(",
")",
";",
"$",
"free",
"=",
"$",
"this",
"->",
"systemFree",
"(",
")",
";",
"$",
"usage",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tot... | Percentage of memory used per slot
@return array Integer percentage of memory used | [
"Percentage",
"of",
"memory",
"used",
"per",
"slot"
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Extreme/SwMonitor/Memory.php#L76-L88 | train |
OWeb/OWeb-Framework | OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/Select.php | Select.add | public function add($text, $value){
$this->select[] = array($text, $value);
$this->validator->addPossibility($value);
} | php | public function add($text, $value){
$this->select[] = array($text, $value);
$this->validator->addPossibility($value);
} | [
"public",
"function",
"add",
"(",
"$",
"text",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"select",
"[",
"]",
"=",
"array",
"(",
"$",
"text",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"validator",
"->",
"addPossibility",
"(",
"$",
"val... | Adds a value to the list of possiblities
@param type $text The text to be shown for this value
@param type $value The actual value. | [
"Adds",
"a",
"value",
"to",
"the",
"list",
"of",
"possiblities"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/Select.php#L48-L51 | train |
crisu83/yii-composer | InstallHandler.php | InstallHandler.setPermissions | public static function setPermissions(Event $event)
{
$options = array_merge(
array(
self::PARAM_WRITABLE => array(),
self::PARAM_EXECUTABLE => array(),
),
$event->getComposer()->getPackage()->getExtra()
);
foreach ((array)$options[self::PARAM_WRITABLE] as $path) {
echo "Setting writable: $path ...";
if (is_dir($path)) {
chmod($path, 0777);
echo "done\n";
} else {
echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path;
return;
}
}
foreach ((array)$options[self::PARAM_EXECUTABLE] as $path) {
echo "Setting executable: $path ... ";
if (is_file($path)) {
chmod($path, 0755);
echo "done\n";
} else {
echo "\n\tThe file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path . "\n";
return;
}
}
} | php | public static function setPermissions(Event $event)
{
$options = array_merge(
array(
self::PARAM_WRITABLE => array(),
self::PARAM_EXECUTABLE => array(),
),
$event->getComposer()->getPackage()->getExtra()
);
foreach ((array)$options[self::PARAM_WRITABLE] as $path) {
echo "Setting writable: $path ...";
if (is_dir($path)) {
chmod($path, 0777);
echo "done\n";
} else {
echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path;
return;
}
}
foreach ((array)$options[self::PARAM_EXECUTABLE] as $path) {
echo "Setting executable: $path ... ";
if (is_file($path)) {
chmod($path, 0755);
echo "done\n";
} else {
echo "\n\tThe file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path . "\n";
return;
}
}
} | [
"public",
"static",
"function",
"setPermissions",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"array",
"(",
"self",
"::",
"PARAM_WRITABLE",
"=>",
"array",
"(",
")",
",",
"self",
"::",
"PARAM_EXECUTABLE",
"=>",
"array",
"(... | Sets the correct permissions of files and directories.
@param Event $event | [
"Sets",
"the",
"correct",
"permissions",
"of",
"files",
"and",
"directories",
"."
] | 848a5b5fd3419ebd504d40d25d9c659411383ae1 | https://github.com/crisu83/yii-composer/blob/848a5b5fd3419ebd504d40d25d9c659411383ae1/InstallHandler.php#L32-L63 | train |
AyeAyeApi/Formatters | src/Writer/Xml.php | Xml.partialFormat | public function partialFormat($data, $nodeName = null)
{
if (!$nodeName) {
$nodeName = $this->getNodeName($data);
}
$data = $this->parseData($data);
if (is_scalar($data)) {
return "<$nodeName>" . $this->parseScalarData($data) . "</$nodeName>";
}
return "<$nodeName>".$this->parseNonScalarData($data, $nodeName)."</$nodeName>";
} | php | public function partialFormat($data, $nodeName = null)
{
if (!$nodeName) {
$nodeName = $this->getNodeName($data);
}
$data = $this->parseData($data);
if (is_scalar($data)) {
return "<$nodeName>" . $this->parseScalarData($data) . "</$nodeName>";
}
return "<$nodeName>".$this->parseNonScalarData($data, $nodeName)."</$nodeName>";
} | [
"public",
"function",
"partialFormat",
"(",
"$",
"data",
",",
"$",
"nodeName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"nodeName",
")",
"{",
"$",
"nodeName",
"=",
"$",
"this",
"->",
"getNodeName",
"(",
"$",
"data",
")",
";",
"}",
"$",
"data",
... | Format part of the data
@param mixed $data The data to be serialised into xml
@param string|null $nodeName The node currently being worked on
@return string | [
"Format",
"part",
"of",
"the",
"data"
] | 0141d0186e0555f7583be419f22280ac7ed24a6f | https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L50-L61 | train |
AyeAyeApi/Formatters | src/Writer/Xml.php | Xml.getNodeName | protected function getNodeName($data)
{
if (is_object($data)) {
$nodeName = preg_replace('/.*\\\/', '', get_class($data));
return preg_replace('/\W/', '', $nodeName);
} elseif (is_array($data)) {
return 'array';
}
return $this->defaultNodeName;
} | php | protected function getNodeName($data)
{
if (is_object($data)) {
$nodeName = preg_replace('/.*\\\/', '', get_class($data));
return preg_replace('/\W/', '', $nodeName);
} elseif (is_array($data)) {
return 'array';
}
return $this->defaultNodeName;
} | [
"protected",
"function",
"getNodeName",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"nodeName",
"=",
"preg_replace",
"(",
"'/.*\\\\\\/'",
",",
"''",
",",
"get_class",
"(",
"$",
"data",
")",
")",
";",
"ret... | Try to guess the node name
@param mixed $data Data to try to find the name of
@return mixed|string | [
"Try",
"to",
"guess",
"the",
"node",
"name"
] | 0141d0186e0555f7583be419f22280ac7ed24a6f | https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L68-L77 | train |
AyeAyeApi/Formatters | src/Writer/Xml.php | Xml.parseNonScalarData | protected function parseNonScalarData($data, $fallbackName = null)
{
$xml = '';
if (!$fallbackName) {
$fallbackName = $this->defaultNodeName;
}
foreach ($data as $property => $value) {
// Clear non-alphanumeric characters
$property = preg_replace('/\W/', '', $property);
// If numeric we'll stick a character in front of it, a bit hack but should be valid
if (is_numeric($property)) {
$property = $fallbackName;
}
$xml .= $this->partialFormat($value, $property);
}
return $xml;
} | php | protected function parseNonScalarData($data, $fallbackName = null)
{
$xml = '';
if (!$fallbackName) {
$fallbackName = $this->defaultNodeName;
}
foreach ($data as $property => $value) {
// Clear non-alphanumeric characters
$property = preg_replace('/\W/', '', $property);
// If numeric we'll stick a character in front of it, a bit hack but should be valid
if (is_numeric($property)) {
$property = $fallbackName;
}
$xml .= $this->partialFormat($value, $property);
}
return $xml;
} | [
"protected",
"function",
"parseNonScalarData",
"(",
"$",
"data",
",",
"$",
"fallbackName",
"=",
"null",
")",
"{",
"$",
"xml",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"fallbackName",
")",
"{",
"$",
"fallbackName",
"=",
"$",
"this",
"->",
"defaultNodeName",
... | Recurse through non scalar data, serializing it
@param array|object $data
@param string|null $fallbackName The name to use for an element in the event it doesn't have one
@return string | [
"Recurse",
"through",
"non",
"scalar",
"data",
"serializing",
"it"
] | 0141d0186e0555f7583be419f22280ac7ed24a6f | https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L98-L116 | train |
JoshuaEstes/Daedalus | src/Daedalus/Application.php | Application.registerCommands | protected function registerCommands()
{
$this->add(new \Daedalus\Command\DumpContainerCommand($this->kernel->getContainer()));
$this->add(new \Daedalus\Command\HelpCommand($this->kernel->getContainer()));
} | php | protected function registerCommands()
{
$this->add(new \Daedalus\Command\DumpContainerCommand($this->kernel->getContainer()));
$this->add(new \Daedalus\Command\HelpCommand($this->kernel->getContainer()));
} | [
"protected",
"function",
"registerCommands",
"(",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"new",
"\\",
"Daedalus",
"\\",
"Command",
"\\",
"DumpContainerCommand",
"(",
"$",
"this",
"->",
"kernel",
"->",
"getContainer",
"(",
")",
")",
")",
";",
"$",
"this... | Registers the commands that are displayed to the developer | [
"Registers",
"the",
"commands",
"that",
"are",
"displayed",
"to",
"the",
"developer"
] | 4c898c41433242e46b30d45ebe03fdc91512b444 | https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Application.php#L105-L109 | train |
JoshuaEstes/Daedalus | src/Daedalus/Application.php | Application.addOutputFormatterStyles | protected function addOutputFormatterStyles(OutputInterface $output)
{
foreach ($this->getOutputFormatterStyles() as $name => $style) {
$output->getFormatter()->setStyle($name, $style);
}
} | php | protected function addOutputFormatterStyles(OutputInterface $output)
{
foreach ($this->getOutputFormatterStyles() as $name => $style) {
$output->getFormatter()->setStyle($name, $style);
}
} | [
"protected",
"function",
"addOutputFormatterStyles",
"(",
"OutputInterface",
"$",
"output",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getOutputFormatterStyles",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"style",
")",
"{",
"$",
"output",
"->",
"getFormatter",... | Adds extra styles to the output
@param OutputInterface $output | [
"Adds",
"extra",
"styles",
"to",
"the",
"output"
] | 4c898c41433242e46b30d45ebe03fdc91512b444 | https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Application.php#L116-L121 | train |
bravesheep/dogmatist | src/Builder.php | Builder.fake | public function fake($field, $type, array $options = [])
{
$field = $this->get($field);
$field->setFake($type, $options);
return $this;
} | php | public function fake($field, $type, array $options = [])
{
$field = $this->get($field);
$field->setFake($type, $options);
return $this;
} | [
"public",
"function",
"fake",
"(",
"$",
"field",
",",
"$",
"type",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"field",
")",
";",
"$",
"field",
"->",
"setFake",
"(",
"$",
"type",... | Fake the contents of a field.
@param string|int $field
@param string|callback $type
@param array $options
@return $this | [
"Fake",
"the",
"contents",
"of",
"a",
"field",
"."
] | 38c332e5ccff4e715b70e5f5ce153d96c745d695 | https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Builder.php#L197-L202 | train |
bravesheep/dogmatist | src/Builder.php | Builder.copy | public function copy($type = null)
{
$builder = new Builder($this->type, $this->dogmatist, $this->parent, $this->strict);
$this->copyData($builder);
if ($type !== null) {
$builder->setType($type);
}
return $builder;
} | php | public function copy($type = null)
{
$builder = new Builder($this->type, $this->dogmatist, $this->parent, $this->strict);
$this->copyData($builder);
if ($type !== null) {
$builder->setType($type);
}
return $builder;
} | [
"public",
"function",
"copy",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"builder",
"=",
"new",
"Builder",
"(",
"$",
"this",
"->",
"type",
",",
"$",
"this",
"->",
"dogmatist",
",",
"$",
"this",
"->",
"parent",
",",
"$",
"this",
"->",
"strict",
... | Returns a clone for the current builder
@param string $type The new type of the cloned builder.
@return $this | [
"Returns",
"a",
"clone",
"for",
"the",
"current",
"builder"
] | 38c332e5ccff4e715b70e5f5ce153d96c745d695 | https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Builder.php#L512-L522 | train |
simplecomplex/php-cache | src/CacheKey.php | CacheKey.validate | public static function validate(string $key) : bool
{
$le = strlen($key);
if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) {
return false;
}
if ($key{0} === '-') {
return false;
}
// Faster than a regular expression.
// Prefix letter to make key without any alphanum pass.
return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key));
} | php | public static function validate(string $key) : bool
{
$le = strlen($key);
if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) {
return false;
}
if ($key{0} === '-') {
return false;
}
// Faster than a regular expression.
// Prefix letter to make key without any alphanum pass.
return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key));
} | [
"public",
"static",
"function",
"validate",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"le",
"=",
"strlen",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"le",
"<",
"static",
"::",
"VALID_LENGTH_MIN",
"||",
"$",
"le",
">",
"static",
"::",
... | Checks that length and content is legal.
First char cannot be hyphen, because that could break CLI interaction.
@param string $key
@return bool | [
"Checks",
"that",
"length",
"and",
"content",
"is",
"legal",
"."
] | 4eb088bc65041948df0dbefcf9da11261c50fca4 | https://github.com/simplecomplex/php-cache/blob/4eb088bc65041948df0dbefcf9da11261c50fca4/src/CacheKey.php#L78-L90 | train |
QuanticTelecom/invoices | src/QuanticTelecom/Invoices/AbstractInvoice.php | AbstractInvoice.setDueDate | private function setDueDate(Carbon $dueDate = null)
{
if (is_null($dueDate)) {
$dueDate = Carbon::now();
}
$this->dueDate = $dueDate;
} | php | private function setDueDate(Carbon $dueDate = null)
{
if (is_null($dueDate)) {
$dueDate = Carbon::now();
}
$this->dueDate = $dueDate;
} | [
"private",
"function",
"setDueDate",
"(",
"Carbon",
"$",
"dueDate",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"dueDate",
")",
")",
"{",
"$",
"dueDate",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"}",
"$",
"this",
"->",
"dueDate",
"=",
... | Set the due date of the invoice, if null, set the current date.
@param Carbon $dueDate | null
@return void | [
"Set",
"the",
"due",
"date",
"of",
"the",
"invoice",
"if",
"null",
"set",
"the",
"current",
"date",
"."
] | 70b946c776a1014ebb8735bd58c2c6a8b37f87ae | https://github.com/QuanticTelecom/invoices/blob/70b946c776a1014ebb8735bd58c2c6a8b37f87ae/src/QuanticTelecom/Invoices/AbstractInvoice.php#L139-L146 | train |
QuanticTelecom/invoices | src/QuanticTelecom/Invoices/AbstractInvoice.php | AbstractInvoice.setCreatedAt | private function setCreatedAt(Carbon $createdAt = null)
{
if (is_null($createdAt)) {
$createdAt = Carbon::now();
}
$this->createdAt = $createdAt;
} | php | private function setCreatedAt(Carbon $createdAt = null)
{
if (is_null($createdAt)) {
$createdAt = Carbon::now();
}
$this->createdAt = $createdAt;
} | [
"private",
"function",
"setCreatedAt",
"(",
"Carbon",
"$",
"createdAt",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"createdAt",
")",
")",
"{",
"$",
"createdAt",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"}",
"$",
"this",
"->",
"createdAt... | Set the creation date of the invoice, if null, set the current date.
@param Carbon $createdAt | null
@return void | [
"Set",
"the",
"creation",
"date",
"of",
"the",
"invoice",
"if",
"null",
"set",
"the",
"current",
"date",
"."
] | 70b946c776a1014ebb8735bd58c2c6a8b37f87ae | https://github.com/QuanticTelecom/invoices/blob/70b946c776a1014ebb8735bd58c2c6a8b37f87ae/src/QuanticTelecom/Invoices/AbstractInvoice.php#L165-L172 | train |
wasabi-cms/core | src/Model/Table/GroupsTable.php | GroupsTable.moveUsersToAlternativeGroups | public function moveUsersToAlternativeGroups($userIdGroupIdMapping)
{
$affectedUsers = 0;
$affectedGroups = [];
foreach ($userIdGroupIdMapping as $userId => $groupId) {
$affectedUsers += $this->UsersGroups->updateAll([
'group_id' => $groupId
], [
'user_id' => $userId
]);
if (!in_array($groupId, $affectedGroups)) {
$affectedGroups[] = $groupId;
}
}
if ($affectedUsers > 0 && !empty($affectedGroups)) {
$this->updateUserCount($affectedGroups);
}
return $affectedUsers;
} | php | public function moveUsersToAlternativeGroups($userIdGroupIdMapping)
{
$affectedUsers = 0;
$affectedGroups = [];
foreach ($userIdGroupIdMapping as $userId => $groupId) {
$affectedUsers += $this->UsersGroups->updateAll([
'group_id' => $groupId
], [
'user_id' => $userId
]);
if (!in_array($groupId, $affectedGroups)) {
$affectedGroups[] = $groupId;
}
}
if ($affectedUsers > 0 && !empty($affectedGroups)) {
$this->updateUserCount($affectedGroups);
}
return $affectedUsers;
} | [
"public",
"function",
"moveUsersToAlternativeGroups",
"(",
"$",
"userIdGroupIdMapping",
")",
"{",
"$",
"affectedUsers",
"=",
"0",
";",
"$",
"affectedGroups",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"userIdGroupIdMapping",
"as",
"$",
"userId",
"=>",
"$",
"grou... | Assign users to new groups.
@param array $userIdGroupIdMapping A mapping of user ids to their new group ids.
@return int number of affected user rows | [
"Assign",
"users",
"to",
"new",
"groups",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/GroupsTable.php#L88-L106 | train |
borobudur-php/borobudur-broadcasting | src/Broadcaster/BroadcasterManager.php | BroadcasterManager.addBroadcaster | public static function addBroadcaster(BroadcasterInterface $broadcaster)
{
self::instantiateDefaultBroadcasters();
self::$broadcasters[$broadcaster->getName()] = $broadcaster;
} | php | public static function addBroadcaster(BroadcasterInterface $broadcaster)
{
self::instantiateDefaultBroadcasters();
self::$broadcasters[$broadcaster->getName()] = $broadcaster;
} | [
"public",
"static",
"function",
"addBroadcaster",
"(",
"BroadcasterInterface",
"$",
"broadcaster",
")",
"{",
"self",
"::",
"instantiateDefaultBroadcasters",
"(",
")",
";",
"self",
"::",
"$",
"broadcasters",
"[",
"$",
"broadcaster",
"->",
"getName",
"(",
")",
"]"... | Add a broadcaster.
@param BroadcasterInterface $broadcaster | [
"Add",
"a",
"broadcaster",
"."
] | d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a | https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L46-L50 | train |
borobudur-php/borobudur-broadcasting | src/Broadcaster/BroadcasterManager.php | BroadcasterManager.get | public static function get($name)
{
$name = strtolower($name);
if (!isset(self::$instantiated[$name])) {
throw new InvalidArgumentException(sprintf('Broadcaster "%s" is not instantiated.', $name));
}
return self::$instantiated[$name];
} | php | public static function get($name)
{
$name = strtolower($name);
if (!isset(self::$instantiated[$name])) {
throw new InvalidArgumentException(sprintf('Broadcaster "%s" is not instantiated.', $name));
}
return self::$instantiated[$name];
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instantiated",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
... | Get instantiated broadcaster.
@param string $name
@return BroadcasterInterface | [
"Get",
"instantiated",
"broadcaster",
"."
] | d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a | https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L59-L68 | train |
borobudur-php/borobudur-broadcasting | src/Broadcaster/BroadcasterManager.php | BroadcasterManager.build | public static function build($name, array $configs = array())
{
if (isset(self::$instantiated[$name])) {
return self::$instantiated[$name];
}
self::instantiateDefaultBroadcasters();
if (!isset(self::$broadcasters[$name])) {
throw new InvalidArgumentException(sprintf('Undefined broadcaster with name "%s".', $name));
}
self::$instantiated[$name] = self::instantiate(self::$broadcasters[$name], $configs);
return self::$instantiated[$name];
} | php | public static function build($name, array $configs = array())
{
if (isset(self::$instantiated[$name])) {
return self::$instantiated[$name];
}
self::instantiateDefaultBroadcasters();
if (!isset(self::$broadcasters[$name])) {
throw new InvalidArgumentException(sprintf('Undefined broadcaster with name "%s".', $name));
}
self::$instantiated[$name] = self::instantiate(self::$broadcasters[$name], $configs);
return self::$instantiated[$name];
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"name",
",",
"array",
"$",
"configs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"instantiated",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"self",
"::",
"... | Build a broadcaster.
@param string $name
@param array $configs
@return BroadcasterInterface | [
"Build",
"a",
"broadcaster",
"."
] | d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a | https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L78-L92 | train |
borobudur-php/borobudur-broadcasting | src/Broadcaster/BroadcasterManager.php | BroadcasterManager.instantiate | private static function instantiate($class, array $configs)
{
$reflection = new ReflectionClass($class);
$constructor = $reflection->getConstructor();
$arguments = array();
foreach ($constructor->getParameters() as $param) {
$name = $param->getName();
if (isset($configs[$name])) {
$arguments[] = $configs[$name];
continue;
}
$arguments[] = null;
}
$broadcaster = $reflection->newInstanceArgs($arguments);
if (!$broadcaster instanceof BroadcasterInterface) {
throw new RuntimeException(sprintf(
'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface',
$class
));
}
return $broadcaster;
} | php | private static function instantiate($class, array $configs)
{
$reflection = new ReflectionClass($class);
$constructor = $reflection->getConstructor();
$arguments = array();
foreach ($constructor->getParameters() as $param) {
$name = $param->getName();
if (isset($configs[$name])) {
$arguments[] = $configs[$name];
continue;
}
$arguments[] = null;
}
$broadcaster = $reflection->newInstanceArgs($arguments);
if (!$broadcaster instanceof BroadcasterInterface) {
throw new RuntimeException(sprintf(
'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface',
$class
));
}
return $broadcaster;
} | [
"private",
"static",
"function",
"instantiate",
"(",
"$",
"class",
",",
"array",
"$",
"configs",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"constructor",
"=",
"$",
"reflection",
"->",
"getConstructor",
"(... | Instantiate broadcaster.
@param string $class
@param array $configs
@return BroadcasterInterface | [
"Instantiate",
"broadcaster",
"."
] | d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a | https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L102-L128 | train |
eix/core | src/php/main/Eix/Core/Responses/Data.php | Data.addData | public function addData($key, $value)
{
if (isset($this->data[$key])) {
$this->data[$key] = array_merge_recursive(
$this->data[$key],
$value
);
} else {
$this->setData($key, $value);
}
} | php | public function addData($key, $value)
{
if (isset($this->data[$key])) {
$this->data[$key] = array_merge_recursive(
$this->data[$key],
$value
);
} else {
$this->setData($key, $value);
}
} | [
"public",
"function",
"addData",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"array_merge_recursive",... | Stores the response data in a key-value fashion, adding the data to the
existing set.
@param string $key the key under which the data is stored.
@param mixed $value the data. | [
"Stores",
"the",
"response",
"data",
"in",
"a",
"key",
"-",
"value",
"fashion",
"adding",
"the",
"data",
"to",
"the",
"existing",
"set",
"."
] | a5b4c09cc168221e85804fdfeb78e519a0415466 | https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Data.php#L33-L43 | train |
PowerOnSystem/HelperService | src/HtmlHelper.php | HtmlHelper.link | public function link($content, $url = [], array $options = []) {
/* @var $url_helper UrlHelper */
$url_helper = $this->url;
$cfg = [
'href' => is_array($url) ? (
key_exists('push', $url) ? $url_helper->push($url['push']) : (
key_exists('add', $url) || key_exists('remove', $url) ?
$url_helper->modify(
key_exists('add', $url) ? $url['add'] : [],
key_exists('remove', $url) ? $url['remove'] : []
) : (
key_exists('generate', $url) ? $url_helper->build($url, Arr::trim($url, 'generate')) :
(key_exists('mailto', $url) ? 'mailto:' . $url['mailto'] : $url_helper->build($url))
)
)) : ( $url_helper->routeExist($url) ? $url_helper->build([], $url) : $url )
] + $options;
return '<a ' . Str::htmlserialize($cfg) . ' >' . $content . '</a>';
} | php | public function link($content, $url = [], array $options = []) {
/* @var $url_helper UrlHelper */
$url_helper = $this->url;
$cfg = [
'href' => is_array($url) ? (
key_exists('push', $url) ? $url_helper->push($url['push']) : (
key_exists('add', $url) || key_exists('remove', $url) ?
$url_helper->modify(
key_exists('add', $url) ? $url['add'] : [],
key_exists('remove', $url) ? $url['remove'] : []
) : (
key_exists('generate', $url) ? $url_helper->build($url, Arr::trim($url, 'generate')) :
(key_exists('mailto', $url) ? 'mailto:' . $url['mailto'] : $url_helper->build($url))
)
)) : ( $url_helper->routeExist($url) ? $url_helper->build([], $url) : $url )
] + $options;
return '<a ' . Str::htmlserialize($cfg) . ' >' . $content . '</a>';
} | [
"public",
"function",
"link",
"(",
"$",
"content",
",",
"$",
"url",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"/* @var $url_helper UrlHelper */",
"$",
"url_helper",
"=",
"$",
"this",
"->",
"url",
";",
"$",
"cfg",
"=",
"[",... | Crea un enlace
@param string $content el contenido del enlace
@param array $url la URL
@param array $options [Opcional] las opciones
@return string una etiqueta a | [
"Crea",
"un",
"enlace"
] | 6d300764d7b3a090dd674b25415ce5088156ce8b | https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L59-L77 | train |
PowerOnSystem/HelperService | src/HtmlHelper.php | HtmlHelper.js | public function js($name = NULL, $external = FALSE, array $options = []) {
if ($name) {
$this->_js[$name] = $options + [
'src' => $external ? $name : PO_PATH_JS . '/' . $name
];
} else {
return implode(PHP_EOL, array_map(function($value) {
return '<script ' . Str::htmlserialize($value) . '></script>';
}, $this->_js)) . PHP_EOL;
}
} | php | public function js($name = NULL, $external = FALSE, array $options = []) {
if ($name) {
$this->_js[$name] = $options + [
'src' => $external ? $name : PO_PATH_JS . '/' . $name
];
} else {
return implode(PHP_EOL, array_map(function($value) {
return '<script ' . Str::htmlserialize($value) . '></script>';
}, $this->_js)) . PHP_EOL;
}
} | [
"public",
"function",
"js",
"(",
"$",
"name",
"=",
"NULL",
",",
"$",
"external",
"=",
"FALSE",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_js",
"[",
"$",
"name",
"]",
"=",
"$",... | Agrega un archivo javascript o enlista los agregados
@param string $name [Opcional] el nombre del archivo si no se especifica name devuelve todos los archivos js incluidos
@param boolean $external [Opcional] Especifica si se trata de un archivo JS externo.
@return string una etiqueta script | [
"Agrega",
"un",
"archivo",
"javascript",
"o",
"enlista",
"los",
"agregados"
] | 6d300764d7b3a090dd674b25415ce5088156ce8b | https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L112-L122 | train |
PowerOnSystem/HelperService | src/HtmlHelper.php | HtmlHelper.meta | public function meta($name = NULL, $content = NULL) {
if ( $name ) {
$this->_meta[$name] = ['name' => $name, 'content' => $content];
} else {
return implode(PHP_EOL, array_map(function($meta) {
return '<meta name="' . $meta['name'] . '" content="' . $meta['content'] . '" />';
}, $this->_meta)) . PHP_EOL;
}
} | php | public function meta($name = NULL, $content = NULL) {
if ( $name ) {
$this->_meta[$name] = ['name' => $name, 'content' => $content];
} else {
return implode(PHP_EOL, array_map(function($meta) {
return '<meta name="' . $meta['name'] . '" content="' . $meta['content'] . '" />';
}, $this->_meta)) . PHP_EOL;
}
} | [
"public",
"function",
"meta",
"(",
"$",
"name",
"=",
"NULL",
",",
"$",
"content",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_meta",
"[",
"$",
"name",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'content'... | Agrega una etiqueta META
@param string $name Nombre/Tipo de etiqueta meta
@param string $content Contenido
@return string La etiqueta formateada | [
"Agrega",
"una",
"etiqueta",
"META"
] | 6d300764d7b3a090dd674b25415ce5088156ce8b | https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L166-L174 | train |
PowerOnSystem/HelperService | src/HtmlHelper.php | HtmlHelper.img | public function img($name, array $options = [], $external = FALSE) {
$cfg = $options + [
'class' => ''
];
return '<img src = "' . ($external ? $name : PO_PATH_IMG . '/' . $name) . '" ' . Str::htmlserialize($cfg) . ' />';
} | php | public function img($name, array $options = [], $external = FALSE) {
$cfg = $options + [
'class' => ''
];
return '<img src = "' . ($external ? $name : PO_PATH_IMG . '/' . $name) . '" ' . Str::htmlserialize($cfg) . ' />';
} | [
"public",
"function",
"img",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"external",
"=",
"FALSE",
")",
"{",
"$",
"cfg",
"=",
"$",
"options",
"+",
"[",
"'class'",
"=>",
"''",
"]",
";",
"return",
"'<img src = \"'",
".",
... | Crea una imagen
@param string $name el nombre del archivo
@param array $options [Opcional] las opciones
@param boolean $external [Opcional] Especifica si se trata de una imagen externa
@return string una etiqueta img | [
"Crea",
"una",
"imagen"
] | 6d300764d7b3a090dd674b25415ce5088156ce8b | https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L183-L189 | train |
PowerOnSystem/HelperService | src/HtmlHelper.php | HtmlHelper.nestedList | public function nestedList(array $list, array $options = [], array $item_options = [], $type_list = 'list') {
$type = $type_list == 'list' ? 'ul' : 'ol';
$r = '<' . $type . ' ' . Str::htmlserialize($options) . '>';
foreach ($list as $key => $l) {
$r .= is_array($l) ? $this->nestedList($l, key_exists($key, $item_options) ? $item_options[$key] : []) :
'<li ' . (key_exists($key, $item_options) ? Str::htmlserialize($item_options[$key]) : '') . ' >' .
$l .
'</li>';
}
$r .= '</' . $type . '>';
return $r;
} | php | public function nestedList(array $list, array $options = [], array $item_options = [], $type_list = 'list') {
$type = $type_list == 'list' ? 'ul' : 'ol';
$r = '<' . $type . ' ' . Str::htmlserialize($options) . '>';
foreach ($list as $key => $l) {
$r .= is_array($l) ? $this->nestedList($l, key_exists($key, $item_options) ? $item_options[$key] : []) :
'<li ' . (key_exists($key, $item_options) ? Str::htmlserialize($item_options[$key]) : '') . ' >' .
$l .
'</li>';
}
$r .= '</' . $type . '>';
return $r;
} | [
"public",
"function",
"nestedList",
"(",
"array",
"$",
"list",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"array",
"$",
"item_options",
"=",
"[",
"]",
",",
"$",
"type_list",
"=",
"'list'",
")",
"{",
"$",
"type",
"=",
"$",
"type_list",
"==",
... | Crea una lista simple u ordenada
@param array $list Array con la lista completa, puede ser un array multidimencional
@param array $options [Opcional] Opciones de la lista Ej: <code>$options = ['class' => 'my_list', 'id' => 'mylist1']</code>
@param array $item_options [Opcional] Opciones de un item específico Ej: <code> $item_options = [1 => ['class' => 'active']] </code>
@param type $type_list [Opcional] Tipo de lista, "ordered" para una lista ordenada o list
@return string | [
"Crea",
"una",
"lista",
"simple",
"u",
"ordenada"
] | 6d300764d7b3a090dd674b25415ce5088156ce8b | https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L199-L211 | train |
Aureja/JobQueue | src/JobFactoryRegistry.php | JobFactoryRegistry.get | public function get($name)
{
if (isset($this->factories[$name])) {
return $this->factories[$name];
}
throw JobFactoryException::create(sprintf('Not found %s job factory', $name));
} | php | public function get($name)
{
if (isset($this->factories[$name])) {
return $this->factories[$name];
}
throw JobFactoryException::create(sprintf('Not found %s job factory', $name));
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"factories",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"factories",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"JobFactor... | Get factory.
@param string $name
@return JobFactoryInterface
@throws JobFactoryException | [
"Get",
"factory",
"."
] | 0e488ca123d3105cf791173e3147ede1bcf39018 | https://github.com/Aureja/JobQueue/blob/0e488ca123d3105cf791173e3147ede1bcf39018/src/JobFactoryRegistry.php#L56-L63 | train |
easy-system/es-error | src/ErrorListenerFactory.php | ErrorListenerFactory.make | public static function make()
{
$services = Provider::getServices();
$config = $services->get('Config');
$strategies = [];
if (isset($config['error']['strategies'])) {
$strategies = (array) $config['error']['strategies'];
}
$listener = new ErrorListener;
foreach ($strategies as $name) {
$strategy = $services->get($name);
$listener->attachErrorStrategy($strategy);
}
return $listener;
} | php | public static function make()
{
$services = Provider::getServices();
$config = $services->get('Config');
$strategies = [];
if (isset($config['error']['strategies'])) {
$strategies = (array) $config['error']['strategies'];
}
$listener = new ErrorListener;
foreach ($strategies as $name) {
$strategy = $services->get($name);
$listener->attachErrorStrategy($strategy);
}
return $listener;
} | [
"public",
"static",
"function",
"make",
"(",
")",
"{",
"$",
"services",
"=",
"Provider",
"::",
"getServices",
"(",
")",
";",
"$",
"config",
"=",
"$",
"services",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"strategies",
"=",
"[",
"]",
";",
"if",
"... | Makes the error listener.
@return \Es\Error\ErrorListener The error listener | [
"Makes",
"the",
"error",
"listener",
"."
] | 5248c52f2992acc9ddf3542092ad7bbbb440e621 | https://github.com/easy-system/es-error/blob/5248c52f2992acc9ddf3542092ad7bbbb440e621/src/ErrorListenerFactory.php#L24-L39 | train |
yii2module/yii2-encrypt | src/console/controllers/CoderController.php | CoderController.actionEncode | public function actionEncode()
{
$text = Enter::display('Enter text');
$encrypted = \App::$domain->encrypt->coder->encode($text);
Output::block($encrypted, 'Encrypted');
} | php | public function actionEncode()
{
$text = Enter::display('Enter text');
$encrypted = \App::$domain->encrypt->coder->encode($text);
Output::block($encrypted, 'Encrypted');
} | [
"public",
"function",
"actionEncode",
"(",
")",
"{",
"$",
"text",
"=",
"Enter",
"::",
"display",
"(",
"'Enter text'",
")",
";",
"$",
"encrypted",
"=",
"\\",
"App",
"::",
"$",
"domain",
"->",
"encrypt",
"->",
"coder",
"->",
"encode",
"(",
"$",
"text",
... | encryption of data | [
"encryption",
"of",
"data"
] | 47ec61161ab24ddf84bb456f27c9ee9704285801 | https://github.com/yii2module/yii2-encrypt/blob/47ec61161ab24ddf84bb456f27c9ee9704285801/src/console/controllers/CoderController.php#L19-L24 | train |
yii2module/yii2-encrypt | src/console/controllers/CoderController.php | CoderController.actionDecode | public function actionDecode()
{
$encrypted = Enter::display('Enter encrypted');
$text = \App::$domain->encrypt->coder->decode($encrypted);
Output::block($text, 'Text');
} | php | public function actionDecode()
{
$encrypted = Enter::display('Enter encrypted');
$text = \App::$domain->encrypt->coder->decode($encrypted);
Output::block($text, 'Text');
} | [
"public",
"function",
"actionDecode",
"(",
")",
"{",
"$",
"encrypted",
"=",
"Enter",
"::",
"display",
"(",
"'Enter encrypted'",
")",
";",
"$",
"text",
"=",
"\\",
"App",
"::",
"$",
"domain",
"->",
"encrypt",
"->",
"coder",
"->",
"decode",
"(",
"$",
"enc... | decryption of data | [
"decryption",
"of",
"data"
] | 47ec61161ab24ddf84bb456f27c9ee9704285801 | https://github.com/yii2module/yii2-encrypt/blob/47ec61161ab24ddf84bb456f27c9ee9704285801/src/console/controllers/CoderController.php#L29-L34 | train |
hmlb/date | src/Translation/DateLocalizationCapabilities.php | DateLocalizationCapabilities.translator | protected static function translator()
{
if (static::$translator === null) {
$translator = new Translator('en');
$translator->addLoader('array', new ArrayLoader());
static::$translator = $translator;
static::setLocale('en');
}
return static::$translator;
} | php | protected static function translator()
{
if (static::$translator === null) {
$translator = new Translator('en');
$translator->addLoader('array', new ArrayLoader());
static::$translator = $translator;
static::setLocale('en');
}
return static::$translator;
} | [
"protected",
"static",
"function",
"translator",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"translator",
"===",
"null",
")",
"{",
"$",
"translator",
"=",
"new",
"Translator",
"(",
"'en'",
")",
";",
"$",
"translator",
"->",
"addLoader",
"(",
"'array'... | Intialize the translator instance if necessary.
@return TranslatorInterface | [
"Intialize",
"the",
"translator",
"instance",
"if",
"necessary",
"."
] | 54ddca80fa4ef7d4a617812e10c291f142a164c0 | https://github.com/hmlb/date/blob/54ddca80fa4ef7d4a617812e10c291f142a164c0/src/Translation/DateLocalizationCapabilities.php#L32-L42 | train |
osflab/view | Helper/Bootstrap/Accordion.php | Accordion.render | protected function render()
{
if (!isset($this->items[0])) {
return '';
}
foreach ($this->items as $itemId => $item) {
$item->setCollapsable(
self::$id,
self::$id . $itemId,
in_array($itemId, $this->openedItems));
}
$this->setAttribute('id', self::$id);
$this->addCssClass($this->itemType . '-group');
return $this
->html('<div' . $this->getEltDecorationStr() . '>')
->html(implode("\n", $this->items))
->html('</div>')
->getHtml();
} | php | protected function render()
{
if (!isset($this->items[0])) {
return '';
}
foreach ($this->items as $itemId => $item) {
$item->setCollapsable(
self::$id,
self::$id . $itemId,
in_array($itemId, $this->openedItems));
}
$this->setAttribute('id', self::$id);
$this->addCssClass($this->itemType . '-group');
return $this
->html('<div' . $this->getEltDecorationStr() . '>')
->html(implode("\n", $this->items))
->html('</div>')
->getHtml();
} | [
"protected",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"0",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"itemId",
"=>",
"$",
"ite... | Display the box at the end of configuration
@return string | [
"Display",
"the",
"box",
"at",
"the",
"end",
"of",
"configuration"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Accordion.php#L60-L78 | train |
marando/phpSOFA | src/Marando/IAU/iauRy.php | iauRy.Ry | public static function Ry($theta, array &$r) {
$s;
$c;
$a00;
$a01;
$a02;
$a20;
$a21;
$a22;
$s = sin($theta);
$c = cos($theta);
$a00 = $c * $r[0][0] - $s * $r[2][0];
$a01 = $c * $r[0][1] - $s * $r[2][1];
$a02 = $c * $r[0][2] - $s * $r[2][2];
$a20 = $s * $r[0][0] + $c * $r[2][0];
$a21 = $s * $r[0][1] + $c * $r[2][1];
$a22 = $s * $r[0][2] + $c * $r[2][2];
$r[0][0] = $a00;
$r[0][1] = $a01;
$r[0][2] = $a02;
$r[2][0] = $a20;
$r[2][1] = $a21;
$r[2][2] = $a22;
return;
} | php | public static function Ry($theta, array &$r) {
$s;
$c;
$a00;
$a01;
$a02;
$a20;
$a21;
$a22;
$s = sin($theta);
$c = cos($theta);
$a00 = $c * $r[0][0] - $s * $r[2][0];
$a01 = $c * $r[0][1] - $s * $r[2][1];
$a02 = $c * $r[0][2] - $s * $r[2][2];
$a20 = $s * $r[0][0] + $c * $r[2][0];
$a21 = $s * $r[0][1] + $c * $r[2][1];
$a22 = $s * $r[0][2] + $c * $r[2][2];
$r[0][0] = $a00;
$r[0][1] = $a01;
$r[0][2] = $a02;
$r[2][0] = $a20;
$r[2][1] = $a21;
$r[2][2] = $a22;
return;
} | [
"public",
"static",
"function",
"Ry",
"(",
"$",
"theta",
",",
"array",
"&",
"$",
"r",
")",
"{",
"$",
"s",
";",
"$",
"c",
";",
"$",
"a00",
";",
"$",
"a01",
";",
"$",
"a02",
";",
"$",
"a20",
";",
"$",
"a21",
";",
"$",
"a22",
";",
"$",
"s",
... | - - - - - -
i a u R y
- - - - - -
Rotate an r-matrix about the y-axis.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: vector/matrix support function.
Given:
theta double angle (radians)
Given and returned:
r double[3][3] r-matrix, rotated
Notes:
1) Calling this function with positive theta incorporates in the
supplied r-matrix r an additional rotation, about the y-axis,
anticlockwise as seen looking towards the origin from positive y.
2) The additional rotation can be represented by this matrix:
( + cos(theta) 0 - sin(theta) )
( )
( 0 1 0 )
( )
( + sin(theta) 0 + cos(theta) )
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"R",
"y",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRy.php#L45-L73 | train |
tekkla/core-html | Core/Html/Bootstrap/Navbar/AbstractNavbarElement.php | AbstractNavbarElement.isActive | final public function isActive($active = null)
{
if (isset($active)) {
$this->active = (bool) $active;
return $this;
}
else {
return $this->active;
}
} | php | final public function isActive($active = null)
{
if (isset($active)) {
$this->active = (bool) $active;
return $this;
}
else {
return $this->active;
}
} | [
"final",
"public",
"function",
"isActive",
"(",
"$",
"active",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"active",
")",
")",
"{",
"$",
"this",
"->",
"active",
"=",
"(",
"bool",
")",
"$",
"active",
";",
"return",
"$",
"this",
";",
"}",
... | Sets or gets active state of element
@param bool $active
@return \Core\Html\Bootstrap\Navbar\NavbarElementAbstract|boolean | [
"Sets",
"or",
"gets",
"active",
"state",
"of",
"element"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Navbar/AbstractNavbarElement.php#L41-L50 | train |
n0m4dz/laracasa | Zend/Gdata/Calendar.php | Zend_Gdata_Calendar.getCalendarEventFeed | public function getCalendarEventFeed($location = null)
{
if ($location == null) {
$uri = self::CALENDAR_EVENT_FEED_URI;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed');
} | php | public function getCalendarEventFeed($location = null)
{
if ($location == null) {
$uri = self::CALENDAR_EVENT_FEED_URI;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed');
} | [
"public",
"function",
"getCalendarEventFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"==",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"CALENDAR_EVENT_FEED_URI",
";",
"}",
"else",
"if",
"(",
"$",
"location",
"instan... | Retreive feed object
@param mixed $location The location for the feed, as a URL or Query
@return Zend_Gdata_Calendar_EventFeed | [
"Retreive",
"feed",
"object"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Calendar.php#L98-L108 | train |
brisum/php-lib-object-manager | src/ObjectManager.php | ObjectManager.get | public function get($class)
{
$class = ltrim($class, '\\');
if (!isset($this->sharedInstances[$class])) {
$this->sharedInstances[$class] = $this->create($class);
}
return $this->sharedInstances[$class];
} | php | public function get($class)
{
$class = ltrim($class, '\\');
if (!isset($this->sharedInstances[$class])) {
$this->sharedInstances[$class] = $this->create($class);
}
return $this->sharedInstances[$class];
} | [
"public",
"function",
"get",
"(",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"ltrim",
"(",
"$",
"class",
",",
"'\\\\'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"sharedInstances",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"t... | Get object from shared instances by class name.
@param string $class
@return mixed | [
"Get",
"object",
"from",
"shared",
"instances",
"by",
"class",
"name",
"."
] | 9d2326a4c4665ec9b8003ef1389f1f55cb4344ec | https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L89-L97 | train |
brisum/php-lib-object-manager | src/ObjectManager.php | ObjectManager.invoke | public function invoke($object, $method, array $arguments = [])
{
$reflection = new \ReflectionClass($object);
$method = $reflection->getMethod($method);
$args = $this->resolveArguments($method, $arguments);
return $method->invokeArgs($object, $args);
} | php | public function invoke($object, $method, array $arguments = [])
{
$reflection = new \ReflectionClass($object);
$method = $reflection->getMethod($method);
$args = $this->resolveArguments($method, $arguments);
return $method->invokeArgs($object, $args);
} | [
"public",
"function",
"invoke",
"(",
"$",
"object",
",",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"$",
"method",
"=",
"$",
"reflectio... | Invoke method of object.
@param mixed $object
@param string $method
@param array $arguments
@return mixed | [
"Invoke",
"method",
"of",
"object",
"."
] | 9d2326a4c4665ec9b8003ef1389f1f55cb4344ec | https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L179-L186 | train |
brisum/php-lib-object-manager | src/ObjectManager.php | ObjectManager.resolveArguments | protected function resolveArguments(
ReflectionMethod $method,
array $arguments
) {
$params = $method->getParameters();
$result = [];
foreach ($params as $param) {
/** @var ReflectionParameter $param */
if (isset($arguments[$param->name])) {
$result[$param->name] = $arguments[$param->name];
continue;
}
$class = $param->getClass();
if ($class) {
$className = $class->getName();
if ($this->isShared($className)) {
$result[$className] = isset($this->sharedInstances[$className])
? $this->sharedInstances[$className]
: $this->get($className);
} else {
$result[$className] = $this->create($className);
}
}
}
return $result;
} | php | protected function resolveArguments(
ReflectionMethod $method,
array $arguments
) {
$params = $method->getParameters();
$result = [];
foreach ($params as $param) {
/** @var ReflectionParameter $param */
if (isset($arguments[$param->name])) {
$result[$param->name] = $arguments[$param->name];
continue;
}
$class = $param->getClass();
if ($class) {
$className = $class->getName();
if ($this->isShared($className)) {
$result[$className] = isset($this->sharedInstances[$className])
? $this->sharedInstances[$className]
: $this->get($className);
} else {
$result[$className] = $this->create($className);
}
}
}
return $result;
} | [
"protected",
"function",
"resolveArguments",
"(",
"ReflectionMethod",
"$",
"method",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"params",
"=",
"$",
"method",
"->",
"getParameters",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$"... | Resolve argument of method.
@param ReflectionMethod $method
@param array $arguments
@return array | [
"Resolve",
"argument",
"of",
"method",
"."
] | 9d2326a4c4665ec9b8003ef1389f1f55cb4344ec | https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L195-L223 | train |
tenside/core-bundle | src/Controller/VersionConstraintController.php | VersionConstraintController.checkVersionConstraintAction | public function checkVersionConstraintAction(Request $request)
{
try {
$inputData = new JsonArray($request->getContent());
} catch (\Exception $exception) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => 'invalid payload'
],
JsonResponse::HTTP_BAD_REQUEST
);
}
$versionParser = new VersionParser();
if (!$inputData->has('constraint')) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => 'invalid payload'
],
JsonResponse::HTTP_BAD_REQUEST
);
}
try {
$versionParser->parseConstraints($inputData->get('constraint'));
} catch (\Exception $exception) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => $exception->getMessage()
],
JsonResponse::HTTP_OK
);
}
return new JsonResponse(
[
'status' => 'OK',
],
JsonResponse::HTTP_OK
);
} | php | public function checkVersionConstraintAction(Request $request)
{
try {
$inputData = new JsonArray($request->getContent());
} catch (\Exception $exception) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => 'invalid payload'
],
JsonResponse::HTTP_BAD_REQUEST
);
}
$versionParser = new VersionParser();
if (!$inputData->has('constraint')) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => 'invalid payload'
],
JsonResponse::HTTP_BAD_REQUEST
);
}
try {
$versionParser->parseConstraints($inputData->get('constraint'));
} catch (\Exception $exception) {
return new JsonResponse(
[
'status' => 'ERROR',
'error' => $exception->getMessage()
],
JsonResponse::HTTP_OK
);
}
return new JsonResponse(
[
'status' => 'OK',
],
JsonResponse::HTTP_OK
);
} | [
"public",
"function",
"checkVersionConstraintAction",
"(",
"Request",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"inputData",
"=",
"new",
"JsonArray",
"(",
"$",
"request",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
... | Try to validate the version constraint.
@param Request $request The request.
@return JsonResponse
@throws \RuntimeException For invalid user classes.
@ApiDoc(
section="misc",
statusCodes = {
200 = "When everything worked out ok",
400 = "When the request payload was invalid."
},
authentication = true,
authenticationRoles = {
"ROLE_NONE"
}
)
@ApiDescription(
request={
"constraint" = {
"description" = "The constraint to test.",
"dataType" = "string",
"required" = true
}
},
response={
"status" = {
"dataType" = "choice",
"description" = "OK or ERROR",
"format" = "['OK', 'ERROR']",
},
"error" = {
"dataType" = "string",
"description" = "The error message (if any).",
}
}
) | [
"Try",
"to",
"validate",
"the",
"version",
"constraint",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/VersionConstraintController.php#L77-L121 | train |
indigophp-archive/fuel-core | classes/theme.php | Theme.set_config | public function set_config($key, $value = null)
{
if (is_array($key))
{
$this->config = \Arr::merge($this->config, $key);
}
else
{
\Arr::set($this->config, $key, $value);
}
return $this;
} | php | public function set_config($key, $value = null)
{
if (is_array($key))
{
$this->config = \Arr::merge($this->config, $key);
}
else
{
\Arr::set($this->config, $key, $value);
}
return $this;
} | [
"public",
"function",
"set_config",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"\\",
"Arr",
"::",
"merge",
"(",
"$",
"this",
"->",
"config",
... | Sets a config item
@param mixed $key Config key or array to merge
@param mixed $value Config value
@return this | [
"Sets",
"a",
"config",
"item"
] | 275462154fb7937f8e1c2c541b31d8e7c5760e39 | https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L42-L54 | train |
indigophp-archive/fuel-core | classes/theme.php | Theme.get_parent_themes | public function get_parent_themes($theme_name)
{
$return = array($this->create_theme_array($theme_name));
$theme_info = $this->load_info($theme_name);
if ( ! empty($theme_info['parent']))
{
$return = array_merge($return, $this->get_parent_themes($theme_info['parent']));
}
elseif($theme_name !== $this->fallback['name'])
{
$return[] = $this->fallback;
}
return $return;
} | php | public function get_parent_themes($theme_name)
{
$return = array($this->create_theme_array($theme_name));
$theme_info = $this->load_info($theme_name);
if ( ! empty($theme_info['parent']))
{
$return = array_merge($return, $this->get_parent_themes($theme_info['parent']));
}
elseif($theme_name !== $this->fallback['name'])
{
$return[] = $this->fallback;
}
return $return;
} | [
"public",
"function",
"get_parent_themes",
"(",
"$",
"theme_name",
")",
"{",
"$",
"return",
"=",
"array",
"(",
"$",
"this",
"->",
"create_theme_array",
"(",
"$",
"theme_name",
")",
")",
";",
"$",
"theme_info",
"=",
"$",
"this",
"->",
"load_info",
"(",
"$... | Returns parent theme info
@param string $theme_name
@return array | [
"Returns",
"parent",
"theme",
"info"
] | 275462154fb7937f8e1c2c541b31d8e7c5760e39 | https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L129-L144 | train |
indigophp-archive/fuel-core | classes/theme.php | Theme.asset_url | public function asset_url($path)
{
$url = $this->asset_path($path);
if (filter_var($url, FILTER_VALIDATE_URL) === false)
{
$url = \Uri::create($url);
}
return $url;
} | php | public function asset_url($path)
{
$url = $this->asset_path($path);
if (filter_var($url, FILTER_VALIDATE_URL) === false)
{
$url = \Uri::create($url);
}
return $url;
} | [
"public",
"function",
"asset_url",
"(",
"$",
"path",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"asset_path",
"(",
"$",
"path",
")",
";",
"if",
"(",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
"===",
"false",
")",
"{",
"$",
"... | Returns an absolute URL to asset
@param string $path
@return string | [
"Returns",
"an",
"absolute",
"URL",
"to",
"asset"
] | 275462154fb7937f8e1c2c541b31d8e7c5760e39 | https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L153-L163 | train |
wp-pluginner/framework | src/Container.php | Container.loadRoutes | public function loadRoutes()
{
if ($this->bound('router')) {
/**
* Use Cached Routes if Available
*/
if ($this['config']->get('routes.cache') && $this['files']->exists($this['config']->get('routes.compiled'))) {
$contents = $this['files']->get($this['config']->get('routes.compiled'));
if (!empty($contents)) {
//Get Cached Routes & Set Them
$this['router']->setRoutes(unserialize(base64_decode($contents)));
}
} else {
//Assign Router to Simple Variable for Include
$route = $this['router'];
$response = $this['response'];
//Include Routes
if($this['files']->exists($this->base_path . '/app/Http/routes.php')){
require_once $this->base_path . '/app/Http/routes.php';
}
}
/**
* Store Cached Routes
*/
if ($this['config']->get('routes.cache') && !$this['files']->exists($this['config']->get('routes.compiled'))) {
try {
//Set Routes Cache
if (!$this['files']->exists($this['config']->get('routes.compiled'))) {
$allRoutes = $this['router']->getRoutes();
//If Routes then Serialize
if (count($allRoutes) > 0) {
foreach ($allRoutes as $routeObject) {
$routeObject->prepareForSerialization();
}
}
//Store Routes in Cache
$this['files']->put($this['config']->get('routes.compiled'), base64_encode(serialize($allRoutes)));
}
} catch (\Exception $exception) {
if (!empty($exception->getMessage())) {
add_action('admin_notices', function () use ($exception) {
?>
<div class="error notice">
<p>⚠ <?php echo $exception->getMessage(); ?></p>
<p><em><? echo 'Route caching cannot serialize closures'; ?>.</em></p>
</div>
<?php
});
}
}
}
}
} | php | public function loadRoutes()
{
if ($this->bound('router')) {
/**
* Use Cached Routes if Available
*/
if ($this['config']->get('routes.cache') && $this['files']->exists($this['config']->get('routes.compiled'))) {
$contents = $this['files']->get($this['config']->get('routes.compiled'));
if (!empty($contents)) {
//Get Cached Routes & Set Them
$this['router']->setRoutes(unserialize(base64_decode($contents)));
}
} else {
//Assign Router to Simple Variable for Include
$route = $this['router'];
$response = $this['response'];
//Include Routes
if($this['files']->exists($this->base_path . '/app/Http/routes.php')){
require_once $this->base_path . '/app/Http/routes.php';
}
}
/**
* Store Cached Routes
*/
if ($this['config']->get('routes.cache') && !$this['files']->exists($this['config']->get('routes.compiled'))) {
try {
//Set Routes Cache
if (!$this['files']->exists($this['config']->get('routes.compiled'))) {
$allRoutes = $this['router']->getRoutes();
//If Routes then Serialize
if (count($allRoutes) > 0) {
foreach ($allRoutes as $routeObject) {
$routeObject->prepareForSerialization();
}
}
//Store Routes in Cache
$this['files']->put($this['config']->get('routes.compiled'), base64_encode(serialize($allRoutes)));
}
} catch (\Exception $exception) {
if (!empty($exception->getMessage())) {
add_action('admin_notices', function () use ($exception) {
?>
<div class="error notice">
<p>⚠ <?php echo $exception->getMessage(); ?></p>
<p><em><? echo 'Route caching cannot serialize closures'; ?>.</em></p>
</div>
<?php
});
}
}
}
}
} | [
"public",
"function",
"loadRoutes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bound",
"(",
"'router'",
")",
")",
"{",
"/**\n\t\t\t * Use Cached Routes if Available\n\t\t\t */",
"if",
"(",
"$",
"this",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'routes.cache'... | Load Routes into Router | [
"Load",
"Routes",
"into",
"Router"
] | 557d62674acf6ca43b2523f8d4a0aa0dbf8e674d | https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Container.php#L101-L155 | train |
wp-pluginner/framework | src/Container.php | Container.routeRequest | public function routeRequest()
{
if($this->bound('router')){
try {
$pluginRequest = $this['request'];
$this['router']->matched(function ($event) {
global $wp_query;
$wp_query->is_404 = false;
$this->route_dispatched = true;
});
$response = $this['router']->dispatch($pluginRequest);
if ($route = $pluginRequest->route()) {
foreach ($route->computedMiddleware as $middleware) {
$instance = $this->make($middleware);
if (method_exists($instance, 'terminate')) {
$instance->terminate($pluginRequest, $response);
}
}
}
if($this->bound('session')) {
$this['session']->save();
}
$response->send();
exit;
}catch (\Exception $e) {
$this->reportException($e);
$this->renderException($pluginRequest, $e);
} catch (\Throwable $e) {
$this->reportException($e = new FatalThrowableError($e));
$this->renderException($pluginRequest, $e);
}
}
} | php | public function routeRequest()
{
if($this->bound('router')){
try {
$pluginRequest = $this['request'];
$this['router']->matched(function ($event) {
global $wp_query;
$wp_query->is_404 = false;
$this->route_dispatched = true;
});
$response = $this['router']->dispatch($pluginRequest);
if ($route = $pluginRequest->route()) {
foreach ($route->computedMiddleware as $middleware) {
$instance = $this->make($middleware);
if (method_exists($instance, 'terminate')) {
$instance->terminate($pluginRequest, $response);
}
}
}
if($this->bound('session')) {
$this['session']->save();
}
$response->send();
exit;
}catch (\Exception $e) {
$this->reportException($e);
$this->renderException($pluginRequest, $e);
} catch (\Throwable $e) {
$this->reportException($e = new FatalThrowableError($e));
$this->renderException($pluginRequest, $e);
}
}
} | [
"public",
"function",
"routeRequest",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bound",
"(",
"'router'",
")",
")",
"{",
"try",
"{",
"$",
"pluginRequest",
"=",
"$",
"this",
"[",
"'request'",
"]",
";",
"$",
"this",
"[",
"'router'",
"]",
"->",
"ma... | Try Routing Requests | [
"Try",
"Routing",
"Requests"
] | 557d62674acf6ca43b2523f8d4a0aa0dbf8e674d | https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Container.php#L159-L191 | train |
benkle-libs/feed-parser | src/Parser.php | Parser.parse | public function parse(\DOMDocument $dom)
{
$feed = $this->getStandard()->newFeed();
$rootNode = $this->getStandard()->getRootNode($dom);
$this->parseNodeChildren($rootNode, $feed);
return $feed;
} | php | public function parse(\DOMDocument $dom)
{
$feed = $this->getStandard()->newFeed();
$rootNode = $this->getStandard()->getRootNode($dom);
$this->parseNodeChildren($rootNode, $feed);
return $feed;
} | [
"public",
"function",
"parse",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"feed",
"=",
"$",
"this",
"->",
"getStandard",
"(",
")",
"->",
"newFeed",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"this",
"->",
"getStandard",
"(",
")",
"->",
"ge... | Turn a dom document into a feed object.
@param \DOMDocument $dom
@return FeedInterface
@throws InvalidNumberOfRootTagsException | [
"Turn",
"a",
"dom",
"document",
"into",
"a",
"feed",
"object",
"."
] | 8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f | https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Parser.php#L63-L69 | train |
benkle-libs/feed-parser | src/Parser.php | Parser.parseNodeChildren | public function parseNodeChildren(\DOMNode $node, NodeInterface $target)
{
$rules = $this->getStandard()->getRules();
foreach ($node->childNodes as $childNode) {
/** @var RuleInterface $rule */
foreach ($rules as $rule) {
if ($rule->canHandle($childNode, $target)) {
$rule->handle($this, $childNode, $target);
break;
}
}
}
} | php | public function parseNodeChildren(\DOMNode $node, NodeInterface $target)
{
$rules = $this->getStandard()->getRules();
foreach ($node->childNodes as $childNode) {
/** @var RuleInterface $rule */
foreach ($rules as $rule) {
if ($rule->canHandle($childNode, $target)) {
$rule->handle($this, $childNode, $target);
break;
}
}
}
} | [
"public",
"function",
"parseNodeChildren",
"(",
"\\",
"DOMNode",
"$",
"node",
",",
"NodeInterface",
"$",
"target",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"getStandard",
"(",
")",
"->",
"getRules",
"(",
")",
";",
"foreach",
"(",
"$",
"node",
"-... | Parse the children of a given node.
@param \DOMNode $node
@param NodeInterface $target | [
"Parse",
"the",
"children",
"of",
"a",
"given",
"node",
"."
] | 8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f | https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Parser.php#L76-L88 | train |
infusephp/rest-api | src/Libs/ApiRoute.php | ApiRoute.getQuery | public function getQuery($index = false)
{
return ($index) ? array_value($this->query, $index) : $this->query;
} | php | public function getQuery($index = false)
{
return ($index) ? array_value($this->query, $index) : $this->query;
} | [
"public",
"function",
"getQuery",
"(",
"$",
"index",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"index",
")",
"?",
"array_value",
"(",
"$",
"this",
"->",
"query",
",",
"$",
"index",
")",
":",
"$",
"this",
"->",
"query",
";",
"}"
] | Gets one or all query parameters.
@param string $index
@return mixed | [
"Gets",
"one",
"or",
"all",
"query",
"parameters",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Libs/ApiRoute.php#L177-L180 | train |
ARCANESOFT/Tracker | src/ViewComposers/Dashboard/ReferersListComposer.php | ReferersListComposer.calculateLanguagesPercentage | private function calculateLanguagesPercentage($referers)
{
$total = $referers->sum('count');
return $referers->transform(function ($item) use ($total) {
return $item + [
'percentage' => round(($item['count'] / $total) * 100, 2)
];
});
} | php | private function calculateLanguagesPercentage($referers)
{
$total = $referers->sum('count');
return $referers->transform(function ($item) use ($total) {
return $item + [
'percentage' => round(($item['count'] / $total) * 100, 2)
];
});
} | [
"private",
"function",
"calculateLanguagesPercentage",
"(",
"$",
"referers",
")",
"{",
"$",
"total",
"=",
"$",
"referers",
"->",
"sum",
"(",
"'count'",
")",
";",
"return",
"$",
"referers",
"->",
"transform",
"(",
"function",
"(",
"$",
"item",
")",
"use",
... | Calculate the referers percentage.
@param \Illuminate\Support\Collection $referers
@return \Illuminate\Support\Collection | [
"Calculate",
"the",
"referers",
"percentage",
"."
] | d106209b32ddbb192066715f0ef99afccfc22dcb | https://github.com/ARCANESOFT/Tracker/blob/d106209b32ddbb192066715f0ef99afccfc22dcb/src/ViewComposers/Dashboard/ReferersListComposer.php#L88-L97 | train |
cmdweb/kernel | Kernel/Database.php | Database.select | public function select($sql, $class = "", $all = FALSE, $array = array())
{
// Prepara a Query
$sth = $this->prepare($sql);
// Define os dados do Where, se existirem.
foreach ($array as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue("$key", $value, $tipo);
}
// Executa
$sth->execute();
// Executar fetchAll() ou fetch()?
// Retorna a cole��o de dados (array multidimensional)
if ($sth->rowCount() <= 0)
return null;
if ($class == "") {
if ($all == false and $sth->rowCount() == 1) {
$array = $sth->fetchAll(PDO::FETCH_OBJ);
return array_shift($array);
}
return $sth->fetchAll(PDO::FETCH_OBJ);
} else {
if ($all == false and $sth->rowCount() == 1) {
$array = $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class));
return array_shift($array);
}
return $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class));
}
} | php | public function select($sql, $class = "", $all = FALSE, $array = array())
{
// Prepara a Query
$sth = $this->prepare($sql);
// Define os dados do Where, se existirem.
foreach ($array as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue("$key", $value, $tipo);
}
// Executa
$sth->execute();
// Executar fetchAll() ou fetch()?
// Retorna a cole��o de dados (array multidimensional)
if ($sth->rowCount() <= 0)
return null;
if ($class == "") {
if ($all == false and $sth->rowCount() == 1) {
$array = $sth->fetchAll(PDO::FETCH_OBJ);
return array_shift($array);
}
return $sth->fetchAll(PDO::FETCH_OBJ);
} else {
if ($all == false and $sth->rowCount() == 1) {
$array = $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class));
return array_shift($array);
}
return $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class));
}
} | [
"public",
"function",
"select",
"(",
"$",
"sql",
",",
"$",
"class",
"=",
"\"\"",
",",
"$",
"all",
"=",
"FALSE",
",",
"$",
"array",
"=",
"array",
"(",
")",
")",
"{",
"// Prepara a Query",
"$",
"sth",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"s... | Executa um select no banco
@param $sql - query
@param string $class - Classe de retorno
@param bool $all - Se quando retornar apenas um resultado vai voltar em um array ou um objeto unico (true = objeto)
@param array $array - Paramentos do PDO
@return array|mixed|null | [
"Executa",
"um",
"select",
"no",
"banco"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L44-L86 | train |
cmdweb/kernel | Kernel/Database.php | Database.ExecuteInsert | public function ExecuteInsert($table, $data)
{
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Campos e valores
$camposNomes = implode('`, `', array_keys($data));
$camposValores = ':' . implode(', :', array_keys($data));
// Prepara a Query
$sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Executa
$sth->execute();
// Retorna o ID desse item inserido
return $this->lastInsertId();
} | php | public function ExecuteInsert($table, $data)
{
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Campos e valores
$camposNomes = implode('`, `', array_keys($data));
$camposValores = ':' . implode(', :', array_keys($data));
// Prepara a Query
$sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Executa
$sth->execute();
// Retorna o ID desse item inserido
return $this->lastInsertId();
} | [
"public",
"function",
"ExecuteInsert",
"(",
"$",
"table",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"ModelState",
"::",
"ModelTreatment",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"d... | Executa um INSERT no banco
@param $table - Noma da Tabela
@param $data - Array com os dados do insert
@return string - id inserido no banco | [
"Executa",
"um",
"INSERT",
"no",
"banco"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L105-L136 | train |
cmdweb/kernel | Kernel/Database.php | Database.ExecuteUpdate | public function ExecuteUpdate($table, $data, $where)
{
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Define os dados que ser�o atualizados
$novosDados = NULL;
foreach ($data as $key => $value) {
$novosDados .= "`$key`=:$key,";
}
$novosDados = rtrim($novosDados, ',');
// Prepara a Query
$sth = $this->prepare("UPDATE $table SET $novosDados WHERE $where");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Sucesso ou falha?
return $sth->execute();
} | php | public function ExecuteUpdate($table, $data, $where)
{
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Define os dados que ser�o atualizados
$novosDados = NULL;
foreach ($data as $key => $value) {
$novosDados .= "`$key`=:$key,";
}
$novosDados = rtrim($novosDados, ',');
// Prepara a Query
$sth = $this->prepare("UPDATE $table SET $novosDados WHERE $where");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Sucesso ou falha?
return $sth->execute();
} | [
"public",
"function",
"ExecuteUpdate",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"ModelState",
"::",
"ModelTreatment",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"(",
"a... | Executa com UPDATE no banco
@param $table - Nome da Tabela
@param $data - Dados que vão ser atualizados
@param $where - WHERE da query do update
@return bool - Sucesso ou falha | [
"Executa",
"com",
"UPDATE",
"no",
"banco"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L145-L177 | train |
kengoldfarb/underscore_libs | src/_Libs/_ServiceResponse.php | _ServiceResponse._success | public static function _success($objects, $echoResponse = TRUE, $format = 'json') {
return self::_doResponse('success', $objects, $echoResponse, $format);
} | php | public static function _success($objects, $echoResponse = TRUE, $format = 'json') {
return self::_doResponse('success', $objects, $echoResponse, $format);
} | [
"public",
"static",
"function",
"_success",
"(",
"$",
"objects",
",",
"$",
"echoResponse",
"=",
"TRUE",
",",
"$",
"format",
"=",
"'json'",
")",
"{",
"return",
"self",
"::",
"_doResponse",
"(",
"'success'",
",",
"$",
"objects",
",",
"$",
"echoResponse",
"... | Create a service response of success
@param array $objects An object or array of objects
@param bool $echoResponse Whether to echo out of response
@param string $format 'json' or 'xml'
@return string The response | [
"Create",
"a",
"service",
"response",
"of",
"success"
] | e0d584f25093b594e67b8a3068ebd41c7f6483c5 | https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L37-L39 | train |
kengoldfarb/underscore_libs | src/_Libs/_ServiceResponse.php | _ServiceResponse._failure | public static function _failure($objects, $echoResponse = TRUE, $format = 'json') {
return self::_doResponse('failure', $objects, $echoResponse, $format);
} | php | public static function _failure($objects, $echoResponse = TRUE, $format = 'json') {
return self::_doResponse('failure', $objects, $echoResponse, $format);
} | [
"public",
"static",
"function",
"_failure",
"(",
"$",
"objects",
",",
"$",
"echoResponse",
"=",
"TRUE",
",",
"$",
"format",
"=",
"'json'",
")",
"{",
"return",
"self",
"::",
"_doResponse",
"(",
"'failure'",
",",
"$",
"objects",
",",
"$",
"echoResponse",
"... | Create a service response of failure
@param array $objects An object or array of objects
@param bool $echoResponse Whether to echo out of response
@param const $format _ServiceResponse_JSON or _ServiceResponse_XML
@return string The response | [
"Create",
"a",
"service",
"response",
"of",
"failure"
] | e0d584f25093b594e67b8a3068ebd41c7f6483c5 | https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L49-L51 | train |
kengoldfarb/underscore_libs | src/_Libs/_ServiceResponse.php | _ServiceResponse._doResponse | private static function _doResponse($type, $objects, $echoResponse, $format) {
$ret = array();
$ret['status'] = $type;
if (is_array($objects)) {
foreach ($objects as $k => $v) {
$ret[$k] = $v;
}
} else {
$ret[] = $objects;
}
switch ($format) {
case 'xml':
require_once 'XML/Serializer.php';
$options = array(
"indent" => " ",
"linebreak" => "\n",
"typeHints" => false,
"addDecl" => true,
"encoding" => "UTF-8",
"rootName" => "data",
// "rootAttributes" => array("version" => "0.91"),
"defaultTagName" => "item",
"attributesArray" => "_attributes"
);
$serializer = new \XML_Serializer($options);
$rc = $serializer->serialize($ret);
if ($rc !== TRUE) {
}
$ret = $serializer->getSerializedData();
break;
case 'json':
default:
$ret = json_encode($ret);
break;
}
if ($echoResponse) {
echo $ret;
}
return $ret;
} | php | private static function _doResponse($type, $objects, $echoResponse, $format) {
$ret = array();
$ret['status'] = $type;
if (is_array($objects)) {
foreach ($objects as $k => $v) {
$ret[$k] = $v;
}
} else {
$ret[] = $objects;
}
switch ($format) {
case 'xml':
require_once 'XML/Serializer.php';
$options = array(
"indent" => " ",
"linebreak" => "\n",
"typeHints" => false,
"addDecl" => true,
"encoding" => "UTF-8",
"rootName" => "data",
// "rootAttributes" => array("version" => "0.91"),
"defaultTagName" => "item",
"attributesArray" => "_attributes"
);
$serializer = new \XML_Serializer($options);
$rc = $serializer->serialize($ret);
if ($rc !== TRUE) {
}
$ret = $serializer->getSerializedData();
break;
case 'json':
default:
$ret = json_encode($ret);
break;
}
if ($echoResponse) {
echo $ret;
}
return $ret;
} | [
"private",
"static",
"function",
"_doResponse",
"(",
"$",
"type",
",",
"$",
"objects",
",",
"$",
"echoResponse",
",",
"$",
"format",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"ret",
"[",
"'status'",
"]",
"=",
"$",
"type",
";",
"if",
... | Builds the response
@param type $type
@param type $objects
@param type $echoResponse
@param type $format
@return type | [
"Builds",
"the",
"response"
] | e0d584f25093b594e67b8a3068ebd41c7f6483c5 | https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L62-L107 | train |
CatLabInteractive/Neuron | src/Neuron/Config.php | Config.loadFile | private function loadFile ($file)
{
if (!isset ($this->files[$file]))
{
$filename = $this->folder . $file . '.php';
// First load these
if (file_exists ($filename))
{
$this->files[$file] = include ($filename);
}
// Now overload with environment values
if (isset ($this->environment))
{
$filename = $this->folder . $this->environment . '/' . $file . '.php';
if (file_exists ($filename))
{
$this->merge ($file, include ($filename));
}
}
}
} | php | private function loadFile ($file)
{
if (!isset ($this->files[$file]))
{
$filename = $this->folder . $file . '.php';
// First load these
if (file_exists ($filename))
{
$this->files[$file] = include ($filename);
}
// Now overload with environment values
if (isset ($this->environment))
{
$filename = $this->folder . $this->environment . '/' . $file . '.php';
if (file_exists ($filename))
{
$this->merge ($file, include ($filename));
}
}
}
} | [
"private",
"function",
"loadFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"files",
"[",
"$",
"file",
"]",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"folder",
".",
"$",
"file",
".",
"'.php'",
"... | Load a file in case it's not loaded yet.
@param $file | [
"Load",
"a",
"file",
"in",
"case",
"it",
"s",
"not",
"loaded",
"yet",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Config.php#L87-L110 | train |
CatLabInteractive/Neuron | src/Neuron/Config.php | Config.getValue | private function getValue ($name, $default)
{
$parts = explode ('.', $name);
$file = array_shift ($parts);
$this->loadFile ($file);
if (! isset ($this->files[$file])) {
return $default;
}
else {
$out = $this->files[$file];
foreach ($parts as $part)
{
if (!isset ($out[$part]))
{
return $default;
}
else {
$out = $out[$part];
}
}
}
return $out;
} | php | private function getValue ($name, $default)
{
$parts = explode ('.', $name);
$file = array_shift ($parts);
$this->loadFile ($file);
if (! isset ($this->files[$file])) {
return $default;
}
else {
$out = $this->files[$file];
foreach ($parts as $part)
{
if (!isset ($out[$part]))
{
return $default;
}
else {
$out = $out[$part];
}
}
}
return $out;
} | [
"private",
"function",
"getValue",
"(",
"$",
"name",
",",
"$",
"default",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
")",
";",
"$",
"file",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"$",
"this",
"->",
"loadFile",
... | Find a config variable and return it.
@param string $name
@param string $default
@return mixed | [
"Find",
"a",
"config",
"variable",
"and",
"return",
"it",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Config.php#L127-L152 | train |
jepihumet/libs | src/FileManager.php | FileManager.expandDirectories | public function expandDirectories($baseDir) {
$directories = array();
foreach (scandir($baseDir) as $file) {
if ($file == '.' || $file == '..')
continue;
$dir = $baseDir . DS . $file;
if (is_dir($dir)) {
$directories [] = $dir;
$directories = array_merge($directories, $this->expandDirectories($dir));
}
}
return $directories;
} | php | public function expandDirectories($baseDir) {
$directories = array();
foreach (scandir($baseDir) as $file) {
if ($file == '.' || $file == '..')
continue;
$dir = $baseDir . DS . $file;
if (is_dir($dir)) {
$directories [] = $dir;
$directories = array_merge($directories, $this->expandDirectories($dir));
}
}
return $directories;
} | [
"public",
"function",
"expandDirectories",
"(",
"$",
"baseDir",
")",
"{",
"$",
"directories",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"baseDir",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"==",
"'.'",
"||",
... | Recursive function that returns all directories inside a base directory.
@param string $baseDir
@return array | [
"Recursive",
"function",
"that",
"returns",
"all",
"directories",
"inside",
"a",
"base",
"directory",
"."
] | a9c7a25e6b7bfa46ea9d61004273f7e29c40885e | https://github.com/jepihumet/libs/blob/a9c7a25e6b7bfa46ea9d61004273f7e29c40885e/src/FileManager.php#L19-L31 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.register | public function register(Application $app)
{
$this->config = $app['config']->load('log');
$handlers = $this->getHandlers($app);
$app['log'] = $app->share(function ($app) use ($handlers) {
return new Logger('main', $handlers);
});
$app->initializer('Synapse\\Log\\LoggerAwareInterface', function ($object, $app) {
$object->setLogger($app['log']);
return $object;
});
} | php | public function register(Application $app)
{
$this->config = $app['config']->load('log');
$handlers = $this->getHandlers($app);
$app['log'] = $app->share(function ($app) use ($handlers) {
return new Logger('main', $handlers);
});
$app->initializer('Synapse\\Log\\LoggerAwareInterface', function ($object, $app) {
$object->setLogger($app['log']);
return $object;
});
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"load",
"(",
"'log'",
")",
";",
"$",
"handlers",
"=",
"$",
"this",
"->",
"getHandlers",
"(",
"$",
... | Register logging related services
@param Application $app Silex application | [
"Register",
"logging",
"related",
"services"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L39-L52 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.boot | public function boot(Application $app)
{
// Register Monolog error handler for fatal errors here because Symfony's handler overrides it
$monologErrorHandler = new MonologErrorHandler($app['log']);
$monologErrorHandler->registerErrorHandler();
$monologErrorHandler->registerFatalHandler();
} | php | public function boot(Application $app)
{
// Register Monolog error handler for fatal errors here because Symfony's handler overrides it
$monologErrorHandler = new MonologErrorHandler($app['log']);
$monologErrorHandler->registerErrorHandler();
$monologErrorHandler->registerFatalHandler();
} | [
"public",
"function",
"boot",
"(",
"Application",
"$",
"app",
")",
"{",
"// Register Monolog error handler for fatal errors here because Symfony's handler overrides it",
"$",
"monologErrorHandler",
"=",
"new",
"MonologErrorHandler",
"(",
"$",
"app",
"[",
"'log'",
"]",
")",
... | Perform extra chores on boot
@param Application $app | [
"Perform",
"extra",
"chores",
"on",
"boot"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L59-L66 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.getHandlers | protected function getHandlers(Application $app)
{
$handlers = [];
// File Handler
$file = Arr::path($this->config, 'file.path');
if ($file) {
$handlers[] = $this->getFileHandler($file);
$handlers[] = $this->getFileExceptionHandler($file);
}
// Loggly Handler
$enableLoggly = Arr::path($this->config, 'loggly.enable');
if ($enableLoggly) {
$handlers[] = $this->getLogglyHandler();
}
// Rollbar Handler
$enableRollbar = Arr::path($this->config, 'rollbar.enable');
if ($enableRollbar) {
$handlers[] = $this->getRollbarHandler($app['environment']);
}
// Syslog Handler
$syslogIdent = Arr::path($this->config, 'syslog.ident');
if ($syslogIdent) {
$handlers[] = $this->getSyslogHandler($syslogIdent);
}
return $handlers;
} | php | protected function getHandlers(Application $app)
{
$handlers = [];
// File Handler
$file = Arr::path($this->config, 'file.path');
if ($file) {
$handlers[] = $this->getFileHandler($file);
$handlers[] = $this->getFileExceptionHandler($file);
}
// Loggly Handler
$enableLoggly = Arr::path($this->config, 'loggly.enable');
if ($enableLoggly) {
$handlers[] = $this->getLogglyHandler();
}
// Rollbar Handler
$enableRollbar = Arr::path($this->config, 'rollbar.enable');
if ($enableRollbar) {
$handlers[] = $this->getRollbarHandler($app['environment']);
}
// Syslog Handler
$syslogIdent = Arr::path($this->config, 'syslog.ident');
if ($syslogIdent) {
$handlers[] = $this->getSyslogHandler($syslogIdent);
}
return $handlers;
} | [
"protected",
"function",
"getHandlers",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"handlers",
"=",
"[",
"]",
";",
"// File Handler",
"$",
"file",
"=",
"Arr",
"::",
"path",
"(",
"$",
"this",
"->",
"config",
",",
"'file.path'",
")",
";",
"if",
"(",
... | Get an array of logging handlers to use
@param Application $app
@return array | [
"Get",
"an",
"array",
"of",
"logging",
"handlers",
"to",
"use"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L74-L108 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.getFileHandler | protected function getFileHandler($file)
{
$format = '[%datetime%] %channel%.%level_name%: %message% %context% %extra%'.PHP_EOL;
$handler = new StreamHandler($file, Logger::INFO);
$handler->setFormatter(new LineFormatter($format));
return new DummyExceptionHandler($handler);
} | php | protected function getFileHandler($file)
{
$format = '[%datetime%] %channel%.%level_name%: %message% %context% %extra%'.PHP_EOL;
$handler = new StreamHandler($file, Logger::INFO);
$handler->setFormatter(new LineFormatter($format));
return new DummyExceptionHandler($handler);
} | [
"protected",
"function",
"getFileHandler",
"(",
"$",
"file",
")",
"{",
"$",
"format",
"=",
"'[%datetime%] %channel%.%level_name%: %message% %context% %extra%'",
".",
"PHP_EOL",
";",
"$",
"handler",
"=",
"new",
"StreamHandler",
"(",
"$",
"file",
",",
"Logger",
"::",
... | Log handler for files
@param string $file Path of log file
@return DummyExceptionHandler | [
"Log",
"handler",
"for",
"files"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L128-L136 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.getFileExceptionHandler | protected function getFileExceptionHandler($file)
{
$format = '%context.stacktrace%'.PHP_EOL;
$handler = new StreamHandler($file, Logger::ERROR);
$handler->setFormatter(new ExceptionLineFormatter($format));
return $handler;
} | php | protected function getFileExceptionHandler($file)
{
$format = '%context.stacktrace%'.PHP_EOL;
$handler = new StreamHandler($file, Logger::ERROR);
$handler->setFormatter(new ExceptionLineFormatter($format));
return $handler;
} | [
"protected",
"function",
"getFileExceptionHandler",
"(",
"$",
"file",
")",
"{",
"$",
"format",
"=",
"'%context.stacktrace%'",
".",
"PHP_EOL",
";",
"$",
"handler",
"=",
"new",
"StreamHandler",
"(",
"$",
"file",
",",
"Logger",
"::",
"ERROR",
")",
";",
"$",
"... | Exception log handler for files
@param string $file Path of log file
@return StreamHandler | [
"Exception",
"log",
"handler",
"for",
"files"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L144-L152 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.getLogglyHandler | protected function getLogglyHandler()
{
$token = Arr::path($this->config, 'loggly.token');
if (! $token) {
throw new ConfigException('Loggly is enabled but the token is not set.');
}
return new LogglyHandler($token, Logger::INFO);
} | php | protected function getLogglyHandler()
{
$token = Arr::path($this->config, 'loggly.token');
if (! $token) {
throw new ConfigException('Loggly is enabled but the token is not set.');
}
return new LogglyHandler($token, Logger::INFO);
} | [
"protected",
"function",
"getLogglyHandler",
"(",
")",
"{",
"$",
"token",
"=",
"Arr",
"::",
"path",
"(",
"$",
"this",
"->",
"config",
",",
"'loggly.token'",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'Log... | Log handler for Loggly
@return LogglyHandler | [
"Log",
"handler",
"for",
"Loggly"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L159-L168 | train |
synapsestudios/synapse-base | src/Synapse/Log/LogServiceProvider.php | LogServiceProvider.getRollbarHandler | protected function getRollbarHandler($environment)
{
$rollbarConfig = Arr::get($this->config, 'rollbar', []);
return new RollbarHandler($rollbarConfig, $environment);
} | php | protected function getRollbarHandler($environment)
{
$rollbarConfig = Arr::get($this->config, 'rollbar', []);
return new RollbarHandler($rollbarConfig, $environment);
} | [
"protected",
"function",
"getRollbarHandler",
"(",
"$",
"environment",
")",
"{",
"$",
"rollbarConfig",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'rollbar'",
",",
"[",
"]",
")",
";",
"return",
"new",
"RollbarHandler",
"(",
"$",
"rol... | Register log handler for Rollbar
@return RollbarHandler | [
"Register",
"log",
"handler",
"for",
"Rollbar"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L175-L179 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php | Mapper.findRootOf | public function findRootOf( $id )
{
return $this->findOne( array(
'id' => $this->sql()
->select()
->columns( array( 'rootId' ) )
->where( array(
'id' => $id,
) ),
) );
} | php | public function findRootOf( $id )
{
return $this->findOne( array(
'id' => $this->sql()
->select()
->columns( array( 'rootId' ) )
->where( array(
'id' => $id,
) ),
) );
} | [
"public",
"function",
"findRootOf",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"findOne",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"sql",
"(",
")",
"->",
"select",
"(",
")",
"->",
"columns",
"(",
"array",
"(",
"'rootId'",
")"... | Find root paragraph of paragraph by id
@param int $id
@return \Paragraph\Model\Paragraph\StructureInterface | [
"Find",
"root",
"paragraph",
"of",
"paragraph",
"by",
"id"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L706-L716 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php | Mapper.getTagIdByName | private function getTagIdByName( $tag )
{
$tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) );
$select = $tagSql->select()
->columns( array( 'id' ) )
->where( array(
new TypedParameters(
'LOWER(?) = ?',
array(
'name',
mb_strtolower( $tag, 'UTF-8' ),
),
array(
TypedParameters::TYPE_IDENTIFIER,
TypedParameters::TYPE_VALUE,
)
),
) );
$result = $tagSql->prepareStatementForSqlObject( $select )
->execute();
foreach ( $result as $row )
{
return $row['id'];
}
return null;
} | php | private function getTagIdByName( $tag )
{
$tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) );
$select = $tagSql->select()
->columns( array( 'id' ) )
->where( array(
new TypedParameters(
'LOWER(?) = ?',
array(
'name',
mb_strtolower( $tag, 'UTF-8' ),
),
array(
TypedParameters::TYPE_IDENTIFIER,
TypedParameters::TYPE_VALUE,
)
),
) );
$result = $tagSql->prepareStatementForSqlObject( $select )
->execute();
foreach ( $result as $row )
{
return $row['id'];
}
return null;
} | [
"private",
"function",
"getTagIdByName",
"(",
"$",
"tag",
")",
"{",
"$",
"tagSql",
"=",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"getTableInSchema",
"(",
"static",
"::",
"$",
"tagTableName",
")",
")",
";",
"$",
"select",
"=",
"$",
"tagSql",
... | Get tag id by its name
@param string $tag
@return int|null | [
"Get",
"tag",
"id",
"by",
"its",
"name"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1133-L1162 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php | Mapper.setTagFor | protected function setTagFor( $paragraphId, $tag )
{
$rows = 0;
$tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) );
$tagJoinSql = $this->sql( $this->getTableInSchema( static::$tagJoinTableName ) );
$tagId = $this->getTagIdByName( $tag );
if ( empty( $tagId ) )
{
$insert = $tagSql->insert()
->values( array(
'locale' => $this->getLocale(),
'name' => $tag,
) );
$rows += $tagSql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
$tagId = $this->getTagIdByName( $tag );
}
$data = array(
'paragraphId' => $paragraphId,
'tagId' => $tagId,
);
$select = $tagJoinSql->select()
->where( $data );
if ( ! $tagJoinSql->prepareStatementForSqlObject( $select )
->execute()
->getAffectedRows() )
{
$insert = $tagJoinSql->insert()
->values( $data );
$rows += $tagJoinSql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $rows;
} | php | protected function setTagFor( $paragraphId, $tag )
{
$rows = 0;
$tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) );
$tagJoinSql = $this->sql( $this->getTableInSchema( static::$tagJoinTableName ) );
$tagId = $this->getTagIdByName( $tag );
if ( empty( $tagId ) )
{
$insert = $tagSql->insert()
->values( array(
'locale' => $this->getLocale(),
'name' => $tag,
) );
$rows += $tagSql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
$tagId = $this->getTagIdByName( $tag );
}
$data = array(
'paragraphId' => $paragraphId,
'tagId' => $tagId,
);
$select = $tagJoinSql->select()
->where( $data );
if ( ! $tagJoinSql->prepareStatementForSqlObject( $select )
->execute()
->getAffectedRows() )
{
$insert = $tagJoinSql->insert()
->values( $data );
$rows += $tagJoinSql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $rows;
} | [
"protected",
"function",
"setTagFor",
"(",
"$",
"paragraphId",
",",
"$",
"tag",
")",
"{",
"$",
"rows",
"=",
"0",
";",
"$",
"tagSql",
"=",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"getTableInSchema",
"(",
"static",
"::",
"$",
"tagTableName",
... | Set a tag for a paragraph
@param int $paragraphId
@param string $tag
@return int | [
"Set",
"a",
"tag",
"for",
"a",
"paragraph"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1171-L1214 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php | Mapper.saveRawProperties | public function saveRawProperties( $id, $properties )
{
$result = 0;
if ( ! empty( $properties ) )
{
foreach ( $properties as $property )
{
$result += $this->saveProperty(
$id,
empty( $property['locale'] ) ? null : $property['locale'],
empty( $property['name'] ) ? null : $property['name'],
empty( $property['value'] ) ? null : $property['value']
);
}
}
return $result;
} | php | public function saveRawProperties( $id, $properties )
{
$result = 0;
if ( ! empty( $properties ) )
{
foreach ( $properties as $property )
{
$result += $this->saveProperty(
$id,
empty( $property['locale'] ) ? null : $property['locale'],
empty( $property['name'] ) ? null : $property['name'],
empty( $property['value'] ) ? null : $property['value']
);
}
}
return $result;
} | [
"public",
"function",
"saveRawProperties",
"(",
"$",
"id",
",",
"$",
"properties",
")",
"{",
"$",
"result",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"properties",
")",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
... | Save raw paragraph properties
@param int $id
@param array|\Traversable $properties
@return int | [
"Save",
"raw",
"paragraph",
"properties"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1223-L1241 | train |
webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php | Mapper.saveRawData | public function saveRawData( array $data )
{
if ( ! parent::save( $data ) )
{
return null;
}
return isset( $data['id'] ) ? $data['id'] : null;
} | php | public function saveRawData( array $data )
{
if ( ! parent::save( $data ) )
{
return null;
}
return isset( $data['id'] ) ? $data['id'] : null;
} | [
"public",
"function",
"saveRawData",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"parent",
"::",
"save",
"(",
"$",
"data",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"isset",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
"?",
"$",
... | Save paragraph form raw data
@param array $data
@return int|null | [
"Save",
"paragraph",
"form",
"raw",
"data"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1315-L1323 | train |
lbmzorx/yii2-components | src/action/ErrorAction.php | ErrorAction.chooseView | protected function chooseView(){
if($this->guestView){
if(Yii::$app->user->isGuest){
$this->controller->layout=$this->guestLayout;
$this->view=$this->guestView;
}
}
if($this->userView){
if(!Yii::$app->user->isGuest){
$this->controller->layout=$this->userLayout;
$this->view=$this->userView;
}
}
} | php | protected function chooseView(){
if($this->guestView){
if(Yii::$app->user->isGuest){
$this->controller->layout=$this->guestLayout;
$this->view=$this->guestView;
}
}
if($this->userView){
if(!Yii::$app->user->isGuest){
$this->controller->layout=$this->userLayout;
$this->view=$this->userView;
}
}
} | [
"protected",
"function",
"chooseView",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"guestView",
")",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"layout",
"=",
"$",
"this... | select view template of error view by different group | [
"select",
"view",
"template",
"of",
"error",
"view",
"by",
"different",
"group"
] | 0d5344fbaf07ee979942414d2874696273ce7bdd | https://github.com/lbmzorx/yii2-components/blob/0d5344fbaf07ee979942414d2874696273ce7bdd/src/action/ErrorAction.php#L83-L96 | train |
consigliere/components | src/Process/Installer.php | Installer.installViaSubtree | public function installViaSubtree()
{
return new Process(sprintf(
'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s',
base_path(),
$this->getComponentName(),
$this->getRepoUrl(),
$this->getDestinationPath(),
$this->getComponentName(),
$this->getBranch()
));
} | php | public function installViaSubtree()
{
return new Process(sprintf(
'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s',
base_path(),
$this->getComponentName(),
$this->getRepoUrl(),
$this->getDestinationPath(),
$this->getComponentName(),
$this->getBranch()
));
} | [
"public",
"function",
"installViaSubtree",
"(",
")",
"{",
"return",
"new",
"Process",
"(",
"sprintf",
"(",
"'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s'",
",",
"base_path",
"(",
")",
",",
"$",
"this",
"->",
"getComponentName",
"(",
")",
... | Install the component via git subtree.
@return \Symfony\Component\Process\Process | [
"Install",
"the",
"component",
"via",
"git",
"subtree",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Process/Installer.php#L270-L281 | train |
remote-office/libx | src/Cache/Storage/Redis.php | Redis.retrieve | public function retrieve($key)
{
// Get value by key
$value = $this->redis->get($key);
if($value === false)
return null;
return $value;
} | php | public function retrieve($key)
{
// Get value by key
$value = $this->redis->get($key);
if($value === false)
return null;
return $value;
} | [
"public",
"function",
"retrieve",
"(",
"$",
"key",
")",
"{",
"// Get value by key",
"$",
"value",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"return",
"null",
";",
"return",
... | Retrieve value from redis server
@param string $key
@return string | [
"Retrieve",
"value",
"from",
"redis",
"server"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Cache/Storage/Redis.php#L29-L38 | train |
AlcyZ/Alcys-ORM | src/Core/Db/Statement/Insert.php | Insert.values | public function values(array $valuesArray)
{
$this->_checkColumnsArrayIsset()->_checkArraysForSameLength($valuesArray)->_checkValuesArrayType($valuesArray);
$this->values[] = $valuesArray;
return $this;
} | php | public function values(array $valuesArray)
{
$this->_checkColumnsArrayIsset()->_checkArraysForSameLength($valuesArray)->_checkValuesArrayType($valuesArray);
$this->values[] = $valuesArray;
return $this;
} | [
"public",
"function",
"values",
"(",
"array",
"$",
"valuesArray",
")",
"{",
"$",
"this",
"->",
"_checkColumnsArrayIsset",
"(",
")",
"->",
"_checkArraysForSameLength",
"(",
"$",
"valuesArray",
")",
"->",
"_checkValuesArrayType",
"(",
"$",
"valuesArray",
")",
";",... | Validate the passed array and add their values to the insert statement.
The columns method must called before, otherwise an exception will thrown.
@param ReferencesInterface[] $valuesArray
@return $this The same instance to concatenate methods.
@throws \Exception When array does not have the same length like the passed array of the column method,
if column method was not invoke or if element of the passed array is not of type ReferenceInterface | [
"Validate",
"the",
"passed",
"array",
"and",
"add",
"their",
"values",
"to",
"the",
"insert",
"statement",
".",
"The",
"columns",
"method",
"must",
"called",
"before",
"otherwise",
"an",
"exception",
"will",
"thrown",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Statement/Insert.php#L104-L110 | train |
ehough/shortstop | src/main/php/ehough/shortstop/api/HttpRequest.php | ehough_shortstop_api_HttpRequest.setUrl | public final function setUrl($url)
{
if (is_string($url)) {
$this->_url = new ehough_curly_Url($url);
return;
}
if (! $url instanceof ehough_curly_Url) {
throw new ehough_shortstop_api_exception_InvalidArgumentException(
'setUrl() only takes a string or a ehough_curly_Url instance'
);
}
$this->_url = $url;
} | php | public final function setUrl($url)
{
if (is_string($url)) {
$this->_url = new ehough_curly_Url($url);
return;
}
if (! $url instanceof ehough_curly_Url) {
throw new ehough_shortstop_api_exception_InvalidArgumentException(
'setUrl() only takes a string or a ehough_curly_Url instance'
);
}
$this->_url = $url;
} | [
"public",
"final",
"function",
"setUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"_url",
"=",
"new",
"ehough_curly_Url",
"(",
"$",
"url",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
... | Sets the URL of this request.
@param mixed $url The URL of this request.
@throws ehough_shortstop_api_exception_InvalidArgumentException If the given URL is not a valid string URL
or instance of ehough_curly_Url
@return void | [
"Sets",
"the",
"URL",
"of",
"this",
"request",
"."
] | 4cef21457741347546c70e8e5c0cef6d3162b257 | https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/api/HttpRequest.php#L92-L109 | train |
iwyg/template | Engine.php | Engine.getErrFunc | protected function getErrFunc()
{
if (null === $this->errFunc) {
$this->errFunc = function ($errno, $errstr, $errfile, $errline) {
$this->stopErrorHandling();
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
};
}
return $this->errFunc;
} | php | protected function getErrFunc()
{
if (null === $this->errFunc) {
$this->errFunc = function ($errno, $errstr, $errfile, $errline) {
$this->stopErrorHandling();
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
};
}
return $this->errFunc;
} | [
"protected",
"function",
"getErrFunc",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"errFunc",
")",
"{",
"$",
"this",
"->",
"errFunc",
"=",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
... | Get the error handler
@return \Closure | [
"Get",
"the",
"error",
"handler"
] | ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e | https://github.com/iwyg/template/blob/ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e/Engine.php#L548-L558 | train |
ronanchilvers/silex-spot2-provider | src/Application/Spot2Trait.php | Spot2Trait.mapper | public function mapper($entityName)
{
if (!class_exists($entityName)) {
throw new \Exception('Unable to get mapper for unknown entity class '.$entityName);
}
$locator = $this['spot2.locator'];
return $locator->mapper($entityName);
} | php | public function mapper($entityName)
{
if (!class_exists($entityName)) {
throw new \Exception('Unable to get mapper for unknown entity class '.$entityName);
}
$locator = $this['spot2.locator'];
return $locator->mapper($entityName);
} | [
"public",
"function",
"mapper",
"(",
"$",
"entityName",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"entityName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to get mapper for unknown entity class '",
".",
"$",
"entityName",
")",
";... | Get a mapper for a given entity.
@param string $entityName
@return Spot\Mapper
@author Ronan Chilvers <ronan@d3r.com> | [
"Get",
"a",
"mapper",
"for",
"a",
"given",
"entity",
"."
] | 9b13856d9560f13604ad885ee4c94e374d5e3635 | https://github.com/ronanchilvers/silex-spot2-provider/blob/9b13856d9560f13604ad885ee4c94e374d5e3635/src/Application/Spot2Trait.php#L36-L44 | train |
a2c/BaconAclBundle | Controller/ModuleController.php | ModuleController.indexAction | public function indexAction($page, $sort, $direction)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'INDEX')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => '',
]);
$breadcumbs->addItem([
'title' => 'List',
'route' => '',
]);
$entity = new Module();
if ($this->get('session')->has('module_search_session')) {
$objSerialize = $this->get('session')->get('module_search_session');
$entity = unserialize($objSerialize);
}
$query = $this->getDoctrine()->getRepository('BaconAclBundle:Module')->getQueryPagination($entity, $sort, $direction);
$paginator = $this->getPagination($query, $page, Module::PER_PAGE);
$paginator->setUsedRoute('module_pagination');
$form = $this->createForm(ModuleFormType::class, $entity, [
'search' => true,
]);
return [
'pagination' => $paginator,
'form_search' => $form->createView(),
'form_delete' => $this->createDeleteForm()->createView(),
];
} | php | public function indexAction($page, $sort, $direction)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'INDEX')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => '',
]);
$breadcumbs->addItem([
'title' => 'List',
'route' => '',
]);
$entity = new Module();
if ($this->get('session')->has('module_search_session')) {
$objSerialize = $this->get('session')->get('module_search_session');
$entity = unserialize($objSerialize);
}
$query = $this->getDoctrine()->getRepository('BaconAclBundle:Module')->getQueryPagination($entity, $sort, $direction);
$paginator = $this->getPagination($query, $page, Module::PER_PAGE);
$paginator->setUsedRoute('module_pagination');
$form = $this->createForm(ModuleFormType::class, $entity, [
'search' => true,
]);
return [
'pagination' => $paginator,
'form_search' => $form->createView(),
'form_delete' => $this->createDeleteForm()->createView(),
];
} | [
"public",
"function",
"indexAction",
"(",
"$",
"page",
",",
"$",
"sort",
",",
"$",
"direction",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",... | Lists all Module entities.
@Route("/",defaults={"page"=1, "sort"="id", "direction"="asc"}, name="module")
@Route("/page/{page}/sort/{sort}/direction/{direction}/", defaults={"page"=1, "sort"="id", "direction"="asc"}, name="module_pagination")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Lists",
"all",
"Module",
"entities",
"."
] | ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c | https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L32-L73 | train |
a2c/BaconAclBundle | Controller/ModuleController.php | ModuleController.newAction | public function newAction(Request $request)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'NEW')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => 'module',
]);
$breadcumbs->addItem([
'title' => 'New',
'route' => '',
]);
$form = $this->createForm(ModuleFormType::class, new Module());
$form->handleRequest($request);
if ($form->isSubmitted()) {
$handler = new ModuleFormHandler(
$form,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('module'));
}
}
return [
'form' => $form->createView(),
];
} | php | public function newAction(Request $request)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'NEW')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => 'module',
]);
$breadcumbs->addItem([
'title' => 'New',
'route' => '',
]);
$form = $this->createForm(ModuleFormType::class, new Module());
$form->handleRequest($request);
if ($form->isSubmitted()) {
$handler = new ModuleFormHandler(
$form,
$this->getDoctrine()->getManager(),
$this->get('session')->getFlashBag()
);
if ($handler->save()) {
return $this->redirect($this->generateUrl('module'));
}
}
return [
'form' => $form->createView(),
];
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'module'",
",",
"'NEW'",
")",... | Displays a form to create a new Module entity.
@Route("/new", name="module_new")
@Method({"GET", "POST"})
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Module",
"entity",
"."
] | ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c | https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L115-L154 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.