id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,800 | firstcomputer/seeme | src/Assertion.php | Assertion.choicesIsset | public static function choicesIsset(array $values, array $choices)
{
self::notEmpty($values, null, null);
foreach ($choices as $choice) {
self::keyIsset($values, $choice, null, null);
}
} | php | public static function choicesIsset(array $values, array $choices)
{
self::notEmpty($values, null, null);
foreach ($choices as $choice) {
self::keyIsset($values, $choice, null, null);
}
} | [
"public",
"static",
"function",
"choicesIsset",
"(",
"array",
"$",
"values",
",",
"array",
"$",
"choices",
")",
"{",
"self",
"::",
"notEmpty",
"(",
"$",
"values",
",",
"null",
",",
"null",
")",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"choice",
")",
"{",
"self",
"::",
"keyIsset",
"(",
"$",
"values",
",",
"$",
"choice",
",",
"null",
",",
"null",
")",
";",
"}",
"}"
] | Determines if the values array has every choice as key and that this choice has content.
@param array $values
@param array $choices | [
"Determines",
"if",
"the",
"values",
"array",
"has",
"every",
"choice",
"as",
"key",
"and",
"that",
"this",
"choice",
"has",
"content",
"."
] | 09954a110e44afe34bb03c87d2a7cbf0a3be86b3 | https://github.com/firstcomputer/seeme/blob/09954a110e44afe34bb03c87d2a7cbf0a3be86b3/src/Assertion.php#L68-L76 |
2,801 | firstcomputer/seeme | src/Assertion.php | Assertion.ip | public static function ip($value)
{
if (!is_string($value) and !filter_var($value, FILTER_VALIDATE_IP)) {
$message = sprintf('Value "%s" expected to be a valid IP address.', static::stringify($value));
throw static::createException($value, $message, static::INVALID_IP, null);
}
} | php | public static function ip($value)
{
if (!is_string($value) and !filter_var($value, FILTER_VALIDATE_IP)) {
$message = sprintf('Value "%s" expected to be a valid IP address.', static::stringify($value));
throw static::createException($value, $message, static::INVALID_IP, null);
}
} | [
"public",
"static",
"function",
"ip",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"and",
"!",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_IP",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Value \"%s\" expected to be a valid IP address.'",
",",
"static",
"::",
"stringify",
"(",
"$",
"value",
")",
")",
";",
"throw",
"static",
"::",
"createException",
"(",
"$",
"value",
",",
"$",
"message",
",",
"static",
"::",
"INVALID_IP",
",",
"null",
")",
";",
"}",
"}"
] | Assert that value is a valid IP address
@param mixed $value
@throws Assert\AssertionFailedException | [
"Assert",
"that",
"value",
"is",
"a",
"valid",
"IP",
"address"
] | 09954a110e44afe34bb03c87d2a7cbf0a3be86b3 | https://github.com/firstcomputer/seeme/blob/09954a110e44afe34bb03c87d2a7cbf0a3be86b3/src/Assertion.php#L85-L92 |
2,802 | phergie/phergie-irc-plugin-react-commandhelp | src/Plugin.php | Plugin.getCommands | protected function getCommands(array $config)
{
if (!is_array($config['plugins'])) {
throw new \RuntimeException(
'Configuration "plugins" key must reference an array',
self::ERR_PLUGINS_NONARRAY
);
}
$plugins = array_filter(
$config['plugins'],
function($plugin) {
return $plugin instanceof PluginInterface;
}
);
if (count($plugins) != count($config['plugins'])) {
throw new \RuntimeException(
'All configuration "plugins" array values must implement \Phergie\Irc\Bot\React\PluginInterface',
self::ERR_PLUGINS_NONPLUGINS
);
}
$commands = array();
foreach ($plugins as $plugin) {
$events = array_keys($plugin->getSubscribedEvents());
$commandEvents = array();
foreach ($events as $event) {
if (!preg_match('/^command\.(.+)\.help$/', $event, $match)) {
continue;
}
$commands[$match[1]] = true;
}
}
return $this->alphabetize($commands);
} | php | protected function getCommands(array $config)
{
if (!is_array($config['plugins'])) {
throw new \RuntimeException(
'Configuration "plugins" key must reference an array',
self::ERR_PLUGINS_NONARRAY
);
}
$plugins = array_filter(
$config['plugins'],
function($plugin) {
return $plugin instanceof PluginInterface;
}
);
if (count($plugins) != count($config['plugins'])) {
throw new \RuntimeException(
'All configuration "plugins" array values must implement \Phergie\Irc\Bot\React\PluginInterface',
self::ERR_PLUGINS_NONPLUGINS
);
}
$commands = array();
foreach ($plugins as $plugin) {
$events = array_keys($plugin->getSubscribedEvents());
$commandEvents = array();
foreach ($events as $event) {
if (!preg_match('/^command\.(.+)\.help$/', $event, $match)) {
continue;
}
$commands[$match[1]] = true;
}
}
return $this->alphabetize($commands);
} | [
"protected",
"function",
"getCommands",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
"[",
"'plugins'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Configuration \"plugins\" key must reference an array'",
",",
"self",
"::",
"ERR_PLUGINS_NONARRAY",
")",
";",
"}",
"$",
"plugins",
"=",
"array_filter",
"(",
"$",
"config",
"[",
"'plugins'",
"]",
",",
"function",
"(",
"$",
"plugin",
")",
"{",
"return",
"$",
"plugin",
"instanceof",
"PluginInterface",
";",
"}",
")",
";",
"if",
"(",
"count",
"(",
"$",
"plugins",
")",
"!=",
"count",
"(",
"$",
"config",
"[",
"'plugins'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'All configuration \"plugins\" array values must implement \\Phergie\\Irc\\Bot\\React\\PluginInterface'",
",",
"self",
"::",
"ERR_PLUGINS_NONPLUGINS",
")",
";",
"}",
"$",
"commands",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"events",
"=",
"array_keys",
"(",
"$",
"plugin",
"->",
"getSubscribedEvents",
"(",
")",
")",
";",
"$",
"commandEvents",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^command\\.(.+)\\.help$/'",
",",
"$",
"event",
",",
"$",
"match",
")",
")",
"{",
"continue",
";",
"}",
"$",
"commands",
"[",
"$",
"match",
"[",
"1",
"]",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"alphabetize",
"(",
"$",
"commands",
")",
";",
"}"
] | Extracts command information from configuration.
@param array $config
@return array | [
"Extracts",
"command",
"information",
"from",
"configuration",
"."
] | 077c47ceec90dc12efb2975fe27bc5ad91dafbcc | https://github.com/phergie/phergie-irc-plugin-react-commandhelp/blob/077c47ceec90dc12efb2975fe27bc5ad91dafbcc/src/Plugin.php#L80-L115 |
2,803 | phergie/phergie-irc-plugin-react-commandhelp | src/Plugin.php | Plugin.handleHelpCommand | public function handleHelpCommand(CommandEvent $event, EventQueueInterface $queue)
{
$params = $event->getCustomParams();
if ($params) {
$command = strtolower(reset($params));
$eventName = 'command.' . $command . '.help';
$this->getEventEmitter()->emit($eventName, array($event, $queue));
} else {
$this->listCommands($event, $queue);
}
} | php | public function handleHelpCommand(CommandEvent $event, EventQueueInterface $queue)
{
$params = $event->getCustomParams();
if ($params) {
$command = strtolower(reset($params));
$eventName = 'command.' . $command . '.help';
$this->getEventEmitter()->emit($eventName, array($event, $queue));
} else {
$this->listCommands($event, $queue);
}
} | [
"public",
"function",
"handleHelpCommand",
"(",
"CommandEvent",
"$",
"event",
",",
"EventQueueInterface",
"$",
"queue",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getCustomParams",
"(",
")",
";",
"if",
"(",
"$",
"params",
")",
"{",
"$",
"command",
"=",
"strtolower",
"(",
"reset",
"(",
"$",
"params",
")",
")",
";",
"$",
"eventName",
"=",
"'command.'",
".",
"$",
"command",
".",
"'.help'",
";",
"$",
"this",
"->",
"getEventEmitter",
"(",
")",
"->",
"emit",
"(",
"$",
"eventName",
",",
"array",
"(",
"$",
"event",
",",
"$",
"queue",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"listCommands",
"(",
"$",
"event",
",",
"$",
"queue",
")",
";",
"}",
"}"
] | Responds to the help command.
@param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Responds",
"to",
"the",
"help",
"command",
"."
] | 077c47ceec90dc12efb2975fe27bc5ad91dafbcc | https://github.com/phergie/phergie-irc-plugin-react-commandhelp/blob/077c47ceec90dc12efb2975fe27bc5ad91dafbcc/src/Plugin.php#L135-L145 |
2,804 | phergie/phergie-irc-plugin-react-commandhelp | src/Plugin.php | Plugin.listCommands | protected function listCommands(CommandEvent $event, EventQueueInterface $queue)
{
$targets = $event->getTargets();
$target = reset($targets);
$nick = $event->getNick();
if ($target === $event->getConnection()->getNickname()) {
$target = $nick;
$address = '';
} else {
$address = $nick . ': ';
}
$method = 'irc' . $event->getCommand();
$message = $address . $this->listText . implode(' ', $this->commands);
$queue->$method($target, $message);
} | php | protected function listCommands(CommandEvent $event, EventQueueInterface $queue)
{
$targets = $event->getTargets();
$target = reset($targets);
$nick = $event->getNick();
if ($target === $event->getConnection()->getNickname()) {
$target = $nick;
$address = '';
} else {
$address = $nick . ': ';
}
$method = 'irc' . $event->getCommand();
$message = $address . $this->listText . implode(' ', $this->commands);
$queue->$method($target, $message);
} | [
"protected",
"function",
"listCommands",
"(",
"CommandEvent",
"$",
"event",
",",
"EventQueueInterface",
"$",
"queue",
")",
"{",
"$",
"targets",
"=",
"$",
"event",
"->",
"getTargets",
"(",
")",
";",
"$",
"target",
"=",
"reset",
"(",
"$",
"targets",
")",
";",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"if",
"(",
"$",
"target",
"===",
"$",
"event",
"->",
"getConnection",
"(",
")",
"->",
"getNickname",
"(",
")",
")",
"{",
"$",
"target",
"=",
"$",
"nick",
";",
"$",
"address",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"address",
"=",
"$",
"nick",
".",
"': '",
";",
"}",
"$",
"method",
"=",
"'irc'",
".",
"$",
"event",
"->",
"getCommand",
"(",
")",
";",
"$",
"message",
"=",
"$",
"address",
".",
"$",
"this",
"->",
"listText",
".",
"implode",
"(",
"' '",
",",
"$",
"this",
"->",
"commands",
")",
";",
"$",
"queue",
"->",
"$",
"method",
"(",
"$",
"target",
",",
"$",
"message",
")",
";",
"}"
] | Responds to a parameter-less help command with a list of available
commands.
@param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Responds",
"to",
"a",
"parameter",
"-",
"less",
"help",
"command",
"with",
"a",
"list",
"of",
"available",
"commands",
"."
] | 077c47ceec90dc12efb2975fe27bc5ad91dafbcc | https://github.com/phergie/phergie-irc-plugin-react-commandhelp/blob/077c47ceec90dc12efb2975fe27bc5ad91dafbcc/src/Plugin.php#L154-L170 |
2,805 | phergie/phergie-irc-plugin-react-commandhelp | src/Plugin.php | Plugin.alphabetize | private function alphabetize( $commands )
{
$commandList = array_keys($commands);
sort($commandList, SORT_NATURAL | SORT_FLAG_CASE);
return array_values($commandList);
} | php | private function alphabetize( $commands )
{
$commandList = array_keys($commands);
sort($commandList, SORT_NATURAL | SORT_FLAG_CASE);
return array_values($commandList);
} | [
"private",
"function",
"alphabetize",
"(",
"$",
"commands",
")",
"{",
"$",
"commandList",
"=",
"array_keys",
"(",
"$",
"commands",
")",
";",
"sort",
"(",
"$",
"commandList",
",",
"SORT_NATURAL",
"|",
"SORT_FLAG_CASE",
")",
";",
"return",
"array_values",
"(",
"$",
"commandList",
")",
";",
"}"
] | Sort array of commands
@param $commands
@return array | [
"Sort",
"array",
"of",
"commands"
] | 077c47ceec90dc12efb2975fe27bc5ad91dafbcc | https://github.com/phergie/phergie-irc-plugin-react-commandhelp/blob/077c47ceec90dc12efb2975fe27bc5ad91dafbcc/src/Plugin.php#L179-L186 |
2,806 | Ara95/user | src/Auth/AuthMiddleware.php | AuthMiddleware.isLoggedIn | public function isLoggedIn()
{
$loggedIn = $this->di->get("session")->has("user");
if (!$loggedIn) {
$this->di->get("response")->redirect("user/login");
return false;
}
return true;
} | php | public function isLoggedIn()
{
$loggedIn = $this->di->get("session")->has("user");
if (!$loggedIn) {
$this->di->get("response")->redirect("user/login");
return false;
}
return true;
} | [
"public",
"function",
"isLoggedIn",
"(",
")",
"{",
"$",
"loggedIn",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"session\"",
")",
"->",
"has",
"(",
"\"user\"",
")",
";",
"if",
"(",
"!",
"$",
"loggedIn",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"response\"",
")",
"->",
"redirect",
"(",
"\"user/login\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if user is logged in.
@return boolean | [
"Check",
"if",
"user",
"is",
"logged",
"in",
"."
] | 96e15a19906562a689abedf6bcf4818ad8437a3b | https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/Auth/AuthMiddleware.php#L22-L30 |
2,807 | Ara95/user | src/Auth/AuthMiddleware.php | AuthMiddleware.isAdmin | public function isAdmin($redirect = false)
{
if (!$this->isLoggedIn()) {
$this->di->get("response")->redirect("user/login");
return false;
}
$email = $this->di->get("session")->get("user");
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("email", $email);
$isAdmin = $user->admin;
if (!$isAdmin) {
if ($redirect) {
$this->di->get("response")->redirect("user");
}
return false;
}
return true;
} | php | public function isAdmin($redirect = false)
{
if (!$this->isLoggedIn()) {
$this->di->get("response")->redirect("user/login");
return false;
}
$email = $this->di->get("session")->get("user");
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("email", $email);
$isAdmin = $user->admin;
if (!$isAdmin) {
if ($redirect) {
$this->di->get("response")->redirect("user");
}
return false;
}
return true;
} | [
"public",
"function",
"isAdmin",
"(",
"$",
"redirect",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"response\"",
")",
"->",
"redirect",
"(",
"\"user/login\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"email",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"session\"",
")",
"->",
"get",
"(",
"\"user\"",
")",
";",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"$",
"user",
"->",
"setDb",
"(",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"db\"",
")",
")",
";",
"$",
"user",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"email",
")",
";",
"$",
"isAdmin",
"=",
"$",
"user",
"->",
"admin",
";",
"if",
"(",
"!",
"$",
"isAdmin",
")",
"{",
"if",
"(",
"$",
"redirect",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"response\"",
")",
"->",
"redirect",
"(",
"\"user\"",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if user is admin
@param string $email user email
@return boolean if the user is an admin | [
"Check",
"if",
"user",
"is",
"admin"
] | 96e15a19906562a689abedf6bcf4818ad8437a3b | https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/Auth/AuthMiddleware.php#L39-L61 |
2,808 | Ara95/user | src/Auth/AuthMiddleware.php | AuthMiddleware.hasAccessToComment | public function hasAccessToComment($commentID)
{
$this->isLoggedIn();
$userid = $this->di->get("session")->get("userid");
$comment = new Comment();
$comment->setDb($this->di->get("db"));
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("id", $userid);
$comment->find("id", $commentID);
if (($comment->user_id == $userid) || $this->isAdmin()) {
return true;
}
$this->di->get("response")->redirect("user");
return false;
} | php | public function hasAccessToComment($commentID)
{
$this->isLoggedIn();
$userid = $this->di->get("session")->get("userid");
$comment = new Comment();
$comment->setDb($this->di->get("db"));
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("id", $userid);
$comment->find("id", $commentID);
if (($comment->user_id == $userid) || $this->isAdmin()) {
return true;
}
$this->di->get("response")->redirect("user");
return false;
} | [
"public",
"function",
"hasAccessToComment",
"(",
"$",
"commentID",
")",
"{",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
";",
"$",
"userid",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"session\"",
")",
"->",
"get",
"(",
"\"userid\"",
")",
";",
"$",
"comment",
"=",
"new",
"Comment",
"(",
")",
";",
"$",
"comment",
"->",
"setDb",
"(",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"db\"",
")",
")",
";",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"$",
"user",
"->",
"setDb",
"(",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"db\"",
")",
")",
";",
"$",
"user",
"->",
"find",
"(",
"\"id\"",
",",
"$",
"userid",
")",
";",
"$",
"comment",
"->",
"find",
"(",
"\"id\"",
",",
"$",
"commentID",
")",
";",
"if",
"(",
"(",
"$",
"comment",
"->",
"user_id",
"==",
"$",
"userid",
")",
"||",
"$",
"this",
"->",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"response\"",
")",
"->",
"redirect",
"(",
"\"user\"",
")",
";",
"return",
"false",
";",
"}"
] | Check if the user have access to the comment
@param integer $commentID Comment ID
@return boolean True if the user is admin or is the owner of the comment | [
"Check",
"if",
"the",
"user",
"have",
"access",
"to",
"the",
"comment"
] | 96e15a19906562a689abedf6bcf4818ad8437a3b | https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/Auth/AuthMiddleware.php#L70-L89 |
2,809 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener.load | public function load(\Zend_EventManager_EventDescription $event)
{
if(false !== ($content = $this->cache->load($this->_getIdentifier($event)))) {
$event->stopPropagation(true);
return $content;
}
} | php | public function load(\Zend_EventManager_EventDescription $event)
{
if(false !== ($content = $this->cache->load($this->_getIdentifier($event)))) {
$event->stopPropagation(true);
return $content;
}
} | [
"public",
"function",
"load",
"(",
"\\",
"Zend_EventManager_EventDescription",
"$",
"event",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"content",
"=",
"$",
"this",
"->",
"cache",
"->",
"load",
"(",
"$",
"this",
"->",
"_getIdentifier",
"(",
"$",
"event",
")",
")",
")",
")",
"{",
"$",
"event",
"->",
"stopPropagation",
"(",
"true",
")",
";",
"return",
"$",
"content",
";",
"}",
"}"
] | Pre event - try load content from cache
@param \Zend_EventManager_EventDescription $event
@return mixed | [
"Pre",
"event",
"-",
"try",
"load",
"content",
"from",
"cache"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L81-L87 |
2,810 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener.save | public function save(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
if(!isset($params['data'])) {
throw new \Zend_EventManager_Exception_InvalidArgumentException('Missing param data.');
}
$this->cache->save($params['data'], $this->_getIdentifier($event), $this->_getTags($event));
} | php | public function save(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
if(!isset($params['data'])) {
throw new \Zend_EventManager_Exception_InvalidArgumentException('Missing param data.');
}
$this->cache->save($params['data'], $this->_getIdentifier($event), $this->_getTags($event));
} | [
"public",
"function",
"save",
"(",
"\\",
"Zend_EventManager_EventDescription",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'data'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Zend_EventManager_Exception_InvalidArgumentException",
"(",
"'Missing param data.'",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"params",
"[",
"'data'",
"]",
",",
"$",
"this",
"->",
"_getIdentifier",
"(",
"$",
"event",
")",
",",
"$",
"this",
"->",
"_getTags",
"(",
"$",
"event",
")",
")",
";",
"}"
] | Post event - save content in cache
@param \Zend_EventManager_EventDescription $event | [
"Post",
"event",
"-",
"save",
"content",
"in",
"cache"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L94-L102 |
2,811 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener.clean | public function clean(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
$mode = \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG;
if (isset($params['mode'])) {
$mode = $params['mode'];
}
return $this->cache->clean($mode, $this->_getTags($event));
} | php | public function clean(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
$mode = \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG;
if (isset($params['mode'])) {
$mode = $params['mode'];
}
return $this->cache->clean($mode, $this->_getTags($event));
} | [
"public",
"function",
"clean",
"(",
"\\",
"Zend_EventManager_EventDescription",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"mode",
"=",
"\\",
"Zend_Cache",
"::",
"CLEANING_MODE_MATCHING_ANY_TAG",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'mode'",
"]",
")",
")",
"{",
"$",
"mode",
"=",
"$",
"params",
"[",
"'mode'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"->",
"clean",
"(",
"$",
"mode",
",",
"$",
"this",
"->",
"_getTags",
"(",
"$",
"event",
")",
")",
";",
"}"
] | Clear event - clear all cache by tags
@param Zend_EventManager_EventDescription $event | [
"Clear",
"event",
"-",
"clear",
"all",
"cache",
"by",
"tags"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L109-L119 |
2,812 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener._getIdentifier | protected function _getIdentifier(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
if(!isset($params['id'])) {
throw new \Zend_EventManager_Exception_InvalidArgumentException('Missing param id.');
}
return md5($this->_getClassName($event->getTarget()) . '-' . $params['id']);
} | php | protected function _getIdentifier(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
if(!isset($params['id'])) {
throw new \Zend_EventManager_Exception_InvalidArgumentException('Missing param id.');
}
return md5($this->_getClassName($event->getTarget()) . '-' . $params['id']);
} | [
"protected",
"function",
"_getIdentifier",
"(",
"\\",
"Zend_EventManager_EventDescription",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'id'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Zend_EventManager_Exception_InvalidArgumentException",
"(",
"'Missing param id.'",
")",
";",
"}",
"return",
"md5",
"(",
"$",
"this",
"->",
"_getClassName",
"(",
"$",
"event",
"->",
"getTarget",
"(",
")",
")",
".",
"'-'",
".",
"$",
"params",
"[",
"'id'",
"]",
")",
";",
"}"
] | Method return identifier name from class and id
@param \Zend_EventManager_EventDescription $event
@return string
@throws \Zend_EventManager_Exception_InvalidArgumentException | [
"Method",
"return",
"identifier",
"name",
"from",
"class",
"and",
"id"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L139-L147 |
2,813 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener._getClassName | protected function _getClassName($target)
{
$className = $target;
if (is_object($target)) {
$className = get_class($target);
}
return $this->_normalizeName($className);
} | php | protected function _getClassName($target)
{
$className = $target;
if (is_object($target)) {
$className = get_class($target);
}
return $this->_normalizeName($className);
} | [
"protected",
"function",
"_getClassName",
"(",
"$",
"target",
")",
"{",
"$",
"className",
"=",
"$",
"target",
";",
"if",
"(",
"is_object",
"(",
"$",
"target",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"target",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_normalizeName",
"(",
"$",
"className",
")",
";",
"}"
] | Method return target class name
@param mixed $target
@return string | [
"Method",
"return",
"target",
"class",
"name"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L155-L163 |
2,814 | lciolecki/zf-extensions-library | library/Extlib/CacheListener.php | CacheListener._getTags | protected function _getTags(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
$tags = array($this->_getClassName($event->getTarget()));
if(isset($params['tags'])) {
if(is_array($params['tags'])) {
$tags = array_merge($tags, $params['tags']);
} else {
$tags[] = $params['tags'];
}
}
foreach ($tags as &$tag) {
$tag = $this->_normalizeName($tag);
}
return $tags;
} | php | protected function _getTags(\Zend_EventManager_EventDescription $event)
{
$params = $event->getParams();
$tags = array($this->_getClassName($event->getTarget()));
if(isset($params['tags'])) {
if(is_array($params['tags'])) {
$tags = array_merge($tags, $params['tags']);
} else {
$tags[] = $params['tags'];
}
}
foreach ($tags as &$tag) {
$tag = $this->_normalizeName($tag);
}
return $tags;
} | [
"protected",
"function",
"_getTags",
"(",
"\\",
"Zend_EventManager_EventDescription",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"tags",
"=",
"array",
"(",
"$",
"this",
"->",
"_getClassName",
"(",
"$",
"event",
"->",
"getTarget",
"(",
")",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
")",
"{",
"$",
"tags",
"=",
"array_merge",
"(",
"$",
"tags",
",",
"$",
"params",
"[",
"'tags'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"tags",
"[",
"]",
"=",
"$",
"params",
"[",
"'tags'",
"]",
";",
"}",
"}",
"foreach",
"(",
"$",
"tags",
"as",
"&",
"$",
"tag",
")",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"_normalizeName",
"(",
"$",
"tag",
")",
";",
"}",
"return",
"$",
"tags",
";",
"}"
] | Method return array of tags from event
@param \Zend_EventManager_EventDescription $event
@return array | [
"Method",
"return",
"array",
"of",
"tags",
"from",
"event"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/CacheListener.php#L171-L190 |
2,815 | popy-dev/popy-calendar | src/Parser/DateLexerResult.php | DateLexerResult.merge | public function merge(DateLexerResult $result)
{
$this->offset = $result->offset;
$this->data = array_merge($this->data, $result->data);
} | php | public function merge(DateLexerResult $result)
{
$this->offset = $result->offset;
$this->data = array_merge($this->data, $result->data);
} | [
"public",
"function",
"merge",
"(",
"DateLexerResult",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"offset",
"=",
"$",
"result",
"->",
"offset",
";",
"$",
"this",
"->",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"result",
"->",
"data",
")",
";",
"}"
] | Merges a result into this one.
@param DateLexerResult $result | [
"Merges",
"a",
"result",
"into",
"this",
"one",
"."
] | 989048be18451c813cfce926229c6aaddd1b0639 | https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/DateLexerResult.php#L79-L83 |
2,816 | popy-dev/popy-calendar | src/Parser/DateLexerResult.php | DateLexerResult.getFirst | public function getFirst($name)
{
$names = func_get_args();
foreach ($names as $name) {
if (isset($this->data[$name])) {
return $this->data[$name];
}
}
} | php | public function getFirst($name)
{
$names = func_get_args();
foreach ($names as $name) {
if (isset($this->data[$name])) {
return $this->data[$name];
}
}
} | [
"public",
"function",
"getFirst",
"(",
"$",
"name",
")",
"{",
"$",
"names",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"}"
] | Get first set symbol value.
@param string $name
@param string ...$name
@return mixed | [
"Get",
"first",
"set",
"symbol",
"value",
"."
] | 989048be18451c813cfce926229c6aaddd1b0639 | https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/DateLexerResult.php#L93-L102 |
2,817 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.cdn | public function cdn($name, $url, $type = null)
{
// Check if there is a type provided
if($type === null)
{
// No type provided, so derive it
$type = substr(strrchr($url, '.'), 1);
}
// Grab the CDN group
$group = config('assetprocessor.attributes.group.cdn', 'cdn');
// Add the asset type
$this->files[$type][$group][$name] = $url;
} | php | public function cdn($name, $url, $type = null)
{
// Check if there is a type provided
if($type === null)
{
// No type provided, so derive it
$type = substr(strrchr($url, '.'), 1);
}
// Grab the CDN group
$group = config('assetprocessor.attributes.group.cdn', 'cdn');
// Add the asset type
$this->files[$type][$group][$name] = $url;
} | [
"public",
"function",
"cdn",
"(",
"$",
"name",
",",
"$",
"url",
",",
"$",
"type",
"=",
"null",
")",
"{",
"// Check if there is a type provided",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"// No type provided, so derive it",
"$",
"type",
"=",
"substr",
"(",
"strrchr",
"(",
"$",
"url",
",",
"'.'",
")",
",",
"1",
")",
";",
"}",
"// Grab the CDN group",
"$",
"group",
"=",
"config",
"(",
"'assetprocessor.attributes.group.cdn'",
",",
"'cdn'",
")",
";",
"// Add the asset type",
"$",
"this",
"->",
"files",
"[",
"$",
"type",
"]",
"[",
"$",
"group",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"url",
";",
"}"
] | Used in order to allow for the use of a CDN for assets.
@param string $name The name of the asset file
@param string $url The URL that we'll be retrieving the assets from
@param string $type Whether the file is a JavaScript file or a CSS file (if not provided
it will derive off of the name)
@return void | [
"Used",
"in",
"order",
"to",
"allow",
"for",
"the",
"use",
"of",
"a",
"CDN",
"for",
"assets",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L113-L127 |
2,818 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.generateSingularFile | public function generateSingularFile($type, $group, $directory)
{
// Check if the group exists
if(!isset($this->files[$type][$group]))
{
// It doesn't so we are done
return null;
}
// Grab the associated assets
$assets = $this->files[$type][$group];
// Write out the files
return $this->write($type, $assets, $directory);
} | php | public function generateSingularFile($type, $group, $directory)
{
// Check if the group exists
if(!isset($this->files[$type][$group]))
{
// It doesn't so we are done
return null;
}
// Grab the associated assets
$assets = $this->files[$type][$group];
// Write out the files
return $this->write($type, $assets, $directory);
} | [
"public",
"function",
"generateSingularFile",
"(",
"$",
"type",
",",
"$",
"group",
",",
"$",
"directory",
")",
"{",
"// Check if the group exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"files",
"[",
"$",
"type",
"]",
"[",
"$",
"group",
"]",
")",
")",
"{",
"// It doesn't so we are done",
"return",
"null",
";",
"}",
"// Grab the associated assets",
"$",
"assets",
"=",
"$",
"this",
"->",
"files",
"[",
"$",
"type",
"]",
"[",
"$",
"group",
"]",
";",
"// Write out the files",
"return",
"$",
"this",
"->",
"write",
"(",
"$",
"type",
",",
"$",
"assets",
",",
"$",
"directory",
")",
";",
"}"
] | Generates a singular file that contains all of the specific asset files.
@return string The file name | [
"Generates",
"a",
"singular",
"file",
"that",
"contains",
"all",
"of",
"the",
"specific",
"asset",
"files",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L331-L345 |
2,819 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.deriveProcessingEnabled | private function deriveProcessingEnabled()
{
// Are they forcing it to be enabled?
if(config('assetprocessor.enabled.force', false))
{
// It was forced, so enable it
$this->processingEnabled = true;
}
else
{
// Otherwise derive it based on the environment that we are in
$this->processingEnabled = in_array(App::environment()
, config('assetprocessor.enabled.environments', array())
);
}
} | php | private function deriveProcessingEnabled()
{
// Are they forcing it to be enabled?
if(config('assetprocessor.enabled.force', false))
{
// It was forced, so enable it
$this->processingEnabled = true;
}
else
{
// Otherwise derive it based on the environment that we are in
$this->processingEnabled = in_array(App::environment()
, config('assetprocessor.enabled.environments', array())
);
}
} | [
"private",
"function",
"deriveProcessingEnabled",
"(",
")",
"{",
"// Are they forcing it to be enabled?",
"if",
"(",
"config",
"(",
"'assetprocessor.enabled.force'",
",",
"false",
")",
")",
"{",
"// It was forced, so enable it",
"$",
"this",
"->",
"processingEnabled",
"=",
"true",
";",
"}",
"else",
"{",
"// Otherwise derive it based on the environment that we are in",
"$",
"this",
"->",
"processingEnabled",
"=",
"in_array",
"(",
"App",
"::",
"environment",
"(",
")",
",",
"config",
"(",
"'assetprocessor.enabled.environments'",
",",
"array",
"(",
")",
")",
")",
";",
"}",
"}"
] | Used internally in order to determine whether or not we need to actually
process the input files. | [
"Used",
"internally",
"in",
"order",
"to",
"determine",
"whether",
"or",
"not",
"we",
"need",
"to",
"actually",
"process",
"the",
"input",
"files",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L511-L526 |
2,820 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.setupLibraries | private function setupLibraries()
{
// Get the list of processors
$processors = config('assetprocessor.processors.types', array());
// Grab the interface we should be implementing
$interface = config('assetprocessor.processors.interface');
// Iterate through the list
foreach($processors as $name => $class)
{
// Get an instance of the processor
$instance = $class::getInstance($this->processingEnabled);
// Ensure that it implements the correct interface
if(!($instance instanceof $interface))
{
throw new Exception(Lang::get('assetprocessor::errors.asset.invalid-type', array('class' => $class, 'interface' => $interface)));
}
// Add it into the array of processors
$this->processors[$name] = $instance;
// Grab the list of extensions it processes
$this->deriveExtensionMapping($name, $class::getAssociatedExtensions());
// Check if the asset type exists
if(!isset($this->files[$instance->getAssetType()]))
{
// Asset type didn't exist, so add it into the mapping
$this->files[$instance->getAssetType()] = array();
}
}
} | php | private function setupLibraries()
{
// Get the list of processors
$processors = config('assetprocessor.processors.types', array());
// Grab the interface we should be implementing
$interface = config('assetprocessor.processors.interface');
// Iterate through the list
foreach($processors as $name => $class)
{
// Get an instance of the processor
$instance = $class::getInstance($this->processingEnabled);
// Ensure that it implements the correct interface
if(!($instance instanceof $interface))
{
throw new Exception(Lang::get('assetprocessor::errors.asset.invalid-type', array('class' => $class, 'interface' => $interface)));
}
// Add it into the array of processors
$this->processors[$name] = $instance;
// Grab the list of extensions it processes
$this->deriveExtensionMapping($name, $class::getAssociatedExtensions());
// Check if the asset type exists
if(!isset($this->files[$instance->getAssetType()]))
{
// Asset type didn't exist, so add it into the mapping
$this->files[$instance->getAssetType()] = array();
}
}
} | [
"private",
"function",
"setupLibraries",
"(",
")",
"{",
"// Get the list of processors",
"$",
"processors",
"=",
"config",
"(",
"'assetprocessor.processors.types'",
",",
"array",
"(",
")",
")",
";",
"// Grab the interface we should be implementing",
"$",
"interface",
"=",
"config",
"(",
"'assetprocessor.processors.interface'",
")",
";",
"// Iterate through the list",
"foreach",
"(",
"$",
"processors",
"as",
"$",
"name",
"=>",
"$",
"class",
")",
"{",
"// Get an instance of the processor",
"$",
"instance",
"=",
"$",
"class",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"processingEnabled",
")",
";",
"// Ensure that it implements the correct interface",
"if",
"(",
"!",
"(",
"$",
"instance",
"instanceof",
"$",
"interface",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Lang",
"::",
"get",
"(",
"'assetprocessor::errors.asset.invalid-type'",
",",
"array",
"(",
"'class'",
"=>",
"$",
"class",
",",
"'interface'",
"=>",
"$",
"interface",
")",
")",
")",
";",
"}",
"// Add it into the array of processors",
"$",
"this",
"->",
"processors",
"[",
"$",
"name",
"]",
"=",
"$",
"instance",
";",
"// Grab the list of extensions it processes",
"$",
"this",
"->",
"deriveExtensionMapping",
"(",
"$",
"name",
",",
"$",
"class",
"::",
"getAssociatedExtensions",
"(",
")",
")",
";",
"// Check if the asset type exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"files",
"[",
"$",
"instance",
"->",
"getAssetType",
"(",
")",
"]",
")",
")",
"{",
"// Asset type didn't exist, so add it into the mapping",
"$",
"this",
"->",
"files",
"[",
"$",
"instance",
"->",
"getAssetType",
"(",
")",
"]",
"=",
"array",
"(",
")",
";",
"}",
"}",
"}"
] | Used internally in order to set up an instance of each of the processors
that we will need.
@return void | [
"Used",
"internally",
"in",
"order",
"to",
"set",
"up",
"an",
"instance",
"of",
"each",
"of",
"the",
"processors",
"that",
"we",
"will",
"need",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L534-L567 |
2,821 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.deriveExtensionMapping | private function deriveExtensionMapping($name, array $extensions)
{
// Iterate through all of the extensions
foreach($extensions as $extension)
{
// Check if it exists
if(!isset($this->extensionMapping[$extension]))
{
// It doesn't, so initialize it
$this->extensionMapping[$extension] = array();
}
// Add a mapping between the two
$this->extensionMapping[$extension][] = $name;
}
} | php | private function deriveExtensionMapping($name, array $extensions)
{
// Iterate through all of the extensions
foreach($extensions as $extension)
{
// Check if it exists
if(!isset($this->extensionMapping[$extension]))
{
// It doesn't, so initialize it
$this->extensionMapping[$extension] = array();
}
// Add a mapping between the two
$this->extensionMapping[$extension][] = $name;
}
} | [
"private",
"function",
"deriveExtensionMapping",
"(",
"$",
"name",
",",
"array",
"$",
"extensions",
")",
"{",
"// Iterate through all of the extensions",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
")",
"{",
"// Check if it exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"extensionMapping",
"[",
"$",
"extension",
"]",
")",
")",
"{",
"// It doesn't, so initialize it",
"$",
"this",
"->",
"extensionMapping",
"[",
"$",
"extension",
"]",
"=",
"array",
"(",
")",
";",
"}",
"// Add a mapping between the two",
"$",
"this",
"->",
"extensionMapping",
"[",
"$",
"extension",
"]",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}"
] | Used internally in order to derive the list of extensions that are used
by a particular processor.
@return void | [
"Used",
"internally",
"in",
"order",
"to",
"derive",
"the",
"list",
"of",
"extensions",
"that",
"are",
"used",
"by",
"a",
"particular",
"processor",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L575-L590 |
2,822 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.write | private function write($type, $contents, $directory = null)
{
// Will contain all of the files put together
$file = '';
// Derive the destination path
$directory = $directory === null ? static::storageFolder() : ($directory . '/');
$directory .= $type . '/';
// Do we have one file or multiple?
if(is_array($contents))
{
// Cycle through each of the files
foreach($contents as $filename)
{
// Check if the file exists on it's own
if(!file_exists($filename))
{
$filename = $directory . $filename;
}
// Keep appending the file's contents
$file .= file_get_contents($filename);
}
}
else
{
// Check if the file exists on it's own
if(!file_exists($contents))
{
$contents = $directory . $contents;
}
// Otherwise just read in the file
$file .= file_get_contents($contents);
}
$filename = md5($file);
// Make sure that the folder exists
if(!file_exists($directory))
{
// It doesn't, so make it (allow us to write)
mkdir($directory, 0777, true);
}
// Write the file to disk
file_put_contents($directory . $filename, $file);
// Return the file name
return $filename;
} | php | private function write($type, $contents, $directory = null)
{
// Will contain all of the files put together
$file = '';
// Derive the destination path
$directory = $directory === null ? static::storageFolder() : ($directory . '/');
$directory .= $type . '/';
// Do we have one file or multiple?
if(is_array($contents))
{
// Cycle through each of the files
foreach($contents as $filename)
{
// Check if the file exists on it's own
if(!file_exists($filename))
{
$filename = $directory . $filename;
}
// Keep appending the file's contents
$file .= file_get_contents($filename);
}
}
else
{
// Check if the file exists on it's own
if(!file_exists($contents))
{
$contents = $directory . $contents;
}
// Otherwise just read in the file
$file .= file_get_contents($contents);
}
$filename = md5($file);
// Make sure that the folder exists
if(!file_exists($directory))
{
// It doesn't, so make it (allow us to write)
mkdir($directory, 0777, true);
}
// Write the file to disk
file_put_contents($directory . $filename, $file);
// Return the file name
return $filename;
} | [
"private",
"function",
"write",
"(",
"$",
"type",
",",
"$",
"contents",
",",
"$",
"directory",
"=",
"null",
")",
"{",
"// Will contain all of the files put together",
"$",
"file",
"=",
"''",
";",
"// Derive the destination path",
"$",
"directory",
"=",
"$",
"directory",
"===",
"null",
"?",
"static",
"::",
"storageFolder",
"(",
")",
":",
"(",
"$",
"directory",
".",
"'/'",
")",
";",
"$",
"directory",
".=",
"$",
"type",
".",
"'/'",
";",
"// Do we have one file or multiple?",
"if",
"(",
"is_array",
"(",
"$",
"contents",
")",
")",
"{",
"// Cycle through each of the files",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"filename",
")",
"{",
"// Check if the file exists on it's own",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"directory",
".",
"$",
"filename",
";",
"}",
"// Keep appending the file's contents",
"$",
"file",
".=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"}",
"}",
"else",
"{",
"// Check if the file exists on it's own",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"contents",
")",
")",
"{",
"$",
"contents",
"=",
"$",
"directory",
".",
"$",
"contents",
";",
"}",
"// Otherwise just read in the file",
"$",
"file",
".=",
"file_get_contents",
"(",
"$",
"contents",
")",
";",
"}",
"$",
"filename",
"=",
"md5",
"(",
"$",
"file",
")",
";",
"// Make sure that the folder exists",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
")",
"{",
"// It doesn't, so make it (allow us to write)",
"mkdir",
"(",
"$",
"directory",
",",
"0777",
",",
"true",
")",
";",
"}",
"// Write the file to disk",
"file_put_contents",
"(",
"$",
"directory",
".",
"$",
"filename",
",",
"$",
"file",
")",
";",
"// Return the file name",
"return",
"$",
"filename",
";",
"}"
] | Used internally in order to write all of the contents for the provided files
into a single file.
@param string $type The type of asset that we are making
@param mixed $contents An array of all of the files to combine OR a single file to write
@param string $directory The name of the directory to store the files in
@return string The new file name | [
"Used",
"internally",
"in",
"order",
"to",
"write",
"all",
"of",
"the",
"contents",
"for",
"the",
"provided",
"files",
"into",
"a",
"single",
"file",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L601-L652 |
2,823 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.autoLoadAssets | private function autoLoadAssets()
{
// Add in the CDN-typed assets
foreach(config('assetprocessor.autoload.cdn', array()) as $asset)
{
// Add in the asset
self::cdn($asset, $asset);
}
// Add in the local assets
foreach(config('assetprocessor.autoload.local', array()) as $asset)
{
// Add in the asset
self::add($asset, $asset);
}
} | php | private function autoLoadAssets()
{
// Add in the CDN-typed assets
foreach(config('assetprocessor.autoload.cdn', array()) as $asset)
{
// Add in the asset
self::cdn($asset, $asset);
}
// Add in the local assets
foreach(config('assetprocessor.autoload.local', array()) as $asset)
{
// Add in the asset
self::add($asset, $asset);
}
} | [
"private",
"function",
"autoLoadAssets",
"(",
")",
"{",
"// Add in the CDN-typed assets",
"foreach",
"(",
"config",
"(",
"'assetprocessor.autoload.cdn'",
",",
"array",
"(",
")",
")",
"as",
"$",
"asset",
")",
"{",
"// Add in the asset",
"self",
"::",
"cdn",
"(",
"$",
"asset",
",",
"$",
"asset",
")",
";",
"}",
"// Add in the local assets",
"foreach",
"(",
"config",
"(",
"'assetprocessor.autoload.local'",
",",
"array",
"(",
")",
")",
"as",
"$",
"asset",
")",
"{",
"// Add in the asset",
"self",
"::",
"add",
"(",
"$",
"asset",
",",
"$",
"asset",
")",
";",
"}",
"}"
] | Used internally in order to help with the auto-loading of all of the assets.
@return void | [
"Used",
"internally",
"in",
"order",
"to",
"help",
"with",
"the",
"auto",
"-",
"loading",
"of",
"all",
"of",
"the",
"assets",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L659-L674 |
2,824 | awjudd/l4-assetprocessor | src/Awjudd/AssetProcessor/AssetProcessor.php | AssetProcessor.setupDirectories | private function setupDirectories()
{
// Check if the internal directory is present
if(!file_exists($dir = config('assetprocessor.cache.directory')))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory'))))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available (CSS)
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory')) . '/css'))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available (JavaScript)
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory')) . '/js'))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
} | php | private function setupDirectories()
{
// Check if the internal directory is present
if(!file_exists($dir = config('assetprocessor.cache.directory')))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory'))))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available (CSS)
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory')) . '/css'))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
// Check if the external directory is available (JavaScript)
if(!file_exists($dir = config('assetprocessor.cache.external', config('assetprocessor.cache.directory')) . '/js'))
{
// It doesn't, so make the folder
mkdir($dir, 0777, true);
}
} | [
"private",
"function",
"setupDirectories",
"(",
")",
"{",
"// Check if the internal directory is present",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
"=",
"config",
"(",
"'assetprocessor.cache.directory'",
")",
")",
")",
"{",
"// It doesn't, so make the folder",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"// Check if the external directory is available",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
"=",
"config",
"(",
"'assetprocessor.cache.external'",
",",
"config",
"(",
"'assetprocessor.cache.directory'",
")",
")",
")",
")",
"{",
"// It doesn't, so make the folder",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"// Check if the external directory is available (CSS)",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
"=",
"config",
"(",
"'assetprocessor.cache.external'",
",",
"config",
"(",
"'assetprocessor.cache.directory'",
")",
")",
".",
"'/css'",
")",
")",
"{",
"// It doesn't, so make the folder",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"// Check if the external directory is available (JavaScript)",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
"=",
"config",
"(",
"'assetprocessor.cache.external'",
",",
"config",
"(",
"'assetprocessor.cache.directory'",
")",
")",
".",
"'/js'",
")",
")",
"{",
"// It doesn't, so make the folder",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"}"
] | Sets up all of the base directories that the plugin will need to run.
@return void | [
"Sets",
"up",
"all",
"of",
"the",
"base",
"directories",
"that",
"the",
"plugin",
"will",
"need",
"to",
"run",
"."
] | 04045197ae1a81d77d0c8879dbc090bbd8a69307 | https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/AssetProcessor.php#L681-L710 |
2,825 | slickframework/orm | src/Mapper/MappersMap.php | MappersMap.set | public function set($key, $value)
{
if (! $value instanceof EntityMapperInterface) {
throw new InvalidArgumentException(
'Trying to add a non EntityMapper to MappersMap.'
);
}
return parent::set($key, $value);
} | php | public function set($key, $value)
{
if (! $value instanceof EntityMapperInterface) {
throw new InvalidArgumentException(
'Trying to add a non EntityMapper to MappersMap.'
);
}
return parent::set($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"EntityMapperInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Trying to add a non EntityMapper to MappersMap.'",
")",
";",
"}",
"return",
"parent",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Puts a new Entity mapper in the map.
@param string|int|HashableInterface $key
@param mixed $value
@return $this|self|MapInterface | [
"Puts",
"a",
"new",
"Entity",
"mapper",
"in",
"the",
"map",
"."
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/MappersMap.php#L35-L43 |
2,826 | helionogueir/languagepack | core/Lang.class.php | Lang.configuration | public static final function configuration(string $locale) {
if (!empty($locale)) {
Lang::$locale = $locale;
} else {
Lang::$locale = Lang::STANDARD_LOCALE;
}
return null;
} | php | public static final function configuration(string $locale) {
if (!empty($locale)) {
Lang::$locale = $locale;
} else {
Lang::$locale = Lang::STANDARD_LOCALE;
}
return null;
} | [
"public",
"static",
"final",
"function",
"configuration",
"(",
"string",
"$",
"locale",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"locale",
")",
")",
"{",
"Lang",
"::",
"$",
"locale",
"=",
"$",
"locale",
";",
"}",
"else",
"{",
"Lang",
"::",
"$",
"locale",
"=",
"Lang",
"::",
"STANDARD_LOCALE",
";",
"}",
"return",
"null",
";",
"}"
] | - Define configuration locate of language
@param string $locale Locate name of language
@return null | [
"-",
"Define",
"configuration",
"locate",
"of",
"language"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L30-L37 |
2,827 | helionogueir/languagepack | core/Lang.class.php | Lang.addRoot | public static final function addRoot(string $package, string $path) {
if (!empty($package) && !empty($path)) {
$dirname = realpath(Path::replaceOSSeparator($path));
if (is_dir($dirname)) {
Lang::$root[$package] = $dirname;
}
}
return null;
} | php | public static final function addRoot(string $package, string $path) {
if (!empty($package) && !empty($path)) {
$dirname = realpath(Path::replaceOSSeparator($path));
if (is_dir($dirname)) {
Lang::$root[$package] = $dirname;
}
}
return null;
} | [
"public",
"static",
"final",
"function",
"addRoot",
"(",
"string",
"$",
"package",
",",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"package",
")",
"&&",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"dirname",
"=",
"realpath",
"(",
"Path",
"::",
"replaceOSSeparator",
"(",
"$",
"path",
")",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"Lang",
"::",
"$",
"root",
"[",
"$",
"package",
"]",
"=",
"$",
"dirname",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | - Define root of find of packages
@param string $package Root name of package language
@param string $path Pathname of package language
@return null | [
"-",
"Define",
"root",
"of",
"find",
"of",
"packages"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L45-L53 |
2,828 | helionogueir/languagepack | core/Lang.class.php | Lang.get | public static final function get(string $identify, string $package, Array $data = null): string {
$text = $identify;
if (!empty($identify)) {
if ($language = Lang::loadPackage($package)) {
if (isset($language->{$identify})) {
$text = Lang::replace($language->{$identify}, $data);
}
}
}
return $text;
} | php | public static final function get(string $identify, string $package, Array $data = null): string {
$text = $identify;
if (!empty($identify)) {
if ($language = Lang::loadPackage($package)) {
if (isset($language->{$identify})) {
$text = Lang::replace($language->{$identify}, $data);
}
}
}
return $text;
} | [
"public",
"static",
"final",
"function",
"get",
"(",
"string",
"$",
"identify",
",",
"string",
"$",
"package",
",",
"Array",
"$",
"data",
"=",
"null",
")",
":",
"string",
"{",
"$",
"text",
"=",
"$",
"identify",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"identify",
")",
")",
"{",
"if",
"(",
"$",
"language",
"=",
"Lang",
"::",
"loadPackage",
"(",
"$",
"package",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"language",
"->",
"{",
"$",
"identify",
"}",
")",
")",
"{",
"$",
"text",
"=",
"Lang",
"::",
"replace",
"(",
"$",
"language",
"->",
"{",
"$",
"identify",
"}",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"return",
"$",
"text",
";",
"}"
] | - Identify TAG and package, and return text
@param string $identify TAG identify language
@param string $package Package language
@param Array $data Data repalce language
@return null | [
"-",
"Identify",
"TAG",
"and",
"package",
"and",
"return",
"text"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L62-L72 |
2,829 | helionogueir/languagepack | core/Lang.class.php | Lang.loadPackage | private static function loadPackage(string $package): stdClass {
$language = new stdClass();
if (!empty($package)) {
$filename = null;
if ($packageData = explode(":", $package)) {
if (!empty($packageData[0])) {
$filename .= Lang::$root[$packageData[0]];
}
if (!empty($packageData[1])) {
$filename .= DIRECTORY_SEPARATOR . $packageData[1];
}
$pathaname = Lang::selectPackage($filename);
if (file_exists($pathaname)) {
$pathaname = Path::replaceOSSeparator($pathaname);
$decode = json_decode(file_get_contents((new SplFileObject($pathaname, "r"))->getPathname()));
$language = (JSON_ERROR_NONE == json_last_error()) ? $decode : $language;
}
}
}
return $language;
} | php | private static function loadPackage(string $package): stdClass {
$language = new stdClass();
if (!empty($package)) {
$filename = null;
if ($packageData = explode(":", $package)) {
if (!empty($packageData[0])) {
$filename .= Lang::$root[$packageData[0]];
}
if (!empty($packageData[1])) {
$filename .= DIRECTORY_SEPARATOR . $packageData[1];
}
$pathaname = Lang::selectPackage($filename);
if (file_exists($pathaname)) {
$pathaname = Path::replaceOSSeparator($pathaname);
$decode = json_decode(file_get_contents((new SplFileObject($pathaname, "r"))->getPathname()));
$language = (JSON_ERROR_NONE == json_last_error()) ? $decode : $language;
}
}
}
return $language;
} | [
"private",
"static",
"function",
"loadPackage",
"(",
"string",
"$",
"package",
")",
":",
"stdClass",
"{",
"$",
"language",
"=",
"new",
"stdClass",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"package",
")",
")",
"{",
"$",
"filename",
"=",
"null",
";",
"if",
"(",
"$",
"packageData",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"package",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"packageData",
"[",
"0",
"]",
")",
")",
"{",
"$",
"filename",
".=",
"Lang",
"::",
"$",
"root",
"[",
"$",
"packageData",
"[",
"0",
"]",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"packageData",
"[",
"1",
"]",
")",
")",
"{",
"$",
"filename",
".=",
"DIRECTORY_SEPARATOR",
".",
"$",
"packageData",
"[",
"1",
"]",
";",
"}",
"$",
"pathaname",
"=",
"Lang",
"::",
"selectPackage",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"pathaname",
")",
")",
"{",
"$",
"pathaname",
"=",
"Path",
"::",
"replaceOSSeparator",
"(",
"$",
"pathaname",
")",
";",
"$",
"decode",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"(",
"new",
"SplFileObject",
"(",
"$",
"pathaname",
",",
"\"r\"",
")",
")",
"->",
"getPathname",
"(",
")",
")",
")",
";",
"$",
"language",
"=",
"(",
"JSON_ERROR_NONE",
"==",
"json_last_error",
"(",
")",
")",
"?",
"$",
"decode",
":",
"$",
"language",
";",
"}",
"}",
"}",
"return",
"$",
"language",
";",
"}"
] | - Identify package and load package language
@param string $package Path name package language
@return stdClass Object with language translate | [
"-",
"Identify",
"package",
"and",
"load",
"package",
"language"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L79-L99 |
2,830 | helionogueir/languagepack | core/Lang.class.php | Lang.selectPackage | private static function selectPackage(string $pathname): string {
$filename = $pathname . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::$locale . ".json";
if (file_exists($filename)) {
$pathname = $filename;
} else {
$pathname .= DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::STANDARD_LOCALE . ".json";
}
return $pathname;
} | php | private static function selectPackage(string $pathname): string {
$filename = $pathname . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::$locale . ".json";
if (file_exists($filename)) {
$pathname = $filename;
} else {
$pathname .= DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::STANDARD_LOCALE . ".json";
}
return $pathname;
} | [
"private",
"static",
"function",
"selectPackage",
"(",
"string",
"$",
"pathname",
")",
":",
"string",
"{",
"$",
"filename",
"=",
"$",
"pathname",
".",
"DIRECTORY_SEPARATOR",
".",
"'lang'",
".",
"DIRECTORY_SEPARATOR",
".",
"Lang",
"::",
"$",
"locale",
".",
"\".json\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"pathname",
"=",
"$",
"filename",
";",
"}",
"else",
"{",
"$",
"pathname",
".=",
"DIRECTORY_SEPARATOR",
".",
"'lang'",
".",
"DIRECTORY_SEPARATOR",
".",
"Lang",
"::",
"STANDARD_LOCALE",
".",
"\".json\"",
";",
"}",
"return",
"$",
"pathname",
";",
"}"
] | - Select package defined in configuration, case not exist package select standard package
@param string $pathname Pathname of package language
@return sting Pathname of package language | [
"-",
"Select",
"package",
"defined",
"in",
"configuration",
"case",
"not",
"exist",
"package",
"select",
"standard",
"package"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L106-L114 |
2,831 | helionogueir/languagepack | core/Lang.class.php | Lang.replace | private static function replace(string $text, Array $data = null): string {
if (!empty($text) && count($data)) {
if ($metaText = (new ReplaceText())->replace($text, $data)) {
$text = $metaText;
}
}
return $text;
} | php | private static function replace(string $text, Array $data = null): string {
if (!empty($text) && count($data)) {
if ($metaText = (new ReplaceText())->replace($text, $data)) {
$text = $metaText;
}
}
return $text;
} | [
"private",
"static",
"function",
"replace",
"(",
"string",
"$",
"text",
",",
"Array",
"$",
"data",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"text",
")",
"&&",
"count",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"$",
"metaText",
"=",
"(",
"new",
"ReplaceText",
"(",
")",
")",
"->",
"replace",
"(",
"$",
"text",
",",
"$",
"data",
")",
")",
"{",
"$",
"text",
"=",
"$",
"metaText",
";",
"}",
"}",
"return",
"$",
"text",
";",
"}"
] | - Replace TAGs in text
@param string $text Text with TAG(s)
@param string $data TAG(s) value(s)
@return sting Text TAG(s) replaced | [
"-",
"Replace",
"TAGs",
"in",
"text"
] | 0cba16308bdb55c9b58728ac3135261578e06fbf | https://github.com/helionogueir/languagepack/blob/0cba16308bdb55c9b58728ac3135261578e06fbf/core/Lang.class.php#L122-L129 |
2,832 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.findByTypesAndNames | public function findByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i');
$index = 0;
$conditions = [];
foreach ($namesByTypes as $type => $names) {
$conditions[] = '(i.type = :type' . $index . ' AND i.name IN (:names' . $index . '))';
$queryBuilder->setParameter('type' . $index, $type)
->setParameter('names' . $index, array_values($names));
++$index;
}
$result = [];
if ($index > 0) {
$queryBuilder->andWhere('(' . implode(' OR ', $conditions) . ')');
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | php | public function findByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i');
$index = 0;
$conditions = [];
foreach ($namesByTypes as $type => $names) {
$conditions[] = '(i.type = :type' . $index . ' AND i.name IN (:names' . $index . '))';
$queryBuilder->setParameter('type' . $index, $type)
->setParameter('names' . $index, array_values($names));
++$index;
}
$result = [];
if ($index > 0) {
$queryBuilder->andWhere('(' . implode(' OR ', $conditions) . ')');
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | [
"public",
"function",
"findByTypesAndNames",
"(",
"array",
"$",
"namesByTypes",
",",
"array",
"$",
"modCombinationIds",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'i'",
")",
"->",
"from",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"conditions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"namesByTypes",
"as",
"$",
"type",
"=>",
"$",
"names",
")",
"{",
"$",
"conditions",
"[",
"]",
"=",
"'(i.type = :type'",
".",
"$",
"index",
".",
"' AND i.name IN (:names'",
".",
"$",
"index",
".",
"'))'",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'type'",
".",
"$",
"index",
",",
"$",
"type",
")",
"->",
"setParameter",
"(",
"'names'",
".",
"$",
"index",
",",
"array_values",
"(",
"$",
"names",
")",
")",
";",
"++",
"$",
"index",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"index",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'('",
".",
"implode",
"(",
"' OR '",
",",
"$",
"conditions",
")",
".",
"')'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"modCombinationIds",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"innerJoin",
"(",
"'i.modCombinations'",
",",
"'mc'",
")",
"->",
"andWhere",
"(",
"'mc.id IN (:modCombinationIds)'",
")",
"->",
"setParameter",
"(",
"'modCombinationIds'",
",",
"array_values",
"(",
"$",
"modCombinationIds",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Finds the items with the specified types and names.
@param array|string[][] $namesByTypes
@param array|int[] $modCombinationIds
@return array|Item[] | [
"Finds",
"the",
"items",
"with",
"the",
"specified",
"types",
"and",
"names",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L25-L52 |
2,833 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.findByIds | public function findByIds(array $ids): array
{
$result = [];
if (count($ids) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i')
->andWhere('i.id IN (:ids)')
->setParameter('ids', array_values($ids));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | php | public function findByIds(array $ids): array
{
$result = [];
if (count($ids) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i')
->andWhere('i.id IN (:ids)')
->setParameter('ids', array_values($ids));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | [
"public",
"function",
"findByIds",
"(",
"array",
"$",
"ids",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"ids",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'i'",
")",
"->",
"from",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
"->",
"andWhere",
"(",
"'i.id IN (:ids)'",
")",
"->",
"setParameter",
"(",
"'ids'",
",",
"array_values",
"(",
"$",
"ids",
")",
")",
";",
"$",
"result",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Finds the items with the specified ids.
@param array|int[] $ids
@return array|Item[] | [
"Finds",
"the",
"items",
"with",
"the",
"specified",
"ids",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L59-L72 |
2,834 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.findByKeywords | public function findByKeywords(array $keywords, array $modCombinationIds = []): array
{
$result = [];
if (count($keywords) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i');
$index = 0;
foreach ($keywords as $keyword) {
$queryBuilder->andWhere('i.name LIKE :keyword' . $index)
->setParameter('keyword' . $index, '%' . addcslashes($keyword, '\\%_') . '%');
++$index;
}
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | php | public function findByKeywords(array $keywords, array $modCombinationIds = []): array
{
$result = [];
if (count($keywords) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i')
->from(Item::class, 'i');
$index = 0;
foreach ($keywords as $keyword) {
$queryBuilder->andWhere('i.name LIKE :keyword' . $index)
->setParameter('keyword' . $index, '%' . addcslashes($keyword, '\\%_') . '%');
++$index;
}
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | [
"public",
"function",
"findByKeywords",
"(",
"array",
"$",
"keywords",
",",
"array",
"$",
"modCombinationIds",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"keywords",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'i'",
")",
"->",
"from",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
";",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"keywords",
"as",
"$",
"keyword",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'i.name LIKE :keyword'",
".",
"$",
"index",
")",
"->",
"setParameter",
"(",
"'keyword'",
".",
"$",
"index",
",",
"'%'",
".",
"addcslashes",
"(",
"$",
"keyword",
",",
"'\\\\%_'",
")",
".",
"'%'",
")",
";",
"++",
"$",
"index",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"modCombinationIds",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"innerJoin",
"(",
"'i.modCombinations'",
",",
"'mc'",
")",
"->",
"andWhere",
"(",
"'mc.id IN (:modCombinationIds)'",
")",
"->",
"setParameter",
"(",
"'modCombinationIds'",
",",
"array_values",
"(",
"$",
"modCombinationIds",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Finds the items matching the specified keywords.
@param array|string[] $keywords
@param array|int[] $modCombinationIds
@return array|Item[] | [
"Finds",
"the",
"items",
"matching",
"the",
"specified",
"keywords",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L80-L104 |
2,835 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.findRandom | public function findRandom(int $numberOfItems, array $modCombinationIds = []): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select(['i', 'RAND() AS HIDDEN rand'])
->from(Item::class, 'i')
->addOrderBy('rand')
->setMaxResults($numberOfItems);
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
return $queryBuilder->getQuery()->getResult();
} | php | public function findRandom(int $numberOfItems, array $modCombinationIds = []): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select(['i', 'RAND() AS HIDDEN rand'])
->from(Item::class, 'i')
->addOrderBy('rand')
->setMaxResults($numberOfItems);
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('i.modCombinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
return $queryBuilder->getQuery()->getResult();
} | [
"public",
"function",
"findRandom",
"(",
"int",
"$",
"numberOfItems",
",",
"array",
"$",
"modCombinationIds",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"[",
"'i'",
",",
"'RAND() AS HIDDEN rand'",
"]",
")",
"->",
"from",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
"->",
"addOrderBy",
"(",
"'rand'",
")",
"->",
"setMaxResults",
"(",
"$",
"numberOfItems",
")",
";",
"if",
"(",
"count",
"(",
"$",
"modCombinationIds",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"innerJoin",
"(",
"'i.modCombinations'",
",",
"'mc'",
")",
"->",
"andWhere",
"(",
"'mc.id IN (:modCombinationIds)'",
")",
"->",
"setParameter",
"(",
"'modCombinationIds'",
",",
"array_values",
"(",
"$",
"modCombinationIds",
")",
")",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] | Finds random items.
@param int $numberOfItems
@param array|int[] $modCombinationIds
@return array|Item[] | [
"Finds",
"random",
"items",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L112-L126 |
2,836 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.removeOrphans | public function removeOrphans(): void
{
$itemIds = $this->findOrphanedIds();
if (count($itemIds) > 0) {
$this->removeIds($itemIds);
}
} | php | public function removeOrphans(): void
{
$itemIds = $this->findOrphanedIds();
if (count($itemIds) > 0) {
$this->removeIds($itemIds);
}
} | [
"public",
"function",
"removeOrphans",
"(",
")",
":",
"void",
"{",
"$",
"itemIds",
"=",
"$",
"this",
"->",
"findOrphanedIds",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"itemIds",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"removeIds",
"(",
"$",
"itemIds",
")",
";",
"}",
"}"
] | Removes any orphaned items, i.e. items no longer used by any recipe or combination. | [
"Removes",
"any",
"orphaned",
"items",
"i",
".",
"e",
".",
"items",
"no",
"longer",
"used",
"by",
"any",
"recipe",
"or",
"combination",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L131-L137 |
2,837 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.findOrphanedIds | protected function findOrphanedIds(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i.id AS id')
->from(Item::class, 'i')
->leftJoin('i.modCombinations', 'mc')
->leftJoin(RecipeIngredient::class, 'ri', 'WITH', 'ri.item = i.id')
->leftJoin(RecipeProduct::class, 'rp', 'WITH', 'rp.item = i.id')
->andWhere('mc.id IS NULL')
->andWhere('ri.item IS NULL')
->andWhere('rp.item IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = (int) $data['id'];
}
return $result;
} | php | protected function findOrphanedIds(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('i.id AS id')
->from(Item::class, 'i')
->leftJoin('i.modCombinations', 'mc')
->leftJoin(RecipeIngredient::class, 'ri', 'WITH', 'ri.item = i.id')
->leftJoin(RecipeProduct::class, 'rp', 'WITH', 'rp.item = i.id')
->andWhere('mc.id IS NULL')
->andWhere('ri.item IS NULL')
->andWhere('rp.item IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = (int) $data['id'];
}
return $result;
} | [
"protected",
"function",
"findOrphanedIds",
"(",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'i.id AS id'",
")",
"->",
"from",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
"->",
"leftJoin",
"(",
"'i.modCombinations'",
",",
"'mc'",
")",
"->",
"leftJoin",
"(",
"RecipeIngredient",
"::",
"class",
",",
"'ri'",
",",
"'WITH'",
",",
"'ri.item = i.id'",
")",
"->",
"leftJoin",
"(",
"RecipeProduct",
"::",
"class",
",",
"'rp'",
",",
"'WITH'",
",",
"'rp.item = i.id'",
")",
"->",
"andWhere",
"(",
"'mc.id IS NULL'",
")",
"->",
"andWhere",
"(",
"'ri.item IS NULL'",
")",
"->",
"andWhere",
"(",
"'rp.item IS NULL'",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
"as",
"$",
"data",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"(",
"int",
")",
"$",
"data",
"[",
"'id'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the ids of orphaned machines, which are no longer used by any recipe or combination.
@return array|int[] | [
"Returns",
"the",
"ids",
"of",
"orphaned",
"machines",
"which",
"are",
"no",
"longer",
"used",
"by",
"any",
"recipe",
"or",
"combination",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L143-L160 |
2,838 | factorio-item-browser/api-database | src/Repository/ItemRepository.php | ItemRepository.removeIds | protected function removeIds(array $itemIds): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(Item::class, 'i')
->andWhere('i.id IN (:itemIds)')
->setParameter('itemIds', array_values($itemIds));
$queryBuilder->getQuery()->execute();
} | php | protected function removeIds(array $itemIds): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(Item::class, 'i')
->andWhere('i.id IN (:itemIds)')
->setParameter('itemIds', array_values($itemIds));
$queryBuilder->getQuery()->execute();
} | [
"protected",
"function",
"removeIds",
"(",
"array",
"$",
"itemIds",
")",
":",
"void",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"delete",
"(",
"Item",
"::",
"class",
",",
"'i'",
")",
"->",
"andWhere",
"(",
"'i.id IN (:itemIds)'",
")",
"->",
"setParameter",
"(",
"'itemIds'",
",",
"array_values",
"(",
"$",
"itemIds",
")",
")",
";",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Removes the items with the specified ids from the database.
@param array|int[] $itemIds | [
"Removes",
"the",
"items",
"with",
"the",
"specified",
"ids",
"from",
"the",
"database",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ItemRepository.php#L166-L174 |
2,839 | marando/phpSOFA | src/Marando/IAU/iauPfw06.php | iauPfw06.Pfw06 | public static function Pfw06($date1, $date2, &$gamb, &$phib, &$psib, &$epsa) {
$t;
/* Interval between fundamental date J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* P03 bias+precession angles. */
$gamb = ( -0.052928 +
( 10.556378 +
( 0.4932044 +
( -0.00031238 +
( -0.000002788 +
( 0.0000000260 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$phib = ( 84381.412819 +
( -46.811016 +
( 0.0511268 +
( 0.00053289 +
( -0.000000440 +
( -0.0000000176 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$psib = ( -0.041775 +
( 5038.481484 +
( 1.5584175 +
( -0.00018522 +
( -0.000026452 +
( -0.0000000148 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$epsa = IAU::Obl06($date1, $date2);
return;
} | php | public static function Pfw06($date1, $date2, &$gamb, &$phib, &$psib, &$epsa) {
$t;
/* Interval between fundamental date J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* P03 bias+precession angles. */
$gamb = ( -0.052928 +
( 10.556378 +
( 0.4932044 +
( -0.00031238 +
( -0.000002788 +
( 0.0000000260 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$phib = ( 84381.412819 +
( -46.811016 +
( 0.0511268 +
( 0.00053289 +
( -0.000000440 +
( -0.0000000176 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$psib = ( -0.041775 +
( 5038.481484 +
( 1.5584175 +
( -0.00018522 +
( -0.000026452 +
( -0.0000000148 ) * $t) * $t) * $t) * $t) * $t) * DAS2R;
$epsa = IAU::Obl06($date1, $date2);
return;
} | [
"public",
"static",
"function",
"Pfw06",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"&",
"$",
"gamb",
",",
"&",
"$",
"phib",
",",
"&",
"$",
"psib",
",",
"&",
"$",
"epsa",
")",
"{",
"$",
"t",
";",
"/* Interval between fundamental date J2000.0 and given date (JC). */",
"$",
"t",
"=",
"(",
"(",
"$",
"date1",
"-",
"DJ00",
")",
"+",
"$",
"date2",
")",
"/",
"DJC",
";",
"/* P03 bias+precession angles. */",
"$",
"gamb",
"=",
"(",
"-",
"0.052928",
"+",
"(",
"10.556378",
"+",
"(",
"0.4932044",
"+",
"(",
"-",
"0.00031238",
"+",
"(",
"-",
"0.000002788",
"+",
"(",
"0.0000000260",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"DAS2R",
";",
"$",
"phib",
"=",
"(",
"84381.412819",
"+",
"(",
"-",
"46.811016",
"+",
"(",
"0.0511268",
"+",
"(",
"0.00053289",
"+",
"(",
"-",
"0.000000440",
"+",
"(",
"-",
"0.0000000176",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"DAS2R",
";",
"$",
"psib",
"=",
"(",
"-",
"0.041775",
"+",
"(",
"5038.481484",
"+",
"(",
"1.5584175",
"+",
"(",
"-",
"0.00018522",
"+",
"(",
"-",
"0.000026452",
"+",
"(",
"-",
"0.0000000148",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"DAS2R",
";",
"$",
"epsa",
"=",
"IAU",
"::",
"Obl06",
"(",
"$",
"date1",
",",
"$",
"date2",
")",
";",
"return",
";",
"}"
] | - - - - - - - - -
i a u P f w 0 6
- - - - - - - - -
Precession angles, IAU 2006 (Fukushima-Williams 4-angle formulation).
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
date1,date2 double TT as a 2-part Julian Date (Note 1)
Returned:
gamb double F-W angle gamma_bar (radians)
phib double F-W angle phi_bar (radians)
psib double F-W angle psi_bar (radians)
epsa double F-W angle epsilon_A (radians)
Notes:
1) The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways,
among others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable. The J2000 method is best matched to the way
the argument is handled internally and will deliver the
optimum resolution. The MJD method and the date & time methods
are both good compromises between resolution and convenience.
2) Naming the following points:
e = J2000.0 ecliptic pole,
p = GCRS pole,
E = mean ecliptic pole of date,
and P = mean pole of date,
the four Fukushima-Williams angles are as follows:
gamb = gamma_bar = epE
phib = phi_bar = pE
psib = psi_bar = pEP
epsa = epsilon_A = EP
3) The matrix representing the combined effects of frame bias and
precession is:
PxB = R_1(-epsa).R_3(-psib).R_1(phib).R_3(gamb)
4) The matrix representing the combined effects of frame bias,
precession and nutation is simply:
NxPxB = R_1(-epsa-dE).R_3(-psib-dP).R_1(phib).R_3(gamb)
where dP and dE are the nutation components with respect to the
ecliptic of date.
Reference:
Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
Called:
iauObl06 mean obliquity, IAU 2006
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"P",
"f",
"w",
"0",
"6",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauPfw06.php#L89-L117 |
2,840 | adrianyg7/Acl | src/Users/User.php | User.permissions | public function permissions()
{
if ( ! isset($this->permissions) ) {
$permissionModel = $this::$permissionModel;
$this->permissions = $permissionModel::whereHas('roles', function ($query) {
$query->whereHas('users', function ($query) {
$query->where('id', $this->id);
});
})->get();
}
return $this->permissions;
} | php | public function permissions()
{
if ( ! isset($this->permissions) ) {
$permissionModel = $this::$permissionModel;
$this->permissions = $permissionModel::whereHas('roles', function ($query) {
$query->whereHas('users', function ($query) {
$query->where('id', $this->id);
});
})->get();
}
return $this->permissions;
} | [
"public",
"function",
"permissions",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"permissions",
")",
")",
"{",
"$",
"permissionModel",
"=",
"$",
"this",
"::",
"$",
"permissionModel",
";",
"$",
"this",
"->",
"permissions",
"=",
"$",
"permissionModel",
"::",
"whereHas",
"(",
"'roles'",
",",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"whereHas",
"(",
"'users'",
",",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'id'",
",",
"$",
"this",
"->",
"id",
")",
";",
"}",
")",
";",
"}",
")",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"permissions",
";",
"}"
] | Get the user permissions.
@return \Illuminate\Database\Eloquent\Collection | [
"Get",
"the",
"user",
"permissions",
"."
] | b3d69199405ca7406b33991884f6bb2e6f85f4e5 | https://github.com/adrianyg7/Acl/blob/b3d69199405ca7406b33991884f6bb2e6f85f4e5/src/Users/User.php#L149-L162 |
2,841 | adrianyg7/Acl | src/Users/User.php | User.hasAnyPermission | public function hasAnyPermission($permissions)
{
$permissions = is_array($permissions) ? $permissions : func_get_args();
foreach ($permissions as $permission) {
if ( $this->permissions()->contains('name', $permission) ) return true;
}
return false;
} | php | public function hasAnyPermission($permissions)
{
$permissions = is_array($permissions) ? $permissions : func_get_args();
foreach ($permissions as $permission) {
if ( $this->permissions()->contains('name', $permission) ) return true;
}
return false;
} | [
"public",
"function",
"hasAnyPermission",
"(",
"$",
"permissions",
")",
"{",
"$",
"permissions",
"=",
"is_array",
"(",
"$",
"permissions",
")",
"?",
"$",
"permissions",
":",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"contains",
"(",
"'name'",
",",
"$",
"permission",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Determines if user has ANY given permissions.
@param string|array $permissions
@return boolean | [
"Determines",
"if",
"user",
"has",
"ANY",
"given",
"permissions",
"."
] | b3d69199405ca7406b33991884f6bb2e6f85f4e5 | https://github.com/adrianyg7/Acl/blob/b3d69199405ca7406b33991884f6bb2e6f85f4e5/src/Users/User.php#L187-L196 |
2,842 | bkdotcom/Toolbox | src/Image.php | Image.cropDefaults | protected function cropDefaults($fpSrc, $vals)
{
$this->debug->groupcollapsed(__METHOD__);
// src Defaults
if (empty($vals['src_type']) || empty($vals['src_w']) || empty($vals['src_h'])) {
// $this->debug->log('determine src info');
$imageInfo = $fpSrc == 'data'
? getimagesizefromstring($vals['src_data'])
: getimagesize($fpSrc);
// $this->debug->log('imageInfo', $imageInfo);
if ($imageInfo) {
$imageInfoVals = array(
'src_type' => $imageInfo[2],
'src_w' => $imageInfo[0],
'src_h' => $imageInfo[1],
);
foreach (array('src_type','src_w','src_h') as $k) {
if (empty($vals[$k])) {
$vals[$k] = $imageInfoVals[$k];
}
}
}
}
// $this->debug->log('vals', $vals);
foreach (array('src_type','dst_type') as $type) {
if (is_int($vals[$type])) {
$vals[$type] = image_type_to_extension($vals[$type], false); // false = no dot
} elseif ($vals[$type] == 'jpg') {
$vals[$type] = 'jpeg';
}
}
if (empty($vals['dst_w'])) {
$vals['dst_w'] = $vals['src_w'];
}
if (empty($vals['dst_h'])) {
$vals['dst_h'] = $vals['src_h'];
}
if (is_string($vals['color_bg'])) {
$vals['color_bg'] = array_values($this->hex2rgb($vals['color_bg']));
}
if (empty($vals['opts'])) {
$quality = $vals['quality'];
if ($vals['dst_type'] == 'png') {
$vals['quality'] = round(abs(($quality - 100) / 11.111111)); // convert 0-100 "quality" to 0-9 "compression"
}
$vals['opts'] = array( $vals['quality'] );
}
// $this->debug->log('vals', $vals);
$this->debug->groupEnd();
return $vals;
} | php | protected function cropDefaults($fpSrc, $vals)
{
$this->debug->groupcollapsed(__METHOD__);
// src Defaults
if (empty($vals['src_type']) || empty($vals['src_w']) || empty($vals['src_h'])) {
// $this->debug->log('determine src info');
$imageInfo = $fpSrc == 'data'
? getimagesizefromstring($vals['src_data'])
: getimagesize($fpSrc);
// $this->debug->log('imageInfo', $imageInfo);
if ($imageInfo) {
$imageInfoVals = array(
'src_type' => $imageInfo[2],
'src_w' => $imageInfo[0],
'src_h' => $imageInfo[1],
);
foreach (array('src_type','src_w','src_h') as $k) {
if (empty($vals[$k])) {
$vals[$k] = $imageInfoVals[$k];
}
}
}
}
// $this->debug->log('vals', $vals);
foreach (array('src_type','dst_type') as $type) {
if (is_int($vals[$type])) {
$vals[$type] = image_type_to_extension($vals[$type], false); // false = no dot
} elseif ($vals[$type] == 'jpg') {
$vals[$type] = 'jpeg';
}
}
if (empty($vals['dst_w'])) {
$vals['dst_w'] = $vals['src_w'];
}
if (empty($vals['dst_h'])) {
$vals['dst_h'] = $vals['src_h'];
}
if (is_string($vals['color_bg'])) {
$vals['color_bg'] = array_values($this->hex2rgb($vals['color_bg']));
}
if (empty($vals['opts'])) {
$quality = $vals['quality'];
if ($vals['dst_type'] == 'png') {
$vals['quality'] = round(abs(($quality - 100) / 11.111111)); // convert 0-100 "quality" to 0-9 "compression"
}
$vals['opts'] = array( $vals['quality'] );
}
// $this->debug->log('vals', $vals);
$this->debug->groupEnd();
return $vals;
} | [
"protected",
"function",
"cropDefaults",
"(",
"$",
"fpSrc",
",",
"$",
"vals",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupcollapsed",
"(",
"__METHOD__",
")",
";",
"// src Defaults",
"if",
"(",
"empty",
"(",
"$",
"vals",
"[",
"'src_type'",
"]",
")",
"||",
"empty",
"(",
"$",
"vals",
"[",
"'src_w'",
"]",
")",
"||",
"empty",
"(",
"$",
"vals",
"[",
"'src_h'",
"]",
")",
")",
"{",
"// $this->debug->log('determine src info');",
"$",
"imageInfo",
"=",
"$",
"fpSrc",
"==",
"'data'",
"?",
"getimagesizefromstring",
"(",
"$",
"vals",
"[",
"'src_data'",
"]",
")",
":",
"getimagesize",
"(",
"$",
"fpSrc",
")",
";",
"// $this->debug->log('imageInfo', $imageInfo);",
"if",
"(",
"$",
"imageInfo",
")",
"{",
"$",
"imageInfoVals",
"=",
"array",
"(",
"'src_type'",
"=>",
"$",
"imageInfo",
"[",
"2",
"]",
",",
"'src_w'",
"=>",
"$",
"imageInfo",
"[",
"0",
"]",
",",
"'src_h'",
"=>",
"$",
"imageInfo",
"[",
"1",
"]",
",",
")",
";",
"foreach",
"(",
"array",
"(",
"'src_type'",
",",
"'src_w'",
",",
"'src_h'",
")",
"as",
"$",
"k",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"vals",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"vals",
"[",
"$",
"k",
"]",
"=",
"$",
"imageInfoVals",
"[",
"$",
"k",
"]",
";",
"}",
"}",
"}",
"}",
"// $this->debug->log('vals', $vals);",
"foreach",
"(",
"array",
"(",
"'src_type'",
",",
"'dst_type'",
")",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"vals",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"vals",
"[",
"$",
"type",
"]",
"=",
"image_type_to_extension",
"(",
"$",
"vals",
"[",
"$",
"type",
"]",
",",
"false",
")",
";",
"// false = no dot",
"}",
"elseif",
"(",
"$",
"vals",
"[",
"$",
"type",
"]",
"==",
"'jpg'",
")",
"{",
"$",
"vals",
"[",
"$",
"type",
"]",
"=",
"'jpeg'",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"vals",
"[",
"'dst_w'",
"]",
")",
")",
"{",
"$",
"vals",
"[",
"'dst_w'",
"]",
"=",
"$",
"vals",
"[",
"'src_w'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"vals",
"[",
"'dst_h'",
"]",
")",
")",
"{",
"$",
"vals",
"[",
"'dst_h'",
"]",
"=",
"$",
"vals",
"[",
"'src_h'",
"]",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"vals",
"[",
"'color_bg'",
"]",
")",
")",
"{",
"$",
"vals",
"[",
"'color_bg'",
"]",
"=",
"array_values",
"(",
"$",
"this",
"->",
"hex2rgb",
"(",
"$",
"vals",
"[",
"'color_bg'",
"]",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"vals",
"[",
"'opts'",
"]",
")",
")",
"{",
"$",
"quality",
"=",
"$",
"vals",
"[",
"'quality'",
"]",
";",
"if",
"(",
"$",
"vals",
"[",
"'dst_type'",
"]",
"==",
"'png'",
")",
"{",
"$",
"vals",
"[",
"'quality'",
"]",
"=",
"round",
"(",
"abs",
"(",
"(",
"$",
"quality",
"-",
"100",
")",
"/",
"11.111111",
")",
")",
";",
"// convert 0-100 \"quality\" to 0-9 \"compression\"",
"}",
"$",
"vals",
"[",
"'opts'",
"]",
"=",
"array",
"(",
"$",
"vals",
"[",
"'quality'",
"]",
")",
";",
"}",
"// $this->debug->log('vals', $vals);",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"vals",
";",
"}"
] | get default & normalize crop parameters
@param string $fpSrc file path or 'data'
@param array $vals paramaters
@return mixed | [
"get",
"default",
"&",
"normalize",
"crop",
"parameters"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L172-L222 |
2,843 | bkdotcom/Toolbox | src/Image.php | Image.getConstrainedDimensions | public function getConstrainedDimensions($curW, $curH, $maxW, $maxH)
{
$this->debug->groupCollapsed(__METHOD__);
$ratio = $curW / $curH; // > 1 = wider than tall (landscape) < 1 = portrait
$return = array('w' => $curW, 'h' => $curH);
if ($return['w'] > $maxW) {
$this->debug->log('fitting to maxW');
$return = array(
'w' => $maxW,
'h' => round($maxW / $ratio)
);
}
if ($return['h'] > $maxH) {
$this->debug->log('fitting to maxH');
$return = array(
'w' => round($maxH * $ratio),
'h' => $maxH
);
}
// $this->debug->log('return', $return);
$this->debug->groupEnd();
return $return;
} | php | public function getConstrainedDimensions($curW, $curH, $maxW, $maxH)
{
$this->debug->groupCollapsed(__METHOD__);
$ratio = $curW / $curH; // > 1 = wider than tall (landscape) < 1 = portrait
$return = array('w' => $curW, 'h' => $curH);
if ($return['w'] > $maxW) {
$this->debug->log('fitting to maxW');
$return = array(
'w' => $maxW,
'h' => round($maxW / $ratio)
);
}
if ($return['h'] > $maxH) {
$this->debug->log('fitting to maxH');
$return = array(
'w' => round($maxH * $ratio),
'h' => $maxH
);
}
// $this->debug->log('return', $return);
$this->debug->groupEnd();
return $return;
} | [
"public",
"function",
"getConstrainedDimensions",
"(",
"$",
"curW",
",",
"$",
"curH",
",",
"$",
"maxW",
",",
"$",
"maxH",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__METHOD__",
")",
";",
"$",
"ratio",
"=",
"$",
"curW",
"/",
"$",
"curH",
";",
"// > 1 = wider than tall (landscape) < 1 = portrait",
"$",
"return",
"=",
"array",
"(",
"'w'",
"=>",
"$",
"curW",
",",
"'h'",
"=>",
"$",
"curH",
")",
";",
"if",
"(",
"$",
"return",
"[",
"'w'",
"]",
">",
"$",
"maxW",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'fitting to maxW'",
")",
";",
"$",
"return",
"=",
"array",
"(",
"'w'",
"=>",
"$",
"maxW",
",",
"'h'",
"=>",
"round",
"(",
"$",
"maxW",
"/",
"$",
"ratio",
")",
")",
";",
"}",
"if",
"(",
"$",
"return",
"[",
"'h'",
"]",
">",
"$",
"maxH",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'fitting to maxH'",
")",
";",
"$",
"return",
"=",
"array",
"(",
"'w'",
"=>",
"round",
"(",
"$",
"maxH",
"*",
"$",
"ratio",
")",
",",
"'h'",
"=>",
"$",
"maxH",
")",
";",
"}",
"// $this->debug->log('return', $return);",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"return",
";",
"}"
] | Get the dimensions to fit an image to maxw and maxH
@param integer $curW current width
@param integer $curH current height
@param integer $maxW maximum width
@param integer $maxH maximum height
@return array | [
"Get",
"the",
"dimensions",
"to",
"fit",
"an",
"image",
"to",
"maxw",
"and",
"maxH"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L302-L324 |
2,844 | bkdotcom/Toolbox | src/Image.php | Image.hex2rgb | public function hex2rgb($str_hex, $returnAsString = false, $seperator = ',')
{
$str_hex = preg_replace("/[^0-9A-Fa-f]/", '', $str_hex); // Gets a proper hex string
$rgbArray = array();
$return = false;
if (strlen($str_hex) == 6) {
// If a proper hex code, convert using bitwise operation. No overhead... faster
$colorVal = hexdec($str_hex);
$rgbArray = array(
'red' => 0xFF & ($colorVal >> 0x10),
'green' => 0xFF & ($colorVal >> 0x8),
'blue' => 0xFF & $colorVal,
);
} elseif (strlen($str_hex) == 3) {
// if shorthand notation, need some string manipulations
$rgbArray = array(
'red' => hexdec(str_repeat(substr($str_hex, 0, 1), 2)),
'green' => hexdec(str_repeat(substr($str_hex, 1, 1), 2)),
'blue' => hexdec(str_repeat(substr($str_hex, 2, 1), 2)),
);
}
if (!empty($rgbArray)) {
$return = $returnAsString
? implode($seperator, $rgbArray)
: $rgbArray; // returns the rgb string or the associative array
}
return $return;
} | php | public function hex2rgb($str_hex, $returnAsString = false, $seperator = ',')
{
$str_hex = preg_replace("/[^0-9A-Fa-f]/", '', $str_hex); // Gets a proper hex string
$rgbArray = array();
$return = false;
if (strlen($str_hex) == 6) {
// If a proper hex code, convert using bitwise operation. No overhead... faster
$colorVal = hexdec($str_hex);
$rgbArray = array(
'red' => 0xFF & ($colorVal >> 0x10),
'green' => 0xFF & ($colorVal >> 0x8),
'blue' => 0xFF & $colorVal,
);
} elseif (strlen($str_hex) == 3) {
// if shorthand notation, need some string manipulations
$rgbArray = array(
'red' => hexdec(str_repeat(substr($str_hex, 0, 1), 2)),
'green' => hexdec(str_repeat(substr($str_hex, 1, 1), 2)),
'blue' => hexdec(str_repeat(substr($str_hex, 2, 1), 2)),
);
}
if (!empty($rgbArray)) {
$return = $returnAsString
? implode($seperator, $rgbArray)
: $rgbArray; // returns the rgb string or the associative array
}
return $return;
} | [
"public",
"function",
"hex2rgb",
"(",
"$",
"str_hex",
",",
"$",
"returnAsString",
"=",
"false",
",",
"$",
"seperator",
"=",
"','",
")",
"{",
"$",
"str_hex",
"=",
"preg_replace",
"(",
"\"/[^0-9A-Fa-f]/\"",
",",
"''",
",",
"$",
"str_hex",
")",
";",
"// Gets a proper hex string",
"$",
"rgbArray",
"=",
"array",
"(",
")",
";",
"$",
"return",
"=",
"false",
";",
"if",
"(",
"strlen",
"(",
"$",
"str_hex",
")",
"==",
"6",
")",
"{",
"// If a proper hex code, convert using bitwise operation. No overhead... faster",
"$",
"colorVal",
"=",
"hexdec",
"(",
"$",
"str_hex",
")",
";",
"$",
"rgbArray",
"=",
"array",
"(",
"'red'",
"=>",
"0xFF",
"&",
"(",
"$",
"colorVal",
">>",
"0x10",
")",
",",
"'green'",
"=>",
"0xFF",
"&",
"(",
"$",
"colorVal",
">>",
"0x8",
")",
",",
"'blue'",
"=>",
"0xFF",
"&",
"$",
"colorVal",
",",
")",
";",
"}",
"elseif",
"(",
"strlen",
"(",
"$",
"str_hex",
")",
"==",
"3",
")",
"{",
"// if shorthand notation, need some string manipulations",
"$",
"rgbArray",
"=",
"array",
"(",
"'red'",
"=>",
"hexdec",
"(",
"str_repeat",
"(",
"substr",
"(",
"$",
"str_hex",
",",
"0",
",",
"1",
")",
",",
"2",
")",
")",
",",
"'green'",
"=>",
"hexdec",
"(",
"str_repeat",
"(",
"substr",
"(",
"$",
"str_hex",
",",
"1",
",",
"1",
")",
",",
"2",
")",
")",
",",
"'blue'",
"=>",
"hexdec",
"(",
"str_repeat",
"(",
"substr",
"(",
"$",
"str_hex",
",",
"2",
",",
"1",
")",
",",
"2",
")",
")",
",",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"rgbArray",
")",
")",
"{",
"$",
"return",
"=",
"$",
"returnAsString",
"?",
"implode",
"(",
"$",
"seperator",
",",
"$",
"rgbArray",
")",
":",
"$",
"rgbArray",
";",
"// returns the rgb string or the associative array",
"}",
"return",
"$",
"return",
";",
"}"
] | Convert a hexadecimal color code to its RGB equivalent
@param string $str_hex hexadecimal color value
@param boolean $returnAsString if set true, returns the value separated by the separator character. Otherwise returns associative array
@param string $seperator to separate RGB values. Applicable only if second parameter is true.
@return array or string (depending on second parameter. Returns false if invalid hex color value) | [
"Convert",
"a",
"hexadecimal",
"color",
"code",
"to",
"its",
"RGB",
"equivalent"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L335-L362 |
2,845 | bkdotcom/Toolbox | src/Image.php | Image.imagebmp | public function imagebmp(&$img, $filename = false)
{
$wid = imagesx($img);
$hei = imagesy($img);
$wid_pad = str_pad('', $wid % 4, "\0");
$size = 54 + ($wid + $wid_pad) * $hei;
// prepare & save header
$header = array(
'identifier' => 'BM',
'file_size' => $this->dword($size),
'reserved' => $this->dword(0),
'bitmap_data' => $this->dword(54),
'header_size' => $this->dword(40),
'width' => $this->dword($wid),
'height' => $this->dword($hei),
'planes' => $this->word(1),
'bits_per_pixel' => $this->word(24),
'compression' => $this->dword(0),
'data_size' => $this->dword(0),
'h_resolution' => $this->dword(0),
'v_resolution' => $this->dword(0),
'colors' => $this->dword(0),
'important_colors' => $this->dword(0),
);
if ($filename) {
$fh = fopen($filename, "wb");
foreach ($header as $h) {
fwrite($fh, $h);
}
// save pixels
for ($y=$hei-1; $y>=0; $y--) {
for ($x=0; $x<$wid; $x++) {
$rgb = imagecolorat($img, $x, $y);
fwrite($fh, $this->byte3($rgb));
}
fwrite($fh, $wid_pad);
}
return fclose($fh);
} else {
foreach ($header as $h) {
echo $h;
}
// save pixels
for ($y = $hei - 1; $y >= 0; $y--) {
for ($x=0; $x<$wid; $x++) {
$rgb = imagecolorat($img, $x, $y);
echo $this->byte3($rgb);
}
echo $wid_pad;
}
return true;
}
} | php | public function imagebmp(&$img, $filename = false)
{
$wid = imagesx($img);
$hei = imagesy($img);
$wid_pad = str_pad('', $wid % 4, "\0");
$size = 54 + ($wid + $wid_pad) * $hei;
// prepare & save header
$header = array(
'identifier' => 'BM',
'file_size' => $this->dword($size),
'reserved' => $this->dword(0),
'bitmap_data' => $this->dword(54),
'header_size' => $this->dword(40),
'width' => $this->dword($wid),
'height' => $this->dword($hei),
'planes' => $this->word(1),
'bits_per_pixel' => $this->word(24),
'compression' => $this->dword(0),
'data_size' => $this->dword(0),
'h_resolution' => $this->dword(0),
'v_resolution' => $this->dword(0),
'colors' => $this->dword(0),
'important_colors' => $this->dword(0),
);
if ($filename) {
$fh = fopen($filename, "wb");
foreach ($header as $h) {
fwrite($fh, $h);
}
// save pixels
for ($y=$hei-1; $y>=0; $y--) {
for ($x=0; $x<$wid; $x++) {
$rgb = imagecolorat($img, $x, $y);
fwrite($fh, $this->byte3($rgb));
}
fwrite($fh, $wid_pad);
}
return fclose($fh);
} else {
foreach ($header as $h) {
echo $h;
}
// save pixels
for ($y = $hei - 1; $y >= 0; $y--) {
for ($x=0; $x<$wid; $x++) {
$rgb = imagecolorat($img, $x, $y);
echo $this->byte3($rgb);
}
echo $wid_pad;
}
return true;
}
} | [
"public",
"function",
"imagebmp",
"(",
"&",
"$",
"img",
",",
"$",
"filename",
"=",
"false",
")",
"{",
"$",
"wid",
"=",
"imagesx",
"(",
"$",
"img",
")",
";",
"$",
"hei",
"=",
"imagesy",
"(",
"$",
"img",
")",
";",
"$",
"wid_pad",
"=",
"str_pad",
"(",
"''",
",",
"$",
"wid",
"%",
"4",
",",
"\"\\0\"",
")",
";",
"$",
"size",
"=",
"54",
"+",
"(",
"$",
"wid",
"+",
"$",
"wid_pad",
")",
"*",
"$",
"hei",
";",
"// prepare & save header",
"$",
"header",
"=",
"array",
"(",
"'identifier'",
"=>",
"'BM'",
",",
"'file_size'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"$",
"size",
")",
",",
"'reserved'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'bitmap_data'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"54",
")",
",",
"'header_size'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"40",
")",
",",
"'width'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"$",
"wid",
")",
",",
"'height'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"$",
"hei",
")",
",",
"'planes'",
"=>",
"$",
"this",
"->",
"word",
"(",
"1",
")",
",",
"'bits_per_pixel'",
"=>",
"$",
"this",
"->",
"word",
"(",
"24",
")",
",",
"'compression'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'data_size'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'h_resolution'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'v_resolution'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'colors'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
"'important_colors'",
"=>",
"$",
"this",
"->",
"dword",
"(",
"0",
")",
",",
")",
";",
"if",
"(",
"$",
"filename",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"wb\"",
")",
";",
"foreach",
"(",
"$",
"header",
"as",
"$",
"h",
")",
"{",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"h",
")",
";",
"}",
"// save pixels",
"for",
"(",
"$",
"y",
"=",
"$",
"hei",
"-",
"1",
";",
"$",
"y",
">=",
"0",
";",
"$",
"y",
"--",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"wid",
";",
"$",
"x",
"++",
")",
"{",
"$",
"rgb",
"=",
"imagecolorat",
"(",
"$",
"img",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"this",
"->",
"byte3",
"(",
"$",
"rgb",
")",
")",
";",
"}",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"wid_pad",
")",
";",
"}",
"return",
"fclose",
"(",
"$",
"fh",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"header",
"as",
"$",
"h",
")",
"{",
"echo",
"$",
"h",
";",
"}",
"// save pixels",
"for",
"(",
"$",
"y",
"=",
"$",
"hei",
"-",
"1",
";",
"$",
"y",
">=",
"0",
";",
"$",
"y",
"--",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"wid",
";",
"$",
"x",
"++",
")",
"{",
"$",
"rgb",
"=",
"imagecolorat",
"(",
"$",
"img",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"echo",
"$",
"this",
"->",
"byte3",
"(",
"$",
"rgb",
")",
";",
"}",
"echo",
"$",
"wid_pad",
";",
"}",
"return",
"true",
";",
"}",
"}"
] | Save 24bit BMP file
@param resource $img image resource
@param boolean $filename (optional) filepath to save to.. otherwise image is echoed
@return boolean | [
"Save",
"24bit",
"BMP",
"file"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L372-L424 |
2,846 | bkdotcom/Toolbox | src/Image.php | Image.isImage | public function isImage($filepath)
{
$this->debug->groupCollapsed(__METHOD__, $filepath);
$isImage = false;
if (false && function_exists('exif_imagetype')) {
$type = exif_imagetype($filepath);
$isImage = ($type !== false && in_array($type, $this->imagetypes));
} else {
$imageInfo = getimagesize($filepath);
$mime = $imageInfo['mime'];
// $this->debug->log('imageInfo', $imageInfo);
$isImage = (isset($this->imageTypes[$mime]) && $imageInfo[0] && $imageInfo[1]);
}
$this->debug->groupEnd();
return $isImage;
} | php | public function isImage($filepath)
{
$this->debug->groupCollapsed(__METHOD__, $filepath);
$isImage = false;
if (false && function_exists('exif_imagetype')) {
$type = exif_imagetype($filepath);
$isImage = ($type !== false && in_array($type, $this->imagetypes));
} else {
$imageInfo = getimagesize($filepath);
$mime = $imageInfo['mime'];
// $this->debug->log('imageInfo', $imageInfo);
$isImage = (isset($this->imageTypes[$mime]) && $imageInfo[0] && $imageInfo[1]);
}
$this->debug->groupEnd();
return $isImage;
} | [
"public",
"function",
"isImage",
"(",
"$",
"filepath",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__METHOD__",
",",
"$",
"filepath",
")",
";",
"$",
"isImage",
"=",
"false",
";",
"if",
"(",
"false",
"&&",
"function_exists",
"(",
"'exif_imagetype'",
")",
")",
"{",
"$",
"type",
"=",
"exif_imagetype",
"(",
"$",
"filepath",
")",
";",
"$",
"isImage",
"=",
"(",
"$",
"type",
"!==",
"false",
"&&",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"imagetypes",
")",
")",
";",
"}",
"else",
"{",
"$",
"imageInfo",
"=",
"getimagesize",
"(",
"$",
"filepath",
")",
";",
"$",
"mime",
"=",
"$",
"imageInfo",
"[",
"'mime'",
"]",
";",
"// $this->debug->log('imageInfo', $imageInfo);",
"$",
"isImage",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"imageTypes",
"[",
"$",
"mime",
"]",
")",
"&&",
"$",
"imageInfo",
"[",
"0",
"]",
"&&",
"$",
"imageInfo",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"isImage",
";",
"}"
] | is the file a supported image?
@param string $filepath filepath
@return boolean | [
"is",
"the",
"file",
"a",
"supported",
"image?"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L529-L544 |
2,847 | bkdotcom/Toolbox | src/Image.php | Image.passthru | public function passthru($filepath, $info = array())
{
$this->debug->group(__METHOD__);
// $this->debug->log('info', $info);
$info = array_merge(array(
'filename' => null,
'md5' => null,
'mime' => 'image/jpeg',
'size' => null,
), $info);
if (file_exists($filepath)) {
if (empty($info['md5'])) {
$info['md5'] = md5_file($filepath);
}
if (empty($info['size'])) {
$info['size'] = filesize($filepath);
}
$headers = apache_request_headers();
$this->debug->log('headers', $headers);
$this->debug->log('info[md5]', $info['md5']);
if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == $info['md5']) {
header('HTTP/1.1 304 Not Modified');
} else {
header('Content-Type: '.$info['mime']);
header('ETag: '.$info['md5']);
header('Content-Length: '.$info['size']);
// header('Cache-Control: must-revalidate');
header('Last Modified: '.gmdate('D, d M Y H:i:s \G\M\T'));
if ($info['filename']) {
header('Content-Disposition: inline; filename="'.$info['filename'].'"');
}
readfile($filepath);
}
} else {
$this->debug->warn('file does not exist', $filepath);
}
$this->debug->groupEnd();
return;
} | php | public function passthru($filepath, $info = array())
{
$this->debug->group(__METHOD__);
// $this->debug->log('info', $info);
$info = array_merge(array(
'filename' => null,
'md5' => null,
'mime' => 'image/jpeg',
'size' => null,
), $info);
if (file_exists($filepath)) {
if (empty($info['md5'])) {
$info['md5'] = md5_file($filepath);
}
if (empty($info['size'])) {
$info['size'] = filesize($filepath);
}
$headers = apache_request_headers();
$this->debug->log('headers', $headers);
$this->debug->log('info[md5]', $info['md5']);
if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == $info['md5']) {
header('HTTP/1.1 304 Not Modified');
} else {
header('Content-Type: '.$info['mime']);
header('ETag: '.$info['md5']);
header('Content-Length: '.$info['size']);
// header('Cache-Control: must-revalidate');
header('Last Modified: '.gmdate('D, d M Y H:i:s \G\M\T'));
if ($info['filename']) {
header('Content-Disposition: inline; filename="'.$info['filename'].'"');
}
readfile($filepath);
}
} else {
$this->debug->warn('file does not exist', $filepath);
}
$this->debug->groupEnd();
return;
} | [
"public",
"function",
"passthru",
"(",
"$",
"filepath",
",",
"$",
"info",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"group",
"(",
"__METHOD__",
")",
";",
"// $this->debug->log('info', $info);",
"$",
"info",
"=",
"array_merge",
"(",
"array",
"(",
"'filename'",
"=>",
"null",
",",
"'md5'",
"=>",
"null",
",",
"'mime'",
"=>",
"'image/jpeg'",
",",
"'size'",
"=>",
"null",
",",
")",
",",
"$",
"info",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filepath",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"info",
"[",
"'md5'",
"]",
")",
")",
"{",
"$",
"info",
"[",
"'md5'",
"]",
"=",
"md5_file",
"(",
"$",
"filepath",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"info",
"[",
"'size'",
"]",
")",
")",
"{",
"$",
"info",
"[",
"'size'",
"]",
"=",
"filesize",
"(",
"$",
"filepath",
")",
";",
"}",
"$",
"headers",
"=",
"apache_request_headers",
"(",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'headers'",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'info[md5]'",
",",
"$",
"info",
"[",
"'md5'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'If-None-Match'",
"]",
")",
"&&",
"$",
"headers",
"[",
"'If-None-Match'",
"]",
"==",
"$",
"info",
"[",
"'md5'",
"]",
")",
"{",
"header",
"(",
"'HTTP/1.1 304 Not Modified'",
")",
";",
"}",
"else",
"{",
"header",
"(",
"'Content-Type: '",
".",
"$",
"info",
"[",
"'mime'",
"]",
")",
";",
"header",
"(",
"'ETag: '",
".",
"$",
"info",
"[",
"'md5'",
"]",
")",
";",
"header",
"(",
"'Content-Length: '",
".",
"$",
"info",
"[",
"'size'",
"]",
")",
";",
"// header('Cache-Control: must-revalidate');",
"header",
"(",
"'Last Modified: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
")",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'filename'",
"]",
")",
"{",
"header",
"(",
"'Content-Disposition: inline; filename=\"'",
".",
"$",
"info",
"[",
"'filename'",
"]",
".",
"'\"'",
")",
";",
"}",
"readfile",
"(",
"$",
"filepath",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"->",
"warn",
"(",
"'file does not exist'",
",",
"$",
"filepath",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
";",
"}"
] | Output image with headers
@param string $filepath file path
@param array $info filename, mime, filesize, etc
@return void | [
"Output",
"image",
"with",
"headers"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Image.php#L586-L624 |
2,848 | donghaichen/framework | src/Illuminate/Clover/Paginator.php | Paginator.make | public function make($items, $total, $pageSize = 10)
{
$this->total = abs($total);
$this->pageSize = $pageSize;
$this->items = $items;
return $this;
} | php | public function make($items, $total, $pageSize = 10)
{
$this->total = abs($total);
$this->pageSize = $pageSize;
$this->items = $items;
return $this;
} | [
"public",
"function",
"make",
"(",
"$",
"items",
",",
"$",
"total",
",",
"$",
"pageSize",
"=",
"10",
")",
"{",
"$",
"this",
"->",
"total",
"=",
"abs",
"(",
"$",
"total",
")",
";",
"$",
"this",
"->",
"pageSize",
"=",
"$",
"pageSize",
";",
"$",
"this",
"->",
"items",
"=",
"$",
"items",
";",
"return",
"$",
"this",
";",
"}"
] | Make a pagination
@param array $items
@param integer $total
@param integer $pageSize
@return array | [
"Make",
"a",
"pagination"
] | 1d08752d98841b2e3536a98c5b07efdb5691bd91 | https://github.com/donghaichen/framework/blob/1d08752d98841b2e3536a98c5b07efdb5691bd91/src/Illuminate/Clover/Paginator.php#L59-L66 |
2,849 | donghaichen/framework | src/Illuminate/Clover/Paginator.php | Paginator.getCurrentPage | public function getCurrentPage($total = null)
{
$page = abs(app()->request->get('page', 1));
if ($total) {
$this->total = $total;
}
$page >= 1 || $page = 1;
if ($this->items) {
$totalPage = $this->getTotalPage();
$page <= $totalPage || $page = $totalPage;
}
return $page;
} | php | public function getCurrentPage($total = null)
{
$page = abs(app()->request->get('page', 1));
if ($total) {
$this->total = $total;
}
$page >= 1 || $page = 1;
if ($this->items) {
$totalPage = $this->getTotalPage();
$page <= $totalPage || $page = $totalPage;
}
return $page;
} | [
"public",
"function",
"getCurrentPage",
"(",
"$",
"total",
"=",
"null",
")",
"{",
"$",
"page",
"=",
"abs",
"(",
"app",
"(",
")",
"->",
"request",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
")",
";",
"if",
"(",
"$",
"total",
")",
"{",
"$",
"this",
"->",
"total",
"=",
"$",
"total",
";",
"}",
"$",
"page",
">=",
"1",
"||",
"$",
"page",
"=",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"items",
")",
"{",
"$",
"totalPage",
"=",
"$",
"this",
"->",
"getTotalPage",
"(",
")",
";",
"$",
"page",
"<=",
"$",
"totalPage",
"||",
"$",
"page",
"=",
"$",
"totalPage",
";",
"}",
"return",
"$",
"page",
";",
"}"
] | Return current page
@return integer | [
"Return",
"current",
"page"
] | 1d08752d98841b2e3536a98c5b07efdb5691bd91 | https://github.com/donghaichen/framework/blob/1d08752d98841b2e3536a98c5b07efdb5691bd91/src/Illuminate/Clover/Paginator.php#L73-L89 |
2,850 | donghaichen/framework | src/Illuminate/Clover/Paginator.php | Paginator.getTotalPage | public function getTotalPage()
{
$this->pageSize > 0 || $this->pageSize = 10;
$totalPage = ceil($this->total / $this->pageSize);
$totalPage >= 1 || $totalPage = 1;
return $totalPage;
} | php | public function getTotalPage()
{
$this->pageSize > 0 || $this->pageSize = 10;
$totalPage = ceil($this->total / $this->pageSize);
$totalPage >= 1 || $totalPage = 1;
return $totalPage;
} | [
"public",
"function",
"getTotalPage",
"(",
")",
"{",
"$",
"this",
"->",
"pageSize",
">",
"0",
"||",
"$",
"this",
"->",
"pageSize",
"=",
"10",
";",
"$",
"totalPage",
"=",
"ceil",
"(",
"$",
"this",
"->",
"total",
"/",
"$",
"this",
"->",
"pageSize",
")",
";",
"$",
"totalPage",
">=",
"1",
"||",
"$",
"totalPage",
"=",
"1",
";",
"return",
"$",
"totalPage",
";",
"}"
] | Return total pages
@return integer | [
"Return",
"total",
"pages"
] | 1d08752d98841b2e3536a98c5b07efdb5691bd91 | https://github.com/donghaichen/framework/blob/1d08752d98841b2e3536a98c5b07efdb5691bd91/src/Illuminate/Clover/Paginator.php#L96-L105 |
2,851 | gregoriohc/argentum-common | src/Common/Bag.php | Bag.replace | public function replace(array $elements = array())
{
$this->elements = array();
foreach ($elements as $element) {
$this->add($element);
}
} | php | public function replace(array $elements = array())
{
$this->elements = array();
foreach ($elements as $element) {
$this->add($element);
}
} | [
"public",
"function",
"replace",
"(",
"array",
"$",
"elements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"}"
] | Replace the contents of this bag with the specified elements
@param array $elements An array of elements | [
"Replace",
"the",
"contents",
"of",
"this",
"bag",
"with",
"the",
"specified",
"elements"
] | 9d914d19aa6ed25d33f00d603eff486484f0f3ba | https://github.com/gregoriohc/argentum-common/blob/9d914d19aa6ed25d33f00d603eff486484f0f3ba/src/Common/Bag.php#L43-L50 |
2,852 | agencms/core | src/Config.php | Config.appendRoute | public function appendRoute(Route $route)
{
if (!$originalRoute = optional($this->routes)[$route->slug()]) {
return "Route {$route->slug()} not found";
}
return $this->routes[$route->slug()]['groups'] =
$originalRoute['groups']->merge($route->get()['groups']);
} | php | public function appendRoute(Route $route)
{
if (!$originalRoute = optional($this->routes)[$route->slug()]) {
return "Route {$route->slug()} not found";
}
return $this->routes[$route->slug()]['groups'] =
$originalRoute['groups']->merge($route->get()['groups']);
} | [
"public",
"function",
"appendRoute",
"(",
"Route",
"$",
"route",
")",
"{",
"if",
"(",
"!",
"$",
"originalRoute",
"=",
"optional",
"(",
"$",
"this",
"->",
"routes",
")",
"[",
"$",
"route",
"->",
"slug",
"(",
")",
"]",
")",
"{",
"return",
"\"Route {$route->slug()} not found\"",
";",
"}",
"return",
"$",
"this",
"->",
"routes",
"[",
"$",
"route",
"->",
"slug",
"(",
")",
"]",
"[",
"'groups'",
"]",
"=",
"$",
"originalRoute",
"[",
"'groups'",
"]",
"->",
"merge",
"(",
"$",
"route",
"->",
"get",
"(",
")",
"[",
"'groups'",
"]",
")",
";",
"}"
] | Append additional groups to an existing Route
@param Agencms\Core\Route $route
@return Illuminate\Support\Collection | [
"Append",
"additional",
"groups",
"to",
"an",
"existing",
"Route"
] | 67a20e1889fb4f8548a38b66ff0abf72194bb49e | https://github.com/agencms/core/blob/67a20e1889fb4f8548a38b66ff0abf72194bb49e/src/Config.php#L68-L76 |
2,853 | budkit/budkit-framework | src/Budkit/Validation/Validate.php | Validate.isTimestamp | public static function isTimestamp($tstamp)
{
return ((string)(int)$tstamp === $tstamp)
&& ($tstamp <= PHP_INT_MAX)
&& ($tstamp >= ~PHP_INT_MAX);
} | php | public static function isTimestamp($tstamp)
{
return ((string)(int)$tstamp === $tstamp)
&& ($tstamp <= PHP_INT_MAX)
&& ($tstamp >= ~PHP_INT_MAX);
} | [
"public",
"static",
"function",
"isTimestamp",
"(",
"$",
"tstamp",
")",
"{",
"return",
"(",
"(",
"string",
")",
"(",
"int",
")",
"$",
"tstamp",
"===",
"$",
"tstamp",
")",
"&&",
"(",
"$",
"tstamp",
"<=",
"PHP_INT_MAX",
")",
"&&",
"(",
"$",
"tstamp",
">=",
"~",
"PHP_INT_MAX",
")",
";",
"}"
] | Checks that a string is a timestamp
@param string $tstamp
@return boolean True if is timestamp, false if not; | [
"Checks",
"that",
"a",
"string",
"is",
"a",
"timestamp"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Validation/Validate.php#L116-L121 |
2,854 | budkit/budkit-framework | src/Budkit/Validation/Validate.php | Validate.isIP | public static function isIP($address)
{
//Split the IP address of the form into parts
$parts = explode('.', $address);
//=4 parts
if (sizeof($parts) != 4) {
return false;
}
foreach ($parts as $part):
if (empty($part) || !static::number($part) || $part > 255) {
return false;
}
endforeach;
return true;
} | php | public static function isIP($address)
{
//Split the IP address of the form into parts
$parts = explode('.', $address);
//=4 parts
if (sizeof($parts) != 4) {
return false;
}
foreach ($parts as $part):
if (empty($part) || !static::number($part) || $part > 255) {
return false;
}
endforeach;
return true;
} | [
"public",
"static",
"function",
"isIP",
"(",
"$",
"address",
")",
"{",
"//Split the IP address of the form into parts",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"address",
")",
";",
"//=4 parts",
"if",
"(",
"sizeof",
"(",
"$",
"parts",
")",
"!=",
"4",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
":",
"if",
"(",
"empty",
"(",
"$",
"part",
")",
"||",
"!",
"static",
"::",
"number",
"(",
"$",
"part",
")",
"||",
"$",
"part",
">",
"255",
")",
"{",
"return",
"false",
";",
"}",
"endforeach",
";",
"return",
"true",
";",
"}"
] | Validates an ip address format
@param string $address
@return boolean True if it is a valid IP address, False if Not. | [
"Validates",
"an",
"ip",
"address",
"format"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Validation/Validate.php#L154-L170 |
2,855 | meliorframework/melior | Classes/Settings/Settings.php | Settings.retrieveAllFiles | protected function retrieveAllFiles(array $paths)
{
$files = [];
foreach ($paths as $path) {
$newFiles = [];
try {
$newFiles = $this->retrieveFiles($path);
} catch (FileSystemException $e) {
continue;
} finally {
$files = array_merge($files, $newFiles);
}
}
return $files;
} | php | protected function retrieveAllFiles(array $paths)
{
$files = [];
foreach ($paths as $path) {
$newFiles = [];
try {
$newFiles = $this->retrieveFiles($path);
} catch (FileSystemException $e) {
continue;
} finally {
$files = array_merge($files, $newFiles);
}
}
return $files;
} | [
"protected",
"function",
"retrieveAllFiles",
"(",
"array",
"$",
"paths",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"newFiles",
"=",
"[",
"]",
";",
"try",
"{",
"$",
"newFiles",
"=",
"$",
"this",
"->",
"retrieveFiles",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"FileSystemException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"finally",
"{",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"newFiles",
")",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | Retrieve all yaml files from an array of directories.
@param array $paths An array of directories to scan
@return array
@throws FileSystemException | [
"Retrieve",
"all",
"yaml",
"files",
"from",
"an",
"array",
"of",
"directories",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Settings/Settings.php#L103-L120 |
2,856 | meliorframework/melior | Classes/Settings/Settings.php | Settings.retrieveFiles | protected function retrieveFiles(string $directory): array
{
$files = [];
foreach (scandir($directory) as $file) {
$elem = $this->pathHelper->join($directory, $file);
if (
$elem != '.' &&
$elem != '..' &&
\is_file($elem) &&
\is_readable($elem) &&
$this->stringHelper->endsWith($elem, '.yaml')
) {
$files[] = $elem;
}
}
if (count($files) == 0) {
throw new FileSystemException('Path does not contain any readable yaml files!', 1527452904);
}
return $files;
} | php | protected function retrieveFiles(string $directory): array
{
$files = [];
foreach (scandir($directory) as $file) {
$elem = $this->pathHelper->join($directory, $file);
if (
$elem != '.' &&
$elem != '..' &&
\is_file($elem) &&
\is_readable($elem) &&
$this->stringHelper->endsWith($elem, '.yaml')
) {
$files[] = $elem;
}
}
if (count($files) == 0) {
throw new FileSystemException('Path does not contain any readable yaml files!', 1527452904);
}
return $files;
} | [
"protected",
"function",
"retrieveFiles",
"(",
"string",
"$",
"directory",
")",
":",
"array",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"directory",
")",
"as",
"$",
"file",
")",
"{",
"$",
"elem",
"=",
"$",
"this",
"->",
"pathHelper",
"->",
"join",
"(",
"$",
"directory",
",",
"$",
"file",
")",
";",
"if",
"(",
"$",
"elem",
"!=",
"'.'",
"&&",
"$",
"elem",
"!=",
"'..'",
"&&",
"\\",
"is_file",
"(",
"$",
"elem",
")",
"&&",
"\\",
"is_readable",
"(",
"$",
"elem",
")",
"&&",
"$",
"this",
"->",
"stringHelper",
"->",
"endsWith",
"(",
"$",
"elem",
",",
"'.yaml'",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"elem",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"files",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"FileSystemException",
"(",
"'Path does not contain any readable yaml files!'",
",",
"1527452904",
")",
";",
"}",
"return",
"$",
"files",
";",
"}"
] | Retrieve all yaml files from a directory.
@param string $directory The directory to scan
@return array
@throws FileSystemException | [
"Retrieve",
"all",
"yaml",
"files",
"from",
"a",
"directory",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Settings/Settings.php#L131-L154 |
2,857 | meliorframework/melior | Classes/Settings/Settings.php | Settings.has | public function has(string $key): bool
{
if (strpos($key, '.') != false) {
return $this->getNested($key) != null;
}
return array_key_exists($key, $this->settings);
} | php | public function has(string $key): bool
{
if (strpos($key, '.') != false) {
return $this->getNested($key) != null;
}
return array_key_exists($key, $this->settings);
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"!=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getNested",
"(",
"$",
"key",
")",
"!=",
"null",
";",
"}",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"settings",
")",
";",
"}"
] | Checks if a key is present in the settings.
@param string $key The key to check for
@return bool | [
"Checks",
"if",
"a",
"key",
"is",
"present",
"in",
"the",
"settings",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Settings/Settings.php#L163-L170 |
2,858 | meliorframework/melior | Classes/Settings/Settings.php | Settings.get | public function get(string $key = null)
{
if (empty($key)) {
return $this->settings;
}
if (\strpos($key, '.') != false) {
return $this->getNested($key);
}
if ($this->has($key)) {
return $this->settings[$key];
}
return null;
} | php | public function get(string $key = null)
{
if (empty($key)) {
return $this->settings;
}
if (\strpos($key, '.') != false) {
return $this->getNested($key);
}
if ($this->has($key)) {
return $this->settings[$key];
}
return null;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"settings",
";",
"}",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"!=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getNested",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"settings",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieves data from the settings.
@param string|null $key The key to retrieve or null if you want all keys
@return mixed | [
"Retrieves",
"data",
"from",
"the",
"settings",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Settings/Settings.php#L179-L194 |
2,859 | meliorframework/melior | Classes/Settings/Settings.php | Settings.getNested | protected function getNested(string $key)
{
$parts = explode('.', $key);
$result = $this->settings[$parts[0]];
for ($i = 1; $i < count($parts); ++$i) {
$value = $parts[$i];
if (is_array($result) && array_key_exists($value, $result)) {
$result = $result[$value];
continue;
}
$result = null;
break;
}
return $result;
} | php | protected function getNested(string $key)
{
$parts = explode('.', $key);
$result = $this->settings[$parts[0]];
for ($i = 1; $i < count($parts); ++$i) {
$value = $parts[$i];
if (is_array($result) && array_key_exists($value, $result)) {
$result = $result[$value];
continue;
}
$result = null;
break;
}
return $result;
} | [
"protected",
"function",
"getNested",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"settings",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"parts",
")",
";",
"++",
"$",
"i",
")",
"{",
"$",
"value",
"=",
"$",
"parts",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"result",
")",
"&&",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"[",
"$",
"value",
"]",
";",
"continue",
";",
"}",
"$",
"result",
"=",
"null",
";",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Retrieves nested data from the settings.
@param string $key The key to recieve
@return mixed | [
"Retrieves",
"nested",
"data",
"from",
"the",
"settings",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Settings/Settings.php#L203-L221 |
2,860 | phospr/locale | src/Locale.php | Locale.isSameValueAs | public function isSameValueAs(Locale $other)
{
return
$this->languageCode == $other->languageCode &&
$this->countryCode == $other->countryCode
;
} | php | public function isSameValueAs(Locale $other)
{
return
$this->languageCode == $other->languageCode &&
$this->countryCode == $other->countryCode
;
} | [
"public",
"function",
"isSameValueAs",
"(",
"Locale",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"languageCode",
"==",
"$",
"other",
"->",
"languageCode",
"&&",
"$",
"this",
"->",
"countryCode",
"==",
"$",
"other",
"->",
"countryCode",
";",
"}"
] | Compares two Locales
@author Tom Haskins-Vaughan <[email protected]>
@since 1.0.0
@param Locale $other
@return bool | [
"Compares",
"two",
"Locales"
] | 4516f7f807cd81bf351b465d3508a6add3d98913 | https://github.com/phospr/locale/blob/4516f7f807cd81bf351b465d3508a6add3d98913/src/Locale.php#L109-L115 |
2,861 | phospr/locale | src/Locale.php | Locale.format | public function format($format)
{
if (!is_string($format)) {
throw new InvalidArgumentException(sprintf(
'format passed must be a string'
));
}
$translateNext = false;
$escNext = false;
$formatted = '';
foreach (str_split($format) as $char) {
if ($escNext) {
$formatted .= $char;
$escNext = false;
continue;
}
if ($translateNext) {
switch ($char) {
case 'c':
$translated = strtolower($this->getCountryCode());
break;
case 'C':
$translated = strtoupper($this->getCountryCode());
break;
case 'l':
$translated = strtolower($this->getLanguageCode());
break;
case 'L':
$translated = strtoupper($this->getLanguageCode());
break;
default:
throw new InvalidArgumentException(sprintf(
'Unkown format'
));
}
$formatted .= $translated;
$translateNext = false;
continue;
}
if ('\\' == $char) {
$escNext = true;
continue;
} elseif ('%' == $char) {
$translateNext = true;
continue;
}
$formatted .= $char;
}
return $formatted;
} | php | public function format($format)
{
if (!is_string($format)) {
throw new InvalidArgumentException(sprintf(
'format passed must be a string'
));
}
$translateNext = false;
$escNext = false;
$formatted = '';
foreach (str_split($format) as $char) {
if ($escNext) {
$formatted .= $char;
$escNext = false;
continue;
}
if ($translateNext) {
switch ($char) {
case 'c':
$translated = strtolower($this->getCountryCode());
break;
case 'C':
$translated = strtoupper($this->getCountryCode());
break;
case 'l':
$translated = strtolower($this->getLanguageCode());
break;
case 'L':
$translated = strtoupper($this->getLanguageCode());
break;
default:
throw new InvalidArgumentException(sprintf(
'Unkown format'
));
}
$formatted .= $translated;
$translateNext = false;
continue;
}
if ('\\' == $char) {
$escNext = true;
continue;
} elseif ('%' == $char) {
$translateNext = true;
continue;
}
$formatted .= $char;
}
return $formatted;
} | [
"public",
"function",
"format",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"format",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'format passed must be a string'",
")",
")",
";",
"}",
"$",
"translateNext",
"=",
"false",
";",
"$",
"escNext",
"=",
"false",
";",
"$",
"formatted",
"=",
"''",
";",
"foreach",
"(",
"str_split",
"(",
"$",
"format",
")",
"as",
"$",
"char",
")",
"{",
"if",
"(",
"$",
"escNext",
")",
"{",
"$",
"formatted",
".=",
"$",
"char",
";",
"$",
"escNext",
"=",
"false",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"translateNext",
")",
"{",
"switch",
"(",
"$",
"char",
")",
"{",
"case",
"'c'",
":",
"$",
"translated",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getCountryCode",
"(",
")",
")",
";",
"break",
";",
"case",
"'C'",
":",
"$",
"translated",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"getCountryCode",
"(",
")",
")",
";",
"break",
";",
"case",
"'l'",
":",
"$",
"translated",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getLanguageCode",
"(",
")",
")",
";",
"break",
";",
"case",
"'L'",
":",
"$",
"translated",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"getLanguageCode",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unkown format'",
")",
")",
";",
"}",
"$",
"formatted",
".=",
"$",
"translated",
";",
"$",
"translateNext",
"=",
"false",
";",
"continue",
";",
"}",
"if",
"(",
"'\\\\'",
"==",
"$",
"char",
")",
"{",
"$",
"escNext",
"=",
"true",
";",
"continue",
";",
"}",
"elseif",
"(",
"'%'",
"==",
"$",
"char",
")",
"{",
"$",
"translateNext",
"=",
"true",
";",
"continue",
";",
"}",
"$",
"formatted",
".=",
"$",
"char",
";",
"}",
"return",
"$",
"formatted",
";",
"}"
] | Format Locale as string
echo Locale::fromString('se_FI')->format('%L_%c'); // SE_fi
echo Locale::fromString('se_FI')->format('%C/%s'); // FI/se
echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se
echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se
Current formatting codes are:
* %L For uppercase language code
* %l For lowercase language code
* %C For uppercase country code
* %c For lowercase country code
* any other combination of %{:char:} will throw an
Invalid argument exception unless the % is escaped with \
* To get a \ You will need to double escape ( \\\ )
@author Christopher Tatro <[email protected]>
@since 1.0.0
@param string $format
@return string | [
"Format",
"Locale",
"as",
"string"
] | 4516f7f807cd81bf351b465d3508a6add3d98913 | https://github.com/phospr/locale/blob/4516f7f807cd81bf351b465d3508a6add3d98913/src/Locale.php#L176-L231 |
2,862 | zepi/turbo-base | Zepi/Web/AccessControl/src/EventHandler/Administration/EditUser.php | EditUser.processFormData | protected function processFormData(WebRequest $request, Response $response, User $user)
{
$result = $this->layout->validateFormData($request, $response, function ($formValues) use ($user) {
return $this->validateData(
$user,
$formValues['required-data.username'],
$formValues['required-data.password'],
$formValues['required-data.password-confirmed']
);
});
if ($result == Form::DATA_VALID) {
$result = $this->saveUser($request, $user);
}
return $result;
} | php | protected function processFormData(WebRequest $request, Response $response, User $user)
{
$result = $this->layout->validateFormData($request, $response, function ($formValues) use ($user) {
return $this->validateData(
$user,
$formValues['required-data.username'],
$formValues['required-data.password'],
$formValues['required-data.password-confirmed']
);
});
if ($result == Form::DATA_VALID) {
$result = $this->saveUser($request, $user);
}
return $result;
} | [
"protected",
"function",
"processFormData",
"(",
"WebRequest",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"User",
"$",
"user",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"layout",
"->",
"validateFormData",
"(",
"$",
"request",
",",
"$",
"response",
",",
"function",
"(",
"$",
"formValues",
")",
"use",
"(",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"validateData",
"(",
"$",
"user",
",",
"$",
"formValues",
"[",
"'required-data.username'",
"]",
",",
"$",
"formValues",
"[",
"'required-data.password'",
"]",
",",
"$",
"formValues",
"[",
"'required-data.password-confirmed'",
"]",
")",
";",
"}",
")",
";",
"if",
"(",
"$",
"result",
"==",
"Form",
"::",
"DATA_VALID",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"saveUser",
"(",
"$",
"request",
",",
"$",
"user",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Validates the form data, updates the user and saves the
user into the database.
@param \Zepi\Turbo\Request\WebRequest $request
@param \Zepi\Turbo\Response\Response $response
@param \Zepi\Web\AccessControl\Entity\User $user
@return boolean|string | [
"Validates",
"the",
"form",
"data",
"updates",
"the",
"user",
"and",
"saves",
"the",
"user",
"into",
"the",
"database",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/Administration/EditUser.php#L162-L178 |
2,863 | zepi/turbo-base | Zepi/Web/AccessControl/src/EventHandler/Administration/EditUser.php | EditUser.isUsernameInUse | protected function isUsernameInUse($username, User $user)
{
return ($this->userManager->hasUserForUsername($username) && $this->userManager->getUserForUsername($username)->getUuid() != $user->getUuid());
} | php | protected function isUsernameInUse($username, User $user)
{
return ($this->userManager->hasUserForUsername($username) && $this->userManager->getUserForUsername($username)->getUuid() != $user->getUuid());
} | [
"protected",
"function",
"isUsernameInUse",
"(",
"$",
"username",
",",
"User",
"$",
"user",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"userManager",
"->",
"hasUserForUsername",
"(",
"$",
"username",
")",
"&&",
"$",
"this",
"->",
"userManager",
"->",
"getUserForUsername",
"(",
"$",
"username",
")",
"->",
"getUuid",
"(",
")",
"!=",
"$",
"user",
"->",
"getUuid",
"(",
")",
")",
";",
"}"
] | Returns true if the username is in use and not is the edited user.
@param string $username
@param \Zepi\Web\AccessControl\Entity\User $user
@return boolean | [
"Returns",
"true",
"if",
"the",
"username",
"is",
"in",
"use",
"and",
"not",
"is",
"the",
"edited",
"user",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/Administration/EditUser.php#L268-L271 |
2,864 | monkeyscode/msc-view | View.php | View.render | public function render($view, $data = [])
{
$this->writeFile($view);
$blade = new Blade($this->getViewPath(), $this->getCachePath());
if (is_array($data)) {
return $blade->view()->make($view, $data)->render();
} else {
throw new Exception('data pass into view must be an array.');
}
} | php | public function render($view, $data = [])
{
$this->writeFile($view);
$blade = new Blade($this->getViewPath(), $this->getCachePath());
if (is_array($data)) {
return $blade->view()->make($view, $data)->render();
} else {
throw new Exception('data pass into view must be an array.');
}
} | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"writeFile",
"(",
"$",
"view",
")",
";",
"$",
"blade",
"=",
"new",
"Blade",
"(",
"$",
"this",
"->",
"getViewPath",
"(",
")",
",",
"$",
"this",
"->",
"getCachePath",
"(",
")",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"blade",
"->",
"view",
"(",
")",
"->",
"make",
"(",
"$",
"view",
",",
"$",
"data",
")",
"->",
"render",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'data pass into view must be an array.'",
")",
";",
"}",
"}"
] | return blade template
@param string $view view name
@param array $data data pass to view
@return string | [
"return",
"blade",
"template"
] | f38f6d6bfa2b8dbabbe39cc926278723b0790328 | https://github.com/monkeyscode/msc-view/blob/f38f6d6bfa2b8dbabbe39cc926278723b0790328/View.php#L63-L73 |
2,865 | monkeyscode/msc-view | View.php | View.writeFile | public function writeFile($path)
{
$fullPath = $this->viewDir . DIRECTORY_SEPARATOR . $this->transformDotToSlash($path) . '.blade.php';
if (!FacadeStorage::has($fullPath)) {
FacadeStorage::createDir(dirname($fullPath));
return FacadeStorage::write($fullPath, '');
}
return false;
} | php | public function writeFile($path)
{
$fullPath = $this->viewDir . DIRECTORY_SEPARATOR . $this->transformDotToSlash($path) . '.blade.php';
if (!FacadeStorage::has($fullPath)) {
FacadeStorage::createDir(dirname($fullPath));
return FacadeStorage::write($fullPath, '');
}
return false;
} | [
"public",
"function",
"writeFile",
"(",
"$",
"path",
")",
"{",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"viewDir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"transformDotToSlash",
"(",
"$",
"path",
")",
".",
"'.blade.php'",
";",
"if",
"(",
"!",
"FacadeStorage",
"::",
"has",
"(",
"$",
"fullPath",
")",
")",
"{",
"FacadeStorage",
"::",
"createDir",
"(",
"dirname",
"(",
"$",
"fullPath",
")",
")",
";",
"return",
"FacadeStorage",
"::",
"write",
"(",
"$",
"fullPath",
",",
"''",
")",
";",
"}",
"return",
"false",
";",
"}"
] | create blade file
@param string $path path to blade file
@since 1.1.0
@return boolean | [
"create",
"blade",
"file"
] | f38f6d6bfa2b8dbabbe39cc926278723b0790328 | https://github.com/monkeyscode/msc-view/blob/f38f6d6bfa2b8dbabbe39cc926278723b0790328/View.php#L82-L92 |
2,866 | monkeyscode/msc-view | View.php | View.createCacheDir | public function createCacheDir()
{
if (!FacadeStorage::has($this->cacheDir)) {
return FacadeStorage::createDir($this->cacheDir);
}
return false;
} | php | public function createCacheDir()
{
if (!FacadeStorage::has($this->cacheDir)) {
return FacadeStorage::createDir($this->cacheDir);
}
return false;
} | [
"public",
"function",
"createCacheDir",
"(",
")",
"{",
"if",
"(",
"!",
"FacadeStorage",
"::",
"has",
"(",
"$",
"this",
"->",
"cacheDir",
")",
")",
"{",
"return",
"FacadeStorage",
"::",
"createDir",
"(",
"$",
"this",
"->",
"cacheDir",
")",
";",
"}",
"return",
"false",
";",
"}"
] | create cache folder
@since 1.1.1 | [
"create",
"cache",
"folder"
] | f38f6d6bfa2b8dbabbe39cc926278723b0790328 | https://github.com/monkeyscode/msc-view/blob/f38f6d6bfa2b8dbabbe39cc926278723b0790328/View.php#L99-L106 |
2,867 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/StrategyService.php | StrategyService.create | public function create(Strategy $strategy)
{
$this->getEm()->persist($strategy);
$this->getEm()->flush();
return $strategy;
} | php | public function create(Strategy $strategy)
{
$this->getEm()->persist($strategy);
$this->getEm()->flush();
return $strategy;
} | [
"public",
"function",
"create",
"(",
"Strategy",
"$",
"strategy",
")",
"{",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"persist",
"(",
"$",
"strategy",
")",
";",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"strategy",
";",
"}"
] | Create a new Strategy.
@param Strategy $strategy the strategy instance.
@return Strategy the strategy instance. | [
"Create",
"a",
"new",
"Strategy",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/StrategyService.php#L56-L62 |
2,868 | donbidon/core | src/Registry/Common.php | Common.getInstance | public static function getInstance(array $scope = [], $options = self::ACTION_ALL)
{
if (!is_object(self::$instance)) {
self::$instance = new static($scope, $options);
}
return self::$instance;
} | php | public static function getInstance(array $scope = [], $options = self::ACTION_ALL)
{
if (!is_object(self::$instance)) {
self::$instance = new static($scope, $options);
}
return self::$instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"array",
"$",
"scope",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"self",
"::",
"ACTION_ALL",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"static",
"(",
"$",
"scope",
",",
"$",
"options",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] | Returns static registry instance.
@param array $scope
@param int $options
@return static | [
"Returns",
"static",
"registry",
"instance",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Registry/Common.php#L157-L164 |
2,869 | donbidon/core | src/Registry/Common.php | Common.override | public function override(array $scope)
{
$this->checkPermissions(null, self::ACTION_OVERRIDE);
$this->scope = $scope;
} | php | public function override(array $scope)
{
$this->checkPermissions(null, self::ACTION_OVERRIDE);
$this->scope = $scope;
} | [
"public",
"function",
"override",
"(",
"array",
"$",
"scope",
")",
"{",
"$",
"this",
"->",
"checkPermissions",
"(",
"null",
",",
"self",
"::",
"ACTION_OVERRIDE",
")",
";",
"$",
"this",
"->",
"scope",
"=",
"$",
"scope",
";",
"}"
] | Overrides scope.
@param array $scope
@return void
@throws \ReflectionException Risen from self::checkPermissions(). | [
"Overrides",
"scope",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Registry/Common.php#L380-L384 |
2,870 | donbidon/core | src/Registry/Common.php | Common.checkPermissions | protected function checkPermissions($key, $action)
{
if (!($action & $this->options)) {
$originalKey = is_null($this->key) ? $key : $this->key;
$this->key = null;
$text = Friendlification::getConstNameByValue(
__CLASS__, $action
);
throw new RuntimeException(
is_null($key)
? sprintf("%s: no permissions", $text)
: sprintf(
"%s: no permissions for key '%s'", $text,
$originalKey
),
$action
);
}
} | php | protected function checkPermissions($key, $action)
{
if (!($action & $this->options)) {
$originalKey = is_null($this->key) ? $key : $this->key;
$this->key = null;
$text = Friendlification::getConstNameByValue(
__CLASS__, $action
);
throw new RuntimeException(
is_null($key)
? sprintf("%s: no permissions", $text)
: sprintf(
"%s: no permissions for key '%s'", $text,
$originalKey
),
$action
);
}
} | [
"protected",
"function",
"checkPermissions",
"(",
"$",
"key",
",",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"action",
"&",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"originalKey",
"=",
"is_null",
"(",
"$",
"this",
"->",
"key",
")",
"?",
"$",
"key",
":",
"$",
"this",
"->",
"key",
";",
"$",
"this",
"->",
"key",
"=",
"null",
";",
"$",
"text",
"=",
"Friendlification",
"::",
"getConstNameByValue",
"(",
"__CLASS__",
",",
"$",
"action",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"is_null",
"(",
"$",
"key",
")",
"?",
"sprintf",
"(",
"\"%s: no permissions\"",
",",
"$",
"text",
")",
":",
"sprintf",
"(",
"\"%s: no permissions for key '%s'\"",
",",
"$",
"text",
",",
"$",
"originalKey",
")",
",",
"$",
"action",
")",
";",
"}",
"}"
] | Check action permissions.
@param string $key
@param int $action
@return void
@throws \ReflectionException Risen from Friendlification::getConstNameByValue().
@throws RuntimeException If doesn't have permissions for passed action. | [
"Check",
"action",
"permissions",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Registry/Common.php#L411-L429 |
2,871 | donbidon/core | src/Registry/Common.php | Common.getByRef | protected function getByRef($key, &$value)
{
if (!$this->checkRefs ||!is_string($value)) {
return;
}
$this->checkRefs = false;
$references = [$key];
$key = $value;
while ($this->isRef($key)) {
if (in_array($key, $references)) {
$this->checkRefs = true;
$this->key = null;
$references[] = $key;
throw new RuntimeException(sprintf(
"Cyclic reference detected: %s",
implode(" ~~> ", $references)
));
}
$references[] = $key;
$previous = $key;
$key = $this->get($key, null, false);
};
$this->checkRefs = true;
if (isset($previous)) {
if ($this->exists($previous)) {
$value = $key;
} else {
$this->key = null;
$references[sizeof($references) - 1] .= " (missing key)";
throw new RuntimeException(sprintf(
"Invalid reference detected: %s",
implode(" ~~> ", $references)
));
}
}
} | php | protected function getByRef($key, &$value)
{
if (!$this->checkRefs ||!is_string($value)) {
return;
}
$this->checkRefs = false;
$references = [$key];
$key = $value;
while ($this->isRef($key)) {
if (in_array($key, $references)) {
$this->checkRefs = true;
$this->key = null;
$references[] = $key;
throw new RuntimeException(sprintf(
"Cyclic reference detected: %s",
implode(" ~~> ", $references)
));
}
$references[] = $key;
$previous = $key;
$key = $this->get($key, null, false);
};
$this->checkRefs = true;
if (isset($previous)) {
if ($this->exists($previous)) {
$value = $key;
} else {
$this->key = null;
$references[sizeof($references) - 1] .= " (missing key)";
throw new RuntimeException(sprintf(
"Invalid reference detected: %s",
implode(" ~~> ", $references)
));
}
}
} | [
"protected",
"function",
"getByRef",
"(",
"$",
"key",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkRefs",
"||",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"checkRefs",
"=",
"false",
";",
"$",
"references",
"=",
"[",
"$",
"key",
"]",
";",
"$",
"key",
"=",
"$",
"value",
";",
"while",
"(",
"$",
"this",
"->",
"isRef",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"references",
")",
")",
"{",
"$",
"this",
"->",
"checkRefs",
"=",
"true",
";",
"$",
"this",
"->",
"key",
"=",
"null",
";",
"$",
"references",
"[",
"]",
"=",
"$",
"key",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"\"Cyclic reference detected: %s\"",
",",
"implode",
"(",
"\" ~~> \"",
",",
"$",
"references",
")",
")",
")",
";",
"}",
"$",
"references",
"[",
"]",
"=",
"$",
"key",
";",
"$",
"previous",
"=",
"$",
"key",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
",",
"null",
",",
"false",
")",
";",
"}",
";",
"$",
"this",
"->",
"checkRefs",
"=",
"true",
";",
"if",
"(",
"isset",
"(",
"$",
"previous",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"previous",
")",
")",
"{",
"$",
"value",
"=",
"$",
"key",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"key",
"=",
"null",
";",
"$",
"references",
"[",
"sizeof",
"(",
"$",
"references",
")",
"-",
"1",
"]",
".=",
"\" (missing key)\"",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"\"Invalid reference detected: %s\"",
",",
"implode",
"(",
"\" ~~> \"",
",",
"$",
"references",
")",
")",
")",
";",
"}",
"}",
"}"
] | Gets value by reference if possible.
@param string $key
@param mixed $value
@return void
@throws \ReflectionException Risen from self::get().
@throws RuntimeException If cyclic or invalid reference detected. | [
"Gets",
"value",
"by",
"reference",
"if",
"possible",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Registry/Common.php#L440-L476 |
2,872 | donbidon/core | src/Registry/Common.php | Common.isRef | protected function isRef(&$value, $modify = true)
{
$matches = null;
$result =
is_string($value) &&
preg_match($this->refPattern, $value, $matches);
if ($result && $modify) {
$value = $matches[1];
}
return $result;
} | php | protected function isRef(&$value, $modify = true)
{
$matches = null;
$result =
is_string($value) &&
preg_match($this->refPattern, $value, $matches);
if ($result && $modify) {
$value = $matches[1];
}
return $result;
} | [
"protected",
"function",
"isRef",
"(",
"&",
"$",
"value",
",",
"$",
"modify",
"=",
"true",
")",
"{",
"$",
"matches",
"=",
"null",
";",
"$",
"result",
"=",
"is_string",
"(",
"$",
"value",
")",
"&&",
"preg_match",
"(",
"$",
"this",
"->",
"refPattern",
",",
"$",
"value",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"result",
"&&",
"$",
"modify",
")",
"{",
"$",
"value",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Validates if passed value is reference.
@param mixed &$value
@param bool $modify Flag specifying to modify $value
(to cut "~~> " prefix)
@return bool | [
"Validates",
"if",
"passed",
"value",
"is",
"reference",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Registry/Common.php#L487-L498 |
2,873 | infinity-se/infinity-bootstrap | src/InfinityBootstrap/View/Helper/Navigation/Bar.php | Bar.render | public function render($container = null)
{
// Get container
if (null !== $container) {
$this->setContainer($container);
}
// Load brand
$container = $this->getContainer();
$brand = $container->findOneBy('class', 'brand');
if ($brand) {
$container->removePage($brand);
}
// Render navigation bar
$viewModel = new ViewModel();
$viewModel->brand = $brand;
$viewModel->container = $container;
$viewModel->setTemplate('helper/navigation/bar');
return $this->getView()->render($viewModel);
} | php | public function render($container = null)
{
// Get container
if (null !== $container) {
$this->setContainer($container);
}
// Load brand
$container = $this->getContainer();
$brand = $container->findOneBy('class', 'brand');
if ($brand) {
$container->removePage($brand);
}
// Render navigation bar
$viewModel = new ViewModel();
$viewModel->brand = $brand;
$viewModel->container = $container;
$viewModel->setTemplate('helper/navigation/bar');
return $this->getView()->render($viewModel);
} | [
"public",
"function",
"render",
"(",
"$",
"container",
"=",
"null",
")",
"{",
"// Get container",
"if",
"(",
"null",
"!==",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"setContainer",
"(",
"$",
"container",
")",
";",
"}",
"// Load brand",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
";",
"$",
"brand",
"=",
"$",
"container",
"->",
"findOneBy",
"(",
"'class'",
",",
"'brand'",
")",
";",
"if",
"(",
"$",
"brand",
")",
"{",
"$",
"container",
"->",
"removePage",
"(",
"$",
"brand",
")",
";",
"}",
"// Render navigation bar",
"$",
"viewModel",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"viewModel",
"->",
"brand",
"=",
"$",
"brand",
";",
"$",
"viewModel",
"->",
"container",
"=",
"$",
"container",
";",
"$",
"viewModel",
"->",
"setTemplate",
"(",
"'helper/navigation/bar'",
")",
";",
"return",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"render",
"(",
"$",
"viewModel",
")",
";",
"}"
] | Renders navigation bar
return string | [
"Renders",
"navigation",
"bar"
] | 9dfeb779497bbdfb0376fe2fae610d7f81b1eb7a | https://github.com/infinity-se/infinity-bootstrap/blob/9dfeb779497bbdfb0376fe2fae610d7f81b1eb7a/src/InfinityBootstrap/View/Helper/Navigation/Bar.php#L37-L58 |
2,874 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.anchor | public static function anchor($href, $text = null, $attr = array(), $secure = null)
{
if ( ! preg_match('#^(\w+://|javascript:|\#)# i', $href))
{
$urlparts = explode('?', $href, 2);
$href = \Uri::create($urlparts[0], array(), isset($urlparts[1])?$urlparts[1]:array(), $secure);
}
elseif ( ! preg_match('#^(javascript:|\#)# i', $href) and is_bool($secure))
{
$href = http_build_url($href, array('scheme' => $secure ? 'https' : 'http'));
// Trim the trailing slash
$href = rtrim($href, '/');
}
// Create and display a URL hyperlink
is_null($text) and $text = $href;
$attr['href'] = $href;
return html_tag('a', $attr, $text);
} | php | public static function anchor($href, $text = null, $attr = array(), $secure = null)
{
if ( ! preg_match('#^(\w+://|javascript:|\#)# i', $href))
{
$urlparts = explode('?', $href, 2);
$href = \Uri::create($urlparts[0], array(), isset($urlparts[1])?$urlparts[1]:array(), $secure);
}
elseif ( ! preg_match('#^(javascript:|\#)# i', $href) and is_bool($secure))
{
$href = http_build_url($href, array('scheme' => $secure ? 'https' : 'http'));
// Trim the trailing slash
$href = rtrim($href, '/');
}
// Create and display a URL hyperlink
is_null($text) and $text = $href;
$attr['href'] = $href;
return html_tag('a', $attr, $text);
} | [
"public",
"static",
"function",
"anchor",
"(",
"$",
"href",
",",
"$",
"text",
"=",
"null",
",",
"$",
"attr",
"=",
"array",
"(",
")",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'#^(\\w+://|javascript:|\\#)# i'",
",",
"$",
"href",
")",
")",
"{",
"$",
"urlparts",
"=",
"explode",
"(",
"'?'",
",",
"$",
"href",
",",
"2",
")",
";",
"$",
"href",
"=",
"\\",
"Uri",
"::",
"create",
"(",
"$",
"urlparts",
"[",
"0",
"]",
",",
"array",
"(",
")",
",",
"isset",
"(",
"$",
"urlparts",
"[",
"1",
"]",
")",
"?",
"$",
"urlparts",
"[",
"1",
"]",
":",
"array",
"(",
")",
",",
"$",
"secure",
")",
";",
"}",
"elseif",
"(",
"!",
"preg_match",
"(",
"'#^(javascript:|\\#)# i'",
",",
"$",
"href",
")",
"and",
"is_bool",
"(",
"$",
"secure",
")",
")",
"{",
"$",
"href",
"=",
"http_build_url",
"(",
"$",
"href",
",",
"array",
"(",
"'scheme'",
"=>",
"$",
"secure",
"?",
"'https'",
":",
"'http'",
")",
")",
";",
"// Trim the trailing slash",
"$",
"href",
"=",
"rtrim",
"(",
"$",
"href",
",",
"'/'",
")",
";",
"}",
"// Create and display a URL hyperlink",
"is_null",
"(",
"$",
"text",
")",
"and",
"$",
"text",
"=",
"$",
"href",
";",
"$",
"attr",
"[",
"'href'",
"]",
"=",
"$",
"href",
";",
"return",
"html_tag",
"(",
"'a'",
",",
"$",
"attr",
",",
"$",
"text",
")",
";",
"}"
] | Creates an html link
@param string the url
@param string the text value
@param array the attributes array
@param bool true to force https, false to force http
@return string the html link | [
"Creates",
"an",
"html",
"link"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L42-L63 |
2,875 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.img | public static function img($src, $attr = array())
{
if ( ! preg_match('#^(\w+://)# i', $src))
{
$src = \Uri::base(false).$src;
}
$attr['src'] = $src;
$attr['alt'] = (isset($attr['alt'])) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME);
return html_tag('img', $attr);
} | php | public static function img($src, $attr = array())
{
if ( ! preg_match('#^(\w+://)# i', $src))
{
$src = \Uri::base(false).$src;
}
$attr['src'] = $src;
$attr['alt'] = (isset($attr['alt'])) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME);
return html_tag('img', $attr);
} | [
"public",
"static",
"function",
"img",
"(",
"$",
"src",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'#^(\\w+://)# i'",
",",
"$",
"src",
")",
")",
"{",
"$",
"src",
"=",
"\\",
"Uri",
"::",
"base",
"(",
"false",
")",
".",
"$",
"src",
";",
"}",
"$",
"attr",
"[",
"'src'",
"]",
"=",
"$",
"src",
";",
"$",
"attr",
"[",
"'alt'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'alt'",
"]",
")",
")",
"?",
"$",
"attr",
"[",
"'alt'",
"]",
":",
"pathinfo",
"(",
"$",
"src",
",",
"PATHINFO_FILENAME",
")",
";",
"return",
"html_tag",
"(",
"'img'",
",",
"$",
"attr",
")",
";",
"}"
] | Creates an html image tag
Sets the alt atribute to filename of it is not supplied.
@param string the source
@param array the attributes array
@return string the image tag | [
"Creates",
"an",
"html",
"image",
"tag"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L74-L83 |
2,876 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.mail_to_safe | public static function mail_to_safe($email, $text = null, $subject = null, $attr = array())
{
$text or $text = str_replace('@', '[at]', $email);
$email = explode("@", $email);
$subject and $subject = '?subject='.$subject;
$attr = array_to_attr($attr);
$attr = ($attr == '' ? '' : ' ').$attr;
$output = '<script type="text/javascript">';
$output .= '(function() {';
$output .= 'var user = "'.$email[0].'";';
$output .= 'var at = "@";';
$output .= 'var server = "'.$email[1].'";';
$output .= "document.write('<a href=\"' + 'mail' + 'to:' + user + at + server + '$subject\"$attr>$text</a>');";
$output .= '})();';
$output .= '</script>';
return $output;
} | php | public static function mail_to_safe($email, $text = null, $subject = null, $attr = array())
{
$text or $text = str_replace('@', '[at]', $email);
$email = explode("@", $email);
$subject and $subject = '?subject='.$subject;
$attr = array_to_attr($attr);
$attr = ($attr == '' ? '' : ' ').$attr;
$output = '<script type="text/javascript">';
$output .= '(function() {';
$output .= 'var user = "'.$email[0].'";';
$output .= 'var at = "@";';
$output .= 'var server = "'.$email[1].'";';
$output .= "document.write('<a href=\"' + 'mail' + 'to:' + user + at + server + '$subject\"$attr>$text</a>');";
$output .= '})();';
$output .= '</script>';
return $output;
} | [
"public",
"static",
"function",
"mail_to_safe",
"(",
"$",
"email",
",",
"$",
"text",
"=",
"null",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"text",
"or",
"$",
"text",
"=",
"str_replace",
"(",
"'@'",
",",
"'[at]'",
",",
"$",
"email",
")",
";",
"$",
"email",
"=",
"explode",
"(",
"\"@\"",
",",
"$",
"email",
")",
";",
"$",
"subject",
"and",
"$",
"subject",
"=",
"'?subject='",
".",
"$",
"subject",
";",
"$",
"attr",
"=",
"array_to_attr",
"(",
"$",
"attr",
")",
";",
"$",
"attr",
"=",
"(",
"$",
"attr",
"==",
"''",
"?",
"''",
":",
"' '",
")",
".",
"$",
"attr",
";",
"$",
"output",
"=",
"'<script type=\"text/javascript\">'",
";",
"$",
"output",
".=",
"'(function() {'",
";",
"$",
"output",
".=",
"'var user = \"'",
".",
"$",
"email",
"[",
"0",
"]",
".",
"'\";'",
";",
"$",
"output",
".=",
"'var at = \"@\";'",
";",
"$",
"output",
".=",
"'var server = \"'",
".",
"$",
"email",
"[",
"1",
"]",
".",
"'\";'",
";",
"$",
"output",
".=",
"\"document.write('<a href=\\\"' + 'mail' + 'to:' + user + at + server + '$subject\\\"$attr>$text</a>');\"",
";",
"$",
"output",
".=",
"'})();'",
";",
"$",
"output",
".=",
"'</script>'",
";",
"return",
"$",
"output",
";",
"}"
] | Creates a mailto link with Javascript to prevent bots from picking up the
email address.
@param string the email address
@param string the text value
@param string the subject
@param array attributes for the tag
@return string the javascript code containg email | [
"Creates",
"a",
"mailto",
"link",
"with",
"Javascript",
"to",
"prevent",
"bots",
"from",
"picking",
"up",
"the",
"email",
"address",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L131-L151 |
2,877 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.meta | public static function meta($name = '', $content = '', $type = 'name')
{
if( ! is_array($name))
{
$result = html_tag('meta', array($type => $name, 'content' => $content));
}
elseif(is_array($name))
{
$result = "";
foreach($name as $array)
{
$meta = $array;
$result .= "\n" . html_tag('meta', $meta);
}
}
return $result;
} | php | public static function meta($name = '', $content = '', $type = 'name')
{
if( ! is_array($name))
{
$result = html_tag('meta', array($type => $name, 'content' => $content));
}
elseif(is_array($name))
{
$result = "";
foreach($name as $array)
{
$meta = $array;
$result .= "\n" . html_tag('meta', $meta);
}
}
return $result;
} | [
"public",
"static",
"function",
"meta",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"content",
"=",
"''",
",",
"$",
"type",
"=",
"'name'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"result",
"=",
"html_tag",
"(",
"'meta'",
",",
"array",
"(",
"$",
"type",
"=>",
"$",
"name",
",",
"'content'",
"=>",
"$",
"content",
")",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"name",
"as",
"$",
"array",
")",
"{",
"$",
"meta",
"=",
"$",
"array",
";",
"$",
"result",
".=",
"\"\\n\"",
".",
"html_tag",
"(",
"'meta'",
",",
"$",
"meta",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Generates a html meta tag
@param string|array multiple inputs or name/http-equiv value
@param string content value
@param string name or http-equiv
@return string | [
"Generates",
"a",
"html",
"meta",
"tag"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L161-L177 |
2,878 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.doctype | public static function doctype($type = 'xhtml1-trans')
{
if(static::$doctypes === null)
{
\Config::load('doctypes', true);
static::$doctypes = \Config::get('doctypes', array());
}
if(is_array(static::$doctypes) and isset(static::$doctypes[$type]))
{
if($type == "html5")
{
static::$html5 = true;
}
return static::$doctypes[$type];
}
else
{
return false;
}
} | php | public static function doctype($type = 'xhtml1-trans')
{
if(static::$doctypes === null)
{
\Config::load('doctypes', true);
static::$doctypes = \Config::get('doctypes', array());
}
if(is_array(static::$doctypes) and isset(static::$doctypes[$type]))
{
if($type == "html5")
{
static::$html5 = true;
}
return static::$doctypes[$type];
}
else
{
return false;
}
} | [
"public",
"static",
"function",
"doctype",
"(",
"$",
"type",
"=",
"'xhtml1-trans'",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"doctypes",
"===",
"null",
")",
"{",
"\\",
"Config",
"::",
"load",
"(",
"'doctypes'",
",",
"true",
")",
";",
"static",
"::",
"$",
"doctypes",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'doctypes'",
",",
"array",
"(",
")",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"static",
"::",
"$",
"doctypes",
")",
"and",
"isset",
"(",
"static",
"::",
"$",
"doctypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"\"html5\"",
")",
"{",
"static",
"::",
"$",
"html5",
"=",
"true",
";",
"}",
"return",
"static",
"::",
"$",
"doctypes",
"[",
"$",
"type",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Generates a html doctype tag
@param string doctype declaration key from doctypes config
@return string | [
"Generates",
"a",
"html",
"doctype",
"tag"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L185-L205 |
2,879 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.audio | public static function audio($src = '', $attr = false)
{
if(static::$html5)
{
if(is_array($src))
{
$source = '';
foreach($src as $item)
{
$source .= html_tag('source', array('src' => $item));
}
}
else
{
$source = html_tag('source', array('src' => $src));
}
return html_tag('audio', $attr, $source);
}
} | php | public static function audio($src = '', $attr = false)
{
if(static::$html5)
{
if(is_array($src))
{
$source = '';
foreach($src as $item)
{
$source .= html_tag('source', array('src' => $item));
}
}
else
{
$source = html_tag('source', array('src' => $src));
}
return html_tag('audio', $attr, $source);
}
} | [
"public",
"static",
"function",
"audio",
"(",
"$",
"src",
"=",
"''",
",",
"$",
"attr",
"=",
"false",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"html5",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"src",
")",
")",
"{",
"$",
"source",
"=",
"''",
";",
"foreach",
"(",
"$",
"src",
"as",
"$",
"item",
")",
"{",
"$",
"source",
".=",
"html_tag",
"(",
"'source'",
",",
"array",
"(",
"'src'",
"=>",
"$",
"item",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"source",
"=",
"html_tag",
"(",
"'source'",
",",
"array",
"(",
"'src'",
"=>",
"$",
"src",
")",
")",
";",
"}",
"return",
"html_tag",
"(",
"'audio'",
",",
"$",
"attr",
",",
"$",
"source",
")",
";",
"}",
"}"
] | Generates a html5 audio tag
It is required that you set html5 as the doctype to use this method
@param string|array one or multiple audio sources
@param array tag attributes
@return string | [
"Generates",
"a",
"html5",
"audio",
"tag",
"It",
"is",
"required",
"that",
"you",
"set",
"html5",
"as",
"the",
"doctype",
"to",
"use",
"this",
"method"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L215-L233 |
2,880 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/html.php | Html.build_list | protected static function build_list($type = 'ul', array $list = array(), $attr = false, $indent = '')
{
if ( ! is_array($list))
{
$result = false;
}
$out = '';
foreach ($list as $key => $val)
{
if ( ! is_array($val))
{
$out .= $indent."\t".html_tag('li', false, $val).PHP_EOL;
}
else
{
$out .= $indent."\t".html_tag('li', false, $key.PHP_EOL.static::build_list($type, $val, '', $indent."\t\t").$indent."\t").PHP_EOL;
}
}
$result = $indent.html_tag($type, $attr, PHP_EOL.$out.$indent).PHP_EOL;
return $result;
} | php | protected static function build_list($type = 'ul', array $list = array(), $attr = false, $indent = '')
{
if ( ! is_array($list))
{
$result = false;
}
$out = '';
foreach ($list as $key => $val)
{
if ( ! is_array($val))
{
$out .= $indent."\t".html_tag('li', false, $val).PHP_EOL;
}
else
{
$out .= $indent."\t".html_tag('li', false, $key.PHP_EOL.static::build_list($type, $val, '', $indent."\t\t").$indent."\t").PHP_EOL;
}
}
$result = $indent.html_tag($type, $attr, PHP_EOL.$out.$indent).PHP_EOL;
return $result;
} | [
"protected",
"static",
"function",
"build_list",
"(",
"$",
"type",
"=",
"'ul'",
",",
"array",
"$",
"list",
"=",
"array",
"(",
")",
",",
"$",
"attr",
"=",
"false",
",",
"$",
"indent",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"list",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"$",
"out",
"=",
"''",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"out",
".=",
"$",
"indent",
".",
"\"\\t\"",
".",
"html_tag",
"(",
"'li'",
",",
"false",
",",
"$",
"val",
")",
".",
"PHP_EOL",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"$",
"indent",
".",
"\"\\t\"",
".",
"html_tag",
"(",
"'li'",
",",
"false",
",",
"$",
"key",
".",
"PHP_EOL",
".",
"static",
"::",
"build_list",
"(",
"$",
"type",
",",
"$",
"val",
",",
"''",
",",
"$",
"indent",
".",
"\"\\t\\t\"",
")",
".",
"$",
"indent",
".",
"\"\\t\"",
")",
".",
"PHP_EOL",
";",
"}",
"}",
"$",
"result",
"=",
"$",
"indent",
".",
"html_tag",
"(",
"$",
"type",
",",
"$",
"attr",
",",
"PHP_EOL",
".",
"$",
"out",
".",
"$",
"indent",
")",
".",
"PHP_EOL",
";",
"return",
"$",
"result",
";",
"}"
] | Generates the html for the list methods
@param string list type (ol or ul)
@param array list items, may be nested
@param array tag attributes
@param string indentation
@return string | [
"Generates",
"the",
"html",
"for",
"the",
"list",
"methods"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/html.php#L268-L289 |
2,881 | AlcyZ/Alcys-ORM | src/Core/Db/Expression/Builder/JoinBuilder.php | JoinBuilder.build | public function build()
{
$this->_checkJoinArray();
$this->way = ($this->joinArray['way']) ?
strtoupper(str_replace(':', ' ', $this->joinArray['way'])) . ' ' : null;
$this->_prepareJoinTable($this->joinArray['tables']);
$this->conditionType = strtoupper($this->joinArray['conditionType']) . ' ';
if($this->joinArray['conditionType'] !== 'natural')
{
$this->_prepareJoinCondition($this->joinArray['condition']);
$expression = $this->way . 'JOIN' . $this->tables . $this->conditionType . $this->condition;
}
else
{
$expression = $this->conditionType . $this->way . 'JOIN' . rtrim($this->tables);
}
return $expression . ' ';
} | php | public function build()
{
$this->_checkJoinArray();
$this->way = ($this->joinArray['way']) ?
strtoupper(str_replace(':', ' ', $this->joinArray['way'])) . ' ' : null;
$this->_prepareJoinTable($this->joinArray['tables']);
$this->conditionType = strtoupper($this->joinArray['conditionType']) . ' ';
if($this->joinArray['conditionType'] !== 'natural')
{
$this->_prepareJoinCondition($this->joinArray['condition']);
$expression = $this->way . 'JOIN' . $this->tables . $this->conditionType . $this->condition;
}
else
{
$expression = $this->conditionType . $this->way . 'JOIN' . rtrim($this->tables);
}
return $expression . ' ';
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"_checkJoinArray",
"(",
")",
";",
"$",
"this",
"->",
"way",
"=",
"(",
"$",
"this",
"->",
"joinArray",
"[",
"'way'",
"]",
")",
"?",
"strtoupper",
"(",
"str_replace",
"(",
"':'",
",",
"' '",
",",
"$",
"this",
"->",
"joinArray",
"[",
"'way'",
"]",
")",
")",
".",
"' '",
":",
"null",
";",
"$",
"this",
"->",
"_prepareJoinTable",
"(",
"$",
"this",
"->",
"joinArray",
"[",
"'tables'",
"]",
")",
";",
"$",
"this",
"->",
"conditionType",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"joinArray",
"[",
"'conditionType'",
"]",
")",
".",
"' '",
";",
"if",
"(",
"$",
"this",
"->",
"joinArray",
"[",
"'conditionType'",
"]",
"!==",
"'natural'",
")",
"{",
"$",
"this",
"->",
"_prepareJoinCondition",
"(",
"$",
"this",
"->",
"joinArray",
"[",
"'condition'",
"]",
")",
";",
"$",
"expression",
"=",
"$",
"this",
"->",
"way",
".",
"'JOIN'",
".",
"$",
"this",
"->",
"tables",
".",
"$",
"this",
"->",
"conditionType",
".",
"$",
"this",
"->",
"condition",
";",
"}",
"else",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"conditionType",
".",
"$",
"this",
"->",
"way",
".",
"'JOIN'",
".",
"rtrim",
"(",
"$",
"this",
"->",
"tables",
")",
";",
"}",
"return",
"$",
"expression",
".",
"' '",
";",
"}"
] | Build the join expression string.
Processing the passed join expression and return it in form of a string.
@see JoinBuilder::_checkJoinArray
@see JoinBuilder::_prepareJoinTable
@see JoinBuilder::_prepareJoinCondition
@return string The join expression as a string.
@throws \Exception When the join expression has an invalid format. | [
"Build",
"the",
"join",
"expression",
"string",
".",
"Processing",
"the",
"passed",
"join",
"expression",
"and",
"return",
"it",
"in",
"form",
"of",
"a",
"string",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Builder/JoinBuilder.php#L85-L104 |
2,882 | AlcyZ/Alcys-ORM | src/Core/Db/Expression/Builder/JoinBuilder.php | JoinBuilder._checkJoinArray | private function _checkJoinArray()
{
$defaultJoinArray = array('way' => null, 'tables' => null, 'conditionType' => null, 'condition' => null);
if($this->joinArray === $defaultJoinArray)
{
throw new \Exception('one of the methods: inner(), natural(), left[Outer](), right[Outer] must called before!');
}
} | php | private function _checkJoinArray()
{
$defaultJoinArray = array('way' => null, 'tables' => null, 'conditionType' => null, 'condition' => null);
if($this->joinArray === $defaultJoinArray)
{
throw new \Exception('one of the methods: inner(), natural(), left[Outer](), right[Outer] must called before!');
}
} | [
"private",
"function",
"_checkJoinArray",
"(",
")",
"{",
"$",
"defaultJoinArray",
"=",
"array",
"(",
"'way'",
"=>",
"null",
",",
"'tables'",
"=>",
"null",
",",
"'conditionType'",
"=>",
"null",
",",
"'condition'",
"=>",
"null",
")",
";",
"if",
"(",
"$",
"this",
"->",
"joinArray",
"===",
"$",
"defaultJoinArray",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'one of the methods: inner(), natural(), left[Outer](), right[Outer] must called before!'",
")",
";",
"}",
"}"
] | Compare the join array with the expressions default join array and throw an exception if they are the same.
@throws \Exception | [
"Compare",
"the",
"join",
"array",
"with",
"the",
"expressions",
"default",
"join",
"array",
"and",
"throw",
"an",
"exception",
"if",
"they",
"are",
"the",
"same",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Builder/JoinBuilder.php#L135-L142 |
2,883 | AlcyZ/Alcys-ORM | src/Core/Db/Expression/Builder/JoinBuilder.php | JoinBuilder._prepareJoinTable | private function _prepareJoinTable(array $tables)
{
$this->tables = ' ';
foreach($tables as $tableObj)
{
$this->tables .= $tableObj->getExpression() . ', ';
}
$this->tables = rtrim(rtrim($this->tables), ',') . ' ';
} | php | private function _prepareJoinTable(array $tables)
{
$this->tables = ' ';
foreach($tables as $tableObj)
{
$this->tables .= $tableObj->getExpression() . ', ';
}
$this->tables = rtrim(rtrim($this->tables), ',') . ' ';
} | [
"private",
"function",
"_prepareJoinTable",
"(",
"array",
"$",
"tables",
")",
"{",
"$",
"this",
"->",
"tables",
"=",
"' '",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableObj",
")",
"{",
"$",
"this",
"->",
"tables",
".=",
"$",
"tableObj",
"->",
"getExpression",
"(",
")",
".",
"', '",
";",
"}",
"$",
"this",
"->",
"tables",
"=",
"rtrim",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"tables",
")",
",",
"','",
")",
".",
"' '",
";",
"}"
] | Validate the tables array to a string.
@param TableInterface[] $tables | [
"Validate",
"the",
"tables",
"array",
"to",
"a",
"string",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Builder/JoinBuilder.php#L150-L158 |
2,884 | AlcyZ/Alcys-ORM | src/Core/Db/Expression/Builder/JoinBuilder.php | JoinBuilder._prepareJoinCondition | private function _prepareJoinCondition(array $condition)
{
if(count($condition) === 1)
{
return $this->condition = '(' . $condition[0]->getColumnName() . ')';
}
return $this->condition =
$condition[0]->getTableName() . '.' . $condition[0]->getColumnName() . ' = ' . $condition[1]->getTableName()
. '.' . $condition[1]->getColumnName();
} | php | private function _prepareJoinCondition(array $condition)
{
if(count($condition) === 1)
{
return $this->condition = '(' . $condition[0]->getColumnName() . ')';
}
return $this->condition =
$condition[0]->getTableName() . '.' . $condition[0]->getColumnName() . ' = ' . $condition[1]->getTableName()
. '.' . $condition[1]->getColumnName();
} | [
"private",
"function",
"_prepareJoinCondition",
"(",
"array",
"$",
"condition",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"condition",
")",
"===",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"condition",
"=",
"'('",
".",
"$",
"condition",
"[",
"0",
"]",
"->",
"getColumnName",
"(",
")",
".",
"')'",
";",
"}",
"return",
"$",
"this",
"->",
"condition",
"=",
"$",
"condition",
"[",
"0",
"]",
"->",
"getTableName",
"(",
")",
".",
"'.'",
".",
"$",
"condition",
"[",
"0",
"]",
"->",
"getColumnName",
"(",
")",
".",
"' = '",
".",
"$",
"condition",
"[",
"1",
"]",
"->",
"getTableName",
"(",
")",
".",
"'.'",
".",
"$",
"condition",
"[",
"1",
"]",
"->",
"getColumnName",
"(",
")",
";",
"}"
] | Validate the columns array to a string.
@param ColumnInterface[] $condition
@return string | [
"Validate",
"the",
"columns",
"array",
"to",
"a",
"string",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Builder/JoinBuilder.php#L168-L178 |
2,885 | PlatoCreative/plato-external-login | src/security/ExternalLoginMember.php | ExternalLoginMember.requireDefaultRecords | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');
if(!$ssLoginUserName){
return;
}
// Check for default admin user by matching email
$member = Member::get()->find(
Member::config()->get('unique_identifier_field'),
$ssLoginUserName
);
// If no member is found at this stage.
// Find member ID 1
if(!$member){
$member = DataObject::get_by_id(Member::class, 1);
}
$firstName = 'Default Admin';
// // If there isn't one then make it
if(!$member){
$member = ExternalLoginMember::create();
$member->FirstName = $firstName;
$member->Email = $ssLoginUserName;
$member->write();
DB::alteration_message("Created admin '$member->Email'", 'created');
} else {
if ($member->ClassName != $this->ClassName || $member->Email != $ssLoginUserName) {
$member->ClassName = $this->ClassName;
$member->FirstName = $firstName;
$member->Surname = null;
$member->Email = $ssLoginUserName;
$member->TempIDHash = null;
$member->TempIDExpired = null;
$member->Password = null;
$member->write();
DB::alteration_message("Modified admin '$member->Email'", 'modified');
}
}
// Find or create ADMIN group
Group::singleton()->requireDefaultRecords();
$adminGroup = Permission::get_groups_by_permission('ADMIN')->First();
// Ensure this user is in the admin group
if(!$member->inGroup($adminGroup)) {
// Add member to group instead of adding group to member
// This bypasses the privilege escallation code in Member_GroupSet
$adminGroup->DirectMembers()->add($member);
}
} | php | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');
if(!$ssLoginUserName){
return;
}
// Check for default admin user by matching email
$member = Member::get()->find(
Member::config()->get('unique_identifier_field'),
$ssLoginUserName
);
// If no member is found at this stage.
// Find member ID 1
if(!$member){
$member = DataObject::get_by_id(Member::class, 1);
}
$firstName = 'Default Admin';
// // If there isn't one then make it
if(!$member){
$member = ExternalLoginMember::create();
$member->FirstName = $firstName;
$member->Email = $ssLoginUserName;
$member->write();
DB::alteration_message("Created admin '$member->Email'", 'created');
} else {
if ($member->ClassName != $this->ClassName || $member->Email != $ssLoginUserName) {
$member->ClassName = $this->ClassName;
$member->FirstName = $firstName;
$member->Surname = null;
$member->Email = $ssLoginUserName;
$member->TempIDHash = null;
$member->TempIDExpired = null;
$member->Password = null;
$member->write();
DB::alteration_message("Modified admin '$member->Email'", 'modified');
}
}
// Find or create ADMIN group
Group::singleton()->requireDefaultRecords();
$adminGroup = Permission::get_groups_by_permission('ADMIN')->First();
// Ensure this user is in the admin group
if(!$member->inGroup($adminGroup)) {
// Add member to group instead of adding group to member
// This bypasses the privilege escallation code in Member_GroupSet
$adminGroup->DirectMembers()->add($member);
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"$",
"ssLoginUserName",
"=",
"Environment",
"::",
"getEnv",
"(",
"'SS_DEFAULT_ADMIN_USERNAME'",
")",
";",
"if",
"(",
"!",
"$",
"ssLoginUserName",
")",
"{",
"return",
";",
"}",
"// Check for default admin user by matching email",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"find",
"(",
"Member",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'unique_identifier_field'",
")",
",",
"$",
"ssLoginUserName",
")",
";",
"// If no member is found at this stage.",
"// Find member ID 1",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"Member",
"::",
"class",
",",
"1",
")",
";",
"}",
"$",
"firstName",
"=",
"'Default Admin'",
";",
"// // If there isn't one then make it",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"ExternalLoginMember",
"::",
"create",
"(",
")",
";",
"$",
"member",
"->",
"FirstName",
"=",
"$",
"firstName",
";",
"$",
"member",
"->",
"Email",
"=",
"$",
"ssLoginUserName",
";",
"$",
"member",
"->",
"write",
"(",
")",
";",
"DB",
"::",
"alteration_message",
"(",
"\"Created admin '$member->Email'\"",
",",
"'created'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"member",
"->",
"ClassName",
"!=",
"$",
"this",
"->",
"ClassName",
"||",
"$",
"member",
"->",
"Email",
"!=",
"$",
"ssLoginUserName",
")",
"{",
"$",
"member",
"->",
"ClassName",
"=",
"$",
"this",
"->",
"ClassName",
";",
"$",
"member",
"->",
"FirstName",
"=",
"$",
"firstName",
";",
"$",
"member",
"->",
"Surname",
"=",
"null",
";",
"$",
"member",
"->",
"Email",
"=",
"$",
"ssLoginUserName",
";",
"$",
"member",
"->",
"TempIDHash",
"=",
"null",
";",
"$",
"member",
"->",
"TempIDExpired",
"=",
"null",
";",
"$",
"member",
"->",
"Password",
"=",
"null",
";",
"$",
"member",
"->",
"write",
"(",
")",
";",
"DB",
"::",
"alteration_message",
"(",
"\"Modified admin '$member->Email'\"",
",",
"'modified'",
")",
";",
"}",
"}",
"// Find or create ADMIN group",
"Group",
"::",
"singleton",
"(",
")",
"->",
"requireDefaultRecords",
"(",
")",
";",
"$",
"adminGroup",
"=",
"Permission",
"::",
"get_groups_by_permission",
"(",
"'ADMIN'",
")",
"->",
"First",
"(",
")",
";",
"// Ensure this user is in the admin group",
"if",
"(",
"!",
"$",
"member",
"->",
"inGroup",
"(",
"$",
"adminGroup",
")",
")",
"{",
"// Add member to group instead of adding group to member",
"// This bypasses the privilege escallation code in Member_GroupSet",
"$",
"adminGroup",
"->",
"DirectMembers",
"(",
")",
"->",
"add",
"(",
"$",
"member",
")",
";",
"}",
"}"
] | Set up default default admin record | [
"Set",
"up",
"default",
"default",
"admin",
"record"
] | 365277a84551e630b03ba24a49f26d536fdf3601 | https://github.com/PlatoCreative/plato-external-login/blob/365277a84551e630b03ba24a49f26d536fdf3601/src/security/ExternalLoginMember.php#L66-L120 |
2,886 | bd808/moar-log | src/Moar/Log/LoggerFactory.php | LoggerFactory.getILoggerFactory | public static function getILoggerFactory () {
static $nop;
if (null === self::$factory) {
if (null == $nop) {
$nop = new NOPLoggerFactory();
}
return $nop;
}
return self::$factory;
} | php | public static function getILoggerFactory () {
static $nop;
if (null === self::$factory) {
if (null == $nop) {
$nop = new NOPLoggerFactory();
}
return $nop;
}
return self::$factory;
} | [
"public",
"static",
"function",
"getILoggerFactory",
"(",
")",
"{",
"static",
"$",
"nop",
";",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"factory",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"nop",
")",
"{",
"$",
"nop",
"=",
"new",
"NOPLoggerFactory",
"(",
")",
";",
"}",
"return",
"$",
"nop",
";",
"}",
"return",
"self",
"::",
"$",
"factory",
";",
"}"
] | Get the currently configured ILoggerFactory.
@return ILoggerFactory Logger factory | [
"Get",
"the",
"currently",
"configured",
"ILoggerFactory",
"."
] | 01f44c46fef9a612cef6209c3bd69c97f3475064 | https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/LoggerFactory.php#L48-L57 |
2,887 | bytic/view | src/View.php | View.assign | public function assign($array = [])
{
foreach ($array as $key => $value) {
if (is_string($key)) {
$this->set($key, $value);
}
}
return $this;
} | php | public function assign($array = [])
{
foreach ($array as $key => $value) {
if (is_string($key)) {
$this->set($key, $value);
}
}
return $this;
} | [
"public",
"function",
"assign",
"(",
"$",
"array",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Assigns variables in bulk in the current scope
@param array $array
@return $this | [
"Assigns",
"variables",
"in",
"bulk",
"in",
"the",
"current",
"scope"
] | afdc509edc626b9aed0ffa4514199fb16759453c | https://github.com/bytic/view/blob/afdc509edc626b9aed0ffa4514199fb16759453c/src/View.php#L128-L137 |
2,888 | ciims/cii | components/CiiAnalytics.php | CiiAnalytics.init | public function init()
{
parent::init();
if (get_class(Yii::app()) != "CConsoleApplication")
{
$asset = Yii::app()->assetManager->publish(__DIR__.DS.'..'.DS.'assets'.DS.'dist', true, -1, YII_DEBUG);
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($asset.(YII_DEBUG ? '/ciianalytics.js' : '/ciianalytics.min.js'));
$cs->registerScript('ciianalytics', 'ciianalytics.init();');
}
} | php | public function init()
{
parent::init();
if (get_class(Yii::app()) != "CConsoleApplication")
{
$asset = Yii::app()->assetManager->publish(__DIR__.DS.'..'.DS.'assets'.DS.'dist', true, -1, YII_DEBUG);
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($asset.(YII_DEBUG ? '/ciianalytics.js' : '/ciianalytics.min.js'));
$cs->registerScript('ciianalytics', 'ciianalytics.init();');
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"get_class",
"(",
"Yii",
"::",
"app",
"(",
")",
")",
"!=",
"\"CConsoleApplication\"",
")",
"{",
"$",
"asset",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
"->",
"publish",
"(",
"__DIR__",
".",
"DS",
".",
"'..'",
".",
"DS",
".",
"'assets'",
".",
"DS",
".",
"'dist'",
",",
"true",
",",
"-",
"1",
",",
"YII_DEBUG",
")",
";",
"$",
"cs",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
";",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"$",
"asset",
".",
"(",
"YII_DEBUG",
"?",
"'/ciianalytics.js'",
":",
"'/ciianalytics.min.js'",
")",
")",
";",
"$",
"cs",
"->",
"registerScript",
"(",
"'ciianalytics'",
",",
"'ciianalytics.init();'",
")",
";",
"}",
"}"
] | Init function overloaded to inject CiiAnalytics JS Tracking | [
"Init",
"function",
"overloaded",
"to",
"inject",
"CiiAnalytics",
"JS",
"Tracking"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/components/CiiAnalytics.php#L12-L24 |
2,889 | ciims/cii | components/CiiAnalytics.php | CiiAnalytics.getAnalyticsProviders | private function getAnalyticsProviders()
{
$providers = Yii::app()->cache->get('analyticsjs_providers');
if ($providers === false)
{
$analytics = new AnalyticsSettings;
$rules = $analytics->rules();
unset($analytics);
// Init the array
$providers = array();
// Retrieve all the providors that are enabled
$response = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_%_enabled" AND value = 1')->queryAll();
foreach ($response as $element)
{
$k = $element['key'];
$provider = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
$provider = reset($provider);
$sqlProvider = str_replace(" ", "__" ,str_replace(".", "___", $provider));
$data = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_' . $sqlProvider .'%" AND `key` != "analyticsjs_' . $sqlProvider .'_enabled"')->queryAll();
foreach ($data as $el)
{
$k = $el['key'];
$v = $el['value'];
$p = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
if ($v !== "")
{
$thisRule = 'string';
foreach ($rules as $rule)
{
if (strpos($rule[0], 'analyticsjs_' . $k) !== false)
$thisRule = $rule[1];
}
if ($thisRule == 'boolean')
{
if ($v == "0")
$providers[$provider][$p[1]] = (bool)false;
else if ($v == "1")
$providers[$provider][$p[1]] = (bool)true;
else
$providers[$provider][$p[1]] = 'null';
}
else
{
if ($v == "" || $v == null || $v == "null")
$providers[$provider][$p[1]] = null;
else
$providers[$provider][$p[1]] = $v;
}
}
}
}
Yii::app()->cache->set('analyticsjs_providers', $providers);
}
return $providers;
} | php | private function getAnalyticsProviders()
{
$providers = Yii::app()->cache->get('analyticsjs_providers');
if ($providers === false)
{
$analytics = new AnalyticsSettings;
$rules = $analytics->rules();
unset($analytics);
// Init the array
$providers = array();
// Retrieve all the providors that are enabled
$response = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_%_enabled" AND value = 1')->queryAll();
foreach ($response as $element)
{
$k = $element['key'];
$provider = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
$provider = reset($provider);
$sqlProvider = str_replace(" ", "__" ,str_replace(".", "___", $provider));
$data = Yii::app()->db->createCommand('SELECT REPLACE(`key`, "analyticsjs_", "") AS `key`, value FROM `configuration` WHERE `key` LIKE "analyticsjs_' . $sqlProvider .'%" AND `key` != "analyticsjs_' . $sqlProvider .'_enabled"')->queryAll();
foreach ($data as $el)
{
$k = $el['key'];
$v = $el['value'];
$p = explode('_', str_replace("__", " " ,str_replace("___", ".", $k)));
if ($v !== "")
{
$thisRule = 'string';
foreach ($rules as $rule)
{
if (strpos($rule[0], 'analyticsjs_' . $k) !== false)
$thisRule = $rule[1];
}
if ($thisRule == 'boolean')
{
if ($v == "0")
$providers[$provider][$p[1]] = (bool)false;
else if ($v == "1")
$providers[$provider][$p[1]] = (bool)true;
else
$providers[$provider][$p[1]] = 'null';
}
else
{
if ($v == "" || $v == null || $v == "null")
$providers[$provider][$p[1]] = null;
else
$providers[$provider][$p[1]] = $v;
}
}
}
}
Yii::app()->cache->set('analyticsjs_providers', $providers);
}
return $providers;
} | [
"private",
"function",
"getAnalyticsProviders",
"(",
")",
"{",
"$",
"providers",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"get",
"(",
"'analyticsjs_providers'",
")",
";",
"if",
"(",
"$",
"providers",
"===",
"false",
")",
"{",
"$",
"analytics",
"=",
"new",
"AnalyticsSettings",
";",
"$",
"rules",
"=",
"$",
"analytics",
"->",
"rules",
"(",
")",
";",
"unset",
"(",
"$",
"analytics",
")",
";",
"// Init the array",
"$",
"providers",
"=",
"array",
"(",
")",
";",
"// Retrieve all the providors that are enabled",
"$",
"response",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"db",
"->",
"createCommand",
"(",
"'SELECT REPLACE(`key`, \"analyticsjs_\", \"\") AS `key`, value FROM `configuration` WHERE `key` LIKE \"analyticsjs_%_enabled\" AND value = 1'",
")",
"->",
"queryAll",
"(",
")",
";",
"foreach",
"(",
"$",
"response",
"as",
"$",
"element",
")",
"{",
"$",
"k",
"=",
"$",
"element",
"[",
"'key'",
"]",
";",
"$",
"provider",
"=",
"explode",
"(",
"'_'",
",",
"str_replace",
"(",
"\"__\"",
",",
"\" \"",
",",
"str_replace",
"(",
"\"___\"",
",",
"\".\"",
",",
"$",
"k",
")",
")",
")",
";",
"$",
"provider",
"=",
"reset",
"(",
"$",
"provider",
")",
";",
"$",
"sqlProvider",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"__\"",
",",
"str_replace",
"(",
"\".\"",
",",
"\"___\"",
",",
"$",
"provider",
")",
")",
";",
"$",
"data",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"db",
"->",
"createCommand",
"(",
"'SELECT REPLACE(`key`, \"analyticsjs_\", \"\") AS `key`, value FROM `configuration` WHERE `key` LIKE \"analyticsjs_'",
".",
"$",
"sqlProvider",
".",
"'%\" AND `key` != \"analyticsjs_'",
".",
"$",
"sqlProvider",
".",
"'_enabled\"'",
")",
"->",
"queryAll",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"el",
")",
"{",
"$",
"k",
"=",
"$",
"el",
"[",
"'key'",
"]",
";",
"$",
"v",
"=",
"$",
"el",
"[",
"'value'",
"]",
";",
"$",
"p",
"=",
"explode",
"(",
"'_'",
",",
"str_replace",
"(",
"\"__\"",
",",
"\" \"",
",",
"str_replace",
"(",
"\"___\"",
",",
"\".\"",
",",
"$",
"k",
")",
")",
")",
";",
"if",
"(",
"$",
"v",
"!==",
"\"\"",
")",
"{",
"$",
"thisRule",
"=",
"'string'",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"rule",
"[",
"0",
"]",
",",
"'analyticsjs_'",
".",
"$",
"k",
")",
"!==",
"false",
")",
"$",
"thisRule",
"=",
"$",
"rule",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"$",
"thisRule",
"==",
"'boolean'",
")",
"{",
"if",
"(",
"$",
"v",
"==",
"\"0\"",
")",
"$",
"providers",
"[",
"$",
"provider",
"]",
"[",
"$",
"p",
"[",
"1",
"]",
"]",
"=",
"(",
"bool",
")",
"false",
";",
"else",
"if",
"(",
"$",
"v",
"==",
"\"1\"",
")",
"$",
"providers",
"[",
"$",
"provider",
"]",
"[",
"$",
"p",
"[",
"1",
"]",
"]",
"=",
"(",
"bool",
")",
"true",
";",
"else",
"$",
"providers",
"[",
"$",
"provider",
"]",
"[",
"$",
"p",
"[",
"1",
"]",
"]",
"=",
"'null'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"v",
"==",
"\"\"",
"||",
"$",
"v",
"==",
"null",
"||",
"$",
"v",
"==",
"\"null\"",
")",
"$",
"providers",
"[",
"$",
"provider",
"]",
"[",
"$",
"p",
"[",
"1",
"]",
"]",
"=",
"null",
";",
"else",
"$",
"providers",
"[",
"$",
"provider",
"]",
"[",
"$",
"p",
"[",
"1",
"]",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"}",
"}",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"set",
"(",
"'analyticsjs_providers'",
",",
"$",
"providers",
")",
";",
"}",
"return",
"$",
"providers",
";",
"}"
] | Retrieves Analytics.js Providers
@return array $providors | [
"Retrieves",
"Analytics",
".",
"js",
"Providers"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/components/CiiAnalytics.php#L39-L103 |
2,890 | gios-asu/nectary | src/models/implementations/json-feed.php | Json_Feed.retrieve_items | public function retrieve_items( $look_at = false ) {
$json = \call_user_func( $this->feed_callback, $this->url );
$raw = $this->parse_feed( $json );
$this->items = $raw;
if ( $look_at !== false ) {
$this->items = $raw[ $look_at ];
}
} | php | public function retrieve_items( $look_at = false ) {
$json = \call_user_func( $this->feed_callback, $this->url );
$raw = $this->parse_feed( $json );
$this->items = $raw;
if ( $look_at !== false ) {
$this->items = $raw[ $look_at ];
}
} | [
"public",
"function",
"retrieve_items",
"(",
"$",
"look_at",
"=",
"false",
")",
"{",
"$",
"json",
"=",
"\\",
"call_user_func",
"(",
"$",
"this",
"->",
"feed_callback",
",",
"$",
"this",
"->",
"url",
")",
";",
"$",
"raw",
"=",
"$",
"this",
"->",
"parse_feed",
"(",
"$",
"json",
")",
";",
"$",
"this",
"->",
"items",
"=",
"$",
"raw",
";",
"if",
"(",
"$",
"look_at",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"$",
"raw",
"[",
"$",
"look_at",
"]",
";",
"}",
"}"
] | Pull the items from the web and store them
in this object
@param int|bool $look_at use to grab items from a section of the json
@throws \Exception | [
"Pull",
"the",
"items",
"from",
"the",
"web",
"and",
"store",
"them",
"in",
"this",
"object"
] | f972c737a9036a3090652950a1309a62c07d86c0 | https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/models/implementations/json-feed.php#L30-L38 |
2,891 | uthando-cms/uthando-twitter | src/UthandoTwitter/Model/TweetCollection.php | TweetCollection.valid | public function valid()
{
$valid = $this->current();
// stop the loop I want to get off.
if ((($this->position + 1) > $this->displayLimit)) {
$valid = false;
}
return $valid;
} | php | public function valid()
{
$valid = $this->current();
// stop the loop I want to get off.
if ((($this->position + 1) > $this->displayLimit)) {
$valid = false;
}
return $valid;
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"$",
"valid",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"// stop the loop I want to get off.",
"if",
"(",
"(",
"(",
"$",
"this",
"->",
"position",
"+",
"1",
")",
">",
"$",
"this",
"->",
"displayLimit",
")",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"}",
"return",
"$",
"valid",
";",
"}"
] | Check to see if we want to terminate this loop. | [
"Check",
"to",
"see",
"if",
"we",
"want",
"to",
"terminate",
"this",
"loop",
"."
] | 003914b2df2255d52314ed8eb5c92f192dab0f12 | https://github.com/uthando-cms/uthando-twitter/blob/003914b2df2255d52314ed8eb5c92f192dab0f12/src/UthandoTwitter/Model/TweetCollection.php#L202-L212 |
2,892 | lucidphp/mux | src/RouteGroup.php | RouteGroup.setPrefix | private function setPrefix($prefix)
{
if (0 === strlen($prefix)) {
throw new \InvalidArgumentException('Group prefix may not be empty.');
}
$prefix = '/'.trim($prefix, '/');
$this->prefix = $this->hasParent() ? $this->parent->getPrefix() . $prefix : $prefix;
} | php | private function setPrefix($prefix)
{
if (0 === strlen($prefix)) {
throw new \InvalidArgumentException('Group prefix may not be empty.');
}
$prefix = '/'.trim($prefix, '/');
$this->prefix = $this->hasParent() ? $this->parent->getPrefix() . $prefix : $prefix;
} | [
"private",
"function",
"setPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"0",
"===",
"strlen",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Group prefix may not be empty.'",
")",
";",
"}",
"$",
"prefix",
"=",
"'/'",
".",
"trim",
"(",
"$",
"prefix",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"prefix",
"=",
"$",
"this",
"->",
"hasParent",
"(",
")",
"?",
"$",
"this",
"->",
"parent",
"->",
"getPrefix",
"(",
")",
".",
"$",
"prefix",
":",
"$",
"prefix",
";",
"}"
] | Set the group prefix
@return void | [
"Set",
"the",
"group",
"prefix"
] | 2d054ea01450bdad6a4af8198ca6f10705e1c327 | https://github.com/lucidphp/mux/blob/2d054ea01450bdad6a4af8198ca6f10705e1c327/src/RouteGroup.php#L84-L93 |
2,893 | lucidphp/mux | src/RouteGroup.php | RouteGroup.setRequirements | private function setRequirements(array $requirements)
{
$requirements = $this->filterRequirements($requirements);
$this->requirements = $this->hasParent() ?
array_merge($this->parent->getRequirements(), $requirements) :
$requirements;
} | php | private function setRequirements(array $requirements)
{
$requirements = $this->filterRequirements($requirements);
$this->requirements = $this->hasParent() ?
array_merge($this->parent->getRequirements(), $requirements) :
$requirements;
} | [
"private",
"function",
"setRequirements",
"(",
"array",
"$",
"requirements",
")",
"{",
"$",
"requirements",
"=",
"$",
"this",
"->",
"filterRequirements",
"(",
"$",
"requirements",
")",
";",
"$",
"this",
"->",
"requirements",
"=",
"$",
"this",
"->",
"hasParent",
"(",
")",
"?",
"array_merge",
"(",
"$",
"this",
"->",
"parent",
"->",
"getRequirements",
"(",
")",
",",
"$",
"requirements",
")",
":",
"$",
"requirements",
";",
"}"
] | Set the group requirements
@return void | [
"Set",
"the",
"group",
"requirements"
] | 2d054ea01450bdad6a4af8198ca6f10705e1c327 | https://github.com/lucidphp/mux/blob/2d054ea01450bdad6a4af8198ca6f10705e1c327/src/RouteGroup.php#L100-L107 |
2,894 | xmlsquad/gsheet-to-xml | src/Command/GsheetToXmlCommand.php | GsheetToXmlCommand.processDataSource | protected function processDataSource(OutputInterface $output, $service, $dataSourceOptions)
{
$this->typeCheckGoogleDriveProcessService($service);
$output->writeln($service->processGoogleUrl($this->doCreateGoogleDriveProcessor(),$dataSourceOptions['url'], $dataSourceOptions['recursive'], $this->doCreateDomainGSheetObjectFactory()));
} | php | protected function processDataSource(OutputInterface $output, $service, $dataSourceOptions)
{
$this->typeCheckGoogleDriveProcessService($service);
$output->writeln($service->processGoogleUrl($this->doCreateGoogleDriveProcessor(),$dataSourceOptions['url'], $dataSourceOptions['recursive'], $this->doCreateDomainGSheetObjectFactory()));
} | [
"protected",
"function",
"processDataSource",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"service",
",",
"$",
"dataSourceOptions",
")",
"{",
"$",
"this",
"->",
"typeCheckGoogleDriveProcessService",
"(",
"$",
"service",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"$",
"service",
"->",
"processGoogleUrl",
"(",
"$",
"this",
"->",
"doCreateGoogleDriveProcessor",
"(",
")",
",",
"$",
"dataSourceOptions",
"[",
"'url'",
"]",
",",
"$",
"dataSourceOptions",
"[",
"'recursive'",
"]",
",",
"$",
"this",
"->",
"doCreateDomainGSheetObjectFactory",
"(",
")",
")",
")",
";",
"}"
] | Invoke the GoogleDriveProcessService to process the data source.
@param OutputInterface $output
@param GoogleDriveProcessService $service
@param $dataSourceOptions
@throws \Exception | [
"Invoke",
"the",
"GoogleDriveProcessService",
"to",
"process",
"the",
"data",
"source",
"."
] | 069539b533160e384562044ca9744162f5cf4eb9 | https://github.com/xmlsquad/gsheet-to-xml/blob/069539b533160e384562044ca9744162f5cf4eb9/src/Command/GsheetToXmlCommand.php#L51-L55 |
2,895 | sgoendoer/sonic | src/Identity/SocialRecordManager.php | SocialRecordManager.retrieveSocialRecord | public static function retrieveSocialRecord($globalID, $skipCache = false)
{
if(Sonic::socialRecordCachingEnabled() === true && $skipCache === false)
{
$sr = Sonic::getSocialRecordCaching()->getSocialRecordFromCache($globalID);
if($sr !== false)
{
$sr->verify();
return $sr;
}
}
return GSLS::getSocialRecord($globalID);
} | php | public static function retrieveSocialRecord($globalID, $skipCache = false)
{
if(Sonic::socialRecordCachingEnabled() === true && $skipCache === false)
{
$sr = Sonic::getSocialRecordCaching()->getSocialRecordFromCache($globalID);
if($sr !== false)
{
$sr->verify();
return $sr;
}
}
return GSLS::getSocialRecord($globalID);
} | [
"public",
"static",
"function",
"retrieveSocialRecord",
"(",
"$",
"globalID",
",",
"$",
"skipCache",
"=",
"false",
")",
"{",
"if",
"(",
"Sonic",
"::",
"socialRecordCachingEnabled",
"(",
")",
"===",
"true",
"&&",
"$",
"skipCache",
"===",
"false",
")",
"{",
"$",
"sr",
"=",
"Sonic",
"::",
"getSocialRecordCaching",
"(",
")",
"->",
"getSocialRecordFromCache",
"(",
"$",
"globalID",
")",
";",
"if",
"(",
"$",
"sr",
"!==",
"false",
")",
"{",
"$",
"sr",
"->",
"verify",
"(",
")",
";",
"return",
"$",
"sr",
";",
"}",
"}",
"return",
"GSLS",
"::",
"getSocialRecord",
"(",
"$",
"globalID",
")",
";",
"}"
] | Retrieves a SocialRecord for a given GID from the GSLS or local cache
throws Exception
@param $globalID String The globalID to resolve
@param $skipCache Boolean Determin whether caching should be skipped or not
@return SocialRecord if social record exists. Otherwise, an exception is thrown | [
"Retrieves",
"a",
"SocialRecord",
"for",
"a",
"given",
"GID",
"from",
"the",
"GSLS",
"or",
"local",
"cache",
"throws",
"Exception"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/SocialRecordManager.php#L55-L69 |
2,896 | sgoendoer/sonic | src/Identity/SocialRecordManager.php | SocialRecordManager.socialRecordExists | public static function socialRecordExists($globalID)
{
if(!GID::isValid($globalID))
{
throw new \Exception('Illegal GID format');
}
try
{
$result = GSLS::getSocialRecord($globalID);
}
catch (SocialRecordNotFoundException $e)
{
return false;
}
return true;
} | php | public static function socialRecordExists($globalID)
{
if(!GID::isValid($globalID))
{
throw new \Exception('Illegal GID format');
}
try
{
$result = GSLS::getSocialRecord($globalID);
}
catch (SocialRecordNotFoundException $e)
{
return false;
}
return true;
} | [
"public",
"static",
"function",
"socialRecordExists",
"(",
"$",
"globalID",
")",
"{",
"if",
"(",
"!",
"GID",
"::",
"isValid",
"(",
"$",
"globalID",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Illegal GID format'",
")",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"GSLS",
"::",
"getSocialRecord",
"(",
"$",
"globalID",
")",
";",
"}",
"catch",
"(",
"SocialRecordNotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Checks if a SocialRecord is available in the GSLS for a given GID
throws Exception
return true if SocialRecord is available in the GSLS, otherwise false | [
"Checks",
"if",
"a",
"SocialRecord",
"is",
"available",
"in",
"the",
"GSLS",
"for",
"a",
"given",
"GID",
"throws",
"Exception"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/SocialRecordManager.php#L77-L94 |
2,897 | sgoendoer/sonic | src/Identity/SocialRecordManager.php | SocialRecordManager.exportSocialRecord | public static function exportSocialRecord(SocialRecord $socialRecord, KeyPair $accountKeyPair = NULL, KeyPair $personalKeyPair = NULL)
{
$json = new JSONObject();
$json->put('socialRecord', $socialRecord->getJSONObject());
if($accountKeyPair != NULL)
$json->put('accountPrivateKey', PrivateKey::exportKey($accountKeyPair->getPrivateKey()));
if($personalKeyPair != NULL)
$json->put('personalPrivateKey', PrivateKey::exportKey($personalKeyPair->getPrivateKey()));
return $json->write();
} | php | public static function exportSocialRecord(SocialRecord $socialRecord, KeyPair $accountKeyPair = NULL, KeyPair $personalKeyPair = NULL)
{
$json = new JSONObject();
$json->put('socialRecord', $socialRecord->getJSONObject());
if($accountKeyPair != NULL)
$json->put('accountPrivateKey', PrivateKey::exportKey($accountKeyPair->getPrivateKey()));
if($personalKeyPair != NULL)
$json->put('personalPrivateKey', PrivateKey::exportKey($personalKeyPair->getPrivateKey()));
return $json->write();
} | [
"public",
"static",
"function",
"exportSocialRecord",
"(",
"SocialRecord",
"$",
"socialRecord",
",",
"KeyPair",
"$",
"accountKeyPair",
"=",
"NULL",
",",
"KeyPair",
"$",
"personalKeyPair",
"=",
"NULL",
")",
"{",
"$",
"json",
"=",
"new",
"JSONObject",
"(",
")",
";",
"$",
"json",
"->",
"put",
"(",
"'socialRecord'",
",",
"$",
"socialRecord",
"->",
"getJSONObject",
"(",
")",
")",
";",
"if",
"(",
"$",
"accountKeyPair",
"!=",
"NULL",
")",
"$",
"json",
"->",
"put",
"(",
"'accountPrivateKey'",
",",
"PrivateKey",
"::",
"exportKey",
"(",
"$",
"accountKeyPair",
"->",
"getPrivateKey",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"personalKeyPair",
"!=",
"NULL",
")",
"$",
"json",
"->",
"put",
"(",
"'personalPrivateKey'",
",",
"PrivateKey",
"::",
"exportKey",
"(",
"$",
"personalKeyPair",
"->",
"getPrivateKey",
"(",
")",
")",
")",
";",
"return",
"$",
"json",
"->",
"write",
"(",
")",
";",
"}"
] | Exports a SocialRecord object to a serialized JSONObject
@param SocialRecord The SocialRecord to export
@param KeyPair account key pair to export
@param KeyPair personal key pair to export
@return string The exported SocialRecord | [
"Exports",
"a",
"SocialRecord",
"object",
"to",
"a",
"serialized",
"JSONObject"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/SocialRecordManager.php#L104-L117 |
2,898 | sgoendoer/sonic | src/Identity/SocialRecordManager.php | SocialRecordManager.importSocialRecord | public static function importSocialRecord($source)
{
$json = new JSONObject($source);
$socialRecord = SocialRecordBuilder::buildFromJSON($json->get('socialRecord'));
$result = array('socialRecord' => $socialRecord);
if($json->has('accountPrivateKey'))
$result['accountKeyPair'] = new KeyPair($json->get('accountPrivateKey'), $socialRecord->getAccountPublicKey());
if($json->has('personalPrivateKey'))
$result['personalKeyPair'] = new KeyPair($json->get('personalPrivateKey'), $socialRecord->getPersonalPublicKey());
return $result;
} | php | public static function importSocialRecord($source)
{
$json = new JSONObject($source);
$socialRecord = SocialRecordBuilder::buildFromJSON($json->get('socialRecord'));
$result = array('socialRecord' => $socialRecord);
if($json->has('accountPrivateKey'))
$result['accountKeyPair'] = new KeyPair($json->get('accountPrivateKey'), $socialRecord->getAccountPublicKey());
if($json->has('personalPrivateKey'))
$result['personalKeyPair'] = new KeyPair($json->get('personalPrivateKey'), $socialRecord->getPersonalPublicKey());
return $result;
} | [
"public",
"static",
"function",
"importSocialRecord",
"(",
"$",
"source",
")",
"{",
"$",
"json",
"=",
"new",
"JSONObject",
"(",
"$",
"source",
")",
";",
"$",
"socialRecord",
"=",
"SocialRecordBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"get",
"(",
"'socialRecord'",
")",
")",
";",
"$",
"result",
"=",
"array",
"(",
"'socialRecord'",
"=>",
"$",
"socialRecord",
")",
";",
"if",
"(",
"$",
"json",
"->",
"has",
"(",
"'accountPrivateKey'",
")",
")",
"$",
"result",
"[",
"'accountKeyPair'",
"]",
"=",
"new",
"KeyPair",
"(",
"$",
"json",
"->",
"get",
"(",
"'accountPrivateKey'",
")",
",",
"$",
"socialRecord",
"->",
"getAccountPublicKey",
"(",
")",
")",
";",
"if",
"(",
"$",
"json",
"->",
"has",
"(",
"'personalPrivateKey'",
")",
")",
"$",
"result",
"[",
"'personalKeyPair'",
"]",
"=",
"new",
"KeyPair",
"(",
"$",
"json",
"->",
"get",
"(",
"'personalPrivateKey'",
")",
",",
"$",
"socialRecord",
"->",
"getPersonalPublicKey",
"(",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Imports a SocialRecord from a string resource
@param $source The string to parse
@return array Array containting the SocialRecord object and optinally the KeyPair(s) | [
"Imports",
"a",
"SocialRecord",
"from",
"a",
"string",
"resource"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/SocialRecordManager.php#L125-L139 |
2,899 | romeOz/rock-template | src/snippets/ListViewSnippet.php | ListViewSnippet.calculatePagination | protected function calculatePagination()
{
if (empty($this->pagination['array']) && empty($this->pagination['call'])) {
return;
}
if (isset($this->pagination['call'])) {
$this->pagination['array'] = $this->callFunction($this->pagination['call']);
}
$keys = ['toPlaceholder'];
$pagination = $this->template->getSnippet('pagination', ArrayHelper::diffByKeys($this->pagination, $keys));
if (!empty($this->pagination['toPlaceholder'])) {
$this->template->addPlaceholder($this->pagination['toPlaceholder'], $pagination);
$this->template->cachePlaceholders[$this->pagination['toPlaceholder']] = $pagination;
return;
}
$this->template->addPlaceholder('pagination', $pagination);
} | php | protected function calculatePagination()
{
if (empty($this->pagination['array']) && empty($this->pagination['call'])) {
return;
}
if (isset($this->pagination['call'])) {
$this->pagination['array'] = $this->callFunction($this->pagination['call']);
}
$keys = ['toPlaceholder'];
$pagination = $this->template->getSnippet('pagination', ArrayHelper::diffByKeys($this->pagination, $keys));
if (!empty($this->pagination['toPlaceholder'])) {
$this->template->addPlaceholder($this->pagination['toPlaceholder'], $pagination);
$this->template->cachePlaceholders[$this->pagination['toPlaceholder']] = $pagination;
return;
}
$this->template->addPlaceholder('pagination', $pagination);
} | [
"protected",
"function",
"calculatePagination",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'array'",
"]",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'call'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'call'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"pagination",
"[",
"'array'",
"]",
"=",
"$",
"this",
"->",
"callFunction",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'call'",
"]",
")",
";",
"}",
"$",
"keys",
"=",
"[",
"'toPlaceholder'",
"]",
";",
"$",
"pagination",
"=",
"$",
"this",
"->",
"template",
"->",
"getSnippet",
"(",
"'pagination'",
",",
"ArrayHelper",
"::",
"diffByKeys",
"(",
"$",
"this",
"->",
"pagination",
",",
"$",
"keys",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'toPlaceholder'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"template",
"->",
"addPlaceholder",
"(",
"$",
"this",
"->",
"pagination",
"[",
"'toPlaceholder'",
"]",
",",
"$",
"pagination",
")",
";",
"$",
"this",
"->",
"template",
"->",
"cachePlaceholders",
"[",
"$",
"this",
"->",
"pagination",
"[",
"'toPlaceholder'",
"]",
"]",
"=",
"$",
"pagination",
";",
"return",
";",
"}",
"$",
"this",
"->",
"template",
"->",
"addPlaceholder",
"(",
"'pagination'",
",",
"$",
"pagination",
")",
";",
"}"
] | Adding pagination.
@return void | [
"Adding",
"pagination",
"."
] | fcb7bd6dd923d11f02a1c71a63065f3f49728e92 | https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/snippets/ListViewSnippet.php#L220-L237 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.