id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
18,400
lode/fem
src/login_github.php
login_github.verify_user
public static function verify_user($oauth_token, $github_username) { $known_login = static::get_by_oauth_token($oauth_token); if (empty($known_login)) { return true; } if ($known_login->github_username != $github_username) { $exception = bootstrap::get_library('exception'); throw new $exception('oauth token switched user'); } return true; }
php
public static function verify_user($oauth_token, $github_username) { $known_login = static::get_by_oauth_token($oauth_token); if (empty($known_login)) { return true; } if ($known_login->github_username != $github_username) { $exception = bootstrap::get_library('exception'); throw new $exception('oauth token switched user'); } return true; }
[ "public", "static", "function", "verify_user", "(", "$", "oauth_token", ",", "$", "github_username", ")", "{", "$", "known_login", "=", "static", "::", "get_by_oauth_token", "(", "$", "oauth_token", ")", ";", "if", "(", "empty", "(", "$", "known_login", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "known_login", "->", "github_username", "!=", "$", "github_username", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'oauth token switched user'", ")", ";", "}", "return", "true", ";", "}" ]
checks whether the username belongs to the user identified by the oauth token @param string $oauth_token as received by the oauth process @param strign $github_username as received by ::get_user_info() @return boolean returns true if there is no login for this token .. .. or the usernames match never returns false @throws exception if the usernames don't match
[ "checks", "whether", "the", "username", "belongs", "to", "the", "user", "identified", "by", "the", "oauth", "token" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_github.php#L448-L460
18,401
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserPeer.php
BaseUserPeer.doCount
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) { // we may modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(UserPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { UserPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count $criteria->setDbName(UserPeer::DATABASE_NAME); // Set the correct dbName if ($con === null) { $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_READ); } // BasePeer returns a PDOStatement $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
php
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) { // we may modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(UserPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { UserPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count $criteria->setDbName(UserPeer::DATABASE_NAME); // Set the correct dbName if ($con === null) { $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_READ); } // BasePeer returns a PDOStatement $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
[ "public", "static", "function", "doCount", "(", "Criteria", "$", "criteria", ",", "$", "distinct", "=", "false", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "// we may modify criteria, so copy it first", "$", "criteria", "=", "clone", "$", "criteria", ";", "// We need to set the primary table name, since in the case that there are no WHERE columns", "// it will be impossible for the BasePeer::createSelectSql() method to determine which", "// tables go into the FROM clause.", "$", "criteria", "->", "setPrimaryTableName", "(", "UserPeer", "::", "TABLE_NAME", ")", ";", "if", "(", "$", "distinct", "&&", "!", "in_array", "(", "Criteria", "::", "DISTINCT", ",", "$", "criteria", "->", "getSelectModifiers", "(", ")", ")", ")", "{", "$", "criteria", "->", "setDistinct", "(", ")", ";", "}", "if", "(", "!", "$", "criteria", "->", "hasSelectClause", "(", ")", ")", "{", "UserPeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "}", "$", "criteria", "->", "clearOrderByColumns", "(", ")", ";", "// ORDER BY won't ever affect the count", "$", "criteria", "->", "setDbName", "(", "UserPeer", "::", "DATABASE_NAME", ")", ";", "// Set the correct dbName", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserPeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_READ", ")", ";", "}", "// BasePeer returns a PDOStatement", "$", "stmt", "=", "BasePeer", "::", "doCount", "(", "$", "criteria", ",", "$", "con", ")", ";", "if", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ")", "{", "$", "count", "=", "(", "int", ")", "$", "row", "[", "0", "]", ";", "}", "else", "{", "$", "count", "=", "0", ";", "// no rows returned; we infer that means 0 matches.", "}", "$", "stmt", "->", "closeCursor", "(", ")", ";", "return", "$", "count", ";", "}" ]
Returns the number of rows matching criteria. @param Criteria $criteria @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @param PropelPDO $con @return int Number of matching rows.
[ "Returns", "the", "number", "of", "rows", "matching", "criteria", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserPeer.php#L232-L267
18,402
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserPeer.php
BaseUserPeer.doDeleteAll
public static function doDeleteAll(PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += UserPeer::doOnDeleteCascade(new Criteria(UserPeer::DATABASE_NAME), $con); $affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con, UserPeer::DATABASE_NAME); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). UserPeer::clearInstancePool(); UserPeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
php
public static function doDeleteAll(PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += UserPeer::doOnDeleteCascade(new Criteria(UserPeer::DATABASE_NAME), $con); $affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con, UserPeer::DATABASE_NAME); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). UserPeer::clearInstancePool(); UserPeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
[ "public", "static", "function", "doDeleteAll", "(", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserPeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "try", "{", "// use transaction because $criteria could contain info", "// for more than one table or we could emulating ON DELETE CASCADE, etc.", "$", "con", "->", "beginTransaction", "(", ")", ";", "$", "affectedRows", "+=", "UserPeer", "::", "doOnDeleteCascade", "(", "new", "Criteria", "(", "UserPeer", "::", "DATABASE_NAME", ")", ",", "$", "con", ")", ";", "$", "affectedRows", "+=", "BasePeer", "::", "doDeleteAll", "(", "UserPeer", "::", "TABLE_NAME", ",", "$", "con", ",", "UserPeer", "::", "DATABASE_NAME", ")", ";", "// Because this db requires some delete cascade/set null emulation, we have to", "// clear the cached instance *after* the emulation has happened (since", "// instances get re-added by the select statement contained therein).", "UserPeer", "::", "clearInstancePool", "(", ")", ";", "UserPeer", "::", "clearRelatedInstancePool", "(", ")", ";", "$", "con", "->", "commit", "(", ")", ";", "return", "$", "affectedRows", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "con", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Deletes all rows from the user table. @param PropelPDO $con the connection to use @return int The number of affected rows (if supported by underlying database driver). @throws PropelException
[ "Deletes", "all", "rows", "from", "the", "user", "table", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserPeer.php#L650-L674
18,403
vi-kon/laravel-auth
src/ViKon/Auth/RouterAuth.php
RouterAuth.hasAccess
public function hasAccess($name) { $permissions = $this->getPermissions($name); $roles = $this->getRoles($name); if ($permissions === null && $roles === null) { return null; } return $this->keeper->hasPermissions($permissions) === true && $this->keeper->hasRoles($roles) === true; }
php
public function hasAccess($name) { $permissions = $this->getPermissions($name); $roles = $this->getRoles($name); if ($permissions === null && $roles === null) { return null; } return $this->keeper->hasPermissions($permissions) === true && $this->keeper->hasRoles($roles) === true; }
[ "public", "function", "hasAccess", "(", "$", "name", ")", "{", "$", "permissions", "=", "$", "this", "->", "getPermissions", "(", "$", "name", ")", ";", "$", "roles", "=", "$", "this", "->", "getRoles", "(", "$", "name", ")", ";", "if", "(", "$", "permissions", "===", "null", "&&", "$", "roles", "===", "null", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "keeper", "->", "hasPermissions", "(", "$", "permissions", ")", "===", "true", "&&", "$", "this", "->", "keeper", "->", "hasRoles", "(", "$", "roles", ")", "===", "true", ";", "}" ]
Check if current user has access to named route @param string $name named route name @return bool|null NULL if route not found, otherwise TRUE or FALSE depend if user has access to route or not
[ "Check", "if", "current", "user", "has", "access", "to", "named", "route" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/RouterAuth.php#L40-L50
18,404
vi-kon/laravel-auth
src/ViKon/Auth/RouterAuth.php
RouterAuth.getPermissions
public function getPermissions($name) { $route = $this->router->getRoutes()->getByName($name); // If route not exists, return NULL if ($route === null) { return null; } $permissions = []; // Get permission from permission middleware foreach ($route->middleware() as $middleware) { if (strpos($middleware, 'permission:') === 0) { list(, $permission) = explode(':', $middleware, 2); $permissions[] = $permission; } } // Get permissions from array syntax $action = $route->getAction(); if (array_key_exists('permission', $action)) { $permissions[] = $action['permission']; } if (array_key_exists('permissions', $action)) { $permissions = array_merge($permissions, $action['permissions']); } return array_unique($permissions); }
php
public function getPermissions($name) { $route = $this->router->getRoutes()->getByName($name); // If route not exists, return NULL if ($route === null) { return null; } $permissions = []; // Get permission from permission middleware foreach ($route->middleware() as $middleware) { if (strpos($middleware, 'permission:') === 0) { list(, $permission) = explode(':', $middleware, 2); $permissions[] = $permission; } } // Get permissions from array syntax $action = $route->getAction(); if (array_key_exists('permission', $action)) { $permissions[] = $action['permission']; } if (array_key_exists('permissions', $action)) { $permissions = array_merge($permissions, $action['permissions']); } return array_unique($permissions); }
[ "public", "function", "getPermissions", "(", "$", "name", ")", "{", "$", "route", "=", "$", "this", "->", "router", "->", "getRoutes", "(", ")", "->", "getByName", "(", "$", "name", ")", ";", "// If route not exists, return NULL", "if", "(", "$", "route", "===", "null", ")", "{", "return", "null", ";", "}", "$", "permissions", "=", "[", "]", ";", "// Get permission from permission middleware", "foreach", "(", "$", "route", "->", "middleware", "(", ")", "as", "$", "middleware", ")", "{", "if", "(", "strpos", "(", "$", "middleware", ",", "'permission:'", ")", "===", "0", ")", "{", "list", "(", ",", "$", "permission", ")", "=", "explode", "(", "':'", ",", "$", "middleware", ",", "2", ")", ";", "$", "permissions", "[", "]", "=", "$", "permission", ";", "}", "}", "// Get permissions from array syntax", "$", "action", "=", "$", "route", "->", "getAction", "(", ")", ";", "if", "(", "array_key_exists", "(", "'permission'", ",", "$", "action", ")", ")", "{", "$", "permissions", "[", "]", "=", "$", "action", "[", "'permission'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'permissions'", ",", "$", "action", ")", ")", "{", "$", "permissions", "=", "array_merge", "(", "$", "permissions", ",", "$", "action", "[", "'permissions'", "]", ")", ";", "}", "return", "array_unique", "(", "$", "permissions", ")", ";", "}" ]
Get permissions for named route @param string $name named route named @return string[]|null NULL if route not found, otherwise array of permissions
[ "Get", "permissions", "for", "named", "route" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/RouterAuth.php#L71-L102
18,405
vi-kon/laravel-auth
src/ViKon/Auth/RouterAuth.php
RouterAuth.getRoles
public function getRoles($name) { $route = $this->router->getRoutes()->getByName($name); // If route not exists, return NULL if ($route === null) { return null; } $roles = []; // Get permissions from array syntax $action = $route->getAction(); if (array_key_exists('role', $action)) { $roles[] = $action['role']; } if (array_key_exists('roles', $action)) { $roles = array_merge($roles, $action['roles']); } return array_unique($roles); }
php
public function getRoles($name) { $route = $this->router->getRoutes()->getByName($name); // If route not exists, return NULL if ($route === null) { return null; } $roles = []; // Get permissions from array syntax $action = $route->getAction(); if (array_key_exists('role', $action)) { $roles[] = $action['role']; } if (array_key_exists('roles', $action)) { $roles = array_merge($roles, $action['roles']); } return array_unique($roles); }
[ "public", "function", "getRoles", "(", "$", "name", ")", "{", "$", "route", "=", "$", "this", "->", "router", "->", "getRoutes", "(", ")", "->", "getByName", "(", "$", "name", ")", ";", "// If route not exists, return NULL", "if", "(", "$", "route", "===", "null", ")", "{", "return", "null", ";", "}", "$", "roles", "=", "[", "]", ";", "// Get permissions from array syntax", "$", "action", "=", "$", "route", "->", "getAction", "(", ")", ";", "if", "(", "array_key_exists", "(", "'role'", ",", "$", "action", ")", ")", "{", "$", "roles", "[", "]", "=", "$", "action", "[", "'role'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'roles'", ",", "$", "action", ")", ")", "{", "$", "roles", "=", "array_merge", "(", "$", "roles", ",", "$", "action", "[", "'roles'", "]", ")", ";", "}", "return", "array_unique", "(", "$", "roles", ")", ";", "}" ]
Get roles for named route @param string $name named route named @return string[]|null NULL if route not found, otherwise array of roles
[ "Get", "roles", "for", "named", "route" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/RouterAuth.php#L111-L134
18,406
shinjin/freezer
src/Storage.php
Storage.store
public function store($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $objects = array(); $id = $this->doStore($this->freezer->freeze($object, $objects)); if ($id !== null) { $object->{$this->freezer->getIdProperty()} = $id; } return $object->{$this->freezer->getIdProperty()}; }
php
public function store($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $objects = array(); $id = $this->doStore($this->freezer->freeze($object, $objects)); if ($id !== null) { $object->{$this->freezer->getIdProperty()} = $id; } return $object->{$this->freezer->getIdProperty()}; }
[ "public", "function", "store", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "1", ",", "'object'", ")", ";", "}", "$", "objects", "=", "array", "(", ")", ";", "$", "id", "=", "$", "this", "->", "doStore", "(", "$", "this", "->", "freezer", "->", "freeze", "(", "$", "object", ",", "$", "objects", ")", ")", ";", "if", "(", "$", "id", "!==", "null", ")", "{", "$", "object", "->", "{", "$", "this", "->", "freezer", "->", "getIdProperty", "(", ")", "}", "=", "$", "id", ";", "}", "return", "$", "object", "->", "{", "$", "this", "->", "freezer", "->", "getIdProperty", "(", ")", "}", ";", "}" ]
Freezes an object and stores it in the object storage. @param object $object The object that is to be stored. @return string
[ "Freezes", "an", "object", "and", "stores", "it", "in", "the", "object", "storage", "." ]
f5955fb5476fa8ac456e27c0edafaae331d02cd3
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Storage.php#L79-L93
18,407
jacobemerick/pqp
src/Console.php
Console.logMemory
public function logMemory($object = null, $name = 'PHP', $literal = false) { $memory = memory_get_usage(); $dataType = ''; if (!is_null($object) && !$literal) { $memory = strlen(serialize($object)); $dataType = gettype($object); } else if (is_numeric($object) && $literal) { $memory = floatval($object); } array_push($this->store, array( 'name' => $name, 'data' => $memory, 'data_type' => $dataType, 'type' => 'memory' )); }
php
public function logMemory($object = null, $name = 'PHP', $literal = false) { $memory = memory_get_usage(); $dataType = ''; if (!is_null($object) && !$literal) { $memory = strlen(serialize($object)); $dataType = gettype($object); } else if (is_numeric($object) && $literal) { $memory = floatval($object); } array_push($this->store, array( 'name' => $name, 'data' => $memory, 'data_type' => $dataType, 'type' => 'memory' )); }
[ "public", "function", "logMemory", "(", "$", "object", "=", "null", ",", "$", "name", "=", "'PHP'", ",", "$", "literal", "=", "false", ")", "{", "$", "memory", "=", "memory_get_usage", "(", ")", ";", "$", "dataType", "=", "''", ";", "if", "(", "!", "is_null", "(", "$", "object", ")", "&&", "!", "$", "literal", ")", "{", "$", "memory", "=", "strlen", "(", "serialize", "(", "$", "object", ")", ")", ";", "$", "dataType", "=", "gettype", "(", "$", "object", ")", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "object", ")", "&&", "$", "literal", ")", "{", "$", "memory", "=", "floatval", "(", "$", "object", ")", ";", "}", "array_push", "(", "$", "this", "->", "store", ",", "array", "(", "'name'", "=>", "$", "name", ",", "'data'", "=>", "$", "memory", ",", "'data_type'", "=>", "$", "dataType", ",", "'type'", "=>", "'memory'", ")", ")", ";", "}" ]
Logs memory usage of a variable If no parameter is passed in, logs current memory usage @param mixed $object @param string $name @param boolean $literal
[ "Logs", "memory", "usage", "of", "a", "variable", "If", "no", "parameter", "is", "passed", "in", "logs", "current", "memory", "usage" ]
08276f050425d1ab71e7ca3b897eb8c409ccbe70
https://github.com/jacobemerick/pqp/blob/08276f050425d1ab71e7ca3b897eb8c409ccbe70/src/Console.php#L43-L60
18,408
jacobemerick/pqp
src/Console.php
Console.logError
public function logError(Exception $exception, $message = '') { if (empty($message)) { $message = $exception->getMessage(); } array_push($this->store, array( 'data' => $message, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'type' => 'error' )); }
php
public function logError(Exception $exception, $message = '') { if (empty($message)) { $message = $exception->getMessage(); } array_push($this->store, array( 'data' => $message, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'type' => 'error' )); }
[ "public", "function", "logError", "(", "Exception", "$", "exception", ",", "$", "message", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "message", ")", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "}", "array_push", "(", "$", "this", "->", "store", ",", "array", "(", "'data'", "=>", "$", "message", ",", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'type'", "=>", "'error'", ")", ")", ";", "}" ]
Logs exception with optional message override @param Exception $exception @param string $message
[ "Logs", "exception", "with", "optional", "message", "override" ]
08276f050425d1ab71e7ca3b897eb8c409ccbe70
https://github.com/jacobemerick/pqp/blob/08276f050425d1ab71e7ca3b897eb8c409ccbe70/src/Console.php#L68-L80
18,409
jacobemerick/pqp
src/Console.php
Console.logSpeed
public function logSpeed($name = 'Point in Time', $literalTime = null) { $time = microtime(true); if (!is_null($literalTime) && is_float($literalTime)) { $time = $literalTime; } array_push($this->store, array( 'data' => $time, 'name' => $name, 'type' => 'speed' )); }
php
public function logSpeed($name = 'Point in Time', $literalTime = null) { $time = microtime(true); if (!is_null($literalTime) && is_float($literalTime)) { $time = $literalTime; } array_push($this->store, array( 'data' => $time, 'name' => $name, 'type' => 'speed' )); }
[ "public", "function", "logSpeed", "(", "$", "name", "=", "'Point in Time'", ",", "$", "literalTime", "=", "null", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", ";", "if", "(", "!", "is_null", "(", "$", "literalTime", ")", "&&", "is_float", "(", "$", "literalTime", ")", ")", "{", "$", "time", "=", "$", "literalTime", ";", "}", "array_push", "(", "$", "this", "->", "store", ",", "array", "(", "'data'", "=>", "$", "time", ",", "'name'", "=>", "$", "name", ",", "'type'", "=>", "'speed'", ")", ")", ";", "}" ]
Logs current time with optional message @param string $name @param float $literalTime
[ "Logs", "current", "time", "with", "optional", "message" ]
08276f050425d1ab71e7ca3b897eb8c409ccbe70
https://github.com/jacobemerick/pqp/blob/08276f050425d1ab71e7ca3b897eb8c409ccbe70/src/Console.php#L88-L100
18,410
Aurora-Framework/Router
src/Router.php
Router.setMatchTypes
public function setMatchTypes($matchTypes) { if (is_array($matchTypes)) { $this->matchTypes = $matchTypes; } else { foreach ( (array) $matchTypes as $key => $matchType) { $this->matchTypes[$key] = $matchType; } } }
php
public function setMatchTypes($matchTypes) { if (is_array($matchTypes)) { $this->matchTypes = $matchTypes; } else { foreach ( (array) $matchTypes as $key => $matchType) { $this->matchTypes[$key] = $matchType; } } }
[ "public", "function", "setMatchTypes", "(", "$", "matchTypes", ")", "{", "if", "(", "is_array", "(", "$", "matchTypes", ")", ")", "{", "$", "this", "->", "matchTypes", "=", "$", "matchTypes", ";", "}", "else", "{", "foreach", "(", "(", "array", ")", "$", "matchTypes", "as", "$", "key", "=>", "$", "matchType", ")", "{", "$", "this", "->", "matchTypes", "[", "$", "key", "]", "=", "$", "matchType", ";", "}", "}", "}" ]
Match types are used to replace given search with replace @param array|string $matchTypes Array containg search and replace
[ "Match", "types", "are", "used", "to", "replace", "given", "search", "with", "replace" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L118-L127
18,411
Aurora-Framework/Router
src/Router.php
Router.mount
public function mount($baseroute, $callable, $extra = []) { $Route = clone $this->Route; $this->Route->addExtra($extra); // Track current baseroute $curBaseroute = $this->baseUri; $this->baseUri .= $baseroute; // Call the callable $callable($this); $this->Route = $Route; // Restore original baseroute $this->baseUri = $curBaseroute; }
php
public function mount($baseroute, $callable, $extra = []) { $Route = clone $this->Route; $this->Route->addExtra($extra); // Track current baseroute $curBaseroute = $this->baseUri; $this->baseUri .= $baseroute; // Call the callable $callable($this); $this->Route = $Route; // Restore original baseroute $this->baseUri = $curBaseroute; }
[ "public", "function", "mount", "(", "$", "baseroute", ",", "$", "callable", ",", "$", "extra", "=", "[", "]", ")", "{", "$", "Route", "=", "clone", "$", "this", "->", "Route", ";", "$", "this", "->", "Route", "->", "addExtra", "(", "$", "extra", ")", ";", "// Track current baseroute", "$", "curBaseroute", "=", "$", "this", "->", "baseUri", ";", "$", "this", "->", "baseUri", ".=", "$", "baseroute", ";", "// Call the callable", "$", "callable", "(", "$", "this", ")", ";", "$", "this", "->", "Route", "=", "$", "Route", ";", "// Restore original baseroute", "$", "this", "->", "baseUri", "=", "$", "curBaseroute", ";", "}" ]
Mount multiple routes via callabck @param string $baseroute Base route for all routes in given callback @param callable $callable Callable to execute
[ "Mount", "multiple", "routes", "via", "callabck" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L232-L247
18,412
Aurora-Framework/Router
src/Router.php
Router.findRequestMethod
public function findRequestMethod() { $method = $_SERVER["REQUEST_METHOD"]; if ($method === "POST") { if (isset($_SERVER["X-HTTP-Method-Override"])) { $method = $_SERVER["X-HTTP-Method-Override"]; } } return $this->method = $method; }
php
public function findRequestMethod() { $method = $_SERVER["REQUEST_METHOD"]; if ($method === "POST") { if (isset($_SERVER["X-HTTP-Method-Override"])) { $method = $_SERVER["X-HTTP-Method-Override"]; } } return $this->method = $method; }
[ "public", "function", "findRequestMethod", "(", ")", "{", "$", "method", "=", "$", "_SERVER", "[", "\"REQUEST_METHOD\"", "]", ";", "if", "(", "$", "method", "===", "\"POST\"", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"X-HTTP-Method-Override\"", "]", ")", ")", "{", "$", "method", "=", "$", "_SERVER", "[", "\"X-HTTP-Method-Override\"", "]", ";", "}", "}", "return", "$", "this", "->", "method", "=", "$", "method", ";", "}" ]
Automatically find the request method @return string Found method
[ "Automatically", "find", "the", "request", "method" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L253-L264
18,413
Aurora-Framework/Router
src/Router.php
Router.findUri
public function findUri() { $uri = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); return ($this->lowerCase) ? strtolower($uri) : $uri; }
php
public function findUri() { $uri = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); return ($this->lowerCase) ? strtolower($uri) : $uri; }
[ "public", "function", "findUri", "(", ")", "{", "$", "uri", "=", "parse_url", "(", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ",", "PHP_URL_PATH", ")", ";", "return", "(", "$", "this", "->", "lowerCase", ")", "?", "strtolower", "(", "$", "uri", ")", ":", "$", "uri", ";", "}" ]
Automatically find the current uri using baseuri @return string Returns found uri
[ "Automatically", "find", "the", "current", "uri", "using", "baseuri" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L296-L301
18,414
Aurora-Framework/Router
src/Router.php
Router.addRoute
public function addRoute($method, $route, $action, $extra = []) { $name = (isset($extra["name"])) ? $extra["name"] : $route; if (isset($this->rawRoutes[$name])) { $Route = $this->rawRoutes[$name]; } else { $Route = clone $this->Route; $Route->route = $this->baseUri.$route; $Route->name = $name; } $Route->addExtra($extra); $methods = []; if ("ANY" === $method) { $methods["GET"] = $action; $methods["POST"] =& $methods["GET"]; $methods["PUT"] =& $methods["GET"]; $Route->methods = $methods; $Route->action = $action; $this->rawRoutes[$name] = $Route; } else { $arrayedMethod = (array) $method; $count = count($arrayedMethod); for ($i = 0; $i < $count; $i++) { if (!isset($this->allowedMethods[$arrayedMethod[$i]])) { throw new InvalidMethodException("Method: " . $arrayedMethod[$i] . " is not valid"); } $method = $arrayedMethod[$i]; $Route->action = $action; $Route->method = $method; $Route->name = $name; $this->rawRoutes[$name] = $Route; } } return $Route; }
php
public function addRoute($method, $route, $action, $extra = []) { $name = (isset($extra["name"])) ? $extra["name"] : $route; if (isset($this->rawRoutes[$name])) { $Route = $this->rawRoutes[$name]; } else { $Route = clone $this->Route; $Route->route = $this->baseUri.$route; $Route->name = $name; } $Route->addExtra($extra); $methods = []; if ("ANY" === $method) { $methods["GET"] = $action; $methods["POST"] =& $methods["GET"]; $methods["PUT"] =& $methods["GET"]; $Route->methods = $methods; $Route->action = $action; $this->rawRoutes[$name] = $Route; } else { $arrayedMethod = (array) $method; $count = count($arrayedMethod); for ($i = 0; $i < $count; $i++) { if (!isset($this->allowedMethods[$arrayedMethod[$i]])) { throw new InvalidMethodException("Method: " . $arrayedMethod[$i] . " is not valid"); } $method = $arrayedMethod[$i]; $Route->action = $action; $Route->method = $method; $Route->name = $name; $this->rawRoutes[$name] = $Route; } } return $Route; }
[ "public", "function", "addRoute", "(", "$", "method", ",", "$", "route", ",", "$", "action", ",", "$", "extra", "=", "[", "]", ")", "{", "$", "name", "=", "(", "isset", "(", "$", "extra", "[", "\"name\"", "]", ")", ")", "?", "$", "extra", "[", "\"name\"", "]", ":", "$", "route", ";", "if", "(", "isset", "(", "$", "this", "->", "rawRoutes", "[", "$", "name", "]", ")", ")", "{", "$", "Route", "=", "$", "this", "->", "rawRoutes", "[", "$", "name", "]", ";", "}", "else", "{", "$", "Route", "=", "clone", "$", "this", "->", "Route", ";", "$", "Route", "->", "route", "=", "$", "this", "->", "baseUri", ".", "$", "route", ";", "$", "Route", "->", "name", "=", "$", "name", ";", "}", "$", "Route", "->", "addExtra", "(", "$", "extra", ")", ";", "$", "methods", "=", "[", "]", ";", "if", "(", "\"ANY\"", "===", "$", "method", ")", "{", "$", "methods", "[", "\"GET\"", "]", "=", "$", "action", ";", "$", "methods", "[", "\"POST\"", "]", "=", "&", "$", "methods", "[", "\"GET\"", "]", ";", "$", "methods", "[", "\"PUT\"", "]", "=", "&", "$", "methods", "[", "\"GET\"", "]", ";", "$", "Route", "->", "methods", "=", "$", "methods", ";", "$", "Route", "->", "action", "=", "$", "action", ";", "$", "this", "->", "rawRoutes", "[", "$", "name", "]", "=", "$", "Route", ";", "}", "else", "{", "$", "arrayedMethod", "=", "(", "array", ")", "$", "method", ";", "$", "count", "=", "count", "(", "$", "arrayedMethod", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "allowedMethods", "[", "$", "arrayedMethod", "[", "$", "i", "]", "]", ")", ")", "{", "throw", "new", "InvalidMethodException", "(", "\"Method: \"", ".", "$", "arrayedMethod", "[", "$", "i", "]", ".", "\" is not valid\"", ")", ";", "}", "$", "method", "=", "$", "arrayedMethod", "[", "$", "i", "]", ";", "$", "Route", "->", "action", "=", "$", "action", ";", "$", "Route", "->", "method", "=", "$", "method", ";", "$", "Route", "->", "name", "=", "$", "name", ";", "$", "this", "->", "rawRoutes", "[", "$", "name", "]", "=", "$", "Route", ";", "}", "}", "return", "$", "Route", ";", "}" ]
Add new route to list of available routes @param $method @param $route @param $action @throws InvalidMethodException
[ "Add", "new", "route", "to", "list", "of", "available", "routes" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L312-L354
18,415
Aurora-Framework/Router
src/Router.php
Router.getMatchType
public function getMatchType($type, $default = null) { if (isset($this->matchTypes[$type])) { return $this->matchTypes[$type]; } else if ($default !== null) { return $default; } else { throw new MatchTypeNotFoundExeption("Unknow match type"); } }
php
public function getMatchType($type, $default = null) { if (isset($this->matchTypes[$type])) { return $this->matchTypes[$type]; } else if ($default !== null) { return $default; } else { throw new MatchTypeNotFoundExeption("Unknow match type"); } }
[ "public", "function", "getMatchType", "(", "$", "type", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "matchTypes", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "matchTypes", "[", "$", "type", "]", ";", "}", "else", "if", "(", "$", "default", "!==", "null", ")", "{", "return", "$", "default", ";", "}", "else", "{", "throw", "new", "MatchTypeNotFoundExeption", "(", "\"Unknow match type\"", ")", ";", "}", "}" ]
Return regex if type is defined otherwise, returns default value. @method getMatchType @throws MatchTypeNotFoundExeption If regex of type wasn"t found @param string $type Type of allowed regex @param string $default Default return value if type is not found @return string Found Regex
[ "Return", "regex", "if", "type", "is", "defined", "otherwise", "returns", "default", "value", "." ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L474-L483
18,416
Aurora-Framework/Router
src/Router.php
Router.normalize
public function normalize($route) { //make sure that all urls have the same structure /* Fix trailling shash */ if (mb_substr($route, -1, 1) == "/") { $route = substr($route, 0, -1); } $result = explode("/", $route); $result[0] = $this->baseUri; $ret = []; //check for dynamic and optional parameters foreach ($result as $v) { if (!$v) { continue; } if (($v[0]) === "?{") { $ret[] = [ "name" => explode("?}", mb_substr($v, 1))[0], "use" => "?" ]; } else if (($v[0]) === "{") { $ret[] = [ "name" => explode("}", mb_substr($v, 1))[0], "use" => "*" ]; } else { $ret[] = [ "name" => $v, "use" => $v ]; } } return $ret; }
php
public function normalize($route) { //make sure that all urls have the same structure /* Fix trailling shash */ if (mb_substr($route, -1, 1) == "/") { $route = substr($route, 0, -1); } $result = explode("/", $route); $result[0] = $this->baseUri; $ret = []; //check for dynamic and optional parameters foreach ($result as $v) { if (!$v) { continue; } if (($v[0]) === "?{") { $ret[] = [ "name" => explode("?}", mb_substr($v, 1))[0], "use" => "?" ]; } else if (($v[0]) === "{") { $ret[] = [ "name" => explode("}", mb_substr($v, 1))[0], "use" => "*" ]; } else { $ret[] = [ "name" => $v, "use" => $v ]; } } return $ret; }
[ "public", "function", "normalize", "(", "$", "route", ")", "{", "//make sure that all urls have the same structure", "/* Fix trailling shash */", "if", "(", "mb_substr", "(", "$", "route", ",", "-", "1", ",", "1", ")", "==", "\"/\"", ")", "{", "$", "route", "=", "substr", "(", "$", "route", ",", "0", ",", "-", "1", ")", ";", "}", "$", "result", "=", "explode", "(", "\"/\"", ",", "$", "route", ")", ";", "$", "result", "[", "0", "]", "=", "$", "this", "->", "baseUri", ";", "$", "ret", "=", "[", "]", ";", "//check for dynamic and optional parameters", "foreach", "(", "$", "result", "as", "$", "v", ")", "{", "if", "(", "!", "$", "v", ")", "{", "continue", ";", "}", "if", "(", "(", "$", "v", "[", "0", "]", ")", "===", "\"?{\"", ")", "{", "$", "ret", "[", "]", "=", "[", "\"name\"", "=>", "explode", "(", "\"?}\"", ",", "mb_substr", "(", "$", "v", ",", "1", ")", ")", "[", "0", "]", ",", "\"use\"", "=>", "\"?\"", "]", ";", "}", "else", "if", "(", "(", "$", "v", "[", "0", "]", ")", "===", "\"{\"", ")", "{", "$", "ret", "[", "]", "=", "[", "\"name\"", "=>", "explode", "(", "\"}\"", ",", "mb_substr", "(", "$", "v", ",", "1", ")", ")", "[", "0", "]", ",", "\"use\"", "=>", "\"*\"", "]", ";", "}", "else", "{", "$", "ret", "[", "]", "=", "[", "\"name\"", "=>", "$", "v", ",", "\"use\"", "=>", "$", "v", "]", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Normalize route structure and extract dynamic and optional parts @param $route @return array
[ "Normalize", "route", "structure", "and", "extract", "dynamic", "and", "optional", "parts" ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L514-L551
18,417
Aurora-Framework/Router
src/Router.php
Router.parseRoutes
protected function parseRoutes($routes) { $tree = []; foreach ($routes as $Route) { $node = &$tree; $routeSegments = $this->normalize($Route->route); foreach ($routeSegments as $segment) { if (!isset($node[$segment["use"]])) { $node[$segment["use"]] = [ "name" => $segment["name"], "routeName" => $Route->name ]; } $node = &$node[$segment["use"]]; } $Route->segments = $routeSegments; //node exec can exists only if a route is already added. //This happens when a route is added more than once with different methods. $node["exec"]["method"][$Route->method] = $Route; } return $tree; }
php
protected function parseRoutes($routes) { $tree = []; foreach ($routes as $Route) { $node = &$tree; $routeSegments = $this->normalize($Route->route); foreach ($routeSegments as $segment) { if (!isset($node[$segment["use"]])) { $node[$segment["use"]] = [ "name" => $segment["name"], "routeName" => $Route->name ]; } $node = &$node[$segment["use"]]; } $Route->segments = $routeSegments; //node exec can exists only if a route is already added. //This happens when a route is added more than once with different methods. $node["exec"]["method"][$Route->method] = $Route; } return $tree; }
[ "protected", "function", "parseRoutes", "(", "$", "routes", ")", "{", "$", "tree", "=", "[", "]", ";", "foreach", "(", "$", "routes", "as", "$", "Route", ")", "{", "$", "node", "=", "&", "$", "tree", ";", "$", "routeSegments", "=", "$", "this", "->", "normalize", "(", "$", "Route", "->", "route", ")", ";", "foreach", "(", "$", "routeSegments", "as", "$", "segment", ")", "{", "if", "(", "!", "isset", "(", "$", "node", "[", "$", "segment", "[", "\"use\"", "]", "]", ")", ")", "{", "$", "node", "[", "$", "segment", "[", "\"use\"", "]", "]", "=", "[", "\"name\"", "=>", "$", "segment", "[", "\"name\"", "]", ",", "\"routeName\"", "=>", "$", "Route", "->", "name", "]", ";", "}", "$", "node", "=", "&", "$", "node", "[", "$", "segment", "[", "\"use\"", "]", "]", ";", "}", "$", "Route", "->", "segments", "=", "$", "routeSegments", ";", "//node exec can exists only if a route is already added.", "//This happens when a route is added more than once with different methods.", "$", "node", "[", "\"exec\"", "]", "[", "\"method\"", "]", "[", "$", "Route", "->", "method", "]", "=", "$", "Route", ";", "}", "return", "$", "tree", ";", "}" ]
Build tree structure from all routes. @param $routes @return array
[ "Build", "tree", "structure", "from", "all", "routes", "." ]
2731e9185a681db286cfa7da3bf1dda4db4c3685
https://github.com/Aurora-Framework/Router/blob/2731e9185a681db286cfa7da3bf1dda4db4c3685/src/Router.php#L559-L583
18,418
bpolaszek/where
src/InsertQuery/InsertQueryBuilder.php
InsertQueryBuilder.split
public function split(int $max): iterable { $pos = 0; $total = count($this->values); while ($pos < $total) { $clone = clone $this; $clone->values = array_slice($this->values, $pos, $max); $pos += $max; yield $clone; } }
php
public function split(int $max): iterable { $pos = 0; $total = count($this->values); while ($pos < $total) { $clone = clone $this; $clone->values = array_slice($this->values, $pos, $max); $pos += $max; yield $clone; } }
[ "public", "function", "split", "(", "int", "$", "max", ")", ":", "iterable", "{", "$", "pos", "=", "0", ";", "$", "total", "=", "count", "(", "$", "this", "->", "values", ")", ";", "while", "(", "$", "pos", "<", "$", "total", ")", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "values", "=", "array_slice", "(", "$", "this", "->", "values", ",", "$", "pos", ",", "$", "max", ")", ";", "$", "pos", "+=", "$", "max", ";", "yield", "$", "clone", ";", "}", "}" ]
Split into multiple INSERT statements. @param int $max @return iterable|self[]
[ "Split", "into", "multiple", "INSERT", "statements", "." ]
f40c6a97bca831c633ee3b87e2c7e3591af4fdff
https://github.com/bpolaszek/where/blob/f40c6a97bca831c633ee3b87e2c7e3591af4fdff/src/InsertQuery/InsertQueryBuilder.php#L233-L243
18,419
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.save
function save() { if (!$this->blnChanged) { return; } $flags = JSON_PRETTY_PRINT; $strContent = json_encode($this->options, $flags); file_put_contents(__CODEGEN_OPTION_FILE__, $strContent); $this->blnChanged = false; }
php
function save() { if (!$this->blnChanged) { return; } $flags = JSON_PRETTY_PRINT; $strContent = json_encode($this->options, $flags); file_put_contents(__CODEGEN_OPTION_FILE__, $strContent); $this->blnChanged = false; }
[ "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "blnChanged", ")", "{", "return", ";", "}", "$", "flags", "=", "JSON_PRETTY_PRINT", ";", "$", "strContent", "=", "json_encode", "(", "$", "this", "->", "options", ",", "$", "flags", ")", ";", "file_put_contents", "(", "__CODEGEN_OPTION_FILE__", ",", "$", "strContent", ")", ";", "$", "this", "->", "blnChanged", "=", "false", ";", "}" ]
Save the current configuration into the options file.
[ "Save", "the", "current", "configuration", "into", "the", "options", "file", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L65-L75
18,420
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.setOption
public function setOption($strTableName, $strFieldName, $strOptionName, $mixValue) { $this->options[$strTableName][$strFieldName][$strOptionName] = $mixValue; $this->blnChanged = true; }
php
public function setOption($strTableName, $strFieldName, $strOptionName, $mixValue) { $this->options[$strTableName][$strFieldName][$strOptionName] = $mixValue; $this->blnChanged = true; }
[ "public", "function", "setOption", "(", "$", "strTableName", ",", "$", "strFieldName", ",", "$", "strOptionName", ",", "$", "mixValue", ")", "{", "$", "this", "->", "options", "[", "$", "strTableName", "]", "[", "$", "strFieldName", "]", "[", "$", "strOptionName", "]", "=", "$", "mixValue", ";", "$", "this", "->", "blnChanged", "=", "true", ";", "}" ]
Set an option for a widget associated with the given table and field. @param $strTableName @param $strFieldName @param $strOptionName @param $mixValue
[ "Set", "an", "option", "for", "a", "widget", "associated", "with", "the", "given", "table", "and", "field", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L94-L98
18,421
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.setOptions
public function setOptions($strClassName, $strFieldName, $mixValue) { if (empty ($mixValue)) { unset($this->options[$strClassName][$strFieldName]); } else { $this->options[$strClassName][$strFieldName] = $mixValue; } $this->blnChanged = true; }
php
public function setOptions($strClassName, $strFieldName, $mixValue) { if (empty ($mixValue)) { unset($this->options[$strClassName][$strFieldName]); } else { $this->options[$strClassName][$strFieldName] = $mixValue; } $this->blnChanged = true; }
[ "public", "function", "setOptions", "(", "$", "strClassName", ",", "$", "strFieldName", ",", "$", "mixValue", ")", "{", "if", "(", "empty", "(", "$", "mixValue", ")", ")", "{", "unset", "(", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", ")", ";", "}", "else", "{", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", "=", "$", "mixValue", ";", "}", "$", "this", "->", "blnChanged", "=", "true", ";", "}" ]
Bulk option setting. @param $strClassName @param $strFieldName @param $mixValue
[ "Bulk", "option", "setting", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L107-L115
18,422
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.unsetOption
public function unsetOption($strClassName, $strFieldName, $strOptionName) { unset ($this->options[$strClassName][$strFieldName][$strOptionName]); $this->blnChanged = true; }
php
public function unsetOption($strClassName, $strFieldName, $strOptionName) { unset ($this->options[$strClassName][$strFieldName][$strOptionName]); $this->blnChanged = true; }
[ "public", "function", "unsetOption", "(", "$", "strClassName", ",", "$", "strFieldName", ",", "$", "strOptionName", ")", "{", "unset", "(", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", "[", "$", "strOptionName", "]", ")", ";", "$", "this", "->", "blnChanged", "=", "true", ";", "}" ]
Remove the option @param $strClassName @param $strFieldName @param $strOptionName
[ "Remove", "the", "option" ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L124-L128
18,423
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.getOption
public function getOption($strClassName, $strFieldName, $strOptionName) { if (isset ($this->options[$strClassName][$strFieldName][$strOptionName])) { return $this->options[$strClassName][$strFieldName][$strOptionName]; } else { return null; } }
php
public function getOption($strClassName, $strFieldName, $strOptionName) { if (isset ($this->options[$strClassName][$strFieldName][$strOptionName])) { return $this->options[$strClassName][$strFieldName][$strOptionName]; } else { return null; } }
[ "public", "function", "getOption", "(", "$", "strClassName", ",", "$", "strFieldName", ",", "$", "strOptionName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", "[", "$", "strOptionName", "]", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", "[", "$", "strOptionName", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Lookup an option. @param $strClassName @param $strFieldName @param $strOptionName @return mixed
[ "Lookup", "an", "option", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L138-L145
18,424
qcubed/orm
src/Codegen/OptionFile.php
OptionFile.getOptions
public function getOptions($strClassName, $strFieldName) { if (isset($this->options[$strClassName][$strFieldName])) { return $this->options[$strClassName][$strFieldName]; } else { return array(); } }
php
public function getOptions($strClassName, $strFieldName) { if (isset($this->options[$strClassName][$strFieldName])) { return $this->options[$strClassName][$strFieldName]; } else { return array(); } }
[ "public", "function", "getOptions", "(", "$", "strClassName", ",", "$", "strFieldName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "strClassName", "]", "[", "$", "strFieldName", "]", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Return all the options associated with the given table and field. @param $strClassName @param $strFieldName @return mixed
[ "Return", "all", "the", "options", "associated", "with", "the", "given", "table", "and", "field", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/OptionFile.php#L153-L160
18,425
mle86/php-wq
src/WQ/Job/AbstractJob.php
AbstractJob.serialize
public function serialize() { $raw = []; foreach ($this->listProperties() as $propName) { $raw[$propName] = $this->{$propName}; } $raw['_try_index'] = $this->_try_index + 1; // ! return serialize($raw); }
php
public function serialize() { $raw = []; foreach ($this->listProperties() as $propName) { $raw[$propName] = $this->{$propName}; } $raw['_try_index'] = $this->_try_index + 1; // ! return serialize($raw); }
[ "public", "function", "serialize", "(", ")", "{", "$", "raw", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "listProperties", "(", ")", "as", "$", "propName", ")", "{", "$", "raw", "[", "$", "propName", "]", "=", "$", "this", "->", "{", "$", "propName", "}", ";", "}", "$", "raw", "[", "'_try_index'", "]", "=", "$", "this", "->", "_try_index", "+", "1", ";", "// !", "return", "serialize", "(", "$", "raw", ")", ";", "}" ]
This default implementation stores all public and protected properties. Override this method if that's not enough or if you want to do some additional pre-serialize processing, but don't forget to include <tt>{@see $_try_index}+1</tt> in the serialization!
[ "This", "default", "implementation", "stores", "all", "public", "and", "protected", "properties", "." ]
e1ca1dcfd3d40edb0085f6dfa83d90db74253de4
https://github.com/mle86/php-wq/blob/e1ca1dcfd3d40edb0085f6dfa83d90db74253de4/src/WQ/Job/AbstractJob.php#L64-L72
18,426
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.getFolderChildrens
public function getFolderChildrens(array $input) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $file = $this->File->byId($input['id']); $fileTree = array('text' => $file->name, 'state' => array('opened' => true) , 'icon' => $file->icon, 'children' => array()); $this->File->byParentId($input['id'], $organizationId)->each(function($file) use (&$fileTree) { if($file->type == 'C') { array_push($fileTree['children'], array('text' => $file->name, 'icon' => $file->icon)); } else { array_push($fileTree['children'], array('text' => $file->name, 'icon' => $file->icon)); } }); //return json_encode(array('fileTree' => $FileTree, 'balanceTypeName' => $this->Lang->get('decima-Fileing::File-management.' . $File->balance_type), 'balanceTypeValue' => $File->balance_type, 'FileTypeName' => $FileType->name, 'FileTypeValue' => $File->File_type_id)); return json_encode(array('fileTree' => $fileTree)); }
php
public function getFolderChildrens(array $input) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id'); $file = $this->File->byId($input['id']); $fileTree = array('text' => $file->name, 'state' => array('opened' => true) , 'icon' => $file->icon, 'children' => array()); $this->File->byParentId($input['id'], $organizationId)->each(function($file) use (&$fileTree) { if($file->type == 'C') { array_push($fileTree['children'], array('text' => $file->name, 'icon' => $file->icon)); } else { array_push($fileTree['children'], array('text' => $file->name, 'icon' => $file->icon)); } }); //return json_encode(array('fileTree' => $FileTree, 'balanceTypeName' => $this->Lang->get('decima-Fileing::File-management.' . $File->balance_type), 'balanceTypeValue' => $File->balance_type, 'FileTypeName' => $FileType->name, 'FileTypeValue' => $File->File_type_id)); return json_encode(array('fileTree' => $fileTree)); }
[ "public", "function", "getFolderChildrens", "(", "array", "$", "input", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganization", "(", "'id'", ")", ";", "$", "file", "=", "$", "this", "->", "File", "->", "byId", "(", "$", "input", "[", "'id'", "]", ")", ";", "$", "fileTree", "=", "array", "(", "'text'", "=>", "$", "file", "->", "name", ",", "'state'", "=>", "array", "(", "'opened'", "=>", "true", ")", ",", "'icon'", "=>", "$", "file", "->", "icon", ",", "'children'", "=>", "array", "(", ")", ")", ";", "$", "this", "->", "File", "->", "byParentId", "(", "$", "input", "[", "'id'", "]", ",", "$", "organizationId", ")", "->", "each", "(", "function", "(", "$", "file", ")", "use", "(", "&", "$", "fileTree", ")", "{", "if", "(", "$", "file", "->", "type", "==", "'C'", ")", "{", "array_push", "(", "$", "fileTree", "[", "'children'", "]", ",", "array", "(", "'text'", "=>", "$", "file", "->", "name", ",", "'icon'", "=>", "$", "file", "->", "icon", ")", ")", ";", "}", "else", "{", "array_push", "(", "$", "fileTree", "[", "'children'", "]", ",", "array", "(", "'text'", "=>", "$", "file", "->", "name", ",", "'icon'", "=>", "$", "file", "->", "icon", ")", ")", ";", "}", "}", ")", ";", "//return json_encode(array('fileTree' => $FileTree, 'balanceTypeName' => $this->Lang->get('decima-Fileing::File-management.' . $File->balance_type), 'balanceTypeValue' => $File->balance_type, 'FileTypeName' => $FileType->name, 'FileTypeValue' => $File->File_type_id));", "return", "json_encode", "(", "array", "(", "'fileTree'", "=>", "$", "fileTree", ")", ")", ";", "}" ]
Get Files children @param array $input An array as follows: array(id => $id); @return JSON encoded string A string as follows: [{"text" : $FileKey . " " . $accountName, "state" : {"opened" : true }, "icon" : $icon, "children" : [{"text" : $childAccountKey0 . " " . $childAccountName0, "icon" : $childIcon0}, …]}]
[ "Get", "Files", "children" ]
94c26ab40f5c4dd12e913e73376c24db27588f0b
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L361-L379
18,427
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.getElementFiles
public function getElementFiles(array $systemReferences, $formatAsHtml = true, $databaseConnectionName = null, $organizationId = null) { $files = array(); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } foreach ($systemReferences as $systemReference) { $this->File->bySystemReferenceTypeBySystemReferenceIdAndByOrganization($this->journalConfigurations[$systemReference['appId']]['journalizedType'][0], $systemReference['systemReferenceId'], $organizationId, $databaseConnectionName)->each(function($File) use (&$files) { // array_push($files, array('id' => $File->id, 'name' => $File->name, 'size' => $this->Storage->size($File->system_route), 'url' => $File->url, 'icon' => str_replace('font-size: 2em;', '', $File->icon_html))); array_push($files, array('id' => $File->id, 'name' => $File->name, 'size' => 0, 'url' => $File->url, 'icon' => str_replace('font-size: 2em;', '', $File->icon_html))); }); } return json_encode($files); }
php
public function getElementFiles(array $systemReferences, $formatAsHtml = true, $databaseConnectionName = null, $organizationId = null) { $files = array(); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } foreach ($systemReferences as $systemReference) { $this->File->bySystemReferenceTypeBySystemReferenceIdAndByOrganization($this->journalConfigurations[$systemReference['appId']]['journalizedType'][0], $systemReference['systemReferenceId'], $organizationId, $databaseConnectionName)->each(function($File) use (&$files) { // array_push($files, array('id' => $File->id, 'name' => $File->name, 'size' => $this->Storage->size($File->system_route), 'url' => $File->url, 'icon' => str_replace('font-size: 2em;', '', $File->icon_html))); array_push($files, array('id' => $File->id, 'name' => $File->name, 'size' => 0, 'url' => $File->url, 'icon' => str_replace('font-size: 2em;', '', $File->icon_html))); }); } return json_encode($files); }
[ "public", "function", "getElementFiles", "(", "array", "$", "systemReferences", ",", "$", "formatAsHtml", "=", "true", ",", "$", "databaseConnectionName", "=", "null", ",", "$", "organizationId", "=", "null", ")", "{", "$", "files", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganizationId", "(", ")", ";", "}", "foreach", "(", "$", "systemReferences", "as", "$", "systemReference", ")", "{", "$", "this", "->", "File", "->", "bySystemReferenceTypeBySystemReferenceIdAndByOrganization", "(", "$", "this", "->", "journalConfigurations", "[", "$", "systemReference", "[", "'appId'", "]", "]", "[", "'journalizedType'", "]", "[", "0", "]", ",", "$", "systemReference", "[", "'systemReferenceId'", "]", ",", "$", "organizationId", ",", "$", "databaseConnectionName", ")", "->", "each", "(", "function", "(", "$", "File", ")", "use", "(", "&", "$", "files", ")", "{", "// array_push($files, array('id' => $File->id, 'name' => $File->name, 'size' => $this->Storage->size($File->system_route), 'url' => $File->url, 'icon' => str_replace('font-size: 2em;', '', $File->icon_html)));", "array_push", "(", "$", "files", ",", "array", "(", "'id'", "=>", "$", "File", "->", "id", ",", "'name'", "=>", "$", "File", "->", "name", ",", "'size'", "=>", "0", ",", "'url'", "=>", "$", "File", "->", "url", ",", "'icon'", "=>", "str_replace", "(", "'font-size: 2em;'", ",", "''", ",", "$", "File", "->", "icon_html", ")", ")", ")", ";", "}", ")", ";", "}", "return", "json_encode", "(", "$", "files", ")", ";", "}" ]
Get element files by system parent type and by system parent id @param array $systemReferences An array of array as follows: array(array(appId => $appId, systemReferenceId = $systemReferenceId), array(appId => $appId, systemReferenceId = $systemReferenceId)); @param boolean $formatAsHtml @return mixed $files An ..
[ "Get", "element", "files", "by", "system", "parent", "type", "and", "by", "system", "parent", "id" ]
94c26ab40f5c4dd12e913e73376c24db27588f0b
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L391-L410
18,428
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.getLocalFilePath
public function getLocalFilePath($filename, $route, &$isTempFile, $includeStoragePath = false) { $isTempFile = false; if($this->Config->get('filesystems.default') == 'gcs') { $isTempFile = true; $this->Storage->disk('local')->put('//temp/' . $filename, $this->Storage->read($route)); $route = 'temp/' . $filename; } if($includeStoragePath) { return storage_path('app') . '/' . $route; } return $route; }
php
public function getLocalFilePath($filename, $route, &$isTempFile, $includeStoragePath = false) { $isTempFile = false; if($this->Config->get('filesystems.default') == 'gcs') { $isTempFile = true; $this->Storage->disk('local')->put('//temp/' . $filename, $this->Storage->read($route)); $route = 'temp/' . $filename; } if($includeStoragePath) { return storage_path('app') . '/' . $route; } return $route; }
[ "public", "function", "getLocalFilePath", "(", "$", "filename", ",", "$", "route", ",", "&", "$", "isTempFile", ",", "$", "includeStoragePath", "=", "false", ")", "{", "$", "isTempFile", "=", "false", ";", "if", "(", "$", "this", "->", "Config", "->", "get", "(", "'filesystems.default'", ")", "==", "'gcs'", ")", "{", "$", "isTempFile", "=", "true", ";", "$", "this", "->", "Storage", "->", "disk", "(", "'local'", ")", "->", "put", "(", "'//temp/'", ".", "$", "filename", ",", "$", "this", "->", "Storage", "->", "read", "(", "$", "route", ")", ")", ";", "$", "route", "=", "'temp/'", ".", "$", "filename", ";", "}", "if", "(", "$", "includeStoragePath", ")", "{", "return", "storage_path", "(", "'app'", ")", ".", "'/'", ".", "$", "route", ";", "}", "return", "$", "route", ";", "}" ]
Get local file path @param string $filename @param string $route @param boolean $isTempFile @param string $key @return Response
[ "Get", "local", "file", "path" ]
94c26ab40f5c4dd12e913e73376c24db27588f0b
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L423-L442
18,429
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.servePrivateFile
public function servePrivateFile($key) { $File = $this->File->byKeyAndPublic($key , false)->first(); if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
php
public function servePrivateFile($key) { $File = $this->File->byKeyAndPublic($key , false)->first(); if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
[ "public", "function", "servePrivateFile", "(", "$", "key", ")", "{", "$", "File", "=", "$", "this", "->", "File", "->", "byKeyAndPublic", "(", "$", "key", ",", "false", ")", "->", "first", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "File", ")", ")", "{", "return", "$", "this", "->", "serveFile", "(", "$", "File", "->", "system_type", ",", "$", "File", "->", "system_route", ",", "$", "File", "->", "name", ")", ";", "}", "return", "$", "this", "->", "Redirector", "->", "to", "(", "$", "this", "->", "AppManager", "->", "getErrorPageUrl", "(", ")", ")", "->", "withError", "(", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.fileNotFound'", ")", ")", ";", "}" ]
Serve private file @param string $key @return Response
[ "Serve", "private", "file" ]
94c26ab40f5c4dd12e913e73376c24db27588f0b
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L1093-L1103
18,430
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.connect
public function connect() { if ($this->isConnected()) { return true; } // @codeCoverageIgnoreStart if (!$this->isEnabled()) { throw new MissingDriverException(sprintf('%s driver extension is not enabled', $this->getDriver())); } // @codeCoverageIgnoreEnd $this->_connections[$this->getContext()] = new PDO($this->getDsn(), $this->getUser(), $this->getPassword(), $this->getConfig('flags') + [ PDO::ATTR_PERSISTENT => $this->isPersistent(), PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); return true; }
php
public function connect() { if ($this->isConnected()) { return true; } // @codeCoverageIgnoreStart if (!$this->isEnabled()) { throw new MissingDriverException(sprintf('%s driver extension is not enabled', $this->getDriver())); } // @codeCoverageIgnoreEnd $this->_connections[$this->getContext()] = new PDO($this->getDsn(), $this->getUser(), $this->getPassword(), $this->getConfig('flags') + [ PDO::ATTR_PERSISTENT => $this->isPersistent(), PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); return true; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "true", ";", "}", "// @codeCoverageIgnoreStart", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "throw", "new", "MissingDriverException", "(", "sprintf", "(", "'%s driver extension is not enabled'", ",", "$", "this", "->", "getDriver", "(", ")", ")", ")", ";", "}", "// @codeCoverageIgnoreEnd", "$", "this", "->", "_connections", "[", "$", "this", "->", "getContext", "(", ")", "]", "=", "new", "PDO", "(", "$", "this", "->", "getDsn", "(", ")", ",", "$", "this", "->", "getUser", "(", ")", ",", "$", "this", "->", "getPassword", "(", ")", ",", "$", "this", "->", "getConfig", "(", "'flags'", ")", "+", "[", "PDO", "::", "ATTR_PERSISTENT", "=>", "$", "this", "->", "isPersistent", "(", ")", ",", "PDO", "::", "ATTR_ERRMODE", "=>", "PDO", "::", "ERRMODE_EXCEPTION", "]", ")", ";", "return", "true", ";", "}" ]
Connect to the database using PDO. @return bool @throws \Titon\Db\Exception\MissingDriverException
[ "Connect", "to", "the", "database", "using", "PDO", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L72-L89
18,431
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveBind
public function resolveBind($field, $value, array $schema = []) { $type = null; // Exit early for functions since we don't have a valid field if ($field instanceof Func) { return [$value, $this->resolveType($value)]; } // Use the raw value for binding if ($value instanceof RawExpr) { $value = $value->getValue(); } // Type cast if ($value === null) { $type = PDO::PARAM_NULL; } else if (isset($schema[$field]['type'])) { $dataType = $this->getType($schema[$field]['type']); $value = $dataType->to($value); $type = $dataType->getBindingType(); } // Fallback and resolve if (!$type) { $type = $this->resolveType($value); } return [$value, $type]; }
php
public function resolveBind($field, $value, array $schema = []) { $type = null; // Exit early for functions since we don't have a valid field if ($field instanceof Func) { return [$value, $this->resolveType($value)]; } // Use the raw value for binding if ($value instanceof RawExpr) { $value = $value->getValue(); } // Type cast if ($value === null) { $type = PDO::PARAM_NULL; } else if (isset($schema[$field]['type'])) { $dataType = $this->getType($schema[$field]['type']); $value = $dataType->to($value); $type = $dataType->getBindingType(); } // Fallback and resolve if (!$type) { $type = $this->resolveType($value); } return [$value, $type]; }
[ "public", "function", "resolveBind", "(", "$", "field", ",", "$", "value", ",", "array", "$", "schema", "=", "[", "]", ")", "{", "$", "type", "=", "null", ";", "// Exit early for functions since we don't have a valid field", "if", "(", "$", "field", "instanceof", "Func", ")", "{", "return", "[", "$", "value", ",", "$", "this", "->", "resolveType", "(", "$", "value", ")", "]", ";", "}", "// Use the raw value for binding", "if", "(", "$", "value", "instanceof", "RawExpr", ")", "{", "$", "value", "=", "$", "value", "->", "getValue", "(", ")", ";", "}", "// Type cast", "if", "(", "$", "value", "===", "null", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_NULL", ";", "}", "else", "if", "(", "isset", "(", "$", "schema", "[", "$", "field", "]", "[", "'type'", "]", ")", ")", "{", "$", "dataType", "=", "$", "this", "->", "getType", "(", "$", "schema", "[", "$", "field", "]", "[", "'type'", "]", ")", ";", "$", "value", "=", "$", "dataType", "->", "to", "(", "$", "value", ")", ";", "$", "type", "=", "$", "dataType", "->", "getBindingType", "(", ")", ";", "}", "// Fallback and resolve", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "resolveType", "(", "$", "value", ")", ";", "}", "return", "[", "$", "value", ",", "$", "type", "]", ";", "}" ]
Resolve the bind value and the PDO binding type. @param string $field @param mixed $value @param array $schema @return array
[ "Resolve", "the", "bind", "value", "and", "the", "PDO", "binding", "type", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L334-L363
18,432
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveParams
public function resolveParams(Query $query) { $params = []; $schema = $query->getRepository()->getSchema()->getColumns(); foreach ($query->getGroupedBindings() as $groupedBinds) { foreach ($groupedBinds as $binds) { $params[] = $this->resolveBind($binds['field'], $binds['value'], $schema); } } foreach ($query->getCompounds() as $compound) { $params = array_merge($params, $this->resolveParams($compound)); } return $params; }
php
public function resolveParams(Query $query) { $params = []; $schema = $query->getRepository()->getSchema()->getColumns(); foreach ($query->getGroupedBindings() as $groupedBinds) { foreach ($groupedBinds as $binds) { $params[] = $this->resolveBind($binds['field'], $binds['value'], $schema); } } foreach ($query->getCompounds() as $compound) { $params = array_merge($params, $this->resolveParams($compound)); } return $params; }
[ "public", "function", "resolveParams", "(", "Query", "$", "query", ")", "{", "$", "params", "=", "[", "]", ";", "$", "schema", "=", "$", "query", "->", "getRepository", "(", ")", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ";", "foreach", "(", "$", "query", "->", "getGroupedBindings", "(", ")", "as", "$", "groupedBinds", ")", "{", "foreach", "(", "$", "groupedBinds", "as", "$", "binds", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "resolveBind", "(", "$", "binds", "[", "'field'", "]", ",", "$", "binds", "[", "'value'", "]", ",", "$", "schema", ")", ";", "}", "}", "foreach", "(", "$", "query", "->", "getCompounds", "(", ")", "as", "$", "compound", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "resolveParams", "(", "$", "compound", ")", ")", ";", "}", "return", "$", "params", ";", "}" ]
Resolve the list of values that will be required for PDO statement binding. @param \Titon\Db\Query $query @return array
[ "Resolve", "the", "list", "of", "values", "that", "will", "be", "required", "for", "PDO", "statement", "binding", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L371-L386
18,433
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveType
public function resolveType($value) { if ($value === null) { $type = PDO::PARAM_NULL; } else if (is_resource($value)) { $type = PDO::PARAM_LOB; } else if (is_numeric($value)) { if (is_float($value) || is_double($value)) { $type = PDO::PARAM_STR; // Uses string type } else { $type = PDO::PARAM_INT; } } else if (is_bool($value)) { $type = PDO::PARAM_BOOL; } else { $type = PDO::PARAM_STR; } return $type; }
php
public function resolveType($value) { if ($value === null) { $type = PDO::PARAM_NULL; } else if (is_resource($value)) { $type = PDO::PARAM_LOB; } else if (is_numeric($value)) { if (is_float($value) || is_double($value)) { $type = PDO::PARAM_STR; // Uses string type } else { $type = PDO::PARAM_INT; } } else if (is_bool($value)) { $type = PDO::PARAM_BOOL; } else { $type = PDO::PARAM_STR; } return $type; }
[ "public", "function", "resolveType", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_NULL", ";", "}", "else", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_LOB", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "if", "(", "is_float", "(", "$", "value", ")", "||", "is_double", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_STR", ";", "// Uses string type", "}", "else", "{", "$", "type", "=", "PDO", "::", "PARAM_INT", ";", "}", "}", "else", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_BOOL", ";", "}", "else", "{", "$", "type", "=", "PDO", "::", "PARAM_STR", ";", "}", "return", "$", "type", ";", "}" ]
Resolve the value type for PDO parameter binding and quoting. @param mixed $value @return int
[ "Resolve", "the", "value", "type", "for", "PDO", "parameter", "binding", "and", "quoting", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L394-L417
18,434
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.parse
public static function parse( $cmd ) { // if we dont have an command if ( empty( $cmd ) ) { return false; } $params = array(); // are we in a string $in_string = false; $len = strlen( $cmd ); $crr_prm = ""; $command_str = $cmd; $cmd = array(); // loop trough for( $i=0;$len>$i;$i++ ) { $char = $command_str[$i]; switch( $char ) { case ' ': if ( !$in_string ) { $cmd[] = $crr_prm; $crr_prm = ''; } else { $crr_prm .= $char; } break; case '"': if( $i > 0 && $command_str[$c-1] != '\\' ) { $in_string = !$in_string; } break; default: $crr_prm .= $char; break; } } $cmd[] = $crr_prm; // get the controller $controller = array_shift( $cmd ); // get the action $action = null; // check we got an action in our controller if ( strpos( $controller, '::' ) !== false ) { $controller = explode( '::', $controller ); $action = $controller[1]; $controller = $controller[0]; } // skipper if we got an named param skip the next $skip = false; // get the params foreach( $cmd as $key => $value ) { if ( $skip ) { $skip = false; continue; } // named param? if ( substr( $value, 0, 1 ) == '-' ) { if ( array_key_exists( $key+1, $cmd ) ) { $next_value = $cmd[$key+1]; if ( substr( $next_value, 0, 1 ) == '-' ) { $params[substr( $value, 1 )] = true; } else { $params[substr( $value, 1 )] = $next_value; $skip = true; } } else { $params[substr( $value, 1 )] = true; } } else { $params[] = $value; } } return static::run( trim( $controller ), trim( $action ), $params ); }
php
public static function parse( $cmd ) { // if we dont have an command if ( empty( $cmd ) ) { return false; } $params = array(); // are we in a string $in_string = false; $len = strlen( $cmd ); $crr_prm = ""; $command_str = $cmd; $cmd = array(); // loop trough for( $i=0;$len>$i;$i++ ) { $char = $command_str[$i]; switch( $char ) { case ' ': if ( !$in_string ) { $cmd[] = $crr_prm; $crr_prm = ''; } else { $crr_prm .= $char; } break; case '"': if( $i > 0 && $command_str[$c-1] != '\\' ) { $in_string = !$in_string; } break; default: $crr_prm .= $char; break; } } $cmd[] = $crr_prm; // get the controller $controller = array_shift( $cmd ); // get the action $action = null; // check we got an action in our controller if ( strpos( $controller, '::' ) !== false ) { $controller = explode( '::', $controller ); $action = $controller[1]; $controller = $controller[0]; } // skipper if we got an named param skip the next $skip = false; // get the params foreach( $cmd as $key => $value ) { if ( $skip ) { $skip = false; continue; } // named param? if ( substr( $value, 0, 1 ) == '-' ) { if ( array_key_exists( $key+1, $cmd ) ) { $next_value = $cmd[$key+1]; if ( substr( $next_value, 0, 1 ) == '-' ) { $params[substr( $value, 1 )] = true; } else { $params[substr( $value, 1 )] = $next_value; $skip = true; } } else { $params[substr( $value, 1 )] = true; } } else { $params[] = $value; } } return static::run( trim( $controller ), trim( $action ), $params ); }
[ "public", "static", "function", "parse", "(", "$", "cmd", ")", "{", "// if we dont have an command", "if", "(", "empty", "(", "$", "cmd", ")", ")", "{", "return", "false", ";", "}", "$", "params", "=", "array", "(", ")", ";", "// are we in a string", "$", "in_string", "=", "false", ";", "$", "len", "=", "strlen", "(", "$", "cmd", ")", ";", "$", "crr_prm", "=", "\"\"", ";", "$", "command_str", "=", "$", "cmd", ";", "$", "cmd", "=", "array", "(", ")", ";", "// loop trough", "for", "(", "$", "i", "=", "0", ";", "$", "len", ">", "$", "i", ";", "$", "i", "++", ")", "{", "$", "char", "=", "$", "command_str", "[", "$", "i", "]", ";", "switch", "(", "$", "char", ")", "{", "case", "' '", ":", "if", "(", "!", "$", "in_string", ")", "{", "$", "cmd", "[", "]", "=", "$", "crr_prm", ";", "$", "crr_prm", "=", "''", ";", "}", "else", "{", "$", "crr_prm", ".=", "$", "char", ";", "}", "break", ";", "case", "'\"'", ":", "if", "(", "$", "i", ">", "0", "&&", "$", "command_str", "[", "$", "c", "-", "1", "]", "!=", "'\\\\'", ")", "{", "$", "in_string", "=", "!", "$", "in_string", ";", "}", "break", ";", "default", ":", "$", "crr_prm", ".=", "$", "char", ";", "break", ";", "}", "}", "$", "cmd", "[", "]", "=", "$", "crr_prm", ";", "// get the controller", "$", "controller", "=", "array_shift", "(", "$", "cmd", ")", ";", "// get the action", "$", "action", "=", "null", ";", "// check we got an action in our controller", "if", "(", "strpos", "(", "$", "controller", ",", "'::'", ")", "!==", "false", ")", "{", "$", "controller", "=", "explode", "(", "'::'", ",", "$", "controller", ")", ";", "$", "action", "=", "$", "controller", "[", "1", "]", ";", "$", "controller", "=", "$", "controller", "[", "0", "]", ";", "}", "// skipper if we got an named param skip the next", "$", "skip", "=", "false", ";", "// get the params", "foreach", "(", "$", "cmd", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "skip", ")", "{", "$", "skip", "=", "false", ";", "continue", ";", "}", "// named param?", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'-'", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", "+", "1", ",", "$", "cmd", ")", ")", "{", "$", "next_value", "=", "$", "cmd", "[", "$", "key", "+", "1", "]", ";", "if", "(", "substr", "(", "$", "next_value", ",", "0", ",", "1", ")", "==", "'-'", ")", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "true", ";", "}", "else", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "$", "next_value", ";", "$", "skip", "=", "true", ";", "}", "}", "else", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "true", ";", "}", "}", "else", "{", "$", "params", "[", "]", "=", "$", "value", ";", "}", "}", "return", "static", "::", "run", "(", "trim", "(", "$", "controller", ")", ",", "trim", "(", "$", "action", ")", ",", "$", "params", ")", ";", "}" ]
Parse an command and execute console style @param string $cmd
[ "Parse", "an", "command", "and", "execute", "console", "style" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L21-L112
18,435
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.run
public static function run( $controller, $action = null, $params = array() ) { // always enable the file infos // this allows CCFile to print an info when a file gets created or deleted. CCFile::enable_infos(); // execute by default the help action if ( empty( $action ) ) { $action = 'default'; } $path = CCPath::get( $controller, CCDIR_CONSOLE, EXT ); // check if the file exists, if not try with core path if ( !file_exists( $path ) ) { if ( !CCPath::contains_namespace( $controller ) ) { $path = CCPath::get( CCCORE_NAMESPACE.'::'.$controller, CCDIR_CONSOLE, EXT ); } } // still nothing? if ( !file_exists( $path ) ) { CCCli::line( "Could not find controller {$controller}.", 'red' ); return false; } // all console classes should be on the CCConsole namespace // this way you can easly overwrite a console script $class = 'CCConsole\\'.$controller; // add the class to the autoloader \CCFinder::bind( $class, $path ); // create an instance $class = new $class( $action, $params ); // run wake function if ( method_exists( $class, 'wake' ) ) { call_user_func( array( $class, 'wake' ), $params ); } // run the execution call_user_func( array( $class, '_execute' ), $action, $params ); // run sleep if ( method_exists( $class, 'sleep' ) ) { call_user_func( array( $class, 'sleep' ), $params ); } }
php
public static function run( $controller, $action = null, $params = array() ) { // always enable the file infos // this allows CCFile to print an info when a file gets created or deleted. CCFile::enable_infos(); // execute by default the help action if ( empty( $action ) ) { $action = 'default'; } $path = CCPath::get( $controller, CCDIR_CONSOLE, EXT ); // check if the file exists, if not try with core path if ( !file_exists( $path ) ) { if ( !CCPath::contains_namespace( $controller ) ) { $path = CCPath::get( CCCORE_NAMESPACE.'::'.$controller, CCDIR_CONSOLE, EXT ); } } // still nothing? if ( !file_exists( $path ) ) { CCCli::line( "Could not find controller {$controller}.", 'red' ); return false; } // all console classes should be on the CCConsole namespace // this way you can easly overwrite a console script $class = 'CCConsole\\'.$controller; // add the class to the autoloader \CCFinder::bind( $class, $path ); // create an instance $class = new $class( $action, $params ); // run wake function if ( method_exists( $class, 'wake' ) ) { call_user_func( array( $class, 'wake' ), $params ); } // run the execution call_user_func( array( $class, '_execute' ), $action, $params ); // run sleep if ( method_exists( $class, 'sleep' ) ) { call_user_func( array( $class, 'sleep' ), $params ); } }
[ "public", "static", "function", "run", "(", "$", "controller", ",", "$", "action", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "// always enable the file infos", "// this allows CCFile to print an info when a file gets created or deleted.", "CCFile", "::", "enable_infos", "(", ")", ";", "// execute by default the help action", "if", "(", "empty", "(", "$", "action", ")", ")", "{", "$", "action", "=", "'default'", ";", "}", "$", "path", "=", "CCPath", "::", "get", "(", "$", "controller", ",", "CCDIR_CONSOLE", ",", "EXT", ")", ";", "// check if the file exists, if not try with core path", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "CCPath", "::", "contains_namespace", "(", "$", "controller", ")", ")", "{", "$", "path", "=", "CCPath", "::", "get", "(", "CCCORE_NAMESPACE", ".", "'::'", ".", "$", "controller", ",", "CCDIR_CONSOLE", ",", "EXT", ")", ";", "}", "}", "// still nothing?", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "CCCli", "::", "line", "(", "\"Could not find controller {$controller}.\"", ",", "'red'", ")", ";", "return", "false", ";", "}", "// all console classes should be on the CCConsole namespace", "// this way you can easly overwrite a console script", "$", "class", "=", "'CCConsole\\\\'", ".", "$", "controller", ";", "// add the class to the autoloader ", "\\", "CCFinder", "::", "bind", "(", "$", "class", ",", "$", "path", ")", ";", "// create an instance", "$", "class", "=", "new", "$", "class", "(", "$", "action", ",", "$", "params", ")", ";", "// run wake function", "if", "(", "method_exists", "(", "$", "class", ",", "'wake'", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "class", ",", "'wake'", ")", ",", "$", "params", ")", ";", "}", "// run the execution", "call_user_func", "(", "array", "(", "$", "class", ",", "'_execute'", ")", ",", "$", "action", ",", "$", "params", ")", ";", "// run sleep", "if", "(", "method_exists", "(", "$", "class", ",", "'sleep'", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "class", ",", "'sleep'", ")", ",", "$", "params", ")", ";", "}", "}" ]
Run a console script @param string $controller @param string $action @param array $params
[ "Run", "a", "console", "script" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L121-L175
18,436
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController._execute
public function _execute( $action, $params = array() ) { if ( method_exists( $this, 'action_'.$action ) ) { call_user_func( array( $this, 'action_'.$action ), $params ); } else { CCCli::line( "There is no action {$action}.", 'red' ); } }
php
public function _execute( $action, $params = array() ) { if ( method_exists( $this, 'action_'.$action ) ) { call_user_func( array( $this, 'action_'.$action ), $params ); } else { CCCli::line( "There is no action {$action}.", 'red' ); } }
[ "public", "function", "_execute", "(", "$", "action", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "'action_'", ".", "$", "action", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "'action_'", ".", "$", "action", ")", ",", "$", "params", ")", ";", "}", "else", "{", "CCCli", "::", "line", "(", "\"There is no action {$action}.\"", ",", "'red'", ")", ";", "}", "}" ]
execute the controller @param string $action @param array $params @return void
[ "execute", "the", "controller" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L202-L212
18,437
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.action_help
public function action_help( $params ) { if ( method_exists( $this, 'help' ) ) { CCCli::line( $this->help_formatter( $this->help() ) ); return; } CCCli::line( 'This console controller does not implement an help function or action.' , 'cyan' ); }
php
public function action_help( $params ) { if ( method_exists( $this, 'help' ) ) { CCCli::line( $this->help_formatter( $this->help() ) ); return; } CCCli::line( 'This console controller does not implement an help function or action.' , 'cyan' ); }
[ "public", "function", "action_help", "(", "$", "params", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "'help'", ")", ")", "{", "CCCli", "::", "line", "(", "$", "this", "->", "help_formatter", "(", "$", "this", "->", "help", "(", ")", ")", ")", ";", "return", ";", "}", "CCCli", "::", "line", "(", "'This console controller does not implement an help function or action.'", ",", "'cyan'", ")", ";", "}" ]
default help action @param array $params @return void
[ "default", "help", "action" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L230-L236
18,438
steeffeen/FancyManiaLinks
FML/ManiaCode/InstallScript.php
InstallScript.create
public static function create($name = null, $file = null, $url = null) { return new static($name, $file, $url); }
php
public static function create($name = null, $file = null, $url = null) { return new static($name, $file, $url); }
[ "public", "static", "function", "create", "(", "$", "name", "=", "null", ",", "$", "file", "=", "null", ",", "$", "url", "=", "null", ")", "{", "return", "new", "static", "(", "$", "name", ",", "$", "file", ",", "$", "url", ")", ";", "}" ]
Create a new InstallScript Element @api @param string $name (optional) Script name @param string $file (optional) Script file @param string $url (optional) Script url @return static
[ "Create", "a", "new", "InstallScript", "Element" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode/InstallScript.php#L39-L42
18,439
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._dataTooltip
protected function _dataTooltip(array $options, $tooltip) { if (Arr::key('title', $options)) { $options['data-tooltip'] = $options['title']; } if (is_string($tooltip)) { $options['data-tooltip'] = $tooltip; } return $options; }
php
protected function _dataTooltip(array $options, $tooltip) { if (Arr::key('title', $options)) { $options['data-tooltip'] = $options['title']; } if (is_string($tooltip)) { $options['data-tooltip'] = $tooltip; } return $options; }
[ "protected", "function", "_dataTooltip", "(", "array", "$", "options", ",", "$", "tooltip", ")", "{", "if", "(", "Arr", "::", "key", "(", "'title'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'data-tooltip'", "]", "=", "$", "options", "[", "'title'", "]", ";", "}", "if", "(", "is_string", "(", "$", "tooltip", ")", ")", "{", "$", "options", "[", "'data-tooltip'", "]", "=", "$", "tooltip", ";", "}", "return", "$", "options", ";", "}" ]
Setup tooltip data-tooltip attr. @param array $options @param string $tooltip @return array
[ "Setup", "tooltip", "data", "-", "tooltip", "attr", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L38-L49
18,440
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._prepareBtn
protected function _prepareBtn(Helper $helper, array $options, $button) { $options = $helper->addClass($options, 'waves-effect waves-light btn'); if (!empty($button)) { $options = $helper->addClass($options, Str::trim((string) $button)); } return $options; }
php
protected function _prepareBtn(Helper $helper, array $options, $button) { $options = $helper->addClass($options, 'waves-effect waves-light btn'); if (!empty($button)) { $options = $helper->addClass($options, Str::trim((string) $button)); } return $options; }
[ "protected", "function", "_prepareBtn", "(", "Helper", "$", "helper", ",", "array", "$", "options", ",", "$", "button", ")", "{", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "'waves-effect waves-light btn'", ")", ";", "if", "(", "!", "empty", "(", "$", "button", ")", ")", "{", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "Str", "::", "trim", "(", "(", "string", ")", "$", "button", ")", ")", ";", "}", "return", "$", "options", ";", "}" ]
Prepare form buttons. @param Helper $helper @param array $options @param string $button @return array
[ "Prepare", "form", "buttons", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L59-L67
18,441
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._prepareTooltip
protected function _prepareTooltip(Helper $helper, array $options, $tooltip) { $_options = [ 'data-position' => 'top' ]; if (Arr::key('tooltipPos', $options)) { $_options['data-position'] = (string) $options['tooltipPos']; unset($options['tooltipPos']); } $options = $this->_tooltipTitle($options, $tooltip); $options = $this->_dataTooltip($options, $tooltip); $options = $helper->addClass($options, 'hasTooltip'); return Hash::merge($_options, $options); }
php
protected function _prepareTooltip(Helper $helper, array $options, $tooltip) { $_options = [ 'data-position' => 'top' ]; if (Arr::key('tooltipPos', $options)) { $_options['data-position'] = (string) $options['tooltipPos']; unset($options['tooltipPos']); } $options = $this->_tooltipTitle($options, $tooltip); $options = $this->_dataTooltip($options, $tooltip); $options = $helper->addClass($options, 'hasTooltip'); return Hash::merge($_options, $options); }
[ "protected", "function", "_prepareTooltip", "(", "Helper", "$", "helper", ",", "array", "$", "options", ",", "$", "tooltip", ")", "{", "$", "_options", "=", "[", "'data-position'", "=>", "'top'", "]", ";", "if", "(", "Arr", "::", "key", "(", "'tooltipPos'", ",", "$", "options", ")", ")", "{", "$", "_options", "[", "'data-position'", "]", "=", "(", "string", ")", "$", "options", "[", "'tooltipPos'", "]", ";", "unset", "(", "$", "options", "[", "'tooltipPos'", "]", ")", ";", "}", "$", "options", "=", "$", "this", "->", "_tooltipTitle", "(", "$", "options", ",", "$", "tooltip", ")", ";", "$", "options", "=", "$", "this", "->", "_dataTooltip", "(", "$", "options", ",", "$", "tooltip", ")", ";", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "'hasTooltip'", ")", ";", "return", "Hash", "::", "merge", "(", "$", "_options", ",", "$", "options", ")", ";", "}" ]
Prepare tooltip attrs. @param Helper $helper @param array $options @param string $tooltip @return array
[ "Prepare", "tooltip", "attrs", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L77-L93
18,442
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._tooltipTitle
protected function _tooltipTitle(array $options, $tooltip) { if ($tooltip === true && !Arr::key('title', $options)) { $options['title'] = strip_tags($options['label']); } if (is_string($tooltip)) { $options['title'] = $tooltip; } return $options; }
php
protected function _tooltipTitle(array $options, $tooltip) { if ($tooltip === true && !Arr::key('title', $options)) { $options['title'] = strip_tags($options['label']); } if (is_string($tooltip)) { $options['title'] = $tooltip; } return $options; }
[ "protected", "function", "_tooltipTitle", "(", "array", "$", "options", ",", "$", "tooltip", ")", "{", "if", "(", "$", "tooltip", "===", "true", "&&", "!", "Arr", "::", "key", "(", "'title'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'title'", "]", "=", "strip_tags", "(", "$", "options", "[", "'label'", "]", ")", ";", "}", "if", "(", "is_string", "(", "$", "tooltip", ")", ")", "{", "$", "options", "[", "'title'", "]", "=", "$", "tooltip", ";", "}", "return", "$", "options", ";", "}" ]
Setup tooltip title. @param array $options @param string $tooltip @return array
[ "Setup", "tooltip", "title", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L102-L113
18,443
ClanCats/Core
src/console/phpunit.php
phpunit.action_build
public function action_build( $params ) { $test_directories = array(); // check if there is an application tests direcotry if ( is_dir( APPPATH.CCDIR_TEST ) ) { $this->line( 'found tests in your application.' ); $test_directories['App'] = APPPATH.CCDIR_TEST; } // add the core tests if ( $params['-include-core'] ) { $test_directories['Core'] = COREPATH.'../'.CCDIR_TEST; } // check all bundles for tests foreach( \CCFinder::$bundles as $bundle => $path ) { if ( is_dir( $path.CCDIR_TEST ) ) { $this->info( 'found tests in the '.$bundle.' bundle.' ); $test_directories[$bundle] = $path.CCDIR_TEST; } } // we have to remove CCROOT from the paths to get the relative one foreach( $test_directories as $key => $dir ) { $test_directories[$key] = './'.str_replace( CCROOT, '', $dir ); } // finally generate an phpunit.xml file $xml = new \DOMDocument("1.0", 'UTF-8'); $root = $xml->createElement( "phpunit" ); $testsuites = $xml->createElement( "testsuites" ); foreach( $test_directories as $key => $dir ) { $testsuite = $xml->createElement( "testsuite" ); $testsuite->setAttribute( 'name', $key.' tests' ); $directory = $xml->createElement( "directory", $dir ); $directory->setAttribute( 'suffix', EXT ); $testsuite->appendChild( $directory ); $testsuites->appendChild( $testsuite ); } $root->appendChild( $testsuites ); $root = $xml->appendChild( $root ); $root->setAttribute( 'colors', 'true' ); $root->setAttribute( 'bootstrap', 'boot/phpunit.php' ); $xml->formatOutput = true; \CCFile::write( CCROOT.'phpunit.xml', $xml->saveXML() ); }
php
public function action_build( $params ) { $test_directories = array(); // check if there is an application tests direcotry if ( is_dir( APPPATH.CCDIR_TEST ) ) { $this->line( 'found tests in your application.' ); $test_directories['App'] = APPPATH.CCDIR_TEST; } // add the core tests if ( $params['-include-core'] ) { $test_directories['Core'] = COREPATH.'../'.CCDIR_TEST; } // check all bundles for tests foreach( \CCFinder::$bundles as $bundle => $path ) { if ( is_dir( $path.CCDIR_TEST ) ) { $this->info( 'found tests in the '.$bundle.' bundle.' ); $test_directories[$bundle] = $path.CCDIR_TEST; } } // we have to remove CCROOT from the paths to get the relative one foreach( $test_directories as $key => $dir ) { $test_directories[$key] = './'.str_replace( CCROOT, '', $dir ); } // finally generate an phpunit.xml file $xml = new \DOMDocument("1.0", 'UTF-8'); $root = $xml->createElement( "phpunit" ); $testsuites = $xml->createElement( "testsuites" ); foreach( $test_directories as $key => $dir ) { $testsuite = $xml->createElement( "testsuite" ); $testsuite->setAttribute( 'name', $key.' tests' ); $directory = $xml->createElement( "directory", $dir ); $directory->setAttribute( 'suffix', EXT ); $testsuite->appendChild( $directory ); $testsuites->appendChild( $testsuite ); } $root->appendChild( $testsuites ); $root = $xml->appendChild( $root ); $root->setAttribute( 'colors', 'true' ); $root->setAttribute( 'bootstrap', 'boot/phpunit.php' ); $xml->formatOutput = true; \CCFile::write( CCROOT.'phpunit.xml', $xml->saveXML() ); }
[ "public", "function", "action_build", "(", "$", "params", ")", "{", "$", "test_directories", "=", "array", "(", ")", ";", "// check if there is an application tests direcotry", "if", "(", "is_dir", "(", "APPPATH", ".", "CCDIR_TEST", ")", ")", "{", "$", "this", "->", "line", "(", "'found tests in your application.'", ")", ";", "$", "test_directories", "[", "'App'", "]", "=", "APPPATH", ".", "CCDIR_TEST", ";", "}", "// add the core tests", "if", "(", "$", "params", "[", "'-include-core'", "]", ")", "{", "$", "test_directories", "[", "'Core'", "]", "=", "COREPATH", ".", "'../'", ".", "CCDIR_TEST", ";", "}", "// check all bundles for tests", "foreach", "(", "\\", "CCFinder", "::", "$", "bundles", "as", "$", "bundle", "=>", "$", "path", ")", "{", "if", "(", "is_dir", "(", "$", "path", ".", "CCDIR_TEST", ")", ")", "{", "$", "this", "->", "info", "(", "'found tests in the '", ".", "$", "bundle", ".", "' bundle.'", ")", ";", "$", "test_directories", "[", "$", "bundle", "]", "=", "$", "path", ".", "CCDIR_TEST", ";", "}", "}", "// we have to remove CCROOT from the paths to get the relative one", "foreach", "(", "$", "test_directories", "as", "$", "key", "=>", "$", "dir", ")", "{", "$", "test_directories", "[", "$", "key", "]", "=", "'./'", ".", "str_replace", "(", "CCROOT", ",", "''", ",", "$", "dir", ")", ";", "}", "// finally generate an phpunit.xml file", "$", "xml", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "'UTF-8'", ")", ";", "$", "root", "=", "$", "xml", "->", "createElement", "(", "\"phpunit\"", ")", ";", "$", "testsuites", "=", "$", "xml", "->", "createElement", "(", "\"testsuites\"", ")", ";", "foreach", "(", "$", "test_directories", "as", "$", "key", "=>", "$", "dir", ")", "{", "$", "testsuite", "=", "$", "xml", "->", "createElement", "(", "\"testsuite\"", ")", ";", "$", "testsuite", "->", "setAttribute", "(", "'name'", ",", "$", "key", ".", "' tests'", ")", ";", "$", "directory", "=", "$", "xml", "->", "createElement", "(", "\"directory\"", ",", "$", "dir", ")", ";", "$", "directory", "->", "setAttribute", "(", "'suffix'", ",", "EXT", ")", ";", "$", "testsuite", "->", "appendChild", "(", "$", "directory", ")", ";", "$", "testsuites", "->", "appendChild", "(", "$", "testsuite", ")", ";", "}", "$", "root", "->", "appendChild", "(", "$", "testsuites", ")", ";", "$", "root", "=", "$", "xml", "->", "appendChild", "(", "$", "root", ")", ";", "$", "root", "->", "setAttribute", "(", "'colors'", ",", "'true'", ")", ";", "$", "root", "->", "setAttribute", "(", "'bootstrap'", ",", "'boot/phpunit.php'", ")", ";", "$", "xml", "->", "formatOutput", "=", "true", ";", "\\", "CCFile", "::", "write", "(", "CCROOT", ".", "'phpunit.xml'", ",", "$", "xml", "->", "saveXML", "(", ")", ")", ";", "}" ]
Builds the phpunit.xml file @param array $params
[ "Builds", "the", "phpunit", ".", "xml", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/phpunit.php#L33-L96
18,444
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.setDataWithKeys
public function setDataWithKeys(Array $keys, $value) { $data =& $this->data; if ($keys === array()) { if (!is_array($value)) { throw new DataInputException('Wenn $keys leer ist, darf value nur ein array sein!'); } return $data = $value; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { $data[$key] = array(); } $data =& $data[$key]; } $data[$lastKey] = $value; return $data; }
php
public function setDataWithKeys(Array $keys, $value) { $data =& $this->data; if ($keys === array()) { if (!is_array($value)) { throw new DataInputException('Wenn $keys leer ist, darf value nur ein array sein!'); } return $data = $value; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { $data[$key] = array(); } $data =& $data[$key]; } $data[$lastKey] = $value; return $data; }
[ "public", "function", "setDataWithKeys", "(", "Array", "$", "keys", ",", "$", "value", ")", "{", "$", "data", "=", "&", "$", "this", "->", "data", ";", "if", "(", "$", "keys", "===", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "throw", "new", "DataInputException", "(", "'Wenn $keys leer ist, darf value nur ein array sein!'", ")", ";", "}", "return", "$", "data", "=", "$", "value", ";", "}", "$", "lastKey", "=", "array_pop", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "$", "data", "=", "&", "$", "data", "[", "$", "key", "]", ";", "}", "$", "data", "[", "$", "lastKey", "]", "=", "$", "value", ";", "return", "$", "data", ";", "}" ]
Setzt einen Wert mit einem Pfad Ableitenden Klassen können dann sowas machen: public function bla() { $keys = func_get_args(); $value = array_pop($keys); return $this->setDataWithKeys($keys, $value, self::THROW_EXCEPTION); } oder so ist $keys ein leerer array werden alle Daten des Objektes mit $value ersetzt. ist $value dann kein Array wird toArray() einen array mit $value als einziges Element zurückgeben - das ist sehr weird also besser ist immer $value einen array zu haben
[ "Setzt", "einen", "Wert", "mit", "einem", "Pfad" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L109-L130
18,445
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.set
public function set($keys, $value) { if (is_string($keys)) $keys = explode('.',$keys); if (is_integer($keys)) $keys = array($keys); return $this->setDataWithKeys($keys, $value); }
php
public function set($keys, $value) { if (is_string($keys)) $keys = explode('.',$keys); if (is_integer($keys)) $keys = array($keys); return $this->setDataWithKeys($keys, $value); }
[ "public", "function", "set", "(", "$", "keys", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "keys", ")", ")", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "keys", ")", ";", "if", "(", "is_integer", "(", "$", "keys", ")", ")", "$", "keys", "=", "array", "(", "$", "keys", ")", ";", "return", "$", "this", "->", "setDataWithKeys", "(", "$", "keys", ",", "$", "value", ")", ";", "}" ]
Setzt einen Wert in den Daten @param string|array $keys @param mixed $value
[ "Setzt", "einen", "Wert", "in", "den", "Daten" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L224-L229
18,446
yuncms/framework
src/sms/Sms.php
Sms.strategy
public function strategy($strategy = null) { if (is_null($strategy)) { $strategy = $this->defaultStrategy ?: OrderStrategy::class; } if (!class_exists($strategy)) { $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy); } if (!class_exists($strategy)) { throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\""); } if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) { $this->strategies[$strategy] = new $strategy($this); } return $this->strategies[$strategy]; }
php
public function strategy($strategy = null) { if (is_null($strategy)) { $strategy = $this->defaultStrategy ?: OrderStrategy::class; } if (!class_exists($strategy)) { $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy); } if (!class_exists($strategy)) { throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\""); } if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) { $this->strategies[$strategy] = new $strategy($this); } return $this->strategies[$strategy]; }
[ "public", "function", "strategy", "(", "$", "strategy", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "strategy", ")", ")", "{", "$", "strategy", "=", "$", "this", "->", "defaultStrategy", "?", ":", "OrderStrategy", "::", "class", ";", "}", "if", "(", "!", "class_exists", "(", "$", "strategy", ")", ")", "{", "$", "strategy", "=", "__NAMESPACE__", ".", "'\\strategies\\\\'", ".", "ucfirst", "(", "$", "strategy", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "strategy", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported strategy \\\"{$strategy}\\\"\"", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "strategies", "[", "$", "strategy", "]", ")", "||", "!", "(", "$", "this", "->", "strategies", "[", "$", "strategy", "]", "instanceof", "StrategyInterface", ")", ")", "{", "$", "this", "->", "strategies", "[", "$", "strategy", "]", "=", "new", "$", "strategy", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "strategies", "[", "$", "strategy", "]", ";", "}" ]
Get a strategy instance. @param string|null $strategy @return StrategyInterface @throws InvalidArgumentException
[ "Get", "a", "strategy", "instance", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L95-L114
18,447
yuncms/framework
src/sms/Sms.php
Sms.get
public function get($id, $throwException = true) { if (isset($this->_gateways[$id])) { return $this->_gateways[$id]; } if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_gateways[$id] = $definition; } return $this->_gateways[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown gateway ID: $id"); } return null; }
php
public function get($id, $throwException = true) { if (isset($this->_gateways[$id])) { return $this->_gateways[$id]; } if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_gateways[$id] = $definition; } return $this->_gateways[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown gateway ID: $id"); } return null; }
[ "public", "function", "get", "(", "$", "id", ",", "$", "throwException", "=", "true", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_gateways", "[", "$", "id", "]", ")", ")", "{", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ")", "{", "$", "definition", "=", "$", "this", "->", "_definitions", "[", "$", "id", "]", ";", "if", "(", "is_object", "(", "$", "definition", ")", "&&", "!", "$", "definition", "instanceof", "Closure", ")", "{", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", "=", "Yii", "::", "createObject", "(", "$", "definition", ")", ";", "}", "elseif", "(", "$", "throwException", ")", "{", "throw", "new", "InvalidConfigException", "(", "\"Unknown gateway ID: $id\"", ")", ";", "}", "return", "null", ";", "}" ]
Returns the gateway instance with the specified ID. @param string $id gateway ID (e.g. `db`). @param bool $throwException whether to throw an exception if `$id` is not registered with the locator before. @return object|null the gateway of the specified ID. If `$throwException` is false and `$id` is not registered before, null will be returned. @throws InvalidConfigException if `$id` refers to a nonexistent gateway ID @see has() @see set()
[ "Returns", "the", "gateway", "instance", "with", "the", "specified", "ID", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L178-L196
18,448
yuncms/framework
src/sms/Sms.php
Sms.set
public function set($id, $definition) { unset($this->_gateways[$id]); if ($definition === null) { unset($this->_definitions[$id]); return; } if (is_object($definition) || is_callable($definition, true)) { // an object, a class name, or a PHP callable $this->_definitions[$id] = $definition; } elseif (is_array($definition)) { // a configuration array if (isset($definition['class'])) { $this->_definitions[$id] = $definition; } else { throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element."); } } else { throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition)); } }
php
public function set($id, $definition) { unset($this->_gateways[$id]); if ($definition === null) { unset($this->_definitions[$id]); return; } if (is_object($definition) || is_callable($definition, true)) { // an object, a class name, or a PHP callable $this->_definitions[$id] = $definition; } elseif (is_array($definition)) { // a configuration array if (isset($definition['class'])) { $this->_definitions[$id] = $definition; } else { throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element."); } } else { throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition)); } }
[ "public", "function", "set", "(", "$", "id", ",", "$", "definition", ")", "{", "unset", "(", "$", "this", "->", "_gateways", "[", "$", "id", "]", ")", ";", "if", "(", "$", "definition", "===", "null", ")", "{", "unset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ";", "return", ";", "}", "if", "(", "is_object", "(", "$", "definition", ")", "||", "is_callable", "(", "$", "definition", ",", "true", ")", ")", "{", "// an object, a class name, or a PHP callable", "$", "this", "->", "_definitions", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "elseif", "(", "is_array", "(", "$", "definition", ")", ")", "{", "// a configuration array", "if", "(", "isset", "(", "$", "definition", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "_definitions", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "else", "{", "throw", "new", "InvalidConfigException", "(", "\"The configuration for the \\\"$id\\\" gateway must contain a \\\"class\\\" element.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "InvalidConfigException", "(", "\"Unexpected configuration type for the \\\"$id\\\" gateway: \"", ".", "gettype", "(", "$", "definition", ")", ")", ";", "}", "}" ]
Registers a gateway definition with this locator. For example, ```php // a class name $locator->set('cache', 'yii\caching\FileCache'); // a configuration array $locator->set('db', [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=demo', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ]); // an anonymous function $locator->set('cache', function ($params) { return new \yii\caching\FileCache; }); // an instance $locator->set('cache', new \yii\caching\FileCache); ``` If a filesystem definition with the same ID already exists, it will be overwritten. @param string $id filesystem ID (e.g. `db`). @param mixed $definition the filesystem definition to be registered with this locator. It can be one of the following: - a class name - a configuration array: the array contains name-value pairs that will be used to initialize the property values of the newly created object when [[get()]] is called. The `class` element is required and stands for the the class of the object to be created. - a PHP callable: either an anonymous function or an array representing a class method (e.g. `['Foo', 'bar']`). The callable will be called by [[get()]] to return an object associated with the specified filesystem ID. - an object: When [[get()]] is called, this object will be returned. @throws InvalidConfigException if the definition is an invalid configuration array
[ "Registers", "a", "gateway", "definition", "with", "this", "locator", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L241-L263
18,449
yuncms/framework
src/sms/Sms.php
Sms.setGateways
public function setGateways($gateways) { foreach ($gateways as $id => $gateway) { $this->set($id, $gateway); } }
php
public function setGateways($gateways) { foreach ($gateways as $id => $gateway) { $this->set($id, $gateway); } }
[ "public", "function", "setGateways", "(", "$", "gateways", ")", "{", "foreach", "(", "$", "gateways", "as", "$", "id", "=>", "$", "gateway", ")", "{", "$", "this", "->", "set", "(", "$", "id", ",", "$", "gateway", ")", ";", "}", "}" ]
Registers a set of gateway definitions in this locator. This is the bulk version of [[set()]]. The parameter should be an array whose keys are gateway IDs and values the corresponding gateway definitions. For more details on how to specify gateway IDs and definitions, please refer to [[set()]]. If a gateway definition with the same ID already exists, it will be overwritten. The following is an example for registering two gateway definitions: ```php [ 'local' => [ 'class' => 'yuncms\payment\gateways\LocalAdapter', 'path' => '@root/storage', ], ] ``` @param array $gateways gateway definitions or instances @throws InvalidConfigException
[ "Registers", "a", "set", "of", "gateway", "definitions", "in", "this", "locator", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L308-L313
18,450
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Dumper.php
Dumper.doGetInjectedDefinitions
protected function doGetInjectedDefinitions($name, array &$visited) { if (isset($visited[$name])) { return; } try { $visited[$name] = $this->proxy->get($name); } catch (RuntimeException $e) { // usually abstract class or interface that cannot be resolved return; } catch (MissingPropertyException $e) { // usually missing parameters required for a particular instance return; } foreach ($visited[$name]->getParams() as $param) { if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } foreach ($visited[$name]->getMethods() as $method) { if (isset($method['params']) && is_array($method['params'])) { foreach ($method['params'] as $param) { /* @var $param GeneratorInstance */ if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } } } }
php
protected function doGetInjectedDefinitions($name, array &$visited) { if (isset($visited[$name])) { return; } try { $visited[$name] = $this->proxy->get($name); } catch (RuntimeException $e) { // usually abstract class or interface that cannot be resolved return; } catch (MissingPropertyException $e) { // usually missing parameters required for a particular instance return; } foreach ($visited[$name]->getParams() as $param) { if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } foreach ($visited[$name]->getMethods() as $method) { if (isset($method['params']) && is_array($method['params'])) { foreach ($method['params'] as $param) { /* @var $param GeneratorInstance */ if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } } } }
[ "protected", "function", "doGetInjectedDefinitions", "(", "$", "name", ",", "array", "&", "$", "visited", ")", "{", "if", "(", "isset", "(", "$", "visited", "[", "$", "name", "]", ")", ")", "{", "return", ";", "}", "try", "{", "$", "visited", "[", "$", "name", "]", "=", "$", "this", "->", "proxy", "->", "get", "(", "$", "name", ")", ";", "}", "catch", "(", "RuntimeException", "$", "e", ")", "{", "// usually abstract class or interface that cannot be resolved", "return", ";", "}", "catch", "(", "MissingPropertyException", "$", "e", ")", "{", "// usually missing parameters required for a particular instance", "return", ";", "}", "foreach", "(", "$", "visited", "[", "$", "name", "]", "->", "getParams", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "GeneratorInstance", ")", "{", "/* @var $param GeneratorInstance */", "$", "this", "->", "doGetInjectedDefinitions", "(", "$", "param", "->", "getName", "(", ")", ",", "$", "visited", ")", ";", "}", "}", "foreach", "(", "$", "visited", "[", "$", "name", "]", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "isset", "(", "$", "method", "[", "'params'", "]", ")", "&&", "is_array", "(", "$", "method", "[", "'params'", "]", ")", ")", "{", "foreach", "(", "$", "method", "[", "'params'", "]", "as", "$", "param", ")", "{", "/* @var $param GeneratorInstance */", "if", "(", "$", "param", "instanceof", "GeneratorInstance", ")", "{", "/* @var $param GeneratorInstance */", "$", "this", "->", "doGetInjectedDefinitions", "(", "$", "param", "->", "getName", "(", ")", ",", "$", "visited", ")", ";", "}", "}", "}", "}", "}" ]
Recursively looks for discovered dependencies @param string $name of the instances to get @param array $visited the array where discovered instance definitions will be stored
[ "Recursively", "looks", "for", "discovered", "dependencies" ]
667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Dumper.php#L149-L183
18,451
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.getFilter
public function getFilter() { $filter = []; $tag = $this->getRequest()->getVar("t"); if ($tag) { $filter["Tags.URLSegment"] = $tag; } $this->extend("updateFilter", $filter); return $filter; }
php
public function getFilter() { $filter = []; $tag = $this->getRequest()->getVar("t"); if ($tag) { $filter["Tags.URLSegment"] = $tag; } $this->extend("updateFilter", $filter); return $filter; }
[ "public", "function", "getFilter", "(", ")", "{", "$", "filter", "=", "[", "]", ";", "$", "tag", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getVar", "(", "\"t\"", ")", ";", "if", "(", "$", "tag", ")", "{", "$", "filter", "[", "\"Tags.URLSegment\"", "]", "=", "$", "tag", ";", "}", "$", "this", "->", "extend", "(", "\"updateFilter\"", ",", "$", "filter", ")", ";", "return", "$", "filter", ";", "}" ]
Find a filter from the URL that we can apply to the products list @return array
[ "Find", "a", "filter", "from", "the", "URL", "that", "we", "can", "apply", "to", "the", "products", "list" ]
671f1e32bf6bc6eb193c6608ae904cd055540cc4
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L31-L43
18,452
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.PaginatedProducts
public function PaginatedProducts($limit = 10) { $products = $this->SortedProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
php
public function PaginatedProducts($limit = 10) { $products = $this->SortedProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
[ "public", "function", "PaginatedProducts", "(", "$", "limit", "=", "10", ")", "{", "$", "products", "=", "$", "this", "->", "SortedProducts", "(", ")", ";", "$", "filter", "=", "$", "this", "->", "getFilter", "(", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ")", "{", "$", "products", "=", "$", "products", "->", "filter", "(", "$", "filter", ")", ";", "}", "return", "PaginatedList", "::", "create", "(", "$", "products", ",", "$", "this", "->", "getRequest", "(", ")", ")", "->", "setPageLength", "(", "$", "limit", ")", ";", "}" ]
Get a paginated list of products contained in this category @return PaginatedList
[ "Get", "a", "paginated", "list", "of", "products", "contained", "in", "this", "category" ]
671f1e32bf6bc6eb193c6608ae904cd055540cc4
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L50-L63
18,453
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.PaginatedAllProducts
public function PaginatedAllProducts($limit = 10) { $products = $this->AllProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
php
public function PaginatedAllProducts($limit = 10) { $products = $this->AllProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
[ "public", "function", "PaginatedAllProducts", "(", "$", "limit", "=", "10", ")", "{", "$", "products", "=", "$", "this", "->", "AllProducts", "(", ")", ";", "$", "filter", "=", "$", "this", "->", "getFilter", "(", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ")", "{", "$", "products", "=", "$", "products", "->", "filter", "(", "$", "filter", ")", ";", "}", "return", "PaginatedList", "::", "create", "(", "$", "products", ",", "$", "this", "->", "getRequest", "(", ")", ")", "->", "setPageLength", "(", "$", "limit", ")", ";", "}" ]
Get a paginated list of all products at this level and below @return PaginatedList
[ "Get", "a", "paginated", "list", "of", "all", "products", "at", "this", "level", "and", "below" ]
671f1e32bf6bc6eb193c6608ae904cd055540cc4
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L71-L84
18,454
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.getViewer
public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || (isset($this->templates['index']) && $this->templates['index']) || $this->template ) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } $templates = array_merge( // Find templates by dataRecord SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Now get templates for sitetree SSViewer::get_templates_by_class(Page::singleton(), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Next, we need to add templates for all controllers SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"), // Fail-over to the same for the "index" action SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"), SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller") ); return SSViewer::create($templates); }
php
public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || (isset($this->templates['index']) && $this->templates['index']) || $this->template ) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } $templates = array_merge( // Find templates by dataRecord SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Now get templates for sitetree SSViewer::get_templates_by_class(Page::singleton(), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Next, we need to add templates for all controllers SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"), // Fail-over to the same for the "index" action SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"), SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller") ); return SSViewer::create($templates); }
[ "public", "function", "getViewer", "(", "$", "action", ")", "{", "// Manually set templates should be dealt with by Controller::getViewer()", "if", "(", "isset", "(", "$", "this", "->", "templates", "[", "$", "action", "]", ")", "&&", "$", "this", "->", "templates", "[", "$", "action", "]", "||", "(", "isset", "(", "$", "this", "->", "templates", "[", "'index'", "]", ")", "&&", "$", "this", "->", "templates", "[", "'index'", "]", ")", "||", "$", "this", "->", "template", ")", "{", "return", "parent", "::", "getViewer", "(", "$", "action", ")", ";", "}", "// Prepare action for template search", "if", "(", "$", "action", "==", "\"index\"", ")", "{", "$", "action", "=", "\"\"", ";", "}", "else", "{", "$", "action", "=", "'_'", ".", "$", "action", ";", "}", "$", "templates", "=", "array_merge", "(", "// Find templates by dataRecord", "SSViewer", "::", "get_templates_by_class", "(", "get_class", "(", "$", "this", "->", "dataRecord", ")", ",", "$", "action", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "// Now get templates for sitetree", "SSViewer", "::", "get_templates_by_class", "(", "Page", "::", "singleton", "(", ")", ",", "$", "action", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "// Next, we need to add templates for all controllers", "SSViewer", "::", "get_templates_by_class", "(", "static", "::", "class", ",", "$", "action", ",", "\"SilverStripe\\\\Control\\\\Controller\"", ")", ",", "// Fail-over to the same for the \"index\" action", "SSViewer", "::", "get_templates_by_class", "(", "get_class", "(", "$", "this", "->", "dataRecord", ")", ",", "\"\"", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "SSViewer", "::", "get_templates_by_class", "(", "static", "::", "class", ",", "\"\"", ",", "\"SilverStripe\\\\Control\\\\Controller\"", ")", ")", ";", "return", "SSViewer", "::", "create", "(", "$", "templates", ")", ";", "}" ]
Overwrite default SSViewer call to get a custom template list @param $action string @return SSViewer
[ "Overwrite", "default", "SSViewer", "call", "to", "get", "a", "custom", "template", "list" ]
671f1e32bf6bc6eb193c6608ae904cd055540cc4
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L231-L261
18,455
zircote/AMQP
library/AMQP/Channel.php
Channel.alert
protected function alert(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $details = $args->readTable(); array_push($this->alerts, array($replyCode, $replyText, $details)); }
php
protected function alert(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $details = $args->readTable(); array_push($this->alerts, array($replyCode, $replyText, $details)); }
[ "protected", "function", "alert", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "replyCode", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "replyText", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "details", "=", "$", "args", "->", "readTable", "(", ")", ";", "array_push", "(", "$", "this", "->", "alerts", ",", "array", "(", "$", "replyCode", ",", "$", "replyText", ",", "$", "details", ")", ")", ";", "}" ]
This method allows the server to send a non-fatal warning to the client. This is used for methods that are normally asynchronous and thus do not have confirmations, and for which the server may detect errors that need to be reported. Fatal errors are handled as channel or connection exceptions; non- fatal errors are sent through this method. @param \AMQP\Wire\Reader $args
[ "This", "method", "allows", "the", "server", "to", "send", "a", "non", "-", "fatal", "warning", "to", "the", "client", ".", "This", "is", "used", "for", "methods", "that", "are", "normally", "asynchronous", "and", "thus", "do", "not", "have", "confirmations", "and", "for", "which", "the", "server", "may", "detect", "errors", "that", "need", "to", "be", "reported", ".", "Fatal", "errors", "are", "handled", "as", "channel", "or", "connection", "exceptions", ";", "non", "-", "fatal", "errors", "are", "sent", "through", "this", "method", "." ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L125-L132
18,456
zircote/AMQP
library/AMQP/Channel.php
Channel.accessRequestOk
protected function accessRequestOk(\AMQP\Wire\Reader $args) { $this->defaultTicket = $args->readShort(); return $this->defaultTicket; }
php
protected function accessRequestOk(\AMQP\Wire\Reader $args) { $this->defaultTicket = $args->readShort(); return $this->defaultTicket; }
[ "protected", "function", "accessRequestOk", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "this", "->", "defaultTicket", "=", "$", "args", "->", "readShort", "(", ")", ";", "return", "$", "this", "->", "defaultTicket", ";", "}" ]
grant access to server resources @param \AMQP\Wire\Reader $args @return int
[ "grant", "access", "to", "server", "resources" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L294-L298
18,457
zircote/AMQP
library/AMQP/Channel.php
Channel.queueDeclareOk
protected function queueDeclareOk(\AMQP\Wire\Reader $args) { $queue = $args->readShortstr(); $messageCount = $args->readLong(); $consumerCount = $args->readLong(); return array($queue, $messageCount, $consumerCount); }
php
protected function queueDeclareOk(\AMQP\Wire\Reader $args) { $queue = $args->readShortstr(); $messageCount = $args->readLong(); $consumerCount = $args->readLong(); return array($queue, $messageCount, $consumerCount); }
[ "protected", "function", "queueDeclareOk", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "queue", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "messageCount", "=", "$", "args", "->", "readLong", "(", ")", ";", "$", "consumerCount", "=", "$", "args", "->", "readLong", "(", ")", ";", "return", "array", "(", "$", "queue", ",", "$", "messageCount", ",", "$", "consumerCount", ")", ";", "}" ]
confirms a queue definition @param \AMQP\Wire\Reader $args @return array
[ "confirms", "a", "queue", "definition" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L514-L521
18,458
zircote/AMQP
library/AMQP/Channel.php
Channel.basicCancel
public function basicCancel($consumerTag, $nowait = false) { $args = $this->frameBuilder->basicCancel($consumerTag, $nowait); $this->sendMethodFrame(array(60, 30), $args); return $this->wait( array( "60,31" // Channel.basicCancelOk ) ); }
php
public function basicCancel($consumerTag, $nowait = false) { $args = $this->frameBuilder->basicCancel($consumerTag, $nowait); $this->sendMethodFrame(array(60, 30), $args); return $this->wait( array( "60,31" // Channel.basicCancelOk ) ); }
[ "public", "function", "basicCancel", "(", "$", "consumerTag", ",", "$", "nowait", "=", "false", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicCancel", "(", "$", "consumerTag", ",", "$", "nowait", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "30", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"60,31\"", "// Channel.basicCancelOk", ")", ")", ";", "}" ]
end a queue consumer @param $consumerTag @param bool $nowait @return mixed|null
[ "end", "a", "queue", "consumer" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L628-L637
18,459
zircote/AMQP
library/AMQP/Channel.php
Channel.basicQos
public function basicQos($prefetchSize, $prefetchCount, $aGlobal) { $args = $this->frameBuilder->basicQos( $prefetchSize, $prefetchCount, $aGlobal ); $this->sendMethodFrame(array(60, 10), $args); return $this->wait( array( "60,11" //Channel.basicQosOk ) ); }
php
public function basicQos($prefetchSize, $prefetchCount, $aGlobal) { $args = $this->frameBuilder->basicQos( $prefetchSize, $prefetchCount, $aGlobal ); $this->sendMethodFrame(array(60, 10), $args); return $this->wait( array( "60,11" //Channel.basicQosOk ) ); }
[ "public", "function", "basicQos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ",", "$", "aGlobal", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicQos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ",", "$", "aGlobal", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "10", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"60,11\"", "//Channel.basicQosOk", ")", ")", ";", "}" ]
specify quality of service @param $prefetchSize @param $prefetchCount @param $aGlobal @return mixed|null
[ "specify", "quality", "of", "service" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L834-L845
18,460
zircote/AMQP
library/AMQP/Channel.php
Channel.basicRecover
public function basicRecover($reQueue = false) { $args = $this->frameBuilder->basicRecover($reQueue); $this->sendMethodFrame(array(60, 100), $args); }
php
public function basicRecover($reQueue = false) { $args = $this->frameBuilder->basicRecover($reQueue); $this->sendMethodFrame(array(60, 100), $args); }
[ "public", "function", "basicRecover", "(", "$", "reQueue", "=", "false", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicRecover", "(", "$", "reQueue", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "100", ")", ",", "$", "args", ")", ";", "}" ]
redeliver unacknowledged messages @param bool $reQueue
[ "redeliver", "unacknowledged", "messages" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L861-L865
18,461
zircote/AMQP
library/AMQP/Channel.php
Channel.basicReject
public function basicReject($deliveryTag, $reQueue) { $args = $this->frameBuilder->basicReject($deliveryTag, $reQueue); $this->sendMethodFrame(array(60, 90), $args); }
php
public function basicReject($deliveryTag, $reQueue) { $args = $this->frameBuilder->basicReject($deliveryTag, $reQueue); $this->sendMethodFrame(array(60, 90), $args); }
[ "public", "function", "basicReject", "(", "$", "deliveryTag", ",", "$", "reQueue", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicReject", "(", "$", "deliveryTag", ",", "$", "reQueue", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "90", ")", ",", "$", "args", ")", ";", "}" ]
reject an incoming message @param $deliveryTag @param $reQueue
[ "reject", "an", "incoming", "message" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L873-L877
18,462
zircote/AMQP
library/AMQP/Channel.php
Channel.basicReturn
protected function basicReturn(\AMQP\Wire\Reader $args) { $reply_code = $args->readShort(); $reply_text = $args->readShortstr(); $exchange = $args->readShortstr(); $routing_key = $args->readShortstr(); $msg = $this->wait(); }
php
protected function basicReturn(\AMQP\Wire\Reader $args) { $reply_code = $args->readShort(); $reply_text = $args->readShortstr(); $exchange = $args->readShortstr(); $routing_key = $args->readShortstr(); $msg = $this->wait(); }
[ "protected", "function", "basicReturn", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "reply_code", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "reply_text", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "exchange", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "routing_key", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "msg", "=", "$", "this", "->", "wait", "(", ")", ";", "}" ]
return a failed message @param \AMQP\Wire\Reader $args
[ "return", "a", "failed", "message" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L884-L891
18,463
barebone-php/barebone-core
lib/Router.php
Router.dispatch
public static function dispatch() { $vars = []; $request = Request::createFromGlobals(); $dispatcher = new Dispatcher(static::instance()->getData()); $routeInfo = $dispatcher->dispatch( $request->getMethod(), $request->getUri()->getPath() ); $controller = "\\Barebone\\Controller"; $action = "index"; switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $action = 'routerError'; $vars['error'] = static::ERR_NOT_FOUND; $vars['subject'] = $request->getUri()->getPath(); break; case Dispatcher::METHOD_NOT_ALLOWED: $action = 'routerError'; $vars['error'] = static::ERR_BAD_METHOD; $vars['subject'] = $routeInfo[1]; break; case Dispatcher::FOUND: $handler = $routeInfo[1]; $vars = $routeInfo[2]; if (!class_exists($handler[0])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_CONTROLLER; $vars['subject'] = $handler[0]; } elseif (!method_exists($handler[0], $handler[1])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_ACTION; $vars['subject'] = $handler[0] . '::' . $handler[1]; } else { $controller = $handler[0]; $action = $handler[1]; } break; } // Start with an empty response $response = new Response(); $request->setAction($action); // @var Controller $instance $instance = new $controller($request, $response); $instance->initController(); // Get Middleware stacks $before = $instance->getMiddlewareBefore(); $after = $instance->getMiddlewareAfter(); // Append the action call to the middleware stack $before[] = function (Request $request, Response $response, callable $next = null ) use ($instance, $action, $vars) { // assigned updated objects $instance->setRequest($request); $instance->setResponse($response); // get updated response from action $response = call_user_func_array([$instance, $action], $vars); // continue return $next($instance->getRequest(), $response); }; // Run the middleware stack and return the Response $middlewares = array_reverse(array_merge($before, $after)); $runner = \Sirius\Middleware\Runner::factory($middlewares); return $runner($request, $response); }
php
public static function dispatch() { $vars = []; $request = Request::createFromGlobals(); $dispatcher = new Dispatcher(static::instance()->getData()); $routeInfo = $dispatcher->dispatch( $request->getMethod(), $request->getUri()->getPath() ); $controller = "\\Barebone\\Controller"; $action = "index"; switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $action = 'routerError'; $vars['error'] = static::ERR_NOT_FOUND; $vars['subject'] = $request->getUri()->getPath(); break; case Dispatcher::METHOD_NOT_ALLOWED: $action = 'routerError'; $vars['error'] = static::ERR_BAD_METHOD; $vars['subject'] = $routeInfo[1]; break; case Dispatcher::FOUND: $handler = $routeInfo[1]; $vars = $routeInfo[2]; if (!class_exists($handler[0])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_CONTROLLER; $vars['subject'] = $handler[0]; } elseif (!method_exists($handler[0], $handler[1])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_ACTION; $vars['subject'] = $handler[0] . '::' . $handler[1]; } else { $controller = $handler[0]; $action = $handler[1]; } break; } // Start with an empty response $response = new Response(); $request->setAction($action); // @var Controller $instance $instance = new $controller($request, $response); $instance->initController(); // Get Middleware stacks $before = $instance->getMiddlewareBefore(); $after = $instance->getMiddlewareAfter(); // Append the action call to the middleware stack $before[] = function (Request $request, Response $response, callable $next = null ) use ($instance, $action, $vars) { // assigned updated objects $instance->setRequest($request); $instance->setResponse($response); // get updated response from action $response = call_user_func_array([$instance, $action], $vars); // continue return $next($instance->getRequest(), $response); }; // Run the middleware stack and return the Response $middlewares = array_reverse(array_merge($before, $after)); $runner = \Sirius\Middleware\Runner::factory($middlewares); return $runner($request, $response); }
[ "public", "static", "function", "dispatch", "(", ")", "{", "$", "vars", "=", "[", "]", ";", "$", "request", "=", "Request", "::", "createFromGlobals", "(", ")", ";", "$", "dispatcher", "=", "new", "Dispatcher", "(", "static", "::", "instance", "(", ")", "->", "getData", "(", ")", ")", ";", "$", "routeInfo", "=", "$", "dispatcher", "->", "dispatch", "(", "$", "request", "->", "getMethod", "(", ")", ",", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ")", ";", "$", "controller", "=", "\"\\\\Barebone\\\\Controller\"", ";", "$", "action", "=", "\"index\"", ";", "switch", "(", "$", "routeInfo", "[", "0", "]", ")", "{", "case", "Dispatcher", "::", "NOT_FOUND", ":", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_NOT_FOUND", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", "break", ";", "case", "Dispatcher", "::", "METHOD_NOT_ALLOWED", ":", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_BAD_METHOD", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "routeInfo", "[", "1", "]", ";", "break", ";", "case", "Dispatcher", "::", "FOUND", ":", "$", "handler", "=", "$", "routeInfo", "[", "1", "]", ";", "$", "vars", "=", "$", "routeInfo", "[", "2", "]", ";", "if", "(", "!", "class_exists", "(", "$", "handler", "[", "0", "]", ")", ")", "{", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_MISSING_CONTROLLER", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "handler", "[", "0", "]", ";", "}", "elseif", "(", "!", "method_exists", "(", "$", "handler", "[", "0", "]", ",", "$", "handler", "[", "1", "]", ")", ")", "{", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_MISSING_ACTION", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "handler", "[", "0", "]", ".", "'::'", ".", "$", "handler", "[", "1", "]", ";", "}", "else", "{", "$", "controller", "=", "$", "handler", "[", "0", "]", ";", "$", "action", "=", "$", "handler", "[", "1", "]", ";", "}", "break", ";", "}", "// Start with an empty response", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "request", "->", "setAction", "(", "$", "action", ")", ";", "// @var Controller $instance", "$", "instance", "=", "new", "$", "controller", "(", "$", "request", ",", "$", "response", ")", ";", "$", "instance", "->", "initController", "(", ")", ";", "// Get Middleware stacks", "$", "before", "=", "$", "instance", "->", "getMiddlewareBefore", "(", ")", ";", "$", "after", "=", "$", "instance", "->", "getMiddlewareAfter", "(", ")", ";", "// Append the action call to the middleware stack", "$", "before", "[", "]", "=", "function", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "callable", "$", "next", "=", "null", ")", "use", "(", "$", "instance", ",", "$", "action", ",", "$", "vars", ")", "{", "// assigned updated objects", "$", "instance", "->", "setRequest", "(", "$", "request", ")", ";", "$", "instance", "->", "setResponse", "(", "$", "response", ")", ";", "// get updated response from action", "$", "response", "=", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "action", "]", ",", "$", "vars", ")", ";", "// continue", "return", "$", "next", "(", "$", "instance", "->", "getRequest", "(", ")", ",", "$", "response", ")", ";", "}", ";", "// Run the middleware stack and return the Response", "$", "middlewares", "=", "array_reverse", "(", "array_merge", "(", "$", "before", ",", "$", "after", ")", ")", ";", "$", "runner", "=", "\\", "Sirius", "\\", "Middleware", "\\", "Runner", "::", "factory", "(", "$", "middlewares", ")", ";", "return", "$", "runner", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Start router and parse incoming requests @return \Zend\Diactoros\Response
[ "Start", "router", "and", "parse", "incoming", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L67-L147
18,464
barebone-php/barebone-core
lib/Router.php
Router.get
public static function get($path, $callback) { self::instance()->addRoute('GET', $path, self::callback($callback)); }
php
public static function get($path, $callback) { self::instance()->addRoute('GET', $path, self::callback($callback)); }
[ "public", "static", "function", "get", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'GET'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle GET HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "GET", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L192-L195
18,465
barebone-php/barebone-core
lib/Router.php
Router.post
public static function post($path, $callback) { self::instance()->addRoute('POST', $path, self::callback($callback)); }
php
public static function post($path, $callback) { self::instance()->addRoute('POST', $path, self::callback($callback)); }
[ "public", "static", "function", "post", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'POST'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle POST HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "POST", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L205-L208
18,466
barebone-php/barebone-core
lib/Router.php
Router.put
public static function put($path, $callback) { self::instance()->addRoute('PUT', $path, self::callback($callback)); }
php
public static function put($path, $callback) { self::instance()->addRoute('PUT', $path, self::callback($callback)); }
[ "public", "static", "function", "put", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'PUT'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle PUT HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "PUT", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L218-L221
18,467
barebone-php/barebone-core
lib/Router.php
Router.delete
public static function delete($path, $callback) { self::instance()->addRoute('DELETE', $path, self::callback($callback)); }
php
public static function delete($path, $callback) { self::instance()->addRoute('DELETE', $path, self::callback($callback)); }
[ "public", "static", "function", "delete", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'DELETE'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle DELETE HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "DELETE", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L231-L234
18,468
barebone-php/barebone-core
lib/Router.php
Router.patch
public static function patch($path, $callback) { self::instance()->addRoute('PATCH', $path, self::callback($callback)); }
php
public static function patch($path, $callback) { self::instance()->addRoute('PATCH', $path, self::callback($callback)); }
[ "public", "static", "function", "patch", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'PATCH'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle PATCH HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "PATCH", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L244-L247
18,469
barebone-php/barebone-core
lib/Router.php
Router.options
public static function options($path, $callback) { self::instance()->addRoute('OPTIONS', $path, self::callback($callback)); }
php
public static function options($path, $callback) { self::instance()->addRoute('OPTIONS', $path, self::callback($callback)); }
[ "public", "static", "function", "options", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'OPTIONS'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle OPTIONS HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "OPTIONS", "HTTP", "requests" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L257-L260
18,470
barebone-php/barebone-core
lib/Router.php
Router.map
public static function map($methods, $path, $callback) { foreach ($methods as $httpMethod) { self::instance()->addRoute( $httpMethod, $path, self::callback($callback) ); } }
php
public static function map($methods, $path, $callback) { foreach ($methods as $httpMethod) { self::instance()->addRoute( $httpMethod, $path, self::callback($callback) ); } }
[ "public", "static", "function", "map", "(", "$", "methods", ",", "$", "path", ",", "$", "callback", ")", "{", "foreach", "(", "$", "methods", "as", "$", "httpMethod", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "$", "httpMethod", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}", "}" ]
Route that handles all HTTP request methods @param array $methods List of HTTP methods to support, i.e: [GET,POST,EDIT] @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Route", "that", "handles", "all", "HTTP", "request", "methods" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L271-L278
18,471
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.confirmGoBack
public function confirmGoBack($user, $message) { if (self::validationVariations($message, 1, "yes")) { //go back to the main menu self::resetUser($user); $user->menu_id = 2; $user->session = 1; $user->progress = 1; $user->save(); //get home menu $menu = ussd_menu::find(2); $menu_items = self::getMenuItems($menu->id); $i = 1; $response = $menu->title . PHP_EOL; foreach ($menu_items as $key => $value) { $response = $response . $i . ": " . $value->description . PHP_EOL; $i++; } self::sendResponse($response, 1, $user); exit; } elseif (self::validationVariations($message, 2, "no")) { $response = "Thank you for using our service"; self::sendResponse($response, 3, $user); } else { $response = ''; self::sendResponse($response, 2, $user); exit; } }
php
public function confirmGoBack($user, $message) { if (self::validationVariations($message, 1, "yes")) { //go back to the main menu self::resetUser($user); $user->menu_id = 2; $user->session = 1; $user->progress = 1; $user->save(); //get home menu $menu = ussd_menu::find(2); $menu_items = self::getMenuItems($menu->id); $i = 1; $response = $menu->title . PHP_EOL; foreach ($menu_items as $key => $value) { $response = $response . $i . ": " . $value->description . PHP_EOL; $i++; } self::sendResponse($response, 1, $user); exit; } elseif (self::validationVariations($message, 2, "no")) { $response = "Thank you for using our service"; self::sendResponse($response, 3, $user); } else { $response = ''; self::sendResponse($response, 2, $user); exit; } }
[ "public", "function", "confirmGoBack", "(", "$", "user", ",", "$", "message", ")", "{", "if", "(", "self", "::", "validationVariations", "(", "$", "message", ",", "1", ",", "\"yes\"", ")", ")", "{", "//go back to the main menu", "self", "::", "resetUser", "(", "$", "user", ")", ";", "$", "user", "->", "menu_id", "=", "2", ";", "$", "user", "->", "session", "=", "1", ";", "$", "user", "->", "progress", "=", "1", ";", "$", "user", "->", "save", "(", ")", ";", "//get home menu", "$", "menu", "=", "ussd_menu", "::", "find", "(", "2", ")", ";", "$", "menu_items", "=", "self", "::", "getMenuItems", "(", "$", "menu", "->", "id", ")", ";", "$", "i", "=", "1", ";", "$", "response", "=", "$", "menu", "->", "title", ".", "PHP_EOL", ";", "foreach", "(", "$", "menu_items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "response", "=", "$", "response", ".", "$", "i", ".", "\": \"", ".", "$", "value", "->", "description", ".", "PHP_EOL", ";", "$", "i", "++", ";", "}", "self", "::", "sendResponse", "(", "$", "response", ",", "1", ",", "$", "user", ")", ";", "exit", ";", "}", "elseif", "(", "self", "::", "validationVariations", "(", "$", "message", ",", "2", ",", "\"no\"", ")", ")", "{", "$", "response", "=", "\"Thank you for using our service\"", ";", "self", "::", "sendResponse", "(", "$", "response", ",", "3", ",", "$", "user", ")", ";", "}", "else", "{", "$", "response", "=", "''", ";", "self", "::", "sendResponse", "(", "$", "response", ",", "2", ",", "$", "user", ")", ";", "exit", ";", "}", "}" ]
confirm go back
[ "confirm", "go", "back" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L112-L145
18,472
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.postUssdConfirmationProcess
public function postUssdConfirmationProcess($user) { switch ($user->confirm_from) { case 1: $no = substr($user->phone, -9); $data['email'] = "0".$no."@agin.com"; User::create($data); return true; break; default : return true; break; } }
php
public function postUssdConfirmationProcess($user) { switch ($user->confirm_from) { case 1: $no = substr($user->phone, -9); $data['email'] = "0".$no."@agin.com"; User::create($data); return true; break; default : return true; break; } }
[ "public", "function", "postUssdConfirmationProcess", "(", "$", "user", ")", "{", "switch", "(", "$", "user", "->", "confirm_from", ")", "{", "case", "1", ":", "$", "no", "=", "substr", "(", "$", "user", "->", "phone", ",", "-", "9", ")", ";", "$", "data", "[", "'email'", "]", "=", "\"0\"", ".", "$", "no", ".", "\"@agin.com\"", ";", "User", "::", "create", "(", "$", "data", ")", ";", "return", "true", ";", "break", ";", "default", ":", "return", "true", ";", "break", ";", "}", "}" ]
post ussd confirmation, define your processes
[ "post", "ussd", "confirmation", "define", "your", "processes" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L183-L201
18,473
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.continueUssdMenuProcess
public function continueUssdMenuProcess($user,$message){ $menu = ussd_menu::find($user->menu_id); //check the user menu switch ($menu->type) { case 0: //authentication mini app break; case 1: //continue to another menu $response = self::continueUssdMenu($user,$message,$menu); break; case 2: //continue to a processs $response = self::continueSingleProcess($user,$message,$menu); break; case 3: //infomation mini app // self::infoMiniApp($user,$menu); break; default : self::resetUser($user); $response = "An error occurred"; break; } return $response; }
php
public function continueUssdMenuProcess($user,$message){ $menu = ussd_menu::find($user->menu_id); //check the user menu switch ($menu->type) { case 0: //authentication mini app break; case 1: //continue to another menu $response = self::continueUssdMenu($user,$message,$menu); break; case 2: //continue to a processs $response = self::continueSingleProcess($user,$message,$menu); break; case 3: //infomation mini app // self::infoMiniApp($user,$menu); break; default : self::resetUser($user); $response = "An error occurred"; break; } return $response; }
[ "public", "function", "continueUssdMenuProcess", "(", "$", "user", ",", "$", "message", ")", "{", "$", "menu", "=", "ussd_menu", "::", "find", "(", "$", "user", "->", "menu_id", ")", ";", "//check the user menu", "switch", "(", "$", "menu", "->", "type", ")", "{", "case", "0", ":", "//authentication mini app", "break", ";", "case", "1", ":", "//continue to another menu", "$", "response", "=", "self", "::", "continueUssdMenu", "(", "$", "user", ",", "$", "message", ",", "$", "menu", ")", ";", "break", ";", "case", "2", ":", "//continue to a processs", "$", "response", "=", "self", "::", "continueSingleProcess", "(", "$", "user", ",", "$", "message", ",", "$", "menu", ")", ";", "break", ";", "case", "3", ":", "//infomation mini app", "//", "self", "::", "infoMiniApp", "(", "$", "user", ",", "$", "menu", ")", ";", "break", ";", "default", ":", "self", "::", "resetUser", "(", "$", "user", ")", ";", "$", "response", "=", "\"An error occurred\"", ";", "break", ";", "}", "return", "$", "response", ";", "}" ]
continue USSD Menu Progress
[ "continue", "USSD", "Menu", "Progress" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L231-L262
18,474
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.infoMiniApp
public function infoMiniApp($user,$menu){ echo "infoMiniAppbased on menu_id"; exit; switch ($menu->id) { case 4: //get the loan balance break; case 5: break; case 6: default : $response = $menu->confirmation_message; $notify = new NotifyController(); //$notify->sendSms($user->phone_no,$response); //self::resetUser($user); self::sendResponse($response,2,$user); break; } }
php
public function infoMiniApp($user,$menu){ echo "infoMiniAppbased on menu_id"; exit; switch ($menu->id) { case 4: //get the loan balance break; case 5: break; case 6: default : $response = $menu->confirmation_message; $notify = new NotifyController(); //$notify->sendSms($user->phone_no,$response); //self::resetUser($user); self::sendResponse($response,2,$user); break; } }
[ "public", "function", "infoMiniApp", "(", "$", "user", ",", "$", "menu", ")", "{", "echo", "\"infoMiniAppbased on menu_id\"", ";", "exit", ";", "switch", "(", "$", "menu", "->", "id", ")", "{", "case", "4", ":", "//get the loan balance", "break", ";", "case", "5", ":", "break", ";", "case", "6", ":", "default", ":", "$", "response", "=", "$", "menu", "->", "confirmation_message", ";", "$", "notify", "=", "new", "NotifyController", "(", ")", ";", "//$notify->sendSms($user->phone_no,$response);", "//self::resetUser($user);", "self", "::", "sendResponse", "(", "$", "response", ",", "2", ",", "$", "user", ")", ";", "break", ";", "}", "}" ]
info mini app
[ "info", "mini", "app" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L265-L291
18,475
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.continueUssdMenu
public function continueUssdMenu($user,$message,$menu){ //verify response $menu_items = self::getMenuItems($user->menu_id); $i = 1; $choice = ""; $next_menu_id = 0; foreach ($menu_items as $key => $value) { if(self::validationVariations(trim($message),$i,$value->description)){ $choice = $value->id; $next_menu_id = $value->next_menu_id; break; } $i++; } if(empty($choice)){ //get error, we could not understand your response $response = "We could not understand your response". PHP_EOL; $i = 1; $response = $menu->title.PHP_EOL; foreach ($menu_items as $key => $value) { $response = $response . $i . ": " . $value->description . PHP_EOL; $i++; } return $response; //save the response }else{ //there is a selected choice $menu = ussd_menu::find($next_menu_id); //next menu switch $response = self::nextMenuSwitch($user,$menu); return $response; } }
php
public function continueUssdMenu($user,$message,$menu){ //verify response $menu_items = self::getMenuItems($user->menu_id); $i = 1; $choice = ""; $next_menu_id = 0; foreach ($menu_items as $key => $value) { if(self::validationVariations(trim($message),$i,$value->description)){ $choice = $value->id; $next_menu_id = $value->next_menu_id; break; } $i++; } if(empty($choice)){ //get error, we could not understand your response $response = "We could not understand your response". PHP_EOL; $i = 1; $response = $menu->title.PHP_EOL; foreach ($menu_items as $key => $value) { $response = $response . $i . ": " . $value->description . PHP_EOL; $i++; } return $response; //save the response }else{ //there is a selected choice $menu = ussd_menu::find($next_menu_id); //next menu switch $response = self::nextMenuSwitch($user,$menu); return $response; } }
[ "public", "function", "continueUssdMenu", "(", "$", "user", ",", "$", "message", ",", "$", "menu", ")", "{", "//verify response", "$", "menu_items", "=", "self", "::", "getMenuItems", "(", "$", "user", "->", "menu_id", ")", ";", "$", "i", "=", "1", ";", "$", "choice", "=", "\"\"", ";", "$", "next_menu_id", "=", "0", ";", "foreach", "(", "$", "menu_items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "self", "::", "validationVariations", "(", "trim", "(", "$", "message", ")", ",", "$", "i", ",", "$", "value", "->", "description", ")", ")", "{", "$", "choice", "=", "$", "value", "->", "id", ";", "$", "next_menu_id", "=", "$", "value", "->", "next_menu_id", ";", "break", ";", "}", "$", "i", "++", ";", "}", "if", "(", "empty", "(", "$", "choice", ")", ")", "{", "//get error, we could not understand your response", "$", "response", "=", "\"We could not understand your response\"", ".", "PHP_EOL", ";", "$", "i", "=", "1", ";", "$", "response", "=", "$", "menu", "->", "title", ".", "PHP_EOL", ";", "foreach", "(", "$", "menu_items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "response", "=", "$", "response", ".", "$", "i", ".", "\": \"", ".", "$", "value", "->", "description", ".", "PHP_EOL", ";", "$", "i", "++", ";", "}", "return", "$", "response", ";", "//save the response", "}", "else", "{", "//there is a selected choice", "$", "menu", "=", "ussd_menu", "::", "find", "(", "$", "next_menu_id", ")", ";", "//next menu switch", "$", "response", "=", "self", "::", "nextMenuSwitch", "(", "$", "user", ",", "$", "menu", ")", ";", "return", "$", "response", ";", "}", "}" ]
continue USSD Menu
[ "continue", "USSD", "Menu" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L323-L361
18,476
le-yo/rapidussd
src/Http/Controllers/UssdController.php
UssdController.storeUssdResponse
public function storeUssdResponse($user,$message){ $data = ['user_id'=>$user->id,'menu_id'=>$user->menu_id,'menu_item_id'=>$user->menu_item_id,'response'=>$message]; return ussd_response::create($data); }
php
public function storeUssdResponse($user,$message){ $data = ['user_id'=>$user->id,'menu_id'=>$user->menu_id,'menu_item_id'=>$user->menu_item_id,'response'=>$message]; return ussd_response::create($data); }
[ "public", "function", "storeUssdResponse", "(", "$", "user", ",", "$", "message", ")", "{", "$", "data", "=", "[", "'user_id'", "=>", "$", "user", "->", "id", ",", "'menu_id'", "=>", "$", "user", "->", "menu_id", ",", "'menu_item_id'", "=>", "$", "user", "->", "menu_item_id", ",", "'response'", "=>", "$", "message", "]", ";", "return", "ussd_response", "::", "create", "(", "$", "data", ")", ";", "}" ]
store USSD response
[ "store", "USSD", "response" ]
37e97a469b31f5a788a8088ed7c4f7b29e040e09
https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L421-L427
18,477
CakeCMS/Core
src/View/Helper/JsHelper.php
JsHelper.getBuffer
public function getBuffer(array $options = []) { $docEol = $this->Document->eol; $options = Hash::merge(['safe' => true], $options); if (Arr::key('block', $options)) { unset($options['block']); } if (count($this->_buffers)) { $scripts = $docEol . 'jQuery (function($) {' . $docEol . implode($docEol, $this->_buffers) . $docEol . '});' . $docEol; return $this->Html->scriptBlock($scripts, $options) . $docEol; } return null; }
php
public function getBuffer(array $options = []) { $docEol = $this->Document->eol; $options = Hash::merge(['safe' => true], $options); if (Arr::key('block', $options)) { unset($options['block']); } if (count($this->_buffers)) { $scripts = $docEol . 'jQuery (function($) {' . $docEol . implode($docEol, $this->_buffers) . $docEol . '});' . $docEol; return $this->Html->scriptBlock($scripts, $options) . $docEol; } return null; }
[ "public", "function", "getBuffer", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "docEol", "=", "$", "this", "->", "Document", "->", "eol", ";", "$", "options", "=", "Hash", "::", "merge", "(", "[", "'safe'", "=>", "true", "]", ",", "$", "options", ")", ";", "if", "(", "Arr", "::", "key", "(", "'block'", ",", "$", "options", ")", ")", "{", "unset", "(", "$", "options", "[", "'block'", "]", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "_buffers", ")", ")", "{", "$", "scripts", "=", "$", "docEol", ".", "'jQuery (function($) {'", ".", "$", "docEol", ".", "implode", "(", "$", "docEol", ",", "$", "this", "->", "_buffers", ")", ".", "$", "docEol", ".", "'});'", ".", "$", "docEol", ";", "return", "$", "this", "->", "Html", "->", "scriptBlock", "(", "$", "scripts", ",", "$", "options", ")", ".", "$", "docEol", ";", "}", "return", "null", ";", "}" ]
Get all holds in buffer scripts. @param array $options @return null|string
[ "Get", "all", "holds", "in", "buffer", "scripts", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L69-L88
18,478
CakeCMS/Core
src/View/Helper/JsHelper.php
JsHelper.setBuffer
public function setBuffer($script, $top = false) { $script = trim($script); if ($top) { array_unshift($this->_buffers, $script); } else { array_push($this->_buffers, $script); } return $this; }
php
public function setBuffer($script, $top = false) { $script = trim($script); if ($top) { array_unshift($this->_buffers, $script); } else { array_push($this->_buffers, $script); } return $this; }
[ "public", "function", "setBuffer", "(", "$", "script", ",", "$", "top", "=", "false", ")", "{", "$", "script", "=", "trim", "(", "$", "script", ")", ";", "if", "(", "$", "top", ")", "{", "array_unshift", "(", "$", "this", "->", "_buffers", ",", "$", "script", ")", ";", "}", "else", "{", "array_push", "(", "$", "this", "->", "_buffers", ",", "$", "script", ")", ";", "}", "return", "$", "this", ";", "}" ]
Setup buffer script. @param string $script @param bool|false $top @return $this
[ "Setup", "buffer", "script", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L97-L107
18,479
CakeCMS/Core
src/View/Helper/JsHelper.php
JsHelper.widget
public function widget($jSelector, $widgetName, array $params = [], $return = false) { static $included = []; $jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector; $hash = $jSelector . ' /// ' . $widgetName; if (!Arr::key($hash, $included)) { $included[$hash] = true; $widgetName = str_replace('.', '', $widgetName); $initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');'; if ($return) { return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});"); } $this->setBuffer($initScript); } return null; }
php
public function widget($jSelector, $widgetName, array $params = [], $return = false) { static $included = []; $jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector; $hash = $jSelector . ' /// ' . $widgetName; if (!Arr::key($hash, $included)) { $included[$hash] = true; $widgetName = str_replace('.', '', $widgetName); $initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');'; if ($return) { return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});"); } $this->setBuffer($initScript); } return null; }
[ "public", "function", "widget", "(", "$", "jSelector", ",", "$", "widgetName", ",", "array", "$", "params", "=", "[", "]", ",", "$", "return", "=", "false", ")", "{", "static", "$", "included", "=", "[", "]", ";", "$", "jSelector", "=", "is_array", "(", "$", "jSelector", ")", "?", "implode", "(", "', '", ",", "$", "jSelector", ")", ":", "$", "jSelector", ";", "$", "hash", "=", "$", "jSelector", ".", "' /// '", ".", "$", "widgetName", ";", "if", "(", "!", "Arr", "::", "key", "(", "$", "hash", ",", "$", "included", ")", ")", "{", "$", "included", "[", "$", "hash", "]", "=", "true", ";", "$", "widgetName", "=", "str_replace", "(", "'.'", ",", "''", ",", "$", "widgetName", ")", ";", "$", "initScript", "=", "'$(\"'", ".", "$", "jSelector", ".", "'\").'", ".", "$", "widgetName", ".", "'('", ".", "json_encode", "(", "$", "params", ")", ".", "');'", ";", "if", "(", "$", "return", ")", "{", "return", "$", "this", "->", "Html", "->", "scriptBlock", "(", "\"\\tjQuery(function($){\"", ".", "$", "initScript", ".", "\"});\"", ")", ";", "}", "$", "this", "->", "setBuffer", "(", "$", "initScript", ")", ";", "}", "return", "null", ";", "}" ]
Initialize java script widget. @param string $jSelector @param string $widgetName @param array $params @param bool $return @return string|null
[ "Initialize", "java", "script", "widget", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L118-L139
18,480
CakeCMS/Core
src/View/Helper/JsHelper.php
JsHelper._setScriptVars
protected function _setScriptVars() { $request = $this->request; $vars = [ 'baseUrl' => Router::fullBaseUrl(), 'alert' => [ 'ok' => __d('alert', 'Ok'), 'cancel' => __d('alert', 'Cancel'), 'sure' => __d('alert', 'Are you sure?'), ], 'request' => [ 'url' => $request->getPath(), 'params' => [ 'pass' => $request->getParam('pass'), 'theme' => $request->getParam('theme'), 'action' => $request->getParam('action'), 'prefix' => $request->getParam('prefix'), 'plugin' => $request->getParam('plugin'), 'controller' => $request->getParam('controller'), ], 'query' => $this->request->getQueryParams(), 'base' => $request->getAttribute('base'), 'here' => $request->getRequestTarget(), ] ]; $this->Html->scriptBlock('window.CMS = ' . json_encode($vars), ['block' => 'css_bottom']); }
php
protected function _setScriptVars() { $request = $this->request; $vars = [ 'baseUrl' => Router::fullBaseUrl(), 'alert' => [ 'ok' => __d('alert', 'Ok'), 'cancel' => __d('alert', 'Cancel'), 'sure' => __d('alert', 'Are you sure?'), ], 'request' => [ 'url' => $request->getPath(), 'params' => [ 'pass' => $request->getParam('pass'), 'theme' => $request->getParam('theme'), 'action' => $request->getParam('action'), 'prefix' => $request->getParam('prefix'), 'plugin' => $request->getParam('plugin'), 'controller' => $request->getParam('controller'), ], 'query' => $this->request->getQueryParams(), 'base' => $request->getAttribute('base'), 'here' => $request->getRequestTarget(), ] ]; $this->Html->scriptBlock('window.CMS = ' . json_encode($vars), ['block' => 'css_bottom']); }
[ "protected", "function", "_setScriptVars", "(", ")", "{", "$", "request", "=", "$", "this", "->", "request", ";", "$", "vars", "=", "[", "'baseUrl'", "=>", "Router", "::", "fullBaseUrl", "(", ")", ",", "'alert'", "=>", "[", "'ok'", "=>", "__d", "(", "'alert'", ",", "'Ok'", ")", ",", "'cancel'", "=>", "__d", "(", "'alert'", ",", "'Cancel'", ")", ",", "'sure'", "=>", "__d", "(", "'alert'", ",", "'Are you sure?'", ")", ",", "]", ",", "'request'", "=>", "[", "'url'", "=>", "$", "request", "->", "getPath", "(", ")", ",", "'params'", "=>", "[", "'pass'", "=>", "$", "request", "->", "getParam", "(", "'pass'", ")", ",", "'theme'", "=>", "$", "request", "->", "getParam", "(", "'theme'", ")", ",", "'action'", "=>", "$", "request", "->", "getParam", "(", "'action'", ")", ",", "'prefix'", "=>", "$", "request", "->", "getParam", "(", "'prefix'", ")", ",", "'plugin'", "=>", "$", "request", "->", "getParam", "(", "'plugin'", ")", ",", "'controller'", "=>", "$", "request", "->", "getParam", "(", "'controller'", ")", ",", "]", ",", "'query'", "=>", "$", "this", "->", "request", "->", "getQueryParams", "(", ")", ",", "'base'", "=>", "$", "request", "->", "getAttribute", "(", "'base'", ")", ",", "'here'", "=>", "$", "request", "->", "getRequestTarget", "(", ")", ",", "]", "]", ";", "$", "this", "->", "Html", "->", "scriptBlock", "(", "'window.CMS = '", ".", "json_encode", "(", "$", "vars", ")", ",", "[", "'block'", "=>", "'css_bottom'", "]", ")", ";", "}" ]
Setup java script variables from server. @return void
[ "Setup", "java", "script", "variables", "from", "server", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L146-L173
18,481
alanpich/slender
src/Core/ModuleLoader/Factory.php
Factory.create
public function create(\Slender\App $app) { $loader = new ModuleLoader(); $loader->setResolver($app['module-resolver']); $loader->setConfig($app['settings']); $loader->setClassLoader($app['autoloader']); return $loader; }
php
public function create(\Slender\App $app) { $loader = new ModuleLoader(); $loader->setResolver($app['module-resolver']); $loader->setConfig($app['settings']); $loader->setClassLoader($app['autoloader']); return $loader; }
[ "public", "function", "create", "(", "\\", "Slender", "\\", "App", "$", "app", ")", "{", "$", "loader", "=", "new", "ModuleLoader", "(", ")", ";", "$", "loader", "->", "setResolver", "(", "$", "app", "[", "'module-resolver'", "]", ")", ";", "$", "loader", "->", "setConfig", "(", "$", "app", "[", "'settings'", "]", ")", ";", "$", "loader", "->", "setClassLoader", "(", "$", "app", "[", "'autoloader'", "]", ")", ";", "return", "$", "loader", ";", "}" ]
Create a ModuleLoader instance @param \Slender\App $app Slender Application instance @return ModuleLoader
[ "Create", "a", "ModuleLoader", "instance" ]
247f5c08af20cda95b116eb5d9f6f623d61e8a8a
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleLoader/Factory.php#L52-L60
18,482
SachaMorard/phalcon-console
Library/Phalcon/Commands/CommandsListener.php
CommandsListener.beforeCommand
public function beforeCommand(Event $event, Command $command) { $parameters = $command->parseParameters([], ['h' => 'help']); if ( count($parameters) < ($command->getRequiredParams() + 1) || $command->isReceivedOption(['help', 'h', '?']) || in_array($command->getOption(1), ['help', 'h', '?']) ) { $command->getHelp(); return false; } if( !defined('BASE_PATH') ) { throw new CommandsException('Commands need a BASE_PATH constant defined.'); } if ($command->canBeExternal() == false) { $path = $command->getOption('directory'); if (!file_exists($path.'.phalcon')) { throw new CommandsException('This command should be invoked inside a Phalcon project directory.'); } } return true; }
php
public function beforeCommand(Event $event, Command $command) { $parameters = $command->parseParameters([], ['h' => 'help']); if ( count($parameters) < ($command->getRequiredParams() + 1) || $command->isReceivedOption(['help', 'h', '?']) || in_array($command->getOption(1), ['help', 'h', '?']) ) { $command->getHelp(); return false; } if( !defined('BASE_PATH') ) { throw new CommandsException('Commands need a BASE_PATH constant defined.'); } if ($command->canBeExternal() == false) { $path = $command->getOption('directory'); if (!file_exists($path.'.phalcon')) { throw new CommandsException('This command should be invoked inside a Phalcon project directory.'); } } return true; }
[ "public", "function", "beforeCommand", "(", "Event", "$", "event", ",", "Command", "$", "command", ")", "{", "$", "parameters", "=", "$", "command", "->", "parseParameters", "(", "[", "]", ",", "[", "'h'", "=>", "'help'", "]", ")", ";", "if", "(", "count", "(", "$", "parameters", ")", "<", "(", "$", "command", "->", "getRequiredParams", "(", ")", "+", "1", ")", "||", "$", "command", "->", "isReceivedOption", "(", "[", "'help'", ",", "'h'", ",", "'?'", "]", ")", "||", "in_array", "(", "$", "command", "->", "getOption", "(", "1", ")", ",", "[", "'help'", ",", "'h'", ",", "'?'", "]", ")", ")", "{", "$", "command", "->", "getHelp", "(", ")", ";", "return", "false", ";", "}", "if", "(", "!", "defined", "(", "'BASE_PATH'", ")", ")", "{", "throw", "new", "CommandsException", "(", "'Commands need a BASE_PATH constant defined.'", ")", ";", "}", "if", "(", "$", "command", "->", "canBeExternal", "(", ")", "==", "false", ")", "{", "$", "path", "=", "$", "command", "->", "getOption", "(", "'directory'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ".", "'.phalcon'", ")", ")", "{", "throw", "new", "CommandsException", "(", "'This command should be invoked inside a Phalcon project directory.'", ")", ";", "}", "}", "return", "true", ";", "}" ]
Before command executing @param Event $event @param Command $command @return bool @throws CommandsException
[ "Before", "command", "executing" ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/CommandsListener.php#L41-L67
18,483
onigoetz/imagecache
src/Image.php
Image.getInfo
public function getInfo() { $this->info = [ 'width' => $this->getWidth(), 'height' => $this->getHeight(), 'file_size' => $this->getFileSize(), ]; return $this->info; }
php
public function getInfo() { $this->info = [ 'width' => $this->getWidth(), 'height' => $this->getHeight(), 'file_size' => $this->getFileSize(), ]; return $this->info; }
[ "public", "function", "getInfo", "(", ")", "{", "$", "this", "->", "info", "=", "[", "'width'", "=>", "$", "this", "->", "getWidth", "(", ")", ",", "'height'", "=>", "$", "this", "->", "getHeight", "(", ")", ",", "'file_size'", "=>", "$", "this", "->", "getFileSize", "(", ")", ",", "]", ";", "return", "$", "this", "->", "info", ";", "}" ]
Get details about an image. @return bool|array false, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image: - "width": Width, in pixels. - "height": Height, in pixels. - "file_size": File size in bytes.
[ "Get", "details", "about", "an", "image", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L106-L115
18,484
onigoetz/imagecache
src/Image.php
Image.scale_and_crop
public function scale_and_crop($width, $height) { if ($width === null) { throw new \LogicException('"width" must not be null for "scale_and_crop"'); } if ($height === null) { throw new \LogicException('"height" must not be null for "scale_and_crop"'); } $scale = max($width / $this->getWidth(), $height / $this->getHeight()); $w = ceil($this->getWidth() * $scale); $h = ceil($this->getHeight() * $scale); $x = ($w - $width) / 2; $y = ($h - $height) / 2; $this->resize($w, $h); $this->crop($x, $y, $width, $height); }
php
public function scale_and_crop($width, $height) { if ($width === null) { throw new \LogicException('"width" must not be null for "scale_and_crop"'); } if ($height === null) { throw new \LogicException('"height" must not be null for "scale_and_crop"'); } $scale = max($width / $this->getWidth(), $height / $this->getHeight()); $w = ceil($this->getWidth() * $scale); $h = ceil($this->getHeight() * $scale); $x = ($w - $width) / 2; $y = ($h - $height) / 2; $this->resize($w, $h); $this->crop($x, $y, $width, $height); }
[ "public", "function", "scale_and_crop", "(", "$", "width", ",", "$", "height", ")", "{", "if", "(", "$", "width", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"width\" must not be null for \"scale_and_crop\"'", ")", ";", "}", "if", "(", "$", "height", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"height\" must not be null for \"scale_and_crop\"'", ")", ";", "}", "$", "scale", "=", "max", "(", "$", "width", "/", "$", "this", "->", "getWidth", "(", ")", ",", "$", "height", "/", "$", "this", "->", "getHeight", "(", ")", ")", ";", "$", "w", "=", "ceil", "(", "$", "this", "->", "getWidth", "(", ")", "*", "$", "scale", ")", ";", "$", "h", "=", "ceil", "(", "$", "this", "->", "getHeight", "(", ")", "*", "$", "scale", ")", ";", "$", "x", "=", "(", "$", "w", "-", "$", "width", ")", "/", "2", ";", "$", "y", "=", "(", "$", "h", "-", "$", "height", ")", "/", "2", ";", "$", "this", "->", "resize", "(", "$", "w", ",", "$", "h", ")", ";", "$", "this", "->", "crop", "(", "$", "x", ",", "$", "y", ",", "$", "width", ",", "$", "height", ")", ";", "}" ]
Scales an image to the exact width and height given. This function achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is useful to create uniform sized avatars from larger images. The resulting image always has the exact target dimensions. @param int $width The target width, in pixels. @param int $height The target height, in pixels. @throws \LogicException if the parameters are wrong @see resize() @see crop()
[ "Scales", "an", "image", "to", "the", "exact", "width", "and", "height", "given", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L134-L152
18,485
onigoetz/imagecache
src/Image.php
Image.scale
public function scale($width = null, $height = null) { if ($width === null && $height === null) { throw new \LogicException('one of "width" or "height" must be set for "scale"'); } if ($width !== null && $height !== null) { $this->resize($width, $height); return; } if ($width !== null) { $this->image->widen($width); return; } $this->image->heighten($height); }
php
public function scale($width = null, $height = null) { if ($width === null && $height === null) { throw new \LogicException('one of "width" or "height" must be set for "scale"'); } if ($width !== null && $height !== null) { $this->resize($width, $height); return; } if ($width !== null) { $this->image->widen($width); return; } $this->image->heighten($height); }
[ "public", "function", "scale", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ")", "{", "if", "(", "$", "width", "===", "null", "&&", "$", "height", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'one of \"width\" or \"height\" must be set for \"scale\"'", ")", ";", "}", "if", "(", "$", "width", "!==", "null", "&&", "$", "height", "!==", "null", ")", "{", "$", "this", "->", "resize", "(", "$", "width", ",", "$", "height", ")", ";", "return", ";", "}", "if", "(", "$", "width", "!==", "null", ")", "{", "$", "this", "->", "image", "->", "widen", "(", "$", "width", ")", ";", "return", ";", "}", "$", "this", "->", "image", "->", "heighten", "(", "$", "height", ")", ";", "}" ]
Scales an image to the given width and height while maintaining aspect ratio. The resulting image can be smaller for one or both target dimensions. @param int $width The target width, in pixels. This value is omitted then the scaling will based only on the height value. @param int $height The target height, in pixels. This value is omitted then the scaling will based only on the width value.
[ "Scales", "an", "image", "to", "the", "given", "width", "and", "height", "while", "maintaining", "aspect", "ratio", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L166-L183
18,486
onigoetz/imagecache
src/Image.php
Image.rotate
public function rotate($degrees, $background = null, $random = false) { if ($background) { $background = trim($background); } else { $background = "ffffff"; } if ($random) { $deg = abs((float) $degrees); $degrees = rand(-1 * $deg, $deg); } $this->image->rotate($degrees, $background); }
php
public function rotate($degrees, $background = null, $random = false) { if ($background) { $background = trim($background); } else { $background = "ffffff"; } if ($random) { $deg = abs((float) $degrees); $degrees = rand(-1 * $deg, $deg); } $this->image->rotate($degrees, $background); }
[ "public", "function", "rotate", "(", "$", "degrees", ",", "$", "background", "=", "null", ",", "$", "random", "=", "false", ")", "{", "if", "(", "$", "background", ")", "{", "$", "background", "=", "trim", "(", "$", "background", ")", ";", "}", "else", "{", "$", "background", "=", "\"ffffff\"", ";", "}", "if", "(", "$", "random", ")", "{", "$", "deg", "=", "abs", "(", "(", "float", ")", "$", "degrees", ")", ";", "$", "degrees", "=", "rand", "(", "-", "1", "*", "$", "deg", ",", "$", "deg", ")", ";", "}", "$", "this", "->", "image", "->", "rotate", "(", "$", "degrees", ",", "$", "background", ")", ";", "}" ]
Rotate an image by the given number of degrees. @param int $degrees The number of (clockwise) degrees to rotate the image. @param string|null $background hexadecimal background color @param bool $random
[ "Rotate", "an", "image", "by", "the", "given", "number", "of", "degrees", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L203-L217
18,487
onigoetz/imagecache
src/Image.php
Image.crop
public function crop($xoffset, $yoffset, $width, $height) { if ($xoffset === null) { throw new \LogicException('"xoffset" must not be null for "crop"'); } if ($yoffset === null) { throw new \LogicException('"yoffset" must not be null for "crop"'); } if ($width === null) { throw new \LogicException('"width" must not be null for "crop"'); } if ($height === null) { throw new \LogicException('"height" must not be null for "crop"'); } $this->image->crop($width, $height, $xoffset, $yoffset); }
php
public function crop($xoffset, $yoffset, $width, $height) { if ($xoffset === null) { throw new \LogicException('"xoffset" must not be null for "crop"'); } if ($yoffset === null) { throw new \LogicException('"yoffset" must not be null for "crop"'); } if ($width === null) { throw new \LogicException('"width" must not be null for "crop"'); } if ($height === null) { throw new \LogicException('"height" must not be null for "crop"'); } $this->image->crop($width, $height, $xoffset, $yoffset); }
[ "public", "function", "crop", "(", "$", "xoffset", ",", "$", "yoffset", ",", "$", "width", ",", "$", "height", ")", "{", "if", "(", "$", "xoffset", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"xoffset\" must not be null for \"crop\"'", ")", ";", "}", "if", "(", "$", "yoffset", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"yoffset\" must not be null for \"crop\"'", ")", ";", "}", "if", "(", "$", "width", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"width\" must not be null for \"crop\"'", ")", ";", "}", "if", "(", "$", "height", "===", "null", ")", "{", "throw", "new", "\\", "LogicException", "(", "'\"height\" must not be null for \"crop\"'", ")", ";", "}", "$", "this", "->", "image", "->", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "xoffset", ",", "$", "yoffset", ")", ";", "}" ]
Crop an image to the rectangle specified by the given rectangle. @param int $xoffset The top left coordinate, in pixels, of the crop area (x axis value). @param int $yoffset The top left coordinate, in pixels, of the crop area (y axis value). @param int $width The target width, in pixels. @param int $height The target height, in pixels. @throws \LogicException if the parameters are wrong
[ "Crop", "an", "image", "to", "the", "rectangle", "specified", "by", "the", "given", "rectangle", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L233-L252
18,488
onigoetz/imagecache
src/Image.php
Image.save
public function save($destination = null) { if (empty($destination)) { $destination = $this->source; } $this->image->save($destination); // Clear the cached file size and refresh the image information. clearstatcache(); chmod($destination, 0644); return new self($destination); }
php
public function save($destination = null) { if (empty($destination)) { $destination = $this->source; } $this->image->save($destination); // Clear the cached file size and refresh the image information. clearstatcache(); chmod($destination, 0644); return new self($destination); }
[ "public", "function", "save", "(", "$", "destination", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "destination", ")", ")", "{", "$", "destination", "=", "$", "this", "->", "source", ";", "}", "$", "this", "->", "image", "->", "save", "(", "$", "destination", ")", ";", "// Clear the cached file size and refresh the image information.", "clearstatcache", "(", ")", ";", "chmod", "(", "$", "destination", ",", "0644", ")", ";", "return", "new", "self", "(", "$", "destination", ")", ";", "}" ]
Close the image and save the changes to a file. @param string|null $destination Destination path where the image should be saved. If it is empty the original image file will be overwritten. @throws \RuntimeException @return Image image or false, based on success.
[ "Close", "the", "image", "and", "save", "the", "changes", "to", "a", "file", "." ]
8e22c11def1733819183e8296bab3c8a4ffc1d9c
https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L269-L283
18,489
FuriosoJack/LaraException
src/ExceptionFather.php
ExceptionFather.buildException
private function buildException() { if($this->isJsonRequest()){ $this->setException(new ExceptionJson($this->message,$this->debugCode,$this->details,$this->errors)); }else{ $exception = new ExceptionView($this->message,$this->debugCode,$this->details,$this->errors); $exception->setViewPath($this->getVewPath()); $exception->setRedirectPath($this->getRedirect()); $this->setException($exception); } }
php
private function buildException() { if($this->isJsonRequest()){ $this->setException(new ExceptionJson($this->message,$this->debugCode,$this->details,$this->errors)); }else{ $exception = new ExceptionView($this->message,$this->debugCode,$this->details,$this->errors); $exception->setViewPath($this->getVewPath()); $exception->setRedirectPath($this->getRedirect()); $this->setException($exception); } }
[ "private", "function", "buildException", "(", ")", "{", "if", "(", "$", "this", "->", "isJsonRequest", "(", ")", ")", "{", "$", "this", "->", "setException", "(", "new", "ExceptionJson", "(", "$", "this", "->", "message", ",", "$", "this", "->", "debugCode", ",", "$", "this", "->", "details", ",", "$", "this", "->", "errors", ")", ")", ";", "}", "else", "{", "$", "exception", "=", "new", "ExceptionView", "(", "$", "this", "->", "message", ",", "$", "this", "->", "debugCode", ",", "$", "this", "->", "details", ",", "$", "this", "->", "errors", ")", ";", "$", "exception", "->", "setViewPath", "(", "$", "this", "->", "getVewPath", "(", ")", ")", ";", "$", "exception", "->", "setRedirectPath", "(", "$", "this", "->", "getRedirect", "(", ")", ")", ";", "$", "this", "->", "setException", "(", "$", "exception", ")", ";", "}", "}" ]
Se encarga de construir el objeto de la excepcion
[ "Se", "encarga", "de", "construir", "el", "objeto", "de", "la", "excepcion" ]
b30ec2ed3331d99fca4d0ae47c8710a522bd0c19
https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/ExceptionFather.php#L203-L213
18,490
FuriosoJack/LaraException
src/ExceptionFather.php
ExceptionFather.build
public function build(int $httpCode = 200) { //Lo primero que todo $this->buildException(); if($this->log){ $this->renderLog(); } if(!$this->showDetails){ $this->getException()->setDetails(null); } if(!$this->showErrors){ $this->getException()->setErrors(null); } $this->getException()->setHttpCode($httpCode); throw $this->getException(); }
php
public function build(int $httpCode = 200) { //Lo primero que todo $this->buildException(); if($this->log){ $this->renderLog(); } if(!$this->showDetails){ $this->getException()->setDetails(null); } if(!$this->showErrors){ $this->getException()->setErrors(null); } $this->getException()->setHttpCode($httpCode); throw $this->getException(); }
[ "public", "function", "build", "(", "int", "$", "httpCode", "=", "200", ")", "{", "//Lo primero que todo", "$", "this", "->", "buildException", "(", ")", ";", "if", "(", "$", "this", "->", "log", ")", "{", "$", "this", "->", "renderLog", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "showDetails", ")", "{", "$", "this", "->", "getException", "(", ")", "->", "setDetails", "(", "null", ")", ";", "}", "if", "(", "!", "$", "this", "->", "showErrors", ")", "{", "$", "this", "->", "getException", "(", ")", "->", "setErrors", "(", "null", ")", ";", "}", "$", "this", "->", "getException", "(", ")", "->", "setHttpCode", "(", "$", "httpCode", ")", ";", "throw", "$", "this", "->", "getException", "(", ")", ";", "}" ]
Se encarga de le ejecucion para la contruccion de la escepcion @throws ExceptionJSON @throws ExceptionVIEW
[ "Se", "encarga", "de", "le", "ejecucion", "para", "la", "contruccion", "de", "la", "escepcion" ]
b30ec2ed3331d99fca4d0ae47c8710a522bd0c19
https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/ExceptionFather.php#L243-L263
18,491
Articus/DataTransfer
src/Articus/DataTransfer/Service.php
Service.transfer
public function transfer($fromObjectOrArray, &$toObjectOrArray, $mapper = null, $fromSubset = '', $toSubset = '') { $result = []; $data = null; //Extract data array switch (true) { case is_object($fromObjectOrArray): $fromMetadata = $this->metadataReader->getMetadata(get_class($fromObjectOrArray), $fromSubset); $fromHydrator = $this->getHydrator($fromMetadata); $data = $fromHydrator->extract($fromObjectOrArray); break; case is_array($fromObjectOrArray): $data = &$fromObjectOrArray; break; default: throw new \InvalidArgumentException('Data transfer is possible only from object or array.'); } //Map data array if (is_callable($mapper) || ($mapper instanceof Mapper\MapperInterface)) { $data = $mapper($data); if (!is_array($data)) { throw new \LogicException( sprintf('Invalid mapping: expecting array result, not %s.', gettype($data)) ); } } //Validate and hydrate data array switch (true) { case is_object($toObjectOrArray): $toMetadata = $this->metadataReader->getMetadata(get_class($toObjectOrArray), $toSubset); $toHydrator = $this->getHydrator($toMetadata); $validator = $this->getValidator($toMetadata); $result = $validator->validate(self::arrayTransfer($toHydrator->extract($toObjectOrArray), $data)); if (empty($result)) { $toObjectOrArray = $toHydrator->hydrate($data, $toObjectOrArray); } break; case is_array($toObjectOrArray): $toObjectOrArray = self::arrayTransfer($toObjectOrArray, $data); break; default: throw new \InvalidArgumentException('Data transfer is possible only to object or array.'); } return $result; }
php
public function transfer($fromObjectOrArray, &$toObjectOrArray, $mapper = null, $fromSubset = '', $toSubset = '') { $result = []; $data = null; //Extract data array switch (true) { case is_object($fromObjectOrArray): $fromMetadata = $this->metadataReader->getMetadata(get_class($fromObjectOrArray), $fromSubset); $fromHydrator = $this->getHydrator($fromMetadata); $data = $fromHydrator->extract($fromObjectOrArray); break; case is_array($fromObjectOrArray): $data = &$fromObjectOrArray; break; default: throw new \InvalidArgumentException('Data transfer is possible only from object or array.'); } //Map data array if (is_callable($mapper) || ($mapper instanceof Mapper\MapperInterface)) { $data = $mapper($data); if (!is_array($data)) { throw new \LogicException( sprintf('Invalid mapping: expecting array result, not %s.', gettype($data)) ); } } //Validate and hydrate data array switch (true) { case is_object($toObjectOrArray): $toMetadata = $this->metadataReader->getMetadata(get_class($toObjectOrArray), $toSubset); $toHydrator = $this->getHydrator($toMetadata); $validator = $this->getValidator($toMetadata); $result = $validator->validate(self::arrayTransfer($toHydrator->extract($toObjectOrArray), $data)); if (empty($result)) { $toObjectOrArray = $toHydrator->hydrate($data, $toObjectOrArray); } break; case is_array($toObjectOrArray): $toObjectOrArray = self::arrayTransfer($toObjectOrArray, $data); break; default: throw new \InvalidArgumentException('Data transfer is possible only to object or array.'); } return $result; }
[ "public", "function", "transfer", "(", "$", "fromObjectOrArray", ",", "&", "$", "toObjectOrArray", ",", "$", "mapper", "=", "null", ",", "$", "fromSubset", "=", "''", ",", "$", "toSubset", "=", "''", ")", "{", "$", "result", "=", "[", "]", ";", "$", "data", "=", "null", ";", "//Extract data array", "switch", "(", "true", ")", "{", "case", "is_object", "(", "$", "fromObjectOrArray", ")", ":", "$", "fromMetadata", "=", "$", "this", "->", "metadataReader", "->", "getMetadata", "(", "get_class", "(", "$", "fromObjectOrArray", ")", ",", "$", "fromSubset", ")", ";", "$", "fromHydrator", "=", "$", "this", "->", "getHydrator", "(", "$", "fromMetadata", ")", ";", "$", "data", "=", "$", "fromHydrator", "->", "extract", "(", "$", "fromObjectOrArray", ")", ";", "break", ";", "case", "is_array", "(", "$", "fromObjectOrArray", ")", ":", "$", "data", "=", "&", "$", "fromObjectOrArray", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Data transfer is possible only from object or array.'", ")", ";", "}", "//Map data array", "if", "(", "is_callable", "(", "$", "mapper", ")", "||", "(", "$", "mapper", "instanceof", "Mapper", "\\", "MapperInterface", ")", ")", "{", "$", "data", "=", "$", "mapper", "(", "$", "data", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid mapping: expecting array result, not %s.'", ",", "gettype", "(", "$", "data", ")", ")", ")", ";", "}", "}", "//Validate and hydrate data array", "switch", "(", "true", ")", "{", "case", "is_object", "(", "$", "toObjectOrArray", ")", ":", "$", "toMetadata", "=", "$", "this", "->", "metadataReader", "->", "getMetadata", "(", "get_class", "(", "$", "toObjectOrArray", ")", ",", "$", "toSubset", ")", ";", "$", "toHydrator", "=", "$", "this", "->", "getHydrator", "(", "$", "toMetadata", ")", ";", "$", "validator", "=", "$", "this", "->", "getValidator", "(", "$", "toMetadata", ")", ";", "$", "result", "=", "$", "validator", "->", "validate", "(", "self", "::", "arrayTransfer", "(", "$", "toHydrator", "->", "extract", "(", "$", "toObjectOrArray", ")", ",", "$", "data", ")", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "toObjectOrArray", "=", "$", "toHydrator", "->", "hydrate", "(", "$", "data", ",", "$", "toObjectOrArray", ")", ";", "}", "break", ";", "case", "is_array", "(", "$", "toObjectOrArray", ")", ":", "$", "toObjectOrArray", "=", "self", "::", "arrayTransfer", "(", "$", "toObjectOrArray", ",", "$", "data", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Data transfer is possible only to object or array.'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Transfers data from source to destination safely. @param array|object $fromObjectOrArray @param array|object $toObjectOrArray @param Mapper\MapperInterface|callable $mapper @param string $fromSubset @param string $toSubset @return array - validation messages if transfer failed
[ "Transfers", "data", "from", "source", "to", "destination", "safely", "." ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L116-L170
18,492
Articus/DataTransfer
src/Articus/DataTransfer/Service.php
Service.getHydrator
public function getHydrator(Metadata $metadata) { if (!isset($this->hydrators[$metadata->className][$metadata->subset])) { $hydrator = new Hydrator(); $hydrator ->setStrategyPluginManager($this->strategyPluginManager) ->setMetadata($metadata) ; $this->hydrators[$metadata->className][$metadata->subset] = $hydrator; } return $this->hydrators[$metadata->className][$metadata->subset]; }
php
public function getHydrator(Metadata $metadata) { if (!isset($this->hydrators[$metadata->className][$metadata->subset])) { $hydrator = new Hydrator(); $hydrator ->setStrategyPluginManager($this->strategyPluginManager) ->setMetadata($metadata) ; $this->hydrators[$metadata->className][$metadata->subset] = $hydrator; } return $this->hydrators[$metadata->className][$metadata->subset]; }
[ "public", "function", "getHydrator", "(", "Metadata", "$", "metadata", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "hydrators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", ")", ")", "{", "$", "hydrator", "=", "new", "Hydrator", "(", ")", ";", "$", "hydrator", "->", "setStrategyPluginManager", "(", "$", "this", "->", "strategyPluginManager", ")", "->", "setMetadata", "(", "$", "metadata", ")", ";", "$", "this", "->", "hydrators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", "=", "$", "hydrator", ";", "}", "return", "$", "this", "->", "hydrators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", ";", "}" ]
Returns hydrator required by metadata @param Metadata $metadata @return Hydrator
[ "Returns", "hydrator", "required", "by", "metadata" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L177-L189
18,493
Articus/DataTransfer
src/Articus/DataTransfer/Service.php
Service.getValidator
public function getValidator(Metadata $metadata) { if (!isset($this->validators[$metadata->className][$metadata->subset])) { $validator = new Validator(); $validator ->setValidatorPluginManager($this->validatorPluginManager) ->setMetadata($metadata) ; $this->validators[$metadata->className][$metadata->subset] = $validator; } return $this->validators[$metadata->className][$metadata->subset]; }
php
public function getValidator(Metadata $metadata) { if (!isset($this->validators[$metadata->className][$metadata->subset])) { $validator = new Validator(); $validator ->setValidatorPluginManager($this->validatorPluginManager) ->setMetadata($metadata) ; $this->validators[$metadata->className][$metadata->subset] = $validator; } return $this->validators[$metadata->className][$metadata->subset]; }
[ "public", "function", "getValidator", "(", "Metadata", "$", "metadata", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "validators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", ")", ")", "{", "$", "validator", "=", "new", "Validator", "(", ")", ";", "$", "validator", "->", "setValidatorPluginManager", "(", "$", "this", "->", "validatorPluginManager", ")", "->", "setMetadata", "(", "$", "metadata", ")", ";", "$", "this", "->", "validators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", "=", "$", "validator", ";", "}", "return", "$", "this", "->", "validators", "[", "$", "metadata", "->", "className", "]", "[", "$", "metadata", "->", "subset", "]", ";", "}" ]
Returns validator required by metadata @param Metadata $metadata @return Validator
[ "Returns", "validator", "required", "by", "metadata" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L196-L208
18,494
Articus/DataTransfer
src/Articus/DataTransfer/Service.php
Service.arrayTransfer
static public function arrayTransfer(array $a, array $b) { if (ArrayUtils::isList($b, ArrayUtils::isList($a))) { $a = $b; } else { foreach ($b as $key => $value) { if (array_key_exists($key, $a) && is_array($value) && is_array($a[$key])) { $a[$key] = self::arrayTransfer($a[$key], $value); } else { $a[$key] = $value; } } } return $a; }
php
static public function arrayTransfer(array $a, array $b) { if (ArrayUtils::isList($b, ArrayUtils::isList($a))) { $a = $b; } else { foreach ($b as $key => $value) { if (array_key_exists($key, $a) && is_array($value) && is_array($a[$key])) { $a[$key] = self::arrayTransfer($a[$key], $value); } else { $a[$key] = $value; } } } return $a; }
[ "static", "public", "function", "arrayTransfer", "(", "array", "$", "a", ",", "array", "$", "b", ")", "{", "if", "(", "ArrayUtils", "::", "isList", "(", "$", "b", ",", "ArrayUtils", "::", "isList", "(", "$", "a", ")", ")", ")", "{", "$", "a", "=", "$", "b", ";", "}", "else", "{", "foreach", "(", "$", "b", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "a", ")", "&&", "is_array", "(", "$", "value", ")", "&&", "is_array", "(", "$", "a", "[", "$", "key", "]", ")", ")", "{", "$", "a", "[", "$", "key", "]", "=", "self", "::", "arrayTransfer", "(", "$", "a", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "a", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "a", ";", "}" ]
Simple data transfer from one array to the other @param array $a @param array $b @return array
[ "Simple", "data", "transfer", "from", "one", "array", "to", "the", "other" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L216-L237
18,495
steeffeen/FancyManiaLinks
FML/Components/CheckBoxDesign.php
CheckBoxDesign.setImageUrl
public function setImageUrl($imageUrl) { $this->style = null; $this->subStyle = null; $this->imageUrl = (string)$imageUrl; return $this; }
php
public function setImageUrl($imageUrl) { $this->style = null; $this->subStyle = null; $this->imageUrl = (string)$imageUrl; return $this; }
[ "public", "function", "setImageUrl", "(", "$", "imageUrl", ")", "{", "$", "this", "->", "style", "=", "null", ";", "$", "this", "->", "subStyle", "=", "null", ";", "$", "this", "->", "imageUrl", "=", "(", "string", ")", "$", "imageUrl", ";", "return", "$", "this", ";", "}" ]
Set the image url @api @param string $imageUrl Image url @return static
[ "Set", "the", "image", "url" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBoxDesign.php#L125-L131
18,496
steeffeen/FancyManiaLinks
FML/Components/CheckBoxDesign.php
CheckBoxDesign.applyToQuad
public function applyToQuad(Quad $quad) { if ($this->imageUrl) { $quad->setImageUrl($this->imageUrl); } else if ($this->style) { $quad->setStyles($this->style, $this->subStyle); } return $this; }
php
public function applyToQuad(Quad $quad) { if ($this->imageUrl) { $quad->setImageUrl($this->imageUrl); } else if ($this->style) { $quad->setStyles($this->style, $this->subStyle); } return $this; }
[ "public", "function", "applyToQuad", "(", "Quad", "$", "quad", ")", "{", "if", "(", "$", "this", "->", "imageUrl", ")", "{", "$", "quad", "->", "setImageUrl", "(", "$", "this", "->", "imageUrl", ")", ";", "}", "else", "if", "(", "$", "this", "->", "style", ")", "{", "$", "quad", "->", "setStyles", "(", "$", "this", "->", "style", ",", "$", "this", "->", "subStyle", ")", ";", "}", "return", "$", "this", ";", "}" ]
Apply the Design to the given Quad @api @param Quad $quad CheckBox Quad @return static
[ "Apply", "the", "Design", "to", "the", "given", "Quad" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBoxDesign.php#L140-L148
18,497
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/RemoteAppController.php
RemoteAppController.indexDataAction
public function indexDataAction(Request $request) { $aRemoteApps = RemoteAppQuery::create()->find(); $sResult = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array( 'entities' => $aRemoteApps, )); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
php
public function indexDataAction(Request $request) { $aRemoteApps = RemoteAppQuery::create()->find(); $sResult = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array( 'entities' => $aRemoteApps, )); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
[ "public", "function", "indexDataAction", "(", "Request", "$", "request", ")", "{", "$", "aRemoteApps", "=", "RemoteAppQuery", "::", "create", "(", ")", "->", "find", "(", ")", ";", "$", "sResult", "=", "$", "this", "->", "renderView", "(", "'SlashworksAppBundle:RemoteApp:data.json.twig'", ",", "array", "(", "'entities'", "=>", "$", "aRemoteApps", ",", ")", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "sResult", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}" ]
Get data as json for remoteapp-list @param \Symfony\Component\HttpFoundation\Request $request @return \Slashworks\AppBundle\Controller\Response
[ "Get", "data", "as", "json", "for", "remoteapp", "-", "list" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L77-L90
18,498
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/RemoteAppController.php
RemoteAppController.detailsAction
public function detailsAction($id) { $aRemoteApps = RemoteAppQuery::create()->findOneById($id); $aRemoteAppHistory = $aRemoteApps->getRemoteHistoryContaoAsArray(); return $this->render('SlashworksAppBundle:RemoteApp:details.html.twig', array( 'remoteapp' => $aRemoteApps, 'remoteappHistory' => $aRemoteAppHistory )); }
php
public function detailsAction($id) { $aRemoteApps = RemoteAppQuery::create()->findOneById($id); $aRemoteAppHistory = $aRemoteApps->getRemoteHistoryContaoAsArray(); return $this->render('SlashworksAppBundle:RemoteApp:details.html.twig', array( 'remoteapp' => $aRemoteApps, 'remoteappHistory' => $aRemoteAppHistory )); }
[ "public", "function", "detailsAction", "(", "$", "id", ")", "{", "$", "aRemoteApps", "=", "RemoteAppQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "$", "aRemoteAppHistory", "=", "$", "aRemoteApps", "->", "getRemoteHistoryContaoAsArray", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:RemoteApp:details.html.twig'", ",", "array", "(", "'remoteapp'", "=>", "$", "aRemoteApps", ",", "'remoteappHistory'", "=>", "$", "aRemoteAppHistory", ")", ")", ";", "}" ]
show details for remoteapp @param $id @return \Symfony\Component\HttpFoundation\Response
[ "show", "details", "for", "remoteapp" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L100-L110
18,499
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/RemoteAppController.php
RemoteAppController.initInstallCallAction
public function initInstallCallAction($id) { $oRemoteApp = RemoteAppQuery::create()->findOneById($id); $sResult = array( "success" => false, "message" => "" ); try { $this->get("API"); Api::$_container = $this->container; $mResult = Api::call("doInstall", array(), $oRemoteApp->getUpdateUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp); if (!empty($mResult)) { if (!isset($mResult['result']['result'])) { $this->get('logger')->error("[INIT ERROR] ".print_r($mResult,true)); throw new \Exception($this->get("translator")->trans("remote_app.api.init.error")); } if ($mResult['result']['result'] == true) { $sResult['success'] = true; $sResult['message'] = $this->get("translator")->trans("remote_app.api.update.successful"); $this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName())); $oRemoteApp->setWebsiteHash($mResult['result']['website_hash']); $oRemoteApp->save(); } else { $this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__." - Result: ".json_encode($mResult), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl())); throw new \Exception("error in " . __FILE__ . " on line " . __LINE__); } } } catch (\Exception $e) { $this->get('logger')->error($e->getMessage(), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl())); $sResult['success'] = false; $sResult['message'] = $e->getMessage(); } $response = new Response(json_encode($sResult)); $response->headers->set('Content-Type', 'application/json'); return $response; }
php
public function initInstallCallAction($id) { $oRemoteApp = RemoteAppQuery::create()->findOneById($id); $sResult = array( "success" => false, "message" => "" ); try { $this->get("API"); Api::$_container = $this->container; $mResult = Api::call("doInstall", array(), $oRemoteApp->getUpdateUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp); if (!empty($mResult)) { if (!isset($mResult['result']['result'])) { $this->get('logger')->error("[INIT ERROR] ".print_r($mResult,true)); throw new \Exception($this->get("translator")->trans("remote_app.api.init.error")); } if ($mResult['result']['result'] == true) { $sResult['success'] = true; $sResult['message'] = $this->get("translator")->trans("remote_app.api.update.successful"); $this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName())); $oRemoteApp->setWebsiteHash($mResult['result']['website_hash']); $oRemoteApp->save(); } else { $this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__." - Result: ".json_encode($mResult), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl())); throw new \Exception("error in " . __FILE__ . " on line " . __LINE__); } } } catch (\Exception $e) { $this->get('logger')->error($e->getMessage(), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl())); $sResult['success'] = false; $sResult['message'] = $e->getMessage(); } $response = new Response(json_encode($sResult)); $response->headers->set('Content-Type', 'application/json'); return $response; }
[ "public", "function", "initInstallCallAction", "(", "$", "id", ")", "{", "$", "oRemoteApp", "=", "RemoteAppQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "$", "sResult", "=", "array", "(", "\"success\"", "=>", "false", ",", "\"message\"", "=>", "\"\"", ")", ";", "try", "{", "$", "this", "->", "get", "(", "\"API\"", ")", ";", "Api", "::", "$", "_container", "=", "$", "this", "->", "container", ";", "$", "mResult", "=", "Api", "::", "call", "(", "\"doInstall\"", ",", "array", "(", ")", ",", "$", "oRemoteApp", "->", "getUpdateUrl", "(", ")", ",", "$", "oRemoteApp", "->", "getPublicKey", "(", ")", ",", "$", "oRemoteApp", ")", ";", "if", "(", "!", "empty", "(", "$", "mResult", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "mResult", "[", "'result'", "]", "[", "'result'", "]", ")", ")", "{", "$", "this", "->", "get", "(", "'logger'", ")", "->", "error", "(", "\"[INIT ERROR] \"", ".", "print_r", "(", "$", "mResult", ",", "true", ")", ")", ";", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"remote_app.api.init.error\"", ")", ")", ";", "}", "if", "(", "$", "mResult", "[", "'result'", "]", "[", "'result'", "]", "==", "true", ")", "{", "$", "sResult", "[", "'success'", "]", "=", "true", ";", "$", "sResult", "[", "'message'", "]", "=", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"remote_app.api.update.successful\"", ")", ";", "$", "this", "->", "get", "(", "'logger'", ")", "->", "info", "(", "\"Api-Call successful\"", ",", "array", "(", "\"Method\"", "=>", "__METHOD__", ",", "\"RemoteApp\"", "=>", "$", "oRemoteApp", "->", "getName", "(", ")", ")", ")", ";", "$", "oRemoteApp", "->", "setWebsiteHash", "(", "$", "mResult", "[", "'result'", "]", "[", "'website_hash'", "]", ")", ";", "$", "oRemoteApp", "->", "save", "(", ")", ";", "}", "else", "{", "$", "this", "->", "get", "(", "'logger'", ")", "->", "error", "(", "\"Unknown error in \"", ".", "__FILE__", ".", "\" on line \"", ".", "__LINE__", ".", "\" - Result: \"", ".", "json_encode", "(", "$", "mResult", ")", ",", "array", "(", "\"Method\"", "=>", "__METHOD__", ",", "\"RemoteApp\"", "=>", "$", "oRemoteApp", "->", "getName", "(", ")", ",", "\"RemoteURL\"", "=>", "$", "oRemoteApp", "->", "getFullApiUrl", "(", ")", ")", ")", ";", "throw", "new", "\\", "Exception", "(", "\"error in \"", ".", "__FILE__", ".", "\" on line \"", ".", "__LINE__", ")", ";", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "get", "(", "'logger'", ")", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ",", "array", "(", "\"Method\"", "=>", "__METHOD__", ",", "\"RemoteApp\"", "=>", "$", "oRemoteApp", "->", "getName", "(", ")", ",", "\"RemoteURL\"", "=>", "$", "oRemoteApp", "->", "getFullApiUrl", "(", ")", ")", ")", ";", "$", "sResult", "[", "'success'", "]", "=", "false", ";", "$", "sResult", "[", "'message'", "]", "=", "$", "e", "->", "getMessage", "(", ")", ";", "}", "$", "response", "=", "new", "Response", "(", "json_encode", "(", "$", "sResult", ")", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}" ]
initiate installation of complete monitoring module @param $id @return \Symfony\Component\HttpFoundation\Response @throws \Exception
[ "initiate", "installation", "of", "complete", "monitoring", "module" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L222-L264