id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
16,900
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.createPermissionModel
protected function createPermissionModel($token, array $options = []) { $permission = $this->newPermissionModel($token, $options); $permission->save(); return $permission; }
php
protected function createPermissionModel($token, array $options = []) { $permission = $this->newPermissionModel($token, $options); $permission->save(); return $permission; }
[ "protected", "function", "createPermissionModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "permission", "=", "$", "this", "->", "newPermissionModel", "(", "$", "token", ",", "$", "options", ")", ";", "$", "permission", "->", "save", "(", ")", ";", "return", "$", "permission", ";", "}" ]
Create and store in database new permission model instance @param string $token @param array $options @return \ViKon\Auth\Model\Permission
[ "Create", "and", "store", "in", "database", "new", "permission", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L197-L203
16,901
webforge-labs/psc-cms
lib/Psc/TPL/TPL.php
TPL.display
public static function display($tpl, $variablesDefinitions = NULL, $indent = NULL) { $html = self::get($tpl, $variablesDefinitions, $indent); print $html; }
php
public static function display($tpl, $variablesDefinitions = NULL, $indent = NULL) { $html = self::get($tpl, $variablesDefinitions, $indent); print $html; }
[ "public", "static", "function", "display", "(", "$", "tpl", ",", "$", "variablesDefinitions", "=", "NULL", ",", "$", "indent", "=", "NULL", ")", "{", "$", "html", "=", "self", "::", "get", "(", "$", "tpl", ",", "$", "variablesDefinitions", ",", "$", "indent", ")", ";", "print", "$", "html", ";", "}" ]
Inkludiert ein Template Gibt die Rückgabe von template_get aus. @param mixed $tpl @param array $variablesDefinitions @param int $indent wie weit der Quelltext eingerückt werden soll @see template_get
[ "Inkludiert", "ein", "Template" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/TPL.php#L53-L56
16,902
cohesion/cohesion-core
src/Config/Config.php
Config.load
public function load($data, $key = null) { if ($key) { if (isset($this->data[$key])) { $this->data[$key] = self::array_merge_recursive_unique($this->data[$key], $data); } else { $this->data[$key] = $data; } } else { if (is_array($data)) { $this->data = self::array_merge_recursive_unique($this->data, $data); } } }
php
public function load($data, $key = null) { if ($key) { if (isset($this->data[$key])) { $this->data[$key] = self::array_merge_recursive_unique($this->data[$key], $data); } else { $this->data[$key] = $data; } } else { if (is_array($data)) { $this->data = self::array_merge_recursive_unique($this->data, $data); } } }
[ "public", "function", "load", "(", "$", "data", ",", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "self", "::", "array_merge_recursive_unique", "(", "$", "this", "->", "data", "[", "$", "key", "]", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "data", ";", "}", "}", "else", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "self", "::", "array_merge_recursive_unique", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "}", "}", "}" ]
Load from array
[ "Load", "from", "array" ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Config/Config.php#L45-L57
16,903
cohesion/cohesion-core
src/Config/Config.php
Config.add
public function add($key, $value) { if (isset($this->data[$key])) { throw new \InvalidArgumentException("Key $key is already set"); } $this->data[$key] = $value; }
php
public function add($key, $value) { if (isset($this->data[$key])) { throw new \InvalidArgumentException("Key $key is already set"); } $this->data[$key] = $value; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Key $key is already set\"", ")", ";", "}", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Add a new key value pairing. @throws InvalidArgumentException if the key is already set
[ "Add", "a", "new", "key", "value", "pairing", "." ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Config/Config.php#L64-L69
16,904
cohesion/cohesion-core
src/Config/Config.php
Config.get
public function get($name = null) { $data = $this->data; if ($name) { $names = explode('.', $name); if ($names) { foreach ($names as $name) { if (is_array($data) && array_key_exists($name, $data)) { $data = $data[$name]; } else { return null; } } } } return $data; }
php
public function get($name = null) { $data = $this->data; if ($name) { $names = explode('.', $name); if ($names) { foreach ($names as $name) { if (is_array($data) && array_key_exists($name, $data)) { $data = $data[$name]; } else { return null; } } } } return $data; }
[ "public", "function", "get", "(", "$", "name", "=", "null", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "if", "(", "$", "name", ")", "{", "$", "names", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "if", "(", "$", "names", ")", "{", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", "&&", "array_key_exists", "(", "$", "name", ",", "$", "data", ")", ")", "{", "$", "data", "=", "$", "data", "[", "$", "name", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}", "}", "return", "$", "data", ";", "}" ]
Get the value for a key with the given name Can use dot notation for acessing nested keys Example: $config->get('database') will return an associative array of all the database values $config->get('database.host') will return the value for 'host' within the array stored at key 'database'
[ "Get", "the", "value", "for", "a", "key", "with", "the", "given", "name", "Can", "use", "dot", "notation", "for", "acessing", "nested", "keys" ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Config/Config.php#L100-L115
16,905
cohesion/cohesion-core
src/Config/Config.php
Config.getConfig
public function getConfig($name) { $data = $this->get($name); if ($data === null) { return null; } if (isset($this->data['global'])) { $data['global'] = $this->data['global']; } $config = new self(); $config->load($data); return $config; }
php
public function getConfig($name) { $data = $this->get($name); if ($data === null) { return null; } if (isset($this->data['global'])) { $data['global'] = $this->data['global']; } $config = new self(); $config->load($data); return $config; }
[ "public", "function", "getConfig", "(", "$", "name", ")", "{", "$", "data", "=", "$", "this", "->", "get", "(", "$", "name", ")", ";", "if", "(", "$", "data", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'global'", "]", ")", ")", "{", "$", "data", "[", "'global'", "]", "=", "$", "this", "->", "data", "[", "'global'", "]", ";", "}", "$", "config", "=", "new", "self", "(", ")", ";", "$", "config", "->", "load", "(", "$", "data", ")", ";", "return", "$", "config", ";", "}" ]
Get the value at the given key and return it as a config object
[ "Get", "the", "value", "at", "the", "given", "key", "and", "return", "it", "as", "a", "config", "object" ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Config/Config.php#L120-L131
16,906
cohesion/cohesion-core
src/Config/Config.php
Config.set
public function set($name, $value) { $data = array(); $dataPointer = &$data; $parents = explode('.', $name); $name = array_pop($parents); foreach ($parents as $parent) { $dataPointer[$parent] = array(); $dataPointer = &$dataPointer[$parent]; } $dataPointer[$name] = $value; $this->load($data); }
php
public function set($name, $value) { $data = array(); $dataPointer = &$data; $parents = explode('.', $name); $name = array_pop($parents); foreach ($parents as $parent) { $dataPointer[$parent] = array(); $dataPointer = &$dataPointer[$parent]; } $dataPointer[$name] = $value; $this->load($data); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "dataPointer", "=", "&", "$", "data", ";", "$", "parents", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "name", "=", "array_pop", "(", "$", "parents", ")", ";", "foreach", "(", "$", "parents", "as", "$", "parent", ")", "{", "$", "dataPointer", "[", "$", "parent", "]", "=", "array", "(", ")", ";", "$", "dataPointer", "=", "&", "$", "dataPointer", "[", "$", "parent", "]", ";", "}", "$", "dataPointer", "[", "$", "name", "]", "=", "$", "value", ";", "$", "this", "->", "load", "(", "$", "data", ")", ";", "}" ]
Set a value in the config. If the value doesn't exist it will be created.
[ "Set", "a", "value", "in", "the", "config", ".", "If", "the", "value", "doesn", "t", "exist", "it", "will", "be", "created", "." ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Config/Config.php#L136-L147
16,907
jfusion/org.jfusion.framework
src/Plugin/Plugin.php
Plugin.getName
final public function getName() { if (!$this->name) { $this->name = get_class($this); list ($jfusion, $plugins, $name) = explode('\\', get_class($this)); $this->name = $name; } return $this->name; }
php
final public function getName() { if (!$this->name) { $this->name = get_class($this); list ($jfusion, $plugins, $name) = explode('\\', get_class($this)); $this->name = $name; } return $this->name; }
[ "final", "public", "function", "getName", "(", ")", "{", "if", "(", "!", "$", "this", "->", "name", ")", "{", "$", "this", "->", "name", "=", "get_class", "(", "$", "this", ")", ";", "list", "(", "$", "jfusion", ",", "$", "plugins", ",", "$", "name", ")", "=", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "this", ")", ")", ";", "$", "this", "->", "name", "=", "$", "name", ";", "}", "return", "$", "this", "->", "name", ";", "}" ]
returns the name of this JFusion plugin, using the "namespace" part of the plugin class @return string name of current JFusion plugin
[ "returns", "the", "name", "of", "this", "JFusion", "plugin", "using", "the", "namespace", "part", "of", "the", "plugin", "class" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Plugin.php#L134-L144
16,908
jfusion/org.jfusion.framework
src/Plugin/Plugin.php
Plugin.isConfigured
final public function isConfigured() { $jname = $this->getJname(); $result = false; if (!empty($jname)) { if (!isset(static::$status[$jname])) { $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('status') ->from('#__jfusion') ->where('name = ' . $db->quote($jname)); $db->setQuery($query); $result = $db->loadResult(); if ($result >= 1) { $result = true; } else { $result = false; } static::$status[$jname] = $result; } else { $result = static::$status[$jname]; } } return $result; }
php
final public function isConfigured() { $jname = $this->getJname(); $result = false; if (!empty($jname)) { if (!isset(static::$status[$jname])) { $db = Factory::getDBO(); $query = $db->getQuery(true) ->select('status') ->from('#__jfusion') ->where('name = ' . $db->quote($jname)); $db->setQuery($query); $result = $db->loadResult(); if ($result >= 1) { $result = true; } else { $result = false; } static::$status[$jname] = $result; } else { $result = static::$status[$jname]; } } return $result; }
[ "final", "public", "function", "isConfigured", "(", ")", "{", "$", "jname", "=", "$", "this", "->", "getJname", "(", ")", ";", "$", "result", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "jname", ")", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "status", "[", "$", "jname", "]", ")", ")", "{", "$", "db", "=", "Factory", "::", "getDBO", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'status'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "jname", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "result", "=", "$", "db", "->", "loadResult", "(", ")", ";", "if", "(", "$", "result", ">=", "1", ")", "{", "$", "result", "=", "true", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "static", "::", "$", "status", "[", "$", "jname", "]", "=", "$", "result", ";", "}", "else", "{", "$", "result", "=", "static", "::", "$", "status", "[", "$", "jname", "]", ";", "}", "}", "return", "$", "result", ";", "}" ]
Checks to see if the JFusion plugin is properly configured @return boolean returns true if plugin is correctly configured
[ "Checks", "to", "see", "if", "the", "JFusion", "plugin", "is", "properly", "configured" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Plugin.php#L185-L211
16,909
jfusion/org.jfusion.framework
src/Plugin/Plugin.php
Plugin.getPluginFile
function getPluginFile($filename, &$error, &$reason) { //check to see if a path is defined $path = $this->params->get('source_path'); if (empty($path)) { $error = 1; $reason = Text::_('SET_PATH_FIRST'); } $mod_file = $path . $filename; //see if the file exists if (!file_exists($mod_file) && $error == 0) { $error = 1; $reason = Text::_('NO_FILE_FOUND'); } return $mod_file; }
php
function getPluginFile($filename, &$error, &$reason) { //check to see if a path is defined $path = $this->params->get('source_path'); if (empty($path)) { $error = 1; $reason = Text::_('SET_PATH_FIRST'); } $mod_file = $path . $filename; //see if the file exists if (!file_exists($mod_file) && $error == 0) { $error = 1; $reason = Text::_('NO_FILE_FOUND'); } return $mod_file; }
[ "function", "getPluginFile", "(", "$", "filename", ",", "&", "$", "error", ",", "&", "$", "reason", ")", "{", "//check to see if a path is defined", "$", "path", "=", "$", "this", "->", "params", "->", "get", "(", "'source_path'", ")", ";", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "$", "error", "=", "1", ";", "$", "reason", "=", "Text", "::", "_", "(", "'SET_PATH_FIRST'", ")", ";", "}", "$", "mod_file", "=", "$", "path", ".", "$", "filename", ";", "//see if the file exists", "if", "(", "!", "file_exists", "(", "$", "mod_file", ")", "&&", "$", "error", "==", "0", ")", "{", "$", "error", "=", "1", ";", "$", "reason", "=", "Text", "::", "_", "(", "'NO_FILE_FOUND'", ")", ";", "}", "return", "$", "mod_file", ";", "}" ]
Function returns the path to the modfile @param string $filename file name @param int &$error error number @param string &$reason error reason @return string $mod_file path and file of the modfile.
[ "Function", "returns", "the", "path", "to", "the", "modfile" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Plugin.php#L222-L239
16,910
leedavis81/altr-ego
library/AltrEgo/AltrEgo.php
AltrEgo.callStatic
public static function callStatic($object, $name, $arguments) { $className = self::getAdapterClassName(); return $className::_callStatic($object, $name, $arguments); }
php
public static function callStatic($object, $name, $arguments) { $className = self::getAdapterClassName(); return $className::_callStatic($object, $name, $arguments); }
[ "public", "static", "function", "callStatic", "(", "$", "object", ",", "$", "name", ",", "$", "arguments", ")", "{", "$", "className", "=", "self", "::", "getAdapterClassName", "(", ")", ";", "return", "$", "className", "::", "_callStatic", "(", "$", "object", ",", "$", "name", ",", "$", "arguments", ")", ";", "}" ]
Allows exposure to privately defined static calls @param mixed $object - Either a AltrEgo object, you own object or the class name the static function resides @param string $name - the static function name you want to call @param mixed $arguments - Can be a single argument, or an array of them that you wish to pass to the function call @throws \Exception
[ "Allows", "exposure", "to", "privately", "defined", "static", "calls" ]
1556556a33c2b6caddef94444522c5bbffc217c7
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/AltrEgo.php#L139-L143
16,911
aedart/laravel-helpers
src/Traits/Session/SessionManagerTrait.php
SessionManagerTrait.getSessionManager
public function getSessionManager(): ?SessionManager { if (!$this->hasSessionManager()) { $this->setSessionManager($this->getDefaultSessionManager()); } return $this->sessionManager; }
php
public function getSessionManager(): ?SessionManager { if (!$this->hasSessionManager()) { $this->setSessionManager($this->getDefaultSessionManager()); } return $this->sessionManager; }
[ "public", "function", "getSessionManager", "(", ")", ":", "?", "SessionManager", "{", "if", "(", "!", "$", "this", "->", "hasSessionManager", "(", ")", ")", "{", "$", "this", "->", "setSessionManager", "(", "$", "this", "->", "getDefaultSessionManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "sessionManager", ";", "}" ]
Get session manager If no session manager has been set, this method will set and return a default session manager, if any such value is available @see getDefaultSessionManager() @return SessionManager|null session manager or null if none session manager has been set
[ "Get", "session", "manager" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Session/SessionManagerTrait.php#L53-L59
16,912
preprocess/pre-class-accessors
source/ClassAccessorsTrait.php
ClassAccessorsTrait.handleSetClassAccessors
protected function handleSetClassAccessors($property, $value) { $property = $this->studly($property); if (method_exists($this, "set{$property}")) { return $this->{"set{$property}"}($value); } }
php
protected function handleSetClassAccessors($property, $value) { $property = $this->studly($property); if (method_exists($this, "set{$property}")) { return $this->{"set{$property}"}($value); } }
[ "protected", "function", "handleSetClassAccessors", "(", "$", "property", ",", "$", "value", ")", "{", "$", "property", "=", "$", "this", "->", "studly", "(", "$", "property", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "\"set{$property}\"", ")", ")", "{", "return", "$", "this", "->", "{", "\"set{$property}\"", "}", "(", "$", "value", ")", ";", "}", "}" ]
Finds and invokes setters. @param string $property @param mixed $value
[ "Finds", "and", "invokes", "setters", "." ]
1723028ee756824ab0bc1dab931da065497cd8fd
https://github.com/preprocess/pre-class-accessors/blob/1723028ee756824ab0bc1dab931da065497cd8fd/source/ClassAccessorsTrait.php#L60-L67
16,913
ClanCats/Core
src/classes/CCResponse.php
CCResponse.json
public static function json( $data = array(), $status = 200, $beautify = true ) { if ( !is_array( $data ) ) { throw new CCException( "CCResponse::json - first argument has to be an array." ); } $response = new static( CCJson::encode( $data, $beautify ), $status ); $response->header( 'Content-Type', 'text/json' ); return $response; }
php
public static function json( $data = array(), $status = 200, $beautify = true ) { if ( !is_array( $data ) ) { throw new CCException( "CCResponse::json - first argument has to be an array." ); } $response = new static( CCJson::encode( $data, $beautify ), $status ); $response->header( 'Content-Type', 'text/json' ); return $response; }
[ "public", "static", "function", "json", "(", "$", "data", "=", "array", "(", ")", ",", "$", "status", "=", "200", ",", "$", "beautify", "=", "true", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCResponse::json - first argument has to be an array.\"", ")", ";", "}", "$", "response", "=", "new", "static", "(", "CCJson", "::", "encode", "(", "$", "data", ",", "$", "beautify", ")", ",", "$", "status", ")", ";", "$", "response", "->", "header", "(", "'Content-Type'", ",", "'text/json'", ")", ";", "return", "$", "response", ";", "}" ]
json response you can pass an array of data wich will be converted to json @param array $data @param int $status @param bool $beautify should the json output be formatted? @return CCResponse
[ "json", "response", "you", "can", "pass", "an", "array", "of", "data", "wich", "will", "be", "converted", "to", "json" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCResponse.php#L123-L134
16,914
ClanCats/Core
src/classes/CCResponse.php
CCResponse.download
public static function download( $body, $filename = null, $status = 200 ) { return static::create( $body, $status )->as_download( $filename ); }
php
public static function download( $body, $filename = null, $status = 200 ) { return static::create( $body, $status )->as_download( $filename ); }
[ "public", "static", "function", "download", "(", "$", "body", ",", "$", "filename", "=", "null", ",", "$", "status", "=", "200", ")", "{", "return", "static", "::", "create", "(", "$", "body", ",", "$", "status", ")", "->", "as_download", "(", "$", "filename", ")", ";", "}" ]
download response creates an respose that forces the browser to download as file @param string $body @param string $filename @param int $status @return CCResponse
[ "download", "response", "creates", "an", "respose", "that", "forces", "the", "browser", "to", "download", "as", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCResponse.php#L145-L148
16,915
ClanCats/Core
src/classes/CCResponse.php
CCResponse.as_download
public function as_download( $filename = null ) { if ( is_null( $filename ) ) { $filename = 'file.'.CCStr::suffix( $this->header( 'Content-Type' ), '/' ); } $this->header( 'Content-Description', 'File Transfer' ); $this->header( 'Content-Disposition', 'attachment; filename='.$filename ); $this->header( 'Content-Transfer-Encoding', 'binary' ); $this->header( 'Expires', '0' ); $this->header( 'Cache-Control', 'must-revalidate' ); $this->header( 'Pragma', 'public' ); $this->header( 'Content-Length', strlen( $this->body() ) ); return $this; }
php
public function as_download( $filename = null ) { if ( is_null( $filename ) ) { $filename = 'file.'.CCStr::suffix( $this->header( 'Content-Type' ), '/' ); } $this->header( 'Content-Description', 'File Transfer' ); $this->header( 'Content-Disposition', 'attachment; filename='.$filename ); $this->header( 'Content-Transfer-Encoding', 'binary' ); $this->header( 'Expires', '0' ); $this->header( 'Cache-Control', 'must-revalidate' ); $this->header( 'Pragma', 'public' ); $this->header( 'Content-Length', strlen( $this->body() ) ); return $this; }
[ "public", "function", "as_download", "(", "$", "filename", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "filename", ")", ")", "{", "$", "filename", "=", "'file.'", ".", "CCStr", "::", "suffix", "(", "$", "this", "->", "header", "(", "'Content-Type'", ")", ",", "'/'", ")", ";", "}", "$", "this", "->", "header", "(", "'Content-Description'", ",", "'File Transfer'", ")", ";", "$", "this", "->", "header", "(", "'Content-Disposition'", ",", "'attachment; filename='", ".", "$", "filename", ")", ";", "$", "this", "->", "header", "(", "'Content-Transfer-Encoding'", ",", "'binary'", ")", ";", "$", "this", "->", "header", "(", "'Expires'", ",", "'0'", ")", ";", "$", "this", "->", "header", "(", "'Cache-Control'", ",", "'must-revalidate'", ")", ";", "$", "this", "->", "header", "(", "'Pragma'", ",", "'public'", ")", ";", "$", "this", "->", "header", "(", "'Content-Length'", ",", "strlen", "(", "$", "this", "->", "body", "(", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
modify the headers to force a download @param string $filename @return void
[ "modify", "the", "headers", "to", "force", "a", "download" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCResponse.php#L251-L267
16,916
ClanCats/Core
src/classes/CCResponse.php
CCResponse.send
public function send( $headers = false ) { if ( $headers && headers_sent() && !CLI ) { throw new CCException( "CCResponse::send - cannot send header, header has already been send." ); } if ( $headers ) { // status header header( CCIn::server( 'SERVER_PROTOCOL' ).' '.$this->_status.' '.CCResponse::$messages[$this->_status] ); // check if content type is already set if ( !isset( $this->_header['Content-Type'] ) ) { $this->header( 'Content-Type', 'text/html; charset='.ClanCats::$config->get( 'charset', 'utf-8' ) ); } $this->header( 'X-Powered-By', 'ClanCatsFramework version: '.ClanCats::VERSION ); // set headers foreach( $this->_header as $key => $content ) { header( $key.': '.$content ); } } // profiler CCProfiler::check( 'CCResponse - sending response' ); // print the body echo CCEvent::pass( 'response.output', $this->body() ); }
php
public function send( $headers = false ) { if ( $headers && headers_sent() && !CLI ) { throw new CCException( "CCResponse::send - cannot send header, header has already been send." ); } if ( $headers ) { // status header header( CCIn::server( 'SERVER_PROTOCOL' ).' '.$this->_status.' '.CCResponse::$messages[$this->_status] ); // check if content type is already set if ( !isset( $this->_header['Content-Type'] ) ) { $this->header( 'Content-Type', 'text/html; charset='.ClanCats::$config->get( 'charset', 'utf-8' ) ); } $this->header( 'X-Powered-By', 'ClanCatsFramework version: '.ClanCats::VERSION ); // set headers foreach( $this->_header as $key => $content ) { header( $key.': '.$content ); } } // profiler CCProfiler::check( 'CCResponse - sending response' ); // print the body echo CCEvent::pass( 'response.output', $this->body() ); }
[ "public", "function", "send", "(", "$", "headers", "=", "false", ")", "{", "if", "(", "$", "headers", "&&", "headers_sent", "(", ")", "&&", "!", "CLI", ")", "{", "throw", "new", "CCException", "(", "\"CCResponse::send - cannot send header, header has already been send.\"", ")", ";", "}", "if", "(", "$", "headers", ")", "{", "// status header", "header", "(", "CCIn", "::", "server", "(", "'SERVER_PROTOCOL'", ")", ".", "' '", ".", "$", "this", "->", "_status", ".", "' '", ".", "CCResponse", "::", "$", "messages", "[", "$", "this", "->", "_status", "]", ")", ";", "// check if content type is already set", "if", "(", "!", "isset", "(", "$", "this", "->", "_header", "[", "'Content-Type'", "]", ")", ")", "{", "$", "this", "->", "header", "(", "'Content-Type'", ",", "'text/html; charset='", ".", "ClanCats", "::", "$", "config", "->", "get", "(", "'charset'", ",", "'utf-8'", ")", ")", ";", "}", "$", "this", "->", "header", "(", "'X-Powered-By'", ",", "'ClanCatsFramework version: '", ".", "ClanCats", "::", "VERSION", ")", ";", "// set headers", "foreach", "(", "$", "this", "->", "_header", "as", "$", "key", "=>", "$", "content", ")", "{", "header", "(", "$", "key", ".", "': '", ".", "$", "content", ")", ";", "}", "}", "// profiler", "CCProfiler", "::", "check", "(", "'CCResponse - sending response'", ")", ";", "// print the body", "echo", "CCEvent", "::", "pass", "(", "'response.output'", ",", "$", "this", "->", "body", "(", ")", ")", ";", "}" ]
send response means printing the response and setting the headers if set @param bool $headers @return void
[ "send", "response", "means", "printing", "the", "response", "and", "setting", "the", "headers", "if", "set" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCResponse.php#L276-L308
16,917
inpsyde/inpsyde-filter
src/DateTime.php
DateTime.normalize_date_time
protected function normalize_date_time( $value ) { if ( $value === '' || $value === NULL ) { return $value; } if ( ! is_string( $value ) && ! is_int( $value ) && ! $value instanceof DateTime ) { return $value; } if ( is_int( $value ) ) { //timestamp $value = new \DateTime( '@' . $value ); } elseif ( ! $value instanceof DateTime ) { $value = new \DateTime( $value ); } return $value->format( $this->options[ 'format' ] ); }
php
protected function normalize_date_time( $value ) { if ( $value === '' || $value === NULL ) { return $value; } if ( ! is_string( $value ) && ! is_int( $value ) && ! $value instanceof DateTime ) { return $value; } if ( is_int( $value ) ) { //timestamp $value = new \DateTime( '@' . $value ); } elseif ( ! $value instanceof DateTime ) { $value = new \DateTime( $value ); } return $value->format( $this->options[ 'format' ] ); }
[ "protected", "function", "normalize_date_time", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "''", "||", "$", "value", "===", "NULL", ")", "{", "return", "$", "value", ";", "}", "if", "(", "!", "is_string", "(", "$", "value", ")", "&&", "!", "is_int", "(", "$", "value", ")", "&&", "!", "$", "value", "instanceof", "DateTime", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "//timestamp", "$", "value", "=", "new", "\\", "DateTime", "(", "'@'", ".", "$", "value", ")", ";", "}", "elseif", "(", "!", "$", "value", "instanceof", "DateTime", ")", "{", "$", "value", "=", "new", "\\", "DateTime", "(", "$", "value", ")", ";", "}", "return", "$", "value", "->", "format", "(", "$", "this", "->", "options", "[", "'format'", "]", ")", ";", "}" ]
Normalize the provided value to a formatted string. @param string|int|DateTime $value @return string
[ "Normalize", "the", "provided", "value", "to", "a", "formatted", "string", "." ]
777a6208ea4dfbeed89e6d0712a35dc25eab498b
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/DateTime.php#L51-L67
16,918
factorio-item-browser/export-data
src/Entity/Recipe.php
Recipe.setIngredients
public function setIngredients(array $ingredients) { $this->ingredients = array_values(array_filter($ingredients, function ($ingredient): bool { return $ingredient instanceof Ingredient; })); return $this; }
php
public function setIngredients(array $ingredients) { $this->ingredients = array_values(array_filter($ingredients, function ($ingredient): bool { return $ingredient instanceof Ingredient; })); return $this; }
[ "public", "function", "setIngredients", "(", "array", "$", "ingredients", ")", "{", "$", "this", "->", "ingredients", "=", "array_values", "(", "array_filter", "(", "$", "ingredients", ",", "function", "(", "$", "ingredient", ")", ":", "bool", "{", "return", "$", "ingredient", "instanceof", "Ingredient", ";", "}", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sets the ingredients of the recipe. @param array|Ingredient[] $ingredients @return $this Implementing fluent interface.
[ "Sets", "the", "ingredients", "of", "the", "recipe", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Recipe.php#L145-L151
16,919
factorio-item-browser/export-data
src/Entity/Recipe.php
Recipe.setProducts
public function setProducts(array $products) { $this->products = array_values(array_filter($products, function ($product): bool { return $product instanceof Product; })); return $this; }
php
public function setProducts(array $products) { $this->products = array_values(array_filter($products, function ($product): bool { return $product instanceof Product; })); return $this; }
[ "public", "function", "setProducts", "(", "array", "$", "products", ")", "{", "$", "this", "->", "products", "=", "array_values", "(", "array_filter", "(", "$", "products", ",", "function", "(", "$", "product", ")", ":", "bool", "{", "return", "$", "product", "instanceof", "Product", ";", "}", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sets the products of the recipe. @param array|Product[] $products @return $this Implementing fluent interface.
[ "Sets", "the", "products", "of", "the", "recipe", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Recipe.php#L178-L184
16,920
thienhungho/yii2-order-management
src/modules/MyOrder/controllers/OrderController.php
OrderController.actionIndex
public function actionIndex() { $searchModel = new OrderSearch(); $queryParams = request()->queryParams; $queryParams['OrderSearch']['customer_username'] = get_current_user_name(); $dataProvider = $searchModel->search($queryParams); $dataProvider->sort->defaultOrder = ['id' => SORT_DESC]; $dataProvider = $searchModel->search(request()->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex() { $searchModel = new OrderSearch(); $queryParams = request()->queryParams; $queryParams['OrderSearch']['customer_username'] = get_current_user_name(); $dataProvider = $searchModel->search($queryParams); $dataProvider->sort->defaultOrder = ['id' => SORT_DESC]; $dataProvider = $searchModel->search(request()->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "OrderSearch", "(", ")", ";", "$", "queryParams", "=", "request", "(", ")", "->", "queryParams", ";", "$", "queryParams", "[", "'OrderSearch'", "]", "[", "'customer_username'", "]", "=", "get_current_user_name", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "$", "queryParams", ")", ";", "$", "dataProvider", "->", "sort", "->", "defaultOrder", "=", "[", "'id'", "=>", "SORT_DESC", "]", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "request", "(", ")", "->", "queryParams", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Lists all Order models. @return mixed
[ "Lists", "all", "Order", "models", "." ]
f263f0b2168d6f5e99cee2e20a5878d09d4e81c0
https://github.com/thienhungho/yii2-order-management/blob/f263f0b2168d6f5e99cee2e20a5878d09d4e81c0/src/modules/MyOrder/controllers/OrderController.php#L33-L46
16,921
xinix-technology/norm
src/Norm/Type/NDateTime.php
NDateTime.tzFormat
public function tzFormat($format, $tz = null) { if (isset($tz)) { $this->setTimezone(new DateTimeZone($tz)); } return $this->format($format); }
php
public function tzFormat($format, $tz = null) { if (isset($tz)) { $this->setTimezone(new DateTimeZone($tz)); } return $this->format($format); }
[ "public", "function", "tzFormat", "(", "$", "format", ",", "$", "tz", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "tz", ")", ")", "{", "$", "this", "->", "setTimezone", "(", "new", "DateTimeZone", "(", "$", "tz", ")", ")", ";", "}", "return", "$", "this", "->", "format", "(", "$", "format", ")", ";", "}" ]
Formatting by timezone @param string $format @param string $tz @return mixed
[ "Formatting", "by", "timezone" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Type/NDateTime.php#L38-L45
16,922
xinix-technology/norm
src/Norm/Type/NDateTime.php
NDateTime.jsonSerialize
public function jsonSerialize() { if ($tz = Norm::options('tz')) { $this->setTimezone(new DateTimeZone($tz)); } return $this->format('c'); }
php
public function jsonSerialize() { if ($tz = Norm::options('tz')) { $this->setTimezone(new DateTimeZone($tz)); } return $this->format('c'); }
[ "public", "function", "jsonSerialize", "(", ")", "{", "if", "(", "$", "tz", "=", "Norm", "::", "options", "(", "'tz'", ")", ")", "{", "$", "this", "->", "setTimezone", "(", "new", "DateTimeZone", "(", "$", "tz", ")", ")", ";", "}", "return", "$", "this", "->", "format", "(", "'c'", ")", ";", "}" ]
Perform serialization of this implementation. @return string
[ "Perform", "serialization", "of", "this", "implementation", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Type/NDateTime.php#L52-L59
16,923
javiacei/IdeupSimplePaginatorBundle
Twig/Extension/PaginatorExtension.php
PaginatorExtension.render
public function render($route, $id = null, $options = array(), $view = null) { return $this->pagebar->render($route, $id, $options, $view); }
php
public function render($route, $id = null, $options = array(), $view = null) { return $this->pagebar->render($route, $id, $options, $view); }
[ "public", "function", "render", "(", "$", "route", ",", "$", "id", "=", "null", ",", "$", "options", "=", "array", "(", ")", ",", "$", "view", "=", "null", ")", "{", "return", "$", "this", "->", "pagebar", "->", "render", "(", "$", "route", ",", "$", "id", ",", "$", "options", ",", "$", "view", ")", ";", "}" ]
Renders the paginator @param string $route @param string $id @param array $options @param string $view @return string
[ "Renders", "the", "paginator" ]
12639a9c75bc403649fc2b2881e190a017d8c5b2
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Twig/Extension/PaginatorExtension.php#L46-L49
16,924
titon/db
src/Titon/Db/Behavior/ConverterBehavior.php
ConverterBehavior.convert
public function convert($field, $type, array $options = []) { if (!isset($this->_defaults[$type])) { throw new InvalidArgumentException(sprintf('Converter %s does not exist', $type)); } $this->_converters[$field] = Hash::merge([ 'encode' => true, 'decode' => true, 'type' => $type, ], $this->_defaults[$type], $options); return $this; }
php
public function convert($field, $type, array $options = []) { if (!isset($this->_defaults[$type])) { throw new InvalidArgumentException(sprintf('Converter %s does not exist', $type)); } $this->_converters[$field] = Hash::merge([ 'encode' => true, 'decode' => true, 'type' => $type, ], $this->_defaults[$type], $options); return $this; }
[ "public", "function", "convert", "(", "$", "field", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_defaults", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Converter %s does not exist'", ",", "$", "type", ")", ")", ";", "}", "$", "this", "->", "_converters", "[", "$", "field", "]", "=", "Hash", "::", "merge", "(", "[", "'encode'", "=>", "true", ",", "'decode'", "=>", "true", ",", "'type'", "=>", "$", "type", ",", "]", ",", "$", "this", "->", "_defaults", "[", "$", "type", "]", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Define a converter for a specific field. @param string $field @param string $type @param array $options @return $this @throws \Titon\Db\Exception\InvalidArgumentException
[ "Define", "a", "converter", "for", "a", "specific", "field", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/ConverterBehavior.php#L56-L68
16,925
titon/db
src/Titon/Db/Behavior/ConverterBehavior.php
ConverterBehavior.preSave
public function preSave(Event $event, Query $query, $id, array &$data) { $repo = $this->getRepository(); $converters = $this->getConverters(); foreach ($data as $key => $value) { if (empty($converters[$key])) { continue; } $converter = $converters[$key]; // Exit if encoding should not happen if (!$converter['encode']) { continue; } switch ($converter['type']) { case self::SERIALIZE: $value = $this->toSerialize($value, $converter); break; case self::JSON: $value = $this->toJson($value, $converter); break; case self::BASE64: $value = $this->toBase64($value, $converter); break; case self::CUSTOM: if (method_exists($repo, $converter['encode'])) { $value = call_user_func_array([$repo, $converter['encode']], [$value, $converter]); } break; } $data[$key] = $value; } return true; }
php
public function preSave(Event $event, Query $query, $id, array &$data) { $repo = $this->getRepository(); $converters = $this->getConverters(); foreach ($data as $key => $value) { if (empty($converters[$key])) { continue; } $converter = $converters[$key]; // Exit if encoding should not happen if (!$converter['encode']) { continue; } switch ($converter['type']) { case self::SERIALIZE: $value = $this->toSerialize($value, $converter); break; case self::JSON: $value = $this->toJson($value, $converter); break; case self::BASE64: $value = $this->toBase64($value, $converter); break; case self::CUSTOM: if (method_exists($repo, $converter['encode'])) { $value = call_user_func_array([$repo, $converter['encode']], [$value, $converter]); } break; } $data[$key] = $value; } return true; }
[ "public", "function", "preSave", "(", "Event", "$", "event", ",", "Query", "$", "query", ",", "$", "id", ",", "array", "&", "$", "data", ")", "{", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "converters", "=", "$", "this", "->", "getConverters", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "converters", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "converter", "=", "$", "converters", "[", "$", "key", "]", ";", "// Exit if encoding should not happen", "if", "(", "!", "$", "converter", "[", "'encode'", "]", ")", "{", "continue", ";", "}", "switch", "(", "$", "converter", "[", "'type'", "]", ")", "{", "case", "self", "::", "SERIALIZE", ":", "$", "value", "=", "$", "this", "->", "toSerialize", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "JSON", ":", "$", "value", "=", "$", "this", "->", "toJson", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "BASE64", ":", "$", "value", "=", "$", "this", "->", "toBase64", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "CUSTOM", ":", "if", "(", "method_exists", "(", "$", "repo", ",", "$", "converter", "[", "'encode'", "]", ")", ")", "{", "$", "value", "=", "call_user_func_array", "(", "[", "$", "repo", ",", "$", "converter", "[", "'encode'", "]", "]", ",", "[", "$", "value", ",", "$", "converter", "]", ")", ";", "}", "break", ";", "}", "$", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "true", ";", "}" ]
Apply the encoding converter before a record is saved. @param \Titon\Event\Event $event @param \Titon\Db\Query $query @param int|int[] $id @param array $data @return bool
[ "Apply", "the", "encoding", "converter", "before", "a", "record", "is", "saved", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/ConverterBehavior.php#L121-L152
16,926
titon/db
src/Titon/Db/Behavior/ConverterBehavior.php
ConverterBehavior.postFind
public function postFind(Event $event, array &$results, $finder) { if (!in_array($finder, ['first', 'all'])) { return; } $repo = $this->getRepository(); $converters = $this->getConverters(); foreach ($results as $i => $result) { foreach ($result as $key => $value) { if (empty($converters[$key])) { continue; } $converter = $converters[$key]; // Exit if decoding should not happen if (!$converter['decode']) { continue; } switch ($converter['type']) { case self::SERIALIZE: $value = $this->fromSerialize($value, $converter); break; case self::JSON: $value = $this->fromJson($value, $converter); break; case self::BASE64: $value = $this->fromBase64($value, $converter); break; case self::CUSTOM: if (method_exists($repo, $converter['decode'])) { $value = call_user_func_array([$repo, $converter['decode']], [$value, $converter]); } break; } $results[$i][$key] = $value; } } }
php
public function postFind(Event $event, array &$results, $finder) { if (!in_array($finder, ['first', 'all'])) { return; } $repo = $this->getRepository(); $converters = $this->getConverters(); foreach ($results as $i => $result) { foreach ($result as $key => $value) { if (empty($converters[$key])) { continue; } $converter = $converters[$key]; // Exit if decoding should not happen if (!$converter['decode']) { continue; } switch ($converter['type']) { case self::SERIALIZE: $value = $this->fromSerialize($value, $converter); break; case self::JSON: $value = $this->fromJson($value, $converter); break; case self::BASE64: $value = $this->fromBase64($value, $converter); break; case self::CUSTOM: if (method_exists($repo, $converter['decode'])) { $value = call_user_func_array([$repo, $converter['decode']], [$value, $converter]); } break; } $results[$i][$key] = $value; } } }
[ "public", "function", "postFind", "(", "Event", "$", "event", ",", "array", "&", "$", "results", ",", "$", "finder", ")", "{", "if", "(", "!", "in_array", "(", "$", "finder", ",", "[", "'first'", ",", "'all'", "]", ")", ")", "{", "return", ";", "}", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "converters", "=", "$", "this", "->", "getConverters", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "i", "=>", "$", "result", ")", "{", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "converters", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "converter", "=", "$", "converters", "[", "$", "key", "]", ";", "// Exit if decoding should not happen", "if", "(", "!", "$", "converter", "[", "'decode'", "]", ")", "{", "continue", ";", "}", "switch", "(", "$", "converter", "[", "'type'", "]", ")", "{", "case", "self", "::", "SERIALIZE", ":", "$", "value", "=", "$", "this", "->", "fromSerialize", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "JSON", ":", "$", "value", "=", "$", "this", "->", "fromJson", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "BASE64", ":", "$", "value", "=", "$", "this", "->", "fromBase64", "(", "$", "value", ",", "$", "converter", ")", ";", "break", ";", "case", "self", "::", "CUSTOM", ":", "if", "(", "method_exists", "(", "$", "repo", ",", "$", "converter", "[", "'decode'", "]", ")", ")", "{", "$", "value", "=", "call_user_func_array", "(", "[", "$", "repo", ",", "$", "converter", "[", "'decode'", "]", "]", ",", "[", "$", "value", ",", "$", "converter", "]", ")", ";", "}", "break", ";", "}", "$", "results", "[", "$", "i", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}" ]
Apply the decoding converter after a record is retrieved. @param \Titon\Event\Event $event @param array $results @param string $finder
[ "Apply", "the", "decoding", "converter", "after", "a", "record", "is", "retrieved", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/ConverterBehavior.php#L161-L196
16,927
antonmedv/silicone
src/Silicone/Application.php
Application.getRootDir
public function getRootDir() { static $dir; if (empty($dir)) { $rc = new \ReflectionClass(get_class($this)); $dir = dirname(dirname($rc->getFileName())); } return $dir; }
php
public function getRootDir() { static $dir; if (empty($dir)) { $rc = new \ReflectionClass(get_class($this)); $dir = dirname(dirname($rc->getFileName())); } return $dir; }
[ "public", "function", "getRootDir", "(", ")", "{", "static", "$", "dir", ";", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "$", "rc", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "dir", "=", "dirname", "(", "dirname", "(", "$", "rc", "->", "getFileName", "(", ")", ")", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Get root directory. @return string
[ "Get", "root", "directory", "." ]
e4a67ed41f0f419984df642b303f2a491c9a3933
https://github.com/antonmedv/silicone/blob/e4a67ed41f0f419984df642b303f2a491c9a3933/src/Silicone/Application.php#L39-L47
16,928
antonmedv/silicone
src/Silicone/Application.php
Application.getCacheDir
public function getCacheDir() { static $dir; if (empty($dir)) { $dir = $this->getOpenDir() . '/cache/'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } } return $dir; }
php
public function getCacheDir() { static $dir; if (empty($dir)) { $dir = $this->getOpenDir() . '/cache/'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } } return $dir; }
[ "public", "function", "getCacheDir", "(", ")", "{", "static", "$", "dir", ";", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "$", "dir", "=", "$", "this", "->", "getOpenDir", "(", ")", ".", "'/cache/'", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0755", ",", "true", ")", ";", "}", "}", "return", "$", "dir", ";", "}" ]
Get cache directory. @return string
[ "Get", "cache", "directory", "." ]
e4a67ed41f0f419984df642b303f2a491c9a3933
https://github.com/antonmedv/silicone/blob/e4a67ed41f0f419984df642b303f2a491c9a3933/src/Silicone/Application.php#L66-L77
16,929
antonmedv/silicone
src/Silicone/Application.php
Application.getLogDir
public function getLogDir() { static $dir; if (empty($dir)) { $dir = $this->getOpenDir() . '/log/'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } } return $dir; }
php
public function getLogDir() { static $dir; if (empty($dir)) { $dir = $this->getOpenDir() . '/log/'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } } return $dir; }
[ "public", "function", "getLogDir", "(", ")", "{", "static", "$", "dir", ";", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "$", "dir", "=", "$", "this", "->", "getOpenDir", "(", ")", ".", "'/log/'", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0755", ",", "true", ")", ";", "}", "}", "return", "$", "dir", ";", "}" ]
Get log directory. @return string
[ "Get", "log", "directory", "." ]
e4a67ed41f0f419984df642b303f2a491c9a3933
https://github.com/antonmedv/silicone/blob/e4a67ed41f0f419984df642b303f2a491c9a3933/src/Silicone/Application.php#L83-L94
16,930
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/CountDownLatch.php
CountDownLatch.await
public function await($timeout = 0, TimeUnit $unit = null) { if (null !== $unit) { $timeout = $unit->toMicros($timeout); } $timeoutAt = microtime(true) + ($timeout / 1000000); while (0 != $this->count) { if ($timeout > 0 && (microtime(true) > $timeoutAt)) { return false; } time_nanosleep(0, 1); } return true; }
php
public function await($timeout = 0, TimeUnit $unit = null) { if (null !== $unit) { $timeout = $unit->toMicros($timeout); } $timeoutAt = microtime(true) + ($timeout / 1000000); while (0 != $this->count) { if ($timeout > 0 && (microtime(true) > $timeoutAt)) { return false; } time_nanosleep(0, 1); } return true; }
[ "public", "function", "await", "(", "$", "timeout", "=", "0", ",", "TimeUnit", "$", "unit", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "unit", ")", "{", "$", "timeout", "=", "$", "unit", "->", "toMicros", "(", "$", "timeout", ")", ";", "}", "$", "timeoutAt", "=", "microtime", "(", "true", ")", "+", "(", "$", "timeout", "/", "1000000", ")", ";", "while", "(", "0", "!=", "$", "this", "->", "count", ")", "{", "if", "(", "$", "timeout", ">", "0", "&&", "(", "microtime", "(", "true", ")", ">", "$", "timeoutAt", ")", ")", "{", "return", "false", ";", "}", "time_nanosleep", "(", "0", ",", "1", ")", ";", "}", "return", "true", ";", "}" ]
Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted. @param int $timeout @param TimeUnit|null $unit the timeunit of the given timeout @return bool true if the count reached zero and false if the waiting time elapsed before the count reached zero
[ "Causes", "the", "current", "thread", "to", "wait", "until", "the", "latch", "has", "counted", "down", "to", "zero", "unless", "the", "thread", "is", "interrupted", "." ]
771b55b3ef79d9a7443c4f6d95373f41b9f34c4a
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/CountDownLatch.php#L35-L48
16,931
left-right/center
src/controllers/LoginController.php
LoginController.getIndex
public static function getIndex() { //show install form try { if (!DB::table(config('center.db.users'))->count()) return view('center::login.install'); } catch (\Exception $e) { if ($e->getCode() == 2002) { trigger_error('Center needs a valid database connection.'); } } return view('center::login.index'); }
php
public static function getIndex() { //show install form try { if (!DB::table(config('center.db.users'))->count()) return view('center::login.install'); } catch (\Exception $e) { if ($e->getCode() == 2002) { trigger_error('Center needs a valid database connection.'); } } return view('center::login.index'); }
[ "public", "static", "function", "getIndex", "(", ")", "{", "//show install form", "try", "{", "if", "(", "!", "DB", "::", "table", "(", "config", "(", "'center.db.users'", ")", ")", "->", "count", "(", ")", ")", "return", "view", "(", "'center::login.install'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getCode", "(", ")", "==", "2002", ")", "{", "trigger_error", "(", "'Center needs a valid database connection.'", ")", ";", "}", "}", "return", "view", "(", "'center::login.index'", ")", ";", "}" ]
show login page if not logged in
[ "show", "login", "page", "if", "not", "logged", "in" ]
47c225538475ca3e87fa49f31a323b6e6bd4eff2
https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/controllers/LoginController.php#L16-L28
16,932
left-right/center
src/controllers/LoginController.php
LoginController.postIndex
public function postIndex(Request $request) { //regular login if (DB::table(config('center.db.users'))->count()) { //attempt auth if (Auth::attempt(['email'=>$request->input('email'), 'password'=>$request->input('password')], true)) { DB::table(config('center.db.users'))->where('id', Auth::user()->id)->update([ 'last_login'=>new DateTime ]); return redirect()->intended(action('\LeftRight\Center\Controllers\TableController@index')); } return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.login_invalid')); } //installing, make user $user_id = DB::table(config('center.db.users'))->insertGetId([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password')), 'last_login' => new DateTime, 'updated_at' => new DateTime, 'updated_by' => 1, ]); Auth::loginUsingId($user_id, true); return redirect()->action('\LeftRight\Center\Controllers\TableController@index'); }
php
public function postIndex(Request $request) { //regular login if (DB::table(config('center.db.users'))->count()) { //attempt auth if (Auth::attempt(['email'=>$request->input('email'), 'password'=>$request->input('password')], true)) { DB::table(config('center.db.users'))->where('id', Auth::user()->id)->update([ 'last_login'=>new DateTime ]); return redirect()->intended(action('\LeftRight\Center\Controllers\TableController@index')); } return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.login_invalid')); } //installing, make user $user_id = DB::table(config('center.db.users'))->insertGetId([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password')), 'last_login' => new DateTime, 'updated_at' => new DateTime, 'updated_by' => 1, ]); Auth::loginUsingId($user_id, true); return redirect()->action('\LeftRight\Center\Controllers\TableController@index'); }
[ "public", "function", "postIndex", "(", "Request", "$", "request", ")", "{", "//regular login", "if", "(", "DB", "::", "table", "(", "config", "(", "'center.db.users'", ")", ")", "->", "count", "(", ")", ")", "{", "//attempt auth", "if", "(", "Auth", "::", "attempt", "(", "[", "'email'", "=>", "$", "request", "->", "input", "(", "'email'", ")", ",", "'password'", "=>", "$", "request", "->", "input", "(", "'password'", ")", "]", ",", "true", ")", ")", "{", "DB", "::", "table", "(", "config", "(", "'center.db.users'", ")", ")", "->", "where", "(", "'id'", ",", "Auth", "::", "user", "(", ")", "->", "id", ")", "->", "update", "(", "[", "'last_login'", "=>", "new", "DateTime", "]", ")", ";", "return", "redirect", "(", ")", "->", "intended", "(", "action", "(", "'\\LeftRight\\Center\\Controllers\\TableController@index'", ")", ")", ";", "}", "return", "redirect", "(", ")", "->", "action", "(", "'\\LeftRight\\Center\\Controllers\\TableController@index'", ")", "->", "with", "(", "'error'", ",", "trans", "(", "'center::site.login_invalid'", ")", ")", ";", "}", "//installing, make user", "$", "user_id", "=", "DB", "::", "table", "(", "config", "(", "'center.db.users'", ")", ")", "->", "insertGetId", "(", "[", "'name'", "=>", "$", "request", "->", "input", "(", "'name'", ")", ",", "'email'", "=>", "$", "request", "->", "input", "(", "'email'", ")", ",", "'password'", "=>", "Hash", "::", "make", "(", "$", "request", "->", "input", "(", "'password'", ")", ")", ",", "'last_login'", "=>", "new", "DateTime", ",", "'updated_at'", "=>", "new", "DateTime", ",", "'updated_by'", "=>", "1", ",", "]", ")", ";", "Auth", "::", "loginUsingId", "(", "$", "user_id", ",", "true", ")", ";", "return", "redirect", "(", ")", "->", "action", "(", "'\\LeftRight\\Center\\Controllers\\TableController@index'", ")", ";", "}" ]
handle a post to the login or install form
[ "handle", "a", "post", "to", "the", "login", "or", "install", "form" ]
47c225538475ca3e87fa49f31a323b6e6bd4eff2
https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/controllers/LoginController.php#L31-L60
16,933
left-right/center
src/controllers/LoginController.php
LoginController.getChange
public function getChange($email, $token) { //todo check email / token combo if (!$user = DB::table(config('center.db.users'))->whereNull('deleted_at')->where('email', $email)->where('token', $token)->first()) { return redirect()->action('\LeftRight\Center\Controllers\LoginController@getReset')->with([ 'error'=>trans('center::site.password_change_error') ]); } return view('center::login.change', [ 'email'=>$email, 'token'=>$token, ]); }
php
public function getChange($email, $token) { //todo check email / token combo if (!$user = DB::table(config('center.db.users'))->whereNull('deleted_at')->where('email', $email)->where('token', $token)->first()) { return redirect()->action('\LeftRight\Center\Controllers\LoginController@getReset')->with([ 'error'=>trans('center::site.password_change_error') ]); } return view('center::login.change', [ 'email'=>$email, 'token'=>$token, ]); }
[ "public", "function", "getChange", "(", "$", "email", ",", "$", "token", ")", "{", "//todo check email / token combo", "if", "(", "!", "$", "user", "=", "DB", "::", "table", "(", "config", "(", "'center.db.users'", ")", ")", "->", "whereNull", "(", "'deleted_at'", ")", "->", "where", "(", "'email'", ",", "$", "email", ")", "->", "where", "(", "'token'", ",", "$", "token", ")", "->", "first", "(", ")", ")", "{", "return", "redirect", "(", ")", "->", "action", "(", "'\\LeftRight\\Center\\Controllers\\LoginController@getReset'", ")", "->", "with", "(", "[", "'error'", "=>", "trans", "(", "'center::site.password_change_error'", ")", "]", ")", ";", "}", "return", "view", "(", "'center::login.change'", ",", "[", "'email'", "=>", "$", "email", ",", "'token'", "=>", "$", "token", ",", "]", ")", ";", "}" ]
reset password form
[ "reset", "password", "form" ]
47c225538475ca3e87fa49f31a323b6e6bd4eff2
https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/controllers/LoginController.php#L100-L112
16,934
ClanCats/Core
src/classes/CCViewController.php
CCViewController._respond
protected function _respond( $string ) { // if no view isset create one with the output buffer if ( is_null( $this->view ) ) { $this->theme->content = $string; } else { $this->theme->content = $this->view->render(); } // dont render the theme? Or does the request force render in modal? if ( CCRequest::current()->args->force_modal || $this->modal ) { return CCResponse::create( $this->theme->content, $this->status ); } // render theme and return response return CCResponse::create( $this->theme->render(), $this->status ); }
php
protected function _respond( $string ) { // if no view isset create one with the output buffer if ( is_null( $this->view ) ) { $this->theme->content = $string; } else { $this->theme->content = $this->view->render(); } // dont render the theme? Or does the request force render in modal? if ( CCRequest::current()->args->force_modal || $this->modal ) { return CCResponse::create( $this->theme->content, $this->status ); } // render theme and return response return CCResponse::create( $this->theme->render(), $this->status ); }
[ "protected", "function", "_respond", "(", "$", "string", ")", "{", "// if no view isset create one with the output buffer", "if", "(", "is_null", "(", "$", "this", "->", "view", ")", ")", "{", "$", "this", "->", "theme", "->", "content", "=", "$", "string", ";", "}", "else", "{", "$", "this", "->", "theme", "->", "content", "=", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}", "// dont render the theme? Or does the request force render in modal?", "if", "(", "CCRequest", "::", "current", "(", ")", "->", "args", "->", "force_modal", "||", "$", "this", "->", "modal", ")", "{", "return", "CCResponse", "::", "create", "(", "$", "this", "->", "theme", "->", "content", ",", "$", "this", "->", "status", ")", ";", "}", "// render theme and return response", "return", "CCResponse", "::", "create", "(", "$", "this", "->", "theme", "->", "render", "(", ")", ",", "$", "this", "->", "status", ")", ";", "}" ]
When a controller gives us a string make a response out of it @param string @return CCResponse
[ "When", "a", "controller", "gives", "us", "a", "string", "make", "a", "response", "out", "of", "it" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCViewController.php#L82-L100
16,935
lode/fem
src/routing.php
routing.handle
protected function handle($handler) { $handler_type = $this->get_handler_type($handler); // unmatched requests if (empty($handler) || empty($handler_type)) { $exception = bootstrap::get_library('exception'); throw new $exception('no route found', response::STATUS_NOT_FOUND); } // default flow: matched requests $this->{'load_handler_as_'.$handler_type}($handler); }
php
protected function handle($handler) { $handler_type = $this->get_handler_type($handler); // unmatched requests if (empty($handler) || empty($handler_type)) { $exception = bootstrap::get_library('exception'); throw new $exception('no route found', response::STATUS_NOT_FOUND); } // default flow: matched requests $this->{'load_handler_as_'.$handler_type}($handler); }
[ "protected", "function", "handle", "(", "$", "handler", ")", "{", "$", "handler_type", "=", "$", "this", "->", "get_handler_type", "(", "$", "handler", ")", ";", "// unmatched requests", "if", "(", "empty", "(", "$", "handler", ")", "||", "empty", "(", "$", "handler_type", ")", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'no route found'", ",", "response", "::", "STATUS_NOT_FOUND", ")", ";", "}", "// default flow: matched requests", "$", "this", "->", "{", "'load_handler_as_'", ".", "$", "handler_type", "}", "(", "$", "handler", ")", ";", "}" ]
find someone else and let them handle the request @param mixed $handler @see get_handler_type() @return void however, it will fire a handler or an error
[ "find", "someone", "else", "and", "let", "them", "handle", "the", "request" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L102-L113
16,936
lode/fem
src/routing.php
routing.find_handler_path
protected function find_handler_path($filename) { $filename = strtolower($filename); if (preg_match('{[^a-z0-9/_-]}', $filename)) { return false; } $base_path = \alsvanzelf\fem\ROOT_DIR_APP.$this->handler_base_path.'/'; $full_path = $base_path.$filename.'.php'; if (file_exists($full_path) == false) { return false; } // sanity check to prevent escaping outside the base dir if (strpos($full_path, $base_path) !== 0) { return false; } return $full_path; }
php
protected function find_handler_path($filename) { $filename = strtolower($filename); if (preg_match('{[^a-z0-9/_-]}', $filename)) { return false; } $base_path = \alsvanzelf\fem\ROOT_DIR_APP.$this->handler_base_path.'/'; $full_path = $base_path.$filename.'.php'; if (file_exists($full_path) == false) { return false; } // sanity check to prevent escaping outside the base dir if (strpos($full_path, $base_path) !== 0) { return false; } return $full_path; }
[ "protected", "function", "find_handler_path", "(", "$", "filename", ")", "{", "$", "filename", "=", "strtolower", "(", "$", "filename", ")", ";", "if", "(", "preg_match", "(", "'{[^a-z0-9/_-]}'", ",", "$", "filename", ")", ")", "{", "return", "false", ";", "}", "$", "base_path", "=", "\\", "alsvanzelf", "\\", "fem", "\\", "ROOT_DIR_APP", ".", "$", "this", "->", "handler_base_path", ".", "'/'", ";", "$", "full_path", "=", "$", "base_path", ".", "$", "filename", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "full_path", ")", "==", "false", ")", "{", "return", "false", ";", "}", "// sanity check to prevent escaping outside the base dir", "if", "(", "strpos", "(", "$", "full_path", ",", "$", "base_path", ")", "!==", "0", ")", "{", "return", "false", ";", "}", "return", "$", "full_path", ";", "}" ]
finds the handler's file @param string $filename a filename, relative to the handlers directory, and w/o '.php' @return string|boolean the full path, including \alsvanzelf\fem\ROOT_DIR_APP or false when not found
[ "finds", "the", "handler", "s", "file" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L122-L141
16,937
lode/fem
src/routing.php
routing.find_handler
private function find_handler() { $handler = false; // empty url leads to the default handler if (empty($this->url)) { return $this->default_handler; } // simple mapping urls to the filesystem if ($this->map_to_filesystem && $this->find_handler_path($this->url)) { // url == handler return $this->url; } // custom mapping via regex to various handler formats if ($this->map_to_filesystem == false) { $handler = $this->find_custom_handler(); // don't return, it could be a 404 } // fallback for unmatched requests if (empty($handler) && $this->fallback_to_default) { return $this->default_handler; } // 404 when file or regex is unmatched return $handler; }
php
private function find_handler() { $handler = false; // empty url leads to the default handler if (empty($this->url)) { return $this->default_handler; } // simple mapping urls to the filesystem if ($this->map_to_filesystem && $this->find_handler_path($this->url)) { // url == handler return $this->url; } // custom mapping via regex to various handler formats if ($this->map_to_filesystem == false) { $handler = $this->find_custom_handler(); // don't return, it could be a 404 } // fallback for unmatched requests if (empty($handler) && $this->fallback_to_default) { return $this->default_handler; } // 404 when file or regex is unmatched return $handler; }
[ "private", "function", "find_handler", "(", ")", "{", "$", "handler", "=", "false", ";", "// empty url leads to the default handler", "if", "(", "empty", "(", "$", "this", "->", "url", ")", ")", "{", "return", "$", "this", "->", "default_handler", ";", "}", "// simple mapping urls to the filesystem", "if", "(", "$", "this", "->", "map_to_filesystem", "&&", "$", "this", "->", "find_handler_path", "(", "$", "this", "->", "url", ")", ")", "{", "// url == handler", "return", "$", "this", "->", "url", ";", "}", "// custom mapping via regex to various handler formats", "if", "(", "$", "this", "->", "map_to_filesystem", "==", "false", ")", "{", "$", "handler", "=", "$", "this", "->", "find_custom_handler", "(", ")", ";", "// don't return, it could be a 404", "}", "// fallback for unmatched requests", "if", "(", "empty", "(", "$", "handler", ")", "&&", "$", "this", "->", "fallback_to_default", ")", "{", "return", "$", "this", "->", "default_handler", ";", "}", "// 404 when file or regex is unmatched", "return", "$", "handler", ";", "}" ]
find a handler for the requested url checks the filesystem directly if $this->map_to_filesystem is true checks user defined routes otherwise gives the default handler for empty url .. .. or when $this->fallback_to_default is true @return mixed $handler see get_handler_type()
[ "find", "a", "handler", "for", "the", "requested", "url" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L173-L200
16,938
lode/fem
src/routing.php
routing.find_custom_handler
private function find_custom_handler() { // get user defined routes $routes = $this->get_custom_routes(); if (empty($routes) || empty($routes[$this->method])) { return false; } // catch the non-regex routes first if (isset($routes[$this->method][$this->url])) { return $routes[$this->method][$this->url]; } // find a matching regex $handler = false; foreach ($routes[$this->method] as $url_regex => $possible_handler) { if (preg_match('{^'.$url_regex.'$}', $this->url, $matches)) { $handler = $possible_handler; // save named subpatterns from the regex, to send them through to the handler if (strpos($url_regex, '?<') && count($matches) > 1) { $this->arguments = $matches; } break; } } return $handler; }
php
private function find_custom_handler() { // get user defined routes $routes = $this->get_custom_routes(); if (empty($routes) || empty($routes[$this->method])) { return false; } // catch the non-regex routes first if (isset($routes[$this->method][$this->url])) { return $routes[$this->method][$this->url]; } // find a matching regex $handler = false; foreach ($routes[$this->method] as $url_regex => $possible_handler) { if (preg_match('{^'.$url_regex.'$}', $this->url, $matches)) { $handler = $possible_handler; // save named subpatterns from the regex, to send them through to the handler if (strpos($url_regex, '?<') && count($matches) > 1) { $this->arguments = $matches; } break; } } return $handler; }
[ "private", "function", "find_custom_handler", "(", ")", "{", "// get user defined routes", "$", "routes", "=", "$", "this", "->", "get_custom_routes", "(", ")", ";", "if", "(", "empty", "(", "$", "routes", ")", "||", "empty", "(", "$", "routes", "[", "$", "this", "->", "method", "]", ")", ")", "{", "return", "false", ";", "}", "// catch the non-regex routes first", "if", "(", "isset", "(", "$", "routes", "[", "$", "this", "->", "method", "]", "[", "$", "this", "->", "url", "]", ")", ")", "{", "return", "$", "routes", "[", "$", "this", "->", "method", "]", "[", "$", "this", "->", "url", "]", ";", "}", "// find a matching regex", "$", "handler", "=", "false", ";", "foreach", "(", "$", "routes", "[", "$", "this", "->", "method", "]", "as", "$", "url_regex", "=>", "$", "possible_handler", ")", "{", "if", "(", "preg_match", "(", "'{^'", ".", "$", "url_regex", ".", "'$}'", ",", "$", "this", "->", "url", ",", "$", "matches", ")", ")", "{", "$", "handler", "=", "$", "possible_handler", ";", "// save named subpatterns from the regex, to send them through to the handler", "if", "(", "strpos", "(", "$", "url_regex", ",", "'?<'", ")", "&&", "count", "(", "$", "matches", ")", ">", "1", ")", "{", "$", "this", "->", "arguments", "=", "$", "matches", ";", "}", "break", ";", "}", "}", "return", "$", "handler", ";", "}" ]
matches the user defined routes @return mixed $handler see get_handler_type()
[ "matches", "the", "user", "defined", "routes" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L207-L234
16,939
lode/fem
src/routing.php
routing.get_handler_type
private function get_handler_type($handler) { if ($handler instanceof \Closure) { return 'function'; } if (is_string($handler) == false) { return false; } if (strpos($handler, '->')) { return 'method'; } if (strpos($handler, '::')) { return 'static'; } if ($handler && $this->find_handler_path($handler)) { return 'file'; } return false; }
php
private function get_handler_type($handler) { if ($handler instanceof \Closure) { return 'function'; } if (is_string($handler) == false) { return false; } if (strpos($handler, '->')) { return 'method'; } if (strpos($handler, '::')) { return 'static'; } if ($handler && $this->find_handler_path($handler)) { return 'file'; } return false; }
[ "private", "function", "get_handler_type", "(", "$", "handler", ")", "{", "if", "(", "$", "handler", "instanceof", "\\", "Closure", ")", "{", "return", "'function'", ";", "}", "if", "(", "is_string", "(", "$", "handler", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "strpos", "(", "$", "handler", ",", "'->'", ")", ")", "{", "return", "'method'", ";", "}", "if", "(", "strpos", "(", "$", "handler", ",", "'::'", ")", ")", "{", "return", "'static'", ";", "}", "if", "(", "$", "handler", "&&", "$", "this", "->", "find_handler_path", "(", "$", "handler", ")", ")", "{", "return", "'file'", ";", "}", "return", "false", ";", "}" ]
figure out how to run the given handler there are a few different handlers formats: - function: an inline function directly handling the request @note it can call handle() with a new handler of another type .. .. this might be useful for database lookups - method: a method in the format of 'class->method' the class will be instantiated before invoking the method - static: a method in the format of 'class::method' where the method will be called statically - file: a file path (relative to $handler_base_path) @see $auto_instantiation: it can instantiate a class with the same name @param mixed $handler @return string|boolean the name of the handler from above description .. .. or false when unknown
[ "figure", "out", "how", "to", "run", "the", "given", "handler" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L258-L277
16,940
lode/fem
src/routing.php
routing.load_handler_as_method
private function load_handler_as_method($handler) { list($class, $method) = explode('->', $handler); $object = new $class; $object->$method($this->url, $this->method, $this->arguments); }
php
private function load_handler_as_method($handler) { list($class, $method) = explode('->', $handler); $object = new $class; $object->$method($this->url, $this->method, $this->arguments); }
[ "private", "function", "load_handler_as_method", "(", "$", "handler", ")", "{", "list", "(", "$", "class", ",", "$", "method", ")", "=", "explode", "(", "'->'", ",", "$", "handler", ")", ";", "$", "object", "=", "new", "$", "class", ";", "$", "object", "->", "$", "method", "(", "$", "this", "->", "url", ",", "$", "this", "->", "method", ",", "$", "this", "->", "arguments", ")", ";", "}" ]
instantiated method handler @param string $handler @return void, the method is called on the object
[ "instantiated", "method", "handler" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L295-L300
16,941
lode/fem
src/routing.php
routing.load_handler_as_static
private function load_handler_as_static($handler) { list($class, $method) = explode('::', $handler); $class::$method($this->url, $this->method, $this->arguments); }
php
private function load_handler_as_static($handler) { list($class, $method) = explode('::', $handler); $class::$method($this->url, $this->method, $this->arguments); }
[ "private", "function", "load_handler_as_static", "(", "$", "handler", ")", "{", "list", "(", "$", "class", ",", "$", "method", ")", "=", "explode", "(", "'::'", ",", "$", "handler", ")", ";", "$", "class", "::", "$", "method", "(", "$", "this", "->", "url", ",", "$", "this", "->", "method", ",", "$", "this", "->", "arguments", ")", ";", "}" ]
static method handler @param string $handler @return void, the method is called on the class
[ "static", "method", "handler" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L308-L312
16,942
lode/fem
src/routing.php
routing.load_handler_as_file
private function load_handler_as_file($handler) { $path = $this->find_handler_path($handler); require_once $path; $class_name = str_replace('/', '\\', $handler); if ($this->auto_instantiation && is_callable($class_name)) { new $class_name($this->url, $this->method, $this->arguments); } }
php
private function load_handler_as_file($handler) { $path = $this->find_handler_path($handler); require_once $path; $class_name = str_replace('/', '\\', $handler); if ($this->auto_instantiation && is_callable($class_name)) { new $class_name($this->url, $this->method, $this->arguments); } }
[ "private", "function", "load_handler_as_file", "(", "$", "handler", ")", "{", "$", "path", "=", "$", "this", "->", "find_handler_path", "(", "$", "handler", ")", ";", "require_once", "$", "path", ";", "$", "class_name", "=", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "handler", ")", ";", "if", "(", "$", "this", "->", "auto_instantiation", "&&", "is_callable", "(", "$", "class_name", ")", ")", "{", "new", "$", "class_name", "(", "$", "this", "->", "url", ",", "$", "this", "->", "method", ",", "$", "this", "->", "arguments", ")", ";", "}", "}" ]
file reference handler @param string $handler @return void, the file is included a inner class is instantiated if $this->auto_instantiation is true
[ "file", "reference", "handler" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/routing.php#L321-L329
16,943
devemio/php-readable-timer
src/Timer.php
Timer.stop
public function stop() { $time = microtime(true); $this->time += $time - $this->start; $this->start = $time; return $this; }
php
public function stop() { $time = microtime(true); $this->time += $time - $this->start; $this->start = $time; return $this; }
[ "public", "function", "stop", "(", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "time", "+=", "$", "time", "-", "$", "this", "->", "start", ";", "$", "this", "->", "start", "=", "$", "time", ";", "return", "$", "this", ";", "}" ]
Stop the timer. @return $this
[ "Stop", "the", "timer", "." ]
50916b630eda07999dc6676528afe59fb2105615
https://github.com/devemio/php-readable-timer/blob/50916b630eda07999dc6676528afe59fb2105615/src/Timer.php#L60-L66
16,944
devemio/php-readable-timer
src/Timer.php
Timer.time
public function time() { $format = $this->format; $format = $this->replace('u', 6, $format); $format = $this->replace('ms', 3, $format); return gmdate($format, $this->time); }
php
public function time() { $format = $this->format; $format = $this->replace('u', 6, $format); $format = $this->replace('ms', 3, $format); return gmdate($format, $this->time); }
[ "public", "function", "time", "(", ")", "{", "$", "format", "=", "$", "this", "->", "format", ";", "$", "format", "=", "$", "this", "->", "replace", "(", "'u'", ",", "6", ",", "$", "format", ")", ";", "$", "format", "=", "$", "this", "->", "replace", "(", "'ms'", ",", "3", ",", "$", "format", ")", ";", "return", "gmdate", "(", "$", "format", ",", "$", "this", "->", "time", ")", ";", "}" ]
Return measured time. @return string
[ "Return", "measured", "time", "." ]
50916b630eda07999dc6676528afe59fb2105615
https://github.com/devemio/php-readable-timer/blob/50916b630eda07999dc6676528afe59fb2105615/src/Timer.php#L85-L94
16,945
devemio/php-readable-timer
src/Timer.php
Timer.replace
private function replace($pattern, $precision, $format) { $time = round($this->time, $precision); $value = substr(number_format($time - floor($time), $precision), 2); return str_replace($pattern, $value, $format); }
php
private function replace($pattern, $precision, $format) { $time = round($this->time, $precision); $value = substr(number_format($time - floor($time), $precision), 2); return str_replace($pattern, $value, $format); }
[ "private", "function", "replace", "(", "$", "pattern", ",", "$", "precision", ",", "$", "format", ")", "{", "$", "time", "=", "round", "(", "$", "this", "->", "time", ",", "$", "precision", ")", ";", "$", "value", "=", "substr", "(", "number_format", "(", "$", "time", "-", "floor", "(", "$", "time", ")", ",", "$", "precision", ")", ",", "2", ")", ";", "return", "str_replace", "(", "$", "pattern", ",", "$", "value", ",", "$", "format", ")", ";", "}" ]
Replace the date format with calculated values. @param string $pattern @param int $precision @param string $format @return string
[ "Replace", "the", "date", "format", "with", "calculated", "values", "." ]
50916b630eda07999dc6676528afe59fb2105615
https://github.com/devemio/php-readable-timer/blob/50916b630eda07999dc6676528afe59fb2105615/src/Timer.php#L104-L109
16,946
lmammino/e-foundation
src/Attribute/Model/AttributeSubjectTrait.php
AttributeSubjectTrait.setAttributesValues
public function setAttributesValues(Collection $attributesValues) { foreach ($attributesValues as $attributeValue) { $this->addAttributeValue($attributeValue); } return $this; }
php
public function setAttributesValues(Collection $attributesValues) { foreach ($attributesValues as $attributeValue) { $this->addAttributeValue($attributeValue); } return $this; }
[ "public", "function", "setAttributesValues", "(", "Collection", "$", "attributesValues", ")", "{", "foreach", "(", "$", "attributesValues", "as", "$", "attributeValue", ")", "{", "$", "this", "->", "addAttributeValue", "(", "$", "attributeValue", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the attribute values @param Collection $attributesValues @return $this
[ "Set", "the", "attribute", "values" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Attribute/Model/AttributeSubjectTrait.php#L45-L52
16,947
lmammino/e-foundation
src/Attribute/Model/AttributeSubjectTrait.php
AttributeSubjectTrait.addAttributeValue
public function addAttributeValue(AttributeValueInterface $attributeValue) { if (!$this->attributeValues->contains($attributeValue)) { $attributeValue->setSubject($this); $this->attributeValues->add($attributeValue); } return $this; }
php
public function addAttributeValue(AttributeValueInterface $attributeValue) { if (!$this->attributeValues->contains($attributeValue)) { $attributeValue->setSubject($this); $this->attributeValues->add($attributeValue); } return $this; }
[ "public", "function", "addAttributeValue", "(", "AttributeValueInterface", "$", "attributeValue", ")", "{", "if", "(", "!", "$", "this", "->", "attributeValues", "->", "contains", "(", "$", "attributeValue", ")", ")", "{", "$", "attributeValue", "->", "setSubject", "(", "$", "this", ")", ";", "$", "this", "->", "attributeValues", "->", "add", "(", "$", "attributeValue", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add an attribute value @param AttributeValueInterface $attributeValue @return $this
[ "Add", "an", "attribute", "value" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Attribute/Model/AttributeSubjectTrait.php#L61-L69
16,948
lmammino/e-foundation
src/Attribute/Model/AttributeSubjectTrait.php
AttributeSubjectTrait.removeAttributeValue
public function removeAttributeValue(AttributeValueInterface $attributeValue) { if ($this->attributeValues->contains($attributeValue)) { $attributeValue->setSubject(null); $this->attributeValues->removeElement($attributeValue); } return $this; }
php
public function removeAttributeValue(AttributeValueInterface $attributeValue) { if ($this->attributeValues->contains($attributeValue)) { $attributeValue->setSubject(null); $this->attributeValues->removeElement($attributeValue); } return $this; }
[ "public", "function", "removeAttributeValue", "(", "AttributeValueInterface", "$", "attributeValue", ")", "{", "if", "(", "$", "this", "->", "attributeValues", "->", "contains", "(", "$", "attributeValue", ")", ")", "{", "$", "attributeValue", "->", "setSubject", "(", "null", ")", ";", "$", "this", "->", "attributeValues", "->", "removeElement", "(", "$", "attributeValue", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove an attribute value @param AttributeValueInterface $attributeValue @return $this
[ "Remove", "an", "attribute", "value" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Attribute/Model/AttributeSubjectTrait.php#L78-L86
16,949
lmammino/e-foundation
src/Attribute/Model/AttributeSubjectTrait.php
AttributeSubjectTrait.hasAttributeValueByName
public function hasAttributeValueByName($attributeValueName) { /** @var AttributeValueInterface $attributeValue */ foreach ($this->attributeValues as $attributeValue) { if ($attributeValue->getAttributeName() == $attributeValueName) { return true; } } return false; }
php
public function hasAttributeValueByName($attributeValueName) { /** @var AttributeValueInterface $attributeValue */ foreach ($this->attributeValues as $attributeValue) { if ($attributeValue->getAttributeName() == $attributeValueName) { return true; } } return false; }
[ "public", "function", "hasAttributeValueByName", "(", "$", "attributeValueName", ")", "{", "/** @var AttributeValueInterface $attributeValue */", "foreach", "(", "$", "this", "->", "attributeValues", "as", "$", "attributeValue", ")", "{", "if", "(", "$", "attributeValue", "->", "getAttributeName", "(", ")", "==", "$", "attributeValueName", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if has an attribute value that matches a given name @param string $attributeValueName @return boolean
[ "Check", "if", "has", "an", "attribute", "value", "that", "matches", "a", "given", "name" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Attribute/Model/AttributeSubjectTrait.php#L107-L117
16,950
lmammino/e-foundation
src/Attribute/Model/AttributeSubjectTrait.php
AttributeSubjectTrait.getAttributeValueByName
public function getAttributeValueByName($attributeValueName) { /** @var AttributeValueInterface $attributeValue */ foreach ($this->attributeValues as $attributeValue) { if ($attributeValue->getAttributeName() == $attributeValueName) { return $attributeValue; } } return null; }
php
public function getAttributeValueByName($attributeValueName) { /** @var AttributeValueInterface $attributeValue */ foreach ($this->attributeValues as $attributeValue) { if ($attributeValue->getAttributeName() == $attributeValueName) { return $attributeValue; } } return null; }
[ "public", "function", "getAttributeValueByName", "(", "$", "attributeValueName", ")", "{", "/** @var AttributeValueInterface $attributeValue */", "foreach", "(", "$", "this", "->", "attributeValues", "as", "$", "attributeValue", ")", "{", "if", "(", "$", "attributeValue", "->", "getAttributeName", "(", ")", "==", "$", "attributeValueName", ")", "{", "return", "$", "attributeValue", ";", "}", "}", "return", "null", ";", "}" ]
Gets an attribute value if matches a given name or null instead @param string $attributeValueName @return AttributeValueInterface|null
[ "Gets", "an", "attribute", "value", "if", "matches", "a", "given", "name", "or", "null", "instead" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Attribute/Model/AttributeSubjectTrait.php#L126-L136
16,951
ClanCats/Core
src/classes/CCView.php
CCView.cache_path
public static function cache_path( $view ) { if ( strpos( $view, '::' ) !== false ) { list( $package, $view ) = explode( '::', $view ); } else { $package = 'app'; } return \CCStorage::path( 'views/'.$package.'/'.$view.EXT ); }
php
public static function cache_path( $view ) { if ( strpos( $view, '::' ) !== false ) { list( $package, $view ) = explode( '::', $view ); } else { $package = 'app'; } return \CCStorage::path( 'views/'.$package.'/'.$view.EXT ); }
[ "public", "static", "function", "cache_path", "(", "$", "view", ")", "{", "if", "(", "strpos", "(", "$", "view", ",", "'::'", ")", "!==", "false", ")", "{", "list", "(", "$", "package", ",", "$", "view", ")", "=", "explode", "(", "'::'", ",", "$", "view", ")", ";", "}", "else", "{", "$", "package", "=", "'app'", ";", "}", "return", "\\", "CCStorage", "::", "path", "(", "'views/'", ".", "$", "package", ".", "'/'", ".", "$", "view", ".", "EXT", ")", ";", "}" ]
Get the cache path of a view @param string $view @return string
[ "Get", "the", "cache", "path", "of", "a", "view" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L72-L84
16,952
ClanCats/Core
src/classes/CCView.php
CCView.file
public function file( $file = null ) { if ( !is_null( $file ) ) { return $this->_file = $file; } return $this->_file; }
php
public function file( $file = null ) { if ( !is_null( $file ) ) { return $this->_file = $file; } return $this->_file; }
[ "public", "function", "file", "(", "$", "file", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "file", ")", ")", "{", "return", "$", "this", "->", "_file", "=", "$", "file", ";", "}", "return", "$", "this", "->", "_file", ";", "}" ]
set or get the current file @param string $file @return string
[ "set", "or", "get", "the", "current", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L126-L134
16,953
ClanCats/Core
src/classes/CCView.php
CCView.set
public function set( $key, $value, $param = null ) { if ( $param === true ) { $value = CCStr::htmlentities( $value ); } return CCArr::set( $key, $value, $this->_data ); }
php
public function set( $key, $value, $param = null ) { if ( $param === true ) { $value = CCStr::htmlentities( $value ); } return CCArr::set( $key, $value, $this->_data ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "param", "=", "null", ")", "{", "if", "(", "$", "param", "===", "true", ")", "{", "$", "value", "=", "CCStr", "::", "htmlentities", "(", "$", "value", ")", ";", "}", "return", "CCArr", "::", "set", "(", "$", "key", ",", "$", "value", ",", "$", "this", "->", "_data", ")", ";", "}" ]
custom setter with encode ability @param string $key @param mixed $value @param mixed $param @return void
[ "custom", "setter", "with", "encode", "ability" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L144-L152
16,954
ClanCats/Core
src/classes/CCView.php
CCView.capture
public function capture( $key, $callback ) { return $this->set( $key, CCStr::capture( $callback, $this ) ); }
php
public function capture( $key, $callback ) { return $this->set( $key, CCStr::capture( $callback, $this ) ); }
[ "public", "function", "capture", "(", "$", "key", ",", "$", "callback", ")", "{", "return", "$", "this", "->", "set", "(", "$", "key", ",", "CCStr", "::", "capture", "(", "$", "callback", ",", "$", "this", ")", ")", ";", "}" ]
just like set but it can captures all output in a closure and set that. @param string $key @param callback $callback @return void
[ "just", "like", "set", "but", "it", "can", "captures", "all", "output", "in", "a", "closure", "and", "set", "that", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L162-L165
16,955
ClanCats/Core
src/classes/CCView.php
CCView.capture_append
public function capture_append( $key, $callback ) { return $this->set( $key, $this->get( $key, '' ).CCStr::capture( $callback, $this ) ); }
php
public function capture_append( $key, $callback ) { return $this->set( $key, $this->get( $key, '' ).CCStr::capture( $callback, $this ) ); }
[ "public", "function", "capture_append", "(", "$", "key", ",", "$", "callback", ")", "{", "return", "$", "this", "->", "set", "(", "$", "key", ",", "$", "this", "->", "get", "(", "$", "key", ",", "''", ")", ".", "CCStr", "::", "capture", "(", "$", "callback", ",", "$", "this", ")", ")", ";", "}" ]
just like capture but it appends @param string $key @param callback $callback @return void
[ "just", "like", "capture", "but", "it", "appends" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L174-L177
16,956
ClanCats/Core
src/classes/CCView.php
CCView.view_path
protected function view_path( $view ) { if ( isset( static::$_view_paths[$view] ) ) { return static::$_view_paths[$view]; } // view is empty? if ( is_null( $view ) ) { throw new CCException( "CCView - cannot render view without a view file." ); } // generate the views path $path = CCPath::get( $view, CCDIR_VIEW, EXT ); if ( !file_exists( $path ) ) { throw new CCException( "CCView - could not find view: ".$view." at: {$path}." ); } // does the view implement a view builder? if ( strpos( $view, '.' ) !== false ) { $cache = static::cache_path( $view ); // does the cache not exits or is out of date if ( !file_exists( $cache ) || filemtime( $cache ) < filemtime( $path ) ) { list( $view_name, $builder ) = explode( '.', $view ); $this->build_cache( $cache, $builder, $path ); } $path = $cache; } return static::$_view_paths[$view] = $path; }
php
protected function view_path( $view ) { if ( isset( static::$_view_paths[$view] ) ) { return static::$_view_paths[$view]; } // view is empty? if ( is_null( $view ) ) { throw new CCException( "CCView - cannot render view without a view file." ); } // generate the views path $path = CCPath::get( $view, CCDIR_VIEW, EXT ); if ( !file_exists( $path ) ) { throw new CCException( "CCView - could not find view: ".$view." at: {$path}." ); } // does the view implement a view builder? if ( strpos( $view, '.' ) !== false ) { $cache = static::cache_path( $view ); // does the cache not exits or is out of date if ( !file_exists( $cache ) || filemtime( $cache ) < filemtime( $path ) ) { list( $view_name, $builder ) = explode( '.', $view ); $this->build_cache( $cache, $builder, $path ); } $path = $cache; } return static::$_view_paths[$view] = $path; }
[ "protected", "function", "view_path", "(", "$", "view", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "_view_paths", "[", "$", "view", "]", ")", ")", "{", "return", "static", "::", "$", "_view_paths", "[", "$", "view", "]", ";", "}", "// view is empty?", "if", "(", "is_null", "(", "$", "view", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCView - cannot render view without a view file.\"", ")", ";", "}", "// generate the views path", "$", "path", "=", "CCPath", "::", "get", "(", "$", "view", ",", "CCDIR_VIEW", ",", "EXT", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCView - could not find view: \"", ".", "$", "view", ".", "\" at: {$path}.\"", ")", ";", "}", "// does the view implement a view builder?", "if", "(", "strpos", "(", "$", "view", ",", "'.'", ")", "!==", "false", ")", "{", "$", "cache", "=", "static", "::", "cache_path", "(", "$", "view", ")", ";", "// does the cache not exits or is out of date", "if", "(", "!", "file_exists", "(", "$", "cache", ")", "||", "filemtime", "(", "$", "cache", ")", "<", "filemtime", "(", "$", "path", ")", ")", "{", "list", "(", "$", "view_name", ",", "$", "builder", ")", "=", "explode", "(", "'.'", ",", "$", "view", ")", ";", "$", "this", "->", "build_cache", "(", "$", "cache", ",", "$", "builder", ",", "$", "path", ")", ";", "}", "$", "path", "=", "$", "cache", ";", "}", "return", "static", "::", "$", "_view_paths", "[", "$", "view", "]", "=", "$", "path", ";", "}" ]
Get the path to real view file This function will also build the cache view file if needed. @param string $path @return string
[ "Get", "the", "path", "to", "real", "view", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L198-L235
16,957
ClanCats/Core
src/classes/CCView.php
CCView.build_cache
protected function build_cache( $path, $builder, $view_path ) { CCFile::write( $path, CCView_Builder::compile( $builder, $view_path ) ); }
php
protected function build_cache( $path, $builder, $view_path ) { CCFile::write( $path, CCView_Builder::compile( $builder, $view_path ) ); }
[ "protected", "function", "build_cache", "(", "$", "path", ",", "$", "builder", ",", "$", "view_path", ")", "{", "CCFile", "::", "write", "(", "$", "path", ",", "CCView_Builder", "::", "compile", "(", "$", "builder", ",", "$", "view_path", ")", ")", ";", "}" ]
Build a view cache file @param string $path @param string $builder @param string @return void
[ "Build", "a", "view", "cache", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L246-L249
16,958
ClanCats/Core
src/classes/CCView.php
CCView.render
public function render( $file = null ) { if ( !is_null( $file ) ) { $this->file( $file ); } $path = $this->view_path( $this->file() ); // extract the view data extract( $this->_data ); // extract globals if they exists if ( !empty( static::$_globals ) ) { extract( static::$_globals, EXTR_PREFIX_SAME, 'global' ); } ob_start(); require( $path ); return ob_get_clean(); }
php
public function render( $file = null ) { if ( !is_null( $file ) ) { $this->file( $file ); } $path = $this->view_path( $this->file() ); // extract the view data extract( $this->_data ); // extract globals if they exists if ( !empty( static::$_globals ) ) { extract( static::$_globals, EXTR_PREFIX_SAME, 'global' ); } ob_start(); require( $path ); return ob_get_clean(); }
[ "public", "function", "render", "(", "$", "file", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "file", ")", ")", "{", "$", "this", "->", "file", "(", "$", "file", ")", ";", "}", "$", "path", "=", "$", "this", "->", "view_path", "(", "$", "this", "->", "file", "(", ")", ")", ";", "// extract the view data", "extract", "(", "$", "this", "->", "_data", ")", ";", "// extract globals if they exists", "if", "(", "!", "empty", "(", "static", "::", "$", "_globals", ")", ")", "{", "extract", "(", "static", "::", "$", "_globals", ",", "EXTR_PREFIX_SAME", ",", "'global'", ")", ";", "}", "ob_start", "(", ")", ";", "require", "(", "$", "path", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Render the view and return the output. @param string $file @return string
[ "Render", "the", "view", "and", "return", "the", "output", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView.php#L257-L280
16,959
boekkooi/tactician-amqp
src/ExchangeLocator/InMemoryLocator.php
InMemoryLocator.addExchanges
protected function addExchanges(array $commandClassToHandlerMap) { foreach ($commandClassToHandlerMap as $messageClass => $handler) { $this->addExchange($handler, $messageClass); } }
php
protected function addExchanges(array $commandClassToHandlerMap) { foreach ($commandClassToHandlerMap as $messageClass => $handler) { $this->addExchange($handler, $messageClass); } }
[ "protected", "function", "addExchanges", "(", "array", "$", "commandClassToHandlerMap", ")", "{", "foreach", "(", "$", "commandClassToHandlerMap", "as", "$", "messageClass", "=>", "$", "handler", ")", "{", "$", "this", "->", "addExchange", "(", "$", "handler", ",", "$", "messageClass", ")", ";", "}", "}" ]
Allows you to add multiple exchanges at once. The map should be an array in the format of: [ AddTaskCommand::class => $someAMQPExchangeInstance, CompleteTaskCommand::class => $someAMQPExchangeInstance, ] @param array $commandClassToHandlerMap
[ "Allows", "you", "to", "add", "multiple", "exchanges", "at", "once", "." ]
55cbb8b9e20aab7891e6a6090b248377c599360e
https://github.com/boekkooi/tactician-amqp/blob/55cbb8b9e20aab7891e6a6090b248377c599360e/src/ExchangeLocator/InMemoryLocator.php#L44-L49
16,960
lmammino/e-foundation
src/Price/Model/AdjustableTrait.php
AdjustableTrait.removeAdjustment
public function removeAdjustment(AdjustmentInterface $adjustment) { if ($this->hasAdjustment($adjustment)) { $this->adjustmentsTotal = null; $adjustment->setAdjustable(null); $this->adjustments->removeElement($adjustment); } return $this; }
php
public function removeAdjustment(AdjustmentInterface $adjustment) { if ($this->hasAdjustment($adjustment)) { $this->adjustmentsTotal = null; $adjustment->setAdjustable(null); $this->adjustments->removeElement($adjustment); } return $this; }
[ "public", "function", "removeAdjustment", "(", "AdjustmentInterface", "$", "adjustment", ")", "{", "if", "(", "$", "this", "->", "hasAdjustment", "(", "$", "adjustment", ")", ")", "{", "$", "this", "->", "adjustmentsTotal", "=", "null", ";", "$", "adjustment", "->", "setAdjustable", "(", "null", ")", ";", "$", "this", "->", "adjustments", "->", "removeElement", "(", "$", "adjustment", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes a given adjustment @param AdjustmentInterface $adjustment @return $this
[ "Removes", "a", "given", "adjustment" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/AdjustableTrait.php#L99-L108
16,961
lmammino/e-foundation
src/Price/Model/AdjustableTrait.php
AdjustableTrait.removeAdjustmentByLabel
public function removeAdjustmentByLabel($adjustmentLabel) { /** @var AdjustmentInterface $adjustment */ foreach ($this->adjustments as $adjustment) { if ($adjustmentLabel == $adjustment->getLabel()) { $this->removeAdjustment($adjustment); return $this; } } return $this; }
php
public function removeAdjustmentByLabel($adjustmentLabel) { /** @var AdjustmentInterface $adjustment */ foreach ($this->adjustments as $adjustment) { if ($adjustmentLabel == $adjustment->getLabel()) { $this->removeAdjustment($adjustment); return $this; } } return $this; }
[ "public", "function", "removeAdjustmentByLabel", "(", "$", "adjustmentLabel", ")", "{", "/** @var AdjustmentInterface $adjustment */", "foreach", "(", "$", "this", "->", "adjustments", "as", "$", "adjustment", ")", "{", "if", "(", "$", "adjustmentLabel", "==", "$", "adjustment", "->", "getLabel", "(", ")", ")", "{", "$", "this", "->", "removeAdjustment", "(", "$", "adjustment", ")", ";", "return", "$", "this", ";", "}", "}", "return", "$", "this", ";", "}" ]
Removes an adjustment by label @param string $adjustmentLabel @return $this
[ "Removes", "an", "adjustment", "by", "label" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/AdjustableTrait.php#L116-L127
16,962
lmammino/e-foundation
src/Price/Model/AdjustableTrait.php
AdjustableTrait.calculateAdjustmentsTotal
public function calculateAdjustmentsTotal() { $this->adjustmentsTotal = 0; foreach ($this->adjustments as $adjustment) { if (!$adjustment->isNeutral()) { $this->adjustmentsTotal += $adjustment->getAmount(); } } return $this; }
php
public function calculateAdjustmentsTotal() { $this->adjustmentsTotal = 0; foreach ($this->adjustments as $adjustment) { if (!$adjustment->isNeutral()) { $this->adjustmentsTotal += $adjustment->getAmount(); } } return $this; }
[ "public", "function", "calculateAdjustmentsTotal", "(", ")", "{", "$", "this", "->", "adjustmentsTotal", "=", "0", ";", "foreach", "(", "$", "this", "->", "adjustments", "as", "$", "adjustment", ")", "{", "if", "(", "!", "$", "adjustment", "->", "isNeutral", "(", ")", ")", "{", "$", "this", "->", "adjustmentsTotal", "+=", "$", "adjustment", "->", "getAmount", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Recalculates the adjustment amount @return $this
[ "Recalculates", "the", "adjustment", "amount" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/AdjustableTrait.php#L158-L169
16,963
askupasoftware/amarkal
Assets/Stylesheet.php
Stylesheet.register
public function register() { wp_register_style( $this->handle, $this->url, $this->dependencies, $this->version, $this->media ); $this->is_registered = true; }
php
public function register() { wp_register_style( $this->handle, $this->url, $this->dependencies, $this->version, $this->media ); $this->is_registered = true; }
[ "public", "function", "register", "(", ")", "{", "wp_register_style", "(", "$", "this", "->", "handle", ",", "$", "this", "->", "url", ",", "$", "this", "->", "dependencies", ",", "$", "this", "->", "version", ",", "$", "this", "->", "media", ")", ";", "$", "this", "->", "is_registered", "=", "true", ";", "}" ]
Register the stylesheet.
[ "Register", "the", "stylesheet", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Assets/Stylesheet.php#L31-L41
16,964
amostajo/wordpress-plugin-core
src/psr4/Plugin.php
Plugin.autoload_init
public function autoload_init() { $this->init(); // Addons for ( $i = count( $this->addons ) - 1; $i >= 0; --$i ) { $this->addons[$i]->init(); } }
php
public function autoload_init() { $this->init(); // Addons for ( $i = count( $this->addons ) - 1; $i >= 0; --$i ) { $this->addons[$i]->init(); } }
[ "public", "function", "autoload_init", "(", ")", "{", "$", "this", "->", "init", "(", ")", ";", "// Addons", "for", "(", "$", "i", "=", "count", "(", "$", "this", "->", "addons", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "--", "$", "i", ")", "{", "$", "this", "->", "addons", "[", "$", "i", "]", "->", "init", "(", ")", ";", "}", "}" ]
Called by autoload to init class. @since 1.2 @return void
[ "Called", "by", "autoload", "to", "init", "class", "." ]
63aba30b07057df540c3af4dc50b92bd5501d6fd
https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Plugin.php#L209-L216
16,965
amostajo/wordpress-plugin-core
src/psr4/Plugin.php
Plugin.autoload_on_admin
public function autoload_on_admin() { $this->on_admin(); // Addons for ( $i = count( $this->addons ) - 1; $i >= 0; --$i ) { $this->addons[$i]->on_admin(); } }
php
public function autoload_on_admin() { $this->on_admin(); // Addons for ( $i = count( $this->addons ) - 1; $i >= 0; --$i ) { $this->addons[$i]->on_admin(); } }
[ "public", "function", "autoload_on_admin", "(", ")", "{", "$", "this", "->", "on_admin", "(", ")", ";", "// Addons", "for", "(", "$", "i", "=", "count", "(", "$", "this", "->", "addons", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "--", "$", "i", ")", "{", "$", "this", "->", "addons", "[", "$", "i", "]", "->", "on_admin", "(", ")", ";", "}", "}" ]
Called by autoload to init on admin. @since 1.2 @return void
[ "Called", "by", "autoload", "to", "init", "on", "admin", "." ]
63aba30b07057df540c3af4dc50b92bd5501d6fd
https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Plugin.php#L223-L230
16,966
amostajo/wordpress-plugin-core
src/psr4/Plugin.php
Plugin.add_hooks
public function add_hooks() { if ( function_exists( 'add_action' ) && function_exists( 'add_filter' ) && function_exists( 'add_shortcode' ) ) { // Actions foreach ( $this->actions as $action ) { add_action( $action['hook'], [ &$this, $this->get_mapped_mvc_call( $action['mvc'] ) ], $action['priority'], $action['args'] ); } // Filters foreach ( $this->filters as $filter ) { add_filter( $filter['hook'], [ &$this, $this->get_mapped_mvc_call( $filter['mvc'], true ) ], $filter['priority'], $filter['args'] ); } // Filters foreach ( $this->shortcodes as $shortcode ) { add_shortcode( $shortcode['tag'], [ &$this, $this->get_mapped_mvc_call( $shortcode['mvc'], true ) ] ); } // Widgets if ( count( $this->widgets ) > 0 ) { add_action( 'widgets_init', [ &$this, '_widgets' ], 1 ); } } }
php
public function add_hooks() { if ( function_exists( 'add_action' ) && function_exists( 'add_filter' ) && function_exists( 'add_shortcode' ) ) { // Actions foreach ( $this->actions as $action ) { add_action( $action['hook'], [ &$this, $this->get_mapped_mvc_call( $action['mvc'] ) ], $action['priority'], $action['args'] ); } // Filters foreach ( $this->filters as $filter ) { add_filter( $filter['hook'], [ &$this, $this->get_mapped_mvc_call( $filter['mvc'], true ) ], $filter['priority'], $filter['args'] ); } // Filters foreach ( $this->shortcodes as $shortcode ) { add_shortcode( $shortcode['tag'], [ &$this, $this->get_mapped_mvc_call( $shortcode['mvc'], true ) ] ); } // Widgets if ( count( $this->widgets ) > 0 ) { add_action( 'widgets_init', [ &$this, '_widgets' ], 1 ); } } }
[ "public", "function", "add_hooks", "(", ")", "{", "if", "(", "function_exists", "(", "'add_action'", ")", "&&", "function_exists", "(", "'add_filter'", ")", "&&", "function_exists", "(", "'add_shortcode'", ")", ")", "{", "// Actions", "foreach", "(", "$", "this", "->", "actions", "as", "$", "action", ")", "{", "add_action", "(", "$", "action", "[", "'hook'", "]", ",", "[", "&", "$", "this", ",", "$", "this", "->", "get_mapped_mvc_call", "(", "$", "action", "[", "'mvc'", "]", ")", "]", ",", "$", "action", "[", "'priority'", "]", ",", "$", "action", "[", "'args'", "]", ")", ";", "}", "// Filters", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "add_filter", "(", "$", "filter", "[", "'hook'", "]", ",", "[", "&", "$", "this", ",", "$", "this", "->", "get_mapped_mvc_call", "(", "$", "filter", "[", "'mvc'", "]", ",", "true", ")", "]", ",", "$", "filter", "[", "'priority'", "]", ",", "$", "filter", "[", "'args'", "]", ")", ";", "}", "// Filters", "foreach", "(", "$", "this", "->", "shortcodes", "as", "$", "shortcode", ")", "{", "add_shortcode", "(", "$", "shortcode", "[", "'tag'", "]", ",", "[", "&", "$", "this", ",", "$", "this", "->", "get_mapped_mvc_call", "(", "$", "shortcode", "[", "'mvc'", "]", ",", "true", ")", "]", ")", ";", "}", "// Widgets", "if", "(", "count", "(", "$", "this", "->", "widgets", ")", ">", "0", ")", "{", "add_action", "(", "'widgets_init'", ",", "[", "&", "$", "this", ",", "'_widgets'", "]", ",", "1", ")", ";", "}", "}", "}" ]
Adds hooks and filters into Wordpress core. @since 1.3
[ "Adds", "hooks", "and", "filters", "into", "Wordpress", "core", "." ]
63aba30b07057df540c3af4dc50b92bd5501d6fd
https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Plugin.php#L325-L361
16,967
steeffeen/FancyManiaLinks
FML/Controls/Label.php
Label.addClockFeature
public function addClockFeature($showSeconds = true, $showFullDate = false) { $clock = new Clock($this, $showSeconds, $showFullDate); $this->addScriptFeature($clock); return $this; }
php
public function addClockFeature($showSeconds = true, $showFullDate = false) { $clock = new Clock($this, $showSeconds, $showFullDate); $this->addScriptFeature($clock); return $this; }
[ "public", "function", "addClockFeature", "(", "$", "showSeconds", "=", "true", ",", "$", "showFullDate", "=", "false", ")", "{", "$", "clock", "=", "new", "Clock", "(", "$", "this", ",", "$", "showSeconds", ",", "$", "showFullDate", ")", ";", "$", "this", "->", "addScriptFeature", "(", "$", "clock", ")", ";", "return", "$", "this", ";", "}" ]
Add a dynamic Feature showing the current time @api @param bool $showSeconds (optional) If the seconds should be shown @param bool $showFullDate (optional) If the date should be shown @return static
[ "Add", "a", "dynamic", "Feature", "showing", "the", "current", "time" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Label.php#L604-L609
16,968
dreamfactorysoftware/df-file
src/Services/BaseFileService.php
BaseFileService.handlePATCH
protected function handlePATCH() { $content = $this->getPayloadData(); if (empty($this->folderPath)) { // update container properties $this->driver->updateContainerProperties($this->container, $content); } else { if (empty($this->filePath)) { // update folder properties $this->driver->updateFolderProperties($this->container, $this->folderPath, $content); } else { // update file properties? $this->driver->updateFileProperties($this->container, $this->filePath, $content); } } return ResponseFactory::create(['success' => true]); }
php
protected function handlePATCH() { $content = $this->getPayloadData(); if (empty($this->folderPath)) { // update container properties $this->driver->updateContainerProperties($this->container, $content); } else { if (empty($this->filePath)) { // update folder properties $this->driver->updateFolderProperties($this->container, $this->folderPath, $content); } else { // update file properties? $this->driver->updateFileProperties($this->container, $this->filePath, $content); } } return ResponseFactory::create(['success' => true]); }
[ "protected", "function", "handlePATCH", "(", ")", "{", "$", "content", "=", "$", "this", "->", "getPayloadData", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "folderPath", ")", ")", "{", "// update container properties", "$", "this", "->", "driver", "->", "updateContainerProperties", "(", "$", "this", "->", "container", ",", "$", "content", ")", ";", "}", "else", "{", "if", "(", "empty", "(", "$", "this", "->", "filePath", ")", ")", "{", "// update folder properties", "$", "this", "->", "driver", "->", "updateFolderProperties", "(", "$", "this", "->", "container", ",", "$", "this", "->", "folderPath", ",", "$", "content", ")", ";", "}", "else", "{", "// update file properties?", "$", "this", "->", "driver", "->", "updateFileProperties", "(", "$", "this", "->", "container", ",", "$", "this", "->", "filePath", ",", "$", "content", ")", ";", "}", "}", "return", "ResponseFactory", "::", "create", "(", "[", "'success'", "=>", "true", "]", ")", ";", "}" ]
Handles PATCH actions. @return \DreamFactory\Core\Utility\ServiceResponse
[ "Handles", "PATCH", "actions", "." ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Services/BaseFileService.php#L569-L586
16,969
dreamfactorysoftware/df-file
src/Services/BaseFileService.php
BaseFileService.handleDELETE
protected function handleDELETE() { $force = $this->request->getParameterAsBool('force', false); $noCheck = $this->request->getParameterAsBool('no_check', false); $contentOnly = $this->request->getParameterAsBool('content_only', false); if (empty($this->folderPath)) { // delete just folders and files from the container if (!empty($content = ResourcesWrapper::unwrapResources($this->request->getPayloadData()))) { $result = $this->deleteFolderContent($content, '', $force); } else { throw new BadRequestException('No resources given for delete.'); } } else { if (empty($this->filePath)) { // delete directory of files and the directory itself // multi-file or folder delete via post data if (!empty($content = ResourcesWrapper::unwrapResources($this->request->getPayloadData()))) { $result = $this->deleteFolderContent($content, $this->folderPath, $force); } else { $this->driver->deleteFolder($this->container, $this->folderPath, $force, $contentOnly); $result = ['name' => basename($this->folderPath), 'path' => $this->folderPath]; } } else { // delete file from permanent storage $this->driver->deleteFile($this->container, $this->filePath, $noCheck); $result = ['name' => basename($this->filePath), 'path' => $this->filePath]; } } return ResponseFactory::create(ResourcesWrapper::cleanResources($result)); }
php
protected function handleDELETE() { $force = $this->request->getParameterAsBool('force', false); $noCheck = $this->request->getParameterAsBool('no_check', false); $contentOnly = $this->request->getParameterAsBool('content_only', false); if (empty($this->folderPath)) { // delete just folders and files from the container if (!empty($content = ResourcesWrapper::unwrapResources($this->request->getPayloadData()))) { $result = $this->deleteFolderContent($content, '', $force); } else { throw new BadRequestException('No resources given for delete.'); } } else { if (empty($this->filePath)) { // delete directory of files and the directory itself // multi-file or folder delete via post data if (!empty($content = ResourcesWrapper::unwrapResources($this->request->getPayloadData()))) { $result = $this->deleteFolderContent($content, $this->folderPath, $force); } else { $this->driver->deleteFolder($this->container, $this->folderPath, $force, $contentOnly); $result = ['name' => basename($this->folderPath), 'path' => $this->folderPath]; } } else { // delete file from permanent storage $this->driver->deleteFile($this->container, $this->filePath, $noCheck); $result = ['name' => basename($this->filePath), 'path' => $this->filePath]; } } return ResponseFactory::create(ResourcesWrapper::cleanResources($result)); }
[ "protected", "function", "handleDELETE", "(", ")", "{", "$", "force", "=", "$", "this", "->", "request", "->", "getParameterAsBool", "(", "'force'", ",", "false", ")", ";", "$", "noCheck", "=", "$", "this", "->", "request", "->", "getParameterAsBool", "(", "'no_check'", ",", "false", ")", ";", "$", "contentOnly", "=", "$", "this", "->", "request", "->", "getParameterAsBool", "(", "'content_only'", ",", "false", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "folderPath", ")", ")", "{", "// delete just folders and files from the container", "if", "(", "!", "empty", "(", "$", "content", "=", "ResourcesWrapper", "::", "unwrapResources", "(", "$", "this", "->", "request", "->", "getPayloadData", "(", ")", ")", ")", ")", "{", "$", "result", "=", "$", "this", "->", "deleteFolderContent", "(", "$", "content", ",", "''", ",", "$", "force", ")", ";", "}", "else", "{", "throw", "new", "BadRequestException", "(", "'No resources given for delete.'", ")", ";", "}", "}", "else", "{", "if", "(", "empty", "(", "$", "this", "->", "filePath", ")", ")", "{", "// delete directory of files and the directory itself", "// multi-file or folder delete via post data", "if", "(", "!", "empty", "(", "$", "content", "=", "ResourcesWrapper", "::", "unwrapResources", "(", "$", "this", "->", "request", "->", "getPayloadData", "(", ")", ")", ")", ")", "{", "$", "result", "=", "$", "this", "->", "deleteFolderContent", "(", "$", "content", ",", "$", "this", "->", "folderPath", ",", "$", "force", ")", ";", "}", "else", "{", "$", "this", "->", "driver", "->", "deleteFolder", "(", "$", "this", "->", "container", ",", "$", "this", "->", "folderPath", ",", "$", "force", ",", "$", "contentOnly", ")", ";", "$", "result", "=", "[", "'name'", "=>", "basename", "(", "$", "this", "->", "folderPath", ")", ",", "'path'", "=>", "$", "this", "->", "folderPath", "]", ";", "}", "}", "else", "{", "// delete file from permanent storage", "$", "this", "->", "driver", "->", "deleteFile", "(", "$", "this", "->", "container", ",", "$", "this", "->", "filePath", ",", "$", "noCheck", ")", ";", "$", "result", "=", "[", "'name'", "=>", "basename", "(", "$", "this", "->", "filePath", ")", ",", "'path'", "=>", "$", "this", "->", "filePath", "]", ";", "}", "}", "return", "ResponseFactory", "::", "create", "(", "ResourcesWrapper", "::", "cleanResources", "(", "$", "result", ")", ")", ";", "}" ]
Handles DELETE actions. @return \DreamFactory\Core\Utility\ServiceResponse @throws BadRequestException
[ "Handles", "DELETE", "actions", "." ]
e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Services/BaseFileService.php#L594-L625
16,970
slashworks/control-bundle
src/Slashworks/BackendBundle/Helper/InstallHelper.php
InstallHelper.resetAsseticConfig
private static function resetAsseticConfig() { return; /** * dev */ $aYaml = Yaml::parse(file_get_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_dev.yml')); $aYaml['assetic']['use_controller'] = false; $sNewYaml = Yaml::dump($aYaml, 5); file_put_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_dev.yml', $sNewYaml); /** * prod */ $aYaml = Yaml::parse(file_get_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_prod.yml')); $aYaml['assetic']['use_controller'] = false; $sNewYaml = Yaml::dump($aYaml, 5); file_put_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_prod.yml', $sNewYaml); }
php
private static function resetAsseticConfig() { return; /** * dev */ $aYaml = Yaml::parse(file_get_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_dev.yml')); $aYaml['assetic']['use_controller'] = false; $sNewYaml = Yaml::dump($aYaml, 5); file_put_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_dev.yml', $sNewYaml); /** * prod */ $aYaml = Yaml::parse(file_get_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_prod.yml')); $aYaml['assetic']['use_controller'] = false; $sNewYaml = Yaml::dump($aYaml, 5); file_put_contents(self::$_container->get('kernel')->getRootDir() . '/config/config_prod.yml', $sNewYaml); }
[ "private", "static", "function", "resetAsseticConfig", "(", ")", "{", "return", ";", "/**\n * dev\n */", "$", "aYaml", "=", "Yaml", "::", "parse", "(", "file_get_contents", "(", "self", "::", "$", "_container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ".", "'/config/config_dev.yml'", ")", ")", ";", "$", "aYaml", "[", "'assetic'", "]", "[", "'use_controller'", "]", "=", "false", ";", "$", "sNewYaml", "=", "Yaml", "::", "dump", "(", "$", "aYaml", ",", "5", ")", ";", "file_put_contents", "(", "self", "::", "$", "_container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ".", "'/config/config_dev.yml'", ",", "$", "sNewYaml", ")", ";", "/**\n * prod\n */", "$", "aYaml", "=", "Yaml", "::", "parse", "(", "file_get_contents", "(", "self", "::", "$", "_container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ".", "'/config/config_prod.yml'", ")", ")", ";", "$", "aYaml", "[", "'assetic'", "]", "[", "'use_controller'", "]", "=", "false", ";", "$", "sNewYaml", "=", "Yaml", "::", "dump", "(", "$", "aYaml", ",", "5", ")", ";", "file_put_contents", "(", "self", "::", "$", "_container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ".", "'/config/config_prod.yml'", ",", "$", "sNewYaml", ")", ";", "}" ]
reset assitx-config not to use controller
[ "reset", "assitx", "-", "config", "not", "to", "use", "controller" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Helper/InstallHelper.php#L99-L120
16,971
slashworks/control-bundle
src/Slashworks/BackendBundle/Helper/InstallHelper.php
InstallHelper._saveControlUrl
private static function _saveControlUrl() { $oStatement = self::$_connection->prepare('INSERT INTO `system_settings` (`key` ,`value`)VALUES (:key, :value);'); $oResult = $oStatement->execute(array( ":key" => "control_url", ":value" => self::$_data['controlUrl'], )); if ($oResult !== true) { throw new Exception("Error while inserting control url"); } $oStatement = self::$_connection->prepare('INSERT INTO `license` (`id`, `max_clients`, `domain`, `serial`, `valid_until`) VALUES (null, 0, :control_url , \'\', 0);'); $oResult = $oStatement->execute(array( ":control_url" => self::$_data['controlUrl'], )); }
php
private static function _saveControlUrl() { $oStatement = self::$_connection->prepare('INSERT INTO `system_settings` (`key` ,`value`)VALUES (:key, :value);'); $oResult = $oStatement->execute(array( ":key" => "control_url", ":value" => self::$_data['controlUrl'], )); if ($oResult !== true) { throw new Exception("Error while inserting control url"); } $oStatement = self::$_connection->prepare('INSERT INTO `license` (`id`, `max_clients`, `domain`, `serial`, `valid_until`) VALUES (null, 0, :control_url , \'\', 0);'); $oResult = $oStatement->execute(array( ":control_url" => self::$_data['controlUrl'], )); }
[ "private", "static", "function", "_saveControlUrl", "(", ")", "{", "$", "oStatement", "=", "self", "::", "$", "_connection", "->", "prepare", "(", "'INSERT INTO `system_settings` (`key` ,`value`)VALUES (:key, :value);'", ")", ";", "$", "oResult", "=", "$", "oStatement", "->", "execute", "(", "array", "(", "\":key\"", "=>", "\"control_url\"", ",", "\":value\"", "=>", "self", "::", "$", "_data", "[", "'controlUrl'", "]", ",", ")", ")", ";", "if", "(", "$", "oResult", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "\"Error while inserting control url\"", ")", ";", "}", "$", "oStatement", "=", "self", "::", "$", "_connection", "->", "prepare", "(", "'INSERT INTO `license` (`id`, `max_clients`, `domain`, `serial`, `valid_until`) VALUES (null, 0, :control_url , \\'\\', 0);'", ")", ";", "$", "oResult", "=", "$", "oStatement", "->", "execute", "(", "array", "(", "\":control_url\"", "=>", "self", "::", "$", "_data", "[", "'controlUrl'", "]", ",", ")", ")", ";", "}" ]
save control-url to database
[ "save", "control", "-", "url", "to", "database" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Helper/InstallHelper.php#L184-L204
16,972
slashworks/control-bundle
src/Slashworks/BackendBundle/Helper/InstallHelper.php
InstallHelper._saveSystemConfig
private static function _saveSystemConfig() { $sYmlDump = array( 'parameters' => array( 'database_driver' => self::checkEmpty(self::$_data['dbDriver']), 'database_host' => self::checkEmpty(self::$_data['dbHost']), 'database_port' => self::checkEmpty(self::$_data['dbPort']), 'database_name' => self::checkEmpty(self::$_data['dbName']), 'database_user' => self::checkEmpty(self::$_data['dbUser']), 'database_password' => self::checkEmpty(self::$_data['dbPassword']), 'mailer_transport' => self::checkEmpty(self::$_data['mailerTransport']), 'mailer_host' => self::checkEmpty(self::$_data['mailerHost']), 'mailer_user' => self::checkEmpty(self::$_data['mailerUser']), 'mailer_password' => self::checkEmpty(self::$_data['mailerPassword']), 'locale' => 'de', 'secret' => md5(uniqid(null, true)), ), ); $oDumper = new Dumper(); $sYaml = $oDumper->dump($sYmlDump, 99, 0, true, false); $sAppPath = self::$_container->get('kernel')->getRootDir(); $sPath = $sAppPath. '/config/parameters.yml'; $sYaml = str_replace("'", '', $sYaml); file_put_contents($sPath, $sYaml); }
php
private static function _saveSystemConfig() { $sYmlDump = array( 'parameters' => array( 'database_driver' => self::checkEmpty(self::$_data['dbDriver']), 'database_host' => self::checkEmpty(self::$_data['dbHost']), 'database_port' => self::checkEmpty(self::$_data['dbPort']), 'database_name' => self::checkEmpty(self::$_data['dbName']), 'database_user' => self::checkEmpty(self::$_data['dbUser']), 'database_password' => self::checkEmpty(self::$_data['dbPassword']), 'mailer_transport' => self::checkEmpty(self::$_data['mailerTransport']), 'mailer_host' => self::checkEmpty(self::$_data['mailerHost']), 'mailer_user' => self::checkEmpty(self::$_data['mailerUser']), 'mailer_password' => self::checkEmpty(self::$_data['mailerPassword']), 'locale' => 'de', 'secret' => md5(uniqid(null, true)), ), ); $oDumper = new Dumper(); $sYaml = $oDumper->dump($sYmlDump, 99, 0, true, false); $sAppPath = self::$_container->get('kernel')->getRootDir(); $sPath = $sAppPath. '/config/parameters.yml'; $sYaml = str_replace("'", '', $sYaml); file_put_contents($sPath, $sYaml); }
[ "private", "static", "function", "_saveSystemConfig", "(", ")", "{", "$", "sYmlDump", "=", "array", "(", "'parameters'", "=>", "array", "(", "'database_driver'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbDriver'", "]", ")", ",", "'database_host'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbHost'", "]", ")", ",", "'database_port'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbPort'", "]", ")", ",", "'database_name'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbName'", "]", ")", ",", "'database_user'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbUser'", "]", ")", ",", "'database_password'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'dbPassword'", "]", ")", ",", "'mailer_transport'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'mailerTransport'", "]", ")", ",", "'mailer_host'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'mailerHost'", "]", ")", ",", "'mailer_user'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'mailerUser'", "]", ")", ",", "'mailer_password'", "=>", "self", "::", "checkEmpty", "(", "self", "::", "$", "_data", "[", "'mailerPassword'", "]", ")", ",", "'locale'", "=>", "'de'", ",", "'secret'", "=>", "md5", "(", "uniqid", "(", "null", ",", "true", ")", ")", ",", ")", ",", ")", ";", "$", "oDumper", "=", "new", "Dumper", "(", ")", ";", "$", "sYaml", "=", "$", "oDumper", "->", "dump", "(", "$", "sYmlDump", ",", "99", ",", "0", ",", "true", ",", "false", ")", ";", "$", "sAppPath", "=", "self", "::", "$", "_container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ";", "$", "sPath", "=", "$", "sAppPath", ".", "'/config/parameters.yml'", ";", "$", "sYaml", "=", "str_replace", "(", "\"'\"", ",", "''", ",", "$", "sYaml", ")", ";", "file_put_contents", "(", "$", "sPath", ",", "$", "sYaml", ")", ";", "}" ]
save systemconfig to parameters.yml
[ "save", "systemconfig", "to", "parameters", ".", "yml" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Helper/InstallHelper.php#L210-L237
16,973
slashworks/control-bundle
src/Slashworks/BackendBundle/Helper/InstallHelper.php
InstallHelper._createAdminUser
private static function _createAdminUser() { $oUser = new User(); $factory = self::$_container->get('security.encoder_factory'); $encoder = $factory->getEncoder($oUser); $sSalt = $oUser->getSalt(); $sPassword = $encoder->encodePassword(self::$_data['adminPassword'], $sSalt); $oStatement = self::$_connection->prepare('INSERT INTO `user` (`id`, `username`, `password`, `salt`, `firstname`, `lastname`, `email`, `phone`, `memo`, `activated`, `last_login`, `notification_change`, `notification_error`) VALUES (null, :adminUser, :adminPassword , :adminPasswordSalt, \'admin\', \'admin\', :adminEmail, \'\', \'\', 1, \'0000-00-00 00:00:00\', 1, 1);'); $oResult = $oStatement->execute(array( ":adminUser" => self::$_data['adminUser'], ":adminPassword" => $sPassword, ":adminPasswordSalt" => $sSalt, ":adminEmail" => self::$_data['adminEmail'], )); if ($oResult !== true) { throw new Exception("Error while creating admin user"); } $iUserId = self::$_connection->lastInsertId(); $oStatement = self::$_connection->prepare('INSERT INTO `user_role` (`user_id` ,`role_id`)VALUES (:user_id, :user_role_id);'); $oResult = $oStatement->execute(array( ":user_id" => $iUserId, ":user_role_id" => 6, )); if ($oResult !== true) { throw new Exception("Error while creating admin user"); } }
php
private static function _createAdminUser() { $oUser = new User(); $factory = self::$_container->get('security.encoder_factory'); $encoder = $factory->getEncoder($oUser); $sSalt = $oUser->getSalt(); $sPassword = $encoder->encodePassword(self::$_data['adminPassword'], $sSalt); $oStatement = self::$_connection->prepare('INSERT INTO `user` (`id`, `username`, `password`, `salt`, `firstname`, `lastname`, `email`, `phone`, `memo`, `activated`, `last_login`, `notification_change`, `notification_error`) VALUES (null, :adminUser, :adminPassword , :adminPasswordSalt, \'admin\', \'admin\', :adminEmail, \'\', \'\', 1, \'0000-00-00 00:00:00\', 1, 1);'); $oResult = $oStatement->execute(array( ":adminUser" => self::$_data['adminUser'], ":adminPassword" => $sPassword, ":adminPasswordSalt" => $sSalt, ":adminEmail" => self::$_data['adminEmail'], )); if ($oResult !== true) { throw new Exception("Error while creating admin user"); } $iUserId = self::$_connection->lastInsertId(); $oStatement = self::$_connection->prepare('INSERT INTO `user_role` (`user_id` ,`role_id`)VALUES (:user_id, :user_role_id);'); $oResult = $oStatement->execute(array( ":user_id" => $iUserId, ":user_role_id" => 6, )); if ($oResult !== true) { throw new Exception("Error while creating admin user"); } }
[ "private", "static", "function", "_createAdminUser", "(", ")", "{", "$", "oUser", "=", "new", "User", "(", ")", ";", "$", "factory", "=", "self", "::", "$", "_container", "->", "get", "(", "'security.encoder_factory'", ")", ";", "$", "encoder", "=", "$", "factory", "->", "getEncoder", "(", "$", "oUser", ")", ";", "$", "sSalt", "=", "$", "oUser", "->", "getSalt", "(", ")", ";", "$", "sPassword", "=", "$", "encoder", "->", "encodePassword", "(", "self", "::", "$", "_data", "[", "'adminPassword'", "]", ",", "$", "sSalt", ")", ";", "$", "oStatement", "=", "self", "::", "$", "_connection", "->", "prepare", "(", "'INSERT INTO `user` (`id`, `username`, `password`, `salt`, `firstname`, `lastname`, `email`, `phone`, `memo`, `activated`, `last_login`, `notification_change`, `notification_error`) VALUES (null, :adminUser, :adminPassword , :adminPasswordSalt, \\'admin\\', \\'admin\\', :adminEmail, \\'\\', \\'\\', 1, \\'0000-00-00 00:00:00\\', 1, 1);'", ")", ";", "$", "oResult", "=", "$", "oStatement", "->", "execute", "(", "array", "(", "\":adminUser\"", "=>", "self", "::", "$", "_data", "[", "'adminUser'", "]", ",", "\":adminPassword\"", "=>", "$", "sPassword", ",", "\":adminPasswordSalt\"", "=>", "$", "sSalt", ",", "\":adminEmail\"", "=>", "self", "::", "$", "_data", "[", "'adminEmail'", "]", ",", ")", ")", ";", "if", "(", "$", "oResult", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "\"Error while creating admin user\"", ")", ";", "}", "$", "iUserId", "=", "self", "::", "$", "_connection", "->", "lastInsertId", "(", ")", ";", "$", "oStatement", "=", "self", "::", "$", "_connection", "->", "prepare", "(", "'INSERT INTO `user_role` (`user_id` ,`role_id`)VALUES (:user_id, :user_role_id);'", ")", ";", "$", "oResult", "=", "$", "oStatement", "->", "execute", "(", "array", "(", "\":user_id\"", "=>", "$", "iUserId", ",", "\":user_role_id\"", "=>", "6", ",", ")", ")", ";", "if", "(", "$", "oResult", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "\"Error while creating admin user\"", ")", ";", "}", "}" ]
create the admin user
[ "create", "the", "admin", "user" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Helper/InstallHelper.php#L309-L343
16,974
joseph-walker/vector
src/Control/Pattern.php
Pattern.__getType
protected static function __getType($param) { $type = is_object($param) ? get_class($param) : gettype($param); return $type === 'integer' ? 'int' : $type; }
php
protected static function __getType($param) { $type = is_object($param) ? get_class($param) : gettype($param); return $type === 'integer' ? 'int' : $type; }
[ "protected", "static", "function", "__getType", "(", "$", "param", ")", "{", "$", "type", "=", "is_object", "(", "$", "param", ")", "?", "get_class", "(", "$", "param", ")", ":", "gettype", "(", "$", "param", ")", ";", "return", "$", "type", "===", "'integer'", "?", "'int'", ":", "$", "type", ";", "}" ]
Get type OR class for params, as well as re-mapping inconsistencies @param $param @return string
[ "Get", "type", "OR", "class", "for", "params", "as", "well", "as", "re", "-", "mapping", "inconsistencies" ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Control/Pattern.php#L27-L34
16,975
joseph-walker/vector
src/Control/Pattern.php
Pattern.__match
protected static function __match(array $patterns) { return function (...$args) use ($patterns) { $parameterTypes = array_map(self::getType(), $args); try { $keysToValues = Arrays::zip(array_keys($patterns), array_values($patterns)); list($key, $matchingPattern) = Arrays::first( Pattern::patternApplies($parameterTypes, $args), $keysToValues ); } catch (ElementNotFoundException $e) { throw new IncompletePatternMatchException( 'Incomplete pattern match expression. (missing ' . implode(', ', $parameterTypes) . ')' ); } /** * Upcoming Feature, Array DSL for matching via `x::xs` etc. */ // // if key is a string, manually match // if (is_string($key)) { // // throw new \Exception('Array DSL not available.'); // } list($hasExtractable, $unwrappedArgs) = self::unwrapArgs($args); $value = $matchingPattern(...$args); $isCallable = is_callable($value); if ($hasExtractable && ! $isCallable) { throw new InvalidPatternMatchException( 'Invalid pattern match expression. (one of ' . implode(', ', $parameterTypes) . ' requires a callback to unwrap)' ); } /** * Extractable requires a callback to feed args into. */ if ($hasExtractable && $isCallable) { return $matchingPattern(...$args)(...$unwrappedArgs); } /** * No extractable so we can just return the value directly. */ return $value; }; }
php
protected static function __match(array $patterns) { return function (...$args) use ($patterns) { $parameterTypes = array_map(self::getType(), $args); try { $keysToValues = Arrays::zip(array_keys($patterns), array_values($patterns)); list($key, $matchingPattern) = Arrays::first( Pattern::patternApplies($parameterTypes, $args), $keysToValues ); } catch (ElementNotFoundException $e) { throw new IncompletePatternMatchException( 'Incomplete pattern match expression. (missing ' . implode(', ', $parameterTypes) . ')' ); } /** * Upcoming Feature, Array DSL for matching via `x::xs` etc. */ // // if key is a string, manually match // if (is_string($key)) { // // throw new \Exception('Array DSL not available.'); // } list($hasExtractable, $unwrappedArgs) = self::unwrapArgs($args); $value = $matchingPattern(...$args); $isCallable = is_callable($value); if ($hasExtractable && ! $isCallable) { throw new InvalidPatternMatchException( 'Invalid pattern match expression. (one of ' . implode(', ', $parameterTypes) . ' requires a callback to unwrap)' ); } /** * Extractable requires a callback to feed args into. */ if ($hasExtractable && $isCallable) { return $matchingPattern(...$args)(...$unwrappedArgs); } /** * No extractable so we can just return the value directly. */ return $value; }; }
[ "protected", "static", "function", "__match", "(", "array", "$", "patterns", ")", "{", "return", "function", "(", "...", "$", "args", ")", "use", "(", "$", "patterns", ")", "{", "$", "parameterTypes", "=", "array_map", "(", "self", "::", "getType", "(", ")", ",", "$", "args", ")", ";", "try", "{", "$", "keysToValues", "=", "Arrays", "::", "zip", "(", "array_keys", "(", "$", "patterns", ")", ",", "array_values", "(", "$", "patterns", ")", ")", ";", "list", "(", "$", "key", ",", "$", "matchingPattern", ")", "=", "Arrays", "::", "first", "(", "Pattern", "::", "patternApplies", "(", "$", "parameterTypes", ",", "$", "args", ")", ",", "$", "keysToValues", ")", ";", "}", "catch", "(", "ElementNotFoundException", "$", "e", ")", "{", "throw", "new", "IncompletePatternMatchException", "(", "'Incomplete pattern match expression. (missing '", ".", "implode", "(", "', '", ",", "$", "parameterTypes", ")", ".", "')'", ")", ";", "}", "/**\n * Upcoming Feature, Array DSL for matching via `x::xs` etc.\n */", "// // if key is a string, manually match", "// if (is_string($key)) {", "//", "// throw new \\Exception('Array DSL not available.');", "// }", "list", "(", "$", "hasExtractable", ",", "$", "unwrappedArgs", ")", "=", "self", "::", "unwrapArgs", "(", "$", "args", ")", ";", "$", "value", "=", "$", "matchingPattern", "(", "...", "$", "args", ")", ";", "$", "isCallable", "=", "is_callable", "(", "$", "value", ")", ";", "if", "(", "$", "hasExtractable", "&&", "!", "$", "isCallable", ")", "{", "throw", "new", "InvalidPatternMatchException", "(", "'Invalid pattern match expression. (one of '", ".", "implode", "(", "', '", ",", "$", "parameterTypes", ")", ".", "' requires a callback to unwrap)'", ")", ";", "}", "/**\n * Extractable requires a callback to feed args into.\n */", "if", "(", "$", "hasExtractable", "&&", "$", "isCallable", ")", "{", "return", "$", "matchingPattern", "(", "...", "$", "args", ")", "(", "...", "$", "unwrappedArgs", ")", ";", "}", "/**\n * No extractable so we can just return the value directly.\n */", "return", "$", "value", ";", "}", ";", "}" ]
Pattern Matching. Use switch-case for explicit values, this for everything else. @param array $patterns @return mixed
[ "Pattern", "Matching", ".", "Use", "switch", "-", "case", "for", "explicit", "values", "this", "for", "everything", "else", "." ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Control/Pattern.php#L41-L93
16,976
joseph-walker/vector
src/Control/Pattern.php
Pattern.unwrapArgs
private static function unwrapArgs(array $args) : array { $hasExtractable = false; $unwrappedArgs = self::flatten(array_map(function ($arg) use (&$hasExtractable) { if (method_exists($arg, 'extract')) { $hasExtractable = true; return $arg->extract(); } return $arg; }, $args)); return [$hasExtractable, $unwrappedArgs]; }
php
private static function unwrapArgs(array $args) : array { $hasExtractable = false; $unwrappedArgs = self::flatten(array_map(function ($arg) use (&$hasExtractable) { if (method_exists($arg, 'extract')) { $hasExtractable = true; return $arg->extract(); } return $arg; }, $args)); return [$hasExtractable, $unwrappedArgs]; }
[ "private", "static", "function", "unwrapArgs", "(", "array", "$", "args", ")", ":", "array", "{", "$", "hasExtractable", "=", "false", ";", "$", "unwrappedArgs", "=", "self", "::", "flatten", "(", "array_map", "(", "function", "(", "$", "arg", ")", "use", "(", "&", "$", "hasExtractable", ")", "{", "if", "(", "method_exists", "(", "$", "arg", ",", "'extract'", ")", ")", "{", "$", "hasExtractable", "=", "true", ";", "return", "$", "arg", "->", "extract", "(", ")", ";", "}", "return", "$", "arg", ";", "}", ",", "$", "args", ")", ")", ";", "return", "[", "$", "hasExtractable", ",", "$", "unwrappedArgs", "]", ";", "}" ]
Extracts args from Extractable values @param array $args @return array
[ "Extracts", "args", "from", "Extractable", "values" ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Control/Pattern.php#L100-L114
16,977
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/Rankings.php
Rankings.getMultiplayerPlayer
function getMultiplayerPlayer($titleId, $login) { if(!$login) { throw new Exception('Invalid login'); } return $this->execute('GET', $this->getPrefixEndpoint($titleId).'/rankings/multiplayer/player/%s/?title=%s', array($login, $titleId)); }
php
function getMultiplayerPlayer($titleId, $login) { if(!$login) { throw new Exception('Invalid login'); } return $this->execute('GET', $this->getPrefixEndpoint($titleId).'/rankings/multiplayer/player/%s/?title=%s', array($login, $titleId)); }
[ "function", "getMultiplayerPlayer", "(", "$", "titleId", ",", "$", "login", ")", "{", "if", "(", "!", "$", "login", ")", "{", "throw", "new", "Exception", "(", "'Invalid login'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'GET'", ",", "$", "this", "->", "getPrefixEndpoint", "(", "$", "titleId", ")", ".", "'/rankings/multiplayer/player/%s/?title=%s'", ",", "array", "(", "$", "login", ",", "$", "titleId", ")", ")", ";", "}" ]
Get player ranking for the give title @param string $titleId @param string $login @return Object @throws Exception
[ "Get", "player", "ranking", "for", "the", "give", "title" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/Rankings.php#L18-L25
16,978
PortaText/php-sdk
src/PortaText/Command/Api/ContactLists.php
ContactLists.withNumber
public function withNumber($number, $variables = null) { if (!is_null($variables)) { $vars = array(); foreach ($variables as $k => $v) { $vars[] = array('key' => $k, 'value' => $v); } $this->setArgument("variables", $vars); } return $this->setArgument("number", $number); }
php
public function withNumber($number, $variables = null) { if (!is_null($variables)) { $vars = array(); foreach ($variables as $k => $v) { $vars[] = array('key' => $k, 'value' => $v); } $this->setArgument("variables", $vars); } return $this->setArgument("number", $number); }
[ "public", "function", "withNumber", "(", "$", "number", ",", "$", "variables", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "variables", ")", ")", "{", "$", "vars", "=", "array", "(", ")", ";", "foreach", "(", "$", "variables", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "vars", "[", "]", "=", "array", "(", "'key'", "=>", "$", "k", ",", "'value'", "=>", "$", "v", ")", ";", "}", "$", "this", "->", "setArgument", "(", "\"variables\"", ",", "$", "vars", ")", ";", "}", "return", "$", "this", "->", "setArgument", "(", "\"number\"", ",", "$", "number", ")", ";", "}" ]
Add or remove this number to the contact list. @param string $number Number. @param array $variables variables. @return PortaText\Command\ICommand
[ "Add", "or", "remove", "this", "number", "to", "the", "contact", "list", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/ContactLists.php#L52-L62
16,979
dandisy/laravel-generator
src/Utils/TableFieldsGenerator.php
TableFieldsGenerator.detectManyToOne
private function detectManyToOne($tables, $modelTable) { $manyToOneRelations = []; $foreignKeys = $modelTable->foreignKeys; foreach ($foreignKeys as $foreignKey) { $foreignTable = $foreignKey->foreignTable; $foreignField = $foreignKey->foreignField; if (!isset($tables[$foreignTable])) { continue; } if ($foreignField == $tables[$foreignTable]->primaryKey) { $modelName = model_name_from_table_name($foreignTable); $manyToOneRelations[] = GeneratorFieldRelation::parseRelation('mt1,'.$modelName); } } return $manyToOneRelations; }
php
private function detectManyToOne($tables, $modelTable) { $manyToOneRelations = []; $foreignKeys = $modelTable->foreignKeys; foreach ($foreignKeys as $foreignKey) { $foreignTable = $foreignKey->foreignTable; $foreignField = $foreignKey->foreignField; if (!isset($tables[$foreignTable])) { continue; } if ($foreignField == $tables[$foreignTable]->primaryKey) { $modelName = model_name_from_table_name($foreignTable); $manyToOneRelations[] = GeneratorFieldRelation::parseRelation('mt1,'.$modelName); } } return $manyToOneRelations; }
[ "private", "function", "detectManyToOne", "(", "$", "tables", ",", "$", "modelTable", ")", "{", "$", "manyToOneRelations", "=", "[", "]", ";", "$", "foreignKeys", "=", "$", "modelTable", "->", "foreignKeys", ";", "foreach", "(", "$", "foreignKeys", "as", "$", "foreignKey", ")", "{", "$", "foreignTable", "=", "$", "foreignKey", "->", "foreignTable", ";", "$", "foreignField", "=", "$", "foreignKey", "->", "foreignField", ";", "if", "(", "!", "isset", "(", "$", "tables", "[", "$", "foreignTable", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "foreignField", "==", "$", "tables", "[", "$", "foreignTable", "]", "->", "primaryKey", ")", "{", "$", "modelName", "=", "model_name_from_table_name", "(", "$", "foreignTable", ")", ";", "$", "manyToOneRelations", "[", "]", "=", "GeneratorFieldRelation", "::", "parseRelation", "(", "'mt1,'", ".", "$", "modelName", ")", ";", "}", "}", "return", "$", "manyToOneRelations", ";", "}" ]
Detect many to one relationship on model table If foreign key of model table is primary key of foreign table. @param GeneratorTable[] $tables @param GeneratorTable $modelTable @return array
[ "Detect", "many", "to", "one", "relationship", "on", "model", "table", "If", "foreign", "key", "of", "model", "table", "is", "primary", "key", "of", "foreign", "table", "." ]
742797c8483bc88b54b6302a516a9a85eeb8579b
https://github.com/dandisy/laravel-generator/blob/742797c8483bc88b54b6302a516a9a85eeb8579b/src/Utils/TableFieldsGenerator.php#L483-L504
16,980
ClanCats/Core
src/classes/CCModel.php
CCModel.__
public function __( $key, $params = array() ) { $namespace = explode( "\\", get_called_class() ); $class = strtolower( 'model/'.str_replace( '_', '/', array_pop( $namespace ) ) ); $namespace = implode( "\\", $namespace ); if ( $namespace ) { $class = $namespace.'::'.$class; } return __( $class.'.label.'.$key, $params ); }
php
public function __( $key, $params = array() ) { $namespace = explode( "\\", get_called_class() ); $class = strtolower( 'model/'.str_replace( '_', '/', array_pop( $namespace ) ) ); $namespace = implode( "\\", $namespace ); if ( $namespace ) { $class = $namespace.'::'.$class; } return __( $class.'.label.'.$key, $params ); }
[ "public", "function", "__", "(", "$", "key", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "namespace", "=", "explode", "(", "\"\\\\\"", ",", "get_called_class", "(", ")", ")", ";", "$", "class", "=", "strtolower", "(", "'model/'", ".", "str_replace", "(", "'_'", ",", "'/'", ",", "array_pop", "(", "$", "namespace", ")", ")", ")", ";", "$", "namespace", "=", "implode", "(", "\"\\\\\"", ",", "$", "namespace", ")", ";", "if", "(", "$", "namespace", ")", "{", "$", "class", "=", "$", "namespace", ".", "'::'", ".", "$", "class", ";", "}", "return", "__", "(", "$", "class", ".", "'.label.'", ".", "$", "key", ",", "$", "params", ")", ";", "}" ]
Label translation helper @param string $key @param array $params @return string
[ "Label", "translation", "helper" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L234-L248
16,981
ClanCats/Core
src/classes/CCModel.php
CCModel.strict_assign
public function strict_assign( array $fields, array $data ) { foreach( $fields as $field ) { if ( isset( $data[$field] ) ) { $this->__set( $field, $data[$field] ); } } }
php
public function strict_assign( array $fields, array $data ) { foreach( $fields as $field ) { if ( isset( $data[$field] ) ) { $this->__set( $field, $data[$field] ); } } }
[ "public", "function", "strict_assign", "(", "array", "$", "fields", ",", "array", "$", "data", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "field", "]", ")", ")", "{", "$", "this", "->", "__set", "(", "$", "field", ",", "$", "data", "[", "$", "field", "]", ")", ";", "}", "}", "}" ]
Strict assign only sets some values out of an array. This can be useful to easly set some values from post. example: $model->srtict_assign( array( 'name', 'description' ), CCIn::all( 'post' ) ) @param array $fields @param array $data @return void
[ "Strict", "assign", "only", "sets", "some", "values", "out", "of", "an", "array", ".", "This", "can", "be", "useful", "to", "easly", "set", "some", "values", "from", "post", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L290-L299
16,982
ClanCats/Core
src/classes/CCModel.php
CCModel._type_assignment_set
protected function _type_assignment_set( $type, $value ) { switch ( $type ) { case 'int': case 'timestamp': return (int) $value; break; case 'string': return (string) $value; break; case 'bool': return (bool) $value; break; // json datatype simply encode case 'json': return json_encode( $value ); break; } return $value; }
php
protected function _type_assignment_set( $type, $value ) { switch ( $type ) { case 'int': case 'timestamp': return (int) $value; break; case 'string': return (string) $value; break; case 'bool': return (bool) $value; break; // json datatype simply encode case 'json': return json_encode( $value ); break; } return $value; }
[ "protected", "function", "_type_assignment_set", "(", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "case", "'timestamp'", ":", "return", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'string'", ":", "return", "(", "string", ")", "$", "value", ";", "break", ";", "case", "'bool'", ":", "return", "(", "bool", ")", "$", "value", ";", "break", ";", "// json datatype simply encode", "case", "'json'", ":", "return", "json_encode", "(", "$", "value", ")", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
Assign the data type in a set operation @param string $type @param mixed $value @return mixed
[ "Assign", "the", "data", "type", "in", "a", "set", "operation" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L308-L332
16,983
ClanCats/Core
src/classes/CCModel.php
CCModel._type_assignment_get
protected function _type_assignment_get( $type, $value ) { switch ( $type ) { case 'int': case 'timestamp': return (int) $value; break; case 'string': return (string) $value; break; case 'bool': return (bool) $value; break; // json datatype try to decode return array on failure case 'json': if ( is_array( $value ) ) { return $value; } if ( is_array( $value = json_decode( $value, true ) ) ) { return $value; } return array(); break; } return $value; }
php
protected function _type_assignment_get( $type, $value ) { switch ( $type ) { case 'int': case 'timestamp': return (int) $value; break; case 'string': return (string) $value; break; case 'bool': return (bool) $value; break; // json datatype try to decode return array on failure case 'json': if ( is_array( $value ) ) { return $value; } if ( is_array( $value = json_decode( $value, true ) ) ) { return $value; } return array(); break; } return $value; }
[ "protected", "function", "_type_assignment_get", "(", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "case", "'timestamp'", ":", "return", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'string'", ":", "return", "(", "string", ")", "$", "value", ";", "break", ";", "case", "'bool'", ":", "return", "(", "bool", ")", "$", "value", ";", "break", ";", "// json datatype try to decode return array on failure", "case", "'json'", ":", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", "=", "json_decode", "(", "$", "value", ",", "true", ")", ")", ")", "{", "return", "$", "value", ";", "}", "return", "array", "(", ")", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
Assign the data type in a get operation @param string $type @param mixed $value @return mixed
[ "Assign", "the", "data", "type", "in", "a", "get", "operation" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L341-L373
16,984
ClanCats/Core
src/classes/CCModel.php
CCModel.&
public function &__get( $key ) { $value = null; // check if the modifier exists $has_modifier = method_exists( $this, '_get_modifier_'.$key ); // try getting the item if ( array_key_exists( $key, $this->_data_store ) ) { $value =& $this->_data_store[$key]; if ( $has_modifier ) { $tmpvalue = $this->{'_get_modifier_'.$key}( $value ); return $tmpvalue; } return $value; } if ( $has_modifier ) { $value = $this->{'_get_modifier_'.$key}(); return $value; } // when a function extists we forward the call if ( method_exists( $this, $key ) ) { $value = $this->__call_property( $key ); return $value; } throw new \InvalidArgumentException( "CCModel - Invalid or undefined model property '".$key."'." ); }
php
public function &__get( $key ) { $value = null; // check if the modifier exists $has_modifier = method_exists( $this, '_get_modifier_'.$key ); // try getting the item if ( array_key_exists( $key, $this->_data_store ) ) { $value =& $this->_data_store[$key]; if ( $has_modifier ) { $tmpvalue = $this->{'_get_modifier_'.$key}( $value ); return $tmpvalue; } return $value; } if ( $has_modifier ) { $value = $this->{'_get_modifier_'.$key}(); return $value; } // when a function extists we forward the call if ( method_exists( $this, $key ) ) { $value = $this->__call_property( $key ); return $value; } throw new \InvalidArgumentException( "CCModel - Invalid or undefined model property '".$key."'." ); }
[ "public", "function", "&", "__get", "(", "$", "key", ")", "{", "$", "value", "=", "null", ";", "// check if the modifier exists", "$", "has_modifier", "=", "method_exists", "(", "$", "this", ",", "'_get_modifier_'", ".", "$", "key", ")", ";", "// try getting the item", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_data_store", ")", ")", "{", "$", "value", "=", "&", "$", "this", "->", "_data_store", "[", "$", "key", "]", ";", "if", "(", "$", "has_modifier", ")", "{", "$", "tmpvalue", "=", "$", "this", "->", "{", "'_get_modifier_'", ".", "$", "key", "}", "(", "$", "value", ")", ";", "return", "$", "tmpvalue", ";", "}", "return", "$", "value", ";", "}", "if", "(", "$", "has_modifier", ")", "{", "$", "value", "=", "$", "this", "->", "{", "'_get_modifier_'", ".", "$", "key", "}", "(", ")", ";", "return", "$", "value", ";", "}", "// when a function extists we forward the call", "if", "(", "method_exists", "(", "$", "this", ",", "$", "key", ")", ")", "{", "$", "value", "=", "$", "this", "->", "__call_property", "(", "$", "key", ")", ";", "return", "$", "value", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCModel - Invalid or undefined model property '\"", ".", "$", "key", ".", "\"'.\"", ")", ";", "}" ]
Get a value by key from the model data @param string $key @return mixed
[ "Get", "a", "value", "by", "key", "from", "the", "model", "data" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L390-L422
16,985
ClanCats/Core
src/classes/CCModel.php
CCModel.__isset
public function __isset( $key ) { return ( array_key_exists( $key, $this->_data_store ) || method_exists( $this, '_get_modifier_'.$key ) ) ? true : false; }
php
public function __isset( $key ) { return ( array_key_exists( $key, $this->_data_store ) || method_exists( $this, '_get_modifier_'.$key ) ) ? true : false; }
[ "public", "function", "__isset", "(", "$", "key", ")", "{", "return", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_data_store", ")", "||", "method_exists", "(", "$", "this", ",", "'_get_modifier_'", ".", "$", "key", ")", ")", "?", "true", ":", "false", ";", "}" ]
Check if model data isset This also checks if a get modifier function exists which will also count as ture. @param $key @return bool
[ "Check", "if", "model", "data", "isset", "This", "also", "checks", "if", "a", "get", "modifier", "function", "exists", "which", "will", "also", "count", "as", "ture", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L456-L459
16,986
ClanCats/Core
src/classes/CCModel.php
CCModel.raw
public function raw( $key = null ) { if ( !is_null( $key ) ) { if ( isset( $this->_data_store[$key] ) ) { return $this->_data_store[$key]; } throw new \InvalidArgumentException( "CCModel - Invalid or undefined model property '".$key."'." ); } return $this->_data_store; }
php
public function raw( $key = null ) { if ( !is_null( $key ) ) { if ( isset( $this->_data_store[$key] ) ) { return $this->_data_store[$key]; } throw new \InvalidArgumentException( "CCModel - Invalid or undefined model property '".$key."'." ); } return $this->_data_store; }
[ "public", "function", "raw", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "key", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_data_store", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_data_store", "[", "$", "key", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCModel - Invalid or undefined model property '\"", ".", "$", "key", ".", "\"'.\"", ")", ";", "}", "return", "$", "this", "->", "_data_store", ";", "}" ]
Returns all raw data of the object or a single property $model->raw(); $model->raw( 'key' ); @param string $key @return array
[ "Returns", "all", "raw", "data", "of", "the", "object", "or", "a", "single", "property" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCModel.php#L470-L483
16,987
spiral-modules/scaffolder
source/Scaffolder/Commands/RequestCommand.php
RequestCommand.parseField
private function parseField(string $field): array { $source = static::DEFAULT_SOURCE; $type = static::DEFAULT_TYPE; $origin = null; if (strpos($field, '(') !== false) { $source = substr($field, strpos($field, '(') + 1, -1); $field = substr($field, 0, strpos($field, '(')); if (strpos($source, ':') !== false) { list($source, $origin) = explode(':', $source); } } if (strpos($field, ':') !== false) { list($field, $type) = explode(':', $field); } return [$field, $type, $source, $origin]; }
php
private function parseField(string $field): array { $source = static::DEFAULT_SOURCE; $type = static::DEFAULT_TYPE; $origin = null; if (strpos($field, '(') !== false) { $source = substr($field, strpos($field, '(') + 1, -1); $field = substr($field, 0, strpos($field, '(')); if (strpos($source, ':') !== false) { list($source, $origin) = explode(':', $source); } } if (strpos($field, ':') !== false) { list($field, $type) = explode(':', $field); } return [$field, $type, $source, $origin]; }
[ "private", "function", "parseField", "(", "string", "$", "field", ")", ":", "array", "{", "$", "source", "=", "static", "::", "DEFAULT_SOURCE", ";", "$", "type", "=", "static", "::", "DEFAULT_TYPE", ";", "$", "origin", "=", "null", ";", "if", "(", "strpos", "(", "$", "field", ",", "'('", ")", "!==", "false", ")", "{", "$", "source", "=", "substr", "(", "$", "field", ",", "strpos", "(", "$", "field", ",", "'('", ")", "+", "1", ",", "-", "1", ")", ";", "$", "field", "=", "substr", "(", "$", "field", ",", "0", ",", "strpos", "(", "$", "field", ",", "'('", ")", ")", ";", "if", "(", "strpos", "(", "$", "source", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "source", ",", "$", "origin", ")", "=", "explode", "(", "':'", ",", "$", "source", ")", ";", "}", "}", "if", "(", "strpos", "(", "$", "field", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "field", ",", "$", "type", ")", "=", "explode", "(", "':'", ",", "$", "field", ")", ";", "}", "return", "[", "$", "field", ",", "$", "type", ",", "$", "source", ",", "$", "origin", "]", ";", "}" ]
Parse field to fetch source, origin and type. @param string $field @return array
[ "Parse", "field", "to", "fetch", "source", "origin", "and", "type", "." ]
9be9dd0da6e4b02232db24e797fe5c288afbbddf
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Commands/RequestCommand.php#L69-L89
16,988
ufocoder/yii2-SyncSocial
src/actions/ActionSynchronize.php
ActionSynchronize.initialRedirectUrl
protected function initialRedirectUrl() { $defaultUrl = '/'. $this->controller->id . '/' . $this->controller->defaultAction; if (isset($this->controller->module->id) && !$this->controller->module instanceof Application) { $defaultUrl = '/' . $this->controller->module->id . $defaultUrl; } if ( empty( $this->successUrl ) ) { $this->successUrl = $defaultUrl; } if ( empty( $this->failedUrl ) ) { $this->failedUrl = $defaultUrl; } }
php
protected function initialRedirectUrl() { $defaultUrl = '/'. $this->controller->id . '/' . $this->controller->defaultAction; if (isset($this->controller->module->id) && !$this->controller->module instanceof Application) { $defaultUrl = '/' . $this->controller->module->id . $defaultUrl; } if ( empty( $this->successUrl ) ) { $this->successUrl = $defaultUrl; } if ( empty( $this->failedUrl ) ) { $this->failedUrl = $defaultUrl; } }
[ "protected", "function", "initialRedirectUrl", "(", ")", "{", "$", "defaultUrl", "=", "'/'", ".", "$", "this", "->", "controller", "->", "id", ".", "'/'", ".", "$", "this", "->", "controller", "->", "defaultAction", ";", "if", "(", "isset", "(", "$", "this", "->", "controller", "->", "module", "->", "id", ")", "&&", "!", "$", "this", "->", "controller", "->", "module", "instanceof", "Application", ")", "{", "$", "defaultUrl", "=", "'/'", ".", "$", "this", "->", "controller", "->", "module", "->", "id", ".", "$", "defaultUrl", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "successUrl", ")", ")", "{", "$", "this", "->", "successUrl", "=", "$", "defaultUrl", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "failedUrl", ")", ")", "{", "$", "this", "->", "failedUrl", "=", "$", "defaultUrl", ";", "}", "}" ]
Set default redirect url
[ "Set", "default", "redirect", "url" ]
2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/actions/ActionSynchronize.php#L37-L53
16,989
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsConfig.php
OptionsConfig.validate_config
private function validate_config( $config ) { $this->section_names = array(); foreach( $config['sections'] as $section ) { if( in_array( $section->title, $this->section_names ) ) { throw new DuplicateSectionException( $section->title ); } // Component name uniqueness is validated by the from object, not here foreach( $section->get_fields() as $field ) { $this->fields[] = $field; } $this->section_names[] = $section->title; } return $config; }
php
private function validate_config( $config ) { $this->section_names = array(); foreach( $config['sections'] as $section ) { if( in_array( $section->title, $this->section_names ) ) { throw new DuplicateSectionException( $section->title ); } // Component name uniqueness is validated by the from object, not here foreach( $section->get_fields() as $field ) { $this->fields[] = $field; } $this->section_names[] = $section->title; } return $config; }
[ "private", "function", "validate_config", "(", "$", "config", ")", "{", "$", "this", "->", "section_names", "=", "array", "(", ")", ";", "foreach", "(", "$", "config", "[", "'sections'", "]", "as", "$", "section", ")", "{", "if", "(", "in_array", "(", "$", "section", "->", "title", ",", "$", "this", "->", "section_names", ")", ")", "{", "throw", "new", "DuplicateSectionException", "(", "$", "section", "->", "title", ")", ";", "}", "// Component name uniqueness is validated by the from object, not here", "foreach", "(", "$", "section", "->", "get_fields", "(", ")", "as", "$", "field", ")", "{", "$", "this", "->", "fields", "[", "]", "=", "$", "field", ";", "}", "$", "this", "->", "section_names", "[", "]", "=", "$", "section", "->", "title", ";", "}", "return", "$", "config", ";", "}" ]
Validate the integrity of the provided configuration array @param array $config @throws DuplicateNameException On duplicate field name
[ "Validate", "the", "integrity", "of", "the", "provided", "configuration", "array" ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsConfig.php#L40-L61
16,990
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsConfig.php
OptionsConfig.set_section_slugs
private function set_section_slugs() { // For more than 1 sections, set section specific slugs if( count( $this->sections ) > 1 ) { foreach( $this->sections as $section ) { $section->set_slug( \Amarkal\Common\Tools::strtoslug( $section->title ) ); } } // For a single section, use the page's title as the slug else { $this->sections[0]->set_slug( \Amarkal\Common\Tools::strtoslug( $this->title ) ); } }
php
private function set_section_slugs() { // For more than 1 sections, set section specific slugs if( count( $this->sections ) > 1 ) { foreach( $this->sections as $section ) { $section->set_slug( \Amarkal\Common\Tools::strtoslug( $section->title ) ); } } // For a single section, use the page's title as the slug else { $this->sections[0]->set_slug( \Amarkal\Common\Tools::strtoslug( $this->title ) ); } }
[ "private", "function", "set_section_slugs", "(", ")", "{", "// For more than 1 sections, set section specific slugs", "if", "(", "count", "(", "$", "this", "->", "sections", ")", ">", "1", ")", "{", "foreach", "(", "$", "this", "->", "sections", "as", "$", "section", ")", "{", "$", "section", "->", "set_slug", "(", "\\", "Amarkal", "\\", "Common", "\\", "Tools", "::", "strtoslug", "(", "$", "section", "->", "title", ")", ")", ";", "}", "}", "// For a single section, use the page's title as the slug", "else", "{", "$", "this", "->", "sections", "[", "0", "]", "->", "set_slug", "(", "\\", "Amarkal", "\\", "Common", "\\", "Tools", "::", "strtoslug", "(", "$", "this", "->", "title", ")", ")", ";", "}", "}" ]
Set slugs to each section, according the number of sections.
[ "Set", "slugs", "to", "each", "section", "according", "the", "number", "of", "sections", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsConfig.php#L66-L82
16,991
Double-Opt-in/php-client-api
src/Client/Commands/Responses/Models/Status.php
Status.toArray
public function toArray() { return array( 'site' => $this->site, 'type' => $this->type, 'storage_time' => $this->storage_time, 'credits' => $this->credits, 'soft_quota' => $this->soft_quota, 'hard_quota' => $this->hard_quota, 'daily_credits_usage' => $this->daily_credits_usage, 'unique_hashes' => $this->unique_hashes, ); }
php
public function toArray() { return array( 'site' => $this->site, 'type' => $this->type, 'storage_time' => $this->storage_time, 'credits' => $this->credits, 'soft_quota' => $this->soft_quota, 'hard_quota' => $this->hard_quota, 'daily_credits_usage' => $this->daily_credits_usage, 'unique_hashes' => $this->unique_hashes, ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'site'", "=>", "$", "this", "->", "site", ",", "'type'", "=>", "$", "this", "->", "type", ",", "'storage_time'", "=>", "$", "this", "->", "storage_time", ",", "'credits'", "=>", "$", "this", "->", "credits", ",", "'soft_quota'", "=>", "$", "this", "->", "soft_quota", ",", "'hard_quota'", "=>", "$", "this", "->", "hard_quota", ",", "'daily_credits_usage'", "=>", "$", "this", "->", "daily_credits_usage", ",", "'unique_hashes'", "=>", "$", "this", "->", "unique_hashes", ",", ")", ";", "}" ]
returns status as array @return array
[ "returns", "status", "as", "array" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Models/Status.php#L196-L208
16,992
geekwright/Po
src/PoEntry.php
PoEntry.add
public function add(string $type, string $value): void { if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
php
public function add(string $type, string $value): void { if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
[ "public", "function", "add", "(", "string", "$", "type", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "(", "array", ")", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a value to an array 'type' in the entry @param string $type PoToken constant @param string $value value to store @return void
[ "add", "a", "value", "to", "an", "array", "type", "in", "the", "entry" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L48-L55
16,993
geekwright/Po
src/PoEntry.php
PoEntry.addQuoted
public function addQuoted(string $type, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
php
public function addQuoted(string $type, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
[ "public", "function", "addQuoted", "(", "string", "$", "type", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "value", "[", "0", "]", "==", "'\"'", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "-", "1", ")", ";", "}", "$", "value", "=", "stripcslashes", "(", "$", "value", ")", ";", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "(", "array", ")", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a quoted value to the array 'type' in the entry @param string $type PoToken constant @param string $value value to store @return void
[ "add", "a", "quoted", "value", "to", "the", "array", "type", "in", "the", "entry" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L64-L76
16,994
geekwright/Po
src/PoEntry.php
PoEntry.addQuotedAtPosition
public function addQuotedAtPosition(string $type, int $position, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } if (isset($this->entry[$type][$position]) && is_scalar($this->entry[$type][$position]) ) { $this->entry[$type][$position] = array($this->entry[$type][$position]); } $this->entry[$type][$position][] = $value; }
php
public function addQuotedAtPosition(string $type, int $position, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } if (isset($this->entry[$type][$position]) && is_scalar($this->entry[$type][$position]) ) { $this->entry[$type][$position] = array($this->entry[$type][$position]); } $this->entry[$type][$position][] = $value; }
[ "public", "function", "addQuotedAtPosition", "(", "string", "$", "type", ",", "int", "$", "position", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "value", "[", "0", "]", "==", "'\"'", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "-", "1", ")", ";", "}", "$", "value", "=", "stripcslashes", "(", "$", "value", ")", ";", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", "&&", "is_scalar", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", "=", "array", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a quoted value to the nested array 'type' in the entry This is mainly useful for translated plurals. Since any plural msgstr can have continuation lines, the message is stored as an array of arrays. @param string $type PoToken constant @param integer $position array position to store @param string $value value to store @return void
[ "add", "a", "quoted", "value", "to", "the", "nested", "array", "type", "in", "the", "entry" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L89-L105
16,995
geekwright/Po
src/PoEntry.php
PoEntry.getAsString
public function getAsString(string $type): ?string { $ret = $this->entry[$type]; if (is_array($ret)) { $ret = implode('', $ret); } return $ret; }
php
public function getAsString(string $type): ?string { $ret = $this->entry[$type]; if (is_array($ret)) { $ret = implode('', $ret); } return $ret; }
[ "public", "function", "getAsString", "(", "string", "$", "type", ")", ":", "?", "string", "{", "$", "ret", "=", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "if", "(", "is_array", "(", "$", "ret", ")", ")", "{", "$", "ret", "=", "implode", "(", "''", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}" ]
get the value of a specified type as a string @param string $type PoToken constant @return string|null
[ "get", "the", "value", "of", "a", "specified", "type", "as", "a", "string" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L125-L132
16,996
geekwright/Po
src/PoEntry.php
PoEntry.getAsStringArray
public function getAsStringArray(string $type): ?array { $plurals = $this->entry[$type]; $plurals = is_array($plurals) ? $plurals : array('', ''); $ret = array(); foreach ($plurals as $i => $value) { if (is_array($value)) { $value = implode('', $value); } $ret[$i] = $value; } return $ret; }
php
public function getAsStringArray(string $type): ?array { $plurals = $this->entry[$type]; $plurals = is_array($plurals) ? $plurals : array('', ''); $ret = array(); foreach ($plurals as $i => $value) { if (is_array($value)) { $value = implode('', $value); } $ret[$i] = $value; } return $ret; }
[ "public", "function", "getAsStringArray", "(", "string", "$", "type", ")", ":", "?", "array", "{", "$", "plurals", "=", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "plurals", "=", "is_array", "(", "$", "plurals", ")", "?", "$", "plurals", ":", "array", "(", "''", ",", "''", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "plurals", "as", "$", "i", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "''", ",", "$", "value", ")", ";", "}", "$", "ret", "[", "$", "i", "]", "=", "$", "value", ";", "}", "return", "$", "ret", ";", "}" ]
Get the value of a specified type as an array of strings. This is mainly for plural TRANSLATED messages. @param string $type PoToken constant @return string[]|null
[ "Get", "the", "value", "of", "a", "specified", "type", "as", "an", "array", "of", "strings", ".", "This", "is", "mainly", "for", "plural", "TRANSLATED", "messages", "." ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L142-L154
16,997
geekwright/Po
src/PoEntry.php
PoEntry.formatQuotedString
protected function formatQuotedString($value, bool $bare = false): string { if (is_array($value)) { $string = ''; foreach ($value as $partial) { $string .= $this->formatQuotedString($partial, true) . "\n"; } return $bare ? $string : ' ' . $string; } else { $string = ($value === null) ? '' : $value; $string = stripcslashes($string); $string = addcslashes($string, "\0..\37\""); $string = '"' . $string . '"'; return $bare ? $string : ' ' . $string . "\n"; } }
php
protected function formatQuotedString($value, bool $bare = false): string { if (is_array($value)) { $string = ''; foreach ($value as $partial) { $string .= $this->formatQuotedString($partial, true) . "\n"; } return $bare ? $string : ' ' . $string; } else { $string = ($value === null) ? '' : $value; $string = stripcslashes($string); $string = addcslashes($string, "\0..\37\""); $string = '"' . $string . '"'; return $bare ? $string : ' ' . $string . "\n"; } }
[ "protected", "function", "formatQuotedString", "(", "$", "value", ",", "bool", "$", "bare", "=", "false", ")", ":", "string", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "string", "=", "''", ";", "foreach", "(", "$", "value", "as", "$", "partial", ")", "{", "$", "string", ".=", "$", "this", "->", "formatQuotedString", "(", "$", "partial", ",", "true", ")", ".", "\"\\n\"", ";", "}", "return", "$", "bare", "?", "$", "string", ":", "' '", ".", "$", "string", ";", "}", "else", "{", "$", "string", "=", "(", "$", "value", "===", "null", ")", "?", "''", ":", "$", "value", ";", "$", "string", "=", "stripcslashes", "(", "$", "string", ")", ";", "$", "string", "=", "addcslashes", "(", "$", "string", ",", "\"\\0..\\37\\\"\"", ")", ";", "$", "string", "=", "'\"'", ".", "$", "string", ".", "'\"'", ";", "return", "$", "bare", "?", "$", "string", ":", "' '", ".", "$", "string", ".", "\"\\n\"", ";", "}", "}" ]
format a string for output by escaping control and double quote characters, then surrounding with double quotes @param string|string[]|null $value string to prepare @param boolean $bare true for bare output, default false adds leading space and trailing newline @return string
[ "format", "a", "string", "for", "output", "by", "escaping", "control", "and", "double", "quote", "characters", "then", "surrounding", "with", "double", "quotes" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L245-L260
16,998
geekwright/Po
src/PoEntry.php
PoEntry.hasFlag
public function hasFlag(string $name): bool { $flags = array(); $flagEntry = $this->entry[PoTokens::FLAG]; if (!empty($flagEntry)) { foreach ((array) $flagEntry as $csv) { $temp = str_getcsv($csv, ','); foreach ($temp as $flag) { $flag = strtolower(trim($flag)); $flags[$flag] = $flag; } } return isset($flags[strtolower(trim($name))]); } return false; }
php
public function hasFlag(string $name): bool { $flags = array(); $flagEntry = $this->entry[PoTokens::FLAG]; if (!empty($flagEntry)) { foreach ((array) $flagEntry as $csv) { $temp = str_getcsv($csv, ','); foreach ($temp as $flag) { $flag = strtolower(trim($flag)); $flags[$flag] = $flag; } } return isset($flags[strtolower(trim($name))]); } return false; }
[ "public", "function", "hasFlag", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "flags", "=", "array", "(", ")", ";", "$", "flagEntry", "=", "$", "this", "->", "entry", "[", "PoTokens", "::", "FLAG", "]", ";", "if", "(", "!", "empty", "(", "$", "flagEntry", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "flagEntry", "as", "$", "csv", ")", "{", "$", "temp", "=", "str_getcsv", "(", "$", "csv", ",", "','", ")", ";", "foreach", "(", "$", "temp", "as", "$", "flag", ")", "{", "$", "flag", "=", "strtolower", "(", "trim", "(", "$", "flag", ")", ")", ";", "$", "flags", "[", "$", "flag", "]", "=", "$", "flag", ";", "}", "}", "return", "isset", "(", "$", "flags", "[", "strtolower", "(", "trim", "(", "$", "name", ")", ")", "]", ")", ";", "}", "return", "false", ";", "}" ]
check for presence of a flag @param string $name flag to check @return boolean true if flag is set, otherwise false
[ "check", "for", "presence", "of", "a", "flag" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L269-L284
16,999
geekwright/Po
src/PoEntry.php
PoEntry.addFlag
public function addFlag(string $name): void { if (!$this->hasFlag($name)) { $flagEntry = $this->entry[PoTokens::FLAG]; if ($flagEntry === null) { $this->set(PoTokens::FLAG, $name); } elseif (is_array($flagEntry)) { $flagEntry[] = $name; $this->set(PoTokens::FLAG, implode(',', $flagEntry)); } else { $this->set(PoTokens::FLAG, $flagEntry . ',' . $name); } } }
php
public function addFlag(string $name): void { if (!$this->hasFlag($name)) { $flagEntry = $this->entry[PoTokens::FLAG]; if ($flagEntry === null) { $this->set(PoTokens::FLAG, $name); } elseif (is_array($flagEntry)) { $flagEntry[] = $name; $this->set(PoTokens::FLAG, implode(',', $flagEntry)); } else { $this->set(PoTokens::FLAG, $flagEntry . ',' . $name); } } }
[ "public", "function", "addFlag", "(", "string", "$", "name", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "hasFlag", "(", "$", "name", ")", ")", "{", "$", "flagEntry", "=", "$", "this", "->", "entry", "[", "PoTokens", "::", "FLAG", "]", ";", "if", "(", "$", "flagEntry", "===", "null", ")", "{", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "$", "name", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "flagEntry", ")", ")", "{", "$", "flagEntry", "[", "]", "=", "$", "name", ";", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "implode", "(", "','", ",", "$", "flagEntry", ")", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "$", "flagEntry", ".", "','", ".", "$", "name", ")", ";", "}", "}", "}" ]
add a flag to the entry @param string $name flag to check @return void
[ "add", "a", "flag", "to", "the", "entry" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L293-L306