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
238,600
drdplusinfo/drdplus-armourer
DrdPlus/Armourer/Armourer.php
Armourer.getBaseOfWoundsUsingWeaponlike
public function getBaseOfWoundsUsingWeaponlike(WeaponlikeCode $weaponlikeCode, Strength $currentStrength): int { // weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column $baseOfWounds = $this->tables->getBaseOfWoundsTable()->getBaseOfWounds( $this->getApplicableStrength($weaponlikeCode, $currentStrength), new IntegerObject($this->getWoundsOfWeaponlike($weaponlikeCode)) ); $baseOfWounds += $this->getBaseOfWoundsMalusByStrengthWithWeaponlike($weaponlikeCode, $currentStrength); return $baseOfWounds; }
php
public function getBaseOfWoundsUsingWeaponlike(WeaponlikeCode $weaponlikeCode, Strength $currentStrength): int { // weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column $baseOfWounds = $this->tables->getBaseOfWoundsTable()->getBaseOfWounds( $this->getApplicableStrength($weaponlikeCode, $currentStrength), new IntegerObject($this->getWoundsOfWeaponlike($weaponlikeCode)) ); $baseOfWounds += $this->getBaseOfWoundsMalusByStrengthWithWeaponlike($weaponlikeCode, $currentStrength); return $baseOfWounds; }
[ "public", "function", "getBaseOfWoundsUsingWeaponlike", "(", "WeaponlikeCode", "$", "weaponlikeCode", ",", "Strength", "$", "currentStrength", ")", ":", "int", "{", "// weapon base of wounds has to be summed with strength via bonus summing, see PPH page 92 right column", "$", "baseOfWounds", "=", "$", "this", "->", "tables", "->", "getBaseOfWoundsTable", "(", ")", "->", "getBaseOfWounds", "(", "$", "this", "->", "getApplicableStrength", "(", "$", "weaponlikeCode", ",", "$", "currentStrength", ")", ",", "new", "IntegerObject", "(", "$", "this", "->", "getWoundsOfWeaponlike", "(", "$", "weaponlikeCode", ")", ")", ")", ";", "$", "baseOfWounds", "+=", "$", "this", "->", "getBaseOfWoundsMalusByStrengthWithWeaponlike", "(", "$", "weaponlikeCode", ",", "$", "currentStrength", ")", ";", "return", "$", "baseOfWounds", ";", "}" ]
Gives base of wound with a weapon and user strength. @param WeaponlikeCode $weaponlikeCode @param Strength $currentStrength @return int @throws \DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownArmament @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownWeaponlike @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownRangedWeapon @throws \DrdPlus\Tables\Armaments\Exceptions\UnknownMeleeWeaponlike @throws \DrdPlus\Tables\Armaments\Weapons\Ranged\Exceptions\UnknownBow
[ "Gives", "base", "of", "wound", "with", "a", "weapon", "and", "user", "strength", "." ]
c2b8e2349881d4edb433689c5edba0810a32c6d8
https://github.com/drdplusinfo/drdplus-armourer/blob/c2b8e2349881d4edb433689c5edba0810a32c6d8/DrdPlus/Armourer/Armourer.php#L872-L882
238,601
zugoripls/laravel-framework
src/Illuminate/Events/Dispatcher.php
Dispatcher.callQueueMethodOnHandler
protected function callQueueMethodOnHandler($class, $method, $arguments) { $handler = (new ReflectionClass($class))->newInstanceWithoutConstructor(); $handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [ 'class' => $class, 'method' => $method, 'data' => serialize($arguments), ]); }
php
protected function callQueueMethodOnHandler($class, $method, $arguments) { $handler = (new ReflectionClass($class))->newInstanceWithoutConstructor(); $handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [ 'class' => $class, 'method' => $method, 'data' => serialize($arguments), ]); }
[ "protected", "function", "callQueueMethodOnHandler", "(", "$", "class", ",", "$", "method", ",", "$", "arguments", ")", "{", "$", "handler", "=", "(", "new", "ReflectionClass", "(", "$", "class", ")", ")", "->", "newInstanceWithoutConstructor", "(", ")", ";", "$", "handler", "->", "queue", "(", "$", "this", "->", "resolveQueue", "(", ")", ",", "'Illuminate\\Events\\CallQueuedHandler@call'", ",", "[", "'class'", "=>", "$", "class", ",", "'method'", "=>", "$", "method", ",", "'data'", "=>", "serialize", "(", "$", "arguments", ")", ",", "]", ")", ";", "}" ]
Call the queue method on the handler class. @param string $class @param string $method @param array $arguments @return void
[ "Call", "the", "queue", "method", "on", "the", "handler", "class", "." ]
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Events/Dispatcher.php#L430-L437
238,602
SocietyCMS/Core
Console/Installers/Scripts/AdminUserInstaller.php
AdminUserInstaller.createFirstUser
protected function createFirstUser() { $info = [ 'first_name' => $this->askForFirstName(), 'last_name' => $this->askForLastName(), 'email' => $this->askForEmail(), 'password' => $this->askForPassword(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), ]; $this->application->make('Modules\User\Repositories\UserRepository')->createWithRoles( $info, $this->getAdminRole() ); $this->command->info('Admin account created!'); }
php
protected function createFirstUser() { $info = [ 'first_name' => $this->askForFirstName(), 'last_name' => $this->askForLastName(), 'email' => $this->askForEmail(), 'password' => $this->askForPassword(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), ]; $this->application->make('Modules\User\Repositories\UserRepository')->createWithRoles( $info, $this->getAdminRole() ); $this->command->info('Admin account created!'); }
[ "protected", "function", "createFirstUser", "(", ")", "{", "$", "info", "=", "[", "'first_name'", "=>", "$", "this", "->", "askForFirstName", "(", ")", ",", "'last_name'", "=>", "$", "this", "->", "askForLastName", "(", ")", ",", "'email'", "=>", "$", "this", "->", "askForEmail", "(", ")", ",", "'password'", "=>", "$", "this", "->", "askForPassword", "(", ")", ",", "'created_at'", "=>", "Carbon", "::", "now", "(", ")", ",", "'updated_at'", "=>", "Carbon", "::", "now", "(", ")", ",", "]", ";", "$", "this", "->", "application", "->", "make", "(", "'Modules\\User\\Repositories\\UserRepository'", ")", "->", "createWithRoles", "(", "$", "info", ",", "$", "this", "->", "getAdminRole", "(", ")", ")", ";", "$", "this", "->", "command", "->", "info", "(", "'Admin account created!'", ")", ";", "}" ]
Create a first admin user. @param $adminRoleId
[ "Create", "a", "first", "admin", "user", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Console/Installers/Scripts/AdminUserInstaller.php#L78-L95
238,603
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.getInstallScript
public function getInstallScript() { if (! $this->installScript) { $installClass = $this->installNamespace.'Install'; if (! class_exists($installClass)) { $message = sprintf('No install class found at %s. Nothing to do.', $installClass); throw new RuntimeException($message); } $installScript = new $installClass; $this->installScript = $installScript; } return $this->installScript; }
php
public function getInstallScript() { if (! $this->installScript) { $installClass = $this->installNamespace.'Install'; if (! class_exists($installClass)) { $message = sprintf('No install class found at %s. Nothing to do.', $installClass); throw new RuntimeException($message); } $installScript = new $installClass; $this->installScript = $installScript; } return $this->installScript; }
[ "public", "function", "getInstallScript", "(", ")", "{", "if", "(", "!", "$", "this", "->", "installScript", ")", "{", "$", "installClass", "=", "$", "this", "->", "installNamespace", ".", "'Install'", ";", "if", "(", "!", "class_exists", "(", "$", "installClass", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'No install class found at %s. Nothing to do.'", ",", "$", "installClass", ")", ";", "throw", "new", "RuntimeException", "(", "$", "message", ")", ";", "}", "$", "installScript", "=", "new", "$", "installClass", ";", "$", "this", "->", "installScript", "=", "$", "installScript", ";", "}", "return", "$", "this", "->", "installScript", ";", "}" ]
Get install script Use injected script if it exist, otherwise instantiate the default. @return AbstractInstall @throws RuntimeException If the install class cannot be found
[ "Get", "install", "script" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L113-L130
238,604
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.hasTablesOrViews
protected function hasTablesOrViews() { $tables = $this->db->query('SHOW TABLES', DbAdapter::QUERY_MODE_EXECUTE); return (bool) count($tables); }
php
protected function hasTablesOrViews() { $tables = $this->db->query('SHOW TABLES', DbAdapter::QUERY_MODE_EXECUTE); return (bool) count($tables); }
[ "protected", "function", "hasTablesOrViews", "(", ")", "{", "$", "tables", "=", "$", "this", "->", "db", "->", "query", "(", "'SHOW TABLES'", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "return", "(", "bool", ")", "count", "(", "$", "tables", ")", ";", "}" ]
Checks for existing tables in the database @return boolean Whether or not there are existing tables
[ "Checks", "for", "existing", "tables", "in", "the", "database" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L180-L185
238,605
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.dropTables
protected function dropTables() { $tables = $this->db->query( 'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "BASE_TABLE"', DbAdapter::QUERY_MODE_EXECUTE ); // Disable foreign key checks -- we are wiping the database on purpose $this->db->query( 'SET FOREIGN_KEY_CHECKS = 0', DbAdapter::QUERY_MODE_EXECUTE ); foreach ($tables as $table) { $this->db->query( 'DROP TABLE '.reset($table), DbAdapter::QUERY_MODE_EXECUTE ); } // Re-enable foreign key checks $this->db->query( 'SET FOREIGN_KEY_CHECKS = 1', DbAdapter::QUERY_MODE_EXECUTE ); }
php
protected function dropTables() { $tables = $this->db->query( 'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "BASE_TABLE"', DbAdapter::QUERY_MODE_EXECUTE ); // Disable foreign key checks -- we are wiping the database on purpose $this->db->query( 'SET FOREIGN_KEY_CHECKS = 0', DbAdapter::QUERY_MODE_EXECUTE ); foreach ($tables as $table) { $this->db->query( 'DROP TABLE '.reset($table), DbAdapter::QUERY_MODE_EXECUTE ); } // Re-enable foreign key checks $this->db->query( 'SET FOREIGN_KEY_CHECKS = 1', DbAdapter::QUERY_MODE_EXECUTE ); }
[ "protected", "function", "dropTables", "(", ")", "{", "$", "tables", "=", "$", "this", "->", "db", "->", "query", "(", "'SHOW FULL TABLES WHERE TABLE_TYPE LIKE \"BASE_TABLE\"'", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "// Disable foreign key checks -- we are wiping the database on purpose", "$", "this", "->", "db", "->", "query", "(", "'SET FOREIGN_KEY_CHECKS = 0'", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "db", "->", "query", "(", "'DROP TABLE '", ".", "reset", "(", "$", "table", ")", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "}", "// Re-enable foreign key checks", "$", "this", "->", "db", "->", "query", "(", "'SET FOREIGN_KEY_CHECKS = 1'", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "}" ]
Drop all tables from the database
[ "Drop", "all", "tables", "from", "the", "database" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L190-L215
238,606
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.dropViews
protected function dropViews() { $views = $this->db->query( 'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "VIEW"', DbAdapter::QUERY_MODE_EXECUTE ); foreach ($views as $view) { $this->db->query( 'DROP VIEW '.reset($view), DbAdapter::QUERY_MODE_EXECUTE ); } }
php
protected function dropViews() { $views = $this->db->query( 'SHOW FULL TABLES WHERE TABLE_TYPE LIKE "VIEW"', DbAdapter::QUERY_MODE_EXECUTE ); foreach ($views as $view) { $this->db->query( 'DROP VIEW '.reset($view), DbAdapter::QUERY_MODE_EXECUTE ); } }
[ "protected", "function", "dropViews", "(", ")", "{", "$", "views", "=", "$", "this", "->", "db", "->", "query", "(", "'SHOW FULL TABLES WHERE TABLE_TYPE LIKE \"VIEW\"'", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "$", "this", "->", "db", "->", "query", "(", "'DROP VIEW '", ".", "reset", "(", "$", "view", ")", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "}", "}" ]
Drop all views from the database
[ "Drop", "all", "views", "from", "the", "database" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L220-L233
238,607
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.install
protected function install(AbstractInstall $installScript, OutputInterface $output) { $dataPath = DATADIR; $output->writeln(' Installing App...'); // Install the database structure $this->runSql( $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE, ' Creating initial database schema', sprintf(' Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE), $output ); // Install the database data $this->runSql( $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE, ' Inserting initial data', sprintf(' Database data file %s not found', GenerateInstallCommand::DATA_FILE), $output ); $output->writeln(' Running install script'); $installScript->execute($this->db); $output->write([' Install completed!', ''], true); }
php
protected function install(AbstractInstall $installScript, OutputInterface $output) { $dataPath = DATADIR; $output->writeln(' Installing App...'); // Install the database structure $this->runSql( $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE, ' Creating initial database schema', sprintf(' Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE), $output ); // Install the database data $this->runSql( $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE, ' Inserting initial data', sprintf(' Database data file %s not found', GenerateInstallCommand::DATA_FILE), $output ); $output->writeln(' Running install script'); $installScript->execute($this->db); $output->write([' Install completed!', ''], true); }
[ "protected", "function", "install", "(", "AbstractInstall", "$", "installScript", ",", "OutputInterface", "$", "output", ")", "{", "$", "dataPath", "=", "DATADIR", ";", "$", "output", "->", "writeln", "(", "' Installing App...'", ")", ";", "// Install the database structure", "$", "this", "->", "runSql", "(", "$", "dataPath", ".", "DIRECTORY_SEPARATOR", ".", "GenerateInstallCommand", "::", "STRUCTURE_FILE", ",", "' Creating initial database schema'", ",", "sprintf", "(", "' Database schema file %s not found'", ",", "GenerateInstallCommand", "::", "STRUCTURE_FILE", ")", ",", "$", "output", ")", ";", "// Install the database data", "$", "this", "->", "runSql", "(", "$", "dataPath", ".", "DIRECTORY_SEPARATOR", ".", "GenerateInstallCommand", "::", "DATA_FILE", ",", "' Inserting initial data'", ",", "sprintf", "(", "' Database data file %s not found'", ",", "GenerateInstallCommand", "::", "DATA_FILE", ")", ",", "$", "output", ")", ";", "$", "output", "->", "writeln", "(", "' Running install script'", ")", ";", "$", "installScript", "->", "execute", "(", "$", "this", "->", "db", ")", ";", "$", "output", "->", "write", "(", "[", "' Install completed!'", ",", "''", "]", ",", "true", ")", ";", "}" ]
Install fresh version of the database from db_structure and db_data files @param AbstractInstall $installScript @param OutputInterface $output Command line output interface
[ "Install", "fresh", "version", "of", "the", "database", "from", "db_structure", "and", "db_data", "files" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L241-L268
238,608
synapsestudios/synapse-base
src/Synapse/Install/RunInstallCommand.php
RunInstallCommand.runSql
protected function runSql($file, $message, $notFoundMessage, $output) { if (! is_file($file)) { $output->writeln($notFoundMessage); return; } $output->writeln($message); $dataSql = file_get_contents($file); // Split the sql file on new lines and insert into the database one line at a time foreach (preg_split('/;\s*\n/', $dataSql) as $command) { try { $query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE); } catch (Database_Exception $e) { if ($e->getCode() !== 1065) { // empty query throw $e; } } } }
php
protected function runSql($file, $message, $notFoundMessage, $output) { if (! is_file($file)) { $output->writeln($notFoundMessage); return; } $output->writeln($message); $dataSql = file_get_contents($file); // Split the sql file on new lines and insert into the database one line at a time foreach (preg_split('/;\s*\n/', $dataSql) as $command) { try { $query = $this->db->query($command, DbAdapter::QUERY_MODE_EXECUTE); } catch (Database_Exception $e) { if ($e->getCode() !== 1065) { // empty query throw $e; } } } }
[ "protected", "function", "runSql", "(", "$", "file", ",", "$", "message", ",", "$", "notFoundMessage", ",", "$", "output", ")", "{", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "$", "output", "->", "writeln", "(", "$", "notFoundMessage", ")", ";", "return", ";", "}", "$", "output", "->", "writeln", "(", "$", "message", ")", ";", "$", "dataSql", "=", "file_get_contents", "(", "$", "file", ")", ";", "// Split the sql file on new lines and insert into the database one line at a time", "foreach", "(", "preg_split", "(", "'/;\\s*\\n/'", ",", "$", "dataSql", ")", "as", "$", "command", ")", "{", "try", "{", "$", "query", "=", "$", "this", "->", "db", "->", "query", "(", "$", "command", ",", "DbAdapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "}", "catch", "(", "Database_Exception", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getCode", "(", ")", "!==", "1065", ")", "{", "// empty query", "throw", "$", "e", ";", "}", "}", "}", "}" ]
Given a filepath to a SQL file, load it and run the SQL statements inside @param string $file Path to SQL file @param string $message Message to output to the console if the file exists @param string $notFoundMessage Message to output to the console if the file does not exist
[ "Given", "a", "filepath", "to", "a", "SQL", "file", "load", "it", "and", "run", "the", "SQL", "statements", "inside" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/RunInstallCommand.php#L277-L299
238,609
cityware/city-snmp
src/MIBS/Extreme/SwMonitor/Memory.php
Memory.percentUsage
public function percentUsage() { $total = $this->systemTotal(); $free = $this->systemFree(); $usage = []; foreach( $total as $slotId => $amount ) { $usage[ $slotId ] = intval( ceil( ( ( $amount - $free[ $slotId ] ) * 100 ) / $amount ) ); } return $usage; }
php
public function percentUsage() { $total = $this->systemTotal(); $free = $this->systemFree(); $usage = []; foreach( $total as $slotId => $amount ) { $usage[ $slotId ] = intval( ceil( ( ( $amount - $free[ $slotId ] ) * 100 ) / $amount ) ); } return $usage; }
[ "public", "function", "percentUsage", "(", ")", "{", "$", "total", "=", "$", "this", "->", "systemTotal", "(", ")", ";", "$", "free", "=", "$", "this", "->", "systemFree", "(", ")", ";", "$", "usage", "=", "[", "]", ";", "foreach", "(", "$", "total", "as", "$", "slotId", "=>", "$", "amount", ")", "{", "$", "usage", "[", "$", "slotId", "]", "=", "intval", "(", "ceil", "(", "(", "(", "$", "amount", "-", "$", "free", "[", "$", "slotId", "]", ")", "*", "100", ")", "/", "$", "amount", ")", ")", ";", "}", "return", "$", "usage", ";", "}" ]
Percentage of memory used per slot @return array Integer percentage of memory used
[ "Percentage", "of", "memory", "used", "per", "slot" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Extreme/SwMonitor/Memory.php#L76-L88
238,610
OWeb/OWeb-Framework
OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/Select.php
Select.add
public function add($text, $value){ $this->select[] = array($text, $value); $this->validator->addPossibility($value); }
php
public function add($text, $value){ $this->select[] = array($text, $value); $this->validator->addPossibility($value); }
[ "public", "function", "add", "(", "$", "text", ",", "$", "value", ")", "{", "$", "this", "->", "select", "[", "]", "=", "array", "(", "$", "text", ",", "$", "value", ")", ";", "$", "this", "->", "validator", "->", "addPossibility", "(", "$", "value", ")", ";", "}" ]
Adds a value to the list of possiblities @param type $text The text to be shown for this value @param type $value The actual value.
[ "Adds", "a", "value", "to", "the", "list", "of", "possiblities" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/Select.php#L48-L51
238,611
crisu83/yii-composer
InstallHandler.php
InstallHandler.setPermissions
public static function setPermissions(Event $event) { $options = array_merge( array( self::PARAM_WRITABLE => array(), self::PARAM_EXECUTABLE => array(), ), $event->getComposer()->getPackage()->getExtra() ); foreach ((array)$options[self::PARAM_WRITABLE] as $path) { echo "Setting writable: $path ..."; if (is_dir($path)) { chmod($path, 0777); echo "done\n"; } else { echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path; return; } } foreach ((array)$options[self::PARAM_EXECUTABLE] as $path) { echo "Setting executable: $path ... "; if (is_file($path)) { chmod($path, 0755); echo "done\n"; } else { echo "\n\tThe file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path . "\n"; return; } } }
php
public static function setPermissions(Event $event) { $options = array_merge( array( self::PARAM_WRITABLE => array(), self::PARAM_EXECUTABLE => array(), ), $event->getComposer()->getPackage()->getExtra() ); foreach ((array)$options[self::PARAM_WRITABLE] as $path) { echo "Setting writable: $path ..."; if (is_dir($path)) { chmod($path, 0777); echo "done\n"; } else { echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path; return; } } foreach ((array)$options[self::PARAM_EXECUTABLE] as $path) { echo "Setting executable: $path ... "; if (is_file($path)) { chmod($path, 0755); echo "done\n"; } else { echo "\n\tThe file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path . "\n"; return; } } }
[ "public", "static", "function", "setPermissions", "(", "Event", "$", "event", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "self", "::", "PARAM_WRITABLE", "=>", "array", "(", ")", ",", "self", "::", "PARAM_EXECUTABLE", "=>", "array", "(", ")", ",", ")", ",", "$", "event", "->", "getComposer", "(", ")", "->", "getPackage", "(", ")", "->", "getExtra", "(", ")", ")", ";", "foreach", "(", "(", "array", ")", "$", "options", "[", "self", "::", "PARAM_WRITABLE", "]", "as", "$", "path", ")", "{", "echo", "\"Setting writable: $path ...\"", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "chmod", "(", "$", "path", ",", "0777", ")", ";", "echo", "\"done\\n\"", ";", "}", "else", "{", "echo", "\"The directory was not found: \"", ".", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ";", "return", ";", "}", "}", "foreach", "(", "(", "array", ")", "$", "options", "[", "self", "::", "PARAM_EXECUTABLE", "]", "as", "$", "path", ")", "{", "echo", "\"Setting executable: $path ... \"", ";", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "chmod", "(", "$", "path", ",", "0755", ")", ";", "echo", "\"done\\n\"", ";", "}", "else", "{", "echo", "\"\\n\\tThe file was not found: \"", ".", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ".", "\"\\n\"", ";", "return", ";", "}", "}", "}" ]
Sets the correct permissions of files and directories. @param Event $event
[ "Sets", "the", "correct", "permissions", "of", "files", "and", "directories", "." ]
848a5b5fd3419ebd504d40d25d9c659411383ae1
https://github.com/crisu83/yii-composer/blob/848a5b5fd3419ebd504d40d25d9c659411383ae1/InstallHandler.php#L32-L63
238,612
AyeAyeApi/Formatters
src/Writer/Xml.php
Xml.partialFormat
public function partialFormat($data, $nodeName = null) { if (!$nodeName) { $nodeName = $this->getNodeName($data); } $data = $this->parseData($data); if (is_scalar($data)) { return "<$nodeName>" . $this->parseScalarData($data) . "</$nodeName>"; } return "<$nodeName>".$this->parseNonScalarData($data, $nodeName)."</$nodeName>"; }
php
public function partialFormat($data, $nodeName = null) { if (!$nodeName) { $nodeName = $this->getNodeName($data); } $data = $this->parseData($data); if (is_scalar($data)) { return "<$nodeName>" . $this->parseScalarData($data) . "</$nodeName>"; } return "<$nodeName>".$this->parseNonScalarData($data, $nodeName)."</$nodeName>"; }
[ "public", "function", "partialFormat", "(", "$", "data", ",", "$", "nodeName", "=", "null", ")", "{", "if", "(", "!", "$", "nodeName", ")", "{", "$", "nodeName", "=", "$", "this", "->", "getNodeName", "(", "$", "data", ")", ";", "}", "$", "data", "=", "$", "this", "->", "parseData", "(", "$", "data", ")", ";", "if", "(", "is_scalar", "(", "$", "data", ")", ")", "{", "return", "\"<$nodeName>\"", ".", "$", "this", "->", "parseScalarData", "(", "$", "data", ")", ".", "\"</$nodeName>\"", ";", "}", "return", "\"<$nodeName>\"", ".", "$", "this", "->", "parseNonScalarData", "(", "$", "data", ",", "$", "nodeName", ")", ".", "\"</$nodeName>\"", ";", "}" ]
Format part of the data @param mixed $data The data to be serialised into xml @param string|null $nodeName The node currently being worked on @return string
[ "Format", "part", "of", "the", "data" ]
0141d0186e0555f7583be419f22280ac7ed24a6f
https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L50-L61
238,613
AyeAyeApi/Formatters
src/Writer/Xml.php
Xml.getNodeName
protected function getNodeName($data) { if (is_object($data)) { $nodeName = preg_replace('/.*\\\/', '', get_class($data)); return preg_replace('/\W/', '', $nodeName); } elseif (is_array($data)) { return 'array'; } return $this->defaultNodeName; }
php
protected function getNodeName($data) { if (is_object($data)) { $nodeName = preg_replace('/.*\\\/', '', get_class($data)); return preg_replace('/\W/', '', $nodeName); } elseif (is_array($data)) { return 'array'; } return $this->defaultNodeName; }
[ "protected", "function", "getNodeName", "(", "$", "data", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "$", "nodeName", "=", "preg_replace", "(", "'/.*\\\\\\/'", ",", "''", ",", "get_class", "(", "$", "data", ")", ")", ";", "return", "preg_replace", "(", "'/\\W/'", ",", "''", ",", "$", "nodeName", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "'array'", ";", "}", "return", "$", "this", "->", "defaultNodeName", ";", "}" ]
Try to guess the node name @param mixed $data Data to try to find the name of @return mixed|string
[ "Try", "to", "guess", "the", "node", "name" ]
0141d0186e0555f7583be419f22280ac7ed24a6f
https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L68-L77
238,614
AyeAyeApi/Formatters
src/Writer/Xml.php
Xml.parseNonScalarData
protected function parseNonScalarData($data, $fallbackName = null) { $xml = ''; if (!$fallbackName) { $fallbackName = $this->defaultNodeName; } foreach ($data as $property => $value) { // Clear non-alphanumeric characters $property = preg_replace('/\W/', '', $property); // If numeric we'll stick a character in front of it, a bit hack but should be valid if (is_numeric($property)) { $property = $fallbackName; } $xml .= $this->partialFormat($value, $property); } return $xml; }
php
protected function parseNonScalarData($data, $fallbackName = null) { $xml = ''; if (!$fallbackName) { $fallbackName = $this->defaultNodeName; } foreach ($data as $property => $value) { // Clear non-alphanumeric characters $property = preg_replace('/\W/', '', $property); // If numeric we'll stick a character in front of it, a bit hack but should be valid if (is_numeric($property)) { $property = $fallbackName; } $xml .= $this->partialFormat($value, $property); } return $xml; }
[ "protected", "function", "parseNonScalarData", "(", "$", "data", ",", "$", "fallbackName", "=", "null", ")", "{", "$", "xml", "=", "''", ";", "if", "(", "!", "$", "fallbackName", ")", "{", "$", "fallbackName", "=", "$", "this", "->", "defaultNodeName", ";", "}", "foreach", "(", "$", "data", "as", "$", "property", "=>", "$", "value", ")", "{", "// Clear non-alphanumeric characters", "$", "property", "=", "preg_replace", "(", "'/\\W/'", ",", "''", ",", "$", "property", ")", ";", "// If numeric we'll stick a character in front of it, a bit hack but should be valid", "if", "(", "is_numeric", "(", "$", "property", ")", ")", "{", "$", "property", "=", "$", "fallbackName", ";", "}", "$", "xml", ".=", "$", "this", "->", "partialFormat", "(", "$", "value", ",", "$", "property", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Recurse through non scalar data, serializing it @param array|object $data @param string|null $fallbackName The name to use for an element in the event it doesn't have one @return string
[ "Recurse", "through", "non", "scalar", "data", "serializing", "it" ]
0141d0186e0555f7583be419f22280ac7ed24a6f
https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Writer/Xml.php#L98-L116
238,615
JoshuaEstes/Daedalus
src/Daedalus/Application.php
Application.registerCommands
protected function registerCommands() { $this->add(new \Daedalus\Command\DumpContainerCommand($this->kernel->getContainer())); $this->add(new \Daedalus\Command\HelpCommand($this->kernel->getContainer())); }
php
protected function registerCommands() { $this->add(new \Daedalus\Command\DumpContainerCommand($this->kernel->getContainer())); $this->add(new \Daedalus\Command\HelpCommand($this->kernel->getContainer())); }
[ "protected", "function", "registerCommands", "(", ")", "{", "$", "this", "->", "add", "(", "new", "\\", "Daedalus", "\\", "Command", "\\", "DumpContainerCommand", "(", "$", "this", "->", "kernel", "->", "getContainer", "(", ")", ")", ")", ";", "$", "this", "->", "add", "(", "new", "\\", "Daedalus", "\\", "Command", "\\", "HelpCommand", "(", "$", "this", "->", "kernel", "->", "getContainer", "(", ")", ")", ")", ";", "}" ]
Registers the commands that are displayed to the developer
[ "Registers", "the", "commands", "that", "are", "displayed", "to", "the", "developer" ]
4c898c41433242e46b30d45ebe03fdc91512b444
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Application.php#L105-L109
238,616
JoshuaEstes/Daedalus
src/Daedalus/Application.php
Application.addOutputFormatterStyles
protected function addOutputFormatterStyles(OutputInterface $output) { foreach ($this->getOutputFormatterStyles() as $name => $style) { $output->getFormatter()->setStyle($name, $style); } }
php
protected function addOutputFormatterStyles(OutputInterface $output) { foreach ($this->getOutputFormatterStyles() as $name => $style) { $output->getFormatter()->setStyle($name, $style); } }
[ "protected", "function", "addOutputFormatterStyles", "(", "OutputInterface", "$", "output", ")", "{", "foreach", "(", "$", "this", "->", "getOutputFormatterStyles", "(", ")", "as", "$", "name", "=>", "$", "style", ")", "{", "$", "output", "->", "getFormatter", "(", ")", "->", "setStyle", "(", "$", "name", ",", "$", "style", ")", ";", "}", "}" ]
Adds extra styles to the output @param OutputInterface $output
[ "Adds", "extra", "styles", "to", "the", "output" ]
4c898c41433242e46b30d45ebe03fdc91512b444
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Application.php#L116-L121
238,617
bravesheep/dogmatist
src/Builder.php
Builder.fake
public function fake($field, $type, array $options = []) { $field = $this->get($field); $field->setFake($type, $options); return $this; }
php
public function fake($field, $type, array $options = []) { $field = $this->get($field); $field->setFake($type, $options); return $this; }
[ "public", "function", "fake", "(", "$", "field", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "field", "=", "$", "this", "->", "get", "(", "$", "field", ")", ";", "$", "field", "->", "setFake", "(", "$", "type", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Fake the contents of a field. @param string|int $field @param string|callback $type @param array $options @return $this
[ "Fake", "the", "contents", "of", "a", "field", "." ]
38c332e5ccff4e715b70e5f5ce153d96c745d695
https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Builder.php#L197-L202
238,618
bravesheep/dogmatist
src/Builder.php
Builder.copy
public function copy($type = null) { $builder = new Builder($this->type, $this->dogmatist, $this->parent, $this->strict); $this->copyData($builder); if ($type !== null) { $builder->setType($type); } return $builder; }
php
public function copy($type = null) { $builder = new Builder($this->type, $this->dogmatist, $this->parent, $this->strict); $this->copyData($builder); if ($type !== null) { $builder->setType($type); } return $builder; }
[ "public", "function", "copy", "(", "$", "type", "=", "null", ")", "{", "$", "builder", "=", "new", "Builder", "(", "$", "this", "->", "type", ",", "$", "this", "->", "dogmatist", ",", "$", "this", "->", "parent", ",", "$", "this", "->", "strict", ")", ";", "$", "this", "->", "copyData", "(", "$", "builder", ")", ";", "if", "(", "$", "type", "!==", "null", ")", "{", "$", "builder", "->", "setType", "(", "$", "type", ")", ";", "}", "return", "$", "builder", ";", "}" ]
Returns a clone for the current builder @param string $type The new type of the cloned builder. @return $this
[ "Returns", "a", "clone", "for", "the", "current", "builder" ]
38c332e5ccff4e715b70e5f5ce153d96c745d695
https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Builder.php#L512-L522
238,619
simplecomplex/php-cache
src/CacheKey.php
CacheKey.validate
public static function validate(string $key) : bool { $le = strlen($key); if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) { return false; } if ($key{0} === '-') { return false; } // Faster than a regular expression. // Prefix letter to make key without any alphanum pass. return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key)); }
php
public static function validate(string $key) : bool { $le = strlen($key); if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) { return false; } if ($key{0} === '-') { return false; } // Faster than a regular expression. // Prefix letter to make key without any alphanum pass. return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key)); }
[ "public", "static", "function", "validate", "(", "string", "$", "key", ")", ":", "bool", "{", "$", "le", "=", "strlen", "(", "$", "key", ")", ";", "if", "(", "$", "le", "<", "static", "::", "VALID_LENGTH_MIN", "||", "$", "le", ">", "static", "::", "VALID_LENGTH_MAX", ")", "{", "return", "false", ";", "}", "if", "(", "$", "key", "{", "0", "}", "===", "'-'", ")", "{", "return", "false", ";", "}", "// Faster than a regular expression.", "// Prefix letter to make key without any alphanum pass.", "return", "!", "!", "ctype_alnum", "(", "'A'", ".", "str_replace", "(", "static", "::", "VALID_NON_ALPHANUM", ",", "''", ",", "$", "key", ")", ")", ";", "}" ]
Checks that length and content is legal. First char cannot be hyphen, because that could break CLI interaction. @param string $key @return bool
[ "Checks", "that", "length", "and", "content", "is", "legal", "." ]
4eb088bc65041948df0dbefcf9da11261c50fca4
https://github.com/simplecomplex/php-cache/blob/4eb088bc65041948df0dbefcf9da11261c50fca4/src/CacheKey.php#L78-L90
238,620
QuanticTelecom/invoices
src/QuanticTelecom/Invoices/AbstractInvoice.php
AbstractInvoice.setDueDate
private function setDueDate(Carbon $dueDate = null) { if (is_null($dueDate)) { $dueDate = Carbon::now(); } $this->dueDate = $dueDate; }
php
private function setDueDate(Carbon $dueDate = null) { if (is_null($dueDate)) { $dueDate = Carbon::now(); } $this->dueDate = $dueDate; }
[ "private", "function", "setDueDate", "(", "Carbon", "$", "dueDate", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "dueDate", ")", ")", "{", "$", "dueDate", "=", "Carbon", "::", "now", "(", ")", ";", "}", "$", "this", "->", "dueDate", "=", "$", "dueDate", ";", "}" ]
Set the due date of the invoice, if null, set the current date. @param Carbon $dueDate | null @return void
[ "Set", "the", "due", "date", "of", "the", "invoice", "if", "null", "set", "the", "current", "date", "." ]
70b946c776a1014ebb8735bd58c2c6a8b37f87ae
https://github.com/QuanticTelecom/invoices/blob/70b946c776a1014ebb8735bd58c2c6a8b37f87ae/src/QuanticTelecom/Invoices/AbstractInvoice.php#L139-L146
238,621
QuanticTelecom/invoices
src/QuanticTelecom/Invoices/AbstractInvoice.php
AbstractInvoice.setCreatedAt
private function setCreatedAt(Carbon $createdAt = null) { if (is_null($createdAt)) { $createdAt = Carbon::now(); } $this->createdAt = $createdAt; }
php
private function setCreatedAt(Carbon $createdAt = null) { if (is_null($createdAt)) { $createdAt = Carbon::now(); } $this->createdAt = $createdAt; }
[ "private", "function", "setCreatedAt", "(", "Carbon", "$", "createdAt", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "createdAt", ")", ")", "{", "$", "createdAt", "=", "Carbon", "::", "now", "(", ")", ";", "}", "$", "this", "->", "createdAt", "=", "$", "createdAt", ";", "}" ]
Set the creation date of the invoice, if null, set the current date. @param Carbon $createdAt | null @return void
[ "Set", "the", "creation", "date", "of", "the", "invoice", "if", "null", "set", "the", "current", "date", "." ]
70b946c776a1014ebb8735bd58c2c6a8b37f87ae
https://github.com/QuanticTelecom/invoices/blob/70b946c776a1014ebb8735bd58c2c6a8b37f87ae/src/QuanticTelecom/Invoices/AbstractInvoice.php#L165-L172
238,622
wasabi-cms/core
src/Model/Table/GroupsTable.php
GroupsTable.moveUsersToAlternativeGroups
public function moveUsersToAlternativeGroups($userIdGroupIdMapping) { $affectedUsers = 0; $affectedGroups = []; foreach ($userIdGroupIdMapping as $userId => $groupId) { $affectedUsers += $this->UsersGroups->updateAll([ 'group_id' => $groupId ], [ 'user_id' => $userId ]); if (!in_array($groupId, $affectedGroups)) { $affectedGroups[] = $groupId; } } if ($affectedUsers > 0 && !empty($affectedGroups)) { $this->updateUserCount($affectedGroups); } return $affectedUsers; }
php
public function moveUsersToAlternativeGroups($userIdGroupIdMapping) { $affectedUsers = 0; $affectedGroups = []; foreach ($userIdGroupIdMapping as $userId => $groupId) { $affectedUsers += $this->UsersGroups->updateAll([ 'group_id' => $groupId ], [ 'user_id' => $userId ]); if (!in_array($groupId, $affectedGroups)) { $affectedGroups[] = $groupId; } } if ($affectedUsers > 0 && !empty($affectedGroups)) { $this->updateUserCount($affectedGroups); } return $affectedUsers; }
[ "public", "function", "moveUsersToAlternativeGroups", "(", "$", "userIdGroupIdMapping", ")", "{", "$", "affectedUsers", "=", "0", ";", "$", "affectedGroups", "=", "[", "]", ";", "foreach", "(", "$", "userIdGroupIdMapping", "as", "$", "userId", "=>", "$", "groupId", ")", "{", "$", "affectedUsers", "+=", "$", "this", "->", "UsersGroups", "->", "updateAll", "(", "[", "'group_id'", "=>", "$", "groupId", "]", ",", "[", "'user_id'", "=>", "$", "userId", "]", ")", ";", "if", "(", "!", "in_array", "(", "$", "groupId", ",", "$", "affectedGroups", ")", ")", "{", "$", "affectedGroups", "[", "]", "=", "$", "groupId", ";", "}", "}", "if", "(", "$", "affectedUsers", ">", "0", "&&", "!", "empty", "(", "$", "affectedGroups", ")", ")", "{", "$", "this", "->", "updateUserCount", "(", "$", "affectedGroups", ")", ";", "}", "return", "$", "affectedUsers", ";", "}" ]
Assign users to new groups. @param array $userIdGroupIdMapping A mapping of user ids to their new group ids. @return int number of affected user rows
[ "Assign", "users", "to", "new", "groups", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/GroupsTable.php#L88-L106
238,623
borobudur-php/borobudur-broadcasting
src/Broadcaster/BroadcasterManager.php
BroadcasterManager.addBroadcaster
public static function addBroadcaster(BroadcasterInterface $broadcaster) { self::instantiateDefaultBroadcasters(); self::$broadcasters[$broadcaster->getName()] = $broadcaster; }
php
public static function addBroadcaster(BroadcasterInterface $broadcaster) { self::instantiateDefaultBroadcasters(); self::$broadcasters[$broadcaster->getName()] = $broadcaster; }
[ "public", "static", "function", "addBroadcaster", "(", "BroadcasterInterface", "$", "broadcaster", ")", "{", "self", "::", "instantiateDefaultBroadcasters", "(", ")", ";", "self", "::", "$", "broadcasters", "[", "$", "broadcaster", "->", "getName", "(", ")", "]", "=", "$", "broadcaster", ";", "}" ]
Add a broadcaster. @param BroadcasterInterface $broadcaster
[ "Add", "a", "broadcaster", "." ]
d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a
https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L46-L50
238,624
borobudur-php/borobudur-broadcasting
src/Broadcaster/BroadcasterManager.php
BroadcasterManager.get
public static function get($name) { $name = strtolower($name); if (!isset(self::$instantiated[$name])) { throw new InvalidArgumentException(sprintf('Broadcaster "%s" is not instantiated.', $name)); } return self::$instantiated[$name]; }
php
public static function get($name) { $name = strtolower($name); if (!isset(self::$instantiated[$name])) { throw new InvalidArgumentException(sprintf('Broadcaster "%s" is not instantiated.', $name)); } return self::$instantiated[$name]; }
[ "public", "static", "function", "get", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "instantiated", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Broadcaster \"%s\" is not instantiated.'", ",", "$", "name", ")", ")", ";", "}", "return", "self", "::", "$", "instantiated", "[", "$", "name", "]", ";", "}" ]
Get instantiated broadcaster. @param string $name @return BroadcasterInterface
[ "Get", "instantiated", "broadcaster", "." ]
d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a
https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L59-L68
238,625
borobudur-php/borobudur-broadcasting
src/Broadcaster/BroadcasterManager.php
BroadcasterManager.build
public static function build($name, array $configs = array()) { if (isset(self::$instantiated[$name])) { return self::$instantiated[$name]; } self::instantiateDefaultBroadcasters(); if (!isset(self::$broadcasters[$name])) { throw new InvalidArgumentException(sprintf('Undefined broadcaster with name "%s".', $name)); } self::$instantiated[$name] = self::instantiate(self::$broadcasters[$name], $configs); return self::$instantiated[$name]; }
php
public static function build($name, array $configs = array()) { if (isset(self::$instantiated[$name])) { return self::$instantiated[$name]; } self::instantiateDefaultBroadcasters(); if (!isset(self::$broadcasters[$name])) { throw new InvalidArgumentException(sprintf('Undefined broadcaster with name "%s".', $name)); } self::$instantiated[$name] = self::instantiate(self::$broadcasters[$name], $configs); return self::$instantiated[$name]; }
[ "public", "static", "function", "build", "(", "$", "name", ",", "array", "$", "configs", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "instantiated", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "instantiated", "[", "$", "name", "]", ";", "}", "self", "::", "instantiateDefaultBroadcasters", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "broadcasters", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Undefined broadcaster with name \"%s\".'", ",", "$", "name", ")", ")", ";", "}", "self", "::", "$", "instantiated", "[", "$", "name", "]", "=", "self", "::", "instantiate", "(", "self", "::", "$", "broadcasters", "[", "$", "name", "]", ",", "$", "configs", ")", ";", "return", "self", "::", "$", "instantiated", "[", "$", "name", "]", ";", "}" ]
Build a broadcaster. @param string $name @param array $configs @return BroadcasterInterface
[ "Build", "a", "broadcaster", "." ]
d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a
https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L78-L92
238,626
borobudur-php/borobudur-broadcasting
src/Broadcaster/BroadcasterManager.php
BroadcasterManager.instantiate
private static function instantiate($class, array $configs) { $reflection = new ReflectionClass($class); $constructor = $reflection->getConstructor(); $arguments = array(); foreach ($constructor->getParameters() as $param) { $name = $param->getName(); if (isset($configs[$name])) { $arguments[] = $configs[$name]; continue; } $arguments[] = null; } $broadcaster = $reflection->newInstanceArgs($arguments); if (!$broadcaster instanceof BroadcasterInterface) { throw new RuntimeException(sprintf( 'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface', $class )); } return $broadcaster; }
php
private static function instantiate($class, array $configs) { $reflection = new ReflectionClass($class); $constructor = $reflection->getConstructor(); $arguments = array(); foreach ($constructor->getParameters() as $param) { $name = $param->getName(); if (isset($configs[$name])) { $arguments[] = $configs[$name]; continue; } $arguments[] = null; } $broadcaster = $reflection->newInstanceArgs($arguments); if (!$broadcaster instanceof BroadcasterInterface) { throw new RuntimeException(sprintf( 'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface', $class )); } return $broadcaster; }
[ "private", "static", "function", "instantiate", "(", "$", "class", ",", "array", "$", "configs", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "class", ")", ";", "$", "constructor", "=", "$", "reflection", "->", "getConstructor", "(", ")", ";", "$", "arguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "constructor", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "name", "=", "$", "param", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "configs", "[", "$", "name", "]", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "configs", "[", "$", "name", "]", ";", "continue", ";", "}", "$", "arguments", "[", "]", "=", "null", ";", "}", "$", "broadcaster", "=", "$", "reflection", "->", "newInstanceArgs", "(", "$", "arguments", ")", ";", "if", "(", "!", "$", "broadcaster", "instanceof", "BroadcasterInterface", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Broadcaster \"%s\" should implement Borobudur\\Broadcasting\\Broadcaster\\BroadcasterInterface'", ",", "$", "class", ")", ")", ";", "}", "return", "$", "broadcaster", ";", "}" ]
Instantiate broadcaster. @param string $class @param array $configs @return BroadcasterInterface
[ "Instantiate", "broadcaster", "." ]
d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a
https://github.com/borobudur-php/borobudur-broadcasting/blob/d2f58ab5a4eb96252f55b4093a9ae027cc35fb0a/src/Broadcaster/BroadcasterManager.php#L102-L128
238,627
eix/core
src/php/main/Eix/Core/Responses/Data.php
Data.addData
public function addData($key, $value) { if (isset($this->data[$key])) { $this->data[$key] = array_merge_recursive( $this->data[$key], $value ); } else { $this->setData($key, $value); } }
php
public function addData($key, $value) { if (isset($this->data[$key])) { $this->data[$key] = array_merge_recursive( $this->data[$key], $value ); } else { $this->setData($key, $value); } }
[ "public", "function", "addData", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "array_merge_recursive", "(", "$", "this", "->", "data", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "setData", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Stores the response data in a key-value fashion, adding the data to the existing set. @param string $key the key under which the data is stored. @param mixed $value the data.
[ "Stores", "the", "response", "data", "in", "a", "key", "-", "value", "fashion", "adding", "the", "data", "to", "the", "existing", "set", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Data.php#L33-L43
238,628
PowerOnSystem/HelperService
src/HtmlHelper.php
HtmlHelper.link
public function link($content, $url = [], array $options = []) { /* @var $url_helper UrlHelper */ $url_helper = $this->url; $cfg = [ 'href' => is_array($url) ? ( key_exists('push', $url) ? $url_helper->push($url['push']) : ( key_exists('add', $url) || key_exists('remove', $url) ? $url_helper->modify( key_exists('add', $url) ? $url['add'] : [], key_exists('remove', $url) ? $url['remove'] : [] ) : ( key_exists('generate', $url) ? $url_helper->build($url, Arr::trim($url, 'generate')) : (key_exists('mailto', $url) ? 'mailto:' . $url['mailto'] : $url_helper->build($url)) ) )) : ( $url_helper->routeExist($url) ? $url_helper->build([], $url) : $url ) ] + $options; return '<a ' . Str::htmlserialize($cfg) . ' >' . $content . '</a>'; }
php
public function link($content, $url = [], array $options = []) { /* @var $url_helper UrlHelper */ $url_helper = $this->url; $cfg = [ 'href' => is_array($url) ? ( key_exists('push', $url) ? $url_helper->push($url['push']) : ( key_exists('add', $url) || key_exists('remove', $url) ? $url_helper->modify( key_exists('add', $url) ? $url['add'] : [], key_exists('remove', $url) ? $url['remove'] : [] ) : ( key_exists('generate', $url) ? $url_helper->build($url, Arr::trim($url, 'generate')) : (key_exists('mailto', $url) ? 'mailto:' . $url['mailto'] : $url_helper->build($url)) ) )) : ( $url_helper->routeExist($url) ? $url_helper->build([], $url) : $url ) ] + $options; return '<a ' . Str::htmlserialize($cfg) . ' >' . $content . '</a>'; }
[ "public", "function", "link", "(", "$", "content", ",", "$", "url", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "/* @var $url_helper UrlHelper */", "$", "url_helper", "=", "$", "this", "->", "url", ";", "$", "cfg", "=", "[", "'href'", "=>", "is_array", "(", "$", "url", ")", "?", "(", "key_exists", "(", "'push'", ",", "$", "url", ")", "?", "$", "url_helper", "->", "push", "(", "$", "url", "[", "'push'", "]", ")", ":", "(", "key_exists", "(", "'add'", ",", "$", "url", ")", "||", "key_exists", "(", "'remove'", ",", "$", "url", ")", "?", "$", "url_helper", "->", "modify", "(", "key_exists", "(", "'add'", ",", "$", "url", ")", "?", "$", "url", "[", "'add'", "]", ":", "[", "]", ",", "key_exists", "(", "'remove'", ",", "$", "url", ")", "?", "$", "url", "[", "'remove'", "]", ":", "[", "]", ")", ":", "(", "key_exists", "(", "'generate'", ",", "$", "url", ")", "?", "$", "url_helper", "->", "build", "(", "$", "url", ",", "Arr", "::", "trim", "(", "$", "url", ",", "'generate'", ")", ")", ":", "(", "key_exists", "(", "'mailto'", ",", "$", "url", ")", "?", "'mailto:'", ".", "$", "url", "[", "'mailto'", "]", ":", "$", "url_helper", "->", "build", "(", "$", "url", ")", ")", ")", ")", ")", ":", "(", "$", "url_helper", "->", "routeExist", "(", "$", "url", ")", "?", "$", "url_helper", "->", "build", "(", "[", "]", ",", "$", "url", ")", ":", "$", "url", ")", "]", "+", "$", "options", ";", "return", "'<a '", ".", "Str", "::", "htmlserialize", "(", "$", "cfg", ")", ".", "' >'", ".", "$", "content", ".", "'</a>'", ";", "}" ]
Crea un enlace @param string $content el contenido del enlace @param array $url la URL @param array $options [Opcional] las opciones @return string una etiqueta a
[ "Crea", "un", "enlace" ]
6d300764d7b3a090dd674b25415ce5088156ce8b
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L59-L77
238,629
PowerOnSystem/HelperService
src/HtmlHelper.php
HtmlHelper.js
public function js($name = NULL, $external = FALSE, array $options = []) { if ($name) { $this->_js[$name] = $options + [ 'src' => $external ? $name : PO_PATH_JS . '/' . $name ]; } else { return implode(PHP_EOL, array_map(function($value) { return '<script ' . Str::htmlserialize($value) . '></script>'; }, $this->_js)) . PHP_EOL; } }
php
public function js($name = NULL, $external = FALSE, array $options = []) { if ($name) { $this->_js[$name] = $options + [ 'src' => $external ? $name : PO_PATH_JS . '/' . $name ]; } else { return implode(PHP_EOL, array_map(function($value) { return '<script ' . Str::htmlserialize($value) . '></script>'; }, $this->_js)) . PHP_EOL; } }
[ "public", "function", "js", "(", "$", "name", "=", "NULL", ",", "$", "external", "=", "FALSE", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "name", ")", "{", "$", "this", "->", "_js", "[", "$", "name", "]", "=", "$", "options", "+", "[", "'src'", "=>", "$", "external", "?", "$", "name", ":", "PO_PATH_JS", ".", "'/'", ".", "$", "name", "]", ";", "}", "else", "{", "return", "implode", "(", "PHP_EOL", ",", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "'<script '", ".", "Str", "::", "htmlserialize", "(", "$", "value", ")", ".", "'></script>'", ";", "}", ",", "$", "this", "->", "_js", ")", ")", ".", "PHP_EOL", ";", "}", "}" ]
Agrega un archivo javascript o enlista los agregados @param string $name [Opcional] el nombre del archivo si no se especifica name devuelve todos los archivos js incluidos @param boolean $external [Opcional] Especifica si se trata de un archivo JS externo. @return string una etiqueta script
[ "Agrega", "un", "archivo", "javascript", "o", "enlista", "los", "agregados" ]
6d300764d7b3a090dd674b25415ce5088156ce8b
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L112-L122
238,630
PowerOnSystem/HelperService
src/HtmlHelper.php
HtmlHelper.meta
public function meta($name = NULL, $content = NULL) { if ( $name ) { $this->_meta[$name] = ['name' => $name, 'content' => $content]; } else { return implode(PHP_EOL, array_map(function($meta) { return '<meta name="' . $meta['name'] . '" content="' . $meta['content'] . '" />'; }, $this->_meta)) . PHP_EOL; } }
php
public function meta($name = NULL, $content = NULL) { if ( $name ) { $this->_meta[$name] = ['name' => $name, 'content' => $content]; } else { return implode(PHP_EOL, array_map(function($meta) { return '<meta name="' . $meta['name'] . '" content="' . $meta['content'] . '" />'; }, $this->_meta)) . PHP_EOL; } }
[ "public", "function", "meta", "(", "$", "name", "=", "NULL", ",", "$", "content", "=", "NULL", ")", "{", "if", "(", "$", "name", ")", "{", "$", "this", "->", "_meta", "[", "$", "name", "]", "=", "[", "'name'", "=>", "$", "name", ",", "'content'", "=>", "$", "content", "]", ";", "}", "else", "{", "return", "implode", "(", "PHP_EOL", ",", "array_map", "(", "function", "(", "$", "meta", ")", "{", "return", "'<meta name=\"'", ".", "$", "meta", "[", "'name'", "]", ".", "'\" content=\"'", ".", "$", "meta", "[", "'content'", "]", ".", "'\" />'", ";", "}", ",", "$", "this", "->", "_meta", ")", ")", ".", "PHP_EOL", ";", "}", "}" ]
Agrega una etiqueta META @param string $name Nombre/Tipo de etiqueta meta @param string $content Contenido @return string La etiqueta formateada
[ "Agrega", "una", "etiqueta", "META" ]
6d300764d7b3a090dd674b25415ce5088156ce8b
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L166-L174
238,631
PowerOnSystem/HelperService
src/HtmlHelper.php
HtmlHelper.img
public function img($name, array $options = [], $external = FALSE) { $cfg = $options + [ 'class' => '' ]; return '<img src = "' . ($external ? $name : PO_PATH_IMG . '/' . $name) . '" ' . Str::htmlserialize($cfg) . ' />'; }
php
public function img($name, array $options = [], $external = FALSE) { $cfg = $options + [ 'class' => '' ]; return '<img src = "' . ($external ? $name : PO_PATH_IMG . '/' . $name) . '" ' . Str::htmlserialize($cfg) . ' />'; }
[ "public", "function", "img", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "$", "external", "=", "FALSE", ")", "{", "$", "cfg", "=", "$", "options", "+", "[", "'class'", "=>", "''", "]", ";", "return", "'<img src = \"'", ".", "(", "$", "external", "?", "$", "name", ":", "PO_PATH_IMG", ".", "'/'", ".", "$", "name", ")", ".", "'\" '", ".", "Str", "::", "htmlserialize", "(", "$", "cfg", ")", ".", "' />'", ";", "}" ]
Crea una imagen @param string $name el nombre del archivo @param array $options [Opcional] las opciones @param boolean $external [Opcional] Especifica si se trata de una imagen externa @return string una etiqueta img
[ "Crea", "una", "imagen" ]
6d300764d7b3a090dd674b25415ce5088156ce8b
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L183-L189
238,632
PowerOnSystem/HelperService
src/HtmlHelper.php
HtmlHelper.nestedList
public function nestedList(array $list, array $options = [], array $item_options = [], $type_list = 'list') { $type = $type_list == 'list' ? 'ul' : 'ol'; $r = '<' . $type . ' ' . Str::htmlserialize($options) . '>'; foreach ($list as $key => $l) { $r .= is_array($l) ? $this->nestedList($l, key_exists($key, $item_options) ? $item_options[$key] : []) : '<li ' . (key_exists($key, $item_options) ? Str::htmlserialize($item_options[$key]) : '') . ' >' . $l . '</li>'; } $r .= '</' . $type . '>'; return $r; }
php
public function nestedList(array $list, array $options = [], array $item_options = [], $type_list = 'list') { $type = $type_list == 'list' ? 'ul' : 'ol'; $r = '<' . $type . ' ' . Str::htmlserialize($options) . '>'; foreach ($list as $key => $l) { $r .= is_array($l) ? $this->nestedList($l, key_exists($key, $item_options) ? $item_options[$key] : []) : '<li ' . (key_exists($key, $item_options) ? Str::htmlserialize($item_options[$key]) : '') . ' >' . $l . '</li>'; } $r .= '</' . $type . '>'; return $r; }
[ "public", "function", "nestedList", "(", "array", "$", "list", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "item_options", "=", "[", "]", ",", "$", "type_list", "=", "'list'", ")", "{", "$", "type", "=", "$", "type_list", "==", "'list'", "?", "'ul'", ":", "'ol'", ";", "$", "r", "=", "'<'", ".", "$", "type", ".", "' '", ".", "Str", "::", "htmlserialize", "(", "$", "options", ")", ".", "'>'", ";", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "l", ")", "{", "$", "r", ".=", "is_array", "(", "$", "l", ")", "?", "$", "this", "->", "nestedList", "(", "$", "l", ",", "key_exists", "(", "$", "key", ",", "$", "item_options", ")", "?", "$", "item_options", "[", "$", "key", "]", ":", "[", "]", ")", ":", "'<li '", ".", "(", "key_exists", "(", "$", "key", ",", "$", "item_options", ")", "?", "Str", "::", "htmlserialize", "(", "$", "item_options", "[", "$", "key", "]", ")", ":", "''", ")", ".", "' >'", ".", "$", "l", ".", "'</li>'", ";", "}", "$", "r", ".=", "'</'", ".", "$", "type", ".", "'>'", ";", "return", "$", "r", ";", "}" ]
Crea una lista simple u ordenada @param array $list Array con la lista completa, puede ser un array multidimencional @param array $options [Opcional] Opciones de la lista Ej: <code>$options = ['class' => 'my_list', 'id' => 'mylist1']</code> @param array $item_options [Opcional] Opciones de un item específico Ej: <code> $item_options = [1 => ['class' => 'active']] </code> @param type $type_list [Opcional] Tipo de lista, "ordered" para una lista ordenada o list @return string
[ "Crea", "una", "lista", "simple", "u", "ordenada" ]
6d300764d7b3a090dd674b25415ce5088156ce8b
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/HtmlHelper.php#L199-L211
238,633
Aureja/JobQueue
src/JobFactoryRegistry.php
JobFactoryRegistry.get
public function get($name) { if (isset($this->factories[$name])) { return $this->factories[$name]; } throw JobFactoryException::create(sprintf('Not found %s job factory', $name)); }
php
public function get($name) { if (isset($this->factories[$name])) { return $this->factories[$name]; } throw JobFactoryException::create(sprintf('Not found %s job factory', $name)); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "factories", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "factories", "[", "$", "name", "]", ";", "}", "throw", "JobFactoryException", "::", "create", "(", "sprintf", "(", "'Not found %s job factory'", ",", "$", "name", ")", ")", ";", "}" ]
Get factory. @param string $name @return JobFactoryInterface @throws JobFactoryException
[ "Get", "factory", "." ]
0e488ca123d3105cf791173e3147ede1bcf39018
https://github.com/Aureja/JobQueue/blob/0e488ca123d3105cf791173e3147ede1bcf39018/src/JobFactoryRegistry.php#L56-L63
238,634
easy-system/es-error
src/ErrorListenerFactory.php
ErrorListenerFactory.make
public static function make() { $services = Provider::getServices(); $config = $services->get('Config'); $strategies = []; if (isset($config['error']['strategies'])) { $strategies = (array) $config['error']['strategies']; } $listener = new ErrorListener; foreach ($strategies as $name) { $strategy = $services->get($name); $listener->attachErrorStrategy($strategy); } return $listener; }
php
public static function make() { $services = Provider::getServices(); $config = $services->get('Config'); $strategies = []; if (isset($config['error']['strategies'])) { $strategies = (array) $config['error']['strategies']; } $listener = new ErrorListener; foreach ($strategies as $name) { $strategy = $services->get($name); $listener->attachErrorStrategy($strategy); } return $listener; }
[ "public", "static", "function", "make", "(", ")", "{", "$", "services", "=", "Provider", "::", "getServices", "(", ")", ";", "$", "config", "=", "$", "services", "->", "get", "(", "'Config'", ")", ";", "$", "strategies", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'error'", "]", "[", "'strategies'", "]", ")", ")", "{", "$", "strategies", "=", "(", "array", ")", "$", "config", "[", "'error'", "]", "[", "'strategies'", "]", ";", "}", "$", "listener", "=", "new", "ErrorListener", ";", "foreach", "(", "$", "strategies", "as", "$", "name", ")", "{", "$", "strategy", "=", "$", "services", "->", "get", "(", "$", "name", ")", ";", "$", "listener", "->", "attachErrorStrategy", "(", "$", "strategy", ")", ";", "}", "return", "$", "listener", ";", "}" ]
Makes the error listener. @return \Es\Error\ErrorListener The error listener
[ "Makes", "the", "error", "listener", "." ]
5248c52f2992acc9ddf3542092ad7bbbb440e621
https://github.com/easy-system/es-error/blob/5248c52f2992acc9ddf3542092ad7bbbb440e621/src/ErrorListenerFactory.php#L24-L39
238,635
yii2module/yii2-encrypt
src/console/controllers/CoderController.php
CoderController.actionEncode
public function actionEncode() { $text = Enter::display('Enter text'); $encrypted = \App::$domain->encrypt->coder->encode($text); Output::block($encrypted, 'Encrypted'); }
php
public function actionEncode() { $text = Enter::display('Enter text'); $encrypted = \App::$domain->encrypt->coder->encode($text); Output::block($encrypted, 'Encrypted'); }
[ "public", "function", "actionEncode", "(", ")", "{", "$", "text", "=", "Enter", "::", "display", "(", "'Enter text'", ")", ";", "$", "encrypted", "=", "\\", "App", "::", "$", "domain", "->", "encrypt", "->", "coder", "->", "encode", "(", "$", "text", ")", ";", "Output", "::", "block", "(", "$", "encrypted", ",", "'Encrypted'", ")", ";", "}" ]
encryption of data
[ "encryption", "of", "data" ]
47ec61161ab24ddf84bb456f27c9ee9704285801
https://github.com/yii2module/yii2-encrypt/blob/47ec61161ab24ddf84bb456f27c9ee9704285801/src/console/controllers/CoderController.php#L19-L24
238,636
yii2module/yii2-encrypt
src/console/controllers/CoderController.php
CoderController.actionDecode
public function actionDecode() { $encrypted = Enter::display('Enter encrypted'); $text = \App::$domain->encrypt->coder->decode($encrypted); Output::block($text, 'Text'); }
php
public function actionDecode() { $encrypted = Enter::display('Enter encrypted'); $text = \App::$domain->encrypt->coder->decode($encrypted); Output::block($text, 'Text'); }
[ "public", "function", "actionDecode", "(", ")", "{", "$", "encrypted", "=", "Enter", "::", "display", "(", "'Enter encrypted'", ")", ";", "$", "text", "=", "\\", "App", "::", "$", "domain", "->", "encrypt", "->", "coder", "->", "decode", "(", "$", "encrypted", ")", ";", "Output", "::", "block", "(", "$", "text", ",", "'Text'", ")", ";", "}" ]
decryption of data
[ "decryption", "of", "data" ]
47ec61161ab24ddf84bb456f27c9ee9704285801
https://github.com/yii2module/yii2-encrypt/blob/47ec61161ab24ddf84bb456f27c9ee9704285801/src/console/controllers/CoderController.php#L29-L34
238,637
hmlb/date
src/Translation/DateLocalizationCapabilities.php
DateLocalizationCapabilities.translator
protected static function translator() { if (static::$translator === null) { $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); static::$translator = $translator; static::setLocale('en'); } return static::$translator; }
php
protected static function translator() { if (static::$translator === null) { $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); static::$translator = $translator; static::setLocale('en'); } return static::$translator; }
[ "protected", "static", "function", "translator", "(", ")", "{", "if", "(", "static", "::", "$", "translator", "===", "null", ")", "{", "$", "translator", "=", "new", "Translator", "(", "'en'", ")", ";", "$", "translator", "->", "addLoader", "(", "'array'", ",", "new", "ArrayLoader", "(", ")", ")", ";", "static", "::", "$", "translator", "=", "$", "translator", ";", "static", "::", "setLocale", "(", "'en'", ")", ";", "}", "return", "static", "::", "$", "translator", ";", "}" ]
Intialize the translator instance if necessary. @return TranslatorInterface
[ "Intialize", "the", "translator", "instance", "if", "necessary", "." ]
54ddca80fa4ef7d4a617812e10c291f142a164c0
https://github.com/hmlb/date/blob/54ddca80fa4ef7d4a617812e10c291f142a164c0/src/Translation/DateLocalizationCapabilities.php#L32-L42
238,638
osflab/view
Helper/Bootstrap/Accordion.php
Accordion.render
protected function render() { if (!isset($this->items[0])) { return ''; } foreach ($this->items as $itemId => $item) { $item->setCollapsable( self::$id, self::$id . $itemId, in_array($itemId, $this->openedItems)); } $this->setAttribute('id', self::$id); $this->addCssClass($this->itemType . '-group'); return $this ->html('<div' . $this->getEltDecorationStr() . '>') ->html(implode("\n", $this->items)) ->html('</div>') ->getHtml(); }
php
protected function render() { if (!isset($this->items[0])) { return ''; } foreach ($this->items as $itemId => $item) { $item->setCollapsable( self::$id, self::$id . $itemId, in_array($itemId, $this->openedItems)); } $this->setAttribute('id', self::$id); $this->addCssClass($this->itemType . '-group'); return $this ->html('<div' . $this->getEltDecorationStr() . '>') ->html(implode("\n", $this->items)) ->html('</div>') ->getHtml(); }
[ "protected", "function", "render", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "0", "]", ")", ")", "{", "return", "''", ";", "}", "foreach", "(", "$", "this", "->", "items", "as", "$", "itemId", "=>", "$", "item", ")", "{", "$", "item", "->", "setCollapsable", "(", "self", "::", "$", "id", ",", "self", "::", "$", "id", ".", "$", "itemId", ",", "in_array", "(", "$", "itemId", ",", "$", "this", "->", "openedItems", ")", ")", ";", "}", "$", "this", "->", "setAttribute", "(", "'id'", ",", "self", "::", "$", "id", ")", ";", "$", "this", "->", "addCssClass", "(", "$", "this", "->", "itemType", ".", "'-group'", ")", ";", "return", "$", "this", "->", "html", "(", "'<div'", ".", "$", "this", "->", "getEltDecorationStr", "(", ")", ".", "'>'", ")", "->", "html", "(", "implode", "(", "\"\\n\"", ",", "$", "this", "->", "items", ")", ")", "->", "html", "(", "'</div>'", ")", "->", "getHtml", "(", ")", ";", "}" ]
Display the box at the end of configuration @return string
[ "Display", "the", "box", "at", "the", "end", "of", "configuration" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Accordion.php#L60-L78
238,639
marando/phpSOFA
src/Marando/IAU/iauRy.php
iauRy.Ry
public static function Ry($theta, array &$r) { $s; $c; $a00; $a01; $a02; $a20; $a21; $a22; $s = sin($theta); $c = cos($theta); $a00 = $c * $r[0][0] - $s * $r[2][0]; $a01 = $c * $r[0][1] - $s * $r[2][1]; $a02 = $c * $r[0][2] - $s * $r[2][2]; $a20 = $s * $r[0][0] + $c * $r[2][0]; $a21 = $s * $r[0][1] + $c * $r[2][1]; $a22 = $s * $r[0][2] + $c * $r[2][2]; $r[0][0] = $a00; $r[0][1] = $a01; $r[0][2] = $a02; $r[2][0] = $a20; $r[2][1] = $a21; $r[2][2] = $a22; return; }
php
public static function Ry($theta, array &$r) { $s; $c; $a00; $a01; $a02; $a20; $a21; $a22; $s = sin($theta); $c = cos($theta); $a00 = $c * $r[0][0] - $s * $r[2][0]; $a01 = $c * $r[0][1] - $s * $r[2][1]; $a02 = $c * $r[0][2] - $s * $r[2][2]; $a20 = $s * $r[0][0] + $c * $r[2][0]; $a21 = $s * $r[0][1] + $c * $r[2][1]; $a22 = $s * $r[0][2] + $c * $r[2][2]; $r[0][0] = $a00; $r[0][1] = $a01; $r[0][2] = $a02; $r[2][0] = $a20; $r[2][1] = $a21; $r[2][2] = $a22; return; }
[ "public", "static", "function", "Ry", "(", "$", "theta", ",", "array", "&", "$", "r", ")", "{", "$", "s", ";", "$", "c", ";", "$", "a00", ";", "$", "a01", ";", "$", "a02", ";", "$", "a20", ";", "$", "a21", ";", "$", "a22", ";", "$", "s", "=", "sin", "(", "$", "theta", ")", ";", "$", "c", "=", "cos", "(", "$", "theta", ")", ";", "$", "a00", "=", "$", "c", "*", "$", "r", "[", "0", "]", "[", "0", "]", "-", "$", "s", "*", "$", "r", "[", "2", "]", "[", "0", "]", ";", "$", "a01", "=", "$", "c", "*", "$", "r", "[", "0", "]", "[", "1", "]", "-", "$", "s", "*", "$", "r", "[", "2", "]", "[", "1", "]", ";", "$", "a02", "=", "$", "c", "*", "$", "r", "[", "0", "]", "[", "2", "]", "-", "$", "s", "*", "$", "r", "[", "2", "]", "[", "2", "]", ";", "$", "a20", "=", "$", "s", "*", "$", "r", "[", "0", "]", "[", "0", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "0", "]", ";", "$", "a21", "=", "$", "s", "*", "$", "r", "[", "0", "]", "[", "1", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "1", "]", ";", "$", "a22", "=", "$", "s", "*", "$", "r", "[", "0", "]", "[", "2", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "2", "]", ";", "$", "r", "[", "0", "]", "[", "0", "]", "=", "$", "a00", ";", "$", "r", "[", "0", "]", "[", "1", "]", "=", "$", "a01", ";", "$", "r", "[", "0", "]", "[", "2", "]", "=", "$", "a02", ";", "$", "r", "[", "2", "]", "[", "0", "]", "=", "$", "a20", ";", "$", "r", "[", "2", "]", "[", "1", "]", "=", "$", "a21", ";", "$", "r", "[", "2", "]", "[", "2", "]", "=", "$", "a22", ";", "return", ";", "}" ]
- - - - - - i a u R y - - - - - - Rotate an r-matrix about the y-axis. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: theta double angle (radians) Given and returned: r double[3][3] r-matrix, rotated Notes: 1) Calling this function with positive theta incorporates in the supplied r-matrix r an additional rotation, about the y-axis, anticlockwise as seen looking towards the origin from positive y. 2) The additional rotation can be represented by this matrix: ( + cos(theta) 0 - sin(theta) ) ( ) ( 0 1 0 ) ( ) ( + sin(theta) 0 + cos(theta) ) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "i", "a", "u", "R", "y", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRy.php#L45-L73
238,640
tekkla/core-html
Core/Html/Bootstrap/Navbar/AbstractNavbarElement.php
AbstractNavbarElement.isActive
final public function isActive($active = null) { if (isset($active)) { $this->active = (bool) $active; return $this; } else { return $this->active; } }
php
final public function isActive($active = null) { if (isset($active)) { $this->active = (bool) $active; return $this; } else { return $this->active; } }
[ "final", "public", "function", "isActive", "(", "$", "active", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "active", ")", ")", "{", "$", "this", "->", "active", "=", "(", "bool", ")", "$", "active", ";", "return", "$", "this", ";", "}", "else", "{", "return", "$", "this", "->", "active", ";", "}", "}" ]
Sets or gets active state of element @param bool $active @return \Core\Html\Bootstrap\Navbar\NavbarElementAbstract|boolean
[ "Sets", "or", "gets", "active", "state", "of", "element" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Navbar/AbstractNavbarElement.php#L41-L50
238,641
n0m4dz/laracasa
Zend/Gdata/Calendar.php
Zend_Gdata_Calendar.getCalendarEventFeed
public function getCalendarEventFeed($location = null) { if ($location == null) { $uri = self::CALENDAR_EVENT_FEED_URI; } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed'); }
php
public function getCalendarEventFeed($location = null) { if ($location == null) { $uri = self::CALENDAR_EVENT_FEED_URI; } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed'); }
[ "public", "function", "getCalendarEventFeed", "(", "$", "location", "=", "null", ")", "{", "if", "(", "$", "location", "==", "null", ")", "{", "$", "uri", "=", "self", "::", "CALENDAR_EVENT_FEED_URI", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Calendar_EventFeed'", ")", ";", "}" ]
Retreive feed object @param mixed $location The location for the feed, as a URL or Query @return Zend_Gdata_Calendar_EventFeed
[ "Retreive", "feed", "object" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Calendar.php#L98-L108
238,642
brisum/php-lib-object-manager
src/ObjectManager.php
ObjectManager.get
public function get($class) { $class = ltrim($class, '\\'); if (!isset($this->sharedInstances[$class])) { $this->sharedInstances[$class] = $this->create($class); } return $this->sharedInstances[$class]; }
php
public function get($class) { $class = ltrim($class, '\\'); if (!isset($this->sharedInstances[$class])) { $this->sharedInstances[$class] = $this->create($class); } return $this->sharedInstances[$class]; }
[ "public", "function", "get", "(", "$", "class", ")", "{", "$", "class", "=", "ltrim", "(", "$", "class", ",", "'\\\\'", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "sharedInstances", "[", "$", "class", "]", ")", ")", "{", "$", "this", "->", "sharedInstances", "[", "$", "class", "]", "=", "$", "this", "->", "create", "(", "$", "class", ")", ";", "}", "return", "$", "this", "->", "sharedInstances", "[", "$", "class", "]", ";", "}" ]
Get object from shared instances by class name. @param string $class @return mixed
[ "Get", "object", "from", "shared", "instances", "by", "class", "name", "." ]
9d2326a4c4665ec9b8003ef1389f1f55cb4344ec
https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L89-L97
238,643
brisum/php-lib-object-manager
src/ObjectManager.php
ObjectManager.invoke
public function invoke($object, $method, array $arguments = []) { $reflection = new \ReflectionClass($object); $method = $reflection->getMethod($method); $args = $this->resolveArguments($method, $arguments); return $method->invokeArgs($object, $args); }
php
public function invoke($object, $method, array $arguments = []) { $reflection = new \ReflectionClass($object); $method = $reflection->getMethod($method); $args = $this->resolveArguments($method, $arguments); return $method->invokeArgs($object, $args); }
[ "public", "function", "invoke", "(", "$", "object", ",", "$", "method", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "method", "=", "$", "reflection", "->", "getMethod", "(", "$", "method", ")", ";", "$", "args", "=", "$", "this", "->", "resolveArguments", "(", "$", "method", ",", "$", "arguments", ")", ";", "return", "$", "method", "->", "invokeArgs", "(", "$", "object", ",", "$", "args", ")", ";", "}" ]
Invoke method of object. @param mixed $object @param string $method @param array $arguments @return mixed
[ "Invoke", "method", "of", "object", "." ]
9d2326a4c4665ec9b8003ef1389f1f55cb4344ec
https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L179-L186
238,644
brisum/php-lib-object-manager
src/ObjectManager.php
ObjectManager.resolveArguments
protected function resolveArguments( ReflectionMethod $method, array $arguments ) { $params = $method->getParameters(); $result = []; foreach ($params as $param) { /** @var ReflectionParameter $param */ if (isset($arguments[$param->name])) { $result[$param->name] = $arguments[$param->name]; continue; } $class = $param->getClass(); if ($class) { $className = $class->getName(); if ($this->isShared($className)) { $result[$className] = isset($this->sharedInstances[$className]) ? $this->sharedInstances[$className] : $this->get($className); } else { $result[$className] = $this->create($className); } } } return $result; }
php
protected function resolveArguments( ReflectionMethod $method, array $arguments ) { $params = $method->getParameters(); $result = []; foreach ($params as $param) { /** @var ReflectionParameter $param */ if (isset($arguments[$param->name])) { $result[$param->name] = $arguments[$param->name]; continue; } $class = $param->getClass(); if ($class) { $className = $class->getName(); if ($this->isShared($className)) { $result[$className] = isset($this->sharedInstances[$className]) ? $this->sharedInstances[$className] : $this->get($className); } else { $result[$className] = $this->create($className); } } } return $result; }
[ "protected", "function", "resolveArguments", "(", "ReflectionMethod", "$", "method", ",", "array", "$", "arguments", ")", "{", "$", "params", "=", "$", "method", "->", "getParameters", "(", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "/** @var ReflectionParameter $param */", "if", "(", "isset", "(", "$", "arguments", "[", "$", "param", "->", "name", "]", ")", ")", "{", "$", "result", "[", "$", "param", "->", "name", "]", "=", "$", "arguments", "[", "$", "param", "->", "name", "]", ";", "continue", ";", "}", "$", "class", "=", "$", "param", "->", "getClass", "(", ")", ";", "if", "(", "$", "class", ")", "{", "$", "className", "=", "$", "class", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "isShared", "(", "$", "className", ")", ")", "{", "$", "result", "[", "$", "className", "]", "=", "isset", "(", "$", "this", "->", "sharedInstances", "[", "$", "className", "]", ")", "?", "$", "this", "->", "sharedInstances", "[", "$", "className", "]", ":", "$", "this", "->", "get", "(", "$", "className", ")", ";", "}", "else", "{", "$", "result", "[", "$", "className", "]", "=", "$", "this", "->", "create", "(", "$", "className", ")", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Resolve argument of method. @param ReflectionMethod $method @param array $arguments @return array
[ "Resolve", "argument", "of", "method", "." ]
9d2326a4c4665ec9b8003ef1389f1f55cb4344ec
https://github.com/brisum/php-lib-object-manager/blob/9d2326a4c4665ec9b8003ef1389f1f55cb4344ec/src/ObjectManager.php#L195-L223
238,645
tenside/core-bundle
src/Controller/VersionConstraintController.php
VersionConstraintController.checkVersionConstraintAction
public function checkVersionConstraintAction(Request $request) { try { $inputData = new JsonArray($request->getContent()); } catch (\Exception $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => 'invalid payload' ], JsonResponse::HTTP_BAD_REQUEST ); } $versionParser = new VersionParser(); if (!$inputData->has('constraint')) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => 'invalid payload' ], JsonResponse::HTTP_BAD_REQUEST ); } try { $versionParser->parseConstraints($inputData->get('constraint')); } catch (\Exception $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => $exception->getMessage() ], JsonResponse::HTTP_OK ); } return new JsonResponse( [ 'status' => 'OK', ], JsonResponse::HTTP_OK ); }
php
public function checkVersionConstraintAction(Request $request) { try { $inputData = new JsonArray($request->getContent()); } catch (\Exception $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => 'invalid payload' ], JsonResponse::HTTP_BAD_REQUEST ); } $versionParser = new VersionParser(); if (!$inputData->has('constraint')) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => 'invalid payload' ], JsonResponse::HTTP_BAD_REQUEST ); } try { $versionParser->parseConstraints($inputData->get('constraint')); } catch (\Exception $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'error' => $exception->getMessage() ], JsonResponse::HTTP_OK ); } return new JsonResponse( [ 'status' => 'OK', ], JsonResponse::HTTP_OK ); }
[ "public", "function", "checkVersionConstraintAction", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "inputData", "=", "new", "JsonArray", "(", "$", "request", "->", "getContent", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'error'", "=>", "'invalid payload'", "]", ",", "JsonResponse", "::", "HTTP_BAD_REQUEST", ")", ";", "}", "$", "versionParser", "=", "new", "VersionParser", "(", ")", ";", "if", "(", "!", "$", "inputData", "->", "has", "(", "'constraint'", ")", ")", "{", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'error'", "=>", "'invalid payload'", "]", ",", "JsonResponse", "::", "HTTP_BAD_REQUEST", ")", ";", "}", "try", "{", "$", "versionParser", "->", "parseConstraints", "(", "$", "inputData", "->", "get", "(", "'constraint'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'error'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ",", "JsonResponse", "::", "HTTP_OK", ")", ";", "}", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'OK'", ",", "]", ",", "JsonResponse", "::", "HTTP_OK", ")", ";", "}" ]
Try to validate the version constraint. @param Request $request The request. @return JsonResponse @throws \RuntimeException For invalid user classes. @ApiDoc( section="misc", statusCodes = { 200 = "When everything worked out ok", 400 = "When the request payload was invalid." }, authentication = true, authenticationRoles = { "ROLE_NONE" } ) @ApiDescription( request={ "constraint" = { "description" = "The constraint to test.", "dataType" = "string", "required" = true } }, response={ "status" = { "dataType" = "choice", "description" = "OK or ERROR", "format" = "['OK', 'ERROR']", }, "error" = { "dataType" = "string", "description" = "The error message (if any).", } } )
[ "Try", "to", "validate", "the", "version", "constraint", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/VersionConstraintController.php#L77-L121
238,646
indigophp-archive/fuel-core
classes/theme.php
Theme.set_config
public function set_config($key, $value = null) { if (is_array($key)) { $this->config = \Arr::merge($this->config, $key); } else { \Arr::set($this->config, $key, $value); } return $this; }
php
public function set_config($key, $value = null) { if (is_array($key)) { $this->config = \Arr::merge($this->config, $key); } else { \Arr::set($this->config, $key, $value); } return $this; }
[ "public", "function", "set_config", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "config", "=", "\\", "Arr", "::", "merge", "(", "$", "this", "->", "config", ",", "$", "key", ")", ";", "}", "else", "{", "\\", "Arr", "::", "set", "(", "$", "this", "->", "config", ",", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a config item @param mixed $key Config key or array to merge @param mixed $value Config value @return this
[ "Sets", "a", "config", "item" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L42-L54
238,647
indigophp-archive/fuel-core
classes/theme.php
Theme.get_parent_themes
public function get_parent_themes($theme_name) { $return = array($this->create_theme_array($theme_name)); $theme_info = $this->load_info($theme_name); if ( ! empty($theme_info['parent'])) { $return = array_merge($return, $this->get_parent_themes($theme_info['parent'])); } elseif($theme_name !== $this->fallback['name']) { $return[] = $this->fallback; } return $return; }
php
public function get_parent_themes($theme_name) { $return = array($this->create_theme_array($theme_name)); $theme_info = $this->load_info($theme_name); if ( ! empty($theme_info['parent'])) { $return = array_merge($return, $this->get_parent_themes($theme_info['parent'])); } elseif($theme_name !== $this->fallback['name']) { $return[] = $this->fallback; } return $return; }
[ "public", "function", "get_parent_themes", "(", "$", "theme_name", ")", "{", "$", "return", "=", "array", "(", "$", "this", "->", "create_theme_array", "(", "$", "theme_name", ")", ")", ";", "$", "theme_info", "=", "$", "this", "->", "load_info", "(", "$", "theme_name", ")", ";", "if", "(", "!", "empty", "(", "$", "theme_info", "[", "'parent'", "]", ")", ")", "{", "$", "return", "=", "array_merge", "(", "$", "return", ",", "$", "this", "->", "get_parent_themes", "(", "$", "theme_info", "[", "'parent'", "]", ")", ")", ";", "}", "elseif", "(", "$", "theme_name", "!==", "$", "this", "->", "fallback", "[", "'name'", "]", ")", "{", "$", "return", "[", "]", "=", "$", "this", "->", "fallback", ";", "}", "return", "$", "return", ";", "}" ]
Returns parent theme info @param string $theme_name @return array
[ "Returns", "parent", "theme", "info" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L129-L144
238,648
indigophp-archive/fuel-core
classes/theme.php
Theme.asset_url
public function asset_url($path) { $url = $this->asset_path($path); if (filter_var($url, FILTER_VALIDATE_URL) === false) { $url = \Uri::create($url); } return $url; }
php
public function asset_url($path) { $url = $this->asset_path($path); if (filter_var($url, FILTER_VALIDATE_URL) === false) { $url = \Uri::create($url); } return $url; }
[ "public", "function", "asset_url", "(", "$", "path", ")", "{", "$", "url", "=", "$", "this", "->", "asset_path", "(", "$", "path", ")", ";", "if", "(", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ")", "===", "false", ")", "{", "$", "url", "=", "\\", "Uri", "::", "create", "(", "$", "url", ")", ";", "}", "return", "$", "url", ";", "}" ]
Returns an absolute URL to asset @param string $path @return string
[ "Returns", "an", "absolute", "URL", "to", "asset" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/theme.php#L153-L163
238,649
wp-pluginner/framework
src/Container.php
Container.loadRoutes
public function loadRoutes() { if ($this->bound('router')) { /** * Use Cached Routes if Available */ if ($this['config']->get('routes.cache') && $this['files']->exists($this['config']->get('routes.compiled'))) { $contents = $this['files']->get($this['config']->get('routes.compiled')); if (!empty($contents)) { //Get Cached Routes & Set Them $this['router']->setRoutes(unserialize(base64_decode($contents))); } } else { //Assign Router to Simple Variable for Include $route = $this['router']; $response = $this['response']; //Include Routes if($this['files']->exists($this->base_path . '/app/Http/routes.php')){ require_once $this->base_path . '/app/Http/routes.php'; } } /** * Store Cached Routes */ if ($this['config']->get('routes.cache') && !$this['files']->exists($this['config']->get('routes.compiled'))) { try { //Set Routes Cache if (!$this['files']->exists($this['config']->get('routes.compiled'))) { $allRoutes = $this['router']->getRoutes(); //If Routes then Serialize if (count($allRoutes) > 0) { foreach ($allRoutes as $routeObject) { $routeObject->prepareForSerialization(); } } //Store Routes in Cache $this['files']->put($this['config']->get('routes.compiled'), base64_encode(serialize($allRoutes))); } } catch (\Exception $exception) { if (!empty($exception->getMessage())) { add_action('admin_notices', function () use ($exception) { ?> <div class="error notice"> <p>&#9888; <?php echo $exception->getMessage(); ?></p> <p><em><? echo 'Route caching cannot serialize closures'; ?>.</em></p> </div> <?php }); } } } } }
php
public function loadRoutes() { if ($this->bound('router')) { /** * Use Cached Routes if Available */ if ($this['config']->get('routes.cache') && $this['files']->exists($this['config']->get('routes.compiled'))) { $contents = $this['files']->get($this['config']->get('routes.compiled')); if (!empty($contents)) { //Get Cached Routes & Set Them $this['router']->setRoutes(unserialize(base64_decode($contents))); } } else { //Assign Router to Simple Variable for Include $route = $this['router']; $response = $this['response']; //Include Routes if($this['files']->exists($this->base_path . '/app/Http/routes.php')){ require_once $this->base_path . '/app/Http/routes.php'; } } /** * Store Cached Routes */ if ($this['config']->get('routes.cache') && !$this['files']->exists($this['config']->get('routes.compiled'))) { try { //Set Routes Cache if (!$this['files']->exists($this['config']->get('routes.compiled'))) { $allRoutes = $this['router']->getRoutes(); //If Routes then Serialize if (count($allRoutes) > 0) { foreach ($allRoutes as $routeObject) { $routeObject->prepareForSerialization(); } } //Store Routes in Cache $this['files']->put($this['config']->get('routes.compiled'), base64_encode(serialize($allRoutes))); } } catch (\Exception $exception) { if (!empty($exception->getMessage())) { add_action('admin_notices', function () use ($exception) { ?> <div class="error notice"> <p>&#9888; <?php echo $exception->getMessage(); ?></p> <p><em><? echo 'Route caching cannot serialize closures'; ?>.</em></p> </div> <?php }); } } } } }
[ "public", "function", "loadRoutes", "(", ")", "{", "if", "(", "$", "this", "->", "bound", "(", "'router'", ")", ")", "{", "/**\n\t\t\t * Use Cached Routes if Available\n\t\t\t */", "if", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.cache'", ")", "&&", "$", "this", "[", "'files'", "]", "->", "exists", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.compiled'", ")", ")", ")", "{", "$", "contents", "=", "$", "this", "[", "'files'", "]", "->", "get", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.compiled'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "contents", ")", ")", "{", "//Get Cached Routes & Set Them", "$", "this", "[", "'router'", "]", "->", "setRoutes", "(", "unserialize", "(", "base64_decode", "(", "$", "contents", ")", ")", ")", ";", "}", "}", "else", "{", "//Assign Router to Simple Variable for Include", "$", "route", "=", "$", "this", "[", "'router'", "]", ";", "$", "response", "=", "$", "this", "[", "'response'", "]", ";", "//Include Routes", "if", "(", "$", "this", "[", "'files'", "]", "->", "exists", "(", "$", "this", "->", "base_path", ".", "'/app/Http/routes.php'", ")", ")", "{", "require_once", "$", "this", "->", "base_path", ".", "'/app/Http/routes.php'", ";", "}", "}", "/**\n\t\t\t * Store Cached Routes\n\t\t\t */", "if", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.cache'", ")", "&&", "!", "$", "this", "[", "'files'", "]", "->", "exists", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.compiled'", ")", ")", ")", "{", "try", "{", "//Set Routes Cache", "if", "(", "!", "$", "this", "[", "'files'", "]", "->", "exists", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.compiled'", ")", ")", ")", "{", "$", "allRoutes", "=", "$", "this", "[", "'router'", "]", "->", "getRoutes", "(", ")", ";", "//If Routes then Serialize", "if", "(", "count", "(", "$", "allRoutes", ")", ">", "0", ")", "{", "foreach", "(", "$", "allRoutes", "as", "$", "routeObject", ")", "{", "$", "routeObject", "->", "prepareForSerialization", "(", ")", ";", "}", "}", "//Store Routes in Cache", "$", "this", "[", "'files'", "]", "->", "put", "(", "$", "this", "[", "'config'", "]", "->", "get", "(", "'routes.compiled'", ")", ",", "base64_encode", "(", "serialize", "(", "$", "allRoutes", ")", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "if", "(", "!", "empty", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ")", "{", "add_action", "(", "'admin_notices'", ",", "function", "(", ")", "use", "(", "$", "exception", ")", "{", "?>\n\t\t\t\t\t\t\t<div class=\"error notice\">\n\t\t\t\t\t\t\t\t<p>&#9888; <?php", "echo", "$", "exception", "->", "getMessage", "(", ")", ";", "?>", "<", "/", "p", ">", "<", "p", ">", "<", "em", ">", "<", "?", "echo", "'Route caching cannot serialize closures'", ";", "?>.</em></p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<?php", "}", ")", ";", "}", "}", "}", "}", "}" ]
Load Routes into Router
[ "Load", "Routes", "into", "Router" ]
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Container.php#L101-L155
238,650
wp-pluginner/framework
src/Container.php
Container.routeRequest
public function routeRequest() { if($this->bound('router')){ try { $pluginRequest = $this['request']; $this['router']->matched(function ($event) { global $wp_query; $wp_query->is_404 = false; $this->route_dispatched = true; }); $response = $this['router']->dispatch($pluginRequest); if ($route = $pluginRequest->route()) { foreach ($route->computedMiddleware as $middleware) { $instance = $this->make($middleware); if (method_exists($instance, 'terminate')) { $instance->terminate($pluginRequest, $response); } } } if($this->bound('session')) { $this['session']->save(); } $response->send(); exit; }catch (\Exception $e) { $this->reportException($e); $this->renderException($pluginRequest, $e); } catch (\Throwable $e) { $this->reportException($e = new FatalThrowableError($e)); $this->renderException($pluginRequest, $e); } } }
php
public function routeRequest() { if($this->bound('router')){ try { $pluginRequest = $this['request']; $this['router']->matched(function ($event) { global $wp_query; $wp_query->is_404 = false; $this->route_dispatched = true; }); $response = $this['router']->dispatch($pluginRequest); if ($route = $pluginRequest->route()) { foreach ($route->computedMiddleware as $middleware) { $instance = $this->make($middleware); if (method_exists($instance, 'terminate')) { $instance->terminate($pluginRequest, $response); } } } if($this->bound('session')) { $this['session']->save(); } $response->send(); exit; }catch (\Exception $e) { $this->reportException($e); $this->renderException($pluginRequest, $e); } catch (\Throwable $e) { $this->reportException($e = new FatalThrowableError($e)); $this->renderException($pluginRequest, $e); } } }
[ "public", "function", "routeRequest", "(", ")", "{", "if", "(", "$", "this", "->", "bound", "(", "'router'", ")", ")", "{", "try", "{", "$", "pluginRequest", "=", "$", "this", "[", "'request'", "]", ";", "$", "this", "[", "'router'", "]", "->", "matched", "(", "function", "(", "$", "event", ")", "{", "global", "$", "wp_query", ";", "$", "wp_query", "->", "is_404", "=", "false", ";", "$", "this", "->", "route_dispatched", "=", "true", ";", "}", ")", ";", "$", "response", "=", "$", "this", "[", "'router'", "]", "->", "dispatch", "(", "$", "pluginRequest", ")", ";", "if", "(", "$", "route", "=", "$", "pluginRequest", "->", "route", "(", ")", ")", "{", "foreach", "(", "$", "route", "->", "computedMiddleware", "as", "$", "middleware", ")", "{", "$", "instance", "=", "$", "this", "->", "make", "(", "$", "middleware", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "'terminate'", ")", ")", "{", "$", "instance", "->", "terminate", "(", "$", "pluginRequest", ",", "$", "response", ")", ";", "}", "}", "}", "if", "(", "$", "this", "->", "bound", "(", "'session'", ")", ")", "{", "$", "this", "[", "'session'", "]", "->", "save", "(", ")", ";", "}", "$", "response", "->", "send", "(", ")", ";", "exit", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "reportException", "(", "$", "e", ")", ";", "$", "this", "->", "renderException", "(", "$", "pluginRequest", ",", "$", "e", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "this", "->", "reportException", "(", "$", "e", "=", "new", "FatalThrowableError", "(", "$", "e", ")", ")", ";", "$", "this", "->", "renderException", "(", "$", "pluginRequest", ",", "$", "e", ")", ";", "}", "}", "}" ]
Try Routing Requests
[ "Try", "Routing", "Requests" ]
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Container.php#L159-L191
238,651
benkle-libs/feed-parser
src/Parser.php
Parser.parse
public function parse(\DOMDocument $dom) { $feed = $this->getStandard()->newFeed(); $rootNode = $this->getStandard()->getRootNode($dom); $this->parseNodeChildren($rootNode, $feed); return $feed; }
php
public function parse(\DOMDocument $dom) { $feed = $this->getStandard()->newFeed(); $rootNode = $this->getStandard()->getRootNode($dom); $this->parseNodeChildren($rootNode, $feed); return $feed; }
[ "public", "function", "parse", "(", "\\", "DOMDocument", "$", "dom", ")", "{", "$", "feed", "=", "$", "this", "->", "getStandard", "(", ")", "->", "newFeed", "(", ")", ";", "$", "rootNode", "=", "$", "this", "->", "getStandard", "(", ")", "->", "getRootNode", "(", "$", "dom", ")", ";", "$", "this", "->", "parseNodeChildren", "(", "$", "rootNode", ",", "$", "feed", ")", ";", "return", "$", "feed", ";", "}" ]
Turn a dom document into a feed object. @param \DOMDocument $dom @return FeedInterface @throws InvalidNumberOfRootTagsException
[ "Turn", "a", "dom", "document", "into", "a", "feed", "object", "." ]
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Parser.php#L63-L69
238,652
benkle-libs/feed-parser
src/Parser.php
Parser.parseNodeChildren
public function parseNodeChildren(\DOMNode $node, NodeInterface $target) { $rules = $this->getStandard()->getRules(); foreach ($node->childNodes as $childNode) { /** @var RuleInterface $rule */ foreach ($rules as $rule) { if ($rule->canHandle($childNode, $target)) { $rule->handle($this, $childNode, $target); break; } } } }
php
public function parseNodeChildren(\DOMNode $node, NodeInterface $target) { $rules = $this->getStandard()->getRules(); foreach ($node->childNodes as $childNode) { /** @var RuleInterface $rule */ foreach ($rules as $rule) { if ($rule->canHandle($childNode, $target)) { $rule->handle($this, $childNode, $target); break; } } } }
[ "public", "function", "parseNodeChildren", "(", "\\", "DOMNode", "$", "node", ",", "NodeInterface", "$", "target", ")", "{", "$", "rules", "=", "$", "this", "->", "getStandard", "(", ")", "->", "getRules", "(", ")", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "childNode", ")", "{", "/** @var RuleInterface $rule */", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "if", "(", "$", "rule", "->", "canHandle", "(", "$", "childNode", ",", "$", "target", ")", ")", "{", "$", "rule", "->", "handle", "(", "$", "this", ",", "$", "childNode", ",", "$", "target", ")", ";", "break", ";", "}", "}", "}", "}" ]
Parse the children of a given node. @param \DOMNode $node @param NodeInterface $target
[ "Parse", "the", "children", "of", "a", "given", "node", "." ]
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Parser.php#L76-L88
238,653
infusephp/rest-api
src/Libs/ApiRoute.php
ApiRoute.getQuery
public function getQuery($index = false) { return ($index) ? array_value($this->query, $index) : $this->query; }
php
public function getQuery($index = false) { return ($index) ? array_value($this->query, $index) : $this->query; }
[ "public", "function", "getQuery", "(", "$", "index", "=", "false", ")", "{", "return", "(", "$", "index", ")", "?", "array_value", "(", "$", "this", "->", "query", ",", "$", "index", ")", ":", "$", "this", "->", "query", ";", "}" ]
Gets one or all query parameters. @param string $index @return mixed
[ "Gets", "one", "or", "all", "query", "parameters", "." ]
3a02152048ea38ec5f0adaed3f10a17730086ec7
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Libs/ApiRoute.php#L177-L180
238,654
ARCANESOFT/Tracker
src/ViewComposers/Dashboard/ReferersListComposer.php
ReferersListComposer.calculateLanguagesPercentage
private function calculateLanguagesPercentage($referers) { $total = $referers->sum('count'); return $referers->transform(function ($item) use ($total) { return $item + [ 'percentage' => round(($item['count'] / $total) * 100, 2) ]; }); }
php
private function calculateLanguagesPercentage($referers) { $total = $referers->sum('count'); return $referers->transform(function ($item) use ($total) { return $item + [ 'percentage' => round(($item['count'] / $total) * 100, 2) ]; }); }
[ "private", "function", "calculateLanguagesPercentage", "(", "$", "referers", ")", "{", "$", "total", "=", "$", "referers", "->", "sum", "(", "'count'", ")", ";", "return", "$", "referers", "->", "transform", "(", "function", "(", "$", "item", ")", "use", "(", "$", "total", ")", "{", "return", "$", "item", "+", "[", "'percentage'", "=>", "round", "(", "(", "$", "item", "[", "'count'", "]", "/", "$", "total", ")", "*", "100", ",", "2", ")", "]", ";", "}", ")", ";", "}" ]
Calculate the referers percentage. @param \Illuminate\Support\Collection $referers @return \Illuminate\Support\Collection
[ "Calculate", "the", "referers", "percentage", "." ]
d106209b32ddbb192066715f0ef99afccfc22dcb
https://github.com/ARCANESOFT/Tracker/blob/d106209b32ddbb192066715f0ef99afccfc22dcb/src/ViewComposers/Dashboard/ReferersListComposer.php#L88-L97
238,655
cmdweb/kernel
Kernel/Database.php
Database.select
public function select($sql, $class = "", $all = FALSE, $array = array()) { // Prepara a Query $sth = $this->prepare($sql); // Define os dados do Where, se existirem. foreach ($array as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue("$key", $value, $tipo); } // Executa $sth->execute(); // Executar fetchAll() ou fetch()? // Retorna a cole��o de dados (array multidimensional) if ($sth->rowCount() <= 0) return null; if ($class == "") { if ($all == false and $sth->rowCount() == 1) { $array = $sth->fetchAll(PDO::FETCH_OBJ); return array_shift($array); } return $sth->fetchAll(PDO::FETCH_OBJ); } else { if ($all == false and $sth->rowCount() == 1) { $array = $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class)); return array_shift($array); } return $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class)); } }
php
public function select($sql, $class = "", $all = FALSE, $array = array()) { // Prepara a Query $sth = $this->prepare($sql); // Define os dados do Where, se existirem. foreach ($array as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue("$key", $value, $tipo); } // Executa $sth->execute(); // Executar fetchAll() ou fetch()? // Retorna a cole��o de dados (array multidimensional) if ($sth->rowCount() <= 0) return null; if ($class == "") { if ($all == false and $sth->rowCount() == 1) { $array = $sth->fetchAll(PDO::FETCH_OBJ); return array_shift($array); } return $sth->fetchAll(PDO::FETCH_OBJ); } else { if ($all == false and $sth->rowCount() == 1) { $array = $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class)); return array_shift($array); } return $sth->fetchAll(PDO::FETCH_CLASS, $this->getClass($class)); } }
[ "public", "function", "select", "(", "$", "sql", ",", "$", "class", "=", "\"\"", ",", "$", "all", "=", "FALSE", ",", "$", "array", "=", "array", "(", ")", ")", "{", "// Prepara a Query", "$", "sth", "=", "$", "this", "->", "prepare", "(", "$", "sql", ")", ";", "// Define os dados do Where, se existirem.", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR", "$", "tipo", "=", "(", "is_int", "(", "$", "value", ")", ")", "?", "PDO", "::", "PARAM_INT", ":", "PDO", "::", "PARAM_STR", ";", "// Define o dado", "$", "sth", "->", "bindValue", "(", "\"$key\"", ",", "$", "value", ",", "$", "tipo", ")", ";", "}", "// Executa", "$", "sth", "->", "execute", "(", ")", ";", "// Executar fetchAll() ou fetch()?", "// Retorna a cole��o de dados (array multidimensional)", "if", "(", "$", "sth", "->", "rowCount", "(", ")", "<=", "0", ")", "return", "null", ";", "if", "(", "$", "class", "==", "\"\"", ")", "{", "if", "(", "$", "all", "==", "false", "and", "$", "sth", "->", "rowCount", "(", ")", "==", "1", ")", "{", "$", "array", "=", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_OBJ", ")", ";", "return", "array_shift", "(", "$", "array", ")", ";", "}", "return", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_OBJ", ")", ";", "}", "else", "{", "if", "(", "$", "all", "==", "false", "and", "$", "sth", "->", "rowCount", "(", ")", "==", "1", ")", "{", "$", "array", "=", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_CLASS", ",", "$", "this", "->", "getClass", "(", "$", "class", ")", ")", ";", "return", "array_shift", "(", "$", "array", ")", ";", "}", "return", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_CLASS", ",", "$", "this", "->", "getClass", "(", "$", "class", ")", ")", ";", "}", "}" ]
Executa um select no banco @param $sql - query @param string $class - Classe de retorno @param bool $all - Se quando retornar apenas um resultado vai voltar em um array ou um objeto unico (true = objeto) @param array $array - Paramentos do PDO @return array|mixed|null
[ "Executa", "um", "select", "no", "banco" ]
01dfc802c582adac1a739bcb34e4c31d86cde268
https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L44-L86
238,656
cmdweb/kernel
Kernel/Database.php
Database.ExecuteInsert
public function ExecuteInsert($table, $data) { if (is_object($data)) ModelState::ModelTreatment($data); $data = (array)$data; // Ordena ksort($data); // Campos e valores $camposNomes = implode('`, `', array_keys($data)); $camposValores = ':' . implode(', :', array_keys($data)); // Prepara a Query $sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)"); // Define os dados foreach ($data as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue(":$key", $value, $tipo); } // Executa $sth->execute(); // Retorna o ID desse item inserido return $this->lastInsertId(); }
php
public function ExecuteInsert($table, $data) { if (is_object($data)) ModelState::ModelTreatment($data); $data = (array)$data; // Ordena ksort($data); // Campos e valores $camposNomes = implode('`, `', array_keys($data)); $camposValores = ':' . implode(', :', array_keys($data)); // Prepara a Query $sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)"); // Define os dados foreach ($data as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue(":$key", $value, $tipo); } // Executa $sth->execute(); // Retorna o ID desse item inserido return $this->lastInsertId(); }
[ "public", "function", "ExecuteInsert", "(", "$", "table", ",", "$", "data", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "ModelState", "::", "ModelTreatment", "(", "$", "data", ")", ";", "$", "data", "=", "(", "array", ")", "$", "data", ";", "// Ordena", "ksort", "(", "$", "data", ")", ";", "// Campos e valores", "$", "camposNomes", "=", "implode", "(", "'`, `'", ",", "array_keys", "(", "$", "data", ")", ")", ";", "$", "camposValores", "=", "':'", ".", "implode", "(", "', :'", ",", "array_keys", "(", "$", "data", ")", ")", ";", "// Prepara a Query", "$", "sth", "=", "$", "this", "->", "prepare", "(", "\"INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)\"", ")", ";", "// Define os dados", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR", "$", "tipo", "=", "(", "is_int", "(", "$", "value", ")", ")", "?", "PDO", "::", "PARAM_INT", ":", "PDO", "::", "PARAM_STR", ";", "// Define o dado", "$", "sth", "->", "bindValue", "(", "\":$key\"", ",", "$", "value", ",", "$", "tipo", ")", ";", "}", "// Executa", "$", "sth", "->", "execute", "(", ")", ";", "// Retorna o ID desse item inserido", "return", "$", "this", "->", "lastInsertId", "(", ")", ";", "}" ]
Executa um INSERT no banco @param $table - Noma da Tabela @param $data - Array com os dados do insert @return string - id inserido no banco
[ "Executa", "um", "INSERT", "no", "banco" ]
01dfc802c582adac1a739bcb34e4c31d86cde268
https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L105-L136
238,657
cmdweb/kernel
Kernel/Database.php
Database.ExecuteUpdate
public function ExecuteUpdate($table, $data, $where) { if (is_object($data)) ModelState::ModelTreatment($data); $data = (array)$data; // Ordena ksort($data); // Define os dados que ser�o atualizados $novosDados = NULL; foreach ($data as $key => $value) { $novosDados .= "`$key`=:$key,"; } $novosDados = rtrim($novosDados, ','); // Prepara a Query $sth = $this->prepare("UPDATE $table SET $novosDados WHERE $where"); // Define os dados foreach ($data as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue(":$key", $value, $tipo); } // Sucesso ou falha? return $sth->execute(); }
php
public function ExecuteUpdate($table, $data, $where) { if (is_object($data)) ModelState::ModelTreatment($data); $data = (array)$data; // Ordena ksort($data); // Define os dados que ser�o atualizados $novosDados = NULL; foreach ($data as $key => $value) { $novosDados .= "`$key`=:$key,"; } $novosDados = rtrim($novosDados, ','); // Prepara a Query $sth = $this->prepare("UPDATE $table SET $novosDados WHERE $where"); // Define os dados foreach ($data as $key => $value) { // Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR $tipo = (is_int($value)) ? PDO::PARAM_INT : PDO::PARAM_STR; // Define o dado $sth->bindValue(":$key", $value, $tipo); } // Sucesso ou falha? return $sth->execute(); }
[ "public", "function", "ExecuteUpdate", "(", "$", "table", ",", "$", "data", ",", "$", "where", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "ModelState", "::", "ModelTreatment", "(", "$", "data", ")", ";", "$", "data", "=", "(", "array", ")", "$", "data", ";", "// Ordena", "ksort", "(", "$", "data", ")", ";", "// Define os dados que ser�o atualizados", "$", "novosDados", "=", "NULL", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "novosDados", ".=", "\"`$key`=:$key,\"", ";", "}", "$", "novosDados", "=", "rtrim", "(", "$", "novosDados", ",", "','", ")", ";", "// Prepara a Query", "$", "sth", "=", "$", "this", "->", "prepare", "(", "\"UPDATE $table SET $novosDados WHERE $where\"", ")", ";", "// Define os dados", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR", "$", "tipo", "=", "(", "is_int", "(", "$", "value", ")", ")", "?", "PDO", "::", "PARAM_INT", ":", "PDO", "::", "PARAM_STR", ";", "// Define o dado", "$", "sth", "->", "bindValue", "(", "\":$key\"", ",", "$", "value", ",", "$", "tipo", ")", ";", "}", "// Sucesso ou falha?", "return", "$", "sth", "->", "execute", "(", ")", ";", "}" ]
Executa com UPDATE no banco @param $table - Nome da Tabela @param $data - Dados que vão ser atualizados @param $where - WHERE da query do update @return bool - Sucesso ou falha
[ "Executa", "com", "UPDATE", "no", "banco" ]
01dfc802c582adac1a739bcb34e4c31d86cde268
https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Database.php#L145-L177
238,658
kengoldfarb/underscore_libs
src/_Libs/_ServiceResponse.php
_ServiceResponse._success
public static function _success($objects, $echoResponse = TRUE, $format = 'json') { return self::_doResponse('success', $objects, $echoResponse, $format); }
php
public static function _success($objects, $echoResponse = TRUE, $format = 'json') { return self::_doResponse('success', $objects, $echoResponse, $format); }
[ "public", "static", "function", "_success", "(", "$", "objects", ",", "$", "echoResponse", "=", "TRUE", ",", "$", "format", "=", "'json'", ")", "{", "return", "self", "::", "_doResponse", "(", "'success'", ",", "$", "objects", ",", "$", "echoResponse", ",", "$", "format", ")", ";", "}" ]
Create a service response of success @param array $objects An object or array of objects @param bool $echoResponse Whether to echo out of response @param string $format 'json' or 'xml' @return string The response
[ "Create", "a", "service", "response", "of", "success" ]
e0d584f25093b594e67b8a3068ebd41c7f6483c5
https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L37-L39
238,659
kengoldfarb/underscore_libs
src/_Libs/_ServiceResponse.php
_ServiceResponse._failure
public static function _failure($objects, $echoResponse = TRUE, $format = 'json') { return self::_doResponse('failure', $objects, $echoResponse, $format); }
php
public static function _failure($objects, $echoResponse = TRUE, $format = 'json') { return self::_doResponse('failure', $objects, $echoResponse, $format); }
[ "public", "static", "function", "_failure", "(", "$", "objects", ",", "$", "echoResponse", "=", "TRUE", ",", "$", "format", "=", "'json'", ")", "{", "return", "self", "::", "_doResponse", "(", "'failure'", ",", "$", "objects", ",", "$", "echoResponse", ",", "$", "format", ")", ";", "}" ]
Create a service response of failure @param array $objects An object or array of objects @param bool $echoResponse Whether to echo out of response @param const $format _ServiceResponse_JSON or _ServiceResponse_XML @return string The response
[ "Create", "a", "service", "response", "of", "failure" ]
e0d584f25093b594e67b8a3068ebd41c7f6483c5
https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L49-L51
238,660
kengoldfarb/underscore_libs
src/_Libs/_ServiceResponse.php
_ServiceResponse._doResponse
private static function _doResponse($type, $objects, $echoResponse, $format) { $ret = array(); $ret['status'] = $type; if (is_array($objects)) { foreach ($objects as $k => $v) { $ret[$k] = $v; } } else { $ret[] = $objects; } switch ($format) { case 'xml': require_once 'XML/Serializer.php'; $options = array( "indent" => " ", "linebreak" => "\n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8", "rootName" => "data", // "rootAttributes" => array("version" => "0.91"), "defaultTagName" => "item", "attributesArray" => "_attributes" ); $serializer = new \XML_Serializer($options); $rc = $serializer->serialize($ret); if ($rc !== TRUE) { } $ret = $serializer->getSerializedData(); break; case 'json': default: $ret = json_encode($ret); break; } if ($echoResponse) { echo $ret; } return $ret; }
php
private static function _doResponse($type, $objects, $echoResponse, $format) { $ret = array(); $ret['status'] = $type; if (is_array($objects)) { foreach ($objects as $k => $v) { $ret[$k] = $v; } } else { $ret[] = $objects; } switch ($format) { case 'xml': require_once 'XML/Serializer.php'; $options = array( "indent" => " ", "linebreak" => "\n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8", "rootName" => "data", // "rootAttributes" => array("version" => "0.91"), "defaultTagName" => "item", "attributesArray" => "_attributes" ); $serializer = new \XML_Serializer($options); $rc = $serializer->serialize($ret); if ($rc !== TRUE) { } $ret = $serializer->getSerializedData(); break; case 'json': default: $ret = json_encode($ret); break; } if ($echoResponse) { echo $ret; } return $ret; }
[ "private", "static", "function", "_doResponse", "(", "$", "type", ",", "$", "objects", ",", "$", "echoResponse", ",", "$", "format", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "ret", "[", "'status'", "]", "=", "$", "type", ";", "if", "(", "is_array", "(", "$", "objects", ")", ")", "{", "foreach", "(", "$", "objects", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "ret", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "else", "{", "$", "ret", "[", "]", "=", "$", "objects", ";", "}", "switch", "(", "$", "format", ")", "{", "case", "'xml'", ":", "require_once", "'XML/Serializer.php'", ";", "$", "options", "=", "array", "(", "\"indent\"", "=>", "\" \"", ",", "\"linebreak\"", "=>", "\"\\n\"", ",", "\"typeHints\"", "=>", "false", ",", "\"addDecl\"", "=>", "true", ",", "\"encoding\"", "=>", "\"UTF-8\"", ",", "\"rootName\"", "=>", "\"data\"", ",", "//\t\t\t\t\t\"rootAttributes\" => array(\"version\" => \"0.91\"),", "\"defaultTagName\"", "=>", "\"item\"", ",", "\"attributesArray\"", "=>", "\"_attributes\"", ")", ";", "$", "serializer", "=", "new", "\\", "XML_Serializer", "(", "$", "options", ")", ";", "$", "rc", "=", "$", "serializer", "->", "serialize", "(", "$", "ret", ")", ";", "if", "(", "$", "rc", "!==", "TRUE", ")", "{", "}", "$", "ret", "=", "$", "serializer", "->", "getSerializedData", "(", ")", ";", "break", ";", "case", "'json'", ":", "default", ":", "$", "ret", "=", "json_encode", "(", "$", "ret", ")", ";", "break", ";", "}", "if", "(", "$", "echoResponse", ")", "{", "echo", "$", "ret", ";", "}", "return", "$", "ret", ";", "}" ]
Builds the response @param type $type @param type $objects @param type $echoResponse @param type $format @return type
[ "Builds", "the", "response" ]
e0d584f25093b594e67b8a3068ebd41c7f6483c5
https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_ServiceResponse.php#L62-L107
238,661
CatLabInteractive/Neuron
src/Neuron/Config.php
Config.loadFile
private function loadFile ($file) { if (!isset ($this->files[$file])) { $filename = $this->folder . $file . '.php'; // First load these if (file_exists ($filename)) { $this->files[$file] = include ($filename); } // Now overload with environment values if (isset ($this->environment)) { $filename = $this->folder . $this->environment . '/' . $file . '.php'; if (file_exists ($filename)) { $this->merge ($file, include ($filename)); } } } }
php
private function loadFile ($file) { if (!isset ($this->files[$file])) { $filename = $this->folder . $file . '.php'; // First load these if (file_exists ($filename)) { $this->files[$file] = include ($filename); } // Now overload with environment values if (isset ($this->environment)) { $filename = $this->folder . $this->environment . '/' . $file . '.php'; if (file_exists ($filename)) { $this->merge ($file, include ($filename)); } } } }
[ "private", "function", "loadFile", "(", "$", "file", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "files", "[", "$", "file", "]", ")", ")", "{", "$", "filename", "=", "$", "this", "->", "folder", ".", "$", "file", ".", "'.php'", ";", "// First load these", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "this", "->", "files", "[", "$", "file", "]", "=", "include", "(", "$", "filename", ")", ";", "}", "// Now overload with environment values", "if", "(", "isset", "(", "$", "this", "->", "environment", ")", ")", "{", "$", "filename", "=", "$", "this", "->", "folder", ".", "$", "this", "->", "environment", ".", "'/'", ".", "$", "file", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "this", "->", "merge", "(", "$", "file", ",", "include", "(", "$", "filename", ")", ")", ";", "}", "}", "}", "}" ]
Load a file in case it's not loaded yet. @param $file
[ "Load", "a", "file", "in", "case", "it", "s", "not", "loaded", "yet", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Config.php#L87-L110
238,662
CatLabInteractive/Neuron
src/Neuron/Config.php
Config.getValue
private function getValue ($name, $default) { $parts = explode ('.', $name); $file = array_shift ($parts); $this->loadFile ($file); if (! isset ($this->files[$file])) { return $default; } else { $out = $this->files[$file]; foreach ($parts as $part) { if (!isset ($out[$part])) { return $default; } else { $out = $out[$part]; } } } return $out; }
php
private function getValue ($name, $default) { $parts = explode ('.', $name); $file = array_shift ($parts); $this->loadFile ($file); if (! isset ($this->files[$file])) { return $default; } else { $out = $this->files[$file]; foreach ($parts as $part) { if (!isset ($out[$part])) { return $default; } else { $out = $out[$part]; } } } return $out; }
[ "private", "function", "getValue", "(", "$", "name", ",", "$", "default", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "file", "=", "array_shift", "(", "$", "parts", ")", ";", "$", "this", "->", "loadFile", "(", "$", "file", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "files", "[", "$", "file", "]", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "$", "out", "=", "$", "this", "->", "files", "[", "$", "file", "]", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "if", "(", "!", "isset", "(", "$", "out", "[", "$", "part", "]", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "$", "out", "=", "$", "out", "[", "$", "part", "]", ";", "}", "}", "}", "return", "$", "out", ";", "}" ]
Find a config variable and return it. @param string $name @param string $default @return mixed
[ "Find", "a", "config", "variable", "and", "return", "it", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Config.php#L127-L152
238,663
jepihumet/libs
src/FileManager.php
FileManager.expandDirectories
public function expandDirectories($baseDir) { $directories = array(); foreach (scandir($baseDir) as $file) { if ($file == '.' || $file == '..') continue; $dir = $baseDir . DS . $file; if (is_dir($dir)) { $directories [] = $dir; $directories = array_merge($directories, $this->expandDirectories($dir)); } } return $directories; }
php
public function expandDirectories($baseDir) { $directories = array(); foreach (scandir($baseDir) as $file) { if ($file == '.' || $file == '..') continue; $dir = $baseDir . DS . $file; if (is_dir($dir)) { $directories [] = $dir; $directories = array_merge($directories, $this->expandDirectories($dir)); } } return $directories; }
[ "public", "function", "expandDirectories", "(", "$", "baseDir", ")", "{", "$", "directories", "=", "array", "(", ")", ";", "foreach", "(", "scandir", "(", "$", "baseDir", ")", "as", "$", "file", ")", "{", "if", "(", "$", "file", "==", "'.'", "||", "$", "file", "==", "'..'", ")", "continue", ";", "$", "dir", "=", "$", "baseDir", ".", "DS", ".", "$", "file", ";", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "directories", "[", "]", "=", "$", "dir", ";", "$", "directories", "=", "array_merge", "(", "$", "directories", ",", "$", "this", "->", "expandDirectories", "(", "$", "dir", ")", ")", ";", "}", "}", "return", "$", "directories", ";", "}" ]
Recursive function that returns all directories inside a base directory. @param string $baseDir @return array
[ "Recursive", "function", "that", "returns", "all", "directories", "inside", "a", "base", "directory", "." ]
a9c7a25e6b7bfa46ea9d61004273f7e29c40885e
https://github.com/jepihumet/libs/blob/a9c7a25e6b7bfa46ea9d61004273f7e29c40885e/src/FileManager.php#L19-L31
238,664
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.register
public function register(Application $app) { $this->config = $app['config']->load('log'); $handlers = $this->getHandlers($app); $app['log'] = $app->share(function ($app) use ($handlers) { return new Logger('main', $handlers); }); $app->initializer('Synapse\\Log\\LoggerAwareInterface', function ($object, $app) { $object->setLogger($app['log']); return $object; }); }
php
public function register(Application $app) { $this->config = $app['config']->load('log'); $handlers = $this->getHandlers($app); $app['log'] = $app->share(function ($app) use ($handlers) { return new Logger('main', $handlers); }); $app->initializer('Synapse\\Log\\LoggerAwareInterface', function ($object, $app) { $object->setLogger($app['log']); return $object; }); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "this", "->", "config", "=", "$", "app", "[", "'config'", "]", "->", "load", "(", "'log'", ")", ";", "$", "handlers", "=", "$", "this", "->", "getHandlers", "(", "$", "app", ")", ";", "$", "app", "[", "'log'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "app", ")", "use", "(", "$", "handlers", ")", "{", "return", "new", "Logger", "(", "'main'", ",", "$", "handlers", ")", ";", "}", ")", ";", "$", "app", "->", "initializer", "(", "'Synapse\\\\Log\\\\LoggerAwareInterface'", ",", "function", "(", "$", "object", ",", "$", "app", ")", "{", "$", "object", "->", "setLogger", "(", "$", "app", "[", "'log'", "]", ")", ";", "return", "$", "object", ";", "}", ")", ";", "}" ]
Register logging related services @param Application $app Silex application
[ "Register", "logging", "related", "services" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L39-L52
238,665
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.boot
public function boot(Application $app) { // Register Monolog error handler for fatal errors here because Symfony's handler overrides it $monologErrorHandler = new MonologErrorHandler($app['log']); $monologErrorHandler->registerErrorHandler(); $monologErrorHandler->registerFatalHandler(); }
php
public function boot(Application $app) { // Register Monolog error handler for fatal errors here because Symfony's handler overrides it $monologErrorHandler = new MonologErrorHandler($app['log']); $monologErrorHandler->registerErrorHandler(); $monologErrorHandler->registerFatalHandler(); }
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "// Register Monolog error handler for fatal errors here because Symfony's handler overrides it", "$", "monologErrorHandler", "=", "new", "MonologErrorHandler", "(", "$", "app", "[", "'log'", "]", ")", ";", "$", "monologErrorHandler", "->", "registerErrorHandler", "(", ")", ";", "$", "monologErrorHandler", "->", "registerFatalHandler", "(", ")", ";", "}" ]
Perform extra chores on boot @param Application $app
[ "Perform", "extra", "chores", "on", "boot" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L59-L66
238,666
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.getHandlers
protected function getHandlers(Application $app) { $handlers = []; // File Handler $file = Arr::path($this->config, 'file.path'); if ($file) { $handlers[] = $this->getFileHandler($file); $handlers[] = $this->getFileExceptionHandler($file); } // Loggly Handler $enableLoggly = Arr::path($this->config, 'loggly.enable'); if ($enableLoggly) { $handlers[] = $this->getLogglyHandler(); } // Rollbar Handler $enableRollbar = Arr::path($this->config, 'rollbar.enable'); if ($enableRollbar) { $handlers[] = $this->getRollbarHandler($app['environment']); } // Syslog Handler $syslogIdent = Arr::path($this->config, 'syslog.ident'); if ($syslogIdent) { $handlers[] = $this->getSyslogHandler($syslogIdent); } return $handlers; }
php
protected function getHandlers(Application $app) { $handlers = []; // File Handler $file = Arr::path($this->config, 'file.path'); if ($file) { $handlers[] = $this->getFileHandler($file); $handlers[] = $this->getFileExceptionHandler($file); } // Loggly Handler $enableLoggly = Arr::path($this->config, 'loggly.enable'); if ($enableLoggly) { $handlers[] = $this->getLogglyHandler(); } // Rollbar Handler $enableRollbar = Arr::path($this->config, 'rollbar.enable'); if ($enableRollbar) { $handlers[] = $this->getRollbarHandler($app['environment']); } // Syslog Handler $syslogIdent = Arr::path($this->config, 'syslog.ident'); if ($syslogIdent) { $handlers[] = $this->getSyslogHandler($syslogIdent); } return $handlers; }
[ "protected", "function", "getHandlers", "(", "Application", "$", "app", ")", "{", "$", "handlers", "=", "[", "]", ";", "// File Handler", "$", "file", "=", "Arr", "::", "path", "(", "$", "this", "->", "config", ",", "'file.path'", ")", ";", "if", "(", "$", "file", ")", "{", "$", "handlers", "[", "]", "=", "$", "this", "->", "getFileHandler", "(", "$", "file", ")", ";", "$", "handlers", "[", "]", "=", "$", "this", "->", "getFileExceptionHandler", "(", "$", "file", ")", ";", "}", "// Loggly Handler", "$", "enableLoggly", "=", "Arr", "::", "path", "(", "$", "this", "->", "config", ",", "'loggly.enable'", ")", ";", "if", "(", "$", "enableLoggly", ")", "{", "$", "handlers", "[", "]", "=", "$", "this", "->", "getLogglyHandler", "(", ")", ";", "}", "// Rollbar Handler", "$", "enableRollbar", "=", "Arr", "::", "path", "(", "$", "this", "->", "config", ",", "'rollbar.enable'", ")", ";", "if", "(", "$", "enableRollbar", ")", "{", "$", "handlers", "[", "]", "=", "$", "this", "->", "getRollbarHandler", "(", "$", "app", "[", "'environment'", "]", ")", ";", "}", "// Syslog Handler", "$", "syslogIdent", "=", "Arr", "::", "path", "(", "$", "this", "->", "config", ",", "'syslog.ident'", ")", ";", "if", "(", "$", "syslogIdent", ")", "{", "$", "handlers", "[", "]", "=", "$", "this", "->", "getSyslogHandler", "(", "$", "syslogIdent", ")", ";", "}", "return", "$", "handlers", ";", "}" ]
Get an array of logging handlers to use @param Application $app @return array
[ "Get", "an", "array", "of", "logging", "handlers", "to", "use" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L74-L108
238,667
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.getFileHandler
protected function getFileHandler($file) { $format = '[%datetime%] %channel%.%level_name%: %message% %context% %extra%'.PHP_EOL; $handler = new StreamHandler($file, Logger::INFO); $handler->setFormatter(new LineFormatter($format)); return new DummyExceptionHandler($handler); }
php
protected function getFileHandler($file) { $format = '[%datetime%] %channel%.%level_name%: %message% %context% %extra%'.PHP_EOL; $handler = new StreamHandler($file, Logger::INFO); $handler->setFormatter(new LineFormatter($format)); return new DummyExceptionHandler($handler); }
[ "protected", "function", "getFileHandler", "(", "$", "file", ")", "{", "$", "format", "=", "'[%datetime%] %channel%.%level_name%: %message% %context% %extra%'", ".", "PHP_EOL", ";", "$", "handler", "=", "new", "StreamHandler", "(", "$", "file", ",", "Logger", "::", "INFO", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "LineFormatter", "(", "$", "format", ")", ")", ";", "return", "new", "DummyExceptionHandler", "(", "$", "handler", ")", ";", "}" ]
Log handler for files @param string $file Path of log file @return DummyExceptionHandler
[ "Log", "handler", "for", "files" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L128-L136
238,668
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.getFileExceptionHandler
protected function getFileExceptionHandler($file) { $format = '%context.stacktrace%'.PHP_EOL; $handler = new StreamHandler($file, Logger::ERROR); $handler->setFormatter(new ExceptionLineFormatter($format)); return $handler; }
php
protected function getFileExceptionHandler($file) { $format = '%context.stacktrace%'.PHP_EOL; $handler = new StreamHandler($file, Logger::ERROR); $handler->setFormatter(new ExceptionLineFormatter($format)); return $handler; }
[ "protected", "function", "getFileExceptionHandler", "(", "$", "file", ")", "{", "$", "format", "=", "'%context.stacktrace%'", ".", "PHP_EOL", ";", "$", "handler", "=", "new", "StreamHandler", "(", "$", "file", ",", "Logger", "::", "ERROR", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "ExceptionLineFormatter", "(", "$", "format", ")", ")", ";", "return", "$", "handler", ";", "}" ]
Exception log handler for files @param string $file Path of log file @return StreamHandler
[ "Exception", "log", "handler", "for", "files" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L144-L152
238,669
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.getLogglyHandler
protected function getLogglyHandler() { $token = Arr::path($this->config, 'loggly.token'); if (! $token) { throw new ConfigException('Loggly is enabled but the token is not set.'); } return new LogglyHandler($token, Logger::INFO); }
php
protected function getLogglyHandler() { $token = Arr::path($this->config, 'loggly.token'); if (! $token) { throw new ConfigException('Loggly is enabled but the token is not set.'); } return new LogglyHandler($token, Logger::INFO); }
[ "protected", "function", "getLogglyHandler", "(", ")", "{", "$", "token", "=", "Arr", "::", "path", "(", "$", "this", "->", "config", ",", "'loggly.token'", ")", ";", "if", "(", "!", "$", "token", ")", "{", "throw", "new", "ConfigException", "(", "'Loggly is enabled but the token is not set.'", ")", ";", "}", "return", "new", "LogglyHandler", "(", "$", "token", ",", "Logger", "::", "INFO", ")", ";", "}" ]
Log handler for Loggly @return LogglyHandler
[ "Log", "handler", "for", "Loggly" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L159-L168
238,670
synapsestudios/synapse-base
src/Synapse/Log/LogServiceProvider.php
LogServiceProvider.getRollbarHandler
protected function getRollbarHandler($environment) { $rollbarConfig = Arr::get($this->config, 'rollbar', []); return new RollbarHandler($rollbarConfig, $environment); }
php
protected function getRollbarHandler($environment) { $rollbarConfig = Arr::get($this->config, 'rollbar', []); return new RollbarHandler($rollbarConfig, $environment); }
[ "protected", "function", "getRollbarHandler", "(", "$", "environment", ")", "{", "$", "rollbarConfig", "=", "Arr", "::", "get", "(", "$", "this", "->", "config", ",", "'rollbar'", ",", "[", "]", ")", ";", "return", "new", "RollbarHandler", "(", "$", "rollbarConfig", ",", "$", "environment", ")", ";", "}" ]
Register log handler for Rollbar @return RollbarHandler
[ "Register", "log", "handler", "for", "Rollbar" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Log/LogServiceProvider.php#L175-L179
238,671
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php
Mapper.findRootOf
public function findRootOf( $id ) { return $this->findOne( array( 'id' => $this->sql() ->select() ->columns( array( 'rootId' ) ) ->where( array( 'id' => $id, ) ), ) ); }
php
public function findRootOf( $id ) { return $this->findOne( array( 'id' => $this->sql() ->select() ->columns( array( 'rootId' ) ) ->where( array( 'id' => $id, ) ), ) ); }
[ "public", "function", "findRootOf", "(", "$", "id", ")", "{", "return", "$", "this", "->", "findOne", "(", "array", "(", "'id'", "=>", "$", "this", "->", "sql", "(", ")", "->", "select", "(", ")", "->", "columns", "(", "array", "(", "'rootId'", ")", ")", "->", "where", "(", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ",", ")", ")", ";", "}" ]
Find root paragraph of paragraph by id @param int $id @return \Paragraph\Model\Paragraph\StructureInterface
[ "Find", "root", "paragraph", "of", "paragraph", "by", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L706-L716
238,672
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php
Mapper.getTagIdByName
private function getTagIdByName( $tag ) { $tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) ); $select = $tagSql->select() ->columns( array( 'id' ) ) ->where( array( new TypedParameters( 'LOWER(?) = ?', array( 'name', mb_strtolower( $tag, 'UTF-8' ), ), array( TypedParameters::TYPE_IDENTIFIER, TypedParameters::TYPE_VALUE, ) ), ) ); $result = $tagSql->prepareStatementForSqlObject( $select ) ->execute(); foreach ( $result as $row ) { return $row['id']; } return null; }
php
private function getTagIdByName( $tag ) { $tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) ); $select = $tagSql->select() ->columns( array( 'id' ) ) ->where( array( new TypedParameters( 'LOWER(?) = ?', array( 'name', mb_strtolower( $tag, 'UTF-8' ), ), array( TypedParameters::TYPE_IDENTIFIER, TypedParameters::TYPE_VALUE, ) ), ) ); $result = $tagSql->prepareStatementForSqlObject( $select ) ->execute(); foreach ( $result as $row ) { return $row['id']; } return null; }
[ "private", "function", "getTagIdByName", "(", "$", "tag", ")", "{", "$", "tagSql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "static", "::", "$", "tagTableName", ")", ")", ";", "$", "select", "=", "$", "tagSql", "->", "select", "(", ")", "->", "columns", "(", "array", "(", "'id'", ")", ")", "->", "where", "(", "array", "(", "new", "TypedParameters", "(", "'LOWER(?) = ?'", ",", "array", "(", "'name'", ",", "mb_strtolower", "(", "$", "tag", ",", "'UTF-8'", ")", ",", ")", ",", "array", "(", "TypedParameters", "::", "TYPE_IDENTIFIER", ",", "TypedParameters", "::", "TYPE_VALUE", ",", ")", ")", ",", ")", ")", ";", "$", "result", "=", "$", "tagSql", "->", "prepareStatementForSqlObject", "(", "$", "select", ")", "->", "execute", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "row", ")", "{", "return", "$", "row", "[", "'id'", "]", ";", "}", "return", "null", ";", "}" ]
Get tag id by its name @param string $tag @return int|null
[ "Get", "tag", "id", "by", "its", "name" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1133-L1162
238,673
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php
Mapper.setTagFor
protected function setTagFor( $paragraphId, $tag ) { $rows = 0; $tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) ); $tagJoinSql = $this->sql( $this->getTableInSchema( static::$tagJoinTableName ) ); $tagId = $this->getTagIdByName( $tag ); if ( empty( $tagId ) ) { $insert = $tagSql->insert() ->values( array( 'locale' => $this->getLocale(), 'name' => $tag, ) ); $rows += $tagSql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); $tagId = $this->getTagIdByName( $tag ); } $data = array( 'paragraphId' => $paragraphId, 'tagId' => $tagId, ); $select = $tagJoinSql->select() ->where( $data ); if ( ! $tagJoinSql->prepareStatementForSqlObject( $select ) ->execute() ->getAffectedRows() ) { $insert = $tagJoinSql->insert() ->values( $data ); $rows += $tagJoinSql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $rows; }
php
protected function setTagFor( $paragraphId, $tag ) { $rows = 0; $tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) ); $tagJoinSql = $this->sql( $this->getTableInSchema( static::$tagJoinTableName ) ); $tagId = $this->getTagIdByName( $tag ); if ( empty( $tagId ) ) { $insert = $tagSql->insert() ->values( array( 'locale' => $this->getLocale(), 'name' => $tag, ) ); $rows += $tagSql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); $tagId = $this->getTagIdByName( $tag ); } $data = array( 'paragraphId' => $paragraphId, 'tagId' => $tagId, ); $select = $tagJoinSql->select() ->where( $data ); if ( ! $tagJoinSql->prepareStatementForSqlObject( $select ) ->execute() ->getAffectedRows() ) { $insert = $tagJoinSql->insert() ->values( $data ); $rows += $tagJoinSql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $rows; }
[ "protected", "function", "setTagFor", "(", "$", "paragraphId", ",", "$", "tag", ")", "{", "$", "rows", "=", "0", ";", "$", "tagSql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "static", "::", "$", "tagTableName", ")", ")", ";", "$", "tagJoinSql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "static", "::", "$", "tagJoinTableName", ")", ")", ";", "$", "tagId", "=", "$", "this", "->", "getTagIdByName", "(", "$", "tag", ")", ";", "if", "(", "empty", "(", "$", "tagId", ")", ")", "{", "$", "insert", "=", "$", "tagSql", "->", "insert", "(", ")", "->", "values", "(", "array", "(", "'locale'", "=>", "$", "this", "->", "getLocale", "(", ")", ",", "'name'", "=>", "$", "tag", ",", ")", ")", ";", "$", "rows", "+=", "$", "tagSql", "->", "prepareStatementForSqlObject", "(", "$", "insert", ")", "->", "execute", "(", ")", "->", "getAffectedRows", "(", ")", ";", "$", "tagId", "=", "$", "this", "->", "getTagIdByName", "(", "$", "tag", ")", ";", "}", "$", "data", "=", "array", "(", "'paragraphId'", "=>", "$", "paragraphId", ",", "'tagId'", "=>", "$", "tagId", ",", ")", ";", "$", "select", "=", "$", "tagJoinSql", "->", "select", "(", ")", "->", "where", "(", "$", "data", ")", ";", "if", "(", "!", "$", "tagJoinSql", "->", "prepareStatementForSqlObject", "(", "$", "select", ")", "->", "execute", "(", ")", "->", "getAffectedRows", "(", ")", ")", "{", "$", "insert", "=", "$", "tagJoinSql", "->", "insert", "(", ")", "->", "values", "(", "$", "data", ")", ";", "$", "rows", "+=", "$", "tagJoinSql", "->", "prepareStatementForSqlObject", "(", "$", "insert", ")", "->", "execute", "(", ")", "->", "getAffectedRows", "(", ")", ";", "}", "return", "$", "rows", ";", "}" ]
Set a tag for a paragraph @param int $paragraphId @param string $tag @return int
[ "Set", "a", "tag", "for", "a", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1171-L1214
238,674
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php
Mapper.saveRawProperties
public function saveRawProperties( $id, $properties ) { $result = 0; if ( ! empty( $properties ) ) { foreach ( $properties as $property ) { $result += $this->saveProperty( $id, empty( $property['locale'] ) ? null : $property['locale'], empty( $property['name'] ) ? null : $property['name'], empty( $property['value'] ) ? null : $property['value'] ); } } return $result; }
php
public function saveRawProperties( $id, $properties ) { $result = 0; if ( ! empty( $properties ) ) { foreach ( $properties as $property ) { $result += $this->saveProperty( $id, empty( $property['locale'] ) ? null : $property['locale'], empty( $property['name'] ) ? null : $property['name'], empty( $property['value'] ) ? null : $property['value'] ); } } return $result; }
[ "public", "function", "saveRawProperties", "(", "$", "id", ",", "$", "properties", ")", "{", "$", "result", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", ")", "{", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "result", "+=", "$", "this", "->", "saveProperty", "(", "$", "id", ",", "empty", "(", "$", "property", "[", "'locale'", "]", ")", "?", "null", ":", "$", "property", "[", "'locale'", "]", ",", "empty", "(", "$", "property", "[", "'name'", "]", ")", "?", "null", ":", "$", "property", "[", "'name'", "]", ",", "empty", "(", "$", "property", "[", "'value'", "]", ")", "?", "null", ":", "$", "property", "[", "'value'", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Save raw paragraph properties @param int $id @param array|\Traversable $properties @return int
[ "Save", "raw", "paragraph", "properties" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1223-L1241
238,675
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php
Mapper.saveRawData
public function saveRawData( array $data ) { if ( ! parent::save( $data ) ) { return null; } return isset( $data['id'] ) ? $data['id'] : null; }
php
public function saveRawData( array $data ) { if ( ! parent::save( $data ) ) { return null; } return isset( $data['id'] ) ? $data['id'] : null; }
[ "public", "function", "saveRawData", "(", "array", "$", "data", ")", "{", "if", "(", "!", "parent", "::", "save", "(", "$", "data", ")", ")", "{", "return", "null", ";", "}", "return", "isset", "(", "$", "data", "[", "'id'", "]", ")", "?", "$", "data", "[", "'id'", "]", ":", "null", ";", "}" ]
Save paragraph form raw data @param array $data @return int|null
[ "Save", "paragraph", "form", "raw", "data" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Mapper.php#L1315-L1323
238,676
lbmzorx/yii2-components
src/action/ErrorAction.php
ErrorAction.chooseView
protected function chooseView(){ if($this->guestView){ if(Yii::$app->user->isGuest){ $this->controller->layout=$this->guestLayout; $this->view=$this->guestView; } } if($this->userView){ if(!Yii::$app->user->isGuest){ $this->controller->layout=$this->userLayout; $this->view=$this->userView; } } }
php
protected function chooseView(){ if($this->guestView){ if(Yii::$app->user->isGuest){ $this->controller->layout=$this->guestLayout; $this->view=$this->guestView; } } if($this->userView){ if(!Yii::$app->user->isGuest){ $this->controller->layout=$this->userLayout; $this->view=$this->userView; } } }
[ "protected", "function", "chooseView", "(", ")", "{", "if", "(", "$", "this", "->", "guestView", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "user", "->", "isGuest", ")", "{", "$", "this", "->", "controller", "->", "layout", "=", "$", "this", "->", "guestLayout", ";", "$", "this", "->", "view", "=", "$", "this", "->", "guestView", ";", "}", "}", "if", "(", "$", "this", "->", "userView", ")", "{", "if", "(", "!", "Yii", "::", "$", "app", "->", "user", "->", "isGuest", ")", "{", "$", "this", "->", "controller", "->", "layout", "=", "$", "this", "->", "userLayout", ";", "$", "this", "->", "view", "=", "$", "this", "->", "userView", ";", "}", "}", "}" ]
select view template of error view by different group
[ "select", "view", "template", "of", "error", "view", "by", "different", "group" ]
0d5344fbaf07ee979942414d2874696273ce7bdd
https://github.com/lbmzorx/yii2-components/blob/0d5344fbaf07ee979942414d2874696273ce7bdd/src/action/ErrorAction.php#L83-L96
238,677
consigliere/components
src/Process/Installer.php
Installer.installViaSubtree
public function installViaSubtree() { return new Process(sprintf( 'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s', base_path(), $this->getComponentName(), $this->getRepoUrl(), $this->getDestinationPath(), $this->getComponentName(), $this->getBranch() )); }
php
public function installViaSubtree() { return new Process(sprintf( 'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s', base_path(), $this->getComponentName(), $this->getRepoUrl(), $this->getDestinationPath(), $this->getComponentName(), $this->getBranch() )); }
[ "public", "function", "installViaSubtree", "(", ")", "{", "return", "new", "Process", "(", "sprintf", "(", "'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s'", ",", "base_path", "(", ")", ",", "$", "this", "->", "getComponentName", "(", ")", ",", "$", "this", "->", "getRepoUrl", "(", ")", ",", "$", "this", "->", "getDestinationPath", "(", ")", ",", "$", "this", "->", "getComponentName", "(", ")", ",", "$", "this", "->", "getBranch", "(", ")", ")", ")", ";", "}" ]
Install the component via git subtree. @return \Symfony\Component\Process\Process
[ "Install", "the", "component", "via", "git", "subtree", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Process/Installer.php#L270-L281
238,678
remote-office/libx
src/Cache/Storage/Redis.php
Redis.retrieve
public function retrieve($key) { // Get value by key $value = $this->redis->get($key); if($value === false) return null; return $value; }
php
public function retrieve($key) { // Get value by key $value = $this->redis->get($key); if($value === false) return null; return $value; }
[ "public", "function", "retrieve", "(", "$", "key", ")", "{", "// Get value by key", "$", "value", "=", "$", "this", "->", "redis", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "value", "===", "false", ")", "return", "null", ";", "return", "$", "value", ";", "}" ]
Retrieve value from redis server @param string $key @return string
[ "Retrieve", "value", "from", "redis", "server" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Cache/Storage/Redis.php#L29-L38
238,679
AlcyZ/Alcys-ORM
src/Core/Db/Statement/Insert.php
Insert.values
public function values(array $valuesArray) { $this->_checkColumnsArrayIsset()->_checkArraysForSameLength($valuesArray)->_checkValuesArrayType($valuesArray); $this->values[] = $valuesArray; return $this; }
php
public function values(array $valuesArray) { $this->_checkColumnsArrayIsset()->_checkArraysForSameLength($valuesArray)->_checkValuesArrayType($valuesArray); $this->values[] = $valuesArray; return $this; }
[ "public", "function", "values", "(", "array", "$", "valuesArray", ")", "{", "$", "this", "->", "_checkColumnsArrayIsset", "(", ")", "->", "_checkArraysForSameLength", "(", "$", "valuesArray", ")", "->", "_checkValuesArrayType", "(", "$", "valuesArray", ")", ";", "$", "this", "->", "values", "[", "]", "=", "$", "valuesArray", ";", "return", "$", "this", ";", "}" ]
Validate the passed array and add their values to the insert statement. The columns method must called before, otherwise an exception will thrown. @param ReferencesInterface[] $valuesArray @return $this The same instance to concatenate methods. @throws \Exception When array does not have the same length like the passed array of the column method, if column method was not invoke or if element of the passed array is not of type ReferenceInterface
[ "Validate", "the", "passed", "array", "and", "add", "their", "values", "to", "the", "insert", "statement", ".", "The", "columns", "method", "must", "called", "before", "otherwise", "an", "exception", "will", "thrown", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Statement/Insert.php#L104-L110
238,680
ehough/shortstop
src/main/php/ehough/shortstop/api/HttpRequest.php
ehough_shortstop_api_HttpRequest.setUrl
public final function setUrl($url) { if (is_string($url)) { $this->_url = new ehough_curly_Url($url); return; } if (! $url instanceof ehough_curly_Url) { throw new ehough_shortstop_api_exception_InvalidArgumentException( 'setUrl() only takes a string or a ehough_curly_Url instance' ); } $this->_url = $url; }
php
public final function setUrl($url) { if (is_string($url)) { $this->_url = new ehough_curly_Url($url); return; } if (! $url instanceof ehough_curly_Url) { throw new ehough_shortstop_api_exception_InvalidArgumentException( 'setUrl() only takes a string or a ehough_curly_Url instance' ); } $this->_url = $url; }
[ "public", "final", "function", "setUrl", "(", "$", "url", ")", "{", "if", "(", "is_string", "(", "$", "url", ")", ")", "{", "$", "this", "->", "_url", "=", "new", "ehough_curly_Url", "(", "$", "url", ")", ";", "return", ";", "}", "if", "(", "!", "$", "url", "instanceof", "ehough_curly_Url", ")", "{", "throw", "new", "ehough_shortstop_api_exception_InvalidArgumentException", "(", "'setUrl() only takes a string or a ehough_curly_Url instance'", ")", ";", "}", "$", "this", "->", "_url", "=", "$", "url", ";", "}" ]
Sets the URL of this request. @param mixed $url The URL of this request. @throws ehough_shortstop_api_exception_InvalidArgumentException If the given URL is not a valid string URL or instance of ehough_curly_Url @return void
[ "Sets", "the", "URL", "of", "this", "request", "." ]
4cef21457741347546c70e8e5c0cef6d3162b257
https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/api/HttpRequest.php#L92-L109
238,681
iwyg/template
Engine.php
Engine.getErrFunc
protected function getErrFunc() { if (null === $this->errFunc) { $this->errFunc = function ($errno, $errstr, $errfile, $errline) { $this->stopErrorHandling(); throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }; } return $this->errFunc; }
php
protected function getErrFunc() { if (null === $this->errFunc) { $this->errFunc = function ($errno, $errstr, $errfile, $errline) { $this->stopErrorHandling(); throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }; } return $this->errFunc; }
[ "protected", "function", "getErrFunc", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "errFunc", ")", "{", "$", "this", "->", "errFunc", "=", "function", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "$", "this", "->", "stopErrorHandling", "(", ")", ";", "throw", "new", "\\", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "}", ";", "}", "return", "$", "this", "->", "errFunc", ";", "}" ]
Get the error handler @return \Closure
[ "Get", "the", "error", "handler" ]
ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e
https://github.com/iwyg/template/blob/ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e/Engine.php#L548-L558
238,682
ronanchilvers/silex-spot2-provider
src/Application/Spot2Trait.php
Spot2Trait.mapper
public function mapper($entityName) { if (!class_exists($entityName)) { throw new \Exception('Unable to get mapper for unknown entity class '.$entityName); } $locator = $this['spot2.locator']; return $locator->mapper($entityName); }
php
public function mapper($entityName) { if (!class_exists($entityName)) { throw new \Exception('Unable to get mapper for unknown entity class '.$entityName); } $locator = $this['spot2.locator']; return $locator->mapper($entityName); }
[ "public", "function", "mapper", "(", "$", "entityName", ")", "{", "if", "(", "!", "class_exists", "(", "$", "entityName", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to get mapper for unknown entity class '", ".", "$", "entityName", ")", ";", "}", "$", "locator", "=", "$", "this", "[", "'spot2.locator'", "]", ";", "return", "$", "locator", "->", "mapper", "(", "$", "entityName", ")", ";", "}" ]
Get a mapper for a given entity. @param string $entityName @return Spot\Mapper @author Ronan Chilvers <ronan@d3r.com>
[ "Get", "a", "mapper", "for", "a", "given", "entity", "." ]
9b13856d9560f13604ad885ee4c94e374d5e3635
https://github.com/ronanchilvers/silex-spot2-provider/blob/9b13856d9560f13604ad885ee4c94e374d5e3635/src/Application/Spot2Trait.php#L36-L44
238,683
a2c/BaconAclBundle
Controller/ModuleController.php
ModuleController.indexAction
public function indexAction($page, $sort, $direction) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'INDEX')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => '', ]); $breadcumbs->addItem([ 'title' => 'List', 'route' => '', ]); $entity = new Module(); if ($this->get('session')->has('module_search_session')) { $objSerialize = $this->get('session')->get('module_search_session'); $entity = unserialize($objSerialize); } $query = $this->getDoctrine()->getRepository('BaconAclBundle:Module')->getQueryPagination($entity, $sort, $direction); $paginator = $this->getPagination($query, $page, Module::PER_PAGE); $paginator->setUsedRoute('module_pagination'); $form = $this->createForm(ModuleFormType::class, $entity, [ 'search' => true, ]); return [ 'pagination' => $paginator, 'form_search' => $form->createView(), 'form_delete' => $this->createDeleteForm()->createView(), ]; }
php
public function indexAction($page, $sort, $direction) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'INDEX')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => '', ]); $breadcumbs->addItem([ 'title' => 'List', 'route' => '', ]); $entity = new Module(); if ($this->get('session')->has('module_search_session')) { $objSerialize = $this->get('session')->get('module_search_session'); $entity = unserialize($objSerialize); } $query = $this->getDoctrine()->getRepository('BaconAclBundle:Module')->getQueryPagination($entity, $sort, $direction); $paginator = $this->getPagination($query, $page, Module::PER_PAGE); $paginator->setUsedRoute('module_pagination'); $form = $this->createForm(ModuleFormType::class, $entity, [ 'search' => true, ]); return [ 'pagination' => $paginator, 'form_search' => $form->createView(), 'form_delete' => $this->createDeleteForm()->createView(), ]; }
[ "public", "function", "indexAction", "(", "$", "page", ",", "$", "sort", ",", "$", "direction", ")", "{", "$", "acl", "=", "$", "this", "->", "get", "(", "'bacon_acl.service.authorization'", ")", ";", "if", "(", "!", "$", "acl", "->", "authorize", "(", "'module'", ",", "'INDEX'", ")", ")", "{", "throw", "$", "this", "->", "createAccessDeniedException", "(", ")", ";", "}", "$", "breadcumbs", "=", "$", "this", "->", "container", "->", "get", "(", "'bacon_breadcrumbs'", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'Module'", ",", "'route'", "=>", "''", ",", "]", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'List'", ",", "'route'", "=>", "''", ",", "]", ")", ";", "$", "entity", "=", "new", "Module", "(", ")", ";", "if", "(", "$", "this", "->", "get", "(", "'session'", ")", "->", "has", "(", "'module_search_session'", ")", ")", "{", "$", "objSerialize", "=", "$", "this", "->", "get", "(", "'session'", ")", "->", "get", "(", "'module_search_session'", ")", ";", "$", "entity", "=", "unserialize", "(", "$", "objSerialize", ")", ";", "}", "$", "query", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'BaconAclBundle:Module'", ")", "->", "getQueryPagination", "(", "$", "entity", ",", "$", "sort", ",", "$", "direction", ")", ";", "$", "paginator", "=", "$", "this", "->", "getPagination", "(", "$", "query", ",", "$", "page", ",", "Module", "::", "PER_PAGE", ")", ";", "$", "paginator", "->", "setUsedRoute", "(", "'module_pagination'", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "ModuleFormType", "::", "class", ",", "$", "entity", ",", "[", "'search'", "=>", "true", ",", "]", ")", ";", "return", "[", "'pagination'", "=>", "$", "paginator", ",", "'form_search'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'form_delete'", "=>", "$", "this", "->", "createDeleteForm", "(", ")", "->", "createView", "(", ")", ",", "]", ";", "}" ]
Lists all Module entities. @Route("/",defaults={"page"=1, "sort"="id", "direction"="asc"}, name="module") @Route("/page/{page}/sort/{sort}/direction/{direction}/", defaults={"page"=1, "sort"="id", "direction"="asc"}, name="module_pagination") @Method("GET") @Security("has_role('ROLE_ADMIN')") @Template()
[ "Lists", "all", "Module", "entities", "." ]
ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c
https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L32-L73
238,684
a2c/BaconAclBundle
Controller/ModuleController.php
ModuleController.newAction
public function newAction(Request $request) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'NEW')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => 'module', ]); $breadcumbs->addItem([ 'title' => 'New', 'route' => '', ]); $form = $this->createForm(ModuleFormType::class, new Module()); $form->handleRequest($request); if ($form->isSubmitted()) { $handler = new ModuleFormHandler( $form, $this->getDoctrine()->getManager(), $this->get('session')->getFlashBag() ); if ($handler->save()) { return $this->redirect($this->generateUrl('module')); } } return [ 'form' => $form->createView(), ]; }
php
public function newAction(Request $request) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'NEW')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => 'module', ]); $breadcumbs->addItem([ 'title' => 'New', 'route' => '', ]); $form = $this->createForm(ModuleFormType::class, new Module()); $form->handleRequest($request); if ($form->isSubmitted()) { $handler = new ModuleFormHandler( $form, $this->getDoctrine()->getManager(), $this->get('session')->getFlashBag() ); if ($handler->save()) { return $this->redirect($this->generateUrl('module')); } } return [ 'form' => $form->createView(), ]; }
[ "public", "function", "newAction", "(", "Request", "$", "request", ")", "{", "$", "acl", "=", "$", "this", "->", "get", "(", "'bacon_acl.service.authorization'", ")", ";", "if", "(", "!", "$", "acl", "->", "authorize", "(", "'module'", ",", "'NEW'", ")", ")", "{", "throw", "$", "this", "->", "createAccessDeniedException", "(", ")", ";", "}", "$", "breadcumbs", "=", "$", "this", "->", "container", "->", "get", "(", "'bacon_breadcrumbs'", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'Module'", ",", "'route'", "=>", "'module'", ",", "]", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'New'", ",", "'route'", "=>", "''", ",", "]", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "ModuleFormType", "::", "class", ",", "new", "Module", "(", ")", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", ")", "{", "$", "handler", "=", "new", "ModuleFormHandler", "(", "$", "form", ",", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ",", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", ")", ";", "if", "(", "$", "handler", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'module'", ")", ")", ";", "}", "}", "return", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ";", "}" ]
Displays a form to create a new Module entity. @Route("/new", name="module_new") @Method({"GET", "POST"}) @Security("has_role('ROLE_ADMIN')") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Module", "entity", "." ]
ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c
https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L115-L154
238,685
a2c/BaconAclBundle
Controller/ModuleController.php
ModuleController.showAction
public function showAction(Request $request, Module $entity) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'SHOW')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => 'module', ]); $breadcumbs->addItem([ 'title' => 'Details', 'route' => '', ]); $deleteForm = $this->createDeleteForm('module_delete', $entity); return [ 'entity' => $entity, 'delete_form' => $deleteForm->createView(), ]; }
php
public function showAction(Request $request, Module $entity) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'SHOW')) { throw $this->createAccessDeniedException(); } $breadcumbs = $this->container->get('bacon_breadcrumbs'); $breadcumbs->addItem([ 'title' => 'Module', 'route' => 'module', ]); $breadcumbs->addItem([ 'title' => 'Details', 'route' => '', ]); $deleteForm = $this->createDeleteForm('module_delete', $entity); return [ 'entity' => $entity, 'delete_form' => $deleteForm->createView(), ]; }
[ "public", "function", "showAction", "(", "Request", "$", "request", ",", "Module", "$", "entity", ")", "{", "$", "acl", "=", "$", "this", "->", "get", "(", "'bacon_acl.service.authorization'", ")", ";", "if", "(", "!", "$", "acl", "->", "authorize", "(", "'module'", ",", "'SHOW'", ")", ")", "{", "throw", "$", "this", "->", "createAccessDeniedException", "(", ")", ";", "}", "$", "breadcumbs", "=", "$", "this", "->", "container", "->", "get", "(", "'bacon_breadcrumbs'", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'Module'", ",", "'route'", "=>", "'module'", ",", "]", ")", ";", "$", "breadcumbs", "->", "addItem", "(", "[", "'title'", "=>", "'Details'", ",", "'route'", "=>", "''", ",", "]", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "'module_delete'", ",", "$", "entity", ")", ";", "return", "[", "'entity'", "=>", "$", "entity", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", "]", ";", "}" ]
Finds and displays a Module entity. @Route("/{id}", name="module_show") @Method("GET") @Security("has_role('ROLE_ADMIN')") @Template()
[ "Finds", "and", "displays", "a", "Module", "entity", "." ]
ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c
https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L216-L242
238,686
a2c/BaconAclBundle
Controller/ModuleController.php
ModuleController.deleteAction
public function deleteAction(Module $entity) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'DELETE')) { throw $this->createAccessDeniedException(); } $handler = new ModuleFormHandler( $this->createDeleteForm('module_delete', $entity), $this->get('doctrine')->getManager(), $this->get('session')->getFlashBag() ); $handler->delete($entity); return $this->redirect($this->generateUrl('module')); }
php
public function deleteAction(Module $entity) { $acl = $this->get('bacon_acl.service.authorization'); if (!$acl->authorize('module', 'DELETE')) { throw $this->createAccessDeniedException(); } $handler = new ModuleFormHandler( $this->createDeleteForm('module_delete', $entity), $this->get('doctrine')->getManager(), $this->get('session')->getFlashBag() ); $handler->delete($entity); return $this->redirect($this->generateUrl('module')); }
[ "public", "function", "deleteAction", "(", "Module", "$", "entity", ")", "{", "$", "acl", "=", "$", "this", "->", "get", "(", "'bacon_acl.service.authorization'", ")", ";", "if", "(", "!", "$", "acl", "->", "authorize", "(", "'module'", ",", "'DELETE'", ")", ")", "{", "throw", "$", "this", "->", "createAccessDeniedException", "(", ")", ";", "}", "$", "handler", "=", "new", "ModuleFormHandler", "(", "$", "this", "->", "createDeleteForm", "(", "'module_delete'", ",", "$", "entity", ")", ",", "$", "this", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ",", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", ")", ";", "$", "handler", "->", "delete", "(", "$", "entity", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'module'", ")", ")", ";", "}" ]
Deletes a Module entity. @Route("/{id}", name="module_delete") @Security("has_role('ROLE_ADMIN')") @Method("DELETE")
[ "Deletes", "a", "Module", "entity", "." ]
ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c
https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L250-L267
238,687
alxmsl/Connection
source/Redis/RedisFactory.php
RedisFactory.createRedisByConfig
public static function createRedisByConfig(array $config) { $Redis = new Connection(); $Redis->setHost(@$config['host']) ->setPort(@$config['port']); (isset($config['persistent'])) && $Redis->setPersistent($config['persistent']); (isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']); (isset($config['connect_tries'])) && $Redis->setConnectTries($config['connect_tries']); return $Redis; }
php
public static function createRedisByConfig(array $config) { $Redis = new Connection(); $Redis->setHost(@$config['host']) ->setPort(@$config['port']); (isset($config['persistent'])) && $Redis->setPersistent($config['persistent']); (isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']); (isset($config['connect_tries'])) && $Redis->setConnectTries($config['connect_tries']); return $Redis; }
[ "public", "static", "function", "createRedisByConfig", "(", "array", "$", "config", ")", "{", "$", "Redis", "=", "new", "Connection", "(", ")", ";", "$", "Redis", "->", "setHost", "(", "@", "$", "config", "[", "'host'", "]", ")", "->", "setPort", "(", "@", "$", "config", "[", "'port'", "]", ")", ";", "(", "isset", "(", "$", "config", "[", "'persistent'", "]", ")", ")", "&&", "$", "Redis", "->", "setPersistent", "(", "$", "config", "[", "'persistent'", "]", ")", ";", "(", "isset", "(", "$", "config", "[", "'connect_timeout'", "]", ")", ")", "&&", "$", "Redis", "->", "setConnectTimeout", "(", "$", "config", "[", "'connect_timeout'", "]", ")", ";", "(", "isset", "(", "$", "config", "[", "'connect_tries'", "]", ")", ")", "&&", "$", "Redis", "->", "setConnectTries", "(", "$", "config", "[", "'connect_tries'", "]", ")", ";", "return", "$", "Redis", ";", "}" ]
Create PhpRedis instance by array config @param array $config array configuration @throws InvalidArgumentException
[ "Create", "PhpRedis", "instance", "by", "array", "config" ]
f686efeb795a5450112a04792876b2198829fd32
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/RedisFactory.php#L32-L40
238,688
zepi/turbo-base
Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php
ExecuteInstallation.execute
public function execute(Framework $framework, CliRequest $request, Response $response) { // Configure turbo $this->configure(); // Save the settings $this->configurationManager->saveConfigurationFile(); // Execute the DataSource setups $dataSourceManager = $framework->getDataSourceManager(); foreach ($dataSourceManager->getDataSourceTypeClasses() as $type) { $dataSource = $dataSourceManager->getDataSource($type); $dataSource->setup(); } }
php
public function execute(Framework $framework, CliRequest $request, Response $response) { // Configure turbo $this->configure(); // Save the settings $this->configurationManager->saveConfigurationFile(); // Execute the DataSource setups $dataSourceManager = $framework->getDataSourceManager(); foreach ($dataSourceManager->getDataSourceTypeClasses() as $type) { $dataSource = $dataSourceManager->getDataSource($type); $dataSource->setup(); } }
[ "public", "function", "execute", "(", "Framework", "$", "framework", ",", "CliRequest", "$", "request", ",", "Response", "$", "response", ")", "{", "// Configure turbo", "$", "this", "->", "configure", "(", ")", ";", "// Save the settings", "$", "this", "->", "configurationManager", "->", "saveConfigurationFile", "(", ")", ";", "// Execute the DataSource setups", "$", "dataSourceManager", "=", "$", "framework", "->", "getDataSourceManager", "(", ")", ";", "foreach", "(", "$", "dataSourceManager", "->", "getDataSourceTypeClasses", "(", ")", "as", "$", "type", ")", "{", "$", "dataSource", "=", "$", "dataSourceManager", "->", "getDataSource", "(", "$", "type", ")", ";", "$", "dataSource", "->", "setup", "(", ")", ";", "}", "}" ]
Execute the installation of Turbo @access public @param \Zepi\Turbo\Framework $framework @param \Zepi\Turbo\Request\CliRequest $request @param \Zepi\Turbo\Response\Response $response
[ "Execute", "the", "installation", "of", "Turbo" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L88-L102
238,689
zepi/turbo-base
Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php
ExecuteInstallation.configure
protected function configure() { $configureSettingGroup = $this->cliHelper->confirmAction('Would you like to change the settings?'); if (!$configureSettingGroup) { return; } $this->configureSettings($this->configurationManager->getSettings()); }
php
protected function configure() { $configureSettingGroup = $this->cliHelper->confirmAction('Would you like to change the settings?'); if (!$configureSettingGroup) { return; } $this->configureSettings($this->configurationManager->getSettings()); }
[ "protected", "function", "configure", "(", ")", "{", "$", "configureSettingGroup", "=", "$", "this", "->", "cliHelper", "->", "confirmAction", "(", "'Would you like to change the settings?'", ")", ";", "if", "(", "!", "$", "configureSettingGroup", ")", "{", "return", ";", "}", "$", "this", "->", "configureSettings", "(", "$", "this", "->", "configurationManager", "->", "getSettings", "(", ")", ")", ";", "}" ]
Iterates trough all configuration settings and asks the user for a value.
[ "Iterates", "trough", "all", "configuration", "settings", "and", "asks", "the", "user", "for", "a", "value", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L108-L116
238,690
zepi/turbo-base
Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php
ExecuteInstallation.configureSettings
protected function configureSettings($settings, $path = '') { foreach ($settings as $key => $node) { if (is_array($node)) { $this->configureSettings($node, $path . $key . '.'); } else { $this->configureSetting($path . $key, $node); } } }
php
protected function configureSettings($settings, $path = '') { foreach ($settings as $key => $node) { if (is_array($node)) { $this->configureSettings($node, $path . $key . '.'); } else { $this->configureSetting($path . $key, $node); } } }
[ "protected", "function", "configureSettings", "(", "$", "settings", ",", "$", "path", "=", "''", ")", "{", "foreach", "(", "$", "settings", "as", "$", "key", "=>", "$", "node", ")", "{", "if", "(", "is_array", "(", "$", "node", ")", ")", "{", "$", "this", "->", "configureSettings", "(", "$", "node", ",", "$", "path", ".", "$", "key", ".", "'.'", ")", ";", "}", "else", "{", "$", "this", "->", "configureSetting", "(", "$", "path", ".", "$", "key", ",", "$", "node", ")", ";", "}", "}", "}" ]
Configures one settings group @access protected @param array $settings
[ "Configures", "one", "settings", "group" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L124-L133
238,691
zepi/turbo-base
Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php
ExecuteInstallation.configureSetting
protected function configureSetting($path, $value) { $newValue = $this->cliHelper->inputText('Please enter the value for "' . $path . '":', $value); if ($newValue === $value) { return; } $this->configurationManager->setSetting($path, $newValue); }
php
protected function configureSetting($path, $value) { $newValue = $this->cliHelper->inputText('Please enter the value for "' . $path . '":', $value); if ($newValue === $value) { return; } $this->configurationManager->setSetting($path, $newValue); }
[ "protected", "function", "configureSetting", "(", "$", "path", ",", "$", "value", ")", "{", "$", "newValue", "=", "$", "this", "->", "cliHelper", "->", "inputText", "(", "'Please enter the value for \"'", ".", "$", "path", ".", "'\":'", ",", "$", "value", ")", ";", "if", "(", "$", "newValue", "===", "$", "value", ")", "{", "return", ";", "}", "$", "this", "->", "configurationManager", "->", "setSetting", "(", "$", "path", ",", "$", "newValue", ")", ";", "}" ]
Configures one setting @access protected @param string $path @param string $value
[ "Configures", "one", "setting" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L142-L151
238,692
vip9008/yii2-googleapisclient
service/MapsEngine.php
MapsEngine_RasterCollectionsRasters_Resource.batchDelete
public function batchDelete($id, MapsEngine_RasterCollectionsRasterBatchDeleteRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchDelete', array($params), "MapsEngine_RasterCollectionsRastersBatchDeleteResponse"); }
php
public function batchDelete($id, MapsEngine_RasterCollectionsRasterBatchDeleteRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchDelete', array($params), "MapsEngine_RasterCollectionsRastersBatchDeleteResponse"); }
[ "public", "function", "batchDelete", "(", "$", "id", ",", "MapsEngine_RasterCollectionsRasterBatchDeleteRequest", "$", "postBody", ",", "$", "optParams", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'postBody'", "=>", "$", "postBody", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "optParams", ")", ";", "return", "$", "this", "->", "call", "(", "'batchDelete'", ",", "array", "(", "$", "params", ")", ",", "\"MapsEngine_RasterCollectionsRastersBatchDeleteResponse\"", ")", ";", "}" ]
Remove rasters from an existing raster collection. Up to 50 rasters can be included in a single batchDelete request. Each batchDelete request is atomic. (rasters.batchDelete) @param string $id The ID of the raster collection to which these rasters belong. @param Google_RasterCollectionsRasterBatchDeleteRequest $postBody @param array $optParams Optional parameters. @return MapsEngine_RasterCollectionsRastersBatchDeleteResponse
[ "Remove", "rasters", "from", "an", "existing", "raster", "collection", "." ]
b6aae1c490d84a6004ed7dccb5d4176184032b57
https://github.com/vip9008/yii2-googleapisclient/blob/b6aae1c490d84a6004ed7dccb5d4176184032b57/service/MapsEngine.php#L2567-L2572
238,693
webriq/core
module/Core/src/Grid/Core/Model/Module/Model.php
Model.onModules
public function onModules( ModulesEvent $event ) { $saved = 0; $model = $event->getTarget(); $mapper = $model->getMapper(); $modules = $event->getParams(); foreach ( $modules as $name => $enabled ) { if ( empty( $name ) ) { continue; } $name = (string) $name; $module = $model->findByName( $name ); if ( empty( $module ) ) { $module = $model->create( array( 'module' => $name, 'enabled' => $enabled, ) ); } else { $module->enabled = $enabled; } $saved += $mapper->save( $module ); } return $saved; }
php
public function onModules( ModulesEvent $event ) { $saved = 0; $model = $event->getTarget(); $mapper = $model->getMapper(); $modules = $event->getParams(); foreach ( $modules as $name => $enabled ) { if ( empty( $name ) ) { continue; } $name = (string) $name; $module = $model->findByName( $name ); if ( empty( $module ) ) { $module = $model->create( array( 'module' => $name, 'enabled' => $enabled, ) ); } else { $module->enabled = $enabled; } $saved += $mapper->save( $module ); } return $saved; }
[ "public", "function", "onModules", "(", "ModulesEvent", "$", "event", ")", "{", "$", "saved", "=", "0", ";", "$", "model", "=", "$", "event", "->", "getTarget", "(", ")", ";", "$", "mapper", "=", "$", "model", "->", "getMapper", "(", ")", ";", "$", "modules", "=", "$", "event", "->", "getParams", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "name", "=>", "$", "enabled", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "name", "=", "(", "string", ")", "$", "name", ";", "$", "module", "=", "$", "model", "->", "findByName", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "module", ")", ")", "{", "$", "module", "=", "$", "model", "->", "create", "(", "array", "(", "'module'", "=>", "$", "name", ",", "'enabled'", "=>", "$", "enabled", ",", ")", ")", ";", "}", "else", "{", "$", "module", "->", "enabled", "=", "$", "enabled", ";", "}", "$", "saved", "+=", "$", "mapper", "->", "save", "(", "$", "module", ")", ";", "}", "return", "$", "saved", ";", "}" ]
Default action on modules-set event @param ModulesEvent $event @return int
[ "Default", "action", "on", "modules", "-", "set", "event" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Module/Model.php#L107-L140
238,694
bugotech/foundation
src/Env.php
Env.load
public function load($path, $file = '.env') { try { $env = new \Dotenv\Dotenv($path, $file); $env->load(); return true; } catch (\Dotenv\Exception\InvalidPathException $e) { return false; } }
php
public function load($path, $file = '.env') { try { $env = new \Dotenv\Dotenv($path, $file); $env->load(); return true; } catch (\Dotenv\Exception\InvalidPathException $e) { return false; } }
[ "public", "function", "load", "(", "$", "path", ",", "$", "file", "=", "'.env'", ")", "{", "try", "{", "$", "env", "=", "new", "\\", "Dotenv", "\\", "Dotenv", "(", "$", "path", ",", "$", "file", ")", ";", "$", "env", "->", "load", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Dotenv", "\\", "Exception", "\\", "InvalidPathException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Load file .env. @param $path @param string $file @return bool
[ "Load", "file", ".", "env", "." ]
e4b96cd1cef117e9c5f2c6f5671d260853317658
https://github.com/bugotech/foundation/blob/e4b96cd1cef117e9c5f2c6f5671d260853317658/src/Env.php#L14-L24
238,695
tenside/core-bundle
src/DependencyInjection/Factory/LoggerFactory.php
LoggerFactory.create
public static function create( $kernel, $filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false ) { return new RotatingFileHandler( $kernel->getLogDir() . DIRECTORY_SEPARATOR . $filename, $maxFiles, $level, $bubble, $filePermission, $useLocking ); }
php
public static function create( $kernel, $filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false ) { return new RotatingFileHandler( $kernel->getLogDir() . DIRECTORY_SEPARATOR . $filename, $maxFiles, $level, $bubble, $filePermission, $useLocking ); }
[ "public", "static", "function", "create", "(", "$", "kernel", ",", "$", "filename", ",", "$", "maxFiles", "=", "0", ",", "$", "level", "=", "Logger", "::", "DEBUG", ",", "$", "bubble", "=", "true", ",", "$", "filePermission", "=", "null", ",", "$", "useLocking", "=", "false", ")", "{", "return", "new", "RotatingFileHandler", "(", "$", "kernel", "->", "getLogDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ",", "$", "maxFiles", ",", "$", "level", ",", "$", "bubble", ",", "$", "filePermission", ",", "$", "useLocking", ")", ";", "}" ]
Create the logger service. @param Kernel $kernel The kernel to retrieve the log dir from. @param string $filename The filename. @param int $maxFiles The maximal amount of files to keep (0 means unlimited). @param int $level The minimum logging level at which this handler will be triggered. @param bool $bubble Whether the messages that are handled can bubble up the stack or not. @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write). @param bool $useLocking Try to lock log file before doing any writes. @return RotatingFileHandler
[ "Create", "the", "logger", "service", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/DependencyInjection/Factory/LoggerFactory.php#L53-L70
238,696
franckysolo/octopush-sdk
src/Octopush/Client.php
Client.send
public function send($message, array $options = []) { $sms = new Message($options); $this->request('sms', $sms->getParams()); $response = $this->getResponse(); if ($response['error_code'] !== '000') { $this->errors[] = $response['error_code']; return false; } return true; }
php
public function send($message, array $options = []) { $sms = new Message($options); $this->request('sms', $sms->getParams()); $response = $this->getResponse(); if ($response['error_code'] !== '000') { $this->errors[] = $response['error_code']; return false; } return true; }
[ "public", "function", "send", "(", "$", "message", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "sms", "=", "new", "Message", "(", "$", "options", ")", ";", "$", "this", "->", "request", "(", "'sms'", ",", "$", "sms", "->", "getParams", "(", ")", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", "[", "'error_code'", "]", "!==", "'000'", ")", "{", "$", "this", "->", "errors", "[", "]", "=", "$", "response", "[", "'error_code'", "]", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Send a sms message @param string $message The string message @param array $options The array options @return bool true if message is send otherwise false
[ "Send", "a", "sms", "message" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L88-L100
238,697
franckysolo/octopush-sdk
src/Octopush/Client.php
Client.request
public function request($url, array $params = []) { $curl = new Curl(); $query = $this->buildQuery($params); $curl->setOptions($this->url . $url, $query, $this->port); $response = $curl->exec(); $this->setResponse($response); $this->setErrors($response); return $this; }
php
public function request($url, array $params = []) { $curl = new Curl(); $query = $this->buildQuery($params); $curl->setOptions($this->url . $url, $query, $this->port); $response = $curl->exec(); $this->setResponse($response); $this->setErrors($response); return $this; }
[ "public", "function", "request", "(", "$", "url", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "query", "=", "$", "this", "->", "buildQuery", "(", "$", "params", ")", ";", "$", "curl", "->", "setOptions", "(", "$", "this", "->", "url", ".", "$", "url", ",", "$", "query", ",", "$", "this", "->", "port", ")", ";", "$", "response", "=", "$", "curl", "->", "exec", "(", ")", ";", "$", "this", "->", "setResponse", "(", "$", "response", ")", ";", "$", "this", "->", "setErrors", "(", "$", "response", ")", ";", "return", "$", "this", ";", "}" ]
Send a curl request @param string $url The url API @param array $params The query params @return \Octopush\Client
[ "Send", "a", "curl", "request" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L109-L118
238,698
franckysolo/octopush-sdk
src/Octopush/Client.php
Client.buildQuery
public function buildQuery(array $params = []) { $params = array_merge($params, [ 'user_login' => $this->login, 'api_key' => $this->apiKey ]); return http_build_query($params); }
php
public function buildQuery(array $params = []) { $params = array_merge($params, [ 'user_login' => $this->login, 'api_key' => $this->apiKey ]); return http_build_query($params); }
[ "public", "function", "buildQuery", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "[", "'user_login'", "=>", "$", "this", "->", "login", ",", "'api_key'", "=>", "$", "this", "->", "apiKey", "]", ")", ";", "return", "http_build_query", "(", "$", "params", ")", ";", "}" ]
Merge the credentials and params then returns the string query @param array $params The params array @return string The query string
[ "Merge", "the", "credentials", "and", "params", "then", "returns", "the", "string", "query" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L126-L133
238,699
franckysolo/octopush-sdk
src/Octopush/Client.php
Client.setErrors
protected function setErrors($response) { libxml_use_internal_errors(true); $doc = new \DOMDocument('1.0', 'utf-8'); $doc->loadXML($response); $errors = libxml_get_errors(); if (!empty($errors)) { $this->errors[] = 'Xml response is invalid'; } return $this; }
php
protected function setErrors($response) { libxml_use_internal_errors(true); $doc = new \DOMDocument('1.0', 'utf-8'); $doc->loadXML($response); $errors = libxml_get_errors(); if (!empty($errors)) { $this->errors[] = 'Xml response is invalid'; } return $this; }
[ "protected", "function", "setErrors", "(", "$", "response", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "doc", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "doc", "->", "loadXML", "(", "$", "response", ")", ";", "$", "errors", "=", "libxml_get_errors", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "{", "$", "this", "->", "errors", "[", "]", "=", "'Xml response is invalid'", ";", "}", "return", "$", "this", ";", "}" ]
Set the xml errors @param string $response @return \Octopush\Client
[ "Set", "the", "xml", "errors" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L195-L208