id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
6,000
SagePHP/System
src/SagePHP/System/Command.php
Command.add
public function add($item, $quoted = false) { if (true === $quoted) { $item = '"' . $item . '"'; } $this->parts[] = $item; }
php
public function add($item, $quoted = false) { if (true === $quoted) { $item = '"' . $item . '"'; } $this->parts[] = $item; }
[ "public", "function", "add", "(", "$", "item", ",", "$", "quoted", "=", "false", ")", "{", "if", "(", "true", "===", "$", "quoted", ")", "{", "$", "item", "=", "'\"'", ".", "$", "item", ".", "'\"'", ";", "}", "$", "this", "->", "parts", "[", "]", "=", "$", "item", ";", "}" ]
adds a CLI part. This function exposes the full functionality to end users @param mixed $item the item to add to the CLI @param boolean $quoted should $item be encloded in double quotes?
[ "adds", "a", "CLI", "part", ".", "This", "function", "exposes", "the", "full", "functionality", "to", "end", "users" ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Command.php#L19-L26
6,001
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.addRole
public function addRole($role) { if (is_array($role) || $role instanceof \Traversable) return $this->addMultipleRoles($role); else return $this->addSingleRole($role); }
php
public function addRole($role) { if (is_array($role) || $role instanceof \Traversable) return $this->addMultipleRoles($role); else return $this->addSingleRole($role); }
[ "public", "function", "addRole", "(", "$", "role", ")", "{", "if", "(", "is_array", "(", "$", "role", ")", "||", "$", "role", "instanceof", "\\", "Traversable", ")", "return", "$", "this", "->", "addMultipleRoles", "(", "$", "role", ")", ";", "else", "return", "$", "this", "->", "addSingleRole", "(", "$", "role", ")", ";", "}" ]
Add a role to the user. The argument can be the role name, ID, Role object, or an array of the previous @param $role array|\Traversable|string|integer The role to add to the current user @return \Searsaw\Drawbridge\Models\BridgeRole|\InvalidArgumentException
[ "Add", "a", "role", "to", "the", "user", ".", "The", "argument", "can", "be", "the", "role", "name", "ID", "Role", "object", "or", "an", "array", "of", "the", "previous" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L45-L51
6,002
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.addSingleRole
public function addSingleRole($role) { if (is_string($role)) return $this->addRoleByName($role); elseif (is_numeric($role)) return $this->addRoleById($role); elseif ($role instanceof BridgeRole) return $this->addRoleByObject($role); else throw new \InvalidArgumentException('Role must be a name, ID, or Role object.'); }
php
public function addSingleRole($role) { if (is_string($role)) return $this->addRoleByName($role); elseif (is_numeric($role)) return $this->addRoleById($role); elseif ($role instanceof BridgeRole) return $this->addRoleByObject($role); else throw new \InvalidArgumentException('Role must be a name, ID, or Role object.'); }
[ "public", "function", "addSingleRole", "(", "$", "role", ")", "{", "if", "(", "is_string", "(", "$", "role", ")", ")", "return", "$", "this", "->", "addRoleByName", "(", "$", "role", ")", ";", "elseif", "(", "is_numeric", "(", "$", "role", ")", ")", "return", "$", "this", "->", "addRoleById", "(", "$", "role", ")", ";", "elseif", "(", "$", "role", "instanceof", "BridgeRole", ")", "return", "$", "this", "->", "addRoleByObject", "(", "$", "role", ")", ";", "else", "throw", "new", "\\", "InvalidArgumentException", "(", "'Role must be a name, ID, or Role object.'", ")", ";", "}" ]
Add a single role. The argument is a string, integer, or instance of BridgeRole @param $role string|integer|\Searsaw\Drawbridge\Models\BridgeRole @throws \InvalidArgumentException @return \Searsaw\Drawbridge\Models\BridgeRole
[ "Add", "a", "single", "role", ".", "The", "argument", "is", "a", "string", "integer", "or", "instance", "of", "BridgeRole" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L75-L85
6,003
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.addRoleByName
public function addRoleByName($role_name) { $role = static::$app['db']->connection() ->table('roles')->where('name', '=', $role_name)->first(); if (! $role) throw new \RuntimeException('No role with that name found.'); if (is_array($role)) return $this->addRoleById($role['id']); elseif (is_object($role)) return $this->addRoleById($role->id); else throw new \UnexpectedValueException('Value returned not array or instance of BridgeRole.'); }
php
public function addRoleByName($role_name) { $role = static::$app['db']->connection() ->table('roles')->where('name', '=', $role_name)->first(); if (! $role) throw new \RuntimeException('No role with that name found.'); if (is_array($role)) return $this->addRoleById($role['id']); elseif (is_object($role)) return $this->addRoleById($role->id); else throw new \UnexpectedValueException('Value returned not array or instance of BridgeRole.'); }
[ "public", "function", "addRoleByName", "(", "$", "role_name", ")", "{", "$", "role", "=", "static", "::", "$", "app", "[", "'db'", "]", "->", "connection", "(", ")", "->", "table", "(", "'roles'", ")", "->", "where", "(", "'name'", ",", "'='", ",", "$", "role_name", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "role", ")", "throw", "new", "\\", "RuntimeException", "(", "'No role with that name found.'", ")", ";", "if", "(", "is_array", "(", "$", "role", ")", ")", "return", "$", "this", "->", "addRoleById", "(", "$", "role", "[", "'id'", "]", ")", ";", "elseif", "(", "is_object", "(", "$", "role", ")", ")", "return", "$", "this", "->", "addRoleById", "(", "$", "role", "->", "id", ")", ";", "else", "throw", "new", "\\", "UnexpectedValueException", "(", "'Value returned not array or instance of BridgeRole.'", ")", ";", "}" ]
Add a single role to the user by name @param $role_name string The name of the role to add @throws \RuntimeException @throws \UnexpectedValueException @return \Searsaw\Drawbridge\Models\BridgeRole
[ "Add", "a", "single", "role", "to", "the", "user", "by", "name" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L97-L111
6,004
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.addRoleByObject
public function addRoleByObject(BridgeRole $role_obj) { if (! $role_obj->exists) $role_obj->save(); $role_id = $role_obj->getKey(); return $this->addRoleById($role_id); }
php
public function addRoleByObject(BridgeRole $role_obj) { if (! $role_obj->exists) $role_obj->save(); $role_id = $role_obj->getKey(); return $this->addRoleById($role_id); }
[ "public", "function", "addRoleByObject", "(", "BridgeRole", "$", "role_obj", ")", "{", "if", "(", "!", "$", "role_obj", "->", "exists", ")", "$", "role_obj", "->", "save", "(", ")", ";", "$", "role_id", "=", "$", "role_obj", "->", "getKey", "(", ")", ";", "return", "$", "this", "->", "addRoleById", "(", "$", "role_id", ")", ";", "}" ]
Add a single role to the user by using the Role object @param $role_obj \Searsaw\Drawbridge\Models\BridgeRole The Role object to add @return \Searsaw\Drawbridge\Models\BridgeRole
[ "Add", "a", "single", "role", "to", "the", "user", "by", "using", "the", "Role", "object" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L132-L140
6,005
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.hasRole
public function hasRole($role) { $roles = $this->roles; foreach ($roles as $role_obj) if ($this->checkRole($role, $role_obj)) return true; return false; }
php
public function hasRole($role) { $roles = $this->roles; foreach ($roles as $role_obj) if ($this->checkRole($role, $role_obj)) return true; return false; }
[ "public", "function", "hasRole", "(", "$", "role", ")", "{", "$", "roles", "=", "$", "this", "->", "roles", ";", "foreach", "(", "$", "roles", "as", "$", "role_obj", ")", "if", "(", "$", "this", "->", "checkRole", "(", "$", "role", ",", "$", "role_obj", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Checks to see if a user has a certain role @param $role string|integer|\Searsaw\Drawbridge\Models\BridgeRole The role to check @return bool
[ "Checks", "to", "see", "if", "a", "user", "has", "a", "certain", "role" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L149-L157
6,006
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.checkRole
public function checkRole($check, BridgeRole $has) { if (is_string($check)) return $this->checkRoleByName($check, $has); elseif (is_numeric($check)) return $this->checkRoleById($check, $has); elseif ($check instanceof BridgeRole) return $this->checkRoleByObject($check, $has); else throw new \InvalidArgumentException('Role to check must be a name, ID, or Role object.'); }
php
public function checkRole($check, BridgeRole $has) { if (is_string($check)) return $this->checkRoleByName($check, $has); elseif (is_numeric($check)) return $this->checkRoleById($check, $has); elseif ($check instanceof BridgeRole) return $this->checkRoleByObject($check, $has); else throw new \InvalidArgumentException('Role to check must be a name, ID, or Role object.'); }
[ "public", "function", "checkRole", "(", "$", "check", ",", "BridgeRole", "$", "has", ")", "{", "if", "(", "is_string", "(", "$", "check", ")", ")", "return", "$", "this", "->", "checkRoleByName", "(", "$", "check", ",", "$", "has", ")", ";", "elseif", "(", "is_numeric", "(", "$", "check", ")", ")", "return", "$", "this", "->", "checkRoleById", "(", "$", "check", ",", "$", "has", ")", ";", "elseif", "(", "$", "check", "instanceof", "BridgeRole", ")", "return", "$", "this", "->", "checkRoleByObject", "(", "$", "check", ",", "$", "has", ")", ";", "else", "throw", "new", "\\", "InvalidArgumentException", "(", "'Role to check must be a name, ID, or Role object.'", ")", ";", "}" ]
Checks to see if a given role is equal to a role the user already has @param $check string|integer|\Searsaw\Drawbridge\Models\BridgeRole The role to check @param $has \Searsaw\Drawbridge\Models\BridgeRole The role the user has to check against @return mixed @throws \InvalidArgumentException
[ "Checks", "to", "see", "if", "a", "given", "role", "is", "equal", "to", "a", "role", "the", "user", "already", "has" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L168-L178
6,007
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.checkRoleByObject
public function checkRoleByObject(BridgeRole $check, BridgeRole $has) { return $this->checkRoleById($check->id, $has); }
php
public function checkRoleByObject(BridgeRole $check, BridgeRole $has) { return $this->checkRoleById($check->id, $has); }
[ "public", "function", "checkRoleByObject", "(", "BridgeRole", "$", "check", ",", "BridgeRole", "$", "has", ")", "{", "return", "$", "this", "->", "checkRoleById", "(", "$", "check", "->", "id", ",", "$", "has", ")", ";", "}" ]
Check to see if the Role provided is the same as the BridgeRole object passed in @param BridgeRole $check The object to check @param BridgeRole $has The object to check against @return bool
[ "Check", "to", "see", "if", "the", "Role", "provided", "is", "the", "same", "as", "the", "BridgeRole", "object", "passed", "in" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L223-L226
6,008
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.hasPermission
public function hasPermission($permission) { $perm_id = $this->getPermissionId($permission); $roles = $this->getRolesWithPermission($perm_id); foreach ($roles as $role) if ($this->hasRole($role)) return true; return false; }
php
public function hasPermission($permission) { $perm_id = $this->getPermissionId($permission); $roles = $this->getRolesWithPermission($perm_id); foreach ($roles as $role) if ($this->hasRole($role)) return true; return false; }
[ "public", "function", "hasPermission", "(", "$", "permission", ")", "{", "$", "perm_id", "=", "$", "this", "->", "getPermissionId", "(", "$", "permission", ")", ";", "$", "roles", "=", "$", "this", "->", "getRolesWithPermission", "(", "$", "perm_id", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "if", "(", "$", "this", "->", "hasRole", "(", "$", "role", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Check to see if the user has the given permission. Permission can be an ID, name, or Permission object @param $permission integer|string|\Searsaw\Drawbridge\Models\BridgePermission The permission to check for @return bool
[ "Check", "to", "see", "if", "the", "user", "has", "the", "given", "permission", ".", "Permission", "can", "be", "an", "ID", "name", "or", "Permission", "object" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L236-L246
6,009
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.getPermissionId
public function getPermissionId($permission) { if (is_numeric($permission)) return $permission; elseif (is_string($permission)) return $this->getPermissionIdFromName($permission); elseif ($permission instanceof BridgePermission) return $permission->id; else throw new \InvalidArgumentException('Permission to check must be a name, ID, or Permission object.'); }
php
public function getPermissionId($permission) { if (is_numeric($permission)) return $permission; elseif (is_string($permission)) return $this->getPermissionIdFromName($permission); elseif ($permission instanceof BridgePermission) return $permission->id; else throw new \InvalidArgumentException('Permission to check must be a name, ID, or Permission object.'); }
[ "public", "function", "getPermissionId", "(", "$", "permission", ")", "{", "if", "(", "is_numeric", "(", "$", "permission", ")", ")", "return", "$", "permission", ";", "elseif", "(", "is_string", "(", "$", "permission", ")", ")", "return", "$", "this", "->", "getPermissionIdFromName", "(", "$", "permission", ")", ";", "elseif", "(", "$", "permission", "instanceof", "BridgePermission", ")", "return", "$", "permission", "->", "id", ";", "else", "throw", "new", "\\", "InvalidArgumentException", "(", "'Permission to check must be a name, ID, or Permission object.'", ")", ";", "}" ]
Get the ID of the passed in permission. Permission can be an ID, name, or Permission object @param $permission integer|string|\Searsaw\Drawbridge\Models\BridgePermission The permission whose ID to get @return integer @throws \InvalidArgumentException
[ "Get", "the", "ID", "of", "the", "passed", "in", "permission", ".", "Permission", "can", "be", "an", "ID", "name", "or", "Permission", "object" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L257-L267
6,010
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.getPermissionIdFromName
public function getPermissionIdFromName($perm_name) { $permission = static::$app['db']->connection() ->table('permissions')->where('name', '=', $perm_name)->first(); return $permission->id; }
php
public function getPermissionIdFromName($perm_name) { $permission = static::$app['db']->connection() ->table('permissions')->where('name', '=', $perm_name)->first(); return $permission->id; }
[ "public", "function", "getPermissionIdFromName", "(", "$", "perm_name", ")", "{", "$", "permission", "=", "static", "::", "$", "app", "[", "'db'", "]", "->", "connection", "(", ")", "->", "table", "(", "'permissions'", ")", "->", "where", "(", "'name'", ",", "'='", ",", "$", "perm_name", ")", "->", "first", "(", ")", ";", "return", "$", "permission", "->", "id", ";", "}" ]
Get the ID of a permission with the passed in name @param $perm_name string The name of the permission whose ID to get @return integer
[ "Get", "the", "ID", "of", "a", "permission", "with", "the", "passed", "in", "name" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L276-L282
6,011
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeUser.php
BridgeUser.getRolesWithPermission
public function getRolesWithPermission($perm_id) { $roles = static::$app['db']->connection() ->table('roles_permissions')->where('permission_id', '=', $perm_id)->lists('role_id'); $roles = array_map('intval', $roles); return $roles; }
php
public function getRolesWithPermission($perm_id) { $roles = static::$app['db']->connection() ->table('roles_permissions')->where('permission_id', '=', $perm_id)->lists('role_id'); $roles = array_map('intval', $roles); return $roles; }
[ "public", "function", "getRolesWithPermission", "(", "$", "perm_id", ")", "{", "$", "roles", "=", "static", "::", "$", "app", "[", "'db'", "]", "->", "connection", "(", ")", "->", "table", "(", "'roles_permissions'", ")", "->", "where", "(", "'permission_id'", ",", "'='", ",", "$", "perm_id", ")", "->", "lists", "(", "'role_id'", ")", ";", "$", "roles", "=", "array_map", "(", "'intval'", ",", "$", "roles", ")", ";", "return", "$", "roles", ";", "}" ]
Get the roles who have the given permission @param $perm_id integer The ID of the permission @return integer
[ "Get", "the", "roles", "who", "have", "the", "given", "permission" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeUser.php#L291-L299
6,012
kompakt/mediameister
lib/Util/Archive/FileAdder.php
FileAdder.addChildren
public function addChildren($dirPathname) { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dirPathname, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST ); foreach($files as $info) { $relativePathname = $this->subtractBasedir($info->getPathname(), $dirPathname); #echo sprintf("%s\n", $relativePathname); if ($info->isDir()) { $this->zip->addEmptyDir($relativePathname); } else { $this->zip->addFile($info->getPathname(), $relativePathname); } } }
php
public function addChildren($dirPathname) { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dirPathname, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST ); foreach($files as $info) { $relativePathname = $this->subtractBasedir($info->getPathname(), $dirPathname); #echo sprintf("%s\n", $relativePathname); if ($info->isDir()) { $this->zip->addEmptyDir($relativePathname); } else { $this->zip->addFile($info->getPathname(), $relativePathname); } } }
[ "public", "function", "addChildren", "(", "$", "dirPathname", ")", "{", "$", "files", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "dirPathname", ",", "\\", "FilesystemIterator", "::", "SKIP_DOTS", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", ";", "foreach", "(", "$", "files", "as", "$", "info", ")", "{", "$", "relativePathname", "=", "$", "this", "->", "subtractBasedir", "(", "$", "info", "->", "getPathname", "(", ")", ",", "$", "dirPathname", ")", ";", "#echo sprintf(\"%s\\n\", $relativePathname);", "if", "(", "$", "info", "->", "isDir", "(", ")", ")", "{", "$", "this", "->", "zip", "->", "addEmptyDir", "(", "$", "relativePathname", ")", ";", "}", "else", "{", "$", "this", "->", "zip", "->", "addFile", "(", "$", "info", "->", "getPathname", "(", ")", ",", "$", "relativePathname", ")", ";", "}", "}", "}" ]
Recursively add children of directory to archive @example Pathname of '/share/lib' will add all children of '/share/lib', not including '/share/lib' @param string $dirPathname The full directory pathname
[ "Recursively", "add", "children", "of", "directory", "to", "archive" ]
370baa5532b4a4b57810d8d7a06061b2432599cb
https://github.com/kompakt/mediameister/blob/370baa5532b4a4b57810d8d7a06061b2432599cb/lib/Util/Archive/FileAdder.php#L30-L50
6,013
kompakt/mediameister
lib/Util/Archive/FileAdder.php
FileAdder.addFileFromBasedir
public function addFileFromBasedir($pathname, $basedir = '') { $info = new \SplFileInfo($pathname); if (!$info->isFile()) { throw new InvalidArgumentException(sprintf('File not found: %s', $pathname)); } if (!$info->isReadable()) { throw new InvalidArgumentException(sprintf('File not readable: %s', $pathname)); } $relativePathname = $this->subtractBasedir($pathname, $basedir); #echo sprintf("%s\n", $relativePathname); if ($basedir && $pathname === '/' . $relativePathname) { throw new InvalidArgumentException(sprintf('Invalid basedir: %s', $basedir)); } $this->zip->addFile($pathname, $relativePathname); }
php
public function addFileFromBasedir($pathname, $basedir = '') { $info = new \SplFileInfo($pathname); if (!$info->isFile()) { throw new InvalidArgumentException(sprintf('File not found: %s', $pathname)); } if (!$info->isReadable()) { throw new InvalidArgumentException(sprintf('File not readable: %s', $pathname)); } $relativePathname = $this->subtractBasedir($pathname, $basedir); #echo sprintf("%s\n", $relativePathname); if ($basedir && $pathname === '/' . $relativePathname) { throw new InvalidArgumentException(sprintf('Invalid basedir: %s', $basedir)); } $this->zip->addFile($pathname, $relativePathname); }
[ "public", "function", "addFileFromBasedir", "(", "$", "pathname", ",", "$", "basedir", "=", "''", ")", "{", "$", "info", "=", "new", "\\", "SplFileInfo", "(", "$", "pathname", ")", ";", "if", "(", "!", "$", "info", "->", "isFile", "(", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'File not found: %s'", ",", "$", "pathname", ")", ")", ";", "}", "if", "(", "!", "$", "info", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'File not readable: %s'", ",", "$", "pathname", ")", ")", ";", "}", "$", "relativePathname", "=", "$", "this", "->", "subtractBasedir", "(", "$", "pathname", ",", "$", "basedir", ")", ";", "#echo sprintf(\"%s\\n\", $relativePathname);", "if", "(", "$", "basedir", "&&", "$", "pathname", "===", "'/'", ".", "$", "relativePathname", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid basedir: %s'", ",", "$", "basedir", ")", ")", ";", "}", "$", "this", "->", "zip", "->", "addFile", "(", "$", "pathname", ",", "$", "relativePathname", ")", ";", "}" ]
Calculate relative pathname within archive and add file @example Pathname of '/share/lib/readme.md' and basedir of '/share' will add 'lib/readme.md' to archive @param string $pathname The full pathname @param string $baseDir The base pathname within pathname
[ "Calculate", "relative", "pathname", "within", "archive", "and", "add", "file" ]
370baa5532b4a4b57810d8d7a06061b2432599cb
https://github.com/kompakt/mediameister/blob/370baa5532b4a4b57810d8d7a06061b2432599cb/lib/Util/Archive/FileAdder.php#L60-L83
6,014
kompakt/mediameister
lib/Util/Archive/FileAdder.php
FileAdder.subtractBasedir
protected function subtractBasedir($pathname, $baseDir) { $baseDir = str_replace('/', '\/', trim($baseDir, '/')); return trim(preg_replace(sprintf('/%s/', $baseDir), '', $pathname), '/'); }
php
protected function subtractBasedir($pathname, $baseDir) { $baseDir = str_replace('/', '\/', trim($baseDir, '/')); return trim(preg_replace(sprintf('/%s/', $baseDir), '', $pathname), '/'); }
[ "protected", "function", "subtractBasedir", "(", "$", "pathname", ",", "$", "baseDir", ")", "{", "$", "baseDir", "=", "str_replace", "(", "'/'", ",", "'\\/'", ",", "trim", "(", "$", "baseDir", ",", "'/'", ")", ")", ";", "return", "trim", "(", "preg_replace", "(", "sprintf", "(", "'/%s/'", ",", "$", "baseDir", ")", ",", "''", ",", "$", "pathname", ")", ",", "'/'", ")", ";", "}" ]
Subtract baseDir from pathname @param string $pathname The full pathname @param string $baseDir The base pathname within pathname @return string Subdir portion, slashes cut off on both sides
[ "Subtract", "baseDir", "from", "pathname" ]
370baa5532b4a4b57810d8d7a06061b2432599cb
https://github.com/kompakt/mediameister/blob/370baa5532b4a4b57810d8d7a06061b2432599cb/lib/Util/Archive/FileAdder.php#L133-L137
6,015
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController.add
public function add() { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } $model = $this->request->data('model'); $foreignKey = (int)$this->request->data('foreign_key'); $languageId = Wasabi::contentLanguage()->id; $url = $this->_formatUrl($this->request->data('url')); $routeType = (int)$this->request->data('route_type'); $element = $this->request->data('element'); $routeData = [ 'url' => $url, 'model' => $model, 'foreign_key' => $foreignKey, 'language_id' => $languageId, ]; $route = $this->_addRoute($routeType, $routeData); $this->_render($route, $element); }
php
public function add() { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } $model = $this->request->data('model'); $foreignKey = (int)$this->request->data('foreign_key'); $languageId = Wasabi::contentLanguage()->id; $url = $this->_formatUrl($this->request->data('url')); $routeType = (int)$this->request->data('route_type'); $element = $this->request->data('element'); $routeData = [ 'url' => $url, 'model' => $model, 'foreign_key' => $foreignKey, 'language_id' => $languageId, ]; $route = $this->_addRoute($routeType, $routeData); $this->_render($route, $element); }
[ "public", "function", "add", "(", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "isAll", "(", "[", "'ajax'", ",", "'post'", "]", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", ")", ";", "}", "$", "model", "=", "$", "this", "->", "request", "->", "data", "(", "'model'", ")", ";", "$", "foreignKey", "=", "(", "int", ")", "$", "this", "->", "request", "->", "data", "(", "'foreign_key'", ")", ";", "$", "languageId", "=", "Wasabi", "::", "contentLanguage", "(", ")", "->", "id", ";", "$", "url", "=", "$", "this", "->", "_formatUrl", "(", "$", "this", "->", "request", "->", "data", "(", "'url'", ")", ")", ";", "$", "routeType", "=", "(", "int", ")", "$", "this", "->", "request", "->", "data", "(", "'route_type'", ")", ";", "$", "element", "=", "$", "this", "->", "request", "->", "data", "(", "'element'", ")", ";", "$", "routeData", "=", "[", "'url'", "=>", "$", "url", ",", "'model'", "=>", "$", "model", ",", "'foreign_key'", "=>", "$", "foreignKey", ",", "'language_id'", "=>", "$", "languageId", ",", "]", ";", "$", "route", "=", "$", "this", "->", "_addRoute", "(", "$", "routeType", ",", "$", "routeData", ")", ";", "$", "this", "->", "_render", "(", "$", "route", ",", "$", "element", ")", ";", "}" ]
Add action AJAX POST @throws MethodNotAllowedException @throws BadRequestException @return void
[ "Add", "action", "AJAX", "POST" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L42-L65
6,016
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController.makeDefault
public function makeDefault($id) { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } /** @var Route $route */ $route = $this->Routes->get($id); /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); $route->set([ 'redirect_to' => null, 'status_code' => null ]); if ($this->Routes->save($route)) { $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id); $this->Routes->redirectRoutesToId($otherRoutes, $route->id); $connection->commit(); $this->Flash->success(__d('wasabi_core', '<strong>{0}</strong> is now the new Default Route.', $route->url), 'routes'); } else { $connection->rollback(); $this->Flash->error($this->dbErrorMessage, 'routes'); } $this->_render($route, $this->request->query('element')); }
php
public function makeDefault($id) { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } /** @var Route $route */ $route = $this->Routes->get($id); /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); $route->set([ 'redirect_to' => null, 'status_code' => null ]); if ($this->Routes->save($route)) { $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id); $this->Routes->redirectRoutesToId($otherRoutes, $route->id); $connection->commit(); $this->Flash->success(__d('wasabi_core', '<strong>{0}</strong> is now the new Default Route.', $route->url), 'routes'); } else { $connection->rollback(); $this->Flash->error($this->dbErrorMessage, 'routes'); } $this->_render($route, $this->request->query('element')); }
[ "public", "function", "makeDefault", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "isAll", "(", "[", "'ajax'", ",", "'post'", "]", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", ")", ";", "}", "/** @var Route $route */", "$", "route", "=", "$", "this", "->", "Routes", "->", "get", "(", "$", "id", ")", ";", "/** @var Connection $connection */", "$", "connection", "=", "$", "this", "->", "Routes", "->", "connection", "(", ")", ";", "$", "connection", "->", "begin", "(", ")", ";", "$", "route", "->", "set", "(", "[", "'redirect_to'", "=>", "null", ",", "'status_code'", "=>", "null", "]", ")", ";", "if", "(", "$", "this", "->", "Routes", "->", "save", "(", "$", "route", ")", ")", "{", "$", "otherRoutes", "=", "$", "this", "->", "Routes", "->", "getOtherRoutesExcept", "(", "$", "route", "->", "id", ",", "$", "route", "->", "model", ",", "$", "route", "->", "foreign_key", ",", "$", "route", "->", "language_id", ")", ";", "$", "this", "->", "Routes", "->", "redirectRoutesToId", "(", "$", "otherRoutes", ",", "$", "route", "->", "id", ")", ";", "$", "connection", "->", "commit", "(", ")", ";", "$", "this", "->", "Flash", "->", "success", "(", "__d", "(", "'wasabi_core'", ",", "'<strong>{0}</strong> is now the new Default Route.'", ",", "$", "route", "->", "url", ")", ",", "'routes'", ")", ";", "}", "else", "{", "$", "connection", "->", "rollback", "(", ")", ";", "$", "this", "->", "Flash", "->", "error", "(", "$", "this", "->", "dbErrorMessage", ",", "'routes'", ")", ";", "}", "$", "this", "->", "_render", "(", "$", "route", ",", "$", "this", "->", "request", "->", "query", "(", "'element'", ")", ")", ";", "}" ]
MakeDefault action AJAX POST @param int|string $id The route id. @return void
[ "MakeDefault", "action", "AJAX", "POST" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L74-L103
6,017
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController.delete
public function delete($id) { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } /** @var Route $route */ $route = $this->Routes->get($id); /** @var ResultSet $otherRoutes */ $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id); if (!empty($otherRoutes) && $otherRoutes->count() >= 1) { /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); $this->Routes->delete($route); if ($route->redirect_to === null) { /** @var Route $newDefaultRoute */ $newDefaultRoute = $otherRoutes->first(); $newDefaultRoute->set([ 'redirect_to' => null, 'status_code' => null ]); $this->Routes->save($newDefaultRoute); $newRedirectRoutes = $otherRoutes->skip(1); foreach ($newRedirectRoutes as $r) { $r->set([ 'redirect_to' => $newDefaultRoute->id, 'status_code' => 301 ]); $this->Routes->save($r); } } $connection->commit(); $this->Flash->success(__d('wasabi_core', 'The URL <strong>{0}</strong> has been deleted.', $route->url), 'routes'); } else { $this->Flash->error(__d('wasabi_core', 'The URL <strong>{0}</strong> cannot be deleted. Please create another URL first.', $route->url), 'routes'); } $this->_render($route, $this->request->query('element')); }
php
public function delete($id) { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } /** @var Route $route */ $route = $this->Routes->get($id); /** @var ResultSet $otherRoutes */ $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id); if (!empty($otherRoutes) && $otherRoutes->count() >= 1) { /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); $this->Routes->delete($route); if ($route->redirect_to === null) { /** @var Route $newDefaultRoute */ $newDefaultRoute = $otherRoutes->first(); $newDefaultRoute->set([ 'redirect_to' => null, 'status_code' => null ]); $this->Routes->save($newDefaultRoute); $newRedirectRoutes = $otherRoutes->skip(1); foreach ($newRedirectRoutes as $r) { $r->set([ 'redirect_to' => $newDefaultRoute->id, 'status_code' => 301 ]); $this->Routes->save($r); } } $connection->commit(); $this->Flash->success(__d('wasabi_core', 'The URL <strong>{0}</strong> has been deleted.', $route->url), 'routes'); } else { $this->Flash->error(__d('wasabi_core', 'The URL <strong>{0}</strong> cannot be deleted. Please create another URL first.', $route->url), 'routes'); } $this->_render($route, $this->request->query('element')); }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "isAll", "(", "[", "'ajax'", ",", "'post'", "]", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", ")", ";", "}", "/** @var Route $route */", "$", "route", "=", "$", "this", "->", "Routes", "->", "get", "(", "$", "id", ")", ";", "/** @var ResultSet $otherRoutes */", "$", "otherRoutes", "=", "$", "this", "->", "Routes", "->", "getOtherRoutesExcept", "(", "$", "route", "->", "id", ",", "$", "route", "->", "model", ",", "$", "route", "->", "foreign_key", ",", "$", "route", "->", "language_id", ")", ";", "if", "(", "!", "empty", "(", "$", "otherRoutes", ")", "&&", "$", "otherRoutes", "->", "count", "(", ")", ">=", "1", ")", "{", "/** @var Connection $connection */", "$", "connection", "=", "$", "this", "->", "Routes", "->", "connection", "(", ")", ";", "$", "connection", "->", "begin", "(", ")", ";", "$", "this", "->", "Routes", "->", "delete", "(", "$", "route", ")", ";", "if", "(", "$", "route", "->", "redirect_to", "===", "null", ")", "{", "/** @var Route $newDefaultRoute */", "$", "newDefaultRoute", "=", "$", "otherRoutes", "->", "first", "(", ")", ";", "$", "newDefaultRoute", "->", "set", "(", "[", "'redirect_to'", "=>", "null", ",", "'status_code'", "=>", "null", "]", ")", ";", "$", "this", "->", "Routes", "->", "save", "(", "$", "newDefaultRoute", ")", ";", "$", "newRedirectRoutes", "=", "$", "otherRoutes", "->", "skip", "(", "1", ")", ";", "foreach", "(", "$", "newRedirectRoutes", "as", "$", "r", ")", "{", "$", "r", "->", "set", "(", "[", "'redirect_to'", "=>", "$", "newDefaultRoute", "->", "id", ",", "'status_code'", "=>", "301", "]", ")", ";", "$", "this", "->", "Routes", "->", "save", "(", "$", "r", ")", ";", "}", "}", "$", "connection", "->", "commit", "(", ")", ";", "$", "this", "->", "Flash", "->", "success", "(", "__d", "(", "'wasabi_core'", ",", "'The URL <strong>{0}</strong> has been deleted.'", ",", "$", "route", "->", "url", ")", ",", "'routes'", ")", ";", "}", "else", "{", "$", "this", "->", "Flash", "->", "error", "(", "__d", "(", "'wasabi_core'", ",", "'The URL <strong>{0}</strong> cannot be deleted. Please create another URL first.'", ",", "$", "route", "->", "url", ")", ",", "'routes'", ")", ";", "}", "$", "this", "->", "_render", "(", "$", "route", ",", "$", "this", "->", "request", "->", "query", "(", "'element'", ")", ")", ";", "}" ]
Delete action AJAX POST @param int|string $id The route id. @return void
[ "Delete", "action", "AJAX", "POST" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L112-L156
6,018
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController._render
protected function _render($route, $element) { $routes = $this->Routes ->findAllFor($route->model, $route->foreign_key, $route->language_id) ->order([$this->Routes->aliasField('url') => 'asc']); $this->set([ 'routes' => $routes, 'routeTypes' => RouteTypes::getForSelect(), 'model' => $route->model, 'element' => $element, 'formRoute' => $route ]); $this->render('add'); }
php
protected function _render($route, $element) { $routes = $this->Routes ->findAllFor($route->model, $route->foreign_key, $route->language_id) ->order([$this->Routes->aliasField('url') => 'asc']); $this->set([ 'routes' => $routes, 'routeTypes' => RouteTypes::getForSelect(), 'model' => $route->model, 'element' => $element, 'formRoute' => $route ]); $this->render('add'); }
[ "protected", "function", "_render", "(", "$", "route", ",", "$", "element", ")", "{", "$", "routes", "=", "$", "this", "->", "Routes", "->", "findAllFor", "(", "$", "route", "->", "model", ",", "$", "route", "->", "foreign_key", ",", "$", "route", "->", "language_id", ")", "->", "order", "(", "[", "$", "this", "->", "Routes", "->", "aliasField", "(", "'url'", ")", "=>", "'asc'", "]", ")", ";", "$", "this", "->", "set", "(", "[", "'routes'", "=>", "$", "routes", ",", "'routeTypes'", "=>", "RouteTypes", "::", "getForSelect", "(", ")", ",", "'model'", "=>", "$", "route", "->", "model", ",", "'element'", "=>", "$", "element", ",", "'formRoute'", "=>", "$", "route", "]", ")", ";", "$", "this", "->", "render", "(", "'add'", ")", ";", "}" ]
Global render method for all actions of this controller. @param Route $route The route. @param string $element The name of the view element. @return void
[ "Global", "render", "method", "for", "all", "actions", "of", "this", "controller", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L165-L180
6,019
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController._addRoute
protected function _addRoute($routeType, $routeData) { switch ($routeType) { case RouteTypes::TYPE_DEFAULT_ROUTE: $route = $this->_addDefaultRoute($routeData); break; case RouteTypes::TYPE_REDIRECT_ROUTE: $route = $this->_addRedirectRoute($routeData); break; default: throw new BadRequestException(); } return $route; }
php
protected function _addRoute($routeType, $routeData) { switch ($routeType) { case RouteTypes::TYPE_DEFAULT_ROUTE: $route = $this->_addDefaultRoute($routeData); break; case RouteTypes::TYPE_REDIRECT_ROUTE: $route = $this->_addRedirectRoute($routeData); break; default: throw new BadRequestException(); } return $route; }
[ "protected", "function", "_addRoute", "(", "$", "routeType", ",", "$", "routeData", ")", "{", "switch", "(", "$", "routeType", ")", "{", "case", "RouteTypes", "::", "TYPE_DEFAULT_ROUTE", ":", "$", "route", "=", "$", "this", "->", "_addDefaultRoute", "(", "$", "routeData", ")", ";", "break", ";", "case", "RouteTypes", "::", "TYPE_REDIRECT_ROUTE", ":", "$", "route", "=", "$", "this", "->", "_addRedirectRoute", "(", "$", "routeData", ")", ";", "break", ";", "default", ":", "throw", "new", "BadRequestException", "(", ")", ";", "}", "return", "$", "route", ";", "}" ]
Add the given route. @param string $routeType The route type (default/redirect). @param array $routeData The route data. @throws BadRequestException @return Route
[ "Add", "the", "given", "route", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L204-L217
6,020
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController._addDefaultRoute
protected function _addDefaultRoute(array $routeData) { /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); // Save the new default route. /** @var Route $defaultRoute */ $defaultRoute = $this->Routes->newEntity($routeData); if ($this->Routes->save($defaultRoute)) { // Make all other routes for this model + foreignKey + languageId // redirect to the new default route. $otherRoutes = $this->Routes->getOtherRoutesExcept($defaultRoute->id, $defaultRoute->model, $defaultRoute->foreign_key, $defaultRoute->language_id); $this->Routes->redirectRoutesToId($otherRoutes, $defaultRoute->id); $connection->commit(); $this->Flash->success(__d('wasabi_core', 'New default URL <strong>{0}</strong> has been added.', $defaultRoute->url), 'routes'); $this->request->data = []; } else { $connection->rollback(); $this->Flash->error($this->formErrorMessage, 'routes'); $defaultRoute->set('type', RouteTypes::TYPE_DEFAULT_ROUTE); } return $defaultRoute; }
php
protected function _addDefaultRoute(array $routeData) { /** @var Connection $connection */ $connection = $this->Routes->connection(); $connection->begin(); // Save the new default route. /** @var Route $defaultRoute */ $defaultRoute = $this->Routes->newEntity($routeData); if ($this->Routes->save($defaultRoute)) { // Make all other routes for this model + foreignKey + languageId // redirect to the new default route. $otherRoutes = $this->Routes->getOtherRoutesExcept($defaultRoute->id, $defaultRoute->model, $defaultRoute->foreign_key, $defaultRoute->language_id); $this->Routes->redirectRoutesToId($otherRoutes, $defaultRoute->id); $connection->commit(); $this->Flash->success(__d('wasabi_core', 'New default URL <strong>{0}</strong> has been added.', $defaultRoute->url), 'routes'); $this->request->data = []; } else { $connection->rollback(); $this->Flash->error($this->formErrorMessage, 'routes'); $defaultRoute->set('type', RouteTypes::TYPE_DEFAULT_ROUTE); } return $defaultRoute; }
[ "protected", "function", "_addDefaultRoute", "(", "array", "$", "routeData", ")", "{", "/** @var Connection $connection */", "$", "connection", "=", "$", "this", "->", "Routes", "->", "connection", "(", ")", ";", "$", "connection", "->", "begin", "(", ")", ";", "// Save the new default route.", "/** @var Route $defaultRoute */", "$", "defaultRoute", "=", "$", "this", "->", "Routes", "->", "newEntity", "(", "$", "routeData", ")", ";", "if", "(", "$", "this", "->", "Routes", "->", "save", "(", "$", "defaultRoute", ")", ")", "{", "// Make all other routes for this model + foreignKey + languageId", "// redirect to the new default route.", "$", "otherRoutes", "=", "$", "this", "->", "Routes", "->", "getOtherRoutesExcept", "(", "$", "defaultRoute", "->", "id", ",", "$", "defaultRoute", "->", "model", ",", "$", "defaultRoute", "->", "foreign_key", ",", "$", "defaultRoute", "->", "language_id", ")", ";", "$", "this", "->", "Routes", "->", "redirectRoutesToId", "(", "$", "otherRoutes", ",", "$", "defaultRoute", "->", "id", ")", ";", "$", "connection", "->", "commit", "(", ")", ";", "$", "this", "->", "Flash", "->", "success", "(", "__d", "(", "'wasabi_core'", ",", "'New default URL <strong>{0}</strong> has been added.'", ",", "$", "defaultRoute", "->", "url", ")", ",", "'routes'", ")", ";", "$", "this", "->", "request", "->", "data", "=", "[", "]", ";", "}", "else", "{", "$", "connection", "->", "rollback", "(", ")", ";", "$", "this", "->", "Flash", "->", "error", "(", "$", "this", "->", "formErrorMessage", ",", "'routes'", ")", ";", "$", "defaultRoute", "->", "set", "(", "'type'", ",", "RouteTypes", "::", "TYPE_DEFAULT_ROUTE", ")", ";", "}", "return", "$", "defaultRoute", ";", "}" ]
Add a new default route. @param array $routeData The route data. @return Route
[ "Add", "a", "new", "default", "route", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L225-L251
6,021
wasabi-cms/core
src/Controller/RoutesController.php
RoutesController._addRedirectRoute
protected function _addRedirectRoute($routeData) { /** @var Route $defaultRoute */ $defaultRoute = $this->Routes->getDefaultRoute($routeData['model'], $routeData['foreign_key'], $routeData['language_id']); /** @var Route $redirectRoute */ $redirectRoute = $this->Routes->newEntity($routeData); if (!empty($defaultRoute)) { $redirectRoute->set('redirect_to', $defaultRoute->id); $redirectRoute->set('status_code', 301); if ($this->Routes->save($redirectRoute)) { $this->Flash->success(__d('wasabi_core', 'New redirect URL <strong>{0}</strong> has been added.', $redirectRoute->url), 'routes'); $this->request->data = []; } else { $this->Flash->error($this->formErrorMessage, 'routes'); $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE); } } else { $this->Flash->error(__d('wasabi_core', 'Please create a default route first.'), 'routes'); $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE); } return $redirectRoute; }
php
protected function _addRedirectRoute($routeData) { /** @var Route $defaultRoute */ $defaultRoute = $this->Routes->getDefaultRoute($routeData['model'], $routeData['foreign_key'], $routeData['language_id']); /** @var Route $redirectRoute */ $redirectRoute = $this->Routes->newEntity($routeData); if (!empty($defaultRoute)) { $redirectRoute->set('redirect_to', $defaultRoute->id); $redirectRoute->set('status_code', 301); if ($this->Routes->save($redirectRoute)) { $this->Flash->success(__d('wasabi_core', 'New redirect URL <strong>{0}</strong> has been added.', $redirectRoute->url), 'routes'); $this->request->data = []; } else { $this->Flash->error($this->formErrorMessage, 'routes'); $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE); } } else { $this->Flash->error(__d('wasabi_core', 'Please create a default route first.'), 'routes'); $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE); } return $redirectRoute; }
[ "protected", "function", "_addRedirectRoute", "(", "$", "routeData", ")", "{", "/** @var Route $defaultRoute */", "$", "defaultRoute", "=", "$", "this", "->", "Routes", "->", "getDefaultRoute", "(", "$", "routeData", "[", "'model'", "]", ",", "$", "routeData", "[", "'foreign_key'", "]", ",", "$", "routeData", "[", "'language_id'", "]", ")", ";", "/** @var Route $redirectRoute */", "$", "redirectRoute", "=", "$", "this", "->", "Routes", "->", "newEntity", "(", "$", "routeData", ")", ";", "if", "(", "!", "empty", "(", "$", "defaultRoute", ")", ")", "{", "$", "redirectRoute", "->", "set", "(", "'redirect_to'", ",", "$", "defaultRoute", "->", "id", ")", ";", "$", "redirectRoute", "->", "set", "(", "'status_code'", ",", "301", ")", ";", "if", "(", "$", "this", "->", "Routes", "->", "save", "(", "$", "redirectRoute", ")", ")", "{", "$", "this", "->", "Flash", "->", "success", "(", "__d", "(", "'wasabi_core'", ",", "'New redirect URL <strong>{0}</strong> has been added.'", ",", "$", "redirectRoute", "->", "url", ")", ",", "'routes'", ")", ";", "$", "this", "->", "request", "->", "data", "=", "[", "]", ";", "}", "else", "{", "$", "this", "->", "Flash", "->", "error", "(", "$", "this", "->", "formErrorMessage", ",", "'routes'", ")", ";", "$", "redirectRoute", "->", "set", "(", "'type'", ",", "RouteTypes", "::", "TYPE_REDIRECT_ROUTE", ")", ";", "}", "}", "else", "{", "$", "this", "->", "Flash", "->", "error", "(", "__d", "(", "'wasabi_core'", ",", "'Please create a default route first.'", ")", ",", "'routes'", ")", ";", "$", "redirectRoute", "->", "set", "(", "'type'", ",", "RouteTypes", "::", "TYPE_REDIRECT_ROUTE", ")", ";", "}", "return", "$", "redirectRoute", ";", "}" ]
Add a new redirect route. @param array $routeData The route data. @return Route
[ "Add", "a", "new", "redirect", "route", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/RoutesController.php#L259-L282
6,022
wp-pluginner/framework
src/Controller/DevController.php
DevController.calcDiskSize
public function calcDiskSize($path, $bytes = 0) { if ($this->plugin['files']->exists($path)) { if ($this->plugin['files']->isDirectory($path)) { foreach ($this->plugin['files']->glob($path) as $file) { $bytes += $this->plugin['files']->size($file); } } else { $bytes += $this->plugin['files']->size($path); } } $units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; for ($i = 0; $bytes > 1024; $i++) { $bytes /= 1024; } $size = round($bytes, 2); return ($size == 0 ? '-' : $size . ' ' . $units[$i]); }
php
public function calcDiskSize($path, $bytes = 0) { if ($this->plugin['files']->exists($path)) { if ($this->plugin['files']->isDirectory($path)) { foreach ($this->plugin['files']->glob($path) as $file) { $bytes += $this->plugin['files']->size($file); } } else { $bytes += $this->plugin['files']->size($path); } } $units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; for ($i = 0; $bytes > 1024; $i++) { $bytes /= 1024; } $size = round($bytes, 2); return ($size == 0 ? '-' : $size . ' ' . $units[$i]); }
[ "public", "function", "calcDiskSize", "(", "$", "path", ",", "$", "bytes", "=", "0", ")", "{", "if", "(", "$", "this", "->", "plugin", "[", "'files'", "]", "->", "exists", "(", "$", "path", ")", ")", "{", "if", "(", "$", "this", "->", "plugin", "[", "'files'", "]", "->", "isDirectory", "(", "$", "path", ")", ")", "{", "foreach", "(", "$", "this", "->", "plugin", "[", "'files'", "]", "->", "glob", "(", "$", "path", ")", "as", "$", "file", ")", "{", "$", "bytes", "+=", "$", "this", "->", "plugin", "[", "'files'", "]", "->", "size", "(", "$", "file", ")", ";", "}", "}", "else", "{", "$", "bytes", "+=", "$", "this", "->", "plugin", "[", "'files'", "]", "->", "size", "(", "$", "path", ")", ";", "}", "}", "$", "units", "=", "[", "'Bytes'", ",", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "bytes", ">", "1024", ";", "$", "i", "++", ")", "{", "$", "bytes", "/=", "1024", ";", "}", "$", "size", "=", "round", "(", "$", "bytes", ",", "2", ")", ";", "return", "(", "$", "size", "==", "0", "?", "'-'", ":", "$", "size", ".", "' '", ".", "$", "units", "[", "$", "i", "]", ")", ";", "}" ]
Format File Sizes @return string
[ "Format", "File", "Sizes" ]
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Controller/DevController.php#L110-L127
6,023
mfrost503/Snaggle
src/Client/Signatures/HmacSha1.php
HmacSha1.createBaseString
public function createBaseString() { if ($this->timestamp === 0) { $this->setTimestamp(); } $paramArray = array( 'oauth_nonce' => $this->getNonce(), 'oauth_callback' => $this->callback, 'oauth_signature_method' => $this->signatureMethod, 'oauth_timestamp' => $this->getTimestamp(), 'oauth_consumer_key' => $this->consumerCredential->getIdentifier(), 'oauth_token' => $this->userCredential->getIdentifier(), 'oauth_version' => $this->version, 'oauth_verifier' => $this->getVerifier() ); return $this->buildBaseString($paramArray); }
php
public function createBaseString() { if ($this->timestamp === 0) { $this->setTimestamp(); } $paramArray = array( 'oauth_nonce' => $this->getNonce(), 'oauth_callback' => $this->callback, 'oauth_signature_method' => $this->signatureMethod, 'oauth_timestamp' => $this->getTimestamp(), 'oauth_consumer_key' => $this->consumerCredential->getIdentifier(), 'oauth_token' => $this->userCredential->getIdentifier(), 'oauth_version' => $this->version, 'oauth_verifier' => $this->getVerifier() ); return $this->buildBaseString($paramArray); }
[ "public", "function", "createBaseString", "(", ")", "{", "if", "(", "$", "this", "->", "timestamp", "===", "0", ")", "{", "$", "this", "->", "setTimestamp", "(", ")", ";", "}", "$", "paramArray", "=", "array", "(", "'oauth_nonce'", "=>", "$", "this", "->", "getNonce", "(", ")", ",", "'oauth_callback'", "=>", "$", "this", "->", "callback", ",", "'oauth_signature_method'", "=>", "$", "this", "->", "signatureMethod", ",", "'oauth_timestamp'", "=>", "$", "this", "->", "getTimestamp", "(", ")", ",", "'oauth_consumer_key'", "=>", "$", "this", "->", "consumerCredential", "->", "getIdentifier", "(", ")", ",", "'oauth_token'", "=>", "$", "this", "->", "userCredential", "->", "getIdentifier", "(", ")", ",", "'oauth_version'", "=>", "$", "this", "->", "version", ",", "'oauth_verifier'", "=>", "$", "this", "->", "getVerifier", "(", ")", ")", ";", "return", "$", "this", "->", "buildBaseString", "(", "$", "paramArray", ")", ";", "}" ]
Create the base string for the signature
[ "Create", "the", "base", "string", "for", "the", "signature" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/HmacSha1.php#L33-L51
6,024
mfrost503/Snaggle
src/Client/Signatures/HmacSha1.php
HmacSha1.buildBaseString
public function buildBaseString(array $oauthParams) { $tempArray = array(); ksort($oauthParams); if ($oauthParams['oauth_callback'] === '') { unset($oauthParams['oauth_callback']); } if ($oauthParams['oauth_verifier'] === '') { unset($oauthParams['oauth_verifier']); } array_walk($oauthParams, function($value, $key) use (&$tempArray) { $tempArray[] = $key . '=' . rawurlencode($value); }); $parsedUrl = parse_url($this->resourceURL); $baseString = $this->httpMethod .'&'; $baseString .= rawurlencode($parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path']); $baseString .= (isset($parsedUrl['query'])) ? '&' . rawurlencode($parsedUrl['query']) . '%26' : '&'; $baseString .= rawurlencode(implode('&', $tempArray)); array_walk($this->postFields, function($value, $key) use (&$baseString) { $baseString .= '%26' . $key . rawurlencode('=' . $value); }); return $baseString; }
php
public function buildBaseString(array $oauthParams) { $tempArray = array(); ksort($oauthParams); if ($oauthParams['oauth_callback'] === '') { unset($oauthParams['oauth_callback']); } if ($oauthParams['oauth_verifier'] === '') { unset($oauthParams['oauth_verifier']); } array_walk($oauthParams, function($value, $key) use (&$tempArray) { $tempArray[] = $key . '=' . rawurlencode($value); }); $parsedUrl = parse_url($this->resourceURL); $baseString = $this->httpMethod .'&'; $baseString .= rawurlencode($parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path']); $baseString .= (isset($parsedUrl['query'])) ? '&' . rawurlencode($parsedUrl['query']) . '%26' : '&'; $baseString .= rawurlencode(implode('&', $tempArray)); array_walk($this->postFields, function($value, $key) use (&$baseString) { $baseString .= '%26' . $key . rawurlencode('=' . $value); }); return $baseString; }
[ "public", "function", "buildBaseString", "(", "array", "$", "oauthParams", ")", "{", "$", "tempArray", "=", "array", "(", ")", ";", "ksort", "(", "$", "oauthParams", ")", ";", "if", "(", "$", "oauthParams", "[", "'oauth_callback'", "]", "===", "''", ")", "{", "unset", "(", "$", "oauthParams", "[", "'oauth_callback'", "]", ")", ";", "}", "if", "(", "$", "oauthParams", "[", "'oauth_verifier'", "]", "===", "''", ")", "{", "unset", "(", "$", "oauthParams", "[", "'oauth_verifier'", "]", ")", ";", "}", "array_walk", "(", "$", "oauthParams", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "tempArray", ")", "{", "$", "tempArray", "[", "]", "=", "$", "key", ".", "'='", ".", "rawurlencode", "(", "$", "value", ")", ";", "}", ")", ";", "$", "parsedUrl", "=", "parse_url", "(", "$", "this", "->", "resourceURL", ")", ";", "$", "baseString", "=", "$", "this", "->", "httpMethod", ".", "'&'", ";", "$", "baseString", ".=", "rawurlencode", "(", "$", "parsedUrl", "[", "'scheme'", "]", ".", "'://'", ".", "$", "parsedUrl", "[", "'host'", "]", ".", "$", "parsedUrl", "[", "'path'", "]", ")", ";", "$", "baseString", ".=", "(", "isset", "(", "$", "parsedUrl", "[", "'query'", "]", ")", ")", "?", "'&'", ".", "rawurlencode", "(", "$", "parsedUrl", "[", "'query'", "]", ")", ".", "'%26'", ":", "'&'", ";", "$", "baseString", ".=", "rawurlencode", "(", "implode", "(", "'&'", ",", "$", "tempArray", ")", ")", ";", "array_walk", "(", "$", "this", "->", "postFields", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "baseString", ")", "{", "$", "baseString", ".=", "'%26'", ".", "$", "key", ".", "rawurlencode", "(", "'='", ".", "$", "value", ")", ";", "}", ")", ";", "return", "$", "baseString", ";", "}" ]
Build the base string based off the values that are passed in @param array $oauthParams @return string
[ "Build", "the", "base", "string", "based", "off", "the", "values", "that", "are", "passed", "in" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/HmacSha1.php#L59-L87
6,025
mfrost503/Snaggle
src/Client/Signatures/HmacSha1.php
HmacSha1.createCompositeKey
private function createCompositeKey() { $key = rawurlencode($this->consumerCredential->getSecret()) . '&'; if (($userSecret = $this->userCredential->getSecret()) !== '') { $key .= rawurlencode($userSecret); } return $key; }
php
private function createCompositeKey() { $key = rawurlencode($this->consumerCredential->getSecret()) . '&'; if (($userSecret = $this->userCredential->getSecret()) !== '') { $key .= rawurlencode($userSecret); } return $key; }
[ "private", "function", "createCompositeKey", "(", ")", "{", "$", "key", "=", "rawurlencode", "(", "$", "this", "->", "consumerCredential", "->", "getSecret", "(", ")", ")", ".", "'&'", ";", "if", "(", "(", "$", "userSecret", "=", "$", "this", "->", "userCredential", "->", "getSecret", "(", ")", ")", "!==", "''", ")", "{", "$", "key", ".=", "rawurlencode", "(", "$", "userSecret", ")", ";", "}", "return", "$", "key", ";", "}" ]
Method to generate the composite key
[ "Method", "to", "generate", "the", "composite", "key" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/HmacSha1.php#L92-L99
6,026
jokamjohn/telco
src/concrete/Telco.php
Telco.send
public function send($recipient, $message) { try { return $this->gateway->sendMessage($recipient, $message); } catch (AfricasTalkingGatewayException $e) { echo "Encountered an error while sending: " . $e->getMessage(); } }
php
public function send($recipient, $message) { try { return $this->gateway->sendMessage($recipient, $message); } catch (AfricasTalkingGatewayException $e) { echo "Encountered an error while sending: " . $e->getMessage(); } }
[ "public", "function", "send", "(", "$", "recipient", ",", "$", "message", ")", "{", "try", "{", "return", "$", "this", "->", "gateway", "->", "sendMessage", "(", "$", "recipient", ",", "$", "message", ")", ";", "}", "catch", "(", "AfricasTalkingGatewayException", "$", "e", ")", "{", "echo", "\"Encountered an error while sending: \"", ".", "$", "e", "->", "getMessage", "(", ")", ";", "}", "}" ]
Method to send a message @param $recipient @param $message @return array
[ "Method", "to", "send", "a", "message" ]
49443d606e422eec7959010aa9b4ee39dc196933
https://github.com/jokamjohn/telco/blob/49443d606e422eec7959010aa9b4ee39dc196933/src/concrete/Telco.php#L38-L45
6,027
consigliere/components
src/Commands/SeedCommand.php
SeedCommand.getSeederName
public function getSeederName($name) { $name = Str::studly($name); $namespace = $this->laravel['components']->config('namespace'); return $namespace . '\\' . $name . '\Database\Seeders\\' . $name . 'DatabaseSeeder'; }
php
public function getSeederName($name) { $name = Str::studly($name); $namespace = $this->laravel['components']->config('namespace'); return $namespace . '\\' . $name . '\Database\Seeders\\' . $name . 'DatabaseSeeder'; }
[ "public", "function", "getSeederName", "(", "$", "name", ")", "{", "$", "name", "=", "Str", "::", "studly", "(", "$", "name", ")", ";", "$", "namespace", "=", "$", "this", "->", "laravel", "[", "'components'", "]", "->", "config", "(", "'namespace'", ")", ";", "return", "$", "namespace", ".", "'\\\\'", ".", "$", "name", ".", "'\\Database\\Seeders\\\\'", ".", "$", "name", ".", "'DatabaseSeeder'", ";", "}" ]
Get master database seeder name for the specified component. @param string $name @return string
[ "Get", "master", "database", "seeder", "name", "for", "the", "specified", "component", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Commands/SeedCommand.php#L145-L152
6,028
anklimsk/cakephp-extended-test
Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/InnerNode.php
InnerNode.getChildren
public function getChildren() { $nodes = []; try { $child = $this->firstChild(); do { $nodes[] = $child; $child = $this->nextChild($child->id()); } while ( ! is_null($child)); } catch (ChildNotFoundException $e) { // we are done looking for children } return $nodes; }
php
public function getChildren() { $nodes = []; try { $child = $this->firstChild(); do { $nodes[] = $child; $child = $this->nextChild($child->id()); } while ( ! is_null($child)); } catch (ChildNotFoundException $e) { // we are done looking for children } return $nodes; }
[ "public", "function", "getChildren", "(", ")", "{", "$", "nodes", "=", "[", "]", ";", "try", "{", "$", "child", "=", "$", "this", "->", "firstChild", "(", ")", ";", "do", "{", "$", "nodes", "[", "]", "=", "$", "child", ";", "$", "child", "=", "$", "this", "->", "nextChild", "(", "$", "child", "->", "id", "(", ")", ")", ";", "}", "while", "(", "!", "is_null", "(", "$", "child", ")", ")", ";", "}", "catch", "(", "ChildNotFoundException", "$", "e", ")", "{", "// we are done looking for children", "}", "return", "$", "nodes", ";", "}" ]
Returns a new array of child nodes @return array
[ "Returns", "a", "new", "array", "of", "child", "nodes" ]
21691a3be8a198419feb92fb6ed3b35a14dc24b1
https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/InnerNode.php#L73-L87
6,029
anklimsk/cakephp-extended-test
Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/InnerNode.php
InnerNode.isChild
public function isChild($id) { foreach ($this->children as $childId => $child) { if ($id == $childId) { return true; } } return false; }
php
public function isChild($id) { foreach ($this->children as $childId => $child) { if ($id == $childId) { return true; } } return false; }
[ "public", "function", "isChild", "(", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "childId", "=>", "$", "child", ")", "{", "if", "(", "$", "id", "==", "$", "childId", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the given node id is a child of the current node. @param int $id @return bool
[ "Checks", "if", "the", "given", "node", "id", "is", "a", "child", "of", "the", "current", "node", "." ]
21691a3be8a198419feb92fb6ed3b35a14dc24b1
https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/InnerNode.php#L217-L226
6,030
tasoftch/skyline-security
src/RememberMe/AbstractRememberMeService.php
AbstractRememberMeService.generateCookieValue
protected function generateCookieValue($username, $password) { // $username is encoded because it might contain COOKIE_DELIMITER, // we assume other values don't return $this->encodeCookie(array( base64_encode($username), $this->generateCookieHash($username, $password), )); }
php
protected function generateCookieValue($username, $password) { // $username is encoded because it might contain COOKIE_DELIMITER, // we assume other values don't return $this->encodeCookie(array( base64_encode($username), $this->generateCookieHash($username, $password), )); }
[ "protected", "function", "generateCookieValue", "(", "$", "username", ",", "$", "password", ")", "{", "// $username is encoded because it might contain COOKIE_DELIMITER,", "// we assume other values don't", "return", "$", "this", "->", "encodeCookie", "(", "array", "(", "base64_encode", "(", "$", "username", ")", ",", "$", "this", "->", "generateCookieHash", "(", "$", "username", ",", "$", "password", ")", ",", ")", ")", ";", "}" ]
Generates the cookie value. @param string $username The username @param string $password The encoded password @return string
[ "Generates", "the", "cookie", "value", "." ]
4944ad319baec84812b30f6a6428e75b27520a34
https://github.com/tasoftch/skyline-security/blob/4944ad319baec84812b30f6a6428e75b27520a34/src/RememberMe/AbstractRememberMeService.php#L275-L283
6,031
skyrpex/laravel-painless-legacy
src/Foundation/Http/Middleware/TransformsRequest.php
TransformsRequest.cleanValue
protected function cleanValue($key, $value) { if (is_array($value)) { return $this->cleanArray($value); } return $this->transform($key, $value); }
php
protected function cleanValue($key, $value) { if (is_array($value)) { return $this->cleanArray($value); } return $this->transform($key, $value); }
[ "protected", "function", "cleanValue", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "cleanArray", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "transform", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Clean the given value. @param string $key @param mixed $value @return mixed
[ "Clean", "the", "given", "value", "." ]
01a00850e3fb3489b51958fbb1a25a36cc42b0fc
https://github.com/skyrpex/laravel-painless-legacy/blob/01a00850e3fb3489b51958fbb1a25a36cc42b0fc/src/Foundation/Http/Middleware/TransformsRequest.php#L81-L88
6,032
ItinerisLtd/preflight-extra
src/Validators/StatusCodes.php
StatusCodes.validate
public function validate(string ...$urls): ResultInterface { $messages = array_filter( array_map(function (string $url): ?string { return $this->getMessage($url); }, $urls) ); return $this->report(...$messages); }
php
public function validate(string ...$urls): ResultInterface { $messages = array_filter( array_map(function (string $url): ?string { return $this->getMessage($url); }, $urls) ); return $this->report(...$messages); }
[ "public", "function", "validate", "(", "string", "...", "$", "urls", ")", ":", "ResultInterface", "{", "$", "messages", "=", "array_filter", "(", "array_map", "(", "function", "(", "string", "$", "url", ")", ":", "?", "string", "{", "return", "$", "this", "->", "getMessage", "(", "$", "url", ")", ";", "}", ",", "$", "urls", ")", ")", ";", "return", "$", "this", "->", "report", "(", "...", "$", "messages", ")", ";", "}" ]
Validates URLs return expected status code. @param string ...$urls Urls to be checked. @return ResultInterface
[ "Validates", "URLs", "return", "expected", "status", "code", "." ]
c5545cbdf2dab9c2921a842185e3159b683f780c
https://github.com/ItinerisLtd/preflight-extra/blob/c5545cbdf2dab9c2921a842185e3159b683f780c/src/Validators/StatusCodes.php#L35-L44
6,033
ItinerisLtd/preflight-extra
src/Validators/StatusCodes.php
StatusCodes.getMessage
protected function getMessage(string $url): ?string { $response = wp_remote_get($url); $responseCode = wp_remote_retrieve_response_code($response); if (! is_int($responseCode)) { return 'Unable to reach ' . $url; } return ($this->expectedStatusCode === $responseCode) ? null : $url . ' returns ' . $responseCode; }
php
protected function getMessage(string $url): ?string { $response = wp_remote_get($url); $responseCode = wp_remote_retrieve_response_code($response); if (! is_int($responseCode)) { return 'Unable to reach ' . $url; } return ($this->expectedStatusCode === $responseCode) ? null : $url . ' returns ' . $responseCode; }
[ "protected", "function", "getMessage", "(", "string", "$", "url", ")", ":", "?", "string", "{", "$", "response", "=", "wp_remote_get", "(", "$", "url", ")", ";", "$", "responseCode", "=", "wp_remote_retrieve_response_code", "(", "$", "response", ")", ";", "if", "(", "!", "is_int", "(", "$", "responseCode", ")", ")", "{", "return", "'Unable to reach '", ".", "$", "url", ";", "}", "return", "(", "$", "this", "->", "expectedStatusCode", "===", "$", "responseCode", ")", "?", "null", ":", "$", "url", ".", "' returns '", ".", "$", "responseCode", ";", "}" ]
Check the URL's status code. @param string $url The URL to be checked. @return null|string Returns null if status codes is expected.
[ "Check", "the", "URL", "s", "status", "code", "." ]
c5545cbdf2dab9c2921a842185e3159b683f780c
https://github.com/ItinerisLtd/preflight-extra/blob/c5545cbdf2dab9c2921a842185e3159b683f780c/src/Validators/StatusCodes.php#L53-L65
6,034
atelierspierrot/library
src/Library/Session/Session.php
Session.start
public function start() { if ( ! $this->isOpened()) { $this->open(); } if ( ! $this->isLoaded()) { $this->read(); } return $this; }
php
public function start() { if ( ! $this->isOpened()) { $this->open(); } if ( ! $this->isLoaded()) { $this->read(); } return $this; }
[ "public", "function", "start", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "open", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isLoaded", "(", ")", ")", "{", "$", "this", "->", "read", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Start the current session and read it @return self
[ "Start", "the", "current", "session", "and", "read", "it" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L173-L182
6,035
atelierspierrot/library
src/Library/Session/Session.php
Session.open
public function open() { if (version_compare(PHP_VERSION, '5.4', '>')) { if (session_status() == PHP_SESSION_NONE) { session_start(); } } else { @session_start(); } $this->is_opened = true; return $this; }
php
public function open() { if (version_compare(PHP_VERSION, '5.4', '>')) { if (session_status() == PHP_SESSION_NONE) { session_start(); } } else { @session_start(); } $this->is_opened = true; return $this; }
[ "public", "function", "open", "(", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4'", ",", "'>'", ")", ")", "{", "if", "(", "session_status", "(", ")", "==", "PHP_SESSION_NONE", ")", "{", "session_start", "(", ")", ";", "}", "}", "else", "{", "@", "session_start", "(", ")", ";", "}", "$", "this", "->", "is_opened", "=", "true", ";", "return", "$", "this", ";", "}" ]
Open the current session @return self
[ "Open", "the", "current", "session" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L189-L200
6,036
atelierspierrot/library
src/Library/Session/Session.php
Session.read
public function read() { if (isset($_SESSION[static::SESSION_NAME])) { $sess_table = $this->_uncrypt($_SESSION[static::SESSION_NAME]); if (isset($sess_table[static::SESSION_ATTRIBUTESNAME])) { $this->attributes = $sess_table[static::SESSION_ATTRIBUTESNAME]; } } $this->addSessionTable(static::SESSION_ATTRIBUTESNAME, $this->attributes); $this->is_loaded = true; return $this; }
php
public function read() { if (isset($_SESSION[static::SESSION_NAME])) { $sess_table = $this->_uncrypt($_SESSION[static::SESSION_NAME]); if (isset($sess_table[static::SESSION_ATTRIBUTESNAME])) { $this->attributes = $sess_table[static::SESSION_ATTRIBUTESNAME]; } } $this->addSessionTable(static::SESSION_ATTRIBUTESNAME, $this->attributes); $this->is_loaded = true; return $this; }
[ "public", "function", "read", "(", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "static", "::", "SESSION_NAME", "]", ")", ")", "{", "$", "sess_table", "=", "$", "this", "->", "_uncrypt", "(", "$", "_SESSION", "[", "static", "::", "SESSION_NAME", "]", ")", ";", "if", "(", "isset", "(", "$", "sess_table", "[", "static", "::", "SESSION_ATTRIBUTESNAME", "]", ")", ")", "{", "$", "this", "->", "attributes", "=", "$", "sess_table", "[", "static", "::", "SESSION_ATTRIBUTESNAME", "]", ";", "}", "}", "$", "this", "->", "addSessionTable", "(", "static", "::", "SESSION_ATTRIBUTESNAME", ",", "$", "this", "->", "attributes", ")", ";", "$", "this", "->", "is_loaded", "=", "true", ";", "return", "$", "this", ";", "}" ]
Read the current session contents @return self
[ "Read", "the", "current", "session", "contents" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L225-L236
6,037
atelierspierrot/library
src/Library/Session/Session.php
Session.has
public function has($param) { if ( ! $this->isOpened()) { $this->start(); } return isset($this->attributes[$param]); }
php
public function has($param) { if ( ! $this->isOpened()) { $this->start(); } return isset($this->attributes[$param]); }
[ "public", "function", "has", "(", "$", "param", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "attributes", "[", "$", "param", "]", ")", ";", "}" ]
Test if the current session has a parameter @param string $param @return bool
[ "Test", "if", "the", "current", "session", "has", "a", "parameter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L301-L307
6,038
atelierspierrot/library
src/Library/Session/Session.php
Session.get
public function get($param) { if ( ! $this->isOpened()) { $this->start(); } return isset($this->attributes[$param]) ? $this->attributes[$param] : null; }
php
public function get($param) { if ( ! $this->isOpened()) { $this->start(); } return isset($this->attributes[$param]) ? $this->attributes[$param] : null; }
[ "public", "function", "get", "(", "$", "param", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "attributes", "[", "$", "param", "]", ")", "?", "$", "this", "->", "attributes", "[", "$", "param", "]", ":", "null", ";", "}" ]
Get current session parameter @param string $param @return mixed
[ "Get", "current", "session", "parameter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L315-L321
6,039
atelierspierrot/library
src/Library/Session/Session.php
Session.set
public function set($param, $value) { if ( ! $this->isOpened()) { $this->start(); } $this->attributes[$param] = $value; return $this; }
php
public function set($param, $value) { if ( ! $this->isOpened()) { $this->start(); } $this->attributes[$param] = $value; return $this; }
[ "public", "function", "set", "(", "$", "param", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "$", "this", "->", "attributes", "[", "$", "param", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set current session parameter @param string $param @param mixed $value @return self
[ "Set", "current", "session", "parameter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L330-L337
6,040
atelierspierrot/library
src/Library/Session/Session.php
Session.remove
public function remove($param) { if ( ! $this->isOpened()) { $this->start(); } if (isset($this->attributes[$param])) { unset($this->attributes[$param]); } return $this; }
php
public function remove($param) { if ( ! $this->isOpened()) { $this->start(); } if (isset($this->attributes[$param])) { unset($this->attributes[$param]); } return $this; }
[ "public", "function", "remove", "(", "$", "param", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "param", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "attributes", "[", "$", "param", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Delete a session parameter @param string $param @return self
[ "Delete", "a", "session", "parameter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L345-L354
6,041
atelierspierrot/library
src/Library/Session/Session.php
Session.getBackup
public function getBackup($param) { if ($this->isOpened()) { if (!empty($param)) { return isset($this->request_session[$param]) ? $this->request_session[$param] : null; } return $this->request_session; } }
php
public function getBackup($param) { if ($this->isOpened()) { if (!empty($param)) { return isset($this->request_session[$param]) ? $this->request_session[$param] : null; } return $this->request_session; } }
[ "public", "function", "getBackup", "(", "$", "param", ")", "{", "if", "(", "$", "this", "->", "isOpened", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "param", ")", ")", "{", "return", "isset", "(", "$", "this", "->", "request_session", "[", "$", "param", "]", ")", "?", "$", "this", "->", "request_session", "[", "$", "param", "]", ":", "null", ";", "}", "return", "$", "this", "->", "request_session", ";", "}", "}" ]
Get an initial session value @param string $param @return self
[ "Get", "an", "initial", "session", "value" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/Session.php#L362-L371
6,042
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.createTemporary
public static function createTemporary($extension = NULL) { $tmpfile = tempnam(sys_get_temp_dir(), mb_substr(uniqid(),0,3)); if ($extension) { rename($tmpfile, $tmpfile = $tmpfile.'.'.ltrim($extension, '.')); } return new static($tmpfile); }
php
public static function createTemporary($extension = NULL) { $tmpfile = tempnam(sys_get_temp_dir(), mb_substr(uniqid(),0,3)); if ($extension) { rename($tmpfile, $tmpfile = $tmpfile.'.'.ltrim($extension, '.')); } return new static($tmpfile); }
[ "public", "static", "function", "createTemporary", "(", "$", "extension", "=", "NULL", ")", "{", "$", "tmpfile", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "mb_substr", "(", "uniqid", "(", ")", ",", "0", ",", "3", ")", ")", ";", "if", "(", "$", "extension", ")", "{", "rename", "(", "$", "tmpfile", ",", "$", "tmpfile", "=", "$", "tmpfile", ".", "'.'", ".", "ltrim", "(", "$", "extension", ",", "'.'", ")", ")", ";", "}", "return", "new", "static", "(", "$", "tmpfile", ")", ";", "}" ]
Creates a temporary File in the system temp directory @return Webforge\Common\System\File
[ "Creates", "a", "temporary", "File", "in", "the", "system", "temp", "directory" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L75-L83
6,043
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.constructString
protected function constructString($file) { if (mb_strlen($file) == 0) throw new Exception('keine Datei angegeben'); $dir = NULL; try { $dir = Dir::extract($file); } catch (Exception $e) { /* kein Verzeichnis vorhanden, vll ein Notice? (aber eigentlich sollte dies ja auch okay sein */ } $filename = self::extractFilename($file); $this->constructDefault($filename,$dir); }
php
protected function constructString($file) { if (mb_strlen($file) == 0) throw new Exception('keine Datei angegeben'); $dir = NULL; try { $dir = Dir::extract($file); } catch (Exception $e) { /* kein Verzeichnis vorhanden, vll ein Notice? (aber eigentlich sollte dies ja auch okay sein */ } $filename = self::extractFilename($file); $this->constructDefault($filename,$dir); }
[ "protected", "function", "constructString", "(", "$", "file", ")", "{", "if", "(", "mb_strlen", "(", "$", "file", ")", "==", "0", ")", "throw", "new", "Exception", "(", "'keine Datei angegeben'", ")", ";", "$", "dir", "=", "NULL", ";", "try", "{", "$", "dir", "=", "Dir", "::", "extract", "(", "$", "file", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "/* kein Verzeichnis vorhanden, vll ein Notice? (aber eigentlich sollte dies ja auch okay sein */", "}", "$", "filename", "=", "self", "::", "extractFilename", "(", "$", "file", ")", ";", "$", "this", "->", "constructDefault", "(", "$", "filename", ",", "$", "dir", ")", ";", "}" ]
Creates a new File instance from single string @param string $file
[ "Creates", "a", "new", "File", "instance", "from", "single", "string" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L103-L117
6,044
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.constructDefault
protected function constructDefault($filename, Dir $directory=NULL) { $this->setName($filename); if (isset($directory)) $this->setDirectory($directory); }
php
protected function constructDefault($filename, Dir $directory=NULL) { $this->setName($filename); if (isset($directory)) $this->setDirectory($directory); }
[ "protected", "function", "constructDefault", "(", "$", "filename", ",", "Dir", "$", "directory", "=", "NULL", ")", "{", "$", "this", "->", "setName", "(", "$", "filename", ")", ";", "if", "(", "isset", "(", "$", "directory", ")", ")", "$", "this", "->", "setDirectory", "(", "$", "directory", ")", ";", "}" ]
Creates a new File from filename and Directory Object @param string $filename der Name der Datei @param Dir $directory das Verzeichnis in dem die Datei liegt
[ "Creates", "a", "new", "File", "from", "filename", "and", "Directory", "Object" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L125-L130
6,045
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.move
public function move(File $fileDestination, $overwrite = FALSE) { if (!$this->exists()) throw new Exception('Quelle von move existiert nicht. '.$this); if ($fileDestination->exists() && !$overwrite) { throw new Exception('Das Ziel von move existiert bereits'.$fileDestination); } if (!$fileDestination->getDirectory()->exists()) { throw new Exception('Das ZielVerzeichnis von move existiert nicht: '.$fileDestination->getDirectory()); } if ($fileDestination->exists() && $overwrite && substr(PHP_OS, 0, 3) == 'WIN') { $fileDestination->delete(); } $ret = rename((string) $this, (string) $fileDestination); if ($ret) { $this->setDirectory($fileDestination->getDirectory()); $this->setName($fileDestination->getName()); } return $ret; }
php
public function move(File $fileDestination, $overwrite = FALSE) { if (!$this->exists()) throw new Exception('Quelle von move existiert nicht. '.$this); if ($fileDestination->exists() && !$overwrite) { throw new Exception('Das Ziel von move existiert bereits'.$fileDestination); } if (!$fileDestination->getDirectory()->exists()) { throw new Exception('Das ZielVerzeichnis von move existiert nicht: '.$fileDestination->getDirectory()); } if ($fileDestination->exists() && $overwrite && substr(PHP_OS, 0, 3) == 'WIN') { $fileDestination->delete(); } $ret = rename((string) $this, (string) $fileDestination); if ($ret) { $this->setDirectory($fileDestination->getDirectory()); $this->setName($fileDestination->getName()); } return $ret; }
[ "public", "function", "move", "(", "File", "$", "fileDestination", ",", "$", "overwrite", "=", "FALSE", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "throw", "new", "Exception", "(", "'Quelle von move existiert nicht. '", ".", "$", "this", ")", ";", "if", "(", "$", "fileDestination", "->", "exists", "(", ")", "&&", "!", "$", "overwrite", ")", "{", "throw", "new", "Exception", "(", "'Das Ziel von move existiert bereits'", ".", "$", "fileDestination", ")", ";", "}", "if", "(", "!", "$", "fileDestination", "->", "getDirectory", "(", ")", "->", "exists", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'Das ZielVerzeichnis von move existiert nicht: '", ".", "$", "fileDestination", "->", "getDirectory", "(", ")", ")", ";", "}", "if", "(", "$", "fileDestination", "->", "exists", "(", ")", "&&", "$", "overwrite", "&&", "substr", "(", "PHP_OS", ",", "0", ",", "3", ")", "==", "'WIN'", ")", "{", "$", "fileDestination", "->", "delete", "(", ")", ";", "}", "$", "ret", "=", "rename", "(", "(", "string", ")", "$", "this", ",", "(", "string", ")", "$", "fileDestination", ")", ";", "if", "(", "$", "ret", ")", "{", "$", "this", "->", "setDirectory", "(", "$", "fileDestination", "->", "getDirectory", "(", ")", ")", ";", "$", "this", "->", "setName", "(", "$", "fileDestination", "->", "getName", "(", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Moves the File to another file and changes the internal state to the destination after this command (string) $fileDestination-> === (string) $this is true @param File $fileDestination @return bool
[ "Moves", "the", "File", "to", "another", "file", "and", "changes", "the", "internal", "state", "to", "the", "destination" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L225-L249
6,046
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.copy
public function copy($destination) { if (!$this->exists()) { throw new Exception('Source from copy does not exist: '.$this); } if ($destination instanceof Dir) { $destination = $destination->getFile($this->getName()); } elseif (!($destination instanceof File)) { throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir'); } if (!$destination->getDirectory()->exists()) { throw new Exception('The directory from the destination file does not exist: '.$destination); } $ret = @copy((string) $this, (string) $destination); if (!$ret) { throw new Exception('PHP Error while copying '.$this.' onto '.$destination); } return $this; }
php
public function copy($destination) { if (!$this->exists()) { throw new Exception('Source from copy does not exist: '.$this); } if ($destination instanceof Dir) { $destination = $destination->getFile($this->getName()); } elseif (!($destination instanceof File)) { throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir'); } if (!$destination->getDirectory()->exists()) { throw new Exception('The directory from the destination file does not exist: '.$destination); } $ret = @copy((string) $this, (string) $destination); if (!$ret) { throw new Exception('PHP Error while copying '.$this.' onto '.$destination); } return $this; }
[ "public", "function", "copy", "(", "$", "destination", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'Source from copy does not exist: '", ".", "$", "this", ")", ";", "}", "if", "(", "$", "destination", "instanceof", "Dir", ")", "{", "$", "destination", "=", "$", "destination", "->", "getFile", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "!", "(", "$", "destination", "instanceof", "File", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid Argument. $destination must be file or dir'", ")", ";", "}", "if", "(", "!", "$", "destination", "->", "getDirectory", "(", ")", "->", "exists", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'The directory from the destination file does not exist: '", ".", "$", "destination", ")", ";", "}", "$", "ret", "=", "@", "copy", "(", "(", "string", ")", "$", "this", ",", "(", "string", ")", "$", "destination", ")", ";", "if", "(", "!", "$", "ret", ")", "{", "throw", "new", "Exception", "(", "'PHP Error while copying '", ".", "$", "this", ".", "' onto '", ".", "$", "destination", ")", ";", "}", "return", "$", "this", ";", "}" ]
Copys the file to another file or into an directory @param File|Dir $fileDestination @chainable
[ "Copys", "the", "file", "to", "another", "file", "or", "into", "an", "directory" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L257-L280
6,047
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.setName
public function setName($name) { if (($pos = mb_strrpos($name,'.')) !== FALSE) { $this->name = mb_substr($name, 0, $pos); $this->extension = mb_substr($name, $pos+1); } else { $this->name = $name; } return $this; }
php
public function setName($name) { if (($pos = mb_strrpos($name,'.')) !== FALSE) { $this->name = mb_substr($name, 0, $pos); $this->extension = mb_substr($name, $pos+1); } else { $this->name = $name; } return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "(", "$", "pos", "=", "mb_strrpos", "(", "$", "name", ",", "'.'", ")", ")", "!==", "FALSE", ")", "{", "$", "this", "->", "name", "=", "mb_substr", "(", "$", "name", ",", "0", ",", "$", "pos", ")", ";", "$", "this", "->", "extension", "=", "mb_substr", "(", "$", "name", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "$", "this", "->", "name", "=", "$", "name", ";", "}", "return", "$", "this", ";", "}" ]
Sets the name of the file If extension is NOT found in $name extension won't be replaced @param string $name filename with extension @chainable
[ "Sets", "the", "name", "of", "the", "file" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L350-L359
6,048
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.getQuotedString
public function getQuotedString() { $str = (string) $this; if (mb_strpos($str, ' ') !== FALSE) { return escapeshellarg($str); } return $str; }
php
public function getQuotedString() { $str = (string) $this; if (mb_strpos($str, ' ') !== FALSE) { return escapeshellarg($str); } return $str; }
[ "public", "function", "getQuotedString", "(", ")", "{", "$", "str", "=", "(", "string", ")", "$", "this", ";", "if", "(", "mb_strpos", "(", "$", "str", ",", "' '", ")", "!==", "FALSE", ")", "{", "return", "escapeshellarg", "(", "$", "str", ")", ";", "}", "return", "$", "str", ";", "}" ]
Returns the filename with quotes if dir or file have whitespace in their names @return string
[ "Returns", "the", "filename", "with", "quotes", "if", "dir", "or", "file", "have", "whitespace", "in", "their", "names" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L397-L405
6,049
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.findExtension
public function findExtension(Array $possibleExtensions) { foreach ($possibleExtensions as $extension) { $file = clone $this; $file->setExtension($extension); if ($file->exists()) { return $file; } } throw FileNotFoundException::fromFileAndExtensions($this, $possibleExtensions); }
php
public function findExtension(Array $possibleExtensions) { foreach ($possibleExtensions as $extension) { $file = clone $this; $file->setExtension($extension); if ($file->exists()) { return $file; } } throw FileNotFoundException::fromFileAndExtensions($this, $possibleExtensions); }
[ "public", "function", "findExtension", "(", "Array", "$", "possibleExtensions", ")", "{", "foreach", "(", "$", "possibleExtensions", "as", "$", "extension", ")", "{", "$", "file", "=", "clone", "$", "this", ";", "$", "file", "->", "setExtension", "(", "$", "extension", ")", ";", "if", "(", "$", "file", "->", "exists", "(", ")", ")", "{", "return", "$", "file", ";", "}", "}", "throw", "FileNotFoundException", "::", "fromFileAndExtensions", "(", "$", "this", ",", "$", "possibleExtensions", ")", ";", "}" ]
Returns the first file that exists with one of the given extensions Dir contents: thefile.js thefile.php thefile.csv $dir->getFile('thefile')->findExtension(array('php', 'js', 'csv')); // returns thefile.php $dir->getFile('thefile')->findExtension(array('js', 'csv')); // returns thefile.js $dir->getFile('thefile')->findExtension(array('html', 'csv')); // returns thefile.csv
[ "Returns", "the", "first", "file", "that", "exists", "with", "one", "of", "the", "given", "extensions" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L505-L516
6,050
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.extractFilename
public static function extractFilename($string) { if (mb_strlen($string) == 0) throw new Exception('Cannot extract filename from empty string'); $file = basename($string); if (mb_strlen($file) == 0) throw new Exception('PHP could not extract the basename of the file: '.$file); return $file; }
php
public static function extractFilename($string) { if (mb_strlen($string) == 0) throw new Exception('Cannot extract filename from empty string'); $file = basename($string); if (mb_strlen($file) == 0) throw new Exception('PHP could not extract the basename of the file: '.$file); return $file; }
[ "public", "static", "function", "extractFilename", "(", "$", "string", ")", "{", "if", "(", "mb_strlen", "(", "$", "string", ")", "==", "0", ")", "throw", "new", "Exception", "(", "'Cannot extract filename from empty string'", ")", ";", "$", "file", "=", "basename", "(", "$", "string", ")", ";", "if", "(", "mb_strlen", "(", "$", "file", ")", "==", "0", ")", "throw", "new", "Exception", "(", "'PHP could not extract the basename of the file: '", ".", "$", "file", ")", ";", "return", "$", "file", ";", "}" ]
Extrahiert eine Datei als String aus einer Pfadangabe @param string $string ein Pfad zu einer Datei @return string name der Datei
[ "Extrahiert", "eine", "Datei", "als", "String", "aus", "einer", "Pfadangabe" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L535-L545
6,051
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.getURL
public function getURL(Dir $relativeDir = NULL) { // rtrim entfernt den TrailingSlash der URL (der eigentlich nie da sein sollte, außer falls directoryURL nur "/" ist) return rtrim($this->directory->getURL($relativeDir),'/').'/'.rawurlencode($this->getName(self::WITH_EXTENSION)); }
php
public function getURL(Dir $relativeDir = NULL) { // rtrim entfernt den TrailingSlash der URL (der eigentlich nie da sein sollte, außer falls directoryURL nur "/" ist) return rtrim($this->directory->getURL($relativeDir),'/').'/'.rawurlencode($this->getName(self::WITH_EXTENSION)); }
[ "public", "function", "getURL", "(", "Dir", "$", "relativeDir", "=", "NULL", ")", "{", "// rtrim entfernt den TrailingSlash der URL (der eigentlich nie da sein sollte, außer falls directoryURL nur \"/\" ist)", "return", "rtrim", "(", "$", "this", "->", "directory", "->", "getURL", "(", "$", "relativeDir", ")", ",", "'/'", ")", ".", "'/'", ".", "rawurlencode", "(", "$", "this", "->", "getName", "(", "self", "::", "WITH_EXTENSION", ")", ")", ";", "}" ]
Returns the URL for the File relative to a directory @return string with forward slashes and the names rawurlencoded
[ "Returns", "the", "URL", "for", "the", "File", "relative", "to", "a", "directory" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L585-L588
6,052
webforge-labs/webforge-utils
src/php/Webforge/Common/System/File.php
File.getSha1
public function getSha1() { if (!isset($this->sha1)) { $this->sha1 = sha1_file((string) $this); } return $this->sha1; }
php
public function getSha1() { if (!isset($this->sha1)) { $this->sha1 = sha1_file((string) $this); } return $this->sha1; }
[ "public", "function", "getSha1", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "sha1", ")", ")", "{", "$", "this", "->", "sha1", "=", "sha1_file", "(", "(", "string", ")", "$", "this", ")", ";", "}", "return", "$", "this", "->", "sha1", ";", "}" ]
returns the SHA1 of the file Attention: the file must exist the hash is cached @return string
[ "returns", "the", "SHA1", "of", "the", "file" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/File.php#L601-L607
6,053
ilya-dev/exo
source/Exo/Builder.php
Builder.buildBlock
public function buildBlock($code) { $lines = $this->parser->splitIntoLines($code); $result = []; foreach (array_filter($lines) as $line) { $result[] = $this->printer->toString( eval ("return {$line};") ); } return sprintf( "```php\n%s```\n```\n%s\n```\n", implode("\n", $lines), implode("\n", $result) ); }
php
public function buildBlock($code) { $lines = $this->parser->splitIntoLines($code); $result = []; foreach (array_filter($lines) as $line) { $result[] = $this->printer->toString( eval ("return {$line};") ); } return sprintf( "```php\n%s```\n```\n%s\n```\n", implode("\n", $lines), implode("\n", $result) ); }
[ "public", "function", "buildBlock", "(", "$", "code", ")", "{", "$", "lines", "=", "$", "this", "->", "parser", "->", "splitIntoLines", "(", "$", "code", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "array_filter", "(", "$", "lines", ")", "as", "$", "line", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "printer", "->", "toString", "(", "eval", "(", "\"return {$line};\"", ")", ")", ";", "}", "return", "sprintf", "(", "\"```php\\n%s```\\n```\\n%s\\n```\\n\"", ",", "implode", "(", "\"\\n\"", ",", "$", "lines", ")", ",", "implode", "(", "\"\\n\"", ",", "$", "result", ")", ")", ";", "}" ]
Build an example block. @param string $code @return string
[ "Build", "an", "example", "block", "." ]
89960a0116513c3172f107041bc9b9fa80ba8e54
https://github.com/ilya-dev/exo/blob/89960a0116513c3172f107041bc9b9fa80ba8e54/source/Exo/Builder.php#L58-L75
6,054
PentagonalProject/SlimService
src/Abstracts/ModularAbstract.php
ModularAbstract.getModularInfo
public function getModularInfo() : array { return [ static::NAME => $this->getModularName(), static::VERSION => $this->getModularVersion(), static::URI => $this->getModularUri(), static::AUTHOR => $this->getModularAuthor(), static::AUTHOR_URI => $this->getModularAuthorUri(), static::DESCRIPTION => $this->getModularDescription(), static::CLASS_NAME => get_class($this), static::FILE_PATH => $this->getModularRealPath(), static::SELECTOR => $this->getModularNameSelector(), ]; }
php
public function getModularInfo() : array { return [ static::NAME => $this->getModularName(), static::VERSION => $this->getModularVersion(), static::URI => $this->getModularUri(), static::AUTHOR => $this->getModularAuthor(), static::AUTHOR_URI => $this->getModularAuthorUri(), static::DESCRIPTION => $this->getModularDescription(), static::CLASS_NAME => get_class($this), static::FILE_PATH => $this->getModularRealPath(), static::SELECTOR => $this->getModularNameSelector(), ]; }
[ "public", "function", "getModularInfo", "(", ")", ":", "array", "{", "return", "[", "static", "::", "NAME", "=>", "$", "this", "->", "getModularName", "(", ")", ",", "static", "::", "VERSION", "=>", "$", "this", "->", "getModularVersion", "(", ")", ",", "static", "::", "URI", "=>", "$", "this", "->", "getModularUri", "(", ")", ",", "static", "::", "AUTHOR", "=>", "$", "this", "->", "getModularAuthor", "(", ")", ",", "static", "::", "AUTHOR_URI", "=>", "$", "this", "->", "getModularAuthorUri", "(", ")", ",", "static", "::", "DESCRIPTION", "=>", "$", "this", "->", "getModularDescription", "(", ")", ",", "static", "::", "CLASS_NAME", "=>", "get_class", "(", "$", "this", ")", ",", "static", "::", "FILE_PATH", "=>", "$", "this", "->", "getModularRealPath", "(", ")", ",", "static", "::", "SELECTOR", "=>", "$", "this", "->", "getModularNameSelector", "(", ")", ",", "]", ";", "}" ]
Get Modular Info @return array
[ "Get", "Modular", "Info" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Abstracts/ModularAbstract.php#L135-L148
6,055
AthensFramework/Core
src/filter/FilterBuilder.php
FilterBuilder.retrieveOrException
protected function retrieveOrException($attrName, $methodName = "this method", $reason = "") { if (property_exists($this, $attrName) === false) { throw new \Exception("Property $attrName not found in class."); } if ($this->$attrName === null) { $message = $reason !== "" ? "Because you $reason, " : "You "; $message .= "must set $attrName for this object before calling $methodName."; throw new \Exception($message); } return $this->$attrName; }
php
protected function retrieveOrException($attrName, $methodName = "this method", $reason = "") { if (property_exists($this, $attrName) === false) { throw new \Exception("Property $attrName not found in class."); } if ($this->$attrName === null) { $message = $reason !== "" ? "Because you $reason, " : "You "; $message .= "must set $attrName for this object before calling $methodName."; throw new \Exception($message); } return $this->$attrName; }
[ "protected", "function", "retrieveOrException", "(", "$", "attrName", ",", "$", "methodName", "=", "\"this method\"", ",", "$", "reason", "=", "\"\"", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "attrName", ")", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Property $attrName not found in class.\"", ")", ";", "}", "if", "(", "$", "this", "->", "$", "attrName", "===", "null", ")", "{", "$", "message", "=", "$", "reason", "!==", "\"\"", "?", "\"Because you $reason, \"", ":", "\"You \"", ";", "$", "message", ".=", "\"must set $attrName for this object before calling $methodName.\"", ";", "throw", "new", "\\", "Exception", "(", "$", "message", ")", ";", "}", "return", "$", "this", "->", "$", "attrName", ";", "}" ]
If it has been set, retrieve the indicated property from this builder. If not, throw exception. @param string $attrName The name of the attribute to retrieve, including underscore. @param string $methodName The name of the calling method, optional. @param string $reason An optional, additional "reason" to display with the exception. @return mixed The indicated attribute, if set. @throws \Exception If the indicated attribute has not been set, or if the attribute does not exist.
[ "If", "it", "has", "been", "set", "retrieve", "the", "indicated", "property", "from", "this", "builder", ".", "If", "not", "throw", "exception", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/filter/FilterBuilder.php#L157-L172
6,056
mooti/framework
src/Framework.php
Framework.createNew
public function createNew($className) { $constructArguments = func_get_args(); $object = $this->_createNew( ...$constructArguments); $traits = class_uses($object); if (isset($traits[Framework::class]) == true) { $object->setContainer($this->container); } return $object; }
php
public function createNew($className) { $constructArguments = func_get_args(); $object = $this->_createNew( ...$constructArguments); $traits = class_uses($object); if (isset($traits[Framework::class]) == true) { $object->setContainer($this->container); } return $object; }
[ "public", "function", "createNew", "(", "$", "className", ")", "{", "$", "constructArguments", "=", "func_get_args", "(", ")", ";", "$", "object", "=", "$", "this", "->", "_createNew", "(", "...", "$", "constructArguments", ")", ";", "$", "traits", "=", "class_uses", "(", "$", "object", ")", ";", "if", "(", "isset", "(", "$", "traits", "[", "Framework", "::", "class", "]", ")", "==", "true", ")", "{", "$", "object", "->", "setContainer", "(", "$", "this", "->", "container", ")", ";", "}", "return", "$", "object", ";", "}" ]
Create a new instance of a given class @param string $className The class to create @return object The new class
[ "Create", "a", "new", "instance", "of", "a", "given", "class" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Framework.php#L47-L59
6,057
sebardo/ecommerce
EcommerceBundle/Factory/Providers/BraintreeProvider.php
BraintreeProvider.initialize
public function initialize($container, PaymentServiceProvider $psp) { parent::initialize($container, $psp); if(isset($this->parameters['environment'])) Braintree_Configuration::environment($this->parameters['environment']); if(isset($this->parameters['merchant_id'])) Braintree_Configuration::merchantId($this->parameters['merchant_id']); if(isset($this->parameters['public_key'])) Braintree_Configuration::publicKey($this->parameters['public_key']); if(isset($this->parameters['private_key'])) Braintree_Configuration::privateKey($this->parameters['private_key']); return $this; }
php
public function initialize($container, PaymentServiceProvider $psp) { parent::initialize($container, $psp); if(isset($this->parameters['environment'])) Braintree_Configuration::environment($this->parameters['environment']); if(isset($this->parameters['merchant_id'])) Braintree_Configuration::merchantId($this->parameters['merchant_id']); if(isset($this->parameters['public_key'])) Braintree_Configuration::publicKey($this->parameters['public_key']); if(isset($this->parameters['private_key'])) Braintree_Configuration::privateKey($this->parameters['private_key']); return $this; }
[ "public", "function", "initialize", "(", "$", "container", ",", "PaymentServiceProvider", "$", "psp", ")", "{", "parent", "::", "initialize", "(", "$", "container", ",", "$", "psp", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "'environment'", "]", ")", ")", "Braintree_Configuration", "::", "environment", "(", "$", "this", "->", "parameters", "[", "'environment'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "'merchant_id'", "]", ")", ")", "Braintree_Configuration", "::", "merchantId", "(", "$", "this", "->", "parameters", "[", "'merchant_id'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "'public_key'", "]", ")", ")", "Braintree_Configuration", "::", "publicKey", "(", "$", "this", "->", "parameters", "[", "'public_key'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "'private_key'", "]", ")", ")", "Braintree_Configuration", "::", "privateKey", "(", "$", "this", "->", "parameters", "[", "'private_key'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Constructor with Braintree configuration @param string $container @param PaymentServiceProvider $psp
[ "Constructor", "with", "Braintree", "configuration" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Factory/Providers/BraintreeProvider.php#L30-L39
6,058
sebardo/ecommerce
EcommerceBundle/Factory/Providers/BraintreeProvider.php
BraintreeProvider.get
public function get($serviceName, array $attributes = array(), $methodName='factory') { $className = 'Braintree_' . ucfirst($serviceName); if(class_exists($className) && method_exists($className, $methodName)) { if($methodName=='factory') return $className::$methodName($attributes); else return $className::$methodName(); } else { throw new InvalidServiceException('Invalid service ' . $serviceName); } }
php
public function get($serviceName, array $attributes = array(), $methodName='factory') { $className = 'Braintree_' . ucfirst($serviceName); if(class_exists($className) && method_exists($className, $methodName)) { if($methodName=='factory') return $className::$methodName($attributes); else return $className::$methodName(); } else { throw new InvalidServiceException('Invalid service ' . $serviceName); } }
[ "public", "function", "get", "(", "$", "serviceName", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "methodName", "=", "'factory'", ")", "{", "$", "className", "=", "'Braintree_'", ".", "ucfirst", "(", "$", "serviceName", ")", ";", "if", "(", "class_exists", "(", "$", "className", ")", "&&", "method_exists", "(", "$", "className", ",", "$", "methodName", ")", ")", "{", "if", "(", "$", "methodName", "==", "'factory'", ")", "return", "$", "className", "::", "$", "methodName", "(", "$", "attributes", ")", ";", "else", "return", "$", "className", "::", "$", "methodName", "(", ")", ";", "}", "else", "{", "throw", "new", "InvalidServiceException", "(", "'Invalid service '", ".", "$", "serviceName", ")", ";", "}", "}" ]
Factory method for creating and getting Braintree services @param string $serviceName braintree service name @param array $attributes attribures for braintree service creation @return mixed
[ "Factory", "method", "for", "creating", "and", "getting", "Braintree", "services" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Factory/Providers/BraintreeProvider.php#L65-L74
6,059
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.isRed
protected function isRed(?RedBlackNode $node): bool { if ($node === null) { return false; } return $node->color() === RedBlackNode::RED; }
php
protected function isRed(?RedBlackNode $node): bool { if ($node === null) { return false; } return $node->color() === RedBlackNode::RED; }
[ "protected", "function", "isRed", "(", "?", "RedBlackNode", "$", "node", ")", ":", "bool", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "false", ";", "}", "return", "$", "node", "->", "color", "(", ")", "===", "RedBlackNode", "::", "RED", ";", "}" ]
Checks if a node is red @param RedBlackNode|null $node The node @return bool
[ "Checks", "if", "a", "node", "is", "red" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L294-L301
6,060
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeSet
protected function nodeSet($key, $value, ?RedBlackNode $node): RedBlackNode { if ($node === null) { return new RedBlackNode($key, $value, 1, RedBlackNode::RED); } $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node->setLeft($this->nodeSet($key, $value, $node->left())); } elseif ($comp > 0) { $node->setRight($this->nodeSet($key, $value, $node->right())); } else { $node->setValue($value); } return $this->balanceOnInsert($node); }
php
protected function nodeSet($key, $value, ?RedBlackNode $node): RedBlackNode { if ($node === null) { return new RedBlackNode($key, $value, 1, RedBlackNode::RED); } $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node->setLeft($this->nodeSet($key, $value, $node->left())); } elseif ($comp > 0) { $node->setRight($this->nodeSet($key, $value, $node->right())); } else { $node->setValue($value); } return $this->balanceOnInsert($node); }
[ "protected", "function", "nodeSet", "(", "$", "key", ",", "$", "value", ",", "?", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "new", "RedBlackNode", "(", "$", "key", ",", "$", "value", ",", "1", ",", "RedBlackNode", "::", "RED", ")", ";", "}", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "<", "0", ")", "{", "$", "node", "->", "setLeft", "(", "$", "this", "->", "nodeSet", "(", "$", "key", ",", "$", "value", ",", "$", "node", "->", "left", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "comp", ">", "0", ")", "{", "$", "node", "->", "setRight", "(", "$", "this", "->", "nodeSet", "(", "$", "key", ",", "$", "value", ",", "$", "node", "->", "right", "(", ")", ")", ")", ";", "}", "else", "{", "$", "node", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "balanceOnInsert", "(", "$", "node", ")", ";", "}" ]
Inserts a key-value pair in a subtree @param mixed $key The key @param mixed $value The value @param RedBlackNode|null $node The subtree root @return RedBlackNode
[ "Inserts", "a", "key", "-", "value", "pair", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L328-L345
6,061
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeGet
protected function nodeGet($key, ?RedBlackNode $node): ?RedBlackNode { while ($node !== null) { $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node = $node->left(); } elseif ($comp > 0) { $node = $node->right(); } else { return $node; } } return null; }
php
protected function nodeGet($key, ?RedBlackNode $node): ?RedBlackNode { while ($node !== null) { $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node = $node->left(); } elseif ($comp > 0) { $node = $node->right(); } else { return $node; } } return null; }
[ "protected", "function", "nodeGet", "(", "$", "key", ",", "?", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "while", "(", "$", "node", "!==", "null", ")", "{", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "<", "0", ")", "{", "$", "node", "=", "$", "node", "->", "left", "(", ")", ";", "}", "elseif", "(", "$", "comp", ">", "0", ")", "{", "$", "node", "=", "$", "node", "->", "right", "(", ")", ";", "}", "else", "{", "return", "$", "node", ";", "}", "}", "return", "null", ";", "}" ]
Retrieves a node by key and subtree Returns null if the node is not found. @param mixed $key The key @param RedBlackNode|null $node The subtree root @return RedBlackNode|null
[ "Retrieves", "a", "node", "by", "key", "and", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L357-L371
6,062
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRemove
protected function nodeRemove($key, RedBlackNode $node): ?RedBlackNode { $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node = $this->nodeRemoveLeft($key, $node); } else { if ($this->isRed($node->left())) { $node = $this->rotateRight($node); } if ($comp === 0 && $node->right() === null) { return null; } $node = $this->nodeRemoveRight($key, $node); } return $this->balanceOnRemove($node); }
php
protected function nodeRemove($key, RedBlackNode $node): ?RedBlackNode { $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { $node = $this->nodeRemoveLeft($key, $node); } else { if ($this->isRed($node->left())) { $node = $this->rotateRight($node); } if ($comp === 0 && $node->right() === null) { return null; } $node = $this->nodeRemoveRight($key, $node); } return $this->balanceOnRemove($node); }
[ "protected", "function", "nodeRemove", "(", "$", "key", ",", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "<", "0", ")", "{", "$", "node", "=", "$", "this", "->", "nodeRemoveLeft", "(", "$", "key", ",", "$", "node", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "rotateRight", "(", "$", "node", ")", ";", "}", "if", "(", "$", "comp", "===", "0", "&&", "$", "node", "->", "right", "(", ")", "===", "null", ")", "{", "return", "null", ";", "}", "$", "node", "=", "$", "this", "->", "nodeRemoveRight", "(", "$", "key", ",", "$", "node", ")", ";", "}", "return", "$", "this", "->", "balanceOnRemove", "(", "$", "node", ")", ";", "}" ]
Deletes a node by key and subtree @param mixed $key The key @param RedBlackNode $node The subtree root @return RedBlackNode|null
[ "Deletes", "a", "node", "by", "key", "and", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L381-L397
6,063
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRemoveLeft
protected function nodeRemoveLeft($key, RedBlackNode $node): RedBlackNode { if (!$this->isRed($node->left()) && !$this->isRed($node->left()->left())) { $node = $this->moveRedLeft($node); } $node->setLeft($this->nodeRemove($key, $node->left())); return $node; }
php
protected function nodeRemoveLeft($key, RedBlackNode $node): RedBlackNode { if (!$this->isRed($node->left()) && !$this->isRed($node->left()->left())) { $node = $this->moveRedLeft($node); } $node->setLeft($this->nodeRemove($key, $node->left())); return $node; }
[ "protected", "function", "nodeRemoveLeft", "(", "$", "key", ",", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", "&&", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "moveRedLeft", "(", "$", "node", ")", ";", "}", "$", "node", "->", "setLeft", "(", "$", "this", "->", "nodeRemove", "(", "$", "key", ",", "$", "node", "->", "left", "(", ")", ")", ")", ";", "return", "$", "node", ";", "}" ]
Deletes a node to the left by key and subtree @internal Helper for nodeRemove() @param mixed $key The key @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Deletes", "a", "node", "to", "the", "left", "by", "key", "and", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L409-L417
6,064
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRemoveRight
protected function nodeRemoveRight($key, RedBlackNode $node): RedBlackNode { if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) { $node = $this->moveRedRight($node); } if ($this->comparator->compare($key, $node->key()) === 0) { $link = $this->nodeMin($node->right()); $node->setKey($link->key()); $node->setValue($link->value()); $node->setRight($this->nodeRemoveMin($node->right())); } else { $node->setRight($this->nodeRemove($key, $node->right())); } return $node; }
php
protected function nodeRemoveRight($key, RedBlackNode $node): RedBlackNode { if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) { $node = $this->moveRedRight($node); } if ($this->comparator->compare($key, $node->key()) === 0) { $link = $this->nodeMin($node->right()); $node->setKey($link->key()); $node->setValue($link->value()); $node->setRight($this->nodeRemoveMin($node->right())); } else { $node->setRight($this->nodeRemove($key, $node->right())); } return $node; }
[ "protected", "function", "nodeRemoveRight", "(", "$", "key", ",", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", ")", "&&", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "moveRedRight", "(", "$", "node", ")", ";", "}", "if", "(", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", "===", "0", ")", "{", "$", "link", "=", "$", "this", "->", "nodeMin", "(", "$", "node", "->", "right", "(", ")", ")", ";", "$", "node", "->", "setKey", "(", "$", "link", "->", "key", "(", ")", ")", ";", "$", "node", "->", "setValue", "(", "$", "link", "->", "value", "(", ")", ")", ";", "$", "node", "->", "setRight", "(", "$", "this", "->", "nodeRemoveMin", "(", "$", "node", "->", "right", "(", ")", ")", ")", ";", "}", "else", "{", "$", "node", "->", "setRight", "(", "$", "this", "->", "nodeRemove", "(", "$", "key", ",", "$", "node", "->", "right", "(", ")", ")", ")", ";", "}", "return", "$", "node", ";", "}" ]
Deletes a node to the right by key and subtree @internal Helper for nodeRemove() @param mixed $key The key @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Deletes", "a", "node", "to", "the", "right", "by", "key", "and", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L429-L444
6,065
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.fillKeys
protected function fillKeys(Queue $queue, $lo, $hi, ?RedBlackNode $node): void { if ($node === null) { return; } $complo = $this->comparator->compare($lo, $node->key()); $comphi = $this->comparator->compare($hi, $node->key()); if ($complo < 0) { $this->fillKeys($queue, $lo, $hi, $node->left()); } if ($complo <= 0 && $comphi >= 0) { $queue->enqueue($node->key()); } if ($comphi > 0) { $this->fillKeys($queue, $lo, $hi, $node->right()); } }
php
protected function fillKeys(Queue $queue, $lo, $hi, ?RedBlackNode $node): void { if ($node === null) { return; } $complo = $this->comparator->compare($lo, $node->key()); $comphi = $this->comparator->compare($hi, $node->key()); if ($complo < 0) { $this->fillKeys($queue, $lo, $hi, $node->left()); } if ($complo <= 0 && $comphi >= 0) { $queue->enqueue($node->key()); } if ($comphi > 0) { $this->fillKeys($queue, $lo, $hi, $node->right()); } }
[ "protected", "function", "fillKeys", "(", "Queue", "$", "queue", ",", "$", "lo", ",", "$", "hi", ",", "?", "RedBlackNode", "$", "node", ")", ":", "void", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", ";", "}", "$", "complo", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "lo", ",", "$", "node", "->", "key", "(", ")", ")", ";", "$", "comphi", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "hi", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "complo", "<", "0", ")", "{", "$", "this", "->", "fillKeys", "(", "$", "queue", ",", "$", "lo", ",", "$", "hi", ",", "$", "node", "->", "left", "(", ")", ")", ";", "}", "if", "(", "$", "complo", "<=", "0", "&&", "$", "comphi", ">=", "0", ")", "{", "$", "queue", "->", "enqueue", "(", "$", "node", "->", "key", "(", ")", ")", ";", "}", "if", "(", "$", "comphi", ">", "0", ")", "{", "$", "this", "->", "fillKeys", "(", "$", "queue", ",", "$", "lo", ",", "$", "hi", ",", "$", "node", "->", "right", "(", ")", ")", ";", "}", "}" ]
Fills a queue with keys between lo and hi in a subtree @param Queue $queue The queue @param mixed $lo The lower bound @param mixed $hi The upper bound @param RedBlackNode|null $node The subtree root @return void
[ "Fills", "a", "queue", "with", "keys", "between", "lo", "and", "hi", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L456-L474
6,066
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeMin
protected function nodeMin(RedBlackNode $node): RedBlackNode { if ($node->left() === null) { return $node; } return $this->nodeMin($node->left()); }
php
protected function nodeMin(RedBlackNode $node): RedBlackNode { if ($node->left() === null) { return $node; } return $this->nodeMin($node->left()); }
[ "protected", "function", "nodeMin", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "$", "node", "->", "left", "(", ")", "===", "null", ")", "{", "return", "$", "node", ";", "}", "return", "$", "this", "->", "nodeMin", "(", "$", "node", "->", "left", "(", ")", ")", ";", "}" ]
Retrieves the node with the minimum key in a subtree @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Retrieves", "the", "node", "with", "the", "minimum", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L483-L490
6,067
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeMax
protected function nodeMax(RedBlackNode $node): RedBlackNode { if ($node->right() === null) { return $node; } return $this->nodeMax($node->right()); }
php
protected function nodeMax(RedBlackNode $node): RedBlackNode { if ($node->right() === null) { return $node; } return $this->nodeMax($node->right()); }
[ "protected", "function", "nodeMax", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "$", "node", "->", "right", "(", ")", "===", "null", ")", "{", "return", "$", "node", ";", "}", "return", "$", "this", "->", "nodeMax", "(", "$", "node", "->", "right", "(", ")", ")", ";", "}" ]
Retrieves the node with the maximum key in a subtree @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Retrieves", "the", "node", "with", "the", "maximum", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L499-L506
6,068
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRemoveMin
protected function nodeRemoveMin(RedBlackNode $node): ?RedBlackNode { if ($node->left() === null) { return null; } if (!$this->isRed($node->left()) && !$this->isRed($node->left()->left())) { $node = $this->moveRedLeft($node); } $node->setLeft($this->nodeRemoveMin($node->left())); return $this->balanceOnRemove($node); }
php
protected function nodeRemoveMin(RedBlackNode $node): ?RedBlackNode { if ($node->left() === null) { return null; } if (!$this->isRed($node->left()) && !$this->isRed($node->left()->left())) { $node = $this->moveRedLeft($node); } $node->setLeft($this->nodeRemoveMin($node->left())); return $this->balanceOnRemove($node); }
[ "protected", "function", "nodeRemoveMin", "(", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "if", "(", "$", "node", "->", "left", "(", ")", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", "&&", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "moveRedLeft", "(", "$", "node", ")", ";", "}", "$", "node", "->", "setLeft", "(", "$", "this", "->", "nodeRemoveMin", "(", "$", "node", "->", "left", "(", ")", ")", ")", ";", "return", "$", "this", "->", "balanceOnRemove", "(", "$", "node", ")", ";", "}" ]
Removes the node with the minimum key in a subtree @param RedBlackNode $node The subtree root @return RedBlackNode|null
[ "Removes", "the", "node", "with", "the", "minimum", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L515-L528
6,069
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRemoveMax
protected function nodeRemoveMax(RedBlackNode $node): ?RedBlackNode { if ($this->isRed($node->left())) { $node = $this->rotateRight($node); } if ($node->right() === null) { return null; } if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) { $node = $this->moveRedRight($node); } $node->setRight($this->nodeRemoveMax($node->right())); return $this->balanceOnRemove($node); }
php
protected function nodeRemoveMax(RedBlackNode $node): ?RedBlackNode { if ($this->isRed($node->left())) { $node = $this->rotateRight($node); } if ($node->right() === null) { return null; } if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) { $node = $this->moveRedRight($node); } $node->setRight($this->nodeRemoveMax($node->right())); return $this->balanceOnRemove($node); }
[ "protected", "function", "nodeRemoveMax", "(", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "rotateRight", "(", "$", "node", ")", ";", "}", "if", "(", "$", "node", "->", "right", "(", ")", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", ")", "&&", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "moveRedRight", "(", "$", "node", ")", ";", "}", "$", "node", "->", "setRight", "(", "$", "this", "->", "nodeRemoveMax", "(", "$", "node", "->", "right", "(", ")", ")", ")", ";", "return", "$", "this", "->", "balanceOnRemove", "(", "$", "node", ")", ";", "}" ]
Removes the node with the maximum key in a subtree @param RedBlackNode $node The subtree root @return RedBlackNode|null
[ "Removes", "the", "node", "with", "the", "maximum", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L537-L554
6,070
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeFloor
protected function nodeFloor($key, ?RedBlackNode $node): ?RedBlackNode { if ($node === null) { return null; } $comp = $this->comparator->compare($key, $node->key()); if ($comp === 0) { return $node; } if ($comp < 0) { return $this->nodeFloor($key, $node->left()); } $right = $this->nodeFloor($key, $node->right()); if ($right !== null) { return $right; } return $node; }
php
protected function nodeFloor($key, ?RedBlackNode $node): ?RedBlackNode { if ($node === null) { return null; } $comp = $this->comparator->compare($key, $node->key()); if ($comp === 0) { return $node; } if ($comp < 0) { return $this->nodeFloor($key, $node->left()); } $right = $this->nodeFloor($key, $node->right()); if ($right !== null) { return $right; } return $node; }
[ "protected", "function", "nodeFloor", "(", "$", "key", ",", "?", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "null", ";", "}", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "===", "0", ")", "{", "return", "$", "node", ";", "}", "if", "(", "$", "comp", "<", "0", ")", "{", "return", "$", "this", "->", "nodeFloor", "(", "$", "key", ",", "$", "node", "->", "left", "(", ")", ")", ";", "}", "$", "right", "=", "$", "this", "->", "nodeFloor", "(", "$", "key", ",", "$", "node", "->", "right", "(", ")", ")", ";", "if", "(", "$", "right", "!==", "null", ")", "{", "return", "$", "right", ";", "}", "return", "$", "node", ";", "}" ]
Retrieves the node with the largest key <= to a key in a subtree Returns null if there is not a key less or equal to the given key. @param mixed $key The key @param RedBlackNode|null $node The subtree root @return RedBlackNode|null
[ "Retrieves", "the", "node", "with", "the", "largest", "key", "<", "=", "to", "a", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L566-L586
6,071
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeCeiling
protected function nodeCeiling($key, ?RedBlackNode $node): ?RedBlackNode { if ($node === null) { return null; } $comp = $this->comparator->compare($key, $node->key()); if ($comp === 0) { return $node; } if ($comp > 0) { return $this->nodeCeiling($key, $node->right()); } $left = $this->nodeCeiling($key, $node->left()); if ($left !== null) { return $left; } return $node; }
php
protected function nodeCeiling($key, ?RedBlackNode $node): ?RedBlackNode { if ($node === null) { return null; } $comp = $this->comparator->compare($key, $node->key()); if ($comp === 0) { return $node; } if ($comp > 0) { return $this->nodeCeiling($key, $node->right()); } $left = $this->nodeCeiling($key, $node->left()); if ($left !== null) { return $left; } return $node; }
[ "protected", "function", "nodeCeiling", "(", "$", "key", ",", "?", "RedBlackNode", "$", "node", ")", ":", "?", "RedBlackNode", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "null", ";", "}", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "===", "0", ")", "{", "return", "$", "node", ";", "}", "if", "(", "$", "comp", ">", "0", ")", "{", "return", "$", "this", "->", "nodeCeiling", "(", "$", "key", ",", "$", "node", "->", "right", "(", ")", ")", ";", "}", "$", "left", "=", "$", "this", "->", "nodeCeiling", "(", "$", "key", ",", "$", "node", "->", "left", "(", ")", ")", ";", "if", "(", "$", "left", "!==", "null", ")", "{", "return", "$", "left", ";", "}", "return", "$", "node", ";", "}" ]
Retrieves the node with the smallest key >= to a key in a subtree Returns null if there is not a key less or equal to the given key. @param mixed $key The key @param RedBlackNode|null $node The subtree root @return RedBlackNode|null
[ "Retrieves", "the", "node", "with", "the", "smallest", "key", ">", "=", "to", "a", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L598-L618
6,072
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeRank
protected function nodeRank($key, ?RedBlackNode $node): int { if ($node === null) { return 0; } $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { return $this->nodeRank($key, $node->left()); } if ($comp > 0) { return 1 + $this->nodeSize($node->left()) + $this->nodeRank($key, $node->right()); } return $this->nodeSize($node->left()); }
php
protected function nodeRank($key, ?RedBlackNode $node): int { if ($node === null) { return 0; } $comp = $this->comparator->compare($key, $node->key()); if ($comp < 0) { return $this->nodeRank($key, $node->left()); } if ($comp > 0) { return 1 + $this->nodeSize($node->left()) + $this->nodeRank($key, $node->right()); } return $this->nodeSize($node->left()); }
[ "protected", "function", "nodeRank", "(", "$", "key", ",", "?", "RedBlackNode", "$", "node", ")", ":", "int", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "0", ";", "}", "$", "comp", "=", "$", "this", "->", "comparator", "->", "compare", "(", "$", "key", ",", "$", "node", "->", "key", "(", ")", ")", ";", "if", "(", "$", "comp", "<", "0", ")", "{", "return", "$", "this", "->", "nodeRank", "(", "$", "key", ",", "$", "node", "->", "left", "(", ")", ")", ";", "}", "if", "(", "$", "comp", ">", "0", ")", "{", "return", "1", "+", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "left", "(", ")", ")", "+", "$", "this", "->", "nodeRank", "(", "$", "key", ",", "$", "node", "->", "right", "(", ")", ")", ";", "}", "return", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "left", "(", ")", ")", ";", "}" ]
Retrieves the rank for a key in a subtree @param mixed $key The key @param RedBlackNode|null $node The subtree root @return int
[ "Retrieves", "the", "rank", "for", "a", "key", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L628-L644
6,073
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.nodeSelect
protected function nodeSelect(int $rank, RedBlackNode $node): RedBlackNode { $size = $this->nodeSize($node->left()); if ($size > $rank) { return $this->nodeSelect($rank, $node->left()); } if ($size < $rank) { return $this->nodeSelect($rank - $size - 1, $node->right()); } return $node; }
php
protected function nodeSelect(int $rank, RedBlackNode $node): RedBlackNode { $size = $this->nodeSize($node->left()); if ($size > $rank) { return $this->nodeSelect($rank, $node->left()); } if ($size < $rank) { return $this->nodeSelect($rank - $size - 1, $node->right()); } return $node; }
[ "protected", "function", "nodeSelect", "(", "int", "$", "rank", ",", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "$", "size", "=", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "left", "(", ")", ")", ";", "if", "(", "$", "size", ">", "$", "rank", ")", "{", "return", "$", "this", "->", "nodeSelect", "(", "$", "rank", ",", "$", "node", "->", "left", "(", ")", ")", ";", "}", "if", "(", "$", "size", "<", "$", "rank", ")", "{", "return", "$", "this", "->", "nodeSelect", "(", "$", "rank", "-", "$", "size", "-", "1", ",", "$", "node", "->", "right", "(", ")", ")", ";", "}", "return", "$", "node", ";", "}" ]
Retrieves the node with the key of a given rank in a subtree @param int $rank The rank @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Retrieves", "the", "node", "with", "the", "key", "of", "a", "given", "rank", "in", "a", "subtree" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L654-L666
6,074
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.rotateLeft
protected function rotateLeft(RedBlackNode $node): RedBlackNode { $link = $node->right(); $node->setRight($link->left()); $link->setLeft($node); $link->setColor($node->color()); $node->setColor(RedBlackNode::RED); $link->setSize($node->size()); $node->setSize(1 + $this->nodeSize($node->left()) + $this->nodeSize($node->right())); return $link; }
php
protected function rotateLeft(RedBlackNode $node): RedBlackNode { $link = $node->right(); $node->setRight($link->left()); $link->setLeft($node); $link->setColor($node->color()); $node->setColor(RedBlackNode::RED); $link->setSize($node->size()); $node->setSize(1 + $this->nodeSize($node->left()) + $this->nodeSize($node->right())); return $link; }
[ "protected", "function", "rotateLeft", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "$", "link", "=", "$", "node", "->", "right", "(", ")", ";", "$", "node", "->", "setRight", "(", "$", "link", "->", "left", "(", ")", ")", ";", "$", "link", "->", "setLeft", "(", "$", "node", ")", ";", "$", "link", "->", "setColor", "(", "$", "node", "->", "color", "(", ")", ")", ";", "$", "node", "->", "setColor", "(", "RedBlackNode", "::", "RED", ")", ";", "$", "link", "->", "setSize", "(", "$", "node", "->", "size", "(", ")", ")", ";", "$", "node", "->", "setSize", "(", "1", "+", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "left", "(", ")", ")", "+", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "right", "(", ")", ")", ")", ";", "return", "$", "link", ";", "}" ]
Rotates a right-learning link to the left Assumes $node->right is red. @param RedBlackNode $node The node @return RedBlackNode
[ "Rotates", "a", "right", "-", "learning", "link", "to", "the", "left" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L677-L688
6,075
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.flipColors
protected function flipColors(RedBlackNode $node): void { $node->setColor(!($node->color())); $node->left()->setColor(!($node->left()->color())); $node->right()->setColor(!($node->right()->color())); }
php
protected function flipColors(RedBlackNode $node): void { $node->setColor(!($node->color())); $node->left()->setColor(!($node->left()->color())); $node->right()->setColor(!($node->right()->color())); }
[ "protected", "function", "flipColors", "(", "RedBlackNode", "$", "node", ")", ":", "void", "{", "$", "node", "->", "setColor", "(", "!", "(", "$", "node", "->", "color", "(", ")", ")", ")", ";", "$", "node", "->", "left", "(", ")", "->", "setColor", "(", "!", "(", "$", "node", "->", "left", "(", ")", "->", "color", "(", ")", ")", ")", ";", "$", "node", "->", "right", "(", ")", "->", "setColor", "(", "!", "(", "$", "node", "->", "right", "(", ")", "->", "color", "(", ")", ")", ")", ";", "}" ]
Flips the colors of a node and its two children Used to maintain symmetric order and perfect black balance when a black node has two red children. @param RedBlackNode $node The node @return void
[ "Flips", "the", "colors", "of", "a", "node", "and", "its", "two", "children" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L722-L727
6,076
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.moveRedLeft
protected function moveRedLeft(RedBlackNode $node): RedBlackNode { $this->flipColors($node); if ($this->isRed($node->right()->left())) { $node->setRight($this->rotateRight($node->right())); $node = $this->rotateLeft($node); $this->flipColors($node); } return $node; }
php
protected function moveRedLeft(RedBlackNode $node): RedBlackNode { $this->flipColors($node); if ($this->isRed($node->right()->left())) { $node->setRight($this->rotateRight($node->right())); $node = $this->rotateLeft($node); $this->flipColors($node); } return $node; }
[ "protected", "function", "moveRedLeft", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "$", "this", "->", "flipColors", "(", "$", "node", ")", ";", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "->", "setRight", "(", "$", "this", "->", "rotateRight", "(", "$", "node", "->", "right", "(", ")", ")", ")", ";", "$", "node", "=", "$", "this", "->", "rotateLeft", "(", "$", "node", ")", ";", "$", "this", "->", "flipColors", "(", "$", "node", ")", ";", "}", "return", "$", "node", ";", "}" ]
Makes a left link or child red Assumes red $node and $node->left and $node->left->left are black. @codeCoverageIgnore @param RedBlackNode $node The node @return RedBlackNode
[ "Makes", "a", "left", "link", "or", "child", "red" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L740-L750
6,077
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.moveRedRight
protected function moveRedRight(RedBlackNode $node): RedBlackNode { $this->flipColors($node); if ($this->isRed($node->left()->left())) { $node = $this->rotateRight($node); $this->flipColors($node); } return $node; }
php
protected function moveRedRight(RedBlackNode $node): RedBlackNode { $this->flipColors($node); if ($this->isRed($node->left()->left())) { $node = $this->rotateRight($node); $this->flipColors($node); } return $node; }
[ "protected", "function", "moveRedRight", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "$", "this", "->", "flipColors", "(", "$", "node", ")", ";", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "rotateRight", "(", "$", "node", ")", ";", "$", "this", "->", "flipColors", "(", "$", "node", ")", ";", "}", "return", "$", "node", ";", "}" ]
Makes a right link or child red Assumes red $node and $node->right and $node->right->left are black. @codeCoverageIgnore @param RedBlackNode $node The node @return RedBlackNode
[ "Makes", "a", "right", "link", "or", "child", "red" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L763-L772
6,078
novuso/system
src/Collection/Tree/RedBlackSearchTree.php
RedBlackSearchTree.balanceOnInsert
protected function balanceOnInsert(RedBlackNode $node): RedBlackNode { if ($this->isRed($node->right()) && !$this->isRed($node->left())) { $node = $this->rotateLeft($node); } if ($this->isRed($node->left()) && $this->isRed($node->left()->left())) { $node = $this->rotateRight($node); } if ($this->isRed($node->left()) && $this->isRed($node->right())) { $this->flipColors($node); } $node->setSize(1 + $this->nodeSize($node->left()) + $this->nodeSize($node->right())); return $node; }
php
protected function balanceOnInsert(RedBlackNode $node): RedBlackNode { if ($this->isRed($node->right()) && !$this->isRed($node->left())) { $node = $this->rotateLeft($node); } if ($this->isRed($node->left()) && $this->isRed($node->left()->left())) { $node = $this->rotateRight($node); } if ($this->isRed($node->left()) && $this->isRed($node->right())) { $this->flipColors($node); } $node->setSize(1 + $this->nodeSize($node->left()) + $this->nodeSize($node->right())); return $node; }
[ "protected", "function", "balanceOnInsert", "(", "RedBlackNode", "$", "node", ")", ":", "RedBlackNode", "{", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", ")", "&&", "!", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "rotateLeft", "(", "$", "node", ")", ";", "}", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", "&&", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", "->", "left", "(", ")", ")", ")", "{", "$", "node", "=", "$", "this", "->", "rotateRight", "(", "$", "node", ")", ";", "}", "if", "(", "$", "this", "->", "isRed", "(", "$", "node", "->", "left", "(", ")", ")", "&&", "$", "this", "->", "isRed", "(", "$", "node", "->", "right", "(", ")", ")", ")", "{", "$", "this", "->", "flipColors", "(", "$", "node", ")", ";", "}", "$", "node", "->", "setSize", "(", "1", "+", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "left", "(", ")", ")", "+", "$", "this", "->", "nodeSize", "(", "$", "node", "->", "right", "(", ")", ")", ")", ";", "return", "$", "node", ";", "}" ]
Restores red-black tree invariant on insert @codeCoverageIgnore @param RedBlackNode $node The subtree root @return RedBlackNode
[ "Restores", "red", "-", "black", "tree", "invariant", "on", "insert" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Tree/RedBlackSearchTree.php#L808-L822
6,079
stubbles/stubbles-values
src/main/php/Rootpath.php
Rootpath.to
public function to(string ...$pathParts): string { return $this->rootpath . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $pathParts); }
php
public function to(string ...$pathParts): string { return $this->rootpath . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $pathParts); }
[ "public", "function", "to", "(", "string", "...", "$", "pathParts", ")", ":", "string", "{", "return", "$", "this", "->", "rootpath", ".", "DIRECTORY_SEPARATOR", ".", "join", "(", "DIRECTORY_SEPARATOR", ",", "$", "pathParts", ")", ";", "}" ]
returns absolute path to given local path Supports arbitrary lists of arguments, e.g. <code>$rootpath->to('src', 'main', 'php', 'Example.php')</code> will return "path/to/root/src/main/php/Example.php". @param string... $pathParts @return string
[ "returns", "absolute", "path", "to", "given", "local", "path" ]
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Rootpath.php#L127-L130
6,080
stubbles/stubbles-values
src/main/php/Rootpath.php
Rootpath.detectRootPath
private function detectRootPath(): string { static $rootpath = null; if (null === $rootpath) { if (\Phar::running() !== '') { $rootpath = dirname(\Phar::running(false)); } elseif (file_exists(__DIR__ . '/../../../../../autoload.php')) { // stubbles/values is inside the vendor dir of the application // it is a dependency of $rootpath = realpath(__DIR__ . '/../../../../../../'); } else { // local checkout while development $rootpath = realpath(__DIR__ . '/../../../'); } } return $rootpath; }
php
private function detectRootPath(): string { static $rootpath = null; if (null === $rootpath) { if (\Phar::running() !== '') { $rootpath = dirname(\Phar::running(false)); } elseif (file_exists(__DIR__ . '/../../../../../autoload.php')) { // stubbles/values is inside the vendor dir of the application // it is a dependency of $rootpath = realpath(__DIR__ . '/../../../../../../'); } else { // local checkout while development $rootpath = realpath(__DIR__ . '/../../../'); } } return $rootpath; }
[ "private", "function", "detectRootPath", "(", ")", ":", "string", "{", "static", "$", "rootpath", "=", "null", ";", "if", "(", "null", "===", "$", "rootpath", ")", "{", "if", "(", "\\", "Phar", "::", "running", "(", ")", "!==", "''", ")", "{", "$", "rootpath", "=", "dirname", "(", "\\", "Phar", "::", "running", "(", "false", ")", ")", ";", "}", "elseif", "(", "file_exists", "(", "__DIR__", ".", "'/../../../../../autoload.php'", ")", ")", "{", "// stubbles/values is inside the vendor dir of the application", "// it is a dependency of", "$", "rootpath", "=", "realpath", "(", "__DIR__", ".", "'/../../../../../../'", ")", ";", "}", "else", "{", "// local checkout while development", "$", "rootpath", "=", "realpath", "(", "__DIR__", ".", "'/../../../'", ")", ";", "}", "}", "return", "$", "rootpath", ";", "}" ]
detects root path @return string
[ "detects", "root", "path" ]
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Rootpath.php#L203-L220
6,081
eghojansu/nutrition
src/Utils/PaginationSetup.php
PaginationSetup.getRouteParams
public function getRouteParams() { if (empty($this->routeParams)) { $this->routeParams = Base::instance()->get('PARAMS'); unset($this->routeParams[0]); } return $this->routeParams; }
php
public function getRouteParams() { if (empty($this->routeParams)) { $this->routeParams = Base::instance()->get('PARAMS'); unset($this->routeParams[0]); } return $this->routeParams; }
[ "public", "function", "getRouteParams", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "routeParams", ")", ")", "{", "$", "this", "->", "routeParams", "=", "Base", "::", "instance", "(", ")", "->", "get", "(", "'PARAMS'", ")", ";", "unset", "(", "$", "this", "->", "routeParams", "[", "0", "]", ")", ";", "}", "return", "$", "this", "->", "routeParams", ";", "}" ]
Get route params @return array
[ "Get", "route", "params" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/PaginationSetup.php#L97-L105
6,082
eghojansu/nutrition
src/Utils/PaginationSetup.php
PaginationSetup.getRequestPage
public function getRequestPage($default = 1) { if (empty($this->requestPage)) { $this->requestPage = abs($this->getRequestArg( $this->pageArgName, $default )); } return $this->requestPage; }
php
public function getRequestPage($default = 1) { if (empty($this->requestPage)) { $this->requestPage = abs($this->getRequestArg( $this->pageArgName, $default )); } return $this->requestPage; }
[ "public", "function", "getRequestPage", "(", "$", "default", "=", "1", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "requestPage", ")", ")", "{", "$", "this", "->", "requestPage", "=", "abs", "(", "$", "this", "->", "getRequestArg", "(", "$", "this", "->", "pageArgName", ",", "$", "default", ")", ")", ";", "}", "return", "$", "this", "->", "requestPage", ";", "}" ]
Get request page @param integer $default @return int
[ "Get", "request", "page" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/PaginationSetup.php#L123-L133
6,083
eghojansu/nutrition
src/Utils/PaginationSetup.php
PaginationSetup.path
public function path($disable, $page) { if ($disable) { return '#'; } return Route::instance()->build( $this->getRoute(), $this->getRouteParams(), [$this->pageArgName => $page] + ($_GET?:[]) ); }
php
public function path($disable, $page) { if ($disable) { return '#'; } return Route::instance()->build( $this->getRoute(), $this->getRouteParams(), [$this->pageArgName => $page] + ($_GET?:[]) ); }
[ "public", "function", "path", "(", "$", "disable", ",", "$", "page", ")", "{", "if", "(", "$", "disable", ")", "{", "return", "'#'", ";", "}", "return", "Route", "::", "instance", "(", ")", "->", "build", "(", "$", "this", "->", "getRoute", "(", ")", ",", "$", "this", "->", "getRouteParams", "(", ")", ",", "[", "$", "this", "->", "pageArgName", "=>", "$", "page", "]", "+", "(", "$", "_GET", "?", ":", "[", "]", ")", ")", ";", "}" ]
Build pagination route @param bool $disable @param int $page @return string
[ "Build", "pagination", "route" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/PaginationSetup.php#L183-L194
6,084
Gelembjuk/locale
src/Gelembjuk/Locale/GetTextTrait.php
GetTextTrait._
protected function _($key,$group='', $p1 = '', $p2 = '', $p3 = '', $p4 = '', $p5 = '') { return $this->getText($key,$group, $p1, $p2, $p3, $p4, $p5); }
php
protected function _($key,$group='', $p1 = '', $p2 = '', $p3 = '', $p4 = '', $p5 = '') { return $this->getText($key,$group, $p1, $p2, $p3, $p4, $p5); }
[ "protected", "function", "_", "(", "$", "key", ",", "$", "group", "=", "''", ",", "$", "p1", "=", "''", ",", "$", "p2", "=", "''", ",", "$", "p3", "=", "''", ",", "$", "p4", "=", "''", ",", "$", "p5", "=", "''", ")", "{", "return", "$", "this", "->", "getText", "(", "$", "key", ",", "$", "group", ",", "$", "p1", ",", "$", "p2", ",", "$", "p3", ",", "$", "p4", ",", "$", "p5", ")", ";", "}" ]
Shortcut for getText function @param string $key Key of text to translate @param string $group Group of keys @param string $p1 Variable 1 to insert in a text if a value fo a key is formatted string @param string $p2 Variable 2 @param string $p3 Variable 3 @param string $p4 Variable 4 @param string $p5 Variable 5 @return string
[ "Shortcut", "for", "getText", "function" ]
4d59f6518bf765c3653f3d2583e6e262ff8bfb29
https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/GetTextTrait.php#L46-L48
6,085
webbuilders-group/silverstripe-cmspreviewpreference
src/Extensions/UserPreviewPreference.php
UserPreviewPreference.updateCMSFields
public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main', $field=new OptionsetField('DefaultPreviewMode', _t('UserPreviewPreference.DEFAULT_MODE', '_Default Preview Mode'), array( 'content'=>_t('UserPreviewPreference.CONTENT_MODE', '_Content Mode: Only menu and content areas are shown'), 'split'=>_t('UserPreviewPreference.SPLIT_MODE', '_Split Mode: Side by Side editing and previewing'), 'preview'=>_t('UserPreviewPreference.PREVIEW_MODE', '_Preview Mode: Only menu and preview areas are shown') ), Config::inst()->get('UserPreviewPreference', 'DefaultMode'))); if(Controller::curr()->getRequest()->getSession()->get('ShowPreviewSettingChangeReload')==true) { $field->setMessage(_t('UserPreviewPreference.CHANGE_REFRESH', '_You have updated your preview preference, you must refresh your browser to see the updated setting'), 'warning'); Requirements::javascript('webbuilders-group/silverstripe-cmspreviewpreference: javascript/clear-local-preference.js'); if($this->isSaving==false) { Controller::curr()->getRequest()->getSession()->clear('ShowPreviewSettingChangeReload'); } } }
php
public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main', $field=new OptionsetField('DefaultPreviewMode', _t('UserPreviewPreference.DEFAULT_MODE', '_Default Preview Mode'), array( 'content'=>_t('UserPreviewPreference.CONTENT_MODE', '_Content Mode: Only menu and content areas are shown'), 'split'=>_t('UserPreviewPreference.SPLIT_MODE', '_Split Mode: Side by Side editing and previewing'), 'preview'=>_t('UserPreviewPreference.PREVIEW_MODE', '_Preview Mode: Only menu and preview areas are shown') ), Config::inst()->get('UserPreviewPreference', 'DefaultMode'))); if(Controller::curr()->getRequest()->getSession()->get('ShowPreviewSettingChangeReload')==true) { $field->setMessage(_t('UserPreviewPreference.CHANGE_REFRESH', '_You have updated your preview preference, you must refresh your browser to see the updated setting'), 'warning'); Requirements::javascript('webbuilders-group/silverstripe-cmspreviewpreference: javascript/clear-local-preference.js'); if($this->isSaving==false) { Controller::curr()->getRequest()->getSession()->clear('ShowPreviewSettingChangeReload'); } } }
[ "public", "function", "updateCMSFields", "(", "FieldList", "$", "fields", ")", "{", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "$", "field", "=", "new", "OptionsetField", "(", "'DefaultPreviewMode'", ",", "_t", "(", "'UserPreviewPreference.DEFAULT_MODE'", ",", "'_Default Preview Mode'", ")", ",", "array", "(", "'content'", "=>", "_t", "(", "'UserPreviewPreference.CONTENT_MODE'", ",", "'_Content Mode: Only menu and content areas are shown'", ")", ",", "'split'", "=>", "_t", "(", "'UserPreviewPreference.SPLIT_MODE'", ",", "'_Split Mode: Side by Side editing and previewing'", ")", ",", "'preview'", "=>", "_t", "(", "'UserPreviewPreference.PREVIEW_MODE'", ",", "'_Preview Mode: Only menu and preview areas are shown'", ")", ")", ",", "Config", "::", "inst", "(", ")", "->", "get", "(", "'UserPreviewPreference'", ",", "'DefaultMode'", ")", ")", ")", ";", "if", "(", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", "->", "get", "(", "'ShowPreviewSettingChangeReload'", ")", "==", "true", ")", "{", "$", "field", "->", "setMessage", "(", "_t", "(", "'UserPreviewPreference.CHANGE_REFRESH'", ",", "'_You have updated your preview preference, you must refresh your browser to see the updated setting'", ")", ",", "'warning'", ")", ";", "Requirements", "::", "javascript", "(", "'webbuilders-group/silverstripe-cmspreviewpreference: javascript/clear-local-preference.js'", ")", ";", "if", "(", "$", "this", "->", "isSaving", "==", "false", ")", "{", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", "->", "clear", "(", "'ShowPreviewSettingChangeReload'", ")", ";", "}", "}", "}" ]
Updates the fields used in the cms @param {FieldList} $fields Fields to be extended
[ "Updates", "the", "fields", "used", "in", "the", "cms" ]
2906b0f779c538018c50286e9001299361170c7a
https://github.com/webbuilders-group/silverstripe-cmspreviewpreference/blob/2906b0f779c538018c50286e9001299361170c7a/src/Extensions/UserPreviewPreference.php#L28-L44
6,086
webbuilders-group/silverstripe-cmspreviewpreference
src/Extensions/UserPreviewPreference.php
UserPreviewPreference.onBeforeWrite
public function onBeforeWrite() { parent::onBeforeWrite(); if(empty($this->owner->DefaultPreviewMode)) { $this->owner->DefaultPreviewMode=Config::inst()->get('UserPreviewPreference', 'DefaultMode'); } //If changed ensure their is a session message if($this->owner->isChanged('DefaultPreviewMode')) { Controller::curr()->getRequest()->getSession()->set('ShowPreviewSettingChangeReload', true); $this->isSaving=true; } }
php
public function onBeforeWrite() { parent::onBeforeWrite(); if(empty($this->owner->DefaultPreviewMode)) { $this->owner->DefaultPreviewMode=Config::inst()->get('UserPreviewPreference', 'DefaultMode'); } //If changed ensure their is a session message if($this->owner->isChanged('DefaultPreviewMode')) { Controller::curr()->getRequest()->getSession()->set('ShowPreviewSettingChangeReload', true); $this->isSaving=true; } }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "parent", "::", "onBeforeWrite", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "owner", "->", "DefaultPreviewMode", ")", ")", "{", "$", "this", "->", "owner", "->", "DefaultPreviewMode", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "'UserPreviewPreference'", ",", "'DefaultMode'", ")", ";", "}", "//If changed ensure their is a session message", "if", "(", "$", "this", "->", "owner", "->", "isChanged", "(", "'DefaultPreviewMode'", ")", ")", "{", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", "->", "set", "(", "'ShowPreviewSettingChangeReload'", ",", "true", ")", ";", "$", "this", "->", "isSaving", "=", "true", ";", "}", "}" ]
Ensures config defaults are enforced on write
[ "Ensures", "config", "defaults", "are", "enforced", "on", "write" ]
2906b0f779c538018c50286e9001299361170c7a
https://github.com/webbuilders-group/silverstripe-cmspreviewpreference/blob/2906b0f779c538018c50286e9001299361170c7a/src/Extensions/UserPreviewPreference.php#L49-L62
6,087
jaredtking/jaqb
src/Query/Traits/Where.php
Where.where
public function where($field, $condition = false, $operator = '=') { if (func_num_args() >= 2) { $this->where->addCondition($field, $condition, $operator); } else { $this->where->addCondition($field); } return $this; }
php
public function where($field, $condition = false, $operator = '=') { if (func_num_args() >= 2) { $this->where->addCondition($field, $condition, $operator); } else { $this->where->addCondition($field); } return $this; }
[ "public", "function", "where", "(", "$", "field", ",", "$", "condition", "=", "false", ",", "$", "operator", "=", "'='", ")", "{", "if", "(", "func_num_args", "(", ")", ">=", "2", ")", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ",", "$", "condition", ",", "$", "operator", ")", ";", "}", "else", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the where conditions for the query. @param array|string $field @param string|bool $condition condition value (optional) @param string $operator operator (optional) @return self
[ "Sets", "the", "where", "conditions", "for", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L21-L30
6,088
jaredtking/jaqb
src/Query/Traits/Where.php
Where.orWhere
public function orWhere($field, $condition = false, $operator = '=') { if (func_num_args() >= 2) { $this->where->addOrCondition($field, $condition, $operator); } else { $this->where->addOrCondition($field); } return $this; }
php
public function orWhere($field, $condition = false, $operator = '=') { if (func_num_args() >= 2) { $this->where->addOrCondition($field, $condition, $operator); } else { $this->where->addOrCondition($field); } return $this; }
[ "public", "function", "orWhere", "(", "$", "field", ",", "$", "condition", "=", "false", ",", "$", "operator", "=", "'='", ")", "{", "if", "(", "func_num_args", "(", ")", ">=", "2", ")", "{", "$", "this", "->", "where", "->", "addOrCondition", "(", "$", "field", ",", "$", "condition", ",", "$", "operator", ")", ";", "}", "else", "{", "$", "this", "->", "where", "->", "addOrCondition", "(", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a where or condition to the query. @param array|string $field @param string $condition condition value (optional) @param string $operator operator (optional) @return self
[ "Adds", "a", "where", "or", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L41-L50
6,089
jaredtking/jaqb
src/Query/Traits/Where.php
Where.whereInfix
public function whereInfix($field, $operator = '=', $condition = false) { $numArgs = func_num_args(); if ($numArgs > 2) { $this->where->addCondition($field, $condition, $operator); } elseif ($numArgs == 2) { $this->where->addCondition($field, $operator, '='); } else { $this->where->addCondition($field); } return $this; }
php
public function whereInfix($field, $operator = '=', $condition = false) { $numArgs = func_num_args(); if ($numArgs > 2) { $this->where->addCondition($field, $condition, $operator); } elseif ($numArgs == 2) { $this->where->addCondition($field, $operator, '='); } else { $this->where->addCondition($field); } return $this; }
[ "public", "function", "whereInfix", "(", "$", "field", ",", "$", "operator", "=", "'='", ",", "$", "condition", "=", "false", ")", "{", "$", "numArgs", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "numArgs", ">", "2", ")", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ",", "$", "condition", ",", "$", "operator", ")", ";", "}", "elseif", "(", "$", "numArgs", "==", "2", ")", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ",", "$", "operator", ",", "'='", ")", ";", "}", "else", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the where conditions for the query with infix style arguments. @param array|string $field @param string $operator operator (optional) @param string|bool $condition condition value (optional) @return self
[ "Sets", "the", "where", "conditions", "for", "the", "query", "with", "infix", "style", "arguments", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L61-L73
6,090
jaredtking/jaqb
src/Query/Traits/Where.php
Where.orWhereInfix
public function orWhereInfix($field, $operator = '=', $condition = false) { $numArgs = func_num_args(); if ($numArgs > 2) { $this->where->addOrCondition($field, $condition, $operator); } elseif ($numArgs == 2) { $this->where->addOrCondition($field, $operator, '='); } else { $this->where->addOrCondition($field); } return $this; }
php
public function orWhereInfix($field, $operator = '=', $condition = false) { $numArgs = func_num_args(); if ($numArgs > 2) { $this->where->addOrCondition($field, $condition, $operator); } elseif ($numArgs == 2) { $this->where->addOrCondition($field, $operator, '='); } else { $this->where->addOrCondition($field); } return $this; }
[ "public", "function", "orWhereInfix", "(", "$", "field", ",", "$", "operator", "=", "'='", ",", "$", "condition", "=", "false", ")", "{", "$", "numArgs", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "numArgs", ">", "2", ")", "{", "$", "this", "->", "where", "->", "addOrCondition", "(", "$", "field", ",", "$", "condition", ",", "$", "operator", ")", ";", "}", "elseif", "(", "$", "numArgs", "==", "2", ")", "{", "$", "this", "->", "where", "->", "addOrCondition", "(", "$", "field", ",", "$", "operator", ",", "'='", ")", ";", "}", "else", "{", "$", "this", "->", "where", "->", "addOrCondition", "(", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a where or condition to the query with infix style arguments. @param array|string $field @param string $operator operator (optional) @param string $condition condition value (optional) @return self
[ "Adds", "a", "where", "or", "condition", "to", "the", "query", "with", "infix", "style", "arguments", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L84-L96
6,091
jaredtking/jaqb
src/Query/Traits/Where.php
Where.not
public function not($field, $condition = true) { $this->where->addCondition($field, $condition, '<>'); return $this; }
php
public function not($field, $condition = true) { $this->where->addCondition($field, $condition, '<>'); return $this; }
[ "public", "function", "not", "(", "$", "field", ",", "$", "condition", "=", "true", ")", "{", "$", "this", "->", "where", "->", "addCondition", "(", "$", "field", ",", "$", "condition", ",", "'<>'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a where not condition to the query. @param string $field @param string $condition condition value (optional) @return self
[ "Adds", "a", "where", "not", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L106-L111
6,092
jaredtking/jaqb
src/Query/Traits/Where.php
Where.between
public function between($field, $a, $b) { $this->where->addBetweenCondition($field, $a, $b); return $this; }
php
public function between($field, $a, $b) { $this->where->addBetweenCondition($field, $a, $b); return $this; }
[ "public", "function", "between", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "where", "->", "addBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", ";", "return", "$", "this", ";", "}" ]
Adds a where between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "where", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L122-L127
6,093
jaredtking/jaqb
src/Query/Traits/Where.php
Where.notBetween
public function notBetween($field, $a, $b) { $this->where->addNotBetweenCondition($field, $a, $b); return $this; }
php
public function notBetween($field, $a, $b) { $this->where->addNotBetweenCondition($field, $a, $b); return $this; }
[ "public", "function", "notBetween", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "where", "->", "addNotBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", ";", "return", "$", "this", ";", "}" ]
Adds a where not between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "where", "not", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/Where.php#L138-L143
6,094
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminBrandController.php
AdminBrandController.newAction
public function newAction() { $entity = new Brand(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newAction() { $entity = new Brand(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "entity", "=", "new", "Brand", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new Brand entity. @Route("/new", name="admin_brand_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Brand", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminBrandController.php#L91-L100
6,095
PentagonalProject/SlimService
src/ModularParser.php
ModularParser.create
public function create(string $file) : ModularParser { $clone = clone $this; $clone->valid = null; $clone->file = false; $clone->class = null; return $clone->setFileToLoad($file); }
php
public function create(string $file) : ModularParser { $clone = clone $this; $clone->valid = null; $clone->file = false; $clone->class = null; return $clone->setFileToLoad($file); }
[ "public", "function", "create", "(", "string", "$", "file", ")", ":", "ModularParser", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "valid", "=", "null", ";", "$", "clone", "->", "file", "=", "false", ";", "$", "clone", "->", "class", "=", "null", ";", "return", "$", "clone", "->", "setFileToLoad", "(", "$", "file", ")", ";", "}" ]
Create Instance ModularParser @param string $file @return ModularParser
[ "Create", "Instance", "ModularParser" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/ModularParser.php#L176-L183
6,096
SagePHP/VCS
src/SagePHP/VCS/Git.php
Git.cloneRepository
public function cloneRepository($uri, $folder = null, $branch = null) { $command = new Command; $command ->binary('git') ->argument('clone') ->argument($uri); if (null !== $folder) { $command->argument($folder); } if (null !== $branch) { $command->option('branch', $branch); } return 0 === $this->execute($command); }
php
public function cloneRepository($uri, $folder = null, $branch = null) { $command = new Command; $command ->binary('git') ->argument('clone') ->argument($uri); if (null !== $folder) { $command->argument($folder); } if (null !== $branch) { $command->option('branch', $branch); } return 0 === $this->execute($command); }
[ "public", "function", "cloneRepository", "(", "$", "uri", ",", "$", "folder", "=", "null", ",", "$", "branch", "=", "null", ")", "{", "$", "command", "=", "new", "Command", ";", "$", "command", "->", "binary", "(", "'git'", ")", "->", "argument", "(", "'clone'", ")", "->", "argument", "(", "$", "uri", ")", ";", "if", "(", "null", "!==", "$", "folder", ")", "{", "$", "command", "->", "argument", "(", "$", "folder", ")", ";", "}", "if", "(", "null", "!==", "$", "branch", ")", "{", "$", "command", "->", "option", "(", "'branch'", ",", "$", "branch", ")", ";", "}", "return", "0", "===", "$", "this", "->", "execute", "(", "$", "command", ")", ";", "}" ]
Clones a git repository. @param string $uri the git url @param string $folder the folder to clone to, if not set defaults to repository name @param string $branch the branch to checkout, defaults to "main" branch (as set in repository config) @return boolean true on success
[ "Clones", "a", "git", "repository", "." ]
e087aa174290ed7a663a486fbb4b66656ddad3bb
https://github.com/SagePHP/VCS/blob/e087aa174290ed7a663a486fbb4b66656ddad3bb/src/SagePHP/VCS/Git.php#L64-L82
6,097
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Asset/TranslationsBuilder.php
TranslationsBuilder.build
public function build($locale, $domain = 'gui') { $cache = new ConfigCache($this->cacheDir.'/translations-'.$locale.'.js', $this->debug); if (!$cache->isFresh()) { $content = $this->buildContent($locale, $domain); $cache->write($content->getContent(), $content->getResources()); if (!$this->debug) { $this->compressor->compressFile((string) $cache); } } return new Asset((string) $cache); }
php
public function build($locale, $domain = 'gui') { $cache = new ConfigCache($this->cacheDir.'/translations-'.$locale.'.js', $this->debug); if (!$cache->isFresh()) { $content = $this->buildContent($locale, $domain); $cache->write($content->getContent(), $content->getResources()); if (!$this->debug) { $this->compressor->compressFile((string) $cache); } } return new Asset((string) $cache); }
[ "public", "function", "build", "(", "$", "locale", ",", "$", "domain", "=", "'gui'", ")", "{", "$", "cache", "=", "new", "ConfigCache", "(", "$", "this", "->", "cacheDir", ".", "'/translations-'", ".", "$", "locale", ".", "'.js'", ",", "$", "this", "->", "debug", ")", ";", "if", "(", "!", "$", "cache", "->", "isFresh", "(", ")", ")", "{", "$", "content", "=", "$", "this", "->", "buildContent", "(", "$", "locale", ",", "$", "domain", ")", ";", "$", "cache", "->", "write", "(", "$", "content", "->", "getContent", "(", ")", ",", "$", "content", "->", "getResources", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "debug", ")", "{", "$", "this", "->", "compressor", "->", "compressFile", "(", "(", "string", ")", "$", "cache", ")", ";", "}", "}", "return", "new", "Asset", "(", "(", "string", ")", "$", "cache", ")", ";", "}" ]
Get all Translations for the given section. @param string $locale @param string $domain @return Asset
[ "Get", "all", "Translations", "for", "the", "given", "section", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Asset/TranslationsBuilder.php#L99-L114
6,098
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/upload.php
Upload.move_callback
public static function move_callback($from, $to) { if (static::$with_ftp) { return static::$with_ftp->upload($from, $to, \Config::get('upload.ftp_mode'), \Config::get('upload.ftp_permissions')); } return false; }
php
public static function move_callback($from, $to) { if (static::$with_ftp) { return static::$with_ftp->upload($from, $to, \Config::get('upload.ftp_mode'), \Config::get('upload.ftp_permissions')); } return false; }
[ "public", "static", "function", "move_callback", "(", "$", "from", ",", "$", "to", ")", "{", "if", "(", "static", "::", "$", "with_ftp", ")", "{", "return", "static", "::", "$", "with_ftp", "->", "upload", "(", "$", "from", ",", "$", "to", ",", "\\", "Config", "::", "get", "(", "'upload.ftp_mode'", ")", ",", "\\", "Config", "::", "get", "(", "'upload.ftp_permissions'", ")", ")", ";", "}", "return", "false", ";", "}" ]
Move callback function, custom method to move an uploaded file. In Fuel 1.x this method is used for FTP uploads only @param string $file The FQFN of the file to move @param string $file The FQFN of the file destination @return bool Result of the move operation
[ "Move", "callback", "function", "custom", "method", "to", "move", "an", "uploaded", "file", ".", "In", "Fuel", "1", ".", "x", "this", "method", "is", "used", "for", "FTP", "uploads", "only" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/upload.php#L150-L158
6,099
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/upload.php
Upload.get_files
public static function get_files($index = null) { // convert element name formats is_string($index) and $index = str_replace(':', '.', $index); $files = static::$upload->getValidFiles($index); // convert the file object to 1.x compatible data $result = array(); foreach ($files as $file) { $data = array(); foreach ($file as $item => $value) { $item == 'element' and $item = 'field'; $item == 'tmp_name' and $item = 'file'; $item == 'filename' and $item = 'saved_as'; $item == 'path' and $item = 'saved_to'; $data[$item] = $value; } $data['field'] = str_replace('.', ':', $data['field']); $data['error'] = ! $file->isValid(); $data['errors'] = array(); $result[] = $data; } // compatibility with < 1.5, return the single entry if only one was found if (func_num_args() and count($result) == 1) { return reset($result); } else { return $result; } }
php
public static function get_files($index = null) { // convert element name formats is_string($index) and $index = str_replace(':', '.', $index); $files = static::$upload->getValidFiles($index); // convert the file object to 1.x compatible data $result = array(); foreach ($files as $file) { $data = array(); foreach ($file as $item => $value) { $item == 'element' and $item = 'field'; $item == 'tmp_name' and $item = 'file'; $item == 'filename' and $item = 'saved_as'; $item == 'path' and $item = 'saved_to'; $data[$item] = $value; } $data['field'] = str_replace('.', ':', $data['field']); $data['error'] = ! $file->isValid(); $data['errors'] = array(); $result[] = $data; } // compatibility with < 1.5, return the single entry if only one was found if (func_num_args() and count($result) == 1) { return reset($result); } else { return $result; } }
[ "public", "static", "function", "get_files", "(", "$", "index", "=", "null", ")", "{", "// convert element name formats", "is_string", "(", "$", "index", ")", "and", "$", "index", "=", "str_replace", "(", "':'", ",", "'.'", ",", "$", "index", ")", ";", "$", "files", "=", "static", "::", "$", "upload", "->", "getValidFiles", "(", "$", "index", ")", ";", "// convert the file object to 1.x compatible data", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "file", "as", "$", "item", "=>", "$", "value", ")", "{", "$", "item", "==", "'element'", "and", "$", "item", "=", "'field'", ";", "$", "item", "==", "'tmp_name'", "and", "$", "item", "=", "'file'", ";", "$", "item", "==", "'filename'", "and", "$", "item", "=", "'saved_as'", ";", "$", "item", "==", "'path'", "and", "$", "item", "=", "'saved_to'", ";", "$", "data", "[", "$", "item", "]", "=", "$", "value", ";", "}", "$", "data", "[", "'field'", "]", "=", "str_replace", "(", "'.'", ",", "':'", ",", "$", "data", "[", "'field'", "]", ")", ";", "$", "data", "[", "'error'", "]", "=", "!", "$", "file", "->", "isValid", "(", ")", ";", "$", "data", "[", "'errors'", "]", "=", "array", "(", ")", ";", "$", "result", "[", "]", "=", "$", "data", ";", "}", "// compatibility with < 1.5, return the single entry if only one was found", "if", "(", "func_num_args", "(", ")", "and", "count", "(", "$", "result", ")", "==", "1", ")", "{", "return", "reset", "(", "$", "result", ")", ";", "}", "else", "{", "return", "$", "result", ";", "}", "}" ]
Get the list of validated files @return array list of uploaded files that are validated
[ "Get", "the", "list", "of", "validated", "files" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/upload.php#L179-L215