id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
25,200
vpg/titon.utility
src/Titon/Utility/Validate.php
Validate.maxFilesize
public static function maxFilesize($input, $max) { if (static::file($input)) { $size = $input['size']; } else if (file_exists($input)) { $size = filesize($input); } else { return false; } return ($size <= Number::bytesFrom($max)); }
php
public static function maxFilesize($input, $max) { if (static::file($input)) { $size = $input['size']; } else if (file_exists($input)) { $size = filesize($input); } else { return false; } return ($size <= Number::bytesFrom($max)); }
[ "public", "static", "function", "maxFilesize", "(", "$", "input", ",", "$", "max", ")", "{", "if", "(", "static", "::", "file", "(", "$", "input", ")", ")", "{", "$", "size", "=", "$", "input", "[", "'size'", "]", ";", "}", "else", "if", "(", "file_exists", "(", "$", "input", ")", ")", "{", "$", "size", "=", "filesize", "(", "$", "input", ")", ";", "}", "else", "{", "return", "false", ";", "}", "return", "(", "$", "size", "<=", "Number", "::", "bytesFrom", "(", "$", "max", ")", ")", ";", "}" ]
Validate an images file size is below the maximum. @uses Titon\Utility\Number @param array $input @param int $max @return bool
[ "Validate", "an", "images", "file", "size", "is", "below", "the", "maximum", "." ]
8a77eb9e7b8baacf41cc25487289779d8319cd3a
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Validate.php#L546-L558
25,201
itkg/core
src/Itkg/Core/Command/DatabaseUpdate/Setup.php
Setup.createMigration
public function createMigration($script, $rollbackScript) { $this->releaseChecker->checkScript($script, $rollbackScript); if ($this->rollbackedFirst) { /* When rollback is needed first we invert script & rollback script */ list($rollbackScript, $script) = array($script, $rollbackScript); } $this->migrations[] = $this->migrationFactory->createMigration( $this->loader->load($script)->getQueries(), $this->loader->load($rollbackScript)->getQueries() ); return $this; }
php
public function createMigration($script, $rollbackScript) { $this->releaseChecker->checkScript($script, $rollbackScript); if ($this->rollbackedFirst) { /* When rollback is needed first we invert script & rollback script */ list($rollbackScript, $script) = array($script, $rollbackScript); } $this->migrations[] = $this->migrationFactory->createMigration( $this->loader->load($script)->getQueries(), $this->loader->load($rollbackScript)->getQueries() ); return $this; }
[ "public", "function", "createMigration", "(", "$", "script", ",", "$", "rollbackScript", ")", "{", "$", "this", "->", "releaseChecker", "->", "checkScript", "(", "$", "script", ",", "$", "rollbackScript", ")", ";", "if", "(", "$", "this", "->", "rollbackedFirst", ")", "{", "/* When rollback is needed first we invert script & rollback script */", "list", "(", "$", "rollbackScript", ",", "$", "script", ")", "=", "array", "(", "$", "script", ",", "$", "rollbackScript", ")", ";", "}", "$", "this", "->", "migrations", "[", "]", "=", "$", "this", "->", "migrationFactory", "->", "createMigration", "(", "$", "this", "->", "loader", "->", "load", "(", "$", "script", ")", "->", "getQueries", "(", ")", ",", "$", "this", "->", "loader", "->", "load", "(", "$", "rollbackScript", ")", "->", "getQueries", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Create a migration from SQL script & rollback script @param $script @param $rollbackScript @throws \InvalidArgumentException @return $this
[ "Create", "a", "migration", "from", "SQL", "script", "&", "rollback", "script" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseUpdate/Setup.php#L129-L144
25,202
itkg/core
src/Itkg/Core/Command/DatabaseUpdate/Setup.php
Setup.createMigrations
private function createMigrations() { $scripts = $this->locator->findScripts(); $rollbacks = $this->locator->findRollbackScripts(); $this->releaseChecker->checkScripts($scripts, $rollbacks); foreach ($scripts as $k => $script) { $this->createMigration($script, $rollbacks[$k]); } }
php
private function createMigrations() { $scripts = $this->locator->findScripts(); $rollbacks = $this->locator->findRollbackScripts(); $this->releaseChecker->checkScripts($scripts, $rollbacks); foreach ($scripts as $k => $script) { $this->createMigration($script, $rollbacks[$k]); } }
[ "private", "function", "createMigrations", "(", ")", "{", "$", "scripts", "=", "$", "this", "->", "locator", "->", "findScripts", "(", ")", ";", "$", "rollbacks", "=", "$", "this", "->", "locator", "->", "findRollbackScripts", "(", ")", ";", "$", "this", "->", "releaseChecker", "->", "checkScripts", "(", "$", "scripts", ",", "$", "rollbacks", ")", ";", "foreach", "(", "$", "scripts", "as", "$", "k", "=>", "$", "script", ")", "{", "$", "this", "->", "createMigration", "(", "$", "script", ",", "$", "rollbacks", "[", "$", "k", "]", ")", ";", "}", "}" ]
Create migrations from scripts & rollback files @return void @throws \RuntimeException @throws \LogicException
[ "Create", "migrations", "from", "scripts", "&", "rollback", "files" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseUpdate/Setup.php#L154-L164
25,203
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/MetaService.php
MetaService.get
public function get($key){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_META . Endpoints::META; $result = $this->authenticationService->getTransport()->fetch($url,array("key"=>$key)); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ $unwrapped = @json_decode($result['results']['value']); $value = $unwrapped === null ? $result['results']['value'] : $unwrapped; return array("value" => $value, "validity" => $result['results']['validity']); }else{ return null; } }
php
public function get($key){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_META . Endpoints::META; $result = $this->authenticationService->getTransport()->fetch($url,array("key"=>$key)); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ $unwrapped = @json_decode($result['results']['value']); $value = $unwrapped === null ? $result['results']['value'] : $unwrapped; return array("value" => $value, "validity" => $result['results']['validity']); }else{ return null; } }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_META", ".", "Endpoints", "::", "META", ";", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ",", "array", "(", "\"key\"", "=>", "$", "key", ")", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ")", "{", "$", "unwrapped", "=", "@", "json_decode", "(", "$", "result", "[", "'results'", "]", "[", "'value'", "]", ")", ";", "$", "value", "=", "$", "unwrapped", "===", "null", "?", "$", "result", "[", "'results'", "]", "[", "'value'", "]", ":", "$", "unwrapped", ";", "return", "array", "(", "\"value\"", "=>", "$", "value", ",", "\"validity\"", "=>", "$", "result", "[", "'results'", "]", "[", "'validity'", "]", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets the stored meta data for the key provided @param $key @return array
[ "Gets", "the", "stored", "meta", "data", "for", "the", "key", "provided" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/MetaService.php#L35-L47
25,204
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/MetaService.php
MetaService.add
public function add($key, $value, $valid_for_minutes = null){ if(is_object($value) || is_array($value)){ $value = json_encode($value); } $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_META . Endpoints::META; $result = $this->authenticationService->getTransport()->fetch($url,array("key"=>$key,"value"=>$value,"validity"=>$valid_for_minutes),'PUT',array(),0); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ return true; }else{ return false; } }
php
public function add($key, $value, $valid_for_minutes = null){ if(is_object($value) || is_array($value)){ $value = json_encode($value); } $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_META . Endpoints::META; $result = $this->authenticationService->getTransport()->fetch($url,array("key"=>$key,"value"=>$value,"validity"=>$valid_for_minutes),'PUT',array(),0); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ return true; }else{ return false; } }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ",", "$", "valid_for_minutes", "=", "null", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "||", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "json_encode", "(", "$", "value", ")", ";", "}", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_META", ".", "Endpoints", "::", "META", ";", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ",", "array", "(", "\"key\"", "=>", "$", "key", ",", "\"value\"", "=>", "$", "value", ",", "\"validity\"", "=>", "$", "valid_for_minutes", ")", ",", "'PUT'", ",", "array", "(", ")", ",", "0", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Adds or Updates meta data for the key provided @param $key @param $value @return bool
[ "Adds", "or", "Updates", "meta", "data", "for", "the", "key", "provided" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/MetaService.php#L55-L69
25,205
Wedeto/DB
src/Schema/Schema.php
Schema.loadCache
public function loadCache() { if (empty($this->name)) throw new DBException("Please provide a name for the schema when using the cache"); $cachemgr = CacheManager::getInstance(); $this->tables = $cachemgr->getCache('dbschema_' . $this->name); }
php
public function loadCache() { if (empty($this->name)) throw new DBException("Please provide a name for the schema when using the cache"); $cachemgr = CacheManager::getInstance(); $this->tables = $cachemgr->getCache('dbschema_' . $this->name); }
[ "public", "function", "loadCache", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "name", ")", ")", "throw", "new", "DBException", "(", "\"Please provide a name for the schema when using the cache\"", ")", ";", "$", "cachemgr", "=", "CacheManager", "::", "getInstance", "(", ")", ";", "$", "this", "->", "tables", "=", "$", "cachemgr", "->", "getCache", "(", "'dbschema_'", ".", "$", "this", "->", "name", ")", ";", "}" ]
Load the cache containing table definitions
[ "Load", "the", "cache", "containing", "table", "definitions" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Schema/Schema.php#L78-L85
25,206
Wedeto/DB
src/Schema/Schema.php
Schema.getTable
public function getTable($table_name) { if (!$this->tables->has('tables', $table_name)) { if ($this->db !== null) { $table = $this->db->loadTable($table_name); $this->tables->set('tables', $table_name, $table); } else throw new DBException("Table $table not ofund"); } return $this->tables->get('tables', $table_name); }
php
public function getTable($table_name) { if (!$this->tables->has('tables', $table_name)) { if ($this->db !== null) { $table = $this->db->loadTable($table_name); $this->tables->set('tables', $table_name, $table); } else throw new DBException("Table $table not ofund"); } return $this->tables->get('tables', $table_name); }
[ "public", "function", "getTable", "(", "$", "table_name", ")", "{", "if", "(", "!", "$", "this", "->", "tables", "->", "has", "(", "'tables'", ",", "$", "table_name", ")", ")", "{", "if", "(", "$", "this", "->", "db", "!==", "null", ")", "{", "$", "table", "=", "$", "this", "->", "db", "->", "loadTable", "(", "$", "table_name", ")", ";", "$", "this", "->", "tables", "->", "set", "(", "'tables'", ",", "$", "table_name", ",", "$", "table", ")", ";", "}", "else", "throw", "new", "DBException", "(", "\"Table $table not ofund\"", ")", ";", "}", "return", "$", "this", "->", "tables", "->", "get", "(", "'tables'", ",", "$", "table_name", ")", ";", "}" ]
Get a table definition from the schema
[ "Get", "a", "table", "definition", "from", "the", "schema" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Schema/Schema.php#L108-L122
25,207
Wedeto/DB
src/Schema/Schema.php
Schema.putTable
public function putTable(Table $table) { $this->tables->set('tables', $table->getName(), $table); return $this; }
php
public function putTable(Table $table) { $this->tables->set('tables', $table->getName(), $table); return $this; }
[ "public", "function", "putTable", "(", "Table", "$", "table", ")", "{", "$", "this", "->", "tables", "->", "set", "(", "'tables'", ",", "$", "table", "->", "getName", "(", ")", ",", "$", "table", ")", ";", "return", "$", "this", ";", "}" ]
Add a table to the schema @return Wedeto\DB\Schema\Schema Provides fluent interface
[ "Add", "a", "table", "to", "the", "schema" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Schema/Schema.php#L129-L133
25,208
Wedeto/DB
src/Schema/Schema.php
Schema.removeTable
public function removeTable($table) { if ($table instanceof Table) $table = $table->getName(); $this->tables->set('tables', $table, null); return $this; }
php
public function removeTable($table) { if ($table instanceof Table) $table = $table->getName(); $this->tables->set('tables', $table, null); return $this; }
[ "public", "function", "removeTable", "(", "$", "table", ")", "{", "if", "(", "$", "table", "instanceof", "Table", ")", "$", "table", "=", "$", "table", "->", "getName", "(", ")", ";", "$", "this", "->", "tables", "->", "set", "(", "'tables'", ",", "$", "table", ",", "null", ")", ";", "return", "$", "this", ";", "}" ]
Remove a schema from the table definition @param string|Table The table to remove @return Wedeto\DB\Schema\Schema Provides fluent interface
[ "Remove", "a", "schema", "from", "the", "table", "definition" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Schema/Schema.php#L140-L146
25,209
phata/widgetfy
src/Theme.php
Theme.stringTrim
public static function stringTrim(string $string, int $length): string { if ($length<16) return $string; if (strlen($string)>$length) { $str_head = substr($string, 0, $length-10); $str_tail = substr($string, -7, 7); return $str_head.'...'.$str_tail; } return $string; }
php
public static function stringTrim(string $string, int $length): string { if ($length<16) return $string; if (strlen($string)>$length) { $str_head = substr($string, 0, $length-10); $str_tail = substr($string, -7, 7); return $str_head.'...'.$str_tail; } return $string; }
[ "public", "static", "function", "stringTrim", "(", "string", "$", "string", ",", "int", "$", "length", ")", ":", "string", "{", "if", "(", "$", "length", "<", "16", ")", "return", "$", "string", ";", "if", "(", "strlen", "(", "$", "string", ")", ">", "$", "length", ")", "{", "$", "str_head", "=", "substr", "(", "$", "string", ",", "0", ",", "$", "length", "-", "10", ")", ";", "$", "str_tail", "=", "substr", "(", "$", "string", ",", "-", "7", ",", "7", ")", ";", "return", "$", "str_head", ".", "'...'", ".", "$", "str_tail", ";", "}", "return", "$", "string", ";", "}" ]
Helper function to make a non-unicode string shortter @param string $string The string to be trimmed @param int $length The targeted trimed length @return string trimmed string
[ "Helper", "function", "to", "make", "a", "non", "-", "unicode", "string", "shortter" ]
00102c35ec5267b42c627f1e34b8e64a7dd3590c
https://github.com/phata/widgetfy/blob/00102c35ec5267b42c627f1e34b8e64a7dd3590c/src/Theme.php#L65-L74
25,210
phata/widgetfy
src/Theme.php
Theme.renderBlockAttrs
public static function renderBlockAttrs(array $embed): string { // attributes to be rendered $classes = array(); $styles = array(); // shortcuts $d = &$embed['dimension']; // determine classes $classes[] = 'videoblock'; if ($d->dynamic) { $classes[] = 'videoblock-dynamic'; } // determine inline CSS style(s) // if scale model is no-scale, allow to "force dynamic" // by setting "dynamic" to TRUE if ($d->dynamic) { $styles[] = 'max-width:'.$d->width.'px'; } else { $styles[] = 'width: '.$d->width.'px'; } // render the attributes $class = implode(' ', $classes); $style = implode('; ', $styles) . (!empty($styles) ? ';' : ''); return 'class="'.$class.'" style="'.$style.'"'; }
php
public static function renderBlockAttrs(array $embed): string { // attributes to be rendered $classes = array(); $styles = array(); // shortcuts $d = &$embed['dimension']; // determine classes $classes[] = 'videoblock'; if ($d->dynamic) { $classes[] = 'videoblock-dynamic'; } // determine inline CSS style(s) // if scale model is no-scale, allow to "force dynamic" // by setting "dynamic" to TRUE if ($d->dynamic) { $styles[] = 'max-width:'.$d->width.'px'; } else { $styles[] = 'width: '.$d->width.'px'; } // render the attributes $class = implode(' ', $classes); $style = implode('; ', $styles) . (!empty($styles) ? ';' : ''); return 'class="'.$class.'" style="'.$style.'"'; }
[ "public", "static", "function", "renderBlockAttrs", "(", "array", "$", "embed", ")", ":", "string", "{", "// attributes to be rendered", "$", "classes", "=", "array", "(", ")", ";", "$", "styles", "=", "array", "(", ")", ";", "// shortcuts", "$", "d", "=", "&", "$", "embed", "[", "'dimension'", "]", ";", "// determine classes", "$", "classes", "[", "]", "=", "'videoblock'", ";", "if", "(", "$", "d", "->", "dynamic", ")", "{", "$", "classes", "[", "]", "=", "'videoblock-dynamic'", ";", "}", "// determine inline CSS style(s)", "// if scale model is no-scale, allow to \"force dynamic\"", "// by setting \"dynamic\" to TRUE", "if", "(", "$", "d", "->", "dynamic", ")", "{", "$", "styles", "[", "]", "=", "'max-width:'", ".", "$", "d", "->", "width", ".", "'px'", ";", "}", "else", "{", "$", "styles", "[", "]", "=", "'width: '", ".", "$", "d", "->", "width", ".", "'px'", ";", "}", "// render the attributes", "$", "class", "=", "implode", "(", "' '", ",", "$", "classes", ")", ";", "$", "style", "=", "implode", "(", "'; '", ",", "$", "styles", ")", ".", "(", "!", "empty", "(", "$", "styles", ")", "?", "';'", ":", "''", ")", ";", "return", "'class=\"'", ".", "$", "class", ".", "'\" style=\"'", ".", "$", "style", ".", "'\"'", ";", "}" ]
Helper funcion to template. Render attributes for .videoblock @param array $embed embed definition @return string HTTP attributes
[ "Helper", "funcion", "to", "template", ".", "Render", "attributes", "for", ".", "videoblock" ]
00102c35ec5267b42c627f1e34b8e64a7dd3590c
https://github.com/phata/widgetfy/blob/00102c35ec5267b42c627f1e34b8e64a7dd3590c/src/Theme.php#L82-L106
25,211
phata/widgetfy
src/Theme.php
Theme.renderWrapperAttrs
public static function renderWrapperAttrs(array $embed): string { // attributes to be rendered $classes = array(); $styles = array(); // shortcuts $d = &$embed['dimension']; // determine classes $classes[] = 'video-wrapper'; if ($d->dynamic) { $classes[] = 'wrap-'.$d->scale_model; } // determine inline CSS style(s) if ($d->dynamic && ($d->scale_model == 'scale-width-height')) { $styles[] = 'padding-bottom: ' . ($d->factor * 100) . '%;'; } // render the attributes $class = implode(' ', $classes); $style = implode('; ', $styles) . (!empty($styles) ? ';' : ''); return 'class="'.$class.'" style="'.$style.'"'; }
php
public static function renderWrapperAttrs(array $embed): string { // attributes to be rendered $classes = array(); $styles = array(); // shortcuts $d = &$embed['dimension']; // determine classes $classes[] = 'video-wrapper'; if ($d->dynamic) { $classes[] = 'wrap-'.$d->scale_model; } // determine inline CSS style(s) if ($d->dynamic && ($d->scale_model == 'scale-width-height')) { $styles[] = 'padding-bottom: ' . ($d->factor * 100) . '%;'; } // render the attributes $class = implode(' ', $classes); $style = implode('; ', $styles) . (!empty($styles) ? ';' : ''); return 'class="'.$class.'" style="'.$style.'"'; }
[ "public", "static", "function", "renderWrapperAttrs", "(", "array", "$", "embed", ")", ":", "string", "{", "// attributes to be rendered", "$", "classes", "=", "array", "(", ")", ";", "$", "styles", "=", "array", "(", ")", ";", "// shortcuts", "$", "d", "=", "&", "$", "embed", "[", "'dimension'", "]", ";", "// determine classes", "$", "classes", "[", "]", "=", "'video-wrapper'", ";", "if", "(", "$", "d", "->", "dynamic", ")", "{", "$", "classes", "[", "]", "=", "'wrap-'", ".", "$", "d", "->", "scale_model", ";", "}", "// determine inline CSS style(s)", "if", "(", "$", "d", "->", "dynamic", "&&", "(", "$", "d", "->", "scale_model", "==", "'scale-width-height'", ")", ")", "{", "$", "styles", "[", "]", "=", "'padding-bottom: '", ".", "(", "$", "d", "->", "factor", "*", "100", ")", ".", "'%;'", ";", "}", "// render the attributes", "$", "class", "=", "implode", "(", "' '", ",", "$", "classes", ")", ";", "$", "style", "=", "implode", "(", "'; '", ",", "$", "styles", ")", ".", "(", "!", "empty", "(", "$", "styles", ")", "?", "';'", ":", "''", ")", ";", "return", "'class=\"'", ".", "$", "class", ".", "'\" style=\"'", ".", "$", "style", ".", "'\"'", ";", "}" ]
Helper funcion to template. Render attributes for .videowrapper @param array $embed embed definition @return string HTTP attributes
[ "Helper", "funcion", "to", "template", ".", "Render", "attributes", "for", ".", "videowrapper" ]
00102c35ec5267b42c627f1e34b8e64a7dd3590c
https://github.com/phata/widgetfy/blob/00102c35ec5267b42c627f1e34b8e64a7dd3590c/src/Theme.php#L116-L136
25,212
phata/widgetfy
src/Theme.php
Theme.toHTML
public static function toHTML(array $embed, bool $inlineStyle=false): string { static $css_done; $css = ''; // use object dimension as dimension reference $d = &$embed['dimension']; // link to the stylesheet on first run if ($inlineStyle && !isset($css_done)) { $css = '<style>' . Theme::style() . '</style>'; $css_done = true; } ob_start(); include __DIR__ . '/Theme/theme.tpl.php'; $codeblock = ob_get_contents(); ob_end_clean(); return preg_replace('/[\t ]*[\r\n]+[\t ]*/', ' ', $css.$codeblock); }
php
public static function toHTML(array $embed, bool $inlineStyle=false): string { static $css_done; $css = ''; // use object dimension as dimension reference $d = &$embed['dimension']; // link to the stylesheet on first run if ($inlineStyle && !isset($css_done)) { $css = '<style>' . Theme::style() . '</style>'; $css_done = true; } ob_start(); include __DIR__ . '/Theme/theme.tpl.php'; $codeblock = ob_get_contents(); ob_end_clean(); return preg_replace('/[\t ]*[\r\n]+[\t ]*/', ' ', $css.$codeblock); }
[ "public", "static", "function", "toHTML", "(", "array", "$", "embed", ",", "bool", "$", "inlineStyle", "=", "false", ")", ":", "string", "{", "static", "$", "css_done", ";", "$", "css", "=", "''", ";", "// use object dimension as dimension reference", "$", "d", "=", "&", "$", "embed", "[", "'dimension'", "]", ";", "// link to the stylesheet on first run", "if", "(", "$", "inlineStyle", "&&", "!", "isset", "(", "$", "css_done", ")", ")", "{", "$", "css", "=", "'<style>'", ".", "Theme", "::", "style", "(", ")", ".", "'</style>'", ";", "$", "css_done", "=", "true", ";", "}", "ob_start", "(", ")", ";", "include", "__DIR__", ".", "'/Theme/theme.tpl.php'", ";", "$", "codeblock", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "preg_replace", "(", "'/[\\t ]*[\\r\\n]+[\\t ]*/'", ",", "' '", ",", "$", "css", ".", "$", "codeblock", ")", ";", "}" ]
Theme the given embed information array into HTML string @param array $embed Embed information produced by Core::translate function. @param boolean $inlineStyle Whether the returned string should include default stylesheet. Default to be false. @return string
[ "Theme", "the", "given", "embed", "information", "array", "into", "HTML", "string" ]
00102c35ec5267b42c627f1e34b8e64a7dd3590c
https://github.com/phata/widgetfy/blob/00102c35ec5267b42c627f1e34b8e64a7dd3590c/src/Theme.php#L148-L167
25,213
PenoaksDev/Milky-Framework
src/Milky/Annotations/DocParser.php
DocParser.classExists
private function classExists( $fqcn ) { if ( isset( $this->classExists[$fqcn] ) ) return $this->classExists[$fqcn]; // first check if the class already exists, maybe loaded through another AnnotationReader if ( class_exists( $fqcn ) ) return $this->classExists[$fqcn] = true; return false; }
php
private function classExists( $fqcn ) { if ( isset( $this->classExists[$fqcn] ) ) return $this->classExists[$fqcn]; // first check if the class already exists, maybe loaded through another AnnotationReader if ( class_exists( $fqcn ) ) return $this->classExists[$fqcn] = true; return false; }
[ "private", "function", "classExists", "(", "$", "fqcn", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "classExists", "[", "$", "fqcn", "]", ")", ")", "return", "$", "this", "->", "classExists", "[", "$", "fqcn", "]", ";", "// first check if the class already exists, maybe loaded through another AnnotationReader", "if", "(", "class_exists", "(", "$", "fqcn", ")", ")", "return", "$", "this", "->", "classExists", "[", "$", "fqcn", "]", "=", "true", ";", "return", "false", ";", "}" ]
Attempts to check if a class exists or not. @param string $fqcn @return boolean
[ "Attempts", "to", "check", "if", "a", "class", "exists", "or", "not", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Annotations/DocParser.php#L321-L331
25,214
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Relations/BelongsToMany.php
BelongsToMany.wherePivotIn
public function wherePivotIn($column, $values, $boolean = 'and', $not = false) { $this->pivotWheres[] = func_get_args(); return $this->whereIn($this->table.'.'.$column, $values, $boolean, $not); }
php
public function wherePivotIn($column, $values, $boolean = 'and', $not = false) { $this->pivotWheres[] = func_get_args(); return $this->whereIn($this->table.'.'.$column, $values, $boolean, $not); }
[ "public", "function", "wherePivotIn", "(", "$", "column", ",", "$", "values", ",", "$", "boolean", "=", "'and'", ",", "$", "not", "=", "false", ")", "{", "$", "this", "->", "pivotWheres", "[", "]", "=", "func_get_args", "(", ")", ";", "return", "$", "this", "->", "whereIn", "(", "$", "this", "->", "table", ".", "'.'", ".", "$", "column", ",", "$", "values", ",", "$", "boolean", ",", "$", "not", ")", ";", "}" ]
Set a "where in" clause for a pivot table column. @param string $column @param mixed $values @param string $boolean @param bool $not @return BelongsToMany
[ "Set", "a", "where", "in", "clause", "for", "a", "pivot", "table", "column", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Relations/BelongsToMany.php#L131-L136
25,215
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Relations/BelongsToMany.php
BelongsToMany.findOrNew
public function findOrNew($id, $columns = ['*']) { if (is_null($instance = $this->find($id, $columns))) { $instance = $this->getRelated()->newInstance(); } return $instance; }
php
public function findOrNew($id, $columns = ['*']) { if (is_null($instance = $this->find($id, $columns))) { $instance = $this->getRelated()->newInstance(); } return $instance; }
[ "public", "function", "findOrNew", "(", "$", "id", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "is_null", "(", "$", "instance", "=", "$", "this", "->", "find", "(", "$", "id", ",", "$", "columns", ")", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getRelated", "(", ")", "->", "newInstance", "(", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Find a related model by its primary key or return new instance of the related model. @param mixed $id @param array $columns @return Model
[ "Find", "a", "related", "model", "by", "its", "primary", "key", "or", "return", "new", "instance", "of", "the", "related", "model", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Relations/BelongsToMany.php#L684-L691
25,216
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Relations/BelongsToMany.php
BelongsToMany.attachNew
protected function attachNew(array $records, array $current, $touch = true) { $changes = ['attached' => [], 'updated' => []]; foreach ($records as $id => $attributes) { // If the ID is not in the list of existing pivot IDs, we will insert a new pivot // record, otherwise, we will just update this existing record on this joining // table, so that the developers will easily update these records pain free. if (! in_array($id, $current)) { $this->attach($id, $attributes, $touch); $changes['attached'][] = is_numeric($id) ? (int) $id : (string) $id; } // Now we'll try to update an existing pivot record with the attributes that were // given to the method. If the model is actually updated we will add it to the // list of updated pivot records so we return them back out to the consumer. elseif (count($attributes) > 0 && $this->updateExistingPivot($id, $attributes, $touch)) { $changes['updated'][] = is_numeric($id) ? (int) $id : (string) $id; } } return $changes; }
php
protected function attachNew(array $records, array $current, $touch = true) { $changes = ['attached' => [], 'updated' => []]; foreach ($records as $id => $attributes) { // If the ID is not in the list of existing pivot IDs, we will insert a new pivot // record, otherwise, we will just update this existing record on this joining // table, so that the developers will easily update these records pain free. if (! in_array($id, $current)) { $this->attach($id, $attributes, $touch); $changes['attached'][] = is_numeric($id) ? (int) $id : (string) $id; } // Now we'll try to update an existing pivot record with the attributes that were // given to the method. If the model is actually updated we will add it to the // list of updated pivot records so we return them back out to the consumer. elseif (count($attributes) > 0 && $this->updateExistingPivot($id, $attributes, $touch)) { $changes['updated'][] = is_numeric($id) ? (int) $id : (string) $id; } } return $changes; }
[ "protected", "function", "attachNew", "(", "array", "$", "records", ",", "array", "$", "current", ",", "$", "touch", "=", "true", ")", "{", "$", "changes", "=", "[", "'attached'", "=>", "[", "]", ",", "'updated'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "records", "as", "$", "id", "=>", "$", "attributes", ")", "{", "// If the ID is not in the list of existing pivot IDs, we will insert a new pivot", "// record, otherwise, we will just update this existing record on this joining", "// table, so that the developers will easily update these records pain free.", "if", "(", "!", "in_array", "(", "$", "id", ",", "$", "current", ")", ")", "{", "$", "this", "->", "attach", "(", "$", "id", ",", "$", "attributes", ",", "$", "touch", ")", ";", "$", "changes", "[", "'attached'", "]", "[", "]", "=", "is_numeric", "(", "$", "id", ")", "?", "(", "int", ")", "$", "id", ":", "(", "string", ")", "$", "id", ";", "}", "// Now we'll try to update an existing pivot record with the attributes that were", "// given to the method. If the model is actually updated we will add it to the", "// list of updated pivot records so we return them back out to the consumer.", "elseif", "(", "count", "(", "$", "attributes", ")", ">", "0", "&&", "$", "this", "->", "updateExistingPivot", "(", "$", "id", ",", "$", "attributes", ",", "$", "touch", ")", ")", "{", "$", "changes", "[", "'updated'", "]", "[", "]", "=", "is_numeric", "(", "$", "id", ")", "?", "(", "int", ")", "$", "id", ":", "(", "string", ")", "$", "id", ";", "}", "}", "return", "$", "changes", ";", "}" ]
Attach all of the IDs that aren't in the current array. @param array $records @param array $current @param bool $touch @return array
[ "Attach", "all", "of", "the", "IDs", "that", "aren", "t", "in", "the", "current", "array", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Relations/BelongsToMany.php#L869-L893
25,217
koolkode/stream
src/Stream.php
Stream.fillBuffer
public static function fillBuffer(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } $buffer = ''; while(!$stream->eof() && strlen($buffer) < $bufferSize) { $buffer .= $stream->read($bufferSize - strlen($buffer)); } return $buffer; }
php
public static function fillBuffer(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } $buffer = ''; while(!$stream->eof() && strlen($buffer) < $bufferSize) { $buffer .= $stream->read($bufferSize - strlen($buffer)); } return $buffer; }
[ "public", "static", "function", "fillBuffer", "(", "StreamInterface", "$", "stream", ",", "$", "bufferSize", "=", "8192", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Stream is not readable: %s'", ",", "get_class", "(", "$", "stream", ")", ")", ")", ";", "}", "$", "buffer", "=", "''", ";", "while", "(", "!", "$", "stream", "->", "eof", "(", ")", "&&", "strlen", "(", "$", "buffer", ")", "<", "$", "bufferSize", ")", "{", "$", "buffer", ".=", "$", "stream", "->", "read", "(", "$", "bufferSize", "-", "strlen", "(", "$", "buffer", ")", ")", ";", "}", "return", "$", "buffer", ";", "}" ]
Read contents from the given input stream until EOF or the specified buffer is full. @param StreamInterface $stream @param int $bufferSize @return string @throws \InvalidArgumentException When the stream is not readable.
[ "Read", "contents", "from", "the", "given", "input", "stream", "until", "EOF", "or", "the", "specified", "buffer", "is", "full", "." ]
05e83efd76e1cb9e40a972711986b4a7e38bc141
https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/Stream.php#L32-L47
25,218
koolkode/stream
src/Stream.php
Stream.reader
public static function reader(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } while(!$stream->eof()) { yield $stream->read($bufferSize); } }
php
public static function reader(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } while(!$stream->eof()) { yield $stream->read($bufferSize); } }
[ "public", "static", "function", "reader", "(", "StreamInterface", "$", "stream", ",", "$", "bufferSize", "=", "8192", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Stream is not readable: %s'", ",", "get_class", "(", "$", "stream", ")", ")", ")", ";", "}", "while", "(", "!", "$", "stream", "->", "eof", "(", ")", ")", "{", "yield", "$", "stream", "->", "read", "(", "$", "bufferSize", ")", ";", "}", "}" ]
Turn a stream into an iterator. @param StreamInterface $stream @param int $bufferSize @return \Iterator @throws \InvalidArgumentException When the stream is not readable.
[ "Turn", "a", "stream", "into", "an", "iterator", "." ]
05e83efd76e1cb9e40a972711986b4a7e38bc141
https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/Stream.php#L58-L69
25,219
koolkode/stream
src/Stream.php
Stream.bufferedReader
public static function bufferedReader(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } $buffer = ''; while(!$stream->eof()) { $buffer .= $stream->read($bufferSize); while(strlen($buffer) >= $bufferSize) { yield (string)substr($buffer, 0, $bufferSize); $buffer = (string)substr($buffer, $bufferSize); } } if($buffer !== '') { yield $buffer; } }
php
public static function bufferedReader(StreamInterface $stream, $bufferSize = 8192) { if(!$stream->isReadable()) { throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream))); } $buffer = ''; while(!$stream->eof()) { $buffer .= $stream->read($bufferSize); while(strlen($buffer) >= $bufferSize) { yield (string)substr($buffer, 0, $bufferSize); $buffer = (string)substr($buffer, $bufferSize); } } if($buffer !== '') { yield $buffer; } }
[ "public", "static", "function", "bufferedReader", "(", "StreamInterface", "$", "stream", ",", "$", "bufferSize", "=", "8192", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Stream is not readable: %s'", ",", "get_class", "(", "$", "stream", ")", ")", ")", ";", "}", "$", "buffer", "=", "''", ";", "while", "(", "!", "$", "stream", "->", "eof", "(", ")", ")", "{", "$", "buffer", ".=", "$", "stream", "->", "read", "(", "$", "bufferSize", ")", ";", "while", "(", "strlen", "(", "$", "buffer", ")", ">=", "$", "bufferSize", ")", "{", "yield", "(", "string", ")", "substr", "(", "$", "buffer", ",", "0", ",", "$", "bufferSize", ")", ";", "$", "buffer", "=", "(", "string", ")", "substr", "(", "$", "buffer", ",", "$", "bufferSize", ")", ";", "}", "}", "if", "(", "$", "buffer", "!==", "''", ")", "{", "yield", "$", "buffer", ";", "}", "}" ]
Turn a stream into an iterator returning even-sized results. @param StreamInterface $stream @param int $bufferSize @return \Iterator @throws \InvalidArgumentException When the stream is not readable.
[ "Turn", "a", "stream", "into", "an", "iterator", "returning", "even", "-", "sized", "results", "." ]
05e83efd76e1cb9e40a972711986b4a7e38bc141
https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/Stream.php#L80-L105
25,220
koolkode/stream
src/Stream.php
Stream.pipe
public static function pipe(StreamInterface $in, StreamInterface $out, $chunkSize = 8192) { if(!$in->isReadable()) { throw new \InvalidArgumentException(sprintf('Input stream is not readable: %s', get_class($in))); } if(!$out->isWritable()) { throw new \InvalidArgumentException(sprintf('Output stream is not writable: %s', get_class($out))); } $size = 0; while(!$in->eof()) { $size += $out->write($in->read($chunkSize)); } return $size; }
php
public static function pipe(StreamInterface $in, StreamInterface $out, $chunkSize = 8192) { if(!$in->isReadable()) { throw new \InvalidArgumentException(sprintf('Input stream is not readable: %s', get_class($in))); } if(!$out->isWritable()) { throw new \InvalidArgumentException(sprintf('Output stream is not writable: %s', get_class($out))); } $size = 0; while(!$in->eof()) { $size += $out->write($in->read($chunkSize)); } return $size; }
[ "public", "static", "function", "pipe", "(", "StreamInterface", "$", "in", ",", "StreamInterface", "$", "out", ",", "$", "chunkSize", "=", "8192", ")", "{", "if", "(", "!", "$", "in", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Input stream is not readable: %s'", ",", "get_class", "(", "$", "in", ")", ")", ")", ";", "}", "if", "(", "!", "$", "out", "->", "isWritable", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Output stream is not writable: %s'", ",", "get_class", "(", "$", "out", ")", ")", ")", ";", "}", "$", "size", "=", "0", ";", "while", "(", "!", "$", "in", "->", "eof", "(", ")", ")", "{", "$", "size", "+=", "$", "out", "->", "write", "(", "$", "in", "->", "read", "(", "$", "chunkSize", ")", ")", ";", "}", "return", "$", "size", ";", "}" ]
Pipe data from an input stream into an output stream. @param StreamInterface $in @param StreamInterface $out @param int $chunkSize Maximum chunk size being used during copy. @return int Number of bytes being copied. @throws \InvalidArgumentException When input stream is not readable or output stream is not writable.
[ "Pipe", "data", "from", "an", "input", "stream", "into", "an", "output", "stream", "." ]
05e83efd76e1cb9e40a972711986b4a7e38bc141
https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/Stream.php#L117-L137
25,221
Danack/Jig
src/Jig/Jig.php
Jig.deleteCompiledFile
public function deleteCompiledFile($templateName) { $className = $this->jigConverter->getClassNameFromFilename($templateName); $compileFilename = $this->jigConfig->getCompiledFilenameFromClassname($className); $deleted = @unlink($compileFilename); return $deleted; }
php
public function deleteCompiledFile($templateName) { $className = $this->jigConverter->getClassNameFromFilename($templateName); $compileFilename = $this->jigConfig->getCompiledFilenameFromClassname($className); $deleted = @unlink($compileFilename); return $deleted; }
[ "public", "function", "deleteCompiledFile", "(", "$", "templateName", ")", "{", "$", "className", "=", "$", "this", "->", "jigConverter", "->", "getClassNameFromFilename", "(", "$", "templateName", ")", ";", "$", "compileFilename", "=", "$", "this", "->", "jigConfig", "->", "getCompiledFilenameFromClassname", "(", "$", "className", ")", ";", "$", "deleted", "=", "@", "unlink", "(", "$", "compileFilename", ")", ";", "return", "$", "deleted", ";", "}" ]
Delete the compiled version of a template. @param $templateName @return bool
[ "Delete", "the", "compiled", "version", "of", "a", "template", "." ]
b11106bc7d634add9873bf246eda1dadb059ed7a
https://github.com/Danack/Jig/blob/b11106bc7d634add9873bf246eda1dadb059ed7a/src/Jig/Jig.php#L78-L85
25,222
ekyna/Table
Bridge/Doctrine/ORM/Source/EntitySource.php
EntitySource.setQueryBuilderInitializer
public function setQueryBuilderInitializer(\Closure $initializer = null) { if (!is_null($initializer)) { $this->validateQueryBuilderInitializer($initializer); } $this->queryBuilderInitializer = $initializer; return $this; }
php
public function setQueryBuilderInitializer(\Closure $initializer = null) { if (!is_null($initializer)) { $this->validateQueryBuilderInitializer($initializer); } $this->queryBuilderInitializer = $initializer; return $this; }
[ "public", "function", "setQueryBuilderInitializer", "(", "\\", "Closure", "$", "initializer", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "initializer", ")", ")", "{", "$", "this", "->", "validateQueryBuilderInitializer", "(", "$", "initializer", ")", ";", "}", "$", "this", "->", "queryBuilderInitializer", "=", "$", "initializer", ";", "return", "$", "this", ";", "}" ]
Sets the query builder initializer. A closure with the query builder as first argument and the root alias as the second argument: function (QueryBuilder $qb, $alias) { } @param \Closure|null $initializer @return EntitySource
[ "Sets", "the", "query", "builder", "initializer", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Bridge/Doctrine/ORM/Source/EntitySource.php#L73-L82
25,223
ekyna/Table
Bridge/Doctrine/ORM/Source/EntitySource.php
EntitySource.validateQueryBuilderInitializer
private function validateQueryBuilderInitializer(\Closure $initializer) { $reflection = new \ReflectionFunction($initializer); $parameters = $reflection->getParameters(); if (2 !== count($parameters)) { throw new InvalidArgumentException("The query builder initializer must have two and only two arguments."); } $class = $parameters[0]->getClass(); if (!$class || $class->getName() !== QueryBuilder::class) { throw new InvalidArgumentException(sprintf( "The query builder initializer's first argument must be type hinted to the %s class.", QueryBuilder::class )); } if (!in_array($parameters[1]->getType(), [null, 'string'], true)) { throw new InvalidArgumentException(sprintf( "The query builder initializer's second must be type hinted to 'string'.", QueryBuilder::class )); } }
php
private function validateQueryBuilderInitializer(\Closure $initializer) { $reflection = new \ReflectionFunction($initializer); $parameters = $reflection->getParameters(); if (2 !== count($parameters)) { throw new InvalidArgumentException("The query builder initializer must have two and only two arguments."); } $class = $parameters[0]->getClass(); if (!$class || $class->getName() !== QueryBuilder::class) { throw new InvalidArgumentException(sprintf( "The query builder initializer's first argument must be type hinted to the %s class.", QueryBuilder::class )); } if (!in_array($parameters[1]->getType(), [null, 'string'], true)) { throw new InvalidArgumentException(sprintf( "The query builder initializer's second must be type hinted to 'string'.", QueryBuilder::class )); } }
[ "private", "function", "validateQueryBuilderInitializer", "(", "\\", "Closure", "$", "initializer", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "initializer", ")", ";", "$", "parameters", "=", "$", "reflection", "->", "getParameters", "(", ")", ";", "if", "(", "2", "!==", "count", "(", "$", "parameters", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"The query builder initializer must have two and only two arguments.\"", ")", ";", "}", "$", "class", "=", "$", "parameters", "[", "0", "]", "->", "getClass", "(", ")", ";", "if", "(", "!", "$", "class", "||", "$", "class", "->", "getName", "(", ")", "!==", "QueryBuilder", "::", "class", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"The query builder initializer's first argument must be type hinted to the %s class.\"", ",", "QueryBuilder", "::", "class", ")", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "parameters", "[", "1", "]", "->", "getType", "(", ")", ",", "[", "null", ",", "'string'", "]", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"The query builder initializer's second must be type hinted to 'string'.\"", ",", "QueryBuilder", "::", "class", ")", ")", ";", "}", "}" ]
Validates the query builder initializer. @param \Closure $initializer @throws InvalidArgumentException
[ "Validates", "the", "query", "builder", "initializer", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Bridge/Doctrine/ORM/Source/EntitySource.php#L91-L114
25,224
ValkSystems/bootbuilder
src/bootbuilder/Form.php
Form.addAll
public function addAll() { if(func_num_args() > 0) { for($i = 0; $i < func_num_args(); $i++) { if(func_get_arg($i) instanceof \bootbuilder\Controls\Control){ array_push($this->controls, func_get_arg($i)); } } } }
php
public function addAll() { if(func_num_args() > 0) { for($i = 0; $i < func_num_args(); $i++) { if(func_get_arg($i) instanceof \bootbuilder\Controls\Control){ array_push($this->controls, func_get_arg($i)); } } } }
[ "public", "function", "addAll", "(", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "0", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "func_num_args", "(", ")", ";", "$", "i", "++", ")", "{", "if", "(", "func_get_arg", "(", "$", "i", ")", "instanceof", "\\", "bootbuilder", "\\", "Controls", "\\", "Control", ")", "{", "array_push", "(", "$", "this", "->", "controls", ",", "func_get_arg", "(", "$", "i", ")", ")", ";", "}", "}", "}", "}" ]
Add multiple controls to form @param \BootBuilder\Controls\Control $control,... Multiple controls
[ "Add", "multiple", "controls", "to", "form" ]
7601a403f42eba47ce4cf02a3c852d5196b1d860
https://github.com/ValkSystems/bootbuilder/blob/7601a403f42eba47ce4cf02a3c852d5196b1d860/src/bootbuilder/Form.php#L72-L80
25,225
ValkSystems/bootbuilder
src/bootbuilder/Form.php
Form.replaceControl
public function replaceControl($nr, $control) { if(isset($this->controls[$nr])) { $this->controls[$nr] = $control; } }
php
public function replaceControl($nr, $control) { if(isset($this->controls[$nr])) { $this->controls[$nr] = $control; } }
[ "public", "function", "replaceControl", "(", "$", "nr", ",", "$", "control", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "controls", "[", "$", "nr", "]", ")", ")", "{", "$", "this", "->", "controls", "[", "$", "nr", "]", "=", "$", "control", ";", "}", "}" ]
Replace current control in array with new one @param int $nr @param mixed $control
[ "Replace", "current", "control", "in", "array", "with", "new", "one" ]
7601a403f42eba47ce4cf02a3c852d5196b1d860
https://github.com/ValkSystems/bootbuilder/blob/7601a403f42eba47ce4cf02a3c852d5196b1d860/src/bootbuilder/Form.php#L143-L147
25,226
ValkSystems/bootbuilder
src/bootbuilder/Form.php
Form.parseParameters
public function parseParameters($parameters) { for($i = 0; $i < count($this->controls); $i++) { $this->controls[$i] = $this->parseParameterControl($this->controls[$i], $parameters); } }
php
public function parseParameters($parameters) { for($i = 0; $i < count($this->controls); $i++) { $this->controls[$i] = $this->parseParameterControl($this->controls[$i], $parameters); } }
[ "public", "function", "parseParameters", "(", "$", "parameters", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "controls", ")", ";", "$", "i", "++", ")", "{", "$", "this", "->", "controls", "[", "$", "i", "]", "=", "$", "this", "->", "parseParameterControl", "(", "$", "this", "->", "controls", "[", "$", "i", "]", ",", "$", "parameters", ")", ";", "}", "}" ]
Parse Posted Parameters into controls @param mixed $parameters
[ "Parse", "Posted", "Parameters", "into", "controls" ]
7601a403f42eba47ce4cf02a3c852d5196b1d860
https://github.com/ValkSystems/bootbuilder/blob/7601a403f42eba47ce4cf02a3c852d5196b1d860/src/bootbuilder/Form.php#L185-L189
25,227
ValkSystems/bootbuilder
src/bootbuilder/Form.php
Form.save
public function save($replace = true, $prepare = true) { $this->add(new \bootbuilder\Controls\Hidden("bootbuilder-form", $this->id)); if($replace) { \bootbuilder\Validation\Validator::clean(); } \bootbuilder\Validation\Validator::save($this, $this->id, $prepare); }
php
public function save($replace = true, $prepare = true) { $this->add(new \bootbuilder\Controls\Hidden("bootbuilder-form", $this->id)); if($replace) { \bootbuilder\Validation\Validator::clean(); } \bootbuilder\Validation\Validator::save($this, $this->id, $prepare); }
[ "public", "function", "save", "(", "$", "replace", "=", "true", ",", "$", "prepare", "=", "true", ")", "{", "$", "this", "->", "add", "(", "new", "\\", "bootbuilder", "\\", "Controls", "\\", "Hidden", "(", "\"bootbuilder-form\"", ",", "$", "this", "->", "id", ")", ")", ";", "if", "(", "$", "replace", ")", "{", "\\", "bootbuilder", "\\", "Validation", "\\", "Validator", "::", "clean", "(", ")", ";", "}", "\\", "bootbuilder", "\\", "Validation", "\\", "Validator", "::", "save", "(", "$", "this", ",", "$", "this", "->", "id", ",", "$", "prepare", ")", ";", "}" ]
Save form for validation @param boolean $replace set false if you have multiple forms on one page @param boolean $prepare prepare session, false on unittesting
[ "Save", "form", "for", "validation" ]
7601a403f42eba47ce4cf02a3c852d5196b1d860
https://github.com/ValkSystems/bootbuilder/blob/7601a403f42eba47ce4cf02a3c852d5196b1d860/src/bootbuilder/Form.php#L226-L234
25,228
Saritasa/php-eloquent-custom
src/Utils/Query.php
Query.captureQueries
public static function captureQueries(\Closure $closure) { DB::enableQueryLog(); $closure(); $logs = DB::getQueryLog(); return array_map(function ($log) { return static::inlineBindings($log['query'], $log['bindings']); }, $logs); }
php
public static function captureQueries(\Closure $closure) { DB::enableQueryLog(); $closure(); $logs = DB::getQueryLog(); return array_map(function ($log) { return static::inlineBindings($log['query'], $log['bindings']); }, $logs); }
[ "public", "static", "function", "captureQueries", "(", "\\", "Closure", "$", "closure", ")", "{", "DB", "::", "enableQueryLog", "(", ")", ";", "$", "closure", "(", ")", ";", "$", "logs", "=", "DB", "::", "getQueryLog", "(", ")", ";", "return", "array_map", "(", "function", "(", "$", "log", ")", "{", "return", "static", "::", "inlineBindings", "(", "$", "log", "[", "'query'", "]", ",", "$", "log", "[", "'bindings'", "]", ")", ";", "}", ",", "$", "logs", ")", ";", "}" ]
Capture SQL queries, called via Eloquent inside argument closure @param \Closure $closure function, that contains DB invocations @return array
[ "Capture", "SQL", "queries", "called", "via", "Eloquent", "inside", "argument", "closure" ]
54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a
https://github.com/Saritasa/php-eloquent-custom/blob/54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a/src/Utils/Query.php#L17-L25
25,229
Saritasa/php-eloquent-custom
src/Utils/Query.php
Query.plainSql
public static function plainSql($query) { $query = static::getBaseQuery($query); return self::inlineBindings($query->toSql(), $query->getBindings()); }
php
public static function plainSql($query) { $query = static::getBaseQuery($query); return self::inlineBindings($query->toSql(), $query->getBindings()); }
[ "public", "static", "function", "plainSql", "(", "$", "query", ")", "{", "$", "query", "=", "static", "::", "getBaseQuery", "(", "$", "query", ")", ";", "return", "self", "::", "inlineBindings", "(", "$", "query", "->", "toSql", "(", ")", ",", "$", "query", "->", "getBindings", "(", ")", ")", ";", "}" ]
Present query builder as plain SQL, including inline parameter values @param QueryBuilder|EloquentBuilder $query Query buiilder @return string
[ "Present", "query", "builder", "as", "plain", "SQL", "including", "inline", "parameter", "values" ]
54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a
https://github.com/Saritasa/php-eloquent-custom/blob/54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a/src/Utils/Query.php#L55-L59
25,230
Xsaven/laravel-intelect-admin
src/Addons/Modules/Generators/FromModuleGenerator.php
FromModuleGenerator.generateModuleJsonFile
private function generateModuleJsonFile() { $path = $this->module->getModulePath($this->getName()) . 'module.json'; if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } $this->filesystem->put($path, $this->getStubContents('json')); }
php
private function generateModuleJsonFile() { $path = $this->module->getModulePath($this->getName()) . 'module.json'; if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } $this->filesystem->put($path, $this->getStubContents('json')); }
[ "private", "function", "generateModuleJsonFile", "(", ")", "{", "$", "path", "=", "$", "this", "->", "module", "->", "getModulePath", "(", "$", "this", "->", "getName", "(", ")", ")", ".", "'module.json'", ";", "if", "(", "!", "$", "this", "->", "filesystem", "->", "isDirectory", "(", "$", "dir", "=", "dirname", "(", "$", "path", ")", ")", ")", "{", "$", "this", "->", "filesystem", "->", "makeDirectory", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "$", "this", "->", "filesystem", "->", "put", "(", "$", "path", ",", "$", "this", "->", "getStubContents", "(", "'json'", ")", ")", ";", "}" ]
Generate the module.json file
[ "Generate", "the", "module", ".", "json", "file" ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/Modules/Generators/FromModuleGenerator.php#L376-L385
25,231
Erebot/Timer
src/Timer.php
Timer.cleanup
protected function cleanup() { if ($this->resource) { proc_terminate($this->resource); } if (is_resource($this->handle)) { fclose($this->handle); } $this->handle = null; $this->resource = null; }
php
protected function cleanup() { if ($this->resource) { proc_terminate($this->resource); } if (is_resource($this->handle)) { fclose($this->handle); } $this->handle = null; $this->resource = null; }
[ "protected", "function", "cleanup", "(", ")", "{", "if", "(", "$", "this", "->", "resource", ")", "{", "proc_terminate", "(", "$", "this", "->", "resource", ")", ";", "}", "if", "(", "is_resource", "(", "$", "this", "->", "handle", ")", ")", "{", "fclose", "(", "$", "this", "->", "handle", ")", ";", "}", "$", "this", "->", "handle", "=", "null", ";", "$", "this", "->", "resource", "=", "null", ";", "}" ]
Performs cleanup duties so that no traces of this timer having ever been used remain.
[ "Performs", "cleanup", "duties", "so", "that", "no", "traces", "of", "this", "timer", "having", "ever", "been", "used", "remain", "." ]
cd04905d859221f9e216deba25693bc8906441f5
https://github.com/Erebot/Timer/blob/cd04905d859221f9e216deba25693bc8906441f5/src/Timer.php#L123-L135
25,232
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.setAttribute
public function setAttribute($name, $value) { if(strlen($name) < 1) { throw new HTMLTagException("Attribute name is empty"); } $this->tag_attributes[strtolower($name)] = $value; return $this; }
php
public function setAttribute($name, $value) { if(strlen($name) < 1) { throw new HTMLTagException("Attribute name is empty"); } $this->tag_attributes[strtolower($name)] = $value; return $this; }
[ "public", "function", "setAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "strlen", "(", "$", "name", ")", "<", "1", ")", "{", "throw", "new", "HTMLTagException", "(", "\"Attribute name is empty\"", ")", ";", "}", "$", "this", "->", "tag_attributes", "[", "strtolower", "(", "$", "name", ")", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets the attribute of this tag to the value given, a value of NULL will list the attribute with no ="value" after @param string $name @param string|null $value @return HTMLTag @throws HTMLTagException
[ "Sets", "the", "attribute", "of", "this", "tag", "to", "the", "value", "given", "a", "value", "of", "NULL", "will", "list", "the", "attribute", "with", "no", "=", "value", "after" ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L77-L87
25,233
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.removeAttribute
public function removeAttribute($name) { if(strlen($name) < 1) { throw new HTMLTagException("Attribute name is empty"); } unset($this->tag_attributes[strtolower($name)]); return $this; }
php
public function removeAttribute($name) { if(strlen($name) < 1) { throw new HTMLTagException("Attribute name is empty"); } unset($this->tag_attributes[strtolower($name)]); return $this; }
[ "public", "function", "removeAttribute", "(", "$", "name", ")", "{", "if", "(", "strlen", "(", "$", "name", ")", "<", "1", ")", "{", "throw", "new", "HTMLTagException", "(", "\"Attribute name is empty\"", ")", ";", "}", "unset", "(", "$", "this", "->", "tag_attributes", "[", "strtolower", "(", "$", "name", ")", "]", ")", ";", "return", "$", "this", ";", "}" ]
Removes the attribute from the tag, along with its value. @param string $name @return HTMLTag @throws HTMLTagException
[ "Removes", "the", "attribute", "from", "the", "tag", "along", "with", "its", "value", "." ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L117-L127
25,234
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.addClass
public function addClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } if(!$this->hasClass($className)) { $classes = $this->getClasses() . " " . $this->removeMultipleSpaces(trim($className)); $this->setAttribute("class",trim($classes)); } return $this; }
php
public function addClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } if(!$this->hasClass($className)) { $classes = $this->getClasses() . " " . $this->removeMultipleSpaces(trim($className)); $this->setAttribute("class",trim($classes)); } return $this; }
[ "public", "function", "addClass", "(", "$", "className", ")", "{", "if", "(", "strlen", "(", "$", "className", ")", "<", "1", ")", "{", "throw", "new", "HTMLTagException", "(", "\"Class name is empty\"", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasClass", "(", "$", "className", ")", ")", "{", "$", "classes", "=", "$", "this", "->", "getClasses", "(", ")", ".", "\" \"", ".", "$", "this", "->", "removeMultipleSpaces", "(", "trim", "(", "$", "className", ")", ")", ";", "$", "this", "->", "setAttribute", "(", "\"class\"", ",", "trim", "(", "$", "classes", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a class name to the class attribute, this won't add duplicates. @param string $className @return HTMLTag @throws HTMLTagException
[ "Add", "a", "class", "name", "to", "the", "class", "attribute", "this", "won", "t", "add", "duplicates", "." ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L163-L177
25,235
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.removeClass
public function removeClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } $classes = explode(" ", $this->getClasses()); $this->clearClasses(); foreach($classes as $class) { if(strtolower($class) != strtolower($className)) { $this->addClass($class); } } return $this; }
php
public function removeClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } $classes = explode(" ", $this->getClasses()); $this->clearClasses(); foreach($classes as $class) { if(strtolower($class) != strtolower($className)) { $this->addClass($class); } } return $this; }
[ "public", "function", "removeClass", "(", "$", "className", ")", "{", "if", "(", "strlen", "(", "$", "className", ")", "<", "1", ")", "{", "throw", "new", "HTMLTagException", "(", "\"Class name is empty\"", ")", ";", "}", "$", "classes", "=", "explode", "(", "\" \"", ",", "$", "this", "->", "getClasses", "(", ")", ")", ";", "$", "this", "->", "clearClasses", "(", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "strtolower", "(", "$", "class", ")", "!=", "strtolower", "(", "$", "className", ")", ")", "{", "$", "this", "->", "addClass", "(", "$", "class", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Removes the specified class name. @param string $className @return HTMLTag @throws HTMLTagException
[ "Removes", "the", "specified", "class", "name", "." ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L196-L214
25,236
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.hasClass
public function hasClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } if($this->hasAttribute("class")) { $classes = $this->getClasses(); foreach(explode(" ",$classes) as $class) { if(strtolower($class) == strtolower($className)) { return true; // We found it. } } } return false; }
php
public function hasClass($className) { if(strlen($className) < 1) { throw new HTMLTagException("Class name is empty"); } if($this->hasAttribute("class")) { $classes = $this->getClasses(); foreach(explode(" ",$classes) as $class) { if(strtolower($class) == strtolower($className)) { return true; // We found it. } } } return false; }
[ "public", "function", "hasClass", "(", "$", "className", ")", "{", "if", "(", "strlen", "(", "$", "className", ")", "<", "1", ")", "{", "throw", "new", "HTMLTagException", "(", "\"Class name is empty\"", ")", ";", "}", "if", "(", "$", "this", "->", "hasAttribute", "(", "\"class\"", ")", ")", "{", "$", "classes", "=", "$", "this", "->", "getClasses", "(", ")", ";", "foreach", "(", "explode", "(", "\" \"", ",", "$", "classes", ")", "as", "$", "class", ")", "{", "if", "(", "strtolower", "(", "$", "class", ")", "==", "strtolower", "(", "$", "className", ")", ")", "{", "return", "true", ";", "// We found it.", "}", "}", "}", "return", "false", ";", "}" ]
Checks to see if the given class name is inside of the class attribute @param string $className @return bool @throws HTMLTagException
[ "Checks", "to", "see", "if", "the", "given", "class", "name", "is", "inside", "of", "the", "class", "attribute" ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L222-L242
25,237
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.getClasses
public function getClasses() { $classes = $this->getAttribute("class"); return (strlen($classes) > 0) ? trim($this->removeMultipleSpaces($classes)) : ""; }
php
public function getClasses() { $classes = $this->getAttribute("class"); return (strlen($classes) > 0) ? trim($this->removeMultipleSpaces($classes)) : ""; }
[ "public", "function", "getClasses", "(", ")", "{", "$", "classes", "=", "$", "this", "->", "getAttribute", "(", "\"class\"", ")", ";", "return", "(", "strlen", "(", "$", "classes", ")", ">", "0", ")", "?", "trim", "(", "$", "this", "->", "removeMultipleSpaces", "(", "$", "classes", ")", ")", ":", "\"\"", ";", "}" ]
Returns a space separated string of classes belonging to the tag. @return string @throws HTMLTagException
[ "Returns", "a", "space", "separated", "string", "of", "classes", "belonging", "to", "the", "tag", "." ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L249-L253
25,238
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.getFormattedAttributes
public function getFormattedAttributes() { $rtn = ""; foreach($this->listAttributes() as $name => $value) { $rtn .= sprintf(" %s=\"%s\"",htmlentities($name),htmlentities($value)); } return $rtn; }
php
public function getFormattedAttributes() { $rtn = ""; foreach($this->listAttributes() as $name => $value) { $rtn .= sprintf(" %s=\"%s\"",htmlentities($name),htmlentities($value)); } return $rtn; }
[ "public", "function", "getFormattedAttributes", "(", ")", "{", "$", "rtn", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "listAttributes", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "rtn", ".=", "sprintf", "(", "\" %s=\\\"%s\\\"\"", ",", "htmlentities", "(", "$", "name", ")", ",", "htmlentities", "(", "$", "value", ")", ")", ";", "}", "return", "$", "rtn", ";", "}" ]
Format and return attributes in a name="value" format as it should appear in an HTML tag. @return string
[ "Format", "and", "return", "attributes", "in", "a", "name", "=", "value", "format", "as", "it", "should", "appear", "in", "an", "HTML", "tag", "." ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L380-L388
25,239
Gercoli/HTMLTags
src/HTMLTag.php
HTMLTag.setTagPrefix
public function setTagPrefix($prefix) { if(!is_string($prefix) && $prefix !== null) { throw new HTMLTagException("The tag prefix must be a string or null."); } $this->tag_prefix_previous = $this->getTagPrefix(); $this->tag_prefix = $prefix; return $this; }
php
public function setTagPrefix($prefix) { if(!is_string($prefix) && $prefix !== null) { throw new HTMLTagException("The tag prefix must be a string or null."); } $this->tag_prefix_previous = $this->getTagPrefix(); $this->tag_prefix = $prefix; return $this; }
[ "public", "function", "setTagPrefix", "(", "$", "prefix", ")", "{", "if", "(", "!", "is_string", "(", "$", "prefix", ")", "&&", "$", "prefix", "!==", "null", ")", "{", "throw", "new", "HTMLTagException", "(", "\"The tag prefix must be a string or null.\"", ")", ";", "}", "$", "this", "->", "tag_prefix_previous", "=", "$", "this", "->", "getTagPrefix", "(", ")", ";", "$", "this", "->", "tag_prefix", "=", "$", "prefix", ";", "return", "$", "this", ";", "}" ]
Sets the string that should precede a tag @param string|null $prefix @return HTMLTag @throws HTMLTagException
[ "Sets", "the", "string", "that", "should", "precede", "a", "tag" ]
795c4c1bab405d1387406a4da0e2884f4314b2ce
https://github.com/Gercoli/HTMLTags/blob/795c4c1bab405d1387406a4da0e2884f4314b2ce/src/HTMLTag.php#L396-L408
25,240
chalasr/RCHCapistranoBundle
Generator/DeployGenerator.php
DeployGenerator.write
public function write() { foreach ($this->parameters as $prop => $value) { $placeHolders[] = sprintf('<%s>', $prop); $replacements[] = $value; } $config = str_replace($placeHolders, $replacements, self::$configTemplate); $config = sprintf('%s%s%s', self::$defaultConfigTemplate, PHP_EOL, $config); if (true === $this->parameters['composer']) { $config = sprintf('%s%s%s', $config, PHP_EOL, self::$downloadComposerTaskTemplate); } if (true === $this->parameters['schemadb']) { $config = sprintf('%s%s%s', $config, PHP_EOL, self::$updateSchemaTaskTemplate); } fwrite($this->file, $this->addHeaders($config)); }
php
public function write() { foreach ($this->parameters as $prop => $value) { $placeHolders[] = sprintf('<%s>', $prop); $replacements[] = $value; } $config = str_replace($placeHolders, $replacements, self::$configTemplate); $config = sprintf('%s%s%s', self::$defaultConfigTemplate, PHP_EOL, $config); if (true === $this->parameters['composer']) { $config = sprintf('%s%s%s', $config, PHP_EOL, self::$downloadComposerTaskTemplate); } if (true === $this->parameters['schemadb']) { $config = sprintf('%s%s%s', $config, PHP_EOL, self::$updateSchemaTaskTemplate); } fwrite($this->file, $this->addHeaders($config)); }
[ "public", "function", "write", "(", ")", "{", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "prop", "=>", "$", "value", ")", "{", "$", "placeHolders", "[", "]", "=", "sprintf", "(", "'<%s>'", ",", "$", "prop", ")", ";", "$", "replacements", "[", "]", "=", "$", "value", ";", "}", "$", "config", "=", "str_replace", "(", "$", "placeHolders", ",", "$", "replacements", ",", "self", "::", "$", "configTemplate", ")", ";", "$", "config", "=", "sprintf", "(", "'%s%s%s'", ",", "self", "::", "$", "defaultConfigTemplate", ",", "PHP_EOL", ",", "$", "config", ")", ";", "if", "(", "true", "===", "$", "this", "->", "parameters", "[", "'composer'", "]", ")", "{", "$", "config", "=", "sprintf", "(", "'%s%s%s'", ",", "$", "config", ",", "PHP_EOL", ",", "self", "::", "$", "downloadComposerTaskTemplate", ")", ";", "}", "if", "(", "true", "===", "$", "this", "->", "parameters", "[", "'schemadb'", "]", ")", "{", "$", "config", "=", "sprintf", "(", "'%s%s%s'", ",", "$", "config", ",", "PHP_EOL", ",", "self", "::", "$", "updateSchemaTaskTemplate", ")", ";", "}", "fwrite", "(", "$", "this", "->", "file", ",", "$", "this", "->", "addHeaders", "(", "$", "config", ")", ")", ";", "}" ]
Writes deployment file.
[ "Writes", "deployment", "file", "." ]
c4a4cbaa2bc05f33bf431fd3afe6cac39947640e
https://github.com/chalasr/RCHCapistranoBundle/blob/c4a4cbaa2bc05f33bf431fd3afe6cac39947640e/Generator/DeployGenerator.php#L111-L130
25,241
Innmind/Socket
src/Server/Unix.php
Unix.recoverable
public static function recoverable(Address $path): self { try { return new self($path); } catch (FailedToOpenSocket $e) { @unlink((string) $path); return new self($path); } }
php
public static function recoverable(Address $path): self { try { return new self($path); } catch (FailedToOpenSocket $e) { @unlink((string) $path); return new self($path); } }
[ "public", "static", "function", "recoverable", "(", "Address", "$", "path", ")", ":", "self", "{", "try", "{", "return", "new", "self", "(", "$", "path", ")", ";", "}", "catch", "(", "FailedToOpenSocket", "$", "e", ")", "{", "@", "unlink", "(", "(", "string", ")", "$", "path", ")", ";", "return", "new", "self", "(", "$", "path", ")", ";", "}", "}" ]
On open failure it will try to delete existing socket file the ntry to reopen the socket connection
[ "On", "open", "failure", "it", "will", "try", "to", "delete", "existing", "socket", "file", "the", "ntry", "to", "reopen", "the", "socket", "connection" ]
4d05c841d85ccbde7bfdaeafc6930970923bab84
https://github.com/Innmind/Socket/blob/4d05c841d85ccbde7bfdaeafc6930970923bab84/src/Server/Unix.php#L49-L58
25,242
phossa/phossa-di
src/Phossa/Di/Container.php
Container.serviceFromDefinition
protected function serviceFromDefinition($id, $args) { // create the service object $service = $this->createServiceObject($id, $args); // run predefined methods if any $this->runDefinedMethods($id, $service); // decorate the service if DecorateExtension loaded $this->decorateService($service); return $service; }
php
protected function serviceFromDefinition($id, $args) { // create the service object $service = $this->createServiceObject($id, $args); // run predefined methods if any $this->runDefinedMethods($id, $service); // decorate the service if DecorateExtension loaded $this->decorateService($service); return $service; }
[ "protected", "function", "serviceFromDefinition", "(", "$", "id", ",", "$", "args", ")", "{", "// create the service object", "$", "service", "=", "$", "this", "->", "createServiceObject", "(", "$", "id", ",", "$", "args", ")", ";", "// run predefined methods if any", "$", "this", "->", "runDefinedMethods", "(", "$", "id", ",", "$", "service", ")", ";", "// decorate the service if DecorateExtension loaded", "$", "this", "->", "decorateService", "(", "$", "service", ")", ";", "return", "$", "service", ";", "}" ]
Check circular, create service and decorate service @param string $id service id @param array $args constructor arguments @return object @access protected
[ "Check", "circular", "create", "service", "and", "decorate", "service" ]
bbe1e95b081068e2bc49c6cd465f38aab0374be5
https://github.com/phossa/phossa-di/blob/bbe1e95b081068e2bc49c6cd465f38aab0374be5/src/Phossa/Di/Container.php#L208-L220
25,243
sndsgd/http
src/http/request/Client.php
Client.getIp
public function getIp(): string { if ($this->ip === null) { foreach (["HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR"] as $key) { $proxyIpList = $this->environment[$key] ?? ""; if ($proxyIpList) { $commaPosition = strpos($proxyIpList, ","); if ($commaPosition !== false) { $this->ip = substr($proxyIpList, 0, $commaPosition); } else { $this->ip = $proxyIpList; } return $this->ip; } } $this->ip = $this->environment["REMOTE_ADDR"] ?? ""; } return $this->ip; }
php
public function getIp(): string { if ($this->ip === null) { foreach (["HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR"] as $key) { $proxyIpList = $this->environment[$key] ?? ""; if ($proxyIpList) { $commaPosition = strpos($proxyIpList, ","); if ($commaPosition !== false) { $this->ip = substr($proxyIpList, 0, $commaPosition); } else { $this->ip = $proxyIpList; } return $this->ip; } } $this->ip = $this->environment["REMOTE_ADDR"] ?? ""; } return $this->ip; }
[ "public", "function", "getIp", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "ip", "===", "null", ")", "{", "foreach", "(", "[", "\"HTTP_X_FORWARDED_FOR\"", ",", "\"X_FORWARDED_FOR\"", "]", "as", "$", "key", ")", "{", "$", "proxyIpList", "=", "$", "this", "->", "environment", "[", "$", "key", "]", "??", "\"\"", ";", "if", "(", "$", "proxyIpList", ")", "{", "$", "commaPosition", "=", "strpos", "(", "$", "proxyIpList", ",", "\",\"", ")", ";", "if", "(", "$", "commaPosition", "!==", "false", ")", "{", "$", "this", "->", "ip", "=", "substr", "(", "$", "proxyIpList", ",", "0", ",", "$", "commaPosition", ")", ";", "}", "else", "{", "$", "this", "->", "ip", "=", "$", "proxyIpList", ";", "}", "return", "$", "this", "->", "ip", ";", "}", "}", "$", "this", "->", "ip", "=", "$", "this", "->", "environment", "[", "\"REMOTE_ADDR\"", "]", "??", "\"\"", ";", "}", "return", "$", "this", "->", "ip", ";", "}" ]
Retrieve the client ip address @return string
[ "Retrieve", "the", "client", "ip", "address" ]
e7f82010a66c6d3241a24ea82baf4593130c723b
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/request/Client.php#L42-L60
25,244
CalderaWP/caldera-interop
src/IteratableCollection.php
IteratableCollection.count
public function count(): int { $key = $this->storeKey(); if (! $this->isCountable($this->$key)) { return 0; } return count($this->$key); }
php
public function count(): int { $key = $this->storeKey(); if (! $this->isCountable($this->$key)) { return 0; } return count($this->$key); }
[ "public", "function", "count", "(", ")", ":", "int", "{", "$", "key", "=", "$", "this", "->", "storeKey", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isCountable", "(", "$", "this", "->", "$", "key", ")", ")", "{", "return", "0", ";", "}", "return", "count", "(", "$", "this", "->", "$", "key", ")", ";", "}" ]
Get size of collection @return int
[ "Get", "size", "of", "collection" ]
d25c4bc930200b314fbd42d084080b5d85261c94
https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/IteratableCollection.php#L38-L45
25,245
CalderaWP/caldera-interop
src/IteratableCollection.php
IteratableCollection.increase
public function increase(int $size) { $count = $this->count(); if ($size > $this->count()) { $add = $size - $this->count(); $key = $this->storeKey(); for ($i = 0; $i < $add; $i++) { $this->addEmpty(); } } return $this; }
php
public function increase(int $size) { $count = $this->count(); if ($size > $this->count()) { $add = $size - $this->count(); $key = $this->storeKey(); for ($i = 0; $i < $add; $i++) { $this->addEmpty(); } } return $this; }
[ "public", "function", "increase", "(", "int", "$", "size", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", ";", "if", "(", "$", "size", ">", "$", "this", "->", "count", "(", ")", ")", "{", "$", "add", "=", "$", "size", "-", "$", "this", "->", "count", "(", ")", ";", "$", "key", "=", "$", "this", "->", "storeKey", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "add", ";", "$", "i", "++", ")", "{", "$", "this", "->", "addEmpty", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Increase size of collection @param int $size @return $this
[ "Increase", "size", "of", "collection" ]
d25c4bc930200b314fbd42d084080b5d85261c94
https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/IteratableCollection.php#L76-L88
25,246
artscorestudio/user-bundle
Repository/UserRepository.php
UserRepository.findByUsernameContains
public function findByUsernameContains($searched_term) { $qb = $this->createQueryBuilder('u'); $qb instanceof QueryBuilder; $qb->add('where', $qb->expr()->like('u.username', $qb->expr()->lower(':searched_term'))) ->setParameter('searched_term', $searched_term . '%'); return $qb->getQuery()->getResult(); }
php
public function findByUsernameContains($searched_term) { $qb = $this->createQueryBuilder('u'); $qb instanceof QueryBuilder; $qb->add('where', $qb->expr()->like('u.username', $qb->expr()->lower(':searched_term'))) ->setParameter('searched_term', $searched_term . '%'); return $qb->getQuery()->getResult(); }
[ "public", "function", "findByUsernameContains", "(", "$", "searched_term", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'u'", ")", ";", "$", "qb", "instanceof", "QueryBuilder", ";", "$", "qb", "->", "add", "(", "'where'", ",", "$", "qb", "->", "expr", "(", ")", "->", "like", "(", "'u.username'", ",", "$", "qb", "->", "expr", "(", ")", "->", "lower", "(", "':searched_term'", ")", ")", ")", "->", "setParameter", "(", "'searched_term'", ",", "$", "searched_term", ".", "'%'", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Find user by username @param string $searched_term
[ "Find", "user", "by", "username" ]
83e660d1073e1cbfde6eed0b528b8c99e78a2e53
https://github.com/artscorestudio/user-bundle/blob/83e660d1073e1cbfde6eed0b528b8c99e78a2e53/Repository/UserRepository.php#L28-L37
25,247
zhaoxianfang/tools
src/Symfony/Component/DependencyInjection/Container.php
Container.normalizeId
public function normalizeId($id) { if (!\is_string($id)) { $id = (string) $id; } if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) { $normalizedId = $this->normalizedIds[$normalizedId]; if ($id !== $normalizedId) { @trigger_error(sprintf('Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.3.', $id, $normalizedId), E_USER_DEPRECATED); } } else { $normalizedId = $this->normalizedIds[$normalizedId] = $id; } return $normalizedId; }
php
public function normalizeId($id) { if (!\is_string($id)) { $id = (string) $id; } if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) { $normalizedId = $this->normalizedIds[$normalizedId]; if ($id !== $normalizedId) { @trigger_error(sprintf('Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.3.', $id, $normalizedId), E_USER_DEPRECATED); } } else { $normalizedId = $this->normalizedIds[$normalizedId] = $id; } return $normalizedId; }
[ "public", "function", "normalizeId", "(", "$", "id", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "id", ")", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "normalizedIds", "[", "$", "normalizedId", "=", "strtolower", "(", "$", "id", ")", "]", ")", ")", "{", "$", "normalizedId", "=", "$", "this", "->", "normalizedIds", "[", "$", "normalizedId", "]", ";", "if", "(", "$", "id", "!==", "$", "normalizedId", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'Service identifiers will be made case sensitive in Symfony 4.0. Using \"%s\" instead of \"%s\" is deprecated since Symfony 3.3.'", ",", "$", "id", ",", "$", "normalizedId", ")", ",", "E_USER_DEPRECATED", ")", ";", "}", "}", "else", "{", "$", "normalizedId", "=", "$", "this", "->", "normalizedIds", "[", "$", "normalizedId", "]", "=", "$", "id", ";", "}", "return", "$", "normalizedId", ";", "}" ]
Returns the case sensitive id used at registration time. @param string $id @return string @internal
[ "Returns", "the", "case", "sensitive", "id", "used", "at", "registration", "time", "." ]
d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7
https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Container.php#L508-L523
25,248
danielgp/common-lib
source/CommonCode.php
CommonCode.getTimestamp
public function getTimestamp($returnType = 'string') { if (in_array($returnType, ['array', 'float', 'string'])) { return $this->getTimestampRaw($returnType); } return sprintf($this->lclMsgCmn('i18n_Error_UnknownReturnType'), $returnType); }
php
public function getTimestamp($returnType = 'string') { if (in_array($returnType, ['array', 'float', 'string'])) { return $this->getTimestampRaw($returnType); } return sprintf($this->lclMsgCmn('i18n_Error_UnknownReturnType'), $returnType); }
[ "public", "function", "getTimestamp", "(", "$", "returnType", "=", "'string'", ")", "{", "if", "(", "in_array", "(", "$", "returnType", ",", "[", "'array'", ",", "'float'", ",", "'string'", "]", ")", ")", "{", "return", "$", "this", "->", "getTimestampRaw", "(", "$", "returnType", ")", ";", "}", "return", "sprintf", "(", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_UnknownReturnType'", ")", ",", "$", "returnType", ")", ";", "}" ]
Returns server Timestamp into various formats @param string $returnType @return string
[ "Returns", "server", "Timestamp", "into", "various", "formats" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L166-L172
25,249
danielgp/common-lib
source/CommonCode.php
CommonCode.isJsonByDanielGP
public function isJsonByDanielGP($inputJson) { if (is_string($inputJson)) { json_decode($inputJson); return (json_last_error() == JSON_ERROR_NONE); } return $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson'); }
php
public function isJsonByDanielGP($inputJson) { if (is_string($inputJson)) { json_decode($inputJson); return (json_last_error() == JSON_ERROR_NONE); } return $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson'); }
[ "public", "function", "isJsonByDanielGP", "(", "$", "inputJson", ")", "{", "if", "(", "is_string", "(", "$", "inputJson", ")", ")", "{", "json_decode", "(", "$", "inputJson", ")", ";", "return", "(", "json_last_error", "(", ")", "==", "JSON_ERROR_NONE", ")", ";", "}", "return", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_GivenInputIsNotJson'", ")", ";", "}" ]
Tests if given string has a valid Json format @param string|null|array $inputJson @return boolean|string
[ "Tests", "if", "given", "string", "has", "a", "valid", "Json", "format" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L180-L187
25,250
danielgp/common-lib
source/CommonCode.php
CommonCode.sendBackgroundEncodedFormElementsByPost
protected function sendBackgroundEncodedFormElementsByPost($urlToSendTo, $params = []) { $postingUrl = filter_var($urlToSendTo, FILTER_VALIDATE_URL); if ($postingUrl === false) { throw new \Exception('Invalid URL in ' . __FUNCTION__); } if ($params !== []) { $cntFailErrMsg = $this->lclMsgCmn('i18n_Error_FailedToConnect'); $this->sendBackgroundPostData($postingUrl, $params, $cntFailErrMsg); return ''; } throw new \Exception($this->lclMsgCmn('i18n_Error_GivenParameterIsNotAnArray')); }
php
protected function sendBackgroundEncodedFormElementsByPost($urlToSendTo, $params = []) { $postingUrl = filter_var($urlToSendTo, FILTER_VALIDATE_URL); if ($postingUrl === false) { throw new \Exception('Invalid URL in ' . __FUNCTION__); } if ($params !== []) { $cntFailErrMsg = $this->lclMsgCmn('i18n_Error_FailedToConnect'); $this->sendBackgroundPostData($postingUrl, $params, $cntFailErrMsg); return ''; } throw new \Exception($this->lclMsgCmn('i18n_Error_GivenParameterIsNotAnArray')); }
[ "protected", "function", "sendBackgroundEncodedFormElementsByPost", "(", "$", "urlToSendTo", ",", "$", "params", "=", "[", "]", ")", "{", "$", "postingUrl", "=", "filter_var", "(", "$", "urlToSendTo", ",", "FILTER_VALIDATE_URL", ")", ";", "if", "(", "$", "postingUrl", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid URL in '", ".", "__FUNCTION__", ")", ";", "}", "if", "(", "$", "params", "!==", "[", "]", ")", "{", "$", "cntFailErrMsg", "=", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_FailedToConnect'", ")", ";", "$", "this", "->", "sendBackgroundPostData", "(", "$", "postingUrl", ",", "$", "params", ",", "$", "cntFailErrMsg", ")", ";", "return", "''", ";", "}", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_GivenParameterIsNotAnArray'", ")", ")", ";", "}" ]
Send an array of parameters like a form through a POST action @param string $urlToSendTo @param array $params @throws \Exception
[ "Send", "an", "array", "of", "parameters", "like", "a", "form", "through", "a", "POST", "action" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L204-L216
25,251
danielgp/common-lib
source/CommonCode.php
CommonCode.setJsonToArray
public function setJsonToArray($inputJson) { if (!$this->isJsonByDanielGP($inputJson)) { return ['error' => $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson')]; } $sReturn = (json_decode($inputJson, true)); $jsonError = $this->setJsonErrorInPlainEnglish(); if ($jsonError == '') { return $sReturn; } return ['error' => $jsonError]; }
php
public function setJsonToArray($inputJson) { if (!$this->isJsonByDanielGP($inputJson)) { return ['error' => $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson')]; } $sReturn = (json_decode($inputJson, true)); $jsonError = $this->setJsonErrorInPlainEnglish(); if ($jsonError == '') { return $sReturn; } return ['error' => $jsonError]; }
[ "public", "function", "setJsonToArray", "(", "$", "inputJson", ")", "{", "if", "(", "!", "$", "this", "->", "isJsonByDanielGP", "(", "$", "inputJson", ")", ")", "{", "return", "[", "'error'", "=>", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_GivenInputIsNotJson'", ")", "]", ";", "}", "$", "sReturn", "=", "(", "json_decode", "(", "$", "inputJson", ",", "true", ")", ")", ";", "$", "jsonError", "=", "$", "this", "->", "setJsonErrorInPlainEnglish", "(", ")", ";", "if", "(", "$", "jsonError", "==", "''", ")", "{", "return", "$", "sReturn", ";", "}", "return", "[", "'error'", "=>", "$", "jsonError", "]", ";", "}" ]
Converts a JSON string into an Array @param string $inputJson @return array
[ "Converts", "a", "JSON", "string", "into", "an", "Array" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L254-L265
25,252
Dhii/factory-base
src/SubjectConfigAwareTrait.php
SubjectConfigAwareTrait._setSubjectConfig
protected function _setSubjectConfig($subjectConfig) { if ($subjectConfig === null || $subjectConfig = $this->_normalizeContainer($subjectConfig)) { $this->subjectConfig = $subjectConfig; } }
php
protected function _setSubjectConfig($subjectConfig) { if ($subjectConfig === null || $subjectConfig = $this->_normalizeContainer($subjectConfig)) { $this->subjectConfig = $subjectConfig; } }
[ "protected", "function", "_setSubjectConfig", "(", "$", "subjectConfig", ")", "{", "if", "(", "$", "subjectConfig", "===", "null", "||", "$", "subjectConfig", "=", "$", "this", "->", "_normalizeContainer", "(", "$", "subjectConfig", ")", ")", "{", "$", "this", "->", "subjectConfig", "=", "$", "subjectConfig", ";", "}", "}" ]
Sets the subject factory configuration for this instance. @since [*next-version*] @param array|ArrayAccess|ContainerInterface|stdClass|null $subjectConfig The subject factory config, if any. @throws InvalidArgumentException If the argument is not a valid container.
[ "Sets", "the", "subject", "factory", "configuration", "for", "this", "instance", "." ]
eb6694178068ec58e0f2de9243f0eb98844511de
https://github.com/Dhii/factory-base/blob/eb6694178068ec58e0f2de9243f0eb98844511de/src/SubjectConfigAwareTrait.php#L47-L52
25,253
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setExpressionVisitor
public function setExpressionVisitor(\Aztech\Skwal\Visitor\Printer\Expression $visitor) { $this->expressionVisitor = $visitor; }
php
public function setExpressionVisitor(\Aztech\Skwal\Visitor\Printer\Expression $visitor) { $this->expressionVisitor = $visitor; }
[ "public", "function", "setExpressionVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Expression", "$", "visitor", ")", "{", "$", "this", "->", "expressionVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output expressions. @param \Aztech\Skwal\Visitor\Printer\Expression $visitor @codeCoverageIgnore Cannot be tested as there are no getters
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "expressions", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L57-L60
25,254
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setTableReferenceVisitor
public function setTableReferenceVisitor(\Aztech\Skwal\Visitor\Printer\TableReference $visitor) { $this->tableReferenceVisitor = $visitor; }
php
public function setTableReferenceVisitor(\Aztech\Skwal\Visitor\Printer\TableReference $visitor) { $this->tableReferenceVisitor = $visitor; }
[ "public", "function", "setTableReferenceVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "TableReference", "$", "visitor", ")", "{", "$", "this", "->", "tableReferenceVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output correlated references. @param \Aztech\Skwal\Visitor\Printer\TableReference $visitor @codeCoverageIgnore Cannot be tested as there are no getters
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "correlated", "references", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L68-L71
25,255
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setPredicateVisitor
public function setPredicateVisitor(\Aztech\Skwal\Visitor\Printer\Predicate $visitor) { $this->predicateVisitor = $visitor; }
php
public function setPredicateVisitor(\Aztech\Skwal\Visitor\Printer\Predicate $visitor) { $this->predicateVisitor = $visitor; }
[ "public", "function", "setPredicateVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Predicate", "$", "visitor", ")", "{", "$", "this", "->", "predicateVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output predicates. @param \Aztech\Skwal\Visitor\Printer\Predicate $visitor @codeCoverageIgnore
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "predicates", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L79-L82
25,256
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.printQuery
public function printQuery(\Aztech\Skwal\Query $query) { $this->visit($query); return $this->queryStack->pop(); }
php
public function printQuery(\Aztech\Skwal\Query $query) { $this->visit($query); return $this->queryStack->pop(); }
[ "public", "function", "printQuery", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "$", "query", ")", "{", "$", "this", "->", "visit", "(", "$", "query", ")", ";", "return", "$", "this", "->", "queryStack", "->", "pop", "(", ")", ";", "}" ]
Generates the SQL command for a given query. @param \Aztech\Skwal\Query $query @return mixed
[ "Generates", "the", "SQL", "command", "for", "a", "given", "query", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L130-L135
25,257
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendSelectList
private function appendSelectList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(true); $selectList = array(); foreach ($query->getColumns() as $column) { $selectList[] = $this->expressionVisitor->printExpression($column); } $assembler->setSelectList($selectList); }
php
private function appendSelectList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(true); $selectList = array(); foreach ($query->getColumns() as $column) { $selectList[] = $this->expressionVisitor->printExpression($column); } $assembler->setSelectList($selectList); }
[ "private", "function", "appendSelectList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "true", ")", ";", "$", "selectList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "$", "selectList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "column", ")", ";", "}", "$", "assembler", "->", "setSelectList", "(", "$", "selectList", ")", ";", "}" ]
Adds the select list elements of a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "select", "list", "elements", "of", "a", "query", "to", "a", "query", "assembler", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L171-L182
25,258
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendFromClause
private function appendFromClause(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $fromStatement = $this->tableReferenceVisitor->printTableStatement($query->getTable()); $assembler->setFromClause($fromStatement); }
php
private function appendFromClause(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $fromStatement = $this->tableReferenceVisitor->printTableStatement($query->getTable()); $assembler->setFromClause($fromStatement); }
[ "private", "function", "appendFromClause", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "fromStatement", "=", "$", "this", "->", "tableReferenceVisitor", "->", "printTableStatement", "(", "$", "query", "->", "getTable", "(", ")", ")", ";", "$", "assembler", "->", "setFromClause", "(", "$", "fromStatement", ")", ";", "}" ]
Adds the from clause of a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "from", "clause", "of", "a", "query", "to", "a", "query", "assembler", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L190-L194
25,259
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendWhereClauseIfNecessary
private function appendWhereClauseIfNecessary(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { if ($query->getCondition() != null) { $whereClause = $this->predicateVisitor->printPredicateStatement($query->getCondition()); $assembler->setWhereClause($whereClause); } }
php
private function appendWhereClauseIfNecessary(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { if ($query->getCondition() != null) { $whereClause = $this->predicateVisitor->printPredicateStatement($query->getCondition()); $assembler->setWhereClause($whereClause); } }
[ "private", "function", "appendWhereClauseIfNecessary", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "if", "(", "$", "query", "->", "getCondition", "(", ")", "!=", "null", ")", "{", "$", "whereClause", "=", "$", "this", "->", "predicateVisitor", "->", "printPredicateStatement", "(", "$", "query", "->", "getCondition", "(", ")", ")", ";", "$", "assembler", "->", "setWhereClause", "(", "$", "whereClause", ")", ";", "}", "}" ]
Adds the where clause of a query to a query assembler if the given query has a selection condition. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "where", "clause", "of", "a", "query", "to", "a", "query", "assembler", "if", "the", "given", "query", "has", "a", "selection", "condition", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L202-L208
25,260
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendGroupByList
private function appendGroupByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $groupByList = array(); foreach ($query->getGroupingColumns() as $groupingColumn) { $groupByList[] = $this->expressionVisitor->printExpression($groupingColumn); } $assembler->setGroupByList($groupByList); }
php
private function appendGroupByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $groupByList = array(); foreach ($query->getGroupingColumns() as $groupingColumn) { $groupByList[] = $this->expressionVisitor->printExpression($groupingColumn); } $assembler->setGroupByList($groupByList); }
[ "private", "function", "appendGroupByList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "false", ")", ";", "$", "groupByList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getGroupingColumns", "(", ")", "as", "$", "groupingColumn", ")", "{", "$", "groupByList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "groupingColumn", ")", ";", "}", "$", "assembler", "->", "setGroupByList", "(", "$", "groupByList", ")", ";", "}" ]
Adds the group by list from a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "group", "by", "list", "from", "a", "query", "to", "a", "query", "assembler", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L216-L227
25,261
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendOrderByList
private function appendOrderByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $orderByList = array(); foreach ($query->getSortingColumns() as $sortingColumn) { $direction = $this->getSortDirectionText($sortingColumn); $orderByList[] = $this->expressionVisitor->printExpression($sortingColumn->getExpression()) . $direction; } $assembler->setOrderByList($orderByList); }
php
private function appendOrderByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $orderByList = array(); foreach ($query->getSortingColumns() as $sortingColumn) { $direction = $this->getSortDirectionText($sortingColumn); $orderByList[] = $this->expressionVisitor->printExpression($sortingColumn->getExpression()) . $direction; } $assembler->setOrderByList($orderByList); }
[ "private", "function", "appendOrderByList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "false", ")", ";", "$", "orderByList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getSortingColumns", "(", ")", "as", "$", "sortingColumn", ")", "{", "$", "direction", "=", "$", "this", "->", "getSortDirectionText", "(", "$", "sortingColumn", ")", ";", "$", "orderByList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "sortingColumn", "->", "getExpression", "(", ")", ")", ".", "$", "direction", ";", "}", "$", "assembler", "->", "setOrderByList", "(", "$", "orderByList", ")", ";", "}" ]
Adds the sort expressions from a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "sort", "expressions", "from", "a", "query", "to", "a", "query", "assembler", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L235-L247
25,262
AnonymPHP/Anonym-HttpFoundation
Redirect.php
Redirect.route
public function route($name = ''){ $routes = AsCollector::getAs(); if (isset($routes[$name])) { $this->to($routes[$name]); }else{ throw new RouteNotFoundException(sprintf('%s Route Not Found')); } }
php
public function route($name = ''){ $routes = AsCollector::getAs(); if (isset($routes[$name])) { $this->to($routes[$name]); }else{ throw new RouteNotFoundException(sprintf('%s Route Not Found')); } }
[ "public", "function", "route", "(", "$", "name", "=", "''", ")", "{", "$", "routes", "=", "AsCollector", "::", "getAs", "(", ")", ";", "if", "(", "isset", "(", "$", "routes", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "to", "(", "$", "routes", "[", "$", "name", "]", ")", ";", "}", "else", "{", "throw", "new", "RouteNotFoundException", "(", "sprintf", "(", "'%s Route Not Found'", ")", ")", ";", "}", "}" ]
redirect to a route @param string $name @throws RouteNotFoundException
[ "redirect", "to", "a", "route" ]
943e5f40f45bc2e11a4b9e1d22c6583c31dc4317
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Redirect.php#L52-L60
25,263
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.addResource
public function addResource($format, $resource, $locale, $domain = null) { if (null !== $domain) { $this->domains[] = $domain; } parent::addResource($format, $resource, $locale, $domain); }
php
public function addResource($format, $resource, $locale, $domain = null) { if (null !== $domain) { $this->domains[] = $domain; } parent::addResource($format, $resource, $locale, $domain); }
[ "public", "function", "addResource", "(", "$", "format", ",", "$", "resource", ",", "$", "locale", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "domain", ")", "{", "$", "this", "->", "domains", "[", "]", "=", "$", "domain", ";", "}", "parent", "::", "addResource", "(", "$", "format", ",", "$", "resource", ",", "$", "locale", ",", "$", "domain", ")", ";", "}" ]
Adds a resource. @see SymfonyTranslator::addResource() Keep track of the translation domains. @param string $format The name of the loader (@see addLoader()). @param mixed $resource The resource name. @param string $locale The locale. @param string|null $domain The domain. @return void
[ "Adds", "a", "resource", "." ]
0a64432baef223dcccbfecf057015440dfa76e49
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L87-L94
25,264
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.hasTrans
public function hasTrans($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->has($id, $domain); }
php
public function hasTrans($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->has($id, $domain); }
[ "public", "function", "hasTrans", "(", "$", "id", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "null", "===", "$", "domain", ")", "{", "$", "domain", "=", "'messages'", ";", "}", "return", "$", "this", "->", "getCatalogue", "(", "$", "locale", ")", "->", "has", "(", "$", "id", ",", "$", "domain", ")", ";", "}" ]
Checks if a message has a translation. @param string $id The message id. @param string|null $domain The domain for the message or NULL to use the default. @param string|null $locale The locale or NULL to use the default. @return boolean TRUE if the message has a translation, FALSE otherwise.
[ "Checks", "if", "a", "message", "has", "a", "translation", "." ]
0a64432baef223dcccbfecf057015440dfa76e49
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L334-L341
25,265
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.isValidTranslation
protected function isValidTranslation($val) { if (empty($val) && !is_numeric($val)) { return false; } if (is_string($val)) { return !empty(trim($val)); } if ($val instanceof Translation) { return true; } if (is_array($val)) { return !!array_filter( $val, function ($v, $k) { if (is_string($k) && strlen($k) > 0) { if (is_string($v) && strlen($v) > 0) { return true; } } return false; }, ARRAY_FILTER_USE_BOTH ); } return false; }
php
protected function isValidTranslation($val) { if (empty($val) && !is_numeric($val)) { return false; } if (is_string($val)) { return !empty(trim($val)); } if ($val instanceof Translation) { return true; } if (is_array($val)) { return !!array_filter( $val, function ($v, $k) { if (is_string($k) && strlen($k) > 0) { if (is_string($v) && strlen($v) > 0) { return true; } } return false; }, ARRAY_FILTER_USE_BOTH ); } return false; }
[ "protected", "function", "isValidTranslation", "(", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "val", ")", "&&", "!", "is_numeric", "(", "$", "val", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(", "$", "val", ")", ")", "{", "return", "!", "empty", "(", "trim", "(", "$", "val", ")", ")", ";", "}", "if", "(", "$", "val", "instanceof", "Translation", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "return", "!", "!", "array_filter", "(", "$", "val", ",", "function", "(", "$", "v", ",", "$", "k", ")", "{", "if", "(", "is_string", "(", "$", "k", ")", "&&", "strlen", "(", "$", "k", ")", ">", "0", ")", "{", "if", "(", "is_string", "(", "$", "v", ")", "&&", "strlen", "(", "$", "v", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "}", "return", "false", ";", "}" ]
Determine if the value is translatable. @param mixed $val The value to be checked. @return boolean
[ "Determine", "if", "the", "value", "is", "translatable", "." ]
0a64432baef223dcccbfecf057015440dfa76e49
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L366-L396
25,266
RocketPropelledTortoise/Core
src/Taxonomy/Utils/PathResolver.php
PathResolver.resolvePaths
public function resolvePaths(Vertex $start_vertex) { $this->paths = []; /** * @var DirectedEdge */ foreach ($start_vertex->incoming_edges as $edge) { $this->current_path = [$start_vertex->get_data()]; $this->getPathsRecursion($edge->get_source(), $edge); } return $this->paths; }
php
public function resolvePaths(Vertex $start_vertex) { $this->paths = []; /** * @var DirectedEdge */ foreach ($start_vertex->incoming_edges as $edge) { $this->current_path = [$start_vertex->get_data()]; $this->getPathsRecursion($edge->get_source(), $edge); } return $this->paths; }
[ "public", "function", "resolvePaths", "(", "Vertex", "$", "start_vertex", ")", "{", "$", "this", "->", "paths", "=", "[", "]", ";", "/**\n * @var DirectedEdge\n */", "foreach", "(", "$", "start_vertex", "->", "incoming_edges", "as", "$", "edge", ")", "{", "$", "this", "->", "current_path", "=", "[", "$", "start_vertex", "->", "get_data", "(", ")", "]", ";", "$", "this", "->", "getPathsRecursion", "(", "$", "edge", "->", "get_source", "(", ")", ",", "$", "edge", ")", ";", "}", "return", "$", "this", "->", "paths", ";", "}" ]
Resolve all paths that can be resolved from the start point. @param Vertex $start_vertex @return array
[ "Resolve", "all", "paths", "that", "can", "be", "resolved", "from", "the", "start", "point", "." ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Utils/PathResolver.php#L48-L61
25,267
RocketPropelledTortoise/Core
src/Taxonomy/Utils/PathResolver.php
PathResolver.getPathsRecursion
protected function getPathsRecursion(Vertex $start, DirectedEdge $edge) { // We don't want to visit the same vertex twice within a single path. (avoid loops) if (in_array($start->get_data(), $this->current_path)) { $this->paths[] = array_reverse($this->current_path); return; } $this->current_path[] = $start->get_data(); if ($start->incoming_edges->count() == 0) { $this->paths[] = array_reverse($this->current_path); return; } /** * @var DirectedEdge */ foreach ($start->incoming_edges as $edge) { $this->getPathsRecursion($edge->get_source(), $edge); //remove the item that was added by the child array_pop($this->current_path); } }
php
protected function getPathsRecursion(Vertex $start, DirectedEdge $edge) { // We don't want to visit the same vertex twice within a single path. (avoid loops) if (in_array($start->get_data(), $this->current_path)) { $this->paths[] = array_reverse($this->current_path); return; } $this->current_path[] = $start->get_data(); if ($start->incoming_edges->count() == 0) { $this->paths[] = array_reverse($this->current_path); return; } /** * @var DirectedEdge */ foreach ($start->incoming_edges as $edge) { $this->getPathsRecursion($edge->get_source(), $edge); //remove the item that was added by the child array_pop($this->current_path); } }
[ "protected", "function", "getPathsRecursion", "(", "Vertex", "$", "start", ",", "DirectedEdge", "$", "edge", ")", "{", "// We don't want to visit the same vertex twice within a single path. (avoid loops)", "if", "(", "in_array", "(", "$", "start", "->", "get_data", "(", ")", ",", "$", "this", "->", "current_path", ")", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "array_reverse", "(", "$", "this", "->", "current_path", ")", ";", "return", ";", "}", "$", "this", "->", "current_path", "[", "]", "=", "$", "start", "->", "get_data", "(", ")", ";", "if", "(", "$", "start", "->", "incoming_edges", "->", "count", "(", ")", "==", "0", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "array_reverse", "(", "$", "this", "->", "current_path", ")", ";", "return", ";", "}", "/**\n * @var DirectedEdge\n */", "foreach", "(", "$", "start", "->", "incoming_edges", "as", "$", "edge", ")", "{", "$", "this", "->", "getPathsRecursion", "(", "$", "edge", "->", "get_source", "(", ")", ",", "$", "edge", ")", ";", "//remove the item that was added by the child", "array_pop", "(", "$", "this", "->", "current_path", ")", ";", "}", "}" ]
Recurse on all paths from the start point @param Vertex $start The Vertex to get started from @param DirectedEdge $edge
[ "Recurse", "on", "all", "paths", "from", "the", "start", "point" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Utils/PathResolver.php#L69-L95
25,268
story75/Bonefish-Router
src/Collectors/CombinedRouteCollector.php
CombinedRouteCollector.collectRoutes
public function collectRoutes() { $routes = []; foreach($this->getCollectors() as $collector) { $routes = array_merge($routes, $collector->collectRoutes()); } return $routes; }
php
public function collectRoutes() { $routes = []; foreach($this->getCollectors() as $collector) { $routes = array_merge($routes, $collector->collectRoutes()); } return $routes; }
[ "public", "function", "collectRoutes", "(", ")", "{", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getCollectors", "(", ")", "as", "$", "collector", ")", "{", "$", "routes", "=", "array_merge", "(", "$", "routes", ",", "$", "collector", "->", "collectRoutes", "(", ")", ")", ";", "}", "return", "$", "routes", ";", "}" ]
Aggregate routes and return an array of Route DTOs @return RouteInterface[]
[ "Aggregate", "routes", "and", "return", "an", "array", "of", "Route", "DTOs" ]
bb16960c9442303ceeb0c9d14b14be62018de05d
https://github.com/story75/Bonefish-Router/blob/bb16960c9442303ceeb0c9d14b14be62018de05d/src/Collectors/CombinedRouteCollector.php#L73-L82
25,269
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.render
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = []) { $this->context->bind($model); $this->context->set('@view', $this); foreach($params as $k => $v) { $this->context->set($k, $v); } try { if($this->getParent() === NULL) { $this->renderMain($out); } else { $this->parent->renderMain($out); } return $out; } finally { $this->parent = false; $this->context->unbind(); } }
php
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = []) { $this->context->bind($model); $this->context->set('@view', $this); foreach($params as $k => $v) { $this->context->set($k, $v); } try { if($this->getParent() === NULL) { $this->renderMain($out); } else { $this->parent->renderMain($out); } return $out; } finally { $this->parent = false; $this->context->unbind(); } }
[ "public", "final", "function", "render", "(", "OutputBuffer", "$", "out", ",", "ViewModelInterface", "$", "model", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "context", "->", "bind", "(", "$", "model", ")", ";", "$", "this", "->", "context", "->", "set", "(", "'@view'", ",", "$", "this", ")", ";", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "context", "->", "set", "(", "$", "k", ",", "$", "v", ")", ";", "}", "try", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "$", "this", "->", "renderMain", "(", "$", "out", ")", ";", "}", "else", "{", "$", "this", "->", "parent", "->", "renderMain", "(", "$", "out", ")", ";", "}", "return", "$", "out", ";", "}", "finally", "{", "$", "this", "->", "parent", "=", "false", ";", "$", "this", "->", "context", "->", "unbind", "(", ")", ";", "}", "}" ]
Bind to the given view model and render contents of the compiled view. @param OutputBuffer $out @param ViewModelInterface $model @param array<string, mixed> $params @return OutputBuffer $out
[ "Bind", "to", "the", "given", "view", "model", "and", "render", "contents", "of", "the", "compiled", "view", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L90-L118
25,270
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderMain
protected function renderMain(OutputBuffer $out) { if($this->getParent() === NULL) { throw new \RuntimeException('Failed to render main part'); } $this->parent->renderMain($out); }
php
protected function renderMain(OutputBuffer $out) { if($this->getParent() === NULL) { throw new \RuntimeException('Failed to render main part'); } $this->parent->renderMain($out); }
[ "protected", "function", "renderMain", "(", "OutputBuffer", "$", "out", ")", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Failed to render main part'", ")", ";", "}", "$", "this", "->", "parent", "->", "renderMain", "(", "$", "out", ")", ";", "}" ]
Render main content of the view. @param OutputBuffer $out @throws \RuntimeException If no parent view is available.
[ "Render", "main", "content", "of", "the", "view", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L141-L149
25,271
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderBlock
public function renderBlock(OutputBuffer $out, $name) { $method = 'block_' . $name; if(method_exists($this, $method)) { $this->$method($out); } elseif($this->getParent() !== NULL) { $this->parent->renderBlock($out, $name); } else { throw new \RuntimeException(sprintf('Block not found: "%s"', $name)); } }
php
public function renderBlock(OutputBuffer $out, $name) { $method = 'block_' . $name; if(method_exists($this, $method)) { $this->$method($out); } elseif($this->getParent() !== NULL) { $this->parent->renderBlock($out, $name); } else { throw new \RuntimeException(sprintf('Block not found: "%s"', $name)); } }
[ "public", "function", "renderBlock", "(", "OutputBuffer", "$", "out", ",", "$", "name", ")", "{", "$", "method", "=", "'block_'", ".", "$", "name", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "this", "->", "$", "method", "(", "$", "out", ")", ";", "}", "elseif", "(", "$", "this", "->", "getParent", "(", ")", "!==", "NULL", ")", "{", "$", "this", "->", "parent", "->", "renderBlock", "(", "$", "out", ",", "$", "name", ")", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Block not found: \"%s\"'", ",", "$", "name", ")", ")", ";", "}", "}" ]
Render contents of a named block. @param OutputBuffer $out @param string $name Name of the block to be rendered. @throws \RuntimeException When no such block exists.
[ "Render", "contents", "of", "a", "named", "block", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L159-L175
25,272
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderParentBlock
public function renderParentBlock(OutputBuffer $out, $name) { if($this->getParent() === NULL) { throw new \RuntimeException('Cannot render parent block because no template is inherited'); } $this->parent->renderBlock($out, $name); }
php
public function renderParentBlock(OutputBuffer $out, $name) { if($this->getParent() === NULL) { throw new \RuntimeException('Cannot render parent block because no template is inherited'); } $this->parent->renderBlock($out, $name); }
[ "public", "function", "renderParentBlock", "(", "OutputBuffer", "$", "out", ",", "$", "name", ")", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot render parent block because no template is inherited'", ")", ";", "}", "$", "this", "->", "parent", "->", "renderBlock", "(", "$", "out", ",", "$", "name", ")", ";", "}" ]
Render a named block from the parent view. @param OutputBuffer $out @param string $name Name of the block to be rendered. @throws \RuntimeException When no parent view is available.
[ "Render", "a", "named", "block", "from", "the", "parent", "view", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L185-L193
25,273
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.inherit
public final function inherit(ExpressContext $context, ExpressionContextInterface $exp) { $this->context = $context; $this->exp = $exp; }
php
public final function inherit(ExpressContext $context, ExpressionContextInterface $exp) { $this->context = $context; $this->exp = $exp; }
[ "public", "final", "function", "inherit", "(", "ExpressContext", "$", "context", ",", "ExpressionContextInterface", "$", "exp", ")", "{", "$", "this", "->", "context", "=", "$", "context", ";", "$", "this", "->", "exp", "=", "$", "exp", ";", "}" ]
Inherit the given express context and bound expression context. @param ExpressContext $context @param ExpressionContextInterface $exp
[ "Inherit", "the", "given", "express", "context", "and", "bound", "expression", "context", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L241-L245
25,274
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.getParent
protected final function getParent() { if($this->parent === false) { if(NULL === ($file = $this->getExtended())) { $this->parent = NULL; } else { $typeName = $this->factory->createView($this->renderer, $this->resolveResource($file)); $this->parent = new $typeName($this->factory, $this->renderer); $this->parent->inherit($this->context, $this->exp); } } return $this->parent; }
php
protected final function getParent() { if($this->parent === false) { if(NULL === ($file = $this->getExtended())) { $this->parent = NULL; } else { $typeName = $this->factory->createView($this->renderer, $this->resolveResource($file)); $this->parent = new $typeName($this->factory, $this->renderer); $this->parent->inherit($this->context, $this->exp); } } return $this->parent; }
[ "protected", "final", "function", "getParent", "(", ")", "{", "if", "(", "$", "this", "->", "parent", "===", "false", ")", "{", "if", "(", "NULL", "===", "(", "$", "file", "=", "$", "this", "->", "getExtended", "(", ")", ")", ")", "{", "$", "this", "->", "parent", "=", "NULL", ";", "}", "else", "{", "$", "typeName", "=", "$", "this", "->", "factory", "->", "createView", "(", "$", "this", "->", "renderer", ",", "$", "this", "->", "resolveResource", "(", "$", "file", ")", ")", ";", "$", "this", "->", "parent", "=", "new", "$", "typeName", "(", "$", "this", "->", "factory", ",", "$", "this", "->", "renderer", ")", ";", "$", "this", "->", "parent", "->", "inherit", "(", "$", "this", "->", "context", ",", "$", "this", "->", "exp", ")", ";", "}", "}", "return", "$", "this", "->", "parent", ";", "}" ]
Get the parent view of this view or NULL if no parent view exists. @return CompiledTemplate
[ "Get", "the", "parent", "view", "of", "this", "view", "or", "NULL", "if", "no", "parent", "view", "exists", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L252-L270
25,275
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.resolveResource
protected final function resolveResource($file) { if(0 === strpos($file, './') || 0 === strpos($file, '../')) { $file = rtrim(dirname($this->getResource()), '/\\') . '/' . $file; } elseif(!preg_match("'^/|(?:[^:]+://)|(?:[a-z]:[\\\\/])'i", $file)) { $dir = rtrim(dirname($this->getResource()), '/\\'); $file = $dir . '/' . ltrim($file, '/\\'); } return (string)$file; }
php
protected final function resolveResource($file) { if(0 === strpos($file, './') || 0 === strpos($file, '../')) { $file = rtrim(dirname($this->getResource()), '/\\') . '/' . $file; } elseif(!preg_match("'^/|(?:[^:]+://)|(?:[a-z]:[\\\\/])'i", $file)) { $dir = rtrim(dirname($this->getResource()), '/\\'); $file = $dir . '/' . ltrim($file, '/\\'); } return (string)$file; }
[ "protected", "final", "function", "resolveResource", "(", "$", "file", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "file", ",", "'./'", ")", "||", "0", "===", "strpos", "(", "$", "file", ",", "'../'", ")", ")", "{", "$", "file", "=", "rtrim", "(", "dirname", "(", "$", "this", "->", "getResource", "(", ")", ")", ",", "'/\\\\'", ")", ".", "'/'", ".", "$", "file", ";", "}", "elseif", "(", "!", "preg_match", "(", "\"'^/|(?:[^:]+://)|(?:[a-z]:[\\\\\\\\/])'i\"", ",", "$", "file", ")", ")", "{", "$", "dir", "=", "rtrim", "(", "dirname", "(", "$", "this", "->", "getResource", "(", ")", ")", ",", "'/\\\\'", ")", ";", "$", "file", "=", "$", "dir", ".", "'/'", ".", "ltrim", "(", "$", "file", ",", "'/\\\\'", ")", ";", "}", "return", "(", "string", ")", "$", "file", ";", "}" ]
Resolve a path considering the location of the view if a relative path is given. @param string $file The path to be resolved. @return string
[ "Resolve", "a", "path", "considering", "the", "location", "of", "the", "view", "if", "a", "relative", "path", "is", "given", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L278-L291
25,276
gplcart/cli
controllers/commands/Database.php
Database.cmdTruncateDatabase
public function cmdTruncateDatabase() { $all = $this->getParam('all'); $tables = $this->getArguments(); if (empty($tables) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $confirm = null; if (!empty($tables)) { $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!')); } else if (!empty($all)) { $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!')); $tables = $this->db->fetchColumnAll('SHOW TABLES'); } if ($confirm === 'y') { foreach ($tables as $table) { $this->db->query("TRUNCATE TABLE `$table`")->execute(); } } $this->output(); }
php
public function cmdTruncateDatabase() { $all = $this->getParam('all'); $tables = $this->getArguments(); if (empty($tables) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $confirm = null; if (!empty($tables)) { $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!')); } else if (!empty($all)) { $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!')); $tables = $this->db->fetchColumnAll('SHOW TABLES'); } if ($confirm === 'y') { foreach ($tables as $table) { $this->db->query("TRUNCATE TABLE `$table`")->execute(); } } $this->output(); }
[ "public", "function", "cmdTruncateDatabase", "(", ")", "{", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "$", "tables", "=", "$", "this", "->", "getArguments", "(", ")", ";", "if", "(", "empty", "(", "$", "tables", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "confirm", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "tables", ")", ")", "{", "$", "confirm", "=", "$", "this", "->", "choose", "(", "$", "this", "->", "text", "(", "'Are you sure you want to empty the tables? It cannot be undone!'", ")", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "confirm", "=", "$", "this", "->", "choose", "(", "$", "this", "->", "text", "(", "'Are you sure you want to empty ALL tables in the database? It cannot be undone!'", ")", ")", ";", "$", "tables", "=", "$", "this", "->", "db", "->", "fetchColumnAll", "(", "'SHOW TABLES'", ")", ";", "}", "if", "(", "$", "confirm", "===", "'y'", ")", "{", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "db", "->", "query", "(", "\"TRUNCATE TABLE `$table`\"", ")", "->", "execute", "(", ")", ";", "}", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-truncate" command
[ "Callback", "for", "database", "-", "truncate", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L39-L64
25,277
gplcart/cli
controllers/commands/Database.php
Database.cmdAddDatabase
public function cmdAddDatabase() { $table = $this->getParam(0); $data = $this->getOptions(); if (empty($table) || empty($data)) { $this->errorAndExit($this->text('Invalid command')); } $this->line($this->db->insert($table, $data)); $this->output(); }
php
public function cmdAddDatabase() { $table = $this->getParam(0); $data = $this->getOptions(); if (empty($table) || empty($data)) { $this->errorAndExit($this->text('Invalid command')); } $this->line($this->db->insert($table, $data)); $this->output(); }
[ "public", "function", "cmdAddDatabase", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "data", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "empty", "(", "$", "table", ")", "||", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "this", "->", "db", "->", "insert", "(", "$", "table", ",", "$", "data", ")", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-add" command
[ "Callback", "for", "database", "-", "add", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L99-L110
25,278
gplcart/cli
controllers/commands/Database.php
Database.cmdDeleteDatabase
public function cmdDeleteDatabase() { $table = $this->getParam(0); $conditions = $this->getOptions(); if (empty($table) || empty($conditions)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->db->delete($table, $conditions)) { $this->errorAndExit($this->text('An error occurred')); } $this->output(); }
php
public function cmdDeleteDatabase() { $table = $this->getParam(0); $conditions = $this->getOptions(); if (empty($table) || empty($conditions)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->db->delete($table, $conditions)) { $this->errorAndExit($this->text('An error occurred')); } $this->output(); }
[ "public", "function", "cmdDeleteDatabase", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "conditions", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "empty", "(", "$", "table", ")", "||", "empty", "(", "$", "conditions", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "->", "delete", "(", "$", "table", ",", "$", "conditions", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'An error occurred'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-delete" command
[ "Callback", "for", "database", "-", "delete", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L115-L129
25,279
gplcart/cli
controllers/commands/Database.php
Database.cmdSqlDatabase
public function cmdSqlDatabase() { $sql = $this->getParam(0); if (empty($sql)) { $this->errorAndExit($this->text('Invalid command')); } $result = $this->db->query($sql); if ($this->getParam('fetch')) { $result = $result->fetchAll(\PDO::FETCH_ASSOC); $this->outputFormat($result); $this->outputFormatTableDatabase($result); } $this->output(); }
php
public function cmdSqlDatabase() { $sql = $this->getParam(0); if (empty($sql)) { $this->errorAndExit($this->text('Invalid command')); } $result = $this->db->query($sql); if ($this->getParam('fetch')) { $result = $result->fetchAll(\PDO::FETCH_ASSOC); $this->outputFormat($result); $this->outputFormatTableDatabase($result); } $this->output(); }
[ "public", "function", "cmdSqlDatabase", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "empty", "(", "$", "sql", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ")", ";", "if", "(", "$", "this", "->", "getParam", "(", "'fetch'", ")", ")", "{", "$", "result", "=", "$", "result", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableDatabase", "(", "$", "result", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-sql" command
[ "Callback", "for", "database", "-", "sql", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L134-L151
25,280
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.setDataSource
protected function setDataSource($dataSource) { if (is_array($dataSource) || $dataSource instanceof \Traversable) { foreach ($dataSource as $value) { $this->internalDataListData[] = $value; } return; } if (is_callable($dataSource)) { $this->internalDataListData = $dataSource; return; } throw new \InvalidArgumentException('The data argument must be iterable or a callback that returns such data.'); }
php
protected function setDataSource($dataSource) { if (is_array($dataSource) || $dataSource instanceof \Traversable) { foreach ($dataSource as $value) { $this->internalDataListData[] = $value; } return; } if (is_callable($dataSource)) { $this->internalDataListData = $dataSource; return; } throw new \InvalidArgumentException('The data argument must be iterable or a callback that returns such data.'); }
[ "protected", "function", "setDataSource", "(", "$", "dataSource", ")", "{", "if", "(", "is_array", "(", "$", "dataSource", ")", "||", "$", "dataSource", "instanceof", "\\", "Traversable", ")", "{", "foreach", "(", "$", "dataSource", "as", "$", "value", ")", "{", "$", "this", "->", "internalDataListData", "[", "]", "=", "$", "value", ";", "}", "return", ";", "}", "if", "(", "is_callable", "(", "$", "dataSource", ")", ")", "{", "$", "this", "->", "internalDataListData", "=", "$", "dataSource", ";", "return", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'The data argument must be iterable or a callback that returns such data.'", ")", ";", "}" ]
Sets a new data source for the list. @param array|iterable|callback $dataSource An array or an iterable containing objects or arrays that will be converted into data objects or a callback that returns such. The callback option enables lazy data loading. @throws \InvalidArgumentException
[ "Sets", "a", "new", "data", "source", "for", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L59-L72
25,281
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.get
public function get(int $index) { $this->internalDataListUpdate(); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } return null; }
php
public function get(int $index) { $this->internalDataListUpdate(); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } return null; }
[ "public", "function", "get", "(", "int", "$", "index", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "index", ")", ";", "}", "return", "null", ";", "}" ]
Returns the object at the index specified or null if not found. @param int $index The index of the item. @return object|null The object at the index specified or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "object", "at", "the", "index", "specified", "or", "null", "if", "not", "found", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L91-L98
25,282
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getFirst
public function getFirst() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); } return null; }
php
public function getFirst() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); } return null; }
[ "public", "function", "getFirst", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "0", ")", ";", "}", "return", "null", ";", "}" ]
Returns the first object or null if not found. @return object|null The first object or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "first", "object", "or", "null", "if", "not", "found", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L106-L113
25,283
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getLast
public function getLast() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if (isset($this->internalDataListData[$count - 1])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $count - 1); } return null; }
php
public function getLast() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if (isset($this->internalDataListData[$count - 1])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $count - 1); } return null; }
[ "public", "function", "getLast", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "$", "count", "=", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "count", "-", "1", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "count", "-", "1", ")", ";", "}", "return", "null", ";", "}" ]
Returns the last object or null if not found. @return object|null The last object or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "last", "object", "or", "null", "if", "not", "found", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L121-L129
25,284
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getRandom
public function getRandom() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if ($count > 0) { $index = rand(0, $count - 1); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } } return null; }
php
public function getRandom() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if ($count > 0) { $index = rand(0, $count - 1); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } } return null; }
[ "public", "function", "getRandom", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "$", "count", "=", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", ";", "if", "(", "$", "count", ">", "0", ")", "{", "$", "index", "=", "rand", "(", "0", ",", "$", "count", "-", "1", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "index", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns a random object from the list or null if the list is empty. @return object|null A random object from the list or null if the list is empty. @throws \InvalidArgumentException
[ "Returns", "a", "random", "object", "from", "the", "list", "or", "null", "if", "the", "list", "is", "empty", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L137-L148
25,285
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.filterBy
public function filterBy(string $property, $value, string $operator = 'equal'): self { if (array_search($operator, ['equal', 'notEqual', 'regExp', 'notRegExp', 'startWith', 'notStartWith', 'endWith', 'notEndWith', 'inArray', 'notInArray']) === false) { throw new \InvalidArgumentException('Invalid operator (' . $operator . ')'); } $this->internalDataListActions[] = ['filterBy', $property, $value, $operator]; return $this; }
php
public function filterBy(string $property, $value, string $operator = 'equal'): self { if (array_search($operator, ['equal', 'notEqual', 'regExp', 'notRegExp', 'startWith', 'notStartWith', 'endWith', 'notEndWith', 'inArray', 'notInArray']) === false) { throw new \InvalidArgumentException('Invalid operator (' . $operator . ')'); } $this->internalDataListActions[] = ['filterBy', $property, $value, $operator]; return $this; }
[ "public", "function", "filterBy", "(", "string", "$", "property", ",", "$", "value", ",", "string", "$", "operator", "=", "'equal'", ")", ":", "self", "{", "if", "(", "array_search", "(", "$", "operator", ",", "[", "'equal'", ",", "'notEqual'", ",", "'regExp'", ",", "'notRegExp'", ",", "'startWith'", ",", "'notStartWith'", ",", "'endWith'", ",", "'notEndWith'", ",", "'inArray'", ",", "'notInArray'", "]", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid operator ('", ".", "$", "operator", ".", "')'", ")", ";", "}", "$", "this", "->", "internalDataListActions", "[", "]", "=", "[", "'filterBy'", ",", "$", "property", ",", "$", "value", ",", "$", "operator", "]", ";", "return", "$", "this", ";", "}" ]
Filters the elements of the list by specific property value. @param string $property The property name. @param mixed $value The value of the property. @param string $operator Available values: equal, notEqual, regExp, notRegExp, startWith, notStartWith, endWith, notEndWith, inArray, notInArray. @return self A reference to the list. @throws \InvalidArgumentException
[ "Filters", "the", "elements", "of", "the", "list", "by", "specific", "property", "value", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L171-L178
25,286
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.sortBy
public function sortBy(string $property, string $order = 'asc'): self { if ($order !== 'asc' && $order !== 'desc') { throw new \InvalidArgumentException('The order argument \'asc\' or \'desc\''); } $this->internalDataListActions[] = ['sortBy', $property, $order]; return $this; }
php
public function sortBy(string $property, string $order = 'asc'): self { if ($order !== 'asc' && $order !== 'desc') { throw new \InvalidArgumentException('The order argument \'asc\' or \'desc\''); } $this->internalDataListActions[] = ['sortBy', $property, $order]; return $this; }
[ "public", "function", "sortBy", "(", "string", "$", "property", ",", "string", "$", "order", "=", "'asc'", ")", ":", "self", "{", "if", "(", "$", "order", "!==", "'asc'", "&&", "$", "order", "!==", "'desc'", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The order argument \\'asc\\' or \\'desc\\''", ")", ";", "}", "$", "this", "->", "internalDataListActions", "[", "]", "=", "[", "'sortBy'", ",", "$", "property", ",", "$", "order", "]", ";", "return", "$", "this", ";", "}" ]
Sorts the elements of the list by specific property. @param string $property The property name. @param string $order The sort order. @return self A reference to the list. @throws \InvalidArgumentException
[ "Sorts", "the", "elements", "of", "the", "list", "by", "specific", "property", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L200-L207
25,287
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.unshift
public function unshift($object): self { $this->internalDataListUpdate(); array_unshift($this->internalDataListData, $object); return $this; }
php
public function unshift($object): self { $this->internalDataListUpdate(); array_unshift($this->internalDataListData, $object); return $this; }
[ "public", "function", "unshift", "(", "$", "object", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "array_unshift", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Prepends an object to the beginning of the list. @param object|array $object The data to be prepended. @return self A reference to the list. @throws \InvalidArgumentException
[ "Prepends", "an", "object", "to", "the", "beginning", "of", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L250-L255
25,288
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.shift
public function shift() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); return array_shift($this->internalDataListData); } return null; }
php
public function shift() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); return array_shift($this->internalDataListData); } return null; }
[ "public", "function", "shift", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "0", ")", ";", "return", "array_shift", "(", "$", "this", "->", "internalDataListData", ")", ";", "}", "return", "null", ";", "}" ]
Shift an object off the beginning of the list. @return object|null Returns the shifted object or null if the list is empty. @throws \InvalidArgumentException
[ "Shift", "an", "object", "off", "the", "beginning", "of", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L263-L271
25,289
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.push
public function push($object): self { $this->internalDataListUpdate(); array_push($this->internalDataListData, $object); return $this; }
php
public function push($object): self { $this->internalDataListUpdate(); array_push($this->internalDataListData, $object); return $this; }
[ "public", "function", "push", "(", "$", "object", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "array_push", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Pushes an object onto the end of the list. @param object|array $object The data to be pushed. @return self A reference to the list. @throws \InvalidArgumentException
[ "Pushes", "an", "object", "onto", "the", "end", "of", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L280-L285
25,290
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.pop
public function pop() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, sizeof($this->internalDataListData) - 1); return array_pop($this->internalDataListData); } return null; }
php
public function pop() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, sizeof($this->internalDataListData) - 1); return array_pop($this->internalDataListData); } return null; }
[ "public", "function", "pop", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", "-", "1", ")", ";", "return", "array_pop", "(", "$", "this", "->", "internalDataListData", ")", ";", "}", "return", "null", ";", "}" ]
Pops an object off the end of the list. @return object|null Returns the popped object or null if the list is empty. @throws \InvalidArgumentException
[ "Pops", "an", "object", "off", "the", "end", "of", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L293-L301
25,291
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.concat
public function concat($list): self { $this->internalDataListUpdate(); foreach ($list as $object) { array_push($this->internalDataListData, $object); } return $this; }
php
public function concat($list): self { $this->internalDataListUpdate(); foreach ($list as $object) { array_push($this->internalDataListData, $object); } return $this; }
[ "public", "function", "concat", "(", "$", "list", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "object", ")", "{", "array_push", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends the items of the list provided to the current list. @param array|iterable $list A list to append after the current one. @return self A reference to the list. @throws \InvalidArgumentException
[ "Appends", "the", "items", "of", "the", "list", "provided", "to", "the", "current", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L310-L317
25,292
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.slice
public function slice(int $offset, int $length = null) { $actions = $this->internalDataListActions; $actions[] = ['slice', $offset, $length]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $slice = array_slice($data, $offset, $length); $className = get_class($this); $list = new $className(); foreach ($slice as $object) { $list->push($object); } return $list; }
php
public function slice(int $offset, int $length = null) { $actions = $this->internalDataListActions; $actions[] = ['slice', $offset, $length]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $slice = array_slice($data, $offset, $length); $className = get_class($this); $list = new $className(); foreach ($slice as $object) { $list->push($object); } return $list; }
[ "public", "function", "slice", "(", "int", "$", "offset", ",", "int", "$", "length", "=", "null", ")", "{", "$", "actions", "=", "$", "this", "->", "internalDataListActions", ";", "$", "actions", "[", "]", "=", "[", "'slice'", ",", "$", "offset", ",", "$", "length", "]", ";", "$", "data", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "actions", ")", ";", "$", "slice", "=", "array_slice", "(", "$", "data", ",", "$", "offset", ",", "$", "length", ")", ";", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "list", "=", "new", "$", "className", "(", ")", ";", "foreach", "(", "$", "slice", "as", "$", "object", ")", "{", "$", "list", "->", "push", "(", "$", "object", ")", ";", "}", "return", "$", "list", ";", "}" ]
Extract a slice of the list. @param int $offset The index position where the extraction should begin @param int $length The max length of the items in the extracted slice. @return mixed Returns a slice of the list. @throws \InvalidArgumentException
[ "Extract", "a", "slice", "of", "the", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L327-L339
25,293
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.sliceProperties
public function sliceProperties(array $properties) { $actions = $this->internalDataListActions; $actions[] = ['sliceProperties', $properties]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $className = get_class($this); $list = new $className(); $class = $this->internalDataListClasses['IvoPetkov\DataListObject']; $tempObject = new $class(); foreach ($data as $index => $object) { $object = $this->internalDataListUpdateValueIfNeeded($data, $index); $newObject = clone($tempObject); foreach ($properties as $property) { $newObject[$property] = isset($object->$property) ? $object->$property : null; } $list->push($newObject); } return $list; }
php
public function sliceProperties(array $properties) { $actions = $this->internalDataListActions; $actions[] = ['sliceProperties', $properties]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $className = get_class($this); $list = new $className(); $class = $this->internalDataListClasses['IvoPetkov\DataListObject']; $tempObject = new $class(); foreach ($data as $index => $object) { $object = $this->internalDataListUpdateValueIfNeeded($data, $index); $newObject = clone($tempObject); foreach ($properties as $property) { $newObject[$property] = isset($object->$property) ? $object->$property : null; } $list->push($newObject); } return $list; }
[ "public", "function", "sliceProperties", "(", "array", "$", "properties", ")", "{", "$", "actions", "=", "$", "this", "->", "internalDataListActions", ";", "$", "actions", "[", "]", "=", "[", "'sliceProperties'", ",", "$", "properties", "]", ";", "$", "data", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "actions", ")", ";", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "list", "=", "new", "$", "className", "(", ")", ";", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListObject'", "]", ";", "$", "tempObject", "=", "new", "$", "class", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "object", ")", "{", "$", "object", "=", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "data", ",", "$", "index", ")", ";", "$", "newObject", "=", "clone", "(", "$", "tempObject", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "newObject", "[", "$", "property", "]", "=", "isset", "(", "$", "object", "->", "$", "property", ")", "?", "$", "object", "->", "$", "property", ":", "null", ";", "}", "$", "list", "->", "push", "(", "$", "newObject", ")", ";", "}", "return", "$", "list", ";", "}" ]
Returns a new list of object that contain only the specified properties of the objects in the current list. @param array $properties The list of property names. @return mixed Returns a new list.
[ "Returns", "a", "new", "list", "of", "object", "that", "contain", "only", "the", "specified", "properties", "of", "the", "objects", "in", "the", "current", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L347-L365
25,294
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdateValueIfNeeded
private function internalDataListUpdateValueIfNeeded(&$data, $index) { $value = $data[$index]; if (is_callable($value)) { $value = call_user_func($value); $data[$index] = $value; } if (is_object($value)) { return $value; } $value = (object) $value; $data[$index] = $value; return $value; }
php
private function internalDataListUpdateValueIfNeeded(&$data, $index) { $value = $data[$index]; if (is_callable($value)) { $value = call_user_func($value); $data[$index] = $value; } if (is_object($value)) { return $value; } $value = (object) $value; $data[$index] = $value; return $value; }
[ "private", "function", "internalDataListUpdateValueIfNeeded", "(", "&", "$", "data", ",", "$", "index", ")", "{", "$", "value", "=", "$", "data", "[", "$", "index", "]", ";", "if", "(", "is_callable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "value", ")", ";", "$", "data", "[", "$", "index", "]", "=", "$", "value", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "(", "object", ")", "$", "value", ";", "$", "data", "[", "$", "index", "]", "=", "$", "value", ";", "return", "$", "value", ";", "}" ]
Converts the value into object if needed. @param int $index
[ "Converts", "the", "value", "into", "object", "if", "needed", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L383-L396
25,295
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdateAllValuesIfNeeded
private function internalDataListUpdateAllValuesIfNeeded(&$data) { foreach ($data as $index => $value) { $this->internalDataListUpdateValueIfNeeded($data, $index); } }
php
private function internalDataListUpdateAllValuesIfNeeded(&$data) { foreach ($data as $index => $value) { $this->internalDataListUpdateValueIfNeeded($data, $index); } }
[ "private", "function", "internalDataListUpdateAllValuesIfNeeded", "(", "&", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "data", ",", "$", "index", ")", ";", "}", "}" ]
Converts all values into objects if needed.
[ "Converts", "all", "values", "into", "objects", "if", "needed", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L401-L406
25,296
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdate
private function internalDataListUpdate() { $this->internalDataListData = $this->internalDataListUpdateData($this->internalDataListData, $this->internalDataListActions); $this->internalDataListActions = []; }
php
private function internalDataListUpdate() { $this->internalDataListData = $this->internalDataListUpdateData($this->internalDataListData, $this->internalDataListActions); $this->internalDataListActions = []; }
[ "private", "function", "internalDataListUpdate", "(", ")", "{", "$", "this", "->", "internalDataListData", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "this", "->", "internalDataListActions", ")", ";", "$", "this", "->", "internalDataListActions", "=", "[", "]", ";", "}" ]
Applies the pending actions to the data list. @throws \InvalidArgumentException
[ "Applies", "the", "pending", "actions", "to", "the", "data", "list", "." ]
024039017fd9e6e3aca6edbad79aaf45764b8991
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L413-L417
25,297
CrunchPHP/fastcgi
src/Protocol/Record.php
Record.encode
public function encode() { return $this->header->encode() . $this->getContent() . \str_repeat("\0", $this->header->getPaddingLength()); }
php
public function encode() { return $this->header->encode() . $this->getContent() . \str_repeat("\0", $this->header->getPaddingLength()); }
[ "public", "function", "encode", "(", ")", "{", "return", "$", "this", "->", "header", "->", "encode", "(", ")", ".", "$", "this", "->", "getContent", "(", ")", ".", "\\", "str_repeat", "(", "\"\\0\"", ",", "$", "this", "->", "header", "->", "getPaddingLength", "(", ")", ")", ";", "}" ]
Compiles record into struct to send. @return string
[ "Compiles", "record", "into", "struct", "to", "send", "." ]
102437193e67e5a841ec5a897549ec345788d1bd
https://github.com/CrunchPHP/fastcgi/blob/102437193e67e5a841ec5a897549ec345788d1bd/src/Protocol/Record.php#L59-L62
25,298
horntell/php-sdk
lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php
MultiAdapter.throwMultiError
public static function throwMultiError($code) { $buffer = function_exists('curl_multi_strerror') ? curl_multi_strerror($code) : self::ERROR_STR; throw new AdapterException(sprintf('cURL error %s: %s', $code, $buffer)); }
php
public static function throwMultiError($code) { $buffer = function_exists('curl_multi_strerror') ? curl_multi_strerror($code) : self::ERROR_STR; throw new AdapterException(sprintf('cURL error %s: %s', $code, $buffer)); }
[ "public", "static", "function", "throwMultiError", "(", "$", "code", ")", "{", "$", "buffer", "=", "function_exists", "(", "'curl_multi_strerror'", ")", "?", "curl_multi_strerror", "(", "$", "code", ")", ":", "self", "::", "ERROR_STR", ";", "throw", "new", "AdapterException", "(", "sprintf", "(", "'cURL error %s: %s'", ",", "$", "code", ",", "$", "buffer", ")", ")", ";", "}" ]
Throw an exception for a cURL multi response @param int $code Curl response code @throws AdapterException
[ "Throw", "an", "exception", "for", "a", "cURL", "multi", "response" ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php#L98-L105
25,299
horntell/php-sdk
lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php
MultiAdapter.checkoutMultiHandle
private function checkoutMultiHandle() { // Find an unused handle in the cache $key = array_search(false, $this->multiOwned, true); if (false !== $key) { $this->multiOwned[$key] = true; return $this->multiHandles[$key]; } // Add a new handle $handle = curl_multi_init(); $id = (int) $handle; $this->multiHandles[$id] = $handle; $this->multiOwned[$id] = true; return $handle; }
php
private function checkoutMultiHandle() { // Find an unused handle in the cache $key = array_search(false, $this->multiOwned, true); if (false !== $key) { $this->multiOwned[$key] = true; return $this->multiHandles[$key]; } // Add a new handle $handle = curl_multi_init(); $id = (int) $handle; $this->multiHandles[$id] = $handle; $this->multiOwned[$id] = true; return $handle; }
[ "private", "function", "checkoutMultiHandle", "(", ")", "{", "// Find an unused handle in the cache", "$", "key", "=", "array_search", "(", "false", ",", "$", "this", "->", "multiOwned", ",", "true", ")", ";", "if", "(", "false", "!==", "$", "key", ")", "{", "$", "this", "->", "multiOwned", "[", "$", "key", "]", "=", "true", ";", "return", "$", "this", "->", "multiHandles", "[", "$", "key", "]", ";", "}", "// Add a new handle", "$", "handle", "=", "curl_multi_init", "(", ")", ";", "$", "id", "=", "(", "int", ")", "$", "handle", ";", "$", "this", "->", "multiHandles", "[", "$", "id", "]", "=", "$", "handle", ";", "$", "this", "->", "multiOwned", "[", "$", "id", "]", "=", "true", ";", "return", "$", "handle", ";", "}" ]
Returns a curl_multi handle from the cache or creates a new one @return resource
[ "Returns", "a", "curl_multi", "handle", "from", "the", "cache", "or", "creates", "a", "new", "one" ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php#L270-L286