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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
24,300
NuclearCMS/Hierarchy
src/Node.php
Node.getMetaImage
public function getMetaImage() { $metaImage = $this->getTranslationAttribute('meta_image'); if ($metaImage = get_nuclear_cover($metaImage)) { return $metaImage; } if ($coverImage = $this->getCoverImage()) { return $coverImage; } return null; }
php
public function getMetaImage() { $metaImage = $this->getTranslationAttribute('meta_image'); if ($metaImage = get_nuclear_cover($metaImage)) { return $metaImage; } if ($coverImage = $this->getCoverImage()) { return $coverImage; } return null; }
[ "public", "function", "getMetaImage", "(", ")", "{", "$", "metaImage", "=", "$", "this", "->", "getTranslationAttribute", "(", "'meta_image'", ")", ";", "if", "(", "$", "metaImage", "=", "get_nuclear_cover", "(", "$", "metaImage", ")", ")", "{", "return", "$", "metaImage", ";", "}", "if", "(", "$", "coverImage", "=", "$", "this", "->", "getCoverImage", "(", ")", ")", "{", "return", "$", "coverImage", ";", "}", "return", "null", ";", "}" ]
Meta image getter @return Image|null
[ "Meta", "image", "getter" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1414-L1429
24,301
NuclearCMS/Hierarchy
src/Node.php
Node.getCoverImage
public function getCoverImage() { if ($this->coverImage) { return $this->coverImage; } $modelName = source_model_name($this->getNodeTypeName(), true); $mutatables = call_user_func([$modelName, 'getMutatables']); foreach ($mutatables as $mutatable => $type) { if ($type === 'gallery' && ($images = $this->getTranslationAttribute($mutatable, null, true, true))) { if ($cover = get_nuclear_cover($images)) { $this->coverImage = $cover; return $cover; } } if ($type === 'document' && ($document = $this->getTranslationAttribute($mutatable, null, true, true))) { if ($document = get_nuclear_cover($document)) { $this->coverImage = $document; return $document; } } } return null; }
php
public function getCoverImage() { if ($this->coverImage) { return $this->coverImage; } $modelName = source_model_name($this->getNodeTypeName(), true); $mutatables = call_user_func([$modelName, 'getMutatables']); foreach ($mutatables as $mutatable => $type) { if ($type === 'gallery' && ($images = $this->getTranslationAttribute($mutatable, null, true, true))) { if ($cover = get_nuclear_cover($images)) { $this->coverImage = $cover; return $cover; } } if ($type === 'document' && ($document = $this->getTranslationAttribute($mutatable, null, true, true))) { if ($document = get_nuclear_cover($document)) { $this->coverImage = $document; return $document; } } } return null; }
[ "public", "function", "getCoverImage", "(", ")", "{", "if", "(", "$", "this", "->", "coverImage", ")", "{", "return", "$", "this", "->", "coverImage", ";", "}", "$", "modelName", "=", "source_model_name", "(", "$", "this", "->", "getNodeTypeName", "(", ")", ",", "true", ")", ";", "$", "mutatables", "=", "call_user_func", "(", "[", "$", "modelName", ",", "'getMutatables'", "]", ")", ";", "foreach", "(", "$", "mutatables", "as", "$", "mutatable", "=>", "$", "type", ")", "{", "if", "(", "$", "type", "===", "'gallery'", "&&", "(", "$", "images", "=", "$", "this", "->", "getTranslationAttribute", "(", "$", "mutatable", ",", "null", ",", "true", ",", "true", ")", ")", ")", "{", "if", "(", "$", "cover", "=", "get_nuclear_cover", "(", "$", "images", ")", ")", "{", "$", "this", "->", "coverImage", "=", "$", "cover", ";", "return", "$", "cover", ";", "}", "}", "if", "(", "$", "type", "===", "'document'", "&&", "(", "$", "document", "=", "$", "this", "->", "getTranslationAttribute", "(", "$", "mutatable", ",", "null", ",", "true", ",", "true", ")", ")", ")", "{", "if", "(", "$", "document", "=", "get_nuclear_cover", "(", "$", "document", ")", ")", "{", "$", "this", "->", "coverImage", "=", "$", "document", ";", "return", "$", "document", ";", "}", "}", "}", "return", "null", ";", "}" ]
Gets the cover image @return Image|null
[ "Gets", "the", "cover", "image" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Node.php#L1436-L1471
24,302
Jimdo/jimphle-data-structure
src/Jimphle/DataStructure/Map.php
Map.setIn
public function setIn($keys, $value) { $lastKey = array_shift($keys); if (count($keys) > 0 && !isset($this->$lastKey->{$keys[0]})) { throw new \RuntimeException(sprintf("Key '%s->%s' does not exist.", $lastKey, $keys[0])); } if (count($keys) > 0 && $this->$lastKey instanceof Map) { return $this->merge(new self(array($lastKey => $this->$lastKey->setIn($keys, $value)))); } return $this->merge(new self(array($lastKey => $value))); }
php
public function setIn($keys, $value) { $lastKey = array_shift($keys); if (count($keys) > 0 && !isset($this->$lastKey->{$keys[0]})) { throw new \RuntimeException(sprintf("Key '%s->%s' does not exist.", $lastKey, $keys[0])); } if (count($keys) > 0 && $this->$lastKey instanceof Map) { return $this->merge(new self(array($lastKey => $this->$lastKey->setIn($keys, $value)))); } return $this->merge(new self(array($lastKey => $value))); }
[ "public", "function", "setIn", "(", "$", "keys", ",", "$", "value", ")", "{", "$", "lastKey", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "count", "(", "$", "keys", ")", ">", "0", "&&", "!", "isset", "(", "$", "this", "->", "$", "lastKey", "->", "{", "$", "keys", "[", "0", "]", "}", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Key '%s->%s' does not exist.\"", ",", "$", "lastKey", ",", "$", "keys", "[", "0", "]", ")", ")", ";", "}", "if", "(", "count", "(", "$", "keys", ")", ">", "0", "&&", "$", "this", "->", "$", "lastKey", "instanceof", "Map", ")", "{", "return", "$", "this", "->", "merge", "(", "new", "self", "(", "array", "(", "$", "lastKey", "=>", "$", "this", "->", "$", "lastKey", "->", "setIn", "(", "$", "keys", ",", "$", "value", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "merge", "(", "new", "self", "(", "array", "(", "$", "lastKey", "=>", "$", "value", ")", ")", ")", ";", "}" ]
set a value in a nested map @param array $keys @param mixed $value @return Map
[ "set", "a", "value", "in", "a", "nested", "map" ]
15f784e4af48520079f8639748ab68b074dbc005
https://github.com/Jimdo/jimphle-data-structure/blob/15f784e4af48520079f8639748ab68b074dbc005/src/Jimphle/DataStructure/Map.php#L74-L84
24,303
oroinc/OroLayoutComponent
AliasCollection.php
AliasCollection.getId
public function getId($alias) { if (!isset($this->aliases[$alias])) { return null; } $id = $this->aliases[$alias]; while (isset($this->aliases[$id])) { $id = $this->aliases[$id]; } return $id; }
php
public function getId($alias) { if (!isset($this->aliases[$alias])) { return null; } $id = $this->aliases[$alias]; while (isset($this->aliases[$id])) { $id = $this->aliases[$id]; } return $id; }
[ "public", "function", "getId", "(", "$", "alias", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ")", "{", "return", "null", ";", "}", "$", "id", "=", "$", "this", "->", "aliases", "[", "$", "alias", "]", ";", "while", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "id", "]", ")", ")", "{", "$", "id", "=", "$", "this", "->", "aliases", "[", "$", "id", "]", ";", "}", "return", "$", "id", ";", "}" ]
Returns the identifier of the item which has the given alias @param string $alias The item alias @return string|null The item identifier or null if no one item has the given alias
[ "Returns", "the", "identifier", "of", "the", "item", "which", "has", "the", "given", "alias" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/AliasCollection.php#L50-L62
24,304
oroinc/OroLayoutComponent
AliasCollection.php
AliasCollection.add
public function add($alias, $id) { if (isset($this->aliases[$alias])) { if ($this->aliases[$alias] === $id) { // exactly the same alias for the specified item is already exists return $this; } throw new Exception\AliasAlreadyExistsException( sprintf( 'The "%s" sting cannot be used as an alias for "%s" item' . ' because it is already used for "%s" item.', $alias, $id, $this->aliases[$alias] ) ); } $this->aliases[$alias] = $id; $id = $this->getId($alias); $this->ids[$id][] = $alias; return $this; }
php
public function add($alias, $id) { if (isset($this->aliases[$alias])) { if ($this->aliases[$alias] === $id) { // exactly the same alias for the specified item is already exists return $this; } throw new Exception\AliasAlreadyExistsException( sprintf( 'The "%s" sting cannot be used as an alias for "%s" item' . ' because it is already used for "%s" item.', $alias, $id, $this->aliases[$alias] ) ); } $this->aliases[$alias] = $id; $id = $this->getId($alias); $this->ids[$id][] = $alias; return $this; }
[ "public", "function", "add", "(", "$", "alias", ",", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ")", "{", "if", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", "===", "$", "id", ")", "{", "// exactly the same alias for the specified item is already exists", "return", "$", "this", ";", "}", "throw", "new", "Exception", "\\", "AliasAlreadyExistsException", "(", "sprintf", "(", "'The \"%s\" sting cannot be used as an alias for \"%s\" item'", ".", "' because it is already used for \"%s\" item.'", ",", "$", "alias", ",", "$", "id", ",", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ")", ";", "}", "$", "this", "->", "aliases", "[", "$", "alias", "]", "=", "$", "id", ";", "$", "id", "=", "$", "this", "->", "getId", "(", "$", "alias", ")", ";", "$", "this", "->", "ids", "[", "$", "id", "]", "[", "]", "=", "$", "alias", ";", "return", "$", "this", ";", "}" ]
Registers an alias for the specified identifier @param string $alias A string that can be used as an alias for the item id @param string $id The item identifier or already registered item alias @return self @throws Exception\AliasAlreadyExistsException if the alias is used for another item
[ "Registers", "an", "alias", "for", "the", "specified", "identifier" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/AliasCollection.php#L88-L113
24,305
oroinc/OroLayoutComponent
AliasCollection.php
AliasCollection.remove
public function remove($alias) { $id = $this->getId($alias); if ($id) { unset($this->aliases[$alias]); $aliases = &$this->ids[$id]; unset($aliases[array_search($alias, $aliases, true)]); if (!empty($aliases)) { $this->removeDependedAliases($alias, $id); } else { unset($this->ids[$id]); } } return $this; }
php
public function remove($alias) { $id = $this->getId($alias); if ($id) { unset($this->aliases[$alias]); $aliases = &$this->ids[$id]; unset($aliases[array_search($alias, $aliases, true)]); if (!empty($aliases)) { $this->removeDependedAliases($alias, $id); } else { unset($this->ids[$id]); } } return $this; }
[ "public", "function", "remove", "(", "$", "alias", ")", "{", "$", "id", "=", "$", "this", "->", "getId", "(", "$", "alias", ")", ";", "if", "(", "$", "id", ")", "{", "unset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ";", "$", "aliases", "=", "&", "$", "this", "->", "ids", "[", "$", "id", "]", ";", "unset", "(", "$", "aliases", "[", "array_search", "(", "$", "alias", ",", "$", "aliases", ",", "true", ")", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "aliases", ")", ")", "{", "$", "this", "->", "removeDependedAliases", "(", "$", "alias", ",", "$", "id", ")", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "ids", "[", "$", "id", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Removes the alias @param string $alias The item alias @return self
[ "Removes", "the", "alias" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/AliasCollection.php#L122-L137
24,306
oroinc/OroLayoutComponent
AliasCollection.php
AliasCollection.removeById
public function removeById($id) { if (isset($this->ids[$id])) { foreach ($this->ids[$id] as $alias) { unset($this->aliases[$alias]); } unset($this->ids[$id]); } return $this; }
php
public function removeById($id) { if (isset($this->ids[$id])) { foreach ($this->ids[$id] as $alias) { unset($this->aliases[$alias]); } unset($this->ids[$id]); } return $this; }
[ "public", "function", "removeById", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "ids", "[", "$", "id", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "ids", "[", "$", "id", "]", "as", "$", "alias", ")", "{", "unset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ";", "}", "unset", "(", "$", "this", "->", "ids", "[", "$", "id", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes all aliases for the specified item @param string $id The identifier of item which aliases should be removed @return self
[ "Removes", "all", "aliases", "for", "the", "specified", "item" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/AliasCollection.php#L146-L156
24,307
oroinc/OroLayoutComponent
AliasCollection.php
AliasCollection.removeDependedAliases
protected function removeDependedAliases($alias, $id) { foreach ($this->ids[$id] as $otherAlias) { if (isset($this->aliases[$otherAlias]) && $this->aliases[$otherAlias] === $alias) { unset($this->aliases[$otherAlias]); $aliases = &$this->ids[$id]; unset($aliases[array_search($otherAlias, $aliases, true)]); if (!empty($aliases)) { $this->removeDependedAliases($otherAlias, $id); } else { unset($this->ids[$id]); } } } }
php
protected function removeDependedAliases($alias, $id) { foreach ($this->ids[$id] as $otherAlias) { if (isset($this->aliases[$otherAlias]) && $this->aliases[$otherAlias] === $alias) { unset($this->aliases[$otherAlias]); $aliases = &$this->ids[$id]; unset($aliases[array_search($otherAlias, $aliases, true)]); if (!empty($aliases)) { $this->removeDependedAliases($otherAlias, $id); } else { unset($this->ids[$id]); } } } }
[ "protected", "function", "removeDependedAliases", "(", "$", "alias", ",", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "ids", "[", "$", "id", "]", "as", "$", "otherAlias", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "otherAlias", "]", ")", "&&", "$", "this", "->", "aliases", "[", "$", "otherAlias", "]", "===", "$", "alias", ")", "{", "unset", "(", "$", "this", "->", "aliases", "[", "$", "otherAlias", "]", ")", ";", "$", "aliases", "=", "&", "$", "this", "->", "ids", "[", "$", "id", "]", ";", "unset", "(", "$", "aliases", "[", "array_search", "(", "$", "otherAlias", ",", "$", "aliases", ",", "true", ")", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "aliases", ")", ")", "{", "$", "this", "->", "removeDependedAliases", "(", "$", "otherAlias", ",", "$", "id", ")", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "ids", "[", "$", "id", "]", ")", ";", "}", "}", "}", "}" ]
Removes all depended aliases For example if "alias3" is removed in alias chain like "alias1 -> alias2 -> alias3 -> id" than both "alias1" and "alias2" are removed as well @param string $alias @param string $id
[ "Removes", "all", "depended", "aliases", "For", "example", "if", "alias3", "is", "removed", "in", "alias", "chain", "like", "alias1", "-", ">", "alias2", "-", ">", "alias3", "-", ">", "id", "than", "both", "alias1", "and", "alias2", "are", "removed", "as", "well" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/AliasCollection.php#L185-L199
24,308
CupOfTea696/WordPress-Composer
src/Plugin.php
Plugin.getRootDirectory
public function getRootDirectory() { $config = $this->composer->getConfig(); return str_replace($config->get('vendor-dir', Config::RELATIVE_PATHS), '', $config->get('vendor-dir')); }
php
public function getRootDirectory() { $config = $this->composer->getConfig(); return str_replace($config->get('vendor-dir', Config::RELATIVE_PATHS), '', $config->get('vendor-dir')); }
[ "public", "function", "getRootDirectory", "(", ")", "{", "$", "config", "=", "$", "this", "->", "composer", "->", "getConfig", "(", ")", ";", "return", "str_replace", "(", "$", "config", "->", "get", "(", "'vendor-dir'", ",", "Config", "::", "RELATIVE_PATHS", ")", ",", "''", ",", "$", "config", "->", "get", "(", "'vendor-dir'", ")", ")", ";", "}" ]
Get the root directory. @return string
[ "Get", "the", "root", "directory", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Plugin.php#L165-L170
24,309
CupOfTea696/WordPress-Composer
src/Plugin.php
Plugin.getPublicDirectory
public function getPublicDirectory() { if (isset($this->publicDirectory)) { return $this->publicDirectory; } $rootPkg = $this->composer->getPackage(); if ($rootPkg) { $extra = $rootPkg->getExtra(); if ($extra && ! empty($extra['public-dir'])) { return $this->publicDirectory = $extra['public-dir']; } } $common_public_dirs = [ 'public', 'public_html', 'htdocs', 'httpdocs', 'html', 'web', 'www', ]; $public = null; foreach ($common_public_dirs as $dir) { if (file_exists($dir)) { $public = $dir; break; } } $publicDirQuestion = 'What is the public directory (web root) for this project?'; if (! $public) { if ($this->io->isInteractive()) { return $this->publicDirectory = trim($this->ask($publicDirQuestion, $common_public_dirs[0]), '/'); } return $this->publicDirectory = $common_public_dirs[0]; } if ($this->io->isInteractive()) { return $this->publicDirectory = trim($this->ask($publicDirQuestion, $public), '/'); } return $this->publicDirectory = $public; }
php
public function getPublicDirectory() { if (isset($this->publicDirectory)) { return $this->publicDirectory; } $rootPkg = $this->composer->getPackage(); if ($rootPkg) { $extra = $rootPkg->getExtra(); if ($extra && ! empty($extra['public-dir'])) { return $this->publicDirectory = $extra['public-dir']; } } $common_public_dirs = [ 'public', 'public_html', 'htdocs', 'httpdocs', 'html', 'web', 'www', ]; $public = null; foreach ($common_public_dirs as $dir) { if (file_exists($dir)) { $public = $dir; break; } } $publicDirQuestion = 'What is the public directory (web root) for this project?'; if (! $public) { if ($this->io->isInteractive()) { return $this->publicDirectory = trim($this->ask($publicDirQuestion, $common_public_dirs[0]), '/'); } return $this->publicDirectory = $common_public_dirs[0]; } if ($this->io->isInteractive()) { return $this->publicDirectory = trim($this->ask($publicDirQuestion, $public), '/'); } return $this->publicDirectory = $public; }
[ "public", "function", "getPublicDirectory", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "publicDirectory", ")", ")", "{", "return", "$", "this", "->", "publicDirectory", ";", "}", "$", "rootPkg", "=", "$", "this", "->", "composer", "->", "getPackage", "(", ")", ";", "if", "(", "$", "rootPkg", ")", "{", "$", "extra", "=", "$", "rootPkg", "->", "getExtra", "(", ")", ";", "if", "(", "$", "extra", "&&", "!", "empty", "(", "$", "extra", "[", "'public-dir'", "]", ")", ")", "{", "return", "$", "this", "->", "publicDirectory", "=", "$", "extra", "[", "'public-dir'", "]", ";", "}", "}", "$", "common_public_dirs", "=", "[", "'public'", ",", "'public_html'", ",", "'htdocs'", ",", "'httpdocs'", ",", "'html'", ",", "'web'", ",", "'www'", ",", "]", ";", "$", "public", "=", "null", ";", "foreach", "(", "$", "common_public_dirs", "as", "$", "dir", ")", "{", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "$", "public", "=", "$", "dir", ";", "break", ";", "}", "}", "$", "publicDirQuestion", "=", "'What is the public directory (web root) for this project?'", ";", "if", "(", "!", "$", "public", ")", "{", "if", "(", "$", "this", "->", "io", "->", "isInteractive", "(", ")", ")", "{", "return", "$", "this", "->", "publicDirectory", "=", "trim", "(", "$", "this", "->", "ask", "(", "$", "publicDirQuestion", ",", "$", "common_public_dirs", "[", "0", "]", ")", ",", "'/'", ")", ";", "}", "return", "$", "this", "->", "publicDirectory", "=", "$", "common_public_dirs", "[", "0", "]", ";", "}", "if", "(", "$", "this", "->", "io", "->", "isInteractive", "(", ")", ")", "{", "return", "$", "this", "->", "publicDirectory", "=", "trim", "(", "$", "this", "->", "ask", "(", "$", "publicDirQuestion", ",", "$", "public", ")", ",", "'/'", ")", ";", "}", "return", "$", "this", "->", "publicDirectory", "=", "$", "public", ";", "}" ]
Get the public directory. @return string
[ "Get", "the", "public", "directory", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Plugin.php#L187-L238
24,310
mothership-ec/composer
src/Composer/Util/Filesystem.php
Filesystem.removeDirectoryPhp
public function removeDirectoryPhp($directory) { $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS); $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); foreach ($ri as $file) { if ($file->isDir()) { $this->rmdir($file->getPathname()); } else { $this->unlink($file->getPathname()); } } return $this->rmdir($directory); }
php
public function removeDirectoryPhp($directory) { $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS); $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); foreach ($ri as $file) { if ($file->isDir()) { $this->rmdir($file->getPathname()); } else { $this->unlink($file->getPathname()); } } return $this->rmdir($directory); }
[ "public", "function", "removeDirectoryPhp", "(", "$", "directory", ")", "{", "$", "it", "=", "new", "RecursiveDirectoryIterator", "(", "$", "directory", ",", "RecursiveDirectoryIterator", "::", "SKIP_DOTS", ")", ";", "$", "ri", "=", "new", "RecursiveIteratorIterator", "(", "$", "it", ",", "RecursiveIteratorIterator", "::", "CHILD_FIRST", ")", ";", "foreach", "(", "$", "ri", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "isDir", "(", ")", ")", "{", "$", "this", "->", "rmdir", "(", "$", "file", "->", "getPathname", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "unlink", "(", "$", "file", "->", "getPathname", "(", ")", ")", ";", "}", "}", "return", "$", "this", "->", "rmdir", "(", "$", "directory", ")", ";", "}" ]
Recursively delete directory using PHP iterators. Uses a CHILD_FIRST RecursiveIteratorIterator to sort files before directories, creating a single non-recursive loop to delete files/directories in the correct order. @param string $directory @return bool
[ "Recursively", "delete", "directory", "using", "PHP", "iterators", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Util/Filesystem.php#L142-L156
24,311
tttptd/laravel-responder
src/Traits/HandlesApiErrors.php
HandlesApiErrors.transformException
protected function transformException(Exception $exception) { if (Request::capture()->wantsJson()) { $this->transformAuthException($exception); $this->transformEloquentException($exception); $this->transformValidationException($exception); } }
php
protected function transformException(Exception $exception) { if (Request::capture()->wantsJson()) { $this->transformAuthException($exception); $this->transformEloquentException($exception); $this->transformValidationException($exception); } }
[ "protected", "function", "transformException", "(", "Exception", "$", "exception", ")", "{", "if", "(", "Request", "::", "capture", "(", ")", "->", "wantsJson", "(", ")", ")", "{", "$", "this", "->", "transformAuthException", "(", "$", "exception", ")", ";", "$", "this", "->", "transformEloquentException", "(", "$", "exception", ")", ";", "$", "this", "->", "transformValidationException", "(", "$", "exception", ")", ";", "}", "}" ]
Transform a Laravel exception into an API exception. @param Exception $exception @return void
[ "Transform", "a", "Laravel", "exception", "into", "an", "API", "exception", "." ]
0e4a32701f0de755c1f1af458045829e1bd6caf6
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/HandlesApiErrors.php#L36-L43
24,312
tttptd/laravel-responder
src/Traits/HandlesApiErrors.php
HandlesApiErrors.renderApiError
protected function renderApiError(ApiException $exception):JsonResponse { return app('responder.error') ->setError($exception->getErrorCode(), $exception->getMessage()) ->addData($exception->getData() ?: []) ->respond($exception->getStatusCode()); }
php
protected function renderApiError(ApiException $exception):JsonResponse { return app('responder.error') ->setError($exception->getErrorCode(), $exception->getMessage()) ->addData($exception->getData() ?: []) ->respond($exception->getStatusCode()); }
[ "protected", "function", "renderApiError", "(", "ApiException", "$", "exception", ")", ":", "JsonResponse", "{", "return", "app", "(", "'responder.error'", ")", "->", "setError", "(", "$", "exception", "->", "getErrorCode", "(", ")", ",", "$", "exception", "->", "getMessage", "(", ")", ")", "->", "addData", "(", "$", "exception", "->", "getData", "(", ")", "?", ":", "[", "]", ")", "->", "respond", "(", "$", "exception", "->", "getStatusCode", "(", ")", ")", ";", "}" ]
Renders any API exception into a JSON error response. @param ApiException $exception @return JsonResponse
[ "Renders", "any", "API", "exception", "into", "a", "JSON", "error", "response", "." ]
0e4a32701f0de755c1f1af458045829e1bd6caf6
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/HandlesApiErrors.php#L103-L109
24,313
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php
ExceptionUtils.getHTMLBackTrace
private static function getHTMLBackTrace($backtrace) { $str = ''; foreach ($backtrace as $step) { if ($step['function'] != 'getHTMLBackTrace' && $step['function'] != 'handle_error') { $str .= '<tr><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['class'])) ? htmlspecialchars($step['class'], ENT_NOQUOTES, 'UTF-8') : ''). ((isset($step['type'])) ? htmlspecialchars($step['type'], ENT_NOQUOTES, 'UTF-8') : '').htmlspecialchars($step['function'], ENT_NOQUOTES, 'UTF-8').'('; if (is_array($step['args'])) { $drawn = false; $params = ''; foreach ($step['args'] as $param) { $params .= self::getPhpVariableAsText($param); //$params .= var_export($param, true); $params .= ', '; $drawn = true; } $str .= htmlspecialchars($params, ENT_NOQUOTES, 'UTF-8'); if ($drawn == true) { $str = substr($str, 0, strlen($str) - 2); } } $str .= ')'; $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['file'])) ? htmlspecialchars(self::displayFile($step['file']), ENT_NOQUOTES, 'UTF-8') : ''); $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['line'])) ? $step['line'] : ''); $str .= '</td></tr>'; } } return $str; }
php
private static function getHTMLBackTrace($backtrace) { $str = ''; foreach ($backtrace as $step) { if ($step['function'] != 'getHTMLBackTrace' && $step['function'] != 'handle_error') { $str .= '<tr><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['class'])) ? htmlspecialchars($step['class'], ENT_NOQUOTES, 'UTF-8') : ''). ((isset($step['type'])) ? htmlspecialchars($step['type'], ENT_NOQUOTES, 'UTF-8') : '').htmlspecialchars($step['function'], ENT_NOQUOTES, 'UTF-8').'('; if (is_array($step['args'])) { $drawn = false; $params = ''; foreach ($step['args'] as $param) { $params .= self::getPhpVariableAsText($param); //$params .= var_export($param, true); $params .= ', '; $drawn = true; } $str .= htmlspecialchars($params, ENT_NOQUOTES, 'UTF-8'); if ($drawn == true) { $str = substr($str, 0, strlen($str) - 2); } } $str .= ')'; $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['file'])) ? htmlspecialchars(self::displayFile($step['file']), ENT_NOQUOTES, 'UTF-8') : ''); $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">'; $str .= ((isset($step['line'])) ? $step['line'] : ''); $str .= '</td></tr>'; } } return $str; }
[ "private", "static", "function", "getHTMLBackTrace", "(", "$", "backtrace", ")", "{", "$", "str", "=", "''", ";", "foreach", "(", "$", "backtrace", "as", "$", "step", ")", "{", "if", "(", "$", "step", "[", "'function'", "]", "!=", "'getHTMLBackTrace'", "&&", "$", "step", "[", "'function'", "]", "!=", "'handle_error'", ")", "{", "$", "str", ".=", "'<tr><td style=\"border-bottom: 1px solid #EEEEEE\">'", ";", "$", "str", ".=", "(", "(", "isset", "(", "$", "step", "[", "'class'", "]", ")", ")", "?", "htmlspecialchars", "(", "$", "step", "[", "'class'", "]", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ":", "''", ")", ".", "(", "(", "isset", "(", "$", "step", "[", "'type'", "]", ")", ")", "?", "htmlspecialchars", "(", "$", "step", "[", "'type'", "]", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ":", "''", ")", ".", "htmlspecialchars", "(", "$", "step", "[", "'function'", "]", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ".", "'('", ";", "if", "(", "is_array", "(", "$", "step", "[", "'args'", "]", ")", ")", "{", "$", "drawn", "=", "false", ";", "$", "params", "=", "''", ";", "foreach", "(", "$", "step", "[", "'args'", "]", "as", "$", "param", ")", "{", "$", "params", ".=", "self", "::", "getPhpVariableAsText", "(", "$", "param", ")", ";", "//$params .= var_export($param, true);", "$", "params", ".=", "', '", ";", "$", "drawn", "=", "true", ";", "}", "$", "str", ".=", "htmlspecialchars", "(", "$", "params", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ";", "if", "(", "$", "drawn", "==", "true", ")", "{", "$", "str", "=", "substr", "(", "$", "str", ",", "0", ",", "strlen", "(", "$", "str", ")", "-", "2", ")", ";", "}", "}", "$", "str", ".=", "')'", ";", "$", "str", ".=", "'</td><td style=\"border-bottom: 1px solid #EEEEEE\">'", ";", "$", "str", ".=", "(", "(", "isset", "(", "$", "step", "[", "'file'", "]", ")", ")", "?", "htmlspecialchars", "(", "self", "::", "displayFile", "(", "$", "step", "[", "'file'", "]", ")", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ":", "''", ")", ";", "$", "str", ".=", "'</td><td style=\"border-bottom: 1px solid #EEEEEE\">'", ";", "$", "str", ".=", "(", "(", "isset", "(", "$", "step", "[", "'line'", "]", ")", ")", "?", "$", "step", "[", "'line'", "]", ":", "''", ")", ";", "$", "str", ".=", "'</td></tr>'", ";", "}", "}", "return", "$", "str", ";", "}" ]
Returns the Exception Backtrace as a nice HTML view. @param array $backtrace @return string
[ "Returns", "the", "Exception", "Backtrace", "as", "a", "nice", "HTML", "view", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php#L14-L48
24,314
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php
ExceptionUtils.getPhpVariableAsText
private static function getPhpVariableAsText($var) { if (is_string($var)) { return('"'.str_replace(array("\x00", "\x0a", "\x0d", "\x1a", "\x09"), array('\0', '\n', '\r', '\Z', '\t'), $var).'"'); } elseif (is_int($var) || is_float($var)) { return($var); } elseif (is_bool($var)) { if ($var) { return('true'); } else { return('false'); } } elseif (is_array($var)) { $result = 'array( '; $comma = ''; foreach ($var as $key => $val) { $result .= $comma.self::getPhpVariableAsText($key).' => '.self::getPhpVariableAsText($val); $comma = ', '; } $result .= ' )'; return($result); } elseif (is_object($var)) { return 'Object '.get_class($var); } elseif (is_resource($var)) { return 'Resource '.get_resource_type($var); } return 'Unknown type variable'; }
php
private static function getPhpVariableAsText($var) { if (is_string($var)) { return('"'.str_replace(array("\x00", "\x0a", "\x0d", "\x1a", "\x09"), array('\0', '\n', '\r', '\Z', '\t'), $var).'"'); } elseif (is_int($var) || is_float($var)) { return($var); } elseif (is_bool($var)) { if ($var) { return('true'); } else { return('false'); } } elseif (is_array($var)) { $result = 'array( '; $comma = ''; foreach ($var as $key => $val) { $result .= $comma.self::getPhpVariableAsText($key).' => '.self::getPhpVariableAsText($val); $comma = ', '; } $result .= ' )'; return($result); } elseif (is_object($var)) { return 'Object '.get_class($var); } elseif (is_resource($var)) { return 'Resource '.get_resource_type($var); } return 'Unknown type variable'; }
[ "private", "static", "function", "getPhpVariableAsText", "(", "$", "var", ")", "{", "if", "(", "is_string", "(", "$", "var", ")", ")", "{", "return", "(", "'\"'", ".", "str_replace", "(", "array", "(", "\"\\x00\"", ",", "\"\\x0a\"", ",", "\"\\x0d\"", ",", "\"\\x1a\"", ",", "\"\\x09\"", ")", ",", "array", "(", "'\\0'", ",", "'\\n'", ",", "'\\r'", ",", "'\\Z'", ",", "'\\t'", ")", ",", "$", "var", ")", ".", "'\"'", ")", ";", "}", "elseif", "(", "is_int", "(", "$", "var", ")", "||", "is_float", "(", "$", "var", ")", ")", "{", "return", "(", "$", "var", ")", ";", "}", "elseif", "(", "is_bool", "(", "$", "var", ")", ")", "{", "if", "(", "$", "var", ")", "{", "return", "(", "'true'", ")", ";", "}", "else", "{", "return", "(", "'false'", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "var", ")", ")", "{", "$", "result", "=", "'array( '", ";", "$", "comma", "=", "''", ";", "foreach", "(", "$", "var", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "result", ".=", "$", "comma", ".", "self", "::", "getPhpVariableAsText", "(", "$", "key", ")", ".", "' => '", ".", "self", "::", "getPhpVariableAsText", "(", "$", "val", ")", ";", "$", "comma", "=", "', '", ";", "}", "$", "result", ".=", "' )'", ";", "return", "(", "$", "result", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "var", ")", ")", "{", "return", "'Object '", ".", "get_class", "(", "$", "var", ")", ";", "}", "elseif", "(", "is_resource", "(", "$", "var", ")", ")", "{", "return", "'Resource '", ".", "get_resource_type", "(", "$", "var", ")", ";", "}", "return", "'Unknown type variable'", ";", "}" ]
Used by the debug function to display a nice view of the parameters. @param mixed $var @return string
[ "Used", "by", "the", "debug", "function", "to", "display", "a", "nice", "view", "of", "the", "parameters", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php#L152-L181
24,315
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php
ExceptionUtils.getRelativePath
private static function getRelativePath($from, $to) { $from = explode('/', $from); $to = explode('/', $to); $relPath = $to; foreach ($from as $depth => $dir) { // find first non-matching dir if (isset($to[$depth]) && $dir === $to[$depth]) { // ignore this directory array_shift($relPath); } else { // get number of remaining dirs to $from $remaining = count($from) - $depth; if ($remaining > 1) { // add traversals up to first matching dir $padLength = (count($relPath) + $remaining - 1) * -1; $relPath = array_pad($relPath, $padLength, '..'); break; } else { $relPath[0] = './'.$relPath[0]; } } } return implode('/', $relPath); }
php
private static function getRelativePath($from, $to) { $from = explode('/', $from); $to = explode('/', $to); $relPath = $to; foreach ($from as $depth => $dir) { // find first non-matching dir if (isset($to[$depth]) && $dir === $to[$depth]) { // ignore this directory array_shift($relPath); } else { // get number of remaining dirs to $from $remaining = count($from) - $depth; if ($remaining > 1) { // add traversals up to first matching dir $padLength = (count($relPath) + $remaining - 1) * -1; $relPath = array_pad($relPath, $padLength, '..'); break; } else { $relPath[0] = './'.$relPath[0]; } } } return implode('/', $relPath); }
[ "private", "static", "function", "getRelativePath", "(", "$", "from", ",", "$", "to", ")", "{", "$", "from", "=", "explode", "(", "'/'", ",", "$", "from", ")", ";", "$", "to", "=", "explode", "(", "'/'", ",", "$", "to", ")", ";", "$", "relPath", "=", "$", "to", ";", "foreach", "(", "$", "from", "as", "$", "depth", "=>", "$", "dir", ")", "{", "// find first non-matching dir", "if", "(", "isset", "(", "$", "to", "[", "$", "depth", "]", ")", "&&", "$", "dir", "===", "$", "to", "[", "$", "depth", "]", ")", "{", "// ignore this directory", "array_shift", "(", "$", "relPath", ")", ";", "}", "else", "{", "// get number of remaining dirs to $from", "$", "remaining", "=", "count", "(", "$", "from", ")", "-", "$", "depth", ";", "if", "(", "$", "remaining", ">", "1", ")", "{", "// add traversals up to first matching dir", "$", "padLength", "=", "(", "count", "(", "$", "relPath", ")", "+", "$", "remaining", "-", "1", ")", "*", "-", "1", ";", "$", "relPath", "=", "array_pad", "(", "$", "relPath", ",", "$", "padLength", ",", "'..'", ")", ";", "break", ";", "}", "else", "{", "$", "relPath", "[", "0", "]", "=", "'./'", ".", "$", "relPath", "[", "0", "]", ";", "}", "}", "}", "return", "implode", "(", "'/'", ",", "$", "relPath", ")", ";", "}" ]
Returns a relative path based on 2 absolute paths. @param string $from @param string $to @return string
[ "Returns", "a", "relative", "path", "based", "on", "2", "absolute", "paths", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Utils/ExceptionUtils.php#L204-L230
24,316
rafalkot/yii2-settings
Settings.php
Settings.get
public function get($category, $key = null, $default = null) { $this->load($category); if ($key === null) { return isset($this->items[$category]) && !empty($this->items[$category]) ? $this->items[$category] : $default; } if (is_string($key)) { return isset($this->items[$category][$key]) ? $this->items[$category][$key] : $default; } if (is_array($key)) { $result = []; foreach ($key as $val) { $result[$val] = isset($this->items[$category][$val]) ? $this->items[$category][$val] : (is_array($default) && isset($default[$val]) ? $default[$val] : null); } return $result; } return $default; }
php
public function get($category, $key = null, $default = null) { $this->load($category); if ($key === null) { return isset($this->items[$category]) && !empty($this->items[$category]) ? $this->items[$category] : $default; } if (is_string($key)) { return isset($this->items[$category][$key]) ? $this->items[$category][$key] : $default; } if (is_array($key)) { $result = []; foreach ($key as $val) { $result[$val] = isset($this->items[$category][$val]) ? $this->items[$category][$val] : (is_array($default) && isset($default[$val]) ? $default[$val] : null); } return $result; } return $default; }
[ "public", "function", "get", "(", "$", "category", ",", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "this", "->", "load", "(", "$", "category", ")", ";", "if", "(", "$", "key", "===", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "category", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "items", "[", "$", "category", "]", ")", "?", "$", "this", "->", "items", "[", "$", "category", "]", ":", "$", "default", ";", "}", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "category", "]", "[", "$", "key", "]", ")", "?", "$", "this", "->", "items", "[", "$", "category", "]", "[", "$", "key", "]", ":", "$", "default", ";", "}", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "key", "as", "$", "val", ")", "{", "$", "result", "[", "$", "val", "]", "=", "isset", "(", "$", "this", "->", "items", "[", "$", "category", "]", "[", "$", "val", "]", ")", "?", "$", "this", "->", "items", "[", "$", "category", "]", "[", "$", "val", "]", ":", "(", "is_array", "(", "$", "default", ")", "&&", "isset", "(", "$", "default", "[", "$", "val", "]", ")", "?", "$", "default", "[", "$", "val", "]", ":", "null", ")", ";", "}", "return", "$", "result", ";", "}", "return", "$", "default", ";", "}" ]
Returns settings. @param string $category Category name @param string|array $key Single or multiple keys in array @param mixed $default Default value when setting does not exist @return mixed Setting value @throws Exception
[ "Returns", "settings", "." ]
b601b58809322f617273093766dc28c08e74d566
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/Settings.php#L56-L77
24,317
rafalkot/yii2-settings
Settings.php
Settings.load
public function load($categories) { if (is_string($categories)) { $categories = [$categories]; } foreach ($categories as $idx => $category) { if (isset($this->items[$category])) { unset($categories[$idx]); } else { $this->items[$category] = []; } } if (empty($categories)) { return; } $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([ 'category' => $categories ])->all(); foreach ($result as $row) { try { $this->items[$row['category']][$row['key']] = Json::decode($row['value']); } catch (InvalidParamException $ex) { $this->items[$row['category']][$row['key']] = $row['value']; } } }
php
public function load($categories) { if (is_string($categories)) { $categories = [$categories]; } foreach ($categories as $idx => $category) { if (isset($this->items[$category])) { unset($categories[$idx]); } else { $this->items[$category] = []; } } if (empty($categories)) { return; } $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([ 'category' => $categories ])->all(); foreach ($result as $row) { try { $this->items[$row['category']][$row['key']] = Json::decode($row['value']); } catch (InvalidParamException $ex) { $this->items[$row['category']][$row['key']] = $row['value']; } } }
[ "public", "function", "load", "(", "$", "categories", ")", "{", "if", "(", "is_string", "(", "$", "categories", ")", ")", "{", "$", "categories", "=", "[", "$", "categories", "]", ";", "}", "foreach", "(", "$", "categories", "as", "$", "idx", "=>", "$", "category", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "category", "]", ")", ")", "{", "unset", "(", "$", "categories", "[", "$", "idx", "]", ")", ";", "}", "else", "{", "$", "this", "->", "items", "[", "$", "category", "]", "=", "[", "]", ";", "}", "}", "if", "(", "empty", "(", "$", "categories", ")", ")", "{", "return", ";", "}", "$", "result", "=", "(", "new", "Query", "(", ")", ")", "->", "select", "(", "[", "'category'", ",", "'key'", ",", "'value'", "]", ")", "->", "from", "(", "'setting'", ")", "->", "where", "(", "[", "'category'", "=>", "$", "categories", "]", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "row", ")", "{", "try", "{", "$", "this", "->", "items", "[", "$", "row", "[", "'category'", "]", "]", "[", "$", "row", "[", "'key'", "]", "]", "=", "Json", "::", "decode", "(", "$", "row", "[", "'value'", "]", ")", ";", "}", "catch", "(", "InvalidParamException", "$", "ex", ")", "{", "$", "this", "->", "items", "[", "$", "row", "[", "'category'", "]", "]", "[", "$", "row", "[", "'key'", "]", "]", "=", "$", "row", "[", "'value'", "]", ";", "}", "}", "}" ]
Loads settings from category or multiple categories @param array|string $categories Category name
[ "Loads", "settings", "from", "category", "or", "multiple", "categories" ]
b601b58809322f617273093766dc28c08e74d566
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/Settings.php#L147-L176
24,318
rafalkot/yii2-settings
Settings.php
Settings.dbInsert
protected function dbInsert($category, $key, $value) { $created_by = \Yii::$app->user->getId(); $this->getDb()->createCommand(' INSERT INTO {{setting}} (`category`, `key`, `value`, `created_at`, `created_by`) VALUES (:category, :key, :value, NOW(), :created_by) ', compact('category', 'key', 'value', 'created_by'))->execute(); }
php
protected function dbInsert($category, $key, $value) { $created_by = \Yii::$app->user->getId(); $this->getDb()->createCommand(' INSERT INTO {{setting}} (`category`, `key`, `value`, `created_at`, `created_by`) VALUES (:category, :key, :value, NOW(), :created_by) ', compact('category', 'key', 'value', 'created_by'))->execute(); }
[ "protected", "function", "dbInsert", "(", "$", "category", ",", "$", "key", ",", "$", "value", ")", "{", "$", "created_by", "=", "\\", "Yii", "::", "$", "app", "->", "user", "->", "getId", "(", ")", ";", "$", "this", "->", "getDb", "(", ")", "->", "createCommand", "(", "'\n INSERT INTO\n {{setting}} (`category`, `key`, `value`, `created_at`, `created_by`)\n VALUES\n (:category, :key, :value, NOW(), :created_by)\n '", ",", "compact", "(", "'category'", ",", "'key'", ",", "'value'", ",", "'created_by'", ")", ")", "->", "execute", "(", ")", ";", "}" ]
Stores settings in database @param string $category Category name @param string $key Setting key @param string $value Setting value @throws \yii\db\Exception
[ "Stores", "settings", "in", "database" ]
b601b58809322f617273093766dc28c08e74d566
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/Settings.php#L194-L203
24,319
rafalkot/yii2-settings
Settings.php
Settings.dbUpdate
protected function dbUpdate($category, $key, $value) { $updated_by = \Yii::$app->user->getId(); $this->getDb()->createCommand(' UPDATE {{setting}} SET `value` = :value, `updated_at` = NOW(), `updated_by` = :updated_by WHERE category = :category AND `key` = :key ', compact('category', 'key', 'value', 'updated_by'))->execute(); }
php
protected function dbUpdate($category, $key, $value) { $updated_by = \Yii::$app->user->getId(); $this->getDb()->createCommand(' UPDATE {{setting}} SET `value` = :value, `updated_at` = NOW(), `updated_by` = :updated_by WHERE category = :category AND `key` = :key ', compact('category', 'key', 'value', 'updated_by'))->execute(); }
[ "protected", "function", "dbUpdate", "(", "$", "category", ",", "$", "key", ",", "$", "value", ")", "{", "$", "updated_by", "=", "\\", "Yii", "::", "$", "app", "->", "user", "->", "getId", "(", ")", ";", "$", "this", "->", "getDb", "(", ")", "->", "createCommand", "(", "'\n UPDATE\n {{setting}}\n SET\n `value` = :value,\n `updated_at` = NOW(),\n `updated_by` = :updated_by\n WHERE\n category = :category\n AND `key` = :key\n '", ",", "compact", "(", "'category'", ",", "'key'", ",", "'value'", ",", "'updated_by'", ")", ")", "->", "execute", "(", ")", ";", "}" ]
Updates setting in database @param string $category Category name @param string $key Setting key @param string $value Setting value @throws \yii\db\Exception
[ "Updates", "setting", "in", "database" ]
b601b58809322f617273093766dc28c08e74d566
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/Settings.php#L213-L227
24,320
rafalkot/yii2-settings
Settings.php
Settings.dbDelete
protected function dbDelete($category, $key = null) { if ($key === null) { $this->getDb()->createCommand(' DELETE FROM {{setting}} WHERE `category` = :category ', compact('category'))->execute(); } if (is_string($key)) { $this->getDb()->createCommand(' DELETE FROM {{setting}} WHERE `category` = :category AND `key` = :key ', compact('category', 'key'))->execute(); } if (is_array($key)) { foreach ($key as $val) { $this->dbDelete($category, $val); } } }
php
protected function dbDelete($category, $key = null) { if ($key === null) { $this->getDb()->createCommand(' DELETE FROM {{setting}} WHERE `category` = :category ', compact('category'))->execute(); } if (is_string($key)) { $this->getDb()->createCommand(' DELETE FROM {{setting}} WHERE `category` = :category AND `key` = :key ', compact('category', 'key'))->execute(); } if (is_array($key)) { foreach ($key as $val) { $this->dbDelete($category, $val); } } }
[ "protected", "function", "dbDelete", "(", "$", "category", ",", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "$", "this", "->", "getDb", "(", ")", "->", "createCommand", "(", "'\n DELETE FROM\n {{setting}}\n WHERE\n `category` = :category\n '", ",", "compact", "(", "'category'", ")", ")", "->", "execute", "(", ")", ";", "}", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "getDb", "(", ")", "->", "createCommand", "(", "'\n DELETE FROM\n {{setting}}\n WHERE\n `category` = :category\n AND `key` = :key\n '", ",", "compact", "(", "'category'", ",", "'key'", ")", ")", "->", "execute", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "val", ")", "{", "$", "this", "->", "dbDelete", "(", "$", "category", ",", "$", "val", ")", ";", "}", "}", "}" ]
Deletes setting from database @param string|array $category Category name(s) @param string|array|null $key Setting key(s) or null to delete all values from category @throws \yii\db\Exception
[ "Deletes", "setting", "from", "database" ]
b601b58809322f617273093766dc28c08e74d566
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/Settings.php#L236-L262
24,321
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.push
public function push($type, $name, $value) { $typeModel = NotificationTypes::where('name', $type)->first(); if (is_null($typeModel)) { return false; } $tId = $typeModel->id; $model = $this->makeModel()->getModel()->newInstance([ 'type_id' => $tId, 'name' => $name, 'value' => $value ]); $model->save(); return $model; }
php
public function push($type, $name, $value) { $typeModel = NotificationTypes::where('name', $type)->first(); if (is_null($typeModel)) { return false; } $tId = $typeModel->id; $model = $this->makeModel()->getModel()->newInstance([ 'type_id' => $tId, 'name' => $name, 'value' => $value ]); $model->save(); return $model; }
[ "public", "function", "push", "(", "$", "type", ",", "$", "name", ",", "$", "value", ")", "{", "$", "typeModel", "=", "NotificationTypes", "::", "where", "(", "'name'", ",", "$", "type", ")", "->", "first", "(", ")", ";", "if", "(", "is_null", "(", "$", "typeModel", ")", ")", "{", "return", "false", ";", "}", "$", "tId", "=", "$", "typeModel", "->", "id", ";", "$", "model", "=", "$", "this", "->", "makeModel", "(", ")", "->", "getModel", "(", ")", "->", "newInstance", "(", "[", "'type_id'", "=>", "$", "tId", ",", "'name'", "=>", "$", "name", ",", "'value'", "=>", "$", "value", "]", ")", ";", "$", "model", "->", "save", "(", ")", ";", "return", "$", "model", ";", "}" ]
push notification to database @param String $type @param String $name @param array $value @return boolean
[ "push", "notification", "to", "database" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L58-L72
24,322
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.findAllNew
public function findAllNew($ids = []) { $query = $model = $this->makeModel()->where('broadcasted', 0); if (!empty($ids)) { $values = array_values($ids); $query->whereNotIn('id', $values); } return $query->get(); }
php
public function findAllNew($ids = []) { $query = $model = $this->makeModel()->where('broadcasted', 0); if (!empty($ids)) { $values = array_values($ids); $query->whereNotIn('id', $values); } return $query->get(); }
[ "public", "function", "findAllNew", "(", "$", "ids", "=", "[", "]", ")", "{", "$", "query", "=", "$", "model", "=", "$", "this", "->", "makeModel", "(", ")", "->", "where", "(", "'broadcasted'", ",", "0", ")", ";", "if", "(", "!", "empty", "(", "$", "ids", ")", ")", "{", "$", "values", "=", "array_values", "(", "$", "ids", ")", ";", "$", "query", "->", "whereNotIn", "(", "'id'", ",", "$", "values", ")", ";", "}", "return", "$", "query", "->", "get", "(", ")", ";", "}" ]
finds all new notification messages @param array $ids @return \Illuminate\Database\Query\Builder
[ "finds", "all", "new", "notification", "messages" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L80-L88
24,323
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.query
public function query() { $read = NotificationsStackRead::select(['stack_id']) ->withTrashed() ->where('user_id', user()->id) ->whereNotNull('deleted_at') ->pluck('stack_id'); return $this->makeModel()->newQuery() ->distinct() ->select(['tbl_notifications_stack.*']) ->whereHas('content', function($query) { $query->where([ 'lang_id' => lang_id() ]); }) ->whereHas('notification', function($query) { $query->whereHas('type', function($subquery) { $subquery->where('name', area()); }); }) ->where(function ($query) { $query ->whereNull('author_id') ->orWhere('author_id', user()->id) ->orWhereHas('author', function($subquery) { $subquery->whereHas('roles', function($rolesQuery) { $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds()); }); }) ->orWhereHas('params', function($subquery) { $subquery->where('model_id', user()->id); }); }) ->whereNotIn('id', $read) ->with('author') ->with('content')->with('notification.severity') ->orderBy('tbl_notifications_stack.created_at', 'desc'); }
php
public function query() { $read = NotificationsStackRead::select(['stack_id']) ->withTrashed() ->where('user_id', user()->id) ->whereNotNull('deleted_at') ->pluck('stack_id'); return $this->makeModel()->newQuery() ->distinct() ->select(['tbl_notifications_stack.*']) ->whereHas('content', function($query) { $query->where([ 'lang_id' => lang_id() ]); }) ->whereHas('notification', function($query) { $query->whereHas('type', function($subquery) { $subquery->where('name', area()); }); }) ->where(function ($query) { $query ->whereNull('author_id') ->orWhere('author_id', user()->id) ->orWhereHas('author', function($subquery) { $subquery->whereHas('roles', function($rolesQuery) { $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds()); }); }) ->orWhereHas('params', function($subquery) { $subquery->where('model_id', user()->id); }); }) ->whereNotIn('id', $read) ->with('author') ->with('content')->with('notification.severity') ->orderBy('tbl_notifications_stack.created_at', 'desc'); }
[ "public", "function", "query", "(", ")", "{", "$", "read", "=", "NotificationsStackRead", "::", "select", "(", "[", "'stack_id'", "]", ")", "->", "withTrashed", "(", ")", "->", "where", "(", "'user_id'", ",", "user", "(", ")", "->", "id", ")", "->", "whereNotNull", "(", "'deleted_at'", ")", "->", "pluck", "(", "'stack_id'", ")", ";", "return", "$", "this", "->", "makeModel", "(", ")", "->", "newQuery", "(", ")", "->", "distinct", "(", ")", "->", "select", "(", "[", "'tbl_notifications_stack.*'", "]", ")", "->", "whereHas", "(", "'content'", ",", "function", "(", "$", "query", ")", "{", "$", "query", "->", "where", "(", "[", "'lang_id'", "=>", "lang_id", "(", ")", "]", ")", ";", "}", ")", "->", "whereHas", "(", "'notification'", ",", "function", "(", "$", "query", ")", "{", "$", "query", "->", "whereHas", "(", "'type'", ",", "function", "(", "$", "subquery", ")", "{", "$", "subquery", "->", "where", "(", "'name'", ",", "area", "(", ")", ")", ";", "}", ")", ";", "}", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "whereNull", "(", "'author_id'", ")", "->", "orWhere", "(", "'author_id'", ",", "user", "(", ")", "->", "id", ")", "->", "orWhereHas", "(", "'author'", ",", "function", "(", "$", "subquery", ")", "{", "$", "subquery", "->", "whereHas", "(", "'roles'", ",", "function", "(", "$", "rolesQuery", ")", "{", "$", "rolesQuery", "->", "whereIn", "(", "'tbl_roles.id'", ",", "user", "(", ")", "->", "roles", "->", "first", "(", ")", "->", "getChilds", "(", ")", ")", ";", "}", ")", ";", "}", ")", "->", "orWhereHas", "(", "'params'", ",", "function", "(", "$", "subquery", ")", "{", "$", "subquery", "->", "where", "(", "'model_id'", ",", "user", "(", ")", "->", "id", ")", ";", "}", ")", ";", "}", ")", "->", "whereNotIn", "(", "'id'", ",", "$", "read", ")", "->", "with", "(", "'author'", ")", "->", "with", "(", "'content'", ")", "->", "with", "(", "'notification.severity'", ")", "->", "orderBy", "(", "'tbl_notifications_stack.created_at'", ",", "'desc'", ")", ";", "}" ]
Gets base query builder for notifications and alerts @return \Illuminate\Database\Query\Builder
[ "Gets", "base", "query", "builder", "for", "notifications", "and", "alerts" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L115-L152
24,324
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.count
protected function count($builder) { $read = NotificationsStackRead::select(['stack_id'])->withTrashed()->where('user_id', user()->id)->pluck('stack_id'); return $builder->whereNotIn('id', $read)->count(); }
php
protected function count($builder) { $read = NotificationsStackRead::select(['stack_id'])->withTrashed()->where('user_id', user()->id)->pluck('stack_id'); return $builder->whereNotIn('id', $read)->count(); }
[ "protected", "function", "count", "(", "$", "builder", ")", "{", "$", "read", "=", "NotificationsStackRead", "::", "select", "(", "[", "'stack_id'", "]", ")", "->", "withTrashed", "(", ")", "->", "where", "(", "'user_id'", ",", "user", "(", ")", "->", "id", ")", "->", "pluck", "(", "'stack_id'", ")", ";", "return", "$", "builder", "->", "whereNotIn", "(", "'id'", ",", "$", "read", ")", "->", "count", "(", ")", ";", "}" ]
Assign counter query @param \Illuminate\Database\Query\Builder $builder @return \Illuminate\Database\Eloquent\Model
[ "Assign", "counter", "query" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L184-L188
24,325
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.clear
public function clear($type = 'notifications') { $builder = ($type === 'alerts') ? $this->getAlerts() : $this->getNotifications(); return $this->makeModel() ->getModel() ->read() ->getModel() ->newQuery() ->whereIn('stack_id', $builder->pluck('id'))->delete(); }
php
public function clear($type = 'notifications') { $builder = ($type === 'alerts') ? $this->getAlerts() : $this->getNotifications(); return $this->makeModel() ->getModel() ->read() ->getModel() ->newQuery() ->whereIn('stack_id', $builder->pluck('id'))->delete(); }
[ "public", "function", "clear", "(", "$", "type", "=", "'notifications'", ")", "{", "$", "builder", "=", "(", "$", "type", "===", "'alerts'", ")", "?", "$", "this", "->", "getAlerts", "(", ")", ":", "$", "this", "->", "getNotifications", "(", ")", ";", "return", "$", "this", "->", "makeModel", "(", ")", "->", "getModel", "(", ")", "->", "read", "(", ")", "->", "getModel", "(", ")", "->", "newQuery", "(", ")", "->", "whereIn", "(", "'stack_id'", ",", "$", "builder", "->", "pluck", "(", "'id'", ")", ")", "->", "delete", "(", ")", ";", "}" ]
Deletes all messages @param String $type @return boolean
[ "Deletes", "all", "messages" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L209-L219
24,326
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.markAsRead
public function markAsRead($type = 'notifications') { DB::beginTransaction(); try { $builder = ($type === 'alerts') ? $this->getAlerts() : $this->getNotifications(); $read = NotificationsStackRead::select(['stack_id'])->withTrashed()->where('user_id', user()->id)->pluck('stack_id'); $items = $builder->whereNotIn('id', $read)->get(); foreach ($items as $item) { $item->read()->save(new NotificationsStackRead([ 'user_id' => user()->id ])); $item->save(); } } catch (Exception $ex) { DB::rollback(); return false; } return DB::commit(); }
php
public function markAsRead($type = 'notifications') { DB::beginTransaction(); try { $builder = ($type === 'alerts') ? $this->getAlerts() : $this->getNotifications(); $read = NotificationsStackRead::select(['stack_id'])->withTrashed()->where('user_id', user()->id)->pluck('stack_id'); $items = $builder->whereNotIn('id', $read)->get(); foreach ($items as $item) { $item->read()->save(new NotificationsStackRead([ 'user_id' => user()->id ])); $item->save(); } } catch (Exception $ex) { DB::rollback(); return false; } return DB::commit(); }
[ "public", "function", "markAsRead", "(", "$", "type", "=", "'notifications'", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "$", "builder", "=", "(", "$", "type", "===", "'alerts'", ")", "?", "$", "this", "->", "getAlerts", "(", ")", ":", "$", "this", "->", "getNotifications", "(", ")", ";", "$", "read", "=", "NotificationsStackRead", "::", "select", "(", "[", "'stack_id'", "]", ")", "->", "withTrashed", "(", ")", "->", "where", "(", "'user_id'", ",", "user", "(", ")", "->", "id", ")", "->", "pluck", "(", "'stack_id'", ")", ";", "$", "items", "=", "$", "builder", "->", "whereNotIn", "(", "'id'", ",", "$", "read", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "item", "->", "read", "(", ")", "->", "save", "(", "new", "NotificationsStackRead", "(", "[", "'user_id'", "=>", "user", "(", ")", "->", "id", "]", ")", ")", ";", "$", "item", "->", "save", "(", ")", ";", "}", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "false", ";", "}", "return", "DB", "::", "commit", "(", ")", ";", "}" ]
Mark notifications or alerts as read @param String $type @return boolean
[ "Mark", "notifications", "or", "alerts", "as", "read" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L227-L246
24,327
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.deleteById
public function deleteById($id) { $read = NotificationsStackRead::where([ 'stack_id' => $id, 'user_id' => user()->id ])->first(); if (!is_null($read)) { return $read->delete(); } return false; }
php
public function deleteById($id) { $read = NotificationsStackRead::where([ 'stack_id' => $id, 'user_id' => user()->id ])->first(); if (!is_null($read)) { return $read->delete(); } return false; }
[ "public", "function", "deleteById", "(", "$", "id", ")", "{", "$", "read", "=", "NotificationsStackRead", "::", "where", "(", "[", "'stack_id'", "=>", "$", "id", ",", "'user_id'", "=>", "user", "(", ")", "->", "id", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "read", ")", ")", "{", "return", "$", "read", "->", "delete", "(", ")", ";", "}", "return", "false", ";", "}" ]
Deletes item by id @param mixed $id @return boolean
[ "Deletes", "item", "by", "id" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L254-L264
24,328
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.resolveJsonCastableColumns
protected function resolveJsonCastableColumns(&$log) { foreach ($log as $name => $value) { if (!is_array($value)) { continue; } $log[$name] = json_encode($value); } return $log; }
php
protected function resolveJsonCastableColumns(&$log) { foreach ($log as $name => $value) { if (!is_array($value)) { continue; } $log[$name] = json_encode($value); } return $log; }
[ "protected", "function", "resolveJsonCastableColumns", "(", "&", "$", "log", ")", "{", "foreach", "(", "$", "log", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "$", "log", "[", "$", "name", "]", "=", "json_encode", "(", "$", "value", ")", ";", "}", "return", "$", "log", ";", "}" ]
Resolves json castable columns @return array
[ "Resolves", "json", "castable", "columns" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L312-L321
24,329
antaresproject/notifications
src/Repository/StackRepository.php
StackRepository.fetchOne
public function fetchOne(int $id): Builder { return $this->makeModel()->newQuery()->withoutGlobalScopes()->distinct() ->select(['tbl_notifications_stack.*'])->with('content')->with('content.lang')->with('notification.type') ->where(function ($query) { $query->whereNull('author_id')->orWhere('author_id', user()->id)->orWhereHas('author', function($subquery) { $subquery->whereHas('roles', function($rolesQuery) { $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds()); }); }); }) ->with('author')->with('author.roles')->with('content') ->whereId($id); }
php
public function fetchOne(int $id): Builder { return $this->makeModel()->newQuery()->withoutGlobalScopes()->distinct() ->select(['tbl_notifications_stack.*'])->with('content')->with('content.lang')->with('notification.type') ->where(function ($query) { $query->whereNull('author_id')->orWhere('author_id', user()->id)->orWhereHas('author', function($subquery) { $subquery->whereHas('roles', function($rolesQuery) { $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds()); }); }); }) ->with('author')->with('author.roles')->with('content') ->whereId($id); }
[ "public", "function", "fetchOne", "(", "int", "$", "id", ")", ":", "Builder", "{", "return", "$", "this", "->", "makeModel", "(", ")", "->", "newQuery", "(", ")", "->", "withoutGlobalScopes", "(", ")", "->", "distinct", "(", ")", "->", "select", "(", "[", "'tbl_notifications_stack.*'", "]", ")", "->", "with", "(", "'content'", ")", "->", "with", "(", "'content.lang'", ")", "->", "with", "(", "'notification.type'", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "whereNull", "(", "'author_id'", ")", "->", "orWhere", "(", "'author_id'", ",", "user", "(", ")", "->", "id", ")", "->", "orWhereHas", "(", "'author'", ",", "function", "(", "$", "subquery", ")", "{", "$", "subquery", "->", "whereHas", "(", "'roles'", ",", "function", "(", "$", "rolesQuery", ")", "{", "$", "rolesQuery", "->", "whereIn", "(", "'tbl_roles.id'", ",", "user", "(", ")", "->", "roles", "->", "first", "(", ")", "->", "getChilds", "(", ")", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", "->", "with", "(", "'author'", ")", "->", "with", "(", "'author.roles'", ")", "->", "with", "(", "'content'", ")", "->", "whereId", "(", "$", "id", ")", ";", "}" ]
Fetch one stack item @param int $id @return Builder
[ "Fetch", "one", "stack", "item" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Repository/StackRepository.php#L366-L379
24,330
Danzabar/config-builder
src/Data/Extracter.php
Extracter.load
public function load($file, $extension = 'json') { $this->file = $file; $this->extension = $extension; return $this; }
php
public function load($file, $extension = 'json') { $this->file = $file; $this->extension = $extension; return $this; }
[ "public", "function", "load", "(", "$", "file", ",", "$", "extension", "=", "'json'", ")", "{", "$", "this", "->", "file", "=", "$", "file", ";", "$", "this", "->", "extension", "=", "$", "extension", ";", "return", "$", "this", ";", "}" ]
Load the file details @param String $file @param String $extension @return Extracter @author Dan Cox
[ "Load", "the", "file", "details" ]
3b237be578172c32498bbcdfb360e69a6243739d
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Extracter.php#L65-L71
24,331
Danzabar/config-builder
src/Data/Extracter.php
Extracter.extract
public function extract() { $this->reader->read($this->file); $this->converter ->setExtension($this->extension) ->process($this->reader->getData()); }
php
public function extract() { $this->reader->read($this->file); $this->converter ->setExtension($this->extension) ->process($this->reader->getData()); }
[ "public", "function", "extract", "(", ")", "{", "$", "this", "->", "reader", "->", "read", "(", "$", "this", "->", "file", ")", ";", "$", "this", "->", "converter", "->", "setExtension", "(", "$", "this", "->", "extension", ")", "->", "process", "(", "$", "this", "->", "reader", "->", "getData", "(", ")", ")", ";", "}" ]
Extracts the raw data from the file for conversion @return Extracter @author Dan Cox
[ "Extracts", "the", "raw", "data", "from", "the", "file", "for", "conversion" ]
3b237be578172c32498bbcdfb360e69a6243739d
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Extracter.php#L79-L86
24,332
kouks/laravel-filters
src/Filters/Behavior/Orderable.php
Orderable.resolveOrder
protected function resolveOrder($column, $key) { $this->resolve($column, $key, $this->getTableName(), function ($query, $pattern) { $this->builder->orderBy($query, $pattern); }); }
php
protected function resolveOrder($column, $key) { $this->resolve($column, $key, $this->getTableName(), function ($query, $pattern) { $this->builder->orderBy($query, $pattern); }); }
[ "protected", "function", "resolveOrder", "(", "$", "column", ",", "$", "key", ")", "{", "$", "this", "->", "resolve", "(", "$", "column", ",", "$", "key", ",", "$", "this", "->", "getTableName", "(", ")", ",", "function", "(", "$", "query", ",", "$", "pattern", ")", "{", "$", "this", "->", "builder", "->", "orderBy", "(", "$", "query", ",", "$", "pattern", ")", ";", "}", ")", ";", "}" ]
Recursively build up the order query. @param string $column @param string $key @return void
[ "Recursively", "build", "up", "the", "order", "query", "." ]
c1a594fd40173dcbb454ea7ec59818a919fff6bd
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Behavior/Orderable.php#L30-L35
24,333
flextype-components/assets
Assets.php
Assets.add
public static function add(string $asset_type, string $asset, string $namespace, int $priority = 1) : void { Assets::$assets[$namespace][$asset_type][$priority][] = [ 'asset' => $asset ]; }
php
public static function add(string $asset_type, string $asset, string $namespace, int $priority = 1) : void { Assets::$assets[$namespace][$asset_type][$priority][] = [ 'asset' => $asset ]; }
[ "public", "static", "function", "add", "(", "string", "$", "asset_type", ",", "string", "$", "asset", ",", "string", "$", "namespace", ",", "int", "$", "priority", "=", "1", ")", ":", "void", "{", "Assets", "::", "$", "assets", "[", "$", "namespace", "]", "[", "$", "asset_type", "]", "[", "$", "priority", "]", "[", "]", "=", "[", "'asset'", "=>", "$", "asset", "]", ";", "}" ]
Add new asset Assets::add('js', 'jquery.js', 'site', 1); Assets::add('js', 'site.js', 'site', 2); Assets::add('css', 'site.css', 'site', 1); Assets::add('css', 'theme.css', 'site', 2); @param string $asset_type @param string $asset @param string $namespace @param int $priority @return void
[ "Add", "new", "asset" ]
fd30d051ceff7491d1fd6dd67913e58c451df2f8
https://github.com/flextype-components/assets/blob/fd30d051ceff7491d1fd6dd67913e58c451df2f8/Assets.php#L38-L43
24,334
flextype-components/assets
Assets.php
Assets.get
public static function get(string $asset_type, string $namespace) : array { $assets = []; // is there some registered $assets for current $namespace ? if (isset(Assets::$assets[$namespace]) && isset(Assets::$assets[$namespace][$asset_type]) && count(Assets::$assets[$namespace][$asset_type]) > 0) { // Get all $assets for given $namespace and $asset_type. $assets = Assets::$assets[$namespace][$asset_type]; // Sort $assets by priority from low to high ksort($assets); } // Return $assets return $assets; }
php
public static function get(string $asset_type, string $namespace) : array { $assets = []; // is there some registered $assets for current $namespace ? if (isset(Assets::$assets[$namespace]) && isset(Assets::$assets[$namespace][$asset_type]) && count(Assets::$assets[$namespace][$asset_type]) > 0) { // Get all $assets for given $namespace and $asset_type. $assets = Assets::$assets[$namespace][$asset_type]; // Sort $assets by priority from low to high ksort($assets); } // Return $assets return $assets; }
[ "public", "static", "function", "get", "(", "string", "$", "asset_type", ",", "string", "$", "namespace", ")", ":", "array", "{", "$", "assets", "=", "[", "]", ";", "// is there some registered $assets for current $namespace ?", "if", "(", "isset", "(", "Assets", "::", "$", "assets", "[", "$", "namespace", "]", ")", "&&", "isset", "(", "Assets", "::", "$", "assets", "[", "$", "namespace", "]", "[", "$", "asset_type", "]", ")", "&&", "count", "(", "Assets", "::", "$", "assets", "[", "$", "namespace", "]", "[", "$", "asset_type", "]", ")", ">", "0", ")", "{", "// Get all $assets for given $namespace and $asset_type.", "$", "assets", "=", "Assets", "::", "$", "assets", "[", "$", "namespace", "]", "[", "$", "asset_type", "]", ";", "// Sort $assets by priority from low to high", "ksort", "(", "$", "assets", ")", ";", "}", "// Return $assets", "return", "$", "assets", ";", "}" ]
Get assets for current namespace and asset type $css = Assets::get('css', 'site'); $js = Assets::get('js', 'site'); @param string $asset_type @param string $namespace @return array
[ "Get", "assets", "for", "current", "namespace", "and", "asset", "type" ]
fd30d051ceff7491d1fd6dd67913e58c451df2f8
https://github.com/flextype-components/assets/blob/fd30d051ceff7491d1fd6dd67913e58c451df2f8/Assets.php#L55-L73
24,335
ekuiter/feature-php
FeaturePhp/Generator/TemplateGenerator.php
TemplateGenerator.getSpecification
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\TemplateSpecification::fromArrayAndSettings($file, $settings, $artifact); }
php
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\TemplateSpecification::fromArrayAndSettings($file, $settings, $artifact); }
[ "protected", "function", "getSpecification", "(", "$", "file", ",", "$", "settings", ",", "$", "artifact", ")", "{", "return", "fphp", "\\", "Specification", "\\", "TemplateSpecification", "::", "fromArrayAndSettings", "(", "$", "file", ",", "$", "settings", ",", "$", "artifact", ")", ";", "}" ]
Returns a template specification from a plain settings array. @param array $file a plain settings array @param Settings $settings the generator's settings @param \FeaturePhp\Artifact\Artifact $artifact the currently processed artifact @return \FeaturePhp\Specification\TemplateSpecification
[ "Returns", "a", "template", "specification", "from", "a", "plain", "settings", "array", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/TemplateGenerator.php#L34-L36
24,336
Humanized/yii2-lookup
controllers/DefaultController.php
DefaultController.actionIndex
public function actionIndex($caller) { $model = new $this->modelClass(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $model = new $this->modelClass(); } if (Yii::$app->request->post('hasEditable')) { $this->_update(); return; } $searchModel = new $this->modelClass(['scenario' => \humanized\lookup\models\LookupTable::SCENARIO_SEARCH]); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'caller' => $caller, 'model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex($caller) { $model = new $this->modelClass(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $model = new $this->modelClass(); } if (Yii::$app->request->post('hasEditable')) { $this->_update(); return; } $searchModel = new $this->modelClass(['scenario' => \humanized\lookup\models\LookupTable::SCENARIO_SEARCH]); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'caller' => $caller, 'model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", "$", "caller", ")", "{", "$", "model", "=", "new", "$", "this", "->", "modelClass", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "$", "model", "=", "new", "$", "this", "->", "modelClass", "(", ")", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'hasEditable'", ")", ")", "{", "$", "this", "->", "_update", "(", ")", ";", "return", ";", "}", "$", "searchModel", "=", "new", "$", "this", "->", "modelClass", "(", "[", "'scenario'", "=>", "\\", "humanized", "\\", "lookup", "\\", "models", "\\", "LookupTable", "::", "SCENARIO_SEARCH", "]", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'caller'", "=>", "$", "caller", ",", "'model'", "=>", "$", "model", ",", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Single interface for all CRUD Operations. @return mixed
[ "Single", "interface", "for", "all", "CRUD", "Operations", "." ]
80982195cca9eb6f502e26fa1a27f72ed28ae25d
https://github.com/Humanized/yii2-lookup/blob/80982195cca9eb6f502e26fa1a27f72ed28ae25d/controllers/DefaultController.php#L50-L70
24,337
Humanized/yii2-lookup
controllers/DefaultController.php
DefaultController.actionDelete
public function actionDelete($caller, $id) { $this->findModel($id)->delete(); return $this->redirect(['index', 'caller' => $caller]); }
php
public function actionDelete($caller, $id) { $this->findModel($id)->delete(); return $this->redirect(['index', 'caller' => $caller]); }
[ "public", "function", "actionDelete", "(", "$", "caller", ",", "$", "id", ")", "{", "$", "this", "->", "findModel", "(", "$", "id", ")", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'index'", ",", "'caller'", "=>", "$", "caller", "]", ")", ";", "}" ]
Deletes an existing ArtifactType model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Deletes", "an", "existing", "ArtifactType", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
80982195cca9eb6f502e26fa1a27f72ed28ae25d
https://github.com/Humanized/yii2-lookup/blob/80982195cca9eb6f502e26fa1a27f72ed28ae25d/controllers/DefaultController.php#L110-L114
24,338
Humanized/yii2-lookup
controllers/DefaultController.php
DefaultController.findModel
protected function findModel($id) { $class = $this->modelClass; if (($model = $class::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
php
protected function findModel($id) { $class = $this->modelClass; if (($model = $class::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "$", "class", "=", "$", "this", "->", "modelClass", ";", "if", "(", "(", "$", "model", "=", "$", "class", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist.'", ")", ";", "}", "}" ]
Finds the ArtifactType model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return ArtifactType the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "ArtifactType", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
80982195cca9eb6f502e26fa1a27f72ed28ae25d
https://github.com/Humanized/yii2-lookup/blob/80982195cca9eb6f502e26fa1a27f72ed28ae25d/controllers/DefaultController.php#L123-L131
24,339
wenbinye/PhalconX
src/Db/Dialect/Mysql.php
Mysql.getColumnDefinition
public function getColumnDefinition(ColumnInterface $column) { $sql = parent::getColumnDefinition($column); if ($column instanceof Column && $column->getComment()) { $sql .= " COMMENT \"" . addcslashes($column->getComment(), '"') . "\""; } $def = $column->getDefault(); // empty value will ignore when create table if (isset($def) && in_array($def, [0, '', '0'])) { $sql .= ' DEFAULT "' . $def . '"'; } if ($column->getType() == Column::TYPE_INTEGER && $column->getSize() == 4) { $sql = preg_replace('/^INT/', 'TINYINT', $sql); } return $sql; }
php
public function getColumnDefinition(ColumnInterface $column) { $sql = parent::getColumnDefinition($column); if ($column instanceof Column && $column->getComment()) { $sql .= " COMMENT \"" . addcslashes($column->getComment(), '"') . "\""; } $def = $column->getDefault(); // empty value will ignore when create table if (isset($def) && in_array($def, [0, '', '0'])) { $sql .= ' DEFAULT "' . $def . '"'; } if ($column->getType() == Column::TYPE_INTEGER && $column->getSize() == 4) { $sql = preg_replace('/^INT/', 'TINYINT', $sql); } return $sql; }
[ "public", "function", "getColumnDefinition", "(", "ColumnInterface", "$", "column", ")", "{", "$", "sql", "=", "parent", "::", "getColumnDefinition", "(", "$", "column", ")", ";", "if", "(", "$", "column", "instanceof", "Column", "&&", "$", "column", "->", "getComment", "(", ")", ")", "{", "$", "sql", ".=", "\" COMMENT \\\"\"", ".", "addcslashes", "(", "$", "column", "->", "getComment", "(", ")", ",", "'\"'", ")", ".", "\"\\\"\"", ";", "}", "$", "def", "=", "$", "column", "->", "getDefault", "(", ")", ";", "// empty value will ignore when create table", "if", "(", "isset", "(", "$", "def", ")", "&&", "in_array", "(", "$", "def", ",", "[", "0", ",", "''", ",", "'0'", "]", ")", ")", "{", "$", "sql", ".=", "' DEFAULT \"'", ".", "$", "def", ".", "'\"'", ";", "}", "if", "(", "$", "column", "->", "getType", "(", ")", "==", "Column", "::", "TYPE_INTEGER", "&&", "$", "column", "->", "getSize", "(", ")", "==", "4", ")", "{", "$", "sql", "=", "preg_replace", "(", "'/^INT/'", ",", "'TINYINT'", ",", "$", "sql", ")", ";", "}", "return", "$", "sql", ";", "}" ]
supports comment and tinyint
[ "supports", "comment", "and", "tinyint" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Dialect/Mysql.php#L24-L40
24,340
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.addBreadcrumbs
public function addBreadcrumbs(array $breadcrumbs = []) { foreach ($breadcrumbs as $breadcrumb) { $this->addCrumb( isset($breadcrumb['name']) ? $breadcrumb['name'] : '', isset($breadcrumb['href']) ? $breadcrumb['href'] : '' ); } return $this; }
php
public function addBreadcrumbs(array $breadcrumbs = []) { foreach ($breadcrumbs as $breadcrumb) { $this->addCrumb( isset($breadcrumb['name']) ? $breadcrumb['name'] : '', isset($breadcrumb['href']) ? $breadcrumb['href'] : '' ); } return $this; }
[ "public", "function", "addBreadcrumbs", "(", "array", "$", "breadcrumbs", "=", "[", "]", ")", "{", "foreach", "(", "$", "breadcrumbs", "as", "$", "breadcrumb", ")", "{", "$", "this", "->", "addCrumb", "(", "isset", "(", "$", "breadcrumb", "[", "'name'", "]", ")", "?", "$", "breadcrumb", "[", "'name'", "]", ":", "''", ",", "isset", "(", "$", "breadcrumb", "[", "'href'", "]", ")", "?", "$", "breadcrumb", "[", "'href'", "]", ":", "''", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add the breadcrumbs to the current list. @param array $breadcrumbs The breadcrumbs to add to the list. @throws \InvalidArgumentException When the breadcrumb is not well formated. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Add", "the", "breadcrumbs", "to", "the", "current", "list", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L81-L91
24,341
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.addCrumb
public function addCrumb(string $name = '', string $href = ''): Breadcrumbs { $breadcrumb = [ 'name' => $name, 'href' => $href ]; if (!$this->validateCrumb($breadcrumb)) { throw new InvalidArgumentException( 'Breadcrumbs::addCrumb() only accepts correctly formatted arrays.' ); } $crumb = [ 'name' => $name, 'href' => $href ]; $this->breadcrumbs[] = $crumb; return $this; }
php
public function addCrumb(string $name = '', string $href = ''): Breadcrumbs { $breadcrumb = [ 'name' => $name, 'href' => $href ]; if (!$this->validateCrumb($breadcrumb)) { throw new InvalidArgumentException( 'Breadcrumbs::addCrumb() only accepts correctly formatted arrays.' ); } $crumb = [ 'name' => $name, 'href' => $href ]; $this->breadcrumbs[] = $crumb; return $this; }
[ "public", "function", "addCrumb", "(", "string", "$", "name", "=", "''", ",", "string", "$", "href", "=", "''", ")", ":", "Breadcrumbs", "{", "$", "breadcrumb", "=", "[", "'name'", "=>", "$", "name", ",", "'href'", "=>", "$", "href", "]", ";", "if", "(", "!", "$", "this", "->", "validateCrumb", "(", "$", "breadcrumb", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Breadcrumbs::addCrumb() only accepts correctly formatted arrays.'", ")", ";", "}", "$", "crumb", "=", "[", "'name'", "=>", "$", "name", ",", "'href'", "=>", "$", "href", "]", ";", "$", "this", "->", "breadcrumbs", "[", "]", "=", "$", "crumb", ";", "return", "$", "this", ";", "}" ]
Add a crumb to the internal array. @param string $name The name of the crumb. @param string $href The link of the crumb. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Add", "a", "crumb", "to", "the", "internal", "array", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L101-L121
24,342
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.firstFormated
public function firstFormated(): string { if ($this->isEmpty()) { return ''; } $crumb = reset($this->breadcrumbs); return $this->renderCrumb($crumb['name'], $crumb['href'], false, 1); }
php
public function firstFormated(): string { if ($this->isEmpty()) { return ''; } $crumb = reset($this->breadcrumbs); return $this->renderCrumb($crumb['name'], $crumb['href'], false, 1); }
[ "public", "function", "firstFormated", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "''", ";", "}", "$", "crumb", "=", "reset", "(", "$", "this", "->", "breadcrumbs", ")", ";", "return", "$", "this", "->", "renderCrumb", "(", "$", "crumb", "[", "'name'", "]", ",", "$", "crumb", "[", "'href'", "]", ",", "false", ",", "1", ")", ";", "}" ]
Get the first crumb formated as HTML. @return string
[ "Get", "the", "first", "crumb", "formated", "as", "HTML", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L195-L204
24,343
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.lastFormated
public function lastFormated(): string { if ($this->isEmpty()) { return ''; } $crumb = end($this->breadcrumbs); return $this->renderCrumb($crumb['name'], $crumb['href'], false, 1); }
php
public function lastFormated(): string { if ($this->isEmpty()) { return ''; } $crumb = end($this->breadcrumbs); return $this->renderCrumb($crumb['name'], $crumb['href'], false, 1); }
[ "public", "function", "lastFormated", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "''", ";", "}", "$", "crumb", "=", "end", "(", "$", "this", "->", "breadcrumbs", ")", ";", "return", "$", "this", "->", "renderCrumb", "(", "$", "crumb", "[", "'name'", "]", ",", "$", "crumb", "[", "'href'", "]", ",", "false", ",", "1", ")", ";", "}" ]
Get the last crumb formated as HTML. @return string
[ "Get", "the", "last", "crumb", "formated", "as", "HTML", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L225-L234
24,344
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.renderCrumb
protected function renderCrumb($name, $href, $isLast = false, $position = null): string { $positionAttribute = ''; if ($this->getOption('position')) { $positionAttribute = "data-position=\"{$position}\""; } if ($isLast) { $element = $this->getOption('listActiveElement'); $classes = $this->getClasses('listActiveElementClasses'); return "<{$element} {$positionAttribute} class=\"{$classes}\">{$name}</{$element}>"; } $element = $this->getOption('listItemElement'); $classes = $this->getClasses('listItemElementClasses'); $divider = ''; if ($this->getDivider() !== null) { $divider = $this->getDivider(); $dividerElement = $this->getOption('dividerElement'); $dividerClasses = $this->getClasses('dividerElementClasses'); $divider = "<{$dividerElement} class=\"{$dividerClasses}\">{$divider}</{$dividerElement}>"; } return "<{$element} {$positionAttribute} class=\"{$classes}\" href=\"{$href}\">{$name}</{$element}>{$divider}"; }
php
protected function renderCrumb($name, $href, $isLast = false, $position = null): string { $positionAttribute = ''; if ($this->getOption('position')) { $positionAttribute = "data-position=\"{$position}\""; } if ($isLast) { $element = $this->getOption('listActiveElement'); $classes = $this->getClasses('listActiveElementClasses'); return "<{$element} {$positionAttribute} class=\"{$classes}\">{$name}</{$element}>"; } $element = $this->getOption('listItemElement'); $classes = $this->getClasses('listItemElementClasses'); $divider = ''; if ($this->getDivider() !== null) { $divider = $this->getDivider(); $dividerElement = $this->getOption('dividerElement'); $dividerClasses = $this->getClasses('dividerElementClasses'); $divider = "<{$dividerElement} class=\"{$dividerClasses}\">{$divider}</{$dividerElement}>"; } return "<{$element} {$positionAttribute} class=\"{$classes}\" href=\"{$href}\">{$name}</{$element}>{$divider}"; }
[ "protected", "function", "renderCrumb", "(", "$", "name", ",", "$", "href", ",", "$", "isLast", "=", "false", ",", "$", "position", "=", "null", ")", ":", "string", "{", "$", "positionAttribute", "=", "''", ";", "if", "(", "$", "this", "->", "getOption", "(", "'position'", ")", ")", "{", "$", "positionAttribute", "=", "\"data-position=\\\"{$position}\\\"\"", ";", "}", "if", "(", "$", "isLast", ")", "{", "$", "element", "=", "$", "this", "->", "getOption", "(", "'listActiveElement'", ")", ";", "$", "classes", "=", "$", "this", "->", "getClasses", "(", "'listActiveElementClasses'", ")", ";", "return", "\"<{$element} {$positionAttribute} class=\\\"{$classes}\\\">{$name}</{$element}>\"", ";", "}", "$", "element", "=", "$", "this", "->", "getOption", "(", "'listItemElement'", ")", ";", "$", "classes", "=", "$", "this", "->", "getClasses", "(", "'listItemElementClasses'", ")", ";", "$", "divider", "=", "''", ";", "if", "(", "$", "this", "->", "getDivider", "(", ")", "!==", "null", ")", "{", "$", "divider", "=", "$", "this", "->", "getDivider", "(", ")", ";", "$", "dividerElement", "=", "$", "this", "->", "getOption", "(", "'dividerElement'", ")", ";", "$", "dividerClasses", "=", "$", "this", "->", "getClasses", "(", "'dividerElementClasses'", ")", ";", "$", "divider", "=", "\"<{$dividerElement} class=\\\"{$dividerClasses}\\\">{$divider}</{$dividerElement}>\"", ";", "}", "return", "\"<{$element} {$positionAttribute} class=\\\"{$classes}\\\" href=\\\"{$href}\\\">{$name}</{$element}>{$divider}\"", ";", "}" ]
Render a crumb. @param string $name The text/HTML to render within the element. @param string $href The link of the crumb. @param bool $isLast Whether the crumb is the last item. @param number $position The current position of the crumb. @return string
[ "Render", "a", "crumb", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L268-L295
24,345
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.getClasses
protected function getClasses(string $option, string $separator = ' '): string { return implode($separator, $this->getOption($option)); }
php
protected function getClasses(string $option, string $separator = ' '): string { return implode($separator, $this->getOption($option)); }
[ "protected", "function", "getClasses", "(", "string", "$", "option", ",", "string", "$", "separator", "=", "' '", ")", ":", "string", "{", "return", "implode", "(", "$", "separator", ",", "$", "this", "->", "getOption", "(", "$", "option", ")", ")", ";", "}" ]
Get the imploded classes for the given option. @param string $option The option where to get the classes from. @param string $separator The separator used by the implode function. @return string
[ "Get", "the", "imploded", "classes", "for", "the", "given", "option", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L305-L308
24,346
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.renderCrumbs
protected function renderCrumbs(): string { end($this->breadcrumbs); $lastKey = key($this->breadcrumbs); $output = ''; $position = 1; foreach ($this->breadcrumbs as $key => $crumb) { $isLast = ($lastKey === $key); $href = $crumb['href']; // Add a slash when the URL is relative and does not contain a slash at the start. if (!preg_match('#^https?://.*#', $href) && mb_substr($href, 0, 1) !== '/') { $href = "/{$href}"; } $output .= $this->renderCrumb($crumb['name'], $href, $isLast, $position); $position++; } return $output; }
php
protected function renderCrumbs(): string { end($this->breadcrumbs); $lastKey = key($this->breadcrumbs); $output = ''; $position = 1; foreach ($this->breadcrumbs as $key => $crumb) { $isLast = ($lastKey === $key); $href = $crumb['href']; // Add a slash when the URL is relative and does not contain a slash at the start. if (!preg_match('#^https?://.*#', $href) && mb_substr($href, 0, 1) !== '/') { $href = "/{$href}"; } $output .= $this->renderCrumb($crumb['name'], $href, $isLast, $position); $position++; } return $output; }
[ "protected", "function", "renderCrumbs", "(", ")", ":", "string", "{", "end", "(", "$", "this", "->", "breadcrumbs", ")", ";", "$", "lastKey", "=", "key", "(", "$", "this", "->", "breadcrumbs", ")", ";", "$", "output", "=", "''", ";", "$", "position", "=", "1", ";", "foreach", "(", "$", "this", "->", "breadcrumbs", "as", "$", "key", "=>", "$", "crumb", ")", "{", "$", "isLast", "=", "(", "$", "lastKey", "===", "$", "key", ")", ";", "$", "href", "=", "$", "crumb", "[", "'href'", "]", ";", "// Add a slash when the URL is relative and does not contain a slash at the start.", "if", "(", "!", "preg_match", "(", "'#^https?://.*#'", ",", "$", "href", ")", "&&", "mb_substr", "(", "$", "href", ",", "0", ",", "1", ")", "!==", "'/'", ")", "{", "$", "href", "=", "\"/{$href}\"", ";", "}", "$", "output", ".=", "$", "this", "->", "renderCrumb", "(", "$", "crumb", "[", "'name'", "]", ",", "$", "href", ",", "$", "isLast", ",", "$", "position", ")", ";", "$", "position", "++", ";", "}", "return", "$", "output", ";", "}" ]
Renders the crumbs. @return string
[ "Renders", "the", "crumbs", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L315-L339
24,347
Xety/Breadcrumbs
src/Breadcrumbs.php
Breadcrumbs.render
public function render(): string { if (empty($this->breadcrumbs)) { return ''; } $classes = $this->getClasses('listElementClasses'); $element = $this->getOption('listElement'); return "<{$element} class=\"{$classes}\">" . $this->renderCrumbs() . "</{$element}>"; }
php
public function render(): string { if (empty($this->breadcrumbs)) { return ''; } $classes = $this->getClasses('listElementClasses'); $element = $this->getOption('listElement'); return "<{$element} class=\"{$classes}\">" . $this->renderCrumbs() . "</{$element}>"; }
[ "public", "function", "render", "(", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "this", "->", "breadcrumbs", ")", ")", "{", "return", "''", ";", "}", "$", "classes", "=", "$", "this", "->", "getClasses", "(", "'listElementClasses'", ")", ";", "$", "element", "=", "$", "this", "->", "getOption", "(", "'listElement'", ")", ";", "return", "\"<{$element} class=\\\"{$classes}\\\">\"", ".", "$", "this", "->", "renderCrumbs", "(", ")", ".", "\"</{$element}>\"", ";", "}" ]
Renders the complete breadcrumbs into HTML. @return string
[ "Renders", "the", "complete", "breadcrumbs", "into", "HTML", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/Breadcrumbs.php#L346-L356
24,348
qlake/framework
src/Qlake/Http/Header.php
Header.set
public function set($name, $value) { $this->data[$this->normalizeKey($name)] = $value; return $this; }
php
public function set($name, $value) { $this->data[$this->normalizeKey($name)] = $value; return $this; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "data", "[", "$", "this", "->", "normalizeKey", "(", "$", "name", ")", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a HTTP header. @param string $name @param string $value @return Qlake\Http\Header
[ "Set", "a", "HTTP", "header", "." ]
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Http/Header.php#L48-L53
24,349
qlake/framework
src/Qlake/Http/Header.php
Header.normalizeKey
protected function normalizeKey($name) { $name = strtolower($name); $name = str_replace(array('-', '_'), ' ', $name); $name = preg_replace('#^http #', '', $name); $name = ucwords($name); $name = str_replace(' ', '-', $name); return $name; }
php
protected function normalizeKey($name) { $name = strtolower($name); $name = str_replace(array('-', '_'), ' ', $name); $name = preg_replace('#^http #', '', $name); $name = ucwords($name); $name = str_replace(' ', '-', $name); return $name; }
[ "protected", "function", "normalizeKey", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "name", "=", "str_replace", "(", "array", "(", "'-'", ",", "'_'", ")", ",", "' '", ",", "$", "name", ")", ";", "$", "name", "=", "preg_replace", "(", "'#^http #'", ",", "''", ",", "$", "name", ")", ";", "$", "name", "=", "ucwords", "(", "$", "name", ")", ";", "$", "name", "=", "str_replace", "(", "' '", ",", "'-'", ",", "$", "name", ")", ";", "return", "$", "name", ";", "}" ]
Normalize HTTP header name. @param string $name @return string
[ "Normalize", "HTTP", "header", "name", "." ]
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Http/Header.php#L137-L146
24,350
webandco/neos-wireframe
Classes/Fusion/WireframeContentImplementation.php
WireframeContentImplementation.evaluate
public function evaluate() { $httpRequest = Request::createFromEnvironment(); /** @var UserInterfaceMode $mode */ $mode = $this->interfaceRenderModeService->findModeByCurrentUser(); /** @var integer $renderMode */ $renderMode = 0; switch (true) { case $mode->getName() === 'wireframe' || $httpRequest->getArgument('wireframeMode') == '1' : $renderMode = 1; break; case $httpRequest->getArgument('wireframeMode') == '2' : $renderMode = 2; break; } return $renderMode; }
php
public function evaluate() { $httpRequest = Request::createFromEnvironment(); /** @var UserInterfaceMode $mode */ $mode = $this->interfaceRenderModeService->findModeByCurrentUser(); /** @var integer $renderMode */ $renderMode = 0; switch (true) { case $mode->getName() === 'wireframe' || $httpRequest->getArgument('wireframeMode') == '1' : $renderMode = 1; break; case $httpRequest->getArgument('wireframeMode') == '2' : $renderMode = 2; break; } return $renderMode; }
[ "public", "function", "evaluate", "(", ")", "{", "$", "httpRequest", "=", "Request", "::", "createFromEnvironment", "(", ")", ";", "/** @var UserInterfaceMode $mode */", "$", "mode", "=", "$", "this", "->", "interfaceRenderModeService", "->", "findModeByCurrentUser", "(", ")", ";", "/** @var integer $renderMode */", "$", "renderMode", "=", "0", ";", "switch", "(", "true", ")", "{", "case", "$", "mode", "->", "getName", "(", ")", "===", "'wireframe'", "||", "$", "httpRequest", "->", "getArgument", "(", "'wireframeMode'", ")", "==", "'1'", ":", "$", "renderMode", "=", "1", ";", "break", ";", "case", "$", "httpRequest", "->", "getArgument", "(", "'wireframeMode'", ")", "==", "'2'", ":", "$", "renderMode", "=", "2", ";", "break", ";", "}", "return", "$", "renderMode", ";", "}" ]
Evaluate wireframe rendering mode @return integer
[ "Evaluate", "wireframe", "rendering", "mode" ]
b1dfd9bedee80001a9a0cf0f483d0261633d12cb
https://github.com/webandco/neos-wireframe/blob/b1dfd9bedee80001a9a0cf0f483d0261633d12cb/Classes/Fusion/WireframeContentImplementation.php#L30-L51
24,351
SporkCode/Spork
src/Mvc/Listener/Limit/Storage/Db.php
Db.setServiceLocator
public function setServiceLocator(ServiceLocatorInterface $serviceManager) { if (!$this->dbAdapter instanceof DbAdapter) { $this->dbAdapter = $serviceManager->getServiceLocator()->get($this->dbAdapter); } }
php
public function setServiceLocator(ServiceLocatorInterface $serviceManager) { if (!$this->dbAdapter instanceof DbAdapter) { $this->dbAdapter = $serviceManager->getServiceLocator()->get($this->dbAdapter); } }
[ "public", "function", "setServiceLocator", "(", "ServiceLocatorInterface", "$", "serviceManager", ")", "{", "if", "(", "!", "$", "this", "->", "dbAdapter", "instanceof", "DbAdapter", ")", "{", "$", "this", "->", "dbAdapter", "=", "$", "serviceManager", "->", "getServiceLocator", "(", ")", "->", "get", "(", "$", "this", "->", "dbAdapter", ")", ";", "}", "}" ]
Use Service Manager to inject database adapter @see \Zend\ServiceManager\ServiceLocatorAwareInterface::setServiceLocator() @param ServiceLocatorInterface $serviceManager
[ "Use", "Service", "Manager", "to", "inject", "database", "adapter" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Storage/Db.php#L114-L119
24,352
SporkCode/Spork
src/Mvc/Listener/Limit/Storage/Db.php
Db.getCleanInterval
public function getCleanInterval() { if (!$this->cleanInterval instanceof DateInterval) { $this->cleanInterval = new DateInterval($this->cleanInterval); } return $this->cleanInterval; }
php
public function getCleanInterval() { if (!$this->cleanInterval instanceof DateInterval) { $this->cleanInterval = new DateInterval($this->cleanInterval); } return $this->cleanInterval; }
[ "public", "function", "getCleanInterval", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cleanInterval", "instanceof", "DateInterval", ")", "{", "$", "this", "->", "cleanInterval", "=", "new", "DateInterval", "(", "$", "this", "->", "cleanInterval", ")", ";", "}", "return", "$", "this", "->", "cleanInterval", ";", "}" ]
Get clean interval @return \Spork\DateTime\DateInterval
[ "Get", "clean", "interval" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Storage/Db.php#L157-L163
24,353
SporkCode/Spork
src/Mvc/Listener/Limit/Storage/Db.php
Db.increment
public function increment($ip, $type) { $this->assertReady(); $sql = sprintf("INSERT INTO %s SET %s=:type, %s=:ip", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->typeColumn), $this->dbAdapter->platform->quoteIdentifier($this->ipColumn)); $parameters = array( 'type' => $type, 'ip' => $ip, ); $this->dbAdapter->query($sql, $parameters); }
php
public function increment($ip, $type) { $this->assertReady(); $sql = sprintf("INSERT INTO %s SET %s=:type, %s=:ip", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->typeColumn), $this->dbAdapter->platform->quoteIdentifier($this->ipColumn)); $parameters = array( 'type' => $type, 'ip' => $ip, ); $this->dbAdapter->query($sql, $parameters); }
[ "public", "function", "increment", "(", "$", "ip", ",", "$", "type", ")", "{", "$", "this", "->", "assertReady", "(", ")", ";", "$", "sql", "=", "sprintf", "(", "\"INSERT INTO %s SET %s=:type, %s=:ip\"", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "table", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "typeColumn", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "ipColumn", ")", ")", ";", "$", "parameters", "=", "array", "(", "'type'", "=>", "$", "type", ",", "'ip'", "=>", "$", "ip", ",", ")", ";", "$", "this", "->", "dbAdapter", "->", "query", "(", "$", "sql", ",", "$", "parameters", ")", ";", "}" ]
Add record to database @see \Spork\Mvc\Listener\Limit\Storage\StorageInterface::increment() @param unknown $ip @param unknown $type
[ "Add", "record", "to", "database" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Storage/Db.php#L292-L307
24,354
SporkCode/Spork
src/Mvc/Listener/Limit/Storage/Db.php
Db.check
public function check($ip, Limit $limit) { $this->assertReady(); if ($this->cleanOnCheck) { $this->clean(); } $sql = sprintf("SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->ipColumn), $this->dbAdapter->platform->quoteIdentifier($this->typeColumn), $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn), $limit->getInterval()->toSeconds()); $parameters = array( 'ip' => $ip, 'type' => $limit->getName(), ); $result = $this->dbAdapter->query($sql, $parameters); $count = $result->current()->count; return $count >= $limit->getLimit(); }
php
public function check($ip, Limit $limit) { $this->assertReady(); if ($this->cleanOnCheck) { $this->clean(); } $sql = sprintf("SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->ipColumn), $this->dbAdapter->platform->quoteIdentifier($this->typeColumn), $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn), $limit->getInterval()->toSeconds()); $parameters = array( 'ip' => $ip, 'type' => $limit->getName(), ); $result = $this->dbAdapter->query($sql, $parameters); $count = $result->current()->count; return $count >= $limit->getLimit(); }
[ "public", "function", "check", "(", "$", "ip", ",", "Limit", "$", "limit", ")", "{", "$", "this", "->", "assertReady", "(", ")", ";", "if", "(", "$", "this", "->", "cleanOnCheck", ")", "{", "$", "this", "->", "clean", "(", ")", ";", "}", "$", "sql", "=", "sprintf", "(", "\"SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND\"", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "table", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "ipColumn", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "typeColumn", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "timestampColumn", ")", ",", "$", "limit", "->", "getInterval", "(", ")", "->", "toSeconds", "(", ")", ")", ";", "$", "parameters", "=", "array", "(", "'ip'", "=>", "$", "ip", ",", "'type'", "=>", "$", "limit", "->", "getName", "(", ")", ",", ")", ";", "$", "result", "=", "$", "this", "->", "dbAdapter", "->", "query", "(", "$", "sql", ",", "$", "parameters", ")", ";", "$", "count", "=", "$", "result", "->", "current", "(", ")", "->", "count", ";", "return", "$", "count", ">=", "$", "limit", "->", "getLimit", "(", ")", ";", "}" ]
Check if the number or records in the database exceeds the set limit @see \Spork\Mvc\Listener\Limit\Storage\StorageInterface::check() @param string $ip @param Limit $limit @return boolean
[ "Check", "if", "the", "number", "or", "records", "in", "the", "database", "exceeds", "the", "set", "limit" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Storage/Db.php#L317-L340
24,355
SporkCode/Spork
src/Mvc/Listener/Limit/Storage/Db.php
Db.clean
public function clean() { $this->assertReady(); $sql = sprintf("DELETE FROM %s WHERE %s < NOW() - INTERVAL %d SECOND", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn), $this->getCleanInterval()->toSeconds()); $this->dbAdapter->query($sql, DbAdapter::QUERY_MODE_EXECUTE); }
php
public function clean() { $this->assertReady(); $sql = sprintf("DELETE FROM %s WHERE %s < NOW() - INTERVAL %d SECOND", $this->dbAdapter->platform->quoteIdentifier($this->table), $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn), $this->getCleanInterval()->toSeconds()); $this->dbAdapter->query($sql, DbAdapter::QUERY_MODE_EXECUTE); }
[ "public", "function", "clean", "(", ")", "{", "$", "this", "->", "assertReady", "(", ")", ";", "$", "sql", "=", "sprintf", "(", "\"DELETE FROM %s WHERE %s < NOW() - INTERVAL %d SECOND\"", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "table", ")", ",", "$", "this", "->", "dbAdapter", "->", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "timestampColumn", ")", ",", "$", "this", "->", "getCleanInterval", "(", ")", "->", "toSeconds", "(", ")", ")", ";", "$", "this", "->", "dbAdapter", "->", "query", "(", "$", "sql", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "}" ]
Remove expired records from database @see \Spork\Mvc\Listener\Limit\Storage\StorageInterface::clean()
[ "Remove", "expired", "records", "from", "database" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/Limit/Storage/Db.php#L347-L357
24,356
newmythmedia/di
src/DI.php
DI.register
public function register($alias, $class) { $alias = strtolower($alias); if (array_key_exists($alias, $this->instances)) { throw new \RuntimeException('You cannot register a provider when an instance of that class has already been created.'); } $this->services[$alias] = $class; return $this; }
php
public function register($alias, $class) { $alias = strtolower($alias); if (array_key_exists($alias, $this->instances)) { throw new \RuntimeException('You cannot register a provider when an instance of that class has already been created.'); } $this->services[$alias] = $class; return $this; }
[ "public", "function", "register", "(", "$", "alias", ",", "$", "class", ")", "{", "$", "alias", "=", "strtolower", "(", "$", "alias", ")", ";", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "instances", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'You cannot register a provider when an instance of that class has already been created.'", ")", ";", "}", "$", "this", "->", "services", "[", "$", "alias", "]", "=", "$", "class", ";", "return", "$", "this", ";", "}" ]
Registers a specific class name with the corresponding alias for the dependency inversion. @param $name @param $class @return $this
[ "Registers", "a", "specific", "class", "name", "with", "the", "corresponding", "alias", "for", "the", "dependency", "inversion", "." ]
bc7397ea447de6a2d7564d7c95abf03f15e7756a
https://github.com/newmythmedia/di/blob/bc7397ea447de6a2d7564d7c95abf03f15e7756a/src/DI.php#L125-L137
24,357
newmythmedia/di
src/DI.php
DI.unregister
public function unregister($alias, $remove_instances=false) { $alias = strtolower($alias); if ($remove_instances && array_key_exists($alias, $this->instances)) { $this->instances[$alias] = null; unset($this->instances[$alias]); } unset($this->services[$alias]); return $this; }
php
public function unregister($alias, $remove_instances=false) { $alias = strtolower($alias); if ($remove_instances && array_key_exists($alias, $this->instances)) { $this->instances[$alias] = null; unset($this->instances[$alias]); } unset($this->services[$alias]); return $this; }
[ "public", "function", "unregister", "(", "$", "alias", ",", "$", "remove_instances", "=", "false", ")", "{", "$", "alias", "=", "strtolower", "(", "$", "alias", ")", ";", "if", "(", "$", "remove_instances", "&&", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "instances", ")", ")", "{", "$", "this", "->", "instances", "[", "$", "alias", "]", "=", "null", ";", "unset", "(", "$", "this", "->", "instances", "[", "$", "alias", "]", ")", ";", "}", "unset", "(", "$", "this", "->", "services", "[", "$", "alias", "]", ")", ";", "return", "$", "this", ";", "}" ]
Unregisters a single service provider. If an instance of that provider has already been created, it will be destroyed. @param $alias @return $this
[ "Unregisters", "a", "single", "service", "provider", ".", "If", "an", "instance", "of", "that", "provider", "has", "already", "been", "created", "it", "will", "be", "destroyed", "." ]
bc7397ea447de6a2d7564d7c95abf03f15e7756a
https://github.com/newmythmedia/di/blob/bc7397ea447de6a2d7564d7c95abf03f15e7756a/src/DI.php#L149-L162
24,358
newmythmedia/di
src/DI.php
DI.saveInstance
public function saveInstance($alias, &$class) { $alias = strtolower($alias); if (array_key_exists($alias, $this->instances)) { unset($this->instances[$alias]); } $this->instances[$alias] = $class; return $this; }
php
public function saveInstance($alias, &$class) { $alias = strtolower($alias); if (array_key_exists($alias, $this->instances)) { unset($this->instances[$alias]); } $this->instances[$alias] = $class; return $this; }
[ "public", "function", "saveInstance", "(", "$", "alias", ",", "&", "$", "class", ")", "{", "$", "alias", "=", "strtolower", "(", "$", "alias", ")", ";", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "instances", ")", ")", "{", "unset", "(", "$", "this", "->", "instances", "[", "$", "alias", "]", ")", ";", "}", "$", "this", "->", "instances", "[", "$", "alias", "]", "=", "$", "class", ";", "return", "$", "this", ";", "}" ]
Registers an instantiated class as a Service Provider. todo Register savedInstance class with the services array. @param $alias @param $class @return $this
[ "Registers", "an", "instantiated", "class", "as", "a", "Service", "Provider", "." ]
bc7397ea447de6a2d7564d7c95abf03f15e7756a
https://github.com/newmythmedia/di/blob/bc7397ea447de6a2d7564d7c95abf03f15e7756a/src/DI.php#L176-L188
24,359
newmythmedia/di
src/DI.php
DI.single
public function single($alias) { $alias = strtolower($alias); // Return the existing object if it exists. if (! empty($this->instances[$alias]) && is_object($this->instances[$alias])) { return $this->instances[$alias]; } // Die if we don't know what class to use. if (empty($this->services[$alias])) { throw new \InvalidArgumentException('Unable to find class with alias: '. $alias); } $instance = $this->make($alias, true); $this->instances[$alias] =& $instance; return $this->instances[$alias]; }
php
public function single($alias) { $alias = strtolower($alias); // Return the existing object if it exists. if (! empty($this->instances[$alias]) && is_object($this->instances[$alias])) { return $this->instances[$alias]; } // Die if we don't know what class to use. if (empty($this->services[$alias])) { throw new \InvalidArgumentException('Unable to find class with alias: '. $alias); } $instance = $this->make($alias, true); $this->instances[$alias] =& $instance; return $this->instances[$alias]; }
[ "public", "function", "single", "(", "$", "alias", ")", "{", "$", "alias", "=", "strtolower", "(", "$", "alias", ")", ";", "// Return the existing object if it exists.", "if", "(", "!", "empty", "(", "$", "this", "->", "instances", "[", "$", "alias", "]", ")", "&&", "is_object", "(", "$", "this", "->", "instances", "[", "$", "alias", "]", ")", ")", "{", "return", "$", "this", "->", "instances", "[", "$", "alias", "]", ";", "}", "// Die if we don't know what class to use.", "if", "(", "empty", "(", "$", "this", "->", "services", "[", "$", "alias", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unable to find class with alias: '", ".", "$", "alias", ")", ";", "}", "$", "instance", "=", "$", "this", "->", "make", "(", "$", "alias", ",", "true", ")", ";", "$", "this", "->", "instances", "[", "$", "alias", "]", "=", "&", "$", "instance", ";", "return", "$", "this", "->", "instances", "[", "$", "alias", "]", ";", "}" ]
Allows you to create a new instance of an object as a singleton, passing in arguments. @param $alias @return mixed
[ "Allows", "you", "to", "create", "a", "new", "instance", "of", "an", "object", "as", "a", "singleton", "passing", "in", "arguments", "." ]
bc7397ea447de6a2d7564d7c95abf03f15e7756a
https://github.com/newmythmedia/di/blob/bc7397ea447de6a2d7564d7c95abf03f15e7756a/src/DI.php#L242-L263
24,360
newmythmedia/di
src/DI.php
DI.getParams
protected function getParams(\ReflectionMethod $mirror, $single=false) { $params = []; foreach ($mirror->getParameters() as $param) { $alias = strtolower($param->name); // Is this a mapped alias? if (! empty($this->services[$alias])) { $params[] = $single ? $this->single($alias) : $this->make($alias); continue; } // Is this a normal class we can give them? $class = $param->getClass()->name; if (class_exists($class)) { $params[] = new $class(); } $params[] = null; } return $params; }
php
protected function getParams(\ReflectionMethod $mirror, $single=false) { $params = []; foreach ($mirror->getParameters() as $param) { $alias = strtolower($param->name); // Is this a mapped alias? if (! empty($this->services[$alias])) { $params[] = $single ? $this->single($alias) : $this->make($alias); continue; } // Is this a normal class we can give them? $class = $param->getClass()->name; if (class_exists($class)) { $params[] = new $class(); } $params[] = null; } return $params; }
[ "protected", "function", "getParams", "(", "\\", "ReflectionMethod", "$", "mirror", ",", "$", "single", "=", "false", ")", "{", "$", "params", "=", "[", "]", ";", "foreach", "(", "$", "mirror", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "alias", "=", "strtolower", "(", "$", "param", "->", "name", ")", ";", "// Is this a mapped alias?", "if", "(", "!", "empty", "(", "$", "this", "->", "services", "[", "$", "alias", "]", ")", ")", "{", "$", "params", "[", "]", "=", "$", "single", "?", "$", "this", "->", "single", "(", "$", "alias", ")", ":", "$", "this", "->", "make", "(", "$", "alias", ")", ";", "continue", ";", "}", "// Is this a normal class we can give them?", "$", "class", "=", "$", "param", "->", "getClass", "(", ")", "->", "name", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "params", "[", "]", "=", "new", "$", "class", "(", ")", ";", "}", "$", "params", "[", "]", "=", "null", ";", "}", "return", "$", "params", ";", "}" ]
Given a reflection method, will get or create an array of objects ready to be inserted into the class' constructor. If $single is true, will return a singleton version of dependencies else will create a new class. @param \ReflectionMethod $mirror @param bool $single @return array
[ "Given", "a", "reflection", "method", "will", "get", "or", "create", "an", "array", "of", "objects", "ready", "to", "be", "inserted", "into", "the", "class", "constructor", "." ]
bc7397ea447de6a2d7564d7c95abf03f15e7756a
https://github.com/newmythmedia/di/blob/bc7397ea447de6a2d7564d7c95abf03f15e7756a/src/DI.php#L406-L433
24,361
SporkCode/Spork
src/CSS/AbstractCompiler.php
AbstractCompiler.compile
public function compile($source, $destination = null, $include = null) { $include = array_merge($this->includes, (array) $include); $useCache = null == $destination && null !== $this->cache; if ($useCache) { if ($this->cache->hasItem($source)) { return $this->cache->getItem($source); } } $arguments = implode(' ', array_map('escapeshellarg', $this->arguments)); $arguments .= ' ' . $this->getCommandArguments($source, $destination, $include); $command = "{$this->compiler} $arguments" . ' 2>&1'; $result = exec($command, $output, $exitCode); if ($exitCode != 0) { throw new \Exception(sprintf('Error compiling CSS "%s": %s', $source, implode(PHP_EOL, $output))); } $css = implode(PHP_EOL, $output); if ($useCache) { $this->cache->setItem($source, $css); } return $css; }
php
public function compile($source, $destination = null, $include = null) { $include = array_merge($this->includes, (array) $include); $useCache = null == $destination && null !== $this->cache; if ($useCache) { if ($this->cache->hasItem($source)) { return $this->cache->getItem($source); } } $arguments = implode(' ', array_map('escapeshellarg', $this->arguments)); $arguments .= ' ' . $this->getCommandArguments($source, $destination, $include); $command = "{$this->compiler} $arguments" . ' 2>&1'; $result = exec($command, $output, $exitCode); if ($exitCode != 0) { throw new \Exception(sprintf('Error compiling CSS "%s": %s', $source, implode(PHP_EOL, $output))); } $css = implode(PHP_EOL, $output); if ($useCache) { $this->cache->setItem($source, $css); } return $css; }
[ "public", "function", "compile", "(", "$", "source", ",", "$", "destination", "=", "null", ",", "$", "include", "=", "null", ")", "{", "$", "include", "=", "array_merge", "(", "$", "this", "->", "includes", ",", "(", "array", ")", "$", "include", ")", ";", "$", "useCache", "=", "null", "==", "$", "destination", "&&", "null", "!==", "$", "this", "->", "cache", ";", "if", "(", "$", "useCache", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "hasItem", "(", "$", "source", ")", ")", "{", "return", "$", "this", "->", "cache", "->", "getItem", "(", "$", "source", ")", ";", "}", "}", "$", "arguments", "=", "implode", "(", "' '", ",", "array_map", "(", "'escapeshellarg'", ",", "$", "this", "->", "arguments", ")", ")", ";", "$", "arguments", ".=", "' '", ".", "$", "this", "->", "getCommandArguments", "(", "$", "source", ",", "$", "destination", ",", "$", "include", ")", ";", "$", "command", "=", "\"{$this->compiler} $arguments\"", ".", "' 2>&1'", ";", "$", "result", "=", "exec", "(", "$", "command", ",", "$", "output", ",", "$", "exitCode", ")", ";", "if", "(", "$", "exitCode", "!=", "0", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Error compiling CSS \"%s\": %s'", ",", "$", "source", ",", "implode", "(", "PHP_EOL", ",", "$", "output", ")", ")", ")", ";", "}", "$", "css", "=", "implode", "(", "PHP_EOL", ",", "$", "output", ")", ";", "if", "(", "$", "useCache", ")", "{", "$", "this", "->", "cache", "->", "setItem", "(", "$", "source", ",", "$", "css", ")", ";", "}", "return", "$", "css", ";", "}" ]
Compile to file. If destination is not specified return CSS. @param string $source @param string|null $destination @param array|string|null $include Include path(s) to use @throws \Exception on compilation error @return string Compiled CSS
[ "Compile", "to", "file", ".", "If", "destination", "is", "not", "specified", "return", "CSS", "." ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/AbstractCompiler.php#L91-L122
24,362
SporkCode/Spork
src/CSS/AbstractCompiler.php
AbstractCompiler.setCache
public function setCache($cache) { if (is_string($cache) && class_exists($cache)) { $cache = new $cache(); } if (is_array($cache)) { $cache = StorageFactory::factory($cache); } if (!$cache instanceof AbstractCacheAdapter) { throw new \Exception('Invalid Cache'); } $this->cache = $cache; }
php
public function setCache($cache) { if (is_string($cache) && class_exists($cache)) { $cache = new $cache(); } if (is_array($cache)) { $cache = StorageFactory::factory($cache); } if (!$cache instanceof AbstractCacheAdapter) { throw new \Exception('Invalid Cache'); } $this->cache = $cache; }
[ "public", "function", "setCache", "(", "$", "cache", ")", "{", "if", "(", "is_string", "(", "$", "cache", ")", "&&", "class_exists", "(", "$", "cache", ")", ")", "{", "$", "cache", "=", "new", "$", "cache", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "cache", ")", ")", "{", "$", "cache", "=", "StorageFactory", "::", "factory", "(", "$", "cache", ")", ";", "}", "if", "(", "!", "$", "cache", "instanceof", "AbstractCacheAdapter", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid Cache'", ")", ";", "}", "$", "this", "->", "cache", "=", "$", "cache", ";", "}" ]
Set cache for CSS Preprocessor Cache parameter can be an instance of \Zend\Cache\Storage\Adapter\AbstractAdapter, the name of a cache adapter class or an array of options to be passed to AbstractAdapter::factory() @param string|array|\Zend\Cache\Storage\Adapter\AbstractAdapter $cache @throws \Exception on invalid cache
[ "Set", "cache", "for", "CSS", "Preprocessor" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/AbstractCompiler.php#L162-L177
24,363
SporkCode/Spork
src/CSS/AbstractCompiler.php
AbstractCompiler.getOptions
protected function getOptions(ServiceLocatorInterface $services, $key) { $appConfig = $services->get('config'); $options = array_key_exists($key, $appConfig) ? $appConfig[$key] : array(); if (array_key_exists('cache', $options) && is_string($options['cache']) && $services->has($options['cache'])) { $options['cache'] = $services->get($options['cache']); } return $options; }
php
protected function getOptions(ServiceLocatorInterface $services, $key) { $appConfig = $services->get('config'); $options = array_key_exists($key, $appConfig) ? $appConfig[$key] : array(); if (array_key_exists('cache', $options) && is_string($options['cache']) && $services->has($options['cache'])) { $options['cache'] = $services->get($options['cache']); } return $options; }
[ "protected", "function", "getOptions", "(", "ServiceLocatorInterface", "$", "services", ",", "$", "key", ")", "{", "$", "appConfig", "=", "$", "services", "->", "get", "(", "'config'", ")", ";", "$", "options", "=", "array_key_exists", "(", "$", "key", ",", "$", "appConfig", ")", "?", "$", "appConfig", "[", "$", "key", "]", ":", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "'cache'", ",", "$", "options", ")", "&&", "is_string", "(", "$", "options", "[", "'cache'", "]", ")", "&&", "$", "services", "->", "has", "(", "$", "options", "[", "'cache'", "]", ")", ")", "{", "$", "options", "[", "'cache'", "]", "=", "$", "services", "->", "get", "(", "$", "options", "[", "'cache'", "]", ")", ";", "}", "return", "$", "options", ";", "}" ]
Get options from application configuration @param ServiceLocatorInterface $services @param string $key @return array
[ "Get", "options", "from", "application", "configuration" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/AbstractCompiler.php#L322-L332
24,364
cartalyst/assetic-filters
src/UriRewriteFilter.php
UriRewriteFilter.realPath
protected function realPath($path) { if (php_sapi_name() == 'cli' && ! $path) { $path = $_SERVER['DOCUMENT_ROOT']; } if ($realPath = realpath($path)) { $path = $realPath; } return rtrim($path, '/\\'); }
php
protected function realPath($path) { if (php_sapi_name() == 'cli' && ! $path) { $path = $_SERVER['DOCUMENT_ROOT']; } if ($realPath = realpath($path)) { $path = $realPath; } return rtrim($path, '/\\'); }
[ "protected", "function", "realPath", "(", "$", "path", ")", "{", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", "&&", "!", "$", "path", ")", "{", "$", "path", "=", "$", "_SERVER", "[", "'DOCUMENT_ROOT'", "]", ";", "}", "if", "(", "$", "realPath", "=", "realpath", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "realPath", ";", "}", "return", "rtrim", "(", "$", "path", ",", "'/\\\\'", ")", ";", "}" ]
Takes a path and transforms it to a real path. @param string $path @return string
[ "Takes", "a", "path", "and", "transforms", "it", "to", "a", "real", "path", "." ]
5e26328f7e46937bf1daa0bee2f744ab3493f471
https://github.com/cartalyst/assetic-filters/blob/5e26328f7e46937bf1daa0bee2f744ab3493f471/src/UriRewriteFilter.php#L165-L176
24,365
kenphp/ken
src/Log/Logger.php
Logger.applyConfig
private function applyConfig($config) { try { if (isset($config['enabledLevels'])) { $this->setEnabledLevels($config['enabledLevels']); } else { $this->setEnabledLevels(['error', 'warning']); } if (isset($config['flushIntervals'])) { $this->setFlushIntervals($config['flushIntervals']); } else { $this->setFlushIntervals(100); } if (isset($config['targets'])) { foreach ($config['targets'] as $key => $value) { if (isset($value['class'])) { $className = $value['class']; $this->_targets[$key] = $className::build($value); } } } } catch (InvalidConfigurationException $e) { $configStr = print_r($config, true); error_log('Invalid Configuration for Logger Component. '.PHP_EOL.$configStr); } }
php
private function applyConfig($config) { try { if (isset($config['enabledLevels'])) { $this->setEnabledLevels($config['enabledLevels']); } else { $this->setEnabledLevels(['error', 'warning']); } if (isset($config['flushIntervals'])) { $this->setFlushIntervals($config['flushIntervals']); } else { $this->setFlushIntervals(100); } if (isset($config['targets'])) { foreach ($config['targets'] as $key => $value) { if (isset($value['class'])) { $className = $value['class']; $this->_targets[$key] = $className::build($value); } } } } catch (InvalidConfigurationException $e) { $configStr = print_r($config, true); error_log('Invalid Configuration for Logger Component. '.PHP_EOL.$configStr); } }
[ "private", "function", "applyConfig", "(", "$", "config", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "config", "[", "'enabledLevels'", "]", ")", ")", "{", "$", "this", "->", "setEnabledLevels", "(", "$", "config", "[", "'enabledLevels'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "setEnabledLevels", "(", "[", "'error'", ",", "'warning'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'flushIntervals'", "]", ")", ")", "{", "$", "this", "->", "setFlushIntervals", "(", "$", "config", "[", "'flushIntervals'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "setFlushIntervals", "(", "100", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'targets'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'targets'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'class'", "]", ")", ")", "{", "$", "className", "=", "$", "value", "[", "'class'", "]", ";", "$", "this", "->", "_targets", "[", "$", "key", "]", "=", "$", "className", "::", "build", "(", "$", "value", ")", ";", "}", "}", "}", "}", "catch", "(", "InvalidConfigurationException", "$", "e", ")", "{", "$", "configStr", "=", "print_r", "(", "$", "config", ",", "true", ")", ";", "error_log", "(", "'Invalid Configuration for Logger Component. '", ".", "PHP_EOL", ".", "$", "configStr", ")", ";", "}", "}" ]
Applies log configuration @param array $config
[ "Applies", "log", "configuration" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/Logger.php#L51-L79
24,366
kenphp/ken
src/Log/Logger.php
Logger.setEnabledLevels
public function setEnabledLevels(array $levels) { $enabledLevels = array(); foreach ($levels as $value) { if ($this->validLevel($value)) { array_push($enabledLevels, $value); } } $this->_enabledLevels = $enabledLevels; }
php
public function setEnabledLevels(array $levels) { $enabledLevels = array(); foreach ($levels as $value) { if ($this->validLevel($value)) { array_push($enabledLevels, $value); } } $this->_enabledLevels = $enabledLevels; }
[ "public", "function", "setEnabledLevels", "(", "array", "$", "levels", ")", "{", "$", "enabledLevels", "=", "array", "(", ")", ";", "foreach", "(", "$", "levels", "as", "$", "value", ")", "{", "if", "(", "$", "this", "->", "validLevel", "(", "$", "value", ")", ")", "{", "array_push", "(", "$", "enabledLevels", ",", "$", "value", ")", ";", "}", "}", "$", "this", "->", "_enabledLevels", "=", "$", "enabledLevels", ";", "}" ]
Sets enabled logging levels. @param array $levels
[ "Sets", "enabled", "logging", "levels", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/Logger.php#L173-L184
24,367
netvlies/NetvliesFormBundle
Twig/Extension/FormExtension.php
FormExtension.showForm
public function showForm($id) { $form = $this->container->get('netvlies.form')->get($id); if ($form->getSuccess()) { return $this->container->get('templating')->render('NetvliesFormBundle:Twig:form_success.html.twig', array( 'successMessage' => $form->getSuccessMessage(), )); } else { $formView = $form->getSf2Form()->createView(); if ($this->container->getParameter('netvlies.form.templates.fields') != null) { $this->container->get('twig')->getExtension('form')->renderer->setTheme($formView, array($this->container->getParameter('netvlies.form.templates.fields'))); } return $this->container->get('templating')->render($this->container->getParameter('netvlies.form.templates.form'), array( 'id' => $form->getId(), 'form' => $formView, )); } }
php
public function showForm($id) { $form = $this->container->get('netvlies.form')->get($id); if ($form->getSuccess()) { return $this->container->get('templating')->render('NetvliesFormBundle:Twig:form_success.html.twig', array( 'successMessage' => $form->getSuccessMessage(), )); } else { $formView = $form->getSf2Form()->createView(); if ($this->container->getParameter('netvlies.form.templates.fields') != null) { $this->container->get('twig')->getExtension('form')->renderer->setTheme($formView, array($this->container->getParameter('netvlies.form.templates.fields'))); } return $this->container->get('templating')->render($this->container->getParameter('netvlies.form.templates.form'), array( 'id' => $form->getId(), 'form' => $formView, )); } }
[ "public", "function", "showForm", "(", "$", "id", ")", "{", "$", "form", "=", "$", "this", "->", "container", "->", "get", "(", "'netvlies.form'", ")", "->", "get", "(", "$", "id", ")", ";", "if", "(", "$", "form", "->", "getSuccess", "(", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'NetvliesFormBundle:Twig:form_success.html.twig'", ",", "array", "(", "'successMessage'", "=>", "$", "form", "->", "getSuccessMessage", "(", ")", ",", ")", ")", ";", "}", "else", "{", "$", "formView", "=", "$", "form", "->", "getSf2Form", "(", ")", "->", "createView", "(", ")", ";", "if", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'netvlies.form.templates.fields'", ")", "!=", "null", ")", "{", "$", "this", "->", "container", "->", "get", "(", "'twig'", ")", "->", "getExtension", "(", "'form'", ")", "->", "renderer", "->", "setTheme", "(", "$", "formView", ",", "array", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'netvlies.form.templates.fields'", ")", ")", ")", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "render", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'netvlies.form.templates.form'", ")", ",", "array", "(", "'id'", "=>", "$", "form", "->", "getId", "(", ")", ",", "'form'", "=>", "$", "formView", ",", ")", ")", ";", "}", "}" ]
Twig function that displays the form with the requested ID. If the form post was successful, the success message is shown by the Twig renderer. @param $id @return mixed
[ "Twig", "function", "that", "displays", "the", "form", "with", "the", "requested", "ID", ".", "If", "the", "form", "post", "was", "successful", "the", "success", "message", "is", "shown", "by", "the", "Twig", "renderer", "." ]
93f9a3321d9925040111374e7c1014a6400a2d08
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/Twig/Extension/FormExtension.php#L51-L70
24,368
Duffleman/json-client
src/Collections/Generic.php
Generic.all
public function all() { $attributes = $this->attributes; return array_map(function ($item) { if (is_object($item) && get_class($item) === Generic::class) { $item = $item->all(); } return $item; }, $attributes); }
php
public function all() { $attributes = $this->attributes; return array_map(function ($item) { if (is_object($item) && get_class($item) === Generic::class) { $item = $item->all(); } return $item; }, $attributes); }
[ "public", "function", "all", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "attributes", ";", "return", "array_map", "(", "function", "(", "$", "item", ")", "{", "if", "(", "is_object", "(", "$", "item", ")", "&&", "get_class", "(", "$", "item", ")", "===", "Generic", "::", "class", ")", "{", "$", "item", "=", "$", "item", "->", "all", "(", ")", ";", "}", "return", "$", "item", ";", "}", ",", "$", "attributes", ")", ";", "}" ]
Return the base attribute array. @return array
[ "Return", "the", "base", "attribute", "array", "." ]
83432875a000e79243424a1e8676acb9969d0c18
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/Collections/Generic.php#L80-L91
24,369
wenbinye/PhalconX
src/Queue/Beanstalk.php
Beanstalk.ignore
public function ignore($tube) { $this->write('ignore ' . $tube); $response = $this->readStatus(); if ($response[0] != "WATCHING") { return false; } return $response[1]; }
php
public function ignore($tube) { $this->write('ignore ' . $tube); $response = $this->readStatus(); if ($response[0] != "WATCHING") { return false; } return $response[1]; }
[ "public", "function", "ignore", "(", "$", "tube", ")", "{", "$", "this", "->", "write", "(", "'ignore '", ".", "$", "tube", ")", ";", "$", "response", "=", "$", "this", "->", "readStatus", "(", ")", ";", "if", "(", "$", "response", "[", "0", "]", "!=", "\"WATCHING\"", ")", "{", "return", "false", ";", "}", "return", "$", "response", "[", "1", "]", ";", "}" ]
Ignores the tube
[ "Ignores", "the", "tube" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Queue/Beanstalk.php#L51-L59
24,370
wenbinye/PhalconX
src/Queue/Beanstalk.php
Beanstalk.put
public function put($job, $options = null) { if ($job instanceof JobInterface) { if ($job->isRunOnce()) { $cacheKey = self::CACHE_JOB . get_class($job); if ($this->getCache()->get($cacheKey) === null) { $expire = $job->getDelay() + $job->getTtr() + 60; $this->getCache()->save($cacheKey, 1, $expire); } else { return true; } } $options = [ 'delay' => $job->getDelay(), 'ttr' => $job->getTtr(), 'priority' => $job->getPriority() ]; } $this->getLogger()->info('Add job ' . json_encode($job)); return parent::put($job, $options); }
php
public function put($job, $options = null) { if ($job instanceof JobInterface) { if ($job->isRunOnce()) { $cacheKey = self::CACHE_JOB . get_class($job); if ($this->getCache()->get($cacheKey) === null) { $expire = $job->getDelay() + $job->getTtr() + 60; $this->getCache()->save($cacheKey, 1, $expire); } else { return true; } } $options = [ 'delay' => $job->getDelay(), 'ttr' => $job->getTtr(), 'priority' => $job->getPriority() ]; } $this->getLogger()->info('Add job ' . json_encode($job)); return parent::put($job, $options); }
[ "public", "function", "put", "(", "$", "job", ",", "$", "options", "=", "null", ")", "{", "if", "(", "$", "job", "instanceof", "JobInterface", ")", "{", "if", "(", "$", "job", "->", "isRunOnce", "(", ")", ")", "{", "$", "cacheKey", "=", "self", "::", "CACHE_JOB", ".", "get_class", "(", "$", "job", ")", ";", "if", "(", "$", "this", "->", "getCache", "(", ")", "->", "get", "(", "$", "cacheKey", ")", "===", "null", ")", "{", "$", "expire", "=", "$", "job", "->", "getDelay", "(", ")", "+", "$", "job", "->", "getTtr", "(", ")", "+", "60", ";", "$", "this", "->", "getCache", "(", ")", "->", "save", "(", "$", "cacheKey", ",", "1", ",", "$", "expire", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}", "$", "options", "=", "[", "'delay'", "=>", "$", "job", "->", "getDelay", "(", ")", ",", "'ttr'", "=>", "$", "job", "->", "getTtr", "(", ")", ",", "'priority'", "=>", "$", "job", "->", "getPriority", "(", ")", "]", ";", "}", "$", "this", "->", "getLogger", "(", ")", "->", "info", "(", "'Add job '", ".", "json_encode", "(", "$", "job", ")", ")", ";", "return", "parent", "::", "put", "(", "$", "job", ",", "$", "options", ")", ";", "}" ]
Inserts jobs into the queue @param mixed $job JobInterface or any data @param array options
[ "Inserts", "jobs", "into", "the", "queue" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Queue/Beanstalk.php#L75-L95
24,371
wenbinye/PhalconX
src/Queue/Beanstalk.php
Beanstalk.delete
public function delete(JobInterface $job) { if ($job->isRunOnce()) { $this->getCache()->delete(self::CACHE_JOB.get_class($job)); } return $job->getBeanstalkJob()->delete(); }
php
public function delete(JobInterface $job) { if ($job->isRunOnce()) { $this->getCache()->delete(self::CACHE_JOB.get_class($job)); } return $job->getBeanstalkJob()->delete(); }
[ "public", "function", "delete", "(", "JobInterface", "$", "job", ")", "{", "if", "(", "$", "job", "->", "isRunOnce", "(", ")", ")", "{", "$", "this", "->", "getCache", "(", ")", "->", "delete", "(", "self", "::", "CACHE_JOB", ".", "get_class", "(", "$", "job", ")", ")", ";", "}", "return", "$", "job", "->", "getBeanstalkJob", "(", ")", "->", "delete", "(", ")", ";", "}" ]
deletes job from queue @var JobInterface $job
[ "deletes", "job", "from", "queue" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Queue/Beanstalk.php#L102-L108
24,372
phergie/phergie-irc-generator
src/Generator.php
Generator.getIrcMessage
protected function getIrcMessage($type, array $params = array()) { $message = ''; if ($this->prefix) { $message .= ':' . $this->prefix . ' '; } $message .= $type; $params = array_filter($params, function($param) { return $param !== null; }); if ($params) { $last = end($params); $params[key($params)] = ':' . $last; $message .= ' ' . implode(' ', $params); } $message .= "\r\n"; return $message; }
php
protected function getIrcMessage($type, array $params = array()) { $message = ''; if ($this->prefix) { $message .= ':' . $this->prefix . ' '; } $message .= $type; $params = array_filter($params, function($param) { return $param !== null; }); if ($params) { $last = end($params); $params[key($params)] = ':' . $last; $message .= ' ' . implode(' ', $params); } $message .= "\r\n"; return $message; }
[ "protected", "function", "getIrcMessage", "(", "$", "type", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "''", ";", "if", "(", "$", "this", "->", "prefix", ")", "{", "$", "message", ".=", "':'", ".", "$", "this", "->", "prefix", ".", "' '", ";", "}", "$", "message", ".=", "$", "type", ";", "$", "params", "=", "array_filter", "(", "$", "params", ",", "function", "(", "$", "param", ")", "{", "return", "$", "param", "!==", "null", ";", "}", ")", ";", "if", "(", "$", "params", ")", "{", "$", "last", "=", "end", "(", "$", "params", ")", ";", "$", "params", "[", "key", "(", "$", "params", ")", "]", "=", "':'", ".", "$", "last", ";", "$", "message", ".=", "' '", ".", "implode", "(", "' '", ",", "$", "params", ")", ";", "}", "$", "message", ".=", "\"\\r\\n\"", ";", "return", "$", "message", ";", "}" ]
Returns a formatted IRC message. @param string $type Command or response code @param array $params Optional message parameters @return string
[ "Returns", "a", "formatted", "IRC", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L45-L64
24,373
phergie/phergie-irc-generator
src/Generator.php
Generator.ircUser
public function ircUser($username, $hostname, $servername, $realname) { return $this->getIrcMessage('USER', array($username, $hostname, $servername, $realname)); }
php
public function ircUser($username, $hostname, $servername, $realname) { return $this->getIrcMessage('USER', array($username, $hostname, $servername, $realname)); }
[ "public", "function", "ircUser", "(", "$", "username", ",", "$", "hostname", ",", "$", "servername", ",", "$", "realname", ")", "{", "return", "$", "this", "->", "getIrcMessage", "(", "'USER'", ",", "array", "(", "$", "username", ",", "$", "hostname", ",", "$", "servername", ",", "$", "realname", ")", ")", ";", "}" ]
Returns a USER message. @param string $username @param string $hostname @param string $servername @param string $realname @return string
[ "Returns", "a", "USER", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L98-L101
24,374
phergie/phergie-irc-generator
src/Generator.php
Generator.ircMode
public function ircMode($target, $mode = null, $param = null) { return $this->getIrcMessage('MODE', array($target, $mode, $param)); }
php
public function ircMode($target, $mode = null, $param = null) { return $this->getIrcMessage('MODE', array($target, $mode, $param)); }
[ "public", "function", "ircMode", "(", "$", "target", ",", "$", "mode", "=", "null", ",", "$", "param", "=", "null", ")", "{", "return", "$", "this", "->", "getIrcMessage", "(", "'MODE'", ",", "array", "(", "$", "target", ",", "$", "mode", ",", "$", "param", ")", ")", ";", "}" ]
Returns a MODE message. @param string $target @param string|null $mode @param string|null $param @return string
[ "Returns", "a", "MODE", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L183-L186
24,375
phergie/phergie-irc-generator
src/Generator.php
Generator.ircKick
public function ircKick($channel, $user, $comment = null) { return $this->getIrcMessage('KICK', array($channel, $user, $comment)); }
php
public function ircKick($channel, $user, $comment = null) { return $this->getIrcMessage('KICK', array($channel, $user, $comment)); }
[ "public", "function", "ircKick", "(", "$", "channel", ",", "$", "user", ",", "$", "comment", "=", "null", ")", "{", "return", "$", "this", "->", "getIrcMessage", "(", "'KICK'", ",", "array", "(", "$", "channel", ",", "$", "user", ",", "$", "comment", ")", ")", ";", "}" ]
Returns a KICK message. @param string $channel @param string $user @param string $comment @return string
[ "Returns", "a", "KICK", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L243-L246
24,376
phergie/phergie-irc-generator
src/Generator.php
Generator.ircConnect
public function ircConnect($targetserver, $port = null, $remoteserver = null) { return $this->getIrcMessage('CONNECT', array($targetserver, $port, $remoteserver)); }
php
public function ircConnect($targetserver, $port = null, $remoteserver = null) { return $this->getIrcMessage('CONNECT', array($targetserver, $port, $remoteserver)); }
[ "public", "function", "ircConnect", "(", "$", "targetserver", ",", "$", "port", "=", "null", ",", "$", "remoteserver", "=", "null", ")", "{", "return", "$", "this", "->", "getIrcMessage", "(", "'CONNECT'", ",", "array", "(", "$", "targetserver", ",", "$", "port", ",", "$", "remoteserver", ")", ")", ";", "}" ]
Returns a CONNECT message. @param string $targetserver @param int $port @param string $remoteserver @return string
[ "Returns", "a", "CONNECT", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L306-L309
24,377
phergie/phergie-irc-generator
src/Generator.php
Generator.ircWhowas
public function ircWhowas($nickname, $count = null, $server = null) { return $this->getIrcMessage('WHOWAS', array($nickname, $count, $server)); }
php
public function ircWhowas($nickname, $count = null, $server = null) { return $this->getIrcMessage('WHOWAS', array($nickname, $count, $server)); }
[ "public", "function", "ircWhowas", "(", "$", "nickname", ",", "$", "count", "=", "null", ",", "$", "server", "=", "null", ")", "{", "return", "$", "this", "->", "getIrcMessage", "(", "'WHOWAS'", ",", "array", "(", "$", "nickname", ",", "$", "count", ",", "$", "server", ")", ")", ";", "}" ]
Returns a WHOWAS message. @param string $nickname @param int $count @param string $server @return string
[ "Returns", "a", "WHOWAS", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L400-L403
24,378
phergie/phergie-irc-generator
src/Generator.php
Generator.ctcpVersionResponse
public function ctcpVersionResponse($nickname, $name, $version, $environment) { return $this->getCtcpResponse($nickname, 'VERSION ' . $name . ':' . $version . ':' . $environment); }
php
public function ctcpVersionResponse($nickname, $name, $version, $environment) { return $this->getCtcpResponse($nickname, 'VERSION ' . $name . ':' . $version . ':' . $environment); }
[ "public", "function", "ctcpVersionResponse", "(", "$", "nickname", ",", "$", "name", ",", "$", "version", ",", "$", "environment", ")", "{", "return", "$", "this", "->", "getCtcpResponse", "(", "$", "nickname", ",", "'VERSION '", ".", "$", "name", ".", "':'", ".", "$", "version", ".", "':'", ".", "$", "environment", ")", ";", "}" ]
Returns a CTCP VERSION reply message. @param string $nickname @param string $name @param string $version @param string $environment @return string
[ "Returns", "a", "CTCP", "VERSION", "reply", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L621-L624
24,379
phergie/phergie-irc-generator
src/Generator.php
Generator.ctcpSourceResponse
public function ctcpSourceResponse($nickname, $host, $directories, $files) { return $this->getCtcpResponse($nickname, 'SOURCE ' . $host . ':' . $directories . ':' . $files); }
php
public function ctcpSourceResponse($nickname, $host, $directories, $files) { return $this->getCtcpResponse($nickname, 'SOURCE ' . $host . ':' . $directories . ':' . $files); }
[ "public", "function", "ctcpSourceResponse", "(", "$", "nickname", ",", "$", "host", ",", "$", "directories", ",", "$", "files", ")", "{", "return", "$", "this", "->", "getCtcpResponse", "(", "$", "nickname", ",", "'SOURCE '", ".", "$", "host", ".", "':'", ".", "$", "directories", ".", "':'", ".", "$", "files", ")", ";", "}" ]
Returns a CTCP SOURCE reply message. @param string $nickname @param string $host @param string $directories @param string $files @return string
[ "Returns", "a", "CTCP", "SOURCE", "reply", "message", "." ]
8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8
https://github.com/phergie/phergie-irc-generator/blob/8e7871f6d4e6c0f409a7912fb967e6cf2ead4ed8/src/Generator.php#L646-L649
24,380
GrupaZero/api
src/Gzero/Api/ServiceProvider.php
ServiceProvider.bind
private function bind() { $this->app->bind( 'League\Fractal\Manager', function () { $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); return $manager; } ); }
php
private function bind() { $this->app->bind( 'League\Fractal\Manager', function () { $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); return $manager; } ); }
[ "private", "function", "bind", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'League\\Fractal\\Manager'", ",", "function", "(", ")", "{", "$", "manager", "=", "new", "Manager", "(", ")", ";", "$", "manager", "->", "setSerializer", "(", "new", "ArraySerializer", "(", ")", ")", ";", "return", "$", "manager", ";", "}", ")", ";", "}" ]
Bind additional classes @return void
[ "Bind", "additional", "classes" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/ServiceProvider.php#L81-L91
24,381
42mate/towel
src/Towel/Migration/BaseMigration.php
BaseMigration.setDone
public function setDone() { $migration = $this->getMigration(); if ($migration['state']) { return true; //alredy done } $this->db()->update($this->table, array('state' => true), array('id' => $migration['id'])); }
php
public function setDone() { $migration = $this->getMigration(); if ($migration['state']) { return true; //alredy done } $this->db()->update($this->table, array('state' => true), array('id' => $migration['id'])); }
[ "public", "function", "setDone", "(", ")", "{", "$", "migration", "=", "$", "this", "->", "getMigration", "(", ")", ";", "if", "(", "$", "migration", "[", "'state'", "]", ")", "{", "return", "true", ";", "//alredy done", "}", "$", "this", "->", "db", "(", ")", "->", "update", "(", "$", "this", "->", "table", ",", "array", "(", "'state'", "=>", "true", ")", ",", "array", "(", "'id'", "=>", "$", "migration", "[", "'id'", "]", ")", ")", ";", "}" ]
Sets that the migration was done. @return bool
[ "Sets", "that", "the", "migration", "was", "done", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Migration/BaseMigration.php#L79-L85
24,382
42mate/towel
src/Towel/Migration/BaseMigration.php
BaseMigration.unsetDone
public function unsetDone() { $migration = $this->getMigration(); if (!$migration['state']) { return true; //alredy undone } $this->db()->update($this->table, array('state' => false), array('id' => $migration['id'])); }
php
public function unsetDone() { $migration = $this->getMigration(); if (!$migration['state']) { return true; //alredy undone } $this->db()->update($this->table, array('state' => false), array('id' => $migration['id'])); }
[ "public", "function", "unsetDone", "(", ")", "{", "$", "migration", "=", "$", "this", "->", "getMigration", "(", ")", ";", "if", "(", "!", "$", "migration", "[", "'state'", "]", ")", "{", "return", "true", ";", "//alredy undone", "}", "$", "this", "->", "db", "(", ")", "->", "update", "(", "$", "this", "->", "table", ",", "array", "(", "'state'", "=>", "false", ")", ",", "array", "(", "'id'", "=>", "$", "migration", "[", "'id'", "]", ")", ")", ";", "}" ]
Sets that the migration was reverted. @return bool
[ "Sets", "that", "the", "migration", "was", "reverted", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Migration/BaseMigration.php#L92-L98
24,383
42mate/towel
src/Towel/Migration/BaseMigration.php
BaseMigration.create
public function create() { $migration = $this->getMessages(); if (!$migration) { $this->db()->insert($this->table, array('migration' => get_class($this), 'state' => false)); } else { throw new \Exception('Migration ' . get_class($this) . ' already created'); } }
php
public function create() { $migration = $this->getMessages(); if (!$migration) { $this->db()->insert($this->table, array('migration' => get_class($this), 'state' => false)); } else { throw new \Exception('Migration ' . get_class($this) . ' already created'); } }
[ "public", "function", "create", "(", ")", "{", "$", "migration", "=", "$", "this", "->", "getMessages", "(", ")", ";", "if", "(", "!", "$", "migration", ")", "{", "$", "this", "->", "db", "(", ")", "->", "insert", "(", "$", "this", "->", "table", ",", "array", "(", "'migration'", "=>", "get_class", "(", "$", "this", ")", ",", "'state'", "=>", "false", ")", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Migration '", ".", "get_class", "(", "$", "this", ")", ".", "' already created'", ")", ";", "}", "}" ]
Creates the record in the database of the migration. @throws \Exception
[ "Creates", "the", "record", "in", "the", "database", "of", "the", "migration", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Migration/BaseMigration.php#L105-L112
24,384
42mate/towel
src/Towel/Migration/BaseMigration.php
BaseMigration.getMigration
public function getMigration() { $query = $this->db()->createQueryBuilder() ->select('m.*') ->from($this->table, 'm') ->where('migration = ?') ->setParameter(0, get_class($this)); $results = $query->execute(); $migration = $results->fetch(); if (!$migration) { $this->create(); return true; //Is not in the DB so is new and is pending } return $migration; }
php
public function getMigration() { $query = $this->db()->createQueryBuilder() ->select('m.*') ->from($this->table, 'm') ->where('migration = ?') ->setParameter(0, get_class($this)); $results = $query->execute(); $migration = $results->fetch(); if (!$migration) { $this->create(); return true; //Is not in the DB so is new and is pending } return $migration; }
[ "public", "function", "getMigration", "(", ")", "{", "$", "query", "=", "$", "this", "->", "db", "(", ")", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'m.*'", ")", "->", "from", "(", "$", "this", "->", "table", ",", "'m'", ")", "->", "where", "(", "'migration = ?'", ")", "->", "setParameter", "(", "0", ",", "get_class", "(", "$", "this", ")", ")", ";", "$", "results", "=", "$", "query", "->", "execute", "(", ")", ";", "$", "migration", "=", "$", "results", "->", "fetch", "(", ")", ";", "if", "(", "!", "$", "migration", ")", "{", "$", "this", "->", "create", "(", ")", ";", "return", "true", ";", "//Is not in the DB so is new and is pending", "}", "return", "$", "migration", ";", "}" ]
Gets the information in the DB of this migration. @return mixed
[ "Gets", "the", "information", "in", "the", "DB", "of", "this", "migration", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Migration/BaseMigration.php#L118-L133
24,385
42mate/towel
src/Towel/Migration/BaseMigration.php
BaseMigration.addMessage
public function addMessage($message) { $migrationName = get_class($this); $this->messages[] = sprintf("%s: %s\n", $migrationName, $message); }
php
public function addMessage($message) { $migrationName = get_class($this); $this->messages[] = sprintf("%s: %s\n", $migrationName, $message); }
[ "public", "function", "addMessage", "(", "$", "message", ")", "{", "$", "migrationName", "=", "get_class", "(", "$", "this", ")", ";", "$", "this", "->", "messages", "[", "]", "=", "sprintf", "(", "\"%s: %s\\n\"", ",", "$", "migrationName", ",", "$", "message", ")", ";", "}" ]
Adds messages in the migration for later use.
[ "Adds", "messages", "in", "the", "migration", "for", "later", "use", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Migration/BaseMigration.php#L138-L141
24,386
rhosocial/yii2-user
models/LoginMethod/ID.php
ID.validate
public static function validate($attribute) { $userClass = Yii::$app->user->identityClass; $regex = $userClass::$idRegex; $result = preg_match($regex, $attribute); return is_int($result) && $result > 0; }
php
public static function validate($attribute) { $userClass = Yii::$app->user->identityClass; $regex = $userClass::$idRegex; $result = preg_match($regex, $attribute); return is_int($result) && $result > 0; }
[ "public", "static", "function", "validate", "(", "$", "attribute", ")", "{", "$", "userClass", "=", "Yii", "::", "$", "app", "->", "user", "->", "identityClass", ";", "$", "regex", "=", "$", "userClass", "::", "$", "idRegex", ";", "$", "result", "=", "preg_match", "(", "$", "regex", ",", "$", "attribute", ")", ";", "return", "is_int", "(", "$", "result", ")", "&&", "$", "result", ">", "0", ";", "}" ]
Validate whether the attribute is valid. @param mixed $attribute @return bool
[ "Validate", "whether", "the", "attribute", "is", "valid", "." ]
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/LoginMethod/ID.php#L44-L50
24,387
arndtteunissen/column-layout
Classes/User/Tca.php
Tca.generateSelectItems
public function generateSelectItems(array &$params) { $pageUid = $params['flexParentDatabaseRow']['_tx_column_layout_orig_pid'] ?? $params['flexParentDatabaseRow']['pid']; $size = $params['config']['txColumnLayout']['size']; $type = $params['config']['txColumnLayout']['type']; $columnSizes = ColumnLayoutUtility::getSizesFor($size, $type, $pageUid); $settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid); $sizeSettings = $settings['sizes.'][$size . '.']; $typeSettings = $settings['types.'][$type . '.']; $itemLabel = $this->getLanguageService()->sL($typeSettings['itemLabel']); $items = array_map(function ($column) use ($size, $itemLabel) { return [ sprintf( $itemLabel, $column, $size ), $column ]; }, $columnSizes); if ($columnSizes[0] === 0 && ($typeSettings['itemLabelDisabled'] ?? false)) { $items[0][0] = sprintf($this->getLanguageService()->sL($typeSettings['itemLabelDisabled']), $type); } $typeOrdering = $typeSettings['ordering'] ?? null; $sizeTypeOverride = array_key_exists($type . '.', $sizeSettings) ? $sizeSettings[$type . '.']['ordering'] ?? false : false; $typeOrdering = $sizeTypeOverride ? $sizeTypeOverride : $typeOrdering; if ($typeOrdering === 'reverse') { $items = array_reverse($items); } $params['items'] = $items; }
php
public function generateSelectItems(array &$params) { $pageUid = $params['flexParentDatabaseRow']['_tx_column_layout_orig_pid'] ?? $params['flexParentDatabaseRow']['pid']; $size = $params['config']['txColumnLayout']['size']; $type = $params['config']['txColumnLayout']['type']; $columnSizes = ColumnLayoutUtility::getSizesFor($size, $type, $pageUid); $settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid); $sizeSettings = $settings['sizes.'][$size . '.']; $typeSettings = $settings['types.'][$type . '.']; $itemLabel = $this->getLanguageService()->sL($typeSettings['itemLabel']); $items = array_map(function ($column) use ($size, $itemLabel) { return [ sprintf( $itemLabel, $column, $size ), $column ]; }, $columnSizes); if ($columnSizes[0] === 0 && ($typeSettings['itemLabelDisabled'] ?? false)) { $items[0][0] = sprintf($this->getLanguageService()->sL($typeSettings['itemLabelDisabled']), $type); } $typeOrdering = $typeSettings['ordering'] ?? null; $sizeTypeOverride = array_key_exists($type . '.', $sizeSettings) ? $sizeSettings[$type . '.']['ordering'] ?? false : false; $typeOrdering = $sizeTypeOverride ? $sizeTypeOverride : $typeOrdering; if ($typeOrdering === 'reverse') { $items = array_reverse($items); } $params['items'] = $items; }
[ "public", "function", "generateSelectItems", "(", "array", "&", "$", "params", ")", "{", "$", "pageUid", "=", "$", "params", "[", "'flexParentDatabaseRow'", "]", "[", "'_tx_column_layout_orig_pid'", "]", "??", "$", "params", "[", "'flexParentDatabaseRow'", "]", "[", "'pid'", "]", ";", "$", "size", "=", "$", "params", "[", "'config'", "]", "[", "'txColumnLayout'", "]", "[", "'size'", "]", ";", "$", "type", "=", "$", "params", "[", "'config'", "]", "[", "'txColumnLayout'", "]", "[", "'type'", "]", ";", "$", "columnSizes", "=", "ColumnLayoutUtility", "::", "getSizesFor", "(", "$", "size", ",", "$", "type", ",", "$", "pageUid", ")", ";", "$", "settings", "=", "ColumnLayoutUtility", "::", "getColumnLayoutSettings", "(", "$", "pageUid", ")", ";", "$", "sizeSettings", "=", "$", "settings", "[", "'sizes.'", "]", "[", "$", "size", ".", "'.'", "]", ";", "$", "typeSettings", "=", "$", "settings", "[", "'types.'", "]", "[", "$", "type", ".", "'.'", "]", ";", "$", "itemLabel", "=", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "$", "typeSettings", "[", "'itemLabel'", "]", ")", ";", "$", "items", "=", "array_map", "(", "function", "(", "$", "column", ")", "use", "(", "$", "size", ",", "$", "itemLabel", ")", "{", "return", "[", "sprintf", "(", "$", "itemLabel", ",", "$", "column", ",", "$", "size", ")", ",", "$", "column", "]", ";", "}", ",", "$", "columnSizes", ")", ";", "if", "(", "$", "columnSizes", "[", "0", "]", "===", "0", "&&", "(", "$", "typeSettings", "[", "'itemLabelDisabled'", "]", "??", "false", ")", ")", "{", "$", "items", "[", "0", "]", "[", "0", "]", "=", "sprintf", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "$", "typeSettings", "[", "'itemLabelDisabled'", "]", ")", ",", "$", "type", ")", ";", "}", "$", "typeOrdering", "=", "$", "typeSettings", "[", "'ordering'", "]", "??", "null", ";", "$", "sizeTypeOverride", "=", "array_key_exists", "(", "$", "type", ".", "'.'", ",", "$", "sizeSettings", ")", "?", "$", "sizeSettings", "[", "$", "type", ".", "'.'", "]", "[", "'ordering'", "]", "??", "false", ":", "false", ";", "$", "typeOrdering", "=", "$", "sizeTypeOverride", "?", "$", "sizeTypeOverride", ":", "$", "typeOrdering", ";", "if", "(", "$", "typeOrdering", "===", "'reverse'", ")", "{", "$", "items", "=", "array_reverse", "(", "$", "items", ")", ";", "}", "$", "params", "[", "'items'", "]", "=", "$", "items", ";", "}" ]
Generates select items for the gridsystem flexform @param array $params @throws Exception when size or type was not defined
[ "Generates", "select", "items", "for", "the", "gridsystem", "flexform" ]
ad737068eef3b084d4d0e3a48e6a3d8277af9560
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/User/Tca.php#L26-L62
24,388
bit3archive/php-remote-objects
src/RemoteObjects/Encode/AesEncoder.php
AesEncoder.getCryptAes
protected function getCryptAes() { if ($this->aes === null) { $this->aes = new \Crypt_AES(); $this->aes->setKey($this->psk); } return $this->aes; }
php
protected function getCryptAes() { if ($this->aes === null) { $this->aes = new \Crypt_AES(); $this->aes->setKey($this->psk); } return $this->aes; }
[ "protected", "function", "getCryptAes", "(", ")", "{", "if", "(", "$", "this", "->", "aes", "===", "null", ")", "{", "$", "this", "->", "aes", "=", "new", "\\", "Crypt_AES", "(", ")", ";", "$", "this", "->", "aes", "->", "setKey", "(", "$", "this", "->", "psk", ")", ";", "}", "return", "$", "this", "->", "aes", ";", "}" ]
Get the crypt aes component. @return \Crypt_RSA
[ "Get", "the", "crypt", "aes", "component", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/AesEncoder.php#L69-L77
24,389
mslib/resource-proxy
Msl/ResourceProxy/Source/Imap.php
Imap.postParseUnitAction
public function postParseUnitAction($uniqueId, $success = true) { // Setting parsed message flag to SEEN $result = new ParseResult(); try { if ($success) { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_SEEN)); } else { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_RECENT)); } } catch (\Exception $e) { $result->setResult(false); $result->setMessage($e->getMessage()); $result->setCode($e->getCode()); } // Returning the result object return $result; }
php
public function postParseUnitAction($uniqueId, $success = true) { // Setting parsed message flag to SEEN $result = new ParseResult(); try { if ($success) { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_SEEN)); } else { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_RECENT)); } } catch (\Exception $e) { $result->setResult(false); $result->setMessage($e->getMessage()); $result->setCode($e->getCode()); } // Returning the result object return $result; }
[ "public", "function", "postParseUnitAction", "(", "$", "uniqueId", ",", "$", "success", "=", "true", ")", "{", "// Setting parsed message flag to SEEN", "$", "result", "=", "new", "ParseResult", "(", ")", ";", "try", "{", "if", "(", "$", "success", ")", "{", "$", "this", "->", "storage", "->", "setFlags", "(", "$", "uniqueId", ",", "array", "(", "ZendStorage", "::", "FLAG_SEEN", ")", ")", ";", "}", "else", "{", "$", "this", "->", "storage", "->", "setFlags", "(", "$", "uniqueId", ",", "array", "(", "ZendStorage", "::", "FLAG_RECENT", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "result", "->", "setResult", "(", "false", ")", ";", "$", "result", "->", "setMessage", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "result", "->", "setCode", "(", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "// Returning the result object", "return", "$", "result", ";", "}" ]
Action to be run after a single set of data retrieved from the remote source has been parsed. @param string $uniqueId Unique id of the single set to be treated (e.g. unique id of a message in a mail box) @param bool $success True if the data of a given resource have been downloaded and used correctly; false otherwise. @return \Msl\ResourceProxy\Source\Parse\ParseResult|void
[ "Action", "to", "be", "run", "after", "a", "single", "set", "of", "data", "retrieved", "from", "the", "remote", "source", "has", "been", "parsed", "." ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Imap.php#L120-L138
24,390
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.get_template_name
public function get_template_name($slug) { $slug = \str_replace( [ Config::get('theme.templates_directory') . '/', $this->blade->getFileExtension(), ], '', $slug ); if (\strpos($slug, 'views/') !== 0) { $slug = 'views.' . $slug; } return $this->bladeify($slug); }
php
public function get_template_name($slug) { $slug = \str_replace( [ Config::get('theme.templates_directory') . '/', $this->blade->getFileExtension(), ], '', $slug ); if (\strpos($slug, 'views/') !== 0) { $slug = 'views.' . $slug; } return $this->bladeify($slug); }
[ "public", "function", "get_template_name", "(", "$", "slug", ")", "{", "$", "slug", "=", "\\", "str_replace", "(", "[", "Config", "::", "get", "(", "'theme.templates_directory'", ")", ".", "'/'", ",", "$", "this", "->", "blade", "->", "getFileExtension", "(", ")", ",", "]", ",", "''", ",", "$", "slug", ")", ";", "if", "(", "\\", "strpos", "(", "$", "slug", ",", "'views/'", ")", "!==", "0", ")", "{", "$", "slug", "=", "'views.'", ".", "$", "slug", ";", "}", "return", "$", "this", "->", "bladeify", "(", "$", "slug", ")", ";", "}" ]
Generate the template file name from the slug. @since 1.0.0 @param string $slug The slug for the generic template. @return string
[ "Generate", "the", "template", "file", "name", "from", "the", "slug", "." ]
41e004e93440f6b58638b64dc8d20cca4a0546fa
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L87-L103
24,391
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.add_default_data
private function add_default_data($data = []) { global $wp_query, $post; $data['wp_query'] = $wp_query; $data['post'] = &$post; $data['current_view'] = $this->current_view; $data['request'] = Request::get_root_instance(); $data['errors'] = Validation::$errors; return $data; }
php
private function add_default_data($data = []) { global $wp_query, $post; $data['wp_query'] = $wp_query; $data['post'] = &$post; $data['current_view'] = $this->current_view; $data['request'] = Request::get_root_instance(); $data['errors'] = Validation::$errors; return $data; }
[ "private", "function", "add_default_data", "(", "$", "data", "=", "[", "]", ")", "{", "global", "$", "wp_query", ",", "$", "post", ";", "$", "data", "[", "'wp_query'", "]", "=", "$", "wp_query", ";", "$", "data", "[", "'post'", "]", "=", "&", "$", "post", ";", "$", "data", "[", "'current_view'", "]", "=", "$", "this", "->", "current_view", ";", "$", "data", "[", "'request'", "]", "=", "Request", "::", "get_root_instance", "(", ")", ";", "$", "data", "[", "'errors'", "]", "=", "Validation", "::", "$", "errors", ";", "return", "$", "data", ";", "}" ]
Add default data to template. @since 1.0.0 @param array $data Data array. @return array
[ "Add", "default", "data", "to", "template", "." ]
41e004e93440f6b58638b64dc8d20cca4a0546fa
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L125-L136
24,392
DataDo/data
src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php
DefaultMethodNameParser.getTokens
private function getTokens($methodName) { preg_match_all('([A-Z_-][^A-Z_-]*)', $methodName, $rawTokens); $result = array(); $lastToken = null; $seenBy = false; foreach ($rawTokens[0] as $token) { $newToken = $this->getToken($token, $seenBy); if ($newToken instanceof ValueToken) { $lastToken = $lastToken !== null && $lastToken instanceof ValueToken ? new ValueToken($lastToken->getSource() . $newToken->getSource()) : $newToken; } else { if ($lastToken instanceof ValueToken) { // Add the last token too $result[] = $lastToken; $lastToken = null; } $result[] = $newToken; } } if ($lastToken !== null) { $result[] = $lastToken; } return $result; }
php
private function getTokens($methodName) { preg_match_all('([A-Z_-][^A-Z_-]*)', $methodName, $rawTokens); $result = array(); $lastToken = null; $seenBy = false; foreach ($rawTokens[0] as $token) { $newToken = $this->getToken($token, $seenBy); if ($newToken instanceof ValueToken) { $lastToken = $lastToken !== null && $lastToken instanceof ValueToken ? new ValueToken($lastToken->getSource() . $newToken->getSource()) : $newToken; } else { if ($lastToken instanceof ValueToken) { // Add the last token too $result[] = $lastToken; $lastToken = null; } $result[] = $newToken; } } if ($lastToken !== null) { $result[] = $lastToken; } return $result; }
[ "private", "function", "getTokens", "(", "$", "methodName", ")", "{", "preg_match_all", "(", "'([A-Z_-][^A-Z_-]*)'", ",", "$", "methodName", ",", "$", "rawTokens", ")", ";", "$", "result", "=", "array", "(", ")", ";", "$", "lastToken", "=", "null", ";", "$", "seenBy", "=", "false", ";", "foreach", "(", "$", "rawTokens", "[", "0", "]", "as", "$", "token", ")", "{", "$", "newToken", "=", "$", "this", "->", "getToken", "(", "$", "token", ",", "$", "seenBy", ")", ";", "if", "(", "$", "newToken", "instanceof", "ValueToken", ")", "{", "$", "lastToken", "=", "$", "lastToken", "!==", "null", "&&", "$", "lastToken", "instanceof", "ValueToken", "?", "new", "ValueToken", "(", "$", "lastToken", "->", "getSource", "(", ")", ".", "$", "newToken", "->", "getSource", "(", ")", ")", ":", "$", "newToken", ";", "}", "else", "{", "if", "(", "$", "lastToken", "instanceof", "ValueToken", ")", "{", "// Add the last token too", "$", "result", "[", "]", "=", "$", "lastToken", ";", "$", "lastToken", "=", "null", ";", "}", "$", "result", "[", "]", "=", "$", "newToken", ";", "}", "}", "if", "(", "$", "lastToken", "!==", "null", ")", "{", "$", "result", "[", "]", "=", "$", "lastToken", ";", "}", "return", "$", "result", ";", "}" ]
Split the method name into tokens and parse them. @param $methodName string the method name @return Token[]
[ "Split", "the", "method", "name", "into", "tokens", "and", "parse", "them", "." ]
555b02a27755032fcd53e165b0674e81a68067c0
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php#L50-L79
24,393
DataDo/data
src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php
DefaultMethodNameParser.getToken
private function getToken($token, &$hasSeenBy) { switch ($token) { case 'And': return new AndToken(); case 'Or': return new OrToken(); case 'By': case 'Where': $hasSeenBy = true; return new ByToken(); case 'All': return new AllToken(); case 'Distinct': if ($hasSeenBy) { return new ValueToken($token); } else { return new DistinctToken(); } case 'Like': if ($hasSeenBy) { return new LikeToken(); } else { return new ValueToken($token); } default: return new ValueToken($token); } }
php
private function getToken($token, &$hasSeenBy) { switch ($token) { case 'And': return new AndToken(); case 'Or': return new OrToken(); case 'By': case 'Where': $hasSeenBy = true; return new ByToken(); case 'All': return new AllToken(); case 'Distinct': if ($hasSeenBy) { return new ValueToken($token); } else { return new DistinctToken(); } case 'Like': if ($hasSeenBy) { return new LikeToken(); } else { return new ValueToken($token); } default: return new ValueToken($token); } }
[ "private", "function", "getToken", "(", "$", "token", ",", "&", "$", "hasSeenBy", ")", "{", "switch", "(", "$", "token", ")", "{", "case", "'And'", ":", "return", "new", "AndToken", "(", ")", ";", "case", "'Or'", ":", "return", "new", "OrToken", "(", ")", ";", "case", "'By'", ":", "case", "'Where'", ":", "$", "hasSeenBy", "=", "true", ";", "return", "new", "ByToken", "(", ")", ";", "case", "'All'", ":", "return", "new", "AllToken", "(", ")", ";", "case", "'Distinct'", ":", "if", "(", "$", "hasSeenBy", ")", "{", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "else", "{", "return", "new", "DistinctToken", "(", ")", ";", "}", "case", "'Like'", ":", "if", "(", "$", "hasSeenBy", ")", "{", "return", "new", "LikeToken", "(", ")", ";", "}", "else", "{", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "default", ":", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "}" ]
Translate a token source to a token object. @param $token string the token source @return Token the token object
[ "Translate", "a", "token", "source", "to", "a", "token", "object", "." ]
555b02a27755032fcd53e165b0674e81a68067c0
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php#L87-L115
24,394
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getWellKnown
public function getWellKnown() { $cached = $this->getCache('wellKnown'); if (!empty($cached)) { return $cached; } try { $response = $this->client->get($this->wellKnownUrl); } catch (RequestException $e) { $this->lastException = $e; return null; } $output = json_decode($response->getBody()); if (json_last_error() !== JSON_ERROR_NONE) { return null; } $this->setCache('wellKnown', $output); return $output; }
php
public function getWellKnown() { $cached = $this->getCache('wellKnown'); if (!empty($cached)) { return $cached; } try { $response = $this->client->get($this->wellKnownUrl); } catch (RequestException $e) { $this->lastException = $e; return null; } $output = json_decode($response->getBody()); if (json_last_error() !== JSON_ERROR_NONE) { return null; } $this->setCache('wellKnown', $output); return $output; }
[ "public", "function", "getWellKnown", "(", ")", "{", "$", "cached", "=", "$", "this", "->", "getCache", "(", "'wellKnown'", ")", ";", "if", "(", "!", "empty", "(", "$", "cached", ")", ")", "{", "return", "$", "cached", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "wellKnownUrl", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "null", ";", "}", "$", "output", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "return", "null", ";", "}", "$", "this", "->", "setCache", "(", "'wellKnown'", ",", "$", "output", ")", ";", "return", "$", "output", ";", "}" ]
Get the response of the specified .well-known URL. @return object Parsed JSON response from the well known URL
[ "Get", "the", "response", "of", "the", "specified", ".", "well", "-", "known", "URL", "." ]
9e55be8928a2c4925176303c100caf293d6a2cf9
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L63-L85
24,395
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getPublicKey
public function getPublicKey() { $cached = $this->getCache('publicKey'); if (!empty($cached)) { return $cached; } $wellKnown = $this->getWellKnown(); if (empty($wellKnown->jwks_uri)) { return null; } try { $response = $this->client->get($wellKnown->jwks_uri); } catch (RequestException $e) { $this->lastException = $e; return null; } $jwks = json_decode($response->getBody()); if (empty($jwks->keys[0]->x5c[0])) { return null; } $X509 = new X509(); if (!$X509->loadX509($jwks->keys[0]->x5c[0])) { return null; } $key = (string)$X509->getPublicKey(); $this->setCache('publicKey', $key); return $key; }
php
public function getPublicKey() { $cached = $this->getCache('publicKey'); if (!empty($cached)) { return $cached; } $wellKnown = $this->getWellKnown(); if (empty($wellKnown->jwks_uri)) { return null; } try { $response = $this->client->get($wellKnown->jwks_uri); } catch (RequestException $e) { $this->lastException = $e; return null; } $jwks = json_decode($response->getBody()); if (empty($jwks->keys[0]->x5c[0])) { return null; } $X509 = new X509(); if (!$X509->loadX509($jwks->keys[0]->x5c[0])) { return null; } $key = (string)$X509->getPublicKey(); $this->setCache('publicKey', $key); return $key; }
[ "public", "function", "getPublicKey", "(", ")", "{", "$", "cached", "=", "$", "this", "->", "getCache", "(", "'publicKey'", ")", ";", "if", "(", "!", "empty", "(", "$", "cached", ")", ")", "{", "return", "$", "cached", ";", "}", "$", "wellKnown", "=", "$", "this", "->", "getWellKnown", "(", ")", ";", "if", "(", "empty", "(", "$", "wellKnown", "->", "jwks_uri", ")", ")", "{", "return", "null", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "wellKnown", "->", "jwks_uri", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "null", ";", "}", "$", "jwks", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "jwks", "->", "keys", "[", "0", "]", "->", "x5c", "[", "0", "]", ")", ")", "{", "return", "null", ";", "}", "$", "X509", "=", "new", "X509", "(", ")", ";", "if", "(", "!", "$", "X509", "->", "loadX509", "(", "$", "jwks", "->", "keys", "[", "0", "]", "->", "x5c", "[", "0", "]", ")", ")", "{", "return", "null", ";", "}", "$", "key", "=", "(", "string", ")", "$", "X509", "->", "getPublicKey", "(", ")", ";", "$", "this", "->", "setCache", "(", "'publicKey'", ",", "$", "key", ")", ";", "return", "$", "key", ";", "}" ]
Get the public key of the current well-known URL @return string
[ "Get", "the", "public", "key", "of", "the", "current", "well", "-", "known", "URL" ]
9e55be8928a2c4925176303c100caf293d6a2cf9
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L92-L126
24,396
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.validateJWT
public function validateJWT($jwt) { try { $decoded = $this->decode($jwt); return !empty($decoded); } catch (Exception $e) { //For simple true/false validation we don't throw exceptions; //just return false but store exception in case further //details are wanted $this->lastException = $e; return false; } }
php
public function validateJWT($jwt) { try { $decoded = $this->decode($jwt); return !empty($decoded); } catch (Exception $e) { //For simple true/false validation we don't throw exceptions; //just return false but store exception in case further //details are wanted $this->lastException = $e; return false; } }
[ "public", "function", "validateJWT", "(", "$", "jwt", ")", "{", "try", "{", "$", "decoded", "=", "$", "this", "->", "decode", "(", "$", "jwt", ")", ";", "return", "!", "empty", "(", "$", "decoded", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "//For simple true/false validation we don't throw exceptions;", "//just return false but store exception in case further", "//details are wanted", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Check if a JWT is valid @param string $jwt JWT @return bool true if $jwt is a valid JWT, false if not
[ "Check", "if", "a", "JWT", "is", "valid" ]
9e55be8928a2c4925176303c100caf293d6a2cf9
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L135-L147
24,397
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.decode
public function decode($jwt) { $wellKnown = $this->getWellKnown(); $key = $this->getPublicKey(); $decodedObject = JWT::decode( $jwt, $key, $wellKnown->id_token_signing_alg_values_supported ); //Firebase\JWT\JWT::decode does not verify that some required //fields actually exist if (empty($decodedObject->iss)) { throw new NoIssuerException('No issuer in JWT'); } if ($decodedObject->iss != $wellKnown->issuer) { throw new BadIssuerException('JWT issuer does not match well-known'); } if (empty($decodedObject->exp)) { //Firebase\JWT\JWT does throw an exception if 'exp' field is in //the past, but not if it's completely missing throw new NoExpirationException('No expiration in JWT'); } //JWT::decode returns at stdClass object, but iterating through keys is much //simpler with an array. So here's a quick Object-to-Array conversion $decoded = json_decode(json_encode($decodedObject), true); return $this->parseClaims($decoded); }
php
public function decode($jwt) { $wellKnown = $this->getWellKnown(); $key = $this->getPublicKey(); $decodedObject = JWT::decode( $jwt, $key, $wellKnown->id_token_signing_alg_values_supported ); //Firebase\JWT\JWT::decode does not verify that some required //fields actually exist if (empty($decodedObject->iss)) { throw new NoIssuerException('No issuer in JWT'); } if ($decodedObject->iss != $wellKnown->issuer) { throw new BadIssuerException('JWT issuer does not match well-known'); } if (empty($decodedObject->exp)) { //Firebase\JWT\JWT does throw an exception if 'exp' field is in //the past, but not if it's completely missing throw new NoExpirationException('No expiration in JWT'); } //JWT::decode returns at stdClass object, but iterating through keys is much //simpler with an array. So here's a quick Object-to-Array conversion $decoded = json_decode(json_encode($decodedObject), true); return $this->parseClaims($decoded); }
[ "public", "function", "decode", "(", "$", "jwt", ")", "{", "$", "wellKnown", "=", "$", "this", "->", "getWellKnown", "(", ")", ";", "$", "key", "=", "$", "this", "->", "getPublicKey", "(", ")", ";", "$", "decodedObject", "=", "JWT", "::", "decode", "(", "$", "jwt", ",", "$", "key", ",", "$", "wellKnown", "->", "id_token_signing_alg_values_supported", ")", ";", "//Firebase\\JWT\\JWT::decode does not verify that some required", "//fields actually exist", "if", "(", "empty", "(", "$", "decodedObject", "->", "iss", ")", ")", "{", "throw", "new", "NoIssuerException", "(", "'No issuer in JWT'", ")", ";", "}", "if", "(", "$", "decodedObject", "->", "iss", "!=", "$", "wellKnown", "->", "issuer", ")", "{", "throw", "new", "BadIssuerException", "(", "'JWT issuer does not match well-known'", ")", ";", "}", "if", "(", "empty", "(", "$", "decodedObject", "->", "exp", ")", ")", "{", "//Firebase\\JWT\\JWT does throw an exception if 'exp' field is in", "//the past, but not if it's completely missing", "throw", "new", "NoExpirationException", "(", "'No expiration in JWT'", ")", ";", "}", "//JWT::decode returns at stdClass object, but iterating through keys is much", "//simpler with an array. So here's a quick Object-to-Array conversion", "$", "decoded", "=", "json_decode", "(", "json_encode", "(", "$", "decodedObject", ")", ",", "true", ")", ";", "return", "$", "this", "->", "parseClaims", "(", "$", "decoded", ")", ";", "}" ]
Decode a JWT @param string $jwt JWT @return object decoded JWT @throws Exception Various exceptions for various problems with JWT (see Firebase\JWT\JWT::decode for details)
[ "Decode", "a", "JWT" ]
9e55be8928a2c4925176303c100caf293d6a2cf9
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L159-L188
24,398
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getCache
protected function getCache($key) { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; } return false; }
php
protected function getCache($key) { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; } return false; }
[ "protected", "function", "getCache", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "cache", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}" ]
Simple cache reader. Implemented as a function so that if you don't want caching, you can make a subclass that overrides this function and always returns false @param string $key Cache key @return various
[ "Simple", "cache", "reader", ".", "Implemented", "as", "a", "function", "so", "that", "if", "you", "don", "t", "want", "caching", "you", "can", "make", "a", "subclass", "that", "overrides", "this", "function", "and", "always", "returns", "false" ]
9e55be8928a2c4925176303c100caf293d6a2cf9
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L275-L281
24,399
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setDividerElement
public function setDividerElement(string $element): Breadcrumbs { $this->validateElement('allowedDividerElement', $element); $this->setOption('dividerElement', $element); return $this; }
php
public function setDividerElement(string $element): Breadcrumbs { $this->validateElement('allowedDividerElement', $element); $this->setOption('dividerElement', $element); return $this; }
[ "public", "function", "setDividerElement", "(", "string", "$", "element", ")", ":", "Breadcrumbs", "{", "$", "this", "->", "validateElement", "(", "'allowedDividerElement'", ",", "$", "element", ")", ";", "$", "this", "->", "setOption", "(", "'dividerElement'", ",", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Set the divider list DOM Element. @param string $element The Element to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "divider", "list", "DOM", "Element", "." ]
aded39bdbf4f6e857f0154a810339d71897a94b0
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L80-L87