id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
10,400
wisquimas/valleysofsorcery
admin/mf_custom_taxonomy.php
mf_custom_taxonomy.save_custom_taxonomy
public function save_custom_taxonomy(){ global $mf_domain; //checking the nonce check_admin_referer('form_custom_taxonomy_mf_custom_taxonomy'); if(isset($_POST['mf_custom_taxonomy'])){ //check custom_taxonomy_id $mf = $_POST['mf_custom_taxonomy']; if($mf['core']['id']){ $this->update_custom_taxonomy($mf); }else{ if($this->new_custom_taxonomy($mf)){ //redirect to dashboard }else{ //reload form and show warning } } } $this->mf_redirect(null,null,array('message' => 'success')); }
php
public function save_custom_taxonomy(){ global $mf_domain; //checking the nonce check_admin_referer('form_custom_taxonomy_mf_custom_taxonomy'); if(isset($_POST['mf_custom_taxonomy'])){ //check custom_taxonomy_id $mf = $_POST['mf_custom_taxonomy']; if($mf['core']['id']){ $this->update_custom_taxonomy($mf); }else{ if($this->new_custom_taxonomy($mf)){ //redirect to dashboard }else{ //reload form and show warning } } } $this->mf_redirect(null,null,array('message' => 'success')); }
[ "public", "function", "save_custom_taxonomy", "(", ")", "{", "global", "$", "mf_domain", ";", "//checking the nonce", "check_admin_referer", "(", "'form_custom_taxonomy_mf_custom_taxonomy'", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'mf_custom_taxonomy'", "]", ")", ")", "{", "//check custom_taxonomy_id", "$", "mf", "=", "$", "_POST", "[", "'mf_custom_taxonomy'", "]", ";", "if", "(", "$", "mf", "[", "'core'", "]", "[", "'id'", "]", ")", "{", "$", "this", "->", "update_custom_taxonomy", "(", "$", "mf", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "new_custom_taxonomy", "(", "$", "mf", ")", ")", "{", "//redirect to dashboard", "}", "else", "{", "//reload form and show warning", "}", "}", "}", "$", "this", "->", "mf_redirect", "(", "null", ",", "null", ",", "array", "(", "'message'", "=>", "'success'", ")", ")", ";", "}" ]
save a custom taxonomy
[ "save", "a", "custom", "taxonomy" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_taxonomy.php#L75-L95
10,401
wisquimas/valleysofsorcery
admin/mf_custom_taxonomy.php
mf_custom_taxonomy.delete_custom_taxonomy
public function delete_custom_taxonomy(){ global $wpdb; //checking the nonce check_admin_referer('delete_custom_taxonomy_mf_custom_taxonomy'); if( isset($_GET['custom_taxonomy_id']) ){ $id = (int)$_GET['custom_taxonomy_id']; if( is_int($id) ){ $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_TAXONOMY." WHERE id = %d",$id ); $wpdb->query($sql); $this->mf_redirect(null,null,array('message' => 'success')); } } }
php
public function delete_custom_taxonomy(){ global $wpdb; //checking the nonce check_admin_referer('delete_custom_taxonomy_mf_custom_taxonomy'); if( isset($_GET['custom_taxonomy_id']) ){ $id = (int)$_GET['custom_taxonomy_id']; if( is_int($id) ){ $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_TAXONOMY." WHERE id = %d",$id ); $wpdb->query($sql); $this->mf_redirect(null,null,array('message' => 'success')); } } }
[ "public", "function", "delete_custom_taxonomy", "(", ")", "{", "global", "$", "wpdb", ";", "//checking the nonce", "check_admin_referer", "(", "'delete_custom_taxonomy_mf_custom_taxonomy'", ")", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'custom_taxonomy_id'", "]", ")", ")", "{", "$", "id", "=", "(", "int", ")", "$", "_GET", "[", "'custom_taxonomy_id'", "]", ";", "if", "(", "is_int", "(", "$", "id", ")", ")", "{", "$", "sql", "=", "$", "wpdb", "->", "prepare", "(", "\"DELETE FROM \"", ".", "MF_TABLE_CUSTOM_TAXONOMY", ".", "\" WHERE id = %d\"", ",", "$", "id", ")", ";", "$", "wpdb", "->", "query", "(", "$", "sql", ")", ";", "$", "this", "->", "mf_redirect", "(", "null", ",", "null", ",", "array", "(", "'message'", "=>", "'success'", ")", ")", ";", "}", "}", "}" ]
delete a custom taxonomy
[ "delete", "a", "custom", "taxonomy" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_taxonomy.php#L100-L115
10,402
dendevs/plpconfig
src/libs/ConfigLib.php
ConfigLib.get_value
public function get_value( $option_name, $default_value = false ) { $service_name = substr( $option_name, 0, strpos( $option_name, '.' ) ); $option_name = str_replace( $service_name . '.', '', $option_name ); // debug // echo $service_name; // echo $option_name; $value = false; if( array_key_exists( $service_name, $this->_configs ) ) { if( array_key_exists( $option_name, $this->_configs[$service_name] ) ) { $value = $this->_configs[$service_name][$option_name]; } else if( $default_value ) { $value = $default_value; } } return $value; }
php
public function get_value( $option_name, $default_value = false ) { $service_name = substr( $option_name, 0, strpos( $option_name, '.' ) ); $option_name = str_replace( $service_name . '.', '', $option_name ); // debug // echo $service_name; // echo $option_name; $value = false; if( array_key_exists( $service_name, $this->_configs ) ) { if( array_key_exists( $option_name, $this->_configs[$service_name] ) ) { $value = $this->_configs[$service_name][$option_name]; } else if( $default_value ) { $value = $default_value; } } return $value; }
[ "public", "function", "get_value", "(", "$", "option_name", ",", "$", "default_value", "=", "false", ")", "{", "$", "service_name", "=", "substr", "(", "$", "option_name", ",", "0", ",", "strpos", "(", "$", "option_name", ",", "'.'", ")", ")", ";", "$", "option_name", "=", "str_replace", "(", "$", "service_name", ".", "'.'", ",", "''", ",", "$", "option_name", ")", ";", "// debug", "// echo $service_name;", "// echo $option_name;", "$", "value", "=", "false", ";", "if", "(", "array_key_exists", "(", "$", "service_name", ",", "$", "this", "->", "_configs", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "option_name", ",", "$", "this", "->", "_configs", "[", "$", "service_name", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "_configs", "[", "$", "service_name", "]", "[", "$", "option_name", "]", ";", "}", "else", "if", "(", "$", "default_value", ")", "{", "$", "value", "=", "$", "default_value", ";", "}", "}", "return", "$", "value", ";", "}" ]
Recupere la valeur de l'option de config L'option coorespond a service.option_name. Si je veux la root_path du kernel -> kernel.option_name @param string $config_name nom de l'option de Configuration a retrouver service.option_name.sous_option @param string $default_value donne une valeur si la config n'existe pas @return mixed renvoi la valeur ou false
[ "Recupere", "la", "valeur", "de", "l", "option", "de", "config" ]
fa198ed504a248420d1a6b59397438a3cfd83d49
https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/ConfigLib.php#L50-L73
10,403
dendevs/plpconfig
src/libs/ConfigLib.php
ConfigLib.get_values
public function get_values( $service_name = false ) { if( $service_name ) { $values = $this->_configs[$service_name]; } else { $values = $this->_configs; } return $values; }
php
public function get_values( $service_name = false ) { if( $service_name ) { $values = $this->_configs[$service_name]; } else { $values = $this->_configs; } return $values; }
[ "public", "function", "get_values", "(", "$", "service_name", "=", "false", ")", "{", "if", "(", "$", "service_name", ")", "{", "$", "values", "=", "$", "this", "->", "_configs", "[", "$", "service_name", "]", ";", "}", "else", "{", "$", "values", "=", "$", "this", "->", "_configs", ";", "}", "return", "$", "values", ";", "}" ]
Retourne toute la configuration. Renvoi toute la config d'un service ou de tout les services @param string $service_name le nom du service dont on veut tout @return array tableau ou tableau de tableau de config
[ "Retourne", "toute", "la", "configuration", "." ]
fa198ed504a248420d1a6b59397438a3cfd83d49
https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/ConfigLib.php#L84-L96
10,404
dendevs/plpconfig
src/libs/ConfigLib.php
ConfigLib.merge_with_default
public function merge_with_default( $service_name, $default_values ) { if( is_array( $default_values ) && is_array( $this->_configs[$service_name] ) ) { $this->_configs[$service_name] = array_merge( $default_values, $this->_configs[$service_name] ); } return $this->_configs[$service_name]; }
php
public function merge_with_default( $service_name, $default_values ) { if( is_array( $default_values ) && is_array( $this->_configs[$service_name] ) ) { $this->_configs[$service_name] = array_merge( $default_values, $this->_configs[$service_name] ); } return $this->_configs[$service_name]; }
[ "public", "function", "merge_with_default", "(", "$", "service_name", ",", "$", "default_values", ")", "{", "if", "(", "is_array", "(", "$", "default_values", ")", "&&", "is_array", "(", "$", "this", "->", "_configs", "[", "$", "service_name", "]", ")", ")", "{", "$", "this", "->", "_configs", "[", "$", "service_name", "]", "=", "array_merge", "(", "$", "default_values", ",", "$", "this", "->", "_configs", "[", "$", "service_name", "]", ")", ";", "}", "return", "$", "this", "->", "_configs", "[", "$", "service_name", "]", ";", "}" ]
Fusionne les valeurs par defaut avec celle du fichier de config. Les valeurs du fichiers sont prioritaire. La mise à jour n'affecte que la config du service @param string $service_name cible les options a mettre a jour @param array $default_values les valeurs de config du service @return array le tableau a jour du service.
[ "Fusionne", "les", "valeurs", "par", "defaut", "avec", "celle", "du", "fichier", "de", "config", "." ]
fa198ed504a248420d1a6b59397438a3cfd83d49
https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/ConfigLib.php#L109-L117
10,405
dendevs/plpconfig
src/libs/ConfigLib.php
ConfigLib._set_config
private function _set_config() { $ok = false; $this->_configs = array(); if( $this->_file_lib->check_dir() ) { $all_configs_file = $this->_file_lib->get_path_files(); $wise = Wise::create( $this->_file_lib ); foreach( $all_configs_file as $service_name => $config_file ) { $this->_configs[$service_name] = $wise->loadFlat( $config_file ); } } return $ok; }
php
private function _set_config() { $ok = false; $this->_configs = array(); if( $this->_file_lib->check_dir() ) { $all_configs_file = $this->_file_lib->get_path_files(); $wise = Wise::create( $this->_file_lib ); foreach( $all_configs_file as $service_name => $config_file ) { $this->_configs[$service_name] = $wise->loadFlat( $config_file ); } } return $ok; }
[ "private", "function", "_set_config", "(", ")", "{", "$", "ok", "=", "false", ";", "$", "this", "->", "_configs", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "_file_lib", "->", "check_dir", "(", ")", ")", "{", "$", "all_configs_file", "=", "$", "this", "->", "_file_lib", "->", "get_path_files", "(", ")", ";", "$", "wise", "=", "Wise", "::", "create", "(", "$", "this", "->", "_file_lib", ")", ";", "foreach", "(", "$", "all_configs_file", "as", "$", "service_name", "=>", "$", "config_file", ")", "{", "$", "this", "->", "_configs", "[", "$", "service_name", "]", "=", "$", "wise", "->", "loadFlat", "(", "$", "config_file", ")", ";", "}", "}", "return", "$", "ok", ";", "}" ]
Charge les configs trouver dans le repertoire Une config est un fichier .php portant le nom du service La contenu du fichier est un return array( "ma_config_name" => "value" ) @return bool true si reussit
[ "Charge", "les", "configs", "trouver", "dans", "le", "repertoire" ]
fa198ed504a248420d1a6b59397438a3cfd83d49
https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/ConfigLib.php#L128-L145
10,406
loopsframework/base
src/Loops/Application.php
Application.definedClasses
public function definedClasses() { $loops = $this->getLoops(); $cache = $loops->getService("cache"); $key = "Loops-Application-definedClasses"; if($cache->contains($key)) { return $cache->fetch($key); } $require = function($dir) use (&$require, &$classes) { foreach(scandir($dir) as $file) { if(substr($file, 0, 1) == '.') { continue; } $filename = "$dir/$file"; if(is_dir($filename)) { $require($filename); } else { require_once($filename); } } }; $dirs = $this->include_dir; array_walk($dirs, $require); $classes = array_values(array_filter(get_declared_classes(), function($classname) use ($dirs, $cache) { $reflection = new ReflectionClass($classname); $filename = $reflection->getFileName(); if(!$filename) { return FALSE; } if($this->enable_cached_autoload) { $key = "Loops-Application-autoload-$classname"; $cache->save($key, $filename); } foreach($dirs as $dir) { if(substr($filename, 0, strlen($dir)) == $dir) { return TRUE; } } return FALSE; })); $cache->save($key, $classes); return $classes; }
php
public function definedClasses() { $loops = $this->getLoops(); $cache = $loops->getService("cache"); $key = "Loops-Application-definedClasses"; if($cache->contains($key)) { return $cache->fetch($key); } $require = function($dir) use (&$require, &$classes) { foreach(scandir($dir) as $file) { if(substr($file, 0, 1) == '.') { continue; } $filename = "$dir/$file"; if(is_dir($filename)) { $require($filename); } else { require_once($filename); } } }; $dirs = $this->include_dir; array_walk($dirs, $require); $classes = array_values(array_filter(get_declared_classes(), function($classname) use ($dirs, $cache) { $reflection = new ReflectionClass($classname); $filename = $reflection->getFileName(); if(!$filename) { return FALSE; } if($this->enable_cached_autoload) { $key = "Loops-Application-autoload-$classname"; $cache->save($key, $filename); } foreach($dirs as $dir) { if(substr($filename, 0, strlen($dir)) == $dir) { return TRUE; } } return FALSE; })); $cache->save($key, $classes); return $classes; }
[ "public", "function", "definedClasses", "(", ")", "{", "$", "loops", "=", "$", "this", "->", "getLoops", "(", ")", ";", "$", "cache", "=", "$", "loops", "->", "getService", "(", "\"cache\"", ")", ";", "$", "key", "=", "\"Loops-Application-definedClasses\"", ";", "if", "(", "$", "cache", "->", "contains", "(", "$", "key", ")", ")", "{", "return", "$", "cache", "->", "fetch", "(", "$", "key", ")", ";", "}", "$", "require", "=", "function", "(", "$", "dir", ")", "use", "(", "&", "$", "require", ",", "&", "$", "classes", ")", "{", "foreach", "(", "scandir", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "if", "(", "substr", "(", "$", "file", ",", "0", ",", "1", ")", "==", "'.'", ")", "{", "continue", ";", "}", "$", "filename", "=", "\"$dir/$file\"", ";", "if", "(", "is_dir", "(", "$", "filename", ")", ")", "{", "$", "require", "(", "$", "filename", ")", ";", "}", "else", "{", "require_once", "(", "$", "filename", ")", ";", "}", "}", "}", ";", "$", "dirs", "=", "$", "this", "->", "include_dir", ";", "array_walk", "(", "$", "dirs", ",", "$", "require", ")", ";", "$", "classes", "=", "array_values", "(", "array_filter", "(", "get_declared_classes", "(", ")", ",", "function", "(", "$", "classname", ")", "use", "(", "$", "dirs", ",", "$", "cache", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "$", "filename", "=", "$", "reflection", "->", "getFileName", "(", ")", ";", "if", "(", "!", "$", "filename", ")", "{", "return", "FALSE", ";", "}", "if", "(", "$", "this", "->", "enable_cached_autoload", ")", "{", "$", "key", "=", "\"Loops-Application-autoload-$classname\"", ";", "$", "cache", "->", "save", "(", "$", "key", ",", "$", "filename", ")", ";", "}", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "if", "(", "substr", "(", "$", "filename", ",", "0", ",", "strlen", "(", "$", "dir", ")", ")", "==", "$", "dir", ")", "{", "return", "TRUE", ";", "}", "}", "return", "FALSE", ";", "}", ")", ")", ";", "$", "cache", "->", "save", "(", "$", "key", ",", "$", "classes", ")", ";", "return", "$", "classes", ";", "}" ]
Get a list of all classnames that are defined in the app directory @return array<string> The list of all classes.
[ "Get", "a", "list", "of", "all", "classnames", "that", "are", "defined", "in", "the", "app", "directory" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application.php#L241-L298
10,407
loopsframework/base
src/Loops/Application.php
Application.isolated_boot
private static function isolated_boot($loops) { if(is_file($loops->getService("application")->boot) && is_readable($loops->getService("application")->boot)) { require($loops->getService("application")->boot); } }
php
private static function isolated_boot($loops) { if(is_file($loops->getService("application")->boot) && is_readable($loops->getService("application")->boot)) { require($loops->getService("application")->boot); } }
[ "private", "static", "function", "isolated_boot", "(", "$", "loops", ")", "{", "if", "(", "is_file", "(", "$", "loops", "->", "getService", "(", "\"application\"", ")", "->", "boot", ")", "&&", "is_readable", "(", "$", "loops", "->", "getService", "(", "\"application\"", ")", "->", "boot", ")", ")", "{", "require", "(", "$", "loops", "->", "getService", "(", "\"application\"", ")", "->", "boot", ")", ";", "}", "}" ]
Includes the boot file in an isolated namespace
[ "Includes", "the", "boot", "file", "in", "an", "isolated", "namespace" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application.php#L311-L315
10,408
belgattitude/soluble-schema
src/Soluble/Schema/Source/Mysql/AbstractMysqlDriver.php
AbstractMysqlDriver.disableInnoDbStats
protected function disableInnoDbStats() { $sql = "show global variables like 'innodb_stats_on_metadata'"; try { $results = $this->adapter->query($sql); if (count($results) > 0) { $row = $results->offsetGet(0); $value = strtoupper($row['Value']); // if 'on' no need to do anything if ($value != 'OFF') { $this->mysql_innodbstats_value = $value; // disabling innodb_stats $this->adapter->query("set global innodb_stats_on_metadata='OFF'"); } } } catch (\Exception $e) { // do nothing, silently fallback } }
php
protected function disableInnoDbStats() { $sql = "show global variables like 'innodb_stats_on_metadata'"; try { $results = $this->adapter->query($sql); if (count($results) > 0) { $row = $results->offsetGet(0); $value = strtoupper($row['Value']); // if 'on' no need to do anything if ($value != 'OFF') { $this->mysql_innodbstats_value = $value; // disabling innodb_stats $this->adapter->query("set global innodb_stats_on_metadata='OFF'"); } } } catch (\Exception $e) { // do nothing, silently fallback } }
[ "protected", "function", "disableInnoDbStats", "(", ")", "{", "$", "sql", "=", "\"show global variables like 'innodb_stats_on_metadata'\"", ";", "try", "{", "$", "results", "=", "$", "this", "->", "adapter", "->", "query", "(", "$", "sql", ")", ";", "if", "(", "count", "(", "$", "results", ")", ">", "0", ")", "{", "$", "row", "=", "$", "results", "->", "offsetGet", "(", "0", ")", ";", "$", "value", "=", "strtoupper", "(", "$", "row", "[", "'Value'", "]", ")", ";", "// if 'on' no need to do anything", "if", "(", "$", "value", "!=", "'OFF'", ")", "{", "$", "this", "->", "mysql_innodbstats_value", "=", "$", "value", ";", "// disabling innodb_stats", "$", "this", "->", "adapter", "->", "query", "(", "\"set global innodb_stats_on_metadata='OFF'\"", ")", ";", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// do nothing, silently fallback", "}", "}" ]
Disable innodbstats will increase speed of metadata lookups.
[ "Disable", "innodbstats", "will", "increase", "speed", "of", "metadata", "lookups", "." ]
7c6959740f7392ef22c12c2118ddf53294a01955
https://github.com/belgattitude/soluble-schema/blob/7c6959740f7392ef22c12c2118ddf53294a01955/src/Soluble/Schema/Source/Mysql/AbstractMysqlDriver.php#L41-L60
10,409
roggeo/glance
src/Extensions.php
Extensions.check
public function check($file, $ret_ext = false) { $exp = explode('.', $file); $ext = end($exp); if( $this->ext('.'.$ext) ) { return (!$ret_ext) ? true : $ext; } return false; }
php
public function check($file, $ret_ext = false) { $exp = explode('.', $file); $ext = end($exp); if( $this->ext('.'.$ext) ) { return (!$ret_ext) ? true : $ext; } return false; }
[ "public", "function", "check", "(", "$", "file", ",", "$", "ret_ext", "=", "false", ")", "{", "$", "exp", "=", "explode", "(", "'.'", ",", "$", "file", ")", ";", "$", "ext", "=", "end", "(", "$", "exp", ")", ";", "if", "(", "$", "this", "->", "ext", "(", "'.'", ".", "$", "ext", ")", ")", "{", "return", "(", "!", "$", "ret_ext", ")", "?", "true", ":", "$", "ext", ";", "}", "return", "false", ";", "}" ]
Check whether extensions are valid to themes @param string $file @param bool $ret_ext If returns extension or not. @retun bool|string
[ "Check", "whether", "extensions", "are", "valid", "to", "themes" ]
b01ac6827e39ec8f3d501c8128551a65ec0bf309
https://github.com/roggeo/glance/blob/b01ac6827e39ec8f3d501c8128551a65ec0bf309/src/Extensions.php#L24-L35
10,410
o3co/query.core
Query/ExpressionBuilder.php
ExpressionBuilder.prefix
public function prefix($field, $value) { if(!$value instanceof Expr\ConditionalExpression) { $value = $this->buildPart(Expr\TextComparisonExpression::escapeString((string)$value) . Expr\TextComparisonExpression::WILDCARD_STRING); } return new Expr\TextComparisonExpression($field, $value, Expr\TextComparisonExpression::MATCH); }
php
public function prefix($field, $value) { if(!$value instanceof Expr\ConditionalExpression) { $value = $this->buildPart(Expr\TextComparisonExpression::escapeString((string)$value) . Expr\TextComparisonExpression::WILDCARD_STRING); } return new Expr\TextComparisonExpression($field, $value, Expr\TextComparisonExpression::MATCH); }
[ "public", "function", "prefix", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "Expr", "\\", "ConditionalExpression", ")", "{", "$", "value", "=", "$", "this", "->", "buildPart", "(", "Expr", "\\", "TextComparisonExpression", "::", "escapeString", "(", "(", "string", ")", "$", "value", ")", ".", "Expr", "\\", "TextComparisonExpression", "::", "WILDCARD_STRING", ")", ";", "}", "return", "new", "Expr", "\\", "TextComparisonExpression", "(", "$", "field", ",", "$", "value", ",", "Expr", "\\", "TextComparisonExpression", "::", "MATCH", ")", ";", "}" ]
prefix Match prefix @param mixed $field @param mixed $value @access public @return void
[ "prefix", "Match", "prefix" ]
92478f21d2b04e21fef936944c7b688a092a4bf4
https://github.com/o3co/query.core/blob/92478f21d2b04e21fef936944c7b688a092a4bf4/Query/ExpressionBuilder.php#L232-L238
10,411
Dhii/normalization-helper-base
src/NormalizeStringCapableTrait.php
NormalizeStringCapableTrait._normalizeString
protected function _normalizeString($subject) { if ($subject instanceof Stringable) { return $subject->__toString(); } if (is_scalar($subject)) { return (string) $subject; } throw $this->_createInvalidArgumentException($this->__('Not a stringable value'), null, null, $subject); }
php
protected function _normalizeString($subject) { if ($subject instanceof Stringable) { return $subject->__toString(); } if (is_scalar($subject)) { return (string) $subject; } throw $this->_createInvalidArgumentException($this->__('Not a stringable value'), null, null, $subject); }
[ "protected", "function", "_normalizeString", "(", "$", "subject", ")", "{", "if", "(", "$", "subject", "instanceof", "Stringable", ")", "{", "return", "$", "subject", "->", "__toString", "(", ")", ";", "}", "if", "(", "is_scalar", "(", "$", "subject", ")", ")", "{", "return", "(", "string", ")", "$", "subject", ";", "}", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Not a stringable value'", ")", ",", "null", ",", "null", ",", "$", "subject", ")", ";", "}" ]
Normalizes a value to its string representation. The values that can be normalized are any scalar values, as well as {@see StringableInterface). @since [*next-version*] @param Stringable|string|int|float|bool $subject The value to normalize to string. @throws InvalidArgumentException If the value cannot be normalized. @return string The string that resulted from normalization.
[ "Normalizes", "a", "value", "to", "its", "string", "representation", "." ]
1b64f0ea6b3e32f9478f854f6049500795b51da7
https://github.com/Dhii/normalization-helper-base/blob/1b64f0ea6b3e32f9478f854f6049500795b51da7/src/NormalizeStringCapableTrait.php#L30-L41
10,412
stratifyphp/http
src/Application.php
Application.run
public function run(ServerRequestInterface $request = null) { $request = $request ?: ServerRequestFactory::fromGlobals(); $response = $this->handle($request); $this->responseEmitter->emit($response); }
php
public function run(ServerRequestInterface $request = null) { $request = $request ?: ServerRequestFactory::fromGlobals(); $response = $this->handle($request); $this->responseEmitter->emit($response); }
[ "public", "function", "run", "(", "ServerRequestInterface", "$", "request", "=", "null", ")", "{", "$", "request", "=", "$", "request", "?", ":", "ServerRequestFactory", "::", "fromGlobals", "(", ")", ";", "$", "response", "=", "$", "this", "->", "handle", "(", "$", "request", ")", ";", "$", "this", "->", "responseEmitter", "->", "emit", "(", "$", "response", ")", ";", "}" ]
Handle the global incoming request and sends the response. @see handle() to handle an HTTP request and not write the response to the output.
[ "Handle", "the", "global", "incoming", "request", "and", "sends", "the", "response", "." ]
5eb55f2ea4ad7bcaefa6a5b26d98c9c804f2d8a4
https://github.com/stratifyphp/http/blob/5eb55f2ea4ad7bcaefa6a5b26d98c9c804f2d8a4/src/Application.php#L53-L60
10,413
leedave/codemonkey
src/Core/Project.php
Project.getAllowedPostedAttributes
protected function getAllowedPostedAttributes() { $arrAddAttributes = []; $arrAllowedAttributes = []; foreach ($this->config['attributes'] as $attr) { $arrAllowedAttributes[] = $attr['name']; } foreach ($_POST as $key => $val) { if (!in_array($key, $arrAllowedAttributes)) { continue; } $arrAddAttributes[$key] = $val; } return $arrAddAttributes; }
php
protected function getAllowedPostedAttributes() { $arrAddAttributes = []; $arrAllowedAttributes = []; foreach ($this->config['attributes'] as $attr) { $arrAllowedAttributes[] = $attr['name']; } foreach ($_POST as $key => $val) { if (!in_array($key, $arrAllowedAttributes)) { continue; } $arrAddAttributes[$key] = $val; } return $arrAddAttributes; }
[ "protected", "function", "getAllowedPostedAttributes", "(", ")", "{", "$", "arrAddAttributes", "=", "[", "]", ";", "$", "arrAllowedAttributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "config", "[", "'attributes'", "]", "as", "$", "attr", ")", "{", "$", "arrAllowedAttributes", "[", "]", "=", "$", "attr", "[", "'name'", "]", ";", "}", "foreach", "(", "$", "_POST", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "arrAllowedAttributes", ")", ")", "{", "continue", ";", "}", "$", "arrAddAttributes", "[", "$", "key", "]", "=", "$", "val", ";", "}", "return", "$", "arrAddAttributes", ";", "}" ]
Catches all POST attributes that were sent from the webform, providing they are defined in the JSON Config @return array
[ "Catches", "all", "POST", "attributes", "that", "were", "sent", "from", "the", "webform", "providing", "they", "are", "defined", "in", "the", "JSON", "Config" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L71-L85
10,414
leedave/codemonkey
src/Core/Project.php
Project.addPostAttributes
protected function addPostAttributes(File $file) { $arrAddAttributes = $this->getAllowedPostedAttributes(); $file->addAttributes($arrAddAttributes); return $file; }
php
protected function addPostAttributes(File $file) { $arrAddAttributes = $this->getAllowedPostedAttributes(); $file->addAttributes($arrAddAttributes); return $file; }
[ "protected", "function", "addPostAttributes", "(", "File", "$", "file", ")", "{", "$", "arrAddAttributes", "=", "$", "this", "->", "getAllowedPostedAttributes", "(", ")", ";", "$", "file", "->", "addAttributes", "(", "$", "arrAddAttributes", ")", ";", "return", "$", "file", ";", "}" ]
Add the POST variables to the placeholders @param File $file @return File
[ "Add", "the", "POST", "variables", "to", "the", "placeholders" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L93-L97
10,415
leedave/codemonkey
src/Core/Project.php
Project.execute
public function execute() { if (!count($this->config['files'])) { return; } if (isset($_POST) && count($_POST) > 0) { $this->createFiles(); $this->returnZipFile(); } else { echo $this->renderInputForm(); } }
php
public function execute() { if (!count($this->config['files'])) { return; } if (isset($_POST) && count($_POST) > 0) { $this->createFiles(); $this->returnZipFile(); } else { echo $this->renderInputForm(); } }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "config", "[", "'files'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "_POST", ")", "&&", "count", "(", "$", "_POST", ")", ">", "0", ")", "{", "$", "this", "->", "createFiles", "(", ")", ";", "$", "this", "->", "returnZipFile", "(", ")", ";", "}", "else", "{", "echo", "$", "this", "->", "renderInputForm", "(", ")", ";", "}", "}" ]
Run the Page 1. If no config set, empty 2. If no POST params, show Webform 3. If POST params, generate and Zip Files @return type
[ "Run", "the", "Page", "1", ".", "If", "no", "config", "set", "empty", "2", ".", "If", "no", "POST", "params", "show", "Webform", "3", ".", "If", "POST", "params", "generate", "and", "Zip", "Files" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L107-L118
10,416
leedave/codemonkey
src/Core/Project.php
Project.renderInputForm
protected function renderInputForm() { $arrTableBody = []; foreach ($this->config['attributes'] as $attribute) { $label = isset($attribute['label'])?$attribute['label']:""; $fieldName = isset($attribute['name'])?$attribute['name']:""; $value = isset($attribute['default'])?$attribute['default']:""; $arrTableBody[] = [ H::label($label, $fieldName), H::input($fieldName, "input", $value), ]; } $content = H::renderTable([], $arrTableBody) . H::button("Generate Code"); $output = H::form($_SERVER['REQUEST_URI'], $content); $headers = ""; if (defined('css_headers')) { foreach(css_headers as $css) { $headers .= H::link("", ["href" => $css, "rel" => "stylesheet"]); } } return H::htmlDocument("Codemonkey", $headers, $output); }
php
protected function renderInputForm() { $arrTableBody = []; foreach ($this->config['attributes'] as $attribute) { $label = isset($attribute['label'])?$attribute['label']:""; $fieldName = isset($attribute['name'])?$attribute['name']:""; $value = isset($attribute['default'])?$attribute['default']:""; $arrTableBody[] = [ H::label($label, $fieldName), H::input($fieldName, "input", $value), ]; } $content = H::renderTable([], $arrTableBody) . H::button("Generate Code"); $output = H::form($_SERVER['REQUEST_URI'], $content); $headers = ""; if (defined('css_headers')) { foreach(css_headers as $css) { $headers .= H::link("", ["href" => $css, "rel" => "stylesheet"]); } } return H::htmlDocument("Codemonkey", $headers, $output); }
[ "protected", "function", "renderInputForm", "(", ")", "{", "$", "arrTableBody", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "config", "[", "'attributes'", "]", "as", "$", "attribute", ")", "{", "$", "label", "=", "isset", "(", "$", "attribute", "[", "'label'", "]", ")", "?", "$", "attribute", "[", "'label'", "]", ":", "\"\"", ";", "$", "fieldName", "=", "isset", "(", "$", "attribute", "[", "'name'", "]", ")", "?", "$", "attribute", "[", "'name'", "]", ":", "\"\"", ";", "$", "value", "=", "isset", "(", "$", "attribute", "[", "'default'", "]", ")", "?", "$", "attribute", "[", "'default'", "]", ":", "\"\"", ";", "$", "arrTableBody", "[", "]", "=", "[", "H", "::", "label", "(", "$", "label", ",", "$", "fieldName", ")", ",", "H", "::", "input", "(", "$", "fieldName", ",", "\"input\"", ",", "$", "value", ")", ",", "]", ";", "}", "$", "content", "=", "H", "::", "renderTable", "(", "[", "]", ",", "$", "arrTableBody", ")", ".", "H", "::", "button", "(", "\"Generate Code\"", ")", ";", "$", "output", "=", "H", "::", "form", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "$", "content", ")", ";", "$", "headers", "=", "\"\"", ";", "if", "(", "defined", "(", "'css_headers'", ")", ")", "{", "foreach", "(", "css_headers", "as", "$", "css", ")", "{", "$", "headers", ".=", "H", "::", "link", "(", "\"\"", ",", "[", "\"href\"", "=>", "$", "css", ",", "\"rel\"", "=>", "\"stylesheet\"", "]", ")", ";", "}", "}", "return", "H", "::", "htmlDocument", "(", "\"Codemonkey\"", ",", "$", "headers", ",", "$", "output", ")", ";", "}" ]
Render webform for dynamic placeholders @return string HTML Page
[ "Render", "webform", "for", "dynamic", "placeholders" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L134-L157
10,417
leedave/codemonkey
src/Core/Project.php
Project.flushDir
protected function flushDir($dir) { if (!file_exists($dir)) { echo "HELP cant find ".$dir."\n"; return; } $objects = scandir($dir); foreach ($objects as $object) { try { $this->deleteFile($object, $dir); } catch (Exception $e) { echo "Can't remove Folder/File ".$dir.DIRECTORY_SEPARATOR.$object."<br />\n" . $e->getMessage()."<br />\n"; } } }
php
protected function flushDir($dir) { if (!file_exists($dir)) { echo "HELP cant find ".$dir."\n"; return; } $objects = scandir($dir); foreach ($objects as $object) { try { $this->deleteFile($object, $dir); } catch (Exception $e) { echo "Can't remove Folder/File ".$dir.DIRECTORY_SEPARATOR.$object."<br />\n" . $e->getMessage()."<br />\n"; } } }
[ "protected", "function", "flushDir", "(", "$", "dir", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "echo", "\"HELP cant find \"", ".", "$", "dir", ".", "\"\\n\"", ";", "return", ";", "}", "$", "objects", "=", "scandir", "(", "$", "dir", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", "try", "{", "$", "this", "->", "deleteFile", "(", "$", "object", ",", "$", "dir", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "echo", "\"Can't remove Folder/File \"", ".", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "object", ".", "\"<br />\\n\"", ".", "$", "e", "->", "getMessage", "(", ")", ".", "\"<br />\\n\"", ";", "}", "}", "}" ]
Deletes contents of a folder and content @param string $dir Directory path
[ "Deletes", "contents", "of", "a", "folder", "and", "content" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L172-L187
10,418
leedave/codemonkey
src/Core/Project.php
Project.listTempDir
protected function listTempDir($dir = ''){ $arrFiles = []; $scandir = ($dir != '')?$dir:'.'; $objects = scandir($scandir); foreach ($objects as $object) { if ($object == "." || $object == "..") { continue; } $objectPath = ($dir != '')?$dir.DIRECTORY_SEPARATOR.$object:$object; if (is_dir($objectPath)) { $arrFiles = array_merge($arrFiles, $this->listTempDir($objectPath)); } else { $arrFiles[] = $objectPath; } } return $arrFiles; }
php
protected function listTempDir($dir = ''){ $arrFiles = []; $scandir = ($dir != '')?$dir:'.'; $objects = scandir($scandir); foreach ($objects as $object) { if ($object == "." || $object == "..") { continue; } $objectPath = ($dir != '')?$dir.DIRECTORY_SEPARATOR.$object:$object; if (is_dir($objectPath)) { $arrFiles = array_merge($arrFiles, $this->listTempDir($objectPath)); } else { $arrFiles[] = $objectPath; } } return $arrFiles; }
[ "protected", "function", "listTempDir", "(", "$", "dir", "=", "''", ")", "{", "$", "arrFiles", "=", "[", "]", ";", "$", "scandir", "=", "(", "$", "dir", "!=", "''", ")", "?", "$", "dir", ":", "'.'", ";", "$", "objects", "=", "scandir", "(", "$", "scandir", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", "if", "(", "$", "object", "==", "\".\"", "||", "$", "object", "==", "\"..\"", ")", "{", "continue", ";", "}", "$", "objectPath", "=", "(", "$", "dir", "!=", "''", ")", "?", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "object", ":", "$", "object", ";", "if", "(", "is_dir", "(", "$", "objectPath", ")", ")", "{", "$", "arrFiles", "=", "array_merge", "(", "$", "arrFiles", ",", "$", "this", "->", "listTempDir", "(", "$", "objectPath", ")", ")", ";", "}", "else", "{", "$", "arrFiles", "[", "]", "=", "$", "objectPath", ";", "}", "}", "return", "$", "arrFiles", ";", "}" ]
Picks up all the file names in the temp folder. Needed to create a zip @return array
[ "Picks", "up", "all", "the", "file", "names", "in", "the", "temp", "folder", ".", "Needed", "to", "create", "a", "zip" ]
306f222c4329bf44d7fd7f91dade0a9594aa9243
https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Project.php#L234-L250
10,419
wasabi-cms/core
src/Model/Table/UsersTable.php
UsersTable.validationPasswordOnly
public function validationPasswordOnly(Validator $validator) { $validator ->notEmpty('password', __d('wasabi_core', 'Please enter a password.')) ->add('password', [ 'length' => [ 'rule' => ['minLength', 6], 'message' => __d('wasabi_core', 'Ensure your password consists of at least 6 characters.') ] ]) ->notEmpty('password_confirmation', __d('wasabi_core', 'Please repeat your Password.'), function ($context) { if ($context['newRecord'] === true) { return true; } if (isset($context['data']['password']) && !empty($context['data']['password'])) { return true; } return false; }) ->add('password_confirmation', 'equalsPassword', [ 'rule' => function ($passwordConfirmation, $provider) { if ($passwordConfirmation !== $provider['data']['password']) { return __d('wasabi_core', 'The Password Confirmation does not match the Password field.'); } return true; } ]); return $validator; }
php
public function validationPasswordOnly(Validator $validator) { $validator ->notEmpty('password', __d('wasabi_core', 'Please enter a password.')) ->add('password', [ 'length' => [ 'rule' => ['minLength', 6], 'message' => __d('wasabi_core', 'Ensure your password consists of at least 6 characters.') ] ]) ->notEmpty('password_confirmation', __d('wasabi_core', 'Please repeat your Password.'), function ($context) { if ($context['newRecord'] === true) { return true; } if (isset($context['data']['password']) && !empty($context['data']['password'])) { return true; } return false; }) ->add('password_confirmation', 'equalsPassword', [ 'rule' => function ($passwordConfirmation, $provider) { if ($passwordConfirmation !== $provider['data']['password']) { return __d('wasabi_core', 'The Password Confirmation does not match the Password field.'); } return true; } ]); return $validator; }
[ "public", "function", "validationPasswordOnly", "(", "Validator", "$", "validator", ")", "{", "$", "validator", "->", "notEmpty", "(", "'password'", ",", "__d", "(", "'wasabi_core'", ",", "'Please enter a password.'", ")", ")", "->", "add", "(", "'password'", ",", "[", "'length'", "=>", "[", "'rule'", "=>", "[", "'minLength'", ",", "6", "]", ",", "'message'", "=>", "__d", "(", "'wasabi_core'", ",", "'Ensure your password consists of at least 6 characters.'", ")", "]", "]", ")", "->", "notEmpty", "(", "'password_confirmation'", ",", "__d", "(", "'wasabi_core'", ",", "'Please repeat your Password.'", ")", ",", "function", "(", "$", "context", ")", "{", "if", "(", "$", "context", "[", "'newRecord'", "]", "===", "true", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "context", "[", "'data'", "]", "[", "'password'", "]", ")", "&&", "!", "empty", "(", "$", "context", "[", "'data'", "]", "[", "'password'", "]", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", ")", "->", "add", "(", "'password_confirmation'", ",", "'equalsPassword'", ",", "[", "'rule'", "=>", "function", "(", "$", "passwordConfirmation", ",", "$", "provider", ")", "{", "if", "(", "$", "passwordConfirmation", "!==", "$", "provider", "[", "'data'", "]", "[", "'password'", "]", ")", "{", "return", "__d", "(", "'wasabi_core'", ",", "'The Password Confirmation does not match the Password field.'", ")", ";", "}", "return", "true", ";", "}", "]", ")", ";", "return", "$", "validator", ";", "}" ]
Only validate password. @param Validator $validator The validator to customize. @return Validator
[ "Only", "validate", "password", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersTable.php#L182-L211
10,420
wasabi-cms/core
src/Model/Table/UsersTable.php
UsersTable.beforeMarshal
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) { if (isset($data['id'])) { // Unset password and password confirmation if password is empty when editing a user. if (isset($data['password']) && empty($data['password'])) { unset($data['password']); if (isset($data['password_confirmation'])) { unset($data['password_confirmation']); } } } }
php
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) { if (isset($data['id'])) { // Unset password and password confirmation if password is empty when editing a user. if (isset($data['password']) && empty($data['password'])) { unset($data['password']); if (isset($data['password_confirmation'])) { unset($data['password_confirmation']); } } } }
[ "public", "function", "beforeMarshal", "(", "Event", "$", "event", ",", "ArrayObject", "$", "data", ",", "ArrayObject", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'id'", "]", ")", ")", "{", "// Unset password and password confirmation if password is empty when editing a user.", "if", "(", "isset", "(", "$", "data", "[", "'password'", "]", ")", "&&", "empty", "(", "$", "data", "[", "'password'", "]", ")", ")", "{", "unset", "(", "$", "data", "[", "'password'", "]", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'password_confirmation'", "]", ")", ")", "{", "unset", "(", "$", "data", "[", "'password_confirmation'", "]", ")", ";", "}", "}", "}", "}" ]
Called before request data is converted to an entity. @param Event $event An event instance. @param ArrayObject $data The data to marshal. @param ArrayObject $options Additional options. @return void
[ "Called", "before", "request", "data", "is", "converted", "to", "an", "entity", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersTable.php#L235-L247
10,421
wasabi-cms/core
src/Model/Table/UsersTable.php
UsersTable.findWithGroupName
public function findWithGroupName(Query $query) { return $query ->select([ 'id', 'username', 'email', 'verified', 'active' ]) ->contain([ 'Groups' => function (Query $q) { return $q->select(['name']); } ]); }
php
public function findWithGroupName(Query $query) { return $query ->select([ 'id', 'username', 'email', 'verified', 'active' ]) ->contain([ 'Groups' => function (Query $q) { return $q->select(['name']); } ]); }
[ "public", "function", "findWithGroupName", "(", "Query", "$", "query", ")", "{", "return", "$", "query", "->", "select", "(", "[", "'id'", ",", "'username'", ",", "'email'", ",", "'verified'", ",", "'active'", "]", ")", "->", "contain", "(", "[", "'Groups'", "=>", "function", "(", "Query", "$", "q", ")", "{", "return", "$", "q", "->", "select", "(", "[", "'name'", "]", ")", ";", "}", "]", ")", ";", "}" ]
Find users including their group name. @param Query $query The query to decorate. @return Query
[ "Find", "users", "including", "their", "group", "name", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersTable.php#L294-L309
10,422
wasabi-cms/core
src/Model/Table/UsersTable.php
UsersTable.findNotVerified
public function findNotVerified($email) { return $this->find() ->where([ $this->aliasField('email') => $email, $this->aliasField('verified') => 0 ]) ->first(); }
php
public function findNotVerified($email) { return $this->find() ->where([ $this->aliasField('email') => $email, $this->aliasField('verified') => 0 ]) ->first(); }
[ "public", "function", "findNotVerified", "(", "$", "email", ")", "{", "return", "$", "this", "->", "find", "(", ")", "->", "where", "(", "[", "$", "this", "->", "aliasField", "(", "'email'", ")", "=>", "$", "email", ",", "$", "this", "->", "aliasField", "(", "'verified'", ")", "=>", "0", "]", ")", "->", "first", "(", ")", ";", "}" ]
Find a user by unverified email address. @param string $email The email to check for. @return User mixed
[ "Find", "a", "user", "by", "unverified", "email", "address", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersTable.php#L366-L374
10,423
wasabi-cms/core
src/Model/Table/UsersTable.php
UsersTable.findUsersWithNoGroup
public function findUsersWithNoGroup() { $query = $this->find(); return $query->leftJoin( [$this->UsersGroups->alias() => $this->UsersGroups->table()], [$this->aliasField('id') . ' = ' . $this->UsersGroups->aliasField('user_id')] ) ->select([ 'Users.id', 'group_count' => $query->func()->count('UsersGroups.group_id') ]) ->group('Users.id') ->having('group_count = 0'); }
php
public function findUsersWithNoGroup() { $query = $this->find(); return $query->leftJoin( [$this->UsersGroups->alias() => $this->UsersGroups->table()], [$this->aliasField('id') . ' = ' . $this->UsersGroups->aliasField('user_id')] ) ->select([ 'Users.id', 'group_count' => $query->func()->count('UsersGroups.group_id') ]) ->group('Users.id') ->having('group_count = 0'); }
[ "public", "function", "findUsersWithNoGroup", "(", ")", "{", "$", "query", "=", "$", "this", "->", "find", "(", ")", ";", "return", "$", "query", "->", "leftJoin", "(", "[", "$", "this", "->", "UsersGroups", "->", "alias", "(", ")", "=>", "$", "this", "->", "UsersGroups", "->", "table", "(", ")", "]", ",", "[", "$", "this", "->", "aliasField", "(", "'id'", ")", ".", "' = '", ".", "$", "this", "->", "UsersGroups", "->", "aliasField", "(", "'user_id'", ")", "]", ")", "->", "select", "(", "[", "'Users.id'", ",", "'group_count'", "=>", "$", "query", "->", "func", "(", ")", "->", "count", "(", "'UsersGroups.group_id'", ")", "]", ")", "->", "group", "(", "'Users.id'", ")", "->", "having", "(", "'group_count = 0'", ")", ";", "}" ]
Find all users that do not belong to a group. @return Query
[ "Find", "all", "users", "that", "do", "not", "belong", "to", "a", "group", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersTable.php#L381-L395
10,424
LabCake/System
src/System.php
System.is_https
public static function is_https() { if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { return TRUE; } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { return TRUE; } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { return TRUE; } return FALSE; }
php
public static function is_https() { if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { return TRUE; } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { return TRUE; } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { return TRUE; } return FALSE; }
[ "public", "static", "function", "is_https", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "&&", "strtolower", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "!==", "'off'", ")", "{", "return", "TRUE", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_PROTO'", "]", ")", "&&", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_PROTO'", "]", "===", "'https'", ")", "{", "return", "TRUE", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_FRONT_END_HTTPS'", "]", ")", "&&", "strtolower", "(", "$", "_SERVER", "[", "'HTTP_FRONT_END_HTTPS'", "]", ")", "!==", "'off'", ")", "{", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Check if connected through https @return bool
[ "Check", "if", "connected", "through", "https" ]
9e574d231bf169b5eb6197d0ab65e2e2aac180f6
https://github.com/LabCake/System/blob/9e574d231bf169b5eb6197d0ab65e2e2aac180f6/src/System.php#L52-L62
10,425
uthando-cms/uthando-common
src/UthandoCommon/Db/Adapter/AdapterServiceFactory.php
AdapterServiceFactory.createService
public function createService(ServiceLocatorInterface $container) { $config = $container->get(DbOptions::class); return new Adapter($config->toArray()); }
php
public function createService(ServiceLocatorInterface $container) { $config = $container->get(DbOptions::class); return new Adapter($config->toArray()); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "container", ")", "{", "$", "config", "=", "$", "container", "->", "get", "(", "DbOptions", "::", "class", ")", ";", "return", "new", "Adapter", "(", "$", "config", "->", "toArray", "(", ")", ")", ";", "}" ]
Create db adapter service @param ServiceLocatorInterface $container @return Adapter
[ "Create", "db", "adapter", "service" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Db/Adapter/AdapterServiceFactory.php#L31-L35
10,426
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getCookie
public function getCookie($name) { $filter = $default = ''; $cookie = $this->getVar($name, $filter, $default, "cookies"); //@TODO cookie before return return empty($cookie) ? false : $cookie; }
php
public function getCookie($name) { $filter = $default = ''; $cookie = $this->getVar($name, $filter, $default, "cookies"); //@TODO cookie before return return empty($cookie) ? false : $cookie; }
[ "public", "function", "getCookie", "(", "$", "name", ")", "{", "$", "filter", "=", "$", "default", "=", "''", ";", "$", "cookie", "=", "$", "this", "->", "getVar", "(", "$", "name", ",", "$", "filter", ",", "$", "default", ",", "\"cookies\"", ")", ";", "//@TODO cookie before return", "return", "empty", "(", "$", "cookie", ")", "?", "false", ":", "$", "cookie", ";", "}" ]
Gets the contents of a cookie by name @param type $name @return type
[ "Gets", "the", "contents", "of", "a", "cookie", "by", "name" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L167-L176
10,427
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getVar
public function getVar($name, $filter = '', $default = '', $verb = 'get', $options = array()) { if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } //just form casting $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //Do we have a filter; if (!isset($filter) || !is_int($filter)) { //PHP warns against using gettype to get type, //but its much easier than running every is_* to determine type //so fo now we go with gettype; $type = gettype($input[$name]); switch ($type) { case "interger": $filter = \IS\INTERGER; break; case "float": case "double": $filter = \IS\FLOAT; $options = array( "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND, "options" => $options ); break; case "string": $filter = \IS\STRING; $options = array( "flags" => !FILTER_FLAG_STRIP_LOW, "options" => $options ); break; case "object": //@TODO, case "resource": case "NULL": case "unknown type": default: $filter = \IS\RAW; $options = array( "flags" => !FILTER_FLAG_STRIP_LOW, "options" => $options ); break; } } //uhhhnrrr... $variable = $input[$name]; //Pre treat; if (get_magic_quotes_gpc() && ($input[$name] != $default) && ($verb != 'files')) { $variable = stripslashes($input[$name]); //?? } return $this->filter($variable, $filter, $options); }
php
public function getVar($name, $filter = '', $default = '', $verb = 'get', $options = array()) { if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } //just form casting $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //Do we have a filter; if (!isset($filter) || !is_int($filter)) { //PHP warns against using gettype to get type, //but its much easier than running every is_* to determine type //so fo now we go with gettype; $type = gettype($input[$name]); switch ($type) { case "interger": $filter = \IS\INTERGER; break; case "float": case "double": $filter = \IS\FLOAT; $options = array( "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND, "options" => $options ); break; case "string": $filter = \IS\STRING; $options = array( "flags" => !FILTER_FLAG_STRIP_LOW, "options" => $options ); break; case "object": //@TODO, case "resource": case "NULL": case "unknown type": default: $filter = \IS\RAW; $options = array( "flags" => !FILTER_FLAG_STRIP_LOW, "options" => $options ); break; } } //uhhhnrrr... $variable = $input[$name]; //Pre treat; if (get_magic_quotes_gpc() && ($input[$name] != $default) && ($verb != 'files')) { $variable = stripslashes($input[$name]); //?? } return $this->filter($variable, $filter, $options); }
[ "public", "function", "getVar", "(", "$", "name", ",", "$", "filter", "=", "''", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "strtolower", "(", "$", "verb", ")", "==", "'request'", ")", "{", "$", "verb", "=", "$", "this", "->", "getVerb", "(", ")", ";", "}", "//just form casting", "$", "verb", "=", "strtolower", "(", "$", "verb", ")", ";", "if", "(", "!", "(", "$", "input", "=", "$", "this", "->", "data", "(", "$", "verb", ")", ")", ")", "{", "return", "$", "default", ";", "}", "//Undefined", "if", "(", "empty", "(", "$", "name", ")", "||", "!", "isset", "(", "$", "input", ")", "||", "!", "isset", "(", "$", "input", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "default", ")", "&&", "!", "empty", "(", "$", "default", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "return", "null", ";", "//nothing for that name;", "}", "}", "//Do we have a filter;", "if", "(", "!", "isset", "(", "$", "filter", ")", "||", "!", "is_int", "(", "$", "filter", ")", ")", "{", "//PHP warns against using gettype to get type,", "//but its much easier than running every is_* to determine type", "//so fo now we go with gettype;", "$", "type", "=", "gettype", "(", "$", "input", "[", "$", "name", "]", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "\"interger\"", ":", "$", "filter", "=", "\\", "IS", "\\", "INTERGER", ";", "break", ";", "case", "\"float\"", ":", "case", "\"double\"", ":", "$", "filter", "=", "\\", "IS", "\\", "FLOAT", ";", "$", "options", "=", "array", "(", "\"flags\"", "=>", "FILTER_FLAG_ALLOW_SCIENTIFIC", "|", "FILTER_FLAG_ALLOW_FRACTION", "|", "FILTER_FLAG_ALLOW_THOUSAND", ",", "\"options\"", "=>", "$", "options", ")", ";", "break", ";", "case", "\"string\"", ":", "$", "filter", "=", "\\", "IS", "\\", "STRING", ";", "$", "options", "=", "array", "(", "\"flags\"", "=>", "!", "FILTER_FLAG_STRIP_LOW", ",", "\"options\"", "=>", "$", "options", ")", ";", "break", ";", "case", "\"object\"", ":", "//@TODO,", "case", "\"resource\"", ":", "case", "\"NULL\"", ":", "case", "\"unknown type\"", ":", "default", ":", "$", "filter", "=", "\\", "IS", "\\", "RAW", ";", "$", "options", "=", "array", "(", "\"flags\"", "=>", "!", "FILTER_FLAG_STRIP_LOW", ",", "\"options\"", "=>", "$", "options", ")", ";", "break", ";", "}", "}", "//uhhhnrrr...", "$", "variable", "=", "$", "input", "[", "$", "name", "]", ";", "//Pre treat;", "if", "(", "get_magic_quotes_gpc", "(", ")", "&&", "(", "$", "input", "[", "$", "name", "]", "!=", "$", "default", ")", "&&", "(", "$", "verb", "!=", "'files'", ")", ")", "{", "$", "variable", "=", "stripslashes", "(", "$", "input", "[", "$", "name", "]", ")", ";", "//??", "}", "return", "$", "this", "->", "filter", "(", "$", "variable", ",", "$", "filter", ",", "$", "options", ")", ";", "}" ]
Gets an input variable. Attempts to determine what its type is and returns a sanitized type @param string $name @param interger $filter @param string $verb @param interger $flags @param array $options
[ "Gets", "an", "input", "variable", ".", "Attempts", "to", "determine", "what", "its", "type", "is", "and", "returns", "a", "sanitized", "type" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L188-L258
10,428
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.unRegisterGlobals
public function unRegisterGlobals() { if (ini_get('register_globals')) { $SUPER_GLOBALS = array('_SESSION', '_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'); foreach ($SUPER_GLOBALS as $UNSAFE) { foreach ($GLOBALS[$UNSAFE] as $key => $var) { unset($GLOBALS[$key]); } } } }
php
public function unRegisterGlobals() { if (ini_get('register_globals')) { $SUPER_GLOBALS = array('_SESSION', '_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'); foreach ($SUPER_GLOBALS as $UNSAFE) { foreach ($GLOBALS[$UNSAFE] as $key => $var) { unset($GLOBALS[$key]); } } } }
[ "public", "function", "unRegisterGlobals", "(", ")", "{", "if", "(", "ini_get", "(", "'register_globals'", ")", ")", "{", "$", "SUPER_GLOBALS", "=", "array", "(", "'_SESSION'", ",", "'_POST'", ",", "'_GET'", ",", "'_COOKIE'", ",", "'_REQUEST'", ",", "'_SERVER'", ",", "'_ENV'", ",", "'_FILES'", ")", ";", "foreach", "(", "$", "SUPER_GLOBALS", "as", "$", "UNSAFE", ")", "{", "foreach", "(", "$", "GLOBALS", "[", "$", "UNSAFE", "]", "as", "$", "key", "=>", "$", "var", ")", "{", "unset", "(", "$", "GLOBALS", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
Checks and removes registered globals @return void
[ "Checks", "and", "removes", "registered", "globals" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L297-L307
10,429
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getEscapedVar
public function getEscapedVar($name, $default = '', $verb = 'get', $options = array()) { //FILTER_SANITIZE_MAGIC_QUOTES //FILTER_SANITIZE_SPECIAL_CHARS $filter = \IS\ESCAPED; //FILTER_SANITIZE_NUMBER_INT $escaped = $this->getVar($name, $filter, $default, $verb, $options); //@TODO validate is interger before return return $escaped; }
php
public function getEscapedVar($name, $default = '', $verb = 'get', $options = array()) { //FILTER_SANITIZE_MAGIC_QUOTES //FILTER_SANITIZE_SPECIAL_CHARS $filter = \IS\ESCAPED; //FILTER_SANITIZE_NUMBER_INT $escaped = $this->getVar($name, $filter, $default, $verb, $options); //@TODO validate is interger before return return $escaped; }
[ "public", "function", "getEscapedVar", "(", "$", "name", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "//FILTER_SANITIZE_MAGIC_QUOTES", "//FILTER_SANITIZE_SPECIAL_CHARS", "$", "filter", "=", "\\", "IS", "\\", "ESCAPED", ";", "//FILTER_SANITIZE_NUMBER_INT", "$", "escaped", "=", "$", "this", "->", "getVar", "(", "$", "name", ",", "$", "filter", ",", "$", "default", ",", "$", "verb", ",", "$", "options", ")", ";", "//@TODO validate is interger before return", "return", "$", "escaped", ";", "}" ]
Magic Quotes, StripSlashes @param string $name @param string $verb
[ "Magic", "Quotes", "StripSlashes" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L315-L325
10,430
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.methodIs
public function methodIs($verb) { $method = $this->getVerb(); $return = ($method === strtolower($verb)) ? true : false; return $return; }
php
public function methodIs($verb) { $method = $this->getVerb(); $return = ($method === strtolower($verb)) ? true : false; return $return; }
[ "public", "function", "methodIs", "(", "$", "verb", ")", "{", "$", "method", "=", "$", "this", "->", "getVerb", "(", ")", ";", "$", "return", "=", "(", "$", "method", "===", "strtolower", "(", "$", "verb", ")", ")", "?", "true", ":", "false", ";", "return", "$", "return", ";", "}" ]
Determines if the input method is of type POST or GET @param string $verb @return boolean
[ "Determines", "if", "the", "input", "method", "is", "of", "type", "POST", "or", "GET" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L348-L355
10,431
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getInt
public function getInt($name, $default = '', $verb = 'get', $options = array()) { $filter = \IS\INTERGER; //FILTER_SANITIZE_NUMBER_INT $interger = $this->getVar($name, $filter, $default, $verb, $options); //@TODO validate is interger before return return (int)$interger; }
php
public function getInt($name, $default = '', $verb = 'get', $options = array()) { $filter = \IS\INTERGER; //FILTER_SANITIZE_NUMBER_INT $interger = $this->getVar($name, $filter, $default, $verb, $options); //@TODO validate is interger before return return (int)$interger; }
[ "public", "function", "getInt", "(", "$", "name", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "filter", "=", "\\", "IS", "\\", "INTERGER", ";", "//FILTER_SANITIZE_NUMBER_INT", "$", "interger", "=", "$", "this", "->", "getVar", "(", "$", "name", ",", "$", "filter", ",", "$", "default", ",", "$", "verb", ",", "$", "options", ")", ";", "//@TODO validate is interger before return", "return", "(", "int", ")", "$", "interger", ";", "}" ]
Remove all characters except digits, plus and minus sign. @param type $name @param type $verb
[ "Remove", "all", "characters", "except", "digits", "plus", "and", "minus", "sign", "." ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L405-L414
10,432
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getFormattedString
public function getFormattedString($name, $default = '', $verb = 'post', $blacklisted = array()) { //FILTER_SANITIZE_STRING //FILTER_SANITIZE_STRIPPED //\IS\HTML; //just form casting if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //uhhhnrrr... $string = $input[$name]; //print_R($string); //DOMDocument will screw up the encoding so we utf8 encode everything? $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string)); $string = mb_convert_encoding($string, 'html-entities', 'utf-8'); //if string is empty no need to proceed; if (empty($string)) return $string; $doc = new \DOMDocument('1.0', 'UTF-8'); //$doc->substituteEntities = TRUE; $doc->loadHTML($string); //Load XML here, if you use loadHTML the string will be wrapped in HTML tags. Not good. $xpath = new \DOMXPath($doc); //@TODO remove tags that are not allowed; //Remove attributes $nodes = $xpath->query('//*[@style]'); foreach ($nodes as $node): $node->removeAttribute('style'); //Removes the style attribute; endforeach; //We don't want to wrap in HTML tags $original = $xpath->query("body/*"); if ($original->length > 0) { $string = ''; foreach ($original as $node) { //cannot use doc->saveElement because it wraps it in p tags! //so lets just go ahead and use the nodevalue; $string .= $node->nodeValue; } } $filter = \IS\SPECIAL_CHARS; $options = array( "flags" => FILTER_FLAG_ENCODE_LOW, //or strip? "options" => array() ); //if (is_array($html)) $str = strip_tags($str, implode('', $html)); //elseif (preg_match('|<([a-z]+)>|i', $html)) $str = strip_tags($str, $html); //elseif ($html !== true) $str = strip_tags($str); //Some tags we really don't need $string = $this->filter($string, $filter, $options); return $string; }
php
public function getFormattedString($name, $default = '', $verb = 'post', $blacklisted = array()) { //FILTER_SANITIZE_STRING //FILTER_SANITIZE_STRIPPED //\IS\HTML; //just form casting if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //uhhhnrrr... $string = $input[$name]; //print_R($string); //DOMDocument will screw up the encoding so we utf8 encode everything? $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string)); $string = mb_convert_encoding($string, 'html-entities', 'utf-8'); //if string is empty no need to proceed; if (empty($string)) return $string; $doc = new \DOMDocument('1.0', 'UTF-8'); //$doc->substituteEntities = TRUE; $doc->loadHTML($string); //Load XML here, if you use loadHTML the string will be wrapped in HTML tags. Not good. $xpath = new \DOMXPath($doc); //@TODO remove tags that are not allowed; //Remove attributes $nodes = $xpath->query('//*[@style]'); foreach ($nodes as $node): $node->removeAttribute('style'); //Removes the style attribute; endforeach; //We don't want to wrap in HTML tags $original = $xpath->query("body/*"); if ($original->length > 0) { $string = ''; foreach ($original as $node) { //cannot use doc->saveElement because it wraps it in p tags! //so lets just go ahead and use the nodevalue; $string .= $node->nodeValue; } } $filter = \IS\SPECIAL_CHARS; $options = array( "flags" => FILTER_FLAG_ENCODE_LOW, //or strip? "options" => array() ); //if (is_array($html)) $str = strip_tags($str, implode('', $html)); //elseif (preg_match('|<([a-z]+)>|i', $html)) $str = strip_tags($str, $html); //elseif ($html !== true) $str = strip_tags($str); //Some tags we really don't need $string = $this->filter($string, $filter, $options); return $string; }
[ "public", "function", "getFormattedString", "(", "$", "name", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'post'", ",", "$", "blacklisted", "=", "array", "(", ")", ")", "{", "//FILTER_SANITIZE_STRING", "//FILTER_SANITIZE_STRIPPED", "//\\IS\\HTML;", "//just form casting", "if", "(", "strtolower", "(", "$", "verb", ")", "==", "'request'", ")", "{", "$", "verb", "=", "$", "this", "->", "getVerb", "(", ")", ";", "}", "$", "verb", "=", "strtolower", "(", "$", "verb", ")", ";", "if", "(", "!", "(", "$", "input", "=", "$", "this", "->", "data", "(", "$", "verb", ")", ")", ")", "{", "return", "$", "default", ";", "}", "//Undefined", "if", "(", "empty", "(", "$", "name", ")", "||", "!", "isset", "(", "$", "input", ")", "||", "!", "isset", "(", "$", "input", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "default", ")", "&&", "!", "empty", "(", "$", "default", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "return", "null", ";", "//nothing for that name;", "}", "}", "//uhhhnrrr...", "$", "string", "=", "$", "input", "[", "$", "name", "]", ";", "//print_R($string);", "//DOMDocument will screw up the encoding so we utf8 encode everything?", "$", "string", "=", "mb_convert_encoding", "(", "$", "string", ",", "'utf-8'", ",", "mb_detect_encoding", "(", "$", "string", ")", ")", ";", "$", "string", "=", "mb_convert_encoding", "(", "$", "string", ",", "'html-entities'", ",", "'utf-8'", ")", ";", "//if string is empty no need to proceed;", "if", "(", "empty", "(", "$", "string", ")", ")", "return", "$", "string", ";", "$", "doc", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "//$doc->substituteEntities = TRUE;", "$", "doc", "->", "loadHTML", "(", "$", "string", ")", ";", "//Load XML here, if you use loadHTML the string will be wrapped in HTML tags. Not good.", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "doc", ")", ";", "//@TODO remove tags that are not allowed;", "//Remove attributes", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "'//*[@style]'", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", ":", "$", "node", "->", "removeAttribute", "(", "'style'", ")", ";", "//Removes the style attribute;", "endforeach", ";", "//We don't want to wrap in HTML tags", "$", "original", "=", "$", "xpath", "->", "query", "(", "\"body/*\"", ")", ";", "if", "(", "$", "original", "->", "length", ">", "0", ")", "{", "$", "string", "=", "''", ";", "foreach", "(", "$", "original", "as", "$", "node", ")", "{", "//cannot use doc->saveElement because it wraps it in p tags!", "//so lets just go ahead and use the nodevalue;", "$", "string", ".=", "$", "node", "->", "nodeValue", ";", "}", "}", "$", "filter", "=", "\\", "IS", "\\", "SPECIAL_CHARS", ";", "$", "options", "=", "array", "(", "\"flags\"", "=>", "FILTER_FLAG_ENCODE_LOW", ",", "//or strip?", "\"options\"", "=>", "array", "(", ")", ")", ";", "//if (is_array($html)) $str = strip_tags($str, implode('', $html));", "//elseif (preg_match('|<([a-z]+)>|i', $html)) $str = strip_tags($str, $html);", "//elseif ($html !== true) $str = strip_tags($str);", "//Some tags we really don't need", "$", "string", "=", "$", "this", "->", "filter", "(", "$", "string", ",", "$", "filter", ",", "$", "options", ")", ";", "return", "$", "string", ";", "}" ]
Returns a formatted string @param type $name @param type $default @param type $verb @param type $allowedtags
[ "Returns", "a", "formatted", "string" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L444-L518
10,433
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getArray
public function getArray($name, $default = [], $verb = 'get', $options = array()) { if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } //just form casting $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //FILTER_SANITIZE_STRING //FILTER_SANITIZE_STRIPPED //\IS\HTML; $filter = \IS\CUSTOM; //FILTER_CALLBACK; $options = array( "flags" => FILTER_REQUIRE_ARRAY, ); //uhhhnrrr... $array = $input[$name]; //Use the call back filter to clean this array //Sub processing for HTML and all that? return (array)$array; }
php
public function getArray($name, $default = [], $verb = 'get', $options = array()) { if (strtolower($verb) == 'request') { $verb = $this->getVerb(); } //just form casting $verb = strtolower($verb); if (!($input = $this->data($verb))) { return $default; } //Undefined if (empty($name) || !isset($input) || !isset($input[$name])) { if (isset($default) && !empty($default)) { return $default; } else { return null; //nothing for that name; } } //FILTER_SANITIZE_STRING //FILTER_SANITIZE_STRIPPED //\IS\HTML; $filter = \IS\CUSTOM; //FILTER_CALLBACK; $options = array( "flags" => FILTER_REQUIRE_ARRAY, ); //uhhhnrrr... $array = $input[$name]; //Use the call back filter to clean this array //Sub processing for HTML and all that? return (array)$array; }
[ "public", "function", "getArray", "(", "$", "name", ",", "$", "default", "=", "[", "]", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "strtolower", "(", "$", "verb", ")", "==", "'request'", ")", "{", "$", "verb", "=", "$", "this", "->", "getVerb", "(", ")", ";", "}", "//just form casting", "$", "verb", "=", "strtolower", "(", "$", "verb", ")", ";", "if", "(", "!", "(", "$", "input", "=", "$", "this", "->", "data", "(", "$", "verb", ")", ")", ")", "{", "return", "$", "default", ";", "}", "//Undefined", "if", "(", "empty", "(", "$", "name", ")", "||", "!", "isset", "(", "$", "input", ")", "||", "!", "isset", "(", "$", "input", "[", "$", "name", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "default", ")", "&&", "!", "empty", "(", "$", "default", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "return", "null", ";", "//nothing for that name;", "}", "}", "//FILTER_SANITIZE_STRING", "//FILTER_SANITIZE_STRIPPED", "//\\IS\\HTML;", "$", "filter", "=", "\\", "IS", "\\", "CUSTOM", ";", "//FILTER_CALLBACK;", "$", "options", "=", "array", "(", "\"flags\"", "=>", "FILTER_REQUIRE_ARRAY", ",", ")", ";", "//uhhhnrrr...", "$", "array", "=", "$", "input", "[", "$", "name", "]", ";", "//Use the call back filter to clean this array", "//Sub processing for HTML and all that?", "return", "(", "array", ")", "$", "array", ";", "}" ]
Returns a cleaned Array @param string $name @param string $verb @param array $flags
[ "Returns", "a", "cleaned", "Array" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L527-L564
10,434
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getBoolean
public function getBoolean($name, $default = '', $verb = 'get', $options = array()) { //FILTER_SANITIZE_NUMBER_INT $filter = \IS\BOOLEAN; $options = array( "options" => $options ); $boolean = $this->getVar($name, $filter, $default, $verb, $options); //@TODO valid is float before return return (boolean)$boolean; }
php
public function getBoolean($name, $default = '', $verb = 'get', $options = array()) { //FILTER_SANITIZE_NUMBER_INT $filter = \IS\BOOLEAN; $options = array( "options" => $options ); $boolean = $this->getVar($name, $filter, $default, $verb, $options); //@TODO valid is float before return return (boolean)$boolean; }
[ "public", "function", "getBoolean", "(", "$", "name", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "//FILTER_SANITIZE_NUMBER_INT", "$", "filter", "=", "\\", "IS", "\\", "BOOLEAN", ";", "$", "options", "=", "array", "(", "\"options\"", "=>", "$", "options", ")", ";", "$", "boolean", "=", "$", "this", "->", "getVar", "(", "$", "name", ",", "$", "filter", ",", "$", "default", ",", "$", "verb", ",", "$", "options", ")", ";", "//@TODO valid is float before return", "return", "(", "boolean", ")", "$", "boolean", ";", "}" ]
Remove all characters except digits 0 and 1. Transforms into Boolean true or false, where 0=false and 1=true @param string $name @param string $verb
[ "Remove", "all", "characters", "except", "digits", "0", "and", "1", ".", "Transforms", "into", "Boolean", "true", "or", "false", "where", "0", "=", "false", "and", "1", "=", "true" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L591-L604
10,435
budkit/budkit-framework
src/Budkit/Protocol/Input.php
Input.getWord
public function getWord($name, $default = '', $verb = 'get', $options = array()) { //First word in a sanitized string $sentence = $this->getString($name, $default, false); //@TODO validate string before breaking into words; //Requires php5.3!! return (string)strstr($sentence, ' ', true); }
php
public function getWord($name, $default = '', $verb = 'get', $options = array()) { //First word in a sanitized string $sentence = $this->getString($name, $default, false); //@TODO validate string before breaking into words; //Requires php5.3!! return (string)strstr($sentence, ' ', true); }
[ "public", "function", "getWord", "(", "$", "name", ",", "$", "default", "=", "''", ",", "$", "verb", "=", "'get'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "//First word in a sanitized string", "$", "sentence", "=", "$", "this", "->", "getString", "(", "$", "name", ",", "$", "default", ",", "false", ")", ";", "//@TODO validate string before breaking into words;", "//Requires php5.3!!", "return", "(", "string", ")", "strstr", "(", "$", "sentence", ",", "' '", ",", "true", ")", ";", "}" ]
Returns the first word a santized string Strip tags, optionally strip or encode special characters. @param string $name @param string $verb @param array $flags
[ "Returns", "the", "first", "word", "a", "santized", "string", "Strip", "tags", "optionally", "strip", "or", "encode", "special", "characters", "." ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Protocol/Input.php#L614-L622
10,436
ruxon/framework
src/Module/Controller/Controller.class.php
Controller.mapper
protected function mapper($alias = false) { return Manager::getInstance()->getMapper($alias ? $alias : $this->sMapperAlias); }
php
protected function mapper($alias = false) { return Manager::getInstance()->getMapper($alias ? $alias : $this->sMapperAlias); }
[ "protected", "function", "mapper", "(", "$", "alias", "=", "false", ")", "{", "return", "Manager", "::", "getInstance", "(", ")", "->", "getMapper", "(", "$", "alias", "?", "$", "alias", ":", "$", "this", "->", "sMapperAlias", ")", ";", "}" ]
Return a object mapper instance @return ObjectMapper
[ "Return", "a", "object", "mapper", "instance" ]
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Module/Controller/Controller.class.php#L196-L199
10,437
ruxon/framework
src/Module/Controller/Controller.class.php
Controller.config
protected function config($sActionAlias) { $sFileName = RX_PATH.'/ruxon/modules/'.$this->sModuleAlias.'/config/controllers/'.$this->sControllerAlias.'/action'.$sActionAlias.'.inc.php'; if (file_exists($sFileName)) { $aConfig = include($sFileName); $sBasePath = 'ruxon/modules/'.$this->sModuleAlias; $aLang = array(); if (file_exists(RX_PATH.'/'.$sBasePath.'/messages/'.Core::app()->config()->getLang().'/messages.inc.php')) { $aLang = Core::require_file($sBasePath.'/messages/'.Core::app()->config()->getLang().'/messages.inc.php'); } else if(file_exists(RX_PATH.'/'.$sBasePath.'/messages/'.Core::app()->config()->getDefaultLang().'/messages.inc.php')) { $aLang = Core::require_file($sBasePath.'/messages/'.Core::app()->config()->getDefaultLang().'/messages.inc.php'); } else { $aLang = array(); } $aConfig = Core::parseXmlI18n($aConfig, $aLang); return $aConfig; } return false; }
php
protected function config($sActionAlias) { $sFileName = RX_PATH.'/ruxon/modules/'.$this->sModuleAlias.'/config/controllers/'.$this->sControllerAlias.'/action'.$sActionAlias.'.inc.php'; if (file_exists($sFileName)) { $aConfig = include($sFileName); $sBasePath = 'ruxon/modules/'.$this->sModuleAlias; $aLang = array(); if (file_exists(RX_PATH.'/'.$sBasePath.'/messages/'.Core::app()->config()->getLang().'/messages.inc.php')) { $aLang = Core::require_file($sBasePath.'/messages/'.Core::app()->config()->getLang().'/messages.inc.php'); } else if(file_exists(RX_PATH.'/'.$sBasePath.'/messages/'.Core::app()->config()->getDefaultLang().'/messages.inc.php')) { $aLang = Core::require_file($sBasePath.'/messages/'.Core::app()->config()->getDefaultLang().'/messages.inc.php'); } else { $aLang = array(); } $aConfig = Core::parseXmlI18n($aConfig, $aLang); return $aConfig; } return false; }
[ "protected", "function", "config", "(", "$", "sActionAlias", ")", "{", "$", "sFileName", "=", "RX_PATH", ".", "'/ruxon/modules/'", ".", "$", "this", "->", "sModuleAlias", ".", "'/config/controllers/'", ".", "$", "this", "->", "sControllerAlias", ".", "'/action'", ".", "$", "sActionAlias", ".", "'.inc.php'", ";", "if", "(", "file_exists", "(", "$", "sFileName", ")", ")", "{", "$", "aConfig", "=", "include", "(", "$", "sFileName", ")", ";", "$", "sBasePath", "=", "'ruxon/modules/'", ".", "$", "this", "->", "sModuleAlias", ";", "$", "aLang", "=", "array", "(", ")", ";", "if", "(", "file_exists", "(", "RX_PATH", ".", "'/'", ".", "$", "sBasePath", ".", "'/messages/'", ".", "Core", "::", "app", "(", ")", "->", "config", "(", ")", "->", "getLang", "(", ")", ".", "'/messages.inc.php'", ")", ")", "{", "$", "aLang", "=", "Core", "::", "require_file", "(", "$", "sBasePath", ".", "'/messages/'", ".", "Core", "::", "app", "(", ")", "->", "config", "(", ")", "->", "getLang", "(", ")", ".", "'/messages.inc.php'", ")", ";", "}", "else", "if", "(", "file_exists", "(", "RX_PATH", ".", "'/'", ".", "$", "sBasePath", ".", "'/messages/'", ".", "Core", "::", "app", "(", ")", "->", "config", "(", ")", "->", "getDefaultLang", "(", ")", ".", "'/messages.inc.php'", ")", ")", "{", "$", "aLang", "=", "Core", "::", "require_file", "(", "$", "sBasePath", ".", "'/messages/'", ".", "Core", "::", "app", "(", ")", "->", "config", "(", ")", "->", "getDefaultLang", "(", ")", ".", "'/messages.inc.php'", ")", ";", "}", "else", "{", "$", "aLang", "=", "array", "(", ")", ";", "}", "$", "aConfig", "=", "Core", "::", "parseXmlI18n", "(", "$", "aConfig", ",", "$", "aLang", ")", ";", "return", "$", "aConfig", ";", "}", "return", "false", ";", "}" ]
Return an action config @param string $sActionAlias action alias @return array|false
[ "Return", "an", "action", "config" ]
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Module/Controller/Controller.class.php#L239-L264
10,438
AthensFramework/Core
src/email/EmailBuilder.php
EmailBuilder.validateEmailer
protected function validateEmailer() { if ($this->emailer === null) { $settingsInstance = $this->getSettingsInstance(); $writerClasses = $settingsInstance->getDefaultEmailWriterClasses(); $emailerClass = $settingsInstance->getDefaultEmailerClass(); $writerInstances = []; foreach ($writerClasses as $writerClass) { $writerInstances[] = new $writerClass(); } $this->emailer = new $emailerClass($writerInstances); } }
php
protected function validateEmailer() { if ($this->emailer === null) { $settingsInstance = $this->getSettingsInstance(); $writerClasses = $settingsInstance->getDefaultEmailWriterClasses(); $emailerClass = $settingsInstance->getDefaultEmailerClass(); $writerInstances = []; foreach ($writerClasses as $writerClass) { $writerInstances[] = new $writerClass(); } $this->emailer = new $emailerClass($writerInstances); } }
[ "protected", "function", "validateEmailer", "(", ")", "{", "if", "(", "$", "this", "->", "emailer", "===", "null", ")", "{", "$", "settingsInstance", "=", "$", "this", "->", "getSettingsInstance", "(", ")", ";", "$", "writerClasses", "=", "$", "settingsInstance", "->", "getDefaultEmailWriterClasses", "(", ")", ";", "$", "emailerClass", "=", "$", "settingsInstance", "->", "getDefaultEmailerClass", "(", ")", ";", "$", "writerInstances", "=", "[", "]", ";", "foreach", "(", "$", "writerClasses", "as", "$", "writerClass", ")", "{", "$", "writerInstances", "[", "]", "=", "new", "$", "writerClass", "(", ")", ";", "}", "$", "this", "->", "emailer", "=", "new", "$", "emailerClass", "(", "$", "writerInstances", ")", ";", "}", "}" ]
Construct a emailer from setting defaults, if none has been provided. @return void
[ "Construct", "a", "emailer", "from", "setting", "defaults", "if", "none", "has", "been", "provided", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/email/EmailBuilder.php#L222-L237
10,439
extendsframework/extends-console
src/Formatter/Ansi/AnsiFormatter.php
AnsiFormatter.resetBuilder
protected function resetBuilder(): void { $this->foreground = 39; $this->background = 49; $this->format = []; $this->width = null; $this->indent = null; }
php
protected function resetBuilder(): void { $this->foreground = 39; $this->background = 49; $this->format = []; $this->width = null; $this->indent = null; }
[ "protected", "function", "resetBuilder", "(", ")", ":", "void", "{", "$", "this", "->", "foreground", "=", "39", ";", "$", "this", "->", "background", "=", "49", ";", "$", "this", "->", "format", "=", "[", "]", ";", "$", "this", "->", "width", "=", "null", ";", "$", "this", "->", "indent", "=", "null", ";", "}" ]
Reset builder with default values.
[ "Reset", "builder", "with", "default", "values", "." ]
ac32b6a6588290f72e292739bdff4ee63dad0667
https://github.com/extendsframework/extends-console/blob/ac32b6a6588290f72e292739bdff4ee63dad0667/src/Formatter/Ansi/AnsiFormatter.php#L207-L214
10,440
milkyway-multimedia/ss-behaviours
src/Traits/Hashable.php
Hashable.regenerateHash
public function regenerateHash() { $this->hashWorkingRecord->{$this->hashDbField} = $this->encrypt(); if ($this->hashMustBeUnique && !$this->hasUniqueHash()) { $this->regenerateHash(); } }
php
public function regenerateHash() { $this->hashWorkingRecord->{$this->hashDbField} = $this->encrypt(); if ($this->hashMustBeUnique && !$this->hasUniqueHash()) { $this->regenerateHash(); } }
[ "public", "function", "regenerateHash", "(", ")", "{", "$", "this", "->", "hashWorkingRecord", "->", "{", "$", "this", "->", "hashDbField", "}", "=", "$", "this", "->", "encrypt", "(", ")", ";", "if", "(", "$", "this", "->", "hashMustBeUnique", "&&", "!", "$", "this", "->", "hasUniqueHash", "(", ")", ")", "{", "$", "this", "->", "regenerateHash", "(", ")", ";", "}", "}" ]
Regenerate a hash for this @DataObject
[ "Regenerate", "a", "hash", "for", "this" ]
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Hashable.php#L53-L60
10,441
milkyway-multimedia/ss-behaviours
src/Traits/Hashable.php
Hashable.generateHashAndSave
protected function generateHashAndSave() { if ($this->hashWorkingRecord->{$this->hashDbField}) { return; } $this->generateHash(); if ($this->hashWorkingRecord->{$this->hashDbField}) { $this->hashWorkingRecord->write(); } }
php
protected function generateHashAndSave() { if ($this->hashWorkingRecord->{$this->hashDbField}) { return; } $this->generateHash(); if ($this->hashWorkingRecord->{$this->hashDbField}) { $this->hashWorkingRecord->write(); } }
[ "protected", "function", "generateHashAndSave", "(", ")", "{", "if", "(", "$", "this", "->", "hashWorkingRecord", "->", "{", "$", "this", "->", "hashDbField", "}", ")", "{", "return", ";", "}", "$", "this", "->", "generateHash", "(", ")", ";", "if", "(", "$", "this", "->", "hashWorkingRecord", "->", "{", "$", "this", "->", "hashDbField", "}", ")", "{", "$", "this", "->", "hashWorkingRecord", "->", "write", "(", ")", ";", "}", "}" ]
Generate hash and save if hash created
[ "Generate", "hash", "and", "save", "if", "hash", "created" ]
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Hashable.php#L65-L76
10,442
milkyway-multimedia/ss-behaviours
src/Traits/Hashable.php
Hashable.hasUniqueHash
public function hasUniqueHash() { $hash = $this->hashWorkingRecord->{$this->hashDbField} ?: $this->encrypt(); $list = $this->hashWorkingRecord->get()->filter($this->hashDbField, $hash); if($this->hashWorkingRecord->ID) { $list = $list->exclude('ID', $this->hashWorkingRecord->ID); } return !($list->exists()); }
php
public function hasUniqueHash() { $hash = $this->hashWorkingRecord->{$this->hashDbField} ?: $this->encrypt(); $list = $this->hashWorkingRecord->get()->filter($this->hashDbField, $hash); if($this->hashWorkingRecord->ID) { $list = $list->exclude('ID', $this->hashWorkingRecord->ID); } return !($list->exists()); }
[ "public", "function", "hasUniqueHash", "(", ")", "{", "$", "hash", "=", "$", "this", "->", "hashWorkingRecord", "->", "{", "$", "this", "->", "hashDbField", "}", "?", ":", "$", "this", "->", "encrypt", "(", ")", ";", "$", "list", "=", "$", "this", "->", "hashWorkingRecord", "->", "get", "(", ")", "->", "filter", "(", "$", "this", "->", "hashDbField", ",", "$", "hash", ")", ";", "if", "(", "$", "this", "->", "hashWorkingRecord", "->", "ID", ")", "{", "$", "list", "=", "$", "list", "->", "exclude", "(", "'ID'", ",", "$", "this", "->", "hashWorkingRecord", "->", "ID", ")", ";", "}", "return", "!", "(", "$", "list", "->", "exists", "(", ")", ")", ";", "}" ]
Check if the hash for this object is unique @return boolean
[ "Check", "if", "the", "hash", "for", "this", "object", "is", "unique" ]
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Hashable.php#L95-L106
10,443
Dhii/container-helper-base
src/ContainerSetManyCapableTrait.php
ContainerSetManyCapableTrait._containerSetMany
protected function _containerSetMany(&$container, $data) { $data = $this->_normalizeIterable($data); foreach ($data as $_k => $_v) { $this->_containerSet($container, $_k, $_v); } }
php
protected function _containerSetMany(&$container, $data) { $data = $this->_normalizeIterable($data); foreach ($data as $_k => $_v) { $this->_containerSet($container, $_k, $_v); } }
[ "protected", "function", "_containerSetMany", "(", "&", "$", "container", ",", "$", "data", ")", "{", "$", "data", "=", "$", "this", "->", "_normalizeIterable", "(", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "_k", "=>", "$", "_v", ")", "{", "$", "this", "->", "_containerSet", "(", "$", "container", ",", "$", "_k", ",", "$", "_v", ")", ";", "}", "}" ]
Sets multiple values on the container. @since [*next-version*] @param array|ArrayAccess|stdClass $container The container to set data on. @param array|Traversable|stdClass $data The map of data to set on the container. @throws InvalidArgumentException If the container or the data map is invalid. @throws OutOfRangeException If one of the data keys is invalid. @throws ContainerExceptionInterface If a problem with setting data occurs.
[ "Sets", "multiple", "values", "on", "the", "container", "." ]
ccb2f56971d70cf203baa596cd14fdf91be6bfae
https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerSetManyCapableTrait.php#L32-L39
10,444
corycollier/php-cli
src/Parser.php
Parser.init
public function init() { $this->setupSupportedArgs($this->supportedArgs); $this->parseArgv($this->argv); return $this; }
php
public function init() { $this->setupSupportedArgs($this->supportedArgs); $this->parseArgv($this->argv); return $this; }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "setupSupportedArgs", "(", "$", "this", "->", "supportedArgs", ")", ";", "$", "this", "->", "parseArgv", "(", "$", "this", "->", "argv", ")", ";", "return", "$", "this", ";", "}" ]
Local implementation of the init hook. @return PhpCli\Parser Returns $this, for object-chaining.
[ "Local", "implementation", "of", "the", "init", "hook", "." ]
f6763c1b22a674ce9d83f179538d5500fa573ec5
https://github.com/corycollier/php-cli/blob/f6763c1b22a674ce9d83f179538d5500fa573ec5/src/Parser.php#L50-L55
10,445
corycollier/php-cli
src/Parser.php
Parser.parseArgv
protected function parseArgv($argv) { foreach ($this->argv as $arg) { $parts = explode('=', $arg); if (! isset($parts[1])) { continue; } $value = $parts[1]; $key = strtr($parts[0], [ '-' => '' ]); if (array_key_exists($key, $this->supportedArgs)) { $this->parsedArgs[$key] = $value; } } return $this; }
php
protected function parseArgv($argv) { foreach ($this->argv as $arg) { $parts = explode('=', $arg); if (! isset($parts[1])) { continue; } $value = $parts[1]; $key = strtr($parts[0], [ '-' => '' ]); if (array_key_exists($key, $this->supportedArgs)) { $this->parsedArgs[$key] = $value; } } return $this; }
[ "protected", "function", "parseArgv", "(", "$", "argv", ")", "{", "foreach", "(", "$", "this", "->", "argv", "as", "$", "arg", ")", "{", "$", "parts", "=", "explode", "(", "'='", ",", "$", "arg", ")", ";", "if", "(", "!", "isset", "(", "$", "parts", "[", "1", "]", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "parts", "[", "1", "]", ";", "$", "key", "=", "strtr", "(", "$", "parts", "[", "0", "]", ",", "[", "'-'", "=>", "''", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "supportedArgs", ")", ")", "{", "$", "this", "->", "parsedArgs", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Parses an array of arguments. @param array $argv The raw array of arguments. @return PhpCli\Parser Returns $this, for object-chaining.
[ "Parses", "an", "array", "of", "arguments", "." ]
f6763c1b22a674ce9d83f179538d5500fa573ec5
https://github.com/corycollier/php-cli/blob/f6763c1b22a674ce9d83f179538d5500fa573ec5/src/Parser.php#L64-L83
10,446
corycollier/php-cli
src/Parser.php
Parser.getArg
public function getArg($name = '') { if (!isset($this->parsedArgs[$name])) { throw new \PhpCli\Exception(self::ERR_NO_ARG_BY_NAME); } return $this->parsedArgs[$name]; }
php
public function getArg($name = '') { if (!isset($this->parsedArgs[$name])) { throw new \PhpCli\Exception(self::ERR_NO_ARG_BY_NAME); } return $this->parsedArgs[$name]; }
[ "public", "function", "getArg", "(", "$", "name", "=", "''", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "parsedArgs", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "PhpCli", "\\", "Exception", "(", "self", "::", "ERR_NO_ARG_BY_NAME", ")", ";", "}", "return", "$", "this", "->", "parsedArgs", "[", "$", "name", "]", ";", "}" ]
Gets an argument by name @param string $name The name of the argument to get. @return string The value of the argument.
[ "Gets", "an", "argument", "by", "name" ]
f6763c1b22a674ce9d83f179538d5500fa573ec5
https://github.com/corycollier/php-cli/blob/f6763c1b22a674ce9d83f179538d5500fa573ec5/src/Parser.php#L102-L109
10,447
corycollier/php-cli
src/Parser.php
Parser.setupSupportedArgs
public function setupSupportedArgs($arguments = []) { $defaults = [ 'help' => 'The help menu', ]; $arguments = array_merge($defaults, $arguments); $this->supportedArgs = $arguments; return $this; }
php
public function setupSupportedArgs($arguments = []) { $defaults = [ 'help' => 'The help menu', ]; $arguments = array_merge($defaults, $arguments); $this->supportedArgs = $arguments; return $this; }
[ "public", "function", "setupSupportedArgs", "(", "$", "arguments", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'help'", "=>", "'The help menu'", ",", "]", ";", "$", "arguments", "=", "array_merge", "(", "$", "defaults", ",", "$", "arguments", ")", ";", "$", "this", "->", "supportedArgs", "=", "$", "arguments", ";", "return", "$", "this", ";", "}" ]
Takes the supported arguments, and does some setup on them @param array $arguments The list of args/descriptions that are supported. @return PhpCli\Parser Returns $this, for object-chaining.
[ "Takes", "the", "supported", "arguments", "and", "does", "some", "setup", "on", "them" ]
f6763c1b22a674ce9d83f179538d5500fa573ec5
https://github.com/corycollier/php-cli/blob/f6763c1b22a674ce9d83f179538d5500fa573ec5/src/Parser.php#L118-L129
10,448
corycollier/php-cli
src/Parser.php
Parser.help
public function help() { echo PHP_EOL; $output = new Output; $output->write('Available Commands', [ 'color' => 'red', 'bold' => true, 'underline' => true, ]); echo PHP_EOL; $maxlen = 0; foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); if ($len > $maxlen) { $maxlen = $len; } } foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); $output->write(' ') ->write($key, ['color' => 'yellow']) ->write(str_repeat(' ', $maxlen - $len)) ->write(' - ') ->write($description); echo PHP_EOL; } echo PHP_EOL; }
php
public function help() { echo PHP_EOL; $output = new Output; $output->write('Available Commands', [ 'color' => 'red', 'bold' => true, 'underline' => true, ]); echo PHP_EOL; $maxlen = 0; foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); if ($len > $maxlen) { $maxlen = $len; } } foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); $output->write(' ') ->write($key, ['color' => 'yellow']) ->write(str_repeat(' ', $maxlen - $len)) ->write(' - ') ->write($description); echo PHP_EOL; } echo PHP_EOL; }
[ "public", "function", "help", "(", ")", "{", "echo", "PHP_EOL", ";", "$", "output", "=", "new", "Output", ";", "$", "output", "->", "write", "(", "'Available Commands'", ",", "[", "'color'", "=>", "'red'", ",", "'bold'", "=>", "true", ",", "'underline'", "=>", "true", ",", "]", ")", ";", "echo", "PHP_EOL", ";", "$", "maxlen", "=", "0", ";", "foreach", "(", "$", "this", "->", "supportedArgs", "as", "$", "key", "=>", "$", "description", ")", "{", "$", "len", "=", "strlen", "(", "$", "key", ")", ";", "if", "(", "$", "len", ">", "$", "maxlen", ")", "{", "$", "maxlen", "=", "$", "len", ";", "}", "}", "foreach", "(", "$", "this", "->", "supportedArgs", "as", "$", "key", "=>", "$", "description", ")", "{", "$", "len", "=", "strlen", "(", "$", "key", ")", ";", "$", "output", "->", "write", "(", "' '", ")", "->", "write", "(", "$", "key", ",", "[", "'color'", "=>", "'yellow'", "]", ")", "->", "write", "(", "str_repeat", "(", "' '", ",", "$", "maxlen", "-", "$", "len", ")", ")", "->", "write", "(", "' - '", ")", "->", "write", "(", "$", "description", ")", ";", "echo", "PHP_EOL", ";", "}", "echo", "PHP_EOL", ";", "}" ]
Outputs the help menu. @return PhpCli\Parser Returns $this, for object-chaining.
[ "Outputs", "the", "help", "menu", "." ]
f6763c1b22a674ce9d83f179538d5500fa573ec5
https://github.com/corycollier/php-cli/blob/f6763c1b22a674ce9d83f179538d5500fa573ec5/src/Parser.php#L136-L169
10,449
efureev/socialite
src/Two/BitbucketProvider.php
BitbucketProvider.getEmailByToken
protected function getEmailByToken($token) { $emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token='.$token; try { $response = $this->getHttpClient()->get($emailsUrl); } catch (Exception $e) { return null; } $emails = json_decode($response->getBody(), true); foreach ($emails['values'] as $email) { if ($email['type'] == 'email' && $email['is_primary'] && $email['is_confirmed']) { return $email['email']; } } }
php
protected function getEmailByToken($token) { $emailsUrl = 'https://api.bitbucket.org/2.0/user/emails?access_token='.$token; try { $response = $this->getHttpClient()->get($emailsUrl); } catch (Exception $e) { return null; } $emails = json_decode($response->getBody(), true); foreach ($emails['values'] as $email) { if ($email['type'] == 'email' && $email['is_primary'] && $email['is_confirmed']) { return $email['email']; } } }
[ "protected", "function", "getEmailByToken", "(", "$", "token", ")", "{", "$", "emailsUrl", "=", "'https://api.bitbucket.org/2.0/user/emails?access_token='", ".", "$", "token", ";", "try", "{", "$", "response", "=", "$", "this", "->", "getHttpClient", "(", ")", "->", "get", "(", "$", "emailsUrl", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "$", "emails", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "emails", "[", "'values'", "]", "as", "$", "email", ")", "{", "if", "(", "$", "email", "[", "'type'", "]", "==", "'email'", "&&", "$", "email", "[", "'is_primary'", "]", "&&", "$", "email", "[", "'is_confirmed'", "]", ")", "{", "return", "$", "email", "[", "'email'", "]", ";", "}", "}", "}" ]
Get the email for the given access token. @param string $token @return string|null
[ "Get", "the", "email", "for", "the", "given", "access", "token", "." ]
5694ac8882712d2aa03009ace51fa323f39f0b4d
https://github.com/efureev/socialite/blob/5694ac8882712d2aa03009ace51fa323f39f0b4d/src/Two/BitbucketProvider.php#L65-L82
10,450
Ingewikkeld/rest-resource-bundle
src/Ingewikkeld/Rest/ResourceBundle/Resource/Controller.php
Controller.validateRequestParameters
protected function validateRequestParameters(Request $request) { $data = $request->request->all(); if (isset($data['id'])) { unset($data['id']); } // we explicitly do not load existing data; an edit is a PUT and should supply all valid data! $this->form->submit($data); if (!$this->form->isValid()) { throw new BadRequestHttpException($this->form->getErrorsAsString()); } return $this->form; }
php
protected function validateRequestParameters(Request $request) { $data = $request->request->all(); if (isset($data['id'])) { unset($data['id']); } // we explicitly do not load existing data; an edit is a PUT and should supply all valid data! $this->form->submit($data); if (!$this->form->isValid()) { throw new BadRequestHttpException($this->form->getErrorsAsString()); } return $this->form; }
[ "protected", "function", "validateRequestParameters", "(", "Request", "$", "request", ")", "{", "$", "data", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'id'", "]", ")", ")", "{", "unset", "(", "$", "data", "[", "'id'", "]", ")", ";", "}", "// we explicitly do not load existing data; an edit is a PUT and should supply all valid data!", "$", "this", "->", "form", "->", "submit", "(", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "form", "->", "isValid", "(", ")", ")", "{", "throw", "new", "BadRequestHttpException", "(", "$", "this", "->", "form", "->", "getErrorsAsString", "(", ")", ")", ";", "}", "return", "$", "this", "->", "form", ";", "}" ]
Takes the request parameters and passes them through the form associated with this controller. @param Request $request @throws BadRequestHttpException if the request parameters could not be validated with the form. @return FormInterface
[ "Takes", "the", "request", "parameters", "and", "passes", "them", "through", "the", "form", "associated", "with", "this", "controller", "." ]
2c0a260bf8a7ceb88964d9ca7cd31027d912b7c2
https://github.com/Ingewikkeld/rest-resource-bundle/blob/2c0a260bf8a7ceb88964d9ca7cd31027d912b7c2/src/Ingewikkeld/Rest/ResourceBundle/Resource/Controller.php#L119-L133
10,451
Ingewikkeld/rest-resource-bundle
src/Ingewikkeld/Rest/ResourceBundle/Resource/Controller.php
Controller.convertResourceToPlainText
protected function convertResourceToPlainText($format, Resource $resource) { switch ($format) { case 'xml': return (string)$resource->getXML()->asXml(); case 'json': return (string)$resource; default: throw new NotAcceptableHttpException(); } }
php
protected function convertResourceToPlainText($format, Resource $resource) { switch ($format) { case 'xml': return (string)$resource->getXML()->asXml(); case 'json': return (string)$resource; default: throw new NotAcceptableHttpException(); } }
[ "protected", "function", "convertResourceToPlainText", "(", "$", "format", ",", "Resource", "$", "resource", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "'xml'", ":", "return", "(", "string", ")", "$", "resource", "->", "getXML", "(", ")", "->", "asXml", "(", ")", ";", "case", "'json'", ":", "return", "(", "string", ")", "$", "resource", ";", "default", ":", "throw", "new", "NotAcceptableHttpException", "(", ")", ";", "}", "}" ]
Converts the give HAL Resource to a plain text representation that can be returned in the response. @param string $format @param \Hal\Resource $resource @throws NotAcceptableHttpException @return string
[ "Converts", "the", "give", "HAL", "Resource", "to", "a", "plain", "text", "representation", "that", "can", "be", "returned", "in", "the", "response", "." ]
2c0a260bf8a7ceb88964d9ca7cd31027d912b7c2
https://github.com/Ingewikkeld/rest-resource-bundle/blob/2c0a260bf8a7ceb88964d9ca7cd31027d912b7c2/src/Ingewikkeld/Rest/ResourceBundle/Resource/Controller.php#L145-L155
10,452
tekkla/core-security
Core/Security/Token/AuthToken.php
AuthToken.getSelector
public function getSelector(): string { if (empty($this->selector)) { $this->setSize($this->selector_size); $this->selector = $this->generateRandomToken(); } return $this->selector; }
php
public function getSelector(): string { if (empty($this->selector)) { $this->setSize($this->selector_size); $this->selector = $this->generateRandomToken(); } return $this->selector; }
[ "public", "function", "getSelector", "(", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "this", "->", "selector", ")", ")", "{", "$", "this", "->", "setSize", "(", "$", "this", "->", "selector_size", ")", ";", "$", "this", "->", "selector", "=", "$", "this", "->", "generateRandomToken", "(", ")", ";", "}", "return", "$", "this", "->", "selector", ";", "}" ]
Returns set selector Generates a selector when not set. @return string
[ "Returns", "set", "selector" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/AuthToken.php#L128-L136
10,453
tekkla/core-security
Core/Security/Token/AuthToken.php
AuthToken.getToken
public function getToken(): string { if (empty($this->token)) { $this->setSize($this->token_size); $this->token = $this->generateRandomToken(); } return $this->token; }
php
public function getToken(): string { if (empty($this->token)) { $this->setSize($this->token_size); $this->token = $this->generateRandomToken(); } return $this->token; }
[ "public", "function", "getToken", "(", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "this", "->", "token", ")", ")", "{", "$", "this", "->", "setSize", "(", "$", "this", "->", "token_size", ")", ";", "$", "this", "->", "token", "=", "$", "this", "->", "generateRandomToken", "(", ")", ";", "}", "return", "$", "this", "->", "token", ";", "}" ]
Returns set token. Generates a token when not set. @return string
[ "Returns", "set", "token", "." ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/AuthToken.php#L161-L169
10,454
tekkla/core-security
Core/Security/Token/AuthToken.php
AuthToken.setExpires
public function setExpires(int $days) { $this->expires_days = $days; $time = strtotime('+ ' . $this->expires_days . ' days'); $this->expires_datetime = date('Y-m-d H:i:s', $time); $this->expires_timestamp = $time; }
php
public function setExpires(int $days) { $this->expires_days = $days; $time = strtotime('+ ' . $this->expires_days . ' days'); $this->expires_datetime = date('Y-m-d H:i:s', $time); $this->expires_timestamp = $time; }
[ "public", "function", "setExpires", "(", "int", "$", "days", ")", "{", "$", "this", "->", "expires_days", "=", "$", "days", ";", "$", "time", "=", "strtotime", "(", "'+ '", ".", "$", "this", "->", "expires_days", ".", "' days'", ")", ";", "$", "this", "->", "expires_datetime", "=", "date", "(", "'Y-m-d H:i:s'", ",", "$", "time", ")", ";", "$", "this", "->", "expires_timestamp", "=", "$", "time", ";", "}" ]
Sets days after token gets expired @param int $days
[ "Sets", "days", "after", "token", "gets", "expired" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/AuthToken.php#L228-L236
10,455
osflab/view
Helper/Bootstrap/Nav.php
Nav.addLink
public function addLink( string $label, string $url, bool $active = false, bool $disabled = false, string $icon = null, string $iconColor = null, string $badge = null, string $badgeColor = null) { Checkers::checkUrl($url); $this->items[] = [ 'label' => $label, 'url' => $url, 'active' => $active, 'disabled' => $disabled, 'icon' => $icon, 'icolor' => $iconColor, 'badge' => $badge, 'bcolor' => $badgeColor ]; return $this; }
php
public function addLink( string $label, string $url, bool $active = false, bool $disabled = false, string $icon = null, string $iconColor = null, string $badge = null, string $badgeColor = null) { Checkers::checkUrl($url); $this->items[] = [ 'label' => $label, 'url' => $url, 'active' => $active, 'disabled' => $disabled, 'icon' => $icon, 'icolor' => $iconColor, 'badge' => $badge, 'bcolor' => $badgeColor ]; return $this; }
[ "public", "function", "addLink", "(", "string", "$", "label", ",", "string", "$", "url", ",", "bool", "$", "active", "=", "false", ",", "bool", "$", "disabled", "=", "false", ",", "string", "$", "icon", "=", "null", ",", "string", "$", "iconColor", "=", "null", ",", "string", "$", "badge", "=", "null", ",", "string", "$", "badgeColor", "=", "null", ")", "{", "Checkers", "::", "checkUrl", "(", "$", "url", ")", ";", "$", "this", "->", "items", "[", "]", "=", "[", "'label'", "=>", "$", "label", ",", "'url'", "=>", "$", "url", ",", "'active'", "=>", "$", "active", ",", "'disabled'", "=>", "$", "disabled", ",", "'icon'", "=>", "$", "icon", ",", "'icolor'", "=>", "$", "iconColor", ",", "'badge'", "=>", "$", "badge", ",", "'bcolor'", "=>", "$", "badgeColor", "]", ";", "return", "$", "this", ";", "}" ]
Add a link element to the nav bar @param string $label @param string $url @param bool $active @param bool $disabled @param string $icon @return $this
[ "Add", "a", "link", "element", "to", "the", "nav", "bar" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Nav.php#L97-L119
10,456
osflab/view
Helper/Bootstrap/Nav.php
Nav.addMenu
public function addMenu(string $label, Addon\DropDownMenu $menu, bool $active = false, bool $disabled = false) { $this->items[] = [ 'label' => $label, 'menu' => $menu, 'active' => $active, 'disabled' => $disabled ]; return $this; }
php
public function addMenu(string $label, Addon\DropDownMenu $menu, bool $active = false, bool $disabled = false) { $this->items[] = [ 'label' => $label, 'menu' => $menu, 'active' => $active, 'disabled' => $disabled ]; return $this; }
[ "public", "function", "addMenu", "(", "string", "$", "label", ",", "Addon", "\\", "DropDownMenu", "$", "menu", ",", "bool", "$", "active", "=", "false", ",", "bool", "$", "disabled", "=", "false", ")", "{", "$", "this", "->", "items", "[", "]", "=", "[", "'label'", "=>", "$", "label", ",", "'menu'", "=>", "$", "menu", ",", "'active'", "=>", "$", "active", ",", "'disabled'", "=>", "$", "disabled", "]", ";", "return", "$", "this", ";", "}" ]
Add a menu element to the nav bar @param string $label @param \Osf\View\Helper\Bootstrap\Addon\DropDownMenu $menu @param bool $active @param bool $disabled @return $this
[ "Add", "a", "menu", "element", "to", "the", "nav", "bar" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Nav.php#L148-L157
10,457
cobonto/module
src/Classes/Actions/Middleware.php
Middleware.add
public function add() { if($moduleMiddleware = $this->module->middleware()) { $middleware = $this->load(); $middleware = array_merge($middleware,$moduleMiddleware); return $this->set($middleware); } return true; }
php
public function add() { if($moduleMiddleware = $this->module->middleware()) { $middleware = $this->load(); $middleware = array_merge($middleware,$moduleMiddleware); return $this->set($middleware); } return true; }
[ "public", "function", "add", "(", ")", "{", "if", "(", "$", "moduleMiddleware", "=", "$", "this", "->", "module", "->", "middleware", "(", ")", ")", "{", "$", "middleware", "=", "$", "this", "->", "load", "(", ")", ";", "$", "middleware", "=", "array_merge", "(", "$", "middleware", ",", "$", "moduleMiddleware", ")", ";", "return", "$", "this", "->", "set", "(", "$", "middleware", ")", ";", "}", "return", "true", ";", "}" ]
add middleware to middleware.php in cache
[ "add", "middleware", "to", "middleware", ".", "php", "in", "cache" ]
0978b5305c3d6f13ef7e0e5297855bd09eee6b76
https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Actions/Middleware.php#L10-L19
10,458
cobonto/module
src/Classes/Actions/Middleware.php
Middleware.remove
public function remove() { if($moduleMiddleware = $this->module->middleware()) { $middleware = $this->load(); $middleware = array_diff($middleware,$moduleMiddleware); return $this->set($middleware); } return true; }
php
public function remove() { if($moduleMiddleware = $this->module->middleware()) { $middleware = $this->load(); $middleware = array_diff($middleware,$moduleMiddleware); return $this->set($middleware); } return true; }
[ "public", "function", "remove", "(", ")", "{", "if", "(", "$", "moduleMiddleware", "=", "$", "this", "->", "module", "->", "middleware", "(", ")", ")", "{", "$", "middleware", "=", "$", "this", "->", "load", "(", ")", ";", "$", "middleware", "=", "array_diff", "(", "$", "middleware", ",", "$", "moduleMiddleware", ")", ";", "return", "$", "this", "->", "set", "(", "$", "middleware", ")", ";", "}", "return", "true", ";", "}" ]
remove middleware to middleware.php in cache
[ "remove", "middleware", "to", "middleware", ".", "php", "in", "cache" ]
0978b5305c3d6f13ef7e0e5297855bd09eee6b76
https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Actions/Middleware.php#L21-L30
10,459
monetise/money
library/Money/Currency.php
Currency.getDefaultFractionDigits
public static function getDefaultFractionDigits($currencyCode) { $defaultFractionDigits = static::getCurrencyData($currencyCode)['default_fraction_digits']; if (!is_int($defaultFractionDigits)) { throw new UnexpectedValueException(sprintf( 'The currency default fraction digits value must be an integer; "%s" given', is_object($defaultFractionDigits) ? get_class($defaultFractionDigits) : gettype($defaultFractionDigits) )); } if ($defaultFractionDigits < 0) { throw new UnexpectedValueException(sprintf( 'The currency default fraction digits value must be greater than 0; "%s" given', $defaultFractionDigits )); } return $defaultFractionDigits; }
php
public static function getDefaultFractionDigits($currencyCode) { $defaultFractionDigits = static::getCurrencyData($currencyCode)['default_fraction_digits']; if (!is_int($defaultFractionDigits)) { throw new UnexpectedValueException(sprintf( 'The currency default fraction digits value must be an integer; "%s" given', is_object($defaultFractionDigits) ? get_class($defaultFractionDigits) : gettype($defaultFractionDigits) )); } if ($defaultFractionDigits < 0) { throw new UnexpectedValueException(sprintf( 'The currency default fraction digits value must be greater than 0; "%s" given', $defaultFractionDigits )); } return $defaultFractionDigits; }
[ "public", "static", "function", "getDefaultFractionDigits", "(", "$", "currencyCode", ")", "{", "$", "defaultFractionDigits", "=", "static", "::", "getCurrencyData", "(", "$", "currencyCode", ")", "[", "'default_fraction_digits'", "]", ";", "if", "(", "!", "is_int", "(", "$", "defaultFractionDigits", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "sprintf", "(", "'The currency default fraction digits value must be an integer; \"%s\" given'", ",", "is_object", "(", "$", "defaultFractionDigits", ")", "?", "get_class", "(", "$", "defaultFractionDigits", ")", ":", "gettype", "(", "$", "defaultFractionDigits", ")", ")", ")", ";", "}", "if", "(", "$", "defaultFractionDigits", "<", "0", ")", "{", "throw", "new", "UnexpectedValueException", "(", "sprintf", "(", "'The currency default fraction digits value must be greater than 0; \"%s\" given'", ",", "$", "defaultFractionDigits", ")", ")", ";", "}", "return", "$", "defaultFractionDigits", ";", "}" ]
Returns the default number of fraction digits @param string $currencyCode The currency ISO 4217 alpha 3 code @return integer @throws InvalidArgumentException
[ "Returns", "the", "default", "number", "of", "fraction", "digits" ]
f1c2e6fef3099dded16cc70f0cee449575952b5b
https://github.com/monetise/money/blob/f1c2e6fef3099dded16cc70f0cee449575952b5b/library/Money/Currency.php#L1174-L1190
10,460
monetise/money
library/Money/Currency.php
Currency.getSubUnit
public static function getSubUnit($currencyCode) { $subunits = static::getCurrencyData($currencyCode)['sub_unit']; if (!is_int($subunits)) { throw new UnexpectedValueException(sprintf( 'The currency sub-units value must be an integer; "%s" given', is_object($subunits) ? get_class($subunits) : gettype($subunits) )); } if ($subunits < 1) { throw new UnexpectedValueException(sprintf( 'The currency sub-units value must be greater than 1; "%s" given', $subunits )); } return $subunits; }
php
public static function getSubUnit($currencyCode) { $subunits = static::getCurrencyData($currencyCode)['sub_unit']; if (!is_int($subunits)) { throw new UnexpectedValueException(sprintf( 'The currency sub-units value must be an integer; "%s" given', is_object($subunits) ? get_class($subunits) : gettype($subunits) )); } if ($subunits < 1) { throw new UnexpectedValueException(sprintf( 'The currency sub-units value must be greater than 1; "%s" given', $subunits )); } return $subunits; }
[ "public", "static", "function", "getSubUnit", "(", "$", "currencyCode", ")", "{", "$", "subunits", "=", "static", "::", "getCurrencyData", "(", "$", "currencyCode", ")", "[", "'sub_unit'", "]", ";", "if", "(", "!", "is_int", "(", "$", "subunits", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "sprintf", "(", "'The currency sub-units value must be an integer; \"%s\" given'", ",", "is_object", "(", "$", "subunits", ")", "?", "get_class", "(", "$", "subunits", ")", ":", "gettype", "(", "$", "subunits", ")", ")", ")", ";", "}", "if", "(", "$", "subunits", "<", "1", ")", "{", "throw", "new", "UnexpectedValueException", "(", "sprintf", "(", "'The currency sub-units value must be greater than 1; \"%s\" given'", ",", "$", "subunits", ")", ")", ";", "}", "return", "$", "subunits", ";", "}" ]
Returns the sub-unit value @param string $currencyCode The currency ISO 4217 alpha 3 code @return integer @throws UnexpectedValueException @throws InvalidArgumentException
[ "Returns", "the", "sub", "-", "unit", "value" ]
f1c2e6fef3099dded16cc70f0cee449575952b5b
https://github.com/monetise/money/blob/f1c2e6fef3099dded16cc70f0cee449575952b5b/library/Money/Currency.php#L1200-L1216
10,461
ekyna/CartBundle
Twig/CartExtension.php
CartExtension.renderCartWidget
public function renderCartWidget(array $options = []) { $template = array_key_exists('template', $options) ? $options['template'] : $this->config['templates']['widget']; $cart = array_key_exists('cart', $options) ? $options['cart'] : $this->cartProvider->getCart(); return $this->twig->render($template, ['cart' => $cart]); }
php
public function renderCartWidget(array $options = []) { $template = array_key_exists('template', $options) ? $options['template'] : $this->config['templates']['widget']; $cart = array_key_exists('cart', $options) ? $options['cart'] : $this->cartProvider->getCart(); return $this->twig->render($template, ['cart' => $cart]); }
[ "public", "function", "renderCartWidget", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "template", "=", "array_key_exists", "(", "'template'", ",", "$", "options", ")", "?", "$", "options", "[", "'template'", "]", ":", "$", "this", "->", "config", "[", "'templates'", "]", "[", "'widget'", "]", ";", "$", "cart", "=", "array_key_exists", "(", "'cart'", ",", "$", "options", ")", "?", "$", "options", "[", "'cart'", "]", ":", "$", "this", "->", "cartProvider", "->", "getCart", "(", ")", ";", "return", "$", "this", "->", "twig", "->", "render", "(", "$", "template", ",", "[", "'cart'", "=>", "$", "cart", "]", ")", ";", "}" ]
Renders the cart widget. @param array $options @return string
[ "Renders", "the", "cart", "widget", "." ]
c486af3d027873c81c7b61ef71980e8062c3dddd
https://github.com/ekyna/CartBundle/blob/c486af3d027873c81c7b61ef71980e8062c3dddd/Twig/CartExtension.php#L80-L86
10,462
mooti/framework
src/Container.php
Container.registerServices
public function registerServices(ServiceProviderInterface $serviceProvider) { $services = $serviceProvider->getServices(); foreach ($services as $id => $service) { if ($this->has($id) == false) { $this->set($id, $service); } } }
php
public function registerServices(ServiceProviderInterface $serviceProvider) { $services = $serviceProvider->getServices(); foreach ($services as $id => $service) { if ($this->has($id) == false) { $this->set($id, $service); } } }
[ "public", "function", "registerServices", "(", "ServiceProviderInterface", "$", "serviceProvider", ")", "{", "$", "services", "=", "$", "serviceProvider", "->", "getServices", "(", ")", ";", "foreach", "(", "$", "services", "as", "$", "id", "=>", "$", "service", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "id", ")", "==", "false", ")", "{", "$", "this", "->", "set", "(", "$", "id", ",", "$", "service", ")", ";", "}", "}", "}" ]
Add services to the container @param ServiceProviderInterface $serviceProvider A service provider
[ "Add", "services", "to", "the", "container" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Container.php#L96-L104
10,463
K-Phoen/FakerServiceProvider
src/KPhoen/Provider/FakerServiceProvider.php
FakerServiceProvider.getBestLanguage
protected function getBestLanguage(Request $request, $default = null) { foreach ($request->getLanguages() as $language) { if (strpos($language, '_') !== false) { return $language; } } return $default; }
php
protected function getBestLanguage(Request $request, $default = null) { foreach ($request->getLanguages() as $language) { if (strpos($language, '_') !== false) { return $language; } } return $default; }
[ "protected", "function", "getBestLanguage", "(", "Request", "$", "request", ",", "$", "default", "=", "null", ")", "{", "foreach", "(", "$", "request", "->", "getLanguages", "(", ")", "as", "$", "language", ")", "{", "if", "(", "strpos", "(", "$", "language", ",", "'_'", ")", "!==", "false", ")", "{", "return", "$", "language", ";", "}", "}", "return", "$", "default", ";", "}" ]
Finds the best language for a given request. @param Request $request The request. @param string $default The default language if nothing satisfying is found in the request.
[ "Finds", "the", "best", "language", "for", "a", "given", "request", "." ]
a0b26638004fa5c905866e0b50797084147a318d
https://github.com/K-Phoen/FakerServiceProvider/blob/a0b26638004fa5c905866e0b50797084147a318d/src/KPhoen/Provider/FakerServiceProvider.php#L75-L84
10,464
sirgrimorum/transarticles
src/GetArticleFromDataBase.php
GetArticleFromDataBase.get
public static function get($nickname) { try { $lang = App::getLocale(); $modelClass = config('sirgrimorum.transarticles.default_articles_model'); $langColumn = config('sirgrimorum.transarticles.default_lang_column'); $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name'); $article = $modelClass::{$findArticle}($nickname)->where($langColumn, "=", $lang)->first(); if ($article) { return $article->content; } else { $article = $modelClass::{$findArticle}($nickname)->first(); if ($article) { return $article->content . "<small><span class='label label-warning'>" . $article->{$langColumn} . "</span></small>"; } else { return $nickname; } } } catch (Exception $ex) { return $nickname . "<pre class='label label-warning'>" . print_r([$ex->getMessage(), $ex->getTraceAsString()], true) . "</pre>"; } }
php
public static function get($nickname) { try { $lang = App::getLocale(); $modelClass = config('sirgrimorum.transarticles.default_articles_model'); $langColumn = config('sirgrimorum.transarticles.default_lang_column'); $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name'); $article = $modelClass::{$findArticle}($nickname)->where($langColumn, "=", $lang)->first(); if ($article) { return $article->content; } else { $article = $modelClass::{$findArticle}($nickname)->first(); if ($article) { return $article->content . "<small><span class='label label-warning'>" . $article->{$langColumn} . "</span></small>"; } else { return $nickname; } } } catch (Exception $ex) { return $nickname . "<pre class='label label-warning'>" . print_r([$ex->getMessage(), $ex->getTraceAsString()], true) . "</pre>"; } }
[ "public", "static", "function", "get", "(", "$", "nickname", ")", "{", "try", "{", "$", "lang", "=", "App", "::", "getLocale", "(", ")", ";", "$", "modelClass", "=", "config", "(", "'sirgrimorum.transarticles.default_articles_model'", ")", ";", "$", "langColumn", "=", "config", "(", "'sirgrimorum.transarticles.default_lang_column'", ")", ";", "$", "findArticle", "=", "config", "(", "'sirgrimorum.transarticles.default_findarticle_function_name'", ")", ";", "$", "article", "=", "$", "modelClass", "::", "{", "$", "findArticle", "}", "(", "$", "nickname", ")", "->", "where", "(", "$", "langColumn", ",", "\"=\"", ",", "$", "lang", ")", "->", "first", "(", ")", ";", "if", "(", "$", "article", ")", "{", "return", "$", "article", "->", "content", ";", "}", "else", "{", "$", "article", "=", "$", "modelClass", "::", "{", "$", "findArticle", "}", "(", "$", "nickname", ")", "->", "first", "(", ")", ";", "if", "(", "$", "article", ")", "{", "return", "$", "article", "->", "content", ".", "\"<small><span class='label label-warning'>\"", ".", "$", "article", "->", "{", "$", "langColumn", "}", ".", "\"</span></small>\"", ";", "}", "else", "{", "return", "$", "nickname", ";", "}", "}", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "nickname", ".", "\"<pre class='label label-warning'>\"", ".", "print_r", "(", "[", "$", "ex", "->", "getMessage", "(", ")", ",", "$", "ex", "->", "getTraceAsString", "(", ")", "]", ",", "true", ")", ".", "\"</pre>\"", ";", "}", "}" ]
Return the translation for the article @param String $nickname The article to load using dot notation @return String The content of the article localized, if not found, return the first article in a diferent language, if neither, returns de $nickname
[ "Return", "the", "translation", "for", "the", "article" ]
92a936cf82024d78ae0272662f930fec97200d20
https://github.com/sirgrimorum/transarticles/blob/92a936cf82024d78ae0272662f930fec97200d20/src/GetArticleFromDataBase.php#L41-L61
10,465
sirgrimorum/transarticles
src/GetArticleFromDataBase.php
GetArticleFromDataBase.getjs
public static function getjs($scope, $basevar = '') { if ($basevar == '') { $basevar = config('sirgrimorum.transarticles.default_base_var'); } $lang = App::getLocale(); $listo = false; try { $modelClass = config('sirgrimorum.transarticles.default_articles_model'); $langColumn = config('sirgrimorum.transarticles.default_lang_column'); $findArticles = config('sirgrimorum.transarticles.default_findarticles_function_name'); $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name'); $articles = $modelClass::{$findArticles}($scope)->where($langColumn, "=", $lang)->get(); if ($articles) { $listo = true; } else { $articles = $modelClass::{$findArticles}($scope)->get(); if ($articles) { $listo = true; } else { $articles = $modelClass::{$findArticle}($scope)->where($langColumn, "=", $lang)->first(); $listo = false; if ($articles) { $jsarray = []; data_fill($jsarray, $scope, $articles->content); } else { $articles = $modelClass::{$findArticle}($scope)->first(); if ($articles) { $jsarray = []; data_fill($jsarray, $scope, $articles->content); //$jsarray = $articles->content; } else { $jsarray = []; data_fill($jsarray, $scope, $scope); } } } } } catch (Exception $ex) { return $scope . " - Error:" . print_r($ex->getMessage(), true); } if ($listo) { if ($articles) { $trans = []; foreach ($articles as $article) { $trans[$article->nickname] = $article->content; } $jsarray = json_encode($trans); return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>"; } else { $jsarray = []; data_fill($jsarray, $scope, $scope); } } $jsarray = json_encode($jsarray); return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>"; }
php
public static function getjs($scope, $basevar = '') { if ($basevar == '') { $basevar = config('sirgrimorum.transarticles.default_base_var'); } $lang = App::getLocale(); $listo = false; try { $modelClass = config('sirgrimorum.transarticles.default_articles_model'); $langColumn = config('sirgrimorum.transarticles.default_lang_column'); $findArticles = config('sirgrimorum.transarticles.default_findarticles_function_name'); $findArticle = config('sirgrimorum.transarticles.default_findarticle_function_name'); $articles = $modelClass::{$findArticles}($scope)->where($langColumn, "=", $lang)->get(); if ($articles) { $listo = true; } else { $articles = $modelClass::{$findArticles}($scope)->get(); if ($articles) { $listo = true; } else { $articles = $modelClass::{$findArticle}($scope)->where($langColumn, "=", $lang)->first(); $listo = false; if ($articles) { $jsarray = []; data_fill($jsarray, $scope, $articles->content); } else { $articles = $modelClass::{$findArticle}($scope)->first(); if ($articles) { $jsarray = []; data_fill($jsarray, $scope, $articles->content); //$jsarray = $articles->content; } else { $jsarray = []; data_fill($jsarray, $scope, $scope); } } } } } catch (Exception $ex) { return $scope . " - Error:" . print_r($ex->getMessage(), true); } if ($listo) { if ($articles) { $trans = []; foreach ($articles as $article) { $trans[$article->nickname] = $article->content; } $jsarray = json_encode($trans); return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>"; } else { $jsarray = []; data_fill($jsarray, $scope, $scope); } } $jsarray = json_encode($jsarray); return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>"; }
[ "public", "static", "function", "getjs", "(", "$", "scope", ",", "$", "basevar", "=", "''", ")", "{", "if", "(", "$", "basevar", "==", "''", ")", "{", "$", "basevar", "=", "config", "(", "'sirgrimorum.transarticles.default_base_var'", ")", ";", "}", "$", "lang", "=", "App", "::", "getLocale", "(", ")", ";", "$", "listo", "=", "false", ";", "try", "{", "$", "modelClass", "=", "config", "(", "'sirgrimorum.transarticles.default_articles_model'", ")", ";", "$", "langColumn", "=", "config", "(", "'sirgrimorum.transarticles.default_lang_column'", ")", ";", "$", "findArticles", "=", "config", "(", "'sirgrimorum.transarticles.default_findarticles_function_name'", ")", ";", "$", "findArticle", "=", "config", "(", "'sirgrimorum.transarticles.default_findarticle_function_name'", ")", ";", "$", "articles", "=", "$", "modelClass", "::", "{", "$", "findArticles", "}", "(", "$", "scope", ")", "->", "where", "(", "$", "langColumn", ",", "\"=\"", ",", "$", "lang", ")", "->", "get", "(", ")", ";", "if", "(", "$", "articles", ")", "{", "$", "listo", "=", "true", ";", "}", "else", "{", "$", "articles", "=", "$", "modelClass", "::", "{", "$", "findArticles", "}", "(", "$", "scope", ")", "->", "get", "(", ")", ";", "if", "(", "$", "articles", ")", "{", "$", "listo", "=", "true", ";", "}", "else", "{", "$", "articles", "=", "$", "modelClass", "::", "{", "$", "findArticle", "}", "(", "$", "scope", ")", "->", "where", "(", "$", "langColumn", ",", "\"=\"", ",", "$", "lang", ")", "->", "first", "(", ")", ";", "$", "listo", "=", "false", ";", "if", "(", "$", "articles", ")", "{", "$", "jsarray", "=", "[", "]", ";", "data_fill", "(", "$", "jsarray", ",", "$", "scope", ",", "$", "articles", "->", "content", ")", ";", "}", "else", "{", "$", "articles", "=", "$", "modelClass", "::", "{", "$", "findArticle", "}", "(", "$", "scope", ")", "->", "first", "(", ")", ";", "if", "(", "$", "articles", ")", "{", "$", "jsarray", "=", "[", "]", ";", "data_fill", "(", "$", "jsarray", ",", "$", "scope", ",", "$", "articles", "->", "content", ")", ";", "//$jsarray = $articles->content;", "}", "else", "{", "$", "jsarray", "=", "[", "]", ";", "data_fill", "(", "$", "jsarray", ",", "$", "scope", ",", "$", "scope", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "scope", ".", "\" - Error:\"", ".", "print_r", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "true", ")", ";", "}", "if", "(", "$", "listo", ")", "{", "if", "(", "$", "articles", ")", "{", "$", "trans", "=", "[", "]", ";", "foreach", "(", "$", "articles", "as", "$", "article", ")", "{", "$", "trans", "[", "$", "article", "->", "nickname", "]", "=", "$", "article", "->", "content", ";", "}", "$", "jsarray", "=", "json_encode", "(", "$", "trans", ")", ";", "return", "\"<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>\"", ";", "}", "else", "{", "$", "jsarray", "=", "[", "]", ";", "data_fill", "(", "$", "jsarray", ",", "$", "scope", ",", "$", "scope", ")", ";", "}", "}", "$", "jsarray", "=", "json_encode", "(", "$", "jsarray", ")", ";", "return", "\"<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>\"", ";", "}" ]
return the JavaScript from article table @param String $scope The scope to load
[ "return", "the", "JavaScript", "from", "article", "table" ]
92a936cf82024d78ae0272662f930fec97200d20
https://github.com/sirgrimorum/transarticles/blob/92a936cf82024d78ae0272662f930fec97200d20/src/GetArticleFromDataBase.php#L70-L125
10,466
CupOfTea696/WordPress-Lib
src/Foundation/Bootstrap/ReadConfiguration.php
ReadConfiguration.getThemeConfigurationFiles
protected function getThemeConfigurationFiles(Container $app) { $files = []; $config_path = $app->make('config')->get('theme.config_path', realpath($app->make('wp.theme')->getRoot()) . '/config'); if (file_exists($config_path) && is_dir($config_path)) { foreach (Finder::create()->files()->name('*.php')->in($config_path) as $file) { $nesting = $this->getThemeConfigurationNesting($file, $config_path); $files[$nesting . basename($file->getRealPath(), '.php')] = $file->getRealPath(); } } return $files; }
php
protected function getThemeConfigurationFiles(Container $app) { $files = []; $config_path = $app->make('config')->get('theme.config_path', realpath($app->make('wp.theme')->getRoot()) . '/config'); if (file_exists($config_path) && is_dir($config_path)) { foreach (Finder::create()->files()->name('*.php')->in($config_path) as $file) { $nesting = $this->getThemeConfigurationNesting($file, $config_path); $files[$nesting . basename($file->getRealPath(), '.php')] = $file->getRealPath(); } } return $files; }
[ "protected", "function", "getThemeConfigurationFiles", "(", "Container", "$", "app", ")", "{", "$", "files", "=", "[", "]", ";", "$", "config_path", "=", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "'theme.config_path'", ",", "realpath", "(", "$", "app", "->", "make", "(", "'wp.theme'", ")", "->", "getRoot", "(", ")", ")", ".", "'/config'", ")", ";", "if", "(", "file_exists", "(", "$", "config_path", ")", "&&", "is_dir", "(", "$", "config_path", ")", ")", "{", "foreach", "(", "Finder", "::", "create", "(", ")", "->", "files", "(", ")", "->", "name", "(", "'*.php'", ")", "->", "in", "(", "$", "config_path", ")", "as", "$", "file", ")", "{", "$", "nesting", "=", "$", "this", "->", "getThemeConfigurationNesting", "(", "$", "file", ",", "$", "config_path", ")", ";", "$", "files", "[", "$", "nesting", ".", "basename", "(", "$", "file", "->", "getRealPath", "(", ")", ",", "'.php'", ")", "]", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "}", "}", "return", "$", "files", ";", "}" ]
Get all of the configuration files for the theme. @param \Illuminate\Contracts\Foundation\Application $app @return array
[ "Get", "all", "of", "the", "configuration", "files", "for", "the", "theme", "." ]
7b31413dff6f4f70b3e2a2fc8172d0721152891d
https://github.com/CupOfTea696/WordPress-Lib/blob/7b31413dff6f4f70b3e2a2fc8172d0721152891d/src/Foundation/Bootstrap/ReadConfiguration.php#L82-L96
10,467
MarcusFulbright/represent
src/Represent/Util/PaginatedCollection.php
PaginatedCollection.getParameters
public function getParameters($page = null, $limit = null) { $params = $this->params; $params[$this->pageParam] = null == $page ? $this->getPage() : $page; $params[$this->limitParam] = null == $limit ? $this->getLimit() : $limit; return $params; }
php
public function getParameters($page = null, $limit = null) { $params = $this->params; $params[$this->pageParam] = null == $page ? $this->getPage() : $page; $params[$this->limitParam] = null == $limit ? $this->getLimit() : $limit; return $params; }
[ "public", "function", "getParameters", "(", "$", "page", "=", "null", ",", "$", "limit", "=", "null", ")", "{", "$", "params", "=", "$", "this", "->", "params", ";", "$", "params", "[", "$", "this", "->", "pageParam", "]", "=", "null", "==", "$", "page", "?", "$", "this", "->", "getPage", "(", ")", ":", "$", "page", ";", "$", "params", "[", "$", "this", "->", "limitParam", "]", "=", "null", "==", "$", "limit", "?", "$", "this", "->", "getLimit", "(", ")", ":", "$", "limit", ";", "return", "$", "params", ";", "}" ]
Handles parsing through parameters array @param null $page @param null $limit @return array
[ "Handles", "parsing", "through", "parameters", "array" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Util/PaginatedCollection.php#L116-L124
10,468
strackovski/semtools
src/Common/ApiReaderAbstract.php
ApiReaderAbstract.setApiKey
public function setApiKey($key) { $this->apiKey = $key; return $this->apiKey === $key ? true : false; }
php
public function setApiKey($key) { $this->apiKey = $key; return $this->apiKey === $key ? true : false; }
[ "public", "function", "setApiKey", "(", "$", "key", ")", "{", "$", "this", "->", "apiKey", "=", "$", "key", ";", "return", "$", "this", "->", "apiKey", "===", "$", "key", "?", "true", ":", "false", ";", "}" ]
Set API key @param $key @return bool True on success, false on failure.
[ "Set", "API", "key" ]
6a11eff4eaa18e2939b08382bca5d60d9864a4fa
https://github.com/strackovski/semtools/blob/6a11eff4eaa18e2939b08382bca5d60d9864a4fa/src/Common/ApiReaderAbstract.php#L76-L80
10,469
strackovski/semtools
src/Common/ApiReaderAbstract.php
ApiReaderAbstract.setApiEndpoint
public function setApiEndpoint($url) { $this->apiEndpoint = $url; return $this->apiEndpoint === $url ? true : false; }
php
public function setApiEndpoint($url) { $this->apiEndpoint = $url; return $this->apiEndpoint === $url ? true : false; }
[ "public", "function", "setApiEndpoint", "(", "$", "url", ")", "{", "$", "this", "->", "apiEndpoint", "=", "$", "url", ";", "return", "$", "this", "->", "apiEndpoint", "===", "$", "url", "?", "true", ":", "false", ";", "}" ]
Set API URL @param $url @return bool
[ "Set", "API", "URL" ]
6a11eff4eaa18e2939b08382bca5d60d9864a4fa
https://github.com/strackovski/semtools/blob/6a11eff4eaa18e2939b08382bca5d60d9864a4fa/src/Common/ApiReaderAbstract.php#L89-L93
10,470
strackovski/semtools
src/Common/ApiReaderAbstract.php
ApiReaderAbstract.setApiQueryStringRequestFormat
public function setApiQueryStringRequestFormat($format) { $this->apiQueryStringRequestFormat = $format; return $this->apiQueryStringRequestFormat === $format ? true : false; }
php
public function setApiQueryStringRequestFormat($format) { $this->apiQueryStringRequestFormat = $format; return $this->apiQueryStringRequestFormat === $format ? true : false; }
[ "public", "function", "setApiQueryStringRequestFormat", "(", "$", "format", ")", "{", "$", "this", "->", "apiQueryStringRequestFormat", "=", "$", "format", ";", "return", "$", "this", "->", "apiQueryStringRequestFormat", "===", "$", "format", "?", "true", ":", "false", ";", "}" ]
Set API URL REST format Used as format for sprintf to inject parameters into the URL string. @param $format @return bool
[ "Set", "API", "URL", "REST", "format", "Used", "as", "format", "for", "sprintf", "to", "inject", "parameters", "into", "the", "URL", "string", "." ]
6a11eff4eaa18e2939b08382bca5d60d9864a4fa
https://github.com/strackovski/semtools/blob/6a11eff4eaa18e2939b08382bca5d60d9864a4fa/src/Common/ApiReaderAbstract.php#L103-L107
10,471
lucidphp/xml
src/Dom/DOMDocument.php
DOMDocument.ensureNodeClass
private function ensureNodeClass(DOMNode $node) { $class = $this->nodeClasses['DOMElement']; if (true !== ($node instanceof $class) && $node instanceof \DOMElement) { return $node->ownerDocument->importNode($node, true); } return $node; }
php
private function ensureNodeClass(DOMNode $node) { $class = $this->nodeClasses['DOMElement']; if (true !== ($node instanceof $class) && $node instanceof \DOMElement) { return $node->ownerDocument->importNode($node, true); } return $node; }
[ "private", "function", "ensureNodeClass", "(", "DOMNode", "$", "node", ")", "{", "$", "class", "=", "$", "this", "->", "nodeClasses", "[", "'DOMElement'", "]", ";", "if", "(", "true", "!==", "(", "$", "node", "instanceof", "$", "class", ")", "&&", "$", "node", "instanceof", "\\", "DOMElement", ")", "{", "return", "$", "node", "->", "ownerDocument", "->", "importNode", "(", "$", "node", ",", "true", ")", ";", "}", "return", "$", "node", ";", "}" ]
Workarround for hhvm issue @see https://github.com/facebook/hhvm/issues/1848 @param DOMNode $node @return DOMNode
[ "Workarround", "for", "hhvm", "issue" ]
4ff1e92c4071887c2802eb7ee3f3c46632ad7db2
https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/Dom/DOMDocument.php#L126-L135
10,472
event-centric/identity
src/EventCentric/Identity/UuidIdentity.php
UuidIdentity.uuid4
private static function uuid4() { $bytes = function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(16) : self::generateBytes(16); $hash = bin2hex($bytes); // Set the version number $timeHi = hexdec(substr($hash, 12, 4)) & 0x0fff; $timeHi &= ~(0xf000); $timeHi |= 4 << 12; // Set the variant to RFC 4122 $clockSeqHi = hexdec(substr($hash, 16, 2)) & 0x3f; $clockSeqHi &= ~(0xc0); $clockSeqHi |= 0x80; $fields = [ 'time_low' => substr($hash, 0, 8), 'time_mid' => substr($hash, 8, 4), 'time_hi_and_version' => sprintf('%04x', $timeHi), 'clock_seq_hi_and_reserved' => sprintf('%02x', $clockSeqHi), 'clock_seq_low' => substr($hash, 18, 2), 'node' => substr($hash, 20, 12), ]; return vsprintf( '%08s-%04s-%04s-%02s%02s-%012s', $fields ); }
php
private static function uuid4() { $bytes = function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(16) : self::generateBytes(16); $hash = bin2hex($bytes); // Set the version number $timeHi = hexdec(substr($hash, 12, 4)) & 0x0fff; $timeHi &= ~(0xf000); $timeHi |= 4 << 12; // Set the variant to RFC 4122 $clockSeqHi = hexdec(substr($hash, 16, 2)) & 0x3f; $clockSeqHi &= ~(0xc0); $clockSeqHi |= 0x80; $fields = [ 'time_low' => substr($hash, 0, 8), 'time_mid' => substr($hash, 8, 4), 'time_hi_and_version' => sprintf('%04x', $timeHi), 'clock_seq_hi_and_reserved' => sprintf('%02x', $clockSeqHi), 'clock_seq_low' => substr($hash, 18, 2), 'node' => substr($hash, 20, 12), ]; return vsprintf( '%08s-%04s-%04s-%02s%02s-%012s', $fields ); }
[ "private", "static", "function", "uuid4", "(", ")", "{", "$", "bytes", "=", "function_exists", "(", "'openssl_random_pseudo_bytes'", ")", "?", "openssl_random_pseudo_bytes", "(", "16", ")", ":", "self", "::", "generateBytes", "(", "16", ")", ";", "$", "hash", "=", "bin2hex", "(", "$", "bytes", ")", ";", "// Set the version number", "$", "timeHi", "=", "hexdec", "(", "substr", "(", "$", "hash", ",", "12", ",", "4", ")", ")", "&", "0x0fff", ";", "$", "timeHi", "&=", "~", "(", "0xf000", ")", ";", "$", "timeHi", "|=", "4", "<<", "12", ";", "// Set the variant to RFC 4122", "$", "clockSeqHi", "=", "hexdec", "(", "substr", "(", "$", "hash", ",", "16", ",", "2", ")", ")", "&", "0x3f", ";", "$", "clockSeqHi", "&=", "~", "(", "0xc0", ")", ";", "$", "clockSeqHi", "|=", "0x80", ";", "$", "fields", "=", "[", "'time_low'", "=>", "substr", "(", "$", "hash", ",", "0", ",", "8", ")", ",", "'time_mid'", "=>", "substr", "(", "$", "hash", ",", "8", ",", "4", ")", ",", "'time_hi_and_version'", "=>", "sprintf", "(", "'%04x'", ",", "$", "timeHi", ")", ",", "'clock_seq_hi_and_reserved'", "=>", "sprintf", "(", "'%02x'", ",", "$", "clockSeqHi", ")", ",", "'clock_seq_low'", "=>", "substr", "(", "$", "hash", ",", "18", ",", "2", ")", ",", "'node'", "=>", "substr", "(", "$", "hash", ",", "20", ",", "12", ")", ",", "]", ";", "return", "vsprintf", "(", "'%08s-%04s-%04s-%02s%02s-%012s'", ",", "$", "fields", ")", ";", "}" ]
Returns a version 4 UUID @return string
[ "Returns", "a", "version", "4", "UUID" ]
e2828d2f0863e22e54c094b8c917734df1c6c87e
https://github.com/event-centric/identity/blob/e2828d2f0863e22e54c094b8c917734df1c6c87e/src/EventCentric/Identity/UuidIdentity.php#L63-L96
10,473
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateApiKeys
public function validateApiKeys(array $keys) { if (empty($keys)) { throw new InvalidArgumentException( 'No API keys specified', 401 ); } foreach ($keys as $key) { $this->validateApiKey($key); } return $this; }
php
public function validateApiKeys(array $keys) { if (empty($keys)) { throw new InvalidArgumentException( 'No API keys specified', 401 ); } foreach ($keys as $key) { $this->validateApiKey($key); } return $this; }
[ "public", "function", "validateApiKeys", "(", "array", "$", "keys", ")", "{", "if", "(", "empty", "(", "$", "keys", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'No API keys specified'", ",", "401", ")", ";", "}", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "validateApiKey", "(", "$", "key", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given API keys. @param string[] $keys API keys. @return $this @throws InvalidArgumentException Thrown if one of the API keys is invalid.
[ "Validates", "the", "given", "API", "keys", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L48-L62
10,474
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateDeveloperKey
public function validateDeveloperKey($key) { if ('' === $key) { return $this; } if (!is_string($key) || strlen($key) !== 48) { throw new InvalidArgumentException( 'Developer key must be a string of exactly 48 characters', 401 ); } return $this; }
php
public function validateDeveloperKey($key) { if ('' === $key) { return $this; } if (!is_string($key) || strlen($key) !== 48) { throw new InvalidArgumentException( 'Developer key must be a string of exactly 48 characters', 401 ); } return $this; }
[ "public", "function", "validateDeveloperKey", "(", "$", "key", ")", "{", "if", "(", "''", "===", "$", "key", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "key", ")", "||", "strlen", "(", "$", "key", ")", "!==", "48", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Developer key must be a string of exactly 48 characters'", ",", "401", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given developer key. @param string $key Developer key. @return $this @throws InvalidArgumentException Thrown if the developer key is invalid.
[ "Validates", "the", "given", "developer", "key", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L94-L108
10,475
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateApplication
public function validateApplication($application) { if (!is_string($application) || strlen($application) > 256 || strlen($application) < 1 ) { throw new InvalidArgumentException( 'Application name must be a non empty string of at most 256 ' . 'characters', 400 ); } return $this; }
php
public function validateApplication($application) { if (!is_string($application) || strlen($application) > 256 || strlen($application) < 1 ) { throw new InvalidArgumentException( 'Application name must be a non empty string of at most 256 ' . 'characters', 400 ); } return $this; }
[ "public", "function", "validateApplication", "(", "$", "application", ")", "{", "if", "(", "!", "is_string", "(", "$", "application", ")", "||", "strlen", "(", "$", "application", ")", ">", "256", "||", "strlen", "(", "$", "application", ")", "<", "1", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Application name must be a non empty string of at most 256 '", ".", "'characters'", ",", "400", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given application name. @param string $application Application name. @return $this @throws InvalidArgumentException Thrown if the application name is invalid.
[ "Validates", "the", "given", "application", "name", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L119-L133
10,476
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateEvent
public function validateEvent($event) { if (!is_string($event) || strlen($event) > 1000 || strlen($event) < 1 ) { throw new InvalidArgumentException( 'Event name must be a non empty string of at most 1,000 ' . 'characters', 400 ); } return $this; }
php
public function validateEvent($event) { if (!is_string($event) || strlen($event) > 1000 || strlen($event) < 1 ) { throw new InvalidArgumentException( 'Event name must be a non empty string of at most 1,000 ' . 'characters', 400 ); } return $this; }
[ "public", "function", "validateEvent", "(", "$", "event", ")", "{", "if", "(", "!", "is_string", "(", "$", "event", ")", "||", "strlen", "(", "$", "event", ")", ">", "1000", "||", "strlen", "(", "$", "event", ")", "<", "1", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Event name must be a non empty string of at most 1,000 '", ".", "'characters'", ",", "400", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given event name. @param string $event Event name. @return $this @throws InvalidArgumentException Thrown if the event name is invalid.
[ "Validates", "the", "given", "event", "name", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L144-L158
10,477
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateDescription
public function validateDescription($event) { if (!is_string($event) || strlen($event) > 10000 || strlen($event) < 1 ) { throw new InvalidArgumentException( 'Event description must be a non empty string of at most ' . '10,000 characters', 400 ); } return $this; }
php
public function validateDescription($event) { if (!is_string($event) || strlen($event) > 10000 || strlen($event) < 1 ) { throw new InvalidArgumentException( 'Event description must be a non empty string of at most ' . '10,000 characters', 400 ); } return $this; }
[ "public", "function", "validateDescription", "(", "$", "event", ")", "{", "if", "(", "!", "is_string", "(", "$", "event", ")", "||", "strlen", "(", "$", "event", ")", ">", "10000", "||", "strlen", "(", "$", "event", ")", "<", "1", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Event description must be a non empty string of at most '", ".", "'10,000 characters'", ",", "400", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given event description. @param string $event Event description. @return $this @throws InvalidArgumentException Thrown if the event description is invalid.
[ "Validates", "the", "given", "event", "description", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L169-L183
10,478
randomhost/notifymyandroid
src/php/Validator.php
Validator.validateUrl
public function validateUrl($url) { if ('' === $url) { return $this; } if (!is_string($url) || strlen($url) > 2000) { throw new InvalidArgumentException( 'URL must be a string of at most 2,000 characters', 400 ); } return $this; }
php
public function validateUrl($url) { if ('' === $url) { return $this; } if (!is_string($url) || strlen($url) > 2000) { throw new InvalidArgumentException( 'URL must be a string of at most 2,000 characters', 400 ); } return $this; }
[ "public", "function", "validateUrl", "(", "$", "url", ")", "{", "if", "(", "''", "===", "$", "url", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "url", ")", "||", "strlen", "(", "$", "url", ")", ">", "2000", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'URL must be a string of at most 2,000 characters'", ",", "400", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the given URL. @param string $url URL/URI to attach to the event. @return $this @throws InvalidArgumentException Thrown if the URL is invalid.
[ "Validates", "the", "given", "URL", "." ]
de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf
https://github.com/randomhost/notifymyandroid/blob/de3d79dc8e6b3933fc2428fcd56cb2e7a0acbfaf/src/php/Validator.php#L218-L232
10,479
bugotech/io
src/Ofx/Ofx.php
Ofx.load
public function load($ofxFile) { $content = file_get_contents($ofxFile); //Headers $inicio = stripos($content, '<OFX>'); $header = trim(substr($content, 0, $inicio)); $this->headers = $this->headers($header); $content = str_replace($header, '', $content); $dom = new \DOMDocument(); $dom->loadXML($content); //Ofx $this->saldoTotal = $dom->getElementsByTagName('BALAMT')->item(0)->textContent; $this->dataInicial = $this->date($dom->getElementsByTagName('DTSTART')->item(0)->textContent); $this->dataFinal = $this->date($dom->getElementsByTagName('DTEND')->item(0)->textContent); //Conta $this->conta->banco = $dom->getElementsByTagName('BANKID')->item(0)->textContent; $this->conta->numConta = substr($dom->getElementsByTagName('ACCTID')->item(0)->textContent, 5); $this->conta->agencia = substr($dom->getElementsByTagName('ACCTID')->item(0)->textContent, 0, 5); //Transacoes foreach ($dom->getElementsByTagName('STMTTRN') as $item) { $transacao = new Transacao(); $transacao->tipo = $item->getElementsByTagName('TRNTYPE')->item(0)->textContent; $transacao->valor = $item->getElementsByTagName('TRNAMT')->item(0)->textContent; $transacao->descricao = $item->getElementsByTagName('MEMO')->item(0)->textContent; $transacao->data = $this->date($item->getElementsByTagName('DTPOSTED')->item(0)->textContent); $transacao->checkNum = $item->getElementsByTagName('CHECKNUM')->item(0)->textContent; $transacao->transacaoId = $item->getElementsByTagName('FITID')->item(0)->textContent; $this->transacoes[] = $transacao; } }
php
public function load($ofxFile) { $content = file_get_contents($ofxFile); //Headers $inicio = stripos($content, '<OFX>'); $header = trim(substr($content, 0, $inicio)); $this->headers = $this->headers($header); $content = str_replace($header, '', $content); $dom = new \DOMDocument(); $dom->loadXML($content); //Ofx $this->saldoTotal = $dom->getElementsByTagName('BALAMT')->item(0)->textContent; $this->dataInicial = $this->date($dom->getElementsByTagName('DTSTART')->item(0)->textContent); $this->dataFinal = $this->date($dom->getElementsByTagName('DTEND')->item(0)->textContent); //Conta $this->conta->banco = $dom->getElementsByTagName('BANKID')->item(0)->textContent; $this->conta->numConta = substr($dom->getElementsByTagName('ACCTID')->item(0)->textContent, 5); $this->conta->agencia = substr($dom->getElementsByTagName('ACCTID')->item(0)->textContent, 0, 5); //Transacoes foreach ($dom->getElementsByTagName('STMTTRN') as $item) { $transacao = new Transacao(); $transacao->tipo = $item->getElementsByTagName('TRNTYPE')->item(0)->textContent; $transacao->valor = $item->getElementsByTagName('TRNAMT')->item(0)->textContent; $transacao->descricao = $item->getElementsByTagName('MEMO')->item(0)->textContent; $transacao->data = $this->date($item->getElementsByTagName('DTPOSTED')->item(0)->textContent); $transacao->checkNum = $item->getElementsByTagName('CHECKNUM')->item(0)->textContent; $transacao->transacaoId = $item->getElementsByTagName('FITID')->item(0)->textContent; $this->transacoes[] = $transacao; } }
[ "public", "function", "load", "(", "$", "ofxFile", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "ofxFile", ")", ";", "//Headers", "$", "inicio", "=", "stripos", "(", "$", "content", ",", "'<OFX>'", ")", ";", "$", "header", "=", "trim", "(", "substr", "(", "$", "content", ",", "0", ",", "$", "inicio", ")", ")", ";", "$", "this", "->", "headers", "=", "$", "this", "->", "headers", "(", "$", "header", ")", ";", "$", "content", "=", "str_replace", "(", "$", "header", ",", "''", ",", "$", "content", ")", ";", "$", "dom", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "dom", "->", "loadXML", "(", "$", "content", ")", ";", "//Ofx", "$", "this", "->", "saldoTotal", "=", "$", "dom", "->", "getElementsByTagName", "(", "'BALAMT'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "this", "->", "dataInicial", "=", "$", "this", "->", "date", "(", "$", "dom", "->", "getElementsByTagName", "(", "'DTSTART'", ")", "->", "item", "(", "0", ")", "->", "textContent", ")", ";", "$", "this", "->", "dataFinal", "=", "$", "this", "->", "date", "(", "$", "dom", "->", "getElementsByTagName", "(", "'DTEND'", ")", "->", "item", "(", "0", ")", "->", "textContent", ")", ";", "//Conta", "$", "this", "->", "conta", "->", "banco", "=", "$", "dom", "->", "getElementsByTagName", "(", "'BANKID'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "this", "->", "conta", "->", "numConta", "=", "substr", "(", "$", "dom", "->", "getElementsByTagName", "(", "'ACCTID'", ")", "->", "item", "(", "0", ")", "->", "textContent", ",", "5", ")", ";", "$", "this", "->", "conta", "->", "agencia", "=", "substr", "(", "$", "dom", "->", "getElementsByTagName", "(", "'ACCTID'", ")", "->", "item", "(", "0", ")", "->", "textContent", ",", "0", ",", "5", ")", ";", "//Transacoes", "foreach", "(", "$", "dom", "->", "getElementsByTagName", "(", "'STMTTRN'", ")", "as", "$", "item", ")", "{", "$", "transacao", "=", "new", "Transacao", "(", ")", ";", "$", "transacao", "->", "tipo", "=", "$", "item", "->", "getElementsByTagName", "(", "'TRNTYPE'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "transacao", "->", "valor", "=", "$", "item", "->", "getElementsByTagName", "(", "'TRNAMT'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "transacao", "->", "descricao", "=", "$", "item", "->", "getElementsByTagName", "(", "'MEMO'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "transacao", "->", "data", "=", "$", "this", "->", "date", "(", "$", "item", "->", "getElementsByTagName", "(", "'DTPOSTED'", ")", "->", "item", "(", "0", ")", "->", "textContent", ")", ";", "$", "transacao", "->", "checkNum", "=", "$", "item", "->", "getElementsByTagName", "(", "'CHECKNUM'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "transacao", "->", "transacaoId", "=", "$", "item", "->", "getElementsByTagName", "(", "'FITID'", ")", "->", "item", "(", "0", ")", "->", "textContent", ";", "$", "this", "->", "transacoes", "[", "]", "=", "$", "transacao", ";", "}", "}" ]
Load an OfxFile. @param $ofxFile
[ "Load", "an", "OfxFile", "." ]
3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0
https://github.com/bugotech/io/blob/3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0/src/Ofx/Ofx.php#L52-L89
10,480
iwyg/common
src/Helper/Arr.php
Arr.flatten
public static function flatten(array $array) { $out = []; foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) { if (is_int($key)) { $out[] = $item; } else { $out[$key] = $item; } } return $out; }
php
public static function flatten(array $array) { $out = []; foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) { if (is_int($key)) { $out[] = $item; } else { $out[$key] = $item; } } return $out; }
[ "public", "static", "function", "flatten", "(", "array", "$", "array", ")", "{", "$", "out", "=", "[", "]", ";", "foreach", "(", "new", "RecursiveIteratorIterator", "(", "new", "RecursiveArrayIterator", "(", "$", "array", ")", ")", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "out", "[", "]", "=", "$", "item", ";", "}", "else", "{", "$", "out", "[", "$", "key", "]", "=", "$", "item", ";", "}", "}", "return", "$", "out", ";", "}" ]
Flattens a multidimensional array. @param array $array @return array
[ "Flattens", "a", "multidimensional", "array", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L35-L48
10,481
iwyg/common
src/Helper/Arr.php
Arr.pluck
public static function pluck(array $array, $key) { return array_map( function ($item) use ($key) { return is_object($item) ? $item->$key : $item[$key]; }, $array ); }
php
public static function pluck(array $array, $key) { return array_map( function ($item) use ($key) { return is_object($item) ? $item->$key : $item[$key]; }, $array ); }
[ "public", "static", "function", "pluck", "(", "array", "$", "array", ",", "$", "key", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "key", ")", "{", "return", "is_object", "(", "$", "item", ")", "?", "$", "item", "->", "$", "key", ":", "$", "item", "[", "$", "key", "]", ";", "}", ",", "$", "array", ")", ";", "}" ]
Plucks values by key from a list of arrays or objects. @param array $array @param string $key @return array
[ "Plucks", "values", "by", "key", "from", "a", "list", "of", "arrays", "or", "objects", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L84-L92
10,482
iwyg/common
src/Helper/Arr.php
Arr.zip
public static function zip() { $args = func_get_args(); $count = count($args); $out = []; for ($i = 0; $i < $count; $i++) { $out[$i] = self::pluck($i, $args); } return $out; }
php
public static function zip() { $args = func_get_args(); $count = count($args); $out = []; for ($i = 0; $i < $count; $i++) { $out[$i] = self::pluck($i, $args); } return $out; }
[ "public", "static", "function", "zip", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "count", "=", "count", "(", "$", "args", ")", ";", "$", "out", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "out", "[", "$", "i", "]", "=", "self", "::", "pluck", "(", "$", "i", ",", "$", "args", ")", ";", "}", "return", "$", "out", ";", "}" ]
Zips to or more arrays @return void
[ "Zips", "to", "or", "more", "arrays" ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L99-L111
10,483
iwyg/common
src/Helper/Arr.php
Arr.max
public static function max(array $args) { uasort( $args, function ($a, $b) { return count($a) < count($b) ? 1 : -1; } ); return count(reset($args)); }
php
public static function max(array $args) { uasort( $args, function ($a, $b) { return count($a) < count($b) ? 1 : -1; } ); return count(reset($args)); }
[ "public", "static", "function", "max", "(", "array", "$", "args", ")", "{", "uasort", "(", "$", "args", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "count", "(", "$", "a", ")", "<", "count", "(", "$", "b", ")", "?", "1", ":", "-", "1", ";", "}", ")", ";", "return", "count", "(", "reset", "(", "$", "args", ")", ")", ";", "}" ]
Get the highest value. @param array $args @return int
[ "Get", "the", "highest", "value", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L120-L129
10,484
iwyg/common
src/Helper/Arr.php
Arr.min
public static function min(array $args) { usort( $args, function ($a, $b) { return count($a) < count($b) ? 1 : -1; } ); return count(end($args)); }
php
public static function min(array $args) { usort( $args, function ($a, $b) { return count($a) < count($b) ? 1 : -1; } ); return count(end($args)); }
[ "public", "static", "function", "min", "(", "array", "$", "args", ")", "{", "usort", "(", "$", "args", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "count", "(", "$", "a", ")", "<", "count", "(", "$", "b", ")", "?", "1", ":", "-", "1", ";", "}", ")", ";", "return", "count", "(", "end", "(", "$", "args", ")", ")", ";", "}" ]
Get the lowest value. @param array $args @return int
[ "Get", "the", "lowest", "value", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L159-L168
10,485
iwyg/common
src/Helper/Arr.php
Arr.get
public static function get(array $array, $namespace = null, $separator = '.') { if (!is_string($namespace)) { return $array; } $keys = explode($separator, $namespace); while (count($keys) > 0 and !is_null($array)) { $key = array_shift($keys); $array = isset($array[$key]) ? $array[$key] : null; } return $array; }
php
public static function get(array $array, $namespace = null, $separator = '.') { if (!is_string($namespace)) { return $array; } $keys = explode($separator, $namespace); while (count($keys) > 0 and !is_null($array)) { $key = array_shift($keys); $array = isset($array[$key]) ? $array[$key] : null; } return $array; }
[ "public", "static", "function", "get", "(", "array", "$", "array", ",", "$", "namespace", "=", "null", ",", "$", "separator", "=", "'.'", ")", "{", "if", "(", "!", "is_string", "(", "$", "namespace", ")", ")", "{", "return", "$", "array", ";", "}", "$", "keys", "=", "explode", "(", "$", "separator", ",", "$", "namespace", ")", ";", "while", "(", "count", "(", "$", "keys", ")", ">", "0", "and", "!", "is_null", "(", "$", "array", ")", ")", "{", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ";", "$", "array", "=", "isset", "(", "$", "array", "[", "$", "key", "]", ")", "?", "$", "array", "[", "$", "key", "]", ":", "null", ";", "}", "return", "$", "array", ";", "}" ]
Getter for multidimensional arrays. @param array $array @param string|null $namespace @param string $separator @return mixed
[ "Getter", "for", "multidimensional", "arrays", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L179-L193
10,486
iwyg/common
src/Helper/Arr.php
Arr.set
public static function set(array &$input, $namespace, $value, $separator = '.') { $keys = explode($separator, $namespace); $pointer = &$input; while (count($keys) > 0) { $key = array_shift($keys); $pointer[$key] = isset($pointer[$key]) ? $pointer[$key] : []; $pointer = &$pointer[$key]; } $pointer = $value; return $input; }
php
public static function set(array &$input, $namespace, $value, $separator = '.') { $keys = explode($separator, $namespace); $pointer = &$input; while (count($keys) > 0) { $key = array_shift($keys); $pointer[$key] = isset($pointer[$key]) ? $pointer[$key] : []; $pointer = &$pointer[$key]; } $pointer = $value; return $input; }
[ "public", "static", "function", "set", "(", "array", "&", "$", "input", ",", "$", "namespace", ",", "$", "value", ",", "$", "separator", "=", "'.'", ")", "{", "$", "keys", "=", "explode", "(", "$", "separator", ",", "$", "namespace", ")", ";", "$", "pointer", "=", "&", "$", "input", ";", "while", "(", "count", "(", "$", "keys", ")", ">", "0", ")", "{", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ";", "$", "pointer", "[", "$", "key", "]", "=", "isset", "(", "$", "pointer", "[", "$", "key", "]", ")", "?", "$", "pointer", "[", "$", "key", "]", ":", "[", "]", ";", "$", "pointer", "=", "&", "$", "pointer", "[", "$", "key", "]", ";", "}", "$", "pointer", "=", "$", "value", ";", "return", "$", "input", ";", "}" ]
Sets a segmented string to an array @param string $namespace @param mixed $value @param array $array @param string $separator @return array
[ "Sets", "a", "segmented", "string", "to", "an", "array" ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L205-L219
10,487
iwyg/common
src/Helper/Arr.php
Arr.unsetKey
public static function unsetKey(array &$array, $namespace, $separator = '.') { if (!is_string($namespace)) { return $array; } $keys = explode($separator, $namespace); while (($count = count($keys)) > 0 and !is_null($array)) { $key = array_shift($keys); if (isset($array[$key])) { if ($count < 2) { unset($array[$key]); } else { $array =& $array[$key]; } } } }
php
public static function unsetKey(array &$array, $namespace, $separator = '.') { if (!is_string($namespace)) { return $array; } $keys = explode($separator, $namespace); while (($count = count($keys)) > 0 and !is_null($array)) { $key = array_shift($keys); if (isset($array[$key])) { if ($count < 2) { unset($array[$key]); } else { $array =& $array[$key]; } } } }
[ "public", "static", "function", "unsetKey", "(", "array", "&", "$", "array", ",", "$", "namespace", ",", "$", "separator", "=", "'.'", ")", "{", "if", "(", "!", "is_string", "(", "$", "namespace", ")", ")", "{", "return", "$", "array", ";", "}", "$", "keys", "=", "explode", "(", "$", "separator", ",", "$", "namespace", ")", ";", "while", "(", "(", "$", "count", "=", "count", "(", "$", "keys", ")", ")", ">", "0", "and", "!", "is_null", "(", "$", "array", ")", ")", "{", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "isset", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "if", "(", "$", "count", "<", "2", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "array", "=", "&", "$", "array", "[", "$", "key", "]", ";", "}", "}", "}", "}" ]
Unsets a value from a multidimensional array @param array $array @param string $namespace @param string $separator @return void
[ "Unsets", "a", "value", "from", "a", "multidimensional", "array" ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L230-L248
10,488
iwyg/common
src/Helper/Arr.php
Arr.compact
public static function compact($array, $reindex = false) { $out = array_filter($array, function ($item) { return false !== (bool)$item; }); return false !== $reindex && self::isList($out) ? array_values($out) : $out; }
php
public static function compact($array, $reindex = false) { $out = array_filter($array, function ($item) { return false !== (bool)$item; }); return false !== $reindex && self::isList($out) ? array_values($out) : $out; }
[ "public", "static", "function", "compact", "(", "$", "array", ",", "$", "reindex", "=", "false", ")", "{", "$", "out", "=", "array_filter", "(", "$", "array", ",", "function", "(", "$", "item", ")", "{", "return", "false", "!==", "(", "bool", ")", "$", "item", ";", "}", ")", ";", "return", "false", "!==", "$", "reindex", "&&", "self", "::", "isList", "(", "$", "out", ")", "?", "array_values", "(", "$", "out", ")", ":", "$", "out", ";", "}" ]
Filters out boolish items that resemble none "truthy" values. @return array
[ "Filters", "out", "boolish", "items", "that", "resemble", "none", "truthy", "values", "." ]
d7f1189faadded3cda542d1fdd050febf4af24f9
https://github.com/iwyg/common/blob/d7f1189faadded3cda542d1fdd050febf4af24f9/src/Helper/Arr.php#L255-L262
10,489
xinc-develop/xinc-core
src/Properties.php
Properties.get
public function get($name) { if (array_key_exists($name, $this->properties)) { return $this->properties[$name]; } elseif (array_key_exists($name, $this->dynamic)) { return $this->dynamic[$name](); } else { return; } }
php
public function get($name) { if (array_key_exists($name, $this->properties)) { return $this->properties[$name]; } elseif (array_key_exists($name, $this->dynamic)) { return $this->dynamic[$name](); } else { return; } }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "properties", ")", ")", "{", "return", "$", "this", "->", "properties", "[", "$", "name", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "dynamic", ")", ")", "{", "return", "$", "this", "->", "dynamic", "[", "$", "name", "]", "(", ")", ";", "}", "else", "{", "return", ";", "}", "}" ]
Returns the property value of the questioned keyname. @param string $name @return mixed String or null if not found
[ "Returns", "the", "property", "value", "of", "the", "questioned", "keyname", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Properties.php#L94-L103
10,490
xinc-develop/xinc-core
src/Properties.php
Properties.getAllProperties
public function getAllProperties() { $props = array(); foreach ($this->dynamic as $k => $c) { $props[$k] = $c(); } return array_replace($props, $this->properties); }
php
public function getAllProperties() { $props = array(); foreach ($this->dynamic as $k => $c) { $props[$k] = $c(); } return array_replace($props, $this->properties); }
[ "public", "function", "getAllProperties", "(", ")", "{", "$", "props", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "dynamic", "as", "$", "k", "=>", "$", "c", ")", "{", "$", "props", "[", "$", "k", "]", "=", "$", "c", "(", ")", ";", "}", "return", "array_replace", "(", "$", "props", ",", "$", "this", "->", "properties", ")", ";", "}" ]
returns all the properties in an array. @return array
[ "returns", "all", "the", "properties", "in", "an", "array", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Properties.php#L110-L118
10,491
phplegends/view
src/Context.php
Context.startSection
public function startSection($name, $content = null) { $section = $this->getSectionCollection()->findOrCreate($name); $content ? $section->setContent($content) : $section->setContent('')->start(); return $this; }
php
public function startSection($name, $content = null) { $section = $this->getSectionCollection()->findOrCreate($name); $content ? $section->setContent($content) : $section->setContent('')->start(); return $this; }
[ "public", "function", "startSection", "(", "$", "name", ",", "$", "content", "=", "null", ")", "{", "$", "section", "=", "$", "this", "->", "getSectionCollection", "(", ")", "->", "findOrCreate", "(", "$", "name", ")", ";", "$", "content", "?", "$", "section", "->", "setContent", "(", "$", "content", ")", ":", "$", "section", "->", "setContent", "(", "''", ")", "->", "start", "(", ")", ";", "return", "$", "this", ";", "}" ]
Starts a section. If content is passed, section doesn't not use "blocks" @param string $name @param string|null $content @return void
[ "Starts", "a", "section", ".", "If", "content", "is", "passed", "section", "doesn", "t", "not", "use", "blocks" ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/Context.php#L95-L103
10,492
phplegends/view
src/Context.php
Context.appendSection
public function appendSection($name, $content = null) { $section = $this->getSectionCollection()->findOrCreate($name); $content ? $section->appendContent($content) : $section->start(); }
php
public function appendSection($name, $content = null) { $section = $this->getSectionCollection()->findOrCreate($name); $content ? $section->appendContent($content) : $section->start(); }
[ "public", "function", "appendSection", "(", "$", "name", ",", "$", "content", "=", "null", ")", "{", "$", "section", "=", "$", "this", "->", "getSectionCollection", "(", ")", "->", "findOrCreate", "(", "$", "name", ")", ";", "$", "content", "?", "$", "section", "->", "appendContent", "(", "$", "content", ")", ":", "$", "section", "->", "start", "(", ")", ";", "}" ]
Append in a section. If content is passed, section doesn't not use "blocks" @param string $name @param string|null $content @return void
[ "Append", "in", "a", "section", ".", "If", "content", "is", "passed", "section", "doesn", "t", "not", "use", "blocks" ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/Context.php#L141-L146
10,493
phplegends/view
src/Context.php
Context.getSection
public function getSection($name, $default = '') { if ($this->getSectionCollection()->has($name)) { return $this->getSectionCollection()->get($name); } return $default; }
php
public function getSection($name, $default = '') { if ($this->getSectionCollection()->has($name)) { return $this->getSectionCollection()->get($name); } return $default; }
[ "public", "function", "getSection", "(", "$", "name", ",", "$", "default", "=", "''", ")", "{", "if", "(", "$", "this", "->", "getSectionCollection", "(", ")", "->", "has", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "getSectionCollection", "(", ")", "->", "get", "(", "$", "name", ")", ";", "}", "return", "$", "default", ";", "}" ]
Gives the value of a initialized section @param string $name @param string $default @return string
[ "Gives", "the", "value", "of", "a", "initialized", "section" ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/Context.php#L155-L164
10,494
phplegends/view
src/Context.php
Context.includes
public function includes($view, $data = []) { $factory = $this->getFactory(); $filename = $factory->getFinder()->find($view); $context = new static($factory); $context->setSectionCollection($this->getSectionCollection()); return new View($filename, $data, $context); }
php
public function includes($view, $data = []) { $factory = $this->getFactory(); $filename = $factory->getFinder()->find($view); $context = new static($factory); $context->setSectionCollection($this->getSectionCollection()); return new View($filename, $data, $context); }
[ "public", "function", "includes", "(", "$", "view", ",", "$", "data", "=", "[", "]", ")", "{", "$", "factory", "=", "$", "this", "->", "getFactory", "(", ")", ";", "$", "filename", "=", "$", "factory", "->", "getFinder", "(", ")", "->", "find", "(", "$", "view", ")", ";", "$", "context", "=", "new", "static", "(", "$", "factory", ")", ";", "$", "context", "->", "setSectionCollection", "(", "$", "this", "->", "getSectionCollection", "(", ")", ")", ";", "return", "new", "View", "(", "$", "filename", ",", "$", "data", ",", "$", "context", ")", ";", "}" ]
Create a view in current context. Is useful for create view inside another. @param string $view @param array
[ "Create", "a", "view", "in", "current", "context", ".", "Is", "useful", "for", "create", "view", "inside", "another", "." ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/Context.php#L220-L231
10,495
edunola13/enolaphp-framework
src/Support/Generic/GenericBehavior.php
GenericBehavior.validate
protected function validate($var, $ruleset = null, $locale = null, $lib= '\Enola\Lib\Validation\ValidationFields', $dir= null){ $validation= new $lib($locale); if($dir == null){ $dir= PATHAPP . 'src/content/messages'; } $validation->dir_content= $dir; $ruleset= $ruleset != null ? $ruleset : $this->configValidation(); if(is_object($var)){ $reflection= new Reflection($var); foreach ($ruleset as $key => $regla) { $validation->add_rule($key, $reflection->getProperty($key), $regla); } }else{ foreach ($ruleset as $key => $regla) { $field= isset($var[$key]) ? $var[$key] : NULL; $validation->add_rule($key, $field, $regla); } } if(! $validation->validate()){ //Consigo los errores y retorno FALSE $this->errors= $validation->error_messages(); return FALSE; }else{ return TRUE; } }
php
protected function validate($var, $ruleset = null, $locale = null, $lib= '\Enola\Lib\Validation\ValidationFields', $dir= null){ $validation= new $lib($locale); if($dir == null){ $dir= PATHAPP . 'src/content/messages'; } $validation->dir_content= $dir; $ruleset= $ruleset != null ? $ruleset : $this->configValidation(); if(is_object($var)){ $reflection= new Reflection($var); foreach ($ruleset as $key => $regla) { $validation->add_rule($key, $reflection->getProperty($key), $regla); } }else{ foreach ($ruleset as $key => $regla) { $field= isset($var[$key]) ? $var[$key] : NULL; $validation->add_rule($key, $field, $regla); } } if(! $validation->validate()){ //Consigo los errores y retorno FALSE $this->errors= $validation->error_messages(); return FALSE; }else{ return TRUE; } }
[ "protected", "function", "validate", "(", "$", "var", ",", "$", "ruleset", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "lib", "=", "'\\Enola\\Lib\\Validation\\ValidationFields'", ",", "$", "dir", "=", "null", ")", "{", "$", "validation", "=", "new", "$", "lib", "(", "$", "locale", ")", ";", "if", "(", "$", "dir", "==", "null", ")", "{", "$", "dir", "=", "PATHAPP", ".", "'src/content/messages'", ";", "}", "$", "validation", "->", "dir_content", "=", "$", "dir", ";", "$", "ruleset", "=", "$", "ruleset", "!=", "null", "?", "$", "ruleset", ":", "$", "this", "->", "configValidation", "(", ")", ";", "if", "(", "is_object", "(", "$", "var", ")", ")", "{", "$", "reflection", "=", "new", "Reflection", "(", "$", "var", ")", ";", "foreach", "(", "$", "ruleset", "as", "$", "key", "=>", "$", "regla", ")", "{", "$", "validation", "->", "add_rule", "(", "$", "key", ",", "$", "reflection", "->", "getProperty", "(", "$", "key", ")", ",", "$", "regla", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "ruleset", "as", "$", "key", "=>", "$", "regla", ")", "{", "$", "field", "=", "isset", "(", "$", "var", "[", "$", "key", "]", ")", "?", "$", "var", "[", "$", "key", "]", ":", "NULL", ";", "$", "validation", "->", "add_rule", "(", "$", "key", ",", "$", "field", ",", "$", "regla", ")", ";", "}", "}", "if", "(", "!", "$", "validation", "->", "validate", "(", ")", ")", "{", "//Consigo los errores y retorno FALSE", "$", "this", "->", "errors", "=", "$", "validation", "->", "error_messages", "(", ")", ";", "return", "FALSE", ";", "}", "else", "{", "return", "TRUE", ";", "}", "}" ]
Valida las variables de un objeto o de un array en base a una definicion de configuracion de validacion Se puede utilizar la libreria que se desee pere debe respetar la inerfaz de la proporcionada por el framework. @param type $var @param array $ruleset @param string $locale @param string $lib @return bool
[ "Valida", "las", "variables", "de", "un", "objeto", "o", "de", "un", "array", "en", "base", "a", "una", "definicion", "de", "configuracion", "de", "validacion", "Se", "puede", "utilizar", "la", "libreria", "que", "se", "desee", "pere", "debe", "respetar", "la", "inerfaz", "de", "la", "proporcionada", "por", "el", "framework", "." ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/Generic/GenericBehavior.php#L22-L49
10,496
edunola13/enolaphp-framework
src/Support/Generic/GenericBehavior.php
GenericBehavior.injectDependency
protected function injectDependency($propertyName, $dependencyName){ EnolaContext::getInstance()->app->dependenciesEngine->injectDependency($this,$propertyName,$dependencyName); }
php
protected function injectDependency($propertyName, $dependencyName){ EnolaContext::getInstance()->app->dependenciesEngine->injectDependency($this,$propertyName,$dependencyName); }
[ "protected", "function", "injectDependency", "(", "$", "propertyName", ",", "$", "dependencyName", ")", "{", "EnolaContext", "::", "getInstance", "(", ")", "->", "app", "->", "dependenciesEngine", "->", "injectDependency", "(", "$", "this", ",", "$", "propertyName", ",", "$", "dependencyName", ")", ";", "}" ]
Carga la dependencias indicada en la instancia actual en la propiedad indicada @param string $propertyName @param string $dependencyName
[ "Carga", "la", "dependencias", "indicada", "en", "la", "instancia", "actual", "en", "la", "propiedad", "indicada" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/Generic/GenericBehavior.php#L116-L118
10,497
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/theme.php
Theme.instance
public static function instance($name = '_default_', array $config = array()) { if ( ! \array_key_exists($name, static::$instances)) { static::$instances[$name] = static::forge($config); } return static::$instances[$name]; }
php
public static function instance($name = '_default_', array $config = array()) { if ( ! \array_key_exists($name, static::$instances)) { static::$instances[$name] = static::forge($config); } return static::$instances[$name]; }
[ "public", "static", "function", "instance", "(", "$", "name", "=", "'_default_'", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "name", ",", "static", "::", "$", "instances", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "name", "]", "=", "static", "::", "forge", "(", "$", "config", ")", ";", "}", "return", "static", "::", "$", "instances", "[", "$", "name", "]", ";", "}" ]
Acts as a Multiton. Will return the requested instance, or will create a new named one if it does not exist. @param string $name The instance name @return Theme
[ "Acts", "as", "a", "Multiton", ".", "Will", "return", "the", "requested", "instance", "or", "will", "create", "a", "new", "named", "one", "if", "it", "does", "not", "exist", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L37-L45
10,498
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/theme.php
Theme.view
public function view($view, $data = array(), $auto_filter = null) { if ($this->active['path'] === null) { throw new \ThemeException('You must set an active theme.'); } return \View::forge($this->find_file($view), $data, $auto_filter); }
php
public function view($view, $data = array(), $auto_filter = null) { if ($this->active['path'] === null) { throw new \ThemeException('You must set an active theme.'); } return \View::forge($this->find_file($view), $data, $auto_filter); }
[ "public", "function", "view", "(", "$", "view", ",", "$", "data", "=", "array", "(", ")", ",", "$", "auto_filter", "=", "null", ")", "{", "if", "(", "$", "this", "->", "active", "[", "'path'", "]", "===", "null", ")", "{", "throw", "new", "\\", "ThemeException", "(", "'You must set an active theme.'", ")", ";", "}", "return", "\\", "View", "::", "forge", "(", "$", "this", "->", "find_file", "(", "$", "view", ")", ",", "$", "data", ",", "$", "auto_filter", ")", ";", "}" ]
Loads a view from the currently active theme, the fallback theme, or via the standard FuelPHP cascading file system for views @param string $view View name @param array $data View data @param bool $auto_filter Auto filter the view data @return View New View object
[ "Loads", "a", "view", "from", "the", "currently", "active", "theme", "the", "fallback", "theme", "or", "via", "the", "standard", "FuelPHP", "cascading", "file", "system", "for", "views" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L204-L212
10,499
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/theme.php
Theme.viewmodel
public function viewmodel($view, $method = 'view', $auto_filter = null) { return \Viewmodel::forge($view, $method, $auto_filter, $this->find_file($view)); }
php
public function viewmodel($view, $method = 'view', $auto_filter = null) { return \Viewmodel::forge($view, $method, $auto_filter, $this->find_file($view)); }
[ "public", "function", "viewmodel", "(", "$", "view", ",", "$", "method", "=", "'view'", ",", "$", "auto_filter", "=", "null", ")", "{", "return", "\\", "Viewmodel", "::", "forge", "(", "$", "view", ",", "$", "method", ",", "$", "auto_filter", ",", "$", "this", "->", "find_file", "(", "$", "view", ")", ")", ";", "}" ]
Loads a viewmodel, and have it use the view from the currently active theme, the fallback theme, or the standard FuelPHP cascading file system @param string ViewModel classname without View_ prefix or full classname @param string Method to execute @param bool $auto_filter Auto filter the view data @return View New View object @deprecated 1.8
[ "Loads", "a", "viewmodel", "and", "have", "it", "use", "the", "view", "from", "the", "currently", "active", "theme", "the", "fallback", "theme", "or", "the", "standard", "FuelPHP", "cascading", "file", "system" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L225-L228