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
15,400
link0/profiler
src/Link0/Profiler/PersistenceService.php
PersistenceService.persist
public function persist(ProfileInterface $profile) { foreach ($this->persistenceHandlers as $persistenceHandler) { $persistenceHandler->persist($profile); } return $this; }
php
public function persist(ProfileInterface $profile) { foreach ($this->persistenceHandlers as $persistenceHandler) { $persistenceHandler->persist($profile); } return $this; }
[ "public", "function", "persist", "(", "ProfileInterface", "$", "profile", ")", "{", "foreach", "(", "$", "this", "->", "persistenceHandlers", "as", "$", "persistenceHandler", ")", "{", "$", "persistenceHandler", "->", "persist", "(", "$", "profile", ")", ";", "}", "return", "$", "this", ";", "}" ]
Persists data to the persistence handlers @param ProfileInterface $profile @return PersistenceService $this
[ "Persists", "data", "to", "the", "persistence", "handlers" ]
0573073ff029743734de747619ab65ab2476052d
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceService.php#L77-L84
15,401
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php
BaseField.removeEval
public function removeEval($key) { if (array_key_exists($key, $this->eval)) { unset($this->eval[$key]); return true; } return false; }
php
public function removeEval($key) { if (array_key_exists($key, $this->eval)) { unset($this->eval[$key]); return true; } return false; }
[ "public", "function", "removeEval", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "eval", ")", ")", "{", "unset", "(", "$", "this", "->", "eval", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Remove an entry vom the eval array Returns true if entry was removed and false if key was not found @param string $key @return bool
[ "Remove", "an", "entry", "vom", "the", "eval", "array", "Returns", "true", "if", "entry", "was", "removed", "and", "false", "if", "key", "was", "not", "found" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php#L85-L95
15,402
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php
BaseField.modifyEval
public function modifyEval($key, $value) { if (array_key_exists($key, $this->eval)) { $this->eval[$key] = $value; } }
php
public function modifyEval($key, $value) { if (array_key_exists($key, $this->eval)) { $this->eval[$key] = $value; } }
[ "public", "function", "modifyEval", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "eval", ")", ")", "{", "$", "this", "->", "eval", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Set a new value to an existing eval entry @param string $key @param mixed $value
[ "Set", "a", "new", "value", "to", "an", "existing", "eval", "entry" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php#L103-L110
15,403
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php
BaseField.getEval
public function getEval($key) { if (array_key_exists($key, $this->eval)) { return $this->eval[$key]; } return false; }
php
public function getEval($key) { if (array_key_exists($key, $this->eval)) { return $this->eval[$key]; } return false; }
[ "public", "function", "getEval", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "eval", ")", ")", "{", "return", "$", "this", "->", "eval", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}" ]
Get an entry from the eval array Returns the entry or false if key not found @param string $key @return mixed|bool
[ "Get", "an", "entry", "from", "the", "eval", "array", "Returns", "the", "entry", "or", "false", "if", "key", "not", "found" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/BaseField.php#L119-L126
15,404
crossjoin/Css
src/Crossjoin/Css/Helper/Placeholder.php
Placeholder.replaceStringsAndComments
public static function replaceStringsAndComments($text) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "'") !== false || strpos($text, '"') !== false) { // Replace all strings in quotes (also in comments, but that's okay - removed in next step) $replaceStringCallback = function ($matches) { return self::addStringReplacement($matches[1] . $matches[2] . $matches[1]); }; $text = preg_replace('/\r/', '', $text); $text = preg_replace('/\\\\\n/', '_STRING_CSSLINEBREAK_', $text); $text = preg_replace('/\\\\"/', '_STRING_ESCAPEDDOUBLEQUOTE_', $text); $text = preg_replace('/\\\\\'/', '_STRING_ESCAPEDSINGLEQUOTE_', $text); $text = preg_replace_callback('/("|\')(.*?)\g{1}/', $replaceStringCallback, $text); } if (strpos($text, "data:") !== false) { // Replace all data URIs // (that are not in quotes and therefor were not replaced by the previous check) $replaceDataUriCallback = function ($matches) { return self::addStringReplacement($matches[1]); }; $text = preg_replace_callback( '/(data:(?:[^;,]+)?(?:;charset=[^;,]+)?' . '(?:;base64,(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?|,[-.a-zA-Z0-9_%]+))/', $replaceDataUriCallback, $text ); } // Fast pre-check, to optimize performance if (strpos($text, "*") !== false) { // Strip multi-line comments (after string replace to keep comments in strings) $replaceCommentCallback = function ($matches) { return self::addCommentReplacement($matches[1]); }; $text = preg_replace_callback('/(\/\*.*?\*\/)/', $replaceCommentCallback, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
php
public static function replaceStringsAndComments($text) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "'") !== false || strpos($text, '"') !== false) { // Replace all strings in quotes (also in comments, but that's okay - removed in next step) $replaceStringCallback = function ($matches) { return self::addStringReplacement($matches[1] . $matches[2] . $matches[1]); }; $text = preg_replace('/\r/', '', $text); $text = preg_replace('/\\\\\n/', '_STRING_CSSLINEBREAK_', $text); $text = preg_replace('/\\\\"/', '_STRING_ESCAPEDDOUBLEQUOTE_', $text); $text = preg_replace('/\\\\\'/', '_STRING_ESCAPEDSINGLEQUOTE_', $text); $text = preg_replace_callback('/("|\')(.*?)\g{1}/', $replaceStringCallback, $text); } if (strpos($text, "data:") !== false) { // Replace all data URIs // (that are not in quotes and therefor were not replaced by the previous check) $replaceDataUriCallback = function ($matches) { return self::addStringReplacement($matches[1]); }; $text = preg_replace_callback( '/(data:(?:[^;,]+)?(?:;charset=[^;,]+)?' . '(?:;base64,(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?|,[-.a-zA-Z0-9_%]+))/', $replaceDataUriCallback, $text ); } // Fast pre-check, to optimize performance if (strpos($text, "*") !== false) { // Strip multi-line comments (after string replace to keep comments in strings) $replaceCommentCallback = function ($matches) { return self::addCommentReplacement($matches[1]); }; $text = preg_replace_callback('/(\/\*.*?\*\/)/', $replaceCommentCallback, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
[ "public", "static", "function", "replaceStringsAndComments", "(", "$", "text", ")", "{", "if", "(", "is_string", "(", "$", "text", ")", ")", "{", "// Fast pre-check, to optimize performance", "if", "(", "strpos", "(", "$", "text", ",", "\"'\"", ")", "!==", "false", "||", "strpos", "(", "$", "text", ",", "'\"'", ")", "!==", "false", ")", "{", "// Replace all strings in quotes (also in comments, but that's okay - removed in next step)", "$", "replaceStringCallback", "=", "function", "(", "$", "matches", ")", "{", "return", "self", "::", "addStringReplacement", "(", "$", "matches", "[", "1", "]", ".", "$", "matches", "[", "2", "]", ".", "$", "matches", "[", "1", "]", ")", ";", "}", ";", "$", "text", "=", "preg_replace", "(", "'/\\r/'", ",", "''", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "'/\\\\\\\\\\n/'", ",", "'_STRING_CSSLINEBREAK_'", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "'/\\\\\\\\\"/'", ",", "'_STRING_ESCAPEDDOUBLEQUOTE_'", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "'/\\\\\\\\\\'/'", ",", "'_STRING_ESCAPEDSINGLEQUOTE_'", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace_callback", "(", "'/(\"|\\')(.*?)\\g{1}/'", ",", "$", "replaceStringCallback", ",", "$", "text", ")", ";", "}", "if", "(", "strpos", "(", "$", "text", ",", "\"data:\"", ")", "!==", "false", ")", "{", "// Replace all data URIs", "// (that are not in quotes and therefor were not replaced by the previous check)", "$", "replaceDataUriCallback", "=", "function", "(", "$", "matches", ")", "{", "return", "self", "::", "addStringReplacement", "(", "$", "matches", "[", "1", "]", ")", ";", "}", ";", "$", "text", "=", "preg_replace_callback", "(", "'/(data:(?:[^;,]+)?(?:;charset=[^;,]+)?'", ".", "'(?:;base64,(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?|,[-.a-zA-Z0-9_%]+))/'", ",", "$", "replaceDataUriCallback", ",", "$", "text", ")", ";", "}", "// Fast pre-check, to optimize performance", "if", "(", "strpos", "(", "$", "text", ",", "\"*\"", ")", "!==", "false", ")", "{", "// Strip multi-line comments (after string replace to keep comments in strings)", "$", "replaceCommentCallback", "=", "function", "(", "$", "matches", ")", "{", "return", "self", "::", "addCommentReplacement", "(", "$", "matches", "[", "1", "]", ")", ";", "}", ";", "$", "text", "=", "preg_replace_callback", "(", "'/(\\/\\*.*?\\*\\/)/'", ",", "$", "replaceCommentCallback", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "text", ")", ".", "\"' for argument 'text' given.\"", ")", ";", "}", "}" ]
Replaces all CSS strings and comments in the given text. @param string $text @return string
[ "Replaces", "all", "CSS", "strings", "and", "comments", "in", "the", "given", "text", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Helper/Placeholder.php#L22-L67
15,405
crossjoin/Css
src/Crossjoin/Css/Helper/Placeholder.php
Placeholder.replaceStringPlaceholders
public static function replaceStringPlaceholders($text, $deletePlaceholders = false) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "_") !== false) { $replaceStringPlaceholders = function ($matches) use ($deletePlaceholders) { $result = ""; if (isset(self::$replacements[$matches[1]])) { $result = self::$replacements[$matches[1]]; $result = str_replace( ['_STRING_CSSLINEBREAK_', '_STRING_ESCAPEDDOUBLEQUOTE_', '_STRING_ESCAPEDSINGLEQUOTE_'], ["\\\n", '\\"', "\\'"], $result ); if ($deletePlaceholders === true) { unset(self::$replacements[$matches[1]]); } } return $result; }; $text = preg_replace_callback('/(?:_STRING_([a-f0-9]{32})_)/', $replaceStringPlaceholders, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
php
public static function replaceStringPlaceholders($text, $deletePlaceholders = false) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "_") !== false) { $replaceStringPlaceholders = function ($matches) use ($deletePlaceholders) { $result = ""; if (isset(self::$replacements[$matches[1]])) { $result = self::$replacements[$matches[1]]; $result = str_replace( ['_STRING_CSSLINEBREAK_', '_STRING_ESCAPEDDOUBLEQUOTE_', '_STRING_ESCAPEDSINGLEQUOTE_'], ["\\\n", '\\"', "\\'"], $result ); if ($deletePlaceholders === true) { unset(self::$replacements[$matches[1]]); } } return $result; }; $text = preg_replace_callback('/(?:_STRING_([a-f0-9]{32})_)/', $replaceStringPlaceholders, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
[ "public", "static", "function", "replaceStringPlaceholders", "(", "$", "text", ",", "$", "deletePlaceholders", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "text", ")", ")", "{", "// Fast pre-check, to optimize performance", "if", "(", "strpos", "(", "$", "text", ",", "\"_\"", ")", "!==", "false", ")", "{", "$", "replaceStringPlaceholders", "=", "function", "(", "$", "matches", ")", "use", "(", "$", "deletePlaceholders", ")", "{", "$", "result", "=", "\"\"", ";", "if", "(", "isset", "(", "self", "::", "$", "replacements", "[", "$", "matches", "[", "1", "]", "]", ")", ")", "{", "$", "result", "=", "self", "::", "$", "replacements", "[", "$", "matches", "[", "1", "]", "]", ";", "$", "result", "=", "str_replace", "(", "[", "'_STRING_CSSLINEBREAK_'", ",", "'_STRING_ESCAPEDDOUBLEQUOTE_'", ",", "'_STRING_ESCAPEDSINGLEQUOTE_'", "]", ",", "[", "\"\\\\\\n\"", ",", "'\\\\\"'", ",", "\"\\\\'\"", "]", ",", "$", "result", ")", ";", "if", "(", "$", "deletePlaceholders", "===", "true", ")", "{", "unset", "(", "self", "::", "$", "replacements", "[", "$", "matches", "[", "1", "]", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}", ";", "$", "text", "=", "preg_replace_callback", "(", "'/(?:_STRING_([a-f0-9]{32})_)/'", ",", "$", "replaceStringPlaceholders", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "text", ")", ".", "\"' for argument 'text' given.\"", ")", ";", "}", "}" ]
Replaces the string place holders wih the saved strings in a given text. @param string $text @param bool $deletePlaceholders @return string
[ "Replaces", "the", "string", "place", "holders", "wih", "the", "saved", "strings", "in", "a", "given", "text", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Helper/Placeholder.php#L76-L104
15,406
crossjoin/Css
src/Crossjoin/Css/Helper/Placeholder.php
Placeholder.removeCommentPlaceholders
public static function removeCommentPlaceholders($text, $deletePlaceholders = false) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "_") !== false) { $removeStringPlaceholders = function ($matches) use ($deletePlaceholders) { if ($deletePlaceholders === true) { if (isset(self::$replacements[$matches[1]])) { unset(self::$replacements[$matches[1]]); } } return ""; }; $text = preg_replace_callback('/(?:_COMMENT_([a-f0-9]{32})_)/', $removeStringPlaceholders, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
php
public static function removeCommentPlaceholders($text, $deletePlaceholders = false) { if (is_string($text)) { // Fast pre-check, to optimize performance if (strpos($text, "_") !== false) { $removeStringPlaceholders = function ($matches) use ($deletePlaceholders) { if ($deletePlaceholders === true) { if (isset(self::$replacements[$matches[1]])) { unset(self::$replacements[$matches[1]]); } } return ""; }; $text = preg_replace_callback('/(?:_COMMENT_([a-f0-9]{32})_)/', $removeStringPlaceholders, $text); } return $text; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($text). "' for argument 'text' given." ); } }
[ "public", "static", "function", "removeCommentPlaceholders", "(", "$", "text", ",", "$", "deletePlaceholders", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "text", ")", ")", "{", "// Fast pre-check, to optimize performance", "if", "(", "strpos", "(", "$", "text", ",", "\"_\"", ")", "!==", "false", ")", "{", "$", "removeStringPlaceholders", "=", "function", "(", "$", "matches", ")", "use", "(", "$", "deletePlaceholders", ")", "{", "if", "(", "$", "deletePlaceholders", "===", "true", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "replacements", "[", "$", "matches", "[", "1", "]", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "replacements", "[", "$", "matches", "[", "1", "]", "]", ")", ";", "}", "}", "return", "\"\"", ";", "}", ";", "$", "text", "=", "preg_replace_callback", "(", "'/(?:_COMMENT_([a-f0-9]{32})_)/'", ",", "$", "removeStringPlaceholders", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "text", ")", ".", "\"' for argument 'text' given.\"", ")", ";", "}", "}" ]
Removes the comment place holders from a given text. @param string $text @param bool $deletePlaceholders @return string
[ "Removes", "the", "comment", "place", "holders", "from", "a", "given", "text", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Helper/Placeholder.php#L146-L167
15,407
crossjoin/Css
src/Crossjoin/Css/Helper/Placeholder.php
Placeholder.addReplacement
protected static function addReplacement($string, $prefix) { if (is_string($string)) { if (is_string($prefix)) { $hash = md5(self::$counter); $placeholder = "_" . $prefix . "_" . $hash . "_"; self::$replacements[$hash] = $string; self::$counter++; return $placeholder; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($prefix). "' for argument 'prefix' given." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($string). "' for argument 'string' given." ); } }
php
protected static function addReplacement($string, $prefix) { if (is_string($string)) { if (is_string($prefix)) { $hash = md5(self::$counter); $placeholder = "_" . $prefix . "_" . $hash . "_"; self::$replacements[$hash] = $string; self::$counter++; return $placeholder; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($prefix). "' for argument 'prefix' given." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($string). "' for argument 'string' given." ); } }
[ "protected", "static", "function", "addReplacement", "(", "$", "string", ",", "$", "prefix", ")", "{", "if", "(", "is_string", "(", "$", "string", ")", ")", "{", "if", "(", "is_string", "(", "$", "prefix", ")", ")", "{", "$", "hash", "=", "md5", "(", "self", "::", "$", "counter", ")", ";", "$", "placeholder", "=", "\"_\"", ".", "$", "prefix", ".", "\"_\"", ".", "$", "hash", ".", "\"_\"", ";", "self", "::", "$", "replacements", "[", "$", "hash", "]", "=", "$", "string", ";", "self", "::", "$", "counter", "++", ";", "return", "$", "placeholder", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "prefix", ")", ".", "\"' for argument 'prefix' given.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "string", ")", ".", "\"' for argument 'string' given.\"", ")", ";", "}", "}" ]
Adds a replacement to the internal list. @param string $string @param string $prefix @return string
[ "Adds", "a", "replacement", "to", "the", "internal", "list", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Helper/Placeholder.php#L198-L218
15,408
axelitus/php-base
src/PropertyAccessible.php
PropertyAccessible.getRefClass
final private function getRefClass() { if ($this->refClass === null) { $this->refClass = new \ReflectionClass($this); } return $this->refClass; }
php
final private function getRefClass() { if ($this->refClass === null) { $this->refClass = new \ReflectionClass($this); } return $this->refClass; }
[ "final", "private", "function", "getRefClass", "(", ")", "{", "if", "(", "$", "this", "->", "refClass", "===", "null", ")", "{", "$", "this", "->", "refClass", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "refClass", ";", "}" ]
Gets the ReflectionClass object for the current object. The ReflectionClass object is created only once, then that value is returned for subsequent calls. @return null|\ReflectionClass The ReflectionClass of the object.
[ "Gets", "the", "ReflectionClass", "object", "for", "the", "current", "object", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/PropertyAccessible.php#L54-L61
15,409
axelitus/php-base
src/PropertyAccessible.php
PropertyAccessible.hasProperty
final public function hasProperty($property) { if (!Str::is($property) || !Str::match($property, "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/") || $property == 'this' ) { throw new \InvalidArgumentException( "The \$property parameter must be a string and follow the PHP rules of variable naming." ); } return property_exists($this, $property); }
php
final public function hasProperty($property) { if (!Str::is($property) || !Str::match($property, "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/") || $property == 'this' ) { throw new \InvalidArgumentException( "The \$property parameter must be a string and follow the PHP rules of variable naming." ); } return property_exists($this, $property); }
[ "final", "public", "function", "hasProperty", "(", "$", "property", ")", "{", "if", "(", "!", "Str", "::", "is", "(", "$", "property", ")", "||", "!", "Str", "::", "match", "(", "$", "property", ",", "\"/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/\"", ")", "||", "$", "property", "==", "'this'", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The \\$property parameter must be a string and follow the PHP rules of variable naming.\"", ")", ";", "}", "return", "property_exists", "(", "$", "this", ",", "$", "property", ")", ";", "}" ]
Checks if the object has the given property. @param string $property The property to check. @return bool Returns true if the property exists, false otherwise. @see http://docs.php.net/manual/en/language.variables.basics.php @throws \InvalidArgumentException
[ "Checks", "if", "the", "object", "has", "the", "given", "property", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/PropertyAccessible.php#L143-L155
15,410
axelitus/php-base
src/PropertyAccessible.php
PropertyAccessible.hasMethod
final public function hasMethod($method) { if (!Str::is($method) || !Str::match($method, "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/") ) { throw new \InvalidArgumentException( "The \$method parameter must be a string and follow the PHP rules of method naming." ); } return method_exists($this, $method); }
php
final public function hasMethod($method) { if (!Str::is($method) || !Str::match($method, "/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/") ) { throw new \InvalidArgumentException( "The \$method parameter must be a string and follow the PHP rules of method naming." ); } return method_exists($this, $method); }
[ "final", "public", "function", "hasMethod", "(", "$", "method", ")", "{", "if", "(", "!", "Str", "::", "is", "(", "$", "method", ")", "||", "!", "Str", "::", "match", "(", "$", "method", ",", "\"/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/\"", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The \\$method parameter must be a string and follow the PHP rules of method naming.\"", ")", ";", "}", "return", "method_exists", "(", "$", "this", ",", "$", "method", ")", ";", "}" ]
Checks if the object has the given method. @param string $method The method to check. @return bool Returns true if the property exists, false otherwise. @see http://docs.php.net/manual/en/function.user-defined.php @throws \InvalidArgumentException
[ "Checks", "if", "the", "object", "has", "the", "given", "method", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/PropertyAccessible.php#L167-L178
15,411
shakahl/hups-util-filedownloader
src/Hups/Util/FileDownloader.php
FileDownloader.download
public static function download($location, $filename = null, $mime = 'application/octet-stream', $speed = 1024, $disposition = 'attachment') { if (connection_status() != 0) return(false); if(!is_file($location)) { http_response_code(404); exit(); } if (empty($mime)) { $mime = static::getFileMime($location); } set_time_limit(0); while (ob_get_level() > 0) { ob_end_clean(); } if (!$filename) { $filename = pathinfo($location, PATHINFO_BASENAME); } $time = date('r', filemtime($location)); $size = filesize($location); $speed = ($speed === null) ? 1024 : intval($speed) * 1024; $begin = 0; $end = $size; $status = 200; if(isset($_SERVER['HTTP_RANGE'])) { if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { $begin = intval($matches[0]); if(!empty($matches[1])) { $end = intval($matches[1]); } $status = 206; } } http_response_code($status); header('Expires: 0'); header("Content-Type: $mime"); header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Accept-Ranges: bytes'); header('Content-Length: '.($end - $begin)); header("Content-Range: bytes $begin-" . ($end - 1) . "/$size"); header("Content-Disposition: " . $disposition . "; filename=$filename"); header("Content-Transfer-Encoding: binary"); header("Last-Modified: $time"); header('Connection: close'); for ($offset = $begin; $offset <= $end; $offset += $speed) { if (connection_status() || connection_aborted()) { exit(1); } echo file_get_contents($location, false, null, $offset, $speed); while (ob_get_level() > 0) { ob_end_flush(); } flush(); //ob_flush(); //ob_implicit_flush(); usleep(intval(floatval($time) * 1000000)); } return ((connection_status()==0) and !connection_aborted()); }
php
public static function download($location, $filename = null, $mime = 'application/octet-stream', $speed = 1024, $disposition = 'attachment') { if (connection_status() != 0) return(false); if(!is_file($location)) { http_response_code(404); exit(); } if (empty($mime)) { $mime = static::getFileMime($location); } set_time_limit(0); while (ob_get_level() > 0) { ob_end_clean(); } if (!$filename) { $filename = pathinfo($location, PATHINFO_BASENAME); } $time = date('r', filemtime($location)); $size = filesize($location); $speed = ($speed === null) ? 1024 : intval($speed) * 1024; $begin = 0; $end = $size; $status = 200; if(isset($_SERVER['HTTP_RANGE'])) { if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { $begin = intval($matches[0]); if(!empty($matches[1])) { $end = intval($matches[1]); } $status = 206; } } http_response_code($status); header('Expires: 0'); header("Content-Type: $mime"); header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Accept-Ranges: bytes'); header('Content-Length: '.($end - $begin)); header("Content-Range: bytes $begin-" . ($end - 1) . "/$size"); header("Content-Disposition: " . $disposition . "; filename=$filename"); header("Content-Transfer-Encoding: binary"); header("Last-Modified: $time"); header('Connection: close'); for ($offset = $begin; $offset <= $end; $offset += $speed) { if (connection_status() || connection_aborted()) { exit(1); } echo file_get_contents($location, false, null, $offset, $speed); while (ob_get_level() > 0) { ob_end_flush(); } flush(); //ob_flush(); //ob_implicit_flush(); usleep(intval(floatval($time) * 1000000)); } return ((connection_status()==0) and !connection_aborted()); }
[ "public", "static", "function", "download", "(", "$", "location", ",", "$", "filename", "=", "null", ",", "$", "mime", "=", "'application/octet-stream'", ",", "$", "speed", "=", "1024", ",", "$", "disposition", "=", "'attachment'", ")", "{", "if", "(", "connection_status", "(", ")", "!=", "0", ")", "return", "(", "false", ")", ";", "if", "(", "!", "is_file", "(", "$", "location", ")", ")", "{", "http_response_code", "(", "404", ")", ";", "exit", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "mime", ")", ")", "{", "$", "mime", "=", "static", "::", "getFileMime", "(", "$", "location", ")", ";", "}", "set_time_limit", "(", "0", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_clean", "(", ")", ";", "}", "if", "(", "!", "$", "filename", ")", "{", "$", "filename", "=", "pathinfo", "(", "$", "location", ",", "PATHINFO_BASENAME", ")", ";", "}", "$", "time", "=", "date", "(", "'r'", ",", "filemtime", "(", "$", "location", ")", ")", ";", "$", "size", "=", "filesize", "(", "$", "location", ")", ";", "$", "speed", "=", "(", "$", "speed", "===", "null", ")", "?", "1024", ":", "intval", "(", "$", "speed", ")", "*", "1024", ";", "$", "begin", "=", "0", ";", "$", "end", "=", "$", "size", ";", "$", "status", "=", "200", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_RANGE'", "]", ")", ")", "{", "if", "(", "preg_match", "(", "'/bytes=\\h*(\\d+)-(\\d*)[\\D.*]?/i'", ",", "$", "_SERVER", "[", "'HTTP_RANGE'", "]", ",", "$", "matches", ")", ")", "{", "$", "begin", "=", "intval", "(", "$", "matches", "[", "0", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "end", "=", "intval", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "$", "status", "=", "206", ";", "}", "}", "http_response_code", "(", "$", "status", ")", ";", "header", "(", "'Expires: 0'", ")", ";", "header", "(", "\"Content-Type: $mime\"", ")", ";", "header", "(", "'Pragma: public'", ")", ";", "header", "(", "'Cache-Control: must-revalidate, post-check=0, pre-check=0'", ")", ";", "header", "(", "'Accept-Ranges: bytes'", ")", ";", "header", "(", "'Content-Length: '", ".", "(", "$", "end", "-", "$", "begin", ")", ")", ";", "header", "(", "\"Content-Range: bytes $begin-\"", ".", "(", "$", "end", "-", "1", ")", ".", "\"/$size\"", ")", ";", "header", "(", "\"Content-Disposition: \"", ".", "$", "disposition", ".", "\"; filename=$filename\"", ")", ";", "header", "(", "\"Content-Transfer-Encoding: binary\"", ")", ";", "header", "(", "\"Last-Modified: $time\"", ")", ";", "header", "(", "'Connection: close'", ")", ";", "for", "(", "$", "offset", "=", "$", "begin", ";", "$", "offset", "<=", "$", "end", ";", "$", "offset", "+=", "$", "speed", ")", "{", "if", "(", "connection_status", "(", ")", "||", "connection_aborted", "(", ")", ")", "{", "exit", "(", "1", ")", ";", "}", "echo", "file_get_contents", "(", "$", "location", ",", "false", ",", "null", ",", "$", "offset", ",", "$", "speed", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_flush", "(", ")", ";", "}", "flush", "(", ")", ";", "//ob_flush();", "//ob_implicit_flush();", "usleep", "(", "intval", "(", "floatval", "(", "$", "time", ")", "*", "1000000", ")", ")", ";", "}", "return", "(", "(", "connection_status", "(", ")", "==", "0", ")", "and", "!", "connection_aborted", "(", ")", ")", ";", "}" ]
Sends the file to the browser for download @param string $location Path to the file @param string|null $filename Filename to download as @param string|null $mime Mime type. Set to null for autodetect. @param int $speed Download speed @param string $disposition Content disposition. attachment or inline. @return bool Return status.
[ "Sends", "the", "file", "to", "the", "browser", "for", "download" ]
e9fa3a02f5ff3e31b4ead8f535362efd27c6cfac
https://github.com/shakahl/hups-util-filedownloader/blob/e9fa3a02f5ff3e31b4ead8f535362efd27c6cfac/src/Hups/Util/FileDownloader.php#L27-L112
15,412
shakahl/hups-util-filedownloader
src/Hups/Util/FileDownloader.php
FileDownloader.getFileMime
public static function getFileMime($filename, $default = 'application/octet-stream') { if(function_exists('mime_content_type')) { return mime_content_type($filename); } $mime_types = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', ); $ext = substr(strrchr($filename, "."), 1); if (array_key_exists($ext, $mime_types)) { return $mime_types[$ext]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } return $default; }
php
public static function getFileMime($filename, $default = 'application/octet-stream') { if(function_exists('mime_content_type')) { return mime_content_type($filename); } $mime_types = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', ); $ext = substr(strrchr($filename, "."), 1); if (array_key_exists($ext, $mime_types)) { return $mime_types[$ext]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } return $default; }
[ "public", "static", "function", "getFileMime", "(", "$", "filename", ",", "$", "default", "=", "'application/octet-stream'", ")", "{", "if", "(", "function_exists", "(", "'mime_content_type'", ")", ")", "{", "return", "mime_content_type", "(", "$", "filename", ")", ";", "}", "$", "mime_types", "=", "array", "(", "'txt'", "=>", "'text/plain'", ",", "'htm'", "=>", "'text/html'", ",", "'html'", "=>", "'text/html'", ",", "'php'", "=>", "'text/html'", ",", "'css'", "=>", "'text/css'", ",", "'js'", "=>", "'application/javascript'", ",", "'json'", "=>", "'application/json'", ",", "'xml'", "=>", "'application/xml'", ",", "'swf'", "=>", "'application/x-shockwave-flash'", ",", "'flv'", "=>", "'video/x-flv'", ",", "// images", "'png'", "=>", "'image/png'", ",", "'jpe'", "=>", "'image/jpeg'", ",", "'jpeg'", "=>", "'image/jpeg'", ",", "'jpg'", "=>", "'image/jpeg'", ",", "'gif'", "=>", "'image/gif'", ",", "'bmp'", "=>", "'image/bmp'", ",", "'ico'", "=>", "'image/vnd.microsoft.icon'", ",", "'tiff'", "=>", "'image/tiff'", ",", "'tif'", "=>", "'image/tiff'", ",", "'svg'", "=>", "'image/svg+xml'", ",", "'svgz'", "=>", "'image/svg+xml'", ",", "// archives", "'zip'", "=>", "'application/zip'", ",", "'rar'", "=>", "'application/x-rar-compressed'", ",", "'exe'", "=>", "'application/x-msdownload'", ",", "'msi'", "=>", "'application/x-msdownload'", ",", "'cab'", "=>", "'application/vnd.ms-cab-compressed'", ",", "// audio/video", "'mp3'", "=>", "'audio/mpeg'", ",", "'qt'", "=>", "'video/quicktime'", ",", "'mov'", "=>", "'video/quicktime'", ",", "// adobe", "'pdf'", "=>", "'application/pdf'", ",", "'psd'", "=>", "'image/vnd.adobe.photoshop'", ",", "'ai'", "=>", "'application/postscript'", ",", "'eps'", "=>", "'application/postscript'", ",", "'ps'", "=>", "'application/postscript'", ",", "// ms office", "'doc'", "=>", "'application/msword'", ",", "'rtf'", "=>", "'application/rtf'", ",", "'xls'", "=>", "'application/vnd.ms-excel'", ",", "'ppt'", "=>", "'application/vnd.ms-powerpoint'", ",", "// open office", "'odt'", "=>", "'application/vnd.oasis.opendocument.text'", ",", "'ods'", "=>", "'application/vnd.oasis.opendocument.spreadsheet'", ",", ")", ";", "$", "ext", "=", "substr", "(", "strrchr", "(", "$", "filename", ",", "\".\"", ")", ",", "1", ")", ";", "if", "(", "array_key_exists", "(", "$", "ext", ",", "$", "mime_types", ")", ")", "{", "return", "$", "mime_types", "[", "$", "ext", "]", ";", "}", "elseif", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME", ")", ";", "$", "mimetype", "=", "finfo_file", "(", "$", "finfo", ",", "$", "filename", ")", ";", "finfo_close", "(", "$", "finfo", ")", ";", "return", "$", "mimetype", ";", "}", "return", "$", "default", ";", "}" ]
Get file's mime type @param string $filename @param string $default Default value @return string
[ "Get", "file", "s", "mime", "type" ]
e9fa3a02f5ff3e31b4ead8f535362efd27c6cfac
https://github.com/shakahl/hups-util-filedownloader/blob/e9fa3a02f5ff3e31b4ead8f535362efd27c6cfac/src/Hups/Util/FileDownloader.php#L120-L198
15,413
slogsdon/staticwp
includes/staticwp-view.class.php
View.notice
public static function notice($slug, $type = null) { ob_start(); self::template($slug, 'notice'); $result = null; if ($type == null) { $result = ob_get_flush(); } else { $result = array( 'message' => ob_get_flush(), 'type' => $type, ); } return $result; }
php
public static function notice($slug, $type = null) { ob_start(); self::template($slug, 'notice'); $result = null; if ($type == null) { $result = ob_get_flush(); } else { $result = array( 'message' => ob_get_flush(), 'type' => $type, ); } return $result; }
[ "public", "static", "function", "notice", "(", "$", "slug", ",", "$", "type", "=", "null", ")", "{", "ob_start", "(", ")", ";", "self", "::", "template", "(", "$", "slug", ",", "'notice'", ")", ";", "$", "result", "=", "null", ";", "if", "(", "$", "type", "==", "null", ")", "{", "$", "result", "=", "ob_get_flush", "(", ")", ";", "}", "else", "{", "$", "result", "=", "array", "(", "'message'", "=>", "ob_get_flush", "(", ")", ",", "'type'", "=>", "$", "type", ",", ")", ";", "}", "return", "$", "result", ";", "}" ]
Loads notice templates. @since 1.3.0 @param string $slug @return string|array
[ "Loads", "notice", "templates", "." ]
e96811e57c521b0dc28fc600647b89828cdba8c0
https://github.com/slogsdon/staticwp/blob/e96811e57c521b0dc28fc600647b89828cdba8c0/includes/staticwp-view.class.php#L28-L44
15,414
withfatpanda/illuminate-wordpress
src/Support/Concerns/BuildsErrorResponses.php
BuildsErrorResponses.buildErrorResponse
public function buildErrorResponse(\Exception $e) { $response = [ 'type' => get_class($e), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'data' => [ 'status' => 500 ] ]; if ($e instanceof ModelNotFoundException) { $response['data']['status'] = 404; } if ($e instanceof HttpException) { $response['data']['status'] = $e->getStatusCode(); } if ($e instanceof ValidationException) { $response['data']['errors'] = $e->messages(); } if ($this->isDebugMode()) { $response['line'] = $e->getLine(); $response['file'] = $e->getFile(); $response['trace'] = $e->getTraceAsString(); } return $response; }
php
public function buildErrorResponse(\Exception $e) { $response = [ 'type' => get_class($e), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'data' => [ 'status' => 500 ] ]; if ($e instanceof ModelNotFoundException) { $response['data']['status'] = 404; } if ($e instanceof HttpException) { $response['data']['status'] = $e->getStatusCode(); } if ($e instanceof ValidationException) { $response['data']['errors'] = $e->messages(); } if ($this->isDebugMode()) { $response['line'] = $e->getLine(); $response['file'] = $e->getFile(); $response['trace'] = $e->getTraceAsString(); } return $response; }
[ "public", "function", "buildErrorResponse", "(", "\\", "Exception", "$", "e", ")", "{", "$", "response", "=", "[", "'type'", "=>", "get_class", "(", "$", "e", ")", ",", "'code'", "=>", "$", "e", "->", "getCode", "(", ")", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'data'", "=>", "[", "'status'", "=>", "500", "]", "]", ";", "if", "(", "$", "e", "instanceof", "ModelNotFoundException", ")", "{", "$", "response", "[", "'data'", "]", "[", "'status'", "]", "=", "404", ";", "}", "if", "(", "$", "e", "instanceof", "HttpException", ")", "{", "$", "response", "[", "'data'", "]", "[", "'status'", "]", "=", "$", "e", "->", "getStatusCode", "(", ")", ";", "}", "if", "(", "$", "e", "instanceof", "ValidationException", ")", "{", "$", "response", "[", "'data'", "]", "[", "'errors'", "]", "=", "$", "e", "->", "messages", "(", ")", ";", "}", "if", "(", "$", "this", "->", "isDebugMode", "(", ")", ")", "{", "$", "response", "[", "'line'", "]", "=", "$", "e", "->", "getLine", "(", ")", ";", "$", "response", "[", "'file'", "]", "=", "$", "e", "->", "getFile", "(", ")", ";", "$", "response", "[", "'trace'", "]", "=", "$", "e", "->", "getTraceAsString", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Given an Exception, build a data package suitable for reporting the error to the client. @param Exception The exception @return array
[ "Given", "an", "Exception", "build", "a", "data", "package", "suitable", "for", "reporting", "the", "error", "to", "the", "client", "." ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/Support/Concerns/BuildsErrorResponses.php#L16-L46
15,415
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveCoreStats
public function retrieveCoreStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22CoreStats%22]"); $coreStats = json_decode($data); return $coreStats; }
php
public function retrieveCoreStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22CoreStats%22]"); $coreStats = json_decode($data); return $coreStats; }
[ "public", "function", "retrieveCoreStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22CoreStats%22]\"", ")", ";", "$", "coreStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "coreStats", ";", "}" ]
Retrieve Core Stats @access public @return object JSON
[ "Retrieve", "Core", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L81-L86
15,416
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveBadPlayerStats
public function retrieveBadPlayerStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22BadPlayerStats%22]"); $badPlayerStats = json_decode($data); return $badPlayerStats; }
php
public function retrieveBadPlayerStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22BadPlayerStats%22]"); $badPlayerStats = json_decode($data); return $badPlayerStats; }
[ "public", "function", "retrieveBadPlayerStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22BadPlayerStats%22]\"", ")", ";", "$", "badPlayerStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "badPlayerStats", ";", "}" ]
Retrieve Bad Player Stats @access public @return object JSON
[ "Retrieve", "Bad", "Player", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L94-L99
15,417
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveVehicleStats
public function retrieveVehicleStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22VehicleStats%22]"); $vehicleStats = json_decode($data); return $vehicleStats; }
php
public function retrieveVehicleStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22VehicleStats%22]"); $vehicleStats = json_decode($data); return $vehicleStats; }
[ "public", "function", "retrieveVehicleStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22VehicleStats%22]\"", ")", ";", "$", "vehicleStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "vehicleStats", ";", "}" ]
Retrieve Vehicle Stats @access public @return object JSON
[ "Retrieve", "Vehicle", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L107-L112
15,418
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveMapStats
public function retrieveMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22MapStats%22]"); $mapStats = json_decode($data); return $mapStats; }
php
public function retrieveMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22MapStats%22]"); $mapStats = json_decode($data); return $mapStats; }
[ "public", "function", "retrieveMapStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22MapStats%22]\"", ")", ";", "$", "mapStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "mapStats", ";", "}" ]
Retrieve Map Stats @access public @return object JSON
[ "Retrieve", "Map", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L120-L125
15,419
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveGameModeMapStats
public function retrieveGameModeMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameModeMapStats%22]"); $gameModeMapStats = json_decode($data); return $gameModeMapStats; }
php
public function retrieveGameModeMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameModeMapStats%22]"); $gameModeMapStats = json_decode($data); return $gameModeMapStats; }
[ "public", "function", "retrieveGameModeMapStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22GameModeMapStats%22]\"", ")", ";", "$", "gameModeMapStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "gameModeMapStats", ";", "}" ]
Retrieve Game Mode Map Stats @access public @return object JSON
[ "Retrieve", "Game", "Mode", "Map", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L133-L138
15,420
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveWeaponStats
public function retrieveWeaponStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22WeaponStats%22]"); $weapons = json_decode($data); return $weapons; }
php
public function retrieveWeaponStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22WeaponStats%22]"); $weapons = json_decode($data); return $weapons; }
[ "public", "function", "retrieveWeaponStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22WeaponStats%22]\"", ")", ";", "$", "weapons", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "weapons", ";", "}" ]
Retrieve Weapon Stats @access public @return object JSON
[ "Retrieve", "Weapon", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L146-L151
15,421
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveGameModeStats
public function retrieveGameModeStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameModeStats%22]"); $gameModeStats = json_decode($data); return $gameModeStats; }
php
public function retrieveGameModeStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameModeStats%22]"); $gameModeStats = json_decode($data); return $gameModeStats; }
[ "public", "function", "retrieveGameModeStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22GameModeStats%22]\"", ")", ";", "$", "gameModeStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "gameModeStats", ";", "}" ]
Retrieve Game Mode Stats @access public @return object JSON
[ "Retrieve", "Game", "Mode", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L159-L164
15,422
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveRushMapStats
public function retrieveRushMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22RushMapStats%22]&_?=1351945928776"); $rushMapStats = json_decode($data); return $rushMapStats; }
php
public function retrieveRushMapStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22RushMapStats%22]&_?=1351945928776"); $rushMapStats = json_decode($data); return $rushMapStats; }
[ "public", "function", "retrieveRushMapStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22RushMapStats%22]&_?=1351945928776\"", ")", ";", "$", "rushMapStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "rushMapStats", ";", "}" ]
Retrieve Rush Map Stats @access public @return object JSON
[ "Retrieve", "Rush", "Map", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L172-L177
15,423
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Stats.php
Stats.retrieveGameEventStats
public function retrieveGameEventStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameEventStats%22]"); $gameEventStats = json_decode($data); return $gameEventStats; }
php
public function retrieveGameEventStats () { $data = file_get_contents("http://battlefield.play4free.com/en/profile/stats/" .$this->_profileID. "/" .$this->_soldierID. "?g=[%22GameEventStats%22]"); $gameEventStats = json_decode($data); return $gameEventStats; }
[ "public", "function", "retrieveGameEventStats", "(", ")", "{", "$", "data", "=", "file_get_contents", "(", "\"http://battlefield.play4free.com/en/profile/stats/\"", ".", "$", "this", "->", "_profileID", ".", "\"/\"", ".", "$", "this", "->", "_soldierID", ".", "\"?g=[%22GameEventStats%22]\"", ")", ";", "$", "gameEventStats", "=", "json_decode", "(", "$", "data", ")", ";", "return", "$", "gameEventStats", ";", "}" ]
Retrieve Game Event Stats @access public @return object JSON
[ "Retrieve", "Game", "Event", "Stats" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Stats.php#L185-L190
15,424
dragosprotung/stc-core
src/Date/DateInterval.php
DateInterval.totalSeconds
public function totalSeconds() : int { return $this->days * 86400 + $this->h * 3600 + $this->i * 60 + $this->s; }
php
public function totalSeconds() : int { return $this->days * 86400 + $this->h * 3600 + $this->i * 60 + $this->s; }
[ "public", "function", "totalSeconds", "(", ")", ":", "int", "{", "return", "$", "this", "->", "days", "*", "86400", "+", "$", "this", "->", "h", "*", "3600", "+", "$", "this", "->", "i", "*", "60", "+", "$", "this", "->", "s", ";", "}" ]
Get the total number of seconds from the DateInterval. @return integer
[ "Get", "the", "total", "number", "of", "seconds", "from", "the", "DateInterval", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Date/DateInterval.php#L17-L20
15,425
stubbles/stubbles-webapp-core
src/main/php/auth/ProtectedResource.php
ProtectedResource.isAuthorized
private function isAuthorized(Request $request, Response $response): bool { $this->authorized = false; $user = $this->authenticate($request, $response); if (null !== $user && $this->authConstraint->requiresRoles()) { $roles = $this->roles($response, $user); if (null !== $roles && $this->authConstraint->satisfiedByRoles($roles)) { $request->associate(new Identity($user, $roles)); $this->authorized = true; } elseif (null !== $roles) { $this->error = $response->forbidden(); } } elseif (null !== $user) { $request->associate(new Identity($user, Roles::none())); $this->authorized = true; } return $this->authorized; }
php
private function isAuthorized(Request $request, Response $response): bool { $this->authorized = false; $user = $this->authenticate($request, $response); if (null !== $user && $this->authConstraint->requiresRoles()) { $roles = $this->roles($response, $user); if (null !== $roles && $this->authConstraint->satisfiedByRoles($roles)) { $request->associate(new Identity($user, $roles)); $this->authorized = true; } elseif (null !== $roles) { $this->error = $response->forbidden(); } } elseif (null !== $user) { $request->associate(new Identity($user, Roles::none())); $this->authorized = true; } return $this->authorized; }
[ "private", "function", "isAuthorized", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", ":", "bool", "{", "$", "this", "->", "authorized", "=", "false", ";", "$", "user", "=", "$", "this", "->", "authenticate", "(", "$", "request", ",", "$", "response", ")", ";", "if", "(", "null", "!==", "$", "user", "&&", "$", "this", "->", "authConstraint", "->", "requiresRoles", "(", ")", ")", "{", "$", "roles", "=", "$", "this", "->", "roles", "(", "$", "response", ",", "$", "user", ")", ";", "if", "(", "null", "!==", "$", "roles", "&&", "$", "this", "->", "authConstraint", "->", "satisfiedByRoles", "(", "$", "roles", ")", ")", "{", "$", "request", "->", "associate", "(", "new", "Identity", "(", "$", "user", ",", "$", "roles", ")", ")", ";", "$", "this", "->", "authorized", "=", "true", ";", "}", "elseif", "(", "null", "!==", "$", "roles", ")", "{", "$", "this", "->", "error", "=", "$", "response", "->", "forbidden", "(", ")", ";", "}", "}", "elseif", "(", "null", "!==", "$", "user", ")", "{", "$", "request", "->", "associate", "(", "new", "Identity", "(", "$", "user", ",", "Roles", "::", "none", "(", ")", ")", ")", ";", "$", "this", "->", "authorized", "=", "true", ";", "}", "return", "$", "this", "->", "authorized", ";", "}" ]
checks if request is authorized @param \stubbles\webapp\Request $request current request @param \stubbles\webapp\Response $response response to send @return bool
[ "checks", "if", "request", "is", "authorized" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/ProtectedResource.php#L140-L158
15,426
stubbles/stubbles-webapp-core
src/main/php/auth/ProtectedResource.php
ProtectedResource.authenticate
private function authenticate(Request $request, Response $response) { $authenticationProvider = $this->injector->getInstance(AuthenticationProvider::class); try { $user = $authenticationProvider->authenticate($request); if (null == $user && $this->authConstraint->loginAllowed()) { $response->redirect($authenticationProvider->loginUri($request)); } elseif (null == $user) { // TODO should become 401 Unauthorized // see https://github.com/stubbles/stubbles-webapp-core/issues/73 $this->error = $response->forbidden(); return null; } return $user; } catch (AuthProviderException $ahe) { $this->handleAuthProviderException($ahe, $response); return null; } }
php
private function authenticate(Request $request, Response $response) { $authenticationProvider = $this->injector->getInstance(AuthenticationProvider::class); try { $user = $authenticationProvider->authenticate($request); if (null == $user && $this->authConstraint->loginAllowed()) { $response->redirect($authenticationProvider->loginUri($request)); } elseif (null == $user) { // TODO should become 401 Unauthorized // see https://github.com/stubbles/stubbles-webapp-core/issues/73 $this->error = $response->forbidden(); return null; } return $user; } catch (AuthProviderException $ahe) { $this->handleAuthProviderException($ahe, $response); return null; } }
[ "private", "function", "authenticate", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "authenticationProvider", "=", "$", "this", "->", "injector", "->", "getInstance", "(", "AuthenticationProvider", "::", "class", ")", ";", "try", "{", "$", "user", "=", "$", "authenticationProvider", "->", "authenticate", "(", "$", "request", ")", ";", "if", "(", "null", "==", "$", "user", "&&", "$", "this", "->", "authConstraint", "->", "loginAllowed", "(", ")", ")", "{", "$", "response", "->", "redirect", "(", "$", "authenticationProvider", "->", "loginUri", "(", "$", "request", ")", ")", ";", "}", "elseif", "(", "null", "==", "$", "user", ")", "{", "// TODO should become 401 Unauthorized", "// see https://github.com/stubbles/stubbles-webapp-core/issues/73", "$", "this", "->", "error", "=", "$", "response", "->", "forbidden", "(", ")", ";", "return", "null", ";", "}", "return", "$", "user", ";", "}", "catch", "(", "AuthProviderException", "$", "ahe", ")", "{", "$", "this", "->", "handleAuthProviderException", "(", "$", "ahe", ",", "$", "response", ")", ";", "return", "null", ";", "}", "}" ]
checks whether request is authenticated @param \stubbles\webapp\Request $request current request @param \stubbles\webapp\Response $response response to send @return \stubbles\webapp\auth\User|null
[ "checks", "whether", "request", "is", "authenticated" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/ProtectedResource.php#L167-L186
15,427
stubbles/stubbles-webapp-core
src/main/php/auth/ProtectedResource.php
ProtectedResource.roles
private function roles(Response $response, User $user) { try { return $this->injector->getInstance(AuthorizationProvider::class) ->roles($user); } catch (AuthProviderException $ahe) { $this->handleAuthProviderException($ahe, $response); return null; } }
php
private function roles(Response $response, User $user) { try { return $this->injector->getInstance(AuthorizationProvider::class) ->roles($user); } catch (AuthProviderException $ahe) { $this->handleAuthProviderException($ahe, $response); return null; } }
[ "private", "function", "roles", "(", "Response", "$", "response", ",", "User", "$", "user", ")", "{", "try", "{", "return", "$", "this", "->", "injector", "->", "getInstance", "(", "AuthorizationProvider", "::", "class", ")", "->", "roles", "(", "$", "user", ")", ";", "}", "catch", "(", "AuthProviderException", "$", "ahe", ")", "{", "$", "this", "->", "handleAuthProviderException", "(", "$", "ahe", ",", "$", "response", ")", ";", "return", "null", ";", "}", "}" ]
checks whether expected role is given @param \stubbles\webapp\Response $response response to send @param \stubbles\webapp\auth\User $user @return \stubbles\webapp\auth\Roles|null
[ "checks", "whether", "expected", "role", "is", "given" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/ProtectedResource.php#L195-L204
15,428
stubbles/stubbles-webapp-core
src/main/php/auth/ProtectedResource.php
ProtectedResource.handleAuthProviderException
private function handleAuthProviderException(AuthProviderException $ahe, Response $response) { if ($ahe->isInternal()) { $this->error = $response->internalServerError($ahe); } else { $response->setStatusCode($ahe->getCode()); $this->error = new Error($ahe->getMessage()); } }
php
private function handleAuthProviderException(AuthProviderException $ahe, Response $response) { if ($ahe->isInternal()) { $this->error = $response->internalServerError($ahe); } else { $response->setStatusCode($ahe->getCode()); $this->error = new Error($ahe->getMessage()); } }
[ "private", "function", "handleAuthProviderException", "(", "AuthProviderException", "$", "ahe", ",", "Response", "$", "response", ")", "{", "if", "(", "$", "ahe", "->", "isInternal", "(", ")", ")", "{", "$", "this", "->", "error", "=", "$", "response", "->", "internalServerError", "(", "$", "ahe", ")", ";", "}", "else", "{", "$", "response", "->", "setStatusCode", "(", "$", "ahe", "->", "getCode", "(", ")", ")", ";", "$", "this", "->", "error", "=", "new", "Error", "(", "$", "ahe", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
sets proper response status code depending on exception @param \stubbles\webapp\auth\AuthProviderException $ahe @param \stubbles\webapp\Response $response
[ "sets", "proper", "response", "status", "code", "depending", "on", "exception" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/ProtectedResource.php#L212-L220
15,429
delboy1978uk/form
src/Field/FieldAbstract.php
FieldAbstract.isValid
public function isValid() { $this->errorMessages = []; $this->validatorCollection->rewind(); while ($this->validatorCollection->valid()) { $this->checkForErrors($this->validatorCollection->current()); $this->validatorCollection->next(); } $count = count($this->errorMessages); return $count == 0; }
php
public function isValid() { $this->errorMessages = []; $this->validatorCollection->rewind(); while ($this->validatorCollection->valid()) { $this->checkForErrors($this->validatorCollection->current()); $this->validatorCollection->next(); } $count = count($this->errorMessages); return $count == 0; }
[ "public", "function", "isValid", "(", ")", "{", "$", "this", "->", "errorMessages", "=", "[", "]", ";", "$", "this", "->", "validatorCollection", "->", "rewind", "(", ")", ";", "while", "(", "$", "this", "->", "validatorCollection", "->", "valid", "(", ")", ")", "{", "$", "this", "->", "checkForErrors", "(", "$", "this", "->", "validatorCollection", "->", "current", "(", ")", ")", ";", "$", "this", "->", "validatorCollection", "->", "next", "(", ")", ";", "}", "$", "count", "=", "count", "(", "$", "this", "->", "errorMessages", ")", ";", "return", "$", "count", "==", "0", ";", "}" ]
Runs the checkForErrors method for each field, which adds to errorMessages if invalid @return bool @throws Exception If validation of $value is impossible
[ "Runs", "the", "checkForErrors", "method", "for", "each", "field", "which", "adds", "to", "errorMessages", "if", "invalid" ]
fbbb042d95deef4603a19edf08c0497f720398a6
https://github.com/delboy1978uk/form/blob/fbbb042d95deef4603a19edf08c0497f720398a6/src/Field/FieldAbstract.php#L184-L194
15,430
marmelab/phpcr-api
src/PHPCRAPI/PHPCR/AbstractCollection.php
AbstractCollection.remove
public function remove($name) { if (!array_key_exists($name, $this->items)) { throw new CollectionUnknownKeyException(sprintf('Item name=%s does not exist in collection',$name)); } unset($this->items[$name]); return true; }
php
public function remove($name) { if (!array_key_exists($name, $this->items)) { throw new CollectionUnknownKeyException(sprintf('Item name=%s does not exist in collection',$name)); } unset($this->items[$name]); return true; }
[ "public", "function", "remove", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "items", ")", ")", "{", "throw", "new", "CollectionUnknownKeyException", "(", "sprintf", "(", "'Item name=%s does not exist in collection'", ",", "$", "name", ")", ")", ";", "}", "unset", "(", "$", "this", "->", "items", "[", "$", "name", "]", ")", ";", "return", "true", ";", "}" ]
Remove an item from the collection @param string $name The name of the item @return boolean Returns true in case of success @throws CollectionUnknownKeyException if the item does not exist in the collection @api
[ "Remove", "an", "item", "from", "the", "collection" ]
372149e27d45babe142d0546894362fce987729b
https://github.com/marmelab/phpcr-api/blob/372149e27d45babe142d0546894362fce987729b/src/PHPCRAPI/PHPCR/AbstractCollection.php#L57-L66
15,431
marmelab/phpcr-api
src/PHPCRAPI/PHPCR/AbstractCollection.php
AbstractCollection.get
public function get($name) { if (!array_key_exists($name, $this->items)) { throw new CollectionUnknownKeyException(sprintf('Item name=%s does not exist in collection',$name)); } return $this->items[$name]; }
php
public function get($name) { if (!array_key_exists($name, $this->items)) { throw new CollectionUnknownKeyException(sprintf('Item name=%s does not exist in collection',$name)); } return $this->items[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "items", ")", ")", "{", "throw", "new", "CollectionUnknownKeyException", "(", "sprintf", "(", "'Item name=%s does not exist in collection'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "items", "[", "$", "name", "]", ";", "}" ]
Get an item from the collection @param string $name The name of the item @return Repository The found item @throws CollectionUnknownKeyException if the item does not exist in the collection @api
[ "Get", "an", "item", "from", "the", "collection" ]
372149e27d45babe142d0546894362fce987729b
https://github.com/marmelab/phpcr-api/blob/372149e27d45babe142d0546894362fce987729b/src/PHPCRAPI/PHPCR/AbstractCollection.php#L79-L86
15,432
Srokap/code_review
classes/CodeReview/Analyzer.php
Analyzer.processFile
public function processFile($filePath, $functions) { $result = array( 'problems' => array(), 'fixes' => array(), ); $phpTokens = new PhpFileParser($filePath); $changes = 0; foreach ($phpTokens as $key => $row) { // get non trivial tokens if (is_array($row)) { list($token, $functionName, $lineNumber) = $row; $originalFunctionName = $functionName; // prepare normalized version of function name for matching $functionName = strtolower($functionName); // check for function call if ($token == T_STRING && !$phpTokens->isEqualToToken(T_OBJECT_OPERATOR, $key-1) //not method && !$phpTokens->isEqualToToken(T_DOUBLE_COLON, $key-1) //not static method && !$phpTokens->isEqualToToken(T_FUNCTION, $key-2) //not definition ) { // mark function as called if (function_exists($functionName) && !in_array($functionName, $this->calledFunctions)) { $this->calledFunctions[] = $functionName; } // is it function we're looking for if (isset($functions[$functionName])) { $definingFunctionName = $phpTokens->getDefiningFunctionName($key); //we're skipping deprecated calls that are in deprecated function itself if (!$definingFunctionName || !isset($functions[strtolower($definingFunctionName)])) { $result['problems'][] = array($functions[$functionName], $originalFunctionName, $lineNumber); } //do instant replacement if ($this->fixProblems && isset($this->instantReplacements[$functionName])) { $phpTokens[$key] = array(T_STRING, $this->instantReplacements[$functionName]); $result['fixes'][] = array($originalFunctionName, $this->instantReplacements[$functionName], $lineNumber); $changes++; } } } } } if ($changes) { try { $phpTokens->exportPhp($filePath); } catch (\CodeReview\IOException $e) { echo '*** Error: ' . $e->getMessage() . " ***\n"; } } unset($phpTokens); return $result; }
php
public function processFile($filePath, $functions) { $result = array( 'problems' => array(), 'fixes' => array(), ); $phpTokens = new PhpFileParser($filePath); $changes = 0; foreach ($phpTokens as $key => $row) { // get non trivial tokens if (is_array($row)) { list($token, $functionName, $lineNumber) = $row; $originalFunctionName = $functionName; // prepare normalized version of function name for matching $functionName = strtolower($functionName); // check for function call if ($token == T_STRING && !$phpTokens->isEqualToToken(T_OBJECT_OPERATOR, $key-1) //not method && !$phpTokens->isEqualToToken(T_DOUBLE_COLON, $key-1) //not static method && !$phpTokens->isEqualToToken(T_FUNCTION, $key-2) //not definition ) { // mark function as called if (function_exists($functionName) && !in_array($functionName, $this->calledFunctions)) { $this->calledFunctions[] = $functionName; } // is it function we're looking for if (isset($functions[$functionName])) { $definingFunctionName = $phpTokens->getDefiningFunctionName($key); //we're skipping deprecated calls that are in deprecated function itself if (!$definingFunctionName || !isset($functions[strtolower($definingFunctionName)])) { $result['problems'][] = array($functions[$functionName], $originalFunctionName, $lineNumber); } //do instant replacement if ($this->fixProblems && isset($this->instantReplacements[$functionName])) { $phpTokens[$key] = array(T_STRING, $this->instantReplacements[$functionName]); $result['fixes'][] = array($originalFunctionName, $this->instantReplacements[$functionName], $lineNumber); $changes++; } } } } } if ($changes) { try { $phpTokens->exportPhp($filePath); } catch (\CodeReview\IOException $e) { echo '*** Error: ' . $e->getMessage() . " ***\n"; } } unset($phpTokens); return $result; }
[ "public", "function", "processFile", "(", "$", "filePath", ",", "$", "functions", ")", "{", "$", "result", "=", "array", "(", "'problems'", "=>", "array", "(", ")", ",", "'fixes'", "=>", "array", "(", ")", ",", ")", ";", "$", "phpTokens", "=", "new", "PhpFileParser", "(", "$", "filePath", ")", ";", "$", "changes", "=", "0", ";", "foreach", "(", "$", "phpTokens", "as", "$", "key", "=>", "$", "row", ")", "{", "// get non trivial tokens", "if", "(", "is_array", "(", "$", "row", ")", ")", "{", "list", "(", "$", "token", ",", "$", "functionName", ",", "$", "lineNumber", ")", "=", "$", "row", ";", "$", "originalFunctionName", "=", "$", "functionName", ";", "// prepare normalized version of function name for matching", "$", "functionName", "=", "strtolower", "(", "$", "functionName", ")", ";", "// check for function call", "if", "(", "$", "token", "==", "T_STRING", "&&", "!", "$", "phpTokens", "->", "isEqualToToken", "(", "T_OBJECT_OPERATOR", ",", "$", "key", "-", "1", ")", "//not method", "&&", "!", "$", "phpTokens", "->", "isEqualToToken", "(", "T_DOUBLE_COLON", ",", "$", "key", "-", "1", ")", "//not static method", "&&", "!", "$", "phpTokens", "->", "isEqualToToken", "(", "T_FUNCTION", ",", "$", "key", "-", "2", ")", "//not definition", ")", "{", "// mark function as called", "if", "(", "function_exists", "(", "$", "functionName", ")", "&&", "!", "in_array", "(", "$", "functionName", ",", "$", "this", "->", "calledFunctions", ")", ")", "{", "$", "this", "->", "calledFunctions", "[", "]", "=", "$", "functionName", ";", "}", "// is it function we're looking for", "if", "(", "isset", "(", "$", "functions", "[", "$", "functionName", "]", ")", ")", "{", "$", "definingFunctionName", "=", "$", "phpTokens", "->", "getDefiningFunctionName", "(", "$", "key", ")", ";", "//we're skipping deprecated calls that are in deprecated function itself", "if", "(", "!", "$", "definingFunctionName", "||", "!", "isset", "(", "$", "functions", "[", "strtolower", "(", "$", "definingFunctionName", ")", "]", ")", ")", "{", "$", "result", "[", "'problems'", "]", "[", "]", "=", "array", "(", "$", "functions", "[", "$", "functionName", "]", ",", "$", "originalFunctionName", ",", "$", "lineNumber", ")", ";", "}", "//do instant replacement", "if", "(", "$", "this", "->", "fixProblems", "&&", "isset", "(", "$", "this", "->", "instantReplacements", "[", "$", "functionName", "]", ")", ")", "{", "$", "phpTokens", "[", "$", "key", "]", "=", "array", "(", "T_STRING", ",", "$", "this", "->", "instantReplacements", "[", "$", "functionName", "]", ")", ";", "$", "result", "[", "'fixes'", "]", "[", "]", "=", "array", "(", "$", "originalFunctionName", ",", "$", "this", "->", "instantReplacements", "[", "$", "functionName", "]", ",", "$", "lineNumber", ")", ";", "$", "changes", "++", ";", "}", "}", "}", "}", "}", "if", "(", "$", "changes", ")", "{", "try", "{", "$", "phpTokens", "->", "exportPhp", "(", "$", "filePath", ")", ";", "}", "catch", "(", "\\", "CodeReview", "\\", "IOException", "$", "e", ")", "{", "echo", "'*** Error: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "\" ***\\n\"", ";", "}", "}", "unset", "(", "$", "phpTokens", ")", ";", "return", "$", "result", ";", "}" ]
Find function calls and extract @param string $filePath @param array $functions @return array
[ "Find", "function", "calls", "and", "extract" ]
c79c619f99279cf15713b118ae19b0ef017db362
https://github.com/Srokap/code_review/blob/c79c619f99279cf15713b118ae19b0ef017db362/classes/CodeReview/Analyzer.php#L224-L278
15,433
FrenchFrogs/framework
src/Form/Renderer/Inline.php
Inline.hidden
public function hidden(Form\Element\Hidden $element) { $html = html('input', $element->getAttributes()); return $html; }
php
public function hidden(Form\Element\Hidden $element) { $html = html('input', $element->getAttributes()); return $html; }
[ "public", "function", "hidden", "(", "Form", "\\", "Element", "\\", "Hidden", "$", "element", ")", "{", "$", "html", "=", "html", "(", "'input'", ",", "$", "element", "->", "getAttributes", "(", ")", ")", ";", "return", "$", "html", ";", "}" ]
render hidden input @param \FrenchFrogs\Form\Element\Hidden $element @return string
[ "render", "hidden", "input" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Renderer/Inline.php#L314-L318
15,434
FrenchFrogs/framework
src/Form/Renderer/Inline.php
Inline.label_date
public function label_date(Form\Element\LabelDate $element) { $html = '<label class="col-md-3 control-label">' . $element->getLabel() . '</label>'; $html .= '<div class="col-md-9"><p class="form-control-static">' . $element->getDisplayValue() . '</p></div>'; $class = Style::FORM_GROUP_CLASS . ' row'; return html('div', compact('class'), $html); }
php
public function label_date(Form\Element\LabelDate $element) { $html = '<label class="col-md-3 control-label">' . $element->getLabel() . '</label>'; $html .= '<div class="col-md-9"><p class="form-control-static">' . $element->getDisplayValue() . '</p></div>'; $class = Style::FORM_GROUP_CLASS . ' row'; return html('div', compact('class'), $html); }
[ "public", "function", "label_date", "(", "Form", "\\", "Element", "\\", "LabelDate", "$", "element", ")", "{", "$", "html", "=", "'<label class=\"col-md-3 control-label\">'", ".", "$", "element", "->", "getLabel", "(", ")", ".", "'</label>'", ";", "$", "html", ".=", "'<div class=\"col-md-9\"><p class=\"form-control-static\">'", ".", "$", "element", "->", "getDisplayValue", "(", ")", ".", "'</p></div>'", ";", "$", "class", "=", "Style", "::", "FORM_GROUP_CLASS", ".", "' row'", ";", "return", "html", "(", "'div'", ",", "compact", "(", "'class'", ")", ",", "$", "html", ")", ";", "}" ]
Render Label Date @param \FrenchFrogs\Form\Element\LabelDate $element @return string
[ "Render", "Label", "Date" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Renderer/Inline.php#L342-L349
15,435
FrenchFrogs/framework
src/Form/Renderer/Inline.php
Inline.image
public function image(Form\Element\Image $element) { $element->addStyle('object-fit', 'cover !important;'); $element->addAttribute('src', $element->getValue()); $html = '<label class="col-md-3 control-label">' . $element->getLabel() . '</label>'; $html .= '<div class="col-md-9"><p class="form-control-static">' . html('img', $element->getAttributes()) . '</p></div>'; $class = Style::FORM_GROUP_CLASS . ' row'; return html('div', compact('class'), $html); }
php
public function image(Form\Element\Image $element) { $element->addStyle('object-fit', 'cover !important;'); $element->addAttribute('src', $element->getValue()); $html = '<label class="col-md-3 control-label">' . $element->getLabel() . '</label>'; $html .= '<div class="col-md-9"><p class="form-control-static">' . html('img', $element->getAttributes()) . '</p></div>'; $class = Style::FORM_GROUP_CLASS . ' row'; return html('div', compact('class'), $html); }
[ "public", "function", "image", "(", "Form", "\\", "Element", "\\", "Image", "$", "element", ")", "{", "$", "element", "->", "addStyle", "(", "'object-fit'", ",", "'cover !important;'", ")", ";", "$", "element", "->", "addAttribute", "(", "'src'", ",", "$", "element", "->", "getValue", "(", ")", ")", ";", "$", "html", "=", "'<label class=\"col-md-3 control-label\">'", ".", "$", "element", "->", "getLabel", "(", ")", ".", "'</label>'", ";", "$", "html", ".=", "'<div class=\"col-md-9\"><p class=\"form-control-static\">'", ".", "html", "(", "'img'", ",", "$", "element", "->", "getAttributes", "(", ")", ")", ".", "'</p></div>'", ";", "$", "class", "=", "Style", "::", "FORM_GROUP_CLASS", ".", "' row'", ";", "return", "html", "(", "'div'", ",", "compact", "(", "'class'", ")", ",", "$", "html", ")", ";", "}" ]
Render Image input @param \FrenchFrogs\Form\Element\Label $element @return string
[ "Render", "Image", "input" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Renderer/Inline.php#L374-L385
15,436
FrenchFrogs/framework
src/Form/Renderer/Inline.php
Inline.button
public function button(Form\Element\Button $element) { //@todo prendre en compte les option et les size $element->addClass('btn btn-default'); $element->addAttribute('id', $element->getName()); $html = '<div class="form-group">'; $html .= '<label class="col-md-3 control-label">&nbsp;</label>'; $html .= '<div class="col-md-9">' . html('button', $element->getAttributes(), $element->getLabel()) . '</div>'; $html .= '</div>'; return $html; }
php
public function button(Form\Element\Button $element) { //@todo prendre en compte les option et les size $element->addClass('btn btn-default'); $element->addAttribute('id', $element->getName()); $html = '<div class="form-group">'; $html .= '<label class="col-md-3 control-label">&nbsp;</label>'; $html .= '<div class="col-md-9">' . html('button', $element->getAttributes(), $element->getLabel()) . '</div>'; $html .= '</div>'; return $html; }
[ "public", "function", "button", "(", "Form", "\\", "Element", "\\", "Button", "$", "element", ")", "{", "//@todo prendre en compte les option et les size", "$", "element", "->", "addClass", "(", "'btn btn-default'", ")", ";", "$", "element", "->", "addAttribute", "(", "'id'", ",", "$", "element", "->", "getName", "(", ")", ")", ";", "$", "html", "=", "'<div class=\"form-group\">'", ";", "$", "html", ".=", "'<label class=\"col-md-3 control-label\">&nbsp;</label>'", ";", "$", "html", ".=", "'<div class=\"col-md-9\">'", ".", "html", "(", "'button'", ",", "$", "element", "->", "getAttributes", "(", ")", ",", "$", "element", "->", "getLabel", "(", ")", ")", ".", "'</div>'", ";", "$", "html", ".=", "'</div>'", ";", "return", "$", "html", ";", "}" ]
rende a button element @param \FrenchFrogs\Form\Element\Button $element @return string
[ "rende", "a", "button", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Renderer/Inline.php#L410-L421
15,437
FrenchFrogs/framework
src/Form/Renderer/Inline.php
Inline.date_range
public function date_range(Form\Element\DateRange $element) { // CLASS $class = Style::FORM_GROUP_CLASS; // ERROR if($hasError = !$element->getValidator()->isValid()){ if(empty($element->getAttribute('data-placement'))){$element->addAttribute('data-placement','bottom');} $message = ''; foreach($element->getValidator()->getErrors() as $error){ $message .= $error . ' '; } $element->addAttribute('data-original-title',$message); $element->addAttribute('data-toggle', 'tooltip'); $class .= ' ' .Style::FORM_GROUP_ERROR; } // LABEL $label = ''; if ($element->getForm()->hasLabel()) { $label = '<label for="' . $element->getName() . '" class="col-md-3 control-label">' . $element->getLabel() . ($element->hasRule('required') ? ' *' : '') . '</label>'; } $html = html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getFrom()]); $html .= '<span class="input-group-addon"> => </span>'; $html .= html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getTo()]); $html = html('div', [ 'class' => 'input-group input-large date-picker daterange input-daterange', 'data-date-format' => configurator()->get('form.element.date.formatjs') ], $html); // DESCRIPTION if ($element->hasDescription()) { $html .= html('span', ['class' => 'help-block'], $element->getDescription()); } // FINAL CONTAINER $html = html('div', ['class' => 'col-md-9'], $html); return html('div', compact('class'), $label . $html); }
php
public function date_range(Form\Element\DateRange $element) { // CLASS $class = Style::FORM_GROUP_CLASS; // ERROR if($hasError = !$element->getValidator()->isValid()){ if(empty($element->getAttribute('data-placement'))){$element->addAttribute('data-placement','bottom');} $message = ''; foreach($element->getValidator()->getErrors() as $error){ $message .= $error . ' '; } $element->addAttribute('data-original-title',$message); $element->addAttribute('data-toggle', 'tooltip'); $class .= ' ' .Style::FORM_GROUP_ERROR; } // LABEL $label = ''; if ($element->getForm()->hasLabel()) { $label = '<label for="' . $element->getName() . '" class="col-md-3 control-label">' . $element->getLabel() . ($element->hasRule('required') ? ' *' : '') . '</label>'; } $html = html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getFrom()]); $html .= '<span class="input-group-addon"> => </span>'; $html .= html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getTo()]); $html = html('div', [ 'class' => 'input-group input-large date-picker daterange input-daterange', 'data-date-format' => configurator()->get('form.element.date.formatjs') ], $html); // DESCRIPTION if ($element->hasDescription()) { $html .= html('span', ['class' => 'help-block'], $element->getDescription()); } // FINAL CONTAINER $html = html('div', ['class' => 'col-md-9'], $html); return html('div', compact('class'), $label . $html); }
[ "public", "function", "date_range", "(", "Form", "\\", "Element", "\\", "DateRange", "$", "element", ")", "{", "// CLASS", "$", "class", "=", "Style", "::", "FORM_GROUP_CLASS", ";", "// ERROR", "if", "(", "$", "hasError", "=", "!", "$", "element", "->", "getValidator", "(", ")", "->", "isValid", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "element", "->", "getAttribute", "(", "'data-placement'", ")", ")", ")", "{", "$", "element", "->", "addAttribute", "(", "'data-placement'", ",", "'bottom'", ")", ";", "}", "$", "message", "=", "''", ";", "foreach", "(", "$", "element", "->", "getValidator", "(", ")", "->", "getErrors", "(", ")", "as", "$", "error", ")", "{", "$", "message", ".=", "$", "error", ".", "' '", ";", "}", "$", "element", "->", "addAttribute", "(", "'data-original-title'", ",", "$", "message", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-toggle'", ",", "'tooltip'", ")", ";", "$", "class", ".=", "' '", ".", "Style", "::", "FORM_GROUP_ERROR", ";", "}", "// LABEL", "$", "label", "=", "''", ";", "if", "(", "$", "element", "->", "getForm", "(", ")", "->", "hasLabel", "(", ")", ")", "{", "$", "label", "=", "'<label for=\"'", ".", "$", "element", "->", "getName", "(", ")", ".", "'\" class=\"col-md-3 control-label\">'", ".", "$", "element", "->", "getLabel", "(", ")", ".", "(", "$", "element", "->", "hasRule", "(", "'required'", ")", "?", "' *'", ":", "''", ")", ".", "'</label>'", ";", "}", "$", "html", "=", "html", "(", "'input'", ",", "[", "'type'", "=>", "'text'", ",", "'class'", "=>", "Style", "::", "FORM_ELEMENT_CONTROL", ",", "'name'", "=>", "$", "element", "->", "getFrom", "(", ")", "]", ")", ";", "$", "html", ".=", "'<span class=\"input-group-addon\"> => </span>'", ";", "$", "html", ".=", "html", "(", "'input'", ",", "[", "'type'", "=>", "'text'", ",", "'class'", "=>", "Style", "::", "FORM_ELEMENT_CONTROL", ",", "'name'", "=>", "$", "element", "->", "getTo", "(", ")", "]", ")", ";", "$", "html", "=", "html", "(", "'div'", ",", "[", "'class'", "=>", "'input-group input-large date-picker daterange input-daterange'", ",", "'data-date-format'", "=>", "configurator", "(", ")", "->", "get", "(", "'form.element.date.formatjs'", ")", "]", ",", "$", "html", ")", ";", "// DESCRIPTION", "if", "(", "$", "element", "->", "hasDescription", "(", ")", ")", "{", "$", "html", ".=", "html", "(", "'span'", ",", "[", "'class'", "=>", "'help-block'", "]", ",", "$", "element", "->", "getDescription", "(", ")", ")", ";", "}", "// FINAL CONTAINER", "$", "html", "=", "html", "(", "'div'", ",", "[", "'class'", "=>", "'col-md-9'", "]", ",", "$", "html", ")", ";", "return", "html", "(", "'div'", ",", "compact", "(", "'class'", ")", ",", "$", "label", ".", "$", "html", ")", ";", "}" ]
Render a date range element @param Form\Element\DateRange $element
[ "Render", "a", "date", "range", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Renderer/Inline.php#L704-L746
15,438
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtPage/PageRule.php
PageRule.parseRuleString
protected function parseRuleString($ruleString) { // Remove at-rule name and unnecessary white-spaces $ruleString = preg_replace('/^[ \r\n\t\f]*@page[ \r\n\t\f]*/i', '', $ruleString); $ruleString = trim($ruleString, " \r\n\t\f"); // Extract query list and create a rule from it $pageSelector = new PageSelector($ruleString, $this->getStyleSheet()); $this->setSelector($pageSelector); }
php
protected function parseRuleString($ruleString) { // Remove at-rule name and unnecessary white-spaces $ruleString = preg_replace('/^[ \r\n\t\f]*@page[ \r\n\t\f]*/i', '', $ruleString); $ruleString = trim($ruleString, " \r\n\t\f"); // Extract query list and create a rule from it $pageSelector = new PageSelector($ruleString, $this->getStyleSheet()); $this->setSelector($pageSelector); }
[ "protected", "function", "parseRuleString", "(", "$", "ruleString", ")", "{", "// Remove at-rule name and unnecessary white-spaces", "$", "ruleString", "=", "preg_replace", "(", "'/^[ \\r\\n\\t\\f]*@page[ \\r\\n\\t\\f]*/i'", ",", "''", ",", "$", "ruleString", ")", ";", "$", "ruleString", "=", "trim", "(", "$", "ruleString", ",", "\" \\r\\n\\t\\f\"", ")", ";", "// Extract query list and create a rule from it", "$", "pageSelector", "=", "new", "PageSelector", "(", "$", "ruleString", ",", "$", "this", "->", "getStyleSheet", "(", ")", ")", ";", "$", "this", "->", "setSelector", "(", "$", "pageSelector", ")", ";", "}" ]
Parses the page rule. @param string $ruleString
[ "Parses", "the", "page", "rule", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtPage/PageRule.php#L76-L85
15,439
JoffreyPoreeCoding/MongoDB-ODM
src/Factory/DocumentManagerFactory.php
DocumentManagerFactory.createDocumentManager
public function createDocumentManager($mongouri, $dbName, $debug = false, $managerId = "", $newConnection = false, $options = []) { if (!isset($this->connexions[$mongouri])) { $client = new Client($mongouri); } if (!isset($this->managers[$managerId])) { $database = new Database($client->getManager(), $dbName); $class = $this->repositoryFactoryClass; $repositoryFactory = new $class(null, $this->classMetadataFactory); $this->managers[$managerId] = new DocumentManager( $client, $database, $repositoryFactory, $debug, $options, [] ); } return $this->managers[$managerId]; }
php
public function createDocumentManager($mongouri, $dbName, $debug = false, $managerId = "", $newConnection = false, $options = []) { if (!isset($this->connexions[$mongouri])) { $client = new Client($mongouri); } if (!isset($this->managers[$managerId])) { $database = new Database($client->getManager(), $dbName); $class = $this->repositoryFactoryClass; $repositoryFactory = new $class(null, $this->classMetadataFactory); $this->managers[$managerId] = new DocumentManager( $client, $database, $repositoryFactory, $debug, $options, [] ); } return $this->managers[$managerId]; }
[ "public", "function", "createDocumentManager", "(", "$", "mongouri", ",", "$", "dbName", ",", "$", "debug", "=", "false", ",", "$", "managerId", "=", "\"\"", ",", "$", "newConnection", "=", "false", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "connexions", "[", "$", "mongouri", "]", ")", ")", "{", "$", "client", "=", "new", "Client", "(", "$", "mongouri", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "managers", "[", "$", "managerId", "]", ")", ")", "{", "$", "database", "=", "new", "Database", "(", "$", "client", "->", "getManager", "(", ")", ",", "$", "dbName", ")", ";", "$", "class", "=", "$", "this", "->", "repositoryFactoryClass", ";", "$", "repositoryFactory", "=", "new", "$", "class", "(", "null", ",", "$", "this", "->", "classMetadataFactory", ")", ";", "$", "this", "->", "managers", "[", "$", "managerId", "]", "=", "new", "DocumentManager", "(", "$", "client", ",", "$", "database", ",", "$", "repositoryFactory", ",", "$", "debug", ",", "$", "options", ",", "[", "]", ")", ";", "}", "return", "$", "this", "->", "managers", "[", "$", "managerId", "]", ";", "}" ]
Create new DocumentManager from mongouri and DB name @param string $mongouri mongodb uri (mongodb://user:[email protected]/auth_db) @param string $dbName name of the DB where to work @param boolean $debug Enable debug mode or not @param mixed $managerId Manager unique id @param boolean $newConnection Force to open new connection @return DocumentManager A DocumentManager connected to mongouri specified
[ "Create", "new", "DocumentManager", "from", "mongouri", "and", "DB", "name" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Factory/DocumentManagerFactory.php#L62-L87
15,440
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php
StubReplaceAttributeData.getFillableReplace
protected function getFillableReplace() { $attributes = array_merge( $this->data['normal_fillable'], $this->data['translated_fillable'] ); if ( ! count($attributes)) return ''; return $this->getAttributePropertySection('fillable', $attributes); }
php
protected function getFillableReplace() { $attributes = array_merge( $this->data['normal_fillable'], $this->data['translated_fillable'] ); if ( ! count($attributes)) return ''; return $this->getAttributePropertySection('fillable', $attributes); }
[ "protected", "function", "getFillableReplace", "(", ")", "{", "$", "attributes", "=", "array_merge", "(", "$", "this", "->", "data", "[", "'normal_fillable'", "]", ",", "$", "this", "->", "data", "[", "'translated_fillable'", "]", ")", ";", "if", "(", "!", "count", "(", "$", "attributes", ")", ")", "return", "''", ";", "return", "$", "this", "->", "getAttributePropertySection", "(", "'fillable'", ",", "$", "attributes", ")", ";", "}" ]
Returns the replacement for the fillable placeholder @return string
[ "Returns", "the", "replacement", "for", "the", "fillable", "placeholder" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php#L23-L33
15,441
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php
StubReplaceAttributeData.getCastsReplace
protected function getCastsReplace() { $attributes = $this->data['casts'] ?: []; if ( ! count($attributes)) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($attributes as $attribute => $type) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$casts = [\n"; foreach ($attributes as $attribute => $type) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => '" . $type . "',\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
php
protected function getCastsReplace() { $attributes = $this->data['casts'] ?: []; if ( ! count($attributes)) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($attributes as $attribute => $type) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$casts = [\n"; foreach ($attributes as $attribute => $type) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => '" . $type . "',\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
[ "protected", "function", "getCastsReplace", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "data", "[", "'casts'", "]", "?", ":", "[", "]", ";", "if", "(", "!", "count", "(", "$", "attributes", ")", ")", "return", "''", ";", "// align assignment signs by longest attribute", "$", "longestLength", "=", "0", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "type", ")", "{", "if", "(", "strlen", "(", "$", "attribute", ")", ">", "$", "longestLength", ")", "{", "$", "longestLength", "=", "strlen", "(", "$", "attribute", ")", ";", "}", "}", "$", "replace", "=", "$", "this", "->", "tab", "(", ")", ".", "\"protected \\$casts = [\\n\"", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "type", ")", "{", "$", "replace", ".=", "$", "this", "->", "tab", "(", "2", ")", ".", "\"'\"", ".", "str_pad", "(", "$", "attribute", ".", "\"'\"", ",", "$", "longestLength", "+", "1", ")", ".", "\" => '\"", ".", "$", "type", ".", "\"',\\n\"", ";", "}", "$", "replace", ".=", "$", "this", "->", "tab", "(", ")", ".", "\"];\\n\\n\"", ";", "return", "$", "replace", ";", "}" ]
Returns the replacement for the casts placeholder @return string
[ "Returns", "the", "replacement", "for", "the", "casts", "placeholder" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php#L68-L96
15,442
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php
StubReplaceAttributeData.getDefaultsReplace
protected function getDefaultsReplace() { if ( ! config('pxlcms.generator.models.include_defaults')) return ''; $attributes = $this->data['defaults'] ?: []; if ( ! count($attributes)) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($attributes as $attribute => $default) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$attributes = [\n"; foreach ($attributes as $attribute => $default) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => " . $default . ",\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
php
protected function getDefaultsReplace() { if ( ! config('pxlcms.generator.models.include_defaults')) return ''; $attributes = $this->data['defaults'] ?: []; if ( ! count($attributes)) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($attributes as $attribute => $default) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$attributes = [\n"; foreach ($attributes as $attribute => $default) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => " . $default . ",\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
[ "protected", "function", "getDefaultsReplace", "(", ")", "{", "if", "(", "!", "config", "(", "'pxlcms.generator.models.include_defaults'", ")", ")", "return", "''", ";", "$", "attributes", "=", "$", "this", "->", "data", "[", "'defaults'", "]", "?", ":", "[", "]", ";", "if", "(", "!", "count", "(", "$", "attributes", ")", ")", "return", "''", ";", "// align assignment signs by longest attribute", "$", "longestLength", "=", "0", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "default", ")", "{", "if", "(", "strlen", "(", "$", "attribute", ")", ">", "$", "longestLength", ")", "{", "$", "longestLength", "=", "strlen", "(", "$", "attribute", ")", ";", "}", "}", "$", "replace", "=", "$", "this", "->", "tab", "(", ")", ".", "\"protected \\$attributes = [\\n\"", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "default", ")", "{", "$", "replace", ".=", "$", "this", "->", "tab", "(", "2", ")", ".", "\"'\"", ".", "str_pad", "(", "$", "attribute", ".", "\"'\"", ",", "$", "longestLength", "+", "1", ")", ".", "\" => \"", ".", "$", "default", ".", "\",\\n\"", ";", "}", "$", "replace", ".=", "$", "this", "->", "tab", "(", ")", ".", "\"];\\n\\n\"", ";", "return", "$", "replace", ";", "}" ]
Returns the replacement for the default attributes placeholder @return string
[ "Returns", "the", "replacement", "for", "the", "default", "attributes", "placeholder" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php#L117-L147
15,443
okvpn/fixture-bundle
src/Entity/Repository/DataFixtureRepository.php
DataFixtureRepository.updateDataFixutreHistory
public function updateDataFixutreHistory(array $updateFields, $where, array $parameters = []) { $qb = $this->_em ->createQueryBuilder() ->update('OkvpnFixtureBundle:DataFixture', 'm') ->where($where); foreach ($updateFields as $fieldName => $fieldValue) { $qb->set($fieldName, $fieldValue); } $qb->getQuery()->execute($parameters); }
php
public function updateDataFixutreHistory(array $updateFields, $where, array $parameters = []) { $qb = $this->_em ->createQueryBuilder() ->update('OkvpnFixtureBundle:DataFixture', 'm') ->where($where); foreach ($updateFields as $fieldName => $fieldValue) { $qb->set($fieldName, $fieldValue); } $qb->getQuery()->execute($parameters); }
[ "public", "function", "updateDataFixutreHistory", "(", "array", "$", "updateFields", ",", "$", "where", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "qb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "update", "(", "'OkvpnFixtureBundle:DataFixture'", ",", "'m'", ")", "->", "where", "(", "$", "where", ")", ";", "foreach", "(", "$", "updateFields", "as", "$", "fieldName", "=>", "$", "fieldValue", ")", "{", "$", "qb", "->", "set", "(", "$", "fieldName", ",", "$", "fieldValue", ")", ";", "}", "$", "qb", "->", "getQuery", "(", ")", "->", "execute", "(", "$", "parameters", ")", ";", "}" ]
Update data fixture history @param array $updateFields assoc array with field names and values that should be updated @param string $where condition @param array $parameters optional parameters for where condition
[ "Update", "data", "fixture", "history" ]
243b5e4dff9773e97fa447280e929c936a5d66ae
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Entity/Repository/DataFixtureRepository.php#L45-L56
15,444
axelitus/php-base
src/DotArr.php
DotArr.is
public static function is(array $arr) { $isdot = true; foreach ($arr as $key => $value) { if (!($isdot = ($isdot && !Str::contains($key, '.')))) { break; } if (is_array($value)) { $isdot = ($isdot && static::is($value)); } } return $isdot; }
php
public static function is(array $arr) { $isdot = true; foreach ($arr as $key => $value) { if (!($isdot = ($isdot && !Str::contains($key, '.')))) { break; } if (is_array($value)) { $isdot = ($isdot && static::is($value)); } } return $isdot; }
[ "public", "static", "function", "is", "(", "array", "$", "arr", ")", "{", "$", "isdot", "=", "true", ";", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "(", "$", "isdot", "=", "(", "$", "isdot", "&&", "!", "Str", "::", "contains", "(", "$", "key", ",", "'.'", ")", ")", ")", ")", "{", "break", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "isdot", "=", "(", "$", "isdot", "&&", "static", "::", "is", "(", "$", "value", ")", ")", ";", "}", "}", "return", "$", "isdot", ";", "}" ]
Tests if the given value is a dot-notated accessible array. This function tests if none of the keys contains a dot. @param array $arr The array to test. @return bool Returns true if the array is dot-notated accessible, false otherwise. @SuppressWarnings(PHPMD.ShortMethodName)
[ "Tests", "if", "the", "given", "value", "is", "a", "dot", "-", "notated", "accessible", "array", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L37-L50
15,445
axelitus/php-base
src/DotArr.php
DotArr.getMultiple
protected static function getMultiple(array $arr, array $keys, $default = null) { $return = []; foreach ($keys as $key) { $return[$key] = static::get($arr, $key, $default); } return $return; }
php
protected static function getMultiple(array $arr, array $keys, $default = null) { $return = []; foreach ($keys as $key) { $return[$key] = static::get($arr, $key, $default); } return $return; }
[ "protected", "static", "function", "getMultiple", "(", "array", "$", "arr", ",", "array", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "return", "[", "$", "key", "]", "=", "static", "::", "get", "(", "$", "arr", ",", "$", "key", ",", "$", "default", ")", ";", "}", "return", "$", "return", ";", "}" ]
Gets multiple values from a dot-notated array. @internal @param array $arr The array to get the values from. @param array $keys The keys to the items to get the values from. @param mixed $default A default value to return if the item is not found. @return array The values of the found items or the default values if not found.
[ "Gets", "multiple", "values", "from", "a", "dot", "-", "notated", "array", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L114-L122
15,446
axelitus/php-base
src/DotArr.php
DotArr.setMultiple
protected static function setMultiple(array &$arr, array $keyvals) { foreach ($keyvals as $key => $value) { static::set($arr, $key, $value); } }
php
protected static function setMultiple(array &$arr, array $keyvals) { foreach ($keyvals as $key => $value) { static::set($arr, $key, $value); } }
[ "protected", "static", "function", "setMultiple", "(", "array", "&", "$", "arr", ",", "array", "$", "keyvals", ")", "{", "foreach", "(", "$", "keyvals", "as", "$", "key", "=>", "$", "value", ")", "{", "static", "::", "set", "(", "$", "arr", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Sets multiple values to a dot-notated array. @internal @param array $arr The array to set the values to. @param array $keyvals The key=>value associative array to set the item values.
[ "Sets", "multiple", "values", "to", "a", "dot", "-", "notated", "array", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L180-L185
15,447
axelitus/php-base
src/DotArr.php
DotArr.deleteMultiple
protected static function deleteMultiple(array &$arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::delete($arr, $key); } return $return; }
php
protected static function deleteMultiple(array &$arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::delete($arr, $key); } return $return; }
[ "protected", "static", "function", "deleteMultiple", "(", "array", "&", "$", "arr", ",", "array", "$", "keys", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "return", "[", "$", "key", "]", "=", "static", "::", "delete", "(", "$", "arr", ",", "$", "key", ")", ";", "}", "return", "$", "return", ";", "}" ]
Deletes multiple items from a dot-notated array. @internal @param array $arr The array to delete the items from. @param array $keys The keys of the items to delete. @return array Returns an array of results.
[ "Deletes", "multiple", "items", "from", "a", "dot", "-", "notated", "array", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L254-L262
15,448
axelitus/php-base
src/DotArr.php
DotArr.keyExistsMultiple
protected static function keyExistsMultiple(array $arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::keyExists($arr, $key); } return $return; }
php
protected static function keyExistsMultiple(array $arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::keyExists($arr, $key); } return $return; }
[ "protected", "static", "function", "keyExistsMultiple", "(", "array", "$", "arr", ",", "array", "$", "keys", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "return", "[", "$", "key", "]", "=", "static", "::", "keyExists", "(", "$", "arr", ",", "$", "key", ")", ";", "}", "return", "$", "return", ";", "}" ]
Verifies if multiple keys exists in a dot-notated array or not. @param array $arr The dot-notated array. @param array $keys The keys to verify. @return array The array of results.
[ "Verifies", "if", "multiple", "keys", "exists", "in", "a", "dot", "-", "notated", "array", "or", "not", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L325-L333
15,449
axelitus/php-base
src/DotArr.php
DotArr.keyMatchesMultiple
protected static function keyMatchesMultiple(array $arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::keyMatches($arr, $key); } return $return; }
php
protected static function keyMatchesMultiple(array $arr, array $keys) { $return = []; foreach ($keys as $key) { $return[$key] = static::keyMatches($arr, $key); } return $return; }
[ "protected", "static", "function", "keyMatchesMultiple", "(", "array", "$", "arr", ",", "array", "$", "keys", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "return", "[", "$", "key", "]", "=", "static", "::", "keyMatches", "(", "$", "arr", ",", "$", "key", ")", ";", "}", "return", "$", "return", ";", "}" ]
Gets full and partial matches to multiple keys. @param array $arr The array to match the keys to. @param array $keys The keys to be matched. @return array The array of ful and partial matches of the given keys.
[ "Gets", "full", "and", "partial", "matches", "to", "multiple", "keys", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L396-L404
15,450
axelitus/php-base
src/DotArr.php
DotArr.convert
public static function convert(array $arr) { $converted = []; foreach ($arr as $key => $value) { $keys = explode('.', $key); $tmp =& $converted; foreach ($keys as $k) { if (!array_key_exists($k, $tmp) || !is_array($tmp[$k])) { $tmp[$k] = []; } $tmp =& $tmp[$k]; } $tmp = is_array($value) ? static::convert($value) : $value; } return $converted; }
php
public static function convert(array $arr) { $converted = []; foreach ($arr as $key => $value) { $keys = explode('.', $key); $tmp =& $converted; foreach ($keys as $k) { if (!array_key_exists($k, $tmp) || !is_array($tmp[$k])) { $tmp[$k] = []; } $tmp =& $tmp[$k]; } $tmp = is_array($value) ? static::convert($value) : $value; } return $converted; }
[ "public", "static", "function", "convert", "(", "array", "$", "arr", ")", "{", "$", "converted", "=", "[", "]", ";", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "tmp", "=", "&", "$", "converted", ";", "foreach", "(", "$", "keys", "as", "$", "k", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "k", ",", "$", "tmp", ")", "||", "!", "is_array", "(", "$", "tmp", "[", "$", "k", "]", ")", ")", "{", "$", "tmp", "[", "$", "k", "]", "=", "[", "]", ";", "}", "$", "tmp", "=", "&", "$", "tmp", "[", "$", "k", "]", ";", "}", "$", "tmp", "=", "is_array", "(", "$", "value", ")", "?", "static", "::", "convert", "(", "$", "value", ")", ":", "$", "value", ";", "}", "return", "$", "converted", ";", "}" ]
Converts an array to a dot-notated array. Be aware that some values may be lost in this conversion if a partial key match is found twice or more. The last found element of a partial key match is the one that takes precedence. @param array $arr The array to convert. @return array The converted array.
[ "Converts", "an", "array", "to", "a", "dot", "-", "notated", "array", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/DotArr.php#L420-L438
15,451
activecollab/databasestructure
src/Builder/Builder.php
Builder.registerEventHandler
public function registerEventHandler($event, callable $handler) { if (empty($event)) { throw new InvalidArgumentException('Event name is required'); } if (is_callable($handler)) { if (empty($this->event_handlers[$event])) { $this->event_handlers[$event] = []; } $this->event_handlers[$event][] = $handler; } else { throw new InvalidArgumentException('Handler not callable'); } }
php
public function registerEventHandler($event, callable $handler) { if (empty($event)) { throw new InvalidArgumentException('Event name is required'); } if (is_callable($handler)) { if (empty($this->event_handlers[$event])) { $this->event_handlers[$event] = []; } $this->event_handlers[$event][] = $handler; } else { throw new InvalidArgumentException('Handler not callable'); } }
[ "public", "function", "registerEventHandler", "(", "$", "event", ",", "callable", "$", "handler", ")", "{", "if", "(", "empty", "(", "$", "event", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Event name is required'", ")", ";", "}", "if", "(", "is_callable", "(", "$", "handler", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "event_handlers", "[", "$", "event", "]", ")", ")", "{", "$", "this", "->", "event_handlers", "[", "$", "event", "]", "=", "[", "]", ";", "}", "$", "this", "->", "event_handlers", "[", "$", "event", "]", "[", "]", "=", "$", "handler", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Handler not callable'", ")", ";", "}", "}" ]
Register an internal event handler. @param string $event @param callable $handler
[ "Register", "an", "internal", "event", "handler", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/Builder.php#L80-L95
15,452
jamband/ripple
src/Utility.php
Utility.domain
private static function domain(string $url): ?string { $domain = parse_url($url, PHP_URL_HOST); if (null !== $domain) { return implode('.', array_slice(explode('.', $domain), -2)); } return null; }
php
private static function domain(string $url): ?string { $domain = parse_url($url, PHP_URL_HOST); if (null !== $domain) { return implode('.', array_slice(explode('.', $domain), -2)); } return null; }
[ "private", "static", "function", "domain", "(", "string", "$", "url", ")", ":", "?", "string", "{", "$", "domain", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_HOST", ")", ";", "if", "(", "null", "!==", "$", "domain", ")", "{", "return", "implode", "(", "'.'", ",", "array_slice", "(", "explode", "(", "'.'", ",", "$", "domain", ")", ",", "-", "2", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns the domain name from URL. @param string $url @return null|string
[ "Returns", "the", "domain", "name", "from", "URL", "." ]
91443f8016af76cacf749e05633abc1bdaf4675f
https://github.com/jamband/ripple/blob/91443f8016af76cacf749e05633abc1bdaf4675f/src/Utility.php#L28-L37
15,453
ekyna/GlsUniBox
Api/Service.php
Service.getLabel
static public function getLabel($code) { static::isValid($code); switch ($code) { case static::EBP : return 'Euro Business Parcel'; case static::GBP : return 'Global Business Parcel'; case static::EP : return 'Express Parcel Guaranteed'; case static::SHD : return 'Shop Delivery Service'; case static::FDF : return 'Flex Delivery Service'; case static::BP : default: return 'Business Parcel'; } }
php
static public function getLabel($code) { static::isValid($code); switch ($code) { case static::EBP : return 'Euro Business Parcel'; case static::GBP : return 'Global Business Parcel'; case static::EP : return 'Express Parcel Guaranteed'; case static::SHD : return 'Shop Delivery Service'; case static::FDF : return 'Flex Delivery Service'; case static::BP : default: return 'Business Parcel'; } }
[ "static", "public", "function", "getLabel", "(", "$", "code", ")", "{", "static", "::", "isValid", "(", "$", "code", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "static", "::", "EBP", ":", "return", "'Euro Business Parcel'", ";", "case", "static", "::", "GBP", ":", "return", "'Global Business Parcel'", ";", "case", "static", "::", "EP", ":", "return", "'Express Parcel Guaranteed'", ";", "case", "static", "::", "SHD", ":", "return", "'Shop Delivery Service'", ";", "case", "static", "::", "FDF", ":", "return", "'Flex Delivery Service'", ";", "case", "static", "::", "BP", ":", "default", ":", "return", "'Business Parcel'", ";", "}", "}" ]
Returns the label for the given product code. @param string $code @return string
[ "Returns", "the", "label", "for", "the", "given", "product", "code", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Service.php#L90-L109
15,454
ekyna/GlsUniBox
Api/Service.php
Service.getUniShip
static function getUniShip($code) { static::isValid($code); switch ($code) { case static::EBP : return 'CC'; case static::GBP : return 'FF'; case static::EP : case static::SHD : case static::FDF : return null; case static::BP : default: return 'AA'; } }
php
static function getUniShip($code) { static::isValid($code); switch ($code) { case static::EBP : return 'CC'; case static::GBP : return 'FF'; case static::EP : case static::SHD : case static::FDF : return null; case static::BP : default: return 'AA'; } }
[ "static", "function", "getUniShip", "(", "$", "code", ")", "{", "static", "::", "isValid", "(", "$", "code", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "static", "::", "EBP", ":", "return", "'CC'", ";", "case", "static", "::", "GBP", ":", "return", "'FF'", ";", "case", "static", "::", "EP", ":", "case", "static", "::", "SHD", ":", "case", "static", "::", "FDF", ":", "return", "null", ";", "case", "static", "::", "BP", ":", "default", ":", "return", "'AA'", ";", "}", "}" ]
Returns the "UNI Ship" equivalent product code. @param string $code @return string
[ "Returns", "the", "UNI", "Ship", "equivalent", "product", "code", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Service.php#L162-L179
15,455
fuzz-productions/laravel-api-data
src/Traits/Transformations.php
Transformations.transformEntity
public function transformEntity($entity, $transformer = null, SerializerAbstract $serializer = null): array { $transformer = $transformer ?: $this->getTransformerFromClassProperty(); $results = $this->transform()->resourceWith($entity, $transformer)->usingPaginatorIfPaged(); if ($serializer) { return $results->serialize($serializer); } return $results->serialize(); }
php
public function transformEntity($entity, $transformer = null, SerializerAbstract $serializer = null): array { $transformer = $transformer ?: $this->getTransformerFromClassProperty(); $results = $this->transform()->resourceWith($entity, $transformer)->usingPaginatorIfPaged(); if ($serializer) { return $results->serialize($serializer); } return $results->serialize(); }
[ "public", "function", "transformEntity", "(", "$", "entity", ",", "$", "transformer", "=", "null", ",", "SerializerAbstract", "$", "serializer", "=", "null", ")", ":", "array", "{", "$", "transformer", "=", "$", "transformer", "?", ":", "$", "this", "->", "getTransformerFromClassProperty", "(", ")", ";", "$", "results", "=", "$", "this", "->", "transform", "(", ")", "->", "resourceWith", "(", "$", "entity", ",", "$", "transformer", ")", "->", "usingPaginatorIfPaged", "(", ")", ";", "if", "(", "$", "serializer", ")", "{", "return", "$", "results", "->", "serialize", "(", "$", "serializer", ")", ";", "}", "return", "$", "results", "->", "serialize", "(", ")", ";", "}" ]
Shortcut method for serializing and transforming an entity. @param $entity @param TransformerAbstract|callable|string|null $transformer @param SerializerAbstract|null $serializer @return array
[ "Shortcut", "method", "for", "serializing", "and", "transforming", "an", "entity", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/Transformations.php#L36-L47
15,456
fuzz-productions/laravel-api-data
src/Traits/Transformations.php
Transformations.getTransformerFromClassProperty
protected function getTransformerFromClassProperty() { if (! isset($this->transformer) || ! $this->isTransformer($this->transformer)) { throw new \InvalidArgumentException('You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstract::class); } return (is_a($this->transformer, TransformerAbstract::class, true) && ! is_object($this->transformer)) ? new $this->transformer : $this->transformer; }
php
protected function getTransformerFromClassProperty() { if (! isset($this->transformer) || ! $this->isTransformer($this->transformer)) { throw new \InvalidArgumentException('You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstract::class); } return (is_a($this->transformer, TransformerAbstract::class, true) && ! is_object($this->transformer)) ? new $this->transformer : $this->transformer; }
[ "protected", "function", "getTransformerFromClassProperty", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "transformer", ")", "||", "!", "$", "this", "->", "isTransformer", "(", "$", "this", "->", "transformer", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You cannot transform the entity without providing a valid Transformer. Verify your transformer extends '", ".", "TransformerAbstract", "::", "class", ")", ";", "}", "return", "(", "is_a", "(", "$", "this", "->", "transformer", ",", "TransformerAbstract", "::", "class", ",", "true", ")", "&&", "!", "is_object", "(", "$", "this", "->", "transformer", ")", ")", "?", "new", "$", "this", "->", "transformer", ":", "$", "this", "->", "transformer", ";", "}" ]
Gets the transformer from the class and validates it's a correct serializer. @throws \InvalidArgumentException - If the class property does not set a proper Transformer. @return TransformerAbstract
[ "Gets", "the", "transformer", "from", "the", "class", "and", "validates", "it", "s", "a", "correct", "serializer", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/Transformations.php#L56-L65
15,457
huasituo/hstcms
src/Providers/RouteServiceProvider.php
RouteServiceProvider.mapApiRoutes
protected function mapApiRoutes() { Route::group([ 'middleware' => 'api', 'namespace' => $this->namespace.'\Api', 'domain' => config('hstcms.apiDomain') ? config('hstcms.apiDomain') : env('APP_URL'), 'prefix' => config('hstcms.apiDomain') ? '' : config('hstcms.apiPrefix') ? config('hstcms.apiPrefix') : 'api', ], function ($router) { require __DIR__.'/../Routes/api.php'; }); }
php
protected function mapApiRoutes() { Route::group([ 'middleware' => 'api', 'namespace' => $this->namespace.'\Api', 'domain' => config('hstcms.apiDomain') ? config('hstcms.apiDomain') : env('APP_URL'), 'prefix' => config('hstcms.apiDomain') ? '' : config('hstcms.apiPrefix') ? config('hstcms.apiPrefix') : 'api', ], function ($router) { require __DIR__.'/../Routes/api.php'; }); }
[ "protected", "function", "mapApiRoutes", "(", ")", "{", "Route", "::", "group", "(", "[", "'middleware'", "=>", "'api'", ",", "'namespace'", "=>", "$", "this", "->", "namespace", ".", "'\\Api'", ",", "'domain'", "=>", "config", "(", "'hstcms.apiDomain'", ")", "?", "config", "(", "'hstcms.apiDomain'", ")", ":", "env", "(", "'APP_URL'", ")", ",", "'prefix'", "=>", "config", "(", "'hstcms.apiDomain'", ")", "?", "''", ":", "config", "(", "'hstcms.apiPrefix'", ")", "?", "config", "(", "'hstcms.apiPrefix'", ")", ":", "'api'", ",", "]", ",", "function", "(", "$", "router", ")", "{", "require", "__DIR__", ".", "'/../Routes/api.php'", ";", "}", ")", ";", "}" ]
Define the "api" routes for the module. These routes are typically stateless. @return void
[ "Define", "the", "api", "routes", "for", "the", "module", "." ]
12819979289e58ce38e3e92540aeeb16e205e525
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/RouteServiceProvider.php#L72-L82
15,458
pageon/SlackWebhookMonolog
src/Slack/Webhook.php
Webhook.setUrl
private function setUrl(Url $url) { $urlValidationRegex = '_https:\/\/hooks.slack.com\/services\/[\w\/]+$_iuS'; if (!preg_match($urlValidationRegex, (string) $url)) { throw new InvalidUrlException( sprintf( 'The url: "%s" is not a valid url. Slack webhook urls should always start with "https://hooks.slack.com/services/"', $url ), 400 ); } $this->url = $url; return $this; }
php
private function setUrl(Url $url) { $urlValidationRegex = '_https:\/\/hooks.slack.com\/services\/[\w\/]+$_iuS'; if (!preg_match($urlValidationRegex, (string) $url)) { throw new InvalidUrlException( sprintf( 'The url: "%s" is not a valid url. Slack webhook urls should always start with "https://hooks.slack.com/services/"', $url ), 400 ); } $this->url = $url; return $this; }
[ "private", "function", "setUrl", "(", "Url", "$", "url", ")", "{", "$", "urlValidationRegex", "=", "'_https:\\/\\/hooks.slack.com\\/services\\/[\\w\\/]+$_iuS'", ";", "if", "(", "!", "preg_match", "(", "$", "urlValidationRegex", ",", "(", "string", ")", "$", "url", ")", ")", "{", "throw", "new", "InvalidUrlException", "(", "sprintf", "(", "'The url: \"%s\" is not a valid url.\n Slack webhook urls should always start with \"https://hooks.slack.com/services/\"'", ",", "$", "url", ")", ",", "400", ")", ";", "}", "$", "this", "->", "url", "=", "$", "url", ";", "return", "$", "this", ";", "}" ]
This wil set the url if it is valid. @param Url $url @throws InvalidUrlException When it is not a valid webhook url of slack @return self
[ "This", "wil", "set", "the", "url", "if", "it", "is", "valid", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Webhook.php#L58-L74
15,459
jpuck/color-mixer
src/Color.php
Color.dec
public function dec() : array { $colors = str_split( $this->hex('no-hash'), 2 ); return array_map(function($color){ return hexdec($color); }, $colors); }
php
public function dec() : array { $colors = str_split( $this->hex('no-hash'), 2 ); return array_map(function($color){ return hexdec($color); }, $colors); }
[ "public", "function", "dec", "(", ")", ":", "array", "{", "$", "colors", "=", "str_split", "(", "$", "this", "->", "hex", "(", "'no-hash'", ")", ",", "2", ")", ";", "return", "array_map", "(", "function", "(", "$", "color", ")", "{", "return", "hexdec", "(", "$", "color", ")", ";", "}", ",", "$", "colors", ")", ";", "}" ]
Get the CSS decimal color. @return array Returns rgb integer decimal colors.
[ "Get", "the", "CSS", "decimal", "color", "." ]
cea01c3082a921a35e00ae0a287c795d9fd73ada
https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Color.php#L58-L65
15,460
jpuck/color-mixer
src/Color.php
Color.validateHexColorString
public static function validateHexColorString(string $hex) : bool { // optional leading hash # $length = strlen( ltrim($hex, '#') ); // must be 3 or 6 characters switch ($length) { case 3: break; case 6: break; default: return false; } return preg_match('/^#?[0-9a-fA-F]{3,6}$/', $hex) === 1; }
php
public static function validateHexColorString(string $hex) : bool { // optional leading hash # $length = strlen( ltrim($hex, '#') ); // must be 3 or 6 characters switch ($length) { case 3: break; case 6: break; default: return false; } return preg_match('/^#?[0-9a-fA-F]{3,6}$/', $hex) === 1; }
[ "public", "static", "function", "validateHexColorString", "(", "string", "$", "hex", ")", ":", "bool", "{", "// optional leading hash #", "$", "length", "=", "strlen", "(", "ltrim", "(", "$", "hex", ",", "'#'", ")", ")", ";", "// must be 3 or 6 characters", "switch", "(", "$", "length", ")", "{", "case", "3", ":", "break", ";", "case", "6", ":", "break", ";", "default", ":", "return", "false", ";", "}", "return", "preg_match", "(", "'/^#?[0-9a-fA-F]{3,6}$/'", ",", "$", "hex", ")", "===", "1", ";", "}" ]
Validates CSS hexadecimal color. @param string $hex CSS hexadecimal color with optional leading hash # @return bool Returns true if valid CSS hexadecimal color, otherwise false.
[ "Validates", "CSS", "hexadecimal", "color", "." ]
cea01c3082a921a35e00ae0a287c795d9fd73ada
https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Color.php#L74-L87
15,461
jan-dolata/crude-crud
src/Http/Controllers/ThumbnailController.php
ThumbnailController.upload
public function upload(ThumbnailRequest $request) { $crudeName = $request->input('crudeName'); $crude = CrudeInstance::get($crudeName); $column = $request->input('columnName'); $file = $request->file()['file']; $id = $request->input('modelId'); $model = $crude->uploadThumbnailByIdAndColumn($id, $column, $file); return ['success' => true, 'model' => $model]; }
php
public function upload(ThumbnailRequest $request) { $crudeName = $request->input('crudeName'); $crude = CrudeInstance::get($crudeName); $column = $request->input('columnName'); $file = $request->file()['file']; $id = $request->input('modelId'); $model = $crude->uploadThumbnailByIdAndColumn($id, $column, $file); return ['success' => true, 'model' => $model]; }
[ "public", "function", "upload", "(", "ThumbnailRequest", "$", "request", ")", "{", "$", "crudeName", "=", "$", "request", "->", "input", "(", "'crudeName'", ")", ";", "$", "crude", "=", "CrudeInstance", "::", "get", "(", "$", "crudeName", ")", ";", "$", "column", "=", "$", "request", "->", "input", "(", "'columnName'", ")", ";", "$", "file", "=", "$", "request", "->", "file", "(", ")", "[", "'file'", "]", ";", "$", "id", "=", "$", "request", "->", "input", "(", "'modelId'", ")", ";", "$", "model", "=", "$", "crude", "->", "uploadThumbnailByIdAndColumn", "(", "$", "id", ",", "$", "column", ",", "$", "file", ")", ";", "return", "[", "'success'", "=>", "true", ",", "'model'", "=>", "$", "model", "]", ";", "}" ]
Handle thumbnail upload @author Wojciech Jurkowski <[email protected]>
[ "Handle", "thumbnail", "upload" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ThumbnailController.php#L18-L29
15,462
jan-dolata/crude-crud
src/Http/Controllers/ThumbnailController.php
ThumbnailController.delete
public function delete(ThumbnailRequest $request) { $crudeName = $request->input('crudeName'); $crude = CrudeInstance::get($crudeName); $id = $request->input('model_id'); $column = $request->input('model_column'); $model = $crude->deleteThumbnailByIdAndColumn($id, $column); return ['model' => $model]; }
php
public function delete(ThumbnailRequest $request) { $crudeName = $request->input('crudeName'); $crude = CrudeInstance::get($crudeName); $id = $request->input('model_id'); $column = $request->input('model_column'); $model = $crude->deleteThumbnailByIdAndColumn($id, $column); return ['model' => $model]; }
[ "public", "function", "delete", "(", "ThumbnailRequest", "$", "request", ")", "{", "$", "crudeName", "=", "$", "request", "->", "input", "(", "'crudeName'", ")", ";", "$", "crude", "=", "CrudeInstance", "::", "get", "(", "$", "crudeName", ")", ";", "$", "id", "=", "$", "request", "->", "input", "(", "'model_id'", ")", ";", "$", "column", "=", "$", "request", "->", "input", "(", "'model_column'", ")", ";", "$", "model", "=", "$", "crude", "->", "deleteThumbnailByIdAndColumn", "(", "$", "id", ",", "$", "column", ")", ";", "return", "[", "'model'", "=>", "$", "model", "]", ";", "}" ]
delete thumbnail file @author Wojciech Jurkowski <[email protected]>
[ "delete", "thumbnail", "file" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ThumbnailController.php#L35-L45
15,463
BugBuster1701/banner
public/conban_clicks.php
BannerClicks.getRedirectType
protected function getRedirectType($BID) { // aus BID die CatID // über CatID in tl_module.banner_categories die tl_module.banner_redirect // Schleife über alle zeilen, falls mehrere $objCat = \Database::getInstance()->prepare("SELECT pid as CatID FROM `tl_banner` WHERE id=?") ->execute($BID); if (0 == $objCat->numRows) { return '301'; // error, but the show must go on } $objCat->next(); $objBRT = \Database::getInstance()->prepare("SELECT `banner_categories` ,`banner_redirect` FROM `tl_module` WHERE type=? AND banner_categories=?") ->execute('banner', $objCat->CatID); if (0 == $objBRT->numRows) { return '301'; // error, but the show must go on } $arrBRT = array(); while ($objBRT->next()) { $arrBRT[] = ($objBRT->banner_redirect == 'temporary') ? '302' : '301'; } if (count($arrBRT) == 1) { return $arrBRT[0]; // Nur ein Modul importiert, eindeutig } else { // mindestens 2 FE Module mit derselben Kategorie, zaehlen $anz301=$anz302=0; foreach ($arrBRT as $type) { if ($type=='301') { $anz301++; } else { $anz302++; } } if ($anz301 >= $anz302) { // 301 hat bei Gleichstand Vorrang return '301'; } else { return '302'; } } }
php
protected function getRedirectType($BID) { // aus BID die CatID // über CatID in tl_module.banner_categories die tl_module.banner_redirect // Schleife über alle zeilen, falls mehrere $objCat = \Database::getInstance()->prepare("SELECT pid as CatID FROM `tl_banner` WHERE id=?") ->execute($BID); if (0 == $objCat->numRows) { return '301'; // error, but the show must go on } $objCat->next(); $objBRT = \Database::getInstance()->prepare("SELECT `banner_categories` ,`banner_redirect` FROM `tl_module` WHERE type=? AND banner_categories=?") ->execute('banner', $objCat->CatID); if (0 == $objBRT->numRows) { return '301'; // error, but the show must go on } $arrBRT = array(); while ($objBRT->next()) { $arrBRT[] = ($objBRT->banner_redirect == 'temporary') ? '302' : '301'; } if (count($arrBRT) == 1) { return $arrBRT[0]; // Nur ein Modul importiert, eindeutig } else { // mindestens 2 FE Module mit derselben Kategorie, zaehlen $anz301=$anz302=0; foreach ($arrBRT as $type) { if ($type=='301') { $anz301++; } else { $anz302++; } } if ($anz301 >= $anz302) { // 301 hat bei Gleichstand Vorrang return '301'; } else { return '302'; } } }
[ "protected", "function", "getRedirectType", "(", "$", "BID", ")", "{", "// aus BID die CatID", "// über CatID in tl_module.banner_categories die tl_module.banner_redirect", "// Schleife über alle zeilen, falls mehrere", "$", "objCat", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT \n pid as CatID \n FROM \n `tl_banner` \n WHERE \n id=?\"", ")", "->", "execute", "(", "$", "BID", ")", ";", "if", "(", "0", "==", "$", "objCat", "->", "numRows", ")", "{", "return", "'301'", ";", "// error, but the show must go on", "}", "$", "objCat", "->", "next", "(", ")", ";", "$", "objBRT", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT \n `banner_categories`\n ,`banner_redirect` \n FROM \n `tl_module` \n WHERE \n type=?\n AND \n banner_categories=?\"", ")", "->", "execute", "(", "'banner'", ",", "$", "objCat", "->", "CatID", ")", ";", "if", "(", "0", "==", "$", "objBRT", "->", "numRows", ")", "{", "return", "'301'", ";", "// error, but the show must go on", "}", "$", "arrBRT", "=", "array", "(", ")", ";", "while", "(", "$", "objBRT", "->", "next", "(", ")", ")", "{", "$", "arrBRT", "[", "]", "=", "(", "$", "objBRT", "->", "banner_redirect", "==", "'temporary'", ")", "?", "'302'", ":", "'301'", ";", "}", "if", "(", "count", "(", "$", "arrBRT", ")", "==", "1", ")", "{", "return", "$", "arrBRT", "[", "0", "]", ";", "// Nur ein Modul importiert, eindeutig", "}", "else", "{", "// mindestens 2 FE Module mit derselben Kategorie, zaehlen", "$", "anz301", "=", "$", "anz302", "=", "0", ";", "foreach", "(", "$", "arrBRT", "as", "$", "type", ")", "{", "if", "(", "$", "type", "==", "'301'", ")", "{", "$", "anz301", "++", ";", "}", "else", "{", "$", "anz302", "++", ";", "}", "}", "if", "(", "$", "anz301", ">=", "$", "anz302", ")", "{", "// 301 hat bei Gleichstand Vorrang", "return", "'301'", ";", "}", "else", "{", "return", "'302'", ";", "}", "}", "}" ]
Search Banner Redirect Definition @return int 301,302
[ "Search", "Banner", "Redirect", "Definition" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L243-L308
15,464
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceScopes.php
StubReplaceScopes.getCmsOrderedConfigReplace
protected function getCmsOrderedConfigReplace() { $orderColumns = $this->data['ordered_by'] ?: []; // for now, ignore the ordering if the column to order on is translated $translatedOrderColumns = array_intersect(array_keys($orderColumns ), $this->data['translated_attributes']); if (count($translatedOrderColumns)) { foreach ($translatedOrderColumns as $column) { unset($orderColumns[ $column ]); } } if ( ! count($orderColumns)) return ''; // we only need to set a config if the scope method is global if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($orderColumns as $attribute => $direction) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$cmsOrderBy = [\n"; foreach ($orderColumns as $attribute => $direction) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => '" . $direction . "',\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
php
protected function getCmsOrderedConfigReplace() { $orderColumns = $this->data['ordered_by'] ?: []; // for now, ignore the ordering if the column to order on is translated $translatedOrderColumns = array_intersect(array_keys($orderColumns ), $this->data['translated_attributes']); if (count($translatedOrderColumns)) { foreach ($translatedOrderColumns as $column) { unset($orderColumns[ $column ]); } } if ( ! count($orderColumns)) return ''; // we only need to set a config if the scope method is global if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return ''; // align assignment signs by longest attribute $longestLength = 0; foreach ($orderColumns as $attribute => $direction) { if (strlen($attribute) > $longestLength) { $longestLength = strlen($attribute); } } $replace = $this->tab() . "protected \$cmsOrderBy = [\n"; foreach ($orderColumns as $attribute => $direction) { $replace .= $this->tab(2) . "'" . str_pad($attribute . "'", $longestLength + 1) . " => '" . $direction . "',\n"; } $replace .= $this->tab() . "];\n\n"; return $replace; }
[ "protected", "function", "getCmsOrderedConfigReplace", "(", ")", "{", "$", "orderColumns", "=", "$", "this", "->", "data", "[", "'ordered_by'", "]", "?", ":", "[", "]", ";", "// for now, ignore the ordering if the column to order on is translated", "$", "translatedOrderColumns", "=", "array_intersect", "(", "array_keys", "(", "$", "orderColumns", ")", ",", "$", "this", "->", "data", "[", "'translated_attributes'", "]", ")", ";", "if", "(", "count", "(", "$", "translatedOrderColumns", ")", ")", "{", "foreach", "(", "$", "translatedOrderColumns", "as", "$", "column", ")", "{", "unset", "(", "$", "orderColumns", "[", "$", "column", "]", ")", ";", "}", "}", "if", "(", "!", "count", "(", "$", "orderColumns", ")", ")", "return", "''", ";", "// we only need to set a config if the scope method is global", "if", "(", "config", "(", "'pxlcms.generator.models.scopes.position_order'", ")", "!==", "CmsModelWriter", "::", "SCOPE_GLOBAL", ")", "return", "''", ";", "// align assignment signs by longest attribute", "$", "longestLength", "=", "0", ";", "foreach", "(", "$", "orderColumns", "as", "$", "attribute", "=>", "$", "direction", ")", "{", "if", "(", "strlen", "(", "$", "attribute", ")", ">", "$", "longestLength", ")", "{", "$", "longestLength", "=", "strlen", "(", "$", "attribute", ")", ";", "}", "}", "$", "replace", "=", "$", "this", "->", "tab", "(", ")", ".", "\"protected \\$cmsOrderBy = [\\n\"", ";", "foreach", "(", "$", "orderColumns", "as", "$", "attribute", "=>", "$", "direction", ")", "{", "$", "replace", ".=", "$", "this", "->", "tab", "(", "2", ")", ".", "\"'\"", ".", "str_pad", "(", "$", "attribute", ".", "\"'\"", ",", "$", "longestLength", "+", "1", ")", ".", "\" => '\"", ".", "$", "direction", ".", "\"',\\n\"", ";", "}", "$", "replace", ".=", "$", "this", "->", "tab", "(", ")", ".", "\"];\\n\\n\"", ";", "return", "$", "replace", ";", "}" ]
Returns the replace required depending on whether the CMS module has automatic sorting for defined columns @return string
[ "Returns", "the", "replace", "required", "depending", "on", "whether", "the", "CMS", "module", "has", "automatic", "sorting", "for", "defined", "columns" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceScopes.php#L87-L131
15,465
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.getCatID
protected function getCatID() { $objBannerCatID = \Database::getInstance()->prepare("SELECT MIN(pid) AS ID FROM tl_banner") ->execute(); $objBannerCatID->next(); if ($objBannerCatID->ID === null) { return 0; } else { return $objBannerCatID->ID; } }
php
protected function getCatID() { $objBannerCatID = \Database::getInstance()->prepare("SELECT MIN(pid) AS ID FROM tl_banner") ->execute(); $objBannerCatID->next(); if ($objBannerCatID->ID === null) { return 0; } else { return $objBannerCatID->ID; } }
[ "protected", "function", "getCatID", "(", ")", "{", "$", "objBannerCatID", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT \n MIN(pid) AS ID \n FROM \n tl_banner\"", ")", "->", "execute", "(", ")", ";", "$", "objBannerCatID", "->", "next", "(", ")", ";", "if", "(", "$", "objBannerCatID", "->", "ID", "===", "null", ")", "{", "return", "0", ";", "}", "else", "{", "return", "$", "objBannerCatID", "->", "ID", ";", "}", "}" ]
Get min category id @deprecated @return number CatID 0|min(pid)
[ "Get", "min", "category", "id" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L89-L105
15,466
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.getBannersByCatID
protected function getBannersByCatID($CatID = 0) { $arrBanners = array(); if ($CatID == -1) { // all Categories $objBanners = \Database::getInstance() ->prepare("SELECT tb.id , tb.banner_type , tb.banner_name , tb.banner_url , tb.banner_jumpTo , tb.banner_image , tb.banner_image_extern , tb.banner_weighting , tb.banner_start , tb.banner_stop , tb.banner_published , tb.banner_until , tb.banner_comment , tb.banner_views_until , tb.banner_clicks_until , tbs.banner_views , tbs.banner_clicks FROM tl_banner tb , tl_banner_stat tbs WHERE tb.id=tbs.id ORDER BY tb.pid , tb.sorting") ->execute(); } else { $objBanners = \Database::getInstance() ->prepare("SELECT tb.id , tb.banner_type , tb.banner_name , tb.banner_url , tb.banner_jumpTo , tb.banner_image , tb.banner_image_extern , tb.banner_weighting , tb.banner_start , tb.banner_stop , tb.banner_published , tb.banner_until , tb.banner_comment , tb.banner_views_until , tb.banner_clicks_until , tbs.banner_views , tbs.banner_clicks FROM tl_banner tb , tl_banner_stat tbs WHERE tb.id=tbs.id AND tb.pid =? ORDER BY tb.sorting") ->execute($CatID); } $intRows = $objBanners->numRows; if ($intRows > 0) { while ($objBanners->next()) { $arrBanners[] = array('id' => $objBanners->id , 'banner_type' => $objBanners->banner_type , 'banner_name' => $objBanners->banner_name , 'banner_url' => $objBanners->banner_url , 'banner_jumpTo' => $objBanners->banner_jumpTo , 'banner_image' => $objBanners->banner_image , 'banner_image_extern' => $objBanners->banner_image_extern , 'banner_weighting' => $objBanners->banner_weighting , 'banner_start' => $objBanners->banner_start , 'banner_stop' => $objBanners->banner_stop , 'banner_published' => $objBanners->banner_published , 'banner_until' => $objBanners->banner_until , 'banner_comment' => $objBanners->banner_comment , 'banner_views_until' => $objBanners->banner_views_until , 'banner_clicks_until' => $objBanners->banner_clicks_until , 'banner_views' => $objBanners->banner_views , 'banner_clicks' => $objBanners->banner_clicks ); } // while } return $arrBanners; }
php
protected function getBannersByCatID($CatID = 0) { $arrBanners = array(); if ($CatID == -1) { // all Categories $objBanners = \Database::getInstance() ->prepare("SELECT tb.id , tb.banner_type , tb.banner_name , tb.banner_url , tb.banner_jumpTo , tb.banner_image , tb.banner_image_extern , tb.banner_weighting , tb.banner_start , tb.banner_stop , tb.banner_published , tb.banner_until , tb.banner_comment , tb.banner_views_until , tb.banner_clicks_until , tbs.banner_views , tbs.banner_clicks FROM tl_banner tb , tl_banner_stat tbs WHERE tb.id=tbs.id ORDER BY tb.pid , tb.sorting") ->execute(); } else { $objBanners = \Database::getInstance() ->prepare("SELECT tb.id , tb.banner_type , tb.banner_name , tb.banner_url , tb.banner_jumpTo , tb.banner_image , tb.banner_image_extern , tb.banner_weighting , tb.banner_start , tb.banner_stop , tb.banner_published , tb.banner_until , tb.banner_comment , tb.banner_views_until , tb.banner_clicks_until , tbs.banner_views , tbs.banner_clicks FROM tl_banner tb , tl_banner_stat tbs WHERE tb.id=tbs.id AND tb.pid =? ORDER BY tb.sorting") ->execute($CatID); } $intRows = $objBanners->numRows; if ($intRows > 0) { while ($objBanners->next()) { $arrBanners[] = array('id' => $objBanners->id , 'banner_type' => $objBanners->banner_type , 'banner_name' => $objBanners->banner_name , 'banner_url' => $objBanners->banner_url , 'banner_jumpTo' => $objBanners->banner_jumpTo , 'banner_image' => $objBanners->banner_image , 'banner_image_extern' => $objBanners->banner_image_extern , 'banner_weighting' => $objBanners->banner_weighting , 'banner_start' => $objBanners->banner_start , 'banner_stop' => $objBanners->banner_stop , 'banner_published' => $objBanners->banner_published , 'banner_until' => $objBanners->banner_until , 'banner_comment' => $objBanners->banner_comment , 'banner_views_until' => $objBanners->banner_views_until , 'banner_clicks_until' => $objBanners->banner_clicks_until , 'banner_views' => $objBanners->banner_views , 'banner_clicks' => $objBanners->banner_clicks ); } // while } return $arrBanners; }
[ "protected", "function", "getBannersByCatID", "(", "$", "CatID", "=", "0", ")", "{", "$", "arrBanners", "=", "array", "(", ")", ";", "if", "(", "$", "CatID", "==", "-", "1", ")", "{", "// all Categories", "$", "objBanners", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT \n tb.id\n , tb.banner_type\n , tb.banner_name\n , tb.banner_url\n , tb.banner_jumpTo\n , tb.banner_image\n , tb.banner_image_extern\n , tb.banner_weighting\n , tb.banner_start\n , tb.banner_stop\n , tb.banner_published\n , tb.banner_until\n , tb.banner_comment\n , tb.banner_views_until\n , tb.banner_clicks_until\n , tbs.banner_views\n , tbs.banner_clicks\n FROM \n tl_banner tb\n , tl_banner_stat tbs\n WHERE \n tb.id=tbs.id\n ORDER BY \n tb.pid\n , tb.sorting\"", ")", "->", "execute", "(", ")", ";", "}", "else", "{", "$", "objBanners", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT\n tb.id\n , tb.banner_type\n , tb.banner_name\n , tb.banner_url\n , tb.banner_jumpTo\n , tb.banner_image\n , tb.banner_image_extern\n , tb.banner_weighting\n , tb.banner_start\n , tb.banner_stop\n , tb.banner_published\n , tb.banner_until\n , tb.banner_comment\n , tb.banner_views_until\n , tb.banner_clicks_until\n , tbs.banner_views\n , tbs.banner_clicks\n FROM\n tl_banner tb\n , tl_banner_stat tbs\n WHERE\n tb.id=tbs.id\n AND\n tb.pid =?\n ORDER BY\n tb.sorting\"", ")", "->", "execute", "(", "$", "CatID", ")", ";", "}", "$", "intRows", "=", "$", "objBanners", "->", "numRows", ";", "if", "(", "$", "intRows", ">", "0", ")", "{", "while", "(", "$", "objBanners", "->", "next", "(", ")", ")", "{", "$", "arrBanners", "[", "]", "=", "array", "(", "'id'", "=>", "$", "objBanners", "->", "id", ",", "'banner_type'", "=>", "$", "objBanners", "->", "banner_type", ",", "'banner_name'", "=>", "$", "objBanners", "->", "banner_name", ",", "'banner_url'", "=>", "$", "objBanners", "->", "banner_url", ",", "'banner_jumpTo'", "=>", "$", "objBanners", "->", "banner_jumpTo", ",", "'banner_image'", "=>", "$", "objBanners", "->", "banner_image", ",", "'banner_image_extern'", "=>", "$", "objBanners", "->", "banner_image_extern", ",", "'banner_weighting'", "=>", "$", "objBanners", "->", "banner_weighting", ",", "'banner_start'", "=>", "$", "objBanners", "->", "banner_start", ",", "'banner_stop'", "=>", "$", "objBanners", "->", "banner_stop", ",", "'banner_published'", "=>", "$", "objBanners", "->", "banner_published", ",", "'banner_until'", "=>", "$", "objBanners", "->", "banner_until", ",", "'banner_comment'", "=>", "$", "objBanners", "->", "banner_comment", ",", "'banner_views_until'", "=>", "$", "objBanners", "->", "banner_views_until", ",", "'banner_clicks_until'", "=>", "$", "objBanners", "->", "banner_clicks_until", ",", "'banner_views'", "=>", "$", "objBanners", "->", "banner_views", ",", "'banner_clicks'", "=>", "$", "objBanners", "->", "banner_clicks", ")", ";", "}", "// while", "}", "return", "$", "arrBanners", ";", "}" ]
Get banners by category id @param integer $CatID @return array $arrBanners
[ "Get", "banners", "by", "category", "id" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L125-L219
15,467
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.getBannerCategories
protected function getBannerCategories($banner_number) { // Kat sammeln $objBannerCat = \Database::getInstance() ->prepare("SELECT id , title FROM tl_banner_category WHERE id IN (SELECT pid FROM tl_banner LEFT JOIN tl_banner_category ON tl_banner.pid = tl_banner_category.id GROUP BY tl_banner.pid ) ORDER BY title") ->execute(); if ($objBannerCat->numRows > 0) { if ($banner_number == 0) { // gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien $arrBannerCats[] = array ( 'id' => '0', 'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['select'] ); $this->intCatID = 0; // template soll nichts anzeigen } $arrBannerCats[] = array ( 'id' => '-1', 'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['allkat'] ); while ($objBannerCat->next()) { $arrBannerCats[] = array ( 'id' => $objBannerCat->id, 'title' => $objBannerCat->title ); } } else { // es gibt keine Kategorie mit Banner $arrBannerCats[] = array ( 'id' => '0', 'title' => '---------' ); } return $arrBannerCats; }
php
protected function getBannerCategories($banner_number) { // Kat sammeln $objBannerCat = \Database::getInstance() ->prepare("SELECT id , title FROM tl_banner_category WHERE id IN (SELECT pid FROM tl_banner LEFT JOIN tl_banner_category ON tl_banner.pid = tl_banner_category.id GROUP BY tl_banner.pid ) ORDER BY title") ->execute(); if ($objBannerCat->numRows > 0) { if ($banner_number == 0) { // gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien $arrBannerCats[] = array ( 'id' => '0', 'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['select'] ); $this->intCatID = 0; // template soll nichts anzeigen } $arrBannerCats[] = array ( 'id' => '-1', 'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['allkat'] ); while ($objBannerCat->next()) { $arrBannerCats[] = array ( 'id' => $objBannerCat->id, 'title' => $objBannerCat->title ); } } else { // es gibt keine Kategorie mit Banner $arrBannerCats[] = array ( 'id' => '0', 'title' => '---------' ); } return $arrBannerCats; }
[ "protected", "function", "getBannerCategories", "(", "$", "banner_number", ")", "{", "// Kat sammeln", "$", "objBannerCat", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT \n id \n , title \n FROM \n tl_banner_category \n WHERE \n id \n IN \n (SELECT \n pid\n FROM\n tl_banner\n LEFT JOIN\n tl_banner_category \n ON \n tl_banner.pid = tl_banner_category.id\n GROUP BY \n tl_banner.pid\n )\n ORDER BY \n title\"", ")", "->", "execute", "(", ")", ";", "if", "(", "$", "objBannerCat", "->", "numRows", ">", "0", ")", "{", "if", "(", "$", "banner_number", "==", "0", ")", "{", "// gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "'0'", ",", "'title'", "=>", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'tl_banner_stat'", "]", "[", "'select'", "]", ")", ";", "$", "this", "->", "intCatID", "=", "0", ";", "// template soll nichts anzeigen", "}", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "'-1'", ",", "'title'", "=>", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'tl_banner_stat'", "]", "[", "'allkat'", "]", ")", ";", "while", "(", "$", "objBannerCat", "->", "next", "(", ")", ")", "{", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "$", "objBannerCat", "->", "id", ",", "'title'", "=>", "$", "objBannerCat", "->", "title", ")", ";", "}", "}", "else", "{", "// es gibt keine Kategorie mit Banner", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "'0'", ",", "'title'", "=>", "'---------'", ")", ";", "}", "return", "$", "arrBannerCats", ";", "}" ]
Get banner categories @deprecated @param integer $banner_number @return array $arrBannerCats
[ "Get", "banner", "categories" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L228-L290
15,468
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.getBannerCategoriesByUsergroups
protected function getBannerCategoriesByUsergroups() { $arrBannerCats = array(); $objBannerCat = \Database::getInstance() ->prepare("SELECT `id` , `title` , `banner_stat_protected` , `banner_stat_groups` FROM tl_banner_category WHERE 1 ORDER BY title ") ->execute(); while ($objBannerCat->next()) { if ( true === $this->isUserInBannerStatGroups($objBannerCat->banner_stat_groups, (bool) $objBannerCat->banner_stat_protected)) { $arrBannerCats[] = array ( 'id' => $objBannerCat->id, 'title' => $objBannerCat->title ); } } if (0 == count($arrBannerCats)) { $arrBannerCats[] = array('id' => '0', 'title' => '---------'); } return $arrBannerCats; }
php
protected function getBannerCategoriesByUsergroups() { $arrBannerCats = array(); $objBannerCat = \Database::getInstance() ->prepare("SELECT `id` , `title` , `banner_stat_protected` , `banner_stat_groups` FROM tl_banner_category WHERE 1 ORDER BY title ") ->execute(); while ($objBannerCat->next()) { if ( true === $this->isUserInBannerStatGroups($objBannerCat->banner_stat_groups, (bool) $objBannerCat->banner_stat_protected)) { $arrBannerCats[] = array ( 'id' => $objBannerCat->id, 'title' => $objBannerCat->title ); } } if (0 == count($arrBannerCats)) { $arrBannerCats[] = array('id' => '0', 'title' => '---------'); } return $arrBannerCats; }
[ "protected", "function", "getBannerCategoriesByUsergroups", "(", ")", "{", "$", "arrBannerCats", "=", "array", "(", ")", ";", "$", "objBannerCat", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"SELECT\n `id`\n , `title`\n , `banner_stat_protected`\n , `banner_stat_groups`\n FROM\n tl_banner_category\n WHERE 1\n ORDER BY \n title\n \"", ")", "->", "execute", "(", ")", ";", "while", "(", "$", "objBannerCat", "->", "next", "(", ")", ")", "{", "if", "(", "true", "===", "$", "this", "->", "isUserInBannerStatGroups", "(", "$", "objBannerCat", "->", "banner_stat_groups", ",", "(", "bool", ")", "$", "objBannerCat", "->", "banner_stat_protected", ")", ")", "{", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "$", "objBannerCat", "->", "id", ",", "'title'", "=>", "$", "objBannerCat", "->", "title", ")", ";", "}", "}", "if", "(", "0", "==", "count", "(", "$", "arrBannerCats", ")", ")", "{", "$", "arrBannerCats", "[", "]", "=", "array", "(", "'id'", "=>", "'0'", ",", "'title'", "=>", "'---------'", ")", ";", "}", "return", "$", "arrBannerCats", ";", "}" ]
Get banner categories by usergroups @param array $Usergroups @return array
[ "Get", "banner", "categories", "by", "usergroups" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L298-L334
15,469
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.getMaxViewsClicksStatus
protected function getMaxViewsClicksStatus( &$Banner ) { $intMaxViews = false; $intMaxClicks= false; if ($Banner['banner_until'] == 1 && $Banner['banner_views_until'] != '' && $Banner['banner_views'] >= $Banner['banner_views_until'] ) { //max views erreicht $intMaxViews = true; } if ($Banner['banner_until'] == 1 && $Banner['banner_clicks_until'] !='' && $Banner['banner_clicks'] >= $Banner['banner_clicks_until'] ) { //max clicks erreicht $intMaxClicks = true; } return array($intMaxViews,$intMaxClicks); }
php
protected function getMaxViewsClicksStatus( &$Banner ) { $intMaxViews = false; $intMaxClicks= false; if ($Banner['banner_until'] == 1 && $Banner['banner_views_until'] != '' && $Banner['banner_views'] >= $Banner['banner_views_until'] ) { //max views erreicht $intMaxViews = true; } if ($Banner['banner_until'] == 1 && $Banner['banner_clicks_until'] !='' && $Banner['banner_clicks'] >= $Banner['banner_clicks_until'] ) { //max clicks erreicht $intMaxClicks = true; } return array($intMaxViews,$intMaxClicks); }
[ "protected", "function", "getMaxViewsClicksStatus", "(", "&", "$", "Banner", ")", "{", "$", "intMaxViews", "=", "false", ";", "$", "intMaxClicks", "=", "false", ";", "if", "(", "$", "Banner", "[", "'banner_until'", "]", "==", "1", "&&", "$", "Banner", "[", "'banner_views_until'", "]", "!=", "''", "&&", "$", "Banner", "[", "'banner_views'", "]", ">=", "$", "Banner", "[", "'banner_views_until'", "]", ")", "{", "//max views erreicht", "$", "intMaxViews", "=", "true", ";", "}", "if", "(", "$", "Banner", "[", "'banner_until'", "]", "==", "1", "&&", "$", "Banner", "[", "'banner_clicks_until'", "]", "!=", "''", "&&", "$", "Banner", "[", "'banner_clicks'", "]", ">=", "$", "Banner", "[", "'banner_clicks_until'", "]", ")", "{", "//max clicks erreicht", "$", "intMaxClicks", "=", "true", ";", "}", "return", "array", "(", "$", "intMaxViews", ",", "$", "intMaxClicks", ")", ";", "}" ]
Get status of maxviews and maxclicks @param array $Banner @return array array(bool $intMaxViews, bool $intMaxClicks)
[ "Get", "status", "of", "maxviews", "and", "maxclicks" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L421-L445
15,470
BugBuster1701/banner
classes/BannerStatisticsHelper.php
BannerStatisticsHelper.isUserInBannerStatGroups
protected function isUserInBannerStatGroups($banner_stat_groups, $banner_stat_protected) { if ( true === $this->User->isAdmin ) { //DEBUG log_message('Ich bin Admin', 'banner.log'); return true; // Admin darf immer } //wenn Schutz nicht aktiviert ist, darf jeder if (false === $banner_stat_protected) { //Debug log_message('Schutz nicht aktiviert', 'banner.log'); return true; } //Schutz aktiviert, Einschränkungen vorhanden? if (0 == strlen($banner_stat_groups)) { //DEBUG log_message('banner_stat_groups ist leer', 'banner.log'); return false; //nicht gefiltert, also darf keiner außer Admin } //mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist foreach (deserialize($banner_stat_groups) as $id => $groupid) { if ( true === $this->User->isMemberOf($groupid) ) { //DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log'); return true; // User is Member of banner_stat_group } } //Debug log_message('Ich bin in der falschen Gruppe', 'banner.log'); return false; }
php
protected function isUserInBannerStatGroups($banner_stat_groups, $banner_stat_protected) { if ( true === $this->User->isAdmin ) { //DEBUG log_message('Ich bin Admin', 'banner.log'); return true; // Admin darf immer } //wenn Schutz nicht aktiviert ist, darf jeder if (false === $banner_stat_protected) { //Debug log_message('Schutz nicht aktiviert', 'banner.log'); return true; } //Schutz aktiviert, Einschränkungen vorhanden? if (0 == strlen($banner_stat_groups)) { //DEBUG log_message('banner_stat_groups ist leer', 'banner.log'); return false; //nicht gefiltert, also darf keiner außer Admin } //mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist foreach (deserialize($banner_stat_groups) as $id => $groupid) { if ( true === $this->User->isMemberOf($groupid) ) { //DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log'); return true; // User is Member of banner_stat_group } } //Debug log_message('Ich bin in der falschen Gruppe', 'banner.log'); return false; }
[ "protected", "function", "isUserInBannerStatGroups", "(", "$", "banner_stat_groups", ",", "$", "banner_stat_protected", ")", "{", "if", "(", "true", "===", "$", "this", "->", "User", "->", "isAdmin", ")", "{", "//DEBUG log_message('Ich bin Admin', 'banner.log');", "return", "true", ";", "// Admin darf immer", "}", "//wenn Schutz nicht aktiviert ist, darf jeder", "if", "(", "false", "===", "$", "banner_stat_protected", ")", "{", "//Debug log_message('Schutz nicht aktiviert', 'banner.log');", "return", "true", ";", "}", "//Schutz aktiviert, Einschränkungen vorhanden?", "if", "(", "0", "==", "strlen", "(", "$", "banner_stat_groups", ")", ")", "{", "//DEBUG log_message('banner_stat_groups ist leer', 'banner.log');", "return", "false", ";", "//nicht gefiltert, also darf keiner außer Admin", "}", "//mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist", "foreach", "(", "deserialize", "(", "$", "banner_stat_groups", ")", "as", "$", "id", "=>", "$", "groupid", ")", "{", "if", "(", "true", "===", "$", "this", "->", "User", "->", "isMemberOf", "(", "$", "groupid", ")", ")", "{", "//DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log');", "return", "true", ";", "// User is Member of banner_stat_group ", "}", "}", "//Debug log_message('Ich bin in der falschen Gruppe', 'banner.log');", "return", "false", ";", "}" ]
Check if User member of group in banner statistik groups @param string DB Field "banner_stat_groups", serialized array @return bool true / false
[ "Check", "if", "User", "member", "of", "group", "in", "banner", "statistik", "groups" ]
3ffac36837923194ab0ebaf308c0b23a3684b005
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L493-L524
15,471
gintonicweb/GintonicCMS
src/Controller/Component/SetupComponent.php
SetupComponent.runMigration
public function runMigration($plugin) { $command = new Migrate(); $output = new NullOutput(); $input = new ArrayInput(['--plugin' => $plugin]); $resultCode = $command->run($input, $output); }
php
public function runMigration($plugin) { $command = new Migrate(); $output = new NullOutput(); $input = new ArrayInput(['--plugin' => $plugin]); $resultCode = $command->run($input, $output); }
[ "public", "function", "runMigration", "(", "$", "plugin", ")", "{", "$", "command", "=", "new", "Migrate", "(", ")", ";", "$", "output", "=", "new", "NullOutput", "(", ")", ";", "$", "input", "=", "new", "ArrayInput", "(", "[", "'--plugin'", "=>", "$", "plugin", "]", ")", ";", "$", "resultCode", "=", "$", "command", "->", "run", "(", "$", "input", ",", "$", "output", ")", ";", "}" ]
Runs the migrations for a given plugin @param string $plugin Name of the plugin @return void
[ "Runs", "the", "migrations", "for", "a", "given", "plugin" ]
b34445fecea56a7d432d0f3e2f988cde8ead746b
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L19-L25
15,472
gintonicweb/GintonicCMS
src/Controller/Component/SetupComponent.php
SetupComponent.tableExists
public function tableExists($tableName, $connectionName = 'default') { try { $db = ConnectionManager::get($connectionName); $collection = $db->schemaCollection(); $tables = $collection->listTables(); if (in_array($tableName, $tables)) { return true; } } catch (PDOException $connectionError) { return false; } return false; }
php
public function tableExists($tableName, $connectionName = 'default') { try { $db = ConnectionManager::get($connectionName); $collection = $db->schemaCollection(); $tables = $collection->listTables(); if (in_array($tableName, $tables)) { return true; } } catch (PDOException $connectionError) { return false; } return false; }
[ "public", "function", "tableExists", "(", "$", "tableName", ",", "$", "connectionName", "=", "'default'", ")", "{", "try", "{", "$", "db", "=", "ConnectionManager", "::", "get", "(", "$", "connectionName", ")", ";", "$", "collection", "=", "$", "db", "->", "schemaCollection", "(", ")", ";", "$", "tables", "=", "$", "collection", "->", "listTables", "(", ")", ";", "if", "(", "in_array", "(", "$", "tableName", ",", "$", "tables", ")", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "PDOException", "$", "connectionError", ")", "{", "return", "false", ";", "}", "return", "false", ";", "}" ]
Check whether table is exists in database or not. @param string $tableName Name of the table to check. @param string $connectionName Connection to use @return bool True if table exists, False else.
[ "Check", "whether", "table", "is", "exists", "in", "database", "or", "not", "." ]
b34445fecea56a7d432d0f3e2f988cde8ead746b
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L34-L47
15,473
gintonicweb/GintonicCMS
src/Controller/Component/SetupComponent.php
SetupComponent.databaseConnection
public function databaseConnection($dataSource = 'default') { try { $connection = ConnectionManager::get($dataSource); $connected = $connection->connect(); } catch (MissingConnectionException $connectionError) { $connected = false; } return $connected; }
php
public function databaseConnection($dataSource = 'default') { try { $connection = ConnectionManager::get($dataSource); $connected = $connection->connect(); } catch (MissingConnectionException $connectionError) { $connected = false; } return $connected; }
[ "public", "function", "databaseConnection", "(", "$", "dataSource", "=", "'default'", ")", "{", "try", "{", "$", "connection", "=", "ConnectionManager", "::", "get", "(", "$", "dataSource", ")", ";", "$", "connected", "=", "$", "connection", "->", "connect", "(", ")", ";", "}", "catch", "(", "MissingConnectionException", "$", "connectionError", ")", "{", "$", "connected", "=", "false", ";", "}", "return", "$", "connected", ";", "}" ]
Test database connection. @param type $dataSource name of data source. @return bool True if we're able to connect to the database
[ "Test", "database", "connection", "." ]
b34445fecea56a7d432d0f3e2f988cde8ead746b
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L55-L64
15,474
stubbles/stubbles-webapp-core
src/main/php/auth/session/CachingAuthorizationProvider.php
CachingAuthorizationProvider.roles
public function roles(User $user) { if ($this->session->hasValue(Roles::SESSION_KEY)) { return $this->session->value(Roles::SESSION_KEY); } $roles = $this->authorizationProvider->roles($user); $this->session->putValue(Roles::SESSION_KEY, $roles); return $roles; }
php
public function roles(User $user) { if ($this->session->hasValue(Roles::SESSION_KEY)) { return $this->session->value(Roles::SESSION_KEY); } $roles = $this->authorizationProvider->roles($user); $this->session->putValue(Roles::SESSION_KEY, $roles); return $roles; }
[ "public", "function", "roles", "(", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "session", "->", "hasValue", "(", "Roles", "::", "SESSION_KEY", ")", ")", "{", "return", "$", "this", "->", "session", "->", "value", "(", "Roles", "::", "SESSION_KEY", ")", ";", "}", "$", "roles", "=", "$", "this", "->", "authorizationProvider", "->", "roles", "(", "$", "user", ")", ";", "$", "this", "->", "session", "->", "putValue", "(", "Roles", "::", "SESSION_KEY", ",", "$", "roles", ")", ";", "return", "$", "roles", ";", "}" ]
returns the roles available for this request and user @param \stubbles\webapp\auth\User $user @return \stubbles\webapp\auth\Roles|null
[ "returns", "the", "roles", "available", "for", "this", "request", "and", "user" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/session/CachingAuthorizationProvider.php#L55-L64
15,475
gintonicweb/requirejs
src/View/Helper/RequireHelper.php
RequireHelper._getAppBase
protected function _getAppBase() { $baseUrl = Configure::read('App.base'); if (!$baseUrl) { $request = Router::getRequest(true); if (!$request) { $baseUrl = ''; } else { $baseUrl = $request->base; } } return $baseUrl . '/'; }
php
protected function _getAppBase() { $baseUrl = Configure::read('App.base'); if (!$baseUrl) { $request = Router::getRequest(true); if (!$request) { $baseUrl = ''; } else { $baseUrl = $request->base; } } return $baseUrl . '/'; }
[ "protected", "function", "_getAppBase", "(", ")", "{", "$", "baseUrl", "=", "Configure", "::", "read", "(", "'App.base'", ")", ";", "if", "(", "!", "$", "baseUrl", ")", "{", "$", "request", "=", "Router", "::", "getRequest", "(", "true", ")", ";", "if", "(", "!", "$", "request", ")", "{", "$", "baseUrl", "=", "''", ";", "}", "else", "{", "$", "baseUrl", "=", "$", "request", "->", "base", ";", "}", "}", "return", "$", "baseUrl", ".", "'/'", ";", "}" ]
Return the content of CakePHP App.base. If the App.base value is false, it returns the generated URL automatically by mimicking how CakePHP add the base to its URL. @return string the application base directory
[ "Return", "the", "content", "of", "CakePHP", "App", ".", "base", ".", "If", "the", "App", ".", "base", "value", "is", "false", "it", "returns", "the", "generated", "URL", "automatically", "by", "mimicking", "how", "CakePHP", "add", "the", "base", "to", "its", "URL", "." ]
befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L78-L90
15,476
gintonicweb/requirejs
src/View/Helper/RequireHelper.php
RequireHelper.module
public function module($name) { list($plugin, $path) = $this->_View->pluginSplit($name, false); if (!empty($plugin)) { $name = $this->Url->assetUrl($name, [ 'pathPrefix' => Configure::read('App.jsBaseUrl'), 'ext' => '.js', ]); } if (!$this->_requireLoaded) { return $this->_preLoadModule($name); } return $this->_loadModule($name); }
php
public function module($name) { list($plugin, $path) = $this->_View->pluginSplit($name, false); if (!empty($plugin)) { $name = $this->Url->assetUrl($name, [ 'pathPrefix' => Configure::read('App.jsBaseUrl'), 'ext' => '.js', ]); } if (!$this->_requireLoaded) { return $this->_preLoadModule($name); } return $this->_loadModule($name); }
[ "public", "function", "module", "(", "$", "name", ")", "{", "list", "(", "$", "plugin", ",", "$", "path", ")", "=", "$", "this", "->", "_View", "->", "pluginSplit", "(", "$", "name", ",", "false", ")", ";", "if", "(", "!", "empty", "(", "$", "plugin", ")", ")", "{", "$", "name", "=", "$", "this", "->", "Url", "->", "assetUrl", "(", "$", "name", ",", "[", "'pathPrefix'", "=>", "Configure", "::", "read", "(", "'App.jsBaseUrl'", ")", ",", "'ext'", "=>", "'.js'", ",", "]", ")", ";", "}", "if", "(", "!", "$", "this", "->", "_requireLoaded", ")", "{", "return", "$", "this", "->", "_preLoadModule", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "_loadModule", "(", "$", "name", ")", ";", "}" ]
Add a javascript module to be loaded on the page. Every module that is called prior to the load() command should be pre-loaded and will be outputted along with the loader. Every module that comes after the loader, for example via ajax, should be loaded right away by setting the "preLoad" option to false @param string $name name of the js module to load @return void|string loader tag is outputted on post-load
[ "Add", "a", "javascript", "module", "to", "be", "loaded", "on", "the", "page", "." ]
befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L159-L172
15,477
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/WhereEvaluation.php
WhereEvaluation.evaluate
public function evaluate(array $item, array $clause) { if (false === isset($clause['key']) || false === isset($clause['value']) || false === isset($clause['operator']) ) { throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.'); } $value = isset($item[$clause['key']]) ? $item[$clause['key']] : null; $value = $this->evaluateFilters($value, $clause); if (false === isset($this->operators[$clause['operator']])) { throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator'])); } if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) { return false; } return true; }
php
public function evaluate(array $item, array $clause) { if (false === isset($clause['key']) || false === isset($clause['value']) || false === isset($clause['operator']) ) { throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.'); } $value = isset($item[$clause['key']]) ? $item[$clause['key']] : null; $value = $this->evaluateFilters($value, $clause); if (false === isset($this->operators[$clause['operator']])) { throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator'])); } if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) { return false; } return true; }
[ "public", "function", "evaluate", "(", "array", "$", "item", ",", "array", "$", "clause", ")", "{", "if", "(", "false", "===", "isset", "(", "$", "clause", "[", "'key'", "]", ")", "||", "false", "===", "isset", "(", "$", "clause", "[", "'value'", "]", ")", "||", "false", "===", "isset", "(", "$", "clause", "[", "'operator'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Clause must contain \"key\", \"value\" and operator.'", ")", ";", "}", "$", "value", "=", "isset", "(", "$", "item", "[", "$", "clause", "[", "'key'", "]", "]", ")", "?", "$", "item", "[", "$", "clause", "[", "'key'", "]", "]", ":", "null", ";", "$", "value", "=", "$", "this", "->", "evaluateFilters", "(", "$", "value", ",", "$", "clause", ")", ";", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "operators", "[", "$", "clause", "[", "'operator'", "]", "]", ")", ")", "{", "throw", "new", "UnkownOperatorException", "(", "sprintf", "(", "'The operator \"%s\" does not exist.'", ",", "$", "clause", "[", "'operator'", "]", ")", ")", ";", "}", "if", "(", "false", "===", "$", "this", "->", "operators", "[", "$", "clause", "[", "'operator'", "]", "]", "->", "evaluate", "(", "$", "value", ",", "$", "clause", "[", "'value'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Evaluates the given item with the given clause. @param array $item The item to evaluate. @param array $clause The clause to evaluate the item with. Has to contain `key`, `value` and `operator` and can optionally also contain `filters`. `filters` can be either a string or an array. @return boolean `true` if the item evaluates to `true`, `false` otherwise. @throws \InvalidArgumentException if `key`, `value` or `operator` is missing in `$clause`. @throws Braincrafted\ArrayQuery\Exception\UnkownFilterException if a filter does not exist. @throws Braincrafted\ArrayQuery\Exception\UnkownOperatorException if the operator does not exist.
[ "Evaluates", "the", "given", "item", "with", "the", "given", "clause", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/WhereEvaluation.php#L77-L98
15,478
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/WhereEvaluation.php
WhereEvaluation.evaluateFilters
protected function evaluateFilters($value, array $clause) { if (true === isset($clause['filters'])) { if (false === is_array($clause['filters'])) { $clause['filters'] = [ $clause['filters'] ]; } foreach ($clause['filters'] as $filter) { $value = $this->evaluateFilter($value, $filter); } } return $value; }
php
protected function evaluateFilters($value, array $clause) { if (true === isset($clause['filters'])) { if (false === is_array($clause['filters'])) { $clause['filters'] = [ $clause['filters'] ]; } foreach ($clause['filters'] as $filter) { $value = $this->evaluateFilter($value, $filter); } } return $value; }
[ "protected", "function", "evaluateFilters", "(", "$", "value", ",", "array", "$", "clause", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "clause", "[", "'filters'", "]", ")", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "clause", "[", "'filters'", "]", ")", ")", "{", "$", "clause", "[", "'filters'", "]", "=", "[", "$", "clause", "[", "'filters'", "]", "]", ";", "}", "foreach", "(", "$", "clause", "[", "'filters'", "]", "as", "$", "filter", ")", "{", "$", "value", "=", "$", "this", "->", "evaluateFilter", "(", "$", "value", ",", "$", "filter", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Evaluates the given value with the given clause. @param mixed $value The value to evaluate. @param array $clause The clause to evaluate the item with. @return mixed The evaluated value. @throws Braincrafted\ArrayQuery\Exception\UnkownFilterException if the given filter does not exist. @see evaluate()
[ "Evaluates", "the", "given", "value", "with", "the", "given", "clause", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/WhereEvaluation.php#L112-L124
15,479
vespolina/VespolinaCommerceBundle
Controller/Product/ProductAdminController.php
ProductController.listAction
public function listAction() { $products = $this->container->get('vespolina.product_manager')->findBy(array()); return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:list.html.'.$this->getEngine(), array('products' => $products)); }
php
public function listAction() { $products = $this->container->get('vespolina.product_manager')->findBy(array()); return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:list.html.'.$this->getEngine(), array('products' => $products)); }
[ "public", "function", "listAction", "(", ")", "{", "$", "products", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product_manager'", ")", "->", "findBy", "(", "array", "(", ")", ")", ";", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "renderResponse", "(", "'VespolinaCommerceBundle:Product:list.html.'", ".", "$", "this", "->", "getEngine", "(", ")", ",", "array", "(", "'products'", "=>", "$", "products", ")", ")", ";", "}" ]
Show all products
[ "Show", "all", "products" ]
0644dd2c0fb39637a0a6c2838b02e17bc480bdbc
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L28-L33
15,480
vespolina/VespolinaCommerceBundle
Controller/Product/ProductAdminController.php
ProductController.detailAction
public function detailAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:show.html.'.$this->getEngine(), array('product' => $product)); }
php
public function detailAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:show.html.'.$this->getEngine(), array('product' => $product)); }
[ "public", "function", "detailAction", "(", "$", "id", ")", "{", "$", "product", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product_manager'", ")", "->", "findProductById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "product", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The product does not exist!'", ")", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "renderResponse", "(", "'VespolinaCommerceBundle:Product:show.html.'", ".", "$", "this", "->", "getEngine", "(", ")", ",", "array", "(", "'product'", "=>", "$", "product", ")", ")", ";", "}" ]
Show one product by object id
[ "Show", "one", "product", "by", "object", "id" ]
0644dd2c0fb39637a0a6c2838b02e17bc480bdbc
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L38-L47
15,481
vespolina/VespolinaCommerceBundle
Controller/Product/ProductAdminController.php
ProductController.editAction
public function editAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } $formHandler = $this->container->get('vespolina.product.form.handler'); $process = $formHandler->process($product); if ($process) { $this->setFlash('vespolina_product_updated', 'success'); $url = $this->container->get('router')->generate('vespolina_product_list'); return new RedirectResponse($url); } $form = $this->container->get('vespolina.product.form'); $form->setData($product); return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:edit.html.'.$this->getEngine(), array( 'form' => $form->createView(), 'id' => $id, 'configuredOptionGroups' => $this->getConfiguredOptionsGroups(), )); }
php
public function editAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } $formHandler = $this->container->get('vespolina.product.form.handler'); $process = $formHandler->process($product); if ($process) { $this->setFlash('vespolina_product_updated', 'success'); $url = $this->container->get('router')->generate('vespolina_product_list'); return new RedirectResponse($url); } $form = $this->container->get('vespolina.product.form'); $form->setData($product); return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:edit.html.'.$this->getEngine(), array( 'form' => $form->createView(), 'id' => $id, 'configuredOptionGroups' => $this->getConfiguredOptionsGroups(), )); }
[ "public", "function", "editAction", "(", "$", "id", ")", "{", "$", "product", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product_manager'", ")", "->", "findProductById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "product", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The product does not exist!'", ")", ";", "}", "$", "formHandler", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product.form.handler'", ")", ";", "$", "process", "=", "$", "formHandler", "->", "process", "(", "$", "product", ")", ";", "if", "(", "$", "process", ")", "{", "$", "this", "->", "setFlash", "(", "'vespolina_product_updated'", ",", "'success'", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'vespolina_product_list'", ")", ";", "return", "new", "RedirectResponse", "(", "$", "url", ")", ";", "}", "$", "form", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product.form'", ")", ";", "$", "form", "->", "setData", "(", "$", "product", ")", ";", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "renderResponse", "(", "'VespolinaCommerceBundle:Product:edit.html.'", ".", "$", "this", "->", "getEngine", "(", ")", ",", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'id'", "=>", "$", "id", ",", "'configuredOptionGroups'", "=>", "$", "this", "->", "getConfiguredOptionsGroups", "(", ")", ",", ")", ")", ";", "}" ]
Edit one product, show the edit form
[ "Edit", "one", "product", "show", "the", "edit", "form" ]
0644dd2c0fb39637a0a6c2838b02e17bc480bdbc
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L52-L78
15,482
vespolina/VespolinaCommerceBundle
Controller/Product/ProductAdminController.php
ProductController.deleteAction
public function deleteAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } $dm = $this->container->get('doctrine.odm.mongodb.document_manager'); $dm->remove($product); $dm->flush(); $this->setFlash('vespolina_product_deleted', 'success'); $url = $this->container->get('router')->generate('vespolina_product_list'); return new RedirectResponse($url); }
php
public function deleteAction($id) { $product = $this->container->get('vespolina.product_manager')->findProductById($id); if (!$product) { throw new NotFoundHttpException('The product does not exist!'); } $dm = $this->container->get('doctrine.odm.mongodb.document_manager'); $dm->remove($product); $dm->flush(); $this->setFlash('vespolina_product_deleted', 'success'); $url = $this->container->get('router')->generate('vespolina_product_list'); return new RedirectResponse($url); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "$", "product", "=", "$", "this", "->", "container", "->", "get", "(", "'vespolina.product_manager'", ")", "->", "findProductById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "product", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The product does not exist!'", ")", ";", "}", "$", "dm", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine.odm.mongodb.document_manager'", ")", ";", "$", "dm", "->", "remove", "(", "$", "product", ")", ";", "$", "dm", "->", "flush", "(", ")", ";", "$", "this", "->", "setFlash", "(", "'vespolina_product_deleted'", ",", "'success'", ")", ";", "$", "url", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'vespolina_product_list'", ")", ";", "return", "new", "RedirectResponse", "(", "$", "url", ")", ";", "}" ]
Delete one product, then show list
[ "Delete", "one", "product", "then", "show", "list" ]
0644dd2c0fb39637a0a6c2838b02e17bc480bdbc
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L83-L98
15,483
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.buildModelMap
private function buildModelMap() { $this->modelMap = ArrayHelper::merge($this->defaultModelMap, $this->modelMap); foreach ($this->modelMap as $modelName => $configuration) { Yii::$container->set($configuration['class'], $configuration); } }
php
private function buildModelMap() { $this->modelMap = ArrayHelper::merge($this->defaultModelMap, $this->modelMap); foreach ($this->modelMap as $modelName => $configuration) { Yii::$container->set($configuration['class'], $configuration); } }
[ "private", "function", "buildModelMap", "(", ")", "{", "$", "this", "->", "modelMap", "=", "ArrayHelper", "::", "merge", "(", "$", "this", "->", "defaultModelMap", ",", "$", "this", "->", "modelMap", ")", ";", "foreach", "(", "$", "this", "->", "modelMap", "as", "$", "modelName", "=>", "$", "configuration", ")", "{", "Yii", "::", "$", "container", "->", "set", "(", "$", "configuration", "[", "'class'", "]", ",", "$", "configuration", ")", ";", "}", "}" ]
Builds model map, setups di container
[ "Builds", "model", "map", "setups", "di", "container" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L142-L148
15,484
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.createVisitor
private function createVisitor() { $this->visitor = Yii::$container->get($this->modelMap['Visitor']['class']); $this->visitor->save(); return $this->visitor; }
php
private function createVisitor() { $this->visitor = Yii::$container->get($this->modelMap['Visitor']['class']); $this->visitor->save(); return $this->visitor; }
[ "private", "function", "createVisitor", "(", ")", "{", "$", "this", "->", "visitor", "=", "Yii", "::", "$", "container", "->", "get", "(", "$", "this", "->", "modelMap", "[", "'Visitor'", "]", "[", "'class'", "]", ")", ";", "$", "this", "->", "visitor", "->", "save", "(", ")", ";", "return", "$", "this", "->", "visitor", ";", "}" ]
Create Visitor record @return Visitor @throws \yii\base\InvalidConfigException
[ "Create", "Visitor", "record" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L156-L161
15,485
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.saveVisitor
private function saveVisitor() { Yii::$app->session->set($this->visitorCookieName, $this->visitor->getPrimaryKey()); if (!Yii::$app->request->cookies->has($this->visitorCookieName)) { $this->setVisitorCookie(); return; } $cookie = Yii::$app->request->cookies->get($this->visitorCookieName); if ($cookie->expire - time() <= $this->visitorCookieExpireTime) { $this->setVisitorCookie(); } }
php
private function saveVisitor() { Yii::$app->session->set($this->visitorCookieName, $this->visitor->getPrimaryKey()); if (!Yii::$app->request->cookies->has($this->visitorCookieName)) { $this->setVisitorCookie(); return; } $cookie = Yii::$app->request->cookies->get($this->visitorCookieName); if ($cookie->expire - time() <= $this->visitorCookieExpireTime) { $this->setVisitorCookie(); } }
[ "private", "function", "saveVisitor", "(", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "set", "(", "$", "this", "->", "visitorCookieName", ",", "$", "this", "->", "visitor", "->", "getPrimaryKey", "(", ")", ")", ";", "if", "(", "!", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "has", "(", "$", "this", "->", "visitorCookieName", ")", ")", "{", "$", "this", "->", "setVisitorCookie", "(", ")", ";", "return", ";", "}", "$", "cookie", "=", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "get", "(", "$", "this", "->", "visitorCookieName", ")", ";", "if", "(", "$", "cookie", "->", "expire", "-", "time", "(", ")", "<=", "$", "this", "->", "visitorCookieExpireTime", ")", "{", "$", "this", "->", "setVisitorCookie", "(", ")", ";", "}", "}" ]
Store visitor_id in session and if require in cookie
[ "Store", "visitor_id", "in", "session", "and", "if", "require", "in", "cookie" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L166-L179
15,486
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.setVisitorCookie
private function setVisitorCookie() { Yii::$app->response->cookies->add(new Cookie([ 'name' => $this->visitorCookieName, 'value' => $this->visitor->getPrimaryKey(), 'expire' => time() + $this->visitorCookieTime, ])); }
php
private function setVisitorCookie() { Yii::$app->response->cookies->add(new Cookie([ 'name' => $this->visitorCookieName, 'value' => $this->visitor->getPrimaryKey(), 'expire' => time() + $this->visitorCookieTime, ])); }
[ "private", "function", "setVisitorCookie", "(", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "cookies", "->", "add", "(", "new", "Cookie", "(", "[", "'name'", "=>", "$", "this", "->", "visitorCookieName", ",", "'value'", "=>", "$", "this", "->", "visitor", "->", "getPrimaryKey", "(", ")", ",", "'expire'", "=>", "time", "(", ")", "+", "$", "this", "->", "visitorCookieTime", ",", "]", ")", ")", ";", "}" ]
Add visitor cookie
[ "Add", "visitor", "cookie" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L184-L191
15,487
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.hasVisitor
public function hasVisitor($visitor_id) { if ($this->visitor !== null) { return true; } /** * @var Visitor $model */ $model = Yii::$container->get($this->modelMap['Visitor']['class']); $this->visitor = $model->find() ->where(['id' => $visitor_id]) ->one(); return $this->visitor !== null; }
php
public function hasVisitor($visitor_id) { if ($this->visitor !== null) { return true; } /** * @var Visitor $model */ $model = Yii::$container->get($this->modelMap['Visitor']['class']); $this->visitor = $model->find() ->where(['id' => $visitor_id]) ->one(); return $this->visitor !== null; }
[ "public", "function", "hasVisitor", "(", "$", "visitor_id", ")", "{", "if", "(", "$", "this", "->", "visitor", "!==", "null", ")", "{", "return", "true", ";", "}", "/**\n * @var Visitor $model\n */", "$", "model", "=", "Yii", "::", "$", "container", "->", "get", "(", "$", "this", "->", "modelMap", "[", "'Visitor'", "]", "[", "'class'", "]", ")", ";", "$", "this", "->", "visitor", "=", "$", "model", "->", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "visitor_id", "]", ")", "->", "one", "(", ")", ";", "return", "$", "this", "->", "visitor", "!==", "null", ";", "}" ]
Check if visitor exists @param int $visitor_id @return bool @throws \yii\base\InvalidConfigException
[ "Check", "if", "visitor", "exists" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L200-L213
15,488
DevGroup-ru/yii2-intent-analytics
src/IntentAnalyticsModule.php
IntentAnalyticsModule.getVisitor
public function getVisitor() { if ($this->visitor !== null) { return $this->visitor; } if (Yii::$app->session->has($this->visitorCookieName)) { $visitor_id = Yii::$app->session->get($this->visitorCookieName); } elseif (Yii::$app->request->cookies->has($this->visitorCookieName)) { $visitor_id = Yii::$app->request->cookies->getValue($this->visitorCookieName); } if (isset($visitor_id) && $this->hasVisitor($visitor_id)) { return $this->visitor; } return $this->createVisitor(); }
php
public function getVisitor() { if ($this->visitor !== null) { return $this->visitor; } if (Yii::$app->session->has($this->visitorCookieName)) { $visitor_id = Yii::$app->session->get($this->visitorCookieName); } elseif (Yii::$app->request->cookies->has($this->visitorCookieName)) { $visitor_id = Yii::$app->request->cookies->getValue($this->visitorCookieName); } if (isset($visitor_id) && $this->hasVisitor($visitor_id)) { return $this->visitor; } return $this->createVisitor(); }
[ "public", "function", "getVisitor", "(", ")", "{", "if", "(", "$", "this", "->", "visitor", "!==", "null", ")", "{", "return", "$", "this", "->", "visitor", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "session", "->", "has", "(", "$", "this", "->", "visitorCookieName", ")", ")", "{", "$", "visitor_id", "=", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "$", "this", "->", "visitorCookieName", ")", ";", "}", "elseif", "(", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "has", "(", "$", "this", "->", "visitorCookieName", ")", ")", "{", "$", "visitor_id", "=", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "getValue", "(", "$", "this", "->", "visitorCookieName", ")", ";", "}", "if", "(", "isset", "(", "$", "visitor_id", ")", "&&", "$", "this", "->", "hasVisitor", "(", "$", "visitor_id", ")", ")", "{", "return", "$", "this", "->", "visitor", ";", "}", "return", "$", "this", "->", "createVisitor", "(", ")", ";", "}" ]
Return current Visitor @return Visitor
[ "Return", "current", "Visitor" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L220-L236
15,489
czim/laravel-pxlcms
src/Models/Scopes/CmsOrdered.php
CmsOrdered.getQualifiedOrderByColumns
public function getQualifiedOrderByColumns() { $columns = $this->cmsOrderBy; $qualified = []; if (empty($columns)) return []; foreach ($columns as $column => $direction) { $qualified[ $this->getTable() . '.' . $column ] = $direction; } return $qualified; }
php
public function getQualifiedOrderByColumns() { $columns = $this->cmsOrderBy; $qualified = []; if (empty($columns)) return []; foreach ($columns as $column => $direction) { $qualified[ $this->getTable() . '.' . $column ] = $direction; } return $qualified; }
[ "public", "function", "getQualifiedOrderByColumns", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "cmsOrderBy", ";", "$", "qualified", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "columns", ")", ")", "return", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "column", "=>", "$", "direction", ")", "{", "$", "qualified", "[", "$", "this", "->", "getTable", "(", ")", ".", "'.'", ".", "$", "column", "]", "=", "$", "direction", ";", "}", "return", "$", "qualified", ";", "}" ]
Get the fully qualified column name for applying the scope @return string
[ "Get", "the", "fully", "qualified", "column", "name", "for", "applying", "the", "scope" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/CmsOrdered.php#L20-L32
15,490
jan-dolata/crude-crud
src/Http/Controllers/ApiController.php
ApiController.store
public function store(ApiStoreRequest $request, $crudeName) { $this->crude = CrudeInstance::get($request->crudeName); $model = $this->crude->store($request->all()); return $this->successResponse([ 'model' => $model, 'message' => $this->crude->getCrudeSetup()->trans('item_has_been_saved') ]); }
php
public function store(ApiStoreRequest $request, $crudeName) { $this->crude = CrudeInstance::get($request->crudeName); $model = $this->crude->store($request->all()); return $this->successResponse([ 'model' => $model, 'message' => $this->crude->getCrudeSetup()->trans('item_has_been_saved') ]); }
[ "public", "function", "store", "(", "ApiStoreRequest", "$", "request", ",", "$", "crudeName", ")", "{", "$", "this", "->", "crude", "=", "CrudeInstance", "::", "get", "(", "$", "request", "->", "crudeName", ")", ";", "$", "model", "=", "$", "this", "->", "crude", "->", "store", "(", "$", "request", "->", "all", "(", ")", ")", ";", "return", "$", "this", "->", "successResponse", "(", "[", "'model'", "=>", "$", "model", ",", "'message'", "=>", "$", "this", "->", "crude", "->", "getCrudeSetup", "(", ")", "->", "trans", "(", "'item_has_been_saved'", ")", "]", ")", ";", "}" ]
Add new model
[ "Add", "new", "model" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ApiController.php#L75-L85
15,491
kderyabin/logger
src/OptionsTrait.php
OptionsTrait.getOptionOrDefault
public function getOptionOrDefault($name) { return isset($this->options[$name]) ? $this->options[$name] : $this->getDefault($name); }
php
public function getOptionOrDefault($name) { return isset($this->options[$name]) ? $this->options[$name] : $this->getDefault($name); }
[ "public", "function", "getOptionOrDefault", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "options", "[", "$", "name", "]", ")", "?", "$", "this", "->", "options", "[", "$", "name", "]", ":", "$", "this", "->", "getDefault", "(", "$", "name", ")", ";", "}" ]
Get an option value by name or a default option with the same name. @param $name @return mixed
[ "Get", "an", "option", "value", "by", "name", "or", "a", "default", "option", "with", "the", "same", "name", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/OptionsTrait.php#L56-L59
15,492
dantleech/glob
lib/DTL/Glob/Finder/AbstractTraversalFinder.php
AbstractTraversalFinder.traverse
private function traverse(array $segments, &$result = array(), $node = null) { $path = array(); if (null !== $node) { $path = explode('/', substr($node->getPath(), 1)); } do { list($element, $bitmask) = array_shift($segments); if ($bitmask & SelectorParser::T_STATIC) { $path[] = $element; if ($bitmask & SelectorParser::T_LAST) { if ($node = $this->getNode($path)) { $result[] = $node; break; } } } if ($bitmask & SelectorParser::T_PATTERN) { if (null === $parentNode = $this->getNode($path)) { return; } $children = $this->getChildren($parentNode, $element); foreach ($children as $child) { if ($bitmask & SelectorParser::T_LAST) { $result[] = $child; } else { $this->traverse($segments, $result, $child); } } return; } } while ($segments); }
php
private function traverse(array $segments, &$result = array(), $node = null) { $path = array(); if (null !== $node) { $path = explode('/', substr($node->getPath(), 1)); } do { list($element, $bitmask) = array_shift($segments); if ($bitmask & SelectorParser::T_STATIC) { $path[] = $element; if ($bitmask & SelectorParser::T_LAST) { if ($node = $this->getNode($path)) { $result[] = $node; break; } } } if ($bitmask & SelectorParser::T_PATTERN) { if (null === $parentNode = $this->getNode($path)) { return; } $children = $this->getChildren($parentNode, $element); foreach ($children as $child) { if ($bitmask & SelectorParser::T_LAST) { $result[] = $child; } else { $this->traverse($segments, $result, $child); } } return; } } while ($segments); }
[ "private", "function", "traverse", "(", "array", "$", "segments", ",", "&", "$", "result", "=", "array", "(", ")", ",", "$", "node", "=", "null", ")", "{", "$", "path", "=", "array", "(", ")", ";", "if", "(", "null", "!==", "$", "node", ")", "{", "$", "path", "=", "explode", "(", "'/'", ",", "substr", "(", "$", "node", "->", "getPath", "(", ")", ",", "1", ")", ")", ";", "}", "do", "{", "list", "(", "$", "element", ",", "$", "bitmask", ")", "=", "array_shift", "(", "$", "segments", ")", ";", "if", "(", "$", "bitmask", "&", "SelectorParser", "::", "T_STATIC", ")", "{", "$", "path", "[", "]", "=", "$", "element", ";", "if", "(", "$", "bitmask", "&", "SelectorParser", "::", "T_LAST", ")", "{", "if", "(", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "path", ")", ")", "{", "$", "result", "[", "]", "=", "$", "node", ";", "break", ";", "}", "}", "}", "if", "(", "$", "bitmask", "&", "SelectorParser", "::", "T_PATTERN", ")", "{", "if", "(", "null", "===", "$", "parentNode", "=", "$", "this", "->", "getNode", "(", "$", "path", ")", ")", "{", "return", ";", "}", "$", "children", "=", "$", "this", "->", "getChildren", "(", "$", "parentNode", ",", "$", "element", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "if", "(", "$", "bitmask", "&", "SelectorParser", "::", "T_LAST", ")", "{", "$", "result", "[", "]", "=", "$", "child", ";", "}", "else", "{", "$", "this", "->", "traverse", "(", "$", "segments", ",", "$", "result", ",", "$", "child", ")", ";", "}", "}", "return", ";", "}", "}", "while", "(", "$", "segments", ")", ";", "}" ]
Traverse the node @param NodeInterface|null $node The node to traverse, if it exists yet @param array $segments The element => token stack @param array $result The result @return null
[ "Traverse", "the", "node" ]
1f618e6b77a5de4c6b0538d82572fe19cbb1c446
https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/Finder/AbstractTraversalFinder.php#L68-L108
15,493
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Widgets/FlowOfDocuments.php
FlowOfDocuments.addEntry
protected function addEntry($id, $number, $type, DateTime $date, $route, $pdfUrl, $translationKey = '') { $this->entries[] = array( 'id' => $id, 'number' => $number, 'type' => $type, 'date' => $date, 'route' => $route, 'pdfUrl' => $pdfUrl, 'translationKey' => $translationKey ); }
php
protected function addEntry($id, $number, $type, DateTime $date, $route, $pdfUrl, $translationKey = '') { $this->entries[] = array( 'id' => $id, 'number' => $number, 'type' => $type, 'date' => $date, 'route' => $route, 'pdfUrl' => $pdfUrl, 'translationKey' => $translationKey ); }
[ "protected", "function", "addEntry", "(", "$", "id", ",", "$", "number", ",", "$", "type", ",", "DateTime", "$", "date", ",", "$", "route", ",", "$", "pdfUrl", ",", "$", "translationKey", "=", "''", ")", "{", "$", "this", "->", "entries", "[", "]", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'number'", "=>", "$", "number", ",", "'type'", "=>", "$", "type", ",", "'date'", "=>", "$", "date", ",", "'route'", "=>", "$", "route", ",", "'pdfUrl'", "=>", "$", "pdfUrl", ",", "'translationKey'", "=>", "$", "translationKey", ")", ";", "}" ]
Creates and adds an entry to the exisiting entries @param String|Number $id @param String $number @param String $type @param DateTime $date @param String $route @param String $pdfUrl @param String $translationKey
[ "Creates", "and", "adds", "an", "entry", "to", "the", "exisiting", "entries" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Widgets/FlowOfDocuments.php#L48-L59
15,494
stubbles/stubbles-webapp-core
src/main/php/routing/RoutingAnnotations.php
RoutingAnnotations.statusCodes
public function statusCodes(): array { return array_map( function($status) { return new Status($status->getCode(), $status->getDescription()); }, $this->annotations->named('Status') ); }
php
public function statusCodes(): array { return array_map( function($status) { return new Status($status->getCode(), $status->getDescription()); }, $this->annotations->named('Status') ); }
[ "public", "function", "statusCodes", "(", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "$", "status", ")", "{", "return", "new", "Status", "(", "$", "status", "->", "getCode", "(", ")", ",", "$", "status", "->", "getDescription", "(", ")", ")", ";", "}", ",", "$", "this", "->", "annotations", "->", "named", "(", "'Status'", ")", ")", ";", "}" ]
returns list of possible status codes on this route @return stubbles\webapp\routing\api\Status[] @since 6.1.0
[ "returns", "list", "of", "possible", "status", "codes", "on", "this", "route" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/RoutingAnnotations.php#L220-L229
15,495
stubbles/stubbles-webapp-core
src/main/php/routing/RoutingAnnotations.php
RoutingAnnotations.headers
public function headers(): array { return array_map( function($header) { return new Header($header->getName(), $header->getDescription()); }, $this->annotations->named('Header') ); }
php
public function headers(): array { return array_map( function($header) { return new Header($header->getName(), $header->getDescription()); }, $this->annotations->named('Header') ); }
[ "public", "function", "headers", "(", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "$", "header", ")", "{", "return", "new", "Header", "(", "$", "header", "->", "getName", "(", ")", ",", "$", "header", "->", "getDescription", "(", ")", ")", ";", "}", ",", "$", "this", "->", "annotations", "->", "named", "(", "'Header'", ")", ")", ";", "}" ]
returns list of headers on this route @return \stubbles\webapp\routing\api\Header[] @since 6.1.0
[ "returns", "list", "of", "headers", "on", "this", "route" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/RoutingAnnotations.php#L248-L257
15,496
stubbles/stubbles-webapp-core
src/main/php/routing/RoutingAnnotations.php
RoutingAnnotations.parameters
public function parameters(): array { return array_map( function($parameter) { $param = new Parameter( $parameter->getName(), $parameter->getDescription(), $parameter->getIn() ); if ($parameter->hasValueByName('required') && $parameter->isRequired()) { $param->markRequired(); } return $param; }, $this->annotations->named('Parameter') ); }
php
public function parameters(): array { return array_map( function($parameter) { $param = new Parameter( $parameter->getName(), $parameter->getDescription(), $parameter->getIn() ); if ($parameter->hasValueByName('required') && $parameter->isRequired()) { $param->markRequired(); } return $param; }, $this->annotations->named('Parameter') ); }
[ "public", "function", "parameters", "(", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "$", "parameter", ")", "{", "$", "param", "=", "new", "Parameter", "(", "$", "parameter", "->", "getName", "(", ")", ",", "$", "parameter", "->", "getDescription", "(", ")", ",", "$", "parameter", "->", "getIn", "(", ")", ")", ";", "if", "(", "$", "parameter", "->", "hasValueByName", "(", "'required'", ")", "&&", "$", "parameter", "->", "isRequired", "(", ")", ")", "{", "$", "param", "->", "markRequired", "(", ")", ";", "}", "return", "$", "param", ";", "}", ",", "$", "this", "->", "annotations", "->", "named", "(", "'Parameter'", ")", ")", ";", "}" ]
returns list of parameters @return \stubbles\webapp\routing\api\Parameter[] @since 6.1.0
[ "returns", "list", "of", "parameters" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/RoutingAnnotations.php#L276-L295
15,497
Laralum/Roles
src/Traits/HasRoles.php
HasRoles.hasRole
public function hasRole(Role $role) { $role = !is_string($role) ?: Role::where(['name' => $role])->firstOrFail(); if ($role) { foreach ($this->roles as $r) { if ($r->id == $role->id) { return true; } } } return false; }
php
public function hasRole(Role $role) { $role = !is_string($role) ?: Role::where(['name' => $role])->firstOrFail(); if ($role) { foreach ($this->roles as $r) { if ($r->id == $role->id) { return true; } } } return false; }
[ "public", "function", "hasRole", "(", "Role", "$", "role", ")", "{", "$", "role", "=", "!", "is_string", "(", "$", "role", ")", "?", ":", "Role", "::", "where", "(", "[", "'name'", "=>", "$", "role", "]", ")", "->", "firstOrFail", "(", ")", ";", "if", "(", "$", "role", ")", "{", "foreach", "(", "$", "this", "->", "roles", "as", "$", "r", ")", "{", "if", "(", "$", "r", "->", "id", "==", "$", "role", "->", "id", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns true if the user has the role. @param mixed $role @return bool
[ "Returns", "true", "if", "the", "user", "has", "the", "role", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Traits/HasRoles.php#L24-L37
15,498
axelitus/php-base
src/Comparer.php
Comparer.compare
final public function compare($item1, $item2) { if (!$this->isReady()) { throw new \RuntimeException("The comparer is not ready, no valid callback has been set."); } return call_user_func_array($this->callback, [$item1, $item2, $this->options]); }
php
final public function compare($item1, $item2) { if (!$this->isReady()) { throw new \RuntimeException("The comparer is not ready, no valid callback has been set."); } return call_user_func_array($this->callback, [$item1, $item2, $this->options]); }
[ "final", "public", "function", "compare", "(", "$", "item1", ",", "$", "item2", ")", "{", "if", "(", "!", "$", "this", "->", "isReady", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"The comparer is not ready, no valid callback has been set.\"", ")", ";", "}", "return", "call_user_func_array", "(", "$", "this", "->", "callback", ",", "[", "$", "item1", ",", "$", "item2", ",", "$", "this", "->", "options", "]", ")", ";", "}" ]
Compares two items. @param mixed $item1 The left operand. @param mixed $item2 The right operand. @throws \RuntimeException @return int Return <0 if $item1<$item2; 0if $item1=$item2; >1 if $item1>$item2
[ "Compares", "two", "items", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Comparer.php#L144-L151
15,499
jan-dolata/crude-crud
src/Engine/Traits/FromModelTraitPart/OrderTrait.php
OrderTrait.reorder
public function reorder(array $newOrder) { $param = $this->crudeSetup->getOrderParameters(); $idAttr = $param['idAttr']; $orderAttr = $param['orderAttr']; $table = $this->model->getTable(); $data = collect($newOrder)->map(function($item) { return "({$item['id']},{$item['order']})"; })->toArray(); $data = implode(',', $data); \DB::statement("INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);"); }
php
public function reorder(array $newOrder) { $param = $this->crudeSetup->getOrderParameters(); $idAttr = $param['idAttr']; $orderAttr = $param['orderAttr']; $table = $this->model->getTable(); $data = collect($newOrder)->map(function($item) { return "({$item['id']},{$item['order']})"; })->toArray(); $data = implode(',', $data); \DB::statement("INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);"); }
[ "public", "function", "reorder", "(", "array", "$", "newOrder", ")", "{", "$", "param", "=", "$", "this", "->", "crudeSetup", "->", "getOrderParameters", "(", ")", ";", "$", "idAttr", "=", "$", "param", "[", "'idAttr'", "]", ";", "$", "orderAttr", "=", "$", "param", "[", "'orderAttr'", "]", ";", "$", "table", "=", "$", "this", "->", "model", "->", "getTable", "(", ")", ";", "$", "data", "=", "collect", "(", "$", "newOrder", ")", "->", "map", "(", "function", "(", "$", "item", ")", "{", "return", "\"({$item['id']},{$item['order']})\"", ";", "}", ")", "->", "toArray", "(", ")", ";", "$", "data", "=", "implode", "(", "','", ",", "$", "data", ")", ";", "\\", "DB", "::", "statement", "(", "\"INSERT INTO {$table} (`{$idAttr}`,`{$orderAttr}`) VALUES {$data} ON DUPLICATE KEY UPDATE `{$orderAttr}`=VALUES(`{$orderAttr}`);\"", ")", ";", "}" ]
Set new order for selected items @param array $newOrder - list of ids and new order positions
[ "Set", "new", "order", "for", "selected", "items" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Traits/FromModelTraitPart/OrderTrait.php#L53-L67