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
18,200
steeffeen/FancyManiaLinks
FML/Script/Script.php
Script.render
public function render(\DOMDocument $domDocument) { $this->loadFeatures($this->features); $scriptXml = $domDocument->createElement("script"); $scriptText = $this->buildScriptText(); $scriptComment = $domDocument->createComment($scriptText); $scriptXml->appendChild($scriptComment); return $scriptXml; }
php
public function render(\DOMDocument $domDocument) { $this->loadFeatures($this->features); $scriptXml = $domDocument->createElement("script"); $scriptText = $this->buildScriptText(); $scriptComment = $domDocument->createComment($scriptText); $scriptXml->appendChild($scriptComment); return $scriptXml; }
[ "public", "function", "render", "(", "\\", "DOMDocument", "$", "domDocument", ")", "{", "$", "this", "->", "loadFeatures", "(", "$", "this", "->", "features", ")", ";", "$", "scriptXml", "=", "$", "domDocument", "->", "createElement", "(", "\"script\"", ")", ";", "$", "scriptText", "=", "$", "this", "->", "buildScriptText", "(", ")", ";", "$", "scriptComment", "=", "$", "domDocument", "->", "createComment", "(", "$", "scriptText", ")", ";", "$", "scriptXml", "->", "appendChild", "(", "$", "scriptComment", ")", ";", "return", "$", "scriptXml", ";", "}" ]
Render the Script @param \DOMDocument $domDocument DOMDocument for which the Script should be created @return \DOMElement
[ "Render", "the", "Script" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Script.php#L290-L301
18,201
steeffeen/FancyManiaLinks
FML/Script/Script.php
Script.getLabels
protected function getLabels() { $customLabelsText = implode(PHP_EOL, $this->customLabels); $genericLabelsText = implode(PHP_EOL, $this->genericLabels); return $customLabelsText . $genericLabelsText; }
php
protected function getLabels() { $customLabelsText = implode(PHP_EOL, $this->customLabels); $genericLabelsText = implode(PHP_EOL, $this->genericLabels); return $customLabelsText . $genericLabelsText; }
[ "protected", "function", "getLabels", "(", ")", "{", "$", "customLabelsText", "=", "implode", "(", "PHP_EOL", ",", "$", "this", "->", "customLabels", ")", ";", "$", "genericLabelsText", "=", "implode", "(", "PHP_EOL", ",", "$", "this", "->", "genericLabels", ")", ";", "return", "$", "customLabelsText", ".", "$", "genericLabelsText", ";", "}" ]
Get the Labels text @return string
[ "Get", "the", "Labels", "text" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Script.php#L361-L366
18,202
steeffeen/FancyManiaLinks
FML/Script/Script.php
Script.getMainFunction
protected function getMainFunction() { $mainFunction = ' Void FML_Dummy() {} main() { declare ' . self::VAR_ScriptStart . ' = Now; +++' . ScriptLabel::ONINIT . '+++ declare ' . self::VAR_LoopCounter . ' = 0; declare ' . self::VAR_LastTick . ' = 0; while (True) { yield; foreach (Event in PendingEvents) { switch (Event.Type) { case CMlEvent::Type::EntrySubmit: { +++' . ScriptLabel::ENTRYSUBMIT . '+++ } case CMlEvent::Type::KeyPress: { +++' . ScriptLabel::KEYPRESS . '+++ } case CMlEvent::Type::MouseClick: { +++' . ScriptLabel::MOUSECLICK . '+++ +++' . ScriptLabel::MOUSECLICK2 . '+++ } case CMlEvent::Type::MouseOut: { +++' . ScriptLabel::MOUSEOUT . '+++ } case CMlEvent::Type::MouseOver: { +++' . ScriptLabel::MOUSEOVER . '+++ } } } +++' . ScriptLabel::LOOP . '+++ ' . self::VAR_LoopCounter . ' += 1; if (' . self::VAR_LastTick . ' + ' . self::TICKINTERVAL . ' > Now) continue; +++' . ScriptLabel::TICK . '+++ ' . self::VAR_LastTick . ' = Now; } }'; return $mainFunction; }
php
protected function getMainFunction() { $mainFunction = ' Void FML_Dummy() {} main() { declare ' . self::VAR_ScriptStart . ' = Now; +++' . ScriptLabel::ONINIT . '+++ declare ' . self::VAR_LoopCounter . ' = 0; declare ' . self::VAR_LastTick . ' = 0; while (True) { yield; foreach (Event in PendingEvents) { switch (Event.Type) { case CMlEvent::Type::EntrySubmit: { +++' . ScriptLabel::ENTRYSUBMIT . '+++ } case CMlEvent::Type::KeyPress: { +++' . ScriptLabel::KEYPRESS . '+++ } case CMlEvent::Type::MouseClick: { +++' . ScriptLabel::MOUSECLICK . '+++ +++' . ScriptLabel::MOUSECLICK2 . '+++ } case CMlEvent::Type::MouseOut: { +++' . ScriptLabel::MOUSEOUT . '+++ } case CMlEvent::Type::MouseOver: { +++' . ScriptLabel::MOUSEOVER . '+++ } } } +++' . ScriptLabel::LOOP . '+++ ' . self::VAR_LoopCounter . ' += 1; if (' . self::VAR_LastTick . ' + ' . self::TICKINTERVAL . ' > Now) continue; +++' . ScriptLabel::TICK . '+++ ' . self::VAR_LastTick . ' = Now; } }'; return $mainFunction; }
[ "protected", "function", "getMainFunction", "(", ")", "{", "$", "mainFunction", "=", "'\nVoid FML_Dummy() {}\nmain() {\n\tdeclare '", ".", "self", "::", "VAR_ScriptStart", ".", "' = Now;\n\t+++'", ".", "ScriptLabel", "::", "ONINIT", ".", "'+++\n\tdeclare '", ".", "self", "::", "VAR_LoopCounter", ".", "' = 0;\n\tdeclare '", ".", "self", "::", "VAR_LastTick", ".", "' = 0;\n\twhile (True) {\n\t\tyield;\n\t\tforeach (Event in PendingEvents) {\n\t\t\tswitch (Event.Type) {\n\t\t\t\tcase CMlEvent::Type::EntrySubmit: {\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "ENTRYSUBMIT", ".", "'+++\n\t\t\t\t}\n\t\t\t\tcase CMlEvent::Type::KeyPress: {\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "KEYPRESS", ".", "'+++\n\t\t\t\t}\n\t\t\t\tcase CMlEvent::Type::MouseClick: {\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "MOUSECLICK", ".", "'+++\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "MOUSECLICK2", ".", "'+++\n\t\t\t\t}\n\t\t\t\tcase CMlEvent::Type::MouseOut: {\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "MOUSEOUT", ".", "'+++\n\t\t\t\t}\n\t\t\t\tcase CMlEvent::Type::MouseOver: {\n\t\t\t\t\t+++'", ".", "ScriptLabel", "::", "MOUSEOVER", ".", "'+++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t+++'", ".", "ScriptLabel", "::", "LOOP", ".", "'+++\n\t\t'", ".", "self", "::", "VAR_LoopCounter", ".", "' += 1;\n\t\tif ('", ".", "self", "::", "VAR_LastTick", ".", "' + '", ".", "self", "::", "TICKINTERVAL", ".", "' > Now) continue;\n\t\t+++'", ".", "ScriptLabel", "::", "TICK", ".", "'+++ \n\t\t'", ".", "self", "::", "VAR_LastTick", ".", "' = Now;\n\t}\n}'", ";", "return", "$", "mainFunction", ";", "}" ]
Get the main function text @return string
[ "Get", "the", "main", "function", "text" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Script.php#L373-L412
18,203
simple-php-mvc/simple-php-mvc
src/MVC/REST/REST.php
REST.setData
protected function setData(&$connect, $data, $content_type) { if ($content_type == "application/json") { if (gettype($data) == "string") { json_decode($data, true); } else { $data = json_encode($data); } if (function_exists('json_last_error')) { $json_error = json_last_error(); if ($json_error != JSON_ERROR_NONE) { throw new Exception("JSON Error [{$json_error}] - Data: {$data}"); } } } curl_setopt($connect, CURLOPT_POSTFIELDS, $data); }
php
protected function setData(&$connect, $data, $content_type) { if ($content_type == "application/json") { if (gettype($data) == "string") { json_decode($data, true); } else { $data = json_encode($data); } if (function_exists('json_last_error')) { $json_error = json_last_error(); if ($json_error != JSON_ERROR_NONE) { throw new Exception("JSON Error [{$json_error}] - Data: {$data}"); } } } curl_setopt($connect, CURLOPT_POSTFIELDS, $data); }
[ "protected", "function", "setData", "(", "&", "$", "connect", ",", "$", "data", ",", "$", "content_type", ")", "{", "if", "(", "$", "content_type", "==", "\"application/json\"", ")", "{", "if", "(", "gettype", "(", "$", "data", ")", "==", "\"string\"", ")", "{", "json_decode", "(", "$", "data", ",", "true", ")", ";", "}", "else", "{", "$", "data", "=", "json_encode", "(", "$", "data", ")", ";", "}", "if", "(", "function_exists", "(", "'json_last_error'", ")", ")", "{", "$", "json_error", "=", "json_last_error", "(", ")", ";", "if", "(", "$", "json_error", "!=", "JSON_ERROR_NONE", ")", "{", "throw", "new", "Exception", "(", "\"JSON Error [{$json_error}] - Data: {$data}\"", ")", ";", "}", "}", "}", "curl_setopt", "(", "$", "connect", ",", "CURLOPT_POSTFIELDS", ",", "$", "data", ")", ";", "}" ]
Sets the data request @access protected @param resource $connect @param type $data @param string $content_type @return void @throws \Exception
[ "Sets", "the", "data", "request" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/REST/REST.php#L72-L90
18,204
simple-php-mvc/simple-php-mvc
src/MVC/REST/REST.php
REST.exec
protected function exec($method, $uri, $data, $content_type) { $connect = $this->getConnect($uri, $method, $content_type); if ($data) { $this->setData($connect, $data, $content_type); } $api_result = curl_exec($connect); $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE); $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME); $response = array( "status" => $api_http_code, "total_time" => $api_http_time, ); if ($content_type == "application/json") { $response["response"] = json_decode($api_result, true); } elseif ($content_type == "text/html") { $response["response"] = $api_result; } if ($response['status'] >= 400) { throw new Exception($response['response'], $response['status']); } curl_close($connect); return $response; }
php
protected function exec($method, $uri, $data, $content_type) { $connect = $this->getConnect($uri, $method, $content_type); if ($data) { $this->setData($connect, $data, $content_type); } $api_result = curl_exec($connect); $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE); $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME); $response = array( "status" => $api_http_code, "total_time" => $api_http_time, ); if ($content_type == "application/json") { $response["response"] = json_decode($api_result, true); } elseif ($content_type == "text/html") { $response["response"] = $api_result; } if ($response['status'] >= 400) { throw new Exception($response['response'], $response['status']); } curl_close($connect); return $response; }
[ "protected", "function", "exec", "(", "$", "method", ",", "$", "uri", ",", "$", "data", ",", "$", "content_type", ")", "{", "$", "connect", "=", "$", "this", "->", "getConnect", "(", "$", "uri", ",", "$", "method", ",", "$", "content_type", ")", ";", "if", "(", "$", "data", ")", "{", "$", "this", "->", "setData", "(", "$", "connect", ",", "$", "data", ",", "$", "content_type", ")", ";", "}", "$", "api_result", "=", "curl_exec", "(", "$", "connect", ")", ";", "$", "api_http_code", "=", "curl_getinfo", "(", "$", "connect", ",", "CURLINFO_HTTP_CODE", ")", ";", "$", "api_http_time", "=", "curl_getinfo", "(", "$", "connect", ",", "CURLINFO_TOTAL_TIME", ")", ";", "$", "response", "=", "array", "(", "\"status\"", "=>", "$", "api_http_code", ",", "\"total_time\"", "=>", "$", "api_http_time", ",", ")", ";", "if", "(", "$", "content_type", "==", "\"application/json\"", ")", "{", "$", "response", "[", "\"response\"", "]", "=", "json_decode", "(", "$", "api_result", ",", "true", ")", ";", "}", "elseif", "(", "$", "content_type", "==", "\"text/html\"", ")", "{", "$", "response", "[", "\"response\"", "]", "=", "$", "api_result", ";", "}", "if", "(", "$", "response", "[", "'status'", "]", ">=", "400", ")", "{", "throw", "new", "Exception", "(", "$", "response", "[", "'response'", "]", ",", "$", "response", "[", "'status'", "]", ")", ";", "}", "curl_close", "(", "$", "connect", ")", ";", "return", "$", "response", ";", "}" ]
Executes the request @access protected @param string $method @param string $uri @param type $data @param string $content_type @return array @throws \Exception
[ "Executes", "the", "request" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/REST/REST.php#L102-L131
18,205
Double-Opt-in/php-client-api
src/Client/Commands/Responses/StatusResponse.php
StatusResponse.status
public function status() { if ($this->status === null) { $stdClass = $this->decoded(); if ( ! $stdClass instanceof stdClass) return null; $this->status = $this->resolveStatusFromStdClass($stdClass); } return $this->status; }
php
public function status() { if ($this->status === null) { $stdClass = $this->decoded(); if ( ! $stdClass instanceof stdClass) return null; $this->status = $this->resolveStatusFromStdClass($stdClass); } return $this->status; }
[ "public", "function", "status", "(", ")", "{", "if", "(", "$", "this", "->", "status", "===", "null", ")", "{", "$", "stdClass", "=", "$", "this", "->", "decoded", "(", ")", ";", "if", "(", "!", "$", "stdClass", "instanceof", "stdClass", ")", "return", "null", ";", "$", "this", "->", "status", "=", "$", "this", "->", "resolveStatusFromStdClass", "(", "$", "stdClass", ")", ";", "}", "return", "$", "this", "->", "status", ";", "}" ]
returns the status model @return Status|null
[ "returns", "the", "status", "model" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/StatusResponse.php#L27-L38
18,206
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/LocationManager.php
LocationManager.getLocationByObject
private function getLocationByObject(ValueObject $object) { $contentInfo = $this->contentService->loadContentInfo($object->data['content_id']); $locations = $this->locationService->loadLocations($contentInfo); foreach ($locations as $loc) { if ($loc->parentLocationId === $object->data['parent_location_id']) { return $loc; } } return; }
php
private function getLocationByObject(ValueObject $object) { $contentInfo = $this->contentService->loadContentInfo($object->data['content_id']); $locations = $this->locationService->loadLocations($contentInfo); foreach ($locations as $loc) { if ($loc->parentLocationId === $object->data['parent_location_id']) { return $loc; } } return; }
[ "private", "function", "getLocationByObject", "(", "ValueObject", "$", "object", ")", "{", "$", "contentInfo", "=", "$", "this", "->", "contentService", "->", "loadContentInfo", "(", "$", "object", "->", "data", "[", "'content_id'", "]", ")", ";", "$", "locations", "=", "$", "this", "->", "locationService", "->", "loadLocations", "(", "$", "contentInfo", ")", ";", "foreach", "(", "$", "locations", "as", "$", "loc", ")", "{", "if", "(", "$", "loc", "->", "parentLocationId", "===", "$", "object", "->", "data", "[", "'parent_location_id'", "]", ")", "{", "return", "$", "loc", ";", "}", "}", "return", ";", "}" ]
Get location by content_id and parent_location_id. @param ValueObject $object @return Location|null
[ "Get", "location", "by", "content_id", "and", "parent_location_id", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/LocationManager.php#L99-L110
18,207
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/LocationManager.php
LocationManager.toggleVisibility
public function toggleVisibility(Location $location) { if ($location->hidden) { return $this->unHide($location); } return $this->hide($location); }
php
public function toggleVisibility(Location $location) { if ($location->hidden) { return $this->unHide($location); } return $this->hide($location); }
[ "public", "function", "toggleVisibility", "(", "Location", "$", "location", ")", "{", "if", "(", "$", "location", "->", "hidden", ")", "{", "return", "$", "this", "->", "unHide", "(", "$", "location", ")", ";", "}", "return", "$", "this", "->", "hide", "(", "$", "location", ")", ";", "}" ]
Toggles location visibility. @param Location $location @return Location
[ "Toggles", "location", "visibility", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/LocationManager.php#L302-L309
18,208
yuncms/framework
src/helpers/FileHelper.php
FileHelper.cleanDirectory
public static function cleanDirectory(string $directory): bool { self::removeDirectory($directory); return self::createDirectory($directory); }
php
public static function cleanDirectory(string $directory): bool { self::removeDirectory($directory); return self::createDirectory($directory); }
[ "public", "static", "function", "cleanDirectory", "(", "string", "$", "directory", ")", ":", "bool", "{", "self", "::", "removeDirectory", "(", "$", "directory", ")", ";", "return", "self", "::", "createDirectory", "(", "$", "directory", ")", ";", "}" ]
Empty the specified directory of all files and folders. @param string $directory @return bool @throws \yii\base\ErrorException @throws Exception
[ "Empty", "the", "specified", "directory", "of", "all", "files", "and", "folders", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/FileHelper.php#L164-L168
18,209
yuncms/framework
src/helpers/FileHelper.php
FileHelper.isAbsolutePath
public static function isAbsolutePath($path): bool { return strspn($path, '/\\', 0, 1) || (strlen($path) > 3 && ctype_alpha($path[0]) && ':' === $path[1] && strspn($path, '/\\', 2, 1) ) || null !== parse_url($path, PHP_URL_SCHEME); }
php
public static function isAbsolutePath($path): bool { return strspn($path, '/\\', 0, 1) || (strlen($path) > 3 && ctype_alpha($path[0]) && ':' === $path[1] && strspn($path, '/\\', 2, 1) ) || null !== parse_url($path, PHP_URL_SCHEME); }
[ "public", "static", "function", "isAbsolutePath", "(", "$", "path", ")", ":", "bool", "{", "return", "strspn", "(", "$", "path", ",", "'/\\\\'", ",", "0", ",", "1", ")", "||", "(", "strlen", "(", "$", "path", ")", ">", "3", "&&", "ctype_alpha", "(", "$", "path", "[", "0", "]", ")", "&&", "':'", "===", "$", "path", "[", "1", "]", "&&", "strspn", "(", "$", "path", ",", "'/\\\\'", ",", "2", ",", "1", ")", ")", "||", "null", "!==", "parse_url", "(", "$", "path", ",", "PHP_URL_SCHEME", ")", ";", "}" ]
Returns whether the file path is an absolute path. @param string $path A file path @return bool
[ "Returns", "whether", "the", "file", "path", "is", "an", "absolute", "path", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/FileHelper.php#L214-L222
18,210
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.path
public static function path( $name, $time = null ) { if ( is_null( $time ) ) { $time = time(); } $namespace = null; if ( strpos( $name, '::' ) !== false ) { list( $namespace, $name ) = explode( '::', $name ); } $name = explode( '/', $name ); foreach( $name as $key => $value ) { $name[$key] = \CCStr::clean_url( $value, '_' ); } $name = implode( '/', $name ); return \CCPath::get( ( $namespace ? $namespace.'::' : '' ) .$name.'_'.$time, \ClanCats::directory( 'migration' ), '.sql' ); }
php
public static function path( $name, $time = null ) { if ( is_null( $time ) ) { $time = time(); } $namespace = null; if ( strpos( $name, '::' ) !== false ) { list( $namespace, $name ) = explode( '::', $name ); } $name = explode( '/', $name ); foreach( $name as $key => $value ) { $name[$key] = \CCStr::clean_url( $value, '_' ); } $name = implode( '/', $name ); return \CCPath::get( ( $namespace ? $namespace.'::' : '' ) .$name.'_'.$time, \ClanCats::directory( 'migration' ), '.sql' ); }
[ "public", "static", "function", "path", "(", "$", "name", ",", "$", "time", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "time", ")", ")", "{", "$", "time", "=", "time", "(", ")", ";", "}", "$", "namespace", "=", "null", ";", "if", "(", "strpos", "(", "$", "name", ",", "'::'", ")", "!==", "false", ")", "{", "list", "(", "$", "namespace", ",", "$", "name", ")", "=", "explode", "(", "'::'", ",", "$", "name", ")", ";", "}", "$", "name", "=", "explode", "(", "'/'", ",", "$", "name", ")", ";", "foreach", "(", "$", "name", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "name", "[", "$", "key", "]", "=", "\\", "CCStr", "::", "clean_url", "(", "$", "value", ",", "'_'", ")", ";", "}", "$", "name", "=", "implode", "(", "'/'", ",", "$", "name", ")", ";", "return", "\\", "CCPath", "::", "get", "(", "(", "$", "namespace", "?", "$", "namespace", ".", "'::'", ":", "''", ")", ".", "$", "name", ".", "'_'", ".", "$", "time", ",", "\\", "ClanCats", "::", "directory", "(", "'migration'", ")", ",", "'.sql'", ")", ";", "}" ]
Get a migration path by name @param string $name @return string
[ "Get", "a", "migration", "path", "by", "name" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L38-L62
18,211
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.migrate
public static function migrate( $silent = false ) { $migrations = $silent ? static::available() : static::unstaged(); foreach( $migrations as $key => $value ) { if ( empty( $value ) ) { continue; } if ( \ClanCats::is_cli() ) { \CCCli::info( 'found new "'.$key.'" migrations.' ); } foreach( $value as $time => $path ) { $migration = new static( $path ); // run the migration $migration->up(); if ( \ClanCats::is_cli() ) { \CCCli::success( 'migrated '.$migration->name() ); } } static::$config->set( $key.'.revision', $time ); } if ( !$silent ) { static::$config->write(); } }
php
public static function migrate( $silent = false ) { $migrations = $silent ? static::available() : static::unstaged(); foreach( $migrations as $key => $value ) { if ( empty( $value ) ) { continue; } if ( \ClanCats::is_cli() ) { \CCCli::info( 'found new "'.$key.'" migrations.' ); } foreach( $value as $time => $path ) { $migration = new static( $path ); // run the migration $migration->up(); if ( \ClanCats::is_cli() ) { \CCCli::success( 'migrated '.$migration->name() ); } } static::$config->set( $key.'.revision', $time ); } if ( !$silent ) { static::$config->write(); } }
[ "public", "static", "function", "migrate", "(", "$", "silent", "=", "false", ")", "{", "$", "migrations", "=", "$", "silent", "?", "static", "::", "available", "(", ")", ":", "static", "::", "unstaged", "(", ")", ";", "foreach", "(", "$", "migrations", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "if", "(", "\\", "ClanCats", "::", "is_cli", "(", ")", ")", "{", "\\", "CCCli", "::", "info", "(", "'found new \"'", ".", "$", "key", ".", "'\" migrations.'", ")", ";", "}", "foreach", "(", "$", "value", "as", "$", "time", "=>", "$", "path", ")", "{", "$", "migration", "=", "new", "static", "(", "$", "path", ")", ";", "// run the migration", "$", "migration", "->", "up", "(", ")", ";", "if", "(", "\\", "ClanCats", "::", "is_cli", "(", ")", ")", "{", "\\", "CCCli", "::", "success", "(", "'migrated '", ".", "$", "migration", "->", "name", "(", ")", ")", ";", "}", "}", "static", "::", "$", "config", "->", "set", "(", "$", "key", ".", "'.revision'", ",", "$", "time", ")", ";", "}", "if", "(", "!", "$", "silent", ")", "{", "static", "::", "$", "config", "->", "write", "(", ")", ";", "}", "}" ]
Run all new migration @param bool $silent In the silent mode the migrator ignores the migration file @return void
[ "Run", "all", "new", "migration" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L71-L107
18,212
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.rollback
public static function rollback() { // first of all we have to filter only the already migrated versions $available = static::available(); foreach( $available as $key => $migrations ) { foreach( $migrations as $time => $migration ) { if ( $time > static::$config->get( $key.'.revision', 0 ) ) { unset( $available[$key][$time] ); } } } $revisions = array(); foreach( $available as $key => $value ) { if ( empty( $value ) ) { continue; } foreach( $value as $name => $path ) { $revisions[$name.'::'.$key] = $path; } } // nothing to rollback? if ( empty( $revisions ) ) { if ( \ClanCats::is_cli() ) { \CCCli::warning( 'nothing to rollback to.' ); } return false; } ksort( $revisions ); end( $revisions ); list( $time, $key ) = explode( '::', key( $revisions ) ); $migration = new static( array_pop( $revisions ) ); // rollback the migration $migration->down(); // get the lastet migration from the group $others = \CCArr::get( $key, $available ); ksort( $others ); array_pop( $others ); end( $others ); // update the config static::$config->set( $key.'.revision', key( $others ) ); static::$config->write(); return true; }
php
public static function rollback() { // first of all we have to filter only the already migrated versions $available = static::available(); foreach( $available as $key => $migrations ) { foreach( $migrations as $time => $migration ) { if ( $time > static::$config->get( $key.'.revision', 0 ) ) { unset( $available[$key][$time] ); } } } $revisions = array(); foreach( $available as $key => $value ) { if ( empty( $value ) ) { continue; } foreach( $value as $name => $path ) { $revisions[$name.'::'.$key] = $path; } } // nothing to rollback? if ( empty( $revisions ) ) { if ( \ClanCats::is_cli() ) { \CCCli::warning( 'nothing to rollback to.' ); } return false; } ksort( $revisions ); end( $revisions ); list( $time, $key ) = explode( '::', key( $revisions ) ); $migration = new static( array_pop( $revisions ) ); // rollback the migration $migration->down(); // get the lastet migration from the group $others = \CCArr::get( $key, $available ); ksort( $others ); array_pop( $others ); end( $others ); // update the config static::$config->set( $key.'.revision', key( $others ) ); static::$config->write(); return true; }
[ "public", "static", "function", "rollback", "(", ")", "{", "// first of all we have to filter only the already migrated versions", "$", "available", "=", "static", "::", "available", "(", ")", ";", "foreach", "(", "$", "available", "as", "$", "key", "=>", "$", "migrations", ")", "{", "foreach", "(", "$", "migrations", "as", "$", "time", "=>", "$", "migration", ")", "{", "if", "(", "$", "time", ">", "static", "::", "$", "config", "->", "get", "(", "$", "key", ".", "'.revision'", ",", "0", ")", ")", "{", "unset", "(", "$", "available", "[", "$", "key", "]", "[", "$", "time", "]", ")", ";", "}", "}", "}", "$", "revisions", "=", "array", "(", ")", ";", "foreach", "(", "$", "available", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "value", "as", "$", "name", "=>", "$", "path", ")", "{", "$", "revisions", "[", "$", "name", ".", "'::'", ".", "$", "key", "]", "=", "$", "path", ";", "}", "}", "// nothing to rollback?", "if", "(", "empty", "(", "$", "revisions", ")", ")", "{", "if", "(", "\\", "ClanCats", "::", "is_cli", "(", ")", ")", "{", "\\", "CCCli", "::", "warning", "(", "'nothing to rollback to.'", ")", ";", "}", "return", "false", ";", "}", "ksort", "(", "$", "revisions", ")", ";", "end", "(", "$", "revisions", ")", ";", "list", "(", "$", "time", ",", "$", "key", ")", "=", "explode", "(", "'::'", ",", "key", "(", "$", "revisions", ")", ")", ";", "$", "migration", "=", "new", "static", "(", "array_pop", "(", "$", "revisions", ")", ")", ";", "// rollback the migration", "$", "migration", "->", "down", "(", ")", ";", "// get the lastet migration from the group", "$", "others", "=", "\\", "CCArr", "::", "get", "(", "$", "key", ",", "$", "available", ")", ";", "ksort", "(", "$", "others", ")", ";", "array_pop", "(", "$", "others", ")", ";", "end", "(", "$", "others", ")", ";", "// update the config", "static", "::", "$", "config", "->", "set", "(", "$", "key", ".", "'.revision'", ",", "key", "(", "$", "others", ")", ")", ";", "static", "::", "$", "config", "->", "write", "(", ")", ";", "return", "true", ";", "}" ]
Revert the last migration @return void
[ "Revert", "the", "last", "migration" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L114-L178
18,213
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.hard_reset
public static function hard_reset( $database = null ) { $tables = DB::fetch( 'SHOW TABLES', array(), $database, array( 'assoc' ) ); foreach( $tables as $table ) { DB::run( 'DROP TABLE IF EXISTS '.reset( $table ), array(), $database ); } }
php
public static function hard_reset( $database = null ) { $tables = DB::fetch( 'SHOW TABLES', array(), $database, array( 'assoc' ) ); foreach( $tables as $table ) { DB::run( 'DROP TABLE IF EXISTS '.reset( $table ), array(), $database ); } }
[ "public", "static", "function", "hard_reset", "(", "$", "database", "=", "null", ")", "{", "$", "tables", "=", "DB", "::", "fetch", "(", "'SHOW TABLES'", ",", "array", "(", ")", ",", "$", "database", ",", "array", "(", "'assoc'", ")", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "DB", "::", "run", "(", "'DROP TABLE IF EXISTS '", ".", "reset", "(", "$", "table", ")", ",", "array", "(", ")", ",", "$", "database", ")", ";", "}", "}" ]
The hard reset method deletes all tables from the database @param string $databse
[ "The", "hard", "reset", "method", "deletes", "all", "tables", "from", "the", "database" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L185-L193
18,214
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.unstaged
public static function unstaged() { $available = static::available(); foreach( $available as $key => $migrations ) { foreach( $migrations as $time => $migration ) { if ( $time <= static::$config->get( $key.'.revision', 0 ) ) { unset( $available[$key][$time] ); } } } return $available; }
php
public static function unstaged() { $available = static::available(); foreach( $available as $key => $migrations ) { foreach( $migrations as $time => $migration ) { if ( $time <= static::$config->get( $key.'.revision', 0 ) ) { unset( $available[$key][$time] ); } } } return $available; }
[ "public", "static", "function", "unstaged", "(", ")", "{", "$", "available", "=", "static", "::", "available", "(", ")", ";", "foreach", "(", "$", "available", "as", "$", "key", "=>", "$", "migrations", ")", "{", "foreach", "(", "$", "migrations", "as", "$", "time", "=>", "$", "migration", ")", "{", "if", "(", "$", "time", "<=", "static", "::", "$", "config", "->", "get", "(", "$", "key", ".", "'.revision'", ",", "0", ")", ")", "{", "unset", "(", "$", "available", "[", "$", "key", "]", "[", "$", "time", "]", ")", ";", "}", "}", "}", "return", "$", "available", ";", "}" ]
Returns the unstaged migrations based on the configuration @return array
[ "Returns", "the", "unstaged", "migrations", "based", "on", "the", "configuration" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L251-L267
18,215
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.run_queries
private function run_queries( $group ) { if ( !$handle = fopen( $this->path , "r") ) { throw new Exception( "Could not read migration: ".$this->path ); } $mode = null; $query = ''; while ( !feof( $handle ) ) { $buffer = trim( fgets( $handle, 4096 ) ); $this->parse_mode( $mode, $buffer ); if ( $this->is_comment( $buffer ) ) { continue; } // only continue if we are in up mode if ( $mode === $group ) { $query .= $buffer; if ( substr( rtrim( $query ), -1 ) == ';' ) { // run the query DB::run( $query ); // reset the query for the next one. $query = ''; } } } fclose($handle); }
php
private function run_queries( $group ) { if ( !$handle = fopen( $this->path , "r") ) { throw new Exception( "Could not read migration: ".$this->path ); } $mode = null; $query = ''; while ( !feof( $handle ) ) { $buffer = trim( fgets( $handle, 4096 ) ); $this->parse_mode( $mode, $buffer ); if ( $this->is_comment( $buffer ) ) { continue; } // only continue if we are in up mode if ( $mode === $group ) { $query .= $buffer; if ( substr( rtrim( $query ), -1 ) == ';' ) { // run the query DB::run( $query ); // reset the query for the next one. $query = ''; } } } fclose($handle); }
[ "private", "function", "run_queries", "(", "$", "group", ")", "{", "if", "(", "!", "$", "handle", "=", "fopen", "(", "$", "this", "->", "path", ",", "\"r\"", ")", ")", "{", "throw", "new", "Exception", "(", "\"Could not read migration: \"", ".", "$", "this", "->", "path", ")", ";", "}", "$", "mode", "=", "null", ";", "$", "query", "=", "''", ";", "while", "(", "!", "feof", "(", "$", "handle", ")", ")", "{", "$", "buffer", "=", "trim", "(", "fgets", "(", "$", "handle", ",", "4096", ")", ")", ";", "$", "this", "->", "parse_mode", "(", "$", "mode", ",", "$", "buffer", ")", ";", "if", "(", "$", "this", "->", "is_comment", "(", "$", "buffer", ")", ")", "{", "continue", ";", "}", "// only continue if we are in up mode", "if", "(", "$", "mode", "===", "$", "group", ")", "{", "$", "query", ".=", "$", "buffer", ";", "if", "(", "substr", "(", "rtrim", "(", "$", "query", ")", ",", "-", "1", ")", "==", "';'", ")", "{", "// run the query", "DB", "::", "run", "(", "$", "query", ")", ";", "// reset the query for the next one.", "$", "query", "=", "''", ";", "}", "}", "}", "fclose", "(", "$", "handle", ")", ";", "}" ]
Run all queries of specified group @param string $group @return void
[ "Run", "all", "queries", "of", "specified", "group" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L333-L372
18,216
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.parse_mode
private function parse_mode( &$mode, $buffer ) { if ( substr( trim( $buffer ), 0, 6 ) === '# --->' ) { $mode = trim( substr( $buffer, 6 ) ); } }
php
private function parse_mode( &$mode, $buffer ) { if ( substr( trim( $buffer ), 0, 6 ) === '# --->' ) { $mode = trim( substr( $buffer, 6 ) ); } }
[ "private", "function", "parse_mode", "(", "&", "$", "mode", ",", "$", "buffer", ")", "{", "if", "(", "substr", "(", "trim", "(", "$", "buffer", ")", ",", "0", ",", "6", ")", "===", "'# --->'", ")", "{", "$", "mode", "=", "trim", "(", "substr", "(", "$", "buffer", ",", "6", ")", ")", ";", "}", "}" ]
Try to parse the current mode @param string $mode @param string $buffer @return bool
[ "Try", "to", "parse", "the", "current", "mode" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L381-L387
18,217
ClanCats/Core
src/bundles/Database/Migrator.php
Migrator.is_comment
private function is_comment( $buffer ) { if ( is_string( $buffer ) && strlen( $buffer ) >= 1 ) { if ( $buffer[0] == '#' ) { return true; } if ( substr( $buffer, 0, 2 ) == '--' ) { return true; } } else { return true; } return false; }
php
private function is_comment( $buffer ) { if ( is_string( $buffer ) && strlen( $buffer ) >= 1 ) { if ( $buffer[0] == '#' ) { return true; } if ( substr( $buffer, 0, 2 ) == '--' ) { return true; } } else { return true; } return false; }
[ "private", "function", "is_comment", "(", "$", "buffer", ")", "{", "if", "(", "is_string", "(", "$", "buffer", ")", "&&", "strlen", "(", "$", "buffer", ")", ">=", "1", ")", "{", "if", "(", "$", "buffer", "[", "0", "]", "==", "'#'", ")", "{", "return", "true", ";", "}", "if", "(", "substr", "(", "$", "buffer", ",", "0", ",", "2", ")", "==", "'--'", ")", "{", "return", "true", ";", "}", "}", "else", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is this string an sql comment? @param string $buffer @return bool
[ "Is", "this", "string", "an", "sql", "comment?" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Migrator.php#L395-L415
18,218
webforge-labs/psc-cms
lib/Psc/HTML/JooseBase.php
JooseBase.autoLoad
protected function autoLoad() { if (!$this->disableAutoLoad) { $constructCode = $this->createConstructCode($this->jooseClass, $this->constructParams, FALSE); if (mb_strpos($this->html->getTemplate(),'%autoLoadJoose%') === FALSE) { $this->html->templateAppend( "\n".'%autoLoadJoose%' ); } $this->html->getTemplateContent() ->autoLoadJoose = jsHelper::embed( jsHelper::requireLoad( array_merge(array('jquery'), array_map(function ($class) { return str_replace('.','/', $class); }, $this->dependencies)), array('jQuery'), $constructCode ) ) ; } return $this; }
php
protected function autoLoad() { if (!$this->disableAutoLoad) { $constructCode = $this->createConstructCode($this->jooseClass, $this->constructParams, FALSE); if (mb_strpos($this->html->getTemplate(),'%autoLoadJoose%') === FALSE) { $this->html->templateAppend( "\n".'%autoLoadJoose%' ); } $this->html->getTemplateContent() ->autoLoadJoose = jsHelper::embed( jsHelper::requireLoad( array_merge(array('jquery'), array_map(function ($class) { return str_replace('.','/', $class); }, $this->dependencies)), array('jQuery'), $constructCode ) ) ; } return $this; }
[ "protected", "function", "autoLoad", "(", ")", "{", "if", "(", "!", "$", "this", "->", "disableAutoLoad", ")", "{", "$", "constructCode", "=", "$", "this", "->", "createConstructCode", "(", "$", "this", "->", "jooseClass", ",", "$", "this", "->", "constructParams", ",", "FALSE", ")", ";", "if", "(", "mb_strpos", "(", "$", "this", "->", "html", "->", "getTemplate", "(", ")", ",", "'%autoLoadJoose%'", ")", "===", "FALSE", ")", "{", "$", "this", "->", "html", "->", "templateAppend", "(", "\"\\n\"", ".", "'%autoLoadJoose%'", ")", ";", "}", "$", "this", "->", "html", "->", "getTemplateContent", "(", ")", "->", "autoLoadJoose", "=", "jsHelper", "::", "embed", "(", "jsHelper", "::", "requireLoad", "(", "array_merge", "(", "array", "(", "'jquery'", ")", ",", "array_map", "(", "function", "(", "$", "class", ")", "{", "return", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "class", ")", ";", "}", ",", "$", "this", "->", "dependencies", ")", ")", ",", "array", "(", "'jQuery'", ")", ",", "$", "constructCode", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Erstellt das Objekt direkt nachdem das HTML geladen wird per inline-Javascript vorher werden mögliche Dependencies geladen und es wird auf Main gewartet. in den Constructor-Parametern ist "main" definiert und zeigt auf Psc.UI.Main man muss selbst sicherstellen dass init() aufgerufen wurde (bzw this->html gesetzt ist)
[ "Erstellt", "das", "Objekt", "direkt", "nachdem", "das", "HTML", "geladen", "wird", "per", "inline", "-", "Javascript" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/HTML/JooseBase.php#L60-L83
18,219
ClanCats/Core
src/classes/CCPath.php
CCPath.get
public static function get( $path, $prefix = '', $suffix = '' ) { if ( substr( $path, 0, 1 ) == '/' || substr( $path, 0, 3 ) == "::/" ) { return $path.$suffix; } if ( strpos( $path, '::' ) === false ) { return \APPPATH.$prefix.$path.$suffix; } $name = explode( '::', $path ); // do we have a namepsace if ( array_key_exists( $name[0], \CCFinder::$bundles ) ) { return \CCFinder::$bundles[$name[0]].$prefix.$name[1].$suffix; } return false; }
php
public static function get( $path, $prefix = '', $suffix = '' ) { if ( substr( $path, 0, 1 ) == '/' || substr( $path, 0, 3 ) == "::/" ) { return $path.$suffix; } if ( strpos( $path, '::' ) === false ) { return \APPPATH.$prefix.$path.$suffix; } $name = explode( '::', $path ); // do we have a namepsace if ( array_key_exists( $name[0], \CCFinder::$bundles ) ) { return \CCFinder::$bundles[$name[0]].$prefix.$name[1].$suffix; } return false; }
[ "public", "static", "function", "get", "(", "$", "path", ",", "$", "prefix", "=", "''", ",", "$", "suffix", "=", "''", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "==", "'/'", "||", "substr", "(", "$", "path", ",", "0", ",", "3", ")", "==", "\"::/\"", ")", "{", "return", "$", "path", ".", "$", "suffix", ";", "}", "if", "(", "strpos", "(", "$", "path", ",", "'::'", ")", "===", "false", ")", "{", "return", "\\", "APPPATH", ".", "$", "prefix", ".", "$", "path", ".", "$", "suffix", ";", "}", "$", "name", "=", "explode", "(", "'::'", ",", "$", "path", ")", ";", "// do we have a namepsace", "if", "(", "array_key_exists", "(", "$", "name", "[", "0", "]", ",", "\\", "CCFinder", "::", "$", "bundles", ")", ")", "{", "return", "\\", "CCFinder", "::", "$", "bundles", "[", "$", "name", "[", "0", "]", "]", ".", "$", "prefix", ".", "$", "name", "[", "1", "]", ".", "$", "suffix", ";", "}", "return", "false", ";", "}" ]
generate an path an path can conatin an namespace for example "core" if an path starts with an "/" only the suffix will be added. @param string $path @param string $prefix @param string $sufix
[ "generate", "an", "path", "an", "path", "can", "conatin", "an", "namespace", "for", "example", "core" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCPath.php#L26-L45
18,220
2amigos/yiifoundation
helpers/Progress.php
Progress.success
public static function success($percent, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions); return static::bar($percent, $htmlOptions); }
php
public static function success($percent, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions); return static::bar($percent, $htmlOptions); }
[ "public", "static", "function", "success", "(", "$", "percent", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "Enum", "::", "COLOR_SUCCESS", ",", "$", "htmlOptions", ")", ";", "return", "static", "::", "bar", "(", "$", "percent", ",", "$", "htmlOptions", ")", ";", "}" ]
Generates success coloured progress bar @param $percent @param array $htmlOptions @return string
[ "Generates", "success", "coloured", "progress", "bar" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Progress.php#L26-L30
18,221
ripaclub/zf2-sphinxsearch-tool
Module.php
Module.createCharsetTableVariables
private function createCharsetTableVariables(array $config, $encoding_type = 'utf8') { if (isset($config['sphinxsearch']) && file_exists(__DIR__ . '/config/sphinx.charset.utf8.config.php')) { $charsetConfig = include __DIR__ . '/config/sphinx.charset.utf8.config.php'; $languages = $charsetConfig['languages']; $defaults = $charsetConfig['defaults']; $prefix = 'charset_' . $encoding_type . '_'; // Inject default charset table variables foreach ($defaults as $name => $table) { $config['sphinxsearch']['variables'][$prefix . $name] = $table; } $default = implode(', ', $defaults); $config['sphinxsearch']['variables'][$prefix . 'default'] = $default; // Inject language charset table variables foreach ($languages as $lang => $table) { if (empty($table)) { $config['sphinxsearch']['variables'][$prefix . $lang] = $default; } else { $alphanum = ''; $alphanum .= $config['sphinxsearch']['variables'][$prefix . 'digits'] . ', '; $alphanum .= $config['sphinxsearch']['variables'][$prefix . 'alphabet']; $config['sphinxsearch']['variables'][$prefix . $lang] = $alphanum . ', ' . $table; } } } return $config; }
php
private function createCharsetTableVariables(array $config, $encoding_type = 'utf8') { if (isset($config['sphinxsearch']) && file_exists(__DIR__ . '/config/sphinx.charset.utf8.config.php')) { $charsetConfig = include __DIR__ . '/config/sphinx.charset.utf8.config.php'; $languages = $charsetConfig['languages']; $defaults = $charsetConfig['defaults']; $prefix = 'charset_' . $encoding_type . '_'; // Inject default charset table variables foreach ($defaults as $name => $table) { $config['sphinxsearch']['variables'][$prefix . $name] = $table; } $default = implode(', ', $defaults); $config['sphinxsearch']['variables'][$prefix . 'default'] = $default; // Inject language charset table variables foreach ($languages as $lang => $table) { if (empty($table)) { $config['sphinxsearch']['variables'][$prefix . $lang] = $default; } else { $alphanum = ''; $alphanum .= $config['sphinxsearch']['variables'][$prefix . 'digits'] . ', '; $alphanum .= $config['sphinxsearch']['variables'][$prefix . 'alphabet']; $config['sphinxsearch']['variables'][$prefix . $lang] = $alphanum . ', ' . $table; } } } return $config; }
[ "private", "function", "createCharsetTableVariables", "(", "array", "$", "config", ",", "$", "encoding_type", "=", "'utf8'", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'sphinxsearch'", "]", ")", "&&", "file_exists", "(", "__DIR__", ".", "'/config/sphinx.charset.utf8.config.php'", ")", ")", "{", "$", "charsetConfig", "=", "include", "__DIR__", ".", "'/config/sphinx.charset.utf8.config.php'", ";", "$", "languages", "=", "$", "charsetConfig", "[", "'languages'", "]", ";", "$", "defaults", "=", "$", "charsetConfig", "[", "'defaults'", "]", ";", "$", "prefix", "=", "'charset_'", ".", "$", "encoding_type", ".", "'_'", ";", "// Inject default charset table variables", "foreach", "(", "$", "defaults", "as", "$", "name", "=>", "$", "table", ")", "{", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "$", "name", "]", "=", "$", "table", ";", "}", "$", "default", "=", "implode", "(", "', '", ",", "$", "defaults", ")", ";", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "'default'", "]", "=", "$", "default", ";", "// Inject language charset table variables", "foreach", "(", "$", "languages", "as", "$", "lang", "=>", "$", "table", ")", "{", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "$", "lang", "]", "=", "$", "default", ";", "}", "else", "{", "$", "alphanum", "=", "''", ";", "$", "alphanum", ".=", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "'digits'", "]", ".", "', '", ";", "$", "alphanum", ".=", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "'alphabet'", "]", ";", "$", "config", "[", "'sphinxsearch'", "]", "[", "'variables'", "]", "[", "$", "prefix", ".", "$", "lang", "]", "=", "$", "alphanum", ".", "', '", ".", "$", "table", ";", "}", "}", "}", "return", "$", "config", ";", "}" ]
Read Sphinx Search charset tables and create variables to expose them @param array $config @param $encoding_type @return array
[ "Read", "Sphinx", "Search", "charset", "tables", "and", "create", "variables", "to", "expose", "them" ]
4cb51341ccf1db9942e3e578855a579afd608d69
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/Module.php#L81-L107
18,222
uthando-cms/uthando-dompdf
src/UthandoDomPdf/Model/PdfFooterCollection.php
PdfFooterCollection.rewind
public function rewind() { if (!$this->sorted) { $this->entities = array_reverse($this->entities); $this->sorted = true; } parent::rewind(); }
php
public function rewind() { if (!$this->sorted) { $this->entities = array_reverse($this->entities); $this->sorted = true; } parent::rewind(); }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sorted", ")", "{", "$", "this", "->", "entities", "=", "array_reverse", "(", "$", "this", "->", "entities", ")", ";", "$", "this", "->", "sorted", "=", "true", ";", "}", "parent", "::", "rewind", "(", ")", ";", "}" ]
Make sure we have the items in the right order, reverse order
[ "Make", "sure", "we", "have", "the", "items", "in", "the", "right", "order", "reverse", "order" ]
60a750058c2db9ed167476192b20c7f544c32007
https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/Model/PdfFooterCollection.php#L71-L79
18,223
mvdbos/vdb-uri
src/VDB/Uri/Uri.php
Uri.toString
public function toString() { if (null === $this->composedURI) { $this->composedURI = ''; if (null !== $this->scheme) { $this->composedURI .= $this->scheme; $this->composedURI .= ':'; } if (null !== $this->host) { $this->composedURI .= '//'; if (null !== $this->username) { $this->composedURI .= $this->username; if (null !== $this->password) { $this->composedURI .= ':'; $this->composedURI .= $this->password; } $this->composedURI .= '@'; } $this->composedURI .= $this->host; } $this->composedURI .= $this->path; if (null !== $this->query) { $this->composedURI .= '?'; $this->composedURI .= $this->query; } if (null !== $this->fragment) { $this->composedURI .= '#'; $this->composedURI .= $this->fragment; } } return $this->composedURI; }
php
public function toString() { if (null === $this->composedURI) { $this->composedURI = ''; if (null !== $this->scheme) { $this->composedURI .= $this->scheme; $this->composedURI .= ':'; } if (null !== $this->host) { $this->composedURI .= '//'; if (null !== $this->username) { $this->composedURI .= $this->username; if (null !== $this->password) { $this->composedURI .= ':'; $this->composedURI .= $this->password; } $this->composedURI .= '@'; } $this->composedURI .= $this->host; } $this->composedURI .= $this->path; if (null !== $this->query) { $this->composedURI .= '?'; $this->composedURI .= $this->query; } if (null !== $this->fragment) { $this->composedURI .= '#'; $this->composedURI .= $this->fragment; } } return $this->composedURI; }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "composedURI", ")", "{", "$", "this", "->", "composedURI", "=", "''", ";", "if", "(", "null", "!==", "$", "this", "->", "scheme", ")", "{", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "scheme", ";", "$", "this", "->", "composedURI", ".=", "':'", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "host", ")", "{", "$", "this", "->", "composedURI", ".=", "'//'", ";", "if", "(", "null", "!==", "$", "this", "->", "username", ")", "{", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "username", ";", "if", "(", "null", "!==", "$", "this", "->", "password", ")", "{", "$", "this", "->", "composedURI", ".=", "':'", ";", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "password", ";", "}", "$", "this", "->", "composedURI", ".=", "'@'", ";", "}", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "host", ";", "}", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "path", ";", "if", "(", "null", "!==", "$", "this", "->", "query", ")", "{", "$", "this", "->", "composedURI", ".=", "'?'", ";", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "query", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "fragment", ")", "{", "$", "this", "->", "composedURI", ".=", "'#'", ";", "$", "this", "->", "composedURI", ".=", "$", "this", "->", "fragment", ";", "}", "}", "return", "$", "this", "->", "composedURI", ";", "}" ]
Recomposes the components of this Uri as a string. A string equivalent to the original input string, or to the string computed from the original string, as appropriate, is returned. This can be influence bij normalization, reference resolution, and so a string is constructed from this Uri's components according to the rules specified in RFC 3986 paragraph 5.3 @return string The string form of this Uri From RFC 3986 paragraph 5.3: result = "" if defined(scheme) then append scheme to result; append ":" to result; endif; if defined(authority) then append "//" to result; append authority to result; endif; append path to result; if defined(query) then append "?" to result; append query to result; endif; if defined(fragment) then append "#" to result; append fragment to result; endif; return result;
[ "Recomposes", "the", "components", "of", "this", "Uri", "as", "a", "string", "." ]
48264d5cd3a61b5166bf62468381cd58405b63ca
https://github.com/mvdbos/vdb-uri/blob/48264d5cd3a61b5166bf62468381cd58405b63ca/src/VDB/Uri/Uri.php#L133-L169
18,224
mvdbos/vdb-uri
src/VDB/Uri/Uri.php
Uri.resolveRelativeReference
private function resolveRelativeReference() { if (null !== $this->scheme) { $this->normalizeDotSegments(); } else { $this->scheme = $this->baseUri->scheme; if (null !== $this->authority) { $this->normalizeDotSegments(); } else { $this->authority = $this->baseUri->authority; $this->parseUserInfoHostPort(); if ('' === $this->path) { $this->path = $this->baseUri->path; if (null === $this->query) { $this->query = $this->baseUri->query; } } else { if (0 === strpos($this->path, '/')) { $this->normalizeDotSegments(); } else { $this->mergeBasePath(); $this->normalizeDotSegments(); } } } } }
php
private function resolveRelativeReference() { if (null !== $this->scheme) { $this->normalizeDotSegments(); } else { $this->scheme = $this->baseUri->scheme; if (null !== $this->authority) { $this->normalizeDotSegments(); } else { $this->authority = $this->baseUri->authority; $this->parseUserInfoHostPort(); if ('' === $this->path) { $this->path = $this->baseUri->path; if (null === $this->query) { $this->query = $this->baseUri->query; } } else { if (0 === strpos($this->path, '/')) { $this->normalizeDotSegments(); } else { $this->mergeBasePath(); $this->normalizeDotSegments(); } } } } }
[ "private", "function", "resolveRelativeReference", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "scheme", ")", "{", "$", "this", "->", "normalizeDotSegments", "(", ")", ";", "}", "else", "{", "$", "this", "->", "scheme", "=", "$", "this", "->", "baseUri", "->", "scheme", ";", "if", "(", "null", "!==", "$", "this", "->", "authority", ")", "{", "$", "this", "->", "normalizeDotSegments", "(", ")", ";", "}", "else", "{", "$", "this", "->", "authority", "=", "$", "this", "->", "baseUri", "->", "authority", ";", "$", "this", "->", "parseUserInfoHostPort", "(", ")", ";", "if", "(", "''", "===", "$", "this", "->", "path", ")", "{", "$", "this", "->", "path", "=", "$", "this", "->", "baseUri", "->", "path", ";", "if", "(", "null", "===", "$", "this", "->", "query", ")", "{", "$", "this", "->", "query", "=", "$", "this", "->", "baseUri", "->", "query", ";", "}", "}", "else", "{", "if", "(", "0", "===", "strpos", "(", "$", "this", "->", "path", ",", "'/'", ")", ")", "{", "$", "this", "->", "normalizeDotSegments", "(", ")", ";", "}", "else", "{", "$", "this", "->", "mergeBasePath", "(", ")", ";", "$", "this", "->", "normalizeDotSegments", "(", ")", ";", "}", "}", "}", "}", "}" ]
From RFC 3986 paragraph 4.2 relative-ref = relative-part [ "?" query ] [ "#" fragment ] relative-part = "//" authority path-abempty / path-absolute / path-noscheme / path-empty then: From RFC 3986 paragraph 5.2.2 For each Uri reference (R), the following pseudocode describes an algorithm for transforming R into its target Uri (T): -- The Uri reference is parsed into the five Uri components -- (R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R); -- A non-strict parser may ignore a scheme in the reference -- if it is identical to the base Uri's scheme. -- if ((not strict) and (R.scheme == Base.scheme)) then undefine(R.scheme); endif; if defined(R.scheme) then T.scheme = R.scheme; T.authority = R.authority; T.path = remove_dot_segments(R.path); T.query = R.query; else if defined(R.authority) then T.authority = R.authority; T.path = remove_dot_segments(R.path); T.query = R.query; else if (R.path == "") then T.path = Base.path; if defined(R.query) then T.query = R.query; else T.query = Base.query; endif; else if (R.path starts-with "/") then T.path = remove_dot_segments(R.path); else T.path = merge(Base.path, R.path); T.path = remove_dot_segments(T.path); endif; T.query = R.query; endif; T.authority = Base.authority; endif; T.scheme = Base.scheme; endif; T.fragment = R.fragment;
[ "From", "RFC", "3986", "paragraph", "4", ".", "2" ]
48264d5cd3a61b5166bf62468381cd58405b63ca
https://github.com/mvdbos/vdb-uri/blob/48264d5cd3a61b5166bf62468381cd58405b63ca/src/VDB/Uri/Uri.php#L538-L564
18,225
mvdbos/vdb-uri
src/VDB/Uri/Uri.php
Uri.normalizeDotSegments
private function normalizeDotSegments() { $input = explode('/', $this->path); $output = array(); while (!empty($input)) { if ('..' === $input[0]) { if (1 === count($input)) { array_shift($input); if ('' !== end($output)) { array_pop($output); } array_push($output, ''); } else { array_shift($input); if ('' !== end($output)) { array_pop($output); } } } elseif ('.' === $input[0]) { if (1 === count($input)) { array_shift($input); array_push($output, ''); } else { array_shift($input); } } else { array_push($output, array_shift($input)); } } $this->path = implode('/', $output); }
php
private function normalizeDotSegments() { $input = explode('/', $this->path); $output = array(); while (!empty($input)) { if ('..' === $input[0]) { if (1 === count($input)) { array_shift($input); if ('' !== end($output)) { array_pop($output); } array_push($output, ''); } else { array_shift($input); if ('' !== end($output)) { array_pop($output); } } } elseif ('.' === $input[0]) { if (1 === count($input)) { array_shift($input); array_push($output, ''); } else { array_shift($input); } } else { array_push($output, array_shift($input)); } } $this->path = implode('/', $output); }
[ "private", "function", "normalizeDotSegments", "(", ")", "{", "$", "input", "=", "explode", "(", "'/'", ",", "$", "this", "->", "path", ")", ";", "$", "output", "=", "array", "(", ")", ";", "while", "(", "!", "empty", "(", "$", "input", ")", ")", "{", "if", "(", "'..'", "===", "$", "input", "[", "0", "]", ")", "{", "if", "(", "1", "===", "count", "(", "$", "input", ")", ")", "{", "array_shift", "(", "$", "input", ")", ";", "if", "(", "''", "!==", "end", "(", "$", "output", ")", ")", "{", "array_pop", "(", "$", "output", ")", ";", "}", "array_push", "(", "$", "output", ",", "''", ")", ";", "}", "else", "{", "array_shift", "(", "$", "input", ")", ";", "if", "(", "''", "!==", "end", "(", "$", "output", ")", ")", "{", "array_pop", "(", "$", "output", ")", ";", "}", "}", "}", "elseif", "(", "'.'", "===", "$", "input", "[", "0", "]", ")", "{", "if", "(", "1", "===", "count", "(", "$", "input", ")", ")", "{", "array_shift", "(", "$", "input", ")", ";", "array_push", "(", "$", "output", ",", "''", ")", ";", "}", "else", "{", "array_shift", "(", "$", "input", ")", ";", "}", "}", "else", "{", "array_push", "(", "$", "output", ",", "array_shift", "(", "$", "input", ")", ")", ";", "}", "}", "$", "this", "->", "path", "=", "implode", "(", "'/'", ",", "$", "output", ")", ";", "}" ]
From RFC 3986 paragraph 5.2.4 1. The input buffer is initialized with the now-appended path components and the output buffer is initialized to the empty string. 2. While the input buffer is not empty, loop as follows: A. If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, B. if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, C. if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, D. if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, E. move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer. 3. Finally, the output buffer is returned as the result of remove_dot_segments.
[ "From", "RFC", "3986", "paragraph", "5", ".", "2", ".", "4" ]
48264d5cd3a61b5166bf62468381cd58405b63ca
https://github.com/mvdbos/vdb-uri/blob/48264d5cd3a61b5166bf62468381cd58405b63ca/src/VDB/Uri/Uri.php#L600-L631
18,226
mvdbos/vdb-uri
src/VDB/Uri/Uri.php
Uri.mergeBasePath
private function mergeBasePath() { if (null !== $this->baseUri->authority && '' === $this->baseUri->path) { $this->path = '/' . $this->path; } else { if (false !== $lastSlashPos = strrpos($this->baseUri->path, '/')) { $basePath = substr($this->baseUri->path, 0, $lastSlashPos + 1); $this->path = $basePath . $this->path; } } }
php
private function mergeBasePath() { if (null !== $this->baseUri->authority && '' === $this->baseUri->path) { $this->path = '/' . $this->path; } else { if (false !== $lastSlashPos = strrpos($this->baseUri->path, '/')) { $basePath = substr($this->baseUri->path, 0, $lastSlashPos + 1); $this->path = $basePath . $this->path; } } }
[ "private", "function", "mergeBasePath", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "baseUri", "->", "authority", "&&", "''", "===", "$", "this", "->", "baseUri", "->", "path", ")", "{", "$", "this", "->", "path", "=", "'/'", ".", "$", "this", "->", "path", ";", "}", "else", "{", "if", "(", "false", "!==", "$", "lastSlashPos", "=", "strrpos", "(", "$", "this", "->", "baseUri", "->", "path", ",", "'/'", ")", ")", "{", "$", "basePath", "=", "substr", "(", "$", "this", "->", "baseUri", "->", "path", ",", "0", ",", "$", "lastSlashPos", "+", "1", ")", ";", "$", "this", "->", "path", "=", "$", "basePath", ".", "$", "this", "->", "path", ";", "}", "}", "}" ]
From RFC 3986 paragraph 5.2.3
[ "From", "RFC", "3986", "paragraph", "5", ".", "2", ".", "3" ]
48264d5cd3a61b5166bf62468381cd58405b63ca
https://github.com/mvdbos/vdb-uri/blob/48264d5cd3a61b5166bf62468381cd58405b63ca/src/VDB/Uri/Uri.php#L636-L646
18,227
mvdbos/vdb-uri
src/VDB/Uri/Uri.php
Uri.parseUriReference
private function parseUriReference() { $this->parseScheme(); $this->parseAuthority(); $this->parsePath(); $this->parseQuery(); $this->parseFragment(); $this->doSchemeSpecificPostProcessing(); if (strlen($this->remaining)) { throw new ErrorException("Still something left after parsing, shouldn't happen: '$this->remaining'"); } }
php
private function parseUriReference() { $this->parseScheme(); $this->parseAuthority(); $this->parsePath(); $this->parseQuery(); $this->parseFragment(); $this->doSchemeSpecificPostProcessing(); if (strlen($this->remaining)) { throw new ErrorException("Still something left after parsing, shouldn't happen: '$this->remaining'"); } }
[ "private", "function", "parseUriReference", "(", ")", "{", "$", "this", "->", "parseScheme", "(", ")", ";", "$", "this", "->", "parseAuthority", "(", ")", ";", "$", "this", "->", "parsePath", "(", ")", ";", "$", "this", "->", "parseQuery", "(", ")", ";", "$", "this", "->", "parseFragment", "(", ")", ";", "$", "this", "->", "doSchemeSpecificPostProcessing", "(", ")", ";", "if", "(", "strlen", "(", "$", "this", "->", "remaining", ")", ")", "{", "throw", "new", "ErrorException", "(", "\"Still something left after parsing, shouldn't happen: '$this->remaining'\"", ")", ";", "}", "}" ]
From RFC 3986 paragraph 4.1 Uri-reference = Uri / relative-ref
[ "From", "RFC", "3986", "paragraph", "4", ".", "1" ]
48264d5cd3a61b5166bf62468381cd58405b63ca
https://github.com/mvdbos/vdb-uri/blob/48264d5cd3a61b5166bf62468381cd58405b63ca/src/VDB/Uri/Uri.php#L725-L738
18,228
digitalkaoz/versioneye-php
src/Output/BaseOutput.php
BaseOutput.printBoolean
protected function printBoolean(OutputInterface $output, $success, $fail, $value, $line = true) { if ($value) { $message = '<info>' . $success . '</info>'; } else { $message = '<error>' . $fail . '</error>'; } if (false === $line) { return $message; } $output->writeln($message); }
php
protected function printBoolean(OutputInterface $output, $success, $fail, $value, $line = true) { if ($value) { $message = '<info>' . $success . '</info>'; } else { $message = '<error>' . $fail . '</error>'; } if (false === $line) { return $message; } $output->writeln($message); }
[ "protected", "function", "printBoolean", "(", "OutputInterface", "$", "output", ",", "$", "success", ",", "$", "fail", ",", "$", "value", ",", "$", "line", "=", "true", ")", "{", "if", "(", "$", "value", ")", "{", "$", "message", "=", "'<info>'", ".", "$", "success", ".", "'</info>'", ";", "}", "else", "{", "$", "message", "=", "'<error>'", ".", "$", "fail", ".", "'</error>'", ";", "}", "if", "(", "false", "===", "$", "line", ")", "{", "return", "$", "message", ";", "}", "$", "output", "->", "writeln", "(", "$", "message", ")", ";", "}" ]
prints a simple boolean. @param OutputInterface $output @param string $success @param string $fail @param bool $value @param bool $line @return string
[ "prints", "a", "simple", "boolean", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/BaseOutput.php#L54-L67
18,229
digitalkaoz/versioneye-php
src/Output/BaseOutput.php
BaseOutput.printMessage
protected function printMessage(OutputInterface $output, array $response) { $this->printBoolean($output, $response['message'], $response['message'], true === $response['success']); }
php
protected function printMessage(OutputInterface $output, array $response) { $this->printBoolean($output, $response['message'], $response['message'], true === $response['success']); }
[ "protected", "function", "printMessage", "(", "OutputInterface", "$", "output", ",", "array", "$", "response", ")", "{", "$", "this", "->", "printBoolean", "(", "$", "output", ",", "$", "response", "[", "'message'", "]", ",", "$", "response", "[", "'message'", "]", ",", "true", "===", "$", "response", "[", "'success'", "]", ")", ";", "}" ]
prints a simple message. @param OutputInterface $output @param array $response
[ "prints", "a", "simple", "message", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/BaseOutput.php#L115-L118
18,230
digitalkaoz/versioneye-php
src/Output/BaseOutput.php
BaseOutput.getColumnWidth
private function getColumnWidth(array $headings) { $width = 0; foreach ($headings as $heading) { $width = strlen($heading) > $width ? strlen($heading) : $width; } return $width + 5; }
php
private function getColumnWidth(array $headings) { $width = 0; foreach ($headings as $heading) { $width = strlen($heading) > $width ? strlen($heading) : $width; } return $width + 5; }
[ "private", "function", "getColumnWidth", "(", "array", "$", "headings", ")", "{", "$", "width", "=", "0", ";", "foreach", "(", "$", "headings", "as", "$", "heading", ")", "{", "$", "width", "=", "strlen", "(", "$", "heading", ")", ">", "$", "width", "?", "strlen", "(", "$", "heading", ")", ":", "$", "width", ";", "}", "return", "$", "width", "+", "5", ";", "}" ]
calculates the max width of a given set of string. @param string[] $headings @return int
[ "calculates", "the", "max", "width", "of", "a", "given", "set", "of", "string", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/BaseOutput.php#L127-L135
18,231
orzcc/autometa
src/AutoMeta/AutoMeta.php
AutoMeta.generate
public function generate() { $this->loadWebMasterTags(); $title = $this->getTitle(); $description = $this->getDescription(); $keywords = $this->getKeywords(); $metatags = $this->metatags; $html = []; if($title): $html[] = "<title>$title</title>"; endif; if(!empty($description)): $html[] = "<meta name=\"description\" content=\"{$description}\" />"; endif; if (!empty($keywords)): $keywords = implode(',', $keywords); $html[] = "<meta name=\"keywords\" content=\"{$keywords}\" />"; endif; foreach ($metatags as $key => $value): $name = $value[0]; $content = $value[1]; $html[] = "<meta {$name}=\"{$key}\" content=\"{$content}\" />"; endforeach; return implode(PHP_EOL, $html); }
php
public function generate() { $this->loadWebMasterTags(); $title = $this->getTitle(); $description = $this->getDescription(); $keywords = $this->getKeywords(); $metatags = $this->metatags; $html = []; if($title): $html[] = "<title>$title</title>"; endif; if(!empty($description)): $html[] = "<meta name=\"description\" content=\"{$description}\" />"; endif; if (!empty($keywords)): $keywords = implode(',', $keywords); $html[] = "<meta name=\"keywords\" content=\"{$keywords}\" />"; endif; foreach ($metatags as $key => $value): $name = $value[0]; $content = $value[1]; $html[] = "<meta {$name}=\"{$key}\" content=\"{$content}\" />"; endforeach; return implode(PHP_EOL, $html); }
[ "public", "function", "generate", "(", ")", "{", "$", "this", "->", "loadWebMasterTags", "(", ")", ";", "$", "title", "=", "$", "this", "->", "getTitle", "(", ")", ";", "$", "description", "=", "$", "this", "->", "getDescription", "(", ")", ";", "$", "keywords", "=", "$", "this", "->", "getKeywords", "(", ")", ";", "$", "metatags", "=", "$", "this", "->", "metatags", ";", "$", "html", "=", "[", "]", ";", "if", "(", "$", "title", ")", ":", "$", "html", "[", "]", "=", "\"<title>$title</title>\"", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "description", ")", ")", ":", "$", "html", "[", "]", "=", "\"<meta name=\\\"description\\\" content=\\\"{$description}\\\" />\"", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "keywords", ")", ")", ":", "$", "keywords", "=", "implode", "(", "','", ",", "$", "keywords", ")", ";", "$", "html", "[", "]", "=", "\"<meta name=\\\"keywords\\\" content=\\\"{$keywords}\\\" />\"", ";", "endif", ";", "foreach", "(", "$", "metatags", "as", "$", "key", "=>", "$", "value", ")", ":", "$", "name", "=", "$", "value", "[", "0", "]", ";", "$", "content", "=", "$", "value", "[", "1", "]", ";", "$", "html", "[", "]", "=", "\"<meta {$name}=\\\"{$key}\\\" content=\\\"{$content}\\\" />\"", ";", "endforeach", ";", "return", "implode", "(", "PHP_EOL", ",", "$", "html", ")", ";", "}" ]
Generates meta tags @return string
[ "Generates", "meta", "tags" ]
1e3bd93f364e2619c9c20820399735c9fe805c9c
https://github.com/orzcc/autometa/blob/1e3bd93f364e2619c9c20820399735c9fe805c9c/src/AutoMeta/AutoMeta.php#L81-L112
18,232
orzcc/autometa
src/AutoMeta/AutoMeta.php
AutoMeta.setTitle
public function setTitle($title, $suffix='', $has_suffix=true) { // clean title $title = strip_tags($title); $suffix = strip_tags($suffix); // store title session $this->title_session = $title; // store title $this->title = $this->parseTitle($title, $suffix, $has_suffix); return $this; }
php
public function setTitle($title, $suffix='', $has_suffix=true) { // clean title $title = strip_tags($title); $suffix = strip_tags($suffix); // store title session $this->title_session = $title; // store title $this->title = $this->parseTitle($title, $suffix, $has_suffix); return $this; }
[ "public", "function", "setTitle", "(", "$", "title", ",", "$", "suffix", "=", "''", ",", "$", "has_suffix", "=", "true", ")", "{", "// clean title", "$", "title", "=", "strip_tags", "(", "$", "title", ")", ";", "$", "suffix", "=", "strip_tags", "(", "$", "suffix", ")", ";", "// store title session", "$", "this", "->", "title_session", "=", "$", "title", ";", "// store title", "$", "this", "->", "title", "=", "$", "this", "->", "parseTitle", "(", "$", "title", ",", "$", "suffix", ",", "$", "has_suffix", ")", ";", "return", "$", "this", ";", "}" ]
Sets the title @param string $title @param string $suffix @param boolean $has_suffix @return MetaTagsContract
[ "Sets", "the", "title" ]
1e3bd93f364e2619c9c20820399735c9fe805c9c
https://github.com/orzcc/autometa/blob/1e3bd93f364e2619c9c20820399735c9fe805c9c/src/AutoMeta/AutoMeta.php#L123-L136
18,233
orzcc/autometa
src/AutoMeta/AutoMeta.php
AutoMeta.setKeywords
public function setKeywords($keywords) { if (!is_array($keywords)): $keywords = explode(', ', $this->keywords); endif; // clean keywords $keywords = array_map('strip_tags', $keywords); // store keywords $this->keywords = $keywords; return $this; }
php
public function setKeywords($keywords) { if (!is_array($keywords)): $keywords = explode(', ', $this->keywords); endif; // clean keywords $keywords = array_map('strip_tags', $keywords); // store keywords $this->keywords = $keywords; return $this; }
[ "public", "function", "setKeywords", "(", "$", "keywords", ")", "{", "if", "(", "!", "is_array", "(", "$", "keywords", ")", ")", ":", "$", "keywords", "=", "explode", "(", "', '", ",", "$", "this", "->", "keywords", ")", ";", "endif", ";", "// clean keywords", "$", "keywords", "=", "array_map", "(", "'strip_tags'", ",", "$", "keywords", ")", ";", "// store keywords", "$", "this", "->", "keywords", "=", "$", "keywords", ";", "return", "$", "this", ";", "}" ]
Sets the list of keywords, you can send an array or string separated with commas also clears the previously set keywords @param string|array $keywords @return MetaTagsContract
[ "Sets", "the", "list", "of", "keywords", "you", "can", "send", "an", "array", "or", "string", "separated", "with", "commas", "also", "clears", "the", "previously", "set", "keywords" ]
1e3bd93f364e2619c9c20820399735c9fe805c9c
https://github.com/orzcc/autometa/blob/1e3bd93f364e2619c9c20820399735c9fe805c9c/src/AutoMeta/AutoMeta.php#L174-L188
18,234
orzcc/autometa
src/AutoMeta/AutoMeta.php
AutoMeta.addKeyword
public function addKeyword($keyword) { if (is_array($keyword)): $this->keywords = array_merge($keyword, $this->keywords); else: $this->keywords[] = strip_tags($keyword); endif; return $this; }
php
public function addKeyword($keyword) { if (is_array($keyword)): $this->keywords = array_merge($keyword, $this->keywords); else: $this->keywords[] = strip_tags($keyword); endif; return $this; }
[ "public", "function", "addKeyword", "(", "$", "keyword", ")", "{", "if", "(", "is_array", "(", "$", "keyword", ")", ")", ":", "$", "this", "->", "keywords", "=", "array_merge", "(", "$", "keyword", ",", "$", "this", "->", "keywords", ")", ";", "else", ":", "$", "this", "->", "keywords", "[", "]", "=", "strip_tags", "(", "$", "keyword", ")", ";", "endif", ";", "return", "$", "this", ";", "}" ]
Add a keyword @param string|array $keyword @return MetaTagsContract
[ "Add", "a", "keyword" ]
1e3bd93f364e2619c9c20820399735c9fe805c9c
https://github.com/orzcc/autometa/blob/1e3bd93f364e2619c9c20820399735c9fe805c9c/src/AutoMeta/AutoMeta.php#L197-L206
18,235
orzcc/autometa
src/AutoMeta/AutoMeta.php
AutoMeta.parseTitle
protected function parseTitle($title, $suffix, $has_suffix) { if (!$has_suffix): return $title; elseif(!empty($suffix)): return $title . $this->getTitleSeperator() . $suffix; else: return $this->config->get('defaults.title') ? $title . $this->getTitleSeperator() . $this->config->get('defaults.title', null) : $title; endif; }
php
protected function parseTitle($title, $suffix, $has_suffix) { if (!$has_suffix): return $title; elseif(!empty($suffix)): return $title . $this->getTitleSeperator() . $suffix; else: return $this->config->get('defaults.title') ? $title . $this->getTitleSeperator() . $this->config->get('defaults.title', null) : $title; endif; }
[ "protected", "function", "parseTitle", "(", "$", "title", ",", "$", "suffix", ",", "$", "has_suffix", ")", "{", "if", "(", "!", "$", "has_suffix", ")", ":", "return", "$", "title", ";", "elseif", "(", "!", "empty", "(", "$", "suffix", ")", ")", ":", "return", "$", "title", ".", "$", "this", "->", "getTitleSeperator", "(", ")", ".", "$", "suffix", ";", "else", ":", "return", "$", "this", "->", "config", "->", "get", "(", "'defaults.title'", ")", "?", "$", "title", ".", "$", "this", "->", "getTitleSeperator", "(", ")", ".", "$", "this", "->", "config", "->", "get", "(", "'defaults.title'", ",", "null", ")", ":", "$", "title", ";", "endif", ";", "}" ]
Get parsed title. @param string $title @param string @suffix @return string
[ "Get", "parsed", "title", "." ]
1e3bd93f364e2619c9c20820399735c9fe805c9c
https://github.com/orzcc/autometa/blob/1e3bd93f364e2619c9c20820399735c9fe805c9c/src/AutoMeta/AutoMeta.php#L299-L308
18,236
Sedona-Solutions/sedona-sbo
src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableDataManager.php
DatatableDataManager.getDatatable
public function getDatatable(DatatableViewInterface $datatableView) { $type = $datatableView->getAjax()->getType(); $entity = $datatableView->getEntity(); if ('GET' === strtoupper($type)) { $this->parameterBag = $this->request->query; } if ('POST' === strtoupper($type)) { $this->parameterBag = $this->request->request; } $params = $this->parameterBag->all(); /** * @var \Doctrine\ORM\Mapping\ClassMetadata */ $metadata = $this->doctrine->getManager()->getClassMetadata($entity); /** * @var \Doctrine\ORM\EntityManager */ $em = $this->doctrine->getManager(); $datatableQuery = new DatatableQuery($params, $metadata, $em); $virtualColumns = $datatableView->getColumnBuilder()->getVirtualColumnNames(); $datatableData = new DatatableData($params, $metadata, $em, $this->serializer, $datatableQuery, $virtualColumns); $datatableData->setLineFormatter($datatableView->getLineFormatter()); return $datatableData; }
php
public function getDatatable(DatatableViewInterface $datatableView) { $type = $datatableView->getAjax()->getType(); $entity = $datatableView->getEntity(); if ('GET' === strtoupper($type)) { $this->parameterBag = $this->request->query; } if ('POST' === strtoupper($type)) { $this->parameterBag = $this->request->request; } $params = $this->parameterBag->all(); /** * @var \Doctrine\ORM\Mapping\ClassMetadata */ $metadata = $this->doctrine->getManager()->getClassMetadata($entity); /** * @var \Doctrine\ORM\EntityManager */ $em = $this->doctrine->getManager(); $datatableQuery = new DatatableQuery($params, $metadata, $em); $virtualColumns = $datatableView->getColumnBuilder()->getVirtualColumnNames(); $datatableData = new DatatableData($params, $metadata, $em, $this->serializer, $datatableQuery, $virtualColumns); $datatableData->setLineFormatter($datatableView->getLineFormatter()); return $datatableData; }
[ "public", "function", "getDatatable", "(", "DatatableViewInterface", "$", "datatableView", ")", "{", "$", "type", "=", "$", "datatableView", "->", "getAjax", "(", ")", "->", "getType", "(", ")", ";", "$", "entity", "=", "$", "datatableView", "->", "getEntity", "(", ")", ";", "if", "(", "'GET'", "===", "strtoupper", "(", "$", "type", ")", ")", "{", "$", "this", "->", "parameterBag", "=", "$", "this", "->", "request", "->", "query", ";", "}", "if", "(", "'POST'", "===", "strtoupper", "(", "$", "type", ")", ")", "{", "$", "this", "->", "parameterBag", "=", "$", "this", "->", "request", "->", "request", ";", "}", "$", "params", "=", "$", "this", "->", "parameterBag", "->", "all", "(", ")", ";", "/**\n * @var \\Doctrine\\ORM\\Mapping\\ClassMetadata\n */", "$", "metadata", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", "->", "getClassMetadata", "(", "$", "entity", ")", ";", "/**\n * @var \\Doctrine\\ORM\\EntityManager\n */", "$", "em", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", ";", "$", "datatableQuery", "=", "new", "DatatableQuery", "(", "$", "params", ",", "$", "metadata", ",", "$", "em", ")", ";", "$", "virtualColumns", "=", "$", "datatableView", "->", "getColumnBuilder", "(", ")", "->", "getVirtualColumnNames", "(", ")", ";", "$", "datatableData", "=", "new", "DatatableData", "(", "$", "params", ",", "$", "metadata", ",", "$", "em", ",", "$", "this", "->", "serializer", ",", "$", "datatableQuery", ",", "$", "virtualColumns", ")", ";", "$", "datatableData", "->", "setLineFormatter", "(", "$", "datatableView", "->", "getLineFormatter", "(", ")", ")", ";", "return", "$", "datatableData", ";", "}" ]
Get Datatable. @param DatatableViewInterface $datatableView @return DatatableData
[ "Get", "Datatable", "." ]
8548be4170d191cb1a3e263577aaaab49f04d5ce
https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableDataManager.php#L80-L111
18,237
ClanCats/Core
src/classes/CCShipyard/Class.php
CCShipyard_Class.create
public function create( $name, $extends = null, $implements = null ) { $this->name = $name; $this->extends = $extends; if ( !is_array( $implements ) && !is_null( $implements ) ) { $implements = array( $implements ); } $this->implements = $implements; }
php
public function create( $name, $extends = null, $implements = null ) { $this->name = $name; $this->extends = $extends; if ( !is_array( $implements ) && !is_null( $implements ) ) { $implements = array( $implements ); } $this->implements = $implements; }
[ "public", "function", "create", "(", "$", "name", ",", "$", "extends", "=", "null", ",", "$", "implements", "=", "null", ")", "{", "$", "this", "->", "name", "=", "$", "name", ";", "$", "this", "->", "extends", "=", "$", "extends", ";", "if", "(", "!", "is_array", "(", "$", "implements", ")", "&&", "!", "is_null", "(", "$", "implements", ")", ")", "{", "$", "implements", "=", "array", "(", "$", "implements", ")", ";", "}", "$", "this", "->", "implements", "=", "$", "implements", ";", "}" ]
Start new class builder @param string $name @param string $extends @param string|array $implements @return void
[ "Start", "new", "class", "builder" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCShipyard/Class.php#L37-L48
18,238
ClanCats/Core
src/classes/CCShipyard/Class.php
CCShipyard_Class.add
public function add() { $args = func_get_args(); $component = array_shift( $args ); $method = 'build_'.strtolower( $component ); if ( !method_exists( $this, $method ) ) { throw new CCException( 'CCShipyard_Class invalid component builder "'.$component.'".' ); } $this->output .= call_user_func_array( array( $this, $method ), $args ); }
php
public function add() { $args = func_get_args(); $component = array_shift( $args ); $method = 'build_'.strtolower( $component ); if ( !method_exists( $this, $method ) ) { throw new CCException( 'CCShipyard_Class invalid component builder "'.$component.'".' ); } $this->output .= call_user_func_array( array( $this, $method ), $args ); }
[ "public", "function", "add", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "component", "=", "array_shift", "(", "$", "args", ")", ";", "$", "method", "=", "'build_'", ".", "strtolower", "(", "$", "component", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "CCException", "(", "'CCShipyard_Class invalid component builder \"'", ".", "$", "component", ".", "'\".'", ")", ";", "}", "$", "this", "->", "output", ".=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "method", ")", ",", "$", "args", ")", ";", "}" ]
Add a component to the class @param mixed ... @return void
[ "Add", "a", "component", "to", "the", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCShipyard/Class.php#L56-L70
18,239
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Template.php
PHPWord_Template.setValue
public function setValue($search, $replace) { if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { $search = '${'.$search.'}'; } $this->_documentXML = str_replace($search, $replace, $this->_documentXML); }
php
public function setValue($search, $replace) { if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { $search = '${'.$search.'}'; } $this->_documentXML = str_replace($search, $replace, $this->_documentXML); }
[ "public", "function", "setValue", "(", "$", "search", ",", "$", "replace", ")", "{", "if", "(", "substr", "(", "$", "search", ",", "0", ",", "2", ")", "!==", "'${'", "&&", "substr", "(", "$", "search", ",", "-", "1", ")", "!==", "'}'", ")", "{", "$", "search", "=", "'${'", ".", "$", "search", ".", "'}'", ";", "}", "$", "this", "->", "_documentXML", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "this", "->", "_documentXML", ")", ";", "}" ]
Set a Template value @param mixed $search @param mixed $replace
[ "Set", "a", "Template", "value" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Template.php#L83-L89
18,240
steeffeen/FancyManiaLinks
FML/Stylesheet/Style3d.php
Style3d.render
public function render(\DOMDocument $domDocument) { $style3dXml = $domDocument->createElement("style3d"); $this->checkId(); if ($this->styleId) { $style3dXml->setAttribute("id", $this->styleId); } if ($this->model) { $style3dXml->setAttribute("model", $this->model); } if ($this->thickness) { $style3dXml->setAttribute("thickness", $this->thickness); } if ($this->color) { $style3dXml->setAttribute("color", $this->color); } if ($this->focusColor) { $style3dXml->setAttribute("fcolor", $this->focusColor); } if ($this->lightColor) { $style3dXml->setAttribute("lightcolor", $this->lightColor); } if ($this->focusLightColor) { $style3dXml->setAttribute("flightcolor", $this->focusLightColor); } if ($this->yOffset) { $style3dXml->setAttribute("yoffset", $this->yOffset); } if ($this->focusYOffset) { $style3dXml->setAttribute("fyoffset", $this->focusYOffset); } if ($this->zOffset) { $style3dXml->setAttribute("zoffset", $this->zOffset); } if ($this->focusZOffset) { $style3dXml->setAttribute("fzoffset", $this->focusZOffset); } return $style3dXml; }
php
public function render(\DOMDocument $domDocument) { $style3dXml = $domDocument->createElement("style3d"); $this->checkId(); if ($this->styleId) { $style3dXml->setAttribute("id", $this->styleId); } if ($this->model) { $style3dXml->setAttribute("model", $this->model); } if ($this->thickness) { $style3dXml->setAttribute("thickness", $this->thickness); } if ($this->color) { $style3dXml->setAttribute("color", $this->color); } if ($this->focusColor) { $style3dXml->setAttribute("fcolor", $this->focusColor); } if ($this->lightColor) { $style3dXml->setAttribute("lightcolor", $this->lightColor); } if ($this->focusLightColor) { $style3dXml->setAttribute("flightcolor", $this->focusLightColor); } if ($this->yOffset) { $style3dXml->setAttribute("yoffset", $this->yOffset); } if ($this->focusYOffset) { $style3dXml->setAttribute("fyoffset", $this->focusYOffset); } if ($this->zOffset) { $style3dXml->setAttribute("zoffset", $this->zOffset); } if ($this->focusZOffset) { $style3dXml->setAttribute("fzoffset", $this->focusZOffset); } return $style3dXml; }
[ "public", "function", "render", "(", "\\", "DOMDocument", "$", "domDocument", ")", "{", "$", "style3dXml", "=", "$", "domDocument", "->", "createElement", "(", "\"style3d\"", ")", ";", "$", "this", "->", "checkId", "(", ")", ";", "if", "(", "$", "this", "->", "styleId", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"id\"", ",", "$", "this", "->", "styleId", ")", ";", "}", "if", "(", "$", "this", "->", "model", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"model\"", ",", "$", "this", "->", "model", ")", ";", "}", "if", "(", "$", "this", "->", "thickness", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"thickness\"", ",", "$", "this", "->", "thickness", ")", ";", "}", "if", "(", "$", "this", "->", "color", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"color\"", ",", "$", "this", "->", "color", ")", ";", "}", "if", "(", "$", "this", "->", "focusColor", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"fcolor\"", ",", "$", "this", "->", "focusColor", ")", ";", "}", "if", "(", "$", "this", "->", "lightColor", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"lightcolor\"", ",", "$", "this", "->", "lightColor", ")", ";", "}", "if", "(", "$", "this", "->", "focusLightColor", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"flightcolor\"", ",", "$", "this", "->", "focusLightColor", ")", ";", "}", "if", "(", "$", "this", "->", "yOffset", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"yoffset\"", ",", "$", "this", "->", "yOffset", ")", ";", "}", "if", "(", "$", "this", "->", "focusYOffset", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"fyoffset\"", ",", "$", "this", "->", "focusYOffset", ")", ";", "}", "if", "(", "$", "this", "->", "zOffset", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"zoffset\"", ",", "$", "this", "->", "zOffset", ")", ";", "}", "if", "(", "$", "this", "->", "focusZOffset", ")", "{", "$", "style3dXml", "->", "setAttribute", "(", "\"fzoffset\"", ",", "$", "this", "->", "focusZOffset", ")", ";", "}", "return", "$", "style3dXml", ";", "}" ]
Render the Style3d @param \DOMDocument $domDocument DOMDocument for which the Style3d should be rendered @return \DOMElement
[ "Render", "the", "Style3d" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Style3d.php#L394-L432
18,241
parsnick/steak
src/Console/InitCommand.php
InitCommand.setupSources
protected function setupSources() { /** @var Repository $config */ $config = $this->container['config']; $cwd = getcwd(); $source = []; $this->output->writeln("Working directory is <path>{$cwd}</path>"); $this->title('Sources'); if ($this->isGitRepo('.')) { $this->output->writeln("It looks your project already has a git repository.\n"); if ($this->confirm('Would you like to store your steak sources in a <b>separate</b> repo/branch?', false)) { $source['git.directory'] = $this->ask( "Where should we check out the site sources <b>repository</b>?", $config->get('source.directory', 'steak') ); // @todo if the sources repo already exists, try reading values from there instead of config? $source['git.url'] = $this->ask( "Enter the source repository URL:", $config->get('source.git.url', $this->getPushUrl('.')) ); $source['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('source.git.branch', 'gh-pages-src') ); } else { // not using a separate source vcs $this->output->writeln([ " Okay, no problem, just commit your steak sources as part of your standard workflow.", " The <comment>steak pull</comment> command will have no effect.", "" ]); $source['directory'] = $this->ask( "Where are the <b>source files</b> kept?", $config->get('source.directory', 'source') ); } } else { // not running inside a git repo $this->output->writeln("working directory not under git", OutputInterface::VERBOSITY_VERBOSE); if ($this->confirm('Would you like to store your steak sources in a git repo?')) { $source['directory'] = $this->ask( "Where should we check out the site sources <b>repository</b>?", $config->get('source.directory', 'steak') ); $source['git.url'] = $this->ask( "Enter the source repository URL:", $config->get('source.git.url'), $this->valueRequiredValidator() ); $source['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('source.git.branch', 'master') ); } else { $this->output->writeln(" Okay, no git."); $source['directory'] = $this->ask( "Where to put the steak <b>source files</b>?", $config->get('source.directory', 'sources') ); } } return $source; }
php
protected function setupSources() { /** @var Repository $config */ $config = $this->container['config']; $cwd = getcwd(); $source = []; $this->output->writeln("Working directory is <path>{$cwd}</path>"); $this->title('Sources'); if ($this->isGitRepo('.')) { $this->output->writeln("It looks your project already has a git repository.\n"); if ($this->confirm('Would you like to store your steak sources in a <b>separate</b> repo/branch?', false)) { $source['git.directory'] = $this->ask( "Where should we check out the site sources <b>repository</b>?", $config->get('source.directory', 'steak') ); // @todo if the sources repo already exists, try reading values from there instead of config? $source['git.url'] = $this->ask( "Enter the source repository URL:", $config->get('source.git.url', $this->getPushUrl('.')) ); $source['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('source.git.branch', 'gh-pages-src') ); } else { // not using a separate source vcs $this->output->writeln([ " Okay, no problem, just commit your steak sources as part of your standard workflow.", " The <comment>steak pull</comment> command will have no effect.", "" ]); $source['directory'] = $this->ask( "Where are the <b>source files</b> kept?", $config->get('source.directory', 'source') ); } } else { // not running inside a git repo $this->output->writeln("working directory not under git", OutputInterface::VERBOSITY_VERBOSE); if ($this->confirm('Would you like to store your steak sources in a git repo?')) { $source['directory'] = $this->ask( "Where should we check out the site sources <b>repository</b>?", $config->get('source.directory', 'steak') ); $source['git.url'] = $this->ask( "Enter the source repository URL:", $config->get('source.git.url'), $this->valueRequiredValidator() ); $source['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('source.git.branch', 'master') ); } else { $this->output->writeln(" Okay, no git."); $source['directory'] = $this->ask( "Where to put the steak <b>source files</b>?", $config->get('source.directory', 'sources') ); } } return $source; }
[ "protected", "function", "setupSources", "(", ")", "{", "/** @var Repository $config */", "$", "config", "=", "$", "this", "->", "container", "[", "'config'", "]", ";", "$", "cwd", "=", "getcwd", "(", ")", ";", "$", "source", "=", "[", "]", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"Working directory is <path>{$cwd}</path>\"", ")", ";", "$", "this", "->", "title", "(", "'Sources'", ")", ";", "if", "(", "$", "this", "->", "isGitRepo", "(", "'.'", ")", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"It looks your project already has a git repository.\\n\"", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "'Would you like to store your steak sources in a <b>separate</b> repo/branch?'", ",", "false", ")", ")", "{", "$", "source", "[", "'git.directory'", "]", "=", "$", "this", "->", "ask", "(", "\"Where should we check out the site sources <b>repository</b>?\"", ",", "$", "config", "->", "get", "(", "'source.directory'", ",", "'steak'", ")", ")", ";", "// @todo if the sources repo already exists, try reading values from there instead of config?", "$", "source", "[", "'git.url'", "]", "=", "$", "this", "->", "ask", "(", "\"Enter the source repository URL:\"", ",", "$", "config", "->", "get", "(", "'source.git.url'", ",", "$", "this", "->", "getPushUrl", "(", "'.'", ")", ")", ")", ";", "$", "source", "[", "'git.branch'", "]", "=", "$", "this", "->", "ask", "(", "\"Specify the branch to use:\"", ",", "$", "config", "->", "get", "(", "'source.git.branch'", ",", "'gh-pages-src'", ")", ")", ";", "}", "else", "{", "// not using a separate source vcs", "$", "this", "->", "output", "->", "writeln", "(", "[", "\" Okay, no problem, just commit your steak sources as part of your standard workflow.\"", ",", "\" The <comment>steak pull</comment> command will have no effect.\"", ",", "\"\"", "]", ")", ";", "$", "source", "[", "'directory'", "]", "=", "$", "this", "->", "ask", "(", "\"Where are the <b>source files</b> kept?\"", ",", "$", "config", "->", "get", "(", "'source.directory'", ",", "'source'", ")", ")", ";", "}", "}", "else", "{", "// not running inside a git repo", "$", "this", "->", "output", "->", "writeln", "(", "\"working directory not under git\"", ",", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "'Would you like to store your steak sources in a git repo?'", ")", ")", "{", "$", "source", "[", "'directory'", "]", "=", "$", "this", "->", "ask", "(", "\"Where should we check out the site sources <b>repository</b>?\"", ",", "$", "config", "->", "get", "(", "'source.directory'", ",", "'steak'", ")", ")", ";", "$", "source", "[", "'git.url'", "]", "=", "$", "this", "->", "ask", "(", "\"Enter the source repository URL:\"", ",", "$", "config", "->", "get", "(", "'source.git.url'", ")", ",", "$", "this", "->", "valueRequiredValidator", "(", ")", ")", ";", "$", "source", "[", "'git.branch'", "]", "=", "$", "this", "->", "ask", "(", "\"Specify the branch to use:\"", ",", "$", "config", "->", "get", "(", "'source.git.branch'", ",", "'master'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "output", "->", "writeln", "(", "\" Okay, no git.\"", ")", ";", "$", "source", "[", "'directory'", "]", "=", "$", "this", "->", "ask", "(", "\"Where to put the steak <b>source files</b>?\"", ",", "$", "config", "->", "get", "(", "'source.directory'", ",", "'sources'", ")", ")", ";", "}", "}", "return", "$", "source", ";", "}" ]
Get the config values related to steak sources. @return array
[ "Get", "the", "config", "values", "related", "to", "steak", "sources", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L134-L212
18,242
parsnick/steak
src/Console/InitCommand.php
InitCommand.setupBuild
protected function setupBuild() { /** @var Repository $config */ $config = $this->container['config']; $build = []; $this->title('Build'); $build['directory'] = $this->ask("Where should we put the generated site files?", $config['build.directory']); return $build; }
php
protected function setupBuild() { /** @var Repository $config */ $config = $this->container['config']; $build = []; $this->title('Build'); $build['directory'] = $this->ask("Where should we put the generated site files?", $config['build.directory']); return $build; }
[ "protected", "function", "setupBuild", "(", ")", "{", "/** @var Repository $config */", "$", "config", "=", "$", "this", "->", "container", "[", "'config'", "]", ";", "$", "build", "=", "[", "]", ";", "$", "this", "->", "title", "(", "'Build'", ")", ";", "$", "build", "[", "'directory'", "]", "=", "$", "this", "->", "ask", "(", "\"Where should we put the generated site files?\"", ",", "$", "config", "[", "'build.directory'", "]", ")", ";", "return", "$", "build", ";", "}" ]
Get the config values related to the build process. @return array
[ "Get", "the", "config", "values", "related", "to", "the", "build", "process", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L219-L231
18,243
parsnick/steak
src/Console/InitCommand.php
InitCommand.setupDeploy
protected function setupDeploy() { /** @var Repository $config */ $config = $this->container['config']; $this->title('Deployment via Git'); $deploy = []; if ($this->confirm('Push the generated static site to a git repository?')) { $deploy['git.url'] = $this->ask( "Specify a destination repository for the <path>steak deploy</path> command to use:", $config->get('deploy.git.url', $this->getPushUrl('.')), $this->valueRequiredValidator() ); $deploy['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('deploy.git.branch', 'gh-pages') ); } else { $this->output->writeln([ " Okay, no problem, steak will not attempt deployments.", " The <comment>steak deploy</comment> command will have no effect.", ]); } return $deploy; }
php
protected function setupDeploy() { /** @var Repository $config */ $config = $this->container['config']; $this->title('Deployment via Git'); $deploy = []; if ($this->confirm('Push the generated static site to a git repository?')) { $deploy['git.url'] = $this->ask( "Specify a destination repository for the <path>steak deploy</path> command to use:", $config->get('deploy.git.url', $this->getPushUrl('.')), $this->valueRequiredValidator() ); $deploy['git.branch'] = $this->ask( "Specify the branch to use:", $config->get('deploy.git.branch', 'gh-pages') ); } else { $this->output->writeln([ " Okay, no problem, steak will not attempt deployments.", " The <comment>steak deploy</comment> command will have no effect.", ]); } return $deploy; }
[ "protected", "function", "setupDeploy", "(", ")", "{", "/** @var Repository $config */", "$", "config", "=", "$", "this", "->", "container", "[", "'config'", "]", ";", "$", "this", "->", "title", "(", "'Deployment via Git'", ")", ";", "$", "deploy", "=", "[", "]", ";", "if", "(", "$", "this", "->", "confirm", "(", "'Push the generated static site to a git repository?'", ")", ")", "{", "$", "deploy", "[", "'git.url'", "]", "=", "$", "this", "->", "ask", "(", "\"Specify a destination repository for the <path>steak deploy</path> command to use:\"", ",", "$", "config", "->", "get", "(", "'deploy.git.url'", ",", "$", "this", "->", "getPushUrl", "(", "'.'", ")", ")", ",", "$", "this", "->", "valueRequiredValidator", "(", ")", ")", ";", "$", "deploy", "[", "'git.branch'", "]", "=", "$", "this", "->", "ask", "(", "\"Specify the branch to use:\"", ",", "$", "config", "->", "get", "(", "'deploy.git.branch'", ",", "'gh-pages'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "output", "->", "writeln", "(", "[", "\" Okay, no problem, steak will not attempt deployments.\"", ",", "\" The <comment>steak deploy</comment> command will have no effect.\"", ",", "]", ")", ";", "}", "return", "$", "deploy", ";", "}" ]
Get the config values related to deployment. @return array
[ "Get", "the", "config", "values", "related", "to", "deployment", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L238-L270
18,244
parsnick/steak
src/Console/InitCommand.php
InitCommand.setupGulp
protected function setupGulp() { /** @var Repository $config */ $config = $this->container['config']; $this->title('Gulp'); $gulp = []; $this->output->writeln([ "steak uses the gulp taskrunner to:", " 1. publish non-PHP files from your source directory to the build directory with <comment>steak:publish</comment>", " 2. run the local development server and rebuild the site on change with <comment>steak:serve</comment>", ]); $gulp['file'] = $this->ask("Which gulpfile should steak use?", $config['gulp.file']); return $gulp; }
php
protected function setupGulp() { /** @var Repository $config */ $config = $this->container['config']; $this->title('Gulp'); $gulp = []; $this->output->writeln([ "steak uses the gulp taskrunner to:", " 1. publish non-PHP files from your source directory to the build directory with <comment>steak:publish</comment>", " 2. run the local development server and rebuild the site on change with <comment>steak:serve</comment>", ]); $gulp['file'] = $this->ask("Which gulpfile should steak use?", $config['gulp.file']); return $gulp; }
[ "protected", "function", "setupGulp", "(", ")", "{", "/** @var Repository $config */", "$", "config", "=", "$", "this", "->", "container", "[", "'config'", "]", ";", "$", "this", "->", "title", "(", "'Gulp'", ")", ";", "$", "gulp", "=", "[", "]", ";", "$", "this", "->", "output", "->", "writeln", "(", "[", "\"steak uses the gulp taskrunner to:\"", ",", "\" 1. publish non-PHP files from your source directory to the build directory with <comment>steak:publish</comment>\"", ",", "\" 2. run the local development server and rebuild the site on change with <comment>steak:serve</comment>\"", ",", "]", ")", ";", "$", "gulp", "[", "'file'", "]", "=", "$", "this", "->", "ask", "(", "\"Which gulpfile should steak use?\"", ",", "$", "config", "[", "'gulp.file'", "]", ")", ";", "return", "$", "gulp", ";", "}" ]
Get the config values related to gulp. @return array
[ "Get", "the", "config", "values", "related", "to", "gulp", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L277-L295
18,245
parsnick/steak
src/Console/InitCommand.php
InitCommand.setupServe
protected function setupServe(array $newConfig) { $newConfig = array_dot($newConfig); if (array_get($newConfig, 'deploy.git.branch') != 'gh-pages') { return []; } $this->title('Local development server'); $this->output->writeln([ "When you publish to github pages, your site is available from username.github.io/projectname", "To help avoid problems with relative URLs, use a matching subdirectory for the local server.", "", ]); return [ 'subdirectory' => $this->ask( "Subdirectory to use for the <comment>steak serve</comment> command?", $this->git->parseRepositoryName(array_get($newConfig, 'deploy.git.url')) ) ]; }
php
protected function setupServe(array $newConfig) { $newConfig = array_dot($newConfig); if (array_get($newConfig, 'deploy.git.branch') != 'gh-pages') { return []; } $this->title('Local development server'); $this->output->writeln([ "When you publish to github pages, your site is available from username.github.io/projectname", "To help avoid problems with relative URLs, use a matching subdirectory for the local server.", "", ]); return [ 'subdirectory' => $this->ask( "Subdirectory to use for the <comment>steak serve</comment> command?", $this->git->parseRepositoryName(array_get($newConfig, 'deploy.git.url')) ) ]; }
[ "protected", "function", "setupServe", "(", "array", "$", "newConfig", ")", "{", "$", "newConfig", "=", "array_dot", "(", "$", "newConfig", ")", ";", "if", "(", "array_get", "(", "$", "newConfig", ",", "'deploy.git.branch'", ")", "!=", "'gh-pages'", ")", "{", "return", "[", "]", ";", "}", "$", "this", "->", "title", "(", "'Local development server'", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "[", "\"When you publish to github pages, your site is available from username.github.io/projectname\"", ",", "\"To help avoid problems with relative URLs, use a matching subdirectory for the local server.\"", ",", "\"\"", ",", "]", ")", ";", "return", "[", "'subdirectory'", "=>", "$", "this", "->", "ask", "(", "\"Subdirectory to use for the <comment>steak serve</comment> command?\"", ",", "$", "this", "->", "git", "->", "parseRepositoryName", "(", "array_get", "(", "$", "newConfig", ",", "'deploy.git.url'", ")", ")", ")", "]", ";", "}" ]
Get the config values related to the development server. @param array $newConfig @return array
[ "Get", "the", "config", "values", "related", "to", "the", "development", "server", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L303-L325
18,246
parsnick/steak
src/Console/InitCommand.php
InitCommand.confirm
protected function confirm($text, $default = true) { $choices = $default ? 'Yn' : 'yN'; $confirm = new ConfirmationQuestion("$text [$choices] ", $default); return $this->getHelper('question')->ask($this->input, $this->output, $confirm); }
php
protected function confirm($text, $default = true) { $choices = $default ? 'Yn' : 'yN'; $confirm = new ConfirmationQuestion("$text [$choices] ", $default); return $this->getHelper('question')->ask($this->input, $this->output, $confirm); }
[ "protected", "function", "confirm", "(", "$", "text", ",", "$", "default", "=", "true", ")", "{", "$", "choices", "=", "$", "default", "?", "'Yn'", ":", "'yN'", ";", "$", "confirm", "=", "new", "ConfirmationQuestion", "(", "\"$text [$choices] \"", ",", "$", "default", ")", ";", "return", "$", "this", "->", "getHelper", "(", "'question'", ")", "->", "ask", "(", "$", "this", "->", "input", ",", "$", "this", "->", "output", ",", "$", "confirm", ")", ";", "}" ]
Ask for user confirmation. @param string $text @param bool $default @return bool
[ "Ask", "for", "user", "confirmation", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L358-L364
18,247
parsnick/steak
src/Console/InitCommand.php
InitCommand.select
protected function select($text, $choices, $default = null) { $question = new ChoiceQuestion($text, $choices, $default); return $this->getHelper('question')->ask($this->input, $this->output, $question); }
php
protected function select($text, $choices, $default = null) { $question = new ChoiceQuestion($text, $choices, $default); return $this->getHelper('question')->ask($this->input, $this->output, $question); }
[ "protected", "function", "select", "(", "$", "text", ",", "$", "choices", ",", "$", "default", "=", "null", ")", "{", "$", "question", "=", "new", "ChoiceQuestion", "(", "$", "text", ",", "$", "choices", ",", "$", "default", ")", ";", "return", "$", "this", "->", "getHelper", "(", "'question'", ")", "->", "ask", "(", "$", "this", "->", "input", ",", "$", "this", "->", "output", ",", "$", "question", ")", ";", "}" ]
Ask user to choose from a list of options. @param string $text @param array $choices @param mixed $default @return mixed
[ "Ask", "user", "to", "choose", "from", "a", "list", "of", "options", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L374-L379
18,248
parsnick/steak
src/Console/InitCommand.php
InitCommand.getPushUrl
protected function getPushUrl($dir, $throws = false) { try { $remotes = $this->git->workingCopy($dir)->remote('show', 'origin', '-n')->getOutput(); if (preg_match('!Push\s*URL:\s*([^\s#]+)!', $remotes, $matches)) { return $matches[1]; } } catch (GitException $exception) { if ($throws) { throw $exception; } } return null; }
php
protected function getPushUrl($dir, $throws = false) { try { $remotes = $this->git->workingCopy($dir)->remote('show', 'origin', '-n')->getOutput(); if (preg_match('!Push\s*URL:\s*([^\s#]+)!', $remotes, $matches)) { return $matches[1]; } } catch (GitException $exception) { if ($throws) { throw $exception; } } return null; }
[ "protected", "function", "getPushUrl", "(", "$", "dir", ",", "$", "throws", "=", "false", ")", "{", "try", "{", "$", "remotes", "=", "$", "this", "->", "git", "->", "workingCopy", "(", "$", "dir", ")", "->", "remote", "(", "'show'", ",", "'origin'", ",", "'-n'", ")", "->", "getOutput", "(", ")", ";", "if", "(", "preg_match", "(", "'!Push\\s*URL:\\s*([^\\s#]+)!'", ",", "$", "remotes", ",", "$", "matches", ")", ")", "{", "return", "$", "matches", "[", "1", "]", ";", "}", "}", "catch", "(", "GitException", "$", "exception", ")", "{", "if", "(", "$", "throws", ")", "{", "throw", "$", "exception", ";", "}", "}", "return", "null", ";", "}" ]
Get the origin's push URL. @param string $dir @param bool $throws @return null|string
[ "Get", "the", "origin", "s", "push", "URL", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L399-L414
18,249
parsnick/steak
src/Console/InitCommand.php
InitCommand.createYaml
protected function createYaml(array $config) { $nested = []; array_walk(array_dot($config), function ($value, $key) use (&$nested) { array_set($nested, $key, $value); }); return $this->yaml->dump($nested, 4); }
php
protected function createYaml(array $config) { $nested = []; array_walk(array_dot($config), function ($value, $key) use (&$nested) { array_set($nested, $key, $value); }); return $this->yaml->dump($nested, 4); }
[ "protected", "function", "createYaml", "(", "array", "$", "config", ")", "{", "$", "nested", "=", "[", "]", ";", "array_walk", "(", "array_dot", "(", "$", "config", ")", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "nested", ")", "{", "array_set", "(", "$", "nested", ",", "$", "key", ",", "$", "value", ")", ";", "}", ")", ";", "return", "$", "this", "->", "yaml", "->", "dump", "(", "$", "nested", ",", "4", ")", ";", "}" ]
Create a YML string from a dotted array. @param array $config @return string
[ "Create", "a", "YML", "string", "from", "a", "dotted", "array", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L422-L431
18,250
parsnick/steak
src/Console/InitCommand.php
InitCommand.dirExists
protected function dirExists($dir) { if ($this->files->exists($dir)) { if ( ! $this->files->isDirectory($dir)) { throw new RuntimeException("The given directory [$dir] is not a directory."); } return true; } return false; }
php
protected function dirExists($dir) { if ($this->files->exists($dir)) { if ( ! $this->files->isDirectory($dir)) { throw new RuntimeException("The given directory [$dir] is not a directory."); } return true; } return false; }
[ "protected", "function", "dirExists", "(", "$", "dir", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "dir", ")", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "dir", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"The given directory [$dir] is not a directory.\"", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a directory exists. @param string $dir @return bool
[ "Check", "if", "a", "directory", "exists", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/InitCommand.php#L440-L452
18,251
koriym/Koriym.QueryLocator
src/QueryLocator.php
QueryLocator.rewriteCountQuery
private function rewriteCountQuery(string $sql) : string { if (preg_match('/^\s*SELECT\s+\bDISTINCT\b/is', $sql) || preg_match('/\s+GROUP\s+BY\s+/is', $sql)) { throw new CountQueryException($sql); } $openParenthesis = '(?:\()'; $closeParenthesis = '(?:\))'; $subQueryInSelect = $openParenthesis . '.*\bFROM\b.*' . $closeParenthesis; $pattern = '/(?:.*' . $subQueryInSelect . '.*)\bFROM\b\s+/Uims'; if (preg_match($pattern, $sql)) { throw new CountQueryException($sql); } $subQueryWithLimitOrder = $openParenthesis . '.*\b(LIMIT|ORDER)\b.*' . $closeParenthesis; $pattern = '/.*\bFROM\b.*(?:.*' . $subQueryWithLimitOrder . '.*).*/Uims'; if (preg_match($pattern, $sql)) { throw new CountQueryException($sql); } $queryCount = preg_replace('/(?:.*)\bFROM\b\s+/Uims', 'SELECT COUNT(*) FROM ', $sql, 1); if (! is_string($queryCount)) { throw new CountQueryException($sql); } list($queryCount) = preg_split('/\s+ORDER\s+BY\s+/is', $queryCount); if (! is_string($queryCount)) { throw new CountQueryException($sql); } list($queryCount) = preg_split('/\bLIMIT\b/is', $queryCount); if (! is_string($queryCount)) { throw new CountQueryException($sql); } return trim($queryCount); }
php
private function rewriteCountQuery(string $sql) : string { if (preg_match('/^\s*SELECT\s+\bDISTINCT\b/is', $sql) || preg_match('/\s+GROUP\s+BY\s+/is', $sql)) { throw new CountQueryException($sql); } $openParenthesis = '(?:\()'; $closeParenthesis = '(?:\))'; $subQueryInSelect = $openParenthesis . '.*\bFROM\b.*' . $closeParenthesis; $pattern = '/(?:.*' . $subQueryInSelect . '.*)\bFROM\b\s+/Uims'; if (preg_match($pattern, $sql)) { throw new CountQueryException($sql); } $subQueryWithLimitOrder = $openParenthesis . '.*\b(LIMIT|ORDER)\b.*' . $closeParenthesis; $pattern = '/.*\bFROM\b.*(?:.*' . $subQueryWithLimitOrder . '.*).*/Uims'; if (preg_match($pattern, $sql)) { throw new CountQueryException($sql); } $queryCount = preg_replace('/(?:.*)\bFROM\b\s+/Uims', 'SELECT COUNT(*) FROM ', $sql, 1); if (! is_string($queryCount)) { throw new CountQueryException($sql); } list($queryCount) = preg_split('/\s+ORDER\s+BY\s+/is', $queryCount); if (! is_string($queryCount)) { throw new CountQueryException($sql); } list($queryCount) = preg_split('/\bLIMIT\b/is', $queryCount); if (! is_string($queryCount)) { throw new CountQueryException($sql); } return trim($queryCount); }
[ "private", "function", "rewriteCountQuery", "(", "string", "$", "sql", ")", ":", "string", "{", "if", "(", "preg_match", "(", "'/^\\s*SELECT\\s+\\bDISTINCT\\b/is'", ",", "$", "sql", ")", "||", "preg_match", "(", "'/\\s+GROUP\\s+BY\\s+/is'", ",", "$", "sql", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "$", "openParenthesis", "=", "'(?:\\()'", ";", "$", "closeParenthesis", "=", "'(?:\\))'", ";", "$", "subQueryInSelect", "=", "$", "openParenthesis", ".", "'.*\\bFROM\\b.*'", ".", "$", "closeParenthesis", ";", "$", "pattern", "=", "'/(?:.*'", ".", "$", "subQueryInSelect", ".", "'.*)\\bFROM\\b\\s+/Uims'", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "sql", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "$", "subQueryWithLimitOrder", "=", "$", "openParenthesis", ".", "'.*\\b(LIMIT|ORDER)\\b.*'", ".", "$", "closeParenthesis", ";", "$", "pattern", "=", "'/.*\\bFROM\\b.*(?:.*'", ".", "$", "subQueryWithLimitOrder", ".", "'.*).*/Uims'", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "sql", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "$", "queryCount", "=", "preg_replace", "(", "'/(?:.*)\\bFROM\\b\\s+/Uims'", ",", "'SELECT COUNT(*) FROM '", ",", "$", "sql", ",", "1", ")", ";", "if", "(", "!", "is_string", "(", "$", "queryCount", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "list", "(", "$", "queryCount", ")", "=", "preg_split", "(", "'/\\s+ORDER\\s+BY\\s+/is'", ",", "$", "queryCount", ")", ";", "if", "(", "!", "is_string", "(", "$", "queryCount", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "list", "(", "$", "queryCount", ")", "=", "preg_split", "(", "'/\\bLIMIT\\b/is'", ",", "$", "queryCount", ")", ";", "if", "(", "!", "is_string", "(", "$", "queryCount", ")", ")", "{", "throw", "new", "CountQueryException", "(", "$", "sql", ")", ";", "}", "return", "trim", "(", "$", "queryCount", ")", ";", "}" ]
Return count query @see https://github.com/pear/Pager/blob/master/examples/Pager_Wrapper.php Taken from pear/pager and modified. tested at https://github.com/pear/Pager/blob/80c0e31c8b94f913cfbdeccbe83b63822f42a2f8/tests/pager_wrapper_test.php#L19 @codeCoverageIgnore
[ "Return", "count", "query" ]
4e9b9ecfdd99c4850e39e88204a597af503c3823
https://github.com/koriym/Koriym.QueryLocator/blob/4e9b9ecfdd99c4850e39e88204a597af503c3823/src/QueryLocator.php#L86-L117
18,252
simple-php-mvc/simple-php-mvc
src/MVC/Sessions/Session.php
Session.set
public function set($name, $value) { if (!$this->has($name)) { $this->vars[$name] = $value; } else { return false; } }
php
public function set($name, $value) { if (!$this->has($name)) { $this->vars[$name] = $value; } else { return false; } }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "$", "this", "->", "vars", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Set var session @access public @param string $name @param mixed $value @return bool
[ "Set", "var", "session" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Sessions/Session.php#L111-L118
18,253
ClanCats/Core
src/console/shipyard.php
shipyard.action_class
public function action_class( $params ) { $options = \CCDataObject::assign( $params ); $name = $options->get( 0, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the class name: ' ); } // try to resolve the path if ( !$path = \CCPath::classes( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // create the class $class = \CCShipyard::create( 'class', $name, $options->get( 'extends', null ), explode( ',', $options->get( 'implements', null ) ) ); // add static init if ( !$options->get( 'no-init', false ) ) { $class->add( 'function', '_init', 'public static', '//', "static class initialisation\n@return void" ); } // check for overwrite if ( file_exists( $path ) ) { if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $class->output() ); }
php
public function action_class( $params ) { $options = \CCDataObject::assign( $params ); $name = $options->get( 0, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the class name: ' ); } // try to resolve the path if ( !$path = \CCPath::classes( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // create the class $class = \CCShipyard::create( 'class', $name, $options->get( 'extends', null ), explode( ',', $options->get( 'implements', null ) ) ); // add static init if ( !$options->get( 'no-init', false ) ) { $class->add( 'function', '_init', 'public static', '//', "static class initialisation\n@return void" ); } // check for overwrite if ( file_exists( $path ) ) { if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $class->output() ); }
[ "public", "function", "action_class", "(", "$", "params", ")", "{", "$", "options", "=", "\\", "CCDataObject", "::", "assign", "(", "$", "params", ")", ";", "$", "name", "=", "$", "options", "->", "get", "(", "0", ",", "null", ")", ";", "// get name if we dont have one", "while", "(", "!", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "read", "(", "'Please enter the class name: '", ")", ";", "}", "// try to resolve the path", "if", "(", "!", "$", "path", "=", "\\", "CCPath", "::", "classes", "(", "str_replace", "(", "'_'", ",", "'/'", ",", "$", "name", ")", ",", "EXT", ")", ")", "{", "$", "this", "->", "error", "(", "'Could not resolve the path. Check if the namespace is registered.'", ")", ";", "return", ";", "}", "// create the class", "$", "class", "=", "\\", "CCShipyard", "::", "create", "(", "'class'", ",", "$", "name", ",", "$", "options", "->", "get", "(", "'extends'", ",", "null", ")", ",", "explode", "(", "','", ",", "$", "options", "->", "get", "(", "'implements'", ",", "null", ")", ")", ")", ";", "// add static init", "if", "(", "!", "$", "options", "->", "get", "(", "'no-init'", ",", "false", ")", ")", "{", "$", "class", "->", "add", "(", "'function'", ",", "'_init'", ",", "'public static'", ",", "'//'", ",", "\"static class initialisation\\n@return void\"", ")", ";", "}", "// check for overwrite", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "$", "this", "->", "confirm", "(", "\"The class already exists. Do you wish to overwrite it?\"", ",", "true", ")", ")", "{", "return", ";", "}", "}", "// write file", "\\", "CCFile", "::", "write", "(", "$", "path", ",", "$", "class", "->", "output", "(", ")", ")", ";", "}" ]
generate an class exmample: run shipyard::class <class> run shipyard::class <namespace>::<class> @param array $params @return void
[ "generate", "an", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/shipyard.php#L88-L126
18,254
ClanCats/Core
src/console/shipyard.php
shipyard.action_model
public function action_model( $params ) { $options = \CCDataObject::assign( $params ); // params $name = $options->get( 0, null ); $table = $options->get( 1, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the class name: ' ); } // get table if we dont have one while( !$table ) { $table = $this->read( 'Please enter the table name: ' ); } // resolve the path if ( !$path = \CCPath::classes( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // create the class $model = \CCShipyard::create( 'dbmodel', $name, $table ); // auto timestamps $model->timestamps( $options->get( 'timestamps', false ) ); // check before if ( file_exists( $path ) ) { if ( !CCCli::confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $model->output() ); }
php
public function action_model( $params ) { $options = \CCDataObject::assign( $params ); // params $name = $options->get( 0, null ); $table = $options->get( 1, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the class name: ' ); } // get table if we dont have one while( !$table ) { $table = $this->read( 'Please enter the table name: ' ); } // resolve the path if ( !$path = \CCPath::classes( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // create the class $model = \CCShipyard::create( 'dbmodel', $name, $table ); // auto timestamps $model->timestamps( $options->get( 'timestamps', false ) ); // check before if ( file_exists( $path ) ) { if ( !CCCli::confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $model->output() ); }
[ "public", "function", "action_model", "(", "$", "params", ")", "{", "$", "options", "=", "\\", "CCDataObject", "::", "assign", "(", "$", "params", ")", ";", "// params", "$", "name", "=", "$", "options", "->", "get", "(", "0", ",", "null", ")", ";", "$", "table", "=", "$", "options", "->", "get", "(", "1", ",", "null", ")", ";", "// get name if we dont have one", "while", "(", "!", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "read", "(", "'Please enter the class name: '", ")", ";", "}", "// get table if we dont have one", "while", "(", "!", "$", "table", ")", "{", "$", "table", "=", "$", "this", "->", "read", "(", "'Please enter the table name: '", ")", ";", "}", "// resolve the path", "if", "(", "!", "$", "path", "=", "\\", "CCPath", "::", "classes", "(", "str_replace", "(", "'_'", ",", "'/'", ",", "$", "name", ")", ",", "EXT", ")", ")", "{", "$", "this", "->", "error", "(", "'Could not resolve the path. Check if the namespace is registered.'", ")", ";", "return", ";", "}", "// create the class", "$", "model", "=", "\\", "CCShipyard", "::", "create", "(", "'dbmodel'", ",", "$", "name", ",", "$", "table", ")", ";", "// auto timestamps", "$", "model", "->", "timestamps", "(", "$", "options", "->", "get", "(", "'timestamps'", ",", "false", ")", ")", ";", "// check before", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "CCCli", "::", "confirm", "(", "\"The class already exists. Do you wish to overwrite it?\"", ",", "true", ")", ")", "{", "return", ";", "}", "}", "// write file", "\\", "CCFile", "::", "write", "(", "$", "path", ",", "$", "model", "->", "output", "(", ")", ")", ";", "}" ]
generate a model class exmample: run shipyard::model <class> run shipyard::model <class> <table> run shipyard::model <namespace>::<class> @param array $params @return void
[ "generate", "a", "model", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/shipyard.php#L139-L182
18,255
ClanCats/Core
src/console/shipyard.php
shipyard.action_controller
public function action_controller( $params ) { $options = \CCDataObject::assign( $params ); $name = $options->get( 0, null ); $parent = $options->get( 1, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the controller name: ' ); } // fix controller suffix if ( substr( $name, ( strlen( 'Controller' ) * -1 ) ) != 'Controller' ) { $name .= 'Controller'; } // try to resolve the path if ( !$path = \CCPath::controllers( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // parent if ( is_null( $parent ) ) { $parent = '\\CCController'; } // view controller if ( $options->get( 'view', false ) ) { $parent = '\\CCViewController'; } // create the class $class = \CCShipyard::create( 'class', $name, $parent ); // get the actions $actions = array( 'index' ); if ( $options->get( 'actions', false ) ) { $actions = array_merge( $actions, explode( ',', $options->get( 'actions' ) ) ); } foreach( $actions as $action ) { $action = trim( $action ); $class->add( 'function', 'action_'.$action, 'protected', 'echo "'.$name.' '.$action.' action";', ucfirst($action)." action\n@return void|CCResponse" ); $class->add( 'line', 2 ); } // add static init if ( !$options->get( 'no-events', false ) ) { $class->add( 'function', 'wake', 'protected', '//', "Controller wake\n@return void|CCResponse" ); $class->add( 'line', 2 ); $class->add( 'function', 'sleep', 'protected', '//', "Controller wake\n@return void" ); } // check for overwrite if ( file_exists( $path ) ) { if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $class->output() ); }
php
public function action_controller( $params ) { $options = \CCDataObject::assign( $params ); $name = $options->get( 0, null ); $parent = $options->get( 1, null ); // get name if we dont have one while( !$name ) { $name = $this->read( 'Please enter the controller name: ' ); } // fix controller suffix if ( substr( $name, ( strlen( 'Controller' ) * -1 ) ) != 'Controller' ) { $name .= 'Controller'; } // try to resolve the path if ( !$path = \CCPath::controllers( str_replace( '_', '/', $name ), EXT ) ) { $this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return; } // parent if ( is_null( $parent ) ) { $parent = '\\CCController'; } // view controller if ( $options->get( 'view', false ) ) { $parent = '\\CCViewController'; } // create the class $class = \CCShipyard::create( 'class', $name, $parent ); // get the actions $actions = array( 'index' ); if ( $options->get( 'actions', false ) ) { $actions = array_merge( $actions, explode( ',', $options->get( 'actions' ) ) ); } foreach( $actions as $action ) { $action = trim( $action ); $class->add( 'function', 'action_'.$action, 'protected', 'echo "'.$name.' '.$action.' action";', ucfirst($action)." action\n@return void|CCResponse" ); $class->add( 'line', 2 ); } // add static init if ( !$options->get( 'no-events', false ) ) { $class->add( 'function', 'wake', 'protected', '//', "Controller wake\n@return void|CCResponse" ); $class->add( 'line', 2 ); $class->add( 'function', 'sleep', 'protected', '//', "Controller wake\n@return void" ); } // check for overwrite if ( file_exists( $path ) ) { if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) { return; } } // write file \CCFile::write( $path, $class->output() ); }
[ "public", "function", "action_controller", "(", "$", "params", ")", "{", "$", "options", "=", "\\", "CCDataObject", "::", "assign", "(", "$", "params", ")", ";", "$", "name", "=", "$", "options", "->", "get", "(", "0", ",", "null", ")", ";", "$", "parent", "=", "$", "options", "->", "get", "(", "1", ",", "null", ")", ";", "// get name if we dont have one", "while", "(", "!", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "read", "(", "'Please enter the controller name: '", ")", ";", "}", "// fix controller suffix", "if", "(", "substr", "(", "$", "name", ",", "(", "strlen", "(", "'Controller'", ")", "*", "-", "1", ")", ")", "!=", "'Controller'", ")", "{", "$", "name", ".=", "'Controller'", ";", "}", "// try to resolve the path", "if", "(", "!", "$", "path", "=", "\\", "CCPath", "::", "controllers", "(", "str_replace", "(", "'_'", ",", "'/'", ",", "$", "name", ")", ",", "EXT", ")", ")", "{", "$", "this", "->", "error", "(", "'Could not resolve the path. Check if the namespace is registered.'", ")", ";", "return", ";", "}", "// parent", "if", "(", "is_null", "(", "$", "parent", ")", ")", "{", "$", "parent", "=", "'\\\\CCController'", ";", "}", "// view controller", "if", "(", "$", "options", "->", "get", "(", "'view'", ",", "false", ")", ")", "{", "$", "parent", "=", "'\\\\CCViewController'", ";", "}", "// create the class", "$", "class", "=", "\\", "CCShipyard", "::", "create", "(", "'class'", ",", "$", "name", ",", "$", "parent", ")", ";", "// get the actions", "$", "actions", "=", "array", "(", "'index'", ")", ";", "if", "(", "$", "options", "->", "get", "(", "'actions'", ",", "false", ")", ")", "{", "$", "actions", "=", "array_merge", "(", "$", "actions", ",", "explode", "(", "','", ",", "$", "options", "->", "get", "(", "'actions'", ")", ")", ")", ";", "}", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "$", "action", "=", "trim", "(", "$", "action", ")", ";", "$", "class", "->", "add", "(", "'function'", ",", "'action_'", ".", "$", "action", ",", "'protected'", ",", "'echo \"'", ".", "$", "name", ".", "' '", ".", "$", "action", ".", "' action\";'", ",", "ucfirst", "(", "$", "action", ")", ".", "\" action\\n@return void|CCResponse\"", ")", ";", "$", "class", "->", "add", "(", "'line'", ",", "2", ")", ";", "}", "// add static init", "if", "(", "!", "$", "options", "->", "get", "(", "'no-events'", ",", "false", ")", ")", "{", "$", "class", "->", "add", "(", "'function'", ",", "'wake'", ",", "'protected'", ",", "'//'", ",", "\"Controller wake\\n@return void|CCResponse\"", ")", ";", "$", "class", "->", "add", "(", "'line'", ",", "2", ")", ";", "$", "class", "->", "add", "(", "'function'", ",", "'sleep'", ",", "'protected'", ",", "'//'", ",", "\"Controller wake\\n@return void\"", ")", ";", "}", "// check for overwrite", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "$", "this", "->", "confirm", "(", "\"The class already exists. Do you wish to overwrite it?\"", ",", "true", ")", ")", "{", "return", ";", "}", "}", "// write file", "\\", "CCFile", "::", "write", "(", "$", "path", ",", "$", "class", "->", "output", "(", ")", ")", ";", "}" ]
generate an controller exmample: run shipyard::controller <controller> run shipyard::controller <controller> <parent_class> run shipyard::controller <namespace>::<controller> @param array $params @return void
[ "generate", "an", "controller" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/shipyard.php#L195-L270
18,256
drsdre/yii2-xmlsoccer
Client.php
Client.getMethodArguments
protected function getMethodArguments($methodName) { if (!empty($this->_magicMethodArgumentNames)) { return ArrayHelper::getValue($this->_magicMethodArgumentNames, $methodName, []); } try { $reflectionClass = new \ReflectionClass($this); $comment = $reflectionClass->getDocComment(); $lines = preg_split('/[\r\n]/', $comment); $regexp = '#\s*\*\s*@method ((?:.*) )?([a-zA-Z_]+)\(((?:[\\a-zA-Z]+\s+)?\$(?:[a-zA-Z_]+),?\s*)*\)#'; foreach ($lines as $line) { $matches = []; if (preg_match($regexp, $line, $matches)) { @list($null, $returnType, $method, $argumentString) = $matches; if (is_null($argumentString)) { $arguments = []; } else { $arguments = array_map('trim', explode(',', $argumentString)); foreach ($arguments as $k => $argument) { if (empty($argument)) { continue; } if (strpos($argument, ' ') !== false) { $tmp = explode(' ', $argument); $arguments[$k] = ['name' => ltrim($tmp[1], '$'), 'type' => $tmp[0]]; } else { $arguments[$k] = ['name' => ltrim($argument, '$'), 'type' => 'mixed']; } } } $this->_magicMethodArgumentNames[$method] = $arguments; } } } catch (\ReflectionException $e) { } return ArrayHelper::getValue($this->_magicMethodArgumentNames, $methodName, []); }
php
protected function getMethodArguments($methodName) { if (!empty($this->_magicMethodArgumentNames)) { return ArrayHelper::getValue($this->_magicMethodArgumentNames, $methodName, []); } try { $reflectionClass = new \ReflectionClass($this); $comment = $reflectionClass->getDocComment(); $lines = preg_split('/[\r\n]/', $comment); $regexp = '#\s*\*\s*@method ((?:.*) )?([a-zA-Z_]+)\(((?:[\\a-zA-Z]+\s+)?\$(?:[a-zA-Z_]+),?\s*)*\)#'; foreach ($lines as $line) { $matches = []; if (preg_match($regexp, $line, $matches)) { @list($null, $returnType, $method, $argumentString) = $matches; if (is_null($argumentString)) { $arguments = []; } else { $arguments = array_map('trim', explode(',', $argumentString)); foreach ($arguments as $k => $argument) { if (empty($argument)) { continue; } if (strpos($argument, ' ') !== false) { $tmp = explode(' ', $argument); $arguments[$k] = ['name' => ltrim($tmp[1], '$'), 'type' => $tmp[0]]; } else { $arguments[$k] = ['name' => ltrim($argument, '$'), 'type' => 'mixed']; } } } $this->_magicMethodArgumentNames[$method] = $arguments; } } } catch (\ReflectionException $e) { } return ArrayHelper::getValue($this->_magicMethodArgumentNames, $methodName, []); }
[ "protected", "function", "getMethodArguments", "(", "$", "methodName", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_magicMethodArgumentNames", ")", ")", "{", "return", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "_magicMethodArgumentNames", ",", "$", "methodName", ",", "[", "]", ")", ";", "}", "try", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "comment", "=", "$", "reflectionClass", "->", "getDocComment", "(", ")", ";", "$", "lines", "=", "preg_split", "(", "'/[\\r\\n]/'", ",", "$", "comment", ")", ";", "$", "regexp", "=", "'#\\s*\\*\\s*@method ((?:.*) )?([a-zA-Z_]+)\\(((?:[\\\\a-zA-Z]+\\s+)?\\$(?:[a-zA-Z_]+),?\\s*)*\\)#'", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "$", "regexp", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "@", "list", "(", "$", "null", ",", "$", "returnType", ",", "$", "method", ",", "$", "argumentString", ")", "=", "$", "matches", ";", "if", "(", "is_null", "(", "$", "argumentString", ")", ")", "{", "$", "arguments", "=", "[", "]", ";", "}", "else", "{", "$", "arguments", "=", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "argumentString", ")", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "k", "=>", "$", "argument", ")", "{", "if", "(", "empty", "(", "$", "argument", ")", ")", "{", "continue", ";", "}", "if", "(", "strpos", "(", "$", "argument", ",", "' '", ")", "!==", "false", ")", "{", "$", "tmp", "=", "explode", "(", "' '", ",", "$", "argument", ")", ";", "$", "arguments", "[", "$", "k", "]", "=", "[", "'name'", "=>", "ltrim", "(", "$", "tmp", "[", "1", "]", ",", "'$'", ")", ",", "'type'", "=>", "$", "tmp", "[", "0", "]", "]", ";", "}", "else", "{", "$", "arguments", "[", "$", "k", "]", "=", "[", "'name'", "=>", "ltrim", "(", "$", "argument", ",", "'$'", ")", ",", "'type'", "=>", "'mixed'", "]", ";", "}", "}", "}", "$", "this", "->", "_magicMethodArgumentNames", "[", "$", "method", "]", "=", "$", "arguments", ";", "}", "}", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "}", "return", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "_magicMethodArgumentNames", ",", "$", "methodName", ",", "[", "]", ")", ";", "}" ]
Get argument names and positions and data types from phpdoc class comment @param string $methodName method to get arguments from @return mixed
[ "Get", "argument", "names", "and", "positions", "and", "data", "types", "from", "phpdoc", "class", "comment" ]
a746edee6269ed0791bac6c6165a946adc30d994
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/Client.php#L269-L310
18,257
SachaMorard/phalcon-console
Library/Phalcon/Script/Color.php
Color.colorize
public static function colorize($string, $fg = null, $at = null, $bg = null) { // Shell not supported, exit early if (!static::isSupportedShell()) { return $string; } $colored = ''; // Check if given foreground color is supported if (isset(static::$_fg[$fg])) { $colored .= "\033[" . static::$_fg[$fg] . "m"; } // Check if given background color is supported if (isset(static::$_bg[$bg])) { $colored .= "\033[" . static::$_bg[$bg] . "m"; } // Check if given attribute is supported if (isset(static::$_at[$at])) { $colored .= "\033[" . static::$_at[$at] . "m"; } // Add string and end coloring $colored .= $string . "\033[0m"; return $colored; }
php
public static function colorize($string, $fg = null, $at = null, $bg = null) { // Shell not supported, exit early if (!static::isSupportedShell()) { return $string; } $colored = ''; // Check if given foreground color is supported if (isset(static::$_fg[$fg])) { $colored .= "\033[" . static::$_fg[$fg] . "m"; } // Check if given background color is supported if (isset(static::$_bg[$bg])) { $colored .= "\033[" . static::$_bg[$bg] . "m"; } // Check if given attribute is supported if (isset(static::$_at[$at])) { $colored .= "\033[" . static::$_at[$at] . "m"; } // Add string and end coloring $colored .= $string . "\033[0m"; return $colored; }
[ "public", "static", "function", "colorize", "(", "$", "string", ",", "$", "fg", "=", "null", ",", "$", "at", "=", "null", ",", "$", "bg", "=", "null", ")", "{", "// Shell not supported, exit early", "if", "(", "!", "static", "::", "isSupportedShell", "(", ")", ")", "{", "return", "$", "string", ";", "}", "$", "colored", "=", "''", ";", "// Check if given foreground color is supported", "if", "(", "isset", "(", "static", "::", "$", "_fg", "[", "$", "fg", "]", ")", ")", "{", "$", "colored", ".=", "\"\\033[\"", ".", "static", "::", "$", "_fg", "[", "$", "fg", "]", ".", "\"m\"", ";", "}", "// Check if given background color is supported", "if", "(", "isset", "(", "static", "::", "$", "_bg", "[", "$", "bg", "]", ")", ")", "{", "$", "colored", ".=", "\"\\033[\"", ".", "static", "::", "$", "_bg", "[", "$", "bg", "]", ".", "\"m\"", ";", "}", "// Check if given attribute is supported", "if", "(", "isset", "(", "static", "::", "$", "_at", "[", "$", "at", "]", ")", ")", "{", "$", "colored", ".=", "\"\\033[\"", ".", "static", "::", "$", "_at", "[", "$", "at", "]", ".", "\"m\"", ";", "}", "// Add string and end coloring", "$", "colored", ".=", "$", "string", ".", "\"\\033[0m\"", ";", "return", "$", "colored", ";", "}" ]
Colorizes the string using provided colors. @static @param $string @param null|integer $fg @param null|integer $at @param null|integer $bg @return string
[ "Colorizes", "the", "string", "using", "provided", "colors", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script/Color.php#L144-L172
18,258
SachaMorard/phalcon-console
Library/Phalcon/Script/Color.php
Color.info
public static function info($msg) { $msg = 'Info: ' . $msg; $space = strlen($msg) + 4; $out = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; $out .= static::colorize(' ' . $msg . ' ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; return $out; }
php
public static function info($msg) { $msg = 'Info: ' . $msg; $space = strlen($msg) + 4; $out = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; $out .= static::colorize(' ' . $msg . ' ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL; return $out; }
[ "public", "static", "function", "info", "(", "$", "msg", ")", "{", "$", "msg", "=", "'Info: '", ".", "$", "msg", ";", "$", "space", "=", "strlen", "(", "$", "msg", ")", "+", "4", ";", "$", "out", "=", "static", "::", "colorize", "(", "str_pad", "(", "' '", ",", "$", "space", ")", ",", "Color", "::", "FG_WHITE", ",", "Color", "::", "AT_BOLD", ",", "Color", "::", "BG_BLUE", ")", ".", "PHP_EOL", ";", "$", "out", ".=", "static", "::", "colorize", "(", "' '", ".", "$", "msg", ".", "' '", ",", "Color", "::", "FG_WHITE", ",", "Color", "::", "AT_BOLD", ",", "Color", "::", "BG_BLUE", ")", ".", "PHP_EOL", ";", "$", "out", ".=", "static", "::", "colorize", "(", "str_pad", "(", "' '", ",", "$", "space", ")", ",", "Color", "::", "FG_WHITE", ",", "Color", "::", "AT_BOLD", ",", "Color", "::", "BG_BLUE", ")", ".", "PHP_EOL", ";", "return", "$", "out", ";", "}" ]
Color style for info messages. @static @param $msg @return string
[ "Color", "style", "for", "info", "messages", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script/Color.php#L222-L231
18,259
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Mvc/Service/ControllerPluginManagerFactory.php
ControllerPluginManagerFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $pluginManagerClass = static::PLUGIN_MANAGER_CLASS; $plugins = new $pluginManagerClass; $plugins->setServiceLocator($serviceLocator); $configuration = $serviceLocator->get('Config'); if (isset($configuration['di']) && $serviceLocator->has('Di')) { $di = $serviceLocator->get('Di'); $plugins->addAbstractFactory( new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI) ); } return $plugins; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $pluginManagerClass = static::PLUGIN_MANAGER_CLASS; $plugins = new $pluginManagerClass; $plugins->setServiceLocator($serviceLocator); $configuration = $serviceLocator->get('Config'); if (isset($configuration['di']) && $serviceLocator->has('Di')) { $di = $serviceLocator->get('Di'); $plugins->addAbstractFactory( new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI) ); } return $plugins; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "pluginManagerClass", "=", "static", "::", "PLUGIN_MANAGER_CLASS", ";", "$", "plugins", "=", "new", "$", "pluginManagerClass", ";", "$", "plugins", "->", "setServiceLocator", "(", "$", "serviceLocator", ")", ";", "$", "configuration", "=", "$", "serviceLocator", "->", "get", "(", "'Config'", ")", ";", "if", "(", "isset", "(", "$", "configuration", "[", "'di'", "]", ")", "&&", "$", "serviceLocator", "->", "has", "(", "'Di'", ")", ")", "{", "$", "di", "=", "$", "serviceLocator", "->", "get", "(", "'Di'", ")", ";", "$", "plugins", "->", "addAbstractFactory", "(", "new", "DiAbstractServiceFactory", "(", "$", "di", ",", "DiAbstractServiceFactory", "::", "USE_SL_BEFORE_DI", ")", ")", ";", "}", "return", "$", "plugins", ";", "}" ]
Create and return the MVC controller plugin manager @param ServiceLocatorInterface $serviceLocator @return \Zend\Mvc\Controller\PluginManager
[ "Create", "and", "return", "the", "MVC", "controller", "plugin", "manager" ]
667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Mvc/Service/ControllerPluginManagerFactory.php#L32-L47
18,260
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php
BaseUserRoleQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof UserRoleQuery) { return $criteria; } $query = new UserRoleQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof UserRoleQuery) { return $criteria; } $query = new UserRoleQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "UserRoleQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "UserRoleQuery", "(", "null", ",", "null", ",", "$", "modelAlias", ")", ";", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new UserRoleQuery object. @param string $modelAlias The alias of a model in the query @param UserRoleQuery|Criteria $criteria Optional Criteria to build the query from @return UserRoleQuery
[ "Returns", "a", "new", "UserRoleQuery", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L77-L89
18,261
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php
BaseUserRoleQuery.filterByRole
public function filterByRole($role, $comparison = null) { if ($role instanceof Role) { return $this ->addUsingAlias(UserRolePeer::ROLE_ID, $role->getId(), $comparison); } elseif ($role instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(UserRolePeer::ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRole() only accepts arguments of type Role or PropelCollection'); } }
php
public function filterByRole($role, $comparison = null) { if ($role instanceof Role) { return $this ->addUsingAlias(UserRolePeer::ROLE_ID, $role->getId(), $comparison); } elseif ($role instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(UserRolePeer::ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRole() only accepts arguments of type Role or PropelCollection'); } }
[ "public", "function", "filterByRole", "(", "$", "role", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "role", "instanceof", "Role", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "role", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "role", "instanceof", "PropelObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "role", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByRole() only accepts arguments of type Role or PropelCollection'", ")", ";", "}", "}" ]
Filter the query by a related Role object @param Role|PropelObjectCollection $role The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return UserRoleQuery The current query, for fluid interface @throws PropelException - if the provided filter is invalid.
[ "Filter", "the", "query", "by", "a", "related", "Role", "object" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L414-L429
18,262
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php
BaseUserRoleQuery.useRoleQuery
public function useRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRole($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Role', '\Slashworks\BackendBundle\Model\RoleQuery'); }
php
public function useRoleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRole($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Role', '\Slashworks\BackendBundle\Model\RoleQuery'); }
[ "public", "function", "useRoleQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinRole", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Role'", ",", "'\\Slashworks\\BackendBundle\\Model\\RoleQuery'", ")", ";", "}" ]
Use the Role relation Role object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Slashworks\BackendBundle\Model\RoleQuery A secondary query class using the current class as primary query
[ "Use", "the", "Role", "relation", "Role", "object" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRoleQuery.php#L474-L479
18,263
2amigos/yiifoundation
helpers/ArrayHelper.php
ArrayHelper.copy
public static function copy($names, $from, &$to) { if (is_array($from) && is_array($to)) { foreach ($names as $key) { if (isset($from[$key]) && !isset($to[$key])) { $to[$key] = static::getValue($from, $key); } } } return $to; }
php
public static function copy($names, $from, &$to) { if (is_array($from) && is_array($to)) { foreach ($names as $key) { if (isset($from[$key]) && !isset($to[$key])) { $to[$key] = static::getValue($from, $key); } } } return $to; }
[ "public", "static", "function", "copy", "(", "$", "names", ",", "$", "from", ",", "&", "$", "to", ")", "{", "if", "(", "is_array", "(", "$", "from", ")", "&&", "is_array", "(", "$", "to", ")", ")", "{", "foreach", "(", "$", "names", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "from", "[", "$", "key", "]", ")", "&&", "!", "isset", "(", "$", "to", "[", "$", "key", "]", ")", ")", "{", "$", "to", "[", "$", "key", "]", "=", "static", "::", "getValue", "(", "$", "from", ",", "$", "key", ")", ";", "}", "}", "}", "return", "$", "to", ";", "}" ]
Copies the values from one option array to another. @param array $names the items names to copy. @param array $from the items to copy from. @param array $to the items to copy to. @return array with copied items.
[ "Copies", "the", "values", "from", "one", "option", "array", "to", "another", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L26-L36
18,264
2amigos/yiifoundation
helpers/ArrayHelper.php
ArrayHelper.move
public static function move($names, &$from, &$to) { if (is_array($from) && is_array($to)) { foreach ($names as $key) { if (isset($from[$key]) && !isset($to[$key])) { $to[$key] = static::getValue($from, $key); $moved[$key] = static::removeValue($from, $key); } } } return $moved; }
php
public static function move($names, &$from, &$to) { if (is_array($from) && is_array($to)) { foreach ($names as $key) { if (isset($from[$key]) && !isset($to[$key])) { $to[$key] = static::getValue($from, $key); $moved[$key] = static::removeValue($from, $key); } } } return $moved; }
[ "public", "static", "function", "move", "(", "$", "names", ",", "&", "$", "from", ",", "&", "$", "to", ")", "{", "if", "(", "is_array", "(", "$", "from", ")", "&&", "is_array", "(", "$", "to", ")", ")", "{", "foreach", "(", "$", "names", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "from", "[", "$", "key", "]", ")", "&&", "!", "isset", "(", "$", "to", "[", "$", "key", "]", ")", ")", "{", "$", "to", "[", "$", "key", "]", "=", "static", "::", "getValue", "(", "$", "from", ",", "$", "key", ")", ";", "$", "moved", "[", "$", "key", "]", "=", "static", "::", "removeValue", "(", "$", "from", ",", "$", "key", ")", ";", "}", "}", "}", "return", "$", "moved", ";", "}" ]
Moves the item values from one array to another. @param array $names the item names to move. @param array $from the values to move from. @param array $to the items to move to. @return array with moved items.
[ "Moves", "the", "item", "values", "from", "one", "array", "to", "another", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L45-L56
18,265
2amigos/yiifoundation
helpers/ArrayHelper.php
ArrayHelper.addValue
public static function addValue($key, $value, &$array, $glue = ' ') { if (isset($array[$key])) { if (!is_array($array[$key])) $array[$key] = explode($glue, $array[$key]); $array[$key][] = $value; $array[$key] = array_unique($array[$key]); $array[$key] = implode($glue, $array[$key]); } else $array[$key] = $value; return $array; }
php
public static function addValue($key, $value, &$array, $glue = ' ') { if (isset($array[$key])) { if (!is_array($array[$key])) $array[$key] = explode($glue, $array[$key]); $array[$key][] = $value; $array[$key] = array_unique($array[$key]); $array[$key] = implode($glue, $array[$key]); } else $array[$key] = $value; return $array; }
[ "public", "static", "function", "addValue", "(", "$", "key", ",", "$", "value", ",", "&", "$", "array", ",", "$", "glue", "=", "' '", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", "[", "$", "key", "]", ")", ")", "$", "array", "[", "$", "key", "]", "=", "explode", "(", "$", "glue", ",", "$", "array", "[", "$", "key", "]", ")", ";", "$", "array", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "$", "array", "[", "$", "key", "]", "=", "array_unique", "(", "$", "array", "[", "$", "key", "]", ")", ";", "$", "array", "[", "$", "key", "]", "=", "implode", "(", "$", "glue", ",", "$", "array", "[", "$", "key", "]", ")", ";", "}", "else", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "array", ";", "}" ]
Adds a new option to the given array. If the key does not exists, it will create one, if it exists it will append the value and also makes sure the uniqueness of them. @param string $key the key name at the array @param string $value the value to add / append @param array $array the options to modify @param string $glue how the values will be joined @return array
[ "Adds", "a", "new", "option", "to", "the", "given", "array", ".", "If", "the", "key", "does", "not", "exists", "it", "will", "create", "one", "if", "it", "exists", "it", "will", "append", "the", "value", "and", "also", "makes", "sure", "the", "uniqueness", "of", "them", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L98-L109
18,266
2amigos/yiifoundation
helpers/ArrayHelper.php
ArrayHelper.getValue
public static function getValue($array, $key, $default = null) { if ($key instanceof \Closure) { return $key($array, $default); } elseif (is_array($array)) { return isset($array[$key]) || array_key_exists($key, $array) ? $array[$key] : $default; } else { return $array->$key; } }
php
public static function getValue($array, $key, $default = null) { if ($key instanceof \Closure) { return $key($array, $default); } elseif (is_array($array)) { return isset($array[$key]) || array_key_exists($key, $array) ? $array[$key] : $default; } else { return $array->$key; } }
[ "public", "static", "function", "getValue", "(", "$", "array", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "key", "instanceof", "\\", "Closure", ")", "{", "return", "$", "key", "(", "$", "array", ",", "$", "default", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "array", ")", ")", "{", "return", "isset", "(", "$", "array", "[", "$", "key", "]", ")", "||", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", "?", "$", "array", "[", "$", "key", "]", ":", "$", "default", ";", "}", "else", "{", "return", "$", "array", "->", "$", "key", ";", "}", "}" ]
Retrieves the value of an array element or object property with the given key or property name. If the key does not exist in the array, the default value will be returned instead. @param array|object $array array or object to extract value from @param string|\Closure $key key name of the array element, or property name of the object, or an anonymous function returning the value. The anonymous function signature should be: `function($array, $defaultValue)`. @param mixed $default the default value to be returned if the specified key does not exist @return mixed the value of the
[ "Retrieves", "the", "value", "of", "an", "array", "element", "or", "object", "property", "with", "the", "given", "key", "or", "property", "name", ".", "If", "the", "key", "does", "not", "exist", "in", "the", "array", "the", "default", "value", "will", "be", "returned", "instead", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L122-L131
18,267
2amigos/yiifoundation
helpers/ArrayHelper.php
ArrayHelper.removeValue
public static function removeValue(&$array, $key, $default = null) { if (is_array($array)) { $value = static::getValue($array, $key, $default); unset($array[$key]); return static::value($value); } return self::value($default); }
php
public static function removeValue(&$array, $key, $default = null) { if (is_array($array)) { $value = static::getValue($array, $key, $default); unset($array[$key]); return static::value($value); } return self::value($default); }
[ "public", "static", "function", "removeValue", "(", "&", "$", "array", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "array", ")", ")", "{", "$", "value", "=", "static", "::", "getValue", "(", "$", "array", ",", "$", "key", ",", "$", "default", ")", ";", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "return", "static", "::", "value", "(", "$", "value", ")", ";", "}", "return", "self", "::", "value", "(", "$", "default", ")", ";", "}" ]
Removes an item from the given options and returns the value. If no key is found, then default value will be returned. @param $array @param $key @param null $default @return mixed|null
[ "Removes", "an", "item", "from", "the", "given", "options", "and", "returns", "the", "value", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/ArrayHelper.php#L143-L151
18,268
dandisy/laravel-generator
src/Common/CommandData.php
CommandData.addLogs
private function addLogs() { $createdBy = new GeneratorField(); $createdBy->name = 'created_by'; $createdBy->parseDBType('integer'); $createdBy->parseOptions('if,n'); $this->fields[] = $createdBy; $updatedBy = new GeneratorField(); $updatedBy->name = 'updated_by'; $updatedBy->parseDBType('integer'); $updatedBy->parseOptions('if,n'); // edited by dandisy $this->fields[] = $updatedBy; }
php
private function addLogs() { $createdBy = new GeneratorField(); $createdBy->name = 'created_by'; $createdBy->parseDBType('integer'); $createdBy->parseOptions('if,n'); $this->fields[] = $createdBy; $updatedBy = new GeneratorField(); $updatedBy->name = 'updated_by'; $updatedBy->parseDBType('integer'); $updatedBy->parseOptions('if,n'); // edited by dandisy $this->fields[] = $updatedBy; }
[ "private", "function", "addLogs", "(", ")", "{", "$", "createdBy", "=", "new", "GeneratorField", "(", ")", ";", "$", "createdBy", "->", "name", "=", "'created_by'", ";", "$", "createdBy", "->", "parseDBType", "(", "'integer'", ")", ";", "$", "createdBy", "->", "parseOptions", "(", "'if,n'", ")", ";", "$", "this", "->", "fields", "[", "]", "=", "$", "createdBy", ";", "$", "updatedBy", "=", "new", "GeneratorField", "(", ")", ";", "$", "updatedBy", "->", "name", "=", "'updated_by'", ";", "$", "updatedBy", "->", "parseDBType", "(", "'integer'", ")", ";", "$", "updatedBy", "->", "parseOptions", "(", "'if,n'", ")", ";", "// edited by dandisy", "$", "this", "->", "fields", "[", "]", "=", "$", "updatedBy", ";", "}" ]
added by dandisy
[ "added", "by", "dandisy" ]
742797c8483bc88b54b6302a516a9a85eeb8579b
https://github.com/dandisy/laravel-generator/blob/742797c8483bc88b54b6302a516a9a85eeb8579b/src/Common/CommandData.php#L184-L197
18,269
webforge-labs/psc-cms
lib/Psc/Net/HTTP/Response.php
Response.output
public function output($flags = 0x00003) { if (($flags & self::OUTPUT_HEADER) == self::OUTPUT_HEADER) { $this->sendHeaders(); } if ($this->outputClosure instanceof \Closure) { $c = $this->outputClosure; $c(); return; } if (($flags & self::OUTPUT_BODY) == self::OUTPUT_BODY) { print $this->body; } }
php
public function output($flags = 0x00003) { if (($flags & self::OUTPUT_HEADER) == self::OUTPUT_HEADER) { $this->sendHeaders(); } if ($this->outputClosure instanceof \Closure) { $c = $this->outputClosure; $c(); return; } if (($flags & self::OUTPUT_BODY) == self::OUTPUT_BODY) { print $this->body; } }
[ "public", "function", "output", "(", "$", "flags", "=", "0x00003", ")", "{", "if", "(", "(", "$", "flags", "&", "self", "::", "OUTPUT_HEADER", ")", "==", "self", "::", "OUTPUT_HEADER", ")", "{", "$", "this", "->", "sendHeaders", "(", ")", ";", "}", "if", "(", "$", "this", "->", "outputClosure", "instanceof", "\\", "Closure", ")", "{", "$", "c", "=", "$", "this", "->", "outputClosure", ";", "$", "c", "(", ")", ";", "return", ";", "}", "if", "(", "(", "$", "flags", "&", "self", "::", "OUTPUT_BODY", ")", "==", "self", "::", "OUTPUT_BODY", ")", "{", "print", "$", "this", "->", "body", ";", "}", "}" ]
Sendet die Headers und gibt den Body aus @param bitmap $flags Default: (self::OUTPUT_HEADER | self::OUTPUT_BODY)
[ "Sendet", "die", "Headers", "und", "gibt", "den", "Body", "aus" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/Response.php#L146-L160
18,270
webtown-php/KunstmaanExtensionBundle
src/Form/PageParts/InsertPagePagePartAdminType.php
InsertPagePagePartAdminType.finishView
public function finishView(FormView $view, FormInterface $form, array $options) { $data = $form->getData(); if ($data instanceof InsertPagePagePart) { $this->validateParentPage(); $reflections = []; $nodeFormView = $view->children['node']; /** @var ChoiceView $choice */ foreach ($nodeFormView->vars['choices'] as $choice) { /** @var Node $currentData */ $currentData = $choice->data; $entityCls = $currentData->getRefEntityName(); if (!array_key_exists($entityCls, $reflections)) { $reflections[$entityCls] = new \ReflectionClass($entityCls); } // only the pages with the right interface are selectable if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) { $choice->attr['disabled'] = 'disabled'; } } } }
php
public function finishView(FormView $view, FormInterface $form, array $options) { $data = $form->getData(); if ($data instanceof InsertPagePagePart) { $this->validateParentPage(); $reflections = []; $nodeFormView = $view->children['node']; /** @var ChoiceView $choice */ foreach ($nodeFormView->vars['choices'] as $choice) { /** @var Node $currentData */ $currentData = $choice->data; $entityCls = $currentData->getRefEntityName(); if (!array_key_exists($entityCls, $reflections)) { $reflections[$entityCls] = new \ReflectionClass($entityCls); } // only the pages with the right interface are selectable if (!$reflections[$entityCls]->implementsInterface(InsertablePageInterface::class)) { $choice->attr['disabled'] = 'disabled'; } } } }
[ "public", "function", "finishView", "(", "FormView", "$", "view", ",", "FormInterface", "$", "form", ",", "array", "$", "options", ")", "{", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "if", "(", "$", "data", "instanceof", "InsertPagePagePart", ")", "{", "$", "this", "->", "validateParentPage", "(", ")", ";", "$", "reflections", "=", "[", "]", ";", "$", "nodeFormView", "=", "$", "view", "->", "children", "[", "'node'", "]", ";", "/** @var ChoiceView $choice */", "foreach", "(", "$", "nodeFormView", "->", "vars", "[", "'choices'", "]", "as", "$", "choice", ")", "{", "/** @var Node $currentData */", "$", "currentData", "=", "$", "choice", "->", "data", ";", "$", "entityCls", "=", "$", "currentData", "->", "getRefEntityName", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "entityCls", ",", "$", "reflections", ")", ")", "{", "$", "reflections", "[", "$", "entityCls", "]", "=", "new", "\\", "ReflectionClass", "(", "$", "entityCls", ")", ";", "}", "// only the pages with the right interface are selectable", "if", "(", "!", "$", "reflections", "[", "$", "entityCls", "]", "->", "implementsInterface", "(", "InsertablePageInterface", "::", "class", ")", ")", "{", "$", "choice", "->", "attr", "[", "'disabled'", "]", "=", "'disabled'", ";", "}", "}", "}", "}" ]
We want to set disable the parent page to prevent infinity insert cycle. If it is an edit page, we can disable this from form's data. @param FormView $view @param FormInterface $form @param array $options
[ "We", "want", "to", "set", "disable", "the", "parent", "page", "to", "prevent", "infinity", "insert", "cycle", ".", "If", "it", "is", "an", "edit", "page", "we", "can", "disable", "this", "from", "form", "s", "data", "." ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Form/PageParts/InsertPagePagePartAdminType.php#L97-L122
18,271
webtown-php/KunstmaanExtensionBundle
src/Form/PageParts/InsertPagePagePartAdminType.php
InsertPagePagePartAdminType.validateParentPage
protected function validateParentPage() { $request = $this->requestStack->getMasterRequest(); // the node which the pagepart belongs to if ($request->query->has('pageid') && $request->query->has('pageclassname')) { $repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node'); $node = $repo->getNodeForIdAndEntityname( $request->query->get('pageid'), $request->query->get('pageclassname') ); $pageReflection = new \ReflectionClass($node->getRefEntityName()); // if the current page implements the interface, then it is forbidden to insert anything beneath if ($pageReflection->implementsInterface(InsertablePageInterface::class)) { $currentContext = $this->requestStack->getMasterRequest()->get('context'); $page = $pageReflection->newInstanceWithoutConstructor(); // get pagepart configurations for the current page $pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page); foreach ($pagePartConfigs as $config) { if ($config->getContext() === $currentContext) { foreach ($config->getPossiblePagePartTypes() as $pagePartType) { if ($pagePartType['class'] === InsertPagePagePart::class) { throw new \LogicException( sprintf( 'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.', $pageReflection->getName(), InsertPagePagePart::class, InsertablePageInterface::class, $currentContext )); } } } } } } }
php
protected function validateParentPage() { $request = $this->requestStack->getMasterRequest(); // the node which the pagepart belongs to if ($request->query->has('pageid') && $request->query->has('pageclassname')) { $repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node'); $node = $repo->getNodeForIdAndEntityname( $request->query->get('pageid'), $request->query->get('pageclassname') ); $pageReflection = new \ReflectionClass($node->getRefEntityName()); // if the current page implements the interface, then it is forbidden to insert anything beneath if ($pageReflection->implementsInterface(InsertablePageInterface::class)) { $currentContext = $this->requestStack->getMasterRequest()->get('context'); $page = $pageReflection->newInstanceWithoutConstructor(); // get pagepart configurations for the current page $pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page); foreach ($pagePartConfigs as $config) { if ($config->getContext() === $currentContext) { foreach ($config->getPossiblePagePartTypes() as $pagePartType) { if ($pagePartType['class'] === InsertPagePagePart::class) { throw new \LogicException( sprintf( 'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.', $pageReflection->getName(), InsertPagePagePart::class, InsertablePageInterface::class, $currentContext )); } } } } } } }
[ "protected", "function", "validateParentPage", "(", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getMasterRequest", "(", ")", ";", "// the node which the pagepart belongs to", "if", "(", "$", "request", "->", "query", "->", "has", "(", "'pageid'", ")", "&&", "$", "request", "->", "query", "->", "has", "(", "'pageclassname'", ")", ")", "{", "$", "repo", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", "->", "getRepository", "(", "'KunstmaanNodeBundle:Node'", ")", ";", "$", "node", "=", "$", "repo", "->", "getNodeForIdAndEntityname", "(", "$", "request", "->", "query", "->", "get", "(", "'pageid'", ")", ",", "$", "request", "->", "query", "->", "get", "(", "'pageclassname'", ")", ")", ";", "$", "pageReflection", "=", "new", "\\", "ReflectionClass", "(", "$", "node", "->", "getRefEntityName", "(", ")", ")", ";", "// if the current page implements the interface, then it is forbidden to insert anything beneath", "if", "(", "$", "pageReflection", "->", "implementsInterface", "(", "InsertablePageInterface", "::", "class", ")", ")", "{", "$", "currentContext", "=", "$", "this", "->", "requestStack", "->", "getMasterRequest", "(", ")", "->", "get", "(", "'context'", ")", ";", "$", "page", "=", "$", "pageReflection", "->", "newInstanceWithoutConstructor", "(", ")", ";", "// get pagepart configurations for the current page", "$", "pagePartConfigs", "=", "$", "this", "->", "pagePartConfigReader", "->", "getPagePartAdminConfigurators", "(", "$", "page", ")", ";", "foreach", "(", "$", "pagePartConfigs", "as", "$", "config", ")", "{", "if", "(", "$", "config", "->", "getContext", "(", ")", "===", "$", "currentContext", ")", "{", "foreach", "(", "$", "config", "->", "getPossiblePagePartTypes", "(", ")", "as", "$", "pagePartType", ")", "{", "if", "(", "$", "pagePartType", "[", "'class'", "]", "===", "InsertPagePagePart", "::", "class", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'The %s page must not allow %s as possible page part, because it implements %s! You must modify the \"%s\" context.'", ",", "$", "pageReflection", "->", "getName", "(", ")", ",", "InsertPagePagePart", "::", "class", ",", "InsertablePageInterface", "::", "class", ",", "$", "currentContext", ")", ")", ";", "}", "}", "}", "}", "}", "}", "}" ]
Check if the page part is insertable into the current page. @throws \LogicException
[ "Check", "if", "the", "page", "part", "is", "insertable", "into", "the", "current", "page", "." ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Form/PageParts/InsertPagePagePartAdminType.php#L129-L169
18,272
digitalkaoz/versioneye-php
src/Api/Github.php
Github.repos
public function repos($language = null, $private = null, $organization = null, $type = null, $imported = null) { return $this->request(sprintf('github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b', $language, $private, $organization, $type, 1, $imported )); }
php
public function repos($language = null, $private = null, $organization = null, $type = null, $imported = null) { return $this->request(sprintf('github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b', $language, $private, $organization, $type, 1, $imported )); }
[ "public", "function", "repos", "(", "$", "language", "=", "null", ",", "$", "private", "=", "null", ",", "$", "organization", "=", "null", ",", "$", "type", "=", "null", ",", "$", "imported", "=", "null", ")", "{", "return", "$", "this", "->", "request", "(", "sprintf", "(", "'github?lang=%s&private=%b&org_name=%s&org_type=%s&page=%d&only_imported=%b'", ",", "$", "language", ",", "$", "private", ",", "$", "organization", ",", "$", "type", ",", "1", ",", "$", "imported", ")", ")", ";", "}" ]
lists your's github repos. @param string $language @param bool $private @param string $organization @param string $type @param bool $imported @return array
[ "lists", "your", "s", "github", "repos", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Api/Github.php#L25-L30
18,273
digitalkaoz/versioneye-php
src/Api/Github.php
Github.import
public function import($repository, $branch = null, $file = null) { return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST'); }
php
public function import($repository, $branch = null, $file = null) { return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST'); }
[ "public", "function", "import", "(", "$", "repository", ",", "$", "branch", "=", "null", ",", "$", "file", "=", "null", ")", "{", "return", "$", "this", "->", "request", "(", "sprintf", "(", "'github/%s?branch=%s&file=%s'", ",", "$", "this", "->", "transform", "(", "$", "repository", ")", ",", "$", "branch", ",", "$", "file", ")", ",", "'POST'", ")", ";", "}" ]
imports project file from github. @param string $repository @param string $branch @param string $file @return array
[ "imports", "project", "file", "from", "github", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Api/Github.php#L63-L66
18,274
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishHelper.php
CoverFishHelper.getClassFromUse
public function getClassFromUse($coverClassName, $usedClasses) { if (false === is_array($usedClasses)) { return $coverClassName; } foreach ($usedClasses as $use) { $this->getClassNameFromClassFQN($use); if ($coverClassName === $this->getClassNameFromClassFQN($use)) { return $use; } } return $coverClassName; }
php
public function getClassFromUse($coverClassName, $usedClasses) { if (false === is_array($usedClasses)) { return $coverClassName; } foreach ($usedClasses as $use) { $this->getClassNameFromClassFQN($use); if ($coverClassName === $this->getClassNameFromClassFQN($use)) { return $use; } } return $coverClassName; }
[ "public", "function", "getClassFromUse", "(", "$", "coverClassName", ",", "$", "usedClasses", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "usedClasses", ")", ")", "{", "return", "$", "coverClassName", ";", "}", "foreach", "(", "$", "usedClasses", "as", "$", "use", ")", "{", "$", "this", "->", "getClassNameFromClassFQN", "(", "$", "use", ")", ";", "if", "(", "$", "coverClassName", "===", "$", "this", "->", "getClassNameFromClassFQN", "(", "$", "use", ")", ")", "{", "return", "$", "use", ";", "}", "}", "return", "$", "coverClassName", ";", "}" ]
check for className in use statements, return className on missing use statement @param string $coverClassName @param array|null $usedClasses @return string
[ "check", "for", "className", "in", "use", "statements", "return", "className", "on", "missing", "use", "statement" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L94-L108
18,275
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishHelper.php
CoverFishHelper.getUsedClassesInClass
public function getUsedClassesInClass($classFile) { $useResult = array(); $content = $this->getFileContent($classFile); if (preg_match_all('/(use\s+)(.*)(;)/', $content, $useResult) && 4 === count($useResult)) { // @todo: use keyName based result check instead of index! return ($useResult[2]); } return null; }
php
public function getUsedClassesInClass($classFile) { $useResult = array(); $content = $this->getFileContent($classFile); if (preg_match_all('/(use\s+)(.*)(;)/', $content, $useResult) && 4 === count($useResult)) { // @todo: use keyName based result check instead of index! return ($useResult[2]); } return null; }
[ "public", "function", "getUsedClassesInClass", "(", "$", "classFile", ")", "{", "$", "useResult", "=", "array", "(", ")", ";", "$", "content", "=", "$", "this", "->", "getFileContent", "(", "$", "classFile", ")", ";", "if", "(", "preg_match_all", "(", "'/(use\\s+)(.*)(;)/'", ",", "$", "content", ",", "$", "useResult", ")", "&&", "4", "===", "count", "(", "$", "useResult", ")", ")", "{", "// @todo: use keyName based result check instead of index!", "return", "(", "$", "useResult", "[", "2", "]", ")", ";", "}", "return", "null", ";", "}" ]
return all in file use statement defined classes @param string $classFile absolute path of readable class file @return array
[ "return", "all", "in", "file", "use", "statement", "defined", "classes" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishHelper.php#L117-L127
18,276
factorio-item-browser/export-data
src/Registry/ContentRegistry.php
ContentRegistry.set
public function set(string $hash, string $content): void { $this->saveContent($hash, $content); }
php
public function set(string $hash, string $content): void { $this->saveContent($hash, $content); }
[ "public", "function", "set", "(", "string", "$", "hash", ",", "string", "$", "content", ")", ":", "void", "{", "$", "this", "->", "saveContent", "(", "$", "hash", ",", "$", "content", ")", ";", "}" ]
Sets content into the registry. @param string $hash @param string $content
[ "Sets", "content", "into", "the", "registry", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/ContentRegistry.php#L20-L23
18,277
gries/rcon
src/MessengerFactory.php
MessengerFactory.create
public static function create($host, $port, $password) { $connection = ConnectionFactory::create($host, $port, $password); return new Messenger($connection); }
php
public static function create($host, $port, $password) { $connection = ConnectionFactory::create($host, $port, $password); return new Messenger($connection); }
[ "public", "static", "function", "create", "(", "$", "host", ",", "$", "port", ",", "$", "password", ")", "{", "$", "connection", "=", "ConnectionFactory", "::", "create", "(", "$", "host", ",", "$", "port", ",", "$", "password", ")", ";", "return", "new", "Messenger", "(", "$", "connection", ")", ";", "}" ]
Create a new RconMessenger @param $host @param $port @param $password @return \gries\Rcon\Messenger
[ "Create", "a", "new", "RconMessenger" ]
7fada05b329d89542692af00ab80db02ad59d45d
https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/MessengerFactory.php#L24-L29
18,278
Nozemi/SlickBoard-Library
lib/SBLib/Utilities/Config.php
Config.get
public function get($name, $default = null, $file = null) { $configVal = null; if(is_array($this->config)) { if($file === null) { if(count(array_column($this->config, $name)) > 0) { $configVal = array_column($this->config, $name)[0]; } else { $configVal = array_column($this->config, $name); } } else { if(count(array_column($this->config->$file, $name)) > 0) { $configVal = array_column($this->config->$file, $name)[0]; } else { $configVal = array_column($this->config->$file, $name); } } } if(empty($configVal)) { return $default; } return $configVal; }
php
public function get($name, $default = null, $file = null) { $configVal = null; if(is_array($this->config)) { if($file === null) { if(count(array_column($this->config, $name)) > 0) { $configVal = array_column($this->config, $name)[0]; } else { $configVal = array_column($this->config, $name); } } else { if(count(array_column($this->config->$file, $name)) > 0) { $configVal = array_column($this->config->$file, $name)[0]; } else { $configVal = array_column($this->config->$file, $name); } } } if(empty($configVal)) { return $default; } return $configVal; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ",", "$", "file", "=", "null", ")", "{", "$", "configVal", "=", "null", ";", "if", "(", "is_array", "(", "$", "this", "->", "config", ")", ")", "{", "if", "(", "$", "file", "===", "null", ")", "{", "if", "(", "count", "(", "array_column", "(", "$", "this", "->", "config", ",", "$", "name", ")", ")", ">", "0", ")", "{", "$", "configVal", "=", "array_column", "(", "$", "this", "->", "config", ",", "$", "name", ")", "[", "0", "]", ";", "}", "else", "{", "$", "configVal", "=", "array_column", "(", "$", "this", "->", "config", ",", "$", "name", ")", ";", "}", "}", "else", "{", "if", "(", "count", "(", "array_column", "(", "$", "this", "->", "config", "->", "$", "file", ",", "$", "name", ")", ")", ">", "0", ")", "{", "$", "configVal", "=", "array_column", "(", "$", "this", "->", "config", "->", "$", "file", ",", "$", "name", ")", "[", "0", "]", ";", "}", "else", "{", "$", "configVal", "=", "array_column", "(", "$", "this", "->", "config", "->", "$", "file", ",", "$", "name", ")", ";", "}", "}", "}", "if", "(", "empty", "(", "$", "configVal", ")", ")", "{", "return", "$", "default", ";", "}", "return", "$", "configVal", ";", "}" ]
Gets a config value from the config array. @param string $name @param string $file @param mixed $default @return mixed
[ "Gets", "a", "config", "value", "from", "the", "config", "array", "." ]
c9f0a26a30f8127c997f75d7232eac170972418d
https://github.com/Nozemi/SlickBoard-Library/blob/c9f0a26a30f8127c997f75d7232eac170972418d/lib/SBLib/Utilities/Config.php#L83-L107
18,279
nyeholt/silverstripe-external-content
code/model/ExternalContentSource.php
ExternalContentSource.getCMSFields
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Sort'); $fields->removeByName('ParentID'); $fields->addFieldToTab('Root.Main', new TextField('Name', _t('ExternalContentSource.NAME', 'Name'))); $fields->addFieldToTab('Root.Main', new CheckboxField("ShowContentInMenu", _t('ExternalContentSource.SHOW_IN_MENUS', 'Show Content in Menus'))); return $fields; }
php
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Sort'); $fields->removeByName('ParentID'); $fields->addFieldToTab('Root.Main', new TextField('Name', _t('ExternalContentSource.NAME', 'Name'))); $fields->addFieldToTab('Root.Main', new CheckboxField("ShowContentInMenu", _t('ExternalContentSource.SHOW_IN_MENUS', 'Show Content in Menus'))); return $fields; }
[ "public", "function", "getCMSFields", "(", ")", "{", "$", "fields", "=", "parent", "::", "getCMSFields", "(", ")", ";", "$", "fields", "->", "removeByName", "(", "'Sort'", ")", ";", "$", "fields", "->", "removeByName", "(", "'ParentID'", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "new", "TextField", "(", "'Name'", ",", "_t", "(", "'ExternalContentSource.NAME'", ",", "'Name'", ")", ")", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "new", "CheckboxField", "(", "\"ShowContentInMenu\"", ",", "_t", "(", "'ExternalContentSource.SHOW_IN_MENUS'", ",", "'Show Content in Menus'", ")", ")", ")", ";", "return", "$", "fields", ";", "}" ]
Child classes should provide connection details to the external content source @see sapphire/core/model/DataObject#getCMSFields($params) @return FieldSet
[ "Child", "classes", "should", "provide", "connection", "details", "to", "the", "external", "content", "source" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentSource.php#L94-L103
18,280
nyeholt/silverstripe-external-content
code/model/ExternalContentSource.php
ExternalContentSource.stageChildren
public function stageChildren($showAll = false) { // if we don't have an ID directly, we should load and return ALL the external content sources if (!$this->ID) { return DataObject::get('ExternalContentSource'); } $children = new ArrayList(); return $children; }
php
public function stageChildren($showAll = false) { // if we don't have an ID directly, we should load and return ALL the external content sources if (!$this->ID) { return DataObject::get('ExternalContentSource'); } $children = new ArrayList(); return $children; }
[ "public", "function", "stageChildren", "(", "$", "showAll", "=", "false", ")", "{", "// if we don't have an ID directly, we should load and return ALL the external content sources", "if", "(", "!", "$", "this", "->", "ID", ")", "{", "return", "DataObject", "::", "get", "(", "'ExternalContentSource'", ")", ";", "}", "$", "children", "=", "new", "ArrayList", "(", ")", ";", "return", "$", "children", ";", "}" ]
Override to return the top level content items from the remote content source. Specific implementations should effectively query the remote source for all items that are children of the 'root' node. @param boolean $showAll @return DataObjectSet
[ "Override", "to", "return", "the", "top", "level", "content", "items", "from", "the", "remote", "content", "source", "." ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentSource.php#L210-L218
18,281
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.core
private static function core($word,$iteration){ /* rotate the 32-bit word 8 bits to the left */ $word = self::rotate($word); /* apply S-Box substitution on all 4 parts of the 32-bit word */ for ($i = 0; $i < 4; ++$i) $word[$i] = self::$sbox[$word[$i]]; /* XOR the output of the rcon operation with i to the first part (leftmost) only */ $word[0] = $word[0]^self::$Rcon[$iteration]; return $word; }
php
private static function core($word,$iteration){ /* rotate the 32-bit word 8 bits to the left */ $word = self::rotate($word); /* apply S-Box substitution on all 4 parts of the 32-bit word */ for ($i = 0; $i < 4; ++$i) $word[$i] = self::$sbox[$word[$i]]; /* XOR the output of the rcon operation with i to the first part (leftmost) only */ $word[0] = $word[0]^self::$Rcon[$iteration]; return $word; }
[ "private", "static", "function", "core", "(", "$", "word", ",", "$", "iteration", ")", "{", "/* rotate the 32-bit word 8 bits to the left */", "$", "word", "=", "self", "::", "rotate", "(", "$", "word", ")", ";", "/* apply S-Box substitution on all 4 parts of the 32-bit word */", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "++", "$", "i", ")", "$", "word", "[", "$", "i", "]", "=", "self", "::", "$", "sbox", "[", "$", "word", "[", "$", "i", "]", "]", ";", "/* XOR the output of the rcon operation with i to the first part (leftmost) only */", "$", "word", "[", "0", "]", "=", "$", "word", "[", "0", "]", "^", "self", "::", "$", "Rcon", "[", "$", "iteration", "]", ";", "return", "$", "word", ";", "}" ]
Key Schedule Core
[ "Key", "Schedule", "Core" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L259-L268
18,282
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.createRoundKey
private static function createRoundKey($expandedKey,$roundKeyPointer){ $roundKey = array(); for ($i = 0; $i < 4; $i++) for ($j = 0; $j < 4; $j++) $roundKey[$j*4+$i] = $expandedKey[$roundKeyPointer + $i*4 + $j]; return $roundKey; }
php
private static function createRoundKey($expandedKey,$roundKeyPointer){ $roundKey = array(); for ($i = 0; $i < 4; $i++) for ($j = 0; $j < 4; $j++) $roundKey[$j*4+$i] = $expandedKey[$roundKeyPointer + $i*4 + $j]; return $roundKey; }
[ "private", "static", "function", "createRoundKey", "(", "$", "expandedKey", ",", "$", "roundKeyPointer", ")", "{", "$", "roundKey", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "$", "i", "++", ")", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "4", ";", "$", "j", "++", ")", "$", "roundKey", "[", "$", "j", "*", "4", "+", "$", "i", "]", "=", "$", "expandedKey", "[", "$", "roundKeyPointer", "+", "$", "i", "*", "4", "+", "$", "j", "]", ";", "return", "$", "roundKey", ";", "}" ]
position within the expanded key.
[ "position", "within", "the", "expanded", "key", "." ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L331-L337
18,283
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.round
private static function round($state, $roundKey){ $state = self::subBytes($state,false); $state = self::shiftRows($state,false); $state = self::mixColumns($state,false); $state = self::addRoundKey($state, $roundKey); return $state; }
php
private static function round($state, $roundKey){ $state = self::subBytes($state,false); $state = self::shiftRows($state,false); $state = self::mixColumns($state,false); $state = self::addRoundKey($state, $roundKey); return $state; }
[ "private", "static", "function", "round", "(", "$", "state", ",", "$", "roundKey", ")", "{", "$", "state", "=", "self", "::", "subBytes", "(", "$", "state", ",", "false", ")", ";", "$", "state", "=", "self", "::", "shiftRows", "(", "$", "state", ",", "false", ")", ";", "$", "state", "=", "self", "::", "mixColumns", "(", "$", "state", ",", "false", ")", ";", "$", "state", "=", "self", "::", "addRoundKey", "(", "$", "state", ",", "$", "roundKey", ")", ";", "return", "$", "state", ";", "}" ]
applies the 4 operations of the forward round in sequence
[ "applies", "the", "4", "operations", "of", "the", "forward", "round", "in", "sequence" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L401-L407
18,284
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.invRound
private static function invRound($state,$roundKey){ $state = self::shiftRows($state,true); $state = self::subBytes($state,true); $state = self::addRoundKey($state, $roundKey); $state = self::mixColumns($state,true); return $state; }
php
private static function invRound($state,$roundKey){ $state = self::shiftRows($state,true); $state = self::subBytes($state,true); $state = self::addRoundKey($state, $roundKey); $state = self::mixColumns($state,true); return $state; }
[ "private", "static", "function", "invRound", "(", "$", "state", ",", "$", "roundKey", ")", "{", "$", "state", "=", "self", "::", "shiftRows", "(", "$", "state", ",", "true", ")", ";", "$", "state", "=", "self", "::", "subBytes", "(", "$", "state", ",", "true", ")", ";", "$", "state", "=", "self", "::", "addRoundKey", "(", "$", "state", ",", "$", "roundKey", ")", ";", "$", "state", "=", "self", "::", "mixColumns", "(", "$", "state", ",", "true", ")", ";", "return", "$", "state", ";", "}" ]
applies the 4 operations of the inverse round in sequence
[ "applies", "the", "4", "operations", "of", "the", "inverse", "round", "in", "sequence" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L410-L416
18,285
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.encryptBlock
private static function encryptBlock($input,$key,$size){ $output = array(); $block = array(); /* the 128 bit block to encode */ $nbrRounds = self::numberOfRounds($size); /* Set the block values, for the block: * a0,0 a0,1 a0,2 a0,3 * a1,0 a1,1 a1,2 a1,3 * a2,0 a2,1 a2,2 a2,3 * a3,0 a3,1 a3,2 a3,3 * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3 */ for ($i = 0; $i < 4; $i++) /* iterate over the columns */ for ($j = 0; $j < 4; $j++) /* iterate over the rows */ $block[($i+($j*4))] = $input[($i*4)+$j]; /* expand the key into an 176, 208, 240 bytes key */ $expandedKey = self::expandKey($key, $size); /* the expanded key */ /* encrypt the block using the expandedKey */ $block = self::main($block, $expandedKey, $nbrRounds); for ($k = 0; $k < 4; $k++) /* unmap the block again into the output */ for ($l = 0; $l < 4; $l++) /* iterate over the rows */ $output[($k*4)+$l] = $block[($k+($l*4))]; return $output; }
php
private static function encryptBlock($input,$key,$size){ $output = array(); $block = array(); /* the 128 bit block to encode */ $nbrRounds = self::numberOfRounds($size); /* Set the block values, for the block: * a0,0 a0,1 a0,2 a0,3 * a1,0 a1,1 a1,2 a1,3 * a2,0 a2,1 a2,2 a2,3 * a3,0 a3,1 a3,2 a3,3 * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3 */ for ($i = 0; $i < 4; $i++) /* iterate over the columns */ for ($j = 0; $j < 4; $j++) /* iterate over the rows */ $block[($i+($j*4))] = $input[($i*4)+$j]; /* expand the key into an 176, 208, 240 bytes key */ $expandedKey = self::expandKey($key, $size); /* the expanded key */ /* encrypt the block using the expandedKey */ $block = self::main($block, $expandedKey, $nbrRounds); for ($k = 0; $k < 4; $k++) /* unmap the block again into the output */ for ($l = 0; $l < 4; $l++) /* iterate over the rows */ $output[($k*4)+$l] = $block[($k+($l*4))]; return $output; }
[ "private", "static", "function", "encryptBlock", "(", "$", "input", ",", "$", "key", ",", "$", "size", ")", "{", "$", "output", "=", "array", "(", ")", ";", "$", "block", "=", "array", "(", ")", ";", "/* the 128 bit block to encode */", "$", "nbrRounds", "=", "self", "::", "numberOfRounds", "(", "$", "size", ")", ";", "/* Set the block values, for the block:\n\t\t * a0,0 a0,1 a0,2 a0,3\n\t\t * a1,0 a1,1 a1,2 a1,3\n\t\t * a2,0 a2,1 a2,2 a2,3\n\t\t * a3,0 a3,1 a3,2 a3,3\n\t\t * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3\n\t\t */", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "$", "i", "++", ")", "/* iterate over the columns */", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "4", ";", "$", "j", "++", ")", "/* iterate over the rows */", "$", "block", "[", "(", "$", "i", "+", "(", "$", "j", "*", "4", ")", ")", "]", "=", "$", "input", "[", "(", "$", "i", "*", "4", ")", "+", "$", "j", "]", ";", "/* expand the key into an 176, 208, 240 bytes key */", "$", "expandedKey", "=", "self", "::", "expandKey", "(", "$", "key", ",", "$", "size", ")", ";", "/* the expanded key */", "/* encrypt the block using the expandedKey */", "$", "block", "=", "self", "::", "main", "(", "$", "block", ",", "$", "expandedKey", ",", "$", "nbrRounds", ")", ";", "for", "(", "$", "k", "=", "0", ";", "$", "k", "<", "4", ";", "$", "k", "++", ")", "/* unmap the block again into the output */", "for", "(", "$", "l", "=", "0", ";", "$", "l", "<", "4", ";", "$", "l", "++", ")", "/* iterate over the rows */", "$", "output", "[", "(", "$", "k", "*", "4", ")", "+", "$", "l", "]", "=", "$", "block", "[", "(", "$", "k", "+", "(", "$", "l", "*", "4", ")", ")", "]", ";", "return", "$", "output", ";", "}" ]
encrypts a 128 bit input block against the given key of size specified
[ "encrypts", "a", "128", "bit", "input", "block", "against", "the", "given", "key", "of", "size", "specified" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L467-L490
18,286
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.decryptBlock
private static function decryptBlock($input, $key, $size){ $output = array(); $block = array(); /* the 128 bit block to decode */ $nbrRounds = self::numberOfRounds($size); /* Set the block values, for the block: * a0,0 a0,1 a0,2 a0,3 * a1,0 a1,1 a1,2 a1,3 * a2,0 a2,1 a2,2 a2,3 * a3,0 a3,1 a3,2 a3,3 * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3 */ for ($i = 0; $i < 4; $i++) /* iterate over the columns */ for ($j = 0; $j < 4; $j++) /* iterate over the rows */ $block[($i+($j*4))] = $input[($i*4)+$j]; /* expand the key into an 176, 208, 240 bytes key */ $expandedKey = self::expandKey($key, $size); /* decrypt the block using the expandedKey */ $block = self::invMain($block, $expandedKey, $nbrRounds); for ($k = 0; $k < 4; $k++)/* unmap the block again into the output */ for ($l = 0; $l < 4; $l++)/* iterate over the rows */ $output[($k*4)+$l] = $block[($k+($l*4))]; return $output; }
php
private static function decryptBlock($input, $key, $size){ $output = array(); $block = array(); /* the 128 bit block to decode */ $nbrRounds = self::numberOfRounds($size); /* Set the block values, for the block: * a0,0 a0,1 a0,2 a0,3 * a1,0 a1,1 a1,2 a1,3 * a2,0 a2,1 a2,2 a2,3 * a3,0 a3,1 a3,2 a3,3 * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3 */ for ($i = 0; $i < 4; $i++) /* iterate over the columns */ for ($j = 0; $j < 4; $j++) /* iterate over the rows */ $block[($i+($j*4))] = $input[($i*4)+$j]; /* expand the key into an 176, 208, 240 bytes key */ $expandedKey = self::expandKey($key, $size); /* decrypt the block using the expandedKey */ $block = self::invMain($block, $expandedKey, $nbrRounds); for ($k = 0; $k < 4; $k++)/* unmap the block again into the output */ for ($l = 0; $l < 4; $l++)/* iterate over the rows */ $output[($k*4)+$l] = $block[($k+($l*4))]; return $output; }
[ "private", "static", "function", "decryptBlock", "(", "$", "input", ",", "$", "key", ",", "$", "size", ")", "{", "$", "output", "=", "array", "(", ")", ";", "$", "block", "=", "array", "(", ")", ";", "/* the 128 bit block to decode */", "$", "nbrRounds", "=", "self", "::", "numberOfRounds", "(", "$", "size", ")", ";", "/* Set the block values, for the block:\n\t\t * a0,0 a0,1 a0,2 a0,3\n\t\t * a1,0 a1,1 a1,2 a1,3\n\t\t * a2,0 a2,1 a2,2 a2,3\n\t\t * a3,0 a3,1 a3,2 a3,3\n\t\t * the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3\n\t\t */", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "$", "i", "++", ")", "/* iterate over the columns */", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "4", ";", "$", "j", "++", ")", "/* iterate over the rows */", "$", "block", "[", "(", "$", "i", "+", "(", "$", "j", "*", "4", ")", ")", "]", "=", "$", "input", "[", "(", "$", "i", "*", "4", ")", "+", "$", "j", "]", ";", "/* expand the key into an 176, 208, 240 bytes key */", "$", "expandedKey", "=", "self", "::", "expandKey", "(", "$", "key", ",", "$", "size", ")", ";", "/* decrypt the block using the expandedKey */", "$", "block", "=", "self", "::", "invMain", "(", "$", "block", ",", "$", "expandedKey", ",", "$", "nbrRounds", ")", ";", "for", "(", "$", "k", "=", "0", ";", "$", "k", "<", "4", ";", "$", "k", "++", ")", "/* unmap the block again into the output */", "for", "(", "$", "l", "=", "0", ";", "$", "l", "<", "4", ";", "$", "l", "++", ")", "/* iterate over the rows */", "$", "output", "[", "(", "$", "k", "*", "4", ")", "+", "$", "l", "]", "=", "$", "block", "[", "(", "$", "k", "+", "(", "$", "l", "*", "4", ")", ")", "]", ";", "return", "$", "output", ";", "}" ]
decrypts a 128 bit input block against the given key of size specified
[ "decrypts", "a", "128", "bit", "input", "block", "against", "the", "given", "key", "of", "size", "specified" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L493-L515
18,287
Double-Opt-in/php-client-api
src/Security/SlowAES/AES.php
AES.getPaddedBlock
private static function getPaddedBlock($bytesIn,$start,$end,$mode){ if($end - $start > 16) $end = $start + 16; $xarray = array_slice($bytesIn, $start, $end-$start); $cpad = 16 - count($xarray); while(count($xarray) < 16){ array_push($xarray, $cpad); } return $xarray; }
php
private static function getPaddedBlock($bytesIn,$start,$end,$mode){ if($end - $start > 16) $end = $start + 16; $xarray = array_slice($bytesIn, $start, $end-$start); $cpad = 16 - count($xarray); while(count($xarray) < 16){ array_push($xarray, $cpad); } return $xarray; }
[ "private", "static", "function", "getPaddedBlock", "(", "$", "bytesIn", ",", "$", "start", ",", "$", "end", ",", "$", "mode", ")", "{", "if", "(", "$", "end", "-", "$", "start", ">", "16", ")", "$", "end", "=", "$", "start", "+", "16", ";", "$", "xarray", "=", "array_slice", "(", "$", "bytesIn", ",", "$", "start", ",", "$", "end", "-", "$", "start", ")", ";", "$", "cpad", "=", "16", "-", "count", "(", "$", "xarray", ")", ";", "while", "(", "count", "(", "$", "xarray", ")", "<", "16", ")", "{", "array_push", "(", "$", "xarray", ",", "$", "cpad", ")", ";", "}", "return", "$", "xarray", ";", "}" ]
gets a properly padded block
[ "gets", "a", "properly", "padded", "block" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/SlowAES/AES.php#L529-L542
18,288
okitcom/ok-lib-php
src/Service/Cash.php
Cash.refund
public function refund($guid, Amount $refundAmount) { return new Transaction( $this->client->post('transactions/' . $guid . '/refunds', ["amount" => $refundAmount]) ); }
php
public function refund($guid, Amount $refundAmount) { return new Transaction( $this->client->post('transactions/' . $guid . '/refunds', ["amount" => $refundAmount]) ); }
[ "public", "function", "refund", "(", "$", "guid", ",", "Amount", "$", "refundAmount", ")", "{", "return", "new", "Transaction", "(", "$", "this", "->", "client", "->", "post", "(", "'transactions/'", ".", "$", "guid", ".", "'/refunds'", ",", "[", "\"amount\"", "=>", "$", "refundAmount", "]", ")", ")", ";", "}" ]
Refunds a previously initiated and closed and captured transaction. @param $guid string identifier of transaction @param $refundAmount Amount amount to refund in cents @return string @throws NetworkException
[ "Refunds", "a", "previously", "initiated", "and", "closed", "and", "captured", "transaction", "." ]
1f441f3d216af7c952788e864bfe66bc4f089467
https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/Cash.php#L101-L105
18,289
ClanCats/Core
src/bundles/Database/Model/Relation/HasOne.php
Model_Relation_HasOne.prepare_query
protected function prepare_query() { $this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} ) ->limit( 1 ); }
php
protected function prepare_query() { $this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} ) ->limit( 1 ); }
[ "protected", "function", "prepare_query", "(", ")", "{", "$", "this", "->", "query", "->", "where", "(", "$", "this", "->", "foreign_key", ",", "$", "this", "->", "local_model", "->", "{", "$", "this", "->", "local_key", "}", ")", "->", "limit", "(", "1", ")", ";", "}" ]
Prepare the query object @return void
[ "Prepare", "the", "query", "object" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model/Relation/HasOne.php#L19-L23
18,290
alanpich/slender
core-modules/event-manager/src/EventManager.php
EventManager.hook
public function hook($event, callable $callback, $priority = 10) { $this->app->hook($event, $callback, $priority); }
php
public function hook($event, callable $callback, $priority = 10) { $this->app->hook($event, $callback, $priority); }
[ "public", "function", "hook", "(", "$", "event", ",", "callable", "$", "callback", ",", "$", "priority", "=", "10", ")", "{", "$", "this", "->", "app", "->", "hook", "(", "$", "event", ",", "$", "callback", ",", "$", "priority", ")", ";", "}" ]
Hook an event @param string $event Event/Hook name @param callable $callback Event handler @param int $priority 0 = high, 10 = low
[ "Hook", "an", "event" ]
247f5c08af20cda95b116eb5d9f6f623d61e8a8a
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/core-modules/event-manager/src/EventManager.php#L65-L68
18,291
alanpich/slender
core-modules/event-manager/src/EventManager.php
EventManager.applyChain
public function applyChain($name, $hookArg = null) { $hooks = $this->app->getHooks(); if (!isset($hooks[$name])) { $hooks[$name] = array(array()); } if (!empty($hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($hooks[$name]) > 1) { ksort($hooks[$name]); } foreach ($hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $value = call_user_func($callable, $hookArg); if ($value !== null) { return $value; } } } } } }
php
public function applyChain($name, $hookArg = null) { $hooks = $this->app->getHooks(); if (!isset($hooks[$name])) { $hooks[$name] = array(array()); } if (!empty($hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($hooks[$name]) > 1) { ksort($hooks[$name]); } foreach ($hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $value = call_user_func($callable, $hookArg); if ($value !== null) { return $value; } } } } } }
[ "public", "function", "applyChain", "(", "$", "name", ",", "$", "hookArg", "=", "null", ")", "{", "$", "hooks", "=", "$", "this", "->", "app", "->", "getHooks", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "hooks", "[", "$", "name", "]", ")", ")", "{", "$", "hooks", "[", "$", "name", "]", "=", "array", "(", "array", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "hooks", "[", "$", "name", "]", ")", ")", "{", "// Sort by priority, low to high, if there's more than one priority", "if", "(", "count", "(", "$", "hooks", "[", "$", "name", "]", ")", ">", "1", ")", "{", "ksort", "(", "$", "hooks", "[", "$", "name", "]", ")", ";", "}", "foreach", "(", "$", "hooks", "[", "$", "name", "]", "as", "$", "priority", ")", "{", "if", "(", "!", "empty", "(", "$", "priority", ")", ")", "{", "foreach", "(", "$", "priority", "as", "$", "callable", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "callable", ",", "$", "hookArg", ")", ";", "if", "(", "$", "value", "!==", "null", ")", "{", "return", "$", "value", ";", "}", "}", "}", "}", "}", "}" ]
Trigger a chained hook - The first callback to return a non-null value will be returned @param string $name the hook name @param mixed $hookArg (Optional) Argument for hooked functions @return mixed|void
[ "Trigger", "a", "chained", "hook", "-", "The", "first", "callback", "to", "return", "a", "non", "-", "null", "value", "will", "be", "returned" ]
247f5c08af20cda95b116eb5d9f6f623d61e8a8a
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/core-modules/event-manager/src/EventManager.php#L104-L127
18,292
yuncms/framework
src/console/controllers/OAuth2Controller.php
OAuth2Controller.actionClear
public function actionClear() { OAuth2AuthorizationCode::deleteAll(['<', 'expires', time()]); OAuth2RefreshToken::deleteAll(['<', 'expires', time()]); OAuth2AccessToken::deleteAll(['<', 'expires', time()]); }
php
public function actionClear() { OAuth2AuthorizationCode::deleteAll(['<', 'expires', time()]); OAuth2RefreshToken::deleteAll(['<', 'expires', time()]); OAuth2AccessToken::deleteAll(['<', 'expires', time()]); }
[ "public", "function", "actionClear", "(", ")", "{", "OAuth2AuthorizationCode", "::", "deleteAll", "(", "[", "'<'", ",", "'expires'", ",", "time", "(", ")", "]", ")", ";", "OAuth2RefreshToken", "::", "deleteAll", "(", "[", "'<'", ",", "'expires'", ",", "time", "(", ")", "]", ")", ";", "OAuth2AccessToken", "::", "deleteAll", "(", "[", "'<'", ",", "'expires'", ",", "time", "(", ")", "]", ")", ";", "}" ]
Clean up expired token
[ "Clean", "up", "expired", "token" ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/OAuth2Controller.php#L23-L28
18,293
nguyenanhung/nusoap
src/nusoap_client.php
nusoap_client.UpdateCookies
function UpdateCookies($cookies) { if (sizeof($this->cookies) == 0) { // no existing cookies: take whatever is new if (sizeof($cookies) > 0) { $this->debug('Setting new cookie(s)'); $this->cookies = $cookies; } return TRUE; } if (sizeof($cookies) == 0) { // no new cookies: keep what we've got return TRUE; } // merge foreach ($cookies as $newCookie) { if (!is_array($newCookie)) { continue; } if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) { continue; } $newName = $newCookie['name']; $found = FALSE; for ($i = 0; $i < count($this->cookies); $i++) { $cookie = $this->cookies[$i]; if (!is_array($cookie)) { continue; } if (!isset($cookie['name'])) { continue; } if ($newName != $cookie['name']) { continue; } $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; if ($newDomain != $domain) { continue; } $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; if ($newPath != $path) { continue; } $this->cookies[$i] = $newCookie; $found = TRUE; $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']); break; } if (!$found) { $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']); $this->cookies[] = $newCookie; } } return TRUE; }
php
function UpdateCookies($cookies) { if (sizeof($this->cookies) == 0) { // no existing cookies: take whatever is new if (sizeof($cookies) > 0) { $this->debug('Setting new cookie(s)'); $this->cookies = $cookies; } return TRUE; } if (sizeof($cookies) == 0) { // no new cookies: keep what we've got return TRUE; } // merge foreach ($cookies as $newCookie) { if (!is_array($newCookie)) { continue; } if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) { continue; } $newName = $newCookie['name']; $found = FALSE; for ($i = 0; $i < count($this->cookies); $i++) { $cookie = $this->cookies[$i]; if (!is_array($cookie)) { continue; } if (!isset($cookie['name'])) { continue; } if ($newName != $cookie['name']) { continue; } $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; if ($newDomain != $domain) { continue; } $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; if ($newPath != $path) { continue; } $this->cookies[$i] = $newCookie; $found = TRUE; $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']); break; } if (!$found) { $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']); $this->cookies[] = $newCookie; } } return TRUE; }
[ "function", "UpdateCookies", "(", "$", "cookies", ")", "{", "if", "(", "sizeof", "(", "$", "this", "->", "cookies", ")", "==", "0", ")", "{", "// no existing cookies: take whatever is new\r", "if", "(", "sizeof", "(", "$", "cookies", ")", ">", "0", ")", "{", "$", "this", "->", "debug", "(", "'Setting new cookie(s)'", ")", ";", "$", "this", "->", "cookies", "=", "$", "cookies", ";", "}", "return", "TRUE", ";", "}", "if", "(", "sizeof", "(", "$", "cookies", ")", "==", "0", ")", "{", "// no new cookies: keep what we've got\r", "return", "TRUE", ";", "}", "// merge\r", "foreach", "(", "$", "cookies", "as", "$", "newCookie", ")", "{", "if", "(", "!", "is_array", "(", "$", "newCookie", ")", ")", "{", "continue", ";", "}", "if", "(", "(", "!", "isset", "(", "$", "newCookie", "[", "'name'", "]", ")", ")", "||", "(", "!", "isset", "(", "$", "newCookie", "[", "'value'", "]", ")", ")", ")", "{", "continue", ";", "}", "$", "newName", "=", "$", "newCookie", "[", "'name'", "]", ";", "$", "found", "=", "FALSE", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "cookies", ")", ";", "$", "i", "++", ")", "{", "$", "cookie", "=", "$", "this", "->", "cookies", "[", "$", "i", "]", ";", "if", "(", "!", "is_array", "(", "$", "cookie", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "cookie", "[", "'name'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "newName", "!=", "$", "cookie", "[", "'name'", "]", ")", "{", "continue", ";", "}", "$", "newDomain", "=", "isset", "(", "$", "newCookie", "[", "'domain'", "]", ")", "?", "$", "newCookie", "[", "'domain'", "]", ":", "'NODOMAIN'", ";", "$", "domain", "=", "isset", "(", "$", "cookie", "[", "'domain'", "]", ")", "?", "$", "cookie", "[", "'domain'", "]", ":", "'NODOMAIN'", ";", "if", "(", "$", "newDomain", "!=", "$", "domain", ")", "{", "continue", ";", "}", "$", "newPath", "=", "isset", "(", "$", "newCookie", "[", "'path'", "]", ")", "?", "$", "newCookie", "[", "'path'", "]", ":", "'NOPATH'", ";", "$", "path", "=", "isset", "(", "$", "cookie", "[", "'path'", "]", ")", "?", "$", "cookie", "[", "'path'", "]", ":", "'NOPATH'", ";", "if", "(", "$", "newPath", "!=", "$", "path", ")", "{", "continue", ";", "}", "$", "this", "->", "cookies", "[", "$", "i", "]", "=", "$", "newCookie", ";", "$", "found", "=", "TRUE", ";", "$", "this", "->", "debug", "(", "'Update cookie '", ".", "$", "newName", ".", "'='", ".", "$", "newCookie", "[", "'value'", "]", ")", ";", "break", ";", "}", "if", "(", "!", "$", "found", ")", "{", "$", "this", "->", "debug", "(", "'Add cookie '", ".", "$", "newName", ".", "'='", ".", "$", "newCookie", "[", "'value'", "]", ")", ";", "$", "this", "->", "cookies", "[", "]", "=", "$", "newCookie", ";", "}", "}", "return", "TRUE", ";", "}" ]
updates the current cookies with a new set @param array $cookies new cookies with which to update current ones @return boolean always return true @access private
[ "updates", "the", "current", "cookies", "with", "a", "new", "set" ]
a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556
https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src/nusoap_client.php#L999-L1058
18,294
yuncms/framework
src/user/models/User.php
User.getNotifications
public function getNotifications() { if ($this instanceof RESTUser) { return $this->hasMany(RESTDatabaseNotification::class, ['notifiable_id' => 'id']) ->onCondition(['notifiable_class' => self::class]) ->addOrderBy(['created_at' => SORT_DESC]); } else { return $this->hasMany(DatabaseNotification::class, ['notifiable_id' => 'id']) ->onCondition(['notifiable_class' => self::class]) ->addOrderBy(['created_at' => SORT_DESC]); } }
php
public function getNotifications() { if ($this instanceof RESTUser) { return $this->hasMany(RESTDatabaseNotification::class, ['notifiable_id' => 'id']) ->onCondition(['notifiable_class' => self::class]) ->addOrderBy(['created_at' => SORT_DESC]); } else { return $this->hasMany(DatabaseNotification::class, ['notifiable_id' => 'id']) ->onCondition(['notifiable_class' => self::class]) ->addOrderBy(['created_at' => SORT_DESC]); } }
[ "public", "function", "getNotifications", "(", ")", "{", "if", "(", "$", "this", "instanceof", "RESTUser", ")", "{", "return", "$", "this", "->", "hasMany", "(", "RESTDatabaseNotification", "::", "class", ",", "[", "'notifiable_id'", "=>", "'id'", "]", ")", "->", "onCondition", "(", "[", "'notifiable_class'", "=>", "self", "::", "class", "]", ")", "->", "addOrderBy", "(", "[", "'created_at'", "=>", "SORT_DESC", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "hasMany", "(", "DatabaseNotification", "::", "class", ",", "[", "'notifiable_id'", "=>", "'id'", "]", ")", "->", "onCondition", "(", "[", "'notifiable_class'", "=>", "self", "::", "class", "]", ")", "->", "addOrderBy", "(", "[", "'created_at'", "=>", "SORT_DESC", "]", ")", ";", "}", "}" ]
Get the entity's notifications. @return \yii\db\ActiveQuery
[ "Get", "the", "entity", "s", "notifications", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L459-L470
18,295
marcmascarell/arrayer
src/Arrayer.php
Arrayer.arrayDot
protected function arrayDot($array, $prepend = null) { if (function_exists('array_dot')) { return array_dot($array); } $results = []; foreach ($array as $key => $value) { if (is_array($value)) { $results = array_merge($results, $this->arrayDot($value, $prepend.$key.'.')); } else { $results[$prepend.$key] = $value; } } return $results; }
php
protected function arrayDot($array, $prepend = null) { if (function_exists('array_dot')) { return array_dot($array); } $results = []; foreach ($array as $key => $value) { if (is_array($value)) { $results = array_merge($results, $this->arrayDot($value, $prepend.$key.'.')); } else { $results[$prepend.$key] = $value; } } return $results; }
[ "protected", "function", "arrayDot", "(", "$", "array", ",", "$", "prepend", "=", "null", ")", "{", "if", "(", "function_exists", "(", "'array_dot'", ")", ")", "{", "return", "array_dot", "(", "$", "array", ")", ";", "}", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "results", "=", "array_merge", "(", "$", "results", ",", "$", "this", "->", "arrayDot", "(", "$", "value", ",", "$", "prepend", ".", "$", "key", ".", "'.'", ")", ")", ";", "}", "else", "{", "$", "results", "[", "$", "prepend", ".", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "results", ";", "}" ]
Flatten a multi-dimensional associative array with dots. From Laravel framework. @param array $array @param string $prepend @return array
[ "Flatten", "a", "multi", "-", "dimensional", "associative", "array", "with", "dots", ".", "From", "Laravel", "framework", "." ]
7c8e8fa95fd15d8f2f7c6ddf1142aa7d32735b09
https://github.com/marcmascarell/arrayer/blob/7c8e8fa95fd15d8f2f7c6ddf1142aa7d32735b09/src/Arrayer.php#L145-L162
18,296
andrelohmann/silverstripe-geolocation
code/defaults/AddGeodistanceFunction.php
AddGeodistanceFunction.requireDefaultRecords
public function requireDefaultRecords() { parent::requireDefaultRecords(); if(defined('CREATE_GEODISTANCE_UDF') && GEOFORM_CREATE_GEODISTANCE_UDF){ if(!defined('CreateGeodistanceOnce')){ define('CreateGeodistanceOnce', true); $q1 = "DROP FUNCTION IF EXISTS geodistance;"; $q2 = " CREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double NO SQL BEGIN DECLARE radius DOUBLE; DECLARE distance DOUBLE; DECLARE vara DOUBLE; DECLARE varb DOUBLE; DECLARE varc DOUBLE; SET lat1 = RADIANS(lat1); SET lng1 = RADIANS(lng1); SET lat2 = RADIANS(lat2); SET lng2 = RADIANS(lng2); SET radius = 6371.0; SET varb = SIN((lat2 - lat1) / 2.0); SET varc = SIN((lng2 - lng1) / 2.0); SET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc))); SET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END)); RETURN distance; END "; DB::query($q1); DB::query($q2); DB::alteration_message('MySQL geodistance function created', 'created'); } } }
php
public function requireDefaultRecords() { parent::requireDefaultRecords(); if(defined('CREATE_GEODISTANCE_UDF') && GEOFORM_CREATE_GEODISTANCE_UDF){ if(!defined('CreateGeodistanceOnce')){ define('CreateGeodistanceOnce', true); $q1 = "DROP FUNCTION IF EXISTS geodistance;"; $q2 = " CREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double NO SQL BEGIN DECLARE radius DOUBLE; DECLARE distance DOUBLE; DECLARE vara DOUBLE; DECLARE varb DOUBLE; DECLARE varc DOUBLE; SET lat1 = RADIANS(lat1); SET lng1 = RADIANS(lng1); SET lat2 = RADIANS(lat2); SET lng2 = RADIANS(lng2); SET radius = 6371.0; SET varb = SIN((lat2 - lat1) / 2.0); SET varc = SIN((lng2 - lng1) / 2.0); SET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc))); SET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END)); RETURN distance; END "; DB::query($q1); DB::query($q2); DB::alteration_message('MySQL geodistance function created', 'created'); } } }
[ "public", "function", "requireDefaultRecords", "(", ")", "{", "parent", "::", "requireDefaultRecords", "(", ")", ";", "if", "(", "defined", "(", "'CREATE_GEODISTANCE_UDF'", ")", "&&", "GEOFORM_CREATE_GEODISTANCE_UDF", ")", "{", "if", "(", "!", "defined", "(", "'CreateGeodistanceOnce'", ")", ")", "{", "define", "(", "'CreateGeodistanceOnce'", ",", "true", ")", ";", "$", "q1", "=", "\"DROP FUNCTION IF EXISTS geodistance;\"", ";", "$", "q2", "=", "\"\nCREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double\n NO SQL\nBEGIN\nDECLARE radius DOUBLE;\nDECLARE distance DOUBLE;\nDECLARE vara DOUBLE;\nDECLARE varb DOUBLE;\nDECLARE varc DOUBLE;\nSET lat1 = RADIANS(lat1);\nSET lng1 = RADIANS(lng1);\nSET lat2 = RADIANS(lat2);\nSET lng2 = RADIANS(lng2);\nSET radius = 6371.0;\nSET varb = SIN((lat2 - lat1) / 2.0);\nSET varc = SIN((lng2 - lng1) / 2.0);\nSET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc)));\nSET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END));\nRETURN distance;\nEND\n\"", ";", "DB", "::", "query", "(", "$", "q1", ")", ";", "DB", "::", "query", "(", "$", "q2", ")", ";", "DB", "::", "alteration_message", "(", "'MySQL geodistance function created'", ",", "'created'", ")", ";", "}", "}", "}" ]
Set Default Frontend group for new members
[ "Set", "Default", "Frontend", "group", "for", "new", "members" ]
124062008d8fa25b631bf5bb69b2ca79b53ef81b
https://github.com/andrelohmann/silverstripe-geolocation/blob/124062008d8fa25b631bf5bb69b2ca79b53ef81b/code/defaults/AddGeodistanceFunction.php#L9-L44
18,297
ARCANEDEV/Sanitizer
src/Entities/Rules.php
Rules.set
public function set(array $rules) { $this->items = array_merge( $this->items, $this->parseRules($rules) ); return $this; }
php
public function set(array $rules) { $this->items = array_merge( $this->items, $this->parseRules($rules) ); return $this; }
[ "public", "function", "set", "(", "array", "$", "rules", ")", "{", "$", "this", "->", "items", "=", "array_merge", "(", "$", "this", "->", "items", ",", "$", "this", "->", "parseRules", "(", "$", "rules", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set multiple rules. @param array $rules @return $this
[ "Set", "multiple", "rules", "." ]
e21990ce6d881366d52a7f4e5040b07cc3ecca96
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L43-L51
18,298
ARCANEDEV/Sanitizer
src/Entities/Rules.php
Rules.parseAttributeFilters
protected function parseAttributeFilters(array &$parsedRules, $attribute, $filters) { foreach (explode('|', $filters) as $filter) { $parsedFilter = $this->parseRule($filter); if ( ! empty($parsedFilter)) { $parsedRules[$attribute][] = $parsedFilter; } } }
php
protected function parseAttributeFilters(array &$parsedRules, $attribute, $filters) { foreach (explode('|', $filters) as $filter) { $parsedFilter = $this->parseRule($filter); if ( ! empty($parsedFilter)) { $parsedRules[$attribute][] = $parsedFilter; } } }
[ "protected", "function", "parseAttributeFilters", "(", "array", "&", "$", "parsedRules", ",", "$", "attribute", ",", "$", "filters", ")", "{", "foreach", "(", "explode", "(", "'|'", ",", "$", "filters", ")", "as", "$", "filter", ")", "{", "$", "parsedFilter", "=", "$", "this", "->", "parseRule", "(", "$", "filter", ")", ";", "if", "(", "!", "empty", "(", "$", "parsedFilter", ")", ")", "{", "$", "parsedRules", "[", "$", "attribute", "]", "[", "]", "=", "$", "parsedFilter", ";", "}", "}", "}" ]
Parse attribute's filters. @param array $parsedRules @param string $attribute @param string $filters
[ "Parse", "attribute", "s", "filters", "." ]
e21990ce6d881366d52a7f4e5040b07cc3ecca96
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L114-L123
18,299
ixocreate/application
src/Http/ErrorHandling/Factory/WhoopsFactory.php
WhoopsFactory.registerJsonHandler
private function registerJsonHandler(Whoops $whoops, $config) : void { if (empty($config['json_exceptions']['display'])) { return; } $handler = new JsonResponseHandler(); if (! empty($config['json_exceptions']['show_trace'])) { $handler->addTraceToOutput(true); } if (! empty($config['json_exceptions']['ajax_only'])) { if (\method_exists(WhoopsUtil::class, 'isAjaxRequest')) { // Whoops 2.x; don't push handler on stack unless we are in // an XHR request. if (! WhoopsUtil::isAjaxRequest()) { return; } } elseif (\method_exists($handler, 'onlyForAjaxRequests')) { // Whoops 1.x $handler->onlyForAjaxRequests(true); } } $whoops->pushHandler($handler); }
php
private function registerJsonHandler(Whoops $whoops, $config) : void { if (empty($config['json_exceptions']['display'])) { return; } $handler = new JsonResponseHandler(); if (! empty($config['json_exceptions']['show_trace'])) { $handler->addTraceToOutput(true); } if (! empty($config['json_exceptions']['ajax_only'])) { if (\method_exists(WhoopsUtil::class, 'isAjaxRequest')) { // Whoops 2.x; don't push handler on stack unless we are in // an XHR request. if (! WhoopsUtil::isAjaxRequest()) { return; } } elseif (\method_exists($handler, 'onlyForAjaxRequests')) { // Whoops 1.x $handler->onlyForAjaxRequests(true); } } $whoops->pushHandler($handler); }
[ "private", "function", "registerJsonHandler", "(", "Whoops", "$", "whoops", ",", "$", "config", ")", ":", "void", "{", "if", "(", "empty", "(", "$", "config", "[", "'json_exceptions'", "]", "[", "'display'", "]", ")", ")", "{", "return", ";", "}", "$", "handler", "=", "new", "JsonResponseHandler", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'json_exceptions'", "]", "[", "'show_trace'", "]", ")", ")", "{", "$", "handler", "->", "addTraceToOutput", "(", "true", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'json_exceptions'", "]", "[", "'ajax_only'", "]", ")", ")", "{", "if", "(", "\\", "method_exists", "(", "WhoopsUtil", "::", "class", ",", "'isAjaxRequest'", ")", ")", "{", "// Whoops 2.x; don't push handler on stack unless we are in", "// an XHR request.", "if", "(", "!", "WhoopsUtil", "::", "isAjaxRequest", "(", ")", ")", "{", "return", ";", "}", "}", "elseif", "(", "\\", "method_exists", "(", "$", "handler", ",", "'onlyForAjaxRequests'", ")", ")", "{", "// Whoops 1.x", "$", "handler", "->", "onlyForAjaxRequests", "(", "true", ")", ";", "}", "}", "$", "whoops", "->", "pushHandler", "(", "$", "handler", ")", ";", "}" ]
If configuration indicates a JsonResponseHandler, configure and register it. @param Whoops $whoops @param array|\ArrayAccess $config @return void
[ "If", "configuration", "indicates", "a", "JsonResponseHandler", "configure", "and", "register", "it", "." ]
6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05
https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/ErrorHandling/Factory/WhoopsFactory.php#L54-L80