id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,700
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Save
function Save($id, $data = null) { if (!$id) return; $this->LoadSchema(); if (is_array($id)) { $data = $id; if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by return; $id = $data[$this->schema['_id']['field']]; } else { $data[$this->schema['_id']['field']] = $id; } if (!$data) return; if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'save', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved) $this->trigger('save', $id, $data); if (!$this->continue) return FALSE; if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->update($this->table, $data); $this->Trigger('saved', $id, $save); $this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data return $this->returnRow ? $this->Get($id) : $save; }
php
function Save($id, $data = null) { if (!$id) return; $this->LoadSchema(); if (is_array($id)) { $data = $id; if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by return; $id = $data[$this->schema['_id']['field']]; } else { $data[$this->schema['_id']['field']] = $id; } if (!$data) return; if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'save', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved) $this->trigger('save', $id, $data); if (!$this->continue) return FALSE; if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->update($this->table, $data); $this->Trigger('saved', $id, $save); $this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data return $this->returnRow ? $this->Get($id) : $save; }
[ "function", "Save", "(", "$", "id", ",", "$", "data", "=", "null", ")", "{", "if", "(", "!", "$", "id", ")", "return", ";", "$", "this", "->", "LoadSchema", "(", ")", ";", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "$", "data", "=", "$", "id", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "]", ")", ")", "// Incomming data has no ID to address by", "return", ";", "$", "id", "=", "$", "data", "[", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "]", ";", "}", "else", "{", "$", "data", "[", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "]", "=", "$", "id", ";", "}", "if", "(", "!", "$", "data", ")", "return", ";", "if", "(", "$", "this", "->", "enforceTypes", ")", "foreach", "(", "$", "this", "->", "schema", "as", "$", "key", "=>", "$", "props", ")", "if", "(", "isset", "(", "$", "data", "[", "$", "key", "]", ")", "||", "$", "props", "[", "'type'", "]", "==", "'json-import'", ")", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "UnCastType", "(", "$", "props", "[", "'type'", "]", ",", "isset", "(", "$", "data", "[", "$", "key", "]", ")", "?", "$", "data", "[", "$", "key", "]", ":", "null", ",", "$", "data", ")", ";", "$", "this", "->", "ResetQuery", "(", "array", "(", "'method'", "=>", "'save'", ",", "'table'", "=>", "$", "this", "->", "table", ",", "'where'", "=>", "array", "(", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "=>", "$", "id", ",", ")", ",", "'data'", "=>", "$", "data", ",", ")", ")", ";", "$", "this", "->", "Trigger", "(", "'access'", ",", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "$", "this", "->", "Trigger", "(", "'push'", ",", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "unset", "(", "$", "data", "[", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "]", ")", ";", "// Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved)", "$", "this", "->", "trigger", "(", "'save'", ",", "$", "id", ",", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "if", "(", "!", "$", "data", "=", "$", "this", "->", "FilterFields", "(", "$", "data", ",", "'set'", ")", ")", "// Nothing to save", "return", "FALSE", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "$", "this", "->", "db", "->", "where", "(", "\"{$this->table}.{$this->schema['_id']['field']}\"", ",", "$", "id", ")", ";", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "table", ",", "$", "data", ")", ";", "$", "this", "->", "Trigger", "(", "'saved'", ",", "$", "id", ",", "$", "save", ")", ";", "$", "this", "->", "ClearCache", "(", "'get'", ",", "$", "id", ")", ";", "// Wipe the cache so the next get() doesn't return cached data", "return", "$", "this", "->", "returnRow", "?", "$", "this", "->", "Get", "(", "$", "id", ")", ":", "$", "save", ";", "}" ]
Attempt to save a database record using the provided data Calls the 'save' trigger on the data before it is saved @param mixed|array $id The ID to use to identify the record to change or the full row to save (data will be ignored) @param array $data A hash of data to attempt to store (optional if ID is the full row) @return null|array If $returnRow is true this function will return the newly saved object, if FALSE the array of data saved
[ "Attempt", "to", "save", "a", "database", "record", "using", "the", "provided", "data", "Calls", "the", "save", "trigger", "on", "the", "data", "before", "it", "is", "saved" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L937-L995
240,701
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Delete
function Delete($id) { $this->LoadSchema(); $data = array($this->schema['_id']['field'] => $id); $this->ResetQuery(array( 'method' => 'delete', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('delete', $id); if (!$id) return FALSE; if (!$this->continue) return FALSE; $this->db->from($this->table); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->delete(); $this->Trigger('deleted', $id); return TRUE; }
php
function Delete($id) { $this->LoadSchema(); $data = array($this->schema['_id']['field'] => $id); $this->ResetQuery(array( 'method' => 'delete', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('delete', $id); if (!$id) return FALSE; if (!$this->continue) return FALSE; $this->db->from($this->table); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->delete(); $this->Trigger('deleted', $id); return TRUE; }
[ "function", "Delete", "(", "$", "id", ")", "{", "$", "this", "->", "LoadSchema", "(", ")", ";", "$", "data", "=", "array", "(", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "=>", "$", "id", ")", ";", "$", "this", "->", "ResetQuery", "(", "array", "(", "'method'", "=>", "'delete'", ",", "'table'", "=>", "$", "this", "->", "table", ",", "'where'", "=>", "array", "(", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "=>", "$", "id", ",", ")", ",", ")", ")", ";", "$", "this", "->", "Trigger", "(", "'access'", ",", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "$", "this", "->", "Trigger", "(", "'push'", ",", "$", "data", ")", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "$", "this", "->", "Trigger", "(", "'delete'", ",", "$", "id", ")", ";", "if", "(", "!", "$", "id", ")", "return", "FALSE", ";", "if", "(", "!", "$", "this", "->", "continue", ")", "return", "FALSE", ";", "$", "this", "->", "db", "->", "from", "(", "$", "this", "->", "table", ")", ";", "$", "this", "->", "db", "->", "where", "(", "\"{$this->table}.{$this->schema['_id']['field']}\"", ",", "$", "id", ")", ";", "$", "this", "->", "db", "->", "delete", "(", ")", ";", "$", "this", "->", "Trigger", "(", "'deleted'", ",", "$", "id", ")", ";", "return", "TRUE", ";", "}" ]
Delete a single item by its ID Calls the 'delete' trigger on the retrieved row @param mixed|null $id The ID (usually an Int) to retrieve the row by @return bool The success of the delete operation
[ "Delete", "a", "single", "item", "by", "its", "ID", "Calls", "the", "delete", "trigger", "on", "the", "retrieved", "row" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L1003-L1036
240,702
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.ResetQuery
function ResetQuery($query = null) { $this->db->ar_select = array(); $this->db->ar_distinct = FALSE; $this->db->ar_from = array(); $this->db->ar_join = array(); $this->db->ar_where = array(); $this->db->ar_like = array(); $this->db->ar_groupby = array(); $this->db->ar_having = array(); $this->db->ar_keys = array(); $this->db->ar_limit = FALSE; $this->db->ar_offset = FALSE; $this->db->ar_order = FALSE; $this->db->ar_orderby = array(); $this->db->ar_set = array(); $this->db->ar_wherein = array(); $this->db->ar_aliased_tables = array(); $this->db->ar_store_array = array(); $this->joystError = ''; $this->continue = TRUE; $this->query = $query; }
php
function ResetQuery($query = null) { $this->db->ar_select = array(); $this->db->ar_distinct = FALSE; $this->db->ar_from = array(); $this->db->ar_join = array(); $this->db->ar_where = array(); $this->db->ar_like = array(); $this->db->ar_groupby = array(); $this->db->ar_having = array(); $this->db->ar_keys = array(); $this->db->ar_limit = FALSE; $this->db->ar_offset = FALSE; $this->db->ar_order = FALSE; $this->db->ar_orderby = array(); $this->db->ar_set = array(); $this->db->ar_wherein = array(); $this->db->ar_aliased_tables = array(); $this->db->ar_store_array = array(); $this->joystError = ''; $this->continue = TRUE; $this->query = $query; }
[ "function", "ResetQuery", "(", "$", "query", "=", "null", ")", "{", "$", "this", "->", "db", "->", "ar_select", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_distinct", "=", "FALSE", ";", "$", "this", "->", "db", "->", "ar_from", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_join", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_where", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_like", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_groupby", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_having", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_keys", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_limit", "=", "FALSE", ";", "$", "this", "->", "db", "->", "ar_offset", "=", "FALSE", ";", "$", "this", "->", "db", "->", "ar_order", "=", "FALSE", ";", "$", "this", "->", "db", "->", "ar_orderby", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_set", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_wherein", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_aliased_tables", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_store_array", "=", "array", "(", ")", ";", "$", "this", "->", "joystError", "=", "''", ";", "$", "this", "->", "continue", "=", "TRUE", ";", "$", "this", "->", "query", "=", "$", "query", ";", "}" ]
Force CI ActiveRecord + Joyst to discard any half formed AR queries @param array $query Optional query to reset Joysts internal query tracker to
[ "Force", "CI", "ActiveRecord", "+", "Joyst", "to", "discard", "any", "half", "formed", "AR", "queries" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L1087-L1109
240,703
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.configureAction
public function configureAction(Request $request) { if ($this->get('tenside.status')->isTensideConfigured()) { throw new NotAcceptableHttpException('Already configured.'); } $inputData = new JsonArray($request->getContent()); $secret = bin2hex(random_bytes(40)); if ($inputData->has('credentials/secret')) { $secret = $inputData->get('credentials/secret'); } // Add tenside configuration. $tensideConfig = $this->get('tenside.config'); $tensideConfig->set('secret', $secret); if ($inputData->has('configuration')) { $this->handleConfiguration($inputData->get('configuration', true)); } $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password')); return new JsonResponse( [ 'status' => 'OK', 'token' => $this->get('tenside.jwt_authenticator')->getTokenForData($user) ], JsonResponse::HTTP_CREATED ); }
php
public function configureAction(Request $request) { if ($this->get('tenside.status')->isTensideConfigured()) { throw new NotAcceptableHttpException('Already configured.'); } $inputData = new JsonArray($request->getContent()); $secret = bin2hex(random_bytes(40)); if ($inputData->has('credentials/secret')) { $secret = $inputData->get('credentials/secret'); } // Add tenside configuration. $tensideConfig = $this->get('tenside.config'); $tensideConfig->set('secret', $secret); if ($inputData->has('configuration')) { $this->handleConfiguration($inputData->get('configuration', true)); } $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password')); return new JsonResponse( [ 'status' => 'OK', 'token' => $this->get('tenside.jwt_authenticator')->getTokenForData($user) ], JsonResponse::HTTP_CREATED ); }
[ "public", "function", "configureAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "get", "(", "'tenside.status'", ")", "->", "isTensideConfigured", "(", ")", ")", "{", "throw", "new", "NotAcceptableHttpException", "(", "'Already configured.'", ")", ";", "}", "$", "inputData", "=", "new", "JsonArray", "(", "$", "request", "->", "getContent", "(", ")", ")", ";", "$", "secret", "=", "bin2hex", "(", "random_bytes", "(", "40", ")", ")", ";", "if", "(", "$", "inputData", "->", "has", "(", "'credentials/secret'", ")", ")", "{", "$", "secret", "=", "$", "inputData", "->", "get", "(", "'credentials/secret'", ")", ";", "}", "// Add tenside configuration.", "$", "tensideConfig", "=", "$", "this", "->", "get", "(", "'tenside.config'", ")", ";", "$", "tensideConfig", "->", "set", "(", "'secret'", ",", "$", "secret", ")", ";", "if", "(", "$", "inputData", "->", "has", "(", "'configuration'", ")", ")", "{", "$", "this", "->", "handleConfiguration", "(", "$", "inputData", "->", "get", "(", "'configuration'", ",", "true", ")", ")", ";", "}", "$", "user", "=", "$", "this", "->", "createUser", "(", "$", "inputData", "->", "get", "(", "'credentials/username'", ")", ",", "$", "inputData", "->", "get", "(", "'credentials/password'", ")", ")", ";", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'OK'", ",", "'token'", "=>", "$", "this", "->", "get", "(", "'tenside.jwt_authenticator'", ")", "->", "getTokenForData", "(", "$", "user", ")", "]", ",", "JsonResponse", "::", "HTTP_CREATED", ")", ";", "}" ]
Configure tenside. NOTE: This method will become inaccessible after the first successful call. @param Request $request The request. @return JsonResponse @throws NotAcceptableHttpException When the configuration is already complete. @ApiDoc( section="install", statusCodes = { 201 = "When everything worked out ok", 406 = "When the configuration is already complete" } ) @ApiDescription( request={ "credentials" = { "description" = "The credentials of the admin user.", "children" = { "secret" = { "dataType" = "string", "description" = "The secret to use for encryption and signing.", "required" = true }, "username" = { "dataType" = "string", "description" = "The name of the admin user.", "required" = true }, "password" = { "dataType" = "string", "description" = "The password to use for the admin.", "required" = false } } }, "configuration" = { "description" = "The application configuration.", "children" = { "php_cli" = { "dataType" = "string", "description" = "The PHP interpreter to run on command line." }, "php_cli_arguments" = { "dataType" = "string", "description" = "Command line arguments to add." }, "github_oauth_token" = { "dataType" = "string", "description" = "Github OAuth token.", "required" = false } } } }, response={ "token" = { "dataType" = "string", "description" = "The API token for the created user" } } )
[ "Configure", "tenside", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L108-L136
240,704
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.getProjectVersionsAction
public function getProjectVersionsAction($vendor, $project) { $this->checkUninstalled(); $url = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project); $rfs = new RemoteFilesystem($this->getInputOutput()); $results = $rfs->getContents($url, $url); $data = new JsonArray($results); $versions = []; foreach ($data->get('package/versions') as $information) { $version = [ 'name' => $information['name'], 'version' => $information['version'], 'version_normalized' => $information['version_normalized'], ]; $normalized = $information['version']; if ('dev-' === substr($normalized, 0, 4)) { if (isset($information['extra']['branch-alias'][$normalized])) { $version['version_normalized'] = $information['extra']['branch-alias'][$normalized]; } } if (isset($information['source']['reference'])) { $version['reference'] = $information['source']['reference']; } elseif (isset($information['dist']['reference'])) { $version['reference'] = $information['dist']['reference']; } $versions[] = $version; } return new JsonResponse( [ 'status' => 'OK', 'versions' => $versions ] ); }
php
public function getProjectVersionsAction($vendor, $project) { $this->checkUninstalled(); $url = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project); $rfs = new RemoteFilesystem($this->getInputOutput()); $results = $rfs->getContents($url, $url); $data = new JsonArray($results); $versions = []; foreach ($data->get('package/versions') as $information) { $version = [ 'name' => $information['name'], 'version' => $information['version'], 'version_normalized' => $information['version_normalized'], ]; $normalized = $information['version']; if ('dev-' === substr($normalized, 0, 4)) { if (isset($information['extra']['branch-alias'][$normalized])) { $version['version_normalized'] = $information['extra']['branch-alias'][$normalized]; } } if (isset($information['source']['reference'])) { $version['reference'] = $information['source']['reference']; } elseif (isset($information['dist']['reference'])) { $version['reference'] = $information['dist']['reference']; } $versions[] = $version; } return new JsonResponse( [ 'status' => 'OK', 'versions' => $versions ] ); }
[ "public", "function", "getProjectVersionsAction", "(", "$", "vendor", ",", "$", "project", ")", "{", "$", "this", "->", "checkUninstalled", "(", ")", ";", "$", "url", "=", "sprintf", "(", "'https://packagist.org/packages/%s/%s.json'", ",", "$", "vendor", ",", "$", "project", ")", ";", "$", "rfs", "=", "new", "RemoteFilesystem", "(", "$", "this", "->", "getInputOutput", "(", ")", ")", ";", "$", "results", "=", "$", "rfs", "->", "getContents", "(", "$", "url", ",", "$", "url", ")", ";", "$", "data", "=", "new", "JsonArray", "(", "$", "results", ")", ";", "$", "versions", "=", "[", "]", ";", "foreach", "(", "$", "data", "->", "get", "(", "'package/versions'", ")", "as", "$", "information", ")", "{", "$", "version", "=", "[", "'name'", "=>", "$", "information", "[", "'name'", "]", ",", "'version'", "=>", "$", "information", "[", "'version'", "]", ",", "'version_normalized'", "=>", "$", "information", "[", "'version_normalized'", "]", ",", "]", ";", "$", "normalized", "=", "$", "information", "[", "'version'", "]", ";", "if", "(", "'dev-'", "===", "substr", "(", "$", "normalized", ",", "0", ",", "4", ")", ")", "{", "if", "(", "isset", "(", "$", "information", "[", "'extra'", "]", "[", "'branch-alias'", "]", "[", "$", "normalized", "]", ")", ")", "{", "$", "version", "[", "'version_normalized'", "]", "=", "$", "information", "[", "'extra'", "]", "[", "'branch-alias'", "]", "[", "$", "normalized", "]", ";", "}", "}", "if", "(", "isset", "(", "$", "information", "[", "'source'", "]", "[", "'reference'", "]", ")", ")", "{", "$", "version", "[", "'reference'", "]", "=", "$", "information", "[", "'source'", "]", "[", "'reference'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "information", "[", "'dist'", "]", "[", "'reference'", "]", ")", ")", "{", "$", "version", "[", "'reference'", "]", "=", "$", "information", "[", "'dist'", "]", "[", "'reference'", "]", ";", "}", "$", "versions", "[", "]", "=", "$", "version", ";", "}", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'OK'", ",", "'versions'", "=>", "$", "versions", "]", ")", ";", "}" ]
Retrieve the available versions of a package. NOTE: This method will become inaccessible as soon as the installation is complete. @param string $vendor The vendor name of the package. @param string $project The name of the package. @return JsonResponse @ApiDoc( section="install", statusCodes = { 201 = "When everything worked out ok", 406 = "When the installation is already complete" }, ) @ApiDescription( response={ "versions" = { "actualType" = "collection", "subType" = "object", "description" = "The list of versions", "children" = { "name" = { "dataType" = "string", "description" = "The name of the package" }, "version" = { "dataType" = "string", "description" = "The version of the package" }, "version_normalized" = { "dataType" = "string", "description" = "The normalized version of the package" }, "reference" = { "dataType" = "string", "description" = "The optional reference" } } } } )
[ "Retrieve", "the", "available", "versions", "of", "a", "package", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L357-L397
240,705
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.getInstallationStateAction
public function getInstallationStateAction() { $status = $this->get('tenside.status'); return new JsonResponse( [ 'state' => [ 'tenside_configured' => $status->isTensideConfigured(), 'project_created' => $status->isProjectPresent(), 'project_installed' => $status->isProjectInstalled(), ], 'status' => 'OK' ] ); }
php
public function getInstallationStateAction() { $status = $this->get('tenside.status'); return new JsonResponse( [ 'state' => [ 'tenside_configured' => $status->isTensideConfigured(), 'project_created' => $status->isProjectPresent(), 'project_installed' => $status->isProjectInstalled(), ], 'status' => 'OK' ] ); }
[ "public", "function", "getInstallationStateAction", "(", ")", "{", "$", "status", "=", "$", "this", "->", "get", "(", "'tenside.status'", ")", ";", "return", "new", "JsonResponse", "(", "[", "'state'", "=>", "[", "'tenside_configured'", "=>", "$", "status", "->", "isTensideConfigured", "(", ")", ",", "'project_created'", "=>", "$", "status", "->", "isProjectPresent", "(", ")", ",", "'project_installed'", "=>", "$", "status", "->", "isProjectInstalled", "(", ")", ",", "]", ",", "'status'", "=>", "'OK'", "]", ")", ";", "}" ]
Check if installation is new, partial or complete. @return JsonResponse @ApiDoc( section="install", description="This method provides information about the installation.", statusCodes = { 201 = "When everything worked out ok", 406 = "When the installation is already complete" }, ) @ApiDescription( response={ "state" = { "children" = { "tenside_configured" = { "dataType" = "bool", "description" = "Flag if tenside has been completely configured." }, "project_created" = { "dataType" = "bool", "description" = "Flag determining if a composer.json is present." }, "project_installed" = { "dataType" = "bool", "description" = "Flag determining if the composer project has been installed (vendor present)." } } }, "status" = { "dataType" = "string", "description" = "Either OK or ERROR" }, "message" = { "dataType" = "string", "description" = "The API error message if any (only present when status is ERROR)" } } )
[ "Check", "if", "installation", "is", "new", "partial", "or", "complete", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L441-L455
240,706
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.createUser
private function createUser($username, $password) { $user = new UserInformation( [ 'username' => $username, 'acl' => UserInformationInterface::ROLE_ALL ] ); $user->set('password', $this->get('security.password_encoder')->encodePassword($user, $password)); $user = $this->get('tenside.user_provider')->addUser($user)->refreshUser($user); return $user; }
php
private function createUser($username, $password) { $user = new UserInformation( [ 'username' => $username, 'acl' => UserInformationInterface::ROLE_ALL ] ); $user->set('password', $this->get('security.password_encoder')->encodePassword($user, $password)); $user = $this->get('tenside.user_provider')->addUser($user)->refreshUser($user); return $user; }
[ "private", "function", "createUser", "(", "$", "username", ",", "$", "password", ")", "{", "$", "user", "=", "new", "UserInformation", "(", "[", "'username'", "=>", "$", "username", ",", "'acl'", "=>", "UserInformationInterface", "::", "ROLE_ALL", "]", ")", ";", "$", "user", "->", "set", "(", "'password'", ",", "$", "this", "->", "get", "(", "'security.password_encoder'", ")", "->", "encodePassword", "(", "$", "user", ",", "$", "password", ")", ")", ";", "$", "user", "=", "$", "this", "->", "get", "(", "'tenside.user_provider'", ")", "->", "addUser", "(", "$", "user", ")", "->", "refreshUser", "(", "$", "user", ")", ";", "return", "$", "user", ";", "}" ]
Add an user to the database. @param string $username The username. @param string $password The password. @return UserInformation
[ "Add", "an", "user", "to", "the", "database", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L480-L494
240,707
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.handleConfiguration
private function handleConfiguration($configuration) { $tensideConfig = $this->get('tenside.config'); if (isset($configuration['php_cli'])) { $tensideConfig->setPhpCliBinary($configuration['php_cli']); } if (isset($configuration['php_cli_arguments'])) { $tensideConfig->setPhpCliArguments($configuration['php_cli_arguments']); } if (isset($configuration['php_cli_environment'])) { $tensideConfig->setPhpCliEnvironment($configuration['php_cli_environment']); } if (isset($configuration['php_force_background'])) { $tensideConfig->setForceToBackground($configuration['php_force_background']); } if (isset($configuration['php_can_fork'])) { $tensideConfig->setForkingAvailable($configuration['php_can_fork']); } if (isset($configuration['github_oauth_token'])) { $composerAuth = new AuthJson( $this->get('tenside.home')->tensideDataDir() . DIRECTORY_SEPARATOR . 'auth.json', null ); $composerAuth->setGithubOAuthToken($configuration['github_oauth_token']); } }
php
private function handleConfiguration($configuration) { $tensideConfig = $this->get('tenside.config'); if (isset($configuration['php_cli'])) { $tensideConfig->setPhpCliBinary($configuration['php_cli']); } if (isset($configuration['php_cli_arguments'])) { $tensideConfig->setPhpCliArguments($configuration['php_cli_arguments']); } if (isset($configuration['php_cli_environment'])) { $tensideConfig->setPhpCliEnvironment($configuration['php_cli_environment']); } if (isset($configuration['php_force_background'])) { $tensideConfig->setForceToBackground($configuration['php_force_background']); } if (isset($configuration['php_can_fork'])) { $tensideConfig->setForkingAvailable($configuration['php_can_fork']); } if (isset($configuration['github_oauth_token'])) { $composerAuth = new AuthJson( $this->get('tenside.home')->tensideDataDir() . DIRECTORY_SEPARATOR . 'auth.json', null ); $composerAuth->setGithubOAuthToken($configuration['github_oauth_token']); } }
[ "private", "function", "handleConfiguration", "(", "$", "configuration", ")", "{", "$", "tensideConfig", "=", "$", "this", "->", "get", "(", "'tenside.config'", ")", ";", "if", "(", "isset", "(", "$", "configuration", "[", "'php_cli'", "]", ")", ")", "{", "$", "tensideConfig", "->", "setPhpCliBinary", "(", "$", "configuration", "[", "'php_cli'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "configuration", "[", "'php_cli_arguments'", "]", ")", ")", "{", "$", "tensideConfig", "->", "setPhpCliArguments", "(", "$", "configuration", "[", "'php_cli_arguments'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "configuration", "[", "'php_cli_environment'", "]", ")", ")", "{", "$", "tensideConfig", "->", "setPhpCliEnvironment", "(", "$", "configuration", "[", "'php_cli_environment'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "configuration", "[", "'php_force_background'", "]", ")", ")", "{", "$", "tensideConfig", "->", "setForceToBackground", "(", "$", "configuration", "[", "'php_force_background'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "configuration", "[", "'php_can_fork'", "]", ")", ")", "{", "$", "tensideConfig", "->", "setForkingAvailable", "(", "$", "configuration", "[", "'php_can_fork'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "configuration", "[", "'github_oauth_token'", "]", ")", ")", "{", "$", "composerAuth", "=", "new", "AuthJson", "(", "$", "this", "->", "get", "(", "'tenside.home'", ")", "->", "tensideDataDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'auth.json'", ",", "null", ")", ";", "$", "composerAuth", "->", "setGithubOAuthToken", "(", "$", "configuration", "[", "'github_oauth_token'", "]", ")", ";", "}", "}" ]
Absorb the passed configuration. @param array $configuration The configuration to absorb. @return void
[ "Absorb", "the", "passed", "configuration", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L503-L535
240,708
99designs/ergo
classes/Ergo/Config/FileConfig.php
FileConfig.loadFile
function loadFile($file, $optional=false, $varname=false, $recursive=false) { if (!is_file($file)) { if ($optional) return $this; else throw new Exception("Failed to read config file '$file'"); } $newConfig = @include($file); if(!is_array($newConfig) && $varname) $newConfig = $$varname; if(!is_array($newConfig) && !$optional) throw new Exception("Config file '$file' doesn't contain a config"); else if(is_array($newConfig)) { if ($recursive) $this->_data = array_merge_recursive($this->_data, $newConfig); else $this->_data = array_merge($this->_data, $newConfig); } return $this; }
php
function loadFile($file, $optional=false, $varname=false, $recursive=false) { if (!is_file($file)) { if ($optional) return $this; else throw new Exception("Failed to read config file '$file'"); } $newConfig = @include($file); if(!is_array($newConfig) && $varname) $newConfig = $$varname; if(!is_array($newConfig) && !$optional) throw new Exception("Config file '$file' doesn't contain a config"); else if(is_array($newConfig)) { if ($recursive) $this->_data = array_merge_recursive($this->_data, $newConfig); else $this->_data = array_merge($this->_data, $newConfig); } return $this; }
[ "function", "loadFile", "(", "$", "file", ",", "$", "optional", "=", "false", ",", "$", "varname", "=", "false", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "if", "(", "$", "optional", ")", "return", "$", "this", ";", "else", "throw", "new", "Exception", "(", "\"Failed to read config file '$file'\"", ")", ";", "}", "$", "newConfig", "=", "@", "include", "(", "$", "file", ")", ";", "if", "(", "!", "is_array", "(", "$", "newConfig", ")", "&&", "$", "varname", ")", "$", "newConfig", "=", "$", "$", "varname", ";", "if", "(", "!", "is_array", "(", "$", "newConfig", ")", "&&", "!", "$", "optional", ")", "throw", "new", "Exception", "(", "\"Config file '$file' doesn't contain a config\"", ")", ";", "else", "if", "(", "is_array", "(", "$", "newConfig", ")", ")", "{", "if", "(", "$", "recursive", ")", "$", "this", "->", "_data", "=", "array_merge_recursive", "(", "$", "this", "->", "_data", ",", "$", "newConfig", ")", ";", "else", "$", "this", "->", "_data", "=", "array_merge", "(", "$", "this", "->", "_data", ",", "$", "newConfig", ")", ";", "}", "return", "$", "this", ";", "}" ]
Loads a config file and merges its contents with the previously loaded settings @param string the name of the file to load @param bool whether the file is optional @param mixed the name of the variable to save as the data @param bool whether the config should merge recursively @chainable
[ "Loads", "a", "config", "file", "and", "merges", "its", "contents", "with", "the", "previously", "loaded", "settings" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Config/FileConfig.php#L65-L91
240,709
BlackBoxRepo/PandoContentBundle
Service/TemplateFinderService.php
TemplateFinderService.find
public function find(PageDocument $page) { $request = $this->requestStack->getCurrentRequest(); $template = $page->getDefault(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY); if ($template === null) { $defaults = []; /** @var RouteEnhancerInterface $enhancer */ foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) { $defaults = array_merge($defaults, $enhancer->enhance(['_content' => $page], $request)); } if (array_key_exists(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY, $defaults)) { $template = $defaults[AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY]; } } return $template; }
php
public function find(PageDocument $page) { $request = $this->requestStack->getCurrentRequest(); $template = $page->getDefault(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY); if ($template === null) { $defaults = []; /** @var RouteEnhancerInterface $enhancer */ foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) { $defaults = array_merge($defaults, $enhancer->enhance(['_content' => $page], $request)); } if (array_key_exists(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY, $defaults)) { $template = $defaults[AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY]; } } return $template; }
[ "public", "function", "find", "(", "PageDocument", "$", "page", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "$", "template", "=", "$", "page", "->", "getDefault", "(", "AbstractPhpcrDocument", "::", "DEFAULT_TEMPLATE_KEY", ")", ";", "if", "(", "$", "template", "===", "null", ")", "{", "$", "defaults", "=", "[", "]", ";", "/** @var RouteEnhancerInterface $enhancer */", "foreach", "(", "$", "this", "->", "dynamicRouter", "->", "getRouteEnhancers", "(", ")", "as", "$", "enhancer", ")", "{", "$", "defaults", "=", "array_merge", "(", "$", "defaults", ",", "$", "enhancer", "->", "enhance", "(", "[", "'_content'", "=>", "$", "page", "]", ",", "$", "request", ")", ")", ";", "}", "if", "(", "array_key_exists", "(", "AbstractPhpcrDocument", "::", "DEFAULT_TEMPLATE_KEY", ",", "$", "defaults", ")", ")", "{", "$", "template", "=", "$", "defaults", "[", "AbstractPhpcrDocument", "::", "DEFAULT_TEMPLATE_KEY", "]", ";", "}", "}", "return", "$", "template", ";", "}" ]
Returns the default template for a given page @param PageDocument $page @return string|null
[ "Returns", "the", "default", "template", "for", "a", "given", "page" ]
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Service/TemplateFinderService.php#L51-L70
240,710
Nobiles2/pcc-3-deklaracja
PCC3/Deklaracja.php
Deklaracja.setPodmiot1
public function setPodmiot1(\KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1) { $this->podmiot1 = $podmiot1; return $this; }
php
public function setPodmiot1(\KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1) { $this->podmiot1 = $podmiot1; return $this; }
[ "public", "function", "setPodmiot1", "(", "\\", "KCH", "\\", "PCC3", "\\", "Deklaracja", "\\", "Podmiot1AnonymousType", "$", "podmiot1", ")", "{", "$", "this", "->", "podmiot1", "=", "$", "podmiot1", ";", "return", "$", "this", ";", "}" ]
Sets a new podmiot1 Dane podatnika dokonującego zapłaty lub zwolnionego z podatku na podstawie art. 9 pkt 10 lit. b ustawy @param \KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1 @return self
[ "Sets", "a", "new", "podmiot1" ]
8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106
https://github.com/Nobiles2/pcc-3-deklaracja/blob/8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106/PCC3/Deklaracja.php#L99-L103
240,711
Nobiles2/pcc-3-deklaracja
PCC3/Deklaracja.php
Deklaracja.setZalaczniki
public function setZalaczniki(\KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki) { $this->zalaczniki = $zalaczniki; return $this; }
php
public function setZalaczniki(\KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki) { $this->zalaczniki = $zalaczniki; return $this; }
[ "public", "function", "setZalaczniki", "(", "\\", "KCH", "\\", "PCC3", "\\", "Deklaracja", "\\", "ZalacznikiAnonymousType", "$", "zalaczniki", ")", "{", "$", "this", "->", "zalaczniki", "=", "$", "zalaczniki", ";", "return", "$", "this", ";", "}" ]
Sets a new zalaczniki @param \KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki @return self
[ "Sets", "a", "new", "zalaczniki" ]
8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106
https://github.com/Nobiles2/pcc-3-deklaracja/blob/8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106/PCC3/Deklaracja.php#L197-L201
240,712
spiritdead/resque
components/workers/base/ResqueWorkerBase.php
ResqueWorkerBase.restore
public function restore($workerInstance) { list($hostname, $pid, $queues) = explode(':', $workerInstance, 3); if (!is_array($queues)) { $queues = explode(',', $queues); } $this->queues = $queues; $this->pid = $pid; $this->id = $workerInstance; //regenerate worker $data = $this->resqueInstance->redis->get($this->workerName() . ':' . $workerInstance); if ($data !== false) { $data = json_decode($data, true); $this->currentJob = new ResqueJobBase($this->resqueInstance, $data['queue'], $data['payload'], true); } $workerPids = self::workerPids(); if (!in_array($pid, $workerPids)) { $this->unregisterWorker(); return false; } return true; }
php
public function restore($workerInstance) { list($hostname, $pid, $queues) = explode(':', $workerInstance, 3); if (!is_array($queues)) { $queues = explode(',', $queues); } $this->queues = $queues; $this->pid = $pid; $this->id = $workerInstance; //regenerate worker $data = $this->resqueInstance->redis->get($this->workerName() . ':' . $workerInstance); if ($data !== false) { $data = json_decode($data, true); $this->currentJob = new ResqueJobBase($this->resqueInstance, $data['queue'], $data['payload'], true); } $workerPids = self::workerPids(); if (!in_array($pid, $workerPids)) { $this->unregisterWorker(); return false; } return true; }
[ "public", "function", "restore", "(", "$", "workerInstance", ")", "{", "list", "(", "$", "hostname", ",", "$", "pid", ",", "$", "queues", ")", "=", "explode", "(", "':'", ",", "$", "workerInstance", ",", "3", ")", ";", "if", "(", "!", "is_array", "(", "$", "queues", ")", ")", "{", "$", "queues", "=", "explode", "(", "','", ",", "$", "queues", ")", ";", "}", "$", "this", "->", "queues", "=", "$", "queues", ";", "$", "this", "->", "pid", "=", "$", "pid", ";", "$", "this", "->", "id", "=", "$", "workerInstance", ";", "//regenerate worker", "$", "data", "=", "$", "this", "->", "resqueInstance", "->", "redis", "->", "get", "(", "$", "this", "->", "workerName", "(", ")", ".", "':'", ".", "$", "workerInstance", ")", ";", "if", "(", "$", "data", "!==", "false", ")", "{", "$", "data", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "$", "this", "->", "currentJob", "=", "new", "ResqueJobBase", "(", "$", "this", "->", "resqueInstance", ",", "$", "data", "[", "'queue'", "]", ",", "$", "data", "[", "'payload'", "]", ",", "true", ")", ";", "}", "$", "workerPids", "=", "self", "::", "workerPids", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "pid", ",", "$", "workerPids", ")", ")", "{", "$", "this", "->", "unregisterWorker", "(", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Method for regenerate worker from the current ID saved in the redis and the instance in the server @param $workerInstance @return boolean // Success or Fail
[ "Method", "for", "regenerate", "worker", "from", "the", "current", "ID", "saved", "in", "the", "redis", "and", "the", "instance", "in", "the", "server" ]
6d1f58c5a15a7f50a90ca08f882e64bc07488cc4
https://github.com/spiritdead/resque/blob/6d1f58c5a15a7f50a90ca08f882e64bc07488cc4/components/workers/base/ResqueWorkerBase.php#L114-L135
240,713
silinternational/psr3-adapters
src/LoggerBase.php
LoggerBase.interpolateString
private function interpolateString($message, array $context = []) { // Build a replacement array with braces around the context keys. $replace = []; foreach ($context as $key => $value) { // Check that the value can be cast to string. if (!is_array($value) && (!is_object($value) || method_exists($value, '__toString'))) { $replace['{' . $key . '}'] = $value; } } // Interpolate replacement values into the message. $result = strtr($message, $replace); if (is_string($result)) { return $result; } /* If something went wrong, return the original message (with a * warning). */ return sprintf( '%s (WARNING: Unable to interpolate the context values into the message. %s).', $message, var_export($replace, true) ); }
php
private function interpolateString($message, array $context = []) { // Build a replacement array with braces around the context keys. $replace = []; foreach ($context as $key => $value) { // Check that the value can be cast to string. if (!is_array($value) && (!is_object($value) || method_exists($value, '__toString'))) { $replace['{' . $key . '}'] = $value; } } // Interpolate replacement values into the message. $result = strtr($message, $replace); if (is_string($result)) { return $result; } /* If something went wrong, return the original message (with a * warning). */ return sprintf( '%s (WARNING: Unable to interpolate the context values into the message. %s).', $message, var_export($replace, true) ); }
[ "private", "function", "interpolateString", "(", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "// Build a replacement array with braces around the context keys.", "$", "replace", "=", "[", "]", ";", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "// Check that the value can be cast to string.", "if", "(", "!", "is_array", "(", "$", "value", ")", "&&", "(", "!", "is_object", "(", "$", "value", ")", "||", "method_exists", "(", "$", "value", ",", "'__toString'", ")", ")", ")", "{", "$", "replace", "[", "'{'", ".", "$", "key", ".", "'}'", "]", "=", "$", "value", ";", "}", "}", "// Interpolate replacement values into the message.", "$", "result", "=", "strtr", "(", "$", "message", ",", "$", "replace", ")", ";", "if", "(", "is_string", "(", "$", "result", ")", ")", "{", "return", "$", "result", ";", "}", "/* If something went wrong, return the original message (with a\n * warning). */", "return", "sprintf", "(", "'%s (WARNING: Unable to interpolate the context values into the message. %s).'", ",", "$", "message", ",", "var_export", "(", "$", "replace", ",", "true", ")", ")", ";", "}" ]
Interpolate context values into the given string. This is based heavily on the example implementation here: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message @param string $message The message (potentially with placeholders). @param array $context (Optional:) The array of values to insert into the corresponding placeholders. @return string The resulting string.
[ "Interpolate", "context", "values", "into", "the", "given", "string", "." ]
dd091be5b23f1f86fbb404dba2c4cf700e2ba9f9
https://github.com/silinternational/psr3-adapters/blob/dd091be5b23f1f86fbb404dba2c4cf700e2ba9f9/src/LoggerBase.php#L51-L76
240,714
rozaverta/cmf
core/Prop.php
Prop.file
public static function file( $name, & $exists = false ) { if( !defined("APP_DIR") ) { return []; } $file = APP_DIR . "config" . DIRECTORY_SEPARATOR . $name . '.php'; if( file_exists( $file ) ) { $data = Helper::includeImport($file); $exists = true; } if( ! isset( $data ) || ! is_array( $data ) ) { $data = []; } return $data; }
php
public static function file( $name, & $exists = false ) { if( !defined("APP_DIR") ) { return []; } $file = APP_DIR . "config" . DIRECTORY_SEPARATOR . $name . '.php'; if( file_exists( $file ) ) { $data = Helper::includeImport($file); $exists = true; } if( ! isset( $data ) || ! is_array( $data ) ) { $data = []; } return $data; }
[ "public", "static", "function", "file", "(", "$", "name", ",", "&", "$", "exists", "=", "false", ")", "{", "if", "(", "!", "defined", "(", "\"APP_DIR\"", ")", ")", "{", "return", "[", "]", ";", "}", "$", "file", "=", "APP_DIR", ".", "\"config\"", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "data", "=", "Helper", "::", "includeImport", "(", "$", "file", ")", ";", "$", "exists", "=", "true", ";", "}", "if", "(", "!", "isset", "(", "$", "data", ")", "||", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "[", "]", ";", "}", "return", "$", "data", ";", "}" ]
Get array data from file @param $name @param bool $exists @return array
[ "Get", "array", "data", "from", "file" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L84-L104
240,715
rozaverta/cmf
core/Prop.php
Prop.cache
public static function cache( $name ) { static $cache = []; $name = (string) $name; if( ! isset($cache[$name]) ) { $cache[$name] = new self($name); } return $cache[$name]; }
php
public static function cache( $name ) { static $cache = []; $name = (string) $name; if( ! isset($cache[$name]) ) { $cache[$name] = new self($name); } return $cache[$name]; }
[ "public", "static", "function", "cache", "(", "$", "name", ")", "{", "static", "$", "cache", "=", "[", "]", ";", "$", "name", "=", "(", "string", ")", "$", "name", ";", "if", "(", "!", "isset", "(", "$", "cache", "[", "$", "name", "]", ")", ")", "{", "$", "cache", "[", "$", "name", "]", "=", "new", "self", "(", "$", "name", ")", ";", "}", "return", "$", "cache", "[", "$", "name", "]", ";", "}" ]
Get cache property from file @param $name @return Prop
[ "Get", "cache", "property", "from", "file" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L112-L124
240,716
rozaverta/cmf
core/Prop.php
Prop.group
public function group( $name ) { $name = rtrim($name, '.'); $pref = $name . '.'; $len = strlen($pref); $data = []; foreach( array_keys($this->items) as $key ) { if( $key === $name ) { $data['.'] = $this->items[$key]; } else if( strlen($key) > $len && substr($key, 0, $len) === $pref ) { $data[substr($key, $len)] = $this->items[$key]; } } return new self($data); }
php
public function group( $name ) { $name = rtrim($name, '.'); $pref = $name . '.'; $len = strlen($pref); $data = []; foreach( array_keys($this->items) as $key ) { if( $key === $name ) { $data['.'] = $this->items[$key]; } else if( strlen($key) > $len && substr($key, 0, $len) === $pref ) { $data[substr($key, $len)] = $this->items[$key]; } } return new self($data); }
[ "public", "function", "group", "(", "$", "name", ")", "{", "$", "name", "=", "rtrim", "(", "$", "name", ",", "'.'", ")", ";", "$", "pref", "=", "$", "name", ".", "'.'", ";", "$", "len", "=", "strlen", "(", "$", "pref", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "items", ")", "as", "$", "key", ")", "{", "if", "(", "$", "key", "===", "$", "name", ")", "{", "$", "data", "[", "'.'", "]", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "}", "else", "if", "(", "strlen", "(", "$", "key", ")", ">", "$", "len", "&&", "substr", "(", "$", "key", ",", "0", ",", "$", "len", ")", "===", "$", "pref", ")", "{", "$", "data", "[", "substr", "(", "$", "key", ",", "$", "len", ")", "]", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "}", "}", "return", "new", "self", "(", "$", "data", ")", ";", "}" ]
Get new property group @param $name @return Prop
[ "Get", "new", "property", "group" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L210-L230
240,717
rozaverta/cmf
core/Prop.php
Prop.pathSet
public function pathSet( $path, $value ) { $path = $this->createPath($path); if( $path[0] == 1 ) { $this->offsetSet($path[1], $value); } else { $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( $i == $len ) { $array[$key] = $value; } else { if( !isset($array[$key]) || !is_array($array[$key]) ) { $array[$key] = []; } $array = & $array[$key]; } } } return $this; }
php
public function pathSet( $path, $value ) { $path = $this->createPath($path); if( $path[0] == 1 ) { $this->offsetSet($path[1], $value); } else { $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( $i == $len ) { $array[$key] = $value; } else { if( !isset($array[$key]) || !is_array($array[$key]) ) { $array[$key] = []; } $array = & $array[$key]; } } } return $this; }
[ "public", "function", "pathSet", "(", "$", "path", ",", "$", "value", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "if", "(", "$", "path", "[", "0", "]", "==", "1", ")", "{", "$", "this", "->", "offsetSet", "(", "$", "path", "[", "1", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "array", "=", "&", "$", "this", "->", "items", ";", "for", "(", "$", "i", "=", "1", ",", "$", "len", "=", "$", "path", "[", "0", "]", ";", "$", "i", "<=", "$", "len", ";", "$", "i", "++", ")", "{", "$", "key", "=", "$", "path", "[", "$", "i", "]", ";", "if", "(", "$", "i", "==", "$", "len", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "array", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "[", "]", ";", "}", "$", "array", "=", "&", "$", "array", "[", "$", "key", "]", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Set value for path. @example $this->pathSet( 'a.b.c', $value ) => $this->items['a']['b']['c'] = $value; @param string $path @param mixed $value @return $this
[ "Set", "value", "for", "path", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L252-L281
240,718
rozaverta/cmf
core/Prop.php
Prop.pathGetIs
public function pathGetIs( $path, $accessible = false ) { $path = $this->createPath($path); $array = & $this->items; $key = $path[1]; if( $path[0] > 1 ) { for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { return false; } if( $i < $len ) { if( is_array($array[$key]) ) { $array = & $array[$key]; } else { return false; } } } } else if( ! array_key_exists($key, $array) ) { return false; } if( $accessible ) { return is_array($array[$key]); } return true; }
php
public function pathGetIs( $path, $accessible = false ) { $path = $this->createPath($path); $array = & $this->items; $key = $path[1]; if( $path[0] > 1 ) { for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { return false; } if( $i < $len ) { if( is_array($array[$key]) ) { $array = & $array[$key]; } else { return false; } } } } else if( ! array_key_exists($key, $array) ) { return false; } if( $accessible ) { return is_array($array[$key]); } return true; }
[ "public", "function", "pathGetIs", "(", "$", "path", ",", "$", "accessible", "=", "false", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "$", "array", "=", "&", "$", "this", "->", "items", ";", "$", "key", "=", "$", "path", "[", "1", "]", ";", "if", "(", "$", "path", "[", "0", "]", ">", "1", ")", "{", "for", "(", "$", "i", "=", "1", ",", "$", "len", "=", "$", "path", "[", "0", "]", ";", "$", "i", "<=", "$", "len", ";", "$", "i", "++", ")", "{", "$", "key", "=", "$", "path", "[", "$", "i", "]", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "i", "<", "$", "len", ")", "{", "if", "(", "is_array", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "$", "array", "=", "&", "$", "array", "[", "$", "key", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}", "}", "}", "else", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "accessible", ")", "{", "return", "is_array", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "return", "true", ";", "}" ]
Check value exists for path exist. @param string $path @param bool $accessible @return bool
[ "Check", "value", "exists", "for", "path", "exist", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L290-L329
240,719
rozaverta/cmf
core/Prop.php
Prop.pathGetOr
public function pathGetOr( $path, $default ) { $path = $this->createPath($path); if( $path[0] == 1 ) { return $this->get($path[1]); } $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { break; } if( $i == $len ) { return $array[$key]; } if( !isset($array[$key]) || !is_array($array[$key]) ) { break; } $array = & $array[$key]; } return $default; }
php
public function pathGetOr( $path, $default ) { $path = $this->createPath($path); if( $path[0] == 1 ) { return $this->get($path[1]); } $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { break; } if( $i == $len ) { return $array[$key]; } if( !isset($array[$key]) || !is_array($array[$key]) ) { break; } $array = & $array[$key]; } return $default; }
[ "public", "function", "pathGetOr", "(", "$", "path", ",", "$", "default", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "if", "(", "$", "path", "[", "0", "]", "==", "1", ")", "{", "return", "$", "this", "->", "get", "(", "$", "path", "[", "1", "]", ")", ";", "}", "$", "array", "=", "&", "$", "this", "->", "items", ";", "for", "(", "$", "i", "=", "1", ",", "$", "len", "=", "$", "path", "[", "0", "]", ";", "$", "i", "<=", "$", "len", ";", "$", "i", "++", ")", "{", "$", "key", "=", "$", "path", "[", "$", "i", "]", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "break", ";", "}", "if", "(", "$", "i", "==", "$", "len", ")", "{", "return", "$", "array", "[", "$", "key", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "array", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "break", ";", "}", "$", "array", "=", "&", "$", "array", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get value from path or get default value if not exists. @param string $path @param mixed $default @return mixed
[ "Get", "value", "from", "path", "or", "get", "default", "value", "if", "not", "exists", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L349-L380
240,720
phn-io/compilation
spec/Phn/Compilation/LoopSpec.php
LoopSpec.it_provides_useful_information_about_iterations
function it_provides_useful_information_about_iterations() { $this->next('one'); $this->getIndex()->shouldBe(0); $this->getKey()->shouldBe('one'); $this->isFirst()->shouldBe(true); $this->isLast()->shouldBe(false); $this->next('two'); $this->getIndex()->shouldBe(1); $this->getKey()->shouldBe('two'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(false); $this->next('three'); $this->getIndex()->shouldBe(2); $this->getKey()->shouldBe('three'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(true); }
php
function it_provides_useful_information_about_iterations() { $this->next('one'); $this->getIndex()->shouldBe(0); $this->getKey()->shouldBe('one'); $this->isFirst()->shouldBe(true); $this->isLast()->shouldBe(false); $this->next('two'); $this->getIndex()->shouldBe(1); $this->getKey()->shouldBe('two'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(false); $this->next('three'); $this->getIndex()->shouldBe(2); $this->getKey()->shouldBe('three'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(true); }
[ "function", "it_provides_useful_information_about_iterations", "(", ")", "{", "$", "this", "->", "next", "(", "'one'", ")", ";", "$", "this", "->", "getIndex", "(", ")", "->", "shouldBe", "(", "0", ")", ";", "$", "this", "->", "getKey", "(", ")", "->", "shouldBe", "(", "'one'", ")", ";", "$", "this", "->", "isFirst", "(", ")", "->", "shouldBe", "(", "true", ")", ";", "$", "this", "->", "isLast", "(", ")", "->", "shouldBe", "(", "false", ")", ";", "$", "this", "->", "next", "(", "'two'", ")", ";", "$", "this", "->", "getIndex", "(", ")", "->", "shouldBe", "(", "1", ")", ";", "$", "this", "->", "getKey", "(", ")", "->", "shouldBe", "(", "'two'", ")", ";", "$", "this", "->", "isFirst", "(", ")", "->", "shouldBe", "(", "false", ")", ";", "$", "this", "->", "isLast", "(", ")", "->", "shouldBe", "(", "false", ")", ";", "$", "this", "->", "next", "(", "'three'", ")", ";", "$", "this", "->", "getIndex", "(", ")", "->", "shouldBe", "(", "2", ")", ";", "$", "this", "->", "getKey", "(", ")", "->", "shouldBe", "(", "'three'", ")", ";", "$", "this", "->", "isFirst", "(", ")", "->", "shouldBe", "(", "false", ")", ";", "$", "this", "->", "isLast", "(", ")", "->", "shouldBe", "(", "true", ")", ";", "}" ]
It provides useful information about iterations.
[ "It", "provides", "useful", "information", "about", "iterations", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/spec/Phn/Compilation/LoopSpec.php#L41-L60
240,721
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.init
public static function init($config) { if (static::$initialized) { throw new \FuelException("You can't initialize Fuel more than once."); } // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis, // like it was in versions before 1.7 class_exists('Redis', false) or class_alias('Redis_Db', 'Redis'); static::$_paths = array(APPPATH, COREPATH); // Is Fuel running on the command line? static::$is_cli = (bool) defined('STDIN'); \Config::load($config); // Disable output compression if the client doesn't support it if (static::$is_cli or ! in_array('gzip', explode(', ', \Input::headers('Accept-Encoding', '')))) { \Config::set('ob_callback', null); } // Start up output buffering ob_start(\Config::get('ob_callback')); if (\Config::get('caching', false)) { \Finder::instance()->read_cache('FuelFileFinder'); } static::$profiling = \Config::get('profiling', false); static::$profiling and \Profiler::init(); // set a default timezone if one is defined try { static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get(); date_default_timezone_set(static::$timezone); } catch (\Exception $e) { date_default_timezone_set('UTC'); throw new \PHPErrorException($e->getMessage()); } static::$encoding = \Config::get('encoding', static::$encoding); MBSTRING and mb_internal_encoding(static::$encoding); static::$locale = \Config::get('locale', static::$locale); if ( ! static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } } // Run Input Filtering \Security::clean_input(); \Event::register('fuel-shutdown', 'Fuel::finish'); // Always load classes, config & language set in always_load.php config static::always_load(); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); // Set locale, log warning when it fails if (static::$locale) { setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale '.static::$locale.' is not installed on your system.', __METHOD__); } static::$initialized = true; // fire any app created events \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none'); if (static::$profiling) { \Profiler::mark(__METHOD__.' End'); } }
php
public static function init($config) { if (static::$initialized) { throw new \FuelException("You can't initialize Fuel more than once."); } // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis, // like it was in versions before 1.7 class_exists('Redis', false) or class_alias('Redis_Db', 'Redis'); static::$_paths = array(APPPATH, COREPATH); // Is Fuel running on the command line? static::$is_cli = (bool) defined('STDIN'); \Config::load($config); // Disable output compression if the client doesn't support it if (static::$is_cli or ! in_array('gzip', explode(', ', \Input::headers('Accept-Encoding', '')))) { \Config::set('ob_callback', null); } // Start up output buffering ob_start(\Config::get('ob_callback')); if (\Config::get('caching', false)) { \Finder::instance()->read_cache('FuelFileFinder'); } static::$profiling = \Config::get('profiling', false); static::$profiling and \Profiler::init(); // set a default timezone if one is defined try { static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get(); date_default_timezone_set(static::$timezone); } catch (\Exception $e) { date_default_timezone_set('UTC'); throw new \PHPErrorException($e->getMessage()); } static::$encoding = \Config::get('encoding', static::$encoding); MBSTRING and mb_internal_encoding(static::$encoding); static::$locale = \Config::get('locale', static::$locale); if ( ! static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } } // Run Input Filtering \Security::clean_input(); \Event::register('fuel-shutdown', 'Fuel::finish'); // Always load classes, config & language set in always_load.php config static::always_load(); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); // Set locale, log warning when it fails if (static::$locale) { setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale '.static::$locale.' is not installed on your system.', __METHOD__); } static::$initialized = true; // fire any app created events \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none'); if (static::$profiling) { \Profiler::mark(__METHOD__.' End'); } }
[ "public", "static", "function", "init", "(", "$", "config", ")", "{", "if", "(", "static", "::", "$", "initialized", ")", "{", "throw", "new", "\\", "FuelException", "(", "\"You can't initialize Fuel more than once.\"", ")", ";", "}", "// BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis,", "// like it was in versions before 1.7", "class_exists", "(", "'Redis'", ",", "false", ")", "or", "class_alias", "(", "'Redis_Db'", ",", "'Redis'", ")", ";", "static", "::", "$", "_paths", "=", "array", "(", "APPPATH", ",", "COREPATH", ")", ";", "// Is Fuel running on the command line?", "static", "::", "$", "is_cli", "=", "(", "bool", ")", "defined", "(", "'STDIN'", ")", ";", "\\", "Config", "::", "load", "(", "$", "config", ")", ";", "// Disable output compression if the client doesn't support it", "if", "(", "static", "::", "$", "is_cli", "or", "!", "in_array", "(", "'gzip'", ",", "explode", "(", "', '", ",", "\\", "Input", "::", "headers", "(", "'Accept-Encoding'", ",", "''", ")", ")", ")", ")", "{", "\\", "Config", "::", "set", "(", "'ob_callback'", ",", "null", ")", ";", "}", "// Start up output buffering", "ob_start", "(", "\\", "Config", "::", "get", "(", "'ob_callback'", ")", ")", ";", "if", "(", "\\", "Config", "::", "get", "(", "'caching'", ",", "false", ")", ")", "{", "\\", "Finder", "::", "instance", "(", ")", "->", "read_cache", "(", "'FuelFileFinder'", ")", ";", "}", "static", "::", "$", "profiling", "=", "\\", "Config", "::", "get", "(", "'profiling'", ",", "false", ")", ";", "static", "::", "$", "profiling", "and", "\\", "Profiler", "::", "init", "(", ")", ";", "// set a default timezone if one is defined", "try", "{", "static", "::", "$", "timezone", "=", "\\", "Config", "::", "get", "(", "'default_timezone'", ")", "?", ":", "date_default_timezone_get", "(", ")", ";", "date_default_timezone_set", "(", "static", "::", "$", "timezone", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "date_default_timezone_set", "(", "'UTC'", ")", ";", "throw", "new", "\\", "PHPErrorException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "static", "::", "$", "encoding", "=", "\\", "Config", "::", "get", "(", "'encoding'", ",", "static", "::", "$", "encoding", ")", ";", "MBSTRING", "and", "mb_internal_encoding", "(", "static", "::", "$", "encoding", ")", ";", "static", "::", "$", "locale", "=", "\\", "Config", "::", "get", "(", "'locale'", ",", "static", "::", "$", "locale", ")", ";", "if", "(", "!", "static", "::", "$", "is_cli", ")", "{", "if", "(", "\\", "Config", "::", "get", "(", "'base_url'", ")", "===", "null", ")", "{", "\\", "Config", "::", "set", "(", "'base_url'", ",", "static", "::", "generate_base_url", "(", ")", ")", ";", "}", "}", "// Run Input Filtering", "\\", "Security", "::", "clean_input", "(", ")", ";", "\\", "Event", "::", "register", "(", "'fuel-shutdown'", ",", "'Fuel::finish'", ")", ";", "// Always load classes, config & language set in always_load.php config", "static", "::", "always_load", "(", ")", ";", "// Load in the routes", "\\", "Config", "::", "load", "(", "'routes'", ",", "true", ")", ";", "\\", "Router", "::", "add", "(", "\\", "Config", "::", "get", "(", "'routes'", ")", ")", ";", "// Set locale, log warning when it fails", "if", "(", "static", "::", "$", "locale", ")", "{", "setlocale", "(", "LC_ALL", ",", "static", "::", "$", "locale", ")", "or", "logger", "(", "\\", "Fuel", "::", "L_WARNING", ",", "'The configured locale '", ".", "static", "::", "$", "locale", ".", "' is not installed on your system.'", ",", "__METHOD__", ")", ";", "}", "static", "::", "$", "initialized", "=", "true", ";", "// fire any app created events", "\\", "Event", "::", "instance", "(", ")", "->", "has_events", "(", "'app_created'", ")", "and", "\\", "Event", "::", "instance", "(", ")", "->", "trigger", "(", "'app_created'", ",", "''", ",", "'none'", ")", ";", "if", "(", "static", "::", "$", "profiling", ")", "{", "\\", "Profiler", "::", "mark", "(", "__METHOD__", ".", "' End'", ")", ";", "}", "}" ]
Initializes the framework. This can only be called once. @access public @return void
[ "Initializes", "the", "framework", ".", "This", "can", "only", "be", "called", "once", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L123-L211
240,722
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.finish
public static function finish() { if (\Config::get('caching', false)) { \Finder::instance()->write_cache('FuelFileFinder'); } if (static::$profiling and ! static::$is_cli and ! \Input::is_ajax()) { // Grab the output buffer and flush it, we will rebuffer later $output = ob_get_clean(); $headers = headers_list(); $show = true; foreach ($headers as $header) { if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false) { $show = false; } } if ($show) { \Profiler::mark('End of Fuel Execution'); if (preg_match("|</body>.*?</html>|is", $output)) { $output = preg_replace("|</body>.*?</html>|is", '', $output); $output .= \Profiler::output(); $output .= '</body></html>'; } else { $output .= \Profiler::output(); } } // Restart the output buffer and send the new output ob_start(\Config::get('ob_callback')); echo $output; } }
php
public static function finish() { if (\Config::get('caching', false)) { \Finder::instance()->write_cache('FuelFileFinder'); } if (static::$profiling and ! static::$is_cli and ! \Input::is_ajax()) { // Grab the output buffer and flush it, we will rebuffer later $output = ob_get_clean(); $headers = headers_list(); $show = true; foreach ($headers as $header) { if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false) { $show = false; } } if ($show) { \Profiler::mark('End of Fuel Execution'); if (preg_match("|</body>.*?</html>|is", $output)) { $output = preg_replace("|</body>.*?</html>|is", '', $output); $output .= \Profiler::output(); $output .= '</body></html>'; } else { $output .= \Profiler::output(); } } // Restart the output buffer and send the new output ob_start(\Config::get('ob_callback')); echo $output; } }
[ "public", "static", "function", "finish", "(", ")", "{", "if", "(", "\\", "Config", "::", "get", "(", "'caching'", ",", "false", ")", ")", "{", "\\", "Finder", "::", "instance", "(", ")", "->", "write_cache", "(", "'FuelFileFinder'", ")", ";", "}", "if", "(", "static", "::", "$", "profiling", "and", "!", "static", "::", "$", "is_cli", "and", "!", "\\", "Input", "::", "is_ajax", "(", ")", ")", "{", "// Grab the output buffer and flush it, we will rebuffer later", "$", "output", "=", "ob_get_clean", "(", ")", ";", "$", "headers", "=", "headers_list", "(", ")", ";", "$", "show", "=", "true", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "if", "(", "stripos", "(", "$", "header", ",", "'content-type'", ")", "===", "0", "and", "stripos", "(", "$", "header", ",", "'text/html'", ")", "===", "false", ")", "{", "$", "show", "=", "false", ";", "}", "}", "if", "(", "$", "show", ")", "{", "\\", "Profiler", "::", "mark", "(", "'End of Fuel Execution'", ")", ";", "if", "(", "preg_match", "(", "\"|</body>.*?</html>|is\"", ",", "$", "output", ")", ")", "{", "$", "output", "=", "preg_replace", "(", "\"|</body>.*?</html>|is\"", ",", "''", ",", "$", "output", ")", ";", "$", "output", ".=", "\\", "Profiler", "::", "output", "(", ")", ";", "$", "output", ".=", "'</body></html>'", ";", "}", "else", "{", "$", "output", ".=", "\\", "Profiler", "::", "output", "(", ")", ";", "}", "}", "// Restart the output buffer and send the new output", "ob_start", "(", "\\", "Config", "::", "get", "(", "'ob_callback'", ")", ")", ";", "echo", "$", "output", ";", "}", "}" ]
Cleans up Fuel execution, ends the output buffering, and outputs the buffer contents. @access public @return void
[ "Cleans", "up", "Fuel", "execution", "ends", "the", "output", "buffering", "and", "outputs", "the", "buffer", "contents", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L220-L261
240,723
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.generate_base_url
protected static function generate_base_url() { $base_url = ''; if(\Input::server('http_host')) { $base_url .= \Input::protocol().'://'.\Input::server('http_host'); } if (\Input::server('script_name')) { $common = get_common_path(array(\Input::server('request_uri'), \Input::server('script_name'))); $base_url .= $common; } // Add a slash if it is missing and return it return rtrim($base_url, '/').'/'; }
php
protected static function generate_base_url() { $base_url = ''; if(\Input::server('http_host')) { $base_url .= \Input::protocol().'://'.\Input::server('http_host'); } if (\Input::server('script_name')) { $common = get_common_path(array(\Input::server('request_uri'), \Input::server('script_name'))); $base_url .= $common; } // Add a slash if it is missing and return it return rtrim($base_url, '/').'/'; }
[ "protected", "static", "function", "generate_base_url", "(", ")", "{", "$", "base_url", "=", "''", ";", "if", "(", "\\", "Input", "::", "server", "(", "'http_host'", ")", ")", "{", "$", "base_url", ".=", "\\", "Input", "::", "protocol", "(", ")", ".", "'://'", ".", "\\", "Input", "::", "server", "(", "'http_host'", ")", ";", "}", "if", "(", "\\", "Input", "::", "server", "(", "'script_name'", ")", ")", "{", "$", "common", "=", "get_common_path", "(", "array", "(", "\\", "Input", "::", "server", "(", "'request_uri'", ")", ",", "\\", "Input", "::", "server", "(", "'script_name'", ")", ")", ")", ";", "$", "base_url", ".=", "$", "common", ";", "}", "// Add a slash if it is missing and return it", "return", "rtrim", "(", "$", "base_url", ",", "'/'", ")", ".", "'/'", ";", "}" ]
Generates a base url. @return string the base url
[ "Generates", "a", "base", "url", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L268-L283
240,724
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.always_load
public static function always_load($array = null) { is_null($array) and $array = \Config::get('always_load', array()); isset($array['packages']) and \Package::load($array['packages']); isset($array['modules']) and \Module::load($array['modules']); if (isset($array['classes'])) { foreach ($array['classes'] as $class) { if ( ! class_exists($class = \Str::ucwords($class))) { throw new \FuelException('Class '.$class.' defined in your "always_load" config could not be loaded.'); } } } /** * Config and Lang must be either just the filename, example: array(filename) * or the filename as key and the group as value, example: array(filename => some_group) */ if (isset($array['config'])) { foreach ($array['config'] as $config => $config_group) { \Config::load((is_int($config) ? $config_group : $config), (is_int($config) ? true : $config_group)); } } if (isset($array['language'])) { foreach ($array['language'] as $lang => $lang_group) { \Lang::load((is_int($lang) ? $lang_group : $lang), (is_int($lang) ? true : $lang_group)); } } }
php
public static function always_load($array = null) { is_null($array) and $array = \Config::get('always_load', array()); isset($array['packages']) and \Package::load($array['packages']); isset($array['modules']) and \Module::load($array['modules']); if (isset($array['classes'])) { foreach ($array['classes'] as $class) { if ( ! class_exists($class = \Str::ucwords($class))) { throw new \FuelException('Class '.$class.' defined in your "always_load" config could not be loaded.'); } } } /** * Config and Lang must be either just the filename, example: array(filename) * or the filename as key and the group as value, example: array(filename => some_group) */ if (isset($array['config'])) { foreach ($array['config'] as $config => $config_group) { \Config::load((is_int($config) ? $config_group : $config), (is_int($config) ? true : $config_group)); } } if (isset($array['language'])) { foreach ($array['language'] as $lang => $lang_group) { \Lang::load((is_int($lang) ? $lang_group : $lang), (is_int($lang) ? true : $lang_group)); } } }
[ "public", "static", "function", "always_load", "(", "$", "array", "=", "null", ")", "{", "is_null", "(", "$", "array", ")", "and", "$", "array", "=", "\\", "Config", "::", "get", "(", "'always_load'", ",", "array", "(", ")", ")", ";", "isset", "(", "$", "array", "[", "'packages'", "]", ")", "and", "\\", "Package", "::", "load", "(", "$", "array", "[", "'packages'", "]", ")", ";", "isset", "(", "$", "array", "[", "'modules'", "]", ")", "and", "\\", "Module", "::", "load", "(", "$", "array", "[", "'modules'", "]", ")", ";", "if", "(", "isset", "(", "$", "array", "[", "'classes'", "]", ")", ")", "{", "foreach", "(", "$", "array", "[", "'classes'", "]", "as", "$", "class", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", "=", "\\", "Str", "::", "ucwords", "(", "$", "class", ")", ")", ")", "{", "throw", "new", "\\", "FuelException", "(", "'Class '", ".", "$", "class", ".", "' defined in your \"always_load\" config could not be loaded.'", ")", ";", "}", "}", "}", "/**\n\t\t * Config and Lang must be either just the filename, example: array(filename)\n\t\t * or the filename as key and the group as value, example: array(filename => some_group)\n\t\t */", "if", "(", "isset", "(", "$", "array", "[", "'config'", "]", ")", ")", "{", "foreach", "(", "$", "array", "[", "'config'", "]", "as", "$", "config", "=>", "$", "config_group", ")", "{", "\\", "Config", "::", "load", "(", "(", "is_int", "(", "$", "config", ")", "?", "$", "config_group", ":", "$", "config", ")", ",", "(", "is_int", "(", "$", "config", ")", "?", "true", ":", "$", "config_group", ")", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "array", "[", "'language'", "]", ")", ")", "{", "foreach", "(", "$", "array", "[", "'language'", "]", "as", "$", "lang", "=>", "$", "lang_group", ")", "{", "\\", "Lang", "::", "load", "(", "(", "is_int", "(", "$", "lang", ")", "?", "$", "lang_group", ":", "$", "lang", ")", ",", "(", "is_int", "(", "$", "lang", ")", "?", "true", ":", "$", "lang_group", ")", ")", ";", "}", "}", "}" ]
Always load packages, modules, classes, config & language files set in always_load.php config @param array what to autoload
[ "Always", "load", "packages", "modules", "classes", "config", "&", "language", "files", "set", "in", "always_load", ".", "php", "config" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L301-L340
240,725
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.clean_path
public static function clean_path($path) { static $search = array(APPPATH, COREPATH, PKGPATH, DOCROOT, '\\'); static $replace = array('APPPATH/', 'COREPATH/', 'PKGPATH/', 'DOCROOT/', '/'); return str_ireplace($search, $replace, $path); }
php
public static function clean_path($path) { static $search = array(APPPATH, COREPATH, PKGPATH, DOCROOT, '\\'); static $replace = array('APPPATH/', 'COREPATH/', 'PKGPATH/', 'DOCROOT/', '/'); return str_ireplace($search, $replace, $path); }
[ "public", "static", "function", "clean_path", "(", "$", "path", ")", "{", "static", "$", "search", "=", "array", "(", "APPPATH", ",", "COREPATH", ",", "PKGPATH", ",", "DOCROOT", ",", "'\\\\'", ")", ";", "static", "$", "replace", "=", "array", "(", "'APPPATH/'", ",", "'COREPATH/'", ",", "'PKGPATH/'", ",", "'DOCROOT/'", ",", "'/'", ")", ";", "return", "str_ireplace", "(", "$", "search", ",", "$", "replace", ",", "$", "path", ")", ";", "}" ]
Cleans a file path so that it does not contain absolute file paths. @param string the filepath @return string the clean path
[ "Cleans", "a", "file", "path", "so", "that", "it", "does", "not", "contain", "absolute", "file", "paths", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L361-L366
240,726
chenwenzhang/initially-rpc
src/Initially/Rpc/Transport/Transport.php
Transport.send
public function send(Request $request) { $interface = $request->getInterface(); $service = ConfigFactory::getClient()->getService($interface); $url = $service->getUrl(); $requestRaw = Formatter::serialize($request); $responseRaw = $this->protocol->sendData($url, $requestRaw); $response = @Formatter::unserialize($responseRaw); if (!($response instanceof Response)) { LoggerProxy::getInstance()->error("illegal response", array($responseRaw)); throw new InitiallyRpcException("illegal response"); } elseif ($response->isHasException()) { $exception = $response->getException(); if (is_object($exception) && $exception instanceof Exception) { throw $exception; } else if (is_string($exception)) { if (class_exists($exception)) { throw new $exception($response->getExceptionMessage()); } else { throw new InitiallyRpcException($response->getExceptionMessage()); } } } return $response->getResult(); }
php
public function send(Request $request) { $interface = $request->getInterface(); $service = ConfigFactory::getClient()->getService($interface); $url = $service->getUrl(); $requestRaw = Formatter::serialize($request); $responseRaw = $this->protocol->sendData($url, $requestRaw); $response = @Formatter::unserialize($responseRaw); if (!($response instanceof Response)) { LoggerProxy::getInstance()->error("illegal response", array($responseRaw)); throw new InitiallyRpcException("illegal response"); } elseif ($response->isHasException()) { $exception = $response->getException(); if (is_object($exception) && $exception instanceof Exception) { throw $exception; } else if (is_string($exception)) { if (class_exists($exception)) { throw new $exception($response->getExceptionMessage()); } else { throw new InitiallyRpcException($response->getExceptionMessage()); } } } return $response->getResult(); }
[ "public", "function", "send", "(", "Request", "$", "request", ")", "{", "$", "interface", "=", "$", "request", "->", "getInterface", "(", ")", ";", "$", "service", "=", "ConfigFactory", "::", "getClient", "(", ")", "->", "getService", "(", "$", "interface", ")", ";", "$", "url", "=", "$", "service", "->", "getUrl", "(", ")", ";", "$", "requestRaw", "=", "Formatter", "::", "serialize", "(", "$", "request", ")", ";", "$", "responseRaw", "=", "$", "this", "->", "protocol", "->", "sendData", "(", "$", "url", ",", "$", "requestRaw", ")", ";", "$", "response", "=", "@", "Formatter", "::", "unserialize", "(", "$", "responseRaw", ")", ";", "if", "(", "!", "(", "$", "response", "instanceof", "Response", ")", ")", "{", "LoggerProxy", "::", "getInstance", "(", ")", "->", "error", "(", "\"illegal response\"", ",", "array", "(", "$", "responseRaw", ")", ")", ";", "throw", "new", "InitiallyRpcException", "(", "\"illegal response\"", ")", ";", "}", "elseif", "(", "$", "response", "->", "isHasException", "(", ")", ")", "{", "$", "exception", "=", "$", "response", "->", "getException", "(", ")", ";", "if", "(", "is_object", "(", "$", "exception", ")", "&&", "$", "exception", "instanceof", "Exception", ")", "{", "throw", "$", "exception", ";", "}", "else", "if", "(", "is_string", "(", "$", "exception", ")", ")", "{", "if", "(", "class_exists", "(", "$", "exception", ")", ")", "{", "throw", "new", "$", "exception", "(", "$", "response", "->", "getExceptionMessage", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "InitiallyRpcException", "(", "$", "response", "->", "getExceptionMessage", "(", ")", ")", ";", "}", "}", "}", "return", "$", "response", "->", "getResult", "(", ")", ";", "}" ]
Send Rpc Request @param Request $request @return mixed @throws InitiallyRpcException
[ "Send", "Rpc", "Request" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Transport/Transport.php#L62-L88
240,727
moaction/jsonrpc-client
src/Moaction/Jsonrpc/Client/ClientBasic.php
ClientBasic.send
protected function send($content) { $streamOptions = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => $content, ) ); $context = stream_context_create($streamOptions); $result = @file_get_contents($this->getServerUrl(), false, $context); if ($result === false) { throw new Exception('Unable to connect to server'); } return $result; }
php
protected function send($content) { $streamOptions = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => $content, ) ); $context = stream_context_create($streamOptions); $result = @file_get_contents($this->getServerUrl(), false, $context); if ($result === false) { throw new Exception('Unable to connect to server'); } return $result; }
[ "protected", "function", "send", "(", "$", "content", ")", "{", "$", "streamOptions", "=", "array", "(", "'http'", "=>", "array", "(", "'method'", "=>", "'POST'", ",", "'header'", "=>", "'Content-Type: application/json'", ",", "'content'", "=>", "$", "content", ",", ")", ")", ";", "$", "context", "=", "stream_context_create", "(", "$", "streamOptions", ")", ";", "$", "result", "=", "@", "file_get_contents", "(", "$", "this", "->", "getServerUrl", "(", ")", ",", "false", ",", "$", "context", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Unable to connect to server'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Send low level data by http @param string $content @return string @throws Exception
[ "Send", "low", "level", "data", "by", "http" ]
cbfb6caeae7dce838cb0f429ae4a60e4ead5ee0c
https://github.com/moaction/jsonrpc-client/blob/cbfb6caeae7dce838cb0f429ae4a60e4ead5ee0c/src/Moaction/Jsonrpc/Client/ClientBasic.php#L43-L61
240,728
CakeCMS/Community
src/Notify/Email.php
Email.sendActivationMessage
public function sendActivationMessage() { $macros = new Macros($this->_data); $message = $this->_params->get('msg_account_activate_msg'); $message = $macros->text($message); $subject = $this->_params->get('msg_account_activate_subject'); return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail()); }
php
public function sendActivationMessage() { $macros = new Macros($this->_data); $message = $this->_params->get('msg_account_activate_msg'); $message = $macros->text($message); $subject = $this->_params->get('msg_account_activate_subject'); return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail()); }
[ "public", "function", "sendActivationMessage", "(", ")", "{", "$", "macros", "=", "new", "Macros", "(", "$", "this", "->", "_data", ")", ";", "$", "message", "=", "$", "this", "->", "_params", "->", "get", "(", "'msg_account_activate_msg'", ")", ";", "$", "message", "=", "$", "macros", "->", "text", "(", "$", "message", ")", ";", "$", "subject", "=", "$", "this", "->", "_params", "->", "get", "(", "'msg_account_activate_subject'", ")", ";", "return", "$", "this", "->", "send", "(", "$", "subject", ",", "$", "message", ",", "$", "this", "->", "_data", "->", "email", ",", "null", ",", "$", "this", "->", "_getFromMail", "(", ")", ")", ";", "}" ]
Send user message when have success activation profile. @return array
[ "Send", "user", "message", "when", "have", "success", "activation", "profile", "." ]
cc2bdb596dd9617d42fd81f59e981024caa062e8
https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Notify/Email.php#L45-L53
240,729
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addAuthor
public function addAuthor(string $name = null, string $email = null) { is_null($name) and $name = ''; is_null($email) and $email = ''; if (empty($name) and empty($email)) { throw new AuthorNoDataException(); } if (!empty($email)) { $author = trim(sprintf(self::FORMAT_AUTHOR, $name, $email)); } else { $author = trim($name); } $this->authors[] = $author; return $this; }
php
public function addAuthor(string $name = null, string $email = null) { is_null($name) and $name = ''; is_null($email) and $email = ''; if (empty($name) and empty($email)) { throw new AuthorNoDataException(); } if (!empty($email)) { $author = trim(sprintf(self::FORMAT_AUTHOR, $name, $email)); } else { $author = trim($name); } $this->authors[] = $author; return $this; }
[ "public", "function", "addAuthor", "(", "string", "$", "name", "=", "null", ",", "string", "$", "email", "=", "null", ")", "{", "is_null", "(", "$", "name", ")", "and", "$", "name", "=", "''", ";", "is_null", "(", "$", "email", ")", "and", "$", "email", "=", "''", ";", "if", "(", "empty", "(", "$", "name", ")", "and", "empty", "(", "$", "email", ")", ")", "{", "throw", "new", "AuthorNoDataException", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "email", ")", ")", "{", "$", "author", "=", "trim", "(", "sprintf", "(", "self", "::", "FORMAT_AUTHOR", ",", "$", "name", ",", "$", "email", ")", ")", ";", "}", "else", "{", "$", "author", "=", "trim", "(", "$", "name", ")", ";", "}", "$", "this", "->", "authors", "[", "]", "=", "$", "author", ";", "return", "$", "this", ";", "}" ]
Adds an author @param string $name @param string $email @return IntercessionClass @throws AuthorNoDataException
[ "Adds", "an", "author" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L216-L234
240,730
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addInterface
public function addInterface(string $interfaceName, string $alias = null) { $this->interfaces[] = $this->addUse($interfaceName, $alias); }
php
public function addInterface(string $interfaceName, string $alias = null) { $this->interfaces[] = $this->addUse($interfaceName, $alias); }
[ "public", "function", "addInterface", "(", "string", "$", "interfaceName", ",", "string", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "interfaces", "[", "]", "=", "$", "this", "->", "addUse", "(", "$", "interfaceName", ",", "$", "alias", ")", ";", "}" ]
Adds an interface @param string $interfaceName @param string $alias @throws DuplicateUseWithAliasException
[ "Adds", "an", "interface" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L302-L305
240,731
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addTrait
public function addTrait(string $traitName, string $alias = null) { $this->traits[] = $this->addUse($traitName, $alias); return $this; }
php
public function addTrait(string $traitName, string $alias = null) { $this->traits[] = $this->addUse($traitName, $alias); return $this; }
[ "public", "function", "addTrait", "(", "string", "$", "traitName", ",", "string", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "traits", "[", "]", "=", "$", "this", "->", "addUse", "(", "$", "traitName", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}" ]
Adds a trait @param string $traitName @param string $alias @return IntercessionClass
[ "Adds", "a", "trait" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L325-L330
240,732
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.extractClassNameFromUse
public function extractClassNameFromUse(string $use) { $matches = []; if (preg_match(self::USE_CLASS_EXTRACT_REGEXP, $use, $matches) === 0) { throw new InvalidNamespaceException($use); } $className = $matches['classname']; $namespace = array_key_exists('namespace', $matches) ? $matches['namespace'] : ''; if (substr($namespace, -1, 1) === '\\') { $namespace = substr($namespace, 0, -1); } return [ $className, $namespace ]; }
php
public function extractClassNameFromUse(string $use) { $matches = []; if (preg_match(self::USE_CLASS_EXTRACT_REGEXP, $use, $matches) === 0) { throw new InvalidNamespaceException($use); } $className = $matches['classname']; $namespace = array_key_exists('namespace', $matches) ? $matches['namespace'] : ''; if (substr($namespace, -1, 1) === '\\') { $namespace = substr($namespace, 0, -1); } return [ $className, $namespace ]; }
[ "public", "function", "extractClassNameFromUse", "(", "string", "$", "use", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "self", "::", "USE_CLASS_EXTRACT_REGEXP", ",", "$", "use", ",", "$", "matches", ")", "===", "0", ")", "{", "throw", "new", "InvalidNamespaceException", "(", "$", "use", ")", ";", "}", "$", "className", "=", "$", "matches", "[", "'classname'", "]", ";", "$", "namespace", "=", "array_key_exists", "(", "'namespace'", ",", "$", "matches", ")", "?", "$", "matches", "[", "'namespace'", "]", ":", "''", ";", "if", "(", "substr", "(", "$", "namespace", ",", "-", "1", ",", "1", ")", "===", "'\\\\'", ")", "{", "$", "namespace", "=", "substr", "(", "$", "namespace", ",", "0", ",", "-", "1", ")", ";", "}", "return", "[", "$", "className", ",", "$", "namespace", "]", ";", "}" ]
Extracts the class name from a used namespaced class @param string $use @return mixed @throws InvalidNamespaceException
[ "Extracts", "the", "class", "name", "from", "a", "used", "namespaced", "class" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L427-L446
240,733
Malwarebytes/AltamiraBundle
ScriptHandler.php
ScriptHandler.installJSDependencies
public static function installJSDependencies($event) { echo "Installing JS Library dependencies for the AltamiraBundle\n"; $dir = getcwd(); ScriptHandler::gitSubmodulesUpdate(); ScriptHandler::cleanPublicJSDir(); // discovered that assetic can minify all the code - all not necessary anymore. /* echo "Compiling jqplot\n"; chdir(static::getLibsDir().DIRECTORY_SEPARATOR."jqplot"); exec('ant clean min', $output, $status); if ($status) { die("Ant failed with $status (is ant installed?)\n"); } chdir($dir); echo "Compiling flot\n"; $flotLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot"; if (($files = scandir($flotLib)) ===false ) { die("failed to traverse through flot directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { exec(static::getYUIBin(). " ".escapeshellarg($flotLib.DIRECTORY_SEPARATOR.$file)." -o " .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); } } echo "Compiling flot bubbles\n"; $flotBubblesLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot-bubbles"; if (($files = scandir($flotBubblesLib)) ===false ) { die("failed to traverse through flot bubbles directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { // minification did not work out, so commented min code. // exec(static::getYUIBin(). " ".escapeshellarg($flotBubblesLib.DIRECTORY_SEPARATOR.$file) ." -o " // .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); // straight copy to min.js for compatibility with min setting in altamira copy($flotBubblesLib.DIRECTORY_SEPARATOR.$file,static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js"); } }*/ echo "Installing jqplot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."jqplot",0777,true); $source = static::getLibsDir().DIRECTORY_SEPARATOR."jqplot".DIRECTORY_SEPARATOR."src"; $dest= static::getJSDir().DIRECTORY_SEPARATOR."jqplot"; recursiveAssetsOnlyCopy($source,$dest); echo "Installing flot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot",static::getJSDir().DIRECTORY_SEPARATOR."flot"); echo "Installing flot-bubbles\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles",static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles"); }
php
public static function installJSDependencies($event) { echo "Installing JS Library dependencies for the AltamiraBundle\n"; $dir = getcwd(); ScriptHandler::gitSubmodulesUpdate(); ScriptHandler::cleanPublicJSDir(); // discovered that assetic can minify all the code - all not necessary anymore. /* echo "Compiling jqplot\n"; chdir(static::getLibsDir().DIRECTORY_SEPARATOR."jqplot"); exec('ant clean min', $output, $status); if ($status) { die("Ant failed with $status (is ant installed?)\n"); } chdir($dir); echo "Compiling flot\n"; $flotLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot"; if (($files = scandir($flotLib)) ===false ) { die("failed to traverse through flot directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { exec(static::getYUIBin(). " ".escapeshellarg($flotLib.DIRECTORY_SEPARATOR.$file)." -o " .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); } } echo "Compiling flot bubbles\n"; $flotBubblesLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot-bubbles"; if (($files = scandir($flotBubblesLib)) ===false ) { die("failed to traverse through flot bubbles directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { // minification did not work out, so commented min code. // exec(static::getYUIBin(). " ".escapeshellarg($flotBubblesLib.DIRECTORY_SEPARATOR.$file) ." -o " // .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); // straight copy to min.js for compatibility with min setting in altamira copy($flotBubblesLib.DIRECTORY_SEPARATOR.$file,static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js"); } }*/ echo "Installing jqplot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."jqplot",0777,true); $source = static::getLibsDir().DIRECTORY_SEPARATOR."jqplot".DIRECTORY_SEPARATOR."src"; $dest= static::getJSDir().DIRECTORY_SEPARATOR."jqplot"; recursiveAssetsOnlyCopy($source,$dest); echo "Installing flot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot",static::getJSDir().DIRECTORY_SEPARATOR."flot"); echo "Installing flot-bubbles\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles",static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles"); }
[ "public", "static", "function", "installJSDependencies", "(", "$", "event", ")", "{", "echo", "\"Installing JS Library dependencies for the AltamiraBundle\\n\"", ";", "$", "dir", "=", "getcwd", "(", ")", ";", "ScriptHandler", "::", "gitSubmodulesUpdate", "(", ")", ";", "ScriptHandler", "::", "cleanPublicJSDir", "(", ")", ";", "// discovered that assetic can minify all the code - all not necessary anymore.", "/*\n echo \"Compiling jqplot\\n\";\n chdir(static::getLibsDir().DIRECTORY_SEPARATOR.\"jqplot\");\n exec('ant clean min', $output, $status);\n if ($status) {\n die(\"Ant failed with $status (is ant installed?)\\n\");\n }\n chdir($dir);\n\n echo \"Compiling flot\\n\";\n $flotLib=static::getLibsDir() .DIRECTORY_SEPARATOR.\"flot\";\n if (($files = scandir($flotLib)) ===false ) {\n die(\"failed to traverse through flot directory\");\n }\n foreach ($files as $file) {\n if (substr($file,-3) == \".js\") {\n exec(static::getYUIBin(). \" \".escapeshellarg($flotLib.DIRECTORY_SEPARATOR.$file).\" -o \"\n .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR.\"flot\".DIRECTORY_SEPARATOR.substr($file,0,-2).\"min.js\"));\n }\n }\n\n echo \"Compiling flot bubbles\\n\";\n $flotBubblesLib=static::getLibsDir() .DIRECTORY_SEPARATOR.\"flot-bubbles\";\n if (($files = scandir($flotBubblesLib)) ===false ) {\n die(\"failed to traverse through flot bubbles directory\");\n }\n\n foreach ($files as $file) {\n if (substr($file,-3) == \".js\") {\n // minification did not work out, so commented min code.\n // exec(static::getYUIBin(). \" \".escapeshellarg($flotBubblesLib.DIRECTORY_SEPARATOR.$file) .\" -o \"\n // .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR.\"flot-bubbles\".DIRECTORY_SEPARATOR.substr($file,0,-2).\"min.js\"));\n\n // straight copy to min.js for compatibility with min setting in altamira\n copy($flotBubblesLib.DIRECTORY_SEPARATOR.$file,static::getLibsDir().DIRECTORY_SEPARATOR.\"flot-bubbles\".DIRECTORY_SEPARATOR.substr($file,0,-2).\"min.js\");\n }\n }*/", "echo", "\"Installing jqplot\\n\"", ";", "mkdir", "(", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"jqplot\"", ",", "0777", ",", "true", ")", ";", "$", "source", "=", "static", "::", "getLibsDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"jqplot\"", ".", "DIRECTORY_SEPARATOR", ".", "\"src\"", ";", "$", "dest", "=", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"jqplot\"", ";", "recursiveAssetsOnlyCopy", "(", "$", "source", ",", "$", "dest", ")", ";", "echo", "\"Installing flot\\n\"", ";", "mkdir", "(", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot\"", ",", "0777", ",", "true", ")", ";", "recursiveAssetsOnlyCopy", "(", "static", "::", "getLibsDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot\"", ",", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot\"", ")", ";", "echo", "\"Installing flot-bubbles\\n\"", ";", "mkdir", "(", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot-bubbles\"", ",", "0777", ",", "true", ")", ";", "recursiveAssetsOnlyCopy", "(", "static", "::", "getLibsDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot-bubbles\"", ",", "static", "::", "getJSDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"flot-bubbles\"", ")", ";", "}" ]
if this gets any bigger, break it up into separate methods
[ "if", "this", "gets", "any", "bigger", "break", "it", "up", "into", "separate", "methods" ]
f42a7c1b27b8d8f15ada10f20571f74b3f95f406
https://github.com/Malwarebytes/AltamiraBundle/blob/f42a7c1b27b8d8f15ada10f20571f74b3f95f406/ScriptHandler.php#L51-L114
240,734
tkhatibi/php-field
src/FieldFactory.php
FieldFactory.getInstance
public static function getInstance(array $config = []) { // If element has no name if (!isset($config['name'])){ throw new \Exception("You have to set the name of the field", 1); } if(!isset($config['class'])){ $config['class'] = Text::className(); } return parent::getInstance($config); }
php
public static function getInstance(array $config = []) { // If element has no name if (!isset($config['name'])){ throw new \Exception("You have to set the name of the field", 1); } if(!isset($config['class'])){ $config['class'] = Text::className(); } return parent::getInstance($config); }
[ "public", "static", "function", "getInstance", "(", "array", "$", "config", "=", "[", "]", ")", "{", "// If element has no name\r", "if", "(", "!", "isset", "(", "$", "config", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"You have to set the name of the field\"", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'class'", "]", ")", ")", "{", "$", "config", "[", "'class'", "]", "=", "Text", "::", "className", "(", ")", ";", "}", "return", "parent", "::", "getInstance", "(", "$", "config", ")", ";", "}" ]
Builds the field and returns it @param array $name field config @return Field instance @throws Exception if the name of the field not found in config array
[ "Builds", "the", "field", "and", "returns", "it" ]
629657a7f96353ab6caf11ca9319a17ede719b76
https://github.com/tkhatibi/php-field/blob/629657a7f96353ab6caf11ca9319a17ede719b76/src/FieldFactory.php#L28-L37
240,735
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.rewindFile
public function rewindFile() { $this->openFile(); if(!rewind($this->getFile())) { throw FileOperationException::createForFailedToRewindFile($this->getFilePath()); } return $this; }
php
public function rewindFile() { $this->openFile(); if(!rewind($this->getFile())) { throw FileOperationException::createForFailedToRewindFile($this->getFilePath()); } return $this; }
[ "public", "function", "rewindFile", "(", ")", "{", "$", "this", "->", "openFile", "(", ")", ";", "if", "(", "!", "rewind", "(", "$", "this", "->", "getFile", "(", ")", ")", ")", "{", "throw", "FileOperationException", "::", "createForFailedToRewindFile", "(", "$", "this", "->", "getFilePath", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Rewind the file @return $this @throws AtomicFileException
[ "Rewind", "the", "file" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L65-L73
240,736
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.isFileEmpty
public function isFileEmpty() { $this->openFile(); $saved_pointer = $this->getFilePointer(); $this->rewindFile()->seekFileToEnd(); $size_pointer = $this->getFilePointer(); $this->seekFile($saved_pointer); return $size_pointer === 0; }
php
public function isFileEmpty() { $this->openFile(); $saved_pointer = $this->getFilePointer(); $this->rewindFile()->seekFileToEnd(); $size_pointer = $this->getFilePointer(); $this->seekFile($saved_pointer); return $size_pointer === 0; }
[ "public", "function", "isFileEmpty", "(", ")", "{", "$", "this", "->", "openFile", "(", ")", ";", "$", "saved_pointer", "=", "$", "this", "->", "getFilePointer", "(", ")", ";", "$", "this", "->", "rewindFile", "(", ")", "->", "seekFileToEnd", "(", ")", ";", "$", "size_pointer", "=", "$", "this", "->", "getFilePointer", "(", ")", ";", "$", "this", "->", "seekFile", "(", "$", "saved_pointer", ")", ";", "return", "$", "size_pointer", "===", "0", ";", "}" ]
Find whether file is empty @return bool @throws AtomicFileException
[ "Find", "whether", "file", "is", "empty" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L142-L151
240,737
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.checkFile
protected function checkFile($writable = true) { if(!$this->fileExists()) throw NonExistentFileException::createForFileDoesNotExists($this->getFilePath()); if(!is_readable($this->file_path)) throw NotReadableFileException::createForNotReadable($this->getFilePath()); if($writable) { if(!is_writable($this->file_path)) throw NotWritableFileException::createForNotWritable($this->getFilePath()); } }
php
protected function checkFile($writable = true) { if(!$this->fileExists()) throw NonExistentFileException::createForFileDoesNotExists($this->getFilePath()); if(!is_readable($this->file_path)) throw NotReadableFileException::createForNotReadable($this->getFilePath()); if($writable) { if(!is_writable($this->file_path)) throw NotWritableFileException::createForNotWritable($this->getFilePath()); } }
[ "protected", "function", "checkFile", "(", "$", "writable", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "fileExists", "(", ")", ")", "throw", "NonExistentFileException", "::", "createForFileDoesNotExists", "(", "$", "this", "->", "getFilePath", "(", ")", ")", ";", "if", "(", "!", "is_readable", "(", "$", "this", "->", "file_path", ")", ")", "throw", "NotReadableFileException", "::", "createForNotReadable", "(", "$", "this", "->", "getFilePath", "(", ")", ")", ";", "if", "(", "$", "writable", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "file_path", ")", ")", "throw", "NotWritableFileException", "::", "createForNotWritable", "(", "$", "this", "->", "getFilePath", "(", ")", ")", ";", "}", "}" ]
Checks the file whether exists and is readable or writable @param bool $writable @throws AtomicFileException
[ "Checks", "the", "file", "whether", "exists", "and", "is", "readable", "or", "writable" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L213-L221
240,738
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.fileExists
protected function fileExists() { $this->clearStatCache(true); return (file_exists($this->file_path) && is_file($this->file_path)); }
php
protected function fileExists() { $this->clearStatCache(true); return (file_exists($this->file_path) && is_file($this->file_path)); }
[ "protected", "function", "fileExists", "(", ")", "{", "$", "this", "->", "clearStatCache", "(", "true", ")", ";", "return", "(", "file_exists", "(", "$", "this", "->", "file_path", ")", "&&", "is_file", "(", "$", "this", "->", "file_path", ")", ")", ";", "}" ]
Checks whether file exists @return bool
[ "Checks", "whether", "file", "exists" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L227-L231
240,739
ojhaujjwal/UserRbac
src/Factory/IdentityRoleProviderFactory.php
IdentityRoleProviderFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $identityRoleProvider = new IdentityRoleProvider( $serviceLocator->get('UserRbac\UserRoleLinkerMapper'), $serviceLocator->get('UserRbac\ModuleOptions') ); if ($serviceLocator->get('zfcuser_auth_service')->hasIdentity()) { $identityRoleProvider->setDefaultIdentity( $serviceLocator->get('zfcuser_auth_service')->getIdentity() ); } return $identityRoleProvider; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $identityRoleProvider = new IdentityRoleProvider( $serviceLocator->get('UserRbac\UserRoleLinkerMapper'), $serviceLocator->get('UserRbac\ModuleOptions') ); if ($serviceLocator->get('zfcuser_auth_service')->hasIdentity()) { $identityRoleProvider->setDefaultIdentity( $serviceLocator->get('zfcuser_auth_service')->getIdentity() ); } return $identityRoleProvider; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "identityRoleProvider", "=", "new", "IdentityRoleProvider", "(", "$", "serviceLocator", "->", "get", "(", "'UserRbac\\UserRoleLinkerMapper'", ")", ",", "$", "serviceLocator", "->", "get", "(", "'UserRbac\\ModuleOptions'", ")", ")", ";", "if", "(", "$", "serviceLocator", "->", "get", "(", "'zfcuser_auth_service'", ")", "->", "hasIdentity", "(", ")", ")", "{", "$", "identityRoleProvider", "->", "setDefaultIdentity", "(", "$", "serviceLocator", "->", "get", "(", "'zfcuser_auth_service'", ")", "->", "getIdentity", "(", ")", ")", ";", "}", "return", "$", "identityRoleProvider", ";", "}" ]
Gets identity role provider @param ServiceLocatorInterface $serviceLocator @return IdentityRoleProvider
[ "Gets", "identity", "role", "provider" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Factory/IdentityRoleProviderFactory.php#L18-L31
240,740
monolyth-php/formulaic
src/Radio/Group.php
Group.setValue
public function setValue($value) { foreach ((array)$this as $element) { if ($value == $element->getElement()->getValue()) { $element->getElement()->check(); } else { $element->getElement()->check(false); } } }
php
public function setValue($value) { foreach ((array)$this as $element) { if ($value == $element->getElement()->getValue()) { $element->getElement()->check(); } else { $element->getElement()->check(false); } } }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "element", ")", "{", "if", "(", "$", "value", "==", "$", "element", "->", "getElement", "(", ")", "->", "getValue", "(", ")", ")", "{", "$", "element", "->", "getElement", "(", ")", "->", "check", "(", ")", ";", "}", "else", "{", "$", "element", "->", "getElement", "(", ")", "->", "check", "(", "false", ")", ";", "}", "}", "}" ]
Sets the element where the value matches to `checked`. @param mixed $value
[ "Sets", "the", "element", "where", "the", "value", "matches", "to", "checked", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L90-L99
240,741
monolyth-php/formulaic
src/Radio/Group.php
Group.getValue
public function getValue() : ArrayObject { foreach ((array)$this as $element) { if ($element->getElement() instanceof Radio && $element->getElement()->checked() ) { return new class([$element->getElement()->getValue()]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; } } return new class([$this->value]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; }
php
public function getValue() : ArrayObject { foreach ((array)$this as $element) { if ($element->getElement() instanceof Radio && $element->getElement()->checked() ) { return new class([$element->getElement()->getValue()]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; } } return new class([$this->value]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; }
[ "public", "function", "getValue", "(", ")", ":", "ArrayObject", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "element", ")", "{", "if", "(", "$", "element", "->", "getElement", "(", ")", "instanceof", "Radio", "&&", "$", "element", "->", "getElement", "(", ")", "->", "checked", "(", ")", ")", "{", "return", "new", "class", "(", "[", "$", "element", "->", "getElement", "(", ")", "->", "getValue", "(", ")", "]", ")", "extends", "ArrayObject", "{", "public", "function", "__toString", "(", ")", ":", "string", "{", "return", "\"{$this[0]}\"", ";", "}", "}", ";", "}", "}", "return", "new", "class", "(", "[", "$", "this", "->", "value", "]", ")", "extends", "ArrayObject", "{", "public", "function", "__toString", "(", ")", ":", "string", "{", "return", "\"{$this[0]}\"", ";", "}", "}", ";", "}" ]
Gets the checked value in the group. @return array Array with a single entry (for compatibility with Element\Group, but obviously radio groups can only ever have one entry checked at a time).
[ "Gets", "the", "checked", "value", "in", "the", "group", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L108-L128
240,742
monolyth-php/formulaic
src/Radio/Group.php
Group.isRequired
public function isRequired() : Group { foreach ((array)$this as $el) { if (!is_object($el)) { continue; } $el->getElement()->attribute('required', 1); } return $this->addTest('required', function ($value) { foreach ($value as $option) { if ($option->getElement() instanceof Radio && $option->getElement()->checked() ) { return true; } } return false; }); }
php
public function isRequired() : Group { foreach ((array)$this as $el) { if (!is_object($el)) { continue; } $el->getElement()->attribute('required', 1); } return $this->addTest('required', function ($value) { foreach ($value as $option) { if ($option->getElement() instanceof Radio && $option->getElement()->checked() ) { return true; } } return false; }); }
[ "public", "function", "isRequired", "(", ")", ":", "Group", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "el", ")", "{", "if", "(", "!", "is_object", "(", "$", "el", ")", ")", "{", "continue", ";", "}", "$", "el", "->", "getElement", "(", ")", "->", "attribute", "(", "'required'", ",", "1", ")", ";", "}", "return", "$", "this", "->", "addTest", "(", "'required'", ",", "function", "(", "$", "value", ")", "{", "foreach", "(", "$", "value", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->", "getElement", "(", ")", "instanceof", "Radio", "&&", "$", "option", "->", "getElement", "(", ")", "->", "checked", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ")", ";", "}" ]
Marks the group as required. @return self
[ "Marks", "the", "group", "as", "required", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L135-L153
240,743
extendsframework/extends-authorization
src/Permission/Permission.php
Permission.getSections
protected function getSections(): array { $sections = explode($this->getDivider(), $this->getNotation()); foreach ($sections as $index => $section) { $sections[$index] = explode($this->getSeparator(), $section); } return $sections; }
php
protected function getSections(): array { $sections = explode($this->getDivider(), $this->getNotation()); foreach ($sections as $index => $section) { $sections[$index] = explode($this->getSeparator(), $section); } return $sections; }
[ "protected", "function", "getSections", "(", ")", ":", "array", "{", "$", "sections", "=", "explode", "(", "$", "this", "->", "getDivider", "(", ")", ",", "$", "this", "->", "getNotation", "(", ")", ")", ";", "foreach", "(", "$", "sections", "as", "$", "index", "=>", "$", "section", ")", "{", "$", "sections", "[", "$", "index", "]", "=", "explode", "(", "$", "this", "->", "getSeparator", "(", ")", ",", "$", "section", ")", ";", "}", "return", "$", "sections", ";", "}" ]
Get exploded notation string. @return array
[ "Get", "exploded", "notation", "string", "." ]
f808ccdbfde07482fb77505a2eb7f7a8854ec828
https://github.com/extendsframework/extends-authorization/blob/f808ccdbfde07482fb77505a2eb7f7a8854ec828/src/Permission/Permission.php#L98-L106
240,744
tenside/core
src/Composer/Search/AbstractSearch.php
AbstractSearch.normalizeResultSet
protected function normalizeResultSet(array $resultSet) { $normalized = []; foreach ($resultSet as $result) { if (($normalizedResult = $this->normalizeResult($result)) === null) { continue; } $normalized[$normalizedResult] = $normalizedResult; } return array_keys($normalized); }
php
protected function normalizeResultSet(array $resultSet) { $normalized = []; foreach ($resultSet as $result) { if (($normalizedResult = $this->normalizeResult($result)) === null) { continue; } $normalized[$normalizedResult] = $normalizedResult; } return array_keys($normalized); }
[ "protected", "function", "normalizeResultSet", "(", "array", "$", "resultSet", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "resultSet", "as", "$", "result", ")", "{", "if", "(", "(", "$", "normalizedResult", "=", "$", "this", "->", "normalizeResult", "(", "$", "result", ")", ")", "===", "null", ")", "{", "continue", ";", "}", "$", "normalized", "[", "$", "normalizedResult", "]", "=", "$", "normalizedResult", ";", "}", "return", "array_keys", "(", "$", "normalized", ")", ";", "}" ]
Normalize a result set. @param array $resultSet The result set. @return string[]
[ "Normalize", "a", "result", "set", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/AbstractSearch.php#L73-L86
240,745
cube-group/myaf-utils
src/PageUtil.php
PageUtil.create
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = []) { $p = new PageUtil(); if ($pageSize < 1) { $pageSize = 1; } $total = ceil($totalPage / $pageSize); if ($page < 1) { $page = 1; } else if ($page > $total) { $page = $total; } $p->page = $page; $p->gets = $gets; $p->total = $total; $p->pageSize = $pageSize; return $p; }
php
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = []) { $p = new PageUtil(); if ($pageSize < 1) { $pageSize = 1; } $total = ceil($totalPage / $pageSize); if ($page < 1) { $page = 1; } else if ($page > $total) { $page = $total; } $p->page = $page; $p->gets = $gets; $p->total = $total; $p->pageSize = $pageSize; return $p; }
[ "public", "static", "function", "create", "(", "$", "totalPage", ",", "$", "pageSize", "=", "10", ",", "$", "page", "=", "1", ",", "$", "gets", "=", "[", "]", ")", "{", "$", "p", "=", "new", "PageUtil", "(", ")", ";", "if", "(", "$", "pageSize", "<", "1", ")", "{", "$", "pageSize", "=", "1", ";", "}", "$", "total", "=", "ceil", "(", "$", "totalPage", "/", "$", "pageSize", ")", ";", "if", "(", "$", "page", "<", "1", ")", "{", "$", "page", "=", "1", ";", "}", "else", "if", "(", "$", "page", ">", "$", "total", ")", "{", "$", "page", "=", "$", "total", ";", "}", "$", "p", "->", "page", "=", "$", "page", ";", "$", "p", "->", "gets", "=", "$", "gets", ";", "$", "p", "->", "total", "=", "$", "total", ";", "$", "p", "->", "pageSize", "=", "$", "pageSize", ";", "return", "$", "p", ";", "}" ]
Page constructor. @param $totalPage int 总条数 @param int $pageSize 每页显示条数 @param int $page 当前页码 @param array $gets url携带get参数数组 @return self
[ "Page", "constructor", "." ]
febc3e1936ebdf763cf5478647e5ba22b3fd2812
https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/PageUtil.php#L42-L62
240,746
phpzm/kernel
src/Kernel/Container.php
Container.make
public function make(string $alias) { if (array_key_exists($alias, $this->bindings)) { $classOrObject = $this->bindings[$alias]; if (is_object($classOrObject)) { return $classOrObject; } return $this->makeInstance($classOrObject); } if (class_exists($alias)) { return self::register($alias, $this->makeInstance($alias))->make($alias); } throw new SimplesRunTimeError("Class '{$alias}' not found"); }
php
public function make(string $alias) { if (array_key_exists($alias, $this->bindings)) { $classOrObject = $this->bindings[$alias]; if (is_object($classOrObject)) { return $classOrObject; } return $this->makeInstance($classOrObject); } if (class_exists($alias)) { return self::register($alias, $this->makeInstance($alias))->make($alias); } throw new SimplesRunTimeError("Class '{$alias}' not found"); }
[ "public", "function", "make", "(", "string", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "bindings", ")", ")", "{", "$", "classOrObject", "=", "$", "this", "->", "bindings", "[", "$", "alias", "]", ";", "if", "(", "is_object", "(", "$", "classOrObject", ")", ")", "{", "return", "$", "classOrObject", ";", "}", "return", "$", "this", "->", "makeInstance", "(", "$", "classOrObject", ")", ";", "}", "if", "(", "class_exists", "(", "$", "alias", ")", ")", "{", "return", "self", "::", "register", "(", "$", "alias", ",", "$", "this", "->", "makeInstance", "(", "$", "alias", ")", ")", "->", "make", "(", "$", "alias", ")", ";", "}", "throw", "new", "SimplesRunTimeError", "(", "\"Class '{$alias}' not found\"", ")", ";", "}" ]
Resolves and created a new instance of a desired class. @param string $alias @return mixed @throws SimplesRunTimeError
[ "Resolves", "and", "created", "a", "new", "instance", "of", "a", "desired", "class", "." ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L124-L140
240,747
phpzm/kernel
src/Kernel/Container.php
Container.makeInstance
public function makeInstance($className) { // class reflection $reflection = new ReflectionClass($className); // get the class constructor $constructor = $reflection->getConstructor(); // if there is no constructor, just create and // return a new instance if (!$constructor) { return $reflection->newInstance(); } // created and returns the new instance passing the // resolved parameters return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), [])); }
php
public function makeInstance($className) { // class reflection $reflection = new ReflectionClass($className); // get the class constructor $constructor = $reflection->getConstructor(); // if there is no constructor, just create and // return a new instance if (!$constructor) { return $reflection->newInstance(); } // created and returns the new instance passing the // resolved parameters return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), [])); }
[ "public", "function", "makeInstance", "(", "$", "className", ")", "{", "// class reflection", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "// get the class constructor", "$", "constructor", "=", "$", "reflection", "->", "getConstructor", "(", ")", ";", "// if there is no constructor, just create and", "// return a new instance", "if", "(", "!", "$", "constructor", ")", "{", "return", "$", "reflection", "->", "newInstance", "(", ")", ";", "}", "// created and returns the new instance passing the", "// resolved parameters", "return", "$", "reflection", "->", "newInstanceArgs", "(", "$", "this", "->", "resolveParameters", "(", "$", "constructor", "->", "getParameters", "(", ")", ",", "[", "]", ")", ")", ";", "}" ]
Created a instance of a desired class. @param $className @return mixed @throws SimplesRunTimeError
[ "Created", "a", "instance", "of", "a", "desired", "class", "." ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L149-L165
240,748
phpzm/kernel
src/Kernel/Container.php
Container.exists
public function exists($instance, string $method) { $reflection = new ReflectionClass(get_class($instance)); return $reflection->hasMethod($method); }
php
public function exists($instance, string $method) { $reflection = new ReflectionClass(get_class($instance)); return $reflection->hasMethod($method); }
[ "public", "function", "exists", "(", "$", "instance", ",", "string", "$", "method", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "get_class", "(", "$", "instance", ")", ")", ";", "return", "$", "reflection", "->", "hasMethod", "(", "$", "method", ")", ";", "}" ]
Checks whether a specific method is defined in a class @param mixed $instance @param string $method @return bool
[ "Checks", "whether", "a", "specific", "method", "is", "defined", "in", "a", "class" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L174-L179
240,749
phpzm/kernel
src/Kernel/Container.php
Container.invoke
public function invoke($instance, string $method, array $data) { // get the parameters $parameters = $this->resolveMethodParameters($instance, $method, $data, true); // get the reflection of method $reflection = new ReflectionMethod(get_class($instance), $method); // allow access $reflection->setAccessible(true); // execute the method return $reflection->invokeArgs($instance, $parameters); }
php
public function invoke($instance, string $method, array $data) { // get the parameters $parameters = $this->resolveMethodParameters($instance, $method, $data, true); // get the reflection of method $reflection = new ReflectionMethod(get_class($instance), $method); // allow access $reflection->setAccessible(true); // execute the method return $reflection->invokeArgs($instance, $parameters); }
[ "public", "function", "invoke", "(", "$", "instance", ",", "string", "$", "method", ",", "array", "$", "data", ")", "{", "// get the parameters", "$", "parameters", "=", "$", "this", "->", "resolveMethodParameters", "(", "$", "instance", ",", "$", "method", ",", "$", "data", ",", "true", ")", ";", "// get the reflection of method", "$", "reflection", "=", "new", "ReflectionMethod", "(", "get_class", "(", "$", "instance", ")", ",", "$", "method", ")", ";", "// allow access", "$", "reflection", "->", "setAccessible", "(", "true", ")", ";", "// execute the method", "return", "$", "reflection", "->", "invokeArgs", "(", "$", "instance", ",", "$", "parameters", ")", ";", "}" ]
Invoke a method of an instance of a class @param mixed $instance @param string $method @param array $data @return mixed @throws SimplesRunTimeError
[ "Invoke", "a", "method", "of", "an", "instance", "of", "a", "class" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L190-L203
240,750
phpzm/kernel
src/Kernel/Container.php
Container.resolveMethodParameters
public function resolveMethodParameters($instance, $method, $parameters, $labels = false) { // method reflection $reflectionMethod = new ReflectionMethod($instance, $method); // resolved array of parameters return $this->resolveParameters($reflectionMethod->getParameters(), $parameters, $labels); }
php
public function resolveMethodParameters($instance, $method, $parameters, $labels = false) { // method reflection $reflectionMethod = new ReflectionMethod($instance, $method); // resolved array of parameters return $this->resolveParameters($reflectionMethod->getParameters(), $parameters, $labels); }
[ "public", "function", "resolveMethodParameters", "(", "$", "instance", ",", "$", "method", ",", "$", "parameters", ",", "$", "labels", "=", "false", ")", "{", "// method reflection", "$", "reflectionMethod", "=", "new", "ReflectionMethod", "(", "$", "instance", ",", "$", "method", ")", ";", "// resolved array of parameters", "return", "$", "this", "->", "resolveParameters", "(", "$", "reflectionMethod", "->", "getParameters", "(", ")", ",", "$", "parameters", ",", "$", "labels", ")", ";", "}" ]
Generate a list of values to be used like parameters to one method @param $instance @param $method @param $parameters @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "method" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L215-L222
240,751
phpzm/kernel
src/Kernel/Container.php
Container.resolveFunctionParameters
public function resolveFunctionParameters($callable, $parameters, $labels = false) { // method reflection $reflectionFunction = new ReflectionFunction($callable); // resolved array of parameters return $this->resolveParameters($reflectionFunction->getParameters(), $parameters, $labels); }
php
public function resolveFunctionParameters($callable, $parameters, $labels = false) { // method reflection $reflectionFunction = new ReflectionFunction($callable); // resolved array of parameters return $this->resolveParameters($reflectionFunction->getParameters(), $parameters, $labels); }
[ "public", "function", "resolveFunctionParameters", "(", "$", "callable", ",", "$", "parameters", ",", "$", "labels", "=", "false", ")", "{", "// method reflection", "$", "reflectionFunction", "=", "new", "ReflectionFunction", "(", "$", "callable", ")", ";", "// resolved array of parameters", "return", "$", "this", "->", "resolveParameters", "(", "$", "reflectionFunction", "->", "getParameters", "(", ")", ",", "$", "parameters", ",", "$", "labels", ")", ";", "}" ]
Generate a list of values to be used like parameters to one function @param $callable @param $parameters @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L233-L240
240,752
phpzm/kernel
src/Kernel/Container.php
Container.resolveParameters
private function resolveParameters($parameters, $data, $labels = false) { $resolved = []; /** @var ReflectionParameter $reflectionParameter */ foreach ($parameters as $reflectionParameter) { /** @noinspection PhpAssignmentInConditionInspection */ $parameter = $this->parseParameter($reflectionParameter, $data, $labels); if (!is_null($parameter)) { $resolved[] = $parameter; continue; } /** @noinspection PhpAssignmentInConditionInspection */ if ($parameterClassName = $this->extractClassName($reflectionParameter)) { $resolved[] = static::make($parameterClassName); continue; } $resolved[] = null; } return $resolved; }
php
private function resolveParameters($parameters, $data, $labels = false) { $resolved = []; /** @var ReflectionParameter $reflectionParameter */ foreach ($parameters as $reflectionParameter) { /** @noinspection PhpAssignmentInConditionInspection */ $parameter = $this->parseParameter($reflectionParameter, $data, $labels); if (!is_null($parameter)) { $resolved[] = $parameter; continue; } /** @noinspection PhpAssignmentInConditionInspection */ if ($parameterClassName = $this->extractClassName($reflectionParameter)) { $resolved[] = static::make($parameterClassName); continue; } $resolved[] = null; } return $resolved; }
[ "private", "function", "resolveParameters", "(", "$", "parameters", ",", "$", "data", ",", "$", "labels", "=", "false", ")", "{", "$", "resolved", "=", "[", "]", ";", "/** @var ReflectionParameter $reflectionParameter */", "foreach", "(", "$", "parameters", "as", "$", "reflectionParameter", ")", "{", "/** @noinspection PhpAssignmentInConditionInspection */", "$", "parameter", "=", "$", "this", "->", "parseParameter", "(", "$", "reflectionParameter", ",", "$", "data", ",", "$", "labels", ")", ";", "if", "(", "!", "is_null", "(", "$", "parameter", ")", ")", "{", "$", "resolved", "[", "]", "=", "$", "parameter", ";", "continue", ";", "}", "/** @noinspection PhpAssignmentInConditionInspection */", "if", "(", "$", "parameterClassName", "=", "$", "this", "->", "extractClassName", "(", "$", "reflectionParameter", ")", ")", "{", "$", "resolved", "[", "]", "=", "static", "::", "make", "(", "$", "parameterClassName", ")", ";", "continue", ";", "}", "$", "resolved", "[", "]", "=", "null", ";", "}", "return", "$", "resolved", ";", "}" ]
Generate a list of values to be used like parameters to one method or function @param $parameters @param $data @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "method", "or", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L251-L270
240,753
phpzm/kernel
src/Kernel/Container.php
Container.parseParameter
private function parseParameter(ReflectionParameter $reflectionParameter, &$data, $labels) { // get the principal properties $name = $reflectionParameter->getName(); $value = null; if ($reflectionParameter->isOptional()) { $value = $reflectionParameter->getDefaultValue(); } // parse data using labels if ($labels) { if (isset($data[$name])) { $value = off($data, $name, $value); unset($data[$name]); } return $value; } // parse data without labels if (isset($data[0])) { $value = $data[0]; array_shift($data); reset($data); } return $value; }
php
private function parseParameter(ReflectionParameter $reflectionParameter, &$data, $labels) { // get the principal properties $name = $reflectionParameter->getName(); $value = null; if ($reflectionParameter->isOptional()) { $value = $reflectionParameter->getDefaultValue(); } // parse data using labels if ($labels) { if (isset($data[$name])) { $value = off($data, $name, $value); unset($data[$name]); } return $value; } // parse data without labels if (isset($data[0])) { $value = $data[0]; array_shift($data); reset($data); } return $value; }
[ "private", "function", "parseParameter", "(", "ReflectionParameter", "$", "reflectionParameter", ",", "&", "$", "data", ",", "$", "labels", ")", "{", "// get the principal properties", "$", "name", "=", "$", "reflectionParameter", "->", "getName", "(", ")", ";", "$", "value", "=", "null", ";", "if", "(", "$", "reflectionParameter", "->", "isOptional", "(", ")", ")", "{", "$", "value", "=", "$", "reflectionParameter", "->", "getDefaultValue", "(", ")", ";", "}", "// parse data using labels", "if", "(", "$", "labels", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "name", "]", ")", ")", "{", "$", "value", "=", "off", "(", "$", "data", ",", "$", "name", ",", "$", "value", ")", ";", "unset", "(", "$", "data", "[", "$", "name", "]", ")", ";", "}", "return", "$", "value", ";", "}", "// parse data without labels", "if", "(", "isset", "(", "$", "data", "[", "0", "]", ")", ")", "{", "$", "value", "=", "$", "data", "[", "0", "]", ";", "array_shift", "(", "$", "data", ")", ";", "reset", "(", "$", "data", ")", ";", "}", "return", "$", "value", ";", "}" ]
Configure the beste resource to each parameter of one method or function @param ReflectionParameter $reflectionParameter @param array $data @param bool $labels @return mixed
[ "Configure", "the", "beste", "resource", "to", "each", "parameter", "of", "one", "method", "or", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L280-L305
240,754
phpzm/kernel
src/Kernel/Container.php
Container.extractClassName
private function extractClassName(ReflectionParameter $reflectionParameter) { if (isset($reflectionParameter->getClass()->name)) { return $reflectionParameter->getClass()->name; } return ''; }
php
private function extractClassName(ReflectionParameter $reflectionParameter) { if (isset($reflectionParameter->getClass()->name)) { return $reflectionParameter->getClass()->name; } return ''; }
[ "private", "function", "extractClassName", "(", "ReflectionParameter", "$", "reflectionParameter", ")", "{", "if", "(", "isset", "(", "$", "reflectionParameter", "->", "getClass", "(", ")", "->", "name", ")", ")", "{", "return", "$", "reflectionParameter", "->", "getClass", "(", ")", "->", "name", ";", "}", "return", "''", ";", "}" ]
Get the name of class related to a list of parameters @param ReflectionParameter $reflectionParameter @return string
[ "Get", "the", "name", "of", "class", "related", "to", "a", "list", "of", "parameters" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L313-L319
240,755
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.execute
public function execute() { $DB = $this->getDBO(); //Run the Query; $resultId = $DB->exec(); //\Platform\Debugger::log($resultId); $this->setResultId($resultId)->setConnectionId($DB->getResourceId())->setAffectedRows($this->getAffectedRows()); $DB->resetRun(); return $this; }
php
public function execute() { $DB = $this->getDBO(); //Run the Query; $resultId = $DB->exec(); //\Platform\Debugger::log($resultId); $this->setResultId($resultId)->setConnectionId($DB->getResourceId())->setAffectedRows($this->getAffectedRows()); $DB->resetRun(); return $this; }
[ "public", "function", "execute", "(", ")", "{", "$", "DB", "=", "$", "this", "->", "getDBO", "(", ")", ";", "//Run the Query;", "$", "resultId", "=", "$", "DB", "->", "exec", "(", ")", ";", "//\\Platform\\Debugger::log($resultId);", "$", "this", "->", "setResultId", "(", "$", "resultId", ")", "->", "setConnectionId", "(", "$", "DB", "->", "getResourceId", "(", ")", ")", "->", "setAffectedRows", "(", "$", "this", "->", "getAffectedRows", "(", ")", ")", ";", "$", "DB", "->", "resetRun", "(", ")", ";", "return", "$", "this", ";", "}" ]
Executes the prepared Statement @return
[ "Executes", "the", "prepared", "Statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L41-L54
240,756
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.listColumns
public function listColumns() { $fieldNames = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $fieldNames[] = $field->name; } return $fieldNames; }
php
public function listColumns() { $fieldNames = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $fieldNames[] = $field->name; } return $fieldNames; }
[ "public", "function", "listColumns", "(", ")", "{", "$", "fieldNames", "=", "array", "(", ")", ";", "$", "field", "=", "NULL", ";", "while", "(", "$", "field", "=", "mysqli_fetch_field", "(", "$", "this", "->", "getResultId", "(", ")", ")", ")", "{", "$", "fieldNames", "[", "]", "=", "$", "field", "->", "name", ";", "}", "return", "$", "fieldNames", ";", "}" ]
Lists all columns in a result row @return array
[ "Lists", "all", "columns", "in", "a", "result", "row" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L92-L101
240,757
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.getColumnMeta
public function getColumnMeta($name = '') { $retval = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $f = new stdClass(); $f->name = $field->name; $f->type = $field->type; $f->default = $field->def; $f->maxLength = $field->max_length; $f->primaryKey = $field->primary_key; $retval[] = $f; } return $retval; }
php
public function getColumnMeta($name = '') { $retval = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $f = new stdClass(); $f->name = $field->name; $f->type = $field->type; $f->default = $field->def; $f->maxLength = $field->max_length; $f->primaryKey = $field->primary_key; $retval[] = $f; } return $retval; }
[ "public", "function", "getColumnMeta", "(", "$", "name", "=", "''", ")", "{", "$", "retval", "=", "array", "(", ")", ";", "$", "field", "=", "NULL", ";", "while", "(", "$", "field", "=", "mysqli_fetch_field", "(", "$", "this", "->", "getResultId", "(", ")", ")", ")", "{", "$", "f", "=", "new", "stdClass", "(", ")", ";", "$", "f", "->", "name", "=", "$", "field", "->", "name", ";", "$", "f", "->", "type", "=", "$", "field", "->", "type", ";", "$", "f", "->", "default", "=", "$", "field", "->", "def", ";", "$", "f", "->", "maxLength", "=", "$", "field", "->", "max_length", ";", "$", "f", "->", "primaryKey", "=", "$", "field", "->", "primary_key", ";", "$", "retval", "[", "]", "=", "$", "f", ";", "}", "return", "$", "retval", ";", "}" ]
Returns metadata for a column or all columns in a result set @return stdClass
[ "Returns", "metadata", "for", "a", "column", "or", "all", "columns", "in", "a", "result", "set" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L108-L125
240,758
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.freeResults
public function freeResults() { if (is_a($this->getResultId(), "mysqli_result")) { mysqli_free_result($this->getResultId()); $this->setResultId(FALSE); } }
php
public function freeResults() { if (is_a($this->getResultId(), "mysqli_result")) { mysqli_free_result($this->getResultId()); $this->setResultId(FALSE); } }
[ "public", "function", "freeResults", "(", ")", "{", "if", "(", "is_a", "(", "$", "this", "->", "getResultId", "(", ")", ",", "\"mysqli_result\"", ")", ")", "{", "mysqli_free_result", "(", "$", "this", "->", "getResultId", "(", ")", ")", ";", "$", "this", "->", "setResultId", "(", "FALSE", ")", ";", "}", "}" ]
Frees the result @return void
[ "Frees", "the", "result" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L132-L138
240,759
jeromeklam/freefw
src/FreeFW/Core/ApiController.php
ApiController.createOne
public function createOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.createOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); if (!$data->isValid()) { $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(409, $data); } $data->create(); $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(201, $data); } else { return $this->createResponse(409); } }
php
public function createOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.createOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); if (!$data->isValid()) { $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(409, $data); } $data->create(); $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(201, $data); } else { return $this->createResponse(409); } }
[ "public", "function", "createOne", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$", "p_request", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.createOne.start'", ")", ";", "$", "apiParams", "=", "$", "p_request", "->", "getAttribute", "(", "'api_params'", ",", "false", ")", ";", "//", "if", "(", "$", "apiParams", "->", "hasData", "(", ")", ")", "{", "/**\n * @var \\FreeFW\\Core\\StorageModel $data\n */", "$", "data", "=", "$", "apiParams", "->", "getData", "(", ")", ";", "if", "(", "!", "$", "data", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.createOne.end'", ")", ";", "return", "$", "this", "->", "createResponse", "(", "409", ",", "$", "data", ")", ";", "}", "$", "data", "->", "create", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.createOne.end'", ")", ";", "return", "$", "this", "->", "createResponse", "(", "201", ",", "$", "data", ")", ";", "}", "else", "{", "return", "$", "this", "->", "createResponse", "(", "409", ")", ";", "}", "}" ]
Add new single element @param \Psr\Http\Message\ServerRequestInterface $p_request
[ "Add", "new", "single", "element" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/ApiController.php#L17-L37
240,760
jeromeklam/freefw
src/FreeFW/Core/ApiController.php
ApiController.removeOne
public function removeOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.removeOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); $data->remove(); $this->logger->debug('FreeFW.ApiController.removeOne.end'); return $this->createResponse(204); } else { return $this->createResponse(409); } }
php
public function removeOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.removeOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); $data->remove(); $this->logger->debug('FreeFW.ApiController.removeOne.end'); return $this->createResponse(204); } else { return $this->createResponse(409); } }
[ "public", "function", "removeOne", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$", "p_request", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.removeOne.start'", ")", ";", "$", "apiParams", "=", "$", "p_request", "->", "getAttribute", "(", "'api_params'", ",", "false", ")", ";", "//", "if", "(", "$", "apiParams", "->", "hasData", "(", ")", ")", "{", "/**\n * @var \\FreeFW\\Core\\StorageModel $data\n */", "$", "data", "=", "$", "apiParams", "->", "getData", "(", ")", ";", "$", "data", "->", "remove", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.removeOne.end'", ")", ";", "return", "$", "this", "->", "createResponse", "(", "204", ")", ";", "}", "else", "{", "return", "$", "this", "->", "createResponse", "(", "409", ")", ";", "}", "}" ]
Remove single element @param \Psr\Http\Message\ServerRequestInterface $p_request
[ "Remove", "single", "element" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/ApiController.php#L69-L85
240,761
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent.filter
public function filter(Query $query) { if (!empty($this->filterOptions['conditions'])) { $query->where($this->filterOptions['conditions']); } if (!empty($this->filterOptions['order'])) { $query->order($this->filterOptions['order']); } return $query; }
php
public function filter(Query $query) { if (!empty($this->filterOptions['conditions'])) { $query->where($this->filterOptions['conditions']); } if (!empty($this->filterOptions['order'])) { $query->order($this->filterOptions['order']); } return $query; }
[ "public", "function", "filter", "(", "Query", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "filterOptions", "[", "'conditions'", "]", ")", ")", "{", "$", "query", "->", "where", "(", "$", "this", "->", "filterOptions", "[", "'conditions'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filterOptions", "[", "'order'", "]", ")", ")", "{", "$", "query", "->", "order", "(", "$", "this", "->", "filterOptions", "[", "'order'", "]", ")", ";", "}", "return", "$", "query", ";", "}" ]
Apply filter conditions and order options to the given query. @param Query $query @return Query
[ "Apply", "filter", "conditions", "and", "order", "options", "to", "the", "given", "query", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L243-L253
240,762
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent.getBacklink
public static function getBacklink($url, ServerRequest $request) { if (!isset($url['plugin'])) { $url['plugin'] = $request->getParam('plugin'); } if (!isset($url['controller'])) { $url['controller'] = $request->getParam('controller'); } $path = join('.', [ 'FILTER_' . ($url['plugin'] ? $url['plugin'] : ''), $url['controller'], $url['action'] ]); if (($filterOptions = $request->getSession()->read($path))) { if (isset($filterOptions['slug'])) { $url['sluggedFilter'] = $filterOptions['slug']; unset($filterOptions['slug']); } if (!empty($filterOptions)) { if (!isset($url['?'])) { $url['?'] = []; } $url['?'] = array_merge($url['?'], $filterOptions); } } return $url; }
php
public static function getBacklink($url, ServerRequest $request) { if (!isset($url['plugin'])) { $url['plugin'] = $request->getParam('plugin'); } if (!isset($url['controller'])) { $url['controller'] = $request->getParam('controller'); } $path = join('.', [ 'FILTER_' . ($url['plugin'] ? $url['plugin'] : ''), $url['controller'], $url['action'] ]); if (($filterOptions = $request->getSession()->read($path))) { if (isset($filterOptions['slug'])) { $url['sluggedFilter'] = $filterOptions['slug']; unset($filterOptions['slug']); } if (!empty($filterOptions)) { if (!isset($url['?'])) { $url['?'] = []; } $url['?'] = array_merge($url['?'], $filterOptions); } } return $url; }
[ "public", "static", "function", "getBacklink", "(", "$", "url", ",", "ServerRequest", "$", "request", ")", "{", "if", "(", "!", "isset", "(", "$", "url", "[", "'plugin'", "]", ")", ")", "{", "$", "url", "[", "'plugin'", "]", "=", "$", "request", "->", "getParam", "(", "'plugin'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "url", "[", "'controller'", "]", ")", ")", "{", "$", "url", "[", "'controller'", "]", "=", "$", "request", "->", "getParam", "(", "'controller'", ")", ";", "}", "$", "path", "=", "join", "(", "'.'", ",", "[", "'FILTER_'", ".", "(", "$", "url", "[", "'plugin'", "]", "?", "$", "url", "[", "'plugin'", "]", ":", "''", ")", ",", "$", "url", "[", "'controller'", "]", ",", "$", "url", "[", "'action'", "]", "]", ")", ";", "if", "(", "(", "$", "filterOptions", "=", "$", "request", "->", "getSession", "(", ")", "->", "read", "(", "$", "path", ")", ")", ")", "{", "if", "(", "isset", "(", "$", "filterOptions", "[", "'slug'", "]", ")", ")", "{", "$", "url", "[", "'sluggedFilter'", "]", "=", "$", "filterOptions", "[", "'slug'", "]", ";", "unset", "(", "$", "filterOptions", "[", "'slug'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "filterOptions", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "url", "[", "'?'", "]", ")", ")", "{", "$", "url", "[", "'?'", "]", "=", "[", "]", ";", "}", "$", "url", "[", "'?'", "]", "=", "array_merge", "(", "$", "url", "[", "'?'", "]", ",", "$", "filterOptions", ")", ";", "}", "}", "return", "$", "url", ";", "}" ]
Try to retrieve a filtered backlink from the session. @param array $url @param ServerRequest $request @return array
[ "Try", "to", "retrieve", "a", "filtered", "backlink", "from", "the", "session", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L411-L440
240,763
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._initFilterOptions
protected function _initFilterOptions() { if (!$this->_filterEnabled && !$this->_sortEnabled) { return; } $options = [ 'conditions' => [], 'order' => [] ]; // check filter params if (!empty($this->request->getData())) { foreach ($this->request->getData() as $field => $value) { if (!isset($this->filterFields[$field]) || $value === '') { continue; } $options = $this->_createFilterFieldOption($field, $value, $options); $this->activeFilters[$field] = $value; } } if (isset($this->sortFields[$this->request->getQuery('s')])) { $d = 'asc'; if ($this->request->getQuery('d')) { $dir = strtolower($this->request->getQuery('d')); if (in_array($dir, ['asc', 'desc'])) { $d = $dir; } } $field = $this->request->getQuery('s'); $options = $this->_createSortFieldOption($field, $d, $options); $this->activeSort[$field] = $d; } elseif (!empty($this->defaultSort)) { $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options); $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir']; } if ($this->request->getQuery('p')) { $this->page = $this->request->getQuery('p'); } $this->filterOptions = $options; }
php
protected function _initFilterOptions() { if (!$this->_filterEnabled && !$this->_sortEnabled) { return; } $options = [ 'conditions' => [], 'order' => [] ]; // check filter params if (!empty($this->request->getData())) { foreach ($this->request->getData() as $field => $value) { if (!isset($this->filterFields[$field]) || $value === '') { continue; } $options = $this->_createFilterFieldOption($field, $value, $options); $this->activeFilters[$field] = $value; } } if (isset($this->sortFields[$this->request->getQuery('s')])) { $d = 'asc'; if ($this->request->getQuery('d')) { $dir = strtolower($this->request->getQuery('d')); if (in_array($dir, ['asc', 'desc'])) { $d = $dir; } } $field = $this->request->getQuery('s'); $options = $this->_createSortFieldOption($field, $d, $options); $this->activeSort[$field] = $d; } elseif (!empty($this->defaultSort)) { $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options); $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir']; } if ($this->request->getQuery('p')) { $this->page = $this->request->getQuery('p'); } $this->filterOptions = $options; }
[ "protected", "function", "_initFilterOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_filterEnabled", "&&", "!", "$", "this", "->", "_sortEnabled", ")", "{", "return", ";", "}", "$", "options", "=", "[", "'conditions'", "=>", "[", "]", ",", "'order'", "=>", "[", "]", "]", ";", "// check filter params", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "getData", "(", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "request", "->", "getData", "(", ")", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "filterFields", "[", "$", "field", "]", ")", "||", "$", "value", "===", "''", ")", "{", "continue", ";", "}", "$", "options", "=", "$", "this", "->", "_createFilterFieldOption", "(", "$", "field", ",", "$", "value", ",", "$", "options", ")", ";", "$", "this", "->", "activeFilters", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "sortFields", "[", "$", "this", "->", "request", "->", "getQuery", "(", "'s'", ")", "]", ")", ")", "{", "$", "d", "=", "'asc'", ";", "if", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'d'", ")", ")", "{", "$", "dir", "=", "strtolower", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'d'", ")", ")", ";", "if", "(", "in_array", "(", "$", "dir", ",", "[", "'asc'", ",", "'desc'", "]", ")", ")", "{", "$", "d", "=", "$", "dir", ";", "}", "}", "$", "field", "=", "$", "this", "->", "request", "->", "getQuery", "(", "'s'", ")", ";", "$", "options", "=", "$", "this", "->", "_createSortFieldOption", "(", "$", "field", ",", "$", "d", ",", "$", "options", ")", ";", "$", "this", "->", "activeSort", "[", "$", "field", "]", "=", "$", "d", ";", "}", "elseif", "(", "!", "empty", "(", "$", "this", "->", "defaultSort", ")", ")", "{", "$", "options", "=", "$", "this", "->", "_createSortFieldOption", "(", "$", "this", "->", "defaultSort", "[", "'field'", "]", ",", "$", "this", "->", "defaultSort", "[", "'dir'", "]", ",", "$", "options", ")", ";", "$", "this", "->", "activeSort", "[", "$", "this", "->", "defaultSort", "[", "'field'", "]", "]", "=", "$", "this", "->", "defaultSort", "[", "'dir'", "]", ";", "}", "if", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'p'", ")", ")", "{", "$", "this", "->", "page", "=", "$", "this", "->", "request", "->", "getQuery", "(", "'p'", ")", ";", "}", "$", "this", "->", "filterOptions", "=", "$", "options", ";", "}" ]
Create the filter options that can be used for model find calls in the controller. @return void
[ "Create", "the", "filter", "options", "that", "can", "be", "used", "for", "model", "find", "calls", "in", "the", "controller", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L449-L494
240,764
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isSortEnabled
protected function _isSortEnabled() { if (!isset($this->controller->sortFields)) { return false; } foreach ($this->controller->sortFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
php
protected function _isSortEnabled() { if (!isset($this->controller->sortFields)) { return false; } foreach ($this->controller->sortFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
[ "protected", "function", "_isSortEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "sortFields", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "controller", "->", "sortFields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "field", "[", "'actions'", "]", ")", "&&", "is_array", "(", "$", "field", "[", "'actions'", "]", ")", "&&", "in_array", "(", "$", "this", "->", "action", ",", "$", "field", "[", "'actions'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if sorting for the current controller action is enabled. @return boolean
[ "Check", "if", "sorting", "for", "the", "current", "controller", "action", "is", "enabled", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L501-L517
240,765
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isFilterEnabled
protected function _isFilterEnabled() { if (!isset($this->controller->filterFields)) { return false; } foreach ($this->controller->filterFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
php
protected function _isFilterEnabled() { if (!isset($this->controller->filterFields)) { return false; } foreach ($this->controller->filterFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
[ "protected", "function", "_isFilterEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "filterFields", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "controller", "->", "filterFields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "field", "[", "'actions'", "]", ")", "&&", "is_array", "(", "$", "field", "[", "'actions'", "]", ")", "&&", "in_array", "(", "$", "this", "->", "action", ",", "$", "field", "[", "'actions'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if filtering for the current controller action is enabled. @return boolean
[ "Check", "if", "filtering", "for", "the", "current", "controller", "action", "is", "enabled", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L524-L540
240,766
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isPaginationEnabled
protected function _isPaginationEnabled() { if (!isset($this->controller->limits) || !isset($this->controller->limits[$this->action]) || !isset($this->controller->limits[$this->action]['default']) || !isset($this->controller->limits[$this->action]['limits']) ) { return false; } return true; }
php
protected function _isPaginationEnabled() { if (!isset($this->controller->limits) || !isset($this->controller->limits[$this->action]) || !isset($this->controller->limits[$this->action]['default']) || !isset($this->controller->limits[$this->action]['limits']) ) { return false; } return true; }
[ "protected", "function", "_isPaginationEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", ")", "||", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "action", "]", ")", "||", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "action", "]", "[", "'default'", "]", ")", "||", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "action", "]", "[", "'limits'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if pagination is enabled for the current controller action. @return boolean
[ "Check", "if", "pagination", "is", "enabled", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L547-L558
240,767
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getSortFields
protected function _getSortFields() { $sortFields = []; foreach ($this->controller->sortFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $sortFields[$field] = $options; } } return $sortFields; }
php
protected function _getSortFields() { $sortFields = []; foreach ($this->controller->sortFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $sortFields[$field] = $options; } } return $sortFields; }
[ "protected", "function", "_getSortFields", "(", ")", "{", "$", "sortFields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controller", "->", "sortFields", "as", "$", "field", "=>", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'actions'", "]", ")", "&&", "is_array", "(", "$", "options", "[", "'actions'", "]", ")", "&&", "in_array", "(", "$", "this", "->", "action", ",", "$", "options", "[", "'actions'", "]", ")", ")", "{", "$", "sortFields", "[", "$", "field", "]", "=", "$", "options", ";", "}", "}", "return", "$", "sortFields", ";", "}" ]
Get all available sort fields for the current controller action. @return array
[ "Get", "all", "available", "sort", "fields", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L565-L579
240,768
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getFilterFields
protected function _getFilterFields() { $filterFields = []; foreach ($this->controller->filterFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $filterFields[$field] = $options; } } return $filterFields; }
php
protected function _getFilterFields() { $filterFields = []; foreach ($this->controller->filterFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $filterFields[$field] = $options; } } return $filterFields; }
[ "protected", "function", "_getFilterFields", "(", ")", "{", "$", "filterFields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controller", "->", "filterFields", "as", "$", "field", "=>", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'actions'", "]", ")", "&&", "is_array", "(", "$", "options", "[", "'actions'", "]", ")", "&&", "in_array", "(", "$", "this", "->", "action", ",", "$", "options", "[", "'actions'", "]", ")", ")", "{", "$", "filterFields", "[", "$", "field", "]", "=", "$", "options", ";", "}", "}", "return", "$", "filterFields", ";", "}" ]
Get all available filter fields for the current controller action. @return array
[ "Get", "all", "available", "filter", "fields", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L586-L600
240,769
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._createSortFieldOption
protected function _createSortFieldOption($field, $dir, $options) { $sortField = $this->sortFields[$field]; if (isset($sortField['custom'])) { if (!is_array($sortField['custom'])) { $sortField['custom'] = [$sortField['custom']]; } foreach ($sortField['custom'] as $sortEntry) { $options['order'][] = preg_replace('/:dir/', $dir, $sortEntry); } } else { $options['order'][] = $sortField['modelField'] . ' ' . $dir; } return $options; }
php
protected function _createSortFieldOption($field, $dir, $options) { $sortField = $this->sortFields[$field]; if (isset($sortField['custom'])) { if (!is_array($sortField['custom'])) { $sortField['custom'] = [$sortField['custom']]; } foreach ($sortField['custom'] as $sortEntry) { $options['order'][] = preg_replace('/:dir/', $dir, $sortEntry); } } else { $options['order'][] = $sortField['modelField'] . ' ' . $dir; } return $options; }
[ "protected", "function", "_createSortFieldOption", "(", "$", "field", ",", "$", "dir", ",", "$", "options", ")", "{", "$", "sortField", "=", "$", "this", "->", "sortFields", "[", "$", "field", "]", ";", "if", "(", "isset", "(", "$", "sortField", "[", "'custom'", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "sortField", "[", "'custom'", "]", ")", ")", "{", "$", "sortField", "[", "'custom'", "]", "=", "[", "$", "sortField", "[", "'custom'", "]", "]", ";", "}", "foreach", "(", "$", "sortField", "[", "'custom'", "]", "as", "$", "sortEntry", ")", "{", "$", "options", "[", "'order'", "]", "[", "]", "=", "preg_replace", "(", "'/:dir/'", ",", "$", "dir", ",", "$", "sortEntry", ")", ";", "}", "}", "else", "{", "$", "options", "[", "'order'", "]", "[", "]", "=", "$", "sortField", "[", "'modelField'", "]", ".", "' '", ".", "$", "dir", ";", "}", "return", "$", "options", ";", "}" ]
Create the 'order' find condition part for a sorted field. @param string $field The field name to sort @param string $dir The sort direction (asc, desc) @param array $options The current find options where the sorting should be added. @return mixed
[ "Create", "the", "order", "find", "condition", "part", "for", "a", "sorted", "field", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L610-L625
240,770
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._extractPassParams
protected function _extractPassParams() { if (!empty($this->controller->filterPassParams[$this->action])) { foreach ($this->controller->filterPassParams[$this->action] as $key) { if (!empty($this->request->getParam($key))) { $this->_passParams[$key] = $this->request->getParam($key); } } } }
php
protected function _extractPassParams() { if (!empty($this->controller->filterPassParams[$this->action])) { foreach ($this->controller->filterPassParams[$this->action] as $key) { if (!empty($this->request->getParam($key))) { $this->_passParams[$key] = $this->request->getParam($key); } } } }
[ "protected", "function", "_extractPassParams", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "controller", "->", "filterPassParams", "[", "$", "this", "->", "action", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "controller", "->", "filterPassParams", "[", "$", "this", "->", "action", "]", "as", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "getParam", "(", "$", "key", ")", ")", ")", "{", "$", "this", "->", "_passParams", "[", "$", "key", "]", "=", "$", "this", "->", "request", "->", "getParam", "(", "$", "key", ")", ";", "}", "}", "}", "}" ]
Puts the values in the passParams array
[ "Puts", "the", "values", "in", "the", "passParams", "array" ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L703-L712
240,771
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getFilterData
protected function _getFilterData() { $rawFilterData = $this->request->getData(); $filterData = []; foreach ($this->filterFields as $filterField => $options) { if (isset($rawFilterData[$filterField]) && $rawFilterData[$filterField] !== '') { $filterData[$filterField] = $rawFilterData[$filterField]; } } return $filterData; }
php
protected function _getFilterData() { $rawFilterData = $this->request->getData(); $filterData = []; foreach ($this->filterFields as $filterField => $options) { if (isset($rawFilterData[$filterField]) && $rawFilterData[$filterField] !== '') { $filterData[$filterField] = $rawFilterData[$filterField]; } } return $filterData; }
[ "protected", "function", "_getFilterData", "(", ")", "{", "$", "rawFilterData", "=", "$", "this", "->", "request", "->", "getData", "(", ")", ";", "$", "filterData", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "filterFields", "as", "$", "filterField", "=>", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "rawFilterData", "[", "$", "filterField", "]", ")", "&&", "$", "rawFilterData", "[", "$", "filterField", "]", "!==", "''", ")", "{", "$", "filterData", "[", "$", "filterField", "]", "=", "$", "rawFilterData", "[", "$", "filterField", "]", ";", "}", "}", "return", "$", "filterData", ";", "}" ]
Get the filter data. @return array
[ "Get", "the", "filter", "data", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L719-L730
240,772
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupSort
protected function _setupSort() { if (!($this->_sortEnabled = $this->_isSortEnabled())) { return; } $this->sortFields = $this->_getSortFields(); foreach ($this->sortFields as $field => $options) { if (!isset($options['default'])) { continue; } $dir = strtolower($options['default']); if (in_array($dir, ['asc', 'desc'])) { $this->defaultSort = [ 'field' => $field, 'dir' => $dir ]; } } }
php
protected function _setupSort() { if (!($this->_sortEnabled = $this->_isSortEnabled())) { return; } $this->sortFields = $this->_getSortFields(); foreach ($this->sortFields as $field => $options) { if (!isset($options['default'])) { continue; } $dir = strtolower($options['default']); if (in_array($dir, ['asc', 'desc'])) { $this->defaultSort = [ 'field' => $field, 'dir' => $dir ]; } } }
[ "protected", "function", "_setupSort", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_sortEnabled", "=", "$", "this", "->", "_isSortEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "sortFields", "=", "$", "this", "->", "_getSortFields", "(", ")", ";", "foreach", "(", "$", "this", "->", "sortFields", "as", "$", "field", "=>", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'default'", "]", ")", ")", "{", "continue", ";", "}", "$", "dir", "=", "strtolower", "(", "$", "options", "[", "'default'", "]", ")", ";", "if", "(", "in_array", "(", "$", "dir", ",", "[", "'asc'", ",", "'desc'", "]", ")", ")", "{", "$", "this", "->", "defaultSort", "=", "[", "'field'", "=>", "$", "field", ",", "'dir'", "=>", "$", "dir", "]", ";", "}", "}", "}" ]
Setup default sort options. @return void
[ "Setup", "default", "sort", "options", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L737-L757
240,773
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupFilters
protected function _setupFilters() { if (!($this->_filterEnabled = $this->_isFilterEnabled())) { return; } $this->filterFields = $this->_getFilterFields(); $sluggedFilter = $this->request->getParam('sluggedFilter', ''); if ($sluggedFilter === '') { return; } $filterData = $this->Filters->find('filterDataBySlug', ['request' => $this->request]); if (empty($filterData)) { return; } $data = array_merge($this->request->getData(), $filterData); foreach ($data as $key => $value) { $this->request = $this->request->withData($key, $value); } $this->slug = $sluggedFilter; }
php
protected function _setupFilters() { if (!($this->_filterEnabled = $this->_isFilterEnabled())) { return; } $this->filterFields = $this->_getFilterFields(); $sluggedFilter = $this->request->getParam('sluggedFilter', ''); if ($sluggedFilter === '') { return; } $filterData = $this->Filters->find('filterDataBySlug', ['request' => $this->request]); if (empty($filterData)) { return; } $data = array_merge($this->request->getData(), $filterData); foreach ($data as $key => $value) { $this->request = $this->request->withData($key, $value); } $this->slug = $sluggedFilter; }
[ "protected", "function", "_setupFilters", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_filterEnabled", "=", "$", "this", "->", "_isFilterEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "filterFields", "=", "$", "this", "->", "_getFilterFields", "(", ")", ";", "$", "sluggedFilter", "=", "$", "this", "->", "request", "->", "getParam", "(", "'sluggedFilter'", ",", "''", ")", ";", "if", "(", "$", "sluggedFilter", "===", "''", ")", "{", "return", ";", "}", "$", "filterData", "=", "$", "this", "->", "Filters", "->", "find", "(", "'filterDataBySlug'", ",", "[", "'request'", "=>", "$", "this", "->", "request", "]", ")", ";", "if", "(", "empty", "(", "$", "filterData", ")", ")", "{", "return", ";", "}", "$", "data", "=", "array_merge", "(", "$", "this", "->", "request", "->", "getData", "(", ")", ",", "$", "filterData", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "request", "=", "$", "this", "->", "request", "->", "withData", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "this", "->", "slug", "=", "$", "sluggedFilter", ";", "}" ]
Setup the filter field options. If the current request is provided with the sluggedFilter param, then the corresponding filter data will be fetched and set on the request data. @return void
[ "Setup", "the", "filter", "field", "options", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L767-L791
240,774
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupPagination
protected function _setupPagination() { if (!($this->_paginationEnabled = $this->_isPaginationEnabled())) { return; } $this->defaultLimit = $this->controller->limits[$this->action]['default']; $this->limits = $this->controller->limits[$this->action]['limits']; }
php
protected function _setupPagination() { if (!($this->_paginationEnabled = $this->_isPaginationEnabled())) { return; } $this->defaultLimit = $this->controller->limits[$this->action]['default']; $this->limits = $this->controller->limits[$this->action]['limits']; }
[ "protected", "function", "_setupPagination", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_paginationEnabled", "=", "$", "this", "->", "_isPaginationEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "defaultLimit", "=", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "action", "]", "[", "'default'", "]", ";", "$", "this", "->", "limits", "=", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "action", "]", "[", "'limits'", "]", ";", "}" ]
Setup the default pagination params. @return void
[ "Setup", "the", "default", "pagination", "params", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L798-L806
240,775
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isFilterRequest
protected function _isFilterRequest() { return ( $this->controller !== null && $this->request !== null && $this->action !== null && $this->_filterEnabled ); }
php
protected function _isFilterRequest() { return ( $this->controller !== null && $this->request !== null && $this->action !== null && $this->_filterEnabled ); }
[ "protected", "function", "_isFilterRequest", "(", ")", "{", "return", "(", "$", "this", "->", "controller", "!==", "null", "&&", "$", "this", "->", "request", "!==", "null", "&&", "$", "this", "->", "action", "!==", "null", "&&", "$", "this", "->", "_filterEnabled", ")", ";", "}" ]
Check if the current request is a filter request. @return bool
[ "Check", "if", "the", "current", "request", "is", "a", "filter", "request", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L813-L821
240,776
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._createFilterSlug
protected function _createFilterSlug(array $filterData) { /** @var Filter $existingFilter */ $existingFilter = $this->Filters->find('slugForFilterData', [ 'request' => $this->request, 'filterData' => $filterData ])->first(); if ($existingFilter) { return $existingFilter->slug; } return $this->Filters->createFilterForFilterData($this->request, $filterData); }
php
protected function _createFilterSlug(array $filterData) { /** @var Filter $existingFilter */ $existingFilter = $this->Filters->find('slugForFilterData', [ 'request' => $this->request, 'filterData' => $filterData ])->first(); if ($existingFilter) { return $existingFilter->slug; } return $this->Filters->createFilterForFilterData($this->request, $filterData); }
[ "protected", "function", "_createFilterSlug", "(", "array", "$", "filterData", ")", "{", "/** @var Filter $existingFilter */", "$", "existingFilter", "=", "$", "this", "->", "Filters", "->", "find", "(", "'slugForFilterData'", ",", "[", "'request'", "=>", "$", "this", "->", "request", ",", "'filterData'", "=>", "$", "filterData", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "existingFilter", ")", "{", "return", "$", "existingFilter", "->", "slug", ";", "}", "return", "$", "this", "->", "Filters", "->", "createFilterForFilterData", "(", "$", "this", "->", "request", ",", "$", "filterData", ")", ";", "}" ]
Create a filter slug for the given filter data. @param array $filterData @return string The slug.
[ "Create", "a", "filter", "slug", "for", "the", "given", "filter", "data", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L829-L842
240,777
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applyFilterData
protected function _applyFilterData($url) { $filterData = $this->_getFilterData(); if (empty($filterData)) { return $url; } return $url + [ 'sluggedFilter' => $this->_createFilterSlug($filterData), '?' => $this->request->getQuery() ]; }
php
protected function _applyFilterData($url) { $filterData = $this->_getFilterData(); if (empty($filterData)) { return $url; } return $url + [ 'sluggedFilter' => $this->_createFilterSlug($filterData), '?' => $this->request->getQuery() ]; }
[ "protected", "function", "_applyFilterData", "(", "$", "url", ")", "{", "$", "filterData", "=", "$", "this", "->", "_getFilterData", "(", ")", ";", "if", "(", "empty", "(", "$", "filterData", ")", ")", "{", "return", "$", "url", ";", "}", "return", "$", "url", "+", "[", "'sluggedFilter'", "=>", "$", "this", "->", "_createFilterSlug", "(", "$", "filterData", ")", ",", "'?'", "=>", "$", "this", "->", "request", "->", "getQuery", "(", ")", "]", ";", "}" ]
Apply filter data to the given url. @param $url @return array modified url array
[ "Apply", "filter", "data", "to", "the", "given", "url", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L850-L861
240,778
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applyPassedParams
protected function _applyPassedParams($url) { if (empty($this->_passParams)) { return $url; } return array_merge($url, $this->_passParams); }
php
protected function _applyPassedParams($url) { if (empty($this->_passParams)) { return $url; } return array_merge($url, $this->_passParams); }
[ "protected", "function", "_applyPassedParams", "(", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_passParams", ")", ")", "{", "return", "$", "url", ";", "}", "return", "array_merge", "(", "$", "url", ",", "$", "this", "->", "_passParams", ")", ";", "}" ]
Apply configured pass params to the url array. @param array $url @return array modified url array
[ "Apply", "configured", "pass", "params", "to", "the", "url", "array", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L869-L876
240,779
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applySort
protected function _applySort($url) { if (!$this->_sortEnabled) { return $url; } if (!empty($this->request->getQuery('s'))) { $url['?']['s'] = $this->request->getQuery('s'); } if (!empty($this->request->getQuery('d'))) { $url['?']['d'] = $this->request->getQuery('d'); } return $url; }
php
protected function _applySort($url) { if (!$this->_sortEnabled) { return $url; } if (!empty($this->request->getQuery('s'))) { $url['?']['s'] = $this->request->getQuery('s'); } if (!empty($this->request->getQuery('d'))) { $url['?']['d'] = $this->request->getQuery('d'); } return $url; }
[ "protected", "function", "_applySort", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "_sortEnabled", ")", "{", "return", "$", "url", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'s'", ")", ")", ")", "{", "$", "url", "[", "'?'", "]", "[", "'s'", "]", "=", "$", "this", "->", "request", "->", "getQuery", "(", "'s'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'d'", ")", ")", ")", "{", "$", "url", "[", "'?'", "]", "[", "'d'", "]", "=", "$", "this", "->", "request", "->", "getQuery", "(", "'d'", ")", ";", "}", "return", "$", "url", ";", "}" ]
Pass sort options through to the filtered url. @param array $url @return array modified url array
[ "Pass", "sort", "options", "through", "to", "the", "filtered", "url", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L884-L899
240,780
canis-io/yii2-canis-lib
lib/web/Response.php
Response.getIsInstructable
public function getIsInstructable() { $isAjax = (isset(Yii::$app->request->isAjax) && Yii::$app->request->isAjax); if (isset($_GET['_instruct'])) { if (!empty($_GET['_instruct'])) { $this->forceInstructions = true; $this->disableInstructions = false; } else { $this->forceInstructions = false; $this->disableInstructions = true; } } return (is_array($this->data) || $this->forceInstructions || $isAjax) && !$this->disableInstructions; }
php
public function getIsInstructable() { $isAjax = (isset(Yii::$app->request->isAjax) && Yii::$app->request->isAjax); if (isset($_GET['_instruct'])) { if (!empty($_GET['_instruct'])) { $this->forceInstructions = true; $this->disableInstructions = false; } else { $this->forceInstructions = false; $this->disableInstructions = true; } } return (is_array($this->data) || $this->forceInstructions || $isAjax) && !$this->disableInstructions; }
[ "public", "function", "getIsInstructable", "(", ")", "{", "$", "isAjax", "=", "(", "isset", "(", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", "&&", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'_instruct'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "_GET", "[", "'_instruct'", "]", ")", ")", "{", "$", "this", "->", "forceInstructions", "=", "true", ";", "$", "this", "->", "disableInstructions", "=", "false", ";", "}", "else", "{", "$", "this", "->", "forceInstructions", "=", "false", ";", "$", "this", "->", "disableInstructions", "=", "true", ";", "}", "}", "return", "(", "is_array", "(", "$", "this", "->", "data", ")", "||", "$", "this", "->", "forceInstructions", "||", "$", "isAjax", ")", "&&", "!", "$", "this", "->", "disableInstructions", ";", "}" ]
Get is instructable. @return [[@doctodo return_type:getIsInstructable]] [[@doctodo return_description:getIsInstructable]]
[ "Get", "is", "instructable", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/Response.php#L139-L153
240,781
mtils/collection
src/Collection/Support/FindsCallableByInheritance.php
FindsCallableByInheritance.classInheritance
public static function classInheritance($object){ $class = new ReflectionClass($object); $classNames = [$class->getName()]; while($class = $class->getParentClass()){ $classNames[] = $class->getName(); } return $classNames; }
php
public static function classInheritance($object){ $class = new ReflectionClass($object); $classNames = [$class->getName()]; while($class = $class->getParentClass()){ $classNames[] = $class->getName(); } return $classNames; }
[ "public", "static", "function", "classInheritance", "(", "$", "object", ")", "{", "$", "class", "=", "new", "ReflectionClass", "(", "$", "object", ")", ";", "$", "classNames", "=", "[", "$", "class", "->", "getName", "(", ")", "]", ";", "while", "(", "$", "class", "=", "$", "class", "->", "getParentClass", "(", ")", ")", "{", "$", "classNames", "[", "]", "=", "$", "class", "->", "getName", "(", ")", ";", "}", "return", "$", "classNames", ";", "}" ]
Returns an array of the classname and all parent class names of the passed class or object @param object|string $object @return array
[ "Returns", "an", "array", "of", "the", "classname", "and", "all", "parent", "class", "names", "of", "the", "passed", "class", "or", "object" ]
186f8a6cc68fef1babc486438aa6d6c643186cc8
https://github.com/mtils/collection/blob/186f8a6cc68fef1babc486438aa6d6c643186cc8/src/Collection/Support/FindsCallableByInheritance.php#L154-L165
240,782
arvici/framework
src/Arvici/Heart/App/AppManager.php
AppManager.initApps
public function initApps() { if (count($this->apps) > 0) { throw new AlreadyInitiatedException('The apps are already loaded!'); } foreach ($this->appList as $className) { $instance = new $className($this); $this->apps->append($instance); } // Let the apps configure itself. foreach ($this->apps as $app) { $app->load(); } // Let the apps register it parts. foreach ($this->apps as $app) { $app->registerRoutes(Router::getInstance()); } }
php
public function initApps() { if (count($this->apps) > 0) { throw new AlreadyInitiatedException('The apps are already loaded!'); } foreach ($this->appList as $className) { $instance = new $className($this); $this->apps->append($instance); } // Let the apps configure itself. foreach ($this->apps as $app) { $app->load(); } // Let the apps register it parts. foreach ($this->apps as $app) { $app->registerRoutes(Router::getInstance()); } }
[ "public", "function", "initApps", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "apps", ")", ">", "0", ")", "{", "throw", "new", "AlreadyInitiatedException", "(", "'The apps are already loaded!'", ")", ";", "}", "foreach", "(", "$", "this", "->", "appList", "as", "$", "className", ")", "{", "$", "instance", "=", "new", "$", "className", "(", "$", "this", ")", ";", "$", "this", "->", "apps", "->", "append", "(", "$", "instance", ")", ";", "}", "// Let the apps configure itself.", "foreach", "(", "$", "this", "->", "apps", "as", "$", "app", ")", "{", "$", "app", "->", "load", "(", ")", ";", "}", "// Let the apps register it parts.", "foreach", "(", "$", "this", "->", "apps", "as", "$", "app", ")", "{", "$", "app", "->", "registerRoutes", "(", "Router", "::", "getInstance", "(", ")", ")", ";", "}", "}" ]
Load and initiate all apps. @codeCoverageIgnore
[ "Load", "and", "initiate", "all", "apps", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/App/AppManager.php#L68-L88
240,783
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.findSection
public function findSection($section) { if (!isset($this->sectionMap[$section])) { throw new UnknownSection($section); } return $this->sectionMap[$section]; }
php
public function findSection($section) { if (!isset($this->sectionMap[$section])) { throw new UnknownSection($section); } return $this->sectionMap[$section]; }
[ "public", "function", "findSection", "(", "$", "section", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "sectionMap", "[", "$", "section", "]", ")", ")", "{", "throw", "new", "UnknownSection", "(", "$", "section", ")", ";", "}", "return", "$", "this", "->", "sectionMap", "[", "$", "section", "]", ";", "}" ]
Finds a section class by name @param string $section @return string @throws UnknownException If section is not found in the section map
[ "Finds", "a", "section", "class", "by", "name" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L63-L70
240,784
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.parseArray
public function parseArray(array $ini) { $sections = []; foreach ($ini as $name => $section) { $section = $this->parseSection($name, $section); $sections[] = $section; } return $sections; }
php
public function parseArray(array $ini) { $sections = []; foreach ($ini as $name => $section) { $section = $this->parseSection($name, $section); $sections[] = $section; } return $sections; }
[ "public", "function", "parseArray", "(", "array", "$", "ini", ")", "{", "$", "sections", "=", "[", "]", ";", "foreach", "(", "$", "ini", "as", "$", "name", "=>", "$", "section", ")", "{", "$", "section", "=", "$", "this", "->", "parseSection", "(", "$", "name", ",", "$", "section", ")", ";", "$", "sections", "[", "]", "=", "$", "section", ";", "}", "return", "$", "sections", ";", "}" ]
Parses an INI array Sections must be included @param array $ini @return Section[]
[ "Parses", "an", "INI", "array" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L81-L91
240,785
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.parseSection
public function parseSection($name, array $section) { $name = explode(':', $name, 2); $class = $this->findSection($name[0]); if (isset($name[1])) { return new $class($name[1], $section); } return new $class($section); }
php
public function parseSection($name, array $section) { $name = explode(':', $name, 2); $class = $this->findSection($name[0]); if (isset($name[1])) { return new $class($name[1], $section); } return new $class($section); }
[ "public", "function", "parseSection", "(", "$", "name", ",", "array", "$", "section", ")", "{", "$", "name", "=", "explode", "(", "':'", ",", "$", "name", ",", "2", ")", ";", "$", "class", "=", "$", "this", "->", "findSection", "(", "$", "name", "[", "0", "]", ")", ";", "if", "(", "isset", "(", "$", "name", "[", "1", "]", ")", ")", "{", "return", "new", "$", "class", "(", "$", "name", "[", "1", "]", ",", "$", "section", ")", ";", "}", "return", "new", "$", "class", "(", "$", "section", ")", ";", "}" ]
Parses an individual section @param string $name @param array $section Array representation of section @return Section
[ "Parses", "an", "individual", "section" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L101-L112
240,786
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/config.php
Config.save
public static function save($file, $config) { if ( ! is_array($config)) { if ( ! isset(static::$items[$config])) { return false; } $config = static::$items[$config]; } $info = pathinfo($file); $type = 'php'; if (isset($info['extension'])) { $type = $info['extension']; // Keep extension when it's an absolute path, because the finder won't add it if ($file[0] !== '/' and $file[1] !== ':') { $file = substr($file, 0, -(strlen($type) + 1)); } } $class = '\\Config_'.ucfirst($type); if ( ! class_exists($class)) { throw new \FuelException(sprintf('Invalid config type "%s".', $type)); } $driver = new $class($file); return $driver->save($config); }
php
public static function save($file, $config) { if ( ! is_array($config)) { if ( ! isset(static::$items[$config])) { return false; } $config = static::$items[$config]; } $info = pathinfo($file); $type = 'php'; if (isset($info['extension'])) { $type = $info['extension']; // Keep extension when it's an absolute path, because the finder won't add it if ($file[0] !== '/' and $file[1] !== ':') { $file = substr($file, 0, -(strlen($type) + 1)); } } $class = '\\Config_'.ucfirst($type); if ( ! class_exists($class)) { throw new \FuelException(sprintf('Invalid config type "%s".', $type)); } $driver = new $class($file); return $driver->save($config); }
[ "public", "static", "function", "save", "(", "$", "file", ",", "$", "config", ")", "{", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "items", "[", "$", "config", "]", ")", ")", "{", "return", "false", ";", "}", "$", "config", "=", "static", "::", "$", "items", "[", "$", "config", "]", ";", "}", "$", "info", "=", "pathinfo", "(", "$", "file", ")", ";", "$", "type", "=", "'php'", ";", "if", "(", "isset", "(", "$", "info", "[", "'extension'", "]", ")", ")", "{", "$", "type", "=", "$", "info", "[", "'extension'", "]", ";", "// Keep extension when it's an absolute path, because the finder won't add it", "if", "(", "$", "file", "[", "0", "]", "!==", "'/'", "and", "$", "file", "[", "1", "]", "!==", "':'", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "0", ",", "-", "(", "strlen", "(", "$", "type", ")", "+", "1", ")", ")", ";", "}", "}", "$", "class", "=", "'\\\\Config_'", ".", "ucfirst", "(", "$", "type", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "FuelException", "(", "sprintf", "(", "'Invalid config type \"%s\".'", ",", "$", "type", ")", ")", ";", "}", "$", "driver", "=", "new", "$", "class", "(", "$", "file", ")", ";", "return", "$", "driver", "->", "save", "(", "$", "config", ")", ";", "}" ]
Save a config array to disc. @param string $file desired file name @param string|array $config master config array key or config array @return bool false when config is empty or invalid else \File::update result
[ "Save", "a", "config", "array", "to", "disc", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/config.php#L140-L174
240,787
lucifurious/kisma
src/Kisma/Core/Utility/ErrorHandler.php
ErrorHandler.renderError
public static function renderError() { try { $_errorTemplate = \Kisma::get( 'app.error_template', '_error.twig' ); Render::twigView( $_errorTemplate, array( 'base_path' => \Kisma::get( 'app.base_path' ), 'app_root' => \Kisma::get( 'app.root' ), 'page_title' => 'Error', 'error' => static::$_error, 'page_header' => 'Something has gone awry...', 'page_header_small' => 'Not cool. :(', 'navbar' => array( 'brand' => 'Kisma v' . \Kisma::KismaVersion, 'items' => array( array( 'title' => 'Kisma on GitHub!', 'href' => 'http://github.com/kisma/kisma/', 'target' => '_blank', 'active' => 'active', ), ), ), ) ); return true; } catch ( \Exception $_ex ) { Log::error( 'Exception during rendering of error: ' . print_r( static::$_error, true ) ); } return false; }
php
public static function renderError() { try { $_errorTemplate = \Kisma::get( 'app.error_template', '_error.twig' ); Render::twigView( $_errorTemplate, array( 'base_path' => \Kisma::get( 'app.base_path' ), 'app_root' => \Kisma::get( 'app.root' ), 'page_title' => 'Error', 'error' => static::$_error, 'page_header' => 'Something has gone awry...', 'page_header_small' => 'Not cool. :(', 'navbar' => array( 'brand' => 'Kisma v' . \Kisma::KismaVersion, 'items' => array( array( 'title' => 'Kisma on GitHub!', 'href' => 'http://github.com/kisma/kisma/', 'target' => '_blank', 'active' => 'active', ), ), ), ) ); return true; } catch ( \Exception $_ex ) { Log::error( 'Exception during rendering of error: ' . print_r( static::$_error, true ) ); } return false; }
[ "public", "static", "function", "renderError", "(", ")", "{", "try", "{", "$", "_errorTemplate", "=", "\\", "Kisma", "::", "get", "(", "'app.error_template'", ",", "'_error.twig'", ")", ";", "Render", "::", "twigView", "(", "$", "_errorTemplate", ",", "array", "(", "'base_path'", "=>", "\\", "Kisma", "::", "get", "(", "'app.base_path'", ")", ",", "'app_root'", "=>", "\\", "Kisma", "::", "get", "(", "'app.root'", ")", ",", "'page_title'", "=>", "'Error'", ",", "'error'", "=>", "static", "::", "$", "_error", ",", "'page_header'", "=>", "'Something has gone awry...'", ",", "'page_header_small'", "=>", "'Not cool. :('", ",", "'navbar'", "=>", "array", "(", "'brand'", "=>", "'Kisma v'", ".", "\\", "Kisma", "::", "KismaVersion", ",", "'items'", "=>", "array", "(", "array", "(", "'title'", "=>", "'Kisma on GitHub!'", ",", "'href'", "=>", "'http://github.com/kisma/kisma/'", ",", "'target'", "=>", "'_blank'", ",", "'active'", "=>", "'active'", ",", ")", ",", ")", ",", ")", ",", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "_ex", ")", "{", "Log", "::", "error", "(", "'Exception during rendering of error: '", ".", "print_r", "(", "static", "::", "$", "_error", ",", "true", ")", ")", ";", "}", "return", "false", ";", "}" ]
Renders an error @return bool
[ "Renders", "an", "error" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/ErrorHandler.php#L168-L205
240,788
lucifurious/kisma
src/Kisma/Core/Utility/ErrorHandler.php
ErrorHandler._cleanTrace
protected static function _cleanTrace( array &$trace, $skipLines = null, $basePath = null ) { $_trace = array(); $_basePath = $basePath ?: \Kisma::get( 'app.base_path' ); // Skip some lines if ( !empty( $skipLines ) && count( $trace ) > $skipLines ) { $trace = array_slice( $trace, $skipLines ); } foreach ( $trace as $_index => $_code ) { $_traceItem = array(); Scalar::sins( $trace[$_index], 'file', 'Unspecified' ); Scalar::sins( $trace[$_index], 'line', 0 ); Scalar::sins( $trace[$_index], 'function', 'Unspecified' ); $_traceItem['file_name'] = trim( str_replace( array( $_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://', ), array( null, ' ', null, null, null, null, ), $trace[$_index]['file'] ) ); $_args = null; if ( isset( $_code['args'] ) && !empty( $_code['args'] ) ) { foreach ( $_code['args'] as $_arg ) { if ( is_object( $_arg ) ) { $_args .= get_class( $_arg ) . ', '; } else if ( is_array( $_arg ) ) { $_args .= '[array], '; } else if ( is_bool( $_arg ) ) { if ( $_arg ) { $_args .= 'true, '; } else { $_args .= 'false, '; } } else if ( is_numeric( $_arg ) ) { $_args .= $_arg . ', '; } else if ( is_scalar( $_arg ) ) { $_args .= '"' . $_arg . '", '; } else { $_args .= '"' . gettype( $_arg ) . '", '; } } } $_traceItem['line'] = $trace[$_index]['line']; if ( isset( $_code['type'] ) ) { $_traceItem['function'] = ( isset( $_code['class'] ) ? $_code['class'] : null ) . $_code['type'] . $_code['function']; } else { $_traceItem['function'] = $_code['function']; } $_traceItem['function'] .= '(' . ( $_args ? ' ' . trim( $_args, ', ' ) . ' ' : null ) . ')'; $_traceItem['index'] = $_index; $_trace[] = $_traceItem; } return $_trace; }
php
protected static function _cleanTrace( array &$trace, $skipLines = null, $basePath = null ) { $_trace = array(); $_basePath = $basePath ?: \Kisma::get( 'app.base_path' ); // Skip some lines if ( !empty( $skipLines ) && count( $trace ) > $skipLines ) { $trace = array_slice( $trace, $skipLines ); } foreach ( $trace as $_index => $_code ) { $_traceItem = array(); Scalar::sins( $trace[$_index], 'file', 'Unspecified' ); Scalar::sins( $trace[$_index], 'line', 0 ); Scalar::sins( $trace[$_index], 'function', 'Unspecified' ); $_traceItem['file_name'] = trim( str_replace( array( $_basePath, "\t", "\r", "\n", PHP_EOL, 'phar://', ), array( null, ' ', null, null, null, null, ), $trace[$_index]['file'] ) ); $_args = null; if ( isset( $_code['args'] ) && !empty( $_code['args'] ) ) { foreach ( $_code['args'] as $_arg ) { if ( is_object( $_arg ) ) { $_args .= get_class( $_arg ) . ', '; } else if ( is_array( $_arg ) ) { $_args .= '[array], '; } else if ( is_bool( $_arg ) ) { if ( $_arg ) { $_args .= 'true, '; } else { $_args .= 'false, '; } } else if ( is_numeric( $_arg ) ) { $_args .= $_arg . ', '; } else if ( is_scalar( $_arg ) ) { $_args .= '"' . $_arg . '", '; } else { $_args .= '"' . gettype( $_arg ) . '", '; } } } $_traceItem['line'] = $trace[$_index]['line']; if ( isset( $_code['type'] ) ) { $_traceItem['function'] = ( isset( $_code['class'] ) ? $_code['class'] : null ) . $_code['type'] . $_code['function']; } else { $_traceItem['function'] = $_code['function']; } $_traceItem['function'] .= '(' . ( $_args ? ' ' . trim( $_args, ', ' ) . ' ' : null ) . ')'; $_traceItem['index'] = $_index; $_trace[] = $_traceItem; } return $_trace; }
[ "protected", "static", "function", "_cleanTrace", "(", "array", "&", "$", "trace", ",", "$", "skipLines", "=", "null", ",", "$", "basePath", "=", "null", ")", "{", "$", "_trace", "=", "array", "(", ")", ";", "$", "_basePath", "=", "$", "basePath", "?", ":", "\\", "Kisma", "::", "get", "(", "'app.base_path'", ")", ";", "//\tSkip some lines", "if", "(", "!", "empty", "(", "$", "skipLines", ")", "&&", "count", "(", "$", "trace", ")", ">", "$", "skipLines", ")", "{", "$", "trace", "=", "array_slice", "(", "$", "trace", ",", "$", "skipLines", ")", ";", "}", "foreach", "(", "$", "trace", "as", "$", "_index", "=>", "$", "_code", ")", "{", "$", "_traceItem", "=", "array", "(", ")", ";", "Scalar", "::", "sins", "(", "$", "trace", "[", "$", "_index", "]", ",", "'file'", ",", "'Unspecified'", ")", ";", "Scalar", "::", "sins", "(", "$", "trace", "[", "$", "_index", "]", ",", "'line'", ",", "0", ")", ";", "Scalar", "::", "sins", "(", "$", "trace", "[", "$", "_index", "]", ",", "'function'", ",", "'Unspecified'", ")", ";", "$", "_traceItem", "[", "'file_name'", "]", "=", "trim", "(", "str_replace", "(", "array", "(", "$", "_basePath", ",", "\"\\t\"", ",", "\"\\r\"", ",", "\"\\n\"", ",", "PHP_EOL", ",", "'phar://'", ",", ")", ",", "array", "(", "null", ",", "' '", ",", "null", ",", "null", ",", "null", ",", "null", ",", ")", ",", "$", "trace", "[", "$", "_index", "]", "[", "'file'", "]", ")", ")", ";", "$", "_args", "=", "null", ";", "if", "(", "isset", "(", "$", "_code", "[", "'args'", "]", ")", "&&", "!", "empty", "(", "$", "_code", "[", "'args'", "]", ")", ")", "{", "foreach", "(", "$", "_code", "[", "'args'", "]", "as", "$", "_arg", ")", "{", "if", "(", "is_object", "(", "$", "_arg", ")", ")", "{", "$", "_args", ".=", "get_class", "(", "$", "_arg", ")", ".", "', '", ";", "}", "else", "if", "(", "is_array", "(", "$", "_arg", ")", ")", "{", "$", "_args", ".=", "'[array], '", ";", "}", "else", "if", "(", "is_bool", "(", "$", "_arg", ")", ")", "{", "if", "(", "$", "_arg", ")", "{", "$", "_args", ".=", "'true, '", ";", "}", "else", "{", "$", "_args", ".=", "'false, '", ";", "}", "}", "else", "if", "(", "is_numeric", "(", "$", "_arg", ")", ")", "{", "$", "_args", ".=", "$", "_arg", ".", "', '", ";", "}", "else", "if", "(", "is_scalar", "(", "$", "_arg", ")", ")", "{", "$", "_args", ".=", "'\"'", ".", "$", "_arg", ".", "'\", '", ";", "}", "else", "{", "$", "_args", ".=", "'\"'", ".", "gettype", "(", "$", "_arg", ")", ".", "'\", '", ";", "}", "}", "}", "$", "_traceItem", "[", "'line'", "]", "=", "$", "trace", "[", "$", "_index", "]", "[", "'line'", "]", ";", "if", "(", "isset", "(", "$", "_code", "[", "'type'", "]", ")", ")", "{", "$", "_traceItem", "[", "'function'", "]", "=", "(", "isset", "(", "$", "_code", "[", "'class'", "]", ")", "?", "$", "_code", "[", "'class'", "]", ":", "null", ")", ".", "$", "_code", "[", "'type'", "]", ".", "$", "_code", "[", "'function'", "]", ";", "}", "else", "{", "$", "_traceItem", "[", "'function'", "]", "=", "$", "_code", "[", "'function'", "]", ";", "}", "$", "_traceItem", "[", "'function'", "]", ".=", "'('", ".", "(", "$", "_args", "?", "' '", ".", "trim", "(", "$", "_args", ",", "', '", ")", ".", "' '", ":", "null", ")", ".", "')'", ";", "$", "_traceItem", "[", "'index'", "]", "=", "$", "_index", ";", "$", "_trace", "[", "]", "=", "$", "_traceItem", ";", "}", "return", "$", "_trace", ";", "}" ]
Cleans up a trace array @param array $trace @param int $skipLines @param null $basePath @return null|string
[ "Cleans", "up", "a", "trace", "array" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/ErrorHandler.php#L216-L314
240,789
phossa2/libs
src/Phossa2/Db/Driver/StatementAbstract.php
StatementAbstract.checkPreparation
protected function checkPreparation() { // must be prepared if (null === $this->prepared) { throw new RuntimeException( Message::get(Message::DB_STMT_NOTPREPARED), Message::DB_STMT_NOTPREPARED ); } // close any previous resultset $this->closeResult(); }
php
protected function checkPreparation() { // must be prepared if (null === $this->prepared) { throw new RuntimeException( Message::get(Message::DB_STMT_NOTPREPARED), Message::DB_STMT_NOTPREPARED ); } // close any previous resultset $this->closeResult(); }
[ "protected", "function", "checkPreparation", "(", ")", "{", "// must be prepared", "if", "(", "null", "===", "$", "this", "->", "prepared", ")", "{", "throw", "new", "RuntimeException", "(", "Message", "::", "get", "(", "Message", "::", "DB_STMT_NOTPREPARED", ")", ",", "Message", "::", "DB_STMT_NOTPREPARED", ")", ";", "}", "// close any previous resultset", "$", "this", "->", "closeResult", "(", ")", ";", "}" ]
Throw exception if not prepared @throws RuntimeException @access protected
[ "Throw", "exception", "if", "not", "prepared" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Driver/StatementAbstract.php#L158-L170
240,790
kairosProject/ApiLoader
KairosProject/ApiLoader/Loader/AbstractApiLoader.php
AbstractApiLoader.loadItemOrThrowException
private function loadItemOrThrowException( QueryBuildingEventInterface $event, string $eventName, EventDispatcherInterface $dispatcher ) { $queryResult = $this->executeItemQuery($event, $eventName, $dispatcher); if (empty($queryResult) && $this->noItemException) { $this->logger->notice( 'Item not found from loader', [ 'loader class' => static::class, 'from event' => $eventName, 'dispatched event' => $this->itemEventName ] ); throw new \RuntimeException('Item not found from loader', 404); } return $queryResult; }
php
private function loadItemOrThrowException( QueryBuildingEventInterface $event, string $eventName, EventDispatcherInterface $dispatcher ) { $queryResult = $this->executeItemQuery($event, $eventName, $dispatcher); if (empty($queryResult) && $this->noItemException) { $this->logger->notice( 'Item not found from loader', [ 'loader class' => static::class, 'from event' => $eventName, 'dispatched event' => $this->itemEventName ] ); throw new \RuntimeException('Item not found from loader', 404); } return $queryResult; }
[ "private", "function", "loadItemOrThrowException", "(", "QueryBuildingEventInterface", "$", "event", ",", "string", "$", "eventName", ",", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "$", "queryResult", "=", "$", "this", "->", "executeItemQuery", "(", "$", "event", ",", "$", "eventName", ",", "$", "dispatcher", ")", ";", "if", "(", "empty", "(", "$", "queryResult", ")", "&&", "$", "this", "->", "noItemException", ")", "{", "$", "this", "->", "logger", "->", "notice", "(", "'Item not found from loader'", ",", "[", "'loader class'", "=>", "static", "::", "class", ",", "'from event'", "=>", "$", "eventName", ",", "'dispatched event'", "=>", "$", "this", "->", "itemEventName", "]", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "'Item not found from loader'", ",", "404", ")", ";", "}", "return", "$", "queryResult", ";", "}" ]
Load item or throw exception Load an item by executing the executeQueryItem. In case of item cannot be resolved, this method will throw a RuntimeException. The exception throwing can be disabled by the $noItemException constructor argument. @param ProcessEventInterface $event The original event. @param string $eventName The original event name. @param EventDispatcherInterface $dispatcher The event dispatcher. @throws \RuntimeException If the item cannot be loaded @return mixed @SuppressWarnings(PHPMD.UnusedPrivateMethod)
[ "Load", "item", "or", "throw", "exception" ]
d07c75ccc139d8b55b782e5e7719f802a61f044a
https://github.com/kairosProject/ApiLoader/blob/d07c75ccc139d8b55b782e5e7719f802a61f044a/KairosProject/ApiLoader/Loader/AbstractApiLoader.php#L307-L328
240,791
nirix/radium
src/Helpers/Pagination.php
Pagination.createUri
public function createUri($page) { $queryString = $this->query; $queryString[] = "page={$page}"; $queryString = implode('&', $queryString); return Request::pathInfo() . "?{$queryString}"; }
php
public function createUri($page) { $queryString = $this->query; $queryString[] = "page={$page}"; $queryString = implode('&', $queryString); return Request::pathInfo() . "?{$queryString}"; }
[ "public", "function", "createUri", "(", "$", "page", ")", "{", "$", "queryString", "=", "$", "this", "->", "query", ";", "$", "queryString", "[", "]", "=", "\"page={$page}\"", ";", "$", "queryString", "=", "implode", "(", "'&'", ",", "$", "queryString", ")", ";", "return", "Request", "::", "pathInfo", "(", ")", ".", "\"?{$queryString}\"", ";", "}" ]
Creates the URI for the specified page. @param integer $page @return string
[ "Creates", "the", "URI", "for", "the", "specified", "page", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Pagination.php#L174-L181
240,792
nirix/radium
src/Helpers/Pagination.php
Pagination.createPageLinks
protected function createPageLinks() { $pageLinks = array(); if ($this->totalPages > 10) { $startRange = $this->page - floor($this->range/2); $endRange = $this->page + floor($this->range/2); //Start range if ($startRange <= 0) { $startRange = 1; $endRange += abs($startRange) + 1; } // End range if ($endRange > $this->totalPages) { $startRange -= $endRange - $this->totalPages; $endRange = $this->totalPages; } // Range $range = range($startRange, $endRange); // Add first page $this->pageLinks[] = array( 'page' => 1, 'uri' => $this->createUri(1) ); foreach ($range as $page) { // Skip for first and last page if ($page == 1 or $page == $this->totalPages) { continue; } $this->pageLinks[] = array( 'page' => $page, 'uri' => $this->createUri($page) ); } // Add last page $this->pageLinks[] = array( 'page' => $this->totalPages, 'uri' => $this->createUri($this->totalPages) ); } else { for ($i = 1; $i <= $this->totalPages; $i++) { $this->pageLinks[] = array( 'page' => $i, 'uri' => $this->createUri($i) ); } } }
php
protected function createPageLinks() { $pageLinks = array(); if ($this->totalPages > 10) { $startRange = $this->page - floor($this->range/2); $endRange = $this->page + floor($this->range/2); //Start range if ($startRange <= 0) { $startRange = 1; $endRange += abs($startRange) + 1; } // End range if ($endRange > $this->totalPages) { $startRange -= $endRange - $this->totalPages; $endRange = $this->totalPages; } // Range $range = range($startRange, $endRange); // Add first page $this->pageLinks[] = array( 'page' => 1, 'uri' => $this->createUri(1) ); foreach ($range as $page) { // Skip for first and last page if ($page == 1 or $page == $this->totalPages) { continue; } $this->pageLinks[] = array( 'page' => $page, 'uri' => $this->createUri($page) ); } // Add last page $this->pageLinks[] = array( 'page' => $this->totalPages, 'uri' => $this->createUri($this->totalPages) ); } else { for ($i = 1; $i <= $this->totalPages; $i++) { $this->pageLinks[] = array( 'page' => $i, 'uri' => $this->createUri($i) ); } } }
[ "protected", "function", "createPageLinks", "(", ")", "{", "$", "pageLinks", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "totalPages", ">", "10", ")", "{", "$", "startRange", "=", "$", "this", "->", "page", "-", "floor", "(", "$", "this", "->", "range", "/", "2", ")", ";", "$", "endRange", "=", "$", "this", "->", "page", "+", "floor", "(", "$", "this", "->", "range", "/", "2", ")", ";", "//Start range", "if", "(", "$", "startRange", "<=", "0", ")", "{", "$", "startRange", "=", "1", ";", "$", "endRange", "+=", "abs", "(", "$", "startRange", ")", "+", "1", ";", "}", "// End range", "if", "(", "$", "endRange", ">", "$", "this", "->", "totalPages", ")", "{", "$", "startRange", "-=", "$", "endRange", "-", "$", "this", "->", "totalPages", ";", "$", "endRange", "=", "$", "this", "->", "totalPages", ";", "}", "// Range", "$", "range", "=", "range", "(", "$", "startRange", ",", "$", "endRange", ")", ";", "// Add first page", "$", "this", "->", "pageLinks", "[", "]", "=", "array", "(", "'page'", "=>", "1", ",", "'uri'", "=>", "$", "this", "->", "createUri", "(", "1", ")", ")", ";", "foreach", "(", "$", "range", "as", "$", "page", ")", "{", "// Skip for first and last page", "if", "(", "$", "page", "==", "1", "or", "$", "page", "==", "$", "this", "->", "totalPages", ")", "{", "continue", ";", "}", "$", "this", "->", "pageLinks", "[", "]", "=", "array", "(", "'page'", "=>", "$", "page", ",", "'uri'", "=>", "$", "this", "->", "createUri", "(", "$", "page", ")", ")", ";", "}", "// Add last page", "$", "this", "->", "pageLinks", "[", "]", "=", "array", "(", "'page'", "=>", "$", "this", "->", "totalPages", ",", "'uri'", "=>", "$", "this", "->", "createUri", "(", "$", "this", "->", "totalPages", ")", ")", ";", "}", "else", "{", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "this", "->", "totalPages", ";", "$", "i", "++", ")", "{", "$", "this", "->", "pageLinks", "[", "]", "=", "array", "(", "'page'", "=>", "$", "i", ",", "'uri'", "=>", "$", "this", "->", "createUri", "(", "$", "i", ")", ")", ";", "}", "}", "}" ]
Creates the page links.
[ "Creates", "the", "page", "links", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Helpers/Pagination.php#L186-L240
240,793
lucifurious/kisma
src/Kisma/Core/Utility/Xml.php
Xml.fromObject
public static function fromObject( $object, $rootName = null, $nodeName = null, $addHeader = true ) { if ( !is_object( $object ) ) { throw new \InvalidArgumentException( 'The value of "$object" is not an object.' ); } return static::fromArray( get_object_vars( $object ), $rootName, $nodeName, $addHeader ); }
php
public static function fromObject( $object, $rootName = null, $nodeName = null, $addHeader = true ) { if ( !is_object( $object ) ) { throw new \InvalidArgumentException( 'The value of "$object" is not an object.' ); } return static::fromArray( get_object_vars( $object ), $rootName, $nodeName, $addHeader ); }
[ "public", "static", "function", "fromObject", "(", "$", "object", ",", "$", "rootName", "=", "null", ",", "$", "nodeName", "=", "null", ",", "$", "addHeader", "=", "true", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The value of \"$object\" is not an object.'", ")", ";", "}", "return", "static", "::", "fromArray", "(", "get_object_vars", "(", "$", "object", ")", ",", "$", "rootName", ",", "$", "nodeName", ",", "$", "addHeader", ")", ";", "}" ]
Converts an object to an XML string @param mixed $object @param string $rootName @param string $nodeName @param bool $addHeader If true, the <?xml?> header is prepended to the result @throws \InvalidArgumentException @return null|string
[ "Converts", "an", "object", "to", "an", "XML", "string" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Xml.php#L42-L50
240,794
lucifurious/kisma
src/Kisma/Core/Utility/Xml.php
Xml.fromArray
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true ) { $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null; if ( null !== $rootName ) { $_xml .= Markup::openTag( $rootName ); } $_string = null; if ( $data instanceof \Traversable ) { foreach ( $data as $_key => $_value ) { if ( is_numeric( $_key ) ) { $_key = $nodeName ?: 'node'; } $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) ); } } else { $_string = htmlspecialchars( $data, ENT_QUOTES ); } // Add the converted XML $_xml .= $_string; if ( null !== $rootName ) { $_xml .= Markup::closeTag( $rootName ); } return $_xml; }
php
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true ) { $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null; if ( null !== $rootName ) { $_xml .= Markup::openTag( $rootName ); } $_string = null; if ( $data instanceof \Traversable ) { foreach ( $data as $_key => $_value ) { if ( is_numeric( $_key ) ) { $_key = $nodeName ?: 'node'; } $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) ); } } else { $_string = htmlspecialchars( $data, ENT_QUOTES ); } // Add the converted XML $_xml .= $_string; if ( null !== $rootName ) { $_xml .= Markup::closeTag( $rootName ); } return $_xml; }
[ "public", "static", "function", "fromArray", "(", "$", "data", ",", "$", "rootName", "=", "null", ",", "$", "nodeName", "=", "null", ",", "$", "addHeader", "=", "true", ")", "{", "$", "_xml", "=", "true", "===", "$", "addHeader", "?", "'<?xml version=\"1.0\" encoding=\"UTF-8\" ?>'", ":", "null", ";", "if", "(", "null", "!==", "$", "rootName", ")", "{", "$", "_xml", ".=", "Markup", "::", "openTag", "(", "$", "rootName", ")", ";", "}", "$", "_string", "=", "null", ";", "if", "(", "$", "data", "instanceof", "\\", "Traversable", ")", "{", "foreach", "(", "$", "data", "as", "$", "_key", "=>", "$", "_value", ")", "{", "if", "(", "is_numeric", "(", "$", "_key", ")", ")", "{", "$", "_key", "=", "$", "nodeName", "?", ":", "'node'", ";", "}", "$", "_string", ".=", "Markup", "::", "tag", "(", "$", "_key", ",", "array", "(", ")", ",", "static", "::", "fromArray", "(", "$", "_value", ",", "$", "nodeName", ")", ")", ";", "}", "}", "else", "{", "$", "_string", "=", "htmlspecialchars", "(", "$", "data", ",", "ENT_QUOTES", ")", ";", "}", "//\tAdd the converted XML", "$", "_xml", ".=", "$", "_string", ";", "if", "(", "null", "!==", "$", "rootName", ")", "{", "$", "_xml", ".=", "Markup", "::", "closeTag", "(", "$", "rootName", ")", ";", "}", "return", "$", "_xml", ";", "}" ]
Converts an array to an XML string @param mixed $data @param string $rootName @param string $nodeName @param bool $addHeader @return null|string
[ "Converts", "an", "array", "to", "an", "XML", "string" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Xml.php#L62-L99
240,795
PentagonalProject/SlimService
src/Session.php
Session.&
public static function &createWithName($name = null, AuraSession $session = null) : Session { $session = ! is_null($session) ? new static : new static($session); if (is_null($name)) { return $session; } $session->setSegmentName($name); return $session; }
php
public static function &createWithName($name = null, AuraSession $session = null) : Session { $session = ! is_null($session) ? new static : new static($session); if (is_null($name)) { return $session; } $session->setSegmentName($name); return $session; }
[ "public", "static", "function", "&", "createWithName", "(", "$", "name", "=", "null", ",", "AuraSession", "$", "session", "=", "null", ")", ":", "Session", "{", "$", "session", "=", "!", "is_null", "(", "$", "session", ")", "?", "new", "static", ":", "new", "static", "(", "$", "session", ")", ";", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "session", ";", "}", "$", "session", "->", "setSegmentName", "(", "$", "name", ")", ";", "return", "$", "session", ";", "}" ]
Create Instance Session @param string|null $name @param AuraSession|null $session @return Session
[ "Create", "Instance", "Session" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L112-L121
240,796
PentagonalProject/SlimService
src/Session.php
Session.startOrResume
public function startOrResume() : bool { if (!$this->session->isStarted()) { return $this->session->start(); } return $this->session->resume(); }
php
public function startOrResume() : bool { if (!$this->session->isStarted()) { return $this->session->start(); } return $this->session->resume(); }
[ "public", "function", "startOrResume", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "session", "->", "isStarted", "(", ")", ")", "{", "return", "$", "this", "->", "session", "->", "start", "(", ")", ";", "}", "return", "$", "this", "->", "session", "->", "resume", "(", ")", ";", "}" ]
Start Or Resume Session @return bool
[ "Start", "Or", "Resume", "Session" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L138-L145
240,797
PentagonalProject/SlimService
src/Session.php
Session.validateToken
public function validateToken($value) : bool { if (!is_string($value)) { return false; } return $this->getCSRFToken()->isValid($value); }
php
public function validateToken($value) : bool { if (!is_string($value)) { return false; } return $this->getCSRFToken()->isValid($value); }
[ "public", "function", "validateToken", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getCSRFToken", "(", ")", "->", "isValid", "(", "$", "value", ")", ";", "}" ]
validate token set @param string $value @return bool
[ "validate", "token", "set" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L194-L201
240,798
PentagonalProject/SlimService
src/Session.php
Session.exist
public function exist($keyName) : bool { # double check return $this->get($keyName, true) !== true && $this->get($keyName, false) !== false; }
php
public function exist($keyName) : bool { # double check return $this->get($keyName, true) !== true && $this->get($keyName, false) !== false; }
[ "public", "function", "exist", "(", "$", "keyName", ")", ":", "bool", "{", "# double check", "return", "$", "this", "->", "get", "(", "$", "keyName", ",", "true", ")", "!==", "true", "&&", "$", "this", "->", "get", "(", "$", "keyName", ",", "false", ")", "!==", "false", ";", "}" ]
Check whether Session is exists or not on segment @param string $keyName @return bool
[ "Check", "whether", "Session", "is", "exists", "or", "not", "on", "segment" ]
65df2ad530e28b6d72aad5394a0872760aad44cb
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Session.php#L227-L233
240,799
railsphp/framework
src/Rails/ActionDispatch/Http/Parameters.php
Parameters.required
public function required($keys, array $params = [], array $parents = []) { if (!$params) { $params = $this->all(); } if (is_array($keys)) { foreach ($keys as $key => $value) { if (is_int($key)) { $key = $value; } if (!isset($params[$key])) { if ($parents) { $str = ''; foreach ($parents as $parent) { $str .= '[ ' . $parent . ' => '; } $str .= $key . str_repeat(' ]', count($parents)); } else { $str = $Key; } throw new ParameterMissingException(sprintf( "Missing parameter %s", $str )); } if (is_array($value)) { $params = $params[$key]; $parents[] = $key; $this->required($value, $params, $parents); } } } else { if (!isset($params[$keys])) { throw new ParameterMissingException(sprintf( "Missing parameter %s", $keys )); } } }
php
public function required($keys, array $params = [], array $parents = []) { if (!$params) { $params = $this->all(); } if (is_array($keys)) { foreach ($keys as $key => $value) { if (is_int($key)) { $key = $value; } if (!isset($params[$key])) { if ($parents) { $str = ''; foreach ($parents as $parent) { $str .= '[ ' . $parent . ' => '; } $str .= $key . str_repeat(' ]', count($parents)); } else { $str = $Key; } throw new ParameterMissingException(sprintf( "Missing parameter %s", $str )); } if (is_array($value)) { $params = $params[$key]; $parents[] = $key; $this->required($value, $params, $parents); } } } else { if (!isset($params[$keys])) { throw new ParameterMissingException(sprintf( "Missing parameter %s", $keys )); } } }
[ "public", "function", "required", "(", "$", "keys", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "parents", "=", "[", "]", ")", "{", "if", "(", "!", "$", "params", ")", "{", "$", "params", "=", "$", "this", "->", "all", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "keys", ")", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "value", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "$", "key", "]", ")", ")", "{", "if", "(", "$", "parents", ")", "{", "$", "str", "=", "''", ";", "foreach", "(", "$", "parents", "as", "$", "parent", ")", "{", "$", "str", ".=", "'[ '", ".", "$", "parent", ".", "' => '", ";", "}", "$", "str", ".=", "$", "key", ".", "str_repeat", "(", "' ]'", ",", "count", "(", "$", "parents", ")", ")", ";", "}", "else", "{", "$", "str", "=", "$", "Key", ";", "}", "throw", "new", "ParameterMissingException", "(", "sprintf", "(", "\"Missing parameter %s\"", ",", "$", "str", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "params", "=", "$", "params", "[", "$", "key", "]", ";", "$", "parents", "[", "]", "=", "$", "key", ";", "$", "this", "->", "required", "(", "$", "value", ",", "$", "params", ",", "$", "parents", ")", ";", "}", "}", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "$", "keys", "]", ")", ")", "{", "throw", "new", "ParameterMissingException", "(", "sprintf", "(", "\"Missing parameter %s\"", ",", "$", "keys", ")", ")", ";", "}", "}", "}" ]
Checks for required parameters. If one of them is null, ParameterMissingException is thrown. ``` // Check for a value. $parameters->required('user'); // Check for an array and some keys $parameters->required(['user' => ['name', 'address']]); ``` @throws ParameterMissingException
[ "Checks", "for", "required", "parameters", ".", "If", "one", "of", "them", "is", "null", "ParameterMissingException", "is", "thrown", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionDispatch/Http/Parameters.php#L200-L242