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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ScriptVariableUpdateFactory.php | ScriptVariableUpdateFactory.updateValue | public function updateValue($group, $variableCode, $newValue)
{
$variable = clone $this->getVariable($variableCode);
$variable->setValue($newValue);
if (!isset($this->queuedForUpdate[$group->getName()])) {
$this->queuedForUpdate[$group->getName()]['time'] = microtime(true);
}
$checkVariable = clone $this->checkVariable;
$uniqueId = uniqid('exp_', true);
$checkVariable->setValue("\"$uniqueId\"");
$this->checkWindow->setValue(Builder::escapeText(get_called_class()));
$this->queuedForUpdate[$group->getName()]['group'] = $group;
$this->queuedForUpdate[$group->getName()]['variables'][$variableCode] = $variable;
$this->queuedForUpdate[$group->getName()]['check'] = $checkVariable;
} | php | public function updateValue($group, $variableCode, $newValue)
{
$variable = clone $this->getVariable($variableCode);
$variable->setValue($newValue);
if (!isset($this->queuedForUpdate[$group->getName()])) {
$this->queuedForUpdate[$group->getName()]['time'] = microtime(true);
}
$checkVariable = clone $this->checkVariable;
$uniqueId = uniqid('exp_', true);
$checkVariable->setValue("\"$uniqueId\"");
$this->checkWindow->setValue(Builder::escapeText(get_called_class()));
$this->queuedForUpdate[$group->getName()]['group'] = $group;
$this->queuedForUpdate[$group->getName()]['variables'][$variableCode] = $variable;
$this->queuedForUpdate[$group->getName()]['check'] = $checkVariable;
} | [
"public",
"function",
"updateValue",
"(",
"$",
"group",
",",
"$",
"variableCode",
",",
"$",
"newValue",
")",
"{",
"$",
"variable",
"=",
"clone",
"$",
"this",
"->",
"getVariable",
"(",
"$",
"variableCode",
")",
";",
"$",
"variable",
"->",
"setValue",
"(",... | Update script value.
@param Group $group
@param string $variableCode
@param string $newValue | [
"Update",
"script",
"value",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ScriptVariableUpdateFactory.php#L82-L99 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ScriptVariableUpdateFactory.php | ScriptVariableUpdateFactory.getScriptInitialization | public function getScriptInitialization($defaultValues = false)
{
$scriptContent = '';
foreach ($this->variables as $variable) {
$scriptContent .= $variable->getScriptDeclaration()."\n";
if ($defaultValues) {
$scriptContent .= $variable->getScriptValueSet()."\n";
}
}
$scriptContent .= $this->checkVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkOldVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkWindow->getScriptDeclaration()."\n";
$scriptContent .= "declare check_original = ".$this->checkWindow->getInitialValue().";\n";
if ($defaultValues) {
$scriptContent .= $this->checkVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkOldVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkWindow->getScriptValueSet()."\n";
}
return $scriptContent;
} | php | public function getScriptInitialization($defaultValues = false)
{
$scriptContent = '';
foreach ($this->variables as $variable) {
$scriptContent .= $variable->getScriptDeclaration()."\n";
if ($defaultValues) {
$scriptContent .= $variable->getScriptValueSet()."\n";
}
}
$scriptContent .= $this->checkVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkOldVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkWindow->getScriptDeclaration()."\n";
$scriptContent .= "declare check_original = ".$this->checkWindow->getInitialValue().";\n";
if ($defaultValues) {
$scriptContent .= $this->checkVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkOldVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkWindow->getScriptValueSet()."\n";
}
return $scriptContent;
} | [
"public",
"function",
"getScriptInitialization",
"(",
"$",
"defaultValues",
"=",
"false",
")",
"{",
"$",
"scriptContent",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"variables",
"as",
"$",
"variable",
")",
"{",
"$",
"scriptContent",
".=",
"$",
"var... | Get initialization script.
@param bool $defaultValues
@return string | [
"Get",
"initialization",
"script",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ScriptVariableUpdateFactory.php#L148-L170 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/alchemy/binary-driver/src/Alchemy/BinaryDriver/Listeners/Listeners.php | Listeners.register | public function register(ListenerInterface $listener, EventEmitter $target = null)
{
$EElisteners = array();
if (null !== $target) {
$EElisteners = $this->forwardEvents($listener, $target, $listener->forwardedEvents());
}
$this->storage->attach($listener, $EElisteners);
return $this;
} | php | public function register(ListenerInterface $listener, EventEmitter $target = null)
{
$EElisteners = array();
if (null !== $target) {
$EElisteners = $this->forwardEvents($listener, $target, $listener->forwardedEvents());
}
$this->storage->attach($listener, $EElisteners);
return $this;
} | [
"public",
"function",
"register",
"(",
"ListenerInterface",
"$",
"listener",
",",
"EventEmitter",
"$",
"target",
"=",
"null",
")",
"{",
"$",
"EElisteners",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"target",
")",
"{",
"$",
"EElisteners"... | Registers a listener, pass the listener events to the target.
@param ListenerInterface $listener
@param null|EventEmitter $target
@return ListenersInterface | [
"Registers",
"a",
"listener",
"pass",
"the",
"listener",
"events",
"to",
"the",
"target",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/alchemy/binary-driver/src/Alchemy/BinaryDriver/Listeners/Listeners.php#L33-L44 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/alchemy/binary-driver/src/Alchemy/BinaryDriver/Listeners/Listeners.php | Listeners.unregister | public function unregister(ListenerInterface $listener)
{
if (!isset($this->storage[$listener])) {
throw new InvalidArgumentException('Listener is not registered.');
}
foreach ($this->storage[$listener] as $event => $EElistener) {
$listener->removeListener($event, $EElistener);
}
$this->storage->detach($listener);
return $this;
} | php | public function unregister(ListenerInterface $listener)
{
if (!isset($this->storage[$listener])) {
throw new InvalidArgumentException('Listener is not registered.');
}
foreach ($this->storage[$listener] as $event => $EElistener) {
$listener->removeListener($event, $EElistener);
}
$this->storage->detach($listener);
return $this;
} | [
"public",
"function",
"unregister",
"(",
"ListenerInterface",
"$",
"listener",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"storage",
"[",
"$",
"listener",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Listener is not ... | Unregisters a listener, removes the listener events from the target.
@param ListenerInterface $listener
@return ListenersInterface
@throws InvalidArgumentException In case the listener is not registered | [
"Unregisters",
"a",
"listener",
"removes",
"the",
"listener",
"events",
"from",
"the",
"target",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/alchemy/binary-driver/src/Alchemy/BinaryDriver/Listeners/Listeners.php#L55-L68 | train |
anklimsk/cakephp-theme | Controller/Component/ThemeComponent.php | ThemeComponent._setLayout | protected function _setLayout(Controller &$controller) {
if ($controller->name == 'CakeError') {
$controller->layout = 'CakeTheme.error';
return;
}
$isAjax = $controller->request->is('ajax');
$isPjax = $controller->request->is('pjax');
$isHtml = $this->_controller->ViewExtension->isHtml();
if ($isPjax) {
$controller->layout = 'CakeTheme.pjax';
} elseif ($isHtml && !$isAjax) {
if ($controller->request->param('controller') === 'users') {
$controller->layout = 'CakeTheme.login';
} else {
if ($controller->layout === 'default') {
$controller->layout = 'CakeTheme.main';
}
}
}
} | php | protected function _setLayout(Controller &$controller) {
if ($controller->name == 'CakeError') {
$controller->layout = 'CakeTheme.error';
return;
}
$isAjax = $controller->request->is('ajax');
$isPjax = $controller->request->is('pjax');
$isHtml = $this->_controller->ViewExtension->isHtml();
if ($isPjax) {
$controller->layout = 'CakeTheme.pjax';
} elseif ($isHtml && !$isAjax) {
if ($controller->request->param('controller') === 'users') {
$controller->layout = 'CakeTheme.login';
} else {
if ($controller->layout === 'default') {
$controller->layout = 'CakeTheme.main';
}
}
}
} | [
"protected",
"function",
"_setLayout",
"(",
"Controller",
"&",
"$",
"controller",
")",
"{",
"if",
"(",
"$",
"controller",
"->",
"name",
"==",
"'CakeError'",
")",
"{",
"$",
"controller",
"->",
"layout",
"=",
"'CakeTheme.error'",
";",
"return",
";",
"}",
"$"... | Sets the layer depending on the request
@param Controller &$controller Instantiating controller
@return void | [
"Sets",
"the",
"layer",
"depending",
"on",
"the",
"request"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ThemeComponent.php#L105-L126 | train |
anklimsk/cakephp-theme | Controller/Component/ThemeComponent.php | ThemeComponent._setConfigVar | protected function _setConfigVar(Controller &$controller) {
$additionalCssFiles = $this->_modelConfigTheme->getListCssFiles();
$additionalJsFiles = $this->_modelConfigTheme->getListJsFiles();
$controller->set(compact('additionalCssFiles', 'additionalJsFiles'));
} | php | protected function _setConfigVar(Controller &$controller) {
$additionalCssFiles = $this->_modelConfigTheme->getListCssFiles();
$additionalJsFiles = $this->_modelConfigTheme->getListJsFiles();
$controller->set(compact('additionalCssFiles', 'additionalJsFiles'));
} | [
"protected",
"function",
"_setConfigVar",
"(",
"Controller",
"&",
"$",
"controller",
")",
"{",
"$",
"additionalCssFiles",
"=",
"$",
"this",
"->",
"_modelConfigTheme",
"->",
"getListCssFiles",
"(",
")",
";",
"$",
"additionalJsFiles",
"=",
"$",
"this",
"->",
"_m... | Set global variable of used plugins
Set global variable:
- `additionalCssFiles`: List of additional CSS files;
- `additionalJsFiles`: List of additional JS files.
@param Controller &$controller Instantiating controller
@return void | [
"Set",
"global",
"variable",
"of",
"used",
"plugins"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/Component/ThemeComponent.php#L138-L142 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByLogin | public function filterByLogin($login = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($login)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LOGIN, $login, $comparison);
} | php | public function filterByLogin($login = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($login)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LOGIN, $login, $comparison);
} | [
"public",
"function",
"filterByLogin",
"(",
"$",
"login",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"login",
")",
")",
"{",
"$",
"comparison",
... | Filter the query on the login column
Example usage:
<code>
$query->filterByLogin('fooValue'); // WHERE login = 'fooValue'
$query->filterByLogin('%fooValue%', Criteria::LIKE); // WHERE login LIKE '%fooValue%'
</code>
@param string $login The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"login",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L338-L347 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByNickname | public function filterByNickname($nickname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nickname)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME, $nickname, $comparison);
} | php | public function filterByNickname($nickname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nickname)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME, $nickname, $comparison);
} | [
"public",
"function",
"filterByNickname",
"(",
"$",
"nickname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"nickname",
")",
")",
"{",
"$",
"compa... | Filter the query on the nickname column
Example usage:
<code>
$query->filterByNickname('fooValue'); // WHERE nickname = 'fooValue'
$query->filterByNickname('%fooValue%', Criteria::LIKE); // WHERE nickname LIKE '%fooValue%'
</code>
@param string $nickname The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"nickname",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L363-L372 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByNicknameStripped | public function filterByNicknameStripped($nicknameStripped = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nicknameStripped)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME_STRIPPED, $nicknameStripped, $comparison);
} | php | public function filterByNicknameStripped($nicknameStripped = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nicknameStripped)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME_STRIPPED, $nicknameStripped, $comparison);
} | [
"public",
"function",
"filterByNicknameStripped",
"(",
"$",
"nicknameStripped",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"nicknameStripped",
")",
")"... | Filter the query on the nickname_stripped column
Example usage:
<code>
$query->filterByNicknameStripped('fooValue'); // WHERE nickname_stripped = 'fooValue'
$query->filterByNicknameStripped('%fooValue%', Criteria::LIKE); // WHERE nickname_stripped LIKE '%fooValue%'
</code>
@param string $nicknameStripped The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"nickname_stripped",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L388-L397 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByPath | public function filterByPath($path = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($path)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_PATH, $path, $comparison);
} | php | public function filterByPath($path = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($path)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_PATH, $path, $comparison);
} | [
"public",
"function",
"filterByPath",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"comparison",
"=... | Filter the query on the path column
Example usage:
<code>
$query->filterByPath('fooValue'); // WHERE path = 'fooValue'
$query->filterByPath('%fooValue%', Criteria::LIKE); // WHERE path LIKE '%fooValue%'
</code>
@param string $path The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"path",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L413-L422 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByWins | public function filterByWins($wins = null, $comparison = null)
{
if (is_array($wins)) {
$useMinMax = false;
if (isset($wins['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($wins['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_WINS, $wins, $comparison);
} | php | public function filterByWins($wins = null, $comparison = null)
{
if (is_array($wins)) {
$useMinMax = false;
if (isset($wins['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($wins['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_WINS, $wins, $comparison);
} | [
"public",
"function",
"filterByWins",
"(",
"$",
"wins",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"wins",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"wins",
... | Filter the query on the wins column
Example usage:
<code>
$query->filterByWins(1234); // WHERE wins = 1234
$query->filterByWins(array(12, 34)); // WHERE wins IN (12, 34)
$query->filterByWins(array('min' => 12)); // WHERE wins > 12
</code>
@param mixed $wins The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"wins",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L442-L463 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByOnlineTime | public function filterByOnlineTime($onlineTime = null, $comparison = null)
{
if (is_array($onlineTime)) {
$useMinMax = false;
if (isset($onlineTime['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($onlineTime['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime, $comparison);
} | php | public function filterByOnlineTime($onlineTime = null, $comparison = null)
{
if (is_array($onlineTime)) {
$useMinMax = false;
if (isset($onlineTime['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($onlineTime['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime, $comparison);
} | [
"public",
"function",
"filterByOnlineTime",
"(",
"$",
"onlineTime",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"onlineTime",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
... | Filter the query on the online_time column
Example usage:
<code>
$query->filterByOnlineTime(1234); // WHERE online_time = 1234
$query->filterByOnlineTime(array(12, 34)); // WHERE online_time IN (12, 34)
$query->filterByOnlineTime(array('min' => 12)); // WHERE online_time > 12
</code>
@param mixed $onlineTime The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"online_time",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L483-L504 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByLastOnline | public function filterByLastOnline($lastOnline = null, $comparison = null)
{
if (is_array($lastOnline)) {
$useMinMax = false;
if (isset($lastOnline['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastOnline['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline, $comparison);
} | php | public function filterByLastOnline($lastOnline = null, $comparison = null)
{
if (is_array($lastOnline)) {
$useMinMax = false;
if (isset($lastOnline['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastOnline['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline, $comparison);
} | [
"public",
"function",
"filterByLastOnline",
"(",
"$",
"lastOnline",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lastOnline",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
... | Filter the query on the last_online column
Example usage:
<code>
$query->filterByLastOnline('2011-03-14'); // WHERE last_online = '2011-03-14'
$query->filterByLastOnline('now'); // WHERE last_online = '2011-03-14'
$query->filterByLastOnline(array('max' => 'yesterday')); // WHERE last_online > '2011-03-13'
</code>
@param mixed $lastOnline The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"last_online",
"column"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L526-L547 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.filterByRecord | public function filterByRecord($record, $comparison = null)
{
if ($record instanceof \eXpansion\Bundle\LocalRecords\Model\Record) {
return $this
->addUsingAlias(PlayerTableMap::COL_ID, $record->getPlayerId(), $comparison);
} elseif ($record instanceof ObjectCollection) {
return $this
->useRecordQuery()
->filterByPrimaryKeys($record->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByRecord() only accepts arguments of type \eXpansion\Bundle\LocalRecords\Model\Record or Collection');
}
} | php | public function filterByRecord($record, $comparison = null)
{
if ($record instanceof \eXpansion\Bundle\LocalRecords\Model\Record) {
return $this
->addUsingAlias(PlayerTableMap::COL_ID, $record->getPlayerId(), $comparison);
} elseif ($record instanceof ObjectCollection) {
return $this
->useRecordQuery()
->filterByPrimaryKeys($record->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByRecord() only accepts arguments of type \eXpansion\Bundle\LocalRecords\Model\Record or Collection');
}
} | [
"public",
"function",
"filterByRecord",
"(",
"$",
"record",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"record",
"instanceof",
"\\",
"eXpansion",
"\\",
"Bundle",
"\\",
"LocalRecords",
"\\",
"Model",
"\\",
"Record",
")",
"{",
"return",
... | Filter the query by a related \eXpansion\Bundle\LocalRecords\Model\Record object
@param \eXpansion\Bundle\LocalRecords\Model\Record|ObjectCollection $record the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildPlayerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"eXpansion",
"\\",
"Bundle",
"\\",
"LocalRecords",
"\\",
"Model",
"\\",
"Record",
"object"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L557-L570 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php | PlayerQuery.useRecordQuery | public function useRecordQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRecord($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Record', '\eXpansion\Bundle\LocalRecords\Model\RecordQuery');
} | php | public function useRecordQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRecord($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Record', '\eXpansion\Bundle\LocalRecords\Model\RecordQuery');
} | [
"public",
"function",
"useRecordQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinRecord",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"use... | Use the Record relation Record object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \eXpansion\Bundle\LocalRecords\Model\RecordQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"Record",
"relation",
"Record",
"object"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/PlayerQuery.php#L615-L620 | train |
Corviz/framework | src/Mvc/View.php | View.draw | public function draw()
{
$file = Application::current()->getDirectory();
$file .= "views/{$this->templateName}.";
$file .= self::$extension;
if (!file_exists($file)) {
throw new Exception("Template file not found: $file");
}
return $this->templateEngine->draw(
$file, $this->data
);
} | php | public function draw()
{
$file = Application::current()->getDirectory();
$file .= "views/{$this->templateName}.";
$file .= self::$extension;
if (!file_exists($file)) {
throw new Exception("Template file not found: $file");
}
return $this->templateEngine->draw(
$file, $this->data
);
} | [
"public",
"function",
"draw",
"(",
")",
"{",
"$",
"file",
"=",
"Application",
"::",
"current",
"(",
")",
"->",
"getDirectory",
"(",
")",
";",
"$",
"file",
".=",
"\"views/{$this->templateName}.\"",
";",
"$",
"file",
".=",
"self",
"::",
"$",
"extension",
"... | Draw a template using application defined
template engine.
@throws \Exception
@return string | [
"Draw",
"a",
"template",
"using",
"application",
"defined",
"template",
"engine",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/View.php#L47-L60 | train |
eXpansionPluginPack/eXpansion2 | src_experimantal/eXpansionExperimantal/Bundle/Dedimania/Classes/Webaccess.php | WebaccessUrl._bad | public function _bad($errstr, $isbad = true)
{
global $_web_access_retry_timeout;
$this->console->writeln($this->_webaccess_str.'$f00'.$errstr);
if ($this->_socket) {
@fclose($this->_socket);
}
$this->_socket = null;
if ($isbad) {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'BAD';
}
$this->_state = 'BAD';
$this->_bad_time = time();
if ($this->_bad_timeout < $_web_access_retry_timeout) {
$this->_bad_timeout = $_web_access_retry_timeout;
} else {
$this->_bad_timeout *= 2;
}
} else {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'OPEN';
}
$this->_state = 'CLOSED';
}
$this->_callCallback($this->_webaccess_str.$errstr);
} | php | public function _bad($errstr, $isbad = true)
{
global $_web_access_retry_timeout;
$this->console->writeln($this->_webaccess_str.'$f00'.$errstr);
if ($this->_socket) {
@fclose($this->_socket);
}
$this->_socket = null;
if ($isbad) {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'BAD';
}
$this->_state = 'BAD';
$this->_bad_time = time();
if ($this->_bad_timeout < $_web_access_retry_timeout) {
$this->_bad_timeout = $_web_access_retry_timeout;
} else {
$this->_bad_timeout *= 2;
}
} else {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'OPEN';
}
$this->_state = 'CLOSED';
}
$this->_callCallback($this->_webaccess_str.$errstr);
} | [
"public",
"function",
"_bad",
"(",
"$",
"errstr",
",",
"$",
"isbad",
"=",
"true",
")",
"{",
"global",
"$",
"_web_access_retry_timeout",
";",
"$",
"this",
"->",
"console",
"->",
"writeln",
"(",
"$",
"this",
"->",
"_webaccess_str",
".",
"'$f00'",
".",
"$",... | put connection in BAD state | [
"put",
"connection",
"in",
"BAD",
"state"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src_experimantal/eXpansionExperimantal/Bundle/Dedimania/Classes/Webaccess.php#L481-L511 | train |
Celarius/spin-framework | src/Database/PdoConnection.php | PdoConnection.rawQuery | public function rawQuery(string $sql, array $params=[]): array
{
$rows = [];
# Sanity check
if (empty($sql)) {
return $rows;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
}
# Close the cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $rows;
} | php | public function rawQuery(string $sql, array $params=[]): array
{
$rows = [];
# Sanity check
if (empty($sql)) {
return $rows;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
}
# Close the cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $rows;
} | [
"public",
"function",
"rawQuery",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"rows",
"=",
"[",
"]",
";",
"# Sanity check",
"if",
"(",
"empty",
"(",
"$",
"sql",
")",
")",
"{",
"return",
"$",... | Execute a SELECT statement
@param string $sql SQL statement to execute (SELECT ...)
@param array $params Bind params
@return array Array with fetched rows | [
"Execute",
"a",
"SELECT",
"statement"
] | 2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0 | https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Database/PdoConnection.php#L503-L536 | train |
Celarius/spin-framework | src/Database/PdoConnection.php | PdoConnection.rawExec | public function rawExec(string $sql, array $params=[]): bool
{
$result = false;
# Sanity check
if (empty($sql)) {
return $result;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$result = $sth->rowCount() > 0;
}
# Close cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $result;
} | php | public function rawExec(string $sql, array $params=[]): bool
{
$result = false;
# Sanity check
if (empty($sql)) {
return $result;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$result = $sth->rowCount() > 0;
}
# Close cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $result;
} | [
"public",
"function",
"rawExec",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"result",
"=",
"false",
";",
"# Sanity check",
"if",
"(",
"empty",
"(",
"$",
"sql",
")",
")",
"{",
"return",
"$",
... | Execute an INSERT, UPDATE or DELETE statement
@param string $sql SQL statement to execute (INSERT, UPDATE,
DELETE ...)
@param array $params Bind params
@return bool True if rows affected > 0 | [
"Execute",
"an",
"INSERT",
"UPDATE",
"or",
"DELETE",
"statement"
] | 2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0 | https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Database/PdoConnection.php#L547-L579 | train |
pauci/cqrs | src/EventHandling/EventHandlerLocator.php | EventHandlerLocator.get | public function get($eventType)
{
$handlers = array_merge_recursive(
array_key_exists($eventType, $this->handlers) ? $this->handlers[$eventType] : [],
array_key_exists('*', $this->handlers) ? $this->handlers['*'] : []
);
krsort($handlers, SORT_NUMERIC);
$eventHandlers = [];
foreach ($handlers as $priority => $handlersByPriority) {
foreach ($handlersByPriority as $handler) {
if ($this->resolver) {
$handler = call_user_func($this->resolver, $handler, $eventType);
}
$eventHandlers[] = $handler;
}
}
return $eventHandlers;
} | php | public function get($eventType)
{
$handlers = array_merge_recursive(
array_key_exists($eventType, $this->handlers) ? $this->handlers[$eventType] : [],
array_key_exists('*', $this->handlers) ? $this->handlers['*'] : []
);
krsort($handlers, SORT_NUMERIC);
$eventHandlers = [];
foreach ($handlers as $priority => $handlersByPriority) {
foreach ($handlersByPriority as $handler) {
if ($this->resolver) {
$handler = call_user_func($this->resolver, $handler, $eventType);
}
$eventHandlers[] = $handler;
}
}
return $eventHandlers;
} | [
"public",
"function",
"get",
"(",
"$",
"eventType",
")",
"{",
"$",
"handlers",
"=",
"array_merge_recursive",
"(",
"array_key_exists",
"(",
"$",
"eventType",
",",
"$",
"this",
"->",
"handlers",
")",
"?",
"$",
"this",
"->",
"handlers",
"[",
"$",
"eventType",... | Returns an array of event handlers sorted by priority from highest to lowest
@param string $eventType
@return callable[] | [
"Returns",
"an",
"array",
"of",
"event",
"handlers",
"sorted",
"by",
"priority",
"from",
"highest",
"to",
"lowest"
] | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/EventHandling/EventHandlerLocator.php#L131-L153 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Analytics.php | Analytics.handshake | protected function handshake()
{
$key = &$this->key;
$lastPing = &$this->lastPing;
$that = $this;
$logger = $this->logger;
$query = http_build_query(
['login' => $this->gameData->getSystemInfo()->serverLogin]
);
$url = $this->handshakeUrl . '?' . $query;
$lastPing = time();
$this->logger->debug("[eXpansion analytics]Starting handshake");
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$key, &$lastPing, $logger, $that) {
$key = null;
if ($result->getHttpCode() != '200') {
$logger->debug('[eXpansion analytics]Handshake failed', ['http_code' => $result->getHttpCode()]);
return;
}
$json = json_decode($result->getResponse());
if (isset($json->key) && !empty($json->key)) {
$logger->debug('[eXpansion analytics]Handshake successfull', ['key' => $json->key]);
$key = $json->key;
$that->ping();
// allow ping just after handshake.
$lastPing = 0;
}
}
);
} | php | protected function handshake()
{
$key = &$this->key;
$lastPing = &$this->lastPing;
$that = $this;
$logger = $this->logger;
$query = http_build_query(
['login' => $this->gameData->getSystemInfo()->serverLogin]
);
$url = $this->handshakeUrl . '?' . $query;
$lastPing = time();
$this->logger->debug("[eXpansion analytics]Starting handshake");
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$key, &$lastPing, $logger, $that) {
$key = null;
if ($result->getHttpCode() != '200') {
$logger->debug('[eXpansion analytics]Handshake failed', ['http_code' => $result->getHttpCode()]);
return;
}
$json = json_decode($result->getResponse());
if (isset($json->key) && !empty($json->key)) {
$logger->debug('[eXpansion analytics]Handshake successfull', ['key' => $json->key]);
$key = $json->key;
$that->ping();
// allow ping just after handshake.
$lastPing = 0;
}
}
);
} | [
"protected",
"function",
"handshake",
"(",
")",
"{",
"$",
"key",
"=",
"&",
"$",
"this",
"->",
"key",
";",
"$",
"lastPing",
"=",
"&",
"$",
"this",
"->",
"lastPing",
";",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"logger",
"=",
"$",
"this",
"->",
... | Handshake with analytics tool! | [
"Handshake",
"with",
"analytics",
"tool!"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Analytics.php#L110-L148 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Analytics.php | Analytics.ping | public function ping()
{
if (!$this->key || $this->operationInProgress || (time() - $this->lastPing) < $this->pingInterval) {
// Attempt a new handshake.
if (is_null($this->key) && (time() - $this->lastPing) > $this->retryInterval) {
$this->lastPing = time();
$this->handshake();
}
return;
}
$data = $this->getBasePingData();
$query = http_build_query(
$data
);
$url = $this->pingUrl . '?' . $query;
$this->operationInProgress = true;
$this->lastPing = time();
$operationInProgress = &$this->operationInProgress;
$key = &$this->key;
$logger = $this->logger;
$logger->debug('[eXpansion analytics]Starting ping');
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$operationInProgress, &$key, $logger) {
if ($result->getHttpCode() == '200') {
$operationInProgress = false;
$logger->debug('[eXpansion analytics]Ping successfull');
} else {
$logger->debug('[eXpansion analytics]Ping failed', ['http_code' => $result->getHttpCode(), 'result' => $result->getResponse()]);
$key = null;
}
}
);
} | php | public function ping()
{
if (!$this->key || $this->operationInProgress || (time() - $this->lastPing) < $this->pingInterval) {
// Attempt a new handshake.
if (is_null($this->key) && (time() - $this->lastPing) > $this->retryInterval) {
$this->lastPing = time();
$this->handshake();
}
return;
}
$data = $this->getBasePingData();
$query = http_build_query(
$data
);
$url = $this->pingUrl . '?' . $query;
$this->operationInProgress = true;
$this->lastPing = time();
$operationInProgress = &$this->operationInProgress;
$key = &$this->key;
$logger = $this->logger;
$logger->debug('[eXpansion analytics]Starting ping');
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$operationInProgress, &$key, $logger) {
if ($result->getHttpCode() == '200') {
$operationInProgress = false;
$logger->debug('[eXpansion analytics]Ping successfull');
} else {
$logger->debug('[eXpansion analytics]Ping failed', ['http_code' => $result->getHttpCode(), 'result' => $result->getResponse()]);
$key = null;
}
}
);
} | [
"public",
"function",
"ping",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"key",
"||",
"$",
"this",
"->",
"operationInProgress",
"||",
"(",
"time",
"(",
")",
"-",
"$",
"this",
"->",
"lastPing",
")",
"<",
"$",
"this",
"->",
"pingInterval",
")"... | Ping the analytics server with proper information. | [
"Ping",
"the",
"analytics",
"server",
"with",
"proper",
"information",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Analytics.php#L153-L191 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Analytics.php | Analytics.getBasePingData | protected function getBasePingData()
{
return [
'key' => $this->key,
'nbPlayers' => count($this->playerStorage->getOnline()),
'country' => $this->countries->getIsoAlpha2FromName($this->countries->parseCountryFromPath($this->gameData->getServerPath())),
'version' => Application::EXPANSION_VERSION,
'php_version' => $this->gameData->getServerCleanPhpVersion(),
'php_version_short' => $this->gameData->getServerMajorPhpVersion(),
'mysql_version' => 'unknown',
'memory' => memory_get_usage(),
'memory_peak' => memory_get_peak_usage(),
'title' => str_replace('@','_by_', $this->gameData->getVersion()->titleId),
'game' => $this->gameData->getTitleGame(),
'mode' => strtolower($this->gameData->getGameInfos()->scriptName),
'serverOs' => $this->gameData->getServerOs(),
];
} | php | protected function getBasePingData()
{
return [
'key' => $this->key,
'nbPlayers' => count($this->playerStorage->getOnline()),
'country' => $this->countries->getIsoAlpha2FromName($this->countries->parseCountryFromPath($this->gameData->getServerPath())),
'version' => Application::EXPANSION_VERSION,
'php_version' => $this->gameData->getServerCleanPhpVersion(),
'php_version_short' => $this->gameData->getServerMajorPhpVersion(),
'mysql_version' => 'unknown',
'memory' => memory_get_usage(),
'memory_peak' => memory_get_peak_usage(),
'title' => str_replace('@','_by_', $this->gameData->getVersion()->titleId),
'game' => $this->gameData->getTitleGame(),
'mode' => strtolower($this->gameData->getGameInfos()->scriptName),
'serverOs' => $this->gameData->getServerOs(),
];
} | [
"protected",
"function",
"getBasePingData",
"(",
")",
"{",
"return",
"[",
"'key'",
"=>",
"$",
"this",
"->",
"key",
",",
"'nbPlayers'",
"=>",
"count",
"(",
"$",
"this",
"->",
"playerStorage",
"->",
"getOnline",
"(",
")",
")",
",",
"'country'",
"=>",
"$",
... | Get base data for pinging the server.
@return array | [
"Get",
"base",
"data",
"for",
"pinging",
"the",
"server",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Analytics.php#L198-L215 | train |
JBZoo/Html | src/Render/Datalist.php | Datalist.render | public function render(array $data, array $attrs = array())
{
$output = array();
$attrs = array_merge(array('class' => 'uk-description-list-horizontal'), $attrs);
$attrs = $this->_mergeAttr($attrs, $this->_jbSrt('data-list'));
$output[] = '<dl ' . $this->buildAttrs($attrs) . '>';
foreach ($data as $label => $text) {
$label = $this->_translate($label);
$output[] = '<dt title="' . $this->_cleanValue($label) . '">' . $label . '</dt>';
$output[] = '<dd>' . $text . '</dd>';
}
$output[] = '</dl>';
return implode('', $output);
} | php | public function render(array $data, array $attrs = array())
{
$output = array();
$attrs = array_merge(array('class' => 'uk-description-list-horizontal'), $attrs);
$attrs = $this->_mergeAttr($attrs, $this->_jbSrt('data-list'));
$output[] = '<dl ' . $this->buildAttrs($attrs) . '>';
foreach ($data as $label => $text) {
$label = $this->_translate($label);
$output[] = '<dt title="' . $this->_cleanValue($label) . '">' . $label . '</dt>';
$output[] = '<dd>' . $text . '</dd>';
}
$output[] = '</dl>';
return implode('', $output);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"attrs",
"=",
"array_merge",
"(",
"array",
"(",
"'class'",
"=>",
"'uk-descriptio... | Create data list.
@param array $data
@param array $attrs
@return string | [
"Create",
"data",
"list",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Datalist.php#L33-L50 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Notifications/Plugins/Gui/NotificationUpdater.php | NotificationUpdater.getTranslations | private function getTranslations($string, $params)
{
$out = [];
$messages = $this->translationsHelper->getTranslations($string, $params);
foreach ($messages as $message) {
$out[$message['Lang']] = $message['Text'];
}
return $out;
} | php | private function getTranslations($string, $params)
{
$out = [];
$messages = $this->translationsHelper->getTranslations($string, $params);
foreach ($messages as $message) {
$out[$message['Lang']] = $message['Text'];
}
return $out;
} | [
"private",
"function",
"getTranslations",
"(",
"$",
"string",
",",
"$",
"params",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"$",
"messages",
"=",
"$",
"this",
"->",
"translationsHelper",
"->",
"getTranslations",
"(",
"$",
"string",
",",
"$",
"params",
... | Generates the needed data structure
@param $string
@param $params
@return array | [
"Generates",
"the",
"needed",
"data",
"structure"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Notifications/Plugins/Gui/NotificationUpdater.php#L69-L78 | train |
dazzle-php/throwable | src/Throwable/ThrowableProxy.php | ThrowableProxy.toThrowable | public function toThrowable()
{
$class = $this->class;
$prev = $this->prev !== null ? $this->prev->toThrowable() : $this->prev;
return new $class($this->message, 0, $prev);
} | php | public function toThrowable()
{
$class = $this->class;
$prev = $this->prev !== null ? $this->prev->toThrowable() : $this->prev;
return new $class($this->message, 0, $prev);
} | [
"public",
"function",
"toThrowable",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"$",
"prev",
"=",
"$",
"this",
"->",
"prev",
"!==",
"null",
"?",
"$",
"this",
"->",
"prev",
"->",
"toThrowable",
"(",
")",
":",
"$",
"this",
"... | Return proxied Throwable.
@return \Error|\Exception | [
"Return",
"proxied",
"Throwable",
"."
] | daeec7b8857763765db686412886831704720bd0 | https://github.com/dazzle-php/throwable/blob/daeec7b8857763765db686412886831704720bd0/src/Throwable/ThrowableProxy.php#L108-L114 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.setStartDay | public function setStartDay($daysBack)
{
if (!is_null($daysBack)) {
$this->addStatusMessage('Start Date '.date('Y-m-d',
mktime(0, 0, 0, date("m"), date("d") - $daysBack, date("Y"))));
}
$this->daysBack = $daysBack;
} | php | public function setStartDay($daysBack)
{
if (!is_null($daysBack)) {
$this->addStatusMessage('Start Date '.date('Y-m-d',
mktime(0, 0, 0, date("m"), date("d") - $daysBack, date("Y"))));
}
$this->daysBack = $daysBack;
} | [
"public",
"function",
"setStartDay",
"(",
"$",
"daysBack",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"daysBack",
")",
")",
"{",
"$",
"this",
"->",
"addStatusMessage",
"(",
"'Start Date '",
".",
"date",
"(",
"'Y-m-d'",
",",
"mktime",
"(",
"0",
",",... | Start set date
@param int $daysBack | [
"Start",
"set",
"date"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L63-L70 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.getInvoicer | public function getInvoicer()
{
if (!is_object($this->invoicer)) {
$this->invoicer = new \FlexiPeeHP\FakturaVydana(null, $this->config);
}
return $this->invoicer;
} | php | public function getInvoicer()
{
if (!is_object($this->invoicer)) {
$this->invoicer = new \FlexiPeeHP\FakturaVydana(null, $this->config);
}
return $this->invoicer;
} | [
"public",
"function",
"getInvoicer",
"(",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"invoicer",
")",
")",
"{",
"$",
"this",
"->",
"invoicer",
"=",
"new",
"\\",
"FlexiPeeHP",
"\\",
"FakturaVydana",
"(",
"null",
",",
"$",
"this",
"... | Prepare invoice helper
@return \FlexiPeeHP\FakturaVydana | [
"Prepare",
"invoice",
"helper"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L76-L82 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.getPaymentsToProcess | public function getPaymentsToProcess($daysBack = 1, $direction = 'in')
{
$result = [];
$this->banker->defaultUrlParams['order'] = 'datVyst@A';
$payments = $this->banker->getColumnsFromFlexibee([
'id',
'kod',
'varSym',
'specSym',
'sumCelkem',
'buc',
'smerKod',
'mena',
'datVyst'],
["sparovano eq false AND typPohybuK eq '".(($direction == 'out') ? 'typPohybu.vydej'
: 'typPohybu.prijem' )."' AND storno eq false ".
(is_null($daysBack) ? '' :
"AND datVyst eq '".\FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate(mktime(0,
0, 0, date("m"), date("d") - $daysBack, date("Y")))."' ")
], 'id');
if ($this->banker->lastResponseCode == 200) {
if (empty($payments)) {
$result = [];
} else {
$result = $payments;
}
}
return $result;
} | php | public function getPaymentsToProcess($daysBack = 1, $direction = 'in')
{
$result = [];
$this->banker->defaultUrlParams['order'] = 'datVyst@A';
$payments = $this->banker->getColumnsFromFlexibee([
'id',
'kod',
'varSym',
'specSym',
'sumCelkem',
'buc',
'smerKod',
'mena',
'datVyst'],
["sparovano eq false AND typPohybuK eq '".(($direction == 'out') ? 'typPohybu.vydej'
: 'typPohybu.prijem' )."' AND storno eq false ".
(is_null($daysBack) ? '' :
"AND datVyst eq '".\FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate(mktime(0,
0, 0, date("m"), date("d") - $daysBack, date("Y")))."' ")
], 'id');
if ($this->banker->lastResponseCode == 200) {
if (empty($payments)) {
$result = [];
} else {
$result = $payments;
}
}
return $result;
} | [
"public",
"function",
"getPaymentsToProcess",
"(",
"$",
"daysBack",
"=",
"1",
",",
"$",
"direction",
"=",
"'in'",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"banker",
"->",
"defaultUrlParams",
"[",
"'order'",
"]",
"=",
"'datVyst@A'",... | Get unmatched payments within given days and direction
@param int $daysBack Maximum age of payment
@param string $direction Incoming or outcoming payents in|out
@return array | [
"Get",
"unmatched",
"payments",
"within",
"given",
"days",
"and",
"direction"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L92-L121 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.getCompanyForBUC | public function getCompanyForBUC($account, $bankCode = null)
{
$bucer = new \FlexiPeeHP\FlexiBeeRW(null,
['evidence' => 'adresar-bankovni-ucet']);
$companyRaw = $bucer->getColumnsFromFlexibee(['firma'],
empty($bankCode) ? ['buc' => $account] : ['buc' => $account, 'smerKod' => $bankCode]);
return array_key_exists(0, $companyRaw) ? $companyRaw[0]['firma'] : null;
} | php | public function getCompanyForBUC($account, $bankCode = null)
{
$bucer = new \FlexiPeeHP\FlexiBeeRW(null,
['evidence' => 'adresar-bankovni-ucet']);
$companyRaw = $bucer->getColumnsFromFlexibee(['firma'],
empty($bankCode) ? ['buc' => $account] : ['buc' => $account, 'smerKod' => $bankCode]);
return array_key_exists(0, $companyRaw) ? $companyRaw[0]['firma'] : null;
} | [
"public",
"function",
"getCompanyForBUC",
"(",
"$",
"account",
",",
"$",
"bankCode",
"=",
"null",
")",
"{",
"$",
"bucer",
"=",
"new",
"\\",
"FlexiPeeHP",
"\\",
"FlexiBeeRW",
"(",
"null",
",",
"[",
"'evidence'",
"=>",
"'adresar-bankovni-ucet'",
"]",
")",
";... | Obtain FlexiBee company code for given bank account number
@param string $account
@param string $bankCode
@return string Company Code | [
"Obtain",
"FlexiBee",
"company",
"code",
"for",
"given",
"bank",
"account",
"number"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L370-L377 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.reorderInvoicesByAge | public static function reorderInvoicesByAge($invoices)
{
$invoicesByAge = [];
$invoicesByAgeRaw = [];
foreach ($invoices as $invoiceData) {
$invoicesByAgeRaw[\FlexiPeeHP\FlexiBeeRW::flexiDateToDateTime($invoiceData['datVyst'])->getTimestamp()]
= $invoiceData;
}
ksort($invoicesByAgeRaw);
foreach ($invoicesByAgeRaw as $invoiceData) {
$invoicesByAge[$invoiceData['kod']] = $invoiceData;
}
return $invoicesByAge;
} | php | public static function reorderInvoicesByAge($invoices)
{
$invoicesByAge = [];
$invoicesByAgeRaw = [];
foreach ($invoices as $invoiceData) {
$invoicesByAgeRaw[\FlexiPeeHP\FlexiBeeRW::flexiDateToDateTime($invoiceData['datVyst'])->getTimestamp()]
= $invoiceData;
}
ksort($invoicesByAgeRaw);
foreach ($invoicesByAgeRaw as $invoiceData) {
$invoicesByAge[$invoiceData['kod']] = $invoiceData;
}
return $invoicesByAge;
} | [
"public",
"static",
"function",
"reorderInvoicesByAge",
"(",
"$",
"invoices",
")",
"{",
"$",
"invoicesByAge",
"=",
"[",
"]",
";",
"$",
"invoicesByAgeRaw",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"invoices",
"as",
"$",
"invoiceData",
")",
"{",
"$",
"invo... | Reorder invoices by Age.
@param array $invoices
@return array Older First sorted invoices | [
"Reorder",
"invoices",
"by",
"Age",
"."
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L820-L833 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/ParovacFaktur.php | ParovacFaktur.getOriginDocumentType | public function getOriginDocumentType($typDokl)
{
if (empty($this->docTypes)) {
$this->docTypes = $this->getDocumentTypes();
}
$documentType = \FlexiPeeHP\FlexiBeeRO::uncode($typDokl);
return array_key_exists($documentType, $this->docTypes) ? $this->docTypes[$documentType]
: 'typDokladu.neznamy';
} | php | public function getOriginDocumentType($typDokl)
{
if (empty($this->docTypes)) {
$this->docTypes = $this->getDocumentTypes();
}
$documentType = \FlexiPeeHP\FlexiBeeRO::uncode($typDokl);
return array_key_exists($documentType, $this->docTypes) ? $this->docTypes[$documentType]
: 'typDokladu.neznamy';
} | [
"public",
"function",
"getOriginDocumentType",
"(",
"$",
"typDokl",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"docTypes",
")",
")",
"{",
"$",
"this",
"->",
"docTypes",
"=",
"$",
"this",
"->",
"getDocumentTypes",
"(",
")",
";",
"}",
"$",
"... | Return Document original type
@param string $typDokl
@return string typDokladu.faktura|typDokladu.dobropis|
typDokladu.zalohFaktura|typDokladu.zdd|
typDokladu.dodList|typDokladu.proforma|
typBanUctu.kc|typBanUctu.mena | [
"Return",
"Document",
"original",
"type"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/ParovacFaktur.php#L1003-L1011 | train |
Corviz/framework | src/Http/RequestParser/MultipartFormDataParser.php | MultipartFormDataParser.getFiles | public function getFiles() : array
{
$files = [];
if (!empty($_FILES)) {
foreach ($_FILES as $inputName => $phpFile) {
if (!is_array($phpFile['name'])) {
// When this was a single file
$files[$inputName] = $this->handleUniqueFile($phpFile);
} else {
//When the input has a 'multiple' attribute
$files[$inputName] = $this->handleMultipleFile($phpFile);
}
}
}
return $files;
} | php | public function getFiles() : array
{
$files = [];
if (!empty($_FILES)) {
foreach ($_FILES as $inputName => $phpFile) {
if (!is_array($phpFile['name'])) {
// When this was a single file
$files[$inputName] = $this->handleUniqueFile($phpFile);
} else {
//When the input has a 'multiple' attribute
$files[$inputName] = $this->handleMultipleFile($phpFile);
}
}
}
return $files;
} | [
"public",
"function",
"getFiles",
"(",
")",
":",
"array",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_FILES",
")",
")",
"{",
"foreach",
"(",
"$",
"_FILES",
"as",
"$",
"inputName",
"=>",
"$",
"phpFile",
")",
"{",
... | Gets an array of uploaded files,
from the request.
@return array | [
"Gets",
"an",
"array",
"of",
"uploaded",
"files",
"from",
"the",
"request",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/RequestParser/MultipartFormDataParser.php#L43-L62 | train |
Corviz/framework | src/Http/RequestParser/MultipartFormDataParser.php | MultipartFormDataParser.handleUniqueFile | protected function handleUniqueFile($file)
{
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file['error']) {
$uploadedFile = new UploadedFile(
$file['tmp_name'],
$file['name'],
$file['type']
);
}
return $uploadedFile;
} | php | protected function handleUniqueFile($file)
{
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file['error']) {
$uploadedFile = new UploadedFile(
$file['tmp_name'],
$file['name'],
$file['type']
);
}
return $uploadedFile;
} | [
"protected",
"function",
"handleUniqueFile",
"(",
"$",
"file",
")",
"{",
"$",
"uploadedFile",
"=",
"null",
";",
"//The current file was uploaded successfully?",
"if",
"(",
"!",
"$",
"file",
"[",
"'error'",
"]",
")",
"{",
"$",
"uploadedFile",
"=",
"new",
"Uploa... | Handle a file input, when it IS NOT 'multiple'.
@param array $file An element from $_FILES superglobal
@return UploadedFile|null | [
"Handle",
"a",
"file",
"input",
"when",
"it",
"IS",
"NOT",
"multiple",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/RequestParser/MultipartFormDataParser.php#L71-L85 | train |
Corviz/framework | src/Http/RequestParser/MultipartFormDataParser.php | MultipartFormDataParser.handleMultipleFile | protected function handleMultipleFile($file) : array
{
$fileBag = [];
foreach ($file['name'] as $idx => $name) {
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file[$idx]['error']) {
$uploadedFile = new UploadedFile(
$file[$idx]['tmp_name'],
$file[$idx]['name'],
$file[$idx]['type']
);
}
$fileBag[$idx] = $uploadedFile;
}
return $fileBag;
} | php | protected function handleMultipleFile($file) : array
{
$fileBag = [];
foreach ($file['name'] as $idx => $name) {
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file[$idx]['error']) {
$uploadedFile = new UploadedFile(
$file[$idx]['tmp_name'],
$file[$idx]['name'],
$file[$idx]['type']
);
}
$fileBag[$idx] = $uploadedFile;
}
return $fileBag;
} | [
"protected",
"function",
"handleMultipleFile",
"(",
"$",
"file",
")",
":",
"array",
"{",
"$",
"fileBag",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"file",
"[",
"'name'",
"]",
"as",
"$",
"idx",
"=>",
"$",
"name",
")",
"{",
"$",
"uploadedFile",
"=",
"... | Handle a file input, when it IS 'multiple'.
@param array $file An element from $_FILES superglobal
@return array | [
"Handle",
"a",
"file",
"input",
"when",
"it",
"IS",
"multiple",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/RequestParser/MultipartFormDataParser.php#L94-L114 | train |
CottaCush/yii2-widgets | src/Widgets/GridViewWidget.php | GridViewWidget.setupDefaultConfigs | private function setupDefaultConfigs()
{
$this->setLayout();
$this->setSummary();
if (!$this->isEmpty()) {
$this->setActionBar();
}
$this->showOnEmpty = false;
} | php | private function setupDefaultConfigs()
{
$this->setLayout();
$this->setSummary();
if (!$this->isEmpty()) {
$this->setActionBar();
}
$this->showOnEmpty = false;
} | [
"private",
"function",
"setupDefaultConfigs",
"(",
")",
"{",
"$",
"this",
"->",
"setLayout",
"(",
")",
";",
"$",
"this",
"->",
"setSummary",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setAct... | Set up default configs for Grid View
@author Olajide Oye <jide@cottacush.com> | [
"Set",
"up",
"default",
"configs",
"for",
"Grid",
"View"
] | e13c09e8d78e3a01b3d64cdb53abba9d41db6277 | https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Widgets/GridViewWidget.php#L33-L43 | train |
CottaCush/yii2-widgets | src/Widgets/GridViewWidget.php | GridViewWidget.setLayout | private function setLayout()
{
$this->layout = Html::tag('div', "{items}", ['class' => 'table-responsive']) .
Html::tag(
'div',
Html::tag('div', "{summary}", ['class' => 'pagination-summary']) .
Html::tag('div', "{pager}", ['class' => 'pagination-wrap']),
['class' => 'pagination-box']
);
} | php | private function setLayout()
{
$this->layout = Html::tag('div', "{items}", ['class' => 'table-responsive']) .
Html::tag(
'div',
Html::tag('div', "{summary}", ['class' => 'pagination-summary']) .
Html::tag('div', "{pager}", ['class' => 'pagination-wrap']),
['class' => 'pagination-box']
);
} | [
"private",
"function",
"setLayout",
"(",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"\"{items}\"",
",",
"[",
"'class'",
"=>",
"'table-responsive'",
"]",
")",
".",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"Html",
... | set the layout
@author Olajide Oye <jide@cottacush.com> | [
"set",
"the",
"layout"
] | e13c09e8d78e3a01b3d64cdb53abba9d41db6277 | https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Widgets/GridViewWidget.php#L49-L58 | train |
CottaCush/yii2-widgets | src/Widgets/GridViewWidget.php | GridViewWidget.setActionBar | public function setActionBar()
{
if (is_null($this->actionButtonLabel) && is_null($this->actionButtonModalId)) {
return;
}
$this->getView()->params['content-header-button'] = [
'label' => $this->actionButtonLabel,
'options' => [
'data-toggle' => 'modal',
'data-target' => $this->actionButtonModalId,
'href' => $this->actionButtonModalHref ?: '#'
]
];
} | php | public function setActionBar()
{
if (is_null($this->actionButtonLabel) && is_null($this->actionButtonModalId)) {
return;
}
$this->getView()->params['content-header-button'] = [
'label' => $this->actionButtonLabel,
'options' => [
'data-toggle' => 'modal',
'data-target' => $this->actionButtonModalId,
'href' => $this->actionButtonModalHref ?: '#'
]
];
} | [
"public",
"function",
"setActionBar",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"actionButtonLabel",
")",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"actionButtonModalId",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getView",
... | set the Action bar
@author Damilola Olaleye <damilola@cottacush.com> | [
"set",
"the",
"Action",
"bar"
] | e13c09e8d78e3a01b3d64cdb53abba9d41db6277 | https://github.com/CottaCush/yii2-widgets/blob/e13c09e8d78e3a01b3d64cdb53abba9d41db6277/src/Widgets/GridViewWidget.php#L77-L91 | train |
TheBnl/event-tickets | code/forms/SummaryForm.php | SummaryForm.getPaymentErrorMessage | public function getPaymentErrorMessage()
{
/** @var Payment $lastPayment */
// Get the last payment
if (!$lastPayment = $this->reservation->Payments()->first()) {
return false;
}
// Find the gateway error
$lastErrorMessage = null;
$errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
foreach ($errorMessages as $errorMessage) {
if ($errorMessage instanceof GatewayErrorMessage) {
$lastErrorMessage = $errorMessage;
break;
}
}
// If no error is found return
if (!$lastErrorMessage) {
return false;
}
return _t("{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}", $lastErrorMessage->Message);
} | php | public function getPaymentErrorMessage()
{
/** @var Payment $lastPayment */
// Get the last payment
if (!$lastPayment = $this->reservation->Payments()->first()) {
return false;
}
// Find the gateway error
$lastErrorMessage = null;
$errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
foreach ($errorMessages as $errorMessage) {
if ($errorMessage instanceof GatewayErrorMessage) {
$lastErrorMessage = $errorMessage;
break;
}
}
// If no error is found return
if (!$lastErrorMessage) {
return false;
}
return _t("{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}", $lastErrorMessage->Message);
} | [
"public",
"function",
"getPaymentErrorMessage",
"(",
")",
"{",
"/** @var Payment $lastPayment */",
"// Get the last payment",
"if",
"(",
"!",
"$",
"lastPayment",
"=",
"$",
"this",
"->",
"reservation",
"->",
"Payments",
"(",
")",
"->",
"first",
"(",
")",
")",
"{"... | Get the last error message from the payment attempts
@return bool|string | [
"Get",
"the",
"last",
"error",
"message",
"from",
"the",
"payment",
"attempts"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/forms/SummaryForm.php#L124-L148 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php | AbstractVotePlugin.start | public function start(Player $player, $params)
{
$this->currentVote = new Vote($player, $this->getCode(), $params);
return $this->currentVote;
} | php | public function start(Player $player, $params)
{
$this->currentVote = new Vote($player, $this->getCode(), $params);
return $this->currentVote;
} | [
"public",
"function",
"start",
"(",
"Player",
"$",
"player",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"currentVote",
"=",
"new",
"Vote",
"(",
"$",
"player",
",",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"params",
")",
";",
"return"... | Start a new vote.
@param Player $player
@return Vote|null | [
"Start",
"a",
"new",
"vote",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php#L61-L65 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php | AbstractVotePlugin.castYes | public function castYes($login)
{
if ($this->currentVote) {
$this->currentVote->castYes($login);
$player = $this->playerStorage->getPlayerInfo($login);
$this->dispatcher->dispatch("votemanager.voteyes", [$player, $this->currentVote]);
}
} | php | public function castYes($login)
{
if ($this->currentVote) {
$this->currentVote->castYes($login);
$player = $this->playerStorage->getPlayerInfo($login);
$this->dispatcher->dispatch("votemanager.voteyes", [$player, $this->currentVote]);
}
} | [
"public",
"function",
"castYes",
"(",
"$",
"login",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentVote",
")",
"{",
"$",
"this",
"->",
"currentVote",
"->",
"castYes",
"(",
"$",
"login",
")",
";",
"$",
"player",
"=",
"$",
"this",
"->",
"playerStorage... | User votes yes
@param string $login | [
"User",
"votes",
"yes"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php#L80-L88 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php | AbstractVotePlugin.update | public function update($time = null)
{
if (!$this->currentVote || $this->currentVote->getStatus() == Vote::STATUS_CANCEL) {
return;
}
if (is_null($time)) {
$time = time();
}
$playerCount = count($this->playerStorage->getOnline());
// Check if vote passes when we suppose that all palyers that didn't vote would vote NO.
if ($playerCount > 0 && ($this->currentVote->getYes() / $playerCount) > $this->ratio) {
$this->votePassed();
return;
}
// If the vote is still not decided wait for the end to decide.
if (($time - $this->currentVote->getStartTime()) > $this->duration) {
$totalVotes = $this->currentVote->getYes() + $this->currentVote->getNo() * 1.0;
if ($totalVotes >= 1 && ($this->currentVote->getYes() / $totalVotes) > $this->ratio) {
$this->votePassed();
} else {
$this->voteFailed();
}
}
} | php | public function update($time = null)
{
if (!$this->currentVote || $this->currentVote->getStatus() == Vote::STATUS_CANCEL) {
return;
}
if (is_null($time)) {
$time = time();
}
$playerCount = count($this->playerStorage->getOnline());
// Check if vote passes when we suppose that all palyers that didn't vote would vote NO.
if ($playerCount > 0 && ($this->currentVote->getYes() / $playerCount) > $this->ratio) {
$this->votePassed();
return;
}
// If the vote is still not decided wait for the end to decide.
if (($time - $this->currentVote->getStartTime()) > $this->duration) {
$totalVotes = $this->currentVote->getYes() + $this->currentVote->getNo() * 1.0;
if ($totalVotes >= 1 && ($this->currentVote->getYes() / $totalVotes) > $this->ratio) {
$this->votePassed();
} else {
$this->voteFailed();
}
}
} | [
"public",
"function",
"update",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"currentVote",
"||",
"$",
"this",
"->",
"currentVote",
"->",
"getStatus",
"(",
")",
"==",
"Vote",
"::",
"STATUS_CANCEL",
")",
"{",
"return",
"... | Update the status of the vote, and execute actions if vote passed.
@param int $time | [
"Update",
"the",
"status",
"of",
"the",
"vote",
"and",
"execute",
"actions",
"if",
"vote",
"passed",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/VoteManager/Plugins/Votes/AbstractVotePlugin.php#L122-L150 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php | SendPage.showForm | public function showForm()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGFILL"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$form = new XmlFormCollection($this->_context, "module:sendpage", $this->_myWords->Value("CAPTION"));
$paragraph->addXmlnukeObject($form);
$caption = new XmlInputCaption($this->_myWords->ValueArgs("INFO", array(urldecode($this->_link))));
$form->addXmlnukeObject($caption);
$hidden = new XmlInputHidden("action", "submit");
$form->addXmlnukeObject($hidden);
$hidden = new XmlInputHidden("link", $this->_link);
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDNAME"), "fromname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDEMAIL"), "frommail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTONAME"), "toname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTOEMAIL"), "tomail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$memo = new XmlInputMemo($this->_myWords->Value("LABEL_MESSAGE"), "custommessage","");
$form->addXmlnukeObject($memo);
$form->addXmlnukeObject(new XmlInputImageValidate($this->_myWords->Value("TYPETEXTFROMIMAGE")));
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_SUBMIT"), "");
$form->addXmlnukeObject($button);
} | php | public function showForm()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGFILL"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$form = new XmlFormCollection($this->_context, "module:sendpage", $this->_myWords->Value("CAPTION"));
$paragraph->addXmlnukeObject($form);
$caption = new XmlInputCaption($this->_myWords->ValueArgs("INFO", array(urldecode($this->_link))));
$form->addXmlnukeObject($caption);
$hidden = new XmlInputHidden("action", "submit");
$form->addXmlnukeObject($hidden);
$hidden = new XmlInputHidden("link", $this->_link);
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDNAME"), "fromname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDEMAIL"), "frommail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTONAME"), "toname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTOEMAIL"), "tomail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$memo = new XmlInputMemo($this->_myWords->Value("LABEL_MESSAGE"), "custommessage","");
$form->addXmlnukeObject($memo);
$form->addXmlnukeObject(new XmlInputImageValidate($this->_myWords->Value("TYPETEXTFROMIMAGE")));
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_SUBMIT"), "");
$form->addXmlnukeObject($button);
} | [
"public",
"function",
"showForm",
"(",
")",
"{",
"$",
"blockcenter",
"=",
"new",
"XmlBlockCollection",
"(",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"MSGFILL\"",
")",
",",
"BlockPosition",
"::",
"Center",
")",
";",
"$",
"this",
"->",
"_document... | Show the form | [
"Show",
"the",
"form"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php#L239-L285 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php | SendPage.goBack | public function goBack($showMessage)
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGERROR"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($showMessage,true));
$anchor = new XmlAnchorCollection("javascript:history.go(-1)");
$anchor->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("TXT_BACK")));
$paragraph->addXmlnukeObject($anchor);
} | php | public function goBack($showMessage)
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGERROR"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($showMessage,true));
$anchor = new XmlAnchorCollection("javascript:history.go(-1)");
$anchor->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("TXT_BACK")));
$paragraph->addXmlnukeObject($anchor);
} | [
"public",
"function",
"goBack",
"(",
"$",
"showMessage",
")",
"{",
"$",
"blockcenter",
"=",
"new",
"XmlBlockCollection",
"(",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"MSGERROR\"",
")",
",",
"BlockPosition",
"::",
"Center",
")",
";",
"$",
"this... | Go to the last page | [
"Go",
"to",
"the",
"last",
"page"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php#L291-L304 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php | SendPage.showMessage | public function showMessage()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGOK"), BlockPosition::Center);
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($_customMessage));
} | php | public function showMessage()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGOK"), BlockPosition::Center);
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($_customMessage));
} | [
"public",
"function",
"showMessage",
"(",
")",
"{",
"$",
"blockcenter",
"=",
"new",
"XmlBlockCollection",
"(",
"$",
"this",
"->",
"_myWords",
"->",
"Value",
"(",
"\"MSGOK\"",
")",
",",
"BlockPosition",
"::",
"Center",
")",
";",
"$",
"this",
"->",
"_documen... | Show a message of the error | [
"Show",
"a",
"message",
"of",
"the",
"error"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/SendPage.php#L310-L319 | train |
Corviz/framework | src/Http/Request.php | Request.fillCurrentHeaders | private static function fillCurrentHeaders(self $request)
{
$headers = [];
//Native method exists?
if (function_exists('getallheaders')) {
//try to use it
if (($headers = getallheaders()) === false) {
$headers = [];
}
}
//No header captured yet? Try to get it myself
if (empty($headers)) {
/*
* Based on a user note provided by joyview
* at http://php.net/manual/en/function.getallheaders.php
*/
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$newKey = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
$headers[$newKey] = $value;
}
}
}
$request->setHeaders($headers);
} | php | private static function fillCurrentHeaders(self $request)
{
$headers = [];
//Native method exists?
if (function_exists('getallheaders')) {
//try to use it
if (($headers = getallheaders()) === false) {
$headers = [];
}
}
//No header captured yet? Try to get it myself
if (empty($headers)) {
/*
* Based on a user note provided by joyview
* at http://php.net/manual/en/function.getallheaders.php
*/
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$newKey = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
$headers[$newKey] = $value;
}
}
}
$request->setHeaders($headers);
} | [
"private",
"static",
"function",
"fillCurrentHeaders",
"(",
"self",
"$",
"request",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"//Native method exists?",
"if",
"(",
"function_exists",
"(",
"'getallheaders'",
")",
")",
"{",
"//try to use it",
"if",
"(",
"(",... | Fill up the headers property with the values
provided by the client browser.
@param Request $request | [
"Fill",
"up",
"the",
"headers",
"property",
"with",
"the",
"values",
"provided",
"by",
"the",
"client",
"browser",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/Request.php#L171-L200 | train |
Corviz/framework | src/Http/Request.php | Request.fillCurrentRouteString | private static function fillCurrentRouteString(self $request)
{
//Read data from $_SERVER array
$requestUri = urldecode($_SERVER['REQUEST_URI']);
$scriptName = $_SERVER['SCRIPT_NAME'];
//Extract route string from the URI
$length = strlen(dirname($scriptName));
$routeAux = substr(explode('?', $requestUri)[0], $length);
$route = '/';
if ($routeAux && $routeAux != '/') {
$route .= trim(str_replace('\\', '/', $routeAux), '/').'/';
}
$request->setRouteStr($route);
} | php | private static function fillCurrentRouteString(self $request)
{
//Read data from $_SERVER array
$requestUri = urldecode($_SERVER['REQUEST_URI']);
$scriptName = $_SERVER['SCRIPT_NAME'];
//Extract route string from the URI
$length = strlen(dirname($scriptName));
$routeAux = substr(explode('?', $requestUri)[0], $length);
$route = '/';
if ($routeAux && $routeAux != '/') {
$route .= trim(str_replace('\\', '/', $routeAux), '/').'/';
}
$request->setRouteStr($route);
} | [
"private",
"static",
"function",
"fillCurrentRouteString",
"(",
"self",
"$",
"request",
")",
"{",
"//Read data from $_SERVER array",
"$",
"requestUri",
"=",
"urldecode",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
";",
"$",
"scriptName",
"=",
"$",
"_SER... | Capture the route string.
@param Request $request | [
"Capture",
"the",
"route",
"string",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/Request.php#L207-L223 | train |
Corviz/framework | src/Http/Request.php | Request.selectDataParser | private function selectDataParser()
{
/* @var ContentTypeParser $selected */
$selected = null;
//Has content?
if (!empty($this->getContentType())) {
//Search trough the registered parsers
foreach (self::$registeredParsers as $parser) {
/* @var ContentTypeParser $parser */
if ($parser->canHandle($this->getContentType())) {
$selected = $parser;
break;
}
}
}
//If no one was found, pick GenericParser
if (is_null($selected)) {
$selected = new GenericParser();
}
$selected->setRequest($this);
$this->parser = $selected;
} | php | private function selectDataParser()
{
/* @var ContentTypeParser $selected */
$selected = null;
//Has content?
if (!empty($this->getContentType())) {
//Search trough the registered parsers
foreach (self::$registeredParsers as $parser) {
/* @var ContentTypeParser $parser */
if ($parser->canHandle($this->getContentType())) {
$selected = $parser;
break;
}
}
}
//If no one was found, pick GenericParser
if (is_null($selected)) {
$selected = new GenericParser();
}
$selected->setRequest($this);
$this->parser = $selected;
} | [
"private",
"function",
"selectDataParser",
"(",
")",
"{",
"/* @var ContentTypeParser $selected */",
"$",
"selected",
"=",
"null",
";",
"//Has content?",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getContentType",
"(",
")",
")",
")",
"{",
"//Search trough ... | Pick a content type parser
from the list. | [
"Pick",
"a",
"content",
"type",
"parser",
"from",
"the",
"list",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Http/Request.php#L396-L421 | train |
dfeyer/Ttree.Oembed | Classes/ResourceFactory.php | ResourceFactory.create | public function create($resource)
{
$className = $this->getResourceClassName($resource->type);
if (!class_exists($className)) {
throw new Exception(
'Unknown resource type "' . $resource->type . '".',
Exception::UNKNOWN_RESOURCE_TYPE
);
}
/** @var AbstractResource $object */
$object = $this->objectManager->get($className);
foreach ($resource as $property => $value) {
if (!ObjectAccess::isPropertySettable($object, $property)) {
continue;
}
ObjectAccess::setProperty($object, $property, $value);
}
$this->postProcessResources($object);
return $object;
} | php | public function create($resource)
{
$className = $this->getResourceClassName($resource->type);
if (!class_exists($className)) {
throw new Exception(
'Unknown resource type "' . $resource->type . '".',
Exception::UNKNOWN_RESOURCE_TYPE
);
}
/** @var AbstractResource $object */
$object = $this->objectManager->get($className);
foreach ($resource as $property => $value) {
if (!ObjectAccess::isPropertySettable($object, $property)) {
continue;
}
ObjectAccess::setProperty($object, $property, $value);
}
$this->postProcessResources($object);
return $object;
} | [
"public",
"function",
"create",
"(",
"$",
"resource",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getResourceClassName",
"(",
"$",
"resource",
"->",
"type",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw... | Create a Resource object from the supplied resource.
@param \stdClass $resource The resource to create an Resource from.
@return AbstractResource
@throws Exception | [
"Create",
"a",
"Resource",
"object",
"from",
"the",
"supplied",
"resource",
"."
] | 1f38d18f51c1abe96c19fe4760acc9ef907194df | https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/ResourceFactory.php#L54-L77 | train |
ansas/php-component | src/Component/Period/Period.php | Period.getPeriod | public function getPeriod($period, $mode = self::DAYS_ONLY)
{
$result = $this->parsePeriod($period);
if ($result['max'] && $mode == self::DAYS_AND_TIME) {
$result['max']->modify("+1 day -1 second");
}
foreach ($result as $key => $value) {
if (!$value) {
unset($result[$key]);
} elseif ($mode == self::DAYS_ONLY) {
$result[$key] = new DateTime($result[$key]->format('Y-m-d'), $this->getTimezoneTo());
} elseif ($this->getTimezoneTo()) {
$result[$key]->setTimezone($this->getTimezoneTo());
}
}
return $result;
} | php | public function getPeriod($period, $mode = self::DAYS_ONLY)
{
$result = $this->parsePeriod($period);
if ($result['max'] && $mode == self::DAYS_AND_TIME) {
$result['max']->modify("+1 day -1 second");
}
foreach ($result as $key => $value) {
if (!$value) {
unset($result[$key]);
} elseif ($mode == self::DAYS_ONLY) {
$result[$key] = new DateTime($result[$key]->format('Y-m-d'), $this->getTimezoneTo());
} elseif ($this->getTimezoneTo()) {
$result[$key]->setTimezone($this->getTimezoneTo());
}
}
return $result;
} | [
"public",
"function",
"getPeriod",
"(",
"$",
"period",
",",
"$",
"mode",
"=",
"self",
"::",
"DAYS_ONLY",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"parsePeriod",
"(",
"$",
"period",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'max'",
"]",
"&&"... | Calculate min and max dates and return them as DateTime objects.
@param string $period Period name
@param int $mode [optional] Period::DAYS_AND_TIME or Period::DAYS_ONLY
@return DateTime[]
@throws Exception If unable to determine the period. | [
"Calculate",
"min",
"and",
"max",
"dates",
"and",
"return",
"them",
"as",
"DateTime",
"objects",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/Period/Period.php#L119-L138 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/php-unoconv/php-unoconv/src/Unoconv/Unoconv.php | Unoconv.transcode | public function transcode($input, $format, $outputFile, $pageRange = null)
{
if (!file_exists($input)) {
throw new InvalidFileArgumentException(sprintf('File %s does not exists', $input));
}
$arguments = array(
'--format=' . $format,
'--stdout'
);
if (preg_match('/\d+-\d+/', $pageRange)) {
$arguments[] = '-e';
$arguments[] = 'PageRange=' . $pageRange;
}
$arguments[] = $input;
try {
$output = $this->command($arguments);
} catch (ExecutionFailureException $e) {
throw new RuntimeException(
'Unoconv failed to transcode file', $e->getCode(), $e
);
}
if (!is_writable(dirname($outputFile)) || !file_put_contents($outputFile, $output)) {
throw new RuntimeException(sprintf(
'Unable to write to output file `%s`', $outputFile
));
}
return $this;
} | php | public function transcode($input, $format, $outputFile, $pageRange = null)
{
if (!file_exists($input)) {
throw new InvalidFileArgumentException(sprintf('File %s does not exists', $input));
}
$arguments = array(
'--format=' . $format,
'--stdout'
);
if (preg_match('/\d+-\d+/', $pageRange)) {
$arguments[] = '-e';
$arguments[] = 'PageRange=' . $pageRange;
}
$arguments[] = $input;
try {
$output = $this->command($arguments);
} catch (ExecutionFailureException $e) {
throw new RuntimeException(
'Unoconv failed to transcode file', $e->getCode(), $e
);
}
if (!is_writable(dirname($outputFile)) || !file_put_contents($outputFile, $output)) {
throw new RuntimeException(sprintf(
'Unable to write to output file `%s`', $outputFile
));
}
return $this;
} | [
"public",
"function",
"transcode",
"(",
"$",
"input",
",",
"$",
"format",
",",
"$",
"outputFile",
",",
"$",
"pageRange",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"InvalidFileArgumentException... | Transcodes a file to another format
@param string $input The path to the input file
@param string $format The output format
@param string $outputFile The path to the output file
@param string $pageRange The range of pages. 1-14 for pages 1 to 14
@return Unoconv
@throws InvalidFileArgumentException In case the input file is not readable or does not exist
@throws RuntimeException In case the output file can not be written, or the process failes | [
"Transcodes",
"a",
"file",
"to",
"another",
"format"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/php-unoconv/php-unoconv/src/Unoconv/Unoconv.php#L47-L80 | train |
BenGorUser/UserBundle | src/BenGorUser/UserBundle/DependentBenGorUserBundle.php | DependentBenGorUserBundle.checkDependencies | public function checkDependencies(array $requiredBundles, ContainerBuilder $container)
{
if (false === ($this instanceof Bundle)) {
throw new RuntimeException('It is a bundle trait, you shouldn\'t have to use in other instances');
}
$enabledBundles = $container->getParameter('kernel.bundles');
foreach ($requiredBundles as $requiredBundle) {
if (!isset($enabledBundles[$requiredBundle])) {
throw new RuntimeException(
sprintf(
'In order to use "%s" you also need to enable and configure the "%s"',
$this->getName(),
$requiredBundle
)
);
}
}
} | php | public function checkDependencies(array $requiredBundles, ContainerBuilder $container)
{
if (false === ($this instanceof Bundle)) {
throw new RuntimeException('It is a bundle trait, you shouldn\'t have to use in other instances');
}
$enabledBundles = $container->getParameter('kernel.bundles');
foreach ($requiredBundles as $requiredBundle) {
if (!isset($enabledBundles[$requiredBundle])) {
throw new RuntimeException(
sprintf(
'In order to use "%s" you also need to enable and configure the "%s"',
$this->getName(),
$requiredBundle
)
);
}
}
} | [
"public",
"function",
"checkDependencies",
"(",
"array",
"$",
"requiredBundles",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"this",
"instanceof",
"Bundle",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
... | Checks the given bundles are enabled in the container.
@param array $requiredBundles The required bundles
@param ContainerBuilder $container The container builder | [
"Checks",
"the",
"given",
"bundles",
"are",
"enabled",
"in",
"the",
"container",
"."
] | a6d0173496c269a6c80e1319d42eaed4b3bbbd4a | https://github.com/BenGorUser/UserBundle/blob/a6d0173496c269a6c80e1319d42eaed4b3bbbd4a/src/BenGorUser/UserBundle/DependentBenGorUserBundle.php#L32-L50 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/Customer.php | Customer.loadFromFlexiBee | public function loadFromFlexiBee($id = null)
{
$result = $this->adresar->loadFromFlexiBee($id);
$this->takeData($this->adresar->getData());
return $result;
} | php | public function loadFromFlexiBee($id = null)
{
$result = $this->adresar->loadFromFlexiBee($id);
$this->takeData($this->adresar->getData());
return $result;
} | [
"public",
"function",
"loadFromFlexiBee",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"adresar",
"->",
"loadFromFlexiBee",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"takeData",
"(",
"$",
"this",
"->",
"adresar",
"... | Load Customer from FlexiBee
@param id $id FlexiBee address record ID
@return int | [
"Load",
"Customer",
"from",
"FlexiBee"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/Customer.php#L112-L117 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/Customer.php | Customer.getCustomerScore | public function getCustomerScore($addressID)
{
$score = 0;
$debts = $this->getCustomerDebts($addressID);
$stitkyRaw = $this->adresar->getColumnsFromFlexiBee(['stitky'],
['id' => $addressID]);
$stitky = $stitkyRaw[0]['stitky'];
if (!empty($debts)) {
foreach ($debts as $did => $debt) {
$ddiff = \FlexiPeeHP\FakturaVydana::overdueDays($debt['datSplat']);
if (($ddiff <= 7) && ($ddiff >= 1)) {
$score = self::maxScore($score, 1);
} else {
if (($ddiff > 7 ) && ($ddiff <= 14)) {
$score = self::maxScore($score, 2);
} else {
if ($ddiff > 14) {
$score = self::maxScore($score, 3);
}
}
}
}
}
if ($score == 3 && !strstr($stitky, 'UPOMINKA2')) {
$score = 2;
}
if (!strstr($stitky, 'UPOMINKA1') && !empty($debts)) {
$score = 1;
}
return $score;
} | php | public function getCustomerScore($addressID)
{
$score = 0;
$debts = $this->getCustomerDebts($addressID);
$stitkyRaw = $this->adresar->getColumnsFromFlexiBee(['stitky'],
['id' => $addressID]);
$stitky = $stitkyRaw[0]['stitky'];
if (!empty($debts)) {
foreach ($debts as $did => $debt) {
$ddiff = \FlexiPeeHP\FakturaVydana::overdueDays($debt['datSplat']);
if (($ddiff <= 7) && ($ddiff >= 1)) {
$score = self::maxScore($score, 1);
} else {
if (($ddiff > 7 ) && ($ddiff <= 14)) {
$score = self::maxScore($score, 2);
} else {
if ($ddiff > 14) {
$score = self::maxScore($score, 3);
}
}
}
}
}
if ($score == 3 && !strstr($stitky, 'UPOMINKA2')) {
$score = 2;
}
if (!strstr($stitky, 'UPOMINKA1') && !empty($debts)) {
$score = 1;
}
return $score;
} | [
"public",
"function",
"getCustomerScore",
"(",
"$",
"addressID",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"debts",
"=",
"$",
"this",
"->",
"getCustomerDebts",
"(",
"$",
"addressID",
")",
";",
"$",
"stitkyRaw",
"=",
"$",
"this",
"->",
"adresar",
"->"... | Obtain Customer "Score"
@param int $addressID FlexiBee user ID
@return int ZewlScore | [
"Obtain",
"Customer",
"Score"
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/Customer.php#L203-L236 | train |
VitexSoftware/FlexiPeeHP-Bricks | src/FlexiPeeHP/Bricks/Customer.php | Customer.getUserEmail | public function getUserEmail()
{
return strlen($this->kontakt->getDataValue($this->mailColumn)) ? $this->kontakt->getDataValue($this->mailColumn)
: $this->adresar->getDataValue($this->mailColumn);
} | php | public function getUserEmail()
{
return strlen($this->kontakt->getDataValue($this->mailColumn)) ? $this->kontakt->getDataValue($this->mailColumn)
: $this->adresar->getDataValue($this->mailColumn);
} | [
"public",
"function",
"getUserEmail",
"(",
")",
"{",
"return",
"strlen",
"(",
"$",
"this",
"->",
"kontakt",
"->",
"getDataValue",
"(",
"$",
"this",
"->",
"mailColumn",
")",
")",
"?",
"$",
"this",
"->",
"kontakt",
"->",
"getDataValue",
"(",
"$",
"this",
... | Retrun user's mail address.
@return string | [
"Retrun",
"user",
"s",
"mail",
"address",
"."
] | e6d6d9b6cb6ceffe31b35e0f8f396f614473047b | https://github.com/VitexSoftware/FlexiPeeHP-Bricks/blob/e6d6d9b6cb6ceffe31b35e0f8f396f614473047b/src/FlexiPeeHP/Bricks/Customer.php#L341-L345 | train |
anklimsk/cakephp-theme | Model/SseTask.php | SseTask.getListQueuedTask | public function getListQueuedTask() {
$result = [];
if (!CakeSession::check($this->_sessionKey)) {
return $result;
}
$tasks = CakeSession::read($this->_sessionKey);
if (!is_array($tasks)) {
return $result;
}
return $tasks;
} | php | public function getListQueuedTask() {
$result = [];
if (!CakeSession::check($this->_sessionKey)) {
return $result;
}
$tasks = CakeSession::read($this->_sessionKey);
if (!is_array($tasks)) {
return $result;
}
return $tasks;
} | [
"public",
"function",
"getListQueuedTask",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"CakeSession",
"::",
"check",
"(",
"$",
"this",
"->",
"_sessionKey",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"tasks",
"=",
"... | Get list of queued tasks.
@return array List of queued tasks. | [
"Get",
"list",
"of",
"queued",
"tasks",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/SseTask.php#L42-L54 | train |
anklimsk/cakephp-theme | Model/SseTask.php | SseTask.deleteQueuedTask | public function deleteQueuedTask($tasks = []) {
if (empty($tasks) || !is_array($tasks)) {
return false;
}
if (!CakeSession::check($this->_sessionKey)) {
return false;
}
$existsTasks = CakeSession::read($this->_sessionKey);
if (empty($existsTasks)) {
return false;
}
$resultTasks = array_values(array_diff((array)$existsTasks, $tasks));
return CakeSession::write($this->_sessionKey, $resultTasks);
} | php | public function deleteQueuedTask($tasks = []) {
if (empty($tasks) || !is_array($tasks)) {
return false;
}
if (!CakeSession::check($this->_sessionKey)) {
return false;
}
$existsTasks = CakeSession::read($this->_sessionKey);
if (empty($existsTasks)) {
return false;
}
$resultTasks = array_values(array_diff((array)$existsTasks, $tasks));
return CakeSession::write($this->_sessionKey, $resultTasks);
} | [
"public",
"function",
"deleteQueuedTask",
"(",
"$",
"tasks",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tasks",
")",
"||",
"!",
"is_array",
"(",
"$",
"tasks",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"CakeSession",
... | Delete queued tasks.
@param array $tasks List of tasks to delete
@return bool Success. | [
"Delete",
"queued",
"tasks",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/SseTask.php#L62-L78 | train |
video-games-records/CoreBundle | Tools/Score.php | Score.parseChartMask | public static function parseChartMask($mask)
{
$result = [];
$arrayParts = explode('|', $mask);
foreach ($arrayParts as $partOfMask) {
$arrayLib = explode('~', $partOfMask);
$result[] = ['size' => (int)$arrayLib[0], 'suffixe' => $arrayLib[1]];
}
return $result;
} | php | public static function parseChartMask($mask)
{
$result = [];
$arrayParts = explode('|', $mask);
foreach ($arrayParts as $partOfMask) {
$arrayLib = explode('~', $partOfMask);
$result[] = ['size' => (int)$arrayLib[0], 'suffixe' => $arrayLib[1]];
}
return $result;
} | [
"public",
"static",
"function",
"parseChartMask",
"(",
"$",
"mask",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"arrayParts",
"=",
"explode",
"(",
"'|'",
",",
"$",
"mask",
")",
";",
"foreach",
"(",
"$",
"arrayParts",
"as",
"$",
"partOfMask",
")... | Parse a type of a libRecord
@param string $mask
@return array | [
"Parse",
"a",
"type",
"of",
"a",
"libRecord"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Tools/Score.php#L14-L24 | train |
video-games-records/CoreBundle | Tools/Score.php | Score.getValues | public static function getValues($mask, $value)
{
$parse = self::parseChartMask($mask);
$negative = 0 === strpos($value, '-');
$value = $negative ? (int)substr($value, 1) : $value;
$data = [];
$laValue = $value;
for ($k = count($parse) - 1; $k >= 0; $k--) {
$size = $parse[$k]['size'];
if (strlen($laValue) > $size) {
$result = substr($laValue, strlen($laValue) - $size, $size);
$laValue = substr($laValue, 0, strlen($laValue) - $size);
} else {
if ($k !== 0) {
$result = str_pad($laValue, $size, '0', STR_PAD_LEFT);
$laValue = '';
} else {
$result = $laValue;
if ('' === $laValue) {
$result = '0';
}
if ($negative) {
$result = '-' . $result;
}
}
}
if ($value === null) {
$result = '';
}
$data[] = ['value' => $result];
}
return array_reverse($data);
} | php | public static function getValues($mask, $value)
{
$parse = self::parseChartMask($mask);
$negative = 0 === strpos($value, '-');
$value = $negative ? (int)substr($value, 1) : $value;
$data = [];
$laValue = $value;
for ($k = count($parse) - 1; $k >= 0; $k--) {
$size = $parse[$k]['size'];
if (strlen($laValue) > $size) {
$result = substr($laValue, strlen($laValue) - $size, $size);
$laValue = substr($laValue, 0, strlen($laValue) - $size);
} else {
if ($k !== 0) {
$result = str_pad($laValue, $size, '0', STR_PAD_LEFT);
$laValue = '';
} else {
$result = $laValue;
if ('' === $laValue) {
$result = '0';
}
if ($negative) {
$result = '-' . $result;
}
}
}
if ($value === null) {
$result = '';
}
$data[] = ['value' => $result];
}
return array_reverse($data);
} | [
"public",
"static",
"function",
"getValues",
"(",
"$",
"mask",
",",
"$",
"value",
")",
"{",
"$",
"parse",
"=",
"self",
"::",
"parseChartMask",
"(",
"$",
"mask",
")",
";",
"$",
"negative",
"=",
"0",
"===",
"strpos",
"(",
"$",
"value",
",",
"'-'",
")... | Transform a value for the form
@param string $mask
@param string|int $value
@return array | [
"Transform",
"a",
"value",
"for",
"the",
"form"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Tools/Score.php#L34-L68 | train |
video-games-records/CoreBundle | Tools/Score.php | Score.formToBdd | public static function formToBdd($mask, $values)
{
$parse = self::parseChartMask($mask);
$nbInput = count($parse);
$value = '';
foreach ($values as $row) {
$value .= $row['value'];
}
if ($value == '') {
return null;
}
if ($nbInput === 1) {
return $values[0]['value'];
}
$value = '';
for ($k = 0; $k <= $nbInput - 1; $k++) {
$part = $values[$k]['value'];
$length = $parse[$k]['size'];
if (strlen($part) < $length) {
if ($k === 0) {
if ($part === '') {
$part = '0';
}
} else {
if ($k === $nbInput - 1) {
$part = str_pad($part, $length, '0', STR_PAD_RIGHT);
} else {
$part = str_pad($part, $length, '0', STR_PAD_LEFT);
}
}
}
$value .= $part;
}
return $value;
} | php | public static function formToBdd($mask, $values)
{
$parse = self::parseChartMask($mask);
$nbInput = count($parse);
$value = '';
foreach ($values as $row) {
$value .= $row['value'];
}
if ($value == '') {
return null;
}
if ($nbInput === 1) {
return $values[0]['value'];
}
$value = '';
for ($k = 0; $k <= $nbInput - 1; $k++) {
$part = $values[$k]['value'];
$length = $parse[$k]['size'];
if (strlen($part) < $length) {
if ($k === 0) {
if ($part === '') {
$part = '0';
}
} else {
if ($k === $nbInput - 1) {
$part = str_pad($part, $length, '0', STR_PAD_RIGHT);
} else {
$part = str_pad($part, $length, '0', STR_PAD_LEFT);
}
}
}
$value .= $part;
}
return $value;
} | [
"public",
"static",
"function",
"formToBdd",
"(",
"$",
"mask",
",",
"$",
"values",
")",
"{",
"$",
"parse",
"=",
"self",
"::",
"parseChartMask",
"(",
"$",
"mask",
")",
";",
"$",
"nbInput",
"=",
"count",
"(",
"$",
"parse",
")",
";",
"$",
"value",
"="... | Transform values to insert database
@param string $mask
@param array $values
@return string | [
"Transform",
"values",
"to",
"insert",
"database"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Tools/Score.php#L78-L113 | train |
JBZoo/Html | src/Render/Tag.php | Tag.render | public function render($content, $class = '', $id = '', array $attrs = array())
{
$attrs = $this->_setId($attrs, $id);
$attrs = $this->_cleanAttrs($attrs);
if (!empty($class)) {
$attrs = $this->_normalizeClassAttr($attrs, $class);
}
$tag = $this->_tag;
if (Arr::key('tag', $attrs)) {
$tag = $attrs['tag'];
unset($attrs['tag']);
}
$format = (!empty($attrs)) ? '<%s %s>%s</%s>' : '<%s%s>%s</%s>';
$output = sprintf($format, $tag, $this->buildAttrs($attrs), $content, $tag);
return $output;
} | php | public function render($content, $class = '', $id = '', array $attrs = array())
{
$attrs = $this->_setId($attrs, $id);
$attrs = $this->_cleanAttrs($attrs);
if (!empty($class)) {
$attrs = $this->_normalizeClassAttr($attrs, $class);
}
$tag = $this->_tag;
if (Arr::key('tag', $attrs)) {
$tag = $attrs['tag'];
unset($attrs['tag']);
}
$format = (!empty($attrs)) ? '<%s %s>%s</%s>' : '<%s%s>%s</%s>';
$output = sprintf($format, $tag, $this->buildAttrs($attrs), $content, $tag);
return $output;
} | [
"public",
"function",
"render",
"(",
"$",
"content",
",",
"$",
"class",
"=",
"''",
",",
"$",
"id",
"=",
"''",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attrs",
"=",
"$",
"this",
"->",
"_setId",
"(",
"$",
"attrs",
",",
... | Create html tag.
@param string $content
@param array|string $class
@param string $id
@param array $attrs
@return string | [
"Create",
"html",
"tag",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Tag.php#L47-L66 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php | PlayerDataProvider.onPlayerConnect | public function onPlayerConnect($login, $isSpectator = false, $dispatch = true)
{
try {
$playerData = $this->playerStorage->getPlayerInfo($login);
} catch (\Exception $e) {
// TODO log that player disconnected very fast.
return;
}
$this->playerStorage->onPlayerConnect($playerData);
if ($dispatch) {
$this->dispatch(__FUNCTION__, [$playerData]);
}
} | php | public function onPlayerConnect($login, $isSpectator = false, $dispatch = true)
{
try {
$playerData = $this->playerStorage->getPlayerInfo($login);
} catch (\Exception $e) {
// TODO log that player disconnected very fast.
return;
}
$this->playerStorage->onPlayerConnect($playerData);
if ($dispatch) {
$this->dispatch(__FUNCTION__, [$playerData]);
}
} | [
"public",
"function",
"onPlayerConnect",
"(",
"$",
"login",
",",
"$",
"isSpectator",
"=",
"false",
",",
"$",
"dispatch",
"=",
"true",
")",
"{",
"try",
"{",
"$",
"playerData",
"=",
"$",
"this",
"->",
"playerStorage",
"->",
"getPlayerInfo",
"(",
"$",
"logi... | Called when a player connects
@param string $login
@param bool $isSpectator | [
"Called",
"when",
"a",
"player",
"connects"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php#L65-L79 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php | PlayerDataProvider.onPlayerDisconnect | public function onPlayerDisconnect($login, $disconnectionReason)
{
$playerData = $this->playerStorage->getPlayerInfo($login);
// dedicated server sends disconnect for server itself when it's closed...
// so it's time to stop application gracefully.
if ($playerData->getPlayerId() == 0) {
// emit event to plugins
$this->application->stopApplication();
return;
}
$this->playerStorage->onPlayerDisconnect($playerData, $disconnectionReason);
$this->dispatch(__FUNCTION__, [$playerData, $disconnectionReason]);
} | php | public function onPlayerDisconnect($login, $disconnectionReason)
{
$playerData = $this->playerStorage->getPlayerInfo($login);
// dedicated server sends disconnect for server itself when it's closed...
// so it's time to stop application gracefully.
if ($playerData->getPlayerId() == 0) {
// emit event to plugins
$this->application->stopApplication();
return;
}
$this->playerStorage->onPlayerDisconnect($playerData, $disconnectionReason);
$this->dispatch(__FUNCTION__, [$playerData, $disconnectionReason]);
} | [
"public",
"function",
"onPlayerDisconnect",
"(",
"$",
"login",
",",
"$",
"disconnectionReason",
")",
"{",
"$",
"playerData",
"=",
"$",
"this",
"->",
"playerStorage",
"->",
"getPlayerInfo",
"(",
"$",
"login",
")",
";",
"// dedicated server sends disconnect for server... | Called when a player disconnects
@param $login
@param $disconnectionReason | [
"Called",
"when",
"a",
"player",
"disconnects"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php#L87-L101 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php | PlayerDataProvider.onPlayerAlliesChanged | public function onPlayerAlliesChanged($login)
{
$playerData = $this->playerStorage->getPlayerInfo($login);
$newPlayerData = $this->playerStorage->getPlayerInfo($login, true);
$this->playerStorage->onPlayerAlliesChanged($playerData, $newPlayerData);
$this->dispatch(__FUNCTION__, [$playerData, $newPlayerData]);
} | php | public function onPlayerAlliesChanged($login)
{
$playerData = $this->playerStorage->getPlayerInfo($login);
$newPlayerData = $this->playerStorage->getPlayerInfo($login, true);
$this->playerStorage->onPlayerAlliesChanged($playerData, $newPlayerData);
$this->dispatch(__FUNCTION__, [$playerData, $newPlayerData]);
} | [
"public",
"function",
"onPlayerAlliesChanged",
"(",
"$",
"login",
")",
"{",
"$",
"playerData",
"=",
"$",
"this",
"->",
"playerStorage",
"->",
"getPlayerInfo",
"(",
"$",
"login",
")",
";",
"$",
"newPlayerData",
"=",
"$",
"this",
"->",
"playerStorage",
"->",
... | When player changes allies. | [
"When",
"player",
"changes",
"allies",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/PlayerDataProvider.php#L123-L130 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php | ActionFactory.createManialinkAction | public function createManialinkAction(ManialinkInterface $manialink, $callable, $args, $permanent = false)
{
$class = $this->class;
/** @var Action $action */
$action = new $class($callable, $args, $permanent);
$this->actions[$action->getId()] = $action;
$this->actionsByManialink[$manialink->getId()][$action->getId()] = $action;
$this->manialinkByAction[$action->getId()] = $manialink;
return $action->getId();
} | php | public function createManialinkAction(ManialinkInterface $manialink, $callable, $args, $permanent = false)
{
$class = $this->class;
/** @var Action $action */
$action = new $class($callable, $args, $permanent);
$this->actions[$action->getId()] = $action;
$this->actionsByManialink[$manialink->getId()][$action->getId()] = $action;
$this->manialinkByAction[$action->getId()] = $manialink;
return $action->getId();
} | [
"public",
"function",
"createManialinkAction",
"(",
"ManialinkInterface",
"$",
"manialink",
",",
"$",
"callable",
",",
"$",
"args",
",",
"$",
"permanent",
"=",
"false",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"/** @var Action $action */",... | Create a Manialink action for a manialink.
@param ManialinkInterface $manialink
@param $callable
@param array $args
@param boolean $permanent
@return string action Id | [
"Create",
"a",
"Manialink",
"action",
"for",
"a",
"manialink",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php#L48-L58 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php | ActionFactory.destroyManialinkActions | public function destroyManialinkActions(ManialinkInterface $manialink)
{
if (isset($this->actionsByManialink[$manialink->getId()])) {
foreach ($this->actionsByManialink[$manialink->getId()] as $actionId => $action) {
unset($this->actions[$actionId]);
unset($this->manialinkByAction[$actionId]);
}
unset($this->actionsByManialink[$manialink->getId()]);
}
} | php | public function destroyManialinkActions(ManialinkInterface $manialink)
{
if (isset($this->actionsByManialink[$manialink->getId()])) {
foreach ($this->actionsByManialink[$manialink->getId()] as $actionId => $action) {
unset($this->actions[$actionId]);
unset($this->manialinkByAction[$actionId]);
}
unset($this->actionsByManialink[$manialink->getId()]);
}
} | [
"public",
"function",
"destroyManialinkActions",
"(",
"ManialinkInterface",
"$",
"manialink",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"actionsByManialink",
"[",
"$",
"manialink",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"foreach",
"(",
"$... | Destroy all actions for a manialink.
@param ManialinkInterface $manialink | [
"Destroy",
"all",
"actions",
"for",
"a",
"manialink",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php#L65-L75 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php | ActionFactory.destroyNotPermanentActions | public function destroyNotPermanentActions(ManialinkInterface $manialink)
{
if (isset($this->actionsByManialink[$manialink->getId()])) {
foreach ($this->actionsByManialink[$manialink->getId()] as $actionId => $action) {
if (!$action->isPermanent()) {
$this->destroyAction($actionId);
}
}
}
} | php | public function destroyNotPermanentActions(ManialinkInterface $manialink)
{
if (isset($this->actionsByManialink[$manialink->getId()])) {
foreach ($this->actionsByManialink[$manialink->getId()] as $actionId => $action) {
if (!$action->isPermanent()) {
$this->destroyAction($actionId);
}
}
}
} | [
"public",
"function",
"destroyNotPermanentActions",
"(",
"ManialinkInterface",
"$",
"manialink",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"actionsByManialink",
"[",
"$",
"manialink",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"foreach",
"(",
... | Destroy actions that are not permanent actions.
@param ManialinkInterface $manialink | [
"Destroy",
"actions",
"that",
"are",
"not",
"permanent",
"actions",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php#L82-L91 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php | ActionFactory.destroyAction | public function destroyAction($actionId)
{
if (isset($this->manialinkByAction[$actionId])) {
unset($this->actionsByManialink[$this->manialinkByAction[$actionId]->getId()][$actionId]);
unset($this->actions[$actionId]);
}
} | php | public function destroyAction($actionId)
{
if (isset($this->manialinkByAction[$actionId])) {
unset($this->actionsByManialink[$this->manialinkByAction[$actionId]->getId()][$actionId]);
unset($this->actions[$actionId]);
}
} | [
"public",
"function",
"destroyAction",
"(",
"$",
"actionId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"manialinkByAction",
"[",
"$",
"actionId",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"actionsByManialink",
"[",
"$",
"this",
"... | Destroy an individual action.
@param $actionId | [
"Destroy",
"an",
"individual",
"action",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/Gui/ActionFactory.php#L99-L105 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/WidgetCurrentMap/Plugins/WidgetCurrentMap.php | WidgetCurrentMap.onMapRatingsLoaded | public function onMapRatingsLoaded($ratings)
{
$this->widget->setMapRatings($ratings);
$this->widget->update($this->players);
} | php | public function onMapRatingsLoaded($ratings)
{
$this->widget->setMapRatings($ratings);
$this->widget->update($this->players);
} | [
"public",
"function",
"onMapRatingsLoaded",
"(",
"$",
"ratings",
")",
"{",
"$",
"this",
"->",
"widget",
"->",
"setMapRatings",
"(",
"$",
"ratings",
")",
";",
"$",
"this",
"->",
"widget",
"->",
"update",
"(",
"$",
"this",
"->",
"players",
")",
";",
"}"
... | Called when map ratings are loaded.
@param Maprating[] $ratings
@return void | [
"Called",
"when",
"map",
"ratings",
"are",
"loaded",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/WidgetCurrentMap/Plugins/WidgetCurrentMap.php#L85-L89 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/WidgetCurrentMap/Plugins/WidgetCurrentMap.php | WidgetCurrentMap.onMapRatingsChanged | public function onMapRatingsChanged($login, $score, $ratings)
{
$this->widget->setMapRatings($ratings);
$this->widget->update($this->players);
} | php | public function onMapRatingsChanged($login, $score, $ratings)
{
$this->widget->setMapRatings($ratings);
$this->widget->update($this->players);
} | [
"public",
"function",
"onMapRatingsChanged",
"(",
"$",
"login",
",",
"$",
"score",
",",
"$",
"ratings",
")",
"{",
"$",
"this",
"->",
"widget",
"->",
"setMapRatings",
"(",
"$",
"ratings",
")",
";",
"$",
"this",
"->",
"widget",
"->",
"update",
"(",
"$",
... | Called when map ratings are changed.
@param string $login
@param int $score
@param Maprating[] $ratings
@return void | [
"Called",
"when",
"map",
"ratings",
"are",
"changed",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/WidgetCurrentMap/Plugins/WidgetCurrentMap.php#L99-L103 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslCallbacks.php | XslCallbacks.addCallback | public function addCallback(string $name, $callback)
{
if (!is_object($callback)) {
throw new \InvalidArgumentException('Given callback must be an object');
}
$this->callbacks[$name] = $callback;
} | php | public function addCallback(string $name, $callback)
{
if (!is_object($callback)) {
throw new \InvalidArgumentException('Given callback must be an object');
}
$this->callbacks[$name] = $callback;
} | [
"public",
"function",
"addCallback",
"(",
"string",
"$",
"name",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given callback must be an object'",
")",... | register a new instance as callback
@param string $name name to register the callback under
@param object $callback
@throws \InvalidArgumentException | [
"register",
"a",
"new",
"instance",
"as",
"callback"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslCallbacks.php#L33-L40 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslCallbacks.php | XslCallbacks.callback | private function callback(string $name)
{
if (!$this->hasCallback($name)) {
throw new XslCallbackException('A callback with the name ' . $name . ' does not exist.');
}
return $this->callbacks[$name];
} | php | private function callback(string $name)
{
if (!$this->hasCallback($name)) {
throw new XslCallbackException('A callback with the name ' . $name . ' does not exist.');
}
return $this->callbacks[$name];
} | [
"private",
"function",
"callback",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCallback",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"XslCallbackException",
"(",
"'A callback with the name '",
".",
"$",
"name",
".",
... | returns a callback
@param string $name
@return object
@throws \stubbles\xml\xsl\XslCallbackException | [
"returns",
"a",
"callback"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslCallbacks.php#L70-L77 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.create | public static function create(string $title, string $link, string $description): self
{
return new self($title, $link, $description);
} | php | public static function create(string $title, string $link, string $description): self
{
return new self($title, $link, $description);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"link",
",",
"string",
"$",
"description",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"$",
"title",
",",
"$",
"link",
",",
"$",
"description",
")",
"... | create a new stubRssFeedItem
@param string $title title of the item
@param string $link URL of the item
@param string $description item synopsis
@return \stubbles\xml\rss\RssFeedItem | [
"create",
"a",
"new",
"stubRssFeedItem"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L134-L137 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.fromEntity | public static function fromEntity($entity, array $overrides = []): self
{
if (!is_object($entity)) {
throw new \InvalidArgumentException('Given entity must be an object.');
}
$annotations = annotationsOf($entity);
if (!$annotations->contain('RssFeedItem')) {
throw new XmlException(
'Class ' . get_class($entity) . ' is not annotated with @RssFeedItem.'
);
}
$rssFeedItemAnnotation = $annotations->firstNamed('RssFeedItem');
$self = new self(
$overrides['title'] ??
self::getRequiredAttribute(
$entity,
'title',
$rssFeedItemAnnotation->getTitleMethod('getTitle')
),
$overrides['link'] ??
self::getRequiredAttribute(
$entity,
'link',
$rssFeedItemAnnotation->getLinkMethod('getLink')
),
$overrides['description'] ??
self::getRequiredAttribute(
$entity,
'description',
$rssFeedItemAnnotation->getDescriptionMethod('getDescription')
)
);
foreach (self::METHODS as $itemMethod => $defaultMethod) {
if (isset($overrides[$itemMethod])) {
$self->$itemMethod($overrides[$itemMethod]);
continue;
}
if (substr($defaultMethod, 0, 3) === 'get') {
$annotationMethod = $defaultMethod . 'Method';
} else {
$annotationMethod = 'get' . $defaultMethod . 'Method';
}
$entityMethod = $rssFeedItemAnnotation->$annotationMethod($defaultMethod);
if (method_exists($entity, $entityMethod)) {
$self->$itemMethod($entity->$entityMethod());
}
}
return $self;
} | php | public static function fromEntity($entity, array $overrides = []): self
{
if (!is_object($entity)) {
throw new \InvalidArgumentException('Given entity must be an object.');
}
$annotations = annotationsOf($entity);
if (!$annotations->contain('RssFeedItem')) {
throw new XmlException(
'Class ' . get_class($entity) . ' is not annotated with @RssFeedItem.'
);
}
$rssFeedItemAnnotation = $annotations->firstNamed('RssFeedItem');
$self = new self(
$overrides['title'] ??
self::getRequiredAttribute(
$entity,
'title',
$rssFeedItemAnnotation->getTitleMethod('getTitle')
),
$overrides['link'] ??
self::getRequiredAttribute(
$entity,
'link',
$rssFeedItemAnnotation->getLinkMethod('getLink')
),
$overrides['description'] ??
self::getRequiredAttribute(
$entity,
'description',
$rssFeedItemAnnotation->getDescriptionMethod('getDescription')
)
);
foreach (self::METHODS as $itemMethod => $defaultMethod) {
if (isset($overrides[$itemMethod])) {
$self->$itemMethod($overrides[$itemMethod]);
continue;
}
if (substr($defaultMethod, 0, 3) === 'get') {
$annotationMethod = $defaultMethod . 'Method';
} else {
$annotationMethod = 'get' . $defaultMethod . 'Method';
}
$entityMethod = $rssFeedItemAnnotation->$annotationMethod($defaultMethod);
if (method_exists($entity, $entityMethod)) {
$self->$itemMethod($entity->$entityMethod());
}
}
return $self;
} | [
"public",
"static",
"function",
"fromEntity",
"(",
"$",
"entity",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
":",
"self",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"entity",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(... | creates a new stubRssFeedItem from given entity
@param object $entity
@param array $overrides
@return \stubbles\xml\rss\RssFeedItem
@throws \InvalidArgumentException
@throws \stubbles\xml\XmlException | [
"creates",
"a",
"new",
"stubRssFeedItem",
"from",
"given",
"entity"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L148-L202 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.getRequiredAttribute | private static function getRequiredAttribute(
$entity,
string $name,
string $method
) {
if (!method_exists($entity, $method)) {
throw new XmlException(
'RSSFeedItem ' . get_class($entity)
. ' does not offer a method named "' . $method
. '" to return the ' . $name . ', but ' . $name
. ' is required.'
);
}
return $entity->$method();
} | php | private static function getRequiredAttribute(
$entity,
string $name,
string $method
) {
if (!method_exists($entity, $method)) {
throw new XmlException(
'RSSFeedItem ' . get_class($entity)
. ' does not offer a method named "' . $method
. '" to return the ' . $name . ', but ' . $name
. ' is required.'
);
}
return $entity->$method();
} | [
"private",
"static",
"function",
"getRequiredAttribute",
"(",
"$",
"entity",
",",
"string",
"$",
"name",
",",
"string",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"entity",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"Xm... | helper method to retrieve a required attribute
@param object $entity
@param string $name
@param string $method
@return string
@throws \stubbles\xml\XmlException | [
"helper",
"method",
"to",
"retrieve",
"a",
"required",
"attribute"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L213-L228 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.byAuthor | public function byAuthor(string $author): self
{
if (!strstr($author, '@')) {
$this->author = 'nospam@example.com (' . $author . ')';
} else {
$this->author = $author;
}
return $this;
} | php | public function byAuthor(string $author): self
{
if (!strstr($author, '@')) {
$this->author = 'nospam@example.com (' . $author . ')';
} else {
$this->author = $author;
}
return $this;
} | [
"public",
"function",
"byAuthor",
"(",
"string",
"$",
"author",
")",
":",
"self",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"author",
",",
"'@'",
")",
")",
"{",
"$",
"this",
"->",
"author",
"=",
"'nospam@example.com ('",
".",
"$",
"author",
".",
"')'"... | set the email address of the author of the item who created the item
@param string $author author of rss feed item
@return \stubbles\xml\rss\RssFeedItem | [
"set",
"the",
"email",
"address",
"of",
"the",
"author",
"of",
"the",
"item",
"who",
"created",
"the",
"item"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L266-L275 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.inCategory | public function inCategory(string $category, string $domain = ''): self
{
$this->categories[] = ['category' => $category, 'domain' => $domain];
return $this;
} | php | public function inCategory(string $category, string $domain = ''): self
{
$this->categories[] = ['category' => $category, 'domain' => $domain];
return $this;
} | [
"public",
"function",
"inCategory",
"(",
"string",
"$",
"category",
",",
"string",
"$",
"domain",
"=",
"''",
")",
":",
"self",
"{",
"$",
"this",
"->",
"categories",
"[",
"]",
"=",
"[",
"'category'",
"=>",
"$",
"category",
",",
"'domain'",
"=>",
"$",
... | set one or more categories where the item is included into
@param string $category category where the item is included
@param string $domain categorization taxonomy
@return \stubbles\xml\rss\RssFeedItem | [
"set",
"one",
"or",
"more",
"categories",
"where",
"the",
"item",
"is",
"included",
"into"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L304-L308 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.inCategories | public function inCategories(array $categories): self
{
foreach ($categories as $category) {
if (is_array($category)) {
$this->inCategory($category['category'], $category['domain']);
} else {
$this->inCategory($category);
}
}
return $this;
} | php | public function inCategories(array $categories): self
{
foreach ($categories as $category) {
if (is_array($category)) {
$this->inCategory($category['category'], $category['domain']);
} else {
$this->inCategory($category);
}
}
return $this;
} | [
"public",
"function",
"inCategories",
"(",
"array",
"$",
"categories",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"category",
")",
")",
"{",
"$",
"this",
"->",
"inCategory... | sets categories where the item is included into
Does not consider the domain of the category.
@param string[] $categories
@return \stubbles\xml\rss\RssFeedItem | [
"sets",
"categories",
"where",
"the",
"item",
"is",
"included",
"into"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L318-L329 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.deliveringEnclosure | public function deliveringEnclosure(string $url, int $length, string $type): self
{
$this->enclosures[] = [
'url' => $url,
'length' => $length,
'type' => $type
];
return $this;
} | php | public function deliveringEnclosure(string $url, int $length, string $type): self
{
$this->enclosures[] = [
'url' => $url,
'length' => $length,
'type' => $type
];
return $this;
} | [
"public",
"function",
"deliveringEnclosure",
"(",
"string",
"$",
"url",
",",
"int",
"$",
"length",
",",
"string",
"$",
"type",
")",
":",
"self",
"{",
"$",
"this",
"->",
"enclosures",
"[",
"]",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'length'",
"=>... | add an enclosure to the item
@param string $url location of enclosure
@param int $length length of enclosure in bytes
@param string $type MIME type of enclosure
@return \stubbles\xml\rss\RssFeedItem | [
"add",
"an",
"enclosure",
"to",
"the",
"item"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L381-L389 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.withGuid | public function withGuid(string $guid): self
{
$this->guid = $guid;
$this->isPermaLink = true;
return $this;
} | php | public function withGuid(string $guid): self
{
$this->guid = $guid;
$this->isPermaLink = true;
return $this;
} | [
"public",
"function",
"withGuid",
"(",
"string",
"$",
"guid",
")",
":",
"self",
"{",
"$",
"this",
"->",
"guid",
"=",
"$",
"guid",
";",
"$",
"this",
"->",
"isPermaLink",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | set id of rss feed item
@param string $guid the id of the item
@return \stubbles\xml\rss\RssFeedItem | [
"set",
"id",
"of",
"rss",
"feed",
"item"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L419-L424 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeedItem.php | RssFeedItem.inspiredBySource | public function inspiredBySource(string $name, string $url): self
{
$this->sources[] = ['name' => $name, 'url' => $url];
return $this;
} | php | public function inspiredBySource(string $name, string $url): self
{
$this->sources[] = ['name' => $name, 'url' => $url];
return $this;
} | [
"public",
"function",
"inspiredBySource",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"url",
")",
":",
"self",
"{",
"$",
"this",
"->",
"sources",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'url'",
"=>",
"$",
"url",
"]",
";",
"return... | set the source where that the item came from
@param string $name name of the source
@param string $url url of the source
@return \stubbles\xml\rss\RssFeedItem | [
"set",
"the",
"source",
"where",
"that",
"the",
"item",
"came",
"from"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeedItem.php#L510-L514 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Content.php | Content.parse | public static function parse(Tag &$Tag)
{
if (!empty($Tag->content) && $Tag->hasOption('translate') && is_callable(Config::get('translator'))) {
$Tag->content = call_user_func_array(
Config::get('translator'),
array(
$Tag->content,
Config::get('textdomain')
)
);
}
if ($Tag->hasOption('bbContent')) {
self::bb($Tag->content);
}
if ($Tag->hasOption('markdown')) {
$Tag->addOption('cleanContent');
self::markdown($Tag->content);
}
if ($Tag->hasOption('compress')) {
self::compress($Tag);
}
return $Tag->content;
} | php | public static function parse(Tag &$Tag)
{
if (!empty($Tag->content) && $Tag->hasOption('translate') && is_callable(Config::get('translator'))) {
$Tag->content = call_user_func_array(
Config::get('translator'),
array(
$Tag->content,
Config::get('textdomain')
)
);
}
if ($Tag->hasOption('bbContent')) {
self::bb($Tag->content);
}
if ($Tag->hasOption('markdown')) {
$Tag->addOption('cleanContent');
self::markdown($Tag->content);
}
if ($Tag->hasOption('compress')) {
self::compress($Tag);
}
return $Tag->content;
} | [
"public",
"static",
"function",
"parse",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"Tag",
"->",
"content",
")",
"&&",
"$",
"Tag",
"->",
"hasOption",
"(",
"'translate'",
")",
"&&",
"is_callable",
"(",
"Config",
"::",
... | Checks if any parsing method should be appended to the
Tags content.
@param Tag &$Tag a Tag instance.
@return string the tags content. | [
"Checks",
"if",
"any",
"parsing",
"method",
"should",
"be",
"appended",
"to",
"the",
"Tags",
"content",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Content.php#L59-L85 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Content.php | Content.bb | public static function bb(&$content)
{
$content = preg_replace(array_flip(self::$_bbs), self::$_bbs, $content);
return $content;
} | php | public static function bb(&$content)
{
$content = preg_replace(array_flip(self::$_bbs), self::$_bbs, $content);
return $content;
} | [
"public",
"static",
"function",
"bb",
"(",
"&",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"preg_replace",
"(",
"array_flip",
"(",
"self",
"::",
"$",
"_bbs",
")",
",",
"self",
"::",
"$",
"_bbs",
",",
"$",
"content",
")",
";",
"return",
"$",
"co... | Appends the BB replacements to the tags content.
@param string &$content the tags content.
@return string the tags content. | [
"Appends",
"the",
"BB",
"replacements",
"to",
"the",
"tags",
"content",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Content.php#L94-L99 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Content.php | Content.markdown | public static function markdown(&$content)
{
if (self::$MarkdownParser === null) {
if (class_exists('dflydev\markdown\MarkdownParser')) {
self::$MarkdownParser = new \dflydev\markdown\MarkdownParser;
} else {
self::$MarkdownParser = false;
}
}
if (self::$MarkdownParser !== false) {
$content = trim(self::$MarkdownParser->transformMarkdown($content));
}
return $content;
} | php | public static function markdown(&$content)
{
if (self::$MarkdownParser === null) {
if (class_exists('dflydev\markdown\MarkdownParser')) {
self::$MarkdownParser = new \dflydev\markdown\MarkdownParser;
} else {
self::$MarkdownParser = false;
}
}
if (self::$MarkdownParser !== false) {
$content = trim(self::$MarkdownParser->transformMarkdown($content));
}
return $content;
} | [
"public",
"static",
"function",
"markdown",
"(",
"&",
"$",
"content",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"MarkdownParser",
"===",
"null",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'dflydev\\markdown\\MarkdownParser'",
")",
")",
"{",
"self",
"::",
"$"... | Appends markdown to the tags content.
@param string &$content the tags content.
@return string the tags content. | [
"Appends",
"markdown",
"to",
"the",
"tags",
"content",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Content.php#L108-L123 | train |
Evaneos/daemon | src/Worker.php | Worker.run | public function run($sessionId = null)
{
$this->sessionId = ($sessionId !== null) ? $sessionId : uniqid();
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, [$this, 'signalHandler']);
pcntl_signal(SIGINT, [$this, 'signalHandler']);
pcntl_signal(SIGHUP, [$this, 'signalHandler']);
}
$this->daemon->start();
} | php | public function run($sessionId = null)
{
$this->sessionId = ($sessionId !== null) ? $sessionId : uniqid();
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, [$this, 'signalHandler']);
pcntl_signal(SIGINT, [$this, 'signalHandler']);
pcntl_signal(SIGHUP, [$this, 'signalHandler']);
}
$this->daemon->start();
} | [
"public",
"function",
"run",
"(",
"$",
"sessionId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"sessionId",
"=",
"(",
"$",
"sessionId",
"!==",
"null",
")",
"?",
"$",
"sessionId",
":",
"uniqid",
"(",
")",
";",
"if",
"(",
"function_exists",
"(",
"'pcntl... | Run as a daemon
@param string $sessionId
@return void | [
"Run",
"as",
"a",
"daemon"
] | 9f9f5f74fb011b1e49b4d7d196f5e665d41d359f | https://github.com/Evaneos/daemon/blob/9f9f5f74fb011b1e49b4d7d196f5e665d41d359f/src/Worker.php#L46-L57 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Store.php | Store.add | public static function add(Tag &$Tag)
{
if (Config::get('store') == 'global') {
self::$_tagStore[$Tag->ID] = &$Tag;
} elseif (Config::get('store') == 'internal') {
Config::getHTMLInstance()->tagStore[$Tag->ID] = &$Tag;
}
} | php | public static function add(Tag &$Tag)
{
if (Config::get('store') == 'global') {
self::$_tagStore[$Tag->ID] = &$Tag;
} elseif (Config::get('store') == 'internal') {
Config::getHTMLInstance()->tagStore[$Tag->ID] = &$Tag;
}
} | [
"public",
"static",
"function",
"add",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"Config",
"::",
"get",
"(",
"'store'",
")",
"==",
"'global'",
")",
"{",
"self",
"::",
"$",
"_tagStore",
"[",
"$",
"Tag",
"->",
"ID",
"]",
"=",
"&",
"$",
"T... | Pass a opened tag to the store
Checks if configuration is set to internal and puts the tag
into HTML calls if true
@param Tag &$Tag the Tag to be stored.
@return void | [
"Pass",
"a",
"opened",
"tag",
"to",
"the",
"store"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Store.php#L69-L76 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Store.php | Store.get | public static function get($ID = 'latest', $offset = 0)
{
if ($ID === 'latest') {
if ($offset > 0) {
$offset = $offset*-1;
}
if (Config::get('store') == 'global') {
$k = array_splice(@array_keys(self::$_tagStore), -1+$offset, 1);
return self::$_tagStore[$k[0]];
} elseif (Config::get('store') == 'internal') {
$Store = Config::getHTMLInstance()->tagStore;
$k = array_splice(@array_keys($Store), -1+$offset, 1);
return $Store[$k[0]];
}
} elseif (is_int($ID)) {
if (Config::get('store') == 'global' && isset(self::$_tagStore[$ID])) {
return self::$_tagStore[$ID];
} elseif (Config::get('store') == 'internal'
&& isset(Config::getHTMLInstance()->tagStore[$ID])
) {
return Config::getHTMLInstance()->tagStore[$ID];
}
}
return false;
} | php | public static function get($ID = 'latest', $offset = 0)
{
if ($ID === 'latest') {
if ($offset > 0) {
$offset = $offset*-1;
}
if (Config::get('store') == 'global') {
$k = array_splice(@array_keys(self::$_tagStore), -1+$offset, 1);
return self::$_tagStore[$k[0]];
} elseif (Config::get('store') == 'internal') {
$Store = Config::getHTMLInstance()->tagStore;
$k = array_splice(@array_keys($Store), -1+$offset, 1);
return $Store[$k[0]];
}
} elseif (is_int($ID)) {
if (Config::get('store') == 'global' && isset(self::$_tagStore[$ID])) {
return self::$_tagStore[$ID];
} elseif (Config::get('store') == 'internal'
&& isset(Config::getHTMLInstance()->tagStore[$ID])
) {
return Config::getHTMLInstance()->tagStore[$ID];
}
}
return false;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"ID",
"=",
"'latest'",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"ID",
"===",
"'latest'",
")",
"{",
"if",
"(",
"$",
"offset",
">",
"0",
")",
"{",
"$",
"offset",
"=",
"$",
"offset",
... | Gets a Tag from store.
Checks if configuration is set to internal
@param mixed $ID Tag ID or 'latest' for the latest tag stored.
@return Tag | [
"Gets",
"a",
"Tag",
"from",
"store",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Store.php#L87-L112 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Store.php | Store.remove | public static function remove(Tag &$Tag)
{
if (Config::get('store') == 'global' && isset(self::$_tagStore[$Tag->ID])) {
unset(self::$_tagStore[$Tag->ID]);
} elseif (Config::get('store') == 'internal'
&& isset(Config::getHTMLInstance()->tagStore[$Tag->ID])
) {
unset(Config::getHTMLInstance()->tagStore[$Tag->ID]);
}
} | php | public static function remove(Tag &$Tag)
{
if (Config::get('store') == 'global' && isset(self::$_tagStore[$Tag->ID])) {
unset(self::$_tagStore[$Tag->ID]);
} elseif (Config::get('store') == 'internal'
&& isset(Config::getHTMLInstance()->tagStore[$Tag->ID])
) {
unset(Config::getHTMLInstance()->tagStore[$Tag->ID]);
}
} | [
"public",
"static",
"function",
"remove",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"Config",
"::",
"get",
"(",
"'store'",
")",
"==",
"'global'",
"&&",
"isset",
"(",
"self",
"::",
"$",
"_tagStore",
"[",
"$",
"Tag",
"->",
"ID",
"]",
")",
"... | Removes the passed tag from tag store.
@param Tag &$Tag the tag to be removed
@return void | [
"Removes",
"the",
"passed",
"tag",
"from",
"tag",
"store",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Store.php#L121-L130 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Store.php | Store.hasTags | public static function hasTags()
{
if (Config::get('store') == 'global') {
return count(self::$_tagStore);
} elseif (Config::get('store') == 'internal') {
return count(Config::getHTMLInstance()->tagStore);
}
} | php | public static function hasTags()
{
if (Config::get('store') == 'global') {
return count(self::$_tagStore);
} elseif (Config::get('store') == 'internal') {
return count(Config::getHTMLInstance()->tagStore);
}
} | [
"public",
"static",
"function",
"hasTags",
"(",
")",
"{",
"if",
"(",
"Config",
"::",
"get",
"(",
"'store'",
")",
"==",
"'global'",
")",
"{",
"return",
"count",
"(",
"self",
"::",
"$",
"_tagStore",
")",
";",
"}",
"elseif",
"(",
"Config",
"::",
"get",
... | Checks if some Tags are stored.
@return boolean | [
"Checks",
"if",
"some",
"Tags",
"are",
"stored",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Store.php#L137-L144 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Input.php | Input.sure | public function sure()
{
$this->_label = null;
switch ($this->called) {
case 'textarea':
$i = 2;
break;
default:
$i = 1;
break;
}
if (isset($this->args[$i])) {
$this->_label = $this->args[$i];
}
return true;
} | php | public function sure()
{
$this->_label = null;
switch ($this->called) {
case 'textarea':
$i = 2;
break;
default:
$i = 1;
break;
}
if (isset($this->args[$i])) {
$this->_label = $this->args[$i];
}
return true;
} | [
"public",
"function",
"sure",
"(",
")",
"{",
"$",
"this",
"->",
"_label",
"=",
"null",
";",
"switch",
"(",
"$",
"this",
"->",
"called",
")",
"{",
"case",
"'textarea'",
":",
"$",
"i",
"=",
"2",
";",
"break",
";",
"default",
":",
"$",
"i",
"=",
"... | Check if Module can be used.
@return boolean | [
"Check",
"if",
"Module",
"can",
"be",
"used",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Input.php#L72-L89 | train |
stubbles/stubbles-xml | src/main/php/LibXmlStreamWriter.php | LibXmlStreamWriter.asDom | public function asDom(): \DOMDocument
{
$doc = new \DOMDocument();
$doc->loadXML($this->writer->outputMemory());
return $doc;
} | php | public function asDom(): \DOMDocument
{
$doc = new \DOMDocument();
$doc->loadXML($this->writer->outputMemory());
return $doc;
} | [
"public",
"function",
"asDom",
"(",
")",
":",
"\\",
"DOMDocument",
"{",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"this",
"->",
"writer",
"->",
"outputMemory",
"(",
")",
")",
";",
"return",
"... | Return the XML as a DOM
@return \DOMDocument | [
"Return",
"the",
"XML",
"as",
"a",
"DOM"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/LibXmlStreamWriter.php#L201-L206 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeed.php | RssFeed.addItem | public function addItem(string $title, string $link, string $description): RssFeedItem
{
return $this->items[] = RssFeedItem::create($title, $link, $description);
} | php | public function addItem(string $title, string $link, string $description): RssFeedItem
{
return $this->items[] = RssFeedItem::create($title, $link, $description);
} | [
"public",
"function",
"addItem",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"link",
",",
"string",
"$",
"description",
")",
":",
"RssFeedItem",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"RssFeedItem",
"::",
"create",
"(",
"$",
"ti... | add an item to the feed and returns it
@param string $title title of the item
@param string $link URL of the item
@param string $description item synopsis
@return \stubbles\xml\rss\RssFeedItem | [
"add",
"an",
"item",
"to",
"the",
"feed",
"and",
"returns",
"it"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeed.php#L215-L218 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeed.php | RssFeed.addEntity | public function addEntity($entity, array $overrides = []): RssFeedItem
{
return $this->items[] = RssFeedItem::fromEntity($entity, $overrides);
} | php | public function addEntity($entity, array $overrides = []): RssFeedItem
{
return $this->items[] = RssFeedItem::fromEntity($entity, $overrides);
} | [
"public",
"function",
"addEntity",
"(",
"$",
"entity",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
":",
"RssFeedItem",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"RssFeedItem",
"::",
"fromEntity",
"(",
"$",
"entity",
",",
"$",
... | creates an item from an entity to the rss feed
Return value is the created item.
@param object $entity
@param array $overrides
@return \stubbles\xml\rss\RssFeedItem | [
"creates",
"an",
"item",
"from",
"an",
"entity",
"to",
"the",
"rss",
"feed"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeed.php#L229-L232 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeed.php | RssFeed.setManagingEditor | public function setManagingEditor(string $managingEditor): self
{
if (!strstr($managingEditor, '@')) {
$this->managingEditor = 'nospam@example.com (' . $managingEditor . ')';
} else {
$this->managingEditor = $managingEditor;
}
return $this;
} | php | public function setManagingEditor(string $managingEditor): self
{
if (!strstr($managingEditor, '@')) {
$this->managingEditor = 'nospam@example.com (' . $managingEditor . ')';
} else {
$this->managingEditor = $managingEditor;
}
return $this;
} | [
"public",
"function",
"setManagingEditor",
"(",
"string",
"$",
"managingEditor",
")",
":",
"self",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"managingEditor",
",",
"'@'",
")",
")",
"{",
"$",
"this",
"->",
"managingEditor",
"=",
"'nospam@example.com ('",
".",
... | set email address for person responsible for editorial content
@param string $managingEditor
@return \stubbles\xml\rss\RssFeed | [
"set",
"email",
"address",
"for",
"person",
"responsible",
"for",
"editorial",
"content"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeed.php#L304-L313 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeed.php | RssFeed.setWebMaster | public function setWebMaster(string $webMaster): self
{
if (!strstr($webMaster, '@')) {
$this->webMaster = 'nospam@example.com (' . $webMaster . ')';
} else {
$this->webMaster = $webMaster;
}
return $this;
} | php | public function setWebMaster(string $webMaster): self
{
if (!strstr($webMaster, '@')) {
$this->webMaster = 'nospam@example.com (' . $webMaster . ')';
} else {
$this->webMaster = $webMaster;
}
return $this;
} | [
"public",
"function",
"setWebMaster",
"(",
"string",
"$",
"webMaster",
")",
":",
"self",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"webMaster",
",",
"'@'",
")",
")",
"{",
"$",
"this",
"->",
"webMaster",
"=",
"'nospam@example.com ('",
".",
"$",
"webMaster"... | set email address for person responsible for technical issues relating to channel
@param string $webMaster
@return \stubbles\xml\rss\RssFeed | [
"set",
"email",
"address",
"for",
"person",
"responsible",
"for",
"technical",
"issues",
"relating",
"to",
"channel"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeed.php#L341-L350 | train |
stubbles/stubbles-xml | src/main/php/rss/RssFeed.php | RssFeed.setImage | public function setImage(
string $url,
string $description,
int $width = 88,
int $height = 31
): self {
if (144 < $width || 0 > $width) {
throw new \InvalidArgumentException('Width must be a value between 0 and 144.');
}
if (400 < $height || 0 > $height) {
throw new \InvalidArgumentException('Height must be a value between 0 and 400.');
}
$this->image = [
'url' => $url,
'description' => $description,
'width' => $width,
'height' => $height
];
return $this;
} | php | public function setImage(
string $url,
string $description,
int $width = 88,
int $height = 31
): self {
if (144 < $width || 0 > $width) {
throw new \InvalidArgumentException('Width must be a value between 0 and 144.');
}
if (400 < $height || 0 > $height) {
throw new \InvalidArgumentException('Height must be a value between 0 and 400.');
}
$this->image = [
'url' => $url,
'description' => $description,
'width' => $width,
'height' => $height
];
return $this;
} | [
"public",
"function",
"setImage",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"description",
",",
"int",
"$",
"width",
"=",
"88",
",",
"int",
"$",
"height",
"=",
"31",
")",
":",
"self",
"{",
"if",
"(",
"144",
"<",
"$",
"width",
"||",
"0",
">",... | specify a GIF, JPEG or PNG image to be displayed with the channel
@param string $url URL of a GIF, JPEG or PNG image that represents the channel
@param string $description contains text that is included in the TITLE attribute of the link formed around the image in the HTML rendering
@param int $width indicating the width of the image in pixels, must be 0 < $width <= 144, default 88
@param int $height indicating the height of the image in pixels, must be 0 < $height <= 400, default 31
@return \stubbles\xml\rss\RssFeed
@throws \InvalidArgumentException in case $width or $height have invalid values | [
"specify",
"a",
"GIF",
"JPEG",
"or",
"PNG",
"image",
"to",
"be",
"displayed",
"with",
"the",
"channel"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/rss/RssFeed.php#L452-L473 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Script.php | Script.sure | public function sure()
{
if ($this->hasOption('start')) {
$this->addOption('doNotSelfQlose');
}
if (empty($this->args[0])) {
$this->args[0] = array();
}
switch ($this->called) {
case 'jquery':
$this->called = 'script';
$this->args[0] = array_merge(
array(
'type' => 'text/javascript',
'src' => 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'
),
$this->args[0]
);
return false;
case 'jqueryui':
$this->called = 'script';
$this->args[0] = array_merge(
array(
'type' => 'text/javascript',
'src' => 'https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'
),
$this->args[0]
);
return false;
default:
$this->called = 'script';
break;
}
if (empty($this->args[0])) {
return false;
}
return is_array($this->args[0])
|| !(substr($this->args[0], 0, 4) == 'http'
|| substr($this->args[0], 0, 3) == '../'
|| substr($this->args[0], 0, 3) == '\./'
|| substr($this->args[0], 0, 2) == './'
|| substr($this->args[0], 0, 1) == '/'
);
} | php | public function sure()
{
if ($this->hasOption('start')) {
$this->addOption('doNotSelfQlose');
}
if (empty($this->args[0])) {
$this->args[0] = array();
}
switch ($this->called) {
case 'jquery':
$this->called = 'script';
$this->args[0] = array_merge(
array(
'type' => 'text/javascript',
'src' => 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'
),
$this->args[0]
);
return false;
case 'jqueryui':
$this->called = 'script';
$this->args[0] = array_merge(
array(
'type' => 'text/javascript',
'src' => 'https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'
),
$this->args[0]
);
return false;
default:
$this->called = 'script';
break;
}
if (empty($this->args[0])) {
return false;
}
return is_array($this->args[0])
|| !(substr($this->args[0], 0, 4) == 'http'
|| substr($this->args[0], 0, 3) == '../'
|| substr($this->args[0], 0, 3) == '\./'
|| substr($this->args[0], 0, 2) == './'
|| substr($this->args[0], 0, 1) == '/'
);
} | [
"public",
"function",
"sure",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"'start'",
")",
")",
"{",
"$",
"this",
"->",
"addOption",
"(",
"'doNotSelfQlose'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"args",
"[",
... | Check if Module should be used.
@return boolean | [
"Check",
"if",
"Module",
"should",
"be",
"used",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Script.php#L58-L105 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Config.php | Config.init | public static function init(array $initArgs = array())
{
if (!self::$_initiated) {
if (!defined('XIPHE_HTML_BASE_FOLDER')) {
define('XIPHE_HTML_BASE_FOLDER', dirname(__DIR__).DIRECTORY_SEPARATOR);
}
foreach (self::getThemasterSettings() as $key => $s) {
if (is_array($s) && isset($s['default'])) {
self::$_defaults[$key] = $s['default'];
}
}
/*
* Get the config array from config.php
*/
$config = array();
if (file_exists(XIPHE_HTML_BASE_FOLDER.'config.php')) {
call_user_func(
function () use (&$config) {
include XIPHE_HTML_BASE_FOLDER.'config.php';
}
);
} elseif(!file_exists(XIPHE_HTML_BASE_FOLDER.'config-sample.php')) {
self::_createSampleConfig();
}
/*
* Make sure config is an array.
*/
if (!is_array($config)) {
Generator::debug('$config is not an array.', 3, 7);
$config = array();
}
/*
* Merge it into the defaults
*/
$defaults = array_merge(self::$_defaults, $config);
/*
* Remove invalid keys and merge the initArgs.
*/
foreach (self::$_defaults as $k => $v) {
self::$_config[$k] = (isset($initArgs[$k]) ? $initArgs[$k] : $defaults[$k]);
}
self::$_initiated = true;
}
} | php | public static function init(array $initArgs = array())
{
if (!self::$_initiated) {
if (!defined('XIPHE_HTML_BASE_FOLDER')) {
define('XIPHE_HTML_BASE_FOLDER', dirname(__DIR__).DIRECTORY_SEPARATOR);
}
foreach (self::getThemasterSettings() as $key => $s) {
if (is_array($s) && isset($s['default'])) {
self::$_defaults[$key] = $s['default'];
}
}
/*
* Get the config array from config.php
*/
$config = array();
if (file_exists(XIPHE_HTML_BASE_FOLDER.'config.php')) {
call_user_func(
function () use (&$config) {
include XIPHE_HTML_BASE_FOLDER.'config.php';
}
);
} elseif(!file_exists(XIPHE_HTML_BASE_FOLDER.'config-sample.php')) {
self::_createSampleConfig();
}
/*
* Make sure config is an array.
*/
if (!is_array($config)) {
Generator::debug('$config is not an array.', 3, 7);
$config = array();
}
/*
* Merge it into the defaults
*/
$defaults = array_merge(self::$_defaults, $config);
/*
* Remove invalid keys and merge the initArgs.
*/
foreach (self::$_defaults as $k => $v) {
self::$_config[$k] = (isset($initArgs[$k]) ? $initArgs[$k] : $defaults[$k]);
}
self::$_initiated = true;
}
} | [
"public",
"static",
"function",
"init",
"(",
"array",
"$",
"initArgs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_initiated",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'XIPHE_HTML_BASE_FOLDER'",
")",
")",
"{",
"define",
"... | One-time-initiation for this Class.
Checks the config.php file and builds the global config.
@param array $initArgs additional configuration
@return void | [
"One",
"-",
"time",
"-",
"initiation",
"for",
"this",
"Class",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Config.php#L116-L165 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Config.php | Config.ajax | public static function ajax($activate = true)
{
if ($activate && !in_array('ajax', self::$modes)) {
self::setMode('ajax');
} else {
self::unsetMode('ajax');
}
} | php | public static function ajax($activate = true)
{
if ($activate && !in_array('ajax', self::$modes)) {
self::setMode('ajax');
} else {
self::unsetMode('ajax');
}
} | [
"public",
"static",
"function",
"ajax",
"(",
"$",
"activate",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"activate",
"&&",
"!",
"in_array",
"(",
"'ajax'",
",",
"self",
"::",
"$",
"modes",
")",
")",
"{",
"self",
"::",
"setMode",
"(",
"'ajax'",
")",
";",... | Activates or deactivates the ajax mode.
@param boolean $activate turn it off or on.
@return void | [
"Activates",
"or",
"deactivates",
"the",
"ajax",
"mode",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Config.php#L187-L194 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Config.php | Config.get | public static function get($key, $preferGlobal = false)
{
if (!self::$_initiated) {
self::init();
}
if (!isset(self::$_config[$key])) {
return null;
}
foreach (self::$modes as $mode) {
if (isset(self::$modeSettings[$mode][$key])) {
return self::$modeSettings[$mode][$key];
}
}
if (!$preferGlobal && self::$_CurrentHTMLInstance && isset(self::$_CurrentHTMLInstance->$key)) {
return self::$_CurrentHTMLInstance->$key;
} else {
if (class_exists('Xiphe\THEMASTER\core\THE')
&& class_exists(TM\THE::WPSETTINGS)
) {
try {
return TM\THEWPSETTINGS::sGet_setting($key, XIPHE_HTML_TEXTID);
} catch(\Exception $c) {
return self::$_config[$key];
}
}
return self::$_config[$key];
}
} | php | public static function get($key, $preferGlobal = false)
{
if (!self::$_initiated) {
self::init();
}
if (!isset(self::$_config[$key])) {
return null;
}
foreach (self::$modes as $mode) {
if (isset(self::$modeSettings[$mode][$key])) {
return self::$modeSettings[$mode][$key];
}
}
if (!$preferGlobal && self::$_CurrentHTMLInstance && isset(self::$_CurrentHTMLInstance->$key)) {
return self::$_CurrentHTMLInstance->$key;
} else {
if (class_exists('Xiphe\THEMASTER\core\THE')
&& class_exists(TM\THE::WPSETTINGS)
) {
try {
return TM\THEWPSETTINGS::sGet_setting($key, XIPHE_HTML_TEXTID);
} catch(\Exception $c) {
return self::$_config[$key];
}
}
return self::$_config[$key];
}
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"preferGlobal",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_initiated",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
... | Getter for the current value for the requested key.
Setting hierarchy:
- Ajax setting (if Mode is on)
- Instance setting
- THEWPSETTING (if Xiphe\THEMASTER\core\THEWPSETTINGS exists)
- config.php setting (if exists)
- default.
If the requested key is not existent on one layer the next one
will be used.
@param string $key The name of the setting.
@param boolean $preferGlobal Eliminates the instance setting from hierarchy.
@return mixed The setting value. | [
"Getter",
"for",
"the",
"current",
"value",
"for",
"the",
"requested",
"key",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Config.php#L243-L273 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.