id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
227,000
whatwedo/TableBundle
Table/Table.php
Table.loadData
public function loadData() { if (!is_callable($this->options['data_loader']) && !is_array($this->options['data_loader'])) { throw new DataLoaderNotAvailableException(); } if ($this->loaded) { return; } $currentPage = 1; $limit = -1; if ($this->hasExtension(PaginationExtension::class)) { /** @var PaginationExtension $paginationExtension */ $paginationExtension = $this->getExtension(PaginationExtension::class); $paginationExtension->setLimit($this->options['default_limit']); $currentPage = $paginationExtension->getCurrentPage(); $limit = $paginationExtension->getLimit(); } $this->eventDispatcher->dispatch(DataLoadEvent::PRE_LOAD, new DataLoadEvent($this)); // loads the data from the data loader callable $tableData = null; if (is_callable($this->options['data_loader'])) { $tableData = ($this->options['data_loader'])($currentPage, $limit); } if (is_array($this->options['data_loader'])) { $tableData = call_user_func($this->options['data_loader'], $currentPage, $limit); } if (!$tableData instanceof TableDataInterface) { throw new \UnexpectedValueException('Table::dataLoader must return a TableDataInterface'); } $this->results = $tableData->getResults(); if ($this->hasExtension(PaginationExtension::class)) { /** @var PaginationExtension $paginationExtension */ $paginationExtension->setTotalResults($tableData->getTotalResults()); } $this->loaded = true; $this->eventDispatcher->dispatch(DataLoadEvent::POST_LOAD, new DataLoadEvent($this)); }
php
public function loadData() { if (!is_callable($this->options['data_loader']) && !is_array($this->options['data_loader'])) { throw new DataLoaderNotAvailableException(); } if ($this->loaded) { return; } $currentPage = 1; $limit = -1; if ($this->hasExtension(PaginationExtension::class)) { /** @var PaginationExtension $paginationExtension */ $paginationExtension = $this->getExtension(PaginationExtension::class); $paginationExtension->setLimit($this->options['default_limit']); $currentPage = $paginationExtension->getCurrentPage(); $limit = $paginationExtension->getLimit(); } $this->eventDispatcher->dispatch(DataLoadEvent::PRE_LOAD, new DataLoadEvent($this)); // loads the data from the data loader callable $tableData = null; if (is_callable($this->options['data_loader'])) { $tableData = ($this->options['data_loader'])($currentPage, $limit); } if (is_array($this->options['data_loader'])) { $tableData = call_user_func($this->options['data_loader'], $currentPage, $limit); } if (!$tableData instanceof TableDataInterface) { throw new \UnexpectedValueException('Table::dataLoader must return a TableDataInterface'); } $this->results = $tableData->getResults(); if ($this->hasExtension(PaginationExtension::class)) { /** @var PaginationExtension $paginationExtension */ $paginationExtension->setTotalResults($tableData->getTotalResults()); } $this->loaded = true; $this->eventDispatcher->dispatch(DataLoadEvent::POST_LOAD, new DataLoadEvent($this)); }
[ "public", "function", "loadData", "(", ")", "{", "if", "(", "!", "is_callable", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ")", "&&", "!", "is_array", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ")", ")", "{", "throw", "new", "DataLoaderNotAvailableException", "(", ")", ";", "}", "if", "(", "$", "this", "->", "loaded", ")", "{", "return", ";", "}", "$", "currentPage", "=", "1", ";", "$", "limit", "=", "-", "1", ";", "if", "(", "$", "this", "->", "hasExtension", "(", "PaginationExtension", "::", "class", ")", ")", "{", "/** @var PaginationExtension $paginationExtension */", "$", "paginationExtension", "=", "$", "this", "->", "getExtension", "(", "PaginationExtension", "::", "class", ")", ";", "$", "paginationExtension", "->", "setLimit", "(", "$", "this", "->", "options", "[", "'default_limit'", "]", ")", ";", "$", "currentPage", "=", "$", "paginationExtension", "->", "getCurrentPage", "(", ")", ";", "$", "limit", "=", "$", "paginationExtension", "->", "getLimit", "(", ")", ";", "}", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "DataLoadEvent", "::", "PRE_LOAD", ",", "new", "DataLoadEvent", "(", "$", "this", ")", ")", ";", "// loads the data from the data loader callable", "$", "tableData", "=", "null", ";", "if", "(", "is_callable", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ")", ")", "{", "$", "tableData", "=", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ")", "(", "$", "currentPage", ",", "$", "limit", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ")", ")", "{", "$", "tableData", "=", "call_user_func", "(", "$", "this", "->", "options", "[", "'data_loader'", "]", ",", "$", "currentPage", ",", "$", "limit", ")", ";", "}", "if", "(", "!", "$", "tableData", "instanceof", "TableDataInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Table::dataLoader must return a TableDataInterface'", ")", ";", "}", "$", "this", "->", "results", "=", "$", "tableData", "->", "getResults", "(", ")", ";", "if", "(", "$", "this", "->", "hasExtension", "(", "PaginationExtension", "::", "class", ")", ")", "{", "/** @var PaginationExtension $paginationExtension */", "$", "paginationExtension", "->", "setTotalResults", "(", "$", "tableData", "->", "getTotalResults", "(", ")", ")", ";", "}", "$", "this", "->", "loaded", "=", "true", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "DataLoadEvent", "::", "POST_LOAD", ",", "new", "DataLoadEvent", "(", "$", "this", ")", ")", ";", "}" ]
loads the data @throws DataLoaderNotAvailableException
[ "loads", "the", "data" ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Table/Table.php#L413-L459
227,001
neoxygen/neo4j-neogen
src/Schema/GraphSchemaBuilder.php
GraphSchemaBuilder.buildGraph
public function buildGraph(array $userSchema) { $graphSchema = new GraphSchema(); foreach ($userSchema['nodes'] as $id => $nodeInfo) { $node = $this->buildNode($id, $nodeInfo); $graphSchema->addNode($node); } if (!isset($userSchema['relationships'])) { $userSchema['relationships'] = []; } foreach ($userSchema['relationships'] as $rel) { $relationship = $this->buildRelationship($rel); $graphSchema->addRelationship($relationship); } return $graphSchema; }
php
public function buildGraph(array $userSchema) { $graphSchema = new GraphSchema(); foreach ($userSchema['nodes'] as $id => $nodeInfo) { $node = $this->buildNode($id, $nodeInfo); $graphSchema->addNode($node); } if (!isset($userSchema['relationships'])) { $userSchema['relationships'] = []; } foreach ($userSchema['relationships'] as $rel) { $relationship = $this->buildRelationship($rel); $graphSchema->addRelationship($relationship); } return $graphSchema; }
[ "public", "function", "buildGraph", "(", "array", "$", "userSchema", ")", "{", "$", "graphSchema", "=", "new", "GraphSchema", "(", ")", ";", "foreach", "(", "$", "userSchema", "[", "'nodes'", "]", "as", "$", "id", "=>", "$", "nodeInfo", ")", "{", "$", "node", "=", "$", "this", "->", "buildNode", "(", "$", "id", ",", "$", "nodeInfo", ")", ";", "$", "graphSchema", "->", "addNode", "(", "$", "node", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "userSchema", "[", "'relationships'", "]", ")", ")", "{", "$", "userSchema", "[", "'relationships'", "]", "=", "[", "]", ";", "}", "foreach", "(", "$", "userSchema", "[", "'relationships'", "]", "as", "$", "rel", ")", "{", "$", "relationship", "=", "$", "this", "->", "buildRelationship", "(", "$", "rel", ")", ";", "$", "graphSchema", "->", "addRelationship", "(", "$", "relationship", ")", ";", "}", "return", "$", "graphSchema", ";", "}" ]
Build a graph definition based on the user parsed schema @param array $userSchema @return \Neoxygen\Neogen\Schema\GraphSchema
[ "Build", "a", "graph", "definition", "based", "on", "the", "user", "parsed", "schema" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/GraphSchemaBuilder.php#L21-L37
227,002
neoxygen/neo4j-neogen
src/Schema/GraphSchemaBuilder.php
GraphSchemaBuilder.buildRelationship
public function buildRelationship(array $relInfo) { $relationship = new Relationship($relInfo['start'], $relInfo['end'], $relInfo['type']); $relationship->setCardinality($relInfo['mode']); if (isset($relInfo['properties'])) { foreach ($relInfo['properties'] as $name => $info) { $property = $this->buildRelationshipProperty($name, $info); $relationship->addProperty($property); } } return $relationship; }
php
public function buildRelationship(array $relInfo) { $relationship = new Relationship($relInfo['start'], $relInfo['end'], $relInfo['type']); $relationship->setCardinality($relInfo['mode']); if (isset($relInfo['properties'])) { foreach ($relInfo['properties'] as $name => $info) { $property = $this->buildRelationshipProperty($name, $info); $relationship->addProperty($property); } } return $relationship; }
[ "public", "function", "buildRelationship", "(", "array", "$", "relInfo", ")", "{", "$", "relationship", "=", "new", "Relationship", "(", "$", "relInfo", "[", "'start'", "]", ",", "$", "relInfo", "[", "'end'", "]", ",", "$", "relInfo", "[", "'type'", "]", ")", ";", "$", "relationship", "->", "setCardinality", "(", "$", "relInfo", "[", "'mode'", "]", ")", ";", "if", "(", "isset", "(", "$", "relInfo", "[", "'properties'", "]", ")", ")", "{", "foreach", "(", "$", "relInfo", "[", "'properties'", "]", "as", "$", "name", "=>", "$", "info", ")", "{", "$", "property", "=", "$", "this", "->", "buildRelationshipProperty", "(", "$", "name", ",", "$", "info", ")", ";", "$", "relationship", "->", "addProperty", "(", "$", "property", ")", ";", "}", "}", "return", "$", "relationship", ";", "}" ]
Builds the relationship object based on user schema @param array $relInfo relationship info from user schema @return Relationship
[ "Builds", "the", "relationship", "object", "based", "on", "user", "schema" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/GraphSchemaBuilder.php#L87-L99
227,003
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.users
public function users() { return $this ->belongsToMany( config('laravel-auth.users.model', User::class), $this->getPrefix().config('laravel-auth.role-user.table', 'permission_role') ) ->using(Pivots\RoleUser::class) ->withTimestamps(); }
php
public function users() { return $this ->belongsToMany( config('laravel-auth.users.model', User::class), $this->getPrefix().config('laravel-auth.role-user.table', 'permission_role') ) ->using(Pivots\RoleUser::class) ->withTimestamps(); }
[ "public", "function", "users", "(", ")", "{", "return", "$", "this", "->", "belongsToMany", "(", "config", "(", "'laravel-auth.users.model'", ",", "User", "::", "class", ")", ",", "$", "this", "->", "getPrefix", "(", ")", ".", "config", "(", "'laravel-auth.role-user.table'", ",", "'permission_role'", ")", ")", "->", "using", "(", "Pivots", "\\", "RoleUser", "::", "class", ")", "->", "withTimestamps", "(", ")", ";", "}" ]
Role belongs to many users. @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
[ "Role", "belongs", "to", "many", "users", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L109-L118
227,004
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.permissions
public function permissions() { return $this ->belongsToMany( config('laravel-auth.permissions.model', Permission::class), $this->getPrefix().config('laravel-auth.permission-role.table', 'permission_role') ) ->using(Pivots\PermissionRole::class) ->withTimestamps(); }
php
public function permissions() { return $this ->belongsToMany( config('laravel-auth.permissions.model', Permission::class), $this->getPrefix().config('laravel-auth.permission-role.table', 'permission_role') ) ->using(Pivots\PermissionRole::class) ->withTimestamps(); }
[ "public", "function", "permissions", "(", ")", "{", "return", "$", "this", "->", "belongsToMany", "(", "config", "(", "'laravel-auth.permissions.model'", ",", "Permission", "::", "class", ")", ",", "$", "this", "->", "getPrefix", "(", ")", ".", "config", "(", "'laravel-auth.permission-role.table'", ",", "'permission_role'", ")", ")", "->", "using", "(", "Pivots", "\\", "PermissionRole", "::", "class", ")", "->", "withTimestamps", "(", ")", ";", "}" ]
Role belongs to many permissions. @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
[ "Role", "belongs", "to", "many", "permissions", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L125-L134
227,005
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.detachUser
public function detachUser($user, $reload = true) { event(new DetachingUserFromRole($this, $user)); $results = $this->users()->detach($user); event(new DetachedUserFromRole($this, $user, $results)); $this->loadUsers($reload); return $results; }
php
public function detachUser($user, $reload = true) { event(new DetachingUserFromRole($this, $user)); $results = $this->users()->detach($user); event(new DetachedUserFromRole($this, $user, $results)); $this->loadUsers($reload); return $results; }
[ "public", "function", "detachUser", "(", "$", "user", ",", "$", "reload", "=", "true", ")", "{", "event", "(", "new", "DetachingUserFromRole", "(", "$", "this", ",", "$", "user", ")", ")", ";", "$", "results", "=", "$", "this", "->", "users", "(", ")", "->", "detach", "(", "$", "user", ")", ";", "event", "(", "new", "DetachedUserFromRole", "(", "$", "this", ",", "$", "user", ",", "$", "results", ")", ")", ";", "$", "this", "->", "loadUsers", "(", "$", "reload", ")", ";", "return", "$", "results", ";", "}" ]
Detach a user from a role. @param \Arcanesoft\Contracts\Auth\Models\User|int $user @param bool $reload @return int
[ "Detach", "a", "user", "from", "a", "role", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L218-L227
227,006
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.detachAllUsers
public function detachAllUsers($reload = true) { event(new DetachingAllUsersFromRole($this)); $results = $this->users()->detach(); event(new DetachedAllUsersFromRole($this, $results)); $this->loadUsers($reload); return $results; }
php
public function detachAllUsers($reload = true) { event(new DetachingAllUsersFromRole($this)); $results = $this->users()->detach(); event(new DetachedAllUsersFromRole($this, $results)); $this->loadUsers($reload); return $results; }
[ "public", "function", "detachAllUsers", "(", "$", "reload", "=", "true", ")", "{", "event", "(", "new", "DetachingAllUsersFromRole", "(", "$", "this", ")", ")", ";", "$", "results", "=", "$", "this", "->", "users", "(", ")", "->", "detach", "(", ")", ";", "event", "(", "new", "DetachedAllUsersFromRole", "(", "$", "this", ",", "$", "results", ")", ")", ";", "$", "this", "->", "loadUsers", "(", "$", "reload", ")", ";", "return", "$", "results", ";", "}" ]
Detach all users from a role. @param bool $reload @return int
[ "Detach", "all", "users", "from", "a", "role", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L238-L247
227,007
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.detachPermission
public function detachPermission($permission, $reload = true) { if ( ! $this->hasPermission($permission)) return 0; event(new DetachingPermissionFromRole($this, $permission)); $results = $this->permissions()->detach($permission); event(new DetachedPermissionFromRole($this, $permission, $results)); $this->loadPermissions($reload); return $results; }
php
public function detachPermission($permission, $reload = true) { if ( ! $this->hasPermission($permission)) return 0; event(new DetachingPermissionFromRole($this, $permission)); $results = $this->permissions()->detach($permission); event(new DetachedPermissionFromRole($this, $permission, $results)); $this->loadPermissions($reload); return $results; }
[ "public", "function", "detachPermission", "(", "$", "permission", ",", "$", "reload", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "hasPermission", "(", "$", "permission", ")", ")", "return", "0", ";", "event", "(", "new", "DetachingPermissionFromRole", "(", "$", "this", ",", "$", "permission", ")", ")", ";", "$", "results", "=", "$", "this", "->", "permissions", "(", ")", "->", "detach", "(", "$", "permission", ")", ";", "event", "(", "new", "DetachedPermissionFromRole", "(", "$", "this", ",", "$", "permission", ",", "$", "results", ")", ")", ";", "$", "this", "->", "loadPermissions", "(", "$", "reload", ")", ";", "return", "$", "results", ";", "}" ]
Detach a permission from a role. @param \Arcanesoft\Contracts\Auth\Models\Permission|int $permission @param bool $reload @return int
[ "Detach", "a", "permission", "from", "a", "role", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L276-L287
227,008
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.detachAllPermissions
public function detachAllPermissions($reload = true) { if ($this->permissions->isEmpty()) return 0; event(new DetachingAllPermissionsFromRole($this)); $results = $this->permissions()->detach(); event(new DetachedAllPermissionsFromRole($this, $results)); $this->loadPermissions($reload); return $results; }
php
public function detachAllPermissions($reload = true) { if ($this->permissions->isEmpty()) return 0; event(new DetachingAllPermissionsFromRole($this)); $results = $this->permissions()->detach(); event(new DetachedAllPermissionsFromRole($this, $results)); $this->loadPermissions($reload); return $results; }
[ "public", "function", "detachAllPermissions", "(", "$", "reload", "=", "true", ")", "{", "if", "(", "$", "this", "->", "permissions", "->", "isEmpty", "(", ")", ")", "return", "0", ";", "event", "(", "new", "DetachingAllPermissionsFromRole", "(", "$", "this", ")", ")", ";", "$", "results", "=", "$", "this", "->", "permissions", "(", ")", "->", "detach", "(", ")", ";", "event", "(", "new", "DetachedAllPermissionsFromRole", "(", "$", "this", ",", "$", "results", ")", ")", ";", "$", "this", "->", "loadPermissions", "(", "$", "reload", ")", ";", "return", "$", "results", ";", "}" ]
Detach all permissions from a role. @param bool $reload @return int
[ "Detach", "all", "permissions", "from", "a", "role", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L298-L309
227,009
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.can
public function can($slug) { if ( ! $this->isActive()) return false; return $this->permissions->filter(function (PermissionContract $permission) use ($slug) { return $permission->hasSlug($slug); })->first() !== null; }
php
public function can($slug) { if ( ! $this->isActive()) return false; return $this->permissions->filter(function (PermissionContract $permission) use ($slug) { return $permission->hasSlug($slug); })->first() !== null; }
[ "public", "function", "can", "(", "$", "slug", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "return", "false", ";", "return", "$", "this", "->", "permissions", "->", "filter", "(", "function", "(", "PermissionContract", "$", "permission", ")", "use", "(", "$", "slug", ")", "{", "return", "$", "permission", "->", "hasSlug", "(", "$", "slug", ")", ";", "}", ")", "->", "first", "(", ")", "!==", "null", ";", "}" ]
Check if role is associated with a permission by slug. @param string $slug @return bool
[ "Check", "if", "role", "is", "associated", "with", "a", "permission", "by", "slug", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L352-L360
227,010
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.canAny
public function canAny($permissions, &$failed = null) { $permissions = is_array($permissions) ? collect($permissions) : $permissions; $failed = $permissions->reject(function ($permission) { return $this->can($permission); })->values(); return $permissions->count() !== $failed->count(); }
php
public function canAny($permissions, &$failed = null) { $permissions = is_array($permissions) ? collect($permissions) : $permissions; $failed = $permissions->reject(function ($permission) { return $this->can($permission); })->values(); return $permissions->count() !== $failed->count(); }
[ "public", "function", "canAny", "(", "$", "permissions", ",", "&", "$", "failed", "=", "null", ")", "{", "$", "permissions", "=", "is_array", "(", "$", "permissions", ")", "?", "collect", "(", "$", "permissions", ")", ":", "$", "permissions", ";", "$", "failed", "=", "$", "permissions", "->", "reject", "(", "function", "(", "$", "permission", ")", "{", "return", "$", "this", "->", "can", "(", "$", "permission", ")", ";", "}", ")", "->", "values", "(", ")", ";", "return", "$", "permissions", "->", "count", "(", ")", "!==", "$", "failed", "->", "count", "(", ")", ";", "}" ]
Check if a role is associated with any of given permissions. @param \Illuminate\Support\Collection|array $permissions @param \Illuminate\Support\Collection &$failed @return bool
[ "Check", "if", "a", "role", "is", "associated", "with", "any", "of", "given", "permissions", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L370-L379
227,011
ARCANEDEV/LaravelAuth
src/Models/Role.php
Role.canAll
public function canAll($permissions, &$failed = null) { $this->canAny($permissions, $failed); return $failed->isEmpty(); }
php
public function canAll($permissions, &$failed = null) { $this->canAny($permissions, $failed); return $failed->isEmpty(); }
[ "public", "function", "canAll", "(", "$", "permissions", ",", "&", "$", "failed", "=", "null", ")", "{", "$", "this", "->", "canAny", "(", "$", "permissions", ",", "$", "failed", ")", ";", "return", "$", "failed", "->", "isEmpty", "(", ")", ";", "}" ]
Check if role is associated with all given permissions. @param \Illuminate\Support\Collection|array $permissions @param \Illuminate\Support\Collection &$failed @return bool
[ "Check", "if", "role", "is", "associated", "with", "all", "given", "permissions", "." ]
a2719e924c2299f931879139c6cd97642e80acc7
https://github.com/ARCANEDEV/LaravelAuth/blob/a2719e924c2299f931879139c6cd97642e80acc7/src/Models/Role.php#L389-L394
227,012
javanile/moldable
src/Parser/Mysql/TypeTrait.php
TypeTrait.getNotationType
public function getNotationType( $notation, &$params = null, &$errors = null, $namespace = null ) { $type = gettype($notation); $params = null; switch ($type) { case 'string': return $this->getNotationTypeString($notation, $params, $errors, $namespace); case 'array': return $this->getNotationTypeArray($notation, $params); case 'integer': return 'integer'; case 'double': return 'float'; case 'boolean': return 'boolean'; case 'NULL': return 'null'; } $errors[] = "irrational type for '{$notation}'"; }
php
public function getNotationType( $notation, &$params = null, &$errors = null, $namespace = null ) { $type = gettype($notation); $params = null; switch ($type) { case 'string': return $this->getNotationTypeString($notation, $params, $errors, $namespace); case 'array': return $this->getNotationTypeArray($notation, $params); case 'integer': return 'integer'; case 'double': return 'float'; case 'boolean': return 'boolean'; case 'NULL': return 'null'; } $errors[] = "irrational type for '{$notation}'"; }
[ "public", "function", "getNotationType", "(", "$", "notation", ",", "&", "$", "params", "=", "null", ",", "&", "$", "errors", "=", "null", ",", "$", "namespace", "=", "null", ")", "{", "$", "type", "=", "gettype", "(", "$", "notation", ")", ";", "$", "params", "=", "null", ";", "switch", "(", "$", "type", ")", "{", "case", "'string'", ":", "return", "$", "this", "->", "getNotationTypeString", "(", "$", "notation", ",", "$", "params", ",", "$", "errors", ",", "$", "namespace", ")", ";", "case", "'array'", ":", "return", "$", "this", "->", "getNotationTypeArray", "(", "$", "notation", ",", "$", "params", ")", ";", "case", "'integer'", ":", "return", "'integer'", ";", "case", "'double'", ":", "return", "'float'", ";", "case", "'boolean'", ":", "return", "'boolean'", ";", "case", "'NULL'", ":", "return", "'null'", ";", "}", "$", "errors", "[", "]", "=", "\"irrational type for '{$notation}'\"", ";", "}" ]
Get type of a notation. @param type $notation @param type $params @param null|mixed $namespace @return string
[ "Get", "type", "of", "a", "notation", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/Mysql/TypeTrait.php#L23-L48
227,013
BootstrapCMS/Credentials
src/Models/User.php
User.getActivatedAtAccessor
public function getActivatedAtAccessor($value) { if ($value) { return new Carbon($value); } if ($this->getAttribute('activated')) { return $this->getAttribute('created_at'); } return false; }
php
public function getActivatedAtAccessor($value) { if ($value) { return new Carbon($value); } if ($this->getAttribute('activated')) { return $this->getAttribute('created_at'); } return false; }
[ "public", "function", "getActivatedAtAccessor", "(", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "return", "new", "Carbon", "(", "$", "value", ")", ";", "}", "if", "(", "$", "this", "->", "getAttribute", "(", "'activated'", ")", ")", "{", "return", "$", "this", "->", "getAttribute", "(", "'created_at'", ")", ";", "}", "return", "false", ";", "}" ]
Activated at accessor. @param string $value @return \Carbon\Carbon|false
[ "Activated", "at", "accessor", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/User.php#L168-L179
227,014
BootstrapCMS/Credentials
src/Models/User.php
User.hasAccess
public function hasAccess($permissions, $all = true) { $key = sha1(json_encode($permissions).json_encode($all)); if (!array_key_exists($key, $this->access)) { $this->access[$key] = parent::hasAccess($permissions, $all); } return $this->access[$key]; }
php
public function hasAccess($permissions, $all = true) { $key = sha1(json_encode($permissions).json_encode($all)); if (!array_key_exists($key, $this->access)) { $this->access[$key] = parent::hasAccess($permissions, $all); } return $this->access[$key]; }
[ "public", "function", "hasAccess", "(", "$", "permissions", ",", "$", "all", "=", "true", ")", "{", "$", "key", "=", "sha1", "(", "json_encode", "(", "$", "permissions", ")", ".", "json_encode", "(", "$", "all", ")", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "access", ")", ")", "{", "$", "this", "->", "access", "[", "$", "key", "]", "=", "parent", "::", "hasAccess", "(", "$", "permissions", ",", "$", "all", ")", ";", "}", "return", "$", "this", "->", "access", "[", "$", "key", "]", ";", "}" ]
Check a user's access. @param string|string[] $permissions @param bool $all @return bool
[ "Check", "a", "user", "s", "access", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/User.php#L189-L198
227,015
whatwedo/TableBundle
Extension/PaginationExtension.php
PaginationExtension.getCurrentPage
public function getCurrentPage() { $page = $this->getRequest()->query->getInt($this->getActionQueryParameter(static::QUERY_PARAMETER_PAGE), 1); if ($page < 1) { $page = 1; } return $page; }
php
public function getCurrentPage() { $page = $this->getRequest()->query->getInt($this->getActionQueryParameter(static::QUERY_PARAMETER_PAGE), 1); if ($page < 1) { $page = 1; } return $page; }
[ "public", "function", "getCurrentPage", "(", ")", "{", "$", "page", "=", "$", "this", "->", "getRequest", "(", ")", "->", "query", "->", "getInt", "(", "$", "this", "->", "getActionQueryParameter", "(", "static", "::", "QUERY_PARAMETER_PAGE", ")", ",", "1", ")", ";", "if", "(", "$", "page", "<", "1", ")", "{", "$", "page", "=", "1", ";", "}", "return", "$", "page", ";", "}" ]
returns current page number. @return int
[ "returns", "current", "page", "number", "." ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Extension/PaginationExtension.php#L69-L76
227,016
OpenSkill/Datatable
src/OpenSkill/Datatable/Datatable.php
Datatable.make
public function make(Provider $provider) { $composer = new ColumnComposer($provider, $this->versionEngine, $this->viewFactory, $this->configRepository); return $composer; }
php
public function make(Provider $provider) { $composer = new ColumnComposer($provider, $this->versionEngine, $this->viewFactory, $this->configRepository); return $composer; }
[ "public", "function", "make", "(", "Provider", "$", "provider", ")", "{", "$", "composer", "=", "new", "ColumnComposer", "(", "$", "provider", ",", "$", "this", "->", "versionEngine", ",", "$", "this", "->", "viewFactory", ",", "$", "this", "->", "configRepository", ")", ";", "return", "$", "composer", ";", "}" ]
Will create a new DataComposer with the given provider as implementation. @param Provider $provider The provider for the underlying data. @return ColumnComposer
[ "Will", "create", "a", "new", "DataComposer", "with", "the", "given", "provider", "as", "implementation", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Datatable.php#L54-L58
227,017
javanile/moldable
src/Functions.php
Functions.applyConventions
public static function applyConventions($convention, $string) { // switch ($convention) { case 'camel-case': return Stringy::create($string)->camelize(); case 'upper-camel-case': return Stringy::create($string)->upperCamelize(); case 'underscore': return Stringy::create($string)->underscored(); default: return $string; } }
php
public static function applyConventions($convention, $string) { // switch ($convention) { case 'camel-case': return Stringy::create($string)->camelize(); case 'upper-camel-case': return Stringy::create($string)->upperCamelize(); case 'underscore': return Stringy::create($string)->underscored(); default: return $string; } }
[ "public", "static", "function", "applyConventions", "(", "$", "convention", ",", "$", "string", ")", "{", "//", "switch", "(", "$", "convention", ")", "{", "case", "'camel-case'", ":", "return", "Stringy", "::", "create", "(", "$", "string", ")", "->", "camelize", "(", ")", ";", "case", "'upper-camel-case'", ":", "return", "Stringy", "::", "create", "(", "$", "string", ")", "->", "upperCamelize", "(", ")", ";", "case", "'underscore'", ":", "return", "Stringy", "::", "create", "(", "$", "string", ")", "->", "underscored", "(", ")", ";", "default", ":", "return", "$", "string", ";", "}", "}" ]
Apply names conventions as camelCase or snake_case. @param mixed $convention @param mixed $string
[ "Apply", "names", "conventions", "as", "camelCase", "or", "snake_case", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Functions.php#L183-L196
227,018
OpenSkill/Datatable
src/OpenSkill/Datatable/Columns/ColumnConfigurationBuilder.php
ColumnConfigurationBuilder.build
public function build() { $this->checkName(); $this->checkCallable(); $this->checkOrderable(); $this->checkSearchable(); return new ColumnConfiguration($this->name, $this->callable, $this->searchable, $this->orderable); }
php
public function build() { $this->checkName(); $this->checkCallable(); $this->checkOrderable(); $this->checkSearchable(); return new ColumnConfiguration($this->name, $this->callable, $this->searchable, $this->orderable); }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "checkName", "(", ")", ";", "$", "this", "->", "checkCallable", "(", ")", ";", "$", "this", "->", "checkOrderable", "(", ")", ";", "$", "this", "->", "checkSearchable", "(", ")", ";", "return", "new", "ColumnConfiguration", "(", "$", "this", "->", "name", ",", "$", "this", "->", "callable", ",", "$", "this", "->", "searchable", ",", "$", "this", "->", "orderable", ")", ";", "}" ]
Will create the final ColumnConfiguration @return ColumnConfiguration
[ "Will", "create", "the", "final", "ColumnConfiguration" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Columns/ColumnConfigurationBuilder.php#L99-L107
227,019
OpenSkill/Datatable
src/OpenSkill/Datatable/Columns/ColumnConfigurationBuilder.php
ColumnConfigurationBuilder.checkCallable
private function checkCallable() { if (is_null($this->callable) || !is_callable($this->callable)) { $this->callable = function ($data) { $name = $this->name; if (is_array($data) && array_key_exists($name, $data)) { return $data[$name]; } if (is_object($data) && property_exists($data, $name)) { return $data->$name; } if (is_object($data) && method_exists($data, $name)) { return $data->$name(); } return ""; }; } }
php
private function checkCallable() { if (is_null($this->callable) || !is_callable($this->callable)) { $this->callable = function ($data) { $name = $this->name; if (is_array($data) && array_key_exists($name, $data)) { return $data[$name]; } if (is_object($data) && property_exists($data, $name)) { return $data->$name; } if (is_object($data) && method_exists($data, $name)) { return $data->$name(); } return ""; }; } }
[ "private", "function", "checkCallable", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "callable", ")", "||", "!", "is_callable", "(", "$", "this", "->", "callable", ")", ")", "{", "$", "this", "->", "callable", "=", "function", "(", "$", "data", ")", "{", "$", "name", "=", "$", "this", "->", "name", ";", "if", "(", "is_array", "(", "$", "data", ")", "&&", "array_key_exists", "(", "$", "name", ",", "$", "data", ")", ")", "{", "return", "$", "data", "[", "$", "name", "]", ";", "}", "if", "(", "is_object", "(", "$", "data", ")", "&&", "property_exists", "(", "$", "data", ",", "$", "name", ")", ")", "{", "return", "$", "data", "->", "$", "name", ";", "}", "if", "(", "is_object", "(", "$", "data", ")", "&&", "method_exists", "(", "$", "data", ",", "$", "name", ")", ")", "{", "return", "$", "data", "->", "$", "name", "(", ")", ";", "}", "return", "\"\"", ";", "}", ";", "}", "}" ]
Will check if the callable is set and is executable, if not a sensible default will be set.
[ "Will", "check", "if", "the", "callable", "is", "set", "and", "is", "executable", "if", "not", "a", "sensible", "default", "will", "be", "set", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Columns/ColumnConfigurationBuilder.php#L142-L163
227,020
javanile/moldable
src/Database/InsertApi.php
InsertApi.insert
public function insert($model, $values, $map = null) { if (is_string($values)) { $values = [ $values => $map, ]; $map = null; } $this->adapt($model, $this->profile($values)); $fieldsArray = []; $tokensArray = []; $valuesArray = []; foreach ($values as $field => $value) { $field = isset($map[$field]) ? $map[$field] : $field; $token = ':'.$field; $fieldsArray[] = '`'.$field.'`'; $tokensArray[] = $token; $valuesArray[$token] = $value; } $fields = implode(',', $fieldsArray); $tokens = implode(',', $tokensArray); $table = $this->getPrefix($model); $sql = "INSERT INTO `{$table}` ({$fields}) VALUES ({$tokens})"; $this->execute($sql, $valuesArray); return $this->getLastId(); }
php
public function insert($model, $values, $map = null) { if (is_string($values)) { $values = [ $values => $map, ]; $map = null; } $this->adapt($model, $this->profile($values)); $fieldsArray = []; $tokensArray = []; $valuesArray = []; foreach ($values as $field => $value) { $field = isset($map[$field]) ? $map[$field] : $field; $token = ':'.$field; $fieldsArray[] = '`'.$field.'`'; $tokensArray[] = $token; $valuesArray[$token] = $value; } $fields = implode(',', $fieldsArray); $tokens = implode(',', $tokensArray); $table = $this->getPrefix($model); $sql = "INSERT INTO `{$table}` ({$fields}) VALUES ({$tokens})"; $this->execute($sql, $valuesArray); return $this->getLastId(); }
[ "public", "function", "insert", "(", "$", "model", ",", "$", "values", ",", "$", "map", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "values", ")", ")", "{", "$", "values", "=", "[", "$", "values", "=>", "$", "map", ",", "]", ";", "$", "map", "=", "null", ";", "}", "$", "this", "->", "adapt", "(", "$", "model", ",", "$", "this", "->", "profile", "(", "$", "values", ")", ")", ";", "$", "fieldsArray", "=", "[", "]", ";", "$", "tokensArray", "=", "[", "]", ";", "$", "valuesArray", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "field", "=", "isset", "(", "$", "map", "[", "$", "field", "]", ")", "?", "$", "map", "[", "$", "field", "]", ":", "$", "field", ";", "$", "token", "=", "':'", ".", "$", "field", ";", "$", "fieldsArray", "[", "]", "=", "'`'", ".", "$", "field", ".", "'`'", ";", "$", "tokensArray", "[", "]", "=", "$", "token", ";", "$", "valuesArray", "[", "$", "token", "]", "=", "$", "value", ";", "}", "$", "fields", "=", "implode", "(", "','", ",", "$", "fieldsArray", ")", ";", "$", "tokens", "=", "implode", "(", "','", ",", "$", "tokensArray", ")", ";", "$", "table", "=", "$", "this", "->", "getPrefix", "(", "$", "model", ")", ";", "$", "sql", "=", "\"INSERT INTO `{$table}` ({$fields}) VALUES ({$tokens})\"", ";", "$", "this", "->", "execute", "(", "$", "sql", ",", "$", "valuesArray", ")", ";", "return", "$", "this", "->", "getLastId", "(", ")", ";", "}" ]
Insert record for specific model with values. @param type $list @param mixed $model @param mixed $values @param null|mixed $map
[ "Insert", "record", "for", "specific", "model", "with", "values", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/InsertApi.php#L22-L52
227,021
javanile/moldable
src/Database.php
Database.getDefault
public static function getDefault() { if (static::$_default != null) { return static::$_default; } // check if running into laravel context if (Context::checkLaravel()) { static::$_default = new self(['socket' => 'Laravel']); return static::$_default; } // check if registered container if (Context::checkContainer()) { return Context::getContainerDatabase(); } }
php
public static function getDefault() { if (static::$_default != null) { return static::$_default; } // check if running into laravel context if (Context::checkLaravel()) { static::$_default = new self(['socket' => 'Laravel']); return static::$_default; } // check if registered container if (Context::checkContainer()) { return Context::getContainerDatabase(); } }
[ "public", "static", "function", "getDefault", "(", ")", "{", "if", "(", "static", "::", "$", "_default", "!=", "null", ")", "{", "return", "static", "::", "$", "_default", ";", "}", "// check if running into laravel context", "if", "(", "Context", "::", "checkLaravel", "(", ")", ")", "{", "static", "::", "$", "_default", "=", "new", "self", "(", "[", "'socket'", "=>", "'Laravel'", "]", ")", ";", "return", "static", "::", "$", "_default", ";", "}", "// check if registered container", "if", "(", "Context", "::", "checkContainer", "(", ")", ")", "{", "return", "Context", "::", "getContainerDatabase", "(", ")", ";", "}", "}" ]
Retrieve default SchemaDB connection. @return type
[ "Retrieve", "default", "SchemaDB", "connection", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database.php#L147-L164
227,022
javanile/moldable
src/Model/FieldApi.php
FieldApi.initSchemaFields
protected function initSchemaFields() { $schema = static::getSchemaFields(); $parser = static::getDatabase()->getParser(); // prepare field values strip schema definitions foreach ($schema as $field) { $this->{$field} = $parser->getNotationValue($this->{$field}); } }
php
protected function initSchemaFields() { $schema = static::getSchemaFields(); $parser = static::getDatabase()->getParser(); // prepare field values strip schema definitions foreach ($schema as $field) { $this->{$field} = $parser->getNotationValue($this->{$field}); } }
[ "protected", "function", "initSchemaFields", "(", ")", "{", "$", "schema", "=", "static", "::", "getSchemaFields", "(", ")", ";", "$", "parser", "=", "static", "::", "getDatabase", "(", ")", "->", "getParser", "(", ")", ";", "// prepare field values strip schema definitions", "foreach", "(", "$", "schema", "as", "$", "field", ")", "{", "$", "this", "->", "{", "$", "field", "}", "=", "$", "parser", "->", "getNotationValue", "(", "$", "this", "->", "{", "$", "field", "}", ")", ";", "}", "}" ]
Initialize all fields in class.
[ "Initialize", "all", "fields", "in", "class", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/FieldApi.php#L17-L26
227,023
javanile/moldable
src/Model/FieldApi.php
FieldApi.fillSchemaFields
public function fillSchemaFields($values, $map = null, $prefix = null) { // if (is_array($map)) { foreach ($map as $alias => $field) { if (isset($values[$alias])) { $values[$field] = $values[$alias]; } } } // foreach (static::getSchema() as $field => $aspects) { if (isset($aspects['Class']) && $aspects['Relation'] == '1:1') { $class = $aspects['Class']; $this->{$field} = $class::create( $values, $map, $prefix.$field.'__' ); } // $field = $prefix.$field; // if (isset($values[$field])) { $this->{$field} = $values[$field]; } } // $key = $this->getPrimaryKey(); // $field = $prefix.$key; // if ($key) { $this->{$key} = isset($values[$field]) ? (int) $values[$field] : (int) $this->{$key}; } }
php
public function fillSchemaFields($values, $map = null, $prefix = null) { // if (is_array($map)) { foreach ($map as $alias => $field) { if (isset($values[$alias])) { $values[$field] = $values[$alias]; } } } // foreach (static::getSchema() as $field => $aspects) { if (isset($aspects['Class']) && $aspects['Relation'] == '1:1') { $class = $aspects['Class']; $this->{$field} = $class::create( $values, $map, $prefix.$field.'__' ); } // $field = $prefix.$field; // if (isset($values[$field])) { $this->{$field} = $values[$field]; } } // $key = $this->getPrimaryKey(); // $field = $prefix.$key; // if ($key) { $this->{$key} = isset($values[$field]) ? (int) $values[$field] : (int) $this->{$key}; } }
[ "public", "function", "fillSchemaFields", "(", "$", "values", ",", "$", "map", "=", "null", ",", "$", "prefix", "=", "null", ")", "{", "//", "if", "(", "is_array", "(", "$", "map", ")", ")", "{", "foreach", "(", "$", "map", "as", "$", "alias", "=>", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "values", "[", "$", "alias", "]", ")", ")", "{", "$", "values", "[", "$", "field", "]", "=", "$", "values", "[", "$", "alias", "]", ";", "}", "}", "}", "//", "foreach", "(", "static", "::", "getSchema", "(", ")", "as", "$", "field", "=>", "$", "aspects", ")", "{", "if", "(", "isset", "(", "$", "aspects", "[", "'Class'", "]", ")", "&&", "$", "aspects", "[", "'Relation'", "]", "==", "'1:1'", ")", "{", "$", "class", "=", "$", "aspects", "[", "'Class'", "]", ";", "$", "this", "->", "{", "$", "field", "}", "=", "$", "class", "::", "create", "(", "$", "values", ",", "$", "map", ",", "$", "prefix", ".", "$", "field", ".", "'__'", ")", ";", "}", "//", "$", "field", "=", "$", "prefix", ".", "$", "field", ";", "//", "if", "(", "isset", "(", "$", "values", "[", "$", "field", "]", ")", ")", "{", "$", "this", "->", "{", "$", "field", "}", "=", "$", "values", "[", "$", "field", "]", ";", "}", "}", "//", "$", "key", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "//", "$", "field", "=", "$", "prefix", ".", "$", "key", ";", "//", "if", "(", "$", "key", ")", "{", "$", "this", "->", "{", "$", "key", "}", "=", "isset", "(", "$", "values", "[", "$", "field", "]", ")", "?", "(", "int", ")", "$", "values", "[", "$", "field", "]", ":", "(", "int", ")", "$", "this", "->", "{", "$", "key", "}", ";", "}", "}" ]
Fill value inside model fields. @param type $values @param null|mixed $map @param null|mixed $prefix
[ "Fill", "value", "inside", "model", "fields", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/FieldApi.php#L35-L79
227,024
javanile/moldable
src/Model/FieldApi.php
FieldApi.getPrimaryKeyValue
public function getPrimaryKeyValue() { // $key = static::getPrimaryKey(); // return $key && isset($this->{$key}) ? $this->{$key} : null; }
php
public function getPrimaryKeyValue() { // $key = static::getPrimaryKey(); // return $key && isset($this->{$key}) ? $this->{$key} : null; }
[ "public", "function", "getPrimaryKeyValue", "(", ")", "{", "//", "$", "key", "=", "static", "::", "getPrimaryKey", "(", ")", ";", "//", "return", "$", "key", "&&", "isset", "(", "$", "this", "->", "{", "$", "key", "}", ")", "?", "$", "this", "->", "{", "$", "key", "}", ":", "null", ";", "}" ]
Get primary key value.
[ "Get", "primary", "key", "value", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/FieldApi.php#L111-L121
227,025
javanile/moldable
src/Model/FieldApi.php
FieldApi.getStaticFields
protected static function getStaticFields() { // $attribute = 'StaticFields'; // retrieve value from class setting definition if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); // $reflection = new \ReflectionClass($class); // $fields = array_keys($reflection->getStaticProperties()); // store as setting for future request static::setClassAttribute($attribute, $fields); } // return primary key field name return static::getClassAttribute($attribute); }
php
protected static function getStaticFields() { // $attribute = 'StaticFields'; // retrieve value from class setting definition if (!static::hasClassAttribute($attribute)) { $class = static::getClass(); // $reflection = new \ReflectionClass($class); // $fields = array_keys($reflection->getStaticProperties()); // store as setting for future request static::setClassAttribute($attribute, $fields); } // return primary key field name return static::getClassAttribute($attribute); }
[ "protected", "static", "function", "getStaticFields", "(", ")", "{", "//", "$", "attribute", "=", "'StaticFields'", ";", "// retrieve value from class setting definition", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "class", "=", "static", "::", "getClass", "(", ")", ";", "//", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "//", "$", "fields", "=", "array_keys", "(", "$", "reflection", "->", "getStaticProperties", "(", ")", ")", ";", "// store as setting for future request", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "fields", ")", ";", "}", "// return primary key field name", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Get all static fields.
[ "Get", "all", "static", "fields", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/FieldApi.php#L248-L269
227,026
whatwedo/TableBundle
Factory/TableFactory.php
TableFactory.createTable
public function createTable($identifier, $options = []) { return new Table( $identifier, $options, $this->eventDispatcher, $this->requestStack, $this->templating, $this->formatterManager, $this->extensions ); }
php
public function createTable($identifier, $options = []) { return new Table( $identifier, $options, $this->eventDispatcher, $this->requestStack, $this->templating, $this->formatterManager, $this->extensions ); }
[ "public", "function", "createTable", "(", "$", "identifier", ",", "$", "options", "=", "[", "]", ")", "{", "return", "new", "Table", "(", "$", "identifier", ",", "$", "options", ",", "$", "this", "->", "eventDispatcher", ",", "$", "this", "->", "requestStack", ",", "$", "this", "->", "templating", ",", "$", "this", "->", "formatterManager", ",", "$", "this", "->", "extensions", ")", ";", "}" ]
returns a new table object @param string $identifier @param array $options @return Table
[ "returns", "a", "new", "table", "object" ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Factory/TableFactory.php#L95-L106
227,027
OpenSkill/Datatable
src/OpenSkill/Datatable/Queries/Parser/Datatable110QueryParser.php
Datatable110QueryParser.parse
public function parse(Request $request, array $columnConfiguration) { $query = $request->query; $builder = QueryConfigurationBuilder::create(); $this->getDrawCall($query, $builder); $this->getStart($query, $builder); $this->getLength($query, $builder); $this->getSearch($query, $builder); $this->getRegex($query, $builder); $this->getOrder($query, $builder, $columnConfiguration); $this->getSearchColumns($query, $builder, $columnConfiguration); return $builder->build(); }
php
public function parse(Request $request, array $columnConfiguration) { $query = $request->query; $builder = QueryConfigurationBuilder::create(); $this->getDrawCall($query, $builder); $this->getStart($query, $builder); $this->getLength($query, $builder); $this->getSearch($query, $builder); $this->getRegex($query, $builder); $this->getOrder($query, $builder, $columnConfiguration); $this->getSearchColumns($query, $builder, $columnConfiguration); return $builder->build(); }
[ "public", "function", "parse", "(", "Request", "$", "request", ",", "array", "$", "columnConfiguration", ")", "{", "$", "query", "=", "$", "request", "->", "query", ";", "$", "builder", "=", "QueryConfigurationBuilder", "::", "create", "(", ")", ";", "$", "this", "->", "getDrawCall", "(", "$", "query", ",", "$", "builder", ")", ";", "$", "this", "->", "getStart", "(", "$", "query", ",", "$", "builder", ")", ";", "$", "this", "->", "getLength", "(", "$", "query", ",", "$", "builder", ")", ";", "$", "this", "->", "getSearch", "(", "$", "query", ",", "$", "builder", ")", ";", "$", "this", "->", "getRegex", "(", "$", "query", ",", "$", "builder", ")", ";", "$", "this", "->", "getOrder", "(", "$", "query", ",", "$", "builder", ",", "$", "columnConfiguration", ")", ";", "$", "this", "->", "getSearchColumns", "(", "$", "query", ",", "$", "builder", ",", "$", "columnConfiguration", ")", ";", "return", "$", "builder", "->", "build", "(", ")", ";", "}" ]
Method that should parse the request and return a DTQueryConfiguration @param Request $request The current request that should be investigated @param ColumnConfiguration[] $columnConfiguration The configuration of the columns @return QueryConfiguration the configuration the provider can use to prepare the data
[ "Method", "that", "should", "parse", "the", "request", "and", "return", "a", "DTQueryConfiguration" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Queries/Parser/Datatable110QueryParser.php#L34-L54
227,028
javanile/moldable
src/Model/RawApi.php
RawApi.raw
public static function raw( $sql, $params = null ) { $results = static::getDatabase()->getResults($sql, $params); return $results; }
php
public static function raw( $sql, $params = null ) { $results = static::getDatabase()->getResults($sql, $params); return $results; }
[ "public", "static", "function", "raw", "(", "$", "sql", ",", "$", "params", "=", "null", ")", "{", "$", "results", "=", "static", "::", "getDatabase", "(", ")", "->", "getResults", "(", "$", "sql", ",", "$", "params", ")", ";", "return", "$", "results", ";", "}" ]
Execute a raw query on database. @param type $array @param mixed $sql @param null|mixed $params @param mixed $singleRecord @param mixed $singleValue @param mixed $casting
[ "Execute", "a", "raw", "query", "on", "database", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/RawApi.php#L24-L31
227,029
whatwedo/TableBundle
Table/DoctrineTable.php
DoctrineTable.dataLoader
public function dataLoader($page, $limit) { if ($limit > 0) { $this->getQueryBuilder()->setMaxResults($limit); $this->getQueryBuilder()->setFirstResult(($page - 1) * $limit); } $paginator = new Paginator($this->getQueryBuilder()); $tableData = new SimpleTableData(); $tableData->setTotalResults(count($paginator)); $tableData->setResults(iterator_to_array($paginator->getIterator())); return $tableData; }
php
public function dataLoader($page, $limit) { if ($limit > 0) { $this->getQueryBuilder()->setMaxResults($limit); $this->getQueryBuilder()->setFirstResult(($page - 1) * $limit); } $paginator = new Paginator($this->getQueryBuilder()); $tableData = new SimpleTableData(); $tableData->setTotalResults(count($paginator)); $tableData->setResults(iterator_to_array($paginator->getIterator())); return $tableData; }
[ "public", "function", "dataLoader", "(", "$", "page", ",", "$", "limit", ")", "{", "if", "(", "$", "limit", ">", "0", ")", "{", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "setMaxResults", "(", "$", "limit", ")", ";", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "setFirstResult", "(", "(", "$", "page", "-", "1", ")", "*", "$", "limit", ")", ";", "}", "$", "paginator", "=", "new", "Paginator", "(", "$", "this", "->", "getQueryBuilder", "(", ")", ")", ";", "$", "tableData", "=", "new", "SimpleTableData", "(", ")", ";", "$", "tableData", "->", "setTotalResults", "(", "count", "(", "$", "paginator", ")", ")", ";", "$", "tableData", "->", "setResults", "(", "iterator_to_array", "(", "$", "paginator", "->", "getIterator", "(", ")", ")", ")", ";", "return", "$", "tableData", ";", "}" ]
Doctrine table data loader @param int $page @param int $limit @return SimpleTableData
[ "Doctrine", "table", "data", "loader" ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Table/DoctrineTable.php#L101-L114
227,030
neoxygen/neo4j-neogen
src/Helper/CypherHelper.php
CypherHelper.addNodeLabel
public function addNodeLabel($alias = null, $label) { if (null === $alias) { $alias = str_replace('.','','n'.microtime(true).rand(0,100000000000)); } return $alias.':'.$label.' '; }
php
public function addNodeLabel($alias = null, $label) { if (null === $alias) { $alias = str_replace('.','','n'.microtime(true).rand(0,100000000000)); } return $alias.':'.$label.' '; }
[ "public", "function", "addNodeLabel", "(", "$", "alias", "=", "null", ",", "$", "label", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "alias", "=", "str_replace", "(", "'.'", ",", "''", ",", "'n'", ".", "microtime", "(", "true", ")", ".", "rand", "(", "0", ",", "100000000000", ")", ")", ";", "}", "return", "$", "alias", ".", "':'", ".", "$", "label", ".", "' '", ";", "}" ]
Add the node alias and the node label @param null $alias @param $label @return string
[ "Add", "the", "node", "alias", "and", "the", "node", "label" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Helper/CypherHelper.php#L25-L32
227,031
neoxygen/neo4j-neogen
src/Helper/CypherHelper.php
CypherHelper.addNodeProperty
public function addNodeProperty($key, $value) { if (is_string($value)) { $value = '"'.htmlentities($value, ENT_QUOTES, 'UTF-8').'"'; } elseif (is_int($value)) { $value = 'toInt('.$value.')'; } return $key.':'.$value; }
php
public function addNodeProperty($key, $value) { if (is_string($value)) { $value = '"'.htmlentities($value, ENT_QUOTES, 'UTF-8').'"'; } elseif (is_int($value)) { $value = 'toInt('.$value.')'; } return $key.':'.$value; }
[ "public", "function", "addNodeProperty", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "'\"'", ".", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ".", "'\"'", ";", "}", "elseif", "(", "is_int", "(", "$", "value", ")", ")", "{", "$", "value", "=", "'toInt('", ".", "$", "value", ".", "')'", ";", "}", "return", "$", "key", ".", "':'", ".", "$", "value", ";", "}" ]
Add a node property key => value, should be used between the "openNodePropertiesBracket" and "closeNodePropertiesBracket" methods @param $key @param $value @return string
[ "Add", "a", "node", "property", "key", "=", ">", "value", "should", "be", "used", "between", "the", "openNodePropertiesBracket", "and", "closeNodePropertiesBracket", "methods" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Helper/CypherHelper.php#L72-L81
227,032
neoxygen/neo4j-neogen
src/Helper/CypherHelper.php
CypherHelper.addRelationship
public function addRelationship($start, $end, $type, array $properties = array()) { $sa = 'r'.sha1($start.microtime()); $es = 'r'.sha1($end.microtime()); $q = 'MERGE ('.$sa.' { neogen_id: "'.$start.'" }) '; $q .= 'MERGE ('.$es.' { neogen_id: "'.$end.'" }) '; if (!empty($properties)) { $props = ' { '; $i = 0; $max = count($properties); foreach ($properties as $key => $value) { if (is_string($value)) { $val = '"'.htmlentities($value, ENT_QUOTES, 'UTF-8').'"'; } elseif (is_int($value)) { $val = 'toInt('.$value.')'; } elseif (is_float($value)) { $val = 'toFloat('.$value.')'; } else { $val = htmlentities($value); } $props .= $key.':'.$val; if ($i < $max-1) { $props .= ','; } $i++; } $props .= '}'; } else { $props = ''; } $q .= 'MERGE ('.$sa.')-[:'.$type.$props.']->('.$es.') '; if (!empty($props)) { //print_r($q); //exit(); } return $q; }
php
public function addRelationship($start, $end, $type, array $properties = array()) { $sa = 'r'.sha1($start.microtime()); $es = 'r'.sha1($end.microtime()); $q = 'MERGE ('.$sa.' { neogen_id: "'.$start.'" }) '; $q .= 'MERGE ('.$es.' { neogen_id: "'.$end.'" }) '; if (!empty($properties)) { $props = ' { '; $i = 0; $max = count($properties); foreach ($properties as $key => $value) { if (is_string($value)) { $val = '"'.htmlentities($value, ENT_QUOTES, 'UTF-8').'"'; } elseif (is_int($value)) { $val = 'toInt('.$value.')'; } elseif (is_float($value)) { $val = 'toFloat('.$value.')'; } else { $val = htmlentities($value); } $props .= $key.':'.$val; if ($i < $max-1) { $props .= ','; } $i++; } $props .= '}'; } else { $props = ''; } $q .= 'MERGE ('.$sa.')-[:'.$type.$props.']->('.$es.') '; if (!empty($props)) { //print_r($q); //exit(); } return $q; }
[ "public", "function", "addRelationship", "(", "$", "start", ",", "$", "end", ",", "$", "type", ",", "array", "$", "properties", "=", "array", "(", ")", ")", "{", "$", "sa", "=", "'r'", ".", "sha1", "(", "$", "start", ".", "microtime", "(", ")", ")", ";", "$", "es", "=", "'r'", ".", "sha1", "(", "$", "end", ".", "microtime", "(", ")", ")", ";", "$", "q", "=", "'MERGE ('", ".", "$", "sa", ".", "' { neogen_id: \"'", ".", "$", "start", ".", "'\" }) '", ";", "$", "q", ".=", "'MERGE ('", ".", "$", "es", ".", "' { neogen_id: \"'", ".", "$", "end", ".", "'\" }) '", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", ")", "{", "$", "props", "=", "' { '", ";", "$", "i", "=", "0", ";", "$", "max", "=", "count", "(", "$", "properties", ")", ";", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "val", "=", "'\"'", ".", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ".", "'\"'", ";", "}", "elseif", "(", "is_int", "(", "$", "value", ")", ")", "{", "$", "val", "=", "'toInt('", ".", "$", "value", ".", "')'", ";", "}", "elseif", "(", "is_float", "(", "$", "value", ")", ")", "{", "$", "val", "=", "'toFloat('", ".", "$", "value", ".", "')'", ";", "}", "else", "{", "$", "val", "=", "htmlentities", "(", "$", "value", ")", ";", "}", "$", "props", ".=", "$", "key", ".", "':'", ".", "$", "val", ";", "if", "(", "$", "i", "<", "$", "max", "-", "1", ")", "{", "$", "props", ".=", "','", ";", "}", "$", "i", "++", ";", "}", "$", "props", ".=", "'}'", ";", "}", "else", "{", "$", "props", "=", "''", ";", "}", "$", "q", ".=", "'MERGE ('", ".", "$", "sa", ".", "')-[:'", ".", "$", "type", ".", "$", "props", ".", "']->('", ".", "$", "es", ".", "') '", ";", "if", "(", "!", "empty", "(", "$", "props", ")", ")", "{", "//print_r($q);", "//exit();", "}", "return", "$", "q", ";", "}" ]
Add a relationship path First it try to merge nodes, id's are taken from the already node generated ids Trying to MERGE the nodes could add payload to the query, but as depending of the amount of nodes and relationships creations, the queries may be splitted in multiple statements to avoid dealing with too large bodies in http requests, that's why we first need to get the start and end nodes @param $start @param $end @param $type @param array $properties @return string
[ "Add", "a", "relationship", "path", "First", "it", "try", "to", "merge", "nodes", "id", "s", "are", "taken", "from", "the", "already", "node", "generated", "ids" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Helper/CypherHelper.php#L98-L139
227,033
neoxygen/neo4j-neogen
src/Schema/Property.php
Property.setProvider
public function setProvider($provider, array $arguments = array()) { if (null === $provider || '' === $provider) { throw new \InvalidArgumentException('A property faker provider name can not be empty'); } $this->provider = $provider; if (!empty($arguments)) { $this->arguments = $arguments; } }
php
public function setProvider($provider, array $arguments = array()) { if (null === $provider || '' === $provider) { throw new \InvalidArgumentException('A property faker provider name can not be empty'); } $this->provider = $provider; if (!empty($arguments)) { $this->arguments = $arguments; } }
[ "public", "function", "setProvider", "(", "$", "provider", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "if", "(", "null", "===", "$", "provider", "||", "''", "===", "$", "provider", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A property faker provider name can not be empty'", ")", ";", "}", "$", "this", "->", "provider", "=", "$", "provider", ";", "if", "(", "!", "empty", "(", "$", "arguments", ")", ")", "{", "$", "this", "->", "arguments", "=", "$", "arguments", ";", "}", "}" ]
Sets the property faker provider to use @param string $provider The property faker provider @param array $arguments The property faker provider arguments (optional)
[ "Sets", "the", "property", "faker", "provider", "to", "use" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Property.php#L57-L68
227,034
hscstudio/yii2-heart
modules/admin/components/DbManager.php
DbManager.getChildrenRecursive
protected function getChildrenRecursive($name, &$result) { if (isset($this->_children[$name])) { foreach ($this->_children[$name] as $child) { $result[$child] = true; $this->getChildrenRecursive($child, $result); } } }
php
protected function getChildrenRecursive($name, &$result) { if (isset($this->_children[$name])) { foreach ($this->_children[$name] as $child) { $result[$child] = true; $this->getChildrenRecursive($child, $result); } } }
[ "protected", "function", "getChildrenRecursive", "(", "$", "name", ",", "&", "$", "result", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_children", "[", "$", "name", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_children", "[", "$", "name", "]", "as", "$", "child", ")", "{", "$", "result", "[", "$", "child", "]", "=", "true", ";", "$", "this", "->", "getChildrenRecursive", "(", "$", "child", ",", "$", "result", ")", ";", "}", "}", "}" ]
Recursively finds all children and grand children of the specified item. @param string $name the name of the item whose children are to be looked for. @param array $result the children and grand children (in array keys)
[ "Recursively", "finds", "all", "children", "and", "grand", "children", "of", "the", "specified", "item", "." ]
7c54c7794c5045c0beb1d8bd70b287278eddbeee
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/modules/admin/components/DbManager.php#L471-L479
227,035
javanile/moldable
src/Model/SchemaApi.php
SchemaApi.applySchema
public static function applySchema() { //if (static::isAdamantTable()) { // return; //} $attribute = 'apply-schema'; if (static::hasClassAttribute($attribute)) { return true; } $database = static::getDatabase(); $schema = static::getSchema(); if (!$schema) { static::error('class', 'empty schema not allowed'); } $table = static::getTable(); $queries = $database->applyTable($table, $schema, false); static::setClassAttribute($attribute, microtime(true)); return $queries; }
php
public static function applySchema() { //if (static::isAdamantTable()) { // return; //} $attribute = 'apply-schema'; if (static::hasClassAttribute($attribute)) { return true; } $database = static::getDatabase(); $schema = static::getSchema(); if (!$schema) { static::error('class', 'empty schema not allowed'); } $table = static::getTable(); $queries = $database->applyTable($table, $schema, false); static::setClassAttribute($attribute, microtime(true)); return $queries; }
[ "public", "static", "function", "applySchema", "(", ")", "{", "//if (static::isAdamantTable()) {", "// return;", "//}", "$", "attribute", "=", "'apply-schema'", ";", "if", "(", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "return", "true", ";", "}", "$", "database", "=", "static", "::", "getDatabase", "(", ")", ";", "$", "schema", "=", "static", "::", "getSchema", "(", ")", ";", "if", "(", "!", "$", "schema", ")", "{", "static", "::", "error", "(", "'class'", ",", "'empty schema not allowed'", ")", ";", "}", "$", "table", "=", "static", "::", "getTable", "(", ")", ";", "$", "queries", "=", "$", "database", "->", "applyTable", "(", "$", "table", ",", "$", "schema", ",", "false", ")", ";", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "microtime", "(", "true", ")", ")", ";", "return", "$", "queries", ";", "}" ]
Apply schema model related. @return type
[ "Apply", "schema", "model", "related", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/SchemaApi.php#L22-L49
227,036
javanile/moldable
src/Model/SchemaApi.php
SchemaApi.getDatabase
public static function getDatabase() { $attribute = 'database'; if (!static::hasClassAttribute($attribute)) { $database = Database::getDefault(); if (!$database) { $error = static::error('connection', 'database not found', 'required-for', 6); switch (static::getClassConfig('error-mode')) { case 'silent': break; case 'exception': throw new Exception($error); default: trigger_error($error, E_USER_ERROR); } } static::setClassAttribute($attribute, $database); } return static::getClassAttribute($attribute); }
php
public static function getDatabase() { $attribute = 'database'; if (!static::hasClassAttribute($attribute)) { $database = Database::getDefault(); if (!$database) { $error = static::error('connection', 'database not found', 'required-for', 6); switch (static::getClassConfig('error-mode')) { case 'silent': break; case 'exception': throw new Exception($error); default: trigger_error($error, E_USER_ERROR); } } static::setClassAttribute($attribute, $database); } return static::getClassAttribute($attribute); }
[ "public", "static", "function", "getDatabase", "(", ")", "{", "$", "attribute", "=", "'database'", ";", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "database", "=", "Database", "::", "getDefault", "(", ")", ";", "if", "(", "!", "$", "database", ")", "{", "$", "error", "=", "static", "::", "error", "(", "'connection'", ",", "'database not found'", ",", "'required-for'", ",", "6", ")", ";", "switch", "(", "static", "::", "getClassConfig", "(", "'error-mode'", ")", ")", "{", "case", "'silent'", ":", "break", ";", "case", "'exception'", ":", "throw", "new", "Exception", "(", "$", "error", ")", ";", "default", ":", "trigger_error", "(", "$", "error", ",", "E_USER_ERROR", ")", ";", "}", "}", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "database", ")", ";", "}", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Retriece linked database or default. @return type
[ "Retriece", "linked", "database", "or", "default", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/SchemaApi.php#L170-L190
227,037
4rthem/graphql-mapper
src/Mapping/MappingNormalizer.php
MappingNormalizer.normalize
public function normalize(SchemaContainer $schemaContainer) { $this->fixNames($schemaContainer); $fields = []; foreach ($schemaContainer->getTypes() as $type) { $fields = array_merge($fields, $type->getFields()); } if (null !== $querySchema = $schemaContainer->getQuerySchema()) { $fields = array_merge($fields, $querySchema->getFields()); } if (null !== $mutationSchema = $schemaContainer->getMutationSchema()) { $fields = array_merge($fields, $mutationSchema->getFields()); } foreach ($fields as $field) { $this->mergeResolveConfig($schemaContainer, $field); } }
php
public function normalize(SchemaContainer $schemaContainer) { $this->fixNames($schemaContainer); $fields = []; foreach ($schemaContainer->getTypes() as $type) { $fields = array_merge($fields, $type->getFields()); } if (null !== $querySchema = $schemaContainer->getQuerySchema()) { $fields = array_merge($fields, $querySchema->getFields()); } if (null !== $mutationSchema = $schemaContainer->getMutationSchema()) { $fields = array_merge($fields, $mutationSchema->getFields()); } foreach ($fields as $field) { $this->mergeResolveConfig($schemaContainer, $field); } }
[ "public", "function", "normalize", "(", "SchemaContainer", "$", "schemaContainer", ")", "{", "$", "this", "->", "fixNames", "(", "$", "schemaContainer", ")", ";", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$", "schemaContainer", "->", "getTypes", "(", ")", "as", "$", "type", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "$", "type", "->", "getFields", "(", ")", ")", ";", "}", "if", "(", "null", "!==", "$", "querySchema", "=", "$", "schemaContainer", "->", "getQuerySchema", "(", ")", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "$", "querySchema", "->", "getFields", "(", ")", ")", ";", "}", "if", "(", "null", "!==", "$", "mutationSchema", "=", "$", "schemaContainer", "->", "getMutationSchema", "(", ")", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "$", "mutationSchema", "->", "getFields", "(", ")", ")", ";", "}", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "mergeResolveConfig", "(", "$", "schemaContainer", ",", "$", "field", ")", ";", "}", "}" ]
Validates mapping and fixes missing definitions @param SchemaContainer $schemaContainer
[ "Validates", "mapping", "and", "fixes", "missing", "definitions" ]
f2dc8d054e25cd6c53ec8ac6cefc9c4bcf89fcaf
https://github.com/4rthem/graphql-mapper/blob/f2dc8d054e25cd6c53ec8ac6cefc9c4bcf89fcaf/src/Mapping/MappingNormalizer.php#L14-L35
227,038
4rthem/graphql-mapper
src/Mapping/MappingNormalizer.php
MappingNormalizer.mergeResolveConfig
private function mergeResolveConfig(SchemaContainer $schemaContainer, Field $field) { $typeName = TypeParser::getFinalType($field->getType()); if ($schemaContainer->hasType($typeName)) { $typeConfig = $schemaContainer ->getType($typeName) ->getResolveConfig(); } elseif ($schemaContainer->hasInterface($typeName)) { $typeConfig = $schemaContainer ->getInterface($typeName) ->getResolveConfig(); } else { return; } $field->mergeResolveConfig($typeConfig); }
php
private function mergeResolveConfig(SchemaContainer $schemaContainer, Field $field) { $typeName = TypeParser::getFinalType($field->getType()); if ($schemaContainer->hasType($typeName)) { $typeConfig = $schemaContainer ->getType($typeName) ->getResolveConfig(); } elseif ($schemaContainer->hasInterface($typeName)) { $typeConfig = $schemaContainer ->getInterface($typeName) ->getResolveConfig(); } else { return; } $field->mergeResolveConfig($typeConfig); }
[ "private", "function", "mergeResolveConfig", "(", "SchemaContainer", "$", "schemaContainer", ",", "Field", "$", "field", ")", "{", "$", "typeName", "=", "TypeParser", "::", "getFinalType", "(", "$", "field", "->", "getType", "(", ")", ")", ";", "if", "(", "$", "schemaContainer", "->", "hasType", "(", "$", "typeName", ")", ")", "{", "$", "typeConfig", "=", "$", "schemaContainer", "->", "getType", "(", "$", "typeName", ")", "->", "getResolveConfig", "(", ")", ";", "}", "elseif", "(", "$", "schemaContainer", "->", "hasInterface", "(", "$", "typeName", ")", ")", "{", "$", "typeConfig", "=", "$", "schemaContainer", "->", "getInterface", "(", "$", "typeName", ")", "->", "getResolveConfig", "(", ")", ";", "}", "else", "{", "return", ";", "}", "$", "field", "->", "mergeResolveConfig", "(", "$", "typeConfig", ")", ";", "}" ]
Apply the resolve config of types that are used by query fields @param SchemaContainer $schemaContainer @param Field $field
[ "Apply", "the", "resolve", "config", "of", "types", "that", "are", "used", "by", "query", "fields" ]
f2dc8d054e25cd6c53ec8ac6cefc9c4bcf89fcaf
https://github.com/4rthem/graphql-mapper/blob/f2dc8d054e25cd6c53ec8ac6cefc9c4bcf89fcaf/src/Mapping/MappingNormalizer.php#L63-L80
227,039
middlewares/geolocation
src/Geolocation.php
Geolocation.getAddress
protected function getAddress(string $ip): Collection { return $this->provider->geocodeQuery(GeocodeQuery::create($ip)); }
php
protected function getAddress(string $ip): Collection { return $this->provider->geocodeQuery(GeocodeQuery::create($ip)); }
[ "protected", "function", "getAddress", "(", "string", "$", "ip", ")", ":", "Collection", "{", "return", "$", "this", "->", "provider", "->", "geocodeQuery", "(", "GeocodeQuery", "::", "create", "(", "$", "ip", ")", ")", ";", "}" ]
Get the address of an ip
[ "Get", "the", "address", "of", "an", "ip" ]
b8aa0af8b85efcab580b16da6a98fbbe70062df9
https://github.com/middlewares/geolocation/blob/b8aa0af8b85efcab580b16da6a98fbbe70062df9/src/Geolocation.php#L77-L80
227,040
middlewares/geolocation
src/Geolocation.php
Geolocation.getIp
private function getIp(ServerRequestInterface $request): string { $server = $request->getServerParams(); if ($this->ipAttribute !== null) { return $request->getAttribute($this->ipAttribute); } return isset($server['REMOTE_ADDR']) ? $server['REMOTE_ADDR'] : ''; }
php
private function getIp(ServerRequestInterface $request): string { $server = $request->getServerParams(); if ($this->ipAttribute !== null) { return $request->getAttribute($this->ipAttribute); } return isset($server['REMOTE_ADDR']) ? $server['REMOTE_ADDR'] : ''; }
[ "private", "function", "getIp", "(", "ServerRequestInterface", "$", "request", ")", ":", "string", "{", "$", "server", "=", "$", "request", "->", "getServerParams", "(", ")", ";", "if", "(", "$", "this", "->", "ipAttribute", "!==", "null", ")", "{", "return", "$", "request", "->", "getAttribute", "(", "$", "this", "->", "ipAttribute", ")", ";", "}", "return", "isset", "(", "$", "server", "[", "'REMOTE_ADDR'", "]", ")", "?", "$", "server", "[", "'REMOTE_ADDR'", "]", ":", "''", ";", "}" ]
Get the client ip.
[ "Get", "the", "client", "ip", "." ]
b8aa0af8b85efcab580b16da6a98fbbe70062df9
https://github.com/middlewares/geolocation/blob/b8aa0af8b85efcab580b16da6a98fbbe70062df9/src/Geolocation.php#L85-L94
227,041
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Example/FileStorage.php
GoogleSafeBrowsing_Example_FileStorage.addHashPrefixes
public function addHashPrefixes($prefixes, $list) { $listdir=$this->getListStorageDir($list); if(!is_dir($listdir)){ mkdir($listdir, 0777, true); } $new_prefixes=array_map('bin2hex',$prefixes); if(is_file($listdir.$this->prefixes_filename)){ $existing_prefixes=explode("\n",file_get_contents($listdir.$this->prefixes_filename)); foreach($new_prefixes as $new_prefix){ $existing_prefixes[]=$new_prefix; } sort($existing_prefixes,SORT_STRING); file_put_contents($listdir.'prefixes', implode("\n",$existing_prefixes)); }else{ sort($new_prefixes,SORT_STRING); file_put_contents($listdir.'prefixes', implode("\n",$new_prefixes)); } $this->debugLog('addHashPrefixes() added '.count($new_prefixes).' prefixes to list '.$list); }
php
public function addHashPrefixes($prefixes, $list) { $listdir=$this->getListStorageDir($list); if(!is_dir($listdir)){ mkdir($listdir, 0777, true); } $new_prefixes=array_map('bin2hex',$prefixes); if(is_file($listdir.$this->prefixes_filename)){ $existing_prefixes=explode("\n",file_get_contents($listdir.$this->prefixes_filename)); foreach($new_prefixes as $new_prefix){ $existing_prefixes[]=$new_prefix; } sort($existing_prefixes,SORT_STRING); file_put_contents($listdir.'prefixes', implode("\n",$existing_prefixes)); }else{ sort($new_prefixes,SORT_STRING); file_put_contents($listdir.'prefixes', implode("\n",$new_prefixes)); } $this->debugLog('addHashPrefixes() added '.count($new_prefixes).' prefixes to list '.$list); }
[ "public", "function", "addHashPrefixes", "(", "$", "prefixes", ",", "$", "list", ")", "{", "$", "listdir", "=", "$", "this", "->", "getListStorageDir", "(", "$", "list", ")", ";", "if", "(", "!", "is_dir", "(", "$", "listdir", ")", ")", "{", "mkdir", "(", "$", "listdir", ",", "0777", ",", "true", ")", ";", "}", "$", "new_prefixes", "=", "array_map", "(", "'bin2hex'", ",", "$", "prefixes", ")", ";", "if", "(", "is_file", "(", "$", "listdir", ".", "$", "this", "->", "prefixes_filename", ")", ")", "{", "$", "existing_prefixes", "=", "explode", "(", "\"\\n\"", ",", "file_get_contents", "(", "$", "listdir", ".", "$", "this", "->", "prefixes_filename", ")", ")", ";", "foreach", "(", "$", "new_prefixes", "as", "$", "new_prefix", ")", "{", "$", "existing_prefixes", "[", "]", "=", "$", "new_prefix", ";", "}", "sort", "(", "$", "existing_prefixes", ",", "SORT_STRING", ")", ";", "file_put_contents", "(", "$", "listdir", ".", "'prefixes'", ",", "implode", "(", "\"\\n\"", ",", "$", "existing_prefixes", ")", ")", ";", "}", "else", "{", "sort", "(", "$", "new_prefixes", ",", "SORT_STRING", ")", ";", "file_put_contents", "(", "$", "listdir", ".", "'prefixes'", ",", "implode", "(", "\"\\n\"", ",", "$", "new_prefixes", ")", ")", ";", "}", "$", "this", "->", "debugLog", "(", "'addHashPrefixes() added '", ".", "count", "(", "$", "new_prefixes", ")", ".", "' prefixes to list '", ".", "$", "list", ")", ";", "}" ]
Adds one or more hashprefixes @param string[] $prefixes @param string $list
[ "Adds", "one", "or", "more", "hashprefixes" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Example/FileStorage.php#L124-L143
227,042
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Example/FileStorage.php
GoogleSafeBrowsing_Example_FileStorage.removeHashPrefixesFromList
public function removeHashPrefixesFromList($list) { $this->debugLog('removeHashPrefixesFromList() list '.$list); $listdir=$this->getListStorageDir($list); if(!$listdir || strlen($listdir)<10){ $this->warningLog('removeHashPrefixesFromList() invalid list directory for list '.$list); return; } if(!is_dir($listdir)){ $this->debugLog('removeHashPrefixesFromList() no list directory for list '.$list); return; } if(!is_file($listdir.$this->prefixes_filename)){ $this->debugLog('removeHashPrefixesFromList() no prefix file for list '.$list); return; } unlink($listdir.$this->prefixes_filename); }
php
public function removeHashPrefixesFromList($list) { $this->debugLog('removeHashPrefixesFromList() list '.$list); $listdir=$this->getListStorageDir($list); if(!$listdir || strlen($listdir)<10){ $this->warningLog('removeHashPrefixesFromList() invalid list directory for list '.$list); return; } if(!is_dir($listdir)){ $this->debugLog('removeHashPrefixesFromList() no list directory for list '.$list); return; } if(!is_file($listdir.$this->prefixes_filename)){ $this->debugLog('removeHashPrefixesFromList() no prefix file for list '.$list); return; } unlink($listdir.$this->prefixes_filename); }
[ "public", "function", "removeHashPrefixesFromList", "(", "$", "list", ")", "{", "$", "this", "->", "debugLog", "(", "'removeHashPrefixesFromList() list '", ".", "$", "list", ")", ";", "$", "listdir", "=", "$", "this", "->", "getListStorageDir", "(", "$", "list", ")", ";", "if", "(", "!", "$", "listdir", "||", "strlen", "(", "$", "listdir", ")", "<", "10", ")", "{", "$", "this", "->", "warningLog", "(", "'removeHashPrefixesFromList() invalid list directory for list '", ".", "$", "list", ")", ";", "return", ";", "}", "if", "(", "!", "is_dir", "(", "$", "listdir", ")", ")", "{", "$", "this", "->", "debugLog", "(", "'removeHashPrefixesFromList() no list directory for list '", ".", "$", "list", ")", ";", "return", ";", "}", "if", "(", "!", "is_file", "(", "$", "listdir", ".", "$", "this", "->", "prefixes_filename", ")", ")", "{", "$", "this", "->", "debugLog", "(", "'removeHashPrefixesFromList() no prefix file for list '", ".", "$", "list", ")", ";", "return", ";", "}", "unlink", "(", "$", "listdir", ".", "$", "this", "->", "prefixes_filename", ")", ";", "}" ]
Remove all prefixes of this list @param string $list
[ "Remove", "all", "prefixes", "of", "this", "list" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Example/FileStorage.php#L187-L204
227,043
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Example/FileStorage.php
GoogleSafeBrowsing_Example_FileStorage.setUpdaterState
public function setUpdaterState($timestamp, $errorcount) { $this->debugLog('setUpdaterState() called ('.$timestamp.', '.$errorcount.')'); file_put_contents($this->storage_dir.$this->nextruntime_filename, $timestamp); file_put_contents($this->storage_dir.$this->errorcount_filename, $errorcount); }
php
public function setUpdaterState($timestamp, $errorcount) { $this->debugLog('setUpdaterState() called ('.$timestamp.', '.$errorcount.')'); file_put_contents($this->storage_dir.$this->nextruntime_filename, $timestamp); file_put_contents($this->storage_dir.$this->errorcount_filename, $errorcount); }
[ "public", "function", "setUpdaterState", "(", "$", "timestamp", ",", "$", "errorcount", ")", "{", "$", "this", "->", "debugLog", "(", "'setUpdaterState() called ('", ".", "$", "timestamp", ".", "', '", ".", "$", "errorcount", ".", "')'", ")", ";", "file_put_contents", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "nextruntime_filename", ",", "$", "timestamp", ")", ";", "file_put_contents", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "errorcount_filename", ",", "$", "errorcount", ")", ";", "}" ]
Store the nextrun timestamp and errorcount @param int $timestamp nextrun timestamp @param int $errorcount how many consecutive errors did we have (if any)
[ "Store", "the", "nextrun", "timestamp", "and", "errorcount" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Example/FileStorage.php#L271-L276
227,044
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Example/FileStorage.php
GoogleSafeBrowsing_Example_FileStorage.getNextRunTimestamp
public function getNextRunTimestamp() { if(is_file($this->storage_dir.$this->nextruntime_filename)){ return (int)file_get_contents($this->storage_dir.$this->nextruntime_filename); }else{ return time(); } }
php
public function getNextRunTimestamp() { if(is_file($this->storage_dir.$this->nextruntime_filename)){ return (int)file_get_contents($this->storage_dir.$this->nextruntime_filename); }else{ return time(); } }
[ "public", "function", "getNextRunTimestamp", "(", ")", "{", "if", "(", "is_file", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "nextruntime_filename", ")", ")", "{", "return", "(", "int", ")", "file_get_contents", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "nextruntime_filename", ")", ";", "}", "else", "{", "return", "time", "(", ")", ";", "}", "}" ]
Retrieve the nextrun timestamp @return int
[ "Retrieve", "the", "nextrun", "timestamp" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Example/FileStorage.php#L283-L290
227,045
web2all/safebrowsingv4
src/GoogleSafeBrowsing/Example/FileStorage.php
GoogleSafeBrowsing_Example_FileStorage.isListedInCache
public function isListedInCache($lookup_hash) { // by default no match in cache $matched_listnames=null; $hex_lookup_hash=bin2hex($lookup_hash); foreach($this->getLists() as $listname => $liststate){ $listdir=$this->getListStorageDir($listname); if(!is_dir($listdir)){ $this->debugLog('isListedInCache() no list directory found for list '.$listname); continue; } if(!is_file($listdir.$this->fullhash_cache_filename)){ //$this->debugLog('isListedInCache() no fullcache file found for list '.$listname); // no cache file, nothing to look up continue; } $cached_hashes=explode("\n",file_get_contents($listdir.$this->fullhash_cache_filename)); foreach($cached_hashes as $cache_entry){ $cache_parts=explode(';',$cache_entry); // 0:prefix;1:fullhash;2:expire_timestamp if($cache_parts[0]===substr($hex_lookup_hash,0,strlen($cache_parts[0]))){ // ok prefix hash match if(is_null($matched_listnames)){ $matched_listnames=array(); } // test against full hash if($cache_parts[1]===$hex_lookup_hash){ // full hash match if($cache_parts[2]<time()){ // expired full match must result in cache-miss so it gets re-fetched return null; } $matched_listnames[]=$listname; // we can skip to the next list continue(2); } } } } if(is_null($matched_listnames)){ // we still have a complete cache miss, as a last resort // check if the prefix is in the negative cache file if(is_file($this->storage_dir.$this->fullhash_cache_filename)){ // negative cache file $negative_prefixes=explode("\n",file_get_contents($this->storage_dir.$this->fullhash_cache_filename)); foreach($negative_prefixes as $cache_entry){ $cache_parts=explode(';',$cache_entry); // 0:prefix;1:expire_timestamp if($cache_parts[0]===substr($hex_lookup_hash,0,strlen($cache_parts[0]))){ // ok prefix hash match if(is_null($matched_listnames)){ $matched_listnames=array(); } if($cache_parts[1]<time()){ // expired prefix match must result in cache-miss so it gets re-fetched return null; } } } } } return $matched_listnames; }
php
public function isListedInCache($lookup_hash) { // by default no match in cache $matched_listnames=null; $hex_lookup_hash=bin2hex($lookup_hash); foreach($this->getLists() as $listname => $liststate){ $listdir=$this->getListStorageDir($listname); if(!is_dir($listdir)){ $this->debugLog('isListedInCache() no list directory found for list '.$listname); continue; } if(!is_file($listdir.$this->fullhash_cache_filename)){ //$this->debugLog('isListedInCache() no fullcache file found for list '.$listname); // no cache file, nothing to look up continue; } $cached_hashes=explode("\n",file_get_contents($listdir.$this->fullhash_cache_filename)); foreach($cached_hashes as $cache_entry){ $cache_parts=explode(';',$cache_entry); // 0:prefix;1:fullhash;2:expire_timestamp if($cache_parts[0]===substr($hex_lookup_hash,0,strlen($cache_parts[0]))){ // ok prefix hash match if(is_null($matched_listnames)){ $matched_listnames=array(); } // test against full hash if($cache_parts[1]===$hex_lookup_hash){ // full hash match if($cache_parts[2]<time()){ // expired full match must result in cache-miss so it gets re-fetched return null; } $matched_listnames[]=$listname; // we can skip to the next list continue(2); } } } } if(is_null($matched_listnames)){ // we still have a complete cache miss, as a last resort // check if the prefix is in the negative cache file if(is_file($this->storage_dir.$this->fullhash_cache_filename)){ // negative cache file $negative_prefixes=explode("\n",file_get_contents($this->storage_dir.$this->fullhash_cache_filename)); foreach($negative_prefixes as $cache_entry){ $cache_parts=explode(';',$cache_entry); // 0:prefix;1:expire_timestamp if($cache_parts[0]===substr($hex_lookup_hash,0,strlen($cache_parts[0]))){ // ok prefix hash match if(is_null($matched_listnames)){ $matched_listnames=array(); } if($cache_parts[1]<time()){ // expired prefix match must result in cache-miss so it gets re-fetched return null; } } } } } return $matched_listnames; }
[ "public", "function", "isListedInCache", "(", "$", "lookup_hash", ")", "{", "// by default no match in cache", "$", "matched_listnames", "=", "null", ";", "$", "hex_lookup_hash", "=", "bin2hex", "(", "$", "lookup_hash", ")", ";", "foreach", "(", "$", "this", "->", "getLists", "(", ")", "as", "$", "listname", "=>", "$", "liststate", ")", "{", "$", "listdir", "=", "$", "this", "->", "getListStorageDir", "(", "$", "listname", ")", ";", "if", "(", "!", "is_dir", "(", "$", "listdir", ")", ")", "{", "$", "this", "->", "debugLog", "(", "'isListedInCache() no list directory found for list '", ".", "$", "listname", ")", ";", "continue", ";", "}", "if", "(", "!", "is_file", "(", "$", "listdir", ".", "$", "this", "->", "fullhash_cache_filename", ")", ")", "{", "//$this->debugLog('isListedInCache() no fullcache file found for list '.$listname);", "// no cache file, nothing to look up", "continue", ";", "}", "$", "cached_hashes", "=", "explode", "(", "\"\\n\"", ",", "file_get_contents", "(", "$", "listdir", ".", "$", "this", "->", "fullhash_cache_filename", ")", ")", ";", "foreach", "(", "$", "cached_hashes", "as", "$", "cache_entry", ")", "{", "$", "cache_parts", "=", "explode", "(", "';'", ",", "$", "cache_entry", ")", ";", "// 0:prefix;1:fullhash;2:expire_timestamp", "if", "(", "$", "cache_parts", "[", "0", "]", "===", "substr", "(", "$", "hex_lookup_hash", ",", "0", ",", "strlen", "(", "$", "cache_parts", "[", "0", "]", ")", ")", ")", "{", "// ok prefix hash match ", "if", "(", "is_null", "(", "$", "matched_listnames", ")", ")", "{", "$", "matched_listnames", "=", "array", "(", ")", ";", "}", "// test against full hash", "if", "(", "$", "cache_parts", "[", "1", "]", "===", "$", "hex_lookup_hash", ")", "{", "// full hash match", "if", "(", "$", "cache_parts", "[", "2", "]", "<", "time", "(", ")", ")", "{", "// expired full match must result in cache-miss so it gets re-fetched", "return", "null", ";", "}", "$", "matched_listnames", "[", "]", "=", "$", "listname", ";", "// we can skip to the next list", "continue", "(", "2", ")", ";", "}", "}", "}", "}", "if", "(", "is_null", "(", "$", "matched_listnames", ")", ")", "{", "// we still have a complete cache miss, as a last resort", "// check if the prefix is in the negative cache file", "if", "(", "is_file", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "fullhash_cache_filename", ")", ")", "{", "// negative cache file", "$", "negative_prefixes", "=", "explode", "(", "\"\\n\"", ",", "file_get_contents", "(", "$", "this", "->", "storage_dir", ".", "$", "this", "->", "fullhash_cache_filename", ")", ")", ";", "foreach", "(", "$", "negative_prefixes", "as", "$", "cache_entry", ")", "{", "$", "cache_parts", "=", "explode", "(", "';'", ",", "$", "cache_entry", ")", ";", "// 0:prefix;1:expire_timestamp", "if", "(", "$", "cache_parts", "[", "0", "]", "===", "substr", "(", "$", "hex_lookup_hash", ",", "0", ",", "strlen", "(", "$", "cache_parts", "[", "0", "]", ")", ")", ")", "{", "// ok prefix hash match ", "if", "(", "is_null", "(", "$", "matched_listnames", ")", ")", "{", "$", "matched_listnames", "=", "array", "(", ")", ";", "}", "if", "(", "$", "cache_parts", "[", "1", "]", "<", "time", "(", ")", ")", "{", "// expired prefix match must result in cache-miss so it gets re-fetched", "return", "null", ";", "}", "}", "}", "}", "}", "return", "$", "matched_listnames", ";", "}" ]
Lookup listnames for the given url hash Only do this for hashes for which a prefix was found! @param string $lookup_hash @return string[] list names or null if not cached
[ "Lookup", "listnames", "for", "the", "given", "url", "hash" ]
e506341efa8d919974c8eb362987bc1e2f398983
https://github.com/web2all/safebrowsingv4/blob/e506341efa8d919974c8eb362987bc1e2f398983/src/GoogleSafeBrowsing/Example/FileStorage.php#L509-L576
227,046
javanile/moldable
src/Database/Socket/PdoSocket.php
PdoSocket.connect
private function connect() { $port = isset($this->_args['port']) && $this->_args['port'] ? $this->_args['port'] : 3306; $dsn = "mysql:host={$this->_args['host']};port={$port};dbname={$this->_args['dbname']}"; $username = $this->_args['username']; $password = $this->_args['password']; // TODO: Move to use the follow: PDO::ATTR_EMULATE_PREPARES to 'false' // For security reason $options = [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']; /*\ * The latter can be fixed by turning off emulation * and using the DSN charset attribute instead of SET NAMES. * The former is tricky, because you have no concept for safely * dealing with identifiers (they're just dumped straight into the query). * One possible approach would be to wrap all identifiers in backticks * while escaping all backticks within the identifiers (through doubling). * Whether this actually works in all cases is an open question, though. \*/ try { $this->_pdo = new PDO($dsn, $username, $password, $options); } catch (PDOException $ex) { $this->_database->error('connect', $ex); } $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
php
private function connect() { $port = isset($this->_args['port']) && $this->_args['port'] ? $this->_args['port'] : 3306; $dsn = "mysql:host={$this->_args['host']};port={$port};dbname={$this->_args['dbname']}"; $username = $this->_args['username']; $password = $this->_args['password']; // TODO: Move to use the follow: PDO::ATTR_EMULATE_PREPARES to 'false' // For security reason $options = [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']; /*\ * The latter can be fixed by turning off emulation * and using the DSN charset attribute instead of SET NAMES. * The former is tricky, because you have no concept for safely * dealing with identifiers (they're just dumped straight into the query). * One possible approach would be to wrap all identifiers in backticks * while escaping all backticks within the identifiers (through doubling). * Whether this actually works in all cases is an open question, though. \*/ try { $this->_pdo = new PDO($dsn, $username, $password, $options); } catch (PDOException $ex) { $this->_database->error('connect', $ex); } $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
[ "private", "function", "connect", "(", ")", "{", "$", "port", "=", "isset", "(", "$", "this", "->", "_args", "[", "'port'", "]", ")", "&&", "$", "this", "->", "_args", "[", "'port'", "]", "?", "$", "this", "->", "_args", "[", "'port'", "]", ":", "3306", ";", "$", "dsn", "=", "\"mysql:host={$this->_args['host']};port={$port};dbname={$this->_args['dbname']}\"", ";", "$", "username", "=", "$", "this", "->", "_args", "[", "'username'", "]", ";", "$", "password", "=", "$", "this", "->", "_args", "[", "'password'", "]", ";", "// TODO: Move to use the follow: PDO::ATTR_EMULATE_PREPARES to 'false'", "// For security reason", "$", "options", "=", "[", "PDO", "::", "MYSQL_ATTR_INIT_COMMAND", "=>", "'SET NAMES utf8'", "]", ";", "/*\\\n * The latter can be fixed by turning off emulation\n * and using the DSN charset attribute instead of SET NAMES.\n * The former is tricky, because you have no concept for safely\n * dealing with identifiers (they're just dumped straight into the query).\n * One possible approach would be to wrap all identifiers in backticks\n * while escaping all backticks within the identifiers (through doubling).\n * Whether this actually works in all cases is an open question, though.\n \\*/", "try", "{", "$", "this", "->", "_pdo", "=", "new", "PDO", "(", "$", "dsn", ",", "$", "username", ",", "$", "password", ",", "$", "options", ")", ";", "}", "catch", "(", "PDOException", "$", "ex", ")", "{", "$", "this", "->", "_database", "->", "error", "(", "'connect'", ",", "$", "ex", ")", ";", "}", "$", "this", "->", "_pdo", "->", "setAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ",", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "}" ]
Start PDO connection.
[ "Start", "PDO", "connection", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/Socket/PdoSocket.php#L81-L109
227,047
javanile/moldable
src/Database/Socket/PdoSocket.php
PdoSocket.getColumn
public function getColumn($sql, $params = null) { $stmt = $this->execute($sql, $params); $column = []; while ($row = $stmt->fetch()) { $column[] = $row[0]; } return $column; }
php
public function getColumn($sql, $params = null) { $stmt = $this->execute($sql, $params); $column = []; while ($row = $stmt->fetch()) { $column[] = $row[0]; } return $column; }
[ "public", "function", "getColumn", "(", "$", "sql", ",", "$", "params", "=", "null", ")", "{", "$", "stmt", "=", "$", "this", "->", "execute", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "column", "=", "[", "]", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", ")", ")", "{", "$", "column", "[", "]", "=", "$", "row", "[", "0", "]", ";", "}", "return", "$", "column", ";", "}" ]
Get single column elements. @param type $sql @param null|mixed $params @return type
[ "Get", "single", "column", "elements", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/Socket/PdoSocket.php#L158-L168
227,048
javanile/moldable
src/Database/Socket/PdoSocket.php
PdoSocket.execute
public function execute($sql, $params = null) { $stmt = $this->_pdo->prepare($sql); if (is_array($params)) { foreach ($params as $token => $value) { $stmt->bindValue($token, $value); } } try { $stmt->execute(); } catch (PDOException $exception) { $this->_database->error('execute', $exception); } return $stmt; }
php
public function execute($sql, $params = null) { $stmt = $this->_pdo->prepare($sql); if (is_array($params)) { foreach ($params as $token => $value) { $stmt->bindValue($token, $value); } } try { $stmt->execute(); } catch (PDOException $exception) { $this->_database->error('execute', $exception); } return $stmt; }
[ "public", "function", "execute", "(", "$", "sql", ",", "$", "params", "=", "null", ")", "{", "$", "stmt", "=", "$", "this", "->", "_pdo", "->", "prepare", "(", "$", "sql", ")", ";", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "foreach", "(", "$", "params", "as", "$", "token", "=>", "$", "value", ")", "{", "$", "stmt", "->", "bindValue", "(", "$", "token", ",", "$", "value", ")", ";", "}", "}", "try", "{", "$", "stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "_database", "->", "error", "(", "'execute'", ",", "$", "exception", ")", ";", "}", "return", "$", "stmt", ";", "}" ]
Execute a SQL query on DB with binded values. @param mixed $sql @param null|mixed $params
[ "Execute", "a", "SQL", "query", "on", "DB", "with", "binded", "values", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/Socket/PdoSocket.php#L257-L274
227,049
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php
QueryBuilderProvider.getColumnFromName
private function getColumnFromName($name) { foreach ($this->columnConfiguration as $i => $col) { if ($col->getName() == $name) { return $col; } } // This exception should never happen. If it does, something is // wrong w/ the relationship between searchable columns and the // configuration. throw new DatatableException("A requested column was not found in the columnConfiguration."); }
php
private function getColumnFromName($name) { foreach ($this->columnConfiguration as $i => $col) { if ($col->getName() == $name) { return $col; } } // This exception should never happen. If it does, something is // wrong w/ the relationship between searchable columns and the // configuration. throw new DatatableException("A requested column was not found in the columnConfiguration."); }
[ "private", "function", "getColumnFromName", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "columnConfiguration", "as", "$", "i", "=>", "$", "col", ")", "{", "if", "(", "$", "col", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", "$", "col", ";", "}", "}", "// This exception should never happen. If it does, something is", "// wrong w/ the relationship between searchable columns and the", "// configuration.", "throw", "new", "DatatableException", "(", "\"A requested column was not found in the columnConfiguration.\"", ")", ";", "}" ]
Get the requested column configuration from the name of a column @param string $name @return ColumnConfiguration @throws DatatableException when a column is not found
[ "Get", "the", "requested", "column", "configuration", "from", "the", "name", "of", "a", "column" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php#L203-L215
227,050
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php
QueryBuilderProvider.compileColumnNames
private function compileColumnNames() { $columns = []; foreach($this->columnConfiguration as $column) { $columns[] = $column->getName(); } return $columns; }
php
private function compileColumnNames() { $columns = []; foreach($this->columnConfiguration as $column) { $columns[] = $column->getName(); } return $columns; }
[ "private", "function", "compileColumnNames", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "columnConfiguration", "as", "$", "column", ")", "{", "$", "columns", "[", "]", "=", "$", "column", "->", "getName", "(", ")", ";", "}", "return", "$", "columns", ";", "}" ]
Get a list of all the column names for the SELECT query.
[ "Get", "a", "list", "of", "all", "the", "column", "names", "for", "the", "SELECT", "query", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php#L220-L228
227,051
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php
QueryBuilderProvider.sortQuery
private function sortQuery() { if ($this->queryConfiguration->hasOrderColumn()) { $orderColumns = $this->queryConfiguration->orderColumns(); foreach($orderColumns as $order) { $this->query->orderBy($order->columnName(), $order->isDescending() ? 'desc' : 'asc'); } } }
php
private function sortQuery() { if ($this->queryConfiguration->hasOrderColumn()) { $orderColumns = $this->queryConfiguration->orderColumns(); foreach($orderColumns as $order) { $this->query->orderBy($order->columnName(), $order->isDescending() ? 'desc' : 'asc'); } } }
[ "private", "function", "sortQuery", "(", ")", "{", "if", "(", "$", "this", "->", "queryConfiguration", "->", "hasOrderColumn", "(", ")", ")", "{", "$", "orderColumns", "=", "$", "this", "->", "queryConfiguration", "->", "orderColumns", "(", ")", ";", "foreach", "(", "$", "orderColumns", "as", "$", "order", ")", "{", "$", "this", "->", "query", "->", "orderBy", "(", "$", "order", "->", "columnName", "(", ")", ",", "$", "order", "->", "isDescending", "(", ")", "?", "'desc'", ":", "'asc'", ")", ";", "}", "}", "}" ]
Will sort the query based on the given datatable query configuration.
[ "Will", "sort", "the", "query", "based", "on", "the", "given", "datatable", "query", "configuration", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php#L233-L242
227,052
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php
QueryBuilderProvider.limitQuery
private function limitQuery() { $this->query->skip($this->queryConfiguration->start()); $this->query->limit($this->queryConfiguration->length()); }
php
private function limitQuery() { $this->query->skip($this->queryConfiguration->start()); $this->query->limit($this->queryConfiguration->length()); }
[ "private", "function", "limitQuery", "(", ")", "{", "$", "this", "->", "query", "->", "skip", "(", "$", "this", "->", "queryConfiguration", "->", "start", "(", ")", ")", ";", "$", "this", "->", "query", "->", "limit", "(", "$", "this", "->", "queryConfiguration", "->", "length", "(", ")", ")", ";", "}" ]
Will limit a query based on the start and length given
[ "Will", "limit", "a", "query", "based", "on", "the", "start", "and", "length", "given" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/QueryBuilderProvider.php#L247-L251
227,053
BootstrapCMS/Credentials
src/Presenters/UserPresenter.php
UserPresenter.securityHistory
public function securityHistory() { $history = $this->wrappedObject->security()->get(); $history->each(function ($item) { $item->security = true; }); return $this->presenter->decorate($history); }
php
public function securityHistory() { $history = $this->wrappedObject->security()->get(); $history->each(function ($item) { $item->security = true; }); return $this->presenter->decorate($history); }
[ "public", "function", "securityHistory", "(", ")", "{", "$", "history", "=", "$", "this", "->", "wrappedObject", "->", "security", "(", ")", "->", "get", "(", ")", ";", "$", "history", "->", "each", "(", "function", "(", "$", "item", ")", "{", "$", "item", "->", "security", "=", "true", ";", "}", ")", ";", "return", "$", "this", "->", "presenter", "->", "decorate", "(", "$", "history", ")", ";", "}" ]
Get the user's security history. @return \Illuminate\Database\Eloquent\Collection
[ "Get", "the", "user", "s", "security", "history", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Presenters/UserPresenter.php#L61-L70
227,054
BootstrapCMS/Credentials
src/Http/Controllers/RegistrationController.php
RegistrationController.postRegister
public function postRegister() { if (!Config::get('credentials.regallowed')) { return Redirect::route('account.register'); } $input = Binput::only(['first_name', 'last_name', 'email', 'password', 'password_confirmation']); $val = UserRepository::validate($input, array_keys($input)); if ($val->fails()) { return Redirect::route('account.register')->withInput()->withErrors($val->errors()); } $this->throttler->hit(); try { unset($input['password_confirmation']); $user = Credentials::register($input); if (!Config::get('credentials.activation')) { $mail = [ 'url' => URL::to(Config::get('credentials.home', '/')), 'email' => $user->getLogin(), 'subject' => Config::get('app.name').' - Welcome', ]; Mail::queue('credentials::emails.welcome', $mail, function ($message) use ($mail) { $message->to($mail['email'])->subject($mail['subject']); }); $user->attemptActivation($user->getActivationCode()); $user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return Redirect::to(Config::get('credentials.home', '/')) ->with('success', 'Your account has been created successfully. You may now login.'); } $code = $user->getActivationCode(); $mail = [ 'url' => URL::to(Config::get('credentials.home', '/')), 'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('app.name').' - Welcome', ]; Mail::queue('credentials::emails.welcome', $mail, function ($message) use ($mail) { $message->to($mail['email'])->subject($mail['subject']); }); return Redirect::to(Config::get('credentials.home', '/')) ->with('success', 'Your account has been created. Check your email for the confirmation link.'); } catch (UserExistsException $e) { return Redirect::route('account.register')->withInput()->withErrors($val->errors()) ->with('error', 'That email address is taken.'); } }
php
public function postRegister() { if (!Config::get('credentials.regallowed')) { return Redirect::route('account.register'); } $input = Binput::only(['first_name', 'last_name', 'email', 'password', 'password_confirmation']); $val = UserRepository::validate($input, array_keys($input)); if ($val->fails()) { return Redirect::route('account.register')->withInput()->withErrors($val->errors()); } $this->throttler->hit(); try { unset($input['password_confirmation']); $user = Credentials::register($input); if (!Config::get('credentials.activation')) { $mail = [ 'url' => URL::to(Config::get('credentials.home', '/')), 'email' => $user->getLogin(), 'subject' => Config::get('app.name').' - Welcome', ]; Mail::queue('credentials::emails.welcome', $mail, function ($message) use ($mail) { $message->to($mail['email'])->subject($mail['subject']); }); $user->attemptActivation($user->getActivationCode()); $user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return Redirect::to(Config::get('credentials.home', '/')) ->with('success', 'Your account has been created successfully. You may now login.'); } $code = $user->getActivationCode(); $mail = [ 'url' => URL::to(Config::get('credentials.home', '/')), 'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('app.name').' - Welcome', ]; Mail::queue('credentials::emails.welcome', $mail, function ($message) use ($mail) { $message->to($mail['email'])->subject($mail['subject']); }); return Redirect::to(Config::get('credentials.home', '/')) ->with('success', 'Your account has been created. Check your email for the confirmation link.'); } catch (UserExistsException $e) { return Redirect::route('account.register')->withInput()->withErrors($val->errors()) ->with('error', 'That email address is taken.'); } }
[ "public", "function", "postRegister", "(", ")", "{", "if", "(", "!", "Config", "::", "get", "(", "'credentials.regallowed'", ")", ")", "{", "return", "Redirect", "::", "route", "(", "'account.register'", ")", ";", "}", "$", "input", "=", "Binput", "::", "only", "(", "[", "'first_name'", ",", "'last_name'", ",", "'email'", ",", "'password'", ",", "'password_confirmation'", "]", ")", ";", "$", "val", "=", "UserRepository", "::", "validate", "(", "$", "input", ",", "array_keys", "(", "$", "input", ")", ")", ";", "if", "(", "$", "val", "->", "fails", "(", ")", ")", "{", "return", "Redirect", "::", "route", "(", "'account.register'", ")", "->", "withInput", "(", ")", "->", "withErrors", "(", "$", "val", "->", "errors", "(", ")", ")", ";", "}", "$", "this", "->", "throttler", "->", "hit", "(", ")", ";", "try", "{", "unset", "(", "$", "input", "[", "'password_confirmation'", "]", ")", ";", "$", "user", "=", "Credentials", "::", "register", "(", "$", "input", ")", ";", "if", "(", "!", "Config", "::", "get", "(", "'credentials.activation'", ")", ")", "{", "$", "mail", "=", "[", "'url'", "=>", "URL", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", ",", "'email'", "=>", "$", "user", "->", "getLogin", "(", ")", ",", "'subject'", "=>", "Config", "::", "get", "(", "'app.name'", ")", ".", "' - Welcome'", ",", "]", ";", "Mail", "::", "queue", "(", "'credentials::emails.welcome'", ",", "$", "mail", ",", "function", "(", "$", "message", ")", "use", "(", "$", "mail", ")", "{", "$", "message", "->", "to", "(", "$", "mail", "[", "'email'", "]", ")", "->", "subject", "(", "$", "mail", "[", "'subject'", "]", ")", ";", "}", ")", ";", "$", "user", "->", "attemptActivation", "(", "$", "user", "->", "getActivationCode", "(", ")", ")", ";", "$", "user", "->", "addGroup", "(", "Credentials", "::", "getGroupProvider", "(", ")", "->", "findByName", "(", "'Users'", ")", ")", ";", "return", "Redirect", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", "->", "with", "(", "'success'", ",", "'Your account has been created successfully. You may now login.'", ")", ";", "}", "$", "code", "=", "$", "user", "->", "getActivationCode", "(", ")", ";", "$", "mail", "=", "[", "'url'", "=>", "URL", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", ",", "'link'", "=>", "URL", "::", "route", "(", "'account.activate'", ",", "[", "'id'", "=>", "$", "user", "->", "id", ",", "'code'", "=>", "$", "code", "]", ")", ",", "'email'", "=>", "$", "user", "->", "getLogin", "(", ")", ",", "'subject'", "=>", "Config", "::", "get", "(", "'app.name'", ")", ".", "' - Welcome'", ",", "]", ";", "Mail", "::", "queue", "(", "'credentials::emails.welcome'", ",", "$", "mail", ",", "function", "(", "$", "message", ")", "use", "(", "$", "mail", ")", "{", "$", "message", "->", "to", "(", "$", "mail", "[", "'email'", "]", ")", "->", "subject", "(", "$", "mail", "[", "'subject'", "]", ")", ";", "}", ")", ";", "return", "Redirect", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", "->", "with", "(", "'success'", ",", "'Your account has been created. Check your email for the confirmation link.'", ")", ";", "}", "catch", "(", "UserExistsException", "$", "e", ")", "{", "return", "Redirect", "::", "route", "(", "'account.register'", ")", "->", "withInput", "(", ")", "->", "withErrors", "(", "$", "val", "->", "errors", "(", ")", ")", "->", "with", "(", "'error'", ",", "'That email address is taken.'", ")", ";", "}", "}" ]
Attempt to register a new user. @return \Illuminate\Http\Response
[ "Attempt", "to", "register", "a", "new", "user", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/RegistrationController.php#L70-L127
227,055
javanile/moldable
src/Parser/Mysql/EnumTrait.php
EnumTrait.getNotationAspectsEnum
private function getNotationAspectsEnum($notation, $aspects) { // $enum = $this->parseEnumNotation($notation); if (!$enum) { return $aspects; } // //$aspects['Enum'] = $enum; $aspects['Default'] = $enum[0]; $aspects['Null'] = in_array(null, $enum) ? 'YES' : 'NO'; // $tokens = []; foreach ($enum as $item) { if ($item !== null) { $tokens[] = "'{$item}'"; } } $aspects['Type'] = 'enum('.implode(',', $tokens).')'; return $aspects; }
php
private function getNotationAspectsEnum($notation, $aspects) { // $enum = $this->parseEnumNotation($notation); if (!$enum) { return $aspects; } // //$aspects['Enum'] = $enum; $aspects['Default'] = $enum[0]; $aspects['Null'] = in_array(null, $enum) ? 'YES' : 'NO'; // $tokens = []; foreach ($enum as $item) { if ($item !== null) { $tokens[] = "'{$item}'"; } } $aspects['Type'] = 'enum('.implode(',', $tokens).')'; return $aspects; }
[ "private", "function", "getNotationAspectsEnum", "(", "$", "notation", ",", "$", "aspects", ")", "{", "//", "$", "enum", "=", "$", "this", "->", "parseEnumNotation", "(", "$", "notation", ")", ";", "if", "(", "!", "$", "enum", ")", "{", "return", "$", "aspects", ";", "}", "//", "//$aspects['Enum'] = $enum;", "$", "aspects", "[", "'Default'", "]", "=", "$", "enum", "[", "0", "]", ";", "$", "aspects", "[", "'Null'", "]", "=", "in_array", "(", "null", ",", "$", "enum", ")", "?", "'YES'", ":", "'NO'", ";", "//", "$", "tokens", "=", "[", "]", ";", "foreach", "(", "$", "enum", "as", "$", "item", ")", "{", "if", "(", "$", "item", "!==", "null", ")", "{", "$", "tokens", "[", "]", "=", "\"'{$item}'\"", ";", "}", "}", "$", "aspects", "[", "'Type'", "]", "=", "'enum('", ".", "implode", "(", "','", ",", "$", "tokens", ")", ".", "')'", ";", "return", "$", "aspects", ";", "}" ]
Get notation aspects for enum. @param mixed $notation @param mixed $aspects
[ "Get", "notation", "aspects", "for", "enum", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/Mysql/EnumTrait.php#L20-L43
227,056
javanile/moldable
src/Parser/Mysql/EnumTrait.php
EnumTrait.parseEnumNotation
private function parseEnumNotation($notation) { if (is_string($notation)) { $notation = json_decode(trim($notation, '<>')); if (json_last_error()) { return; } } return $notation; }
php
private function parseEnumNotation($notation) { if (is_string($notation)) { $notation = json_decode(trim($notation, '<>')); if (json_last_error()) { return; } } return $notation; }
[ "private", "function", "parseEnumNotation", "(", "$", "notation", ")", "{", "if", "(", "is_string", "(", "$", "notation", ")", ")", "{", "$", "notation", "=", "json_decode", "(", "trim", "(", "$", "notation", ",", "'<>'", ")", ")", ";", "if", "(", "json_last_error", "(", ")", ")", "{", "return", ";", "}", "}", "return", "$", "notation", ";", "}" ]
Parse enum if is inside a string. @param mixed $notation
[ "Parse", "enum", "if", "is", "inside", "a", "string", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Parser/Mysql/EnumTrait.php#L50-L61
227,057
BootstrapCMS/Credentials
src/Models/BaseModelTrait.php
BaseModelTrait.update
public function update(array $input = []) { DB::beginTransaction(); try { LaravelEvent::fire(static::$name.'.updating', $this); $this->beforeUpdate($input); $return = parent::update($input); $this->afterUpdate($input, $return); LaravelEvent::fire(static::$name.'.updated', $this); DB::commit(); } catch (\Exception $e) { DB::rollBack(); throw $e; } return $return; }
php
public function update(array $input = []) { DB::beginTransaction(); try { LaravelEvent::fire(static::$name.'.updating', $this); $this->beforeUpdate($input); $return = parent::update($input); $this->afterUpdate($input, $return); LaravelEvent::fire(static::$name.'.updated', $this); DB::commit(); } catch (\Exception $e) { DB::rollBack(); throw $e; } return $return; }
[ "public", "function", "update", "(", "array", "$", "input", "=", "[", "]", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "LaravelEvent", "::", "fire", "(", "static", "::", "$", "name", ".", "'.updating'", ",", "$", "this", ")", ";", "$", "this", "->", "beforeUpdate", "(", "$", "input", ")", ";", "$", "return", "=", "parent", "::", "update", "(", "$", "input", ")", ";", "$", "this", "->", "afterUpdate", "(", "$", "input", ",", "$", "return", ")", ";", "LaravelEvent", "::", "fire", "(", "static", "::", "$", "name", ".", "'.updated'", ",", "$", "this", ")", ";", "DB", "::", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "return", ";", "}" ]
Update an existing model. @param array $input @throws \Exception @return bool|int
[ "Update", "an", "existing", "model", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/BaseModelTrait.php#L88-L106
227,058
BootstrapCMS/Credentials
src/Models/BaseModelTrait.php
BaseModelTrait.delete
public function delete() { DB::beginTransaction(); try { LaravelEvent::fire(static::$name.'.deleting', $this); $this->beforeDelete(); $return = parent::delete(); $this->afterDelete($return); LaravelEvent::fire(static::$name.'.deleted', $this); DB::commit(); } catch (\Exception $e) { DB::rollBack(); throw $e; } return $return; }
php
public function delete() { DB::beginTransaction(); try { LaravelEvent::fire(static::$name.'.deleting', $this); $this->beforeDelete(); $return = parent::delete(); $this->afterDelete($return); LaravelEvent::fire(static::$name.'.deleted', $this); DB::commit(); } catch (\Exception $e) { DB::rollBack(); throw $e; } return $return; }
[ "public", "function", "delete", "(", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "LaravelEvent", "::", "fire", "(", "static", "::", "$", "name", ".", "'.deleting'", ",", "$", "this", ")", ";", "$", "this", "->", "beforeDelete", "(", ")", ";", "$", "return", "=", "parent", "::", "delete", "(", ")", ";", "$", "this", "->", "afterDelete", "(", "$", "return", ")", ";", "LaravelEvent", "::", "fire", "(", "static", "::", "$", "name", ".", "'.deleted'", ",", "$", "this", ")", ";", "DB", "::", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "return", ";", "}" ]
Delete an existing model. @throws \Exception @return bool
[ "Delete", "an", "existing", "model", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Models/BaseModelTrait.php#L140-L158
227,059
javanile/moldable
src/Model/ReadApi.php
ReadApi.exists
public static function exists($query) { // static::applySchema(); // $table = self::getTable(); // $whereArray = []; // $valuesArray = []; // if (isset($query['where'])) { $whereArray[] = $query['where']; unset($query['where']); } // $schema = static::getSchemaFields(); // foreach ($schema as $field) { if (isset($query[$field])) { $token = ':'.$field; $whereArray[] = "`{$field}` = {$token}"; $valuesArray[$token] = $query[$field]; } } $where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : ''; $sql = "SELECT * FROM `{$table}` {$where} LIMIT 1"; $row = static::getDatabase()->getRow($sql, $valuesArray); return $row ? self::create($row) : false; }
php
public static function exists($query) { // static::applySchema(); // $table = self::getTable(); // $whereArray = []; // $valuesArray = []; // if (isset($query['where'])) { $whereArray[] = $query['where']; unset($query['where']); } // $schema = static::getSchemaFields(); // foreach ($schema as $field) { if (isset($query[$field])) { $token = ':'.$field; $whereArray[] = "`{$field}` = {$token}"; $valuesArray[$token] = $query[$field]; } } $where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : ''; $sql = "SELECT * FROM `{$table}` {$where} LIMIT 1"; $row = static::getDatabase()->getRow($sql, $valuesArray); return $row ? self::create($row) : false; }
[ "public", "static", "function", "exists", "(", "$", "query", ")", "{", "//", "static", "::", "applySchema", "(", ")", ";", "//", "$", "table", "=", "self", "::", "getTable", "(", ")", ";", "//", "$", "whereArray", "=", "[", "]", ";", "//", "$", "valuesArray", "=", "[", "]", ";", "//", "if", "(", "isset", "(", "$", "query", "[", "'where'", "]", ")", ")", "{", "$", "whereArray", "[", "]", "=", "$", "query", "[", "'where'", "]", ";", "unset", "(", "$", "query", "[", "'where'", "]", ")", ";", "}", "//", "$", "schema", "=", "static", "::", "getSchemaFields", "(", ")", ";", "//", "foreach", "(", "$", "schema", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "query", "[", "$", "field", "]", ")", ")", "{", "$", "token", "=", "':'", ".", "$", "field", ";", "$", "whereArray", "[", "]", "=", "\"`{$field}` = {$token}\"", ";", "$", "valuesArray", "[", "$", "token", "]", "=", "$", "query", "[", "$", "field", "]", ";", "}", "}", "$", "where", "=", "count", "(", "$", "whereArray", ")", ">", "0", "?", "'WHERE '", ".", "implode", "(", "' AND '", ",", "$", "whereArray", ")", ":", "''", ";", "$", "sql", "=", "\"SELECT * FROM `{$table}` {$where} LIMIT 1\"", ";", "$", "row", "=", "static", "::", "getDatabase", "(", ")", "->", "getRow", "(", "$", "sql", ",", "$", "valuesArray", ")", ";", "return", "$", "row", "?", "self", "::", "create", "(", "$", "row", ")", ":", "false", ";", "}" ]
Alias of ping. @param type $query @return type
[ "Alias", "of", "ping", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/ReadApi.php#L261-L302
227,060
BootstrapCMS/Credentials
src/Presenters/AuthorPresenterTrait.php
AuthorPresenterTrait.author
public function author() { $user = $this->getWrappedObject()->user()->withTrashed()->first(['first_name', 'last_name']); if ($user) { return $user->first_name.' '.$user->last_name; } }
php
public function author() { $user = $this->getWrappedObject()->user()->withTrashed()->first(['first_name', 'last_name']); if ($user) { return $user->first_name.' '.$user->last_name; } }
[ "public", "function", "author", "(", ")", "{", "$", "user", "=", "$", "this", "->", "getWrappedObject", "(", ")", "->", "user", "(", ")", "->", "withTrashed", "(", ")", "->", "first", "(", "[", "'first_name'", ",", "'last_name'", "]", ")", ";", "if", "(", "$", "user", ")", "{", "return", "$", "user", "->", "first_name", ".", "' '", ".", "$", "user", "->", "last_name", ";", "}", "}" ]
Get the author's name. @return string
[ "Get", "the", "author", "s", "name", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Presenters/AuthorPresenterTrait.php#L26-L33
227,061
aik099/CodingStandard
CodingStandard/Sniffs/Formatting/ItemAssignmentSniff.php
ItemAssignmentSniff.checkSpacing
protected function checkSpacing(File $phpcsFile, $stackPtr, $before) { if ($before === true) { $stackPtrDiff = -1; $errorWord = 'prefix'; $errorCode = 'Before'; } else { $stackPtrDiff = 1; $errorWord = 'follow'; $errorCode = 'After'; } $tokens = $phpcsFile->getTokens(); $tokenData = $tokens[($stackPtr + $stackPtrDiff)]; if ($tokenData['code'] !== T_WHITESPACE) { $error = 'Whitespace must '.$errorWord.' the item assignment operator =>'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpacing'.$errorCode); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); if ($before === true) { $phpcsFile->fixer->addContentBefore($stackPtr, ' '); } else { $phpcsFile->fixer->addContent($stackPtr, ' '); } $phpcsFile->fixer->endChangeset(); } return; } if (isset($tokenData['orig_content']) === true) { $content = $tokenData['orig_content']; } else { $content = $tokenData['content']; } if ($this->hasOnlySpaces($content) === false) { $error = 'Spaces must be used to '.$errorWord.' the item assignment operator =>'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MixedWhitespace'.$errorCode); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( ($stackPtr + $stackPtrDiff), str_repeat(' ', strlen($content)) ); $phpcsFile->fixer->endChangeset(); } } }
php
protected function checkSpacing(File $phpcsFile, $stackPtr, $before) { if ($before === true) { $stackPtrDiff = -1; $errorWord = 'prefix'; $errorCode = 'Before'; } else { $stackPtrDiff = 1; $errorWord = 'follow'; $errorCode = 'After'; } $tokens = $phpcsFile->getTokens(); $tokenData = $tokens[($stackPtr + $stackPtrDiff)]; if ($tokenData['code'] !== T_WHITESPACE) { $error = 'Whitespace must '.$errorWord.' the item assignment operator =>'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpacing'.$errorCode); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); if ($before === true) { $phpcsFile->fixer->addContentBefore($stackPtr, ' '); } else { $phpcsFile->fixer->addContent($stackPtr, ' '); } $phpcsFile->fixer->endChangeset(); } return; } if (isset($tokenData['orig_content']) === true) { $content = $tokenData['orig_content']; } else { $content = $tokenData['content']; } if ($this->hasOnlySpaces($content) === false) { $error = 'Spaces must be used to '.$errorWord.' the item assignment operator =>'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MixedWhitespace'.$errorCode); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( ($stackPtr + $stackPtrDiff), str_repeat(' ', strlen($content)) ); $phpcsFile->fixer->endChangeset(); } } }
[ "protected", "function", "checkSpacing", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "before", ")", "{", "if", "(", "$", "before", "===", "true", ")", "{", "$", "stackPtrDiff", "=", "-", "1", ";", "$", "errorWord", "=", "'prefix'", ";", "$", "errorCode", "=", "'Before'", ";", "}", "else", "{", "$", "stackPtrDiff", "=", "1", ";", "$", "errorWord", "=", "'follow'", ";", "$", "errorCode", "=", "'After'", ";", "}", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "tokenData", "=", "$", "tokens", "[", "(", "$", "stackPtr", "+", "$", "stackPtrDiff", ")", "]", ";", "if", "(", "$", "tokenData", "[", "'code'", "]", "!==", "T_WHITESPACE", ")", "{", "$", "error", "=", "'Whitespace must '", ".", "$", "errorWord", ".", "' the item assignment operator =>'", ";", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "$", "error", ",", "$", "stackPtr", ",", "'NoSpacing'", ".", "$", "errorCode", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "if", "(", "$", "before", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "addContentBefore", "(", "$", "stackPtr", ",", "' '", ")", ";", "}", "else", "{", "$", "phpcsFile", "->", "fixer", "->", "addContent", "(", "$", "stackPtr", ",", "' '", ")", ";", "}", "$", "phpcsFile", "->", "fixer", "->", "endChangeset", "(", ")", ";", "}", "return", ";", "}", "if", "(", "isset", "(", "$", "tokenData", "[", "'orig_content'", "]", ")", "===", "true", ")", "{", "$", "content", "=", "$", "tokenData", "[", "'orig_content'", "]", ";", "}", "else", "{", "$", "content", "=", "$", "tokenData", "[", "'content'", "]", ";", "}", "if", "(", "$", "this", "->", "hasOnlySpaces", "(", "$", "content", ")", "===", "false", ")", "{", "$", "error", "=", "'Spaces must be used to '", ".", "$", "errorWord", ".", "' the item assignment operator =>'", ";", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "$", "error", ",", "$", "stackPtr", ",", "'MixedWhitespace'", ".", "$", "errorCode", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "phpcsFile", "->", "fixer", "->", "replaceToken", "(", "(", "$", "stackPtr", "+", "$", "stackPtrDiff", ")", ",", "str_repeat", "(", "' '", ",", "strlen", "(", "$", "content", ")", ")", ")", ";", "$", "phpcsFile", "->", "fixer", "->", "endChangeset", "(", ")", ";", "}", "}", "}" ]
Checks spacing at given position. @param File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param bool $before Determines direction in which to check spacing. @return void
[ "Checks", "spacing", "at", "given", "position", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Formatting/ItemAssignmentSniff.php#L74-L125
227,062
andre487/php_rutils
Dt.php
Dt._processDateTime
private function _processDateTime($dateTime) { if (is_numeric($dateTime)) { $timestamp = $dateTime; $dateTime = new \DateTime(); $dateTime->setTimestamp($timestamp); } elseif (empty($dateTime)) { throw new \InvalidArgumentException('Date/time is empty'); } elseif (is_string($dateTime)) { $dateTime = new \DateTime($dateTime); } if (!($dateTime instanceof \DateTime)) { throw new \InvalidArgumentException('Incorrect date/time type'); } return $dateTime; }
php
private function _processDateTime($dateTime) { if (is_numeric($dateTime)) { $timestamp = $dateTime; $dateTime = new \DateTime(); $dateTime->setTimestamp($timestamp); } elseif (empty($dateTime)) { throw new \InvalidArgumentException('Date/time is empty'); } elseif (is_string($dateTime)) { $dateTime = new \DateTime($dateTime); } if (!($dateTime instanceof \DateTime)) { throw new \InvalidArgumentException('Incorrect date/time type'); } return $dateTime; }
[ "private", "function", "_processDateTime", "(", "$", "dateTime", ")", "{", "if", "(", "is_numeric", "(", "$", "dateTime", ")", ")", "{", "$", "timestamp", "=", "$", "dateTime", ";", "$", "dateTime", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "dateTime", "->", "setTimestamp", "(", "$", "timestamp", ")", ";", "}", "elseif", "(", "empty", "(", "$", "dateTime", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Date/time is empty'", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "dateTime", ")", ")", "{", "$", "dateTime", "=", "new", "\\", "DateTime", "(", "$", "dateTime", ")", ";", "}", "if", "(", "!", "(", "$", "dateTime", "instanceof", "\\", "DateTime", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Incorrect date/time type'", ")", ";", "}", "return", "$", "dateTime", ";", "}" ]
Process mixed format date @param mixed $dateTime @return \DateTime @throws \InvalidArgumentException
[ "Process", "mixed", "format", "date" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Dt.php#L115-L131
227,063
andre487/php_rutils
Dt.php
Dt._addResultSuffix
private function _addResultSuffix(\DateInterval $interval, $result) { return $interval->invert ? self::$PREFIX_IN."\xC2\xA0".$result : $result."\xC2\xA0".self::$SUFFIX_AGO; }
php
private function _addResultSuffix(\DateInterval $interval, $result) { return $interval->invert ? self::$PREFIX_IN."\xC2\xA0".$result : $result."\xC2\xA0".self::$SUFFIX_AGO; }
[ "private", "function", "_addResultSuffix", "(", "\\", "DateInterval", "$", "interval", ",", "$", "result", ")", "{", "return", "$", "interval", "->", "invert", "?", "self", "::", "$", "PREFIX_IN", ".", "\"\\xC2\\xA0\"", ".", "$", "result", ":", "$", "result", ".", "\"\\xC2\\xA0\"", ".", "self", "::", "$", "SUFFIX_AGO", ";", "}" ]
Add suffix or Postfix to string. @param \DateInterval $interval @param $result string @return string modified $result.
[ "Add", "suffix", "or", "Postfix", "to", "string", "." ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Dt.php#L315-L318
227,064
javanile/moldable
src/Model/TableApi.php
TableApi.getTable
public static function getTable() { $attribute = 'table'; if (!static::hasClassAttribute($attribute)) { $name = !isset(static::$table) ? static::getClassName() : static::$table; $conventionName = Functions::applyConventions( static::getClassConfig('table-name-conventions'), $name ); $tableName = static::getDatabase()->getPrefix($conventionName); static::setClassAttribute($attribute, $tableName); } return static::getClassAttribute($attribute); }
php
public static function getTable() { $attribute = 'table'; if (!static::hasClassAttribute($attribute)) { $name = !isset(static::$table) ? static::getClassName() : static::$table; $conventionName = Functions::applyConventions( static::getClassConfig('table-name-conventions'), $name ); $tableName = static::getDatabase()->getPrefix($conventionName); static::setClassAttribute($attribute, $tableName); } return static::getClassAttribute($attribute); }
[ "public", "static", "function", "getTable", "(", ")", "{", "$", "attribute", "=", "'table'", ";", "if", "(", "!", "static", "::", "hasClassAttribute", "(", "$", "attribute", ")", ")", "{", "$", "name", "=", "!", "isset", "(", "static", "::", "$", "table", ")", "?", "static", "::", "getClassName", "(", ")", ":", "static", "::", "$", "table", ";", "$", "conventionName", "=", "Functions", "::", "applyConventions", "(", "static", "::", "getClassConfig", "(", "'table-name-conventions'", ")", ",", "$", "name", ")", ";", "$", "tableName", "=", "static", "::", "getDatabase", "(", ")", "->", "getPrefix", "(", "$", "conventionName", ")", ";", "static", "::", "setClassAttribute", "(", "$", "attribute", ",", "$", "tableName", ")", ";", "}", "return", "static", "::", "getClassAttribute", "(", "$", "attribute", ")", ";", "}" ]
Retrieve table name. @return string
[ "Retrieve", "table", "name", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Model/TableApi.php#L21-L41
227,065
OpenSkill/Datatable
src/OpenSkill/Datatable/Views/DatatableView.php
DatatableView.columns
public function columns($columnName, $label = null) { if (!is_string($columnName)) { throw new \InvalidArgumentException('$columnName must be set'); } if ($this->resetColumns) { $this->columns = []; $this->resetColumns = false; } if (is_null($label)) { $label = $columnName; } $this->columns[$columnName] = $label; return $this; }
php
public function columns($columnName, $label = null) { if (!is_string($columnName)) { throw new \InvalidArgumentException('$columnName must be set'); } if ($this->resetColumns) { $this->columns = []; $this->resetColumns = false; } if (is_null($label)) { $label = $columnName; } $this->columns[$columnName] = $label; return $this; }
[ "public", "function", "columns", "(", "$", "columnName", ",", "$", "label", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "columnName", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$columnName must be set'", ")", ";", "}", "if", "(", "$", "this", "->", "resetColumns", ")", "{", "$", "this", "->", "columns", "=", "[", "]", ";", "$", "this", "->", "resetColumns", "=", "false", ";", "}", "if", "(", "is_null", "(", "$", "label", ")", ")", "{", "$", "label", "=", "$", "columnName", ";", "}", "$", "this", "->", "columns", "[", "$", "columnName", "]", "=", "$", "label", ";", "return", "$", "this", ";", "}" ]
Will set the columns for the view @param string $columnName The name of the column @param string $label The label for this column @return $this
[ "Will", "set", "the", "columns", "for", "the", "view" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Views/DatatableView.php#L143-L158
227,066
OpenSkill/Datatable
src/OpenSkill/Datatable/Views/DatatableView.php
DatatableView.table
public function table() { if (empty($this->columns)) { throw new \InvalidArgumentException("There are no columns defined"); } return $this->viewFactory ->make($this->tableView, [ 'columns' => $this->columns, 'showHeaders' => $this->printHeaders, 'id' => $this->tableId, 'endpoint' => $this->endpointURL, ]) ->render(); }
php
public function table() { if (empty($this->columns)) { throw new \InvalidArgumentException("There are no columns defined"); } return $this->viewFactory ->make($this->tableView, [ 'columns' => $this->columns, 'showHeaders' => $this->printHeaders, 'id' => $this->tableId, 'endpoint' => $this->endpointURL, ]) ->render(); }
[ "public", "function", "table", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "columns", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"There are no columns defined\"", ")", ";", "}", "return", "$", "this", "->", "viewFactory", "->", "make", "(", "$", "this", "->", "tableView", ",", "[", "'columns'", "=>", "$", "this", "->", "columns", ",", "'showHeaders'", "=>", "$", "this", "->", "printHeaders", ",", "'id'", "=>", "$", "this", "->", "tableId", ",", "'endpoint'", "=>", "$", "this", "->", "endpointURL", ",", "]", ")", "->", "render", "(", ")", ";", "}" ]
Will render the table @return string the rendered view that represents the table
[ "Will", "render", "the", "table" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Views/DatatableView.php#L165-L179
227,067
OpenSkill/Datatable
src/OpenSkill/Datatable/Views/DatatableView.php
DatatableView.script
public function script() { if (empty($this->columns)) { throw new \InvalidArgumentException("There are no columns defined"); } return $this->viewFactory ->make($this->scriptView, [ 'id' => $this->tableId, 'columns' => $this->columns, 'options' => $this->scriptOptions, 'callbacks' => $this->scriptCallbacks, 'endpoint' => $this->endpointURL, ]) ->render(); }
php
public function script() { if (empty($this->columns)) { throw new \InvalidArgumentException("There are no columns defined"); } return $this->viewFactory ->make($this->scriptView, [ 'id' => $this->tableId, 'columns' => $this->columns, 'options' => $this->scriptOptions, 'callbacks' => $this->scriptCallbacks, 'endpoint' => $this->endpointURL, ]) ->render(); }
[ "public", "function", "script", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "columns", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"There are no columns defined\"", ")", ";", "}", "return", "$", "this", "->", "viewFactory", "->", "make", "(", "$", "this", "->", "scriptView", ",", "[", "'id'", "=>", "$", "this", "->", "tableId", ",", "'columns'", "=>", "$", "this", "->", "columns", ",", "'options'", "=>", "$", "this", "->", "scriptOptions", ",", "'callbacks'", "=>", "$", "this", "->", "scriptCallbacks", ",", "'endpoint'", "=>", "$", "this", "->", "endpointURL", ",", "]", ")", "->", "render", "(", ")", ";", "}" ]
Will render the javascript for the table @return string the rendered view that represents the script
[ "Will", "render", "the", "javascript", "for", "the", "table" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Views/DatatableView.php#L186-L200
227,068
javanile/moldable
src/Database/ErrorApi.php
ErrorApi.error
public function error($type, $exception) { switch ($type) { // Trigger a connection-with-database error. case 'connect': $slug = 'Moldable connection error, '; $backtrace = $this->_trace; $offset = 0; break; // Trigger a error in executed sql query. case 'execute': $slug = 'Moldable query error, '; $backtrace = debug_backtrace(); $offset = 2; break; // Trigger a error in executed sql query. case 'generic': $slug = 'Moldable error, '; $backtrace = debug_backtrace(); $offset = 1; break; // Trigger a error in executed sql query. /* default: $slug = 'Moldable uknown error, '; $backtrace = debug_backtrace(); $offset = 0; break;*/ } Functions::throwException($slug, $exception, $backtrace, $offset); }
php
public function error($type, $exception) { switch ($type) { // Trigger a connection-with-database error. case 'connect': $slug = 'Moldable connection error, '; $backtrace = $this->_trace; $offset = 0; break; // Trigger a error in executed sql query. case 'execute': $slug = 'Moldable query error, '; $backtrace = debug_backtrace(); $offset = 2; break; // Trigger a error in executed sql query. case 'generic': $slug = 'Moldable error, '; $backtrace = debug_backtrace(); $offset = 1; break; // Trigger a error in executed sql query. /* default: $slug = 'Moldable uknown error, '; $backtrace = debug_backtrace(); $offset = 0; break;*/ } Functions::throwException($slug, $exception, $backtrace, $offset); }
[ "public", "function", "error", "(", "$", "type", ",", "$", "exception", ")", "{", "switch", "(", "$", "type", ")", "{", "// Trigger a connection-with-database error.", "case", "'connect'", ":", "$", "slug", "=", "'Moldable connection error, '", ";", "$", "backtrace", "=", "$", "this", "->", "_trace", ";", "$", "offset", "=", "0", ";", "break", ";", "// Trigger a error in executed sql query.", "case", "'execute'", ":", "$", "slug", "=", "'Moldable query error, '", ";", "$", "backtrace", "=", "debug_backtrace", "(", ")", ";", "$", "offset", "=", "2", ";", "break", ";", "// Trigger a error in executed sql query.", "case", "'generic'", ":", "$", "slug", "=", "'Moldable error, '", ";", "$", "backtrace", "=", "debug_backtrace", "(", ")", ";", "$", "offset", "=", "1", ";", "break", ";", "// Trigger a error in executed sql query.", "/*\n default:\n $slug = 'Moldable uknown error, ';\n $backtrace = debug_backtrace();\n $offset = 0;\n break;*/", "}", "Functions", "::", "throwException", "(", "$", "slug", ",", "$", "exception", ",", "$", "backtrace", ",", "$", "offset", ")", ";", "}" ]
Trigger a error. @param object $exception Exception catched with try-catch @param mixed $type
[ "Trigger", "a", "error", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Database/ErrorApi.php#L22-L56
227,069
whatwedo/TableBundle
Table/Column.php
Column.getContents
public function getContents($row) { if (is_callable($this->options['callable'])) { if (is_array($this->options['callable'])) { return call_user_func($this->options['callable'], [$row]); } return $this->options['callable']($row); } $propertyAccessor = PropertyAccess::createPropertyAccessor(); try { return $propertyAccessor->getValue($row, $this->options['accessor_path']); } catch (UnexpectedTypeException $e) { return ''; } catch (NoSuchPropertyException $e) { return $e->getMessage(); } }
php
public function getContents($row) { if (is_callable($this->options['callable'])) { if (is_array($this->options['callable'])) { return call_user_func($this->options['callable'], [$row]); } return $this->options['callable']($row); } $propertyAccessor = PropertyAccess::createPropertyAccessor(); try { return $propertyAccessor->getValue($row, $this->options['accessor_path']); } catch (UnexpectedTypeException $e) { return ''; } catch (NoSuchPropertyException $e) { return $e->getMessage(); } }
[ "public", "function", "getContents", "(", "$", "row", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "options", "[", "'callable'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "options", "[", "'callable'", "]", ")", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "options", "[", "'callable'", "]", ",", "[", "$", "row", "]", ")", ";", "}", "return", "$", "this", "->", "options", "[", "'callable'", "]", "(", "$", "row", ")", ";", "}", "$", "propertyAccessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "try", "{", "return", "$", "propertyAccessor", "->", "getValue", "(", "$", "row", ",", "$", "this", "->", "options", "[", "'accessor_path'", "]", ")", ";", "}", "catch", "(", "UnexpectedTypeException", "$", "e", ")", "{", "return", "''", ";", "}", "catch", "(", "NoSuchPropertyException", "$", "e", ")", "{", "return", "$", "e", "->", "getMessage", "(", ")", ";", "}", "}" ]
gets the content of the row @param $row @return string
[ "gets", "the", "content", "of", "the", "row" ]
b527b92dc1e59280cdaef4bd6e4722fc6f49359e
https://github.com/whatwedo/TableBundle/blob/b527b92dc1e59280cdaef4bd6e4722fc6f49359e/Table/Column.php#L74-L93
227,070
BootstrapCMS/Credentials
src/Http/Controllers/ActivationController.php
ActivationController.getActivate
public function getActivate($id, $code) { if (!$id || !$code) { throw new BadRequestHttpException(); } try { $user = Credentials::getUserProvider()->findById($id); if (!$user->attemptActivation($code)) { return Redirect::to(Config::get('credentials.home', '/')) ->with('error', 'There was a problem activating this account. Please contact support.'); } $user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return Redirect::route('account.login') ->with('success', 'Your account has been activated successfully. You may now login.'); } catch (UserNotFoundException $e) { return Redirect::to(Config::get('credentials.home', '/')) ->with('error', 'There was a problem activating this account. Please contact support.'); } catch (UserAlreadyActivatedException $e) { return Redirect::route('account.login') ->with('warning', 'You have already activated this account. You may want to login.'); } }
php
public function getActivate($id, $code) { if (!$id || !$code) { throw new BadRequestHttpException(); } try { $user = Credentials::getUserProvider()->findById($id); if (!$user->attemptActivation($code)) { return Redirect::to(Config::get('credentials.home', '/')) ->with('error', 'There was a problem activating this account. Please contact support.'); } $user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return Redirect::route('account.login') ->with('success', 'Your account has been activated successfully. You may now login.'); } catch (UserNotFoundException $e) { return Redirect::to(Config::get('credentials.home', '/')) ->with('error', 'There was a problem activating this account. Please contact support.'); } catch (UserAlreadyActivatedException $e) { return Redirect::route('account.login') ->with('warning', 'You have already activated this account. You may want to login.'); } }
[ "public", "function", "getActivate", "(", "$", "id", ",", "$", "code", ")", "{", "if", "(", "!", "$", "id", "||", "!", "$", "code", ")", "{", "throw", "new", "BadRequestHttpException", "(", ")", ";", "}", "try", "{", "$", "user", "=", "Credentials", "::", "getUserProvider", "(", ")", "->", "findById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", "->", "attemptActivation", "(", "$", "code", ")", ")", "{", "return", "Redirect", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", "->", "with", "(", "'error'", ",", "'There was a problem activating this account. Please contact support.'", ")", ";", "}", "$", "user", "->", "addGroup", "(", "Credentials", "::", "getGroupProvider", "(", ")", "->", "findByName", "(", "'Users'", ")", ")", ";", "return", "Redirect", "::", "route", "(", "'account.login'", ")", "->", "with", "(", "'success'", ",", "'Your account has been activated successfully. You may now login.'", ")", ";", "}", "catch", "(", "UserNotFoundException", "$", "e", ")", "{", "return", "Redirect", "::", "to", "(", "Config", "::", "get", "(", "'credentials.home'", ",", "'/'", ")", ")", "->", "with", "(", "'error'", ",", "'There was a problem activating this account. Please contact support.'", ")", ";", "}", "catch", "(", "UserAlreadyActivatedException", "$", "e", ")", "{", "return", "Redirect", "::", "route", "(", "'account.login'", ")", "->", "with", "(", "'warning'", ",", "'You have already activated this account. You may want to login.'", ")", ";", "}", "}" ]
Activate an existing user. @param int $id @param string $code @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException @return \Illuminate\Http\Response
[ "Activate", "an", "existing", "user", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Http/Controllers/ActivationController.php#L68-L93
227,071
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.setupBlade
protected function setupBlade(View $view) { $blade = $view->getEngineResolver()->resolve('blade')->getCompiler(); $blade->directive('auth', function ($expression) { return "<?php if (\GrahamCampbell\Credentials\Facades\Credentials::check() && \GrahamCampbell\Credentials\Facades\Credentials::hasAccess{$expression}): ?>"; }); $blade->directive('endauth', function () { return '<?php endif; ?>'; }); }
php
protected function setupBlade(View $view) { $blade = $view->getEngineResolver()->resolve('blade')->getCompiler(); $blade->directive('auth', function ($expression) { return "<?php if (\GrahamCampbell\Credentials\Facades\Credentials::check() && \GrahamCampbell\Credentials\Facades\Credentials::hasAccess{$expression}): ?>"; }); $blade->directive('endauth', function () { return '<?php endif; ?>'; }); }
[ "protected", "function", "setupBlade", "(", "View", "$", "view", ")", "{", "$", "blade", "=", "$", "view", "->", "getEngineResolver", "(", ")", "->", "resolve", "(", "'blade'", ")", "->", "getCompiler", "(", ")", ";", "$", "blade", "->", "directive", "(", "'auth'", ",", "function", "(", "$", "expression", ")", "{", "return", "\"<?php if (\\GrahamCampbell\\Credentials\\Facades\\Credentials::check() && \\GrahamCampbell\\Credentials\\Facades\\Credentials::hasAccess{$expression}): ?>\"", ";", "}", ")", ";", "$", "blade", "->", "directive", "(", "'endauth'", ",", "function", "(", ")", "{", "return", "'<?php endif; ?>'", ";", "}", ")", ";", "}" ]
Setup the blade compiler class. @param \Illuminate\Contracts\View\Factory $view @return void
[ "Setup", "the", "blade", "compiler", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L74-L85
227,072
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerRevisionRepository
protected function registerRevisionRepository() { $this->app->singleton('revisionrepository', function ($app) { $model = $app['config']['credentials.revision']; $revision = new $model(); $validator = $app['validator']; return new RevisionRepository($revision, $validator); }); $this->app->alias('revisionrepository', RevisionRepository::class); }
php
protected function registerRevisionRepository() { $this->app->singleton('revisionrepository', function ($app) { $model = $app['config']['credentials.revision']; $revision = new $model(); $validator = $app['validator']; return new RevisionRepository($revision, $validator); }); $this->app->alias('revisionrepository', RevisionRepository::class); }
[ "protected", "function", "registerRevisionRepository", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'revisionrepository'", ",", "function", "(", "$", "app", ")", "{", "$", "model", "=", "$", "app", "[", "'config'", "]", "[", "'credentials.revision'", "]", ";", "$", "revision", "=", "new", "$", "model", "(", ")", ";", "$", "validator", "=", "$", "app", "[", "'validator'", "]", ";", "return", "new", "RevisionRepository", "(", "$", "revision", ",", "$", "validator", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'revisionrepository'", ",", "RevisionRepository", "::", "class", ")", ";", "}" ]
Register the revision repository class. @return void
[ "Register", "the", "revision", "repository", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L126-L138
227,073
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerUserRepository
protected function registerUserRepository() { $this->app->singleton('userrepository', function ($app) { $model = $app['config']['sentry.users.model']; $user = new $model(); $validator = $app['validator']; return new UserRepository($user, $validator); }); $this->app->alias('userrepository', UserRepository::class); }
php
protected function registerUserRepository() { $this->app->singleton('userrepository', function ($app) { $model = $app['config']['sentry.users.model']; $user = new $model(); $validator = $app['validator']; return new UserRepository($user, $validator); }); $this->app->alias('userrepository', UserRepository::class); }
[ "protected", "function", "registerUserRepository", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'userrepository'", ",", "function", "(", "$", "app", ")", "{", "$", "model", "=", "$", "app", "[", "'config'", "]", "[", "'sentry.users.model'", "]", ";", "$", "user", "=", "new", "$", "model", "(", ")", ";", "$", "validator", "=", "$", "app", "[", "'validator'", "]", ";", "return", "new", "UserRepository", "(", "$", "user", ",", "$", "validator", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'userrepository'", ",", "UserRepository", "::", "class", ")", ";", "}" ]
Register the user repository class. @return void
[ "Register", "the", "user", "repository", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L145-L157
227,074
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerGroupRepository
protected function registerGroupRepository() { $this->app->singleton('grouprepository', function ($app) { $model = $app['config']['sentry.groups.model']; $group = new $model(); $validator = $app['validator']; return new GroupRepository($group, $validator); }); $this->app->alias('grouprepository', GroupRepository::class); }
php
protected function registerGroupRepository() { $this->app->singleton('grouprepository', function ($app) { $model = $app['config']['sentry.groups.model']; $group = new $model(); $validator = $app['validator']; return new GroupRepository($group, $validator); }); $this->app->alias('grouprepository', GroupRepository::class); }
[ "protected", "function", "registerGroupRepository", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'grouprepository'", ",", "function", "(", "$", "app", ")", "{", "$", "model", "=", "$", "app", "[", "'config'", "]", "[", "'sentry.groups.model'", "]", ";", "$", "group", "=", "new", "$", "model", "(", ")", ";", "$", "validator", "=", "$", "app", "[", "'validator'", "]", ";", "return", "new", "GroupRepository", "(", "$", "group", ",", "$", "validator", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'grouprepository'", ",", "GroupRepository", "::", "class", ")", ";", "}" ]
Register the group repository class. @return void
[ "Register", "the", "group", "repository", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L164-L176
227,075
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerCredentials
protected function registerCredentials() { $this->app->singleton('credentials', function ($app) { $sentry = $app['sentry']; $decorator = $app->make(PresenterDecorator::class); return new Credentials($sentry, $decorator); }); $this->app->alias('credentials', Credentials::class); }
php
protected function registerCredentials() { $this->app->singleton('credentials', function ($app) { $sentry = $app['sentry']; $decorator = $app->make(PresenterDecorator::class); return new Credentials($sentry, $decorator); }); $this->app->alias('credentials', Credentials::class); }
[ "protected", "function", "registerCredentials", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'credentials'", ",", "function", "(", "$", "app", ")", "{", "$", "sentry", "=", "$", "app", "[", "'sentry'", "]", ";", "$", "decorator", "=", "$", "app", "->", "make", "(", "PresenterDecorator", "::", "class", ")", ";", "return", "new", "Credentials", "(", "$", "sentry", ",", "$", "decorator", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'credentials'", ",", "Credentials", "::", "class", ")", ";", "}" ]
Register the credentials class. @return void
[ "Register", "the", "credentials", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L183-L193
227,076
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerLoginController
protected function registerLoginController() { $this->app->bind(LoginController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 10, 10); return new LoginController($throttler); }); }
php
protected function registerLoginController() { $this->app->bind(LoginController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 10, 10); return new LoginController($throttler); }); }
[ "protected", "function", "registerLoginController", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "LoginController", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "throttler", "=", "$", "app", "[", "'throttle'", "]", "->", "get", "(", "$", "app", "[", "'request'", "]", ",", "10", ",", "10", ")", ";", "return", "new", "LoginController", "(", "$", "throttler", ")", ";", "}", ")", ";", "}" ]
Register the login controller class. @return void
[ "Register", "the", "login", "controller", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L200-L207
227,077
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerRegistrationController
protected function registerRegistrationController() { $this->app->bind(RegistrationController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new RegistrationController($throttler); }); }
php
protected function registerRegistrationController() { $this->app->bind(RegistrationController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new RegistrationController($throttler); }); }
[ "protected", "function", "registerRegistrationController", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "RegistrationController", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "throttler", "=", "$", "app", "[", "'throttle'", "]", "->", "get", "(", "$", "app", "[", "'request'", "]", ",", "5", ",", "30", ")", ";", "return", "new", "RegistrationController", "(", "$", "throttler", ")", ";", "}", ")", ";", "}" ]
Register the registration controller class. @return void
[ "Register", "the", "registration", "controller", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L214-L221
227,078
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerResetController
protected function registerResetController() { $this->app->bind(ResetController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new ResetController($throttler); }); }
php
protected function registerResetController() { $this->app->bind(ResetController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new ResetController($throttler); }); }
[ "protected", "function", "registerResetController", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "ResetController", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "throttler", "=", "$", "app", "[", "'throttle'", "]", "->", "get", "(", "$", "app", "[", "'request'", "]", ",", "5", ",", "30", ")", ";", "return", "new", "ResetController", "(", "$", "throttler", ")", ";", "}", ")", ";", "}" ]
Register the reset controller class. @return void
[ "Register", "the", "reset", "controller", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L228-L235
227,079
BootstrapCMS/Credentials
src/CredentialsServiceProvider.php
CredentialsServiceProvider.registerActivationController
protected function registerActivationController() { $this->app->bind(ActivationController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new ActivationController($throttler); }); }
php
protected function registerActivationController() { $this->app->bind(ActivationController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 5, 30); return new ActivationController($throttler); }); }
[ "protected", "function", "registerActivationController", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "ActivationController", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "throttler", "=", "$", "app", "[", "'throttle'", "]", "->", "get", "(", "$", "app", "[", "'request'", "]", ",", "5", ",", "30", ")", ";", "return", "new", "ActivationController", "(", "$", "throttler", ")", ";", "}", ")", ";", "}" ]
Register the resend controller class. @return void
[ "Register", "the", "resend", "controller", "class", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/CredentialsServiceProvider.php#L242-L249
227,080
javanile/moldable
src/Storable.php
Storable.store
public function store($values = null) { static::applySchema(); // update values before store if (is_array($values)) { foreach ($values as $field => $value) { $this->{$field} = $value; } } // if has primary update else insert $key = static::getPrimaryKey(); if ($key && isset($this->{$key}) && $this->{$key}) { return $this->storeUpdate(); } return $this->storeInsert(); }
php
public function store($values = null) { static::applySchema(); // update values before store if (is_array($values)) { foreach ($values as $field => $value) { $this->{$field} = $value; } } // if has primary update else insert $key = static::getPrimaryKey(); if ($key && isset($this->{$key}) && $this->{$key}) { return $this->storeUpdate(); } return $this->storeInsert(); }
[ "public", "function", "store", "(", "$", "values", "=", "null", ")", "{", "static", "::", "applySchema", "(", ")", ";", "// update values before store", "if", "(", "is_array", "(", "$", "values", ")", ")", "{", "foreach", "(", "$", "values", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "{", "$", "field", "}", "=", "$", "value", ";", "}", "}", "// if has primary update else insert", "$", "key", "=", "static", "::", "getPrimaryKey", "(", ")", ";", "if", "(", "$", "key", "&&", "isset", "(", "$", "this", "->", "{", "$", "key", "}", ")", "&&", "$", "this", "->", "{", "$", "key", "}", ")", "{", "return", "$", "this", "->", "storeUpdate", "(", ")", ";", "}", "return", "$", "this", "->", "storeInsert", "(", ")", ";", "}" ]
Auto-store element method. @param null|mixed $values @return type
[ "Auto", "-", "store", "element", "method", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Storable.php#L70-L88
227,081
neoxygen/neo4j-neogen
src/Schema/Relationship.php
Relationship.addProperty
public function addProperty(RelationshipProperty $property) { foreach ($this->properties as $prop) { if ($prop->getName() === $property->getName()) { $this->properties->removeElement($prop); } } return $this->properties->add($property); }
php
public function addProperty(RelationshipProperty $property) { foreach ($this->properties as $prop) { if ($prop->getName() === $property->getName()) { $this->properties->removeElement($prop); } } return $this->properties->add($property); }
[ "public", "function", "addProperty", "(", "RelationshipProperty", "$", "property", ")", "{", "foreach", "(", "$", "this", "->", "properties", "as", "$", "prop", ")", "{", "if", "(", "$", "prop", "->", "getName", "(", ")", "===", "$", "property", "->", "getName", "(", ")", ")", "{", "$", "this", "->", "properties", "->", "removeElement", "(", "$", "prop", ")", ";", "}", "}", "return", "$", "this", "->", "properties", "->", "add", "(", "$", "property", ")", ";", "}" ]
Adds a relationship property to the collection and avoid duplicated @param RelationshipProperty $property @return bool
[ "Adds", "a", "relationship", "property", "to", "the", "collection", "and", "avoid", "duplicated" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Relationship.php#L100-L109
227,082
neoxygen/neo4j-neogen
src/Schema/Relationship.php
Relationship.hasProperty
public function hasProperty($name) { if (null !== $name) { $n = (string) $name; foreach ($this->properties as $property) { if ($property->getName() === $n) { return true; } } } return false; }
php
public function hasProperty($name) { if (null !== $name) { $n = (string) $name; foreach ($this->properties as $property) { if ($property->getName() === $n) { return true; } } } return false; }
[ "public", "function", "hasProperty", "(", "$", "name", ")", "{", "if", "(", "null", "!==", "$", "name", ")", "{", "$", "n", "=", "(", "string", ")", "$", "name", ";", "foreach", "(", "$", "this", "->", "properties", "as", "$", "property", ")", "{", "if", "(", "$", "property", "->", "getName", "(", ")", "===", "$", "n", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks whether or not this relationship has the property with the specified name @param string $name The relationship property name @return bool
[ "Checks", "whether", "or", "not", "this", "relationship", "has", "the", "property", "with", "the", "specified", "name" ]
3bc3ae1b95aae13915ce699b4f2d20762b2f0146
https://github.com/neoxygen/neo4j-neogen/blob/3bc3ae1b95aae13915ce699b4f2d20762b2f0146/src/Schema/Relationship.php#L131-L143
227,083
andre487/php_rutils
Numeral.php
Numeral.getPlural
public function getPlural($amount, array $variants, $absence = null) { if ($amount || $absence === null) { $result = RUtils::formatNumber($amount).' '.$this->choosePlural($amount, $variants); } else { $result = $absence; } return $result; }
php
public function getPlural($amount, array $variants, $absence = null) { if ($amount || $absence === null) { $result = RUtils::formatNumber($amount).' '.$this->choosePlural($amount, $variants); } else { $result = $absence; } return $result; }
[ "public", "function", "getPlural", "(", "$", "amount", ",", "array", "$", "variants", ",", "$", "absence", "=", "null", ")", "{", "if", "(", "$", "amount", "||", "$", "absence", "===", "null", ")", "{", "$", "result", "=", "RUtils", "::", "formatNumber", "(", "$", "amount", ")", ".", "' '", ".", "$", "this", "->", "choosePlural", "(", "$", "amount", ",", "$", "variants", ")", ";", "}", "else", "{", "$", "result", "=", "$", "absence", ";", "}", "return", "$", "result", ";", "}" ]
Get proper case with value @param int $amount Amount of objects @param array $variants Variants (forms) of object in such form: array('1 object', '2 objects', '5 objects') @param string|null $absence If amount is zero will return it @return string|null
[ "Get", "proper", "case", "with", "value" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L79-L87
227,084
andre487/php_rutils
Numeral.php
Numeral.choosePlural
public function choosePlural($amount, array $variants) { if (sizeof($variants) < 3) { throw new \InvalidArgumentException('Incorrect values length (must be 3)'); } $amount = abs($amount); $mod10 = $amount % 10; $mod100 = $amount % 100; if ($mod10 == 1 && $mod100 != 11) { $variant = 0; } elseif ($mod10 >= 2 && $mod10 <= 4 && !($mod100 > 10 && $mod100 < 20)) { $variant = 1; } else { $variant = 2; } return $variants[$variant]; }
php
public function choosePlural($amount, array $variants) { if (sizeof($variants) < 3) { throw new \InvalidArgumentException('Incorrect values length (must be 3)'); } $amount = abs($amount); $mod10 = $amount % 10; $mod100 = $amount % 100; if ($mod10 == 1 && $mod100 != 11) { $variant = 0; } elseif ($mod10 >= 2 && $mod10 <= 4 && !($mod100 > 10 && $mod100 < 20)) { $variant = 1; } else { $variant = 2; } return $variants[$variant]; }
[ "public", "function", "choosePlural", "(", "$", "amount", ",", "array", "$", "variants", ")", "{", "if", "(", "sizeof", "(", "$", "variants", ")", "<", "3", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Incorrect values length (must be 3)'", ")", ";", "}", "$", "amount", "=", "abs", "(", "$", "amount", ")", ";", "$", "mod10", "=", "$", "amount", "%", "10", ";", "$", "mod100", "=", "$", "amount", "%", "100", ";", "if", "(", "$", "mod10", "==", "1", "&&", "$", "mod100", "!=", "11", ")", "{", "$", "variant", "=", "0", ";", "}", "elseif", "(", "$", "mod10", ">=", "2", "&&", "$", "mod10", "<=", "4", "&&", "!", "(", "$", "mod100", ">", "10", "&&", "$", "mod100", "<", "20", ")", ")", "{", "$", "variant", "=", "1", ";", "}", "else", "{", "$", "variant", "=", "2", ";", "}", "return", "$", "variants", "[", "$", "variant", "]", ";", "}" ]
Choose proper case depending on amount @param int $amount Amount of objects @param string[] $variants Variants (forms) of object in such form: array('1 object', '2 objects', '5 objects') @return string Proper variant @throws \InvalidArgumentException Variants' length lesser than 3
[ "Choose", "proper", "case", "depending", "on", "amount" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L96-L115
227,085
andre487/php_rutils
Numeral.php
Numeral._sumStringOneOrder
private function _sumStringOneOrder($prevResult, $tmpVal, $gender, array $variants) { if ($tmpVal == 0) { return array($prevResult, $tmpVal); } $words = array(); $fiveItems = $variants[2]; $rest = $tmpVal % 1000; if ($rest < 0) { throw new \RangeException('Int overflow'); } $tmpVal = intval($tmpVal / 1000); //check last digits are 0 if ($rest == 0) { if (!$prevResult) { $prevResult = $fiveItems.' '; } return array($prevResult, $tmpVal); } //hundreds $words[] = self::$_HUNDREDS[intval($rest / 100)]; //tens $rest %= 100; $rest1 = intval($rest / 10); $words[] = ($rest1 == 1) ? self::$_TENS[$rest] : self::$_TENS[$rest1]; //ones if ($rest1 == 1) { $endWord = $fiveItems; } else { $amount = $rest % 10; $words[] = self::$_ONES[$amount][$gender - 1]; $endWord = $this->choosePlural($amount, $variants); } $words[] = $endWord; $words[] = $prevResult; $words = array_filter($words, 'strlen'); $result = trim(implode(' ', $words)); return array($result, $tmpVal); }
php
private function _sumStringOneOrder($prevResult, $tmpVal, $gender, array $variants) { if ($tmpVal == 0) { return array($prevResult, $tmpVal); } $words = array(); $fiveItems = $variants[2]; $rest = $tmpVal % 1000; if ($rest < 0) { throw new \RangeException('Int overflow'); } $tmpVal = intval($tmpVal / 1000); //check last digits are 0 if ($rest == 0) { if (!$prevResult) { $prevResult = $fiveItems.' '; } return array($prevResult, $tmpVal); } //hundreds $words[] = self::$_HUNDREDS[intval($rest / 100)]; //tens $rest %= 100; $rest1 = intval($rest / 10); $words[] = ($rest1 == 1) ? self::$_TENS[$rest] : self::$_TENS[$rest1]; //ones if ($rest1 == 1) { $endWord = $fiveItems; } else { $amount = $rest % 10; $words[] = self::$_ONES[$amount][$gender - 1]; $endWord = $this->choosePlural($amount, $variants); } $words[] = $endWord; $words[] = $prevResult; $words = array_filter($words, 'strlen'); $result = trim(implode(' ', $words)); return array($result, $tmpVal); }
[ "private", "function", "_sumStringOneOrder", "(", "$", "prevResult", ",", "$", "tmpVal", ",", "$", "gender", ",", "array", "$", "variants", ")", "{", "if", "(", "$", "tmpVal", "==", "0", ")", "{", "return", "array", "(", "$", "prevResult", ",", "$", "tmpVal", ")", ";", "}", "$", "words", "=", "array", "(", ")", ";", "$", "fiveItems", "=", "$", "variants", "[", "2", "]", ";", "$", "rest", "=", "$", "tmpVal", "%", "1000", ";", "if", "(", "$", "rest", "<", "0", ")", "{", "throw", "new", "\\", "RangeException", "(", "'Int overflow'", ")", ";", "}", "$", "tmpVal", "=", "intval", "(", "$", "tmpVal", "/", "1000", ")", ";", "//check last digits are 0", "if", "(", "$", "rest", "==", "0", ")", "{", "if", "(", "!", "$", "prevResult", ")", "{", "$", "prevResult", "=", "$", "fiveItems", ".", "' '", ";", "}", "return", "array", "(", "$", "prevResult", ",", "$", "tmpVal", ")", ";", "}", "//hundreds", "$", "words", "[", "]", "=", "self", "::", "$", "_HUNDREDS", "[", "intval", "(", "$", "rest", "/", "100", ")", "]", ";", "//tens", "$", "rest", "%=", "100", ";", "$", "rest1", "=", "intval", "(", "$", "rest", "/", "10", ")", ";", "$", "words", "[", "]", "=", "(", "$", "rest1", "==", "1", ")", "?", "self", "::", "$", "_TENS", "[", "$", "rest", "]", ":", "self", "::", "$", "_TENS", "[", "$", "rest1", "]", ";", "//ones", "if", "(", "$", "rest1", "==", "1", ")", "{", "$", "endWord", "=", "$", "fiveItems", ";", "}", "else", "{", "$", "amount", "=", "$", "rest", "%", "10", ";", "$", "words", "[", "]", "=", "self", "::", "$", "_ONES", "[", "$", "amount", "]", "[", "$", "gender", "-", "1", "]", ";", "$", "endWord", "=", "$", "this", "->", "choosePlural", "(", "$", "amount", ",", "$", "variants", ")", ";", "}", "$", "words", "[", "]", "=", "$", "endWord", ";", "$", "words", "[", "]", "=", "$", "prevResult", ";", "$", "words", "=", "array_filter", "(", "$", "words", ",", "'strlen'", ")", ";", "$", "result", "=", "trim", "(", "implode", "(", "' '", ",", "$", "words", ")", ")", ";", "return", "array", "(", "$", "result", ",", "$", "tmpVal", ")", ";", "}" ]
Make in-words representation of single order @param string $prevResult In-words representation of lower orders @param int $tmpVal Temporary value without lower orders @param int $gender (MALE, FEMALE or NEUTER) @param string[] $variants Variants of objects @throws \RangeException @return array ($result, $tmpVal)
[ "Make", "in", "-", "words", "representation", "of", "single", "order" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L180-L226
227,086
andre487/php_rutils
Numeral.php
Numeral.getInWords
public function getInWords($amount, $gender = RUtils::MALE) { if ($amount == (int)$amount) { return $this->getInWordsInt($amount, $gender); } else { return $this->getInWordsFloat($amount); } }
php
public function getInWords($amount, $gender = RUtils::MALE) { if ($amount == (int)$amount) { return $this->getInWordsInt($amount, $gender); } else { return $this->getInWordsFloat($amount); } }
[ "public", "function", "getInWords", "(", "$", "amount", ",", "$", "gender", "=", "RUtils", "::", "MALE", ")", "{", "if", "(", "$", "amount", "==", "(", "int", ")", "$", "amount", ")", "{", "return", "$", "this", "->", "getInWordsInt", "(", "$", "amount", ",", "$", "gender", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getInWordsFloat", "(", "$", "amount", ")", ";", "}", "}" ]
Numeral in words @param float $amount Amount of objects @param int|null $gender (MALE, FEMALE, NEUTER or null) @return string In-words representation of numeral
[ "Numeral", "in", "words" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L234-L241
227,087
andre487/php_rutils
Numeral.php
Numeral.getInWordsInt
public function getInWordsInt($amount, $gender = RUtils::MALE) { $amount = round($amount); return $this->sumString($amount, $gender); }
php
public function getInWordsInt($amount, $gender = RUtils::MALE) { $amount = round($amount); return $this->sumString($amount, $gender); }
[ "public", "function", "getInWordsInt", "(", "$", "amount", ",", "$", "gender", "=", "RUtils", "::", "MALE", ")", "{", "$", "amount", "=", "round", "(", "$", "amount", ")", ";", "return", "$", "this", "->", "sumString", "(", "$", "amount", ",", "$", "gender", ")", ";", "}" ]
Integer in words @param int $amount Amount of objects (0 <= amount <= PHP_INT_MAX) @param int $gender (MALE, FEMALE or NEUTER) @return string In-words representation of numeral
[ "Integer", "in", "words" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L249-L253
227,088
andre487/php_rutils
Numeral.php
Numeral._getFloatRemainder
private function _getFloatRemainder($value, $signs = 9) { if ($value == (int)$value) { return '0'; } $signs = min($signs, sizeof(self::$_FRACTIONS)); $value = number_format($value, $signs, '.', ''); list(, $remainder) = explode('.', $value); $remainder = preg_replace('/0+$/', '', $remainder); if (!$remainder) { $remainder = '0'; } return $remainder; }
php
private function _getFloatRemainder($value, $signs = 9) { if ($value == (int)$value) { return '0'; } $signs = min($signs, sizeof(self::$_FRACTIONS)); $value = number_format($value, $signs, '.', ''); list(, $remainder) = explode('.', $value); $remainder = preg_replace('/0+$/', '', $remainder); if (!$remainder) { $remainder = '0'; } return $remainder; }
[ "private", "function", "_getFloatRemainder", "(", "$", "value", ",", "$", "signs", "=", "9", ")", "{", "if", "(", "$", "value", "==", "(", "int", ")", "$", "value", ")", "{", "return", "'0'", ";", "}", "$", "signs", "=", "min", "(", "$", "signs", ",", "sizeof", "(", "self", "::", "$", "_FRACTIONS", ")", ")", ";", "$", "value", "=", "number_format", "(", "$", "value", ",", "$", "signs", ",", "'.'", ",", "''", ")", ";", "list", "(", ",", "$", "remainder", ")", "=", "explode", "(", "'.'", ",", "$", "value", ")", ";", "$", "remainder", "=", "preg_replace", "(", "'/0+$/'", ",", "''", ",", "$", "remainder", ")", ";", "if", "(", "!", "$", "remainder", ")", "{", "$", "remainder", "=", "'0'", ";", "}", "return", "$", "remainder", ";", "}" ]
Get remainder of float, i.e. 2.05 -> '05' @param float $value @param int $signs @return string
[ "Get", "remainder", "of", "float", "i", ".", "e", ".", "2", ".", "05", "-", ">", "05" ]
f85a9f17d55259458326f657211c7b411a30bc53
https://github.com/andre487/php_rutils/blob/f85a9f17d55259458326f657211c7b411a30bc53/Numeral.php#L282-L297
227,089
hscstudio/yii2-heart
modules/admin/items/AssigmentController.php
AssigmentController.actionIndex
public function actionIndex() { if($this->searchClass === null){ $searchModel = new AssigmentSearch; } else { $class = $this->searchClass; $searchModel = new $class; } $dataProvider = $searchModel->search(\Yii::$app->request->getQueryParams(), $this->userClassName, $this->usernameField); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'idField' => $this->idField, 'usernameField' => $this->usernameField, ]); }
php
public function actionIndex() { if($this->searchClass === null){ $searchModel = new AssigmentSearch; } else { $class = $this->searchClass; $searchModel = new $class; } $dataProvider = $searchModel->search(\Yii::$app->request->getQueryParams(), $this->userClassName, $this->usernameField); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'idField' => $this->idField, 'usernameField' => $this->usernameField, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "if", "(", "$", "this", "->", "searchClass", "===", "null", ")", "{", "$", "searchModel", "=", "new", "AssigmentSearch", ";", "}", "else", "{", "$", "class", "=", "$", "this", "->", "searchClass", ";", "$", "searchModel", "=", "new", "$", "class", ";", "}", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ",", "$", "this", "->", "userClassName", ",", "$", "this", "->", "usernameField", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'searchModel'", "=>", "$", "searchModel", ",", "'idField'", "=>", "$", "this", "->", "idField", ",", "'usernameField'", "=>", "$", "this", "->", "usernameField", ",", "]", ")", ";", "}" ]
Lists all Assigment models. @return mixed
[ "Lists", "all", "Assigment", "models", "." ]
7c54c7794c5045c0beb1d8bd70b287278eddbeee
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/modules/admin/items/AssigmentController.php#L50-L67
227,090
hscstudio/yii2-heart
modules/admin/items/AssigmentController.php
AssigmentController.actionView
public function actionView($id) { $model = $this->findModel($id); $authManager = Yii::$app->authManager; $avaliable = []; foreach ($authManager->getRoles() as $role) { $avaliable[$role->name] = $role->name; } $assigned = []; foreach ($authManager->getRolesByUser($id) as $role) { $assigned[$role->name] = $role->name; unset($avaliable[$role->name]); } return $this->render('view', [ 'model' => $model, 'avaliable' => $avaliable, 'assigned' => $assigned, 'idField' => $this->idField, 'usernameField' => $this->usernameField, ]); }
php
public function actionView($id) { $model = $this->findModel($id); $authManager = Yii::$app->authManager; $avaliable = []; foreach ($authManager->getRoles() as $role) { $avaliable[$role->name] = $role->name; } $assigned = []; foreach ($authManager->getRolesByUser($id) as $role) { $assigned[$role->name] = $role->name; unset($avaliable[$role->name]); } return $this->render('view', [ 'model' => $model, 'avaliable' => $avaliable, 'assigned' => $assigned, 'idField' => $this->idField, 'usernameField' => $this->usernameField, ]); }
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "authManager", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "avaliable", "=", "[", "]", ";", "foreach", "(", "$", "authManager", "->", "getRoles", "(", ")", "as", "$", "role", ")", "{", "$", "avaliable", "[", "$", "role", "->", "name", "]", "=", "$", "role", "->", "name", ";", "}", "$", "assigned", "=", "[", "]", ";", "foreach", "(", "$", "authManager", "->", "getRolesByUser", "(", "$", "id", ")", "as", "$", "role", ")", "{", "$", "assigned", "[", "$", "role", "->", "name", "]", "=", "$", "role", "->", "name", ";", "unset", "(", "$", "avaliable", "[", "$", "role", "->", "name", "]", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'view'", ",", "[", "'model'", "=>", "$", "model", ",", "'avaliable'", "=>", "$", "avaliable", ",", "'assigned'", "=>", "$", "assigned", ",", "'idField'", "=>", "$", "this", "->", "idField", ",", "'usernameField'", "=>", "$", "this", "->", "usernameField", ",", "]", ")", ";", "}" ]
Displays a single Assigment model. @param integer $id @return mixed
[ "Displays", "a", "single", "Assigment", "model", "." ]
7c54c7794c5045c0beb1d8bd70b287278eddbeee
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/modules/admin/items/AssigmentController.php#L74-L94
227,091
aik099/CodingStandard
CodingStandard/Sniffs/Strings/ConcatenationSpacingSniff.php
ConcatenationSpacingSniff.checkContent
protected function checkContent(File $phpcsFile, $stackPtr, $before) { if ($before === true) { $contentToken = ($phpcsFile->findPrevious( T_WHITESPACE, ($stackPtr - 1), null, true ) + 1); $errorWord = 'before'; } else { $contentToken = ($phpcsFile->findNext( T_WHITESPACE, ($stackPtr + 1), null, true ) - 1); $errorWord = 'after'; } $tokens = $phpcsFile->getTokens(); $contentData = $tokens[$contentToken]; if ($contentData['line'] !== $tokens[$stackPtr]['line']) { // Ignore concat operator split across several lines. return; } if ($contentData['code'] !== T_WHITESPACE) { $fix = $phpcsFile->addFixableError( 'Expected 1 space '.$errorWord.' concat operator; 0 found', $stackPtr, 'NoSpace'.ucfirst($errorWord) ); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); if ($before === true) { $phpcsFile->fixer->addContentBefore($stackPtr, ' '); } else { $phpcsFile->fixer->addContent($stackPtr, ' '); } $phpcsFile->fixer->endChangeset(); } } elseif ($contentData['length'] !== 1) { $data = array($contentData['length']); $fix = $phpcsFile->addFixableError( 'Expected 1 space '.$errorWord.' concat operator; %s found', $stackPtr, 'SpaceBefore'.ucfirst($errorWord), $data ); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken($contentToken, ' '); $phpcsFile->fixer->endChangeset(); } } }
php
protected function checkContent(File $phpcsFile, $stackPtr, $before) { if ($before === true) { $contentToken = ($phpcsFile->findPrevious( T_WHITESPACE, ($stackPtr - 1), null, true ) + 1); $errorWord = 'before'; } else { $contentToken = ($phpcsFile->findNext( T_WHITESPACE, ($stackPtr + 1), null, true ) - 1); $errorWord = 'after'; } $tokens = $phpcsFile->getTokens(); $contentData = $tokens[$contentToken]; if ($contentData['line'] !== $tokens[$stackPtr]['line']) { // Ignore concat operator split across several lines. return; } if ($contentData['code'] !== T_WHITESPACE) { $fix = $phpcsFile->addFixableError( 'Expected 1 space '.$errorWord.' concat operator; 0 found', $stackPtr, 'NoSpace'.ucfirst($errorWord) ); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); if ($before === true) { $phpcsFile->fixer->addContentBefore($stackPtr, ' '); } else { $phpcsFile->fixer->addContent($stackPtr, ' '); } $phpcsFile->fixer->endChangeset(); } } elseif ($contentData['length'] !== 1) { $data = array($contentData['length']); $fix = $phpcsFile->addFixableError( 'Expected 1 space '.$errorWord.' concat operator; %s found', $stackPtr, 'SpaceBefore'.ucfirst($errorWord), $data ); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken($contentToken, ' '); $phpcsFile->fixer->endChangeset(); } } }
[ "protected", "function", "checkContent", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "before", ")", "{", "if", "(", "$", "before", "===", "true", ")", "{", "$", "contentToken", "=", "(", "$", "phpcsFile", "->", "findPrevious", "(", "T_WHITESPACE", ",", "(", "$", "stackPtr", "-", "1", ")", ",", "null", ",", "true", ")", "+", "1", ")", ";", "$", "errorWord", "=", "'before'", ";", "}", "else", "{", "$", "contentToken", "=", "(", "$", "phpcsFile", "->", "findNext", "(", "T_WHITESPACE", ",", "(", "$", "stackPtr", "+", "1", ")", ",", "null", ",", "true", ")", "-", "1", ")", ";", "$", "errorWord", "=", "'after'", ";", "}", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "contentData", "=", "$", "tokens", "[", "$", "contentToken", "]", ";", "if", "(", "$", "contentData", "[", "'line'", "]", "!==", "$", "tokens", "[", "$", "stackPtr", "]", "[", "'line'", "]", ")", "{", "// Ignore concat operator split across several lines.", "return", ";", "}", "if", "(", "$", "contentData", "[", "'code'", "]", "!==", "T_WHITESPACE", ")", "{", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "'Expected 1 space '", ".", "$", "errorWord", ".", "' concat operator; 0 found'", ",", "$", "stackPtr", ",", "'NoSpace'", ".", "ucfirst", "(", "$", "errorWord", ")", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "if", "(", "$", "before", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "addContentBefore", "(", "$", "stackPtr", ",", "' '", ")", ";", "}", "else", "{", "$", "phpcsFile", "->", "fixer", "->", "addContent", "(", "$", "stackPtr", ",", "' '", ")", ";", "}", "$", "phpcsFile", "->", "fixer", "->", "endChangeset", "(", ")", ";", "}", "}", "elseif", "(", "$", "contentData", "[", "'length'", "]", "!==", "1", ")", "{", "$", "data", "=", "array", "(", "$", "contentData", "[", "'length'", "]", ")", ";", "$", "fix", "=", "$", "phpcsFile", "->", "addFixableError", "(", "'Expected 1 space '", ".", "$", "errorWord", ".", "' concat operator; %s found'", ",", "$", "stackPtr", ",", "'SpaceBefore'", ".", "ucfirst", "(", "$", "errorWord", ")", ",", "$", "data", ")", ";", "if", "(", "$", "fix", "===", "true", ")", "{", "$", "phpcsFile", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "phpcsFile", "->", "fixer", "->", "replaceToken", "(", "$", "contentToken", ",", "' '", ")", ";", "$", "phpcsFile", "->", "fixer", "->", "endChangeset", "(", ")", ";", "}", "}", "}" ]
Checks content before concat operator. @param File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param bool $before Check content before concat operator. @return void
[ "Checks", "content", "before", "concat", "operator", "." ]
0f65c52bf2d95d5068af9f73110770ddb9de8de7
https://github.com/aik099/CodingStandard/blob/0f65c52bf2d95d5068af9f73110770ddb9de8de7/CodingStandard/Sniffs/Strings/ConcatenationSpacingSniff.php#L74-L135
227,092
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/CollectionProvider.php
CollectionProvider.transformCollectionData
private function transformCollectionData($columnConfiguration, $searchFunc) { $this->collection->transform(function ($data) use ($columnConfiguration, $searchFunc) { $entry = []; // for each column call the callback foreach ($columnConfiguration as $i => $col) { $func = $col->getCallable(); $entry[$col->getName()] = $func($data); if ($this->queryConfiguration->hasSearchColumn($col->getName())) { // column search exists, so check if the column matches the search if (!$this->columnSearchFunction[$col->getName()]($entry, $this->queryConfiguration->searchColumns()[$col->getName()]) ) { // did not match, so return an empty array, the row will be removed later return []; } } } // also do search right away if ($this->queryConfiguration->isGlobalSearch()) { if (!$searchFunc($entry, $this->queryConfiguration->searchValue(), $this->columnConfiguration)) { $entry = []; } } return $entry; }); }
php
private function transformCollectionData($columnConfiguration, $searchFunc) { $this->collection->transform(function ($data) use ($columnConfiguration, $searchFunc) { $entry = []; // for each column call the callback foreach ($columnConfiguration as $i => $col) { $func = $col->getCallable(); $entry[$col->getName()] = $func($data); if ($this->queryConfiguration->hasSearchColumn($col->getName())) { // column search exists, so check if the column matches the search if (!$this->columnSearchFunction[$col->getName()]($entry, $this->queryConfiguration->searchColumns()[$col->getName()]) ) { // did not match, so return an empty array, the row will be removed later return []; } } } // also do search right away if ($this->queryConfiguration->isGlobalSearch()) { if (!$searchFunc($entry, $this->queryConfiguration->searchValue(), $this->columnConfiguration)) { $entry = []; } } return $entry; }); }
[ "private", "function", "transformCollectionData", "(", "$", "columnConfiguration", ",", "$", "searchFunc", ")", "{", "$", "this", "->", "collection", "->", "transform", "(", "function", "(", "$", "data", ")", "use", "(", "$", "columnConfiguration", ",", "$", "searchFunc", ")", "{", "$", "entry", "=", "[", "]", ";", "// for each column call the callback", "foreach", "(", "$", "columnConfiguration", "as", "$", "i", "=>", "$", "col", ")", "{", "$", "func", "=", "$", "col", "->", "getCallable", "(", ")", ";", "$", "entry", "[", "$", "col", "->", "getName", "(", ")", "]", "=", "$", "func", "(", "$", "data", ")", ";", "if", "(", "$", "this", "->", "queryConfiguration", "->", "hasSearchColumn", "(", "$", "col", "->", "getName", "(", ")", ")", ")", "{", "// column search exists, so check if the column matches the search", "if", "(", "!", "$", "this", "->", "columnSearchFunction", "[", "$", "col", "->", "getName", "(", ")", "]", "(", "$", "entry", ",", "$", "this", "->", "queryConfiguration", "->", "searchColumns", "(", ")", "[", "$", "col", "->", "getName", "(", ")", "]", ")", ")", "{", "// did not match, so return an empty array, the row will be removed later", "return", "[", "]", ";", "}", "}", "}", "// also do search right away", "if", "(", "$", "this", "->", "queryConfiguration", "->", "isGlobalSearch", "(", ")", ")", "{", "if", "(", "!", "$", "searchFunc", "(", "$", "entry", ",", "$", "this", "->", "queryConfiguration", "->", "searchValue", "(", ")", ",", "$", "this", "->", "columnConfiguration", ")", ")", "{", "$", "entry", "=", "[", "]", ";", "}", "}", "return", "$", "entry", ";", "}", ")", ";", "}" ]
Transform collection data. Used for searches. @param ColumnConfiguration[] $columnConfiguration @param $searchFunc
[ "Transform", "collection", "data", ".", "Used", "for", "searches", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/CollectionProvider.php#L150-L178
227,093
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/CollectionProvider.php
CollectionProvider.removeEmptyRowsFromCollection
private function removeEmptyRowsFromCollection() { $this->collection = $this->collection->reject(function ($data) { if (empty($data)) { return true; } else { return false; } }); }
php
private function removeEmptyRowsFromCollection() { $this->collection = $this->collection->reject(function ($data) { if (empty($data)) { return true; } else { return false; } }); }
[ "private", "function", "removeEmptyRowsFromCollection", "(", ")", "{", "$", "this", "->", "collection", "=", "$", "this", "->", "collection", "->", "reject", "(", "function", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", ")", ";", "}" ]
Remove the empty rows from the collection @see compileCollection
[ "Remove", "the", "empty", "rows", "from", "the", "collection" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/CollectionProvider.php#L185-L194
227,094
OpenSkill/Datatable
src/OpenSkill/Datatable/Providers/CollectionProvider.php
CollectionProvider.sortCollection
private function sortCollection() { if ($this->queryConfiguration->hasOrderColumn()) { $order = $this->queryConfiguration->orderColumns(); $orderFunc = $this->defaultGlobalOrderFunction; $this->collection = $this->collection->sort(function ($first, $second) use ($order, $orderFunc) { return $orderFunc($first, $second, $order); }); } }
php
private function sortCollection() { if ($this->queryConfiguration->hasOrderColumn()) { $order = $this->queryConfiguration->orderColumns(); $orderFunc = $this->defaultGlobalOrderFunction; $this->collection = $this->collection->sort(function ($first, $second) use ($order, $orderFunc) { return $orderFunc($first, $second, $order); }); } }
[ "private", "function", "sortCollection", "(", ")", "{", "if", "(", "$", "this", "->", "queryConfiguration", "->", "hasOrderColumn", "(", ")", ")", "{", "$", "order", "=", "$", "this", "->", "queryConfiguration", "->", "orderColumns", "(", ")", ";", "$", "orderFunc", "=", "$", "this", "->", "defaultGlobalOrderFunction", ";", "$", "this", "->", "collection", "=", "$", "this", "->", "collection", "->", "sort", "(", "function", "(", "$", "first", ",", "$", "second", ")", "use", "(", "$", "order", ",", "$", "orderFunc", ")", "{", "return", "$", "orderFunc", "(", "$", "first", ",", "$", "second", ",", "$", "order", ")", ";", "}", ")", ";", "}", "}" ]
Will sort the internal collection based on the given query configuration. Most tables only support the ordering by just one column, but we will enable sorting on all columns here
[ "Will", "sort", "the", "internal", "collection", "based", "on", "the", "given", "query", "configuration", ".", "Most", "tables", "only", "support", "the", "ordering", "by", "just", "one", "column", "but", "we", "will", "enable", "sorting", "on", "all", "columns", "here" ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Providers/CollectionProvider.php#L236-L245
227,095
OpenSkill/Datatable
src/OpenSkill/Datatable/Versions/Datatable19Version.php
Datatable19Version.createResponse
public function createResponse( ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfigurations ) { $responseData = [ 'sEcho' => $queryConfiguration->drawCall(), 'iTotalRecords' => $data->totalDataCount(), 'iTotalDisplayRecords' => $data->filteredDataCount(), 'aaData' => $data->data()->toArray() ]; return new JsonResponse($responseData); }
php
public function createResponse( ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfigurations ) { $responseData = [ 'sEcho' => $queryConfiguration->drawCall(), 'iTotalRecords' => $data->totalDataCount(), 'iTotalDisplayRecords' => $data->filteredDataCount(), 'aaData' => $data->data()->toArray() ]; return new JsonResponse($responseData); }
[ "public", "function", "createResponse", "(", "ResponseData", "$", "data", ",", "QueryConfiguration", "$", "queryConfiguration", ",", "array", "$", "columnConfigurations", ")", "{", "$", "responseData", "=", "[", "'sEcho'", "=>", "$", "queryConfiguration", "->", "drawCall", "(", ")", ",", "'iTotalRecords'", "=>", "$", "data", "->", "totalDataCount", "(", ")", ",", "'iTotalDisplayRecords'", "=>", "$", "data", "->", "filteredDataCount", "(", ")", ",", "'aaData'", "=>", "$", "data", "->", "data", "(", ")", "->", "toArray", "(", ")", "]", ";", "return", "new", "JsonResponse", "(", "$", "responseData", ")", ";", "}" ]
Is responsible to take the generated data and prepare a response for it. @param ResponseData $data The processed data. @param QueryConfiguration $queryConfiguration the query configuration for the current request. @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table. @return JsonResponse the response that should be returned to the client.
[ "Is", "responsible", "to", "take", "the", "generated", "data", "and", "prepare", "a", "response", "for", "it", "." ]
e9814345dca4d0427da512f17c24117797e6ffbb
https://github.com/OpenSkill/Datatable/blob/e9814345dca4d0427da512f17c24117797e6ffbb/src/OpenSkill/Datatable/Versions/Datatable19Version.php#L41-L54
227,096
hscstudio/yii2-heart
helpers/Kalkun.php
Kalkun.HexToAscii
public static function HexToAscii($hex) { $ascii = ''; if (strlen($hex) % 2 == 1) $hex = '0'.$hex; for($i = 0; $i < strlen($hex); $i += 2) $ascii .= chr(base_convert(substr($hex, $i, 2), 16, 10)); return $ascii; }
php
public static function HexToAscii($hex) { $ascii = ''; if (strlen($hex) % 2 == 1) $hex = '0'.$hex; for($i = 0; $i < strlen($hex); $i += 2) $ascii .= chr(base_convert(substr($hex, $i, 2), 16, 10)); return $ascii; }
[ "public", "static", "function", "HexToAscii", "(", "$", "hex", ")", "{", "$", "ascii", "=", "''", ";", "if", "(", "strlen", "(", "$", "hex", ")", "%", "2", "==", "1", ")", "$", "hex", "=", "'0'", ".", "$", "hex", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "hex", ")", ";", "$", "i", "+=", "2", ")", "$", "ascii", ".=", "chr", "(", "base_convert", "(", "substr", "(", "$", "hex", ",", "$", "i", ",", "2", ")", ",", "16", ",", "10", ")", ")", ";", "return", "$", "ascii", ";", "}" ]
of characters in length
[ "of", "characters", "in", "length" ]
7c54c7794c5045c0beb1d8bd70b287278eddbeee
https://github.com/hscstudio/yii2-heart/blob/7c54c7794c5045c0beb1d8bd70b287278eddbeee/helpers/Kalkun.php#L32-L43
227,097
javanile/moldable
src/Writer/MysqlWriter.php
MysqlWriter.createTable
public function createTable($table, $schema) { // $columnsArray = []; // loop throut schema foreach ($schema as $field => $attributes) { if (is_numeric($field) && is_string($attributes)) { $field = $attributes; $attributes = []; } // $column = $this->columnDefinition($attributes, false); // $columnsArray[] = "`{$field}` {$column}"; } // implode $columns = implode(',', $columnsArray); // template sql to create table $sql = "CREATE TABLE `{$table}` ({$columns})"; // return the sql return $sql; }
php
public function createTable($table, $schema) { // $columnsArray = []; // loop throut schema foreach ($schema as $field => $attributes) { if (is_numeric($field) && is_string($attributes)) { $field = $attributes; $attributes = []; } // $column = $this->columnDefinition($attributes, false); // $columnsArray[] = "`{$field}` {$column}"; } // implode $columns = implode(',', $columnsArray); // template sql to create table $sql = "CREATE TABLE `{$table}` ({$columns})"; // return the sql return $sql; }
[ "public", "function", "createTable", "(", "$", "table", ",", "$", "schema", ")", "{", "//", "$", "columnsArray", "=", "[", "]", ";", "// loop throut schema", "foreach", "(", "$", "schema", "as", "$", "field", "=>", "$", "attributes", ")", "{", "if", "(", "is_numeric", "(", "$", "field", ")", "&&", "is_string", "(", "$", "attributes", ")", ")", "{", "$", "field", "=", "$", "attributes", ";", "$", "attributes", "=", "[", "]", ";", "}", "//", "$", "column", "=", "$", "this", "->", "columnDefinition", "(", "$", "attributes", ",", "false", ")", ";", "//", "$", "columnsArray", "[", "]", "=", "\"`{$field}` {$column}\"", ";", "}", "// implode", "$", "columns", "=", "implode", "(", "','", ",", "$", "columnsArray", ")", ";", "// template sql to create table", "$", "sql", "=", "\"CREATE TABLE `{$table}` ({$columns})\"", ";", "// return the sql", "return", "$", "sql", ";", "}" ]
Prepare sql code to create a table. @param string $table The name of table to create @param array $schema Skema of the table contain column definitions @return string Sql code statament of CREATE TABLE
[ "Prepare", "sql", "code", "to", "create", "a", "table", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Writer/MysqlWriter.php#L68-L95
227,098
javanile/moldable
src/Writer/MysqlWriter.php
MysqlWriter.alterTableChange
public function alterTableChange($table, $field, $attributes) { // $column = $this->columnDefinition($attributes); // $sql = "ALTER TABLE `{$table}` CHANGE COLUMN `{$field}` `{$field}` {$column}"; // return $sql; }
php
public function alterTableChange($table, $field, $attributes) { // $column = $this->columnDefinition($attributes); // $sql = "ALTER TABLE `{$table}` CHANGE COLUMN `{$field}` `{$field}` {$column}"; // return $sql; }
[ "public", "function", "alterTableChange", "(", "$", "table", ",", "$", "field", ",", "$", "attributes", ")", "{", "//", "$", "column", "=", "$", "this", "->", "columnDefinition", "(", "$", "attributes", ")", ";", "//", "$", "sql", "=", "\"ALTER TABLE `{$table}` CHANGE COLUMN `{$field}` `{$field}` {$column}\"", ";", "//", "return", "$", "sql", ";", "}" ]
Retrieve sql to alter table definition. @param type $t @param type $f @param type $d @param mixed $table @param mixed $field @param mixed $attributes @return type
[ "Retrieve", "sql", "to", "alter", "table", "definition", "." ]
463ec60ba1fc00ffac39416302103af47aae42fb
https://github.com/javanile/moldable/blob/463ec60ba1fc00ffac39416302103af47aae42fb/src/Writer/MysqlWriter.php#L128-L138
227,099
BootstrapCMS/Credentials
src/Repositories/PaginateRepositoryTrait.php
PaginateRepositoryTrait.paginate
public function paginate() { $model = $this->model; if (property_exists($model, 'order')) { $paginator = $model::orderBy($model::$order, $model::$sort)->paginate($model::$paginate, $model::$index); } else { $paginator = $model::paginate($model::$paginate, $model::$index); } if (!$this->isPageInRange($paginator) && !$this->isFirstPage($paginator)) { throw new NotFoundHttpException(); } if (count($paginator)) { $this->paginateLinks = $paginator->render(); } return $paginator; }
php
public function paginate() { $model = $this->model; if (property_exists($model, 'order')) { $paginator = $model::orderBy($model::$order, $model::$sort)->paginate($model::$paginate, $model::$index); } else { $paginator = $model::paginate($model::$paginate, $model::$index); } if (!$this->isPageInRange($paginator) && !$this->isFirstPage($paginator)) { throw new NotFoundHttpException(); } if (count($paginator)) { $this->paginateLinks = $paginator->render(); } return $paginator; }
[ "public", "function", "paginate", "(", ")", "{", "$", "model", "=", "$", "this", "->", "model", ";", "if", "(", "property_exists", "(", "$", "model", ",", "'order'", ")", ")", "{", "$", "paginator", "=", "$", "model", "::", "orderBy", "(", "$", "model", "::", "$", "order", ",", "$", "model", "::", "$", "sort", ")", "->", "paginate", "(", "$", "model", "::", "$", "paginate", ",", "$", "model", "::", "$", "index", ")", ";", "}", "else", "{", "$", "paginator", "=", "$", "model", "::", "paginate", "(", "$", "model", "::", "$", "paginate", ",", "$", "model", "::", "$", "index", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isPageInRange", "(", "$", "paginator", ")", "&&", "!", "$", "this", "->", "isFirstPage", "(", "$", "paginator", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", ")", ";", "}", "if", "(", "count", "(", "$", "paginator", ")", ")", "{", "$", "this", "->", "paginateLinks", "=", "$", "paginator", "->", "render", "(", ")", ";", "}", "return", "$", "paginator", ";", "}" ]
Get a paginated list of the models. @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException @return \Illuminate\Database\Eloquent\Collection
[ "Get", "a", "paginated", "list", "of", "the", "models", "." ]
128c5359eea7417ca95670933a28d4e6c7e01e6b
https://github.com/BootstrapCMS/Credentials/blob/128c5359eea7417ca95670933a28d4e6c7e01e6b/src/Repositories/PaginateRepositoryTrait.php#L38-L57