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
partition
stringclasses
1 value
flavorzyb/simple
src/Session/SessionManager.php
SessionManager.createFileDriver
protected function createFileDriver() { $path = $this->config['files']; $fileSystem = Helper::getFileSystem(); if (!$fileSystem->isDirectory($path)) { throw new SessionException("session path({$path}) is not exists."); } return new FileSessionHandler($fileSystem, $path); }
php
protected function createFileDriver() { $path = $this->config['files']; $fileSystem = Helper::getFileSystem(); if (!$fileSystem->isDirectory($path)) { throw new SessionException("session path({$path}) is not exists."); } return new FileSessionHandler($fileSystem, $path); }
[ "protected", "function", "createFileDriver", "(", ")", "{", "$", "path", "=", "$", "this", "->", "config", "[", "'files'", "]", ";", "$", "fileSystem", "=", "Helper", "::", "getFileSystem", "(", ")", ";", "if", "(", "!", "$", "fileSystem", "->", "isDir...
create file session driver throw SessionException when session save path is not exists @return FileSessionHandler @throws SessionException
[ "create", "file", "session", "driver", "throw", "SessionException", "when", "session", "save", "path", "is", "not", "exists" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Session/SessionManager.php#L78-L89
train
flavorzyb/simple
src/Session/SessionManager.php
SessionManager.createMemcacheDriver
protected function createMemcacheDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $name = trim($this->config['server_name']); $prefix = trim($this->config['prefix']); $expireTime = intval($this->config['lifetime']); if ($persistent && (strlen($name) > 0)) { $memcached = new Memcached($name); } else { $memcached = new Memcached(); } if (!sizeof($memcached->getServerList())) { $memcached->addServers($serverArray); } $store = new MemcachedStore($memcached, $prefix); return new CacheSessionHandler($store, $expireTime); }
php
protected function createMemcacheDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $name = trim($this->config['server_name']); $prefix = trim($this->config['prefix']); $expireTime = intval($this->config['lifetime']); if ($persistent && (strlen($name) > 0)) { $memcached = new Memcached($name); } else { $memcached = new Memcached(); } if (!sizeof($memcached->getServerList())) { $memcached->addServers($serverArray); } $store = new MemcachedStore($memcached, $prefix); return new CacheSessionHandler($store, $expireTime); }
[ "protected", "function", "createMemcacheDriver", "(", ")", "{", "$", "serverArray", "=", "$", "this", "->", "config", "[", "'servers'", "]", ";", "$", "persistent", "=", "boolval", "(", "$", "this", "->", "config", "[", "'persistent'", "]", ")", ";", "$"...
create memcached session driver throw SessionException when session save path is not exists @return CacheSessionHandler
[ "create", "memcached", "session", "driver", "throw", "SessionException", "when", "session", "save", "path", "is", "not", "exists" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Session/SessionManager.php#L97-L117
train
flavorzyb/simple
src/Session/SessionManager.php
SessionManager.createRedisDriver
protected function createRedisDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $prefix = trim($this->config['prefix']); $expireTime = intval($this->config['lifetime']); if ($persistent) { foreach ($serverArray as $k => $v) { $v['persistent'] = true; $serverArray[$k] = $v; } } $redisServer = new RedisServer($serverArray); $redisStore = new RedisStore($redisServer, $prefix); return new CacheSessionHandler($redisStore, $expireTime); }
php
protected function createRedisDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $prefix = trim($this->config['prefix']); $expireTime = intval($this->config['lifetime']); if ($persistent) { foreach ($serverArray as $k => $v) { $v['persistent'] = true; $serverArray[$k] = $v; } } $redisServer = new RedisServer($serverArray); $redisStore = new RedisStore($redisServer, $prefix); return new CacheSessionHandler($redisStore, $expireTime); }
[ "protected", "function", "createRedisDriver", "(", ")", "{", "$", "serverArray", "=", "$", "this", "->", "config", "[", "'servers'", "]", ";", "$", "persistent", "=", "boolval", "(", "$", "this", "->", "config", "[", "'persistent'", "]", ")", ";", "$", ...
create redis server driver @return CacheSessionHandler
[ "create", "redis", "server", "driver" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Session/SessionManager.php#L124-L141
train
flavorzyb/simple
src/Session/SessionManager.php
SessionManager.getDriver
public function getDriver() { if (null != $this->driver) { return $this->driver; } switch($this->config['driver']) { case "file": $this->driver = $this->createFileDriver(); break; case "memcached": $this->driver = $this->createMemcacheDriver(); break; case "redis": $this->driver = $this->createRedisDriver(); break; default: throw new SessionException("Driver [{$this->config['driver']}] not supported."); } return $this->driver; }
php
public function getDriver() { if (null != $this->driver) { return $this->driver; } switch($this->config['driver']) { case "file": $this->driver = $this->createFileDriver(); break; case "memcached": $this->driver = $this->createMemcacheDriver(); break; case "redis": $this->driver = $this->createRedisDriver(); break; default: throw new SessionException("Driver [{$this->config['driver']}] not supported."); } return $this->driver; }
[ "public", "function", "getDriver", "(", ")", "{", "if", "(", "null", "!=", "$", "this", "->", "driver", ")", "{", "return", "$", "this", "->", "driver", ";", "}", "switch", "(", "$", "this", "->", "config", "[", "'driver'", "]", ")", "{", "case", ...
get session driver @return \SessionHandlerInterface @throws SessionException
[ "get", "session", "driver" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Session/SessionManager.php#L149-L170
train
flavorzyb/simple
src/Session/SessionManager.php
SessionManager.init
public function init() { session_set_save_handler($this->getDriver(), false); $this->setOptions($this->config->all()); session_start(); }
php
public function init() { session_set_save_handler($this->getDriver(), false); $this->setOptions($this->config->all()); session_start(); }
[ "public", "function", "init", "(", ")", "{", "session_set_save_handler", "(", "$", "this", "->", "getDriver", "(", ")", ",", "false", ")", ";", "$", "this", "->", "setOptions", "(", "$", "this", "->", "config", "->", "all", "(", ")", ")", ";", "sessi...
init session handler @throws SessionException
[ "init", "session", "handler" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Session/SessionManager.php#L177-L182
train
TAMULib/Pipit
Core/Classes/Data/UserDB.php
UserDB.logIn
public function logIn($username,$password) { session_regenerate_id(true); $sql = "SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0"; if ($result = $this->executeQuery($sql,array(":username"=>$username))) { if (password_verify($password,$result[0]['password'])) { $this->setSessionUserId($result[0]['id']); return true; } } return false; }
php
public function logIn($username,$password) { session_regenerate_id(true); $sql = "SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0"; if ($result = $this->executeQuery($sql,array(":username"=>$username))) { if (password_verify($password,$result[0]['password'])) { $this->setSessionUserId($result[0]['id']); return true; } } return false; }
[ "public", "function", "logIn", "(", "$", "username", ",", "$", "password", ")", "{", "session_regenerate_id", "(", "true", ")", ";", "$", "sql", "=", "\"SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0\"", ";", "if", "(", "$", "res...
Log in a User @param string $username The User's username @param string $password The User's password @return boolean True on successful login, false on anything else
[ "Log", "in", "a", "User" ]
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/UserDB.php#L98-L108
train
TAMULib/Pipit
Core/Classes/Data/UserDB.php
UserDB.buildProfile
protected function buildProfile() { $sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id"; if ($user = $this->executeQuery($sql,array(":id"=>$this->getSessionUserId()))[0]) { unset($user['password']); foreach ($user as $field=>$value) { $this->profile[$field] = $value; } } }
php
protected function buildProfile() { $sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id"; if ($user = $this->executeQuery($sql,array(":id"=>$this->getSessionUserId()))[0]) { unset($user['password']); foreach ($user as $field=>$value) { $this->profile[$field] = $value; } } }
[ "protected", "function", "buildProfile", "(", ")", "{", "$", "sql", "=", "\"SELECT * FROM {$this->primaryTable} WHERE id=:id\"", ";", "if", "(", "$", "user", "=", "$", "this", "->", "executeQuery", "(", "$", "sql", ",", "array", "(", "\":id\"", "=>", "$", "t...
Builds the User's profile data which is exposed to the application
[ "Builds", "the", "User", "s", "profile", "data", "which", "is", "exposed", "to", "the", "application" ]
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/UserDB.php#L113-L121
train
TAMULib/Pipit
Core/Classes/Data/UserDB.php
UserDB.getProfileValue
function getProfileValue($field) { $temp = $this->getProfile(); if (array_key_exists($field,$temp)) { return $temp[$field]; } return null; }
php
function getProfileValue($field) { $temp = $this->getProfile(); if (array_key_exists($field,$temp)) { return $temp[$field]; } return null; }
[ "function", "getProfileValue", "(", "$", "field", ")", "{", "$", "temp", "=", "$", "this", "->", "getProfile", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "temp", ")", ")", "{", "return", "$", "temp", "[", "$", "field...
Retrieves a particular profile value from the User's profile @param string $field The name of the profile value to retrieve @return mixed The value of the profile $field, null if the $field is not present on the profile
[ "Retrieves", "a", "particular", "profile", "value", "from", "the", "User", "s", "profile" ]
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/UserDB.php#L128-L134
train
samurai-fw/samurai
src/Samurai/Component/Core/ErrorList.php
ErrorList.add
public function add($key, $message) { if (! isset($this->errors[$key])) $this->errors[$key] = []; $this->errors[$key][] = $message; }
php
public function add($key, $message) { if (! isset($this->errors[$key])) $this->errors[$key] = []; $this->errors[$key][] = $message; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "message", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "errors", "[", "$", "key", "]", ")", ")", "$", "this", "->", "errors", "[", "$", "key", "]", "=", "[", "]", ";", "...
add error message @param string $key @param string $message
[ "add", "error", "message" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/ErrorList.php#L99-L103
train
samurai-fw/samurai
src/Samurai/Component/Core/ErrorList.php
ErrorList.getAllMessage
public function getAllMessage() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages[$key] = $this->getMessage($key); } return $messages; }
php
public function getAllMessage() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages[$key] = $this->getMessage($key); } return $messages; }
[ "public", "function", "getAllMessage", "(", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "errors", ")", "as", "$", "key", ")", "{", "$", "messages", "[", "$", "key", "]", "=", "$", "this", "...
get all each key @return array
[ "get", "all", "each", "key" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/ErrorList.php#L142-L149
train
samurai-fw/samurai
src/Samurai/Component/Core/ErrorList.php
ErrorList.getAllMessages
public function getAllMessages() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages = array_merge($messages, $this->getMessages($key)); } return $messages; }
php
public function getAllMessages() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages = array_merge($messages, $this->getMessages($key)); } return $messages; }
[ "public", "function", "getAllMessages", "(", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "errors", ")", "as", "$", "key", ")", "{", "$", "messages", "=", "array_merge", "(", "$", "messages", ",...
get all messages @return array
[ "get", "all", "messages" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/ErrorList.php#L156-L163
train
webriq/core
module/Core/src/Grid/Core/Model/Uri/Rpc.php
Rpc.isUriAvailable
public function isUriAvailable( $uri, $params = array() ) { $params = (object) $params; if ( empty( $params->subdomainId ) ) { return false; } return ! $this->getMapper() ->isSubdomainUriExists( $params->subdomainId, $uri, empty( $params->id ) ? null : $params->id ); }
php
public function isUriAvailable( $uri, $params = array() ) { $params = (object) $params; if ( empty( $params->subdomainId ) ) { return false; } return ! $this->getMapper() ->isSubdomainUriExists( $params->subdomainId, $uri, empty( $params->id ) ? null : $params->id ); }
[ "public", "function", "isUriAvailable", "(", "$", "uri", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "=", "(", "object", ")", "$", "params", ";", "if", "(", "empty", "(", "$", "params", "->", "subdomainId", ")", ")", "{", ...
Return true, if uri is available in a subdomain @param string $uri @param array|object $params subdomainId, [id] @return bool
[ "Return", "true", "if", "uri", "is", "available", "in", "a", "subdomain" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Uri/Rpc.php#L39-L54
train
novuso/common
src/Application/Templating/Exception/DuplicateHelperException.php
DuplicateHelperException.fromName
public static function fromName(string $name, ?Throwable $previous = null): DuplicateHelperException { $message = sprintf('Duplicate helper: %s', $name); return new static($message, $name, $previous); }
php
public static function fromName(string $name, ?Throwable $previous = null): DuplicateHelperException { $message = sprintf('Duplicate helper: %s', $name); return new static($message, $name, $previous); }
[ "public", "static", "function", "fromName", "(", "string", "$", "name", ",", "?", "Throwable", "$", "previous", "=", "null", ")", ":", "DuplicateHelperException", "{", "$", "message", "=", "sprintf", "(", "'Duplicate helper: %s'", ",", "$", "name", ")", ";",...
Creates exception for a given helper name @param string $name The helper name @param Throwable|null $previous The previous exception @return DuplicateHelperException
[ "Creates", "exception", "for", "a", "given", "helper", "name" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Templating/Exception/DuplicateHelperException.php#L44-L49
train
kuria/enum
src/EnumObject.php
EnumObject.fromKey
static function fromKey(string $key) { return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
php
static function fromKey(string $key) { return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
[ "static", "function", "fromKey", "(", "string", "$", "key", ")", "{", "return", "self", "::", "$", "instanceCache", "[", "static", "::", "class", "]", "[", "$", "key", "]", "??", "(", "self", "::", "$", "instanceCache", "[", "static", "::", "class", ...
Get instance for the given key @throws InvalidKeyException if there is no such key @return static
[ "Get", "instance", "for", "the", "given", "key" ]
9d9c1907f8a6910552b50b175398393909028eaa
https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/EnumObject.php#L87-L91
train
kuria/enum
src/EnumObject.php
EnumObject.fromValue
static function fromValue($value) { $key = self::getKey($value); return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
php
static function fromValue($value) { $key = self::getKey($value); return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
[ "static", "function", "fromValue", "(", "$", "value", ")", "{", "$", "key", "=", "self", "::", "getKey", "(", "$", "value", ")", ";", "return", "self", "::", "$", "instanceCache", "[", "static", "::", "class", "]", "[", "$", "key", "]", "??", "(", ...
Get instance for the given value @throws InvalidValueException if there is no such value @return static
[ "Get", "instance", "for", "the", "given", "value" ]
9d9c1907f8a6910552b50b175398393909028eaa
https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/EnumObject.php#L99-L105
train
kuria/enum
src/EnumObject.php
EnumObject.all
static function all(): array { $instances = []; foreach (static::getMap() as $key => $value) { $instances[$key] = self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, $value)); } return $instances; }
php
static function all(): array { $instances = []; foreach (static::getMap() as $key => $value) { $instances[$key] = self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, $value)); } return $instances; }
[ "static", "function", "all", "(", ")", ":", "array", "{", "$", "instances", "=", "[", "]", ";", "foreach", "(", "static", "::", "getMap", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "instances", "[", "$", "key", "]", "=", "se...
Get instance for each defined key-value pair @return static[]
[ "Get", "instance", "for", "each", "defined", "key", "-", "value", "pair" ]
9d9c1907f8a6910552b50b175398393909028eaa
https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/EnumObject.php#L112-L122
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.numeroFormatoBrParaSql
public function numeroFormatoBrParaSql($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com o ponto $numero = str_replace(".", "", $numero); //Substitui separador de decimal de virgula para ponto $numero = str_replace(",", ".", $numero); if (!is_numeric($numero)) { return false; } return $numero; }
php
public function numeroFormatoBrParaSql($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com o ponto $numero = str_replace(".", "", $numero); //Substitui separador de decimal de virgula para ponto $numero = str_replace(",", ".", $numero); if (!is_numeric($numero)) { return false; } return $numero; }
[ "public", "function", "numeroFormatoBrParaSql", "(", "$", "numero", ")", "{", "//Retira espaços", "$", "numero", "=", "trim", "(", "$", "numero", ")", ";", "//Retira separador de milhar com o ponto", "$", "numero", "=", "str_replace", "(", "\".\"", ",", "\"\"", ...
Converter um numero de um formato '12.345.678,00' para um formato '12345678.00'. @param string $numero @return false|mixed
[ "Converter", "um", "numero", "de", "um", "formato", "12", ".", "345", ".", "678", "00", "para", "um", "formato", "12345678", ".", "00", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L127-L143
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.numeroFormatoSqlParaBr
public function numeroFormatoSqlParaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(",", "", $numero); if (!is_numeric($numero)) { return false; } //Se não tiver ponto if (strpos($numero, '.') === false) { return number_format($numero, 0, ",", "."); } return number_format($numero, 2, ",", "."); }
php
public function numeroFormatoSqlParaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(",", "", $numero); if (!is_numeric($numero)) { return false; } //Se não tiver ponto if (strpos($numero, '.') === false) { return number_format($numero, 0, ",", "."); } return number_format($numero, 2, ",", "."); }
[ "public", "function", "numeroFormatoSqlParaBr", "(", "$", "numero", ")", "{", "//Retira espaços", "$", "numero", "=", "trim", "(", "$", "numero", ")", ";", "//Retira separador de milhar com a virgula", "$", "numero", "=", "str_replace", "(", "\",\"", ",", "\"\"", ...
Converter um numero de um formato '12345678.00' para um formato '12.345.678,00' com ou sem casas decimais. @param $numero @return false|string
[ "Converter", "um", "numero", "de", "um", "formato", "12345678", ".", "00", "para", "um", "formato", "12", ".", "345", ".", "678", "00", "com", "ou", "sem", "casas", "decimais", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L151-L169
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.numeroFormatoSqlParaMoedaBr
public function numeroFormatoSqlParaMoedaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(",", "", $numero); if(!is_numeric($numero)){ return false; } return number_format($numero, 2, ",", "."); }
php
public function numeroFormatoSqlParaMoedaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(",", "", $numero); if(!is_numeric($numero)){ return false; } return number_format($numero, 2, ",", "."); }
[ "public", "function", "numeroFormatoSqlParaMoedaBr", "(", "$", "numero", ")", "{", "//Retira espaços", "$", "numero", "=", "trim", "(", "$", "numero", ")", ";", "//Retira separador de milhar com a virgula", "$", "numero", "=", "str_replace", "(", "\",\"", ",", "\"...
Converter um numero de um formato '12345678' para um formato '12.345.678,00' sempre com casas decimais. @param $numero @return false|string
[ "Converter", "um", "numero", "de", "um", "formato", "12345678", "para", "um", "formato", "12", ".", "345", ".", "678", "00", "sempre", "com", "casas", "decimais", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L177-L190
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.numeroFormatoBrParaMoedaBr
public function numeroFormatoBrParaMoedaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(".", "", $numero); //transforma para numero $numero = str_replace(",", ".", $numero); if(!is_numeric($numero)){ return false; } return number_format($numero, 2, ",", "."); }
php
public function numeroFormatoBrParaMoedaBr($numero) { //Retira espaços $numero = trim($numero); //Retira separador de milhar com a virgula $numero = str_replace(".", "", $numero); //transforma para numero $numero = str_replace(",", ".", $numero); if(!is_numeric($numero)){ return false; } return number_format($numero, 2, ",", "."); }
[ "public", "function", "numeroFormatoBrParaMoedaBr", "(", "$", "numero", ")", "{", "//Retira espaços", "$", "numero", "=", "trim", "(", "$", "numero", ")", ";", "//Retira separador de milhar com a virgula", "$", "numero", "=", "str_replace", "(", "\".\"", ",", "\"\...
Converter um numero de um formato '2345678,00' para um formato '12.345.678,00' sempre com casas decimais. @param string $numero @return false|mixed
[ "Converter", "um", "numero", "de", "um", "formato", "2345678", "00", "para", "um", "formato", "12", ".", "345", ".", "678", "00", "sempre", "com", "casas", "decimais", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L198-L213
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.checarValorArrayMultidimensional
public function checarValorArrayMultidimensional($key, $value, array $array) { foreach ($array as $a) { if (isset($a[$key]) && $a[$key] == $value) { return true; } } return false; }
php
public function checarValorArrayMultidimensional($key, $value, array $array) { foreach ($array as $a) { if (isset($a[$key]) && $a[$key] == $value) { return true; } } return false; }
[ "public", "function", "checarValorArrayMultidimensional", "(", "$", "key", ",", "$", "value", ",", "array", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "a", ")", "{", "if", "(", "isset", "(", "$", "a", "[", "$", "key", "]", ")"...
Checar se um valor existe em um array multidimensional @param string $key @param string $value @param array $array @return bool
[ "Checar", "se", "um", "valor", "existe", "em", "um", "array", "multidimensional" ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L223-L231
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.formatarIeCpfCnpj
function formatarIeCpfCnpj($valor) { if (strlen($valor) == 9) { return $this->formatarIe($valor); } if (strlen($valor) == 11) { return $this->formatarCpf($valor); } return $this->formatarCnpj($valor); }
php
function formatarIeCpfCnpj($valor) { if (strlen($valor) == 9) { return $this->formatarIe($valor); } if (strlen($valor) == 11) { return $this->formatarCpf($valor); } return $this->formatarCnpj($valor); }
[ "function", "formatarIeCpfCnpj", "(", "$", "valor", ")", "{", "if", "(", "strlen", "(", "$", "valor", ")", "==", "9", ")", "{", "return", "$", "this", "->", "formatarIe", "(", "$", "valor", ")", ";", "}", "if", "(", "strlen", "(", "$", "valor", "...
Converter um numero para os formatos de Inscricao Estadual, Cpf ou Cnpj, de acordo com o tamanho do parametro informado. @param $valor @return string
[ "Converter", "um", "numero", "para", "os", "formatos", "de", "Inscricao", "Estadual", "Cpf", "ou", "Cnpj", "de", "acordo", "com", "o", "tamanho", "do", "parametro", "informado", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L314-L325
train
motamonteiro/helpers
src/Traits/StringHelper.php
StringHelper.formatarTelefone
function formatarTelefone($valor) { if (strlen($valor) < 10) { return $this->formatarValor($valor, '####-####'); } if (strlen($valor) == 10) { return $this->formatarValor($valor, '(##) ####-####'); } return $this->formatarValor($valor, '(##) #####-####'); }
php
function formatarTelefone($valor) { if (strlen($valor) < 10) { return $this->formatarValor($valor, '####-####'); } if (strlen($valor) == 10) { return $this->formatarValor($valor, '(##) ####-####'); } return $this->formatarValor($valor, '(##) #####-####'); }
[ "function", "formatarTelefone", "(", "$", "valor", ")", "{", "if", "(", "strlen", "(", "$", "valor", ")", "<", "10", ")", "{", "return", "$", "this", "->", "formatarValor", "(", "$", "valor", ",", "'####-####'", ")", ";", "}", "if", "(", "strlen", ...
Converter um numero para os formatos de telefone simples, telefone com ddd ou telefone celular, de acordo com o tamanho do parametro informado. @param $valor @return string
[ "Converter", "um", "numero", "para", "os", "formatos", "de", "telefone", "simples", "telefone", "com", "ddd", "ou", "telefone", "celular", "de", "acordo", "com", "o", "tamanho", "do", "parametro", "informado", "." ]
4cd246d454968865758e74c5be383063e0f7ccd4
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L333-L344
train
MadrakIO/extendable-configuration-bundle
Controller/AbstractExtendableConfigurationController.php
AbstractExtendableConfigurationController.indexAction
public function indexAction(Request $request) { $form = $this->createForm(new ExtendableConfigurationType($this->get('madrak_io_extendable_configuration.extendable_configuration_chain')->getBuiltConfiguration())); $form->setData($this->get('madrak_io_extendable_configuration.configuration_service')->getAll()); $form->handleRequest($request); if ($form->isValid() === true) { $entityClass = $this->getParameter('madrak_io_extendable_configuration.configuration_class'); $entityManager = $this->get('doctrine.orm.default_entity_manager'); $repository = $entityManager->getRepository($entityClass); $recursiveIteratorIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($form->getData()['configuration'])); foreach ($recursiveIteratorIterator as $configurationValue) { $keys = []; for ($depth = 0; $depth <= $recursiveIteratorIterator->getDepth(); ++$depth) { $keys[] = $recursiveIteratorIterator->getSubIterator($depth)->key(); } $configurationField = implode('.', $keys); $configurationEntity = $repository->findOneBy(['field' => $configurationField]); if (($configurationEntity instanceof $entityClass) === false) { $configurationEntity = new $entityClass(); $configurationEntity->setField($configurationField); } $configurationEntity->setValue($configurationValue); $entityManager->persist($configurationEntity); } $entityManager->flush(); } return $this->render('MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig', [ 'parent_template' => $this->getParentTemplate(), 'form' => $form->createView(), ]); }
php
public function indexAction(Request $request) { $form = $this->createForm(new ExtendableConfigurationType($this->get('madrak_io_extendable_configuration.extendable_configuration_chain')->getBuiltConfiguration())); $form->setData($this->get('madrak_io_extendable_configuration.configuration_service')->getAll()); $form->handleRequest($request); if ($form->isValid() === true) { $entityClass = $this->getParameter('madrak_io_extendable_configuration.configuration_class'); $entityManager = $this->get('doctrine.orm.default_entity_manager'); $repository = $entityManager->getRepository($entityClass); $recursiveIteratorIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($form->getData()['configuration'])); foreach ($recursiveIteratorIterator as $configurationValue) { $keys = []; for ($depth = 0; $depth <= $recursiveIteratorIterator->getDepth(); ++$depth) { $keys[] = $recursiveIteratorIterator->getSubIterator($depth)->key(); } $configurationField = implode('.', $keys); $configurationEntity = $repository->findOneBy(['field' => $configurationField]); if (($configurationEntity instanceof $entityClass) === false) { $configurationEntity = new $entityClass(); $configurationEntity->setField($configurationField); } $configurationEntity->setValue($configurationValue); $entityManager->persist($configurationEntity); } $entityManager->flush(); } return $this->render('MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig', [ 'parent_template' => $this->getParentTemplate(), 'form' => $form->createView(), ]); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ExtendableConfigurationType", "(", "$", "this", "->", "get", "(", "'madrak_io_extendable_configuration.extendable_configura...
Lists all available configurations. @Route("/") @Method("GET|POST")
[ "Lists", "all", "available", "configurations", "." ]
f6fec2913a52ad634852df41b29a0dbbf16eeb47
https://github.com/MadrakIO/extendable-configuration-bundle/blob/f6fec2913a52ad634852df41b29a0dbbf16eeb47/Controller/AbstractExtendableConfigurationController.php#L23-L63
train
juanparati/Emoji
src/Emoji.php
Emoji.char
public static function char($symbol) { if (is_string($symbol) && EmojiDictionary::get($symbol)) $symbol = EmojiDictionary::get($symbol); // In case that multiple unicode sequences are used if (is_array($symbol)) { $output = ''; foreach ($symbol as $sequence) $output .= self::char($sequence); return $output; } return self::uni2utf8($symbol); // Another alternative solution is to use mb_convert_encoding (Slow and it requires MB) // echo mb_convert_encoding('&#x1F600;', 'UTF-8', 'HTML-ENTITIES'); }
php
public static function char($symbol) { if (is_string($symbol) && EmojiDictionary::get($symbol)) $symbol = EmojiDictionary::get($symbol); // In case that multiple unicode sequences are used if (is_array($symbol)) { $output = ''; foreach ($symbol as $sequence) $output .= self::char($sequence); return $output; } return self::uni2utf8($symbol); // Another alternative solution is to use mb_convert_encoding (Slow and it requires MB) // echo mb_convert_encoding('&#x1F600;', 'UTF-8', 'HTML-ENTITIES'); }
[ "public", "static", "function", "char", "(", "$", "symbol", ")", "{", "if", "(", "is_string", "(", "$", "symbol", ")", "&&", "EmojiDictionary", "::", "get", "(", "$", "symbol", ")", ")", "$", "symbol", "=", "EmojiDictionary", "::", "get", "(", "$", "...
Return an emoji as char @param $symbol @return bool|string
[ "Return", "an", "emoji", "as", "char" ]
53a34e1d3714f2a11ddc0451030eee06ea2f8f21
https://github.com/juanparati/Emoji/blob/53a34e1d3714f2a11ddc0451030eee06ea2f8f21/src/Emoji.php#L18-L40
train
juanparati/Emoji
src/Emoji.php
Emoji.html
public static function html($symbol) { if (is_string($symbol) && EmojiDictionary::get($symbol)) $symbol = EmojiDictionary::get($symbol); // In case that multiple unicode sequences are used if (is_array($symbol)) { $output = ''; foreach ($symbol as $sequence) $output .= self::html($sequence); return $output; } $symbol = dechex($symbol); return '&#x' . $symbol; }
php
public static function html($symbol) { if (is_string($symbol) && EmojiDictionary::get($symbol)) $symbol = EmojiDictionary::get($symbol); // In case that multiple unicode sequences are used if (is_array($symbol)) { $output = ''; foreach ($symbol as $sequence) $output .= self::html($sequence); return $output; } $symbol = dechex($symbol); return '&#x' . $symbol; }
[ "public", "static", "function", "html", "(", "$", "symbol", ")", "{", "if", "(", "is_string", "(", "$", "symbol", ")", "&&", "EmojiDictionary", "::", "get", "(", "$", "symbol", ")", ")", "$", "symbol", "=", "EmojiDictionary", "::", "get", "(", "$", "...
Return an emoji as a html entity @param $symbol @return string
[ "Return", "an", "emoji", "as", "a", "html", "entity" ]
53a34e1d3714f2a11ddc0451030eee06ea2f8f21
https://github.com/juanparati/Emoji/blob/53a34e1d3714f2a11ddc0451030eee06ea2f8f21/src/Emoji.php#L49-L71
train
Morannon/Morannon
src/Morannon/Base/Utils/UrlUtils.php
UrlUtils.removeTrainingSlash
public function removeTrainingSlash($url) { if (null === $url || strlen($url) <= 2) { return $url; } return (substr($url, -1, 1) == '/')? substr($url, 0, -1) : $url; }
php
public function removeTrainingSlash($url) { if (null === $url || strlen($url) <= 2) { return $url; } return (substr($url, -1, 1) == '/')? substr($url, 0, -1) : $url; }
[ "public", "function", "removeTrainingSlash", "(", "$", "url", ")", "{", "if", "(", "null", "===", "$", "url", "||", "strlen", "(", "$", "url", ")", "<=", "2", ")", "{", "return", "$", "url", ";", "}", "return", "(", "substr", "(", "$", "url", ","...
Removes a trailing slash from an url string. @param string $url @return string
[ "Removes", "a", "trailing", "slash", "from", "an", "url", "string", "." ]
1990d830452625c41eb4c1d1ff3313fb892b12f3
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L14-L21
train
Morannon/Morannon
src/Morannon/Base/Utils/UrlUtils.php
UrlUtils.buildUrlString
public function buildUrlString($baseUrl, $resource) { if (null === $baseUrl || '' == $baseUrl) { return null; } if (null === $resource || '' == $resource) { return $baseUrl; } $baseUrl = $this->removeTrainingSlash($baseUrl); if (!substr($resource, 0, 1) == '/') { $resource = '/' . $resource; } return $baseUrl . $resource; }
php
public function buildUrlString($baseUrl, $resource) { if (null === $baseUrl || '' == $baseUrl) { return null; } if (null === $resource || '' == $resource) { return $baseUrl; } $baseUrl = $this->removeTrainingSlash($baseUrl); if (!substr($resource, 0, 1) == '/') { $resource = '/' . $resource; } return $baseUrl . $resource; }
[ "public", "function", "buildUrlString", "(", "$", "baseUrl", ",", "$", "resource", ")", "{", "if", "(", "null", "===", "$", "baseUrl", "||", "''", "==", "$", "baseUrl", ")", "{", "return", "null", ";", "}", "if", "(", "null", "===", "$", "resource", ...
Returns either the concatenated string or null on wrong params. @param string $baseUrl @param string $resource @return string|null Null on invalid {$baseUrl}
[ "Returns", "either", "the", "concatenated", "string", "or", "null", "on", "wrong", "params", "." ]
1990d830452625c41eb4c1d1ff3313fb892b12f3
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L30-L46
train
Morannon/Morannon
src/Morannon/Base/Utils/UrlUtils.php
UrlUtils.parseNewLineSeparatedBody
public function parseNewLineSeparatedBody($body) { $data = array(); if (!$body) { return $data; } $parts = preg_split("/\\r?\\n/", $body); foreach ($parts as $str) { if (!$str) { continue; } list ($key, $value) = explode('=', $str); $data[$key] = $value; } return $data; }
php
public function parseNewLineSeparatedBody($body) { $data = array(); if (!$body) { return $data; } $parts = preg_split("/\\r?\\n/", $body); foreach ($parts as $str) { if (!$str) { continue; } list ($key, $value) = explode('=', $str); $data[$key] = $value; } return $data; }
[ "public", "function", "parseNewLineSeparatedBody", "(", "$", "body", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "!", "$", "body", ")", "{", "return", "$", "data", ";", "}", "$", "parts", "=", "preg_split", "(", "\"/\\\\r?\\\\n/\"", ...
Separates given string in key value parts. @param string $body @return array
[ "Separates", "given", "string", "in", "key", "value", "parts", "." ]
1990d830452625c41eb4c1d1ff3313fb892b12f3
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L54-L73
train
ItalyStrap/debug
src/Debug/Asset_Queued.php
Asset_Queued.make_output
private function make_output( $assets, $type ) { $output = ''; $output .= '<pre>' . $type . ' trovati in coda'."\r\n"; foreach ( $assets->queue as $asset ) { if ( ! isset( $assets->registered[ $asset ] ) ) { continue; } $output .= "\r\nHandle: <strong>" . $asset . "</strong>\n"; $output .= "<i class='small'>URL: " . $assets->registered[ $asset ]->src . "</i class='small'>\r\n"; $deps = $assets->registered[ $asset ]->deps; if ( $deps ) { $output .= 'Dipende da >>>>>>> '; // $output .= print_r( $deps, true ); foreach ( $deps as $dep ) { $output .= '<strong>' . $dep . '</strong>, '; } $output .= "\r\n"; } else { $output .= "Non dipende da nessuno\r\n"; } } $output .= "\r\n</pre>"; return $output; }
php
private function make_output( $assets, $type ) { $output = ''; $output .= '<pre>' . $type . ' trovati in coda'."\r\n"; foreach ( $assets->queue as $asset ) { if ( ! isset( $assets->registered[ $asset ] ) ) { continue; } $output .= "\r\nHandle: <strong>" . $asset . "</strong>\n"; $output .= "<i class='small'>URL: " . $assets->registered[ $asset ]->src . "</i class='small'>\r\n"; $deps = $assets->registered[ $asset ]->deps; if ( $deps ) { $output .= 'Dipende da >>>>>>> '; // $output .= print_r( $deps, true ); foreach ( $deps as $dep ) { $output .= '<strong>' . $dep . '</strong>, '; } $output .= "\r\n"; } else { $output .= "Non dipende da nessuno\r\n"; } } $output .= "\r\n</pre>"; return $output; }
[ "private", "function", "make_output", "(", "$", "assets", ",", "$", "type", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "'<pre>'", ".", "$", "type", ".", "' trovati in coda'", ".", "\"\\r\\n\"", ";", "foreach", "(", "$", "assets", "->...
Make the list assets output. @param WP_Style|WP_Script $assets WP_Style or WP_Script object. @return string Return the list of asset enqueued.
[ "Make", "the", "list", "assets", "output", "." ]
955951b3df3a5c91bdc4cba51348645ccca6bddd
https://github.com/ItalyStrap/debug/blob/955951b3df3a5c91bdc4cba51348645ccca6bddd/src/Debug/Asset_Queued.php#L63-L91
train
AlcyZ/Alcys-ORM
src/Core/Db/Factory/ExpressionBuilderFactory.php
ExpressionBuilderFactory.create
public function create(ExpressionInterface $expression = null) { if($expression instanceof ConditionInterface) { return new ConditionBuilder($expression); } elseif($expression instanceof JoinInterface) { return new JoinBuilder($expression); } else { return new NullBuilder(); } }
php
public function create(ExpressionInterface $expression = null) { if($expression instanceof ConditionInterface) { return new ConditionBuilder($expression); } elseif($expression instanceof JoinInterface) { return new JoinBuilder($expression); } else { return new NullBuilder(); } }
[ "public", "function", "create", "(", "ExpressionInterface", "$", "expression", "=", "null", ")", "{", "if", "(", "$", "expression", "instanceof", "ConditionInterface", ")", "{", "return", "new", "ConditionBuilder", "(", "$", "expression", ")", ";", "}", "elsei...
Create and return an instance of a specific expression builder. @param ExpressionInterface|JoinInterface|ConditionInterface $expression @return ConditionBuilder|JoinBuilder|NullBuilder
[ "Create", "and", "return", "an", "instance", "of", "a", "specific", "expression", "builder", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Factory/ExpressionBuilderFactory.php#L47-L61
train
kyoya-de/php-job-runner
src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php
PhpSerialize.persist
public function persist($identifier, ParameterBagInterface $parameterBag) { $stateFilename = $this->getStateFilename($identifier); if (!touch($stateFilename) || (file_exists($stateFilename) && !is_writable($stateFilename))) { throw new IOException("State isn't writable!"); } file_put_contents($stateFilename, serialize($parameterBag)); }
php
public function persist($identifier, ParameterBagInterface $parameterBag) { $stateFilename = $this->getStateFilename($identifier); if (!touch($stateFilename) || (file_exists($stateFilename) && !is_writable($stateFilename))) { throw new IOException("State isn't writable!"); } file_put_contents($stateFilename, serialize($parameterBag)); }
[ "public", "function", "persist", "(", "$", "identifier", ",", "ParameterBagInterface", "$", "parameterBag", ")", "{", "$", "stateFilename", "=", "$", "this", "->", "getStateFilename", "(", "$", "identifier", ")", ";", "if", "(", "!", "touch", "(", "$", "st...
Puts the parameter bag to a persistent storage. @param string $identifier @param ParameterBagInterface $parameterBag @throws IOException If the state file isn't writable. @return void
[ "Puts", "the", "parameter", "bag", "to", "a", "persistent", "storage", "." ]
c161c1e391d857ecd19e256593ced671bc13f5ff
https://github.com/kyoya-de/php-job-runner/blob/c161c1e391d857ecd19e256593ced671bc13f5ff/src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php#L32-L40
train
kyoya-de/php-job-runner
src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php
PhpSerialize.load
public function load($identifier, ParameterBagInterface $parameterBag) { $stateFilename = $this->getStateFilename($identifier); if (!file_exists($stateFilename)) { throw new IOException("State file {$stateFilename} doesn't exist!"); } $stateFileContent = file_get_contents($stateFilename); $parameterBag->add(unserialize($stateFileContent)); }
php
public function load($identifier, ParameterBagInterface $parameterBag) { $stateFilename = $this->getStateFilename($identifier); if (!file_exists($stateFilename)) { throw new IOException("State file {$stateFilename} doesn't exist!"); } $stateFileContent = file_get_contents($stateFilename); $parameterBag->add(unserialize($stateFileContent)); }
[ "public", "function", "load", "(", "$", "identifier", ",", "ParameterBagInterface", "$", "parameterBag", ")", "{", "$", "stateFilename", "=", "$", "this", "->", "getStateFilename", "(", "$", "identifier", ")", ";", "if", "(", "!", "file_exists", "(", "$", ...
Loads the parameter bag from a persistent storage. @param string $identifier @param ParameterBagInterface $parameterBag @throws IOException If state file doesn't exist. @return void
[ "Loads", "the", "parameter", "bag", "from", "a", "persistent", "storage", "." ]
c161c1e391d857ecd19e256593ced671bc13f5ff
https://github.com/kyoya-de/php-job-runner/blob/c161c1e391d857ecd19e256593ced671bc13f5ff/src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php#L52-L62
train
chemel/addic7ed-cli
src/Scrapper/Addic7edScrapper.php
Addic7edScrapper.parse
protected function parse($url) { $html = $this->get($url)->getBody()->getContents(); $parser = $this->getParser($html); return $parser; }
php
protected function parse($url) { $html = $this->get($url)->getBody()->getContents(); $parser = $this->getParser($html); return $parser; }
[ "protected", "function", "parse", "(", "$", "url", ")", "{", "$", "html", "=", "$", "this", "->", "get", "(", "$", "url", ")", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ";", "$", "parser", "=", "$", "this", "->", "getParser", "(",...
Parse HTML page @param string url @return Crawler parser
[ "Parse", "HTML", "page" ]
e10ff6f4a3a37151b9141f15c231ba480aa1c78c
https://github.com/chemel/addic7ed-cli/blob/e10ff6f4a3a37151b9141f15c231ba480aa1c78c/src/Scrapper/Addic7edScrapper.php#L68-L75
train
mszewcz/php-light-framework
src/Db/MySQL/Query/Insert.php
Insert.into
public function into($table = null): Insert { $this->into = []; if (!\is_string($table) && !\is_array($table)) { throw new InvalidArgumentException('$table has to be an array or a string'); } $this->into = $this->namesClass->parse($table, true); return $this; }
php
public function into($table = null): Insert { $this->into = []; if (!\is_string($table) && !\is_array($table)) { throw new InvalidArgumentException('$table has to be an array or a string'); } $this->into = $this->namesClass->parse($table, true); return $this; }
[ "public", "function", "into", "(", "$", "table", "=", "null", ")", ":", "Insert", "{", "$", "this", "->", "into", "=", "[", "]", ";", "if", "(", "!", "\\", "is_string", "(", "$", "table", ")", "&&", "!", "\\", "is_array", "(", "$", "table", ")"...
Adds table names for insert @param mixed|null $table @return Insert
[ "Adds", "table", "names", "for", "insert" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Insert.php#L54-L63
train
konservs/brilliant.framework
libraries/Items/BItemsItemRTree.php
BItemsItemRTree.getCollection
public function getCollection() { $collectionName = $this->collectionName; if(empty($collectionName)){ return NULL; } $collection = $collectionName::getInstance(); return $collection; }
php
public function getCollection() { $collectionName = $this->collectionName; if(empty($collectionName)){ return NULL; } $collection = $collectionName::getInstance(); return $collection; }
[ "public", "function", "getCollection", "(", ")", "{", "$", "collectionName", "=", "$", "this", "->", "collectionName", ";", "if", "(", "empty", "(", "$", "collectionName", ")", ")", "{", "return", "NULL", ";", "}", "$", "collection", "=", "$", "collectio...
Get collection of such elements @return BItemsRTree
[ "Get", "collection", "of", "such", "elements" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItemRTree.php#L49-L56
train
konservs/brilliant.framework
libraries/Items/BItemsItemRTree.php
BItemsItemRTree.getfieldsvalues
protected function getfieldsvalues(&$qr_fields, &$qr_values) { $qr_fields = array(); $qr_values = array(); parent::getfieldsvalues($qr_fields, $qr_values); if (empty($this->{$this->parentKeyName})) { $qr_fields[] = '`' . $this->parentKeyName . '`'; $qr_values[] = 'NULL'; } else { $qr_fields[] = '`' . $this->parentKeyName . '`'; $qr_values[] = $this->{$this->parentKeyName}; } $qr_fields[] = '`' . $this->leftKeyName . '`'; $qr_values[] = $this->{$this->leftKeyName}; $qr_fields[] = '`' . $this->rightKeyName . '`'; $qr_values[] = $this->{$this->rightKeyName}; $qr_fields[] = '`' . $this->levelKeyName . '`'; $qr_values[] = $this->{$this->levelKeyName}; $qr_fields[] = '`' . $this->groupKeyName . '`'; $qr_values[] = $this->{$this->groupKeyName}; return true; }
php
protected function getfieldsvalues(&$qr_fields, &$qr_values) { $qr_fields = array(); $qr_values = array(); parent::getfieldsvalues($qr_fields, $qr_values); if (empty($this->{$this->parentKeyName})) { $qr_fields[] = '`' . $this->parentKeyName . '`'; $qr_values[] = 'NULL'; } else { $qr_fields[] = '`' . $this->parentKeyName . '`'; $qr_values[] = $this->{$this->parentKeyName}; } $qr_fields[] = '`' . $this->leftKeyName . '`'; $qr_values[] = $this->{$this->leftKeyName}; $qr_fields[] = '`' . $this->rightKeyName . '`'; $qr_values[] = $this->{$this->rightKeyName}; $qr_fields[] = '`' . $this->levelKeyName . '`'; $qr_values[] = $this->{$this->levelKeyName}; $qr_fields[] = '`' . $this->groupKeyName . '`'; $qr_values[] = $this->{$this->groupKeyName}; return true; }
[ "protected", "function", "getfieldsvalues", "(", "&", "$", "qr_fields", ",", "&", "$", "qr_values", ")", "{", "$", "qr_fields", "=", "array", "(", ")", ";", "$", "qr_values", "=", "array", "(", ")", ";", "parent", "::", "getfieldsvalues", "(", "$", "qr...
Get values of fields. @param $qr_fields @param $qr_values @return bool
[ "Get", "values", "of", "fields", "." ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItemRTree.php#L65-L87
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
InventoryItemController.newAction
public function newAction(Inventory $inventory) { $inventoryitem = new InventoryItem(); $inventoryitem->setInventory($inventory); $form = $this->createForm(new InventoryItemType(), $inventoryitem); return array( 'inventoryitem' => $inventoryitem, 'form' => $form->createView(), ); }
php
public function newAction(Inventory $inventory) { $inventoryitem = new InventoryItem(); $inventoryitem->setInventory($inventory); $form = $this->createForm(new InventoryItemType(), $inventoryitem); return array( 'inventoryitem' => $inventoryitem, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", "Inventory", "$", "inventory", ")", "{", "$", "inventoryitem", "=", "new", "InventoryItem", "(", ")", ";", "$", "inventoryitem", "->", "setInventory", "(", "$", "inventory", ")", ";", "$", "form", "=", "$", "this", ...
Displays a form to create a new InventoryItem entity. @Route("/inventory/{id}/new", name="stock_inventoryitem_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "InventoryItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L72-L82
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
InventoryItemController.createAction
public function createAction(Request $request) { $inventoryitem = new InventoryItem(); $form = $this->createForm(new InventoryItemType(), $inventoryitem); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($inventoryitem); $em->flush(); return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventoryitem->getInventory()->getId()))); } return array( 'inventoryitem' => $inventoryitem, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $inventoryitem = new InventoryItem(); $form = $this->createForm(new InventoryItemType(), $inventoryitem); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($inventoryitem); $em->flush(); return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventoryitem->getInventory()->getId()))); } return array( 'inventoryitem' => $inventoryitem, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "inventoryitem", "=", "new", "InventoryItem", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "InventoryItemType", "(", ")", ",", "$", "inv...
Creates a new InventoryItem entity. @Route("/create", name="stock_inventoryitem_create") @Method("POST") @Template("FlowerStockBundle:InventoryItem:new.html.twig")
[ "Creates", "a", "new", "InventoryItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L91-L107
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
InventoryItemController.editAction
public function editAction(InventoryItem $inventoryitem) { $editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array( 'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete'); return array( 'inventoryitem' => $inventoryitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editAction(InventoryItem $inventoryitem) { $editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array( 'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete'); return array( 'inventoryitem' => $inventoryitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editAction", "(", "InventoryItem", "$", "inventoryitem", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "InventoryItemType", "(", ")", ",", "$", "inventoryitem", ",", "array", "(", "'action'", "=>", "$", ...
Displays a form to edit an existing InventoryItem entity. @Route("/{id}/edit", name="stock_inventoryitem_edit", requirements={"id"="\d+"}) @Method("GET") @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "InventoryItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L116-L129
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
InventoryItemController.updateAction
public function updateAction(InventoryItem $inventoryitem, Request $request) { $editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array( 'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_inventoryitem_show', array('id' => $inventoryitem->getId()))); } $deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete'); return array( 'inventoryitem' => $inventoryitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(InventoryItem $inventoryitem, Request $request) { $editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array( 'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_inventoryitem_show', array('id' => $inventoryitem->getId()))); } $deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete'); return array( 'inventoryitem' => $inventoryitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "InventoryItem", "$", "inventoryitem", ",", "Request", "$", "request", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "InventoryItemType", "(", ")", ",", "$", "inventoryitem", ",", "arr...
Edits an existing InventoryItem entity. @Route("/{id}/update", name="stock_inventoryitem_update", requirements={"id"="\d+"}) @Method("PUT") @Template("FlowerStockBundle:InventoryItem:edit.html.twig")
[ "Edits", "an", "existing", "InventoryItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L138-L156
train
asika32764/joomla-framework-console
Descriptor/Text/TextDescriptorHelper.php
TextDescriptorHelper.describe
public function describe(AbstractCommand $command) { // Describe Options $options = $command->getAllOptions(); $optionDescriptor = $this->getOptionDescriptor(); foreach ($options as $option) { $optionDescriptor->addItem($option); } $render['option'] = count($options) ? "\n\nOptions:\n\n" . $optionDescriptor->render() : ''; // Describe Commands $commands = $command->getChildren(); $commandDescriptor = $this->getCommandDescriptor(); foreach ($commands as $cmd) { $commandDescriptor->addItem($cmd); } $render['command'] = count($commands) ? "\nAvailable commands:\n\n" . $commandDescriptor->render() : ''; // Render Help template /** @var Console $console */ $console = $command->getApplication(); if (!($console instanceof Console)) { throw new \RuntimeException(sprintf('Help descriptor need Console object in %s command.', get_class($command))); } $consoleName = $console->getName(); $version = $console->getVersion(); $commandName = $command->getName(); $description = $command->getDescription(); $usage = $command->getUsage(); $help = $command->getHelp(); // Clean line indent of description $description = explode("\n", $description); foreach ($description as &$line) { $line = trim($line); } $description = implode("\n", $description); $description = $description ? $description . "\n" : ''; $template = sprintf( $this->template, $consoleName, $version, $commandName, $description, $usage, $help ); return str_replace( array('{OPTIONS}', '{COMMANDS}'), $render, $template ); }
php
public function describe(AbstractCommand $command) { // Describe Options $options = $command->getAllOptions(); $optionDescriptor = $this->getOptionDescriptor(); foreach ($options as $option) { $optionDescriptor->addItem($option); } $render['option'] = count($options) ? "\n\nOptions:\n\n" . $optionDescriptor->render() : ''; // Describe Commands $commands = $command->getChildren(); $commandDescriptor = $this->getCommandDescriptor(); foreach ($commands as $cmd) { $commandDescriptor->addItem($cmd); } $render['command'] = count($commands) ? "\nAvailable commands:\n\n" . $commandDescriptor->render() : ''; // Render Help template /** @var Console $console */ $console = $command->getApplication(); if (!($console instanceof Console)) { throw new \RuntimeException(sprintf('Help descriptor need Console object in %s command.', get_class($command))); } $consoleName = $console->getName(); $version = $console->getVersion(); $commandName = $command->getName(); $description = $command->getDescription(); $usage = $command->getUsage(); $help = $command->getHelp(); // Clean line indent of description $description = explode("\n", $description); foreach ($description as &$line) { $line = trim($line); } $description = implode("\n", $description); $description = $description ? $description . "\n" : ''; $template = sprintf( $this->template, $consoleName, $version, $commandName, $description, $usage, $help ); return str_replace( array('{OPTIONS}', '{COMMANDS}'), $render, $template ); }
[ "public", "function", "describe", "(", "AbstractCommand", "$", "command", ")", "{", "// Describe Options", "$", "options", "=", "$", "command", "->", "getAllOptions", "(", ")", ";", "$", "optionDescriptor", "=", "$", "this", "->", "getOptionDescriptor", "(", "...
Describe a command detail. @param AbstractCommand $command The command to described. @return string Return the described text. @throws \RuntimeException @since 1.0
[ "Describe", "a", "command", "detail", "." ]
fe28cf9e1c694049e015121e2bd041268e814249
https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Descriptor/Text/TextDescriptorHelper.php#L55-L122
train
matryoshka-model/rest-wrapper
library/Paginator/RestPaginatorAdapter.php
RestPaginatorAdapter.getItems
public function getItems($offset, $itemCountPerPage) { $cacheKey = $offset . '-' . $itemCountPerPage; if (isset($this->preloadCache[$cacheKey])) { return $this->preloadCache[$cacheKey]; } return $this->loadItems($offset, $itemCountPerPage); }
php
public function getItems($offset, $itemCountPerPage) { $cacheKey = $offset . '-' . $itemCountPerPage; if (isset($this->preloadCache[$cacheKey])) { return $this->preloadCache[$cacheKey]; } return $this->loadItems($offset, $itemCountPerPage); }
[ "public", "function", "getItems", "(", "$", "offset", ",", "$", "itemCountPerPage", ")", "{", "$", "cacheKey", "=", "$", "offset", ".", "'-'", ".", "$", "itemCountPerPage", ";", "if", "(", "isset", "(", "$", "this", "->", "preloadCache", "[", "$", "cac...
Returns an result set of items for a page @param int $offset Page offset @param int $itemCountPerPage Number of items per page @return HydratingResultSet
[ "Returns", "an", "result", "set", "of", "items", "for", "a", "page" ]
a612f2a998f37717ac9fbddf3080ce275e4c8ade
https://github.com/matryoshka-model/rest-wrapper/blob/a612f2a998f37717ac9fbddf3080ce275e4c8ade/library/Paginator/RestPaginatorAdapter.php#L175-L184
train
aedart/model
src/Traits/Strings/CardNumberTrait.php
CardNumberTrait.getCardNumber
public function getCardNumber() : ?string { if ( ! $this->hasCardNumber()) { $this->setCardNumber($this->getDefaultCardNumber()); } return $this->cardNumber; }
php
public function getCardNumber() : ?string { if ( ! $this->hasCardNumber()) { $this->setCardNumber($this->getDefaultCardNumber()); } return $this->cardNumber; }
[ "public", "function", "getCardNumber", "(", ")", ":", "?", "string", "{", "if", "(", "!", "$", "this", "->", "hasCardNumber", "(", ")", ")", "{", "$", "this", "->", "setCardNumber", "(", "$", "this", "->", "getDefaultCardNumber", "(", ")", ")", ";", ...
Get card number If no "card number" value has been set, this method will set and return a default "card number" value, if any such value is available @see getDefaultCardNumber() @return string|null card number or null if no card number has been set
[ "Get", "card", "number" ]
9a562c1c53a276d01ace0ab71f5305458bea542f
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/CardNumberTrait.php#L48-L54
train
razielsd/webdriverlib
WebDriver/WebDriver/Element.php
WebDriver_Element.getElementId
public function getElementId() { if ($this->elementId === null) { $param = WebDriver_Util::parseLocator($this->locator); $commandUri = (null === $this->parent) ? 'element' : "element/{$this->parent->getElementId()}/element"; $command = $this->driver->factoryCommand($commandUri, WebDriver_Command::METHOD_POST, $param); try { $result = $this->driver->curl($command); } catch (WebDriver_Exception $e) { $parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})"; $e->setMessage("Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}"); throw $e; } if (!isset($result['value']['ELEMENT'])) { $parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})"; throw new WebDriver_Exception("Element not found: {$this->locator}{$parentText}"); } $this->elementId = $result['value']['ELEMENT']; } return $this->elementId; }
php
public function getElementId() { if ($this->elementId === null) { $param = WebDriver_Util::parseLocator($this->locator); $commandUri = (null === $this->parent) ? 'element' : "element/{$this->parent->getElementId()}/element"; $command = $this->driver->factoryCommand($commandUri, WebDriver_Command::METHOD_POST, $param); try { $result = $this->driver->curl($command); } catch (WebDriver_Exception $e) { $parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})"; $e->setMessage("Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}"); throw $e; } if (!isset($result['value']['ELEMENT'])) { $parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})"; throw new WebDriver_Exception("Element not found: {$this->locator}{$parentText}"); } $this->elementId = $result['value']['ELEMENT']; } return $this->elementId; }
[ "public", "function", "getElementId", "(", ")", "{", "if", "(", "$", "this", "->", "elementId", "===", "null", ")", "{", "$", "param", "=", "WebDriver_Util", "::", "parseLocator", "(", "$", "this", "->", "locator", ")", ";", "$", "commandUri", "=", "("...
Get element Id from webdriver @return int @throws WebDriver_Exception
[ "Get", "element", "Id", "from", "webdriver" ]
e498afc36a8cdeab5b6ca95016420557baf32f36
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L84-L104
train
razielsd/webdriverlib
WebDriver/WebDriver/Element.php
WebDriver_Element.tagName
public function tagName() { if (!$this->state['tagName']) { $result = $this->sendCommand('element/:id/name', WebDriver_Command::METHOD_GET); $this->state['tagName'] = strtolower($result['value']); } return $this->state['tagName']; }
php
public function tagName() { if (!$this->state['tagName']) { $result = $this->sendCommand('element/:id/name', WebDriver_Command::METHOD_GET); $this->state['tagName'] = strtolower($result['value']); } return $this->state['tagName']; }
[ "public", "function", "tagName", "(", ")", "{", "if", "(", "!", "$", "this", "->", "state", "[", "'tagName'", "]", ")", "{", "$", "result", "=", "$", "this", "->", "sendCommand", "(", "'element/:id/name'", ",", "WebDriver_Command", "::", "METHOD_GET", ")...
Get element tag name @return mixed
[ "Get", "element", "tag", "name" ]
e498afc36a8cdeab5b6ca95016420557baf32f36
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L395-L402
train
razielsd/webdriverlib
WebDriver/WebDriver/Element.php
WebDriver_Element.location
public function location() { $result = $this->sendCommand('element/:id/location', WebDriver_Command::METHOD_GET); $value = $result['value']; return ['x' => $value['x'], 'y' => $value['y']]; }
php
public function location() { $result = $this->sendCommand('element/:id/location', WebDriver_Command::METHOD_GET); $value = $result['value']; return ['x' => $value['x'], 'y' => $value['y']]; }
[ "public", "function", "location", "(", ")", "{", "$", "result", "=", "$", "this", "->", "sendCommand", "(", "'element/:id/location'", ",", "WebDriver_Command", "::", "METHOD_GET", ")", ";", "$", "value", "=", "$", "result", "[", "'value'", "]", ";", "retur...
Get element upper-left corner of the page
[ "Get", "element", "upper", "-", "left", "corner", "of", "the", "page" ]
e498afc36a8cdeab5b6ca95016420557baf32f36
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L474-L479
train
ricardoh/wurfl-php-api
WURFL/Request/UserAgentNormalizer/Specific/Chrome.php
WURFL_Request_UserAgentNormalizer_Specific_Chrome.chromeWithMajorVersion
private function chromeWithMajorVersion($userAgent) { $start_idx = strpos($userAgent, 'Chrome'); $end_idx = strpos($userAgent, '.', $start_idx); if ($end_idx === false) { return substr($userAgent, $start_idx); } else { return substr($userAgent, $start_idx, ($end_idx - $start_idx)); } }
php
private function chromeWithMajorVersion($userAgent) { $start_idx = strpos($userAgent, 'Chrome'); $end_idx = strpos($userAgent, '.', $start_idx); if ($end_idx === false) { return substr($userAgent, $start_idx); } else { return substr($userAgent, $start_idx, ($end_idx - $start_idx)); } }
[ "private", "function", "chromeWithMajorVersion", "(", "$", "userAgent", ")", "{", "$", "start_idx", "=", "strpos", "(", "$", "userAgent", ",", "'Chrome'", ")", ";", "$", "end_idx", "=", "strpos", "(", "$", "userAgent", ",", "'.'", ",", "$", "start_idx", ...
Returns Google Chrome's Major version number @param string $userAgent @return string|int Version number
[ "Returns", "Google", "Chrome", "s", "Major", "version", "number" ]
1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546
https://github.com/ricardoh/wurfl-php-api/blob/1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546/WURFL/Request/UserAgentNormalizer/Specific/Chrome.php#L34-L42
train
laravelflare/cms
src/Cms/Tree/TreeManager.php
TreeManager.findOrFail
public function findOrFail($fullslug) { if (!$tree = $this->find($fullslug)) { throw (new ModelNotFoundException)->setModel(Tree::class); } return $tree; }
php
public function findOrFail($fullslug) { if (!$tree = $this->find($fullslug)) { throw (new ModelNotFoundException)->setModel(Tree::class); } return $tree; }
[ "public", "function", "findOrFail", "(", "$", "fullslug", ")", "{", "if", "(", "!", "$", "tree", "=", "$", "this", "->", "find", "(", "$", "fullslug", ")", ")", "{", "throw", "(", "new", "ModelNotFoundException", ")", "->", "setModel", "(", "Tree", "...
Find a Tree Item by Slug or throw an exception. @param string $fullslug @return \LaravelFlare\Cms\Tree\Tree @throws \Illuminate\Database\Eloquent\ModelNotFoundException
[ "Find", "a", "Tree", "Item", "by", "Slug", "or", "throw", "an", "exception", "." ]
fe94b922c5b1232ea7ab63abd47dbbe34e47ad2f
https://github.com/laravelflare/cms/blob/fe94b922c5b1232ea7ab63abd47dbbe34e47ad2f/src/Cms/Tree/TreeManager.php#L48-L55
train
glynnforrest/speedy-config
src/Processor/ReferenceProcessor.php
ReferenceProcessor.resolveValue
protected function resolveValue(Config $config, $key) { $value = $config->getRequired($key); if (is_array($value)) { throw new KeyException(sprintf('Referenced configuration key "%s" must not be an array.', $key)); } if (in_array($key, $this->referenceStack)) { throw new KeyException(sprintf('Circular reference detected resolving configuration key "%s"', $key)); } $this->referenceStack[] = $key; preg_match_all('/%([^%]+)%/', $value, $matches); if (!$matches) { return; } foreach ($matches[1] as $referenceKey) { $replacement = $this->resolveValue($config, $referenceKey); $value = str_replace('%'.$referenceKey.'%', $replacement, $value); } array_pop($this->referenceStack); return $value; }
php
protected function resolveValue(Config $config, $key) { $value = $config->getRequired($key); if (is_array($value)) { throw new KeyException(sprintf('Referenced configuration key "%s" must not be an array.', $key)); } if (in_array($key, $this->referenceStack)) { throw new KeyException(sprintf('Circular reference detected resolving configuration key "%s"', $key)); } $this->referenceStack[] = $key; preg_match_all('/%([^%]+)%/', $value, $matches); if (!$matches) { return; } foreach ($matches[1] as $referenceKey) { $replacement = $this->resolveValue($config, $referenceKey); $value = str_replace('%'.$referenceKey.'%', $replacement, $value); } array_pop($this->referenceStack); return $value; }
[ "protected", "function", "resolveValue", "(", "Config", "$", "config", ",", "$", "key", ")", "{", "$", "value", "=", "$", "config", "->", "getRequired", "(", "$", "key", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "throw", "n...
Resolve a configuration value by replacing any %tokens% with their substituted values. @param Config $config @param string $key
[ "Resolve", "a", "configuration", "value", "by", "replacing", "any", "%tokens%", "with", "their", "substituted", "values", "." ]
613995cd89b6212f2beca50f646a36a08e4dcaf7
https://github.com/glynnforrest/speedy-config/blob/613995cd89b6212f2beca50f646a36a08e4dcaf7/src/Processor/ReferenceProcessor.php#L37-L61
train
kevindierkx/elicit
src/Connector/BasicAuthConnector.php
BasicAuthConnector.connect
public function connect(array $config) { $connection = $this->createConnection($config); $this->validateCredentials($config); // For basic authentication we need an Authorization // header to be set. We add it to the request here. $this->addHeader( 'Authorization', 'Basic ' . base64_encode( array_get($config, 'identifier') . ':' . array_get($config, 'secret') ) ); return $connection; }
php
public function connect(array $config) { $connection = $this->createConnection($config); $this->validateCredentials($config); // For basic authentication we need an Authorization // header to be set. We add it to the request here. $this->addHeader( 'Authorization', 'Basic ' . base64_encode( array_get($config, 'identifier') . ':' . array_get($config, 'secret') ) ); return $connection; }
[ "public", "function", "connect", "(", "array", "$", "config", ")", "{", "$", "connection", "=", "$", "this", "->", "createConnection", "(", "$", "config", ")", ";", "$", "this", "->", "validateCredentials", "(", "$", "config", ")", ";", "// For basic authe...
Establish an API connection. @param array $config @return self
[ "Establish", "an", "API", "connection", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/BasicAuthConnector.php#L15-L31
train
nachonerd/silex_finder_provider
src/Extensions/Finder.php
Finder.sortByNameDesc
public function sortByNameDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return strcmp($b->getRealpath(), $a->getRealpath()); } ); return $this; }
php
public function sortByNameDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return strcmp($b->getRealpath(), $a->getRealpath()); } ); return $this; }
[ "public", "function", "sortByNameDesc", "(", ")", "{", "$", "this", "->", "sort", "(", "function", "(", "SplFileInfo", "$", "a", ",", "SplFileInfo", "$", "b", ")", "{", "return", "strcmp", "(", "$", "b", "->", "getRealpath", "(", ")", ",", "$", "a", ...
Sorts files and directories by name DESC. This can be slow as all the matching files and directories must be retrieved for comparison. @return Finder The current Finder instance @see SortableIterator @api
[ "Sorts", "files", "and", "directories", "by", "name", "DESC", "." ]
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L58-L66
train
nachonerd/silex_finder_provider
src/Extensions/Finder.php
Finder.sortByAccessedTimeDesc
public function sortByAccessedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getATime() - $a->getATime()); } ); return $this; }
php
public function sortByAccessedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getATime() - $a->getATime()); } ); return $this; }
[ "public", "function", "sortByAccessedTimeDesc", "(", ")", "{", "$", "this", "->", "sort", "(", "function", "(", "SplFileInfo", "$", "a", ",", "SplFileInfo", "$", "b", ")", "{", "return", "(", "$", "b", "->", "getATime", "(", ")", "-", "$", "a", "->",...
Sorts files and directories by the last accessed time desc. This is the time that the file was last accessed, read or written to. This can be slow as all the matching files and directories must be retrieved for comparison. @return Finder The current Finder instance @see SortableIterator @api
[ "Sorts", "files", "and", "directories", "by", "the", "last", "accessed", "time", "desc", "." ]
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L111-L119
train
nachonerd/silex_finder_provider
src/Extensions/Finder.php
Finder.sortByChangedTimeDesc
public function sortByChangedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getCTime() - $a->getCTime()); } ); return $this; }
php
public function sortByChangedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getCTime() - $a->getCTime()); } ); return $this; }
[ "public", "function", "sortByChangedTimeDesc", "(", ")", "{", "$", "this", "->", "sort", "(", "function", "(", "SplFileInfo", "$", "a", ",", "SplFileInfo", "$", "b", ")", "{", "return", "(", "$", "b", "->", "getCTime", "(", ")", "-", "$", "a", "->", ...
Sorts files and directories by the last inode changed time Desc. This is the time that the inode information was last modified (permissions, owner, group or other metadata). On Windows, since inode is not available, changed time is actually the file creation time. This can be slow as all the matching files and directories must be retrieved for comparison. @return Finder The current Finder instance @see SortableIterator @api
[ "Sorts", "files", "and", "directories", "by", "the", "last", "inode", "changed", "time", "Desc", "." ]
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L139-L147
train
nachonerd/silex_finder_provider
src/Extensions/Finder.php
Finder.sortByModifiedTimeDesc
public function sortByModifiedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getMTime() - $a->getMTime()); } ); return $this; }
php
public function sortByModifiedTimeDesc() { $this->sort( function (SplFileInfo $a, SplFileInfo $b) { return ($b->getMTime() - $a->getMTime()); } ); return $this; }
[ "public", "function", "sortByModifiedTimeDesc", "(", ")", "{", "$", "this", "->", "sort", "(", "function", "(", "SplFileInfo", "$", "a", ",", "SplFileInfo", "$", "b", ")", "{", "return", "(", "$", "b", "->", "getMTime", "(", ")", "-", "$", "a", "->",...
Sorts files and directories by the last modified time Desc. This is the last time the actual contents of the file were last modified. This can be slow as all the matching files and directories must be retrieved for comparison. @return Finder The current Finder instance @see SortableIterator @api
[ "Sorts", "files", "and", "directories", "by", "the", "last", "modified", "time", "Desc", "." ]
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L164-L172
train
nachonerd/silex_finder_provider
src/Extensions/Finder.php
Finder.getNFirst
public function getNFirst($n) { $it = new \ArrayIterator(); $j = 0; foreach ($this as $file) { if ($j == $n) { break; } $j++; $it->append($file); } $finder = new static(); $finder->append($it); return $finder; }
php
public function getNFirst($n) { $it = new \ArrayIterator(); $j = 0; foreach ($this as $file) { if ($j == $n) { break; } $j++; $it->append($file); } $finder = new static(); $finder->append($it); return $finder; }
[ "public", "function", "getNFirst", "(", "$", "n", ")", "{", "$", "it", "=", "new", "\\", "ArrayIterator", "(", ")", ";", "$", "j", "=", "0", ";", "foreach", "(", "$", "this", "as", "$", "file", ")", "{", "if", "(", "$", "j", "==", "$", "n", ...
Get First N Files or Dirs @param integer $n Umpteenth Number @return Return a new Finder instance @see SortableIterator @api
[ "Get", "First", "N", "Files", "or", "Dirs" ]
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L185-L201
train
weew/app-monolog
src/Weew/App/Monolog/MonologChannelManager.php
MonologChannelManager.getAllLoggers
public function getAllLoggers() { // instantiate all loggers foreach ($this->config->getChannelConfigs() as $name => $config) { $this->getLogger($name); } return $this->getLoggers(); }
php
public function getAllLoggers() { // instantiate all loggers foreach ($this->config->getChannelConfigs() as $name => $config) { $this->getLogger($name); } return $this->getLoggers(); }
[ "public", "function", "getAllLoggers", "(", ")", "{", "// instantiate all loggers", "foreach", "(", "$", "this", "->", "config", "->", "getChannelConfigs", "(", ")", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "this", "->", "getLogger", "(", "$"...
Get all registered loggers. Instantiate if necessary. @return Logger[] @throws UndefinedChannelException
[ "Get", "all", "registered", "loggers", ".", "Instantiate", "if", "necessary", "." ]
8bb5c502900736d961b735b664e0f365b87dce3d
https://github.com/weew/app-monolog/blob/8bb5c502900736d961b735b664e0f365b87dce3d/src/Weew/App/Monolog/MonologChannelManager.php#L80-L87
train
aedart/model
src/Traits/Strings/InvoiceAddressTrait.php
InvoiceAddressTrait.getInvoiceAddress
public function getInvoiceAddress() : ?string { if ( ! $this->hasInvoiceAddress()) { $this->setInvoiceAddress($this->getDefaultInvoiceAddress()); } return $this->invoiceAddress; }
php
public function getInvoiceAddress() : ?string { if ( ! $this->hasInvoiceAddress()) { $this->setInvoiceAddress($this->getDefaultInvoiceAddress()); } return $this->invoiceAddress; }
[ "public", "function", "getInvoiceAddress", "(", ")", ":", "?", "string", "{", "if", "(", "!", "$", "this", "->", "hasInvoiceAddress", "(", ")", ")", "{", "$", "this", "->", "setInvoiceAddress", "(", "$", "this", "->", "getDefaultInvoiceAddress", "(", ")", ...
Get invoice address If no "invoice address" value has been set, this method will set and return a default "invoice address" value, if any such value is available @see getDefaultInvoiceAddress() @return string|null invoice address or null if no invoice address has been set
[ "Get", "invoice", "address" ]
9a562c1c53a276d01ace0ab71f5305458bea542f
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/InvoiceAddressTrait.php#L48-L54
train
interactivesolutions/honeycomb-pages
src/app/http/controllers/HCPagesController.php
HCPagesController.options
public function options() { if (request()->has('language')) { $pages = HCPagesTranslations::select('record_id as id', 'title', 'language_code') ->where('language_code', request('language')); if (request()->has('type')) { $pages->whereHas('record', function ($query) { $query->where('type', strtoupper(request('type'))); }); } if (request()->has('q')) { $pages->where('title', 'LIKE', '%' . request('q') . '%'); } return $pages->get(); } return []; }
php
public function options() { if (request()->has('language')) { $pages = HCPagesTranslations::select('record_id as id', 'title', 'language_code') ->where('language_code', request('language')); if (request()->has('type')) { $pages->whereHas('record', function ($query) { $query->where('type', strtoupper(request('type'))); }); } if (request()->has('q')) { $pages->where('title', 'LIKE', '%' . request('q') . '%'); } return $pages->get(); } return []; }
[ "public", "function", "options", "(", ")", "{", "if", "(", "request", "(", ")", "->", "has", "(", "'language'", ")", ")", "{", "$", "pages", "=", "HCPagesTranslations", "::", "select", "(", "'record_id as id'", ",", "'title'", ",", "'language_code'", ")", ...
Get options by request data @return array
[ "Get", "options", "by", "request", "data" ]
f628e4df80589f6e86099fb2d4fcf0fc520e8228
https://github.com/interactivesolutions/honeycomb-pages/blob/f628e4df80589f6e86099fb2d4fcf0fc520e8228/src/app/http/controllers/HCPagesController.php#L310-L330
train
crater-framework/crater-php-framework
Error.php
Error.indexAction
public function indexAction() { header("HTTP/1.0 404 Not Found"); $data['title'] = '404'; $data['error'] = $this->_error; $this->view->render('error/404', $data); }
php
public function indexAction() { header("HTTP/1.0 404 Not Found"); $data['title'] = '404'; $data['error'] = $this->_error; $this->view->render('error/404', $data); }
[ "public", "function", "indexAction", "(", ")", "{", "header", "(", "\"HTTP/1.0 404 Not Found\"", ")", ";", "$", "data", "[", "'title'", "]", "=", "'404'", ";", "$", "data", "[", "'error'", "]", "=", "$", "this", "->", "_error", ";", "$", "this", "->", ...
404 page Action load a 404 page with the error message
[ "404", "page", "Action", "load", "a", "404", "page", "with", "the", "error", "message" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Error.php#L31-L40
train
osflab/controller
Request.php
Request.getUri
public function getUri($withBaseUrl = false) { $prefix = $withBaseUrl ? $this->getBaseUrl() : ''; $uri = $prefix . $this->uri; $uri = '/' . ltrim($uri, '/'); return $uri; }
php
public function getUri($withBaseUrl = false) { $prefix = $withBaseUrl ? $this->getBaseUrl() : ''; $uri = $prefix . $this->uri; $uri = '/' . ltrim($uri, '/'); return $uri; }
[ "public", "function", "getUri", "(", "$", "withBaseUrl", "=", "false", ")", "{", "$", "prefix", "=", "$", "withBaseUrl", "?", "$", "this", "->", "getBaseUrl", "(", ")", ":", "''", ";", "$", "uri", "=", "$", "prefix", ".", "$", "this", "->", "uri", ...
Get URI without baseurl @return string @task [URI] Voir comment gérer le baseUrl '/'
[ "Get", "URI", "without", "baseurl" ]
d59344fc204a74995224e3da39b9debd78fdb974
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L36-L42
train
osflab/controller
Request.php
Request.getParams
public function getParams($withActionParams = false) { return $withActionParams ? array_merge($this->actionParams, $this->params) : $this->params; }
php
public function getParams($withActionParams = false) { return $withActionParams ? array_merge($this->actionParams, $this->params) : $this->params; }
[ "public", "function", "getParams", "(", "$", "withActionParams", "=", "false", ")", "{", "return", "$", "withActionParams", "?", "array_merge", "(", "$", "this", "->", "actionParams", ",", "$", "this", "->", "params", ")", ":", "$", "this", "->", "params",...
Get current params @return multitype:
[ "Get", "current", "params" ]
d59344fc204a74995224e3da39b9debd78fdb974
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L77-L80
train
osflab/controller
Request.php
Request.getParam
public function getParam(string $key) { $isActionParam = in_array($key, [self::PARAM_CONTROLLER, self::PARAM_ACTION]); $params = $isActionParam ? $this->actionParams: $this->params; return array_key_exists($key, $params) ? $params[$key] : null; }
php
public function getParam(string $key) { $isActionParam = in_array($key, [self::PARAM_CONTROLLER, self::PARAM_ACTION]); $params = $isActionParam ? $this->actionParams: $this->params; return array_key_exists($key, $params) ? $params[$key] : null; }
[ "public", "function", "getParam", "(", "string", "$", "key", ")", "{", "$", "isActionParam", "=", "in_array", "(", "$", "key", ",", "[", "self", "::", "PARAM_CONTROLLER", ",", "self", "::", "PARAM_ACTION", "]", ")", ";", "$", "params", "=", "$", "isAct...
Get param value. Get action param if key = controller or action @param string $key @return string|null
[ "Get", "param", "value", ".", "Get", "action", "param", "if", "key", "=", "controller", "or", "action" ]
d59344fc204a74995224e3da39b9debd78fdb974
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L87-L92
train
codebobbly/dvoconnector
Classes/Domain/Filter/GenericFilter.php
GenericFilter.getURLQuery
public function getURLQuery() { $qstr = '?'; $params = $this->getParametersArray(); $paramCount = count($params); $i = 0; foreach ($params as $key => $value) { if ($value === null) { continue; } $qstr .= $key . '=' . rawurlencode($value); if ($i < $paramCount - 1) { $qstr .= '&'; } $i++; } return $qstr; }
php
public function getURLQuery() { $qstr = '?'; $params = $this->getParametersArray(); $paramCount = count($params); $i = 0; foreach ($params as $key => $value) { if ($value === null) { continue; } $qstr .= $key . '=' . rawurlencode($value); if ($i < $paramCount - 1) { $qstr .= '&'; } $i++; } return $qstr; }
[ "public", "function", "getURLQuery", "(", ")", "{", "$", "qstr", "=", "'?'", ";", "$", "params", "=", "$", "this", "->", "getParametersArray", "(", ")", ";", "$", "paramCount", "=", "count", "(", "$", "params", ")", ";", "$", "i", "=", "0", ";", ...
Builds a query string from an array and takes care of proper url-encoding @return string Query string including the '?'
[ "Builds", "a", "query", "string", "from", "an", "array", "and", "takes", "care", "of", "proper", "url", "-", "encoding" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Domain/Filter/GenericFilter.php#L26-L49
train
marando/phpSOFA
src/Marando/IAU/iauGst06.php
iauGst06.Gst06
public static function Gst06($uta, $utb, $tta, $ttb, array $rnpb) { $x; $y; $s; $era; $eors; $gst; /* Extract CIP coordinates. */ IAU::Bpn2xy($rnpb, $x, $y); /* The CIO locator, s. */ $s = IAU::S06($tta, $ttb, $x, $y); /* Greenwich apparent sidereal time. */ $era = IAU::Era00($uta, $utb); $eors = IAU::Eors($rnpb, $s); $gst = IAU::Anp($era - $eors); return $gst; }
php
public static function Gst06($uta, $utb, $tta, $ttb, array $rnpb) { $x; $y; $s; $era; $eors; $gst; /* Extract CIP coordinates. */ IAU::Bpn2xy($rnpb, $x, $y); /* The CIO locator, s. */ $s = IAU::S06($tta, $ttb, $x, $y); /* Greenwich apparent sidereal time. */ $era = IAU::Era00($uta, $utb); $eors = IAU::Eors($rnpb, $s); $gst = IAU::Anp($era - $eors); return $gst; }
[ "public", "static", "function", "Gst06", "(", "$", "uta", ",", "$", "utb", ",", "$", "tta", ",", "$", "ttb", ",", "array", "$", "rnpb", ")", "{", "$", "x", ";", "$", "y", ";", "$", "s", ";", "$", "era", ";", "$", "eors", ";", "$", "gst", ...
- - - - - - - - - i a u G s t 0 6 - - - - - - - - - Greenwich apparent sidereal time, IAU 2006, given the NPB matrix. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: support function. Given: uta,utb double UT1 as a 2-part Julian Date (Notes 1,2) tta,ttb double TT as a 2-part Julian Date (Notes 1,2) rnpb double[3][3] nutation x precession x bias matrix Returned (function value): double Greenwich apparent sidereal time (radians) Notes: 1) The UT1 and TT dates uta+utb and tta+ttb respectively, are both Julian Dates, apportioned in any convenient way between the argument pairs. For example, JD=2450123.7 could be expressed in any of these ways, among others: Part A Part B 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable (in the case of UT; the TT is not at all critical in this respect). The J2000 and MJD methods are good compromises between resolution and convenience. For UT, the date & time method is best matched to the algorithm that is used by the Earth rotation angle function, called internally: maximum precision is delivered when the uta argument is for 0hrs UT1 on the day in question and the utb argument lies in the range 0 to 1, or vice versa. 2) Both UT1 and TT are required, UT1 to predict the Earth rotation and TT to predict the effects of precession-nutation. If UT1 is used for both purposes, errors of order 100 microarcseconds result. 3) Although the function uses the IAU 2006 series for s+XY/2, it is otherwise independent of the precession-nutation model and can in practice be used with any equinox-based NPB matrix. 4) The result is returned in the range 0 to 2pi. Called: iauBpn2xy extract CIP X,Y coordinates from NPB matrix iauS06 the CIO locator s, given X,Y, IAU 2006 iauAnp normalize angle into range 0 to 2pi iauEra00 Earth rotation angle, IAU 2000 iauEors equation of the origins, given NPB matrix and s Reference: Wallace, P.T. & Capitaine, N., 2006, Astron.Astrophys. 459, 981 This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "G", "s", "t", "0", "6", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGst06.php#L80-L100
train
DevGroup-ru/yii2-admin-utils
src/traits/BackendRedirect.php
BackendRedirect.redirectUser
public function redirectUser( $id, $setFlash = true, $indexAction = ['index'], $editAction = ['edit'], $overrideReturnUrl = false ) { /** @var \yii\web\Controller $this */ if ($setFlash === true) { Yii::$app->session->setFlash('success', AdminModule::t('app', 'Object saved')); } elseif (is_string($setFlash)) { Yii::$app->session->setFlash('success', $setFlash); } if ($overrideReturnUrl === false) { $returnUrl = Yii::$app->request->get( 'returnUrl', Yii::$app->request->getReferrer() === null ? Url::to([$indexAction]) : Yii::$app->request->getReferrer() ); } else { $returnUrl = $overrideReturnUrl; } switch (Yii::$app->request->post('action', 'save')) { case 'save-and-next': // as you can see there's no id param here and there should be no such in $editAction $url = $editAction; $url['returnUrl'] = $returnUrl; return $this->redirect($url); case 'save-and-back': return $this->redirect($returnUrl); default: $url = $editAction; $url['returnUrl'] = $returnUrl; $url['id'] = $id; return $this->redirect($url); } }
php
public function redirectUser( $id, $setFlash = true, $indexAction = ['index'], $editAction = ['edit'], $overrideReturnUrl = false ) { /** @var \yii\web\Controller $this */ if ($setFlash === true) { Yii::$app->session->setFlash('success', AdminModule::t('app', 'Object saved')); } elseif (is_string($setFlash)) { Yii::$app->session->setFlash('success', $setFlash); } if ($overrideReturnUrl === false) { $returnUrl = Yii::$app->request->get( 'returnUrl', Yii::$app->request->getReferrer() === null ? Url::to([$indexAction]) : Yii::$app->request->getReferrer() ); } else { $returnUrl = $overrideReturnUrl; } switch (Yii::$app->request->post('action', 'save')) { case 'save-and-next': // as you can see there's no id param here and there should be no such in $editAction $url = $editAction; $url['returnUrl'] = $returnUrl; return $this->redirect($url); case 'save-and-back': return $this->redirect($returnUrl); default: $url = $editAction; $url['returnUrl'] = $returnUrl; $url['id'] = $id; return $this->redirect($url); } }
[ "public", "function", "redirectUser", "(", "$", "id", ",", "$", "setFlash", "=", "true", ",", "$", "indexAction", "=", "[", "'index'", "]", ",", "$", "editAction", "=", "[", "'edit'", "]", ",", "$", "overrideReturnUrl", "=", "false", ")", "{", "/** @va...
Redirects user as was specified by his action and returnUrl variable on successful record saving. @param string|integer $id Id of model @param bool|string $setFlash True if set standard flash, string for custom flash, false for not setting any flash @param array $indexAction URL route array to index action, must include route and can include additional params @param array $editAction URL route array to edit action, must include route and can include additional params @param array|boolean $overrideReturnUrl false to use default returnUrl from _GET or array to create new url @return \yii\web\Response
[ "Redirects", "user", "as", "was", "specified", "by", "his", "action", "and", "returnUrl", "variable", "on", "successful", "record", "saving", "." ]
15c1853a5ec264602de3ad82dbf70f85de66adff
https://github.com/DevGroup-ru/yii2-admin-utils/blob/15c1853a5ec264602de3ad82dbf70f85de66adff/src/traits/BackendRedirect.php#L32-L69
train
Kagency/http-replay
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
Symfony2.convertFromRequest
public function convertFromRequest(SimplifiedRequest $request) { return Request::create( $request->path, $request->method, array(), array(), array(), $this->mapHeaderKeys($request->headers), $request->content ); }
php
public function convertFromRequest(SimplifiedRequest $request) { return Request::create( $request->path, $request->method, array(), array(), array(), $this->mapHeaderKeys($request->headers), $request->content ); }
[ "public", "function", "convertFromRequest", "(", "SimplifiedRequest", "$", "request", ")", "{", "return", "Request", "::", "create", "(", "$", "request", "->", "path", ",", "$", "request", "->", "method", ",", "array", "(", ")", ",", "array", "(", ")", "...
Convert from simplified request Converts a simplified request into the request structure you need for your current framework. @param SimplifiedRequest $request @return mixed
[ "Convert", "from", "simplified", "request" ]
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L23-L34
train
Kagency/http-replay
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
Symfony2.mapHeaderKeys
protected function mapHeaderKeys(array $headers) { $phpHeaders = array(); foreach ($headers as $key => $value) { $phpHeaders['HTTP_' . str_replace('-', '_', strtoupper($key))] = $value; } return $phpHeaders; }
php
protected function mapHeaderKeys(array $headers) { $phpHeaders = array(); foreach ($headers as $key => $value) { $phpHeaders['HTTP_' . str_replace('-', '_', strtoupper($key))] = $value; } return $phpHeaders; }
[ "protected", "function", "mapHeaderKeys", "(", "array", "$", "headers", ")", "{", "$", "phpHeaders", "=", "array", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "phpHeaders", "[", "'HTTP_'", ".", ...
Map header keys @param array $headers @return array
[ "Map", "header", "keys" ]
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L42-L50
train
Kagency/http-replay
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
Symfony2.convertFromResponse
public function convertFromResponse(SimplifiedResponse $response) { return Response::create( $response->content, $response->status, $response->headers ); }
php
public function convertFromResponse(SimplifiedResponse $response) { return Response::create( $response->content, $response->status, $response->headers ); }
[ "public", "function", "convertFromResponse", "(", "SimplifiedResponse", "$", "response", ")", "{", "return", "Response", "::", "create", "(", "$", "response", "->", "content", ",", "$", "response", "->", "status", ",", "$", "response", "->", "headers", ")", ...
Convert from simplified response Converts a simplified response into the response structure you need for your current framework. @param SimplifiedResponse $response @return mixed
[ "Convert", "from", "simplified", "response" ]
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L61-L68
train
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsMinifier.php
AssetsMinifier.compress
public function compress($type, $files, $file) { // files have been updated so update the minified file if($this->isUpdated($files)) { $content = $this->getFileContents($files); switch($type){ case 'css': $content = $this->minifyCSS($content); break; case 'js': $content = $this->minifyJS($content); break; } $this->saveFile($file, $content); } return str_replace($this->scriptPath,$this->coreUrl,$file); }
php
public function compress($type, $files, $file) { // files have been updated so update the minified file if($this->isUpdated($files)) { $content = $this->getFileContents($files); switch($type){ case 'css': $content = $this->minifyCSS($content); break; case 'js': $content = $this->minifyJS($content); break; } $this->saveFile($file, $content); } return str_replace($this->scriptPath,$this->coreUrl,$file); }
[ "public", "function", "compress", "(", "$", "type", ",", "$", "files", ",", "$", "file", ")", "{", "// files have been updated so update the minified file", "if", "(", "$", "this", "->", "isUpdated", "(", "$", "files", ")", ")", "{", "$", "content", "=", "...
get all contents and process the whole contents @param string $type compress by type @param array $files files that will be compressed @param string $file @return string return cache url of
[ "get", "all", "contents", "and", "process", "the", "whole", "contents" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsMinifier.php#L96-L113
train
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsMinifier.php
AssetsMinifier.getFileContents
private function getFileContents($files) { $content = ''; $basePath = $this->basePath; array_walk($files,function(&$value, $key) use(&$content, $basePath){ if(file_exists($basePath.$value)) $content .= file_get_contents($basePath.$value); }); return $content; }
php
private function getFileContents($files) { $content = ''; $basePath = $this->basePath; array_walk($files,function(&$value, $key) use(&$content, $basePath){ if(file_exists($basePath.$value)) $content .= file_get_contents($basePath.$value); }); return $content; }
[ "private", "function", "getFileContents", "(", "$", "files", ")", "{", "$", "content", "=", "''", ";", "$", "basePath", "=", "$", "this", "->", "basePath", ";", "array_walk", "(", "$", "files", ",", "function", "(", "&", "$", "value", ",", "$", "key"...
get contents of all registered files, it is also check whether file is exist or not @param array $files all files that will be retrieved @return strign return mixed of all contents
[ "get", "contents", "of", "all", "registered", "files", "it", "is", "also", "check", "whether", "file", "is", "exist", "or", "not" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsMinifier.php#L154-L164
train
douyacun/dyc-pay-supports
src/Traits/HasHttpRequest.php
HasHttpRequest.getBaseOptions
protected function getBaseOptions() { $options = [ 'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '', 'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0, 'connect_timeout' => property_exists($this, 'connect_timeout') ? $this->connect_timeout : 5.0, ]; return $options; }
php
protected function getBaseOptions() { $options = [ 'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '', 'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0, 'connect_timeout' => property_exists($this, 'connect_timeout') ? $this->connect_timeout : 5.0, ]; return $options; }
[ "protected", "function", "getBaseOptions", "(", ")", "{", "$", "options", "=", "[", "'base_uri'", "=>", "property_exists", "(", "$", "this", ",", "'baseUri'", ")", "?", "$", "this", "->", "baseUri", ":", "''", ",", "'timeout'", "=>", "property_exists", "("...
Get base options. @author yansongda <me@yansongda.cn> @return array
[ "Get", "base", "options", "." ]
d676c7f0b8ac2da2954b4b76448af18c9953381e
https://github.com/douyacun/dyc-pay-supports/blob/d676c7f0b8ac2da2954b4b76448af18c9953381e/src/Traits/HasHttpRequest.php#L74-L83
train
slickframework/mvc
src/Controller/EntityCreateMethods.php
EntityCreateMethods.add
public function add() { $form = $this->getForm(); $this->set(compact('form')); if (!$form->wasSubmitted()) { return; } try { $this->getUpdateService() ->setForm($form) ->update(); ; } catch (InvalidFormDataException $caught) { Log::logger()->addNotice($caught->getMessage(), $form->getData()); $this->addErrorMessage($this->getInvalidFormDataMessage()); return; } catch (\Exception $caught) { Log::logger()->addCritical( $caught->getMessage(), $form->getData() ); $this->addErrorMessage($this->getGeneralErrorMessage($caught)); return; } $this->addSuccessMessage( $this->getCreateSuccessMessage( $this->getUpdateService()->getEntity() ) ); $this->redirectFromCreated($this->getUpdateService()->getEntity()); }
php
public function add() { $form = $this->getForm(); $this->set(compact('form')); if (!$form->wasSubmitted()) { return; } try { $this->getUpdateService() ->setForm($form) ->update(); ; } catch (InvalidFormDataException $caught) { Log::logger()->addNotice($caught->getMessage(), $form->getData()); $this->addErrorMessage($this->getInvalidFormDataMessage()); return; } catch (\Exception $caught) { Log::logger()->addCritical( $caught->getMessage(), $form->getData() ); $this->addErrorMessage($this->getGeneralErrorMessage($caught)); return; } $this->addSuccessMessage( $this->getCreateSuccessMessage( $this->getUpdateService()->getEntity() ) ); $this->redirectFromCreated($this->getUpdateService()->getEntity()); }
[ "public", "function", "add", "(", ")", "{", "$", "form", "=", "$", "this", "->", "getForm", "(", ")", ";", "$", "this", "->", "set", "(", "compact", "(", "'form'", ")", ")", ";", "if", "(", "!", "$", "form", "->", "wasSubmitted", "(", ")", ")",...
Handle the add entity request
[ "Handle", "the", "add", "entity", "request" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/EntityCreateMethods.php#L33-L66
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator.handleflags
function handleflags($i, $argv) { if (!isset($argv[1]) || !isset(self::$_options[$argv[$i][1]])) { throw new Exception('Command line syntax error: undefined option "' . $argv[$i] . '"'); } $v = self::$_options[$argv[$i][1]] == '-'; if (self::$_options[$argv[$i][1]]['type'] == self::OPT_FLAG) { $this->{self::$_options[$argv[$i][1]]['arg']} = 1; } elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FFLAG) { $this->{self::$_options[$argv[$i][1]]['arg']}($v); } elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FSTR) { $this->{self::$_options[$argv[$i][1]]['arg']}(substr($v, 2)); } else { throw new Exception('Command line syntax error: missing argument on switch: "' . $argv[$i] . '"'); } return 0; }
php
function handleflags($i, $argv) { if (!isset($argv[1]) || !isset(self::$_options[$argv[$i][1]])) { throw new Exception('Command line syntax error: undefined option "' . $argv[$i] . '"'); } $v = self::$_options[$argv[$i][1]] == '-'; if (self::$_options[$argv[$i][1]]['type'] == self::OPT_FLAG) { $this->{self::$_options[$argv[$i][1]]['arg']} = 1; } elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FFLAG) { $this->{self::$_options[$argv[$i][1]]['arg']}($v); } elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FSTR) { $this->{self::$_options[$argv[$i][1]]['arg']}(substr($v, 2)); } else { throw new Exception('Command line syntax error: missing argument on switch: "' . $argv[$i] . '"'); } return 0; }
[ "function", "handleflags", "(", "$", "i", ",", "$", "argv", ")", "{", "if", "(", "!", "isset", "(", "$", "argv", "[", "1", "]", ")", "||", "!", "isset", "(", "self", "::", "$", "_options", "[", "$", "argv", "[", "$", "i", "]", "[", "1", "]"...
Process a flag command line argument. @param int $i @param array $argv @return int
[ "Process", "a", "flag", "command", "line", "argument", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L171-L187
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator._argindex
private function _argindex($n, $a) { $dashdash = 0; if (!is_array($a) || !count($a)) { return -1; } for ($i=1; $i < count($a); $i++) { if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' || strchr($a[$i], '='))) { if ($n == 0) { return $i; } $n--; } if ($_SERVER['argv'][$i] == '--') { $dashdash = 1; } } return -1; }
php
private function _argindex($n, $a) { $dashdash = 0; if (!is_array($a) || !count($a)) { return -1; } for ($i=1; $i < count($a); $i++) { if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' || strchr($a[$i], '='))) { if ($n == 0) { return $i; } $n--; } if ($_SERVER['argv'][$i] == '--') { $dashdash = 1; } } return -1; }
[ "private", "function", "_argindex", "(", "$", "n", ",", "$", "a", ")", "{", "$", "dashdash", "=", "0", ";", "if", "(", "!", "is_array", "(", "$", "a", ")", "||", "!", "count", "(", "$", "a", ")", ")", "{", "return", "-", "1", ";", "}", "for...
Return the index of the N-th non-switch argument. Return -1 if N is out of range. @param int $n @param int $a @return int
[ "Return", "the", "index", "of", "the", "N", "-", "th", "non", "-", "switch", "argument", ".", "Return", "-", "1", "if", "N", "is", "out", "of", "range", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L296-L314
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator.OptPrint
function OptPrint() { $max = 0; foreach (self::$_options as $label => $info) { $len = strlen($label) + 1; switch ($info['type']) { case self::OPT_FLAG: case self::OPT_FFLAG: break; case self::OPT_INT: case self::OPT_FINT: $len += 9; /* length of "<integer>" */ break; case self::OPT_DBL: case self::OPT_FDBL: $len += 6; /* length of "<real>" */ break; case self::OPT_STR: case self::OPT_FSTR: $len += 8; /* length of "<string>" */ break; } if ($len > $max) { $max = $len; } } foreach (self::$_options as $label => $info) { switch ($info['type']) { case self::OPT_FLAG: case self::OPT_FFLAG: echo " -$label"; echo str_repeat(' ', $max - strlen($label)); echo " $info[message]\n"; break; case self::OPT_INT: case self::OPT_FINT: echo " $label=<integer>" . str_repeat(' ', $max - strlen($label) - 9); echo " $info[message]\n"; break; case self::OPT_DBL: case self::OPT_FDBL: echo " $label=<real>" . str_repeat(' ', $max - strlen($label) - 6); echo " $info[message]\n"; break; case self::OPT_STR: case self::OPT_FSTR: echo " $label=<string>" . str_repeat(' ', $max - strlen($label) - 8); echo " $info[message]\n"; break; } } }
php
function OptPrint() { $max = 0; foreach (self::$_options as $label => $info) { $len = strlen($label) + 1; switch ($info['type']) { case self::OPT_FLAG: case self::OPT_FFLAG: break; case self::OPT_INT: case self::OPT_FINT: $len += 9; /* length of "<integer>" */ break; case self::OPT_DBL: case self::OPT_FDBL: $len += 6; /* length of "<real>" */ break; case self::OPT_STR: case self::OPT_FSTR: $len += 8; /* length of "<string>" */ break; } if ($len > $max) { $max = $len; } } foreach (self::$_options as $label => $info) { switch ($info['type']) { case self::OPT_FLAG: case self::OPT_FFLAG: echo " -$label"; echo str_repeat(' ', $max - strlen($label)); echo " $info[message]\n"; break; case self::OPT_INT: case self::OPT_FINT: echo " $label=<integer>" . str_repeat(' ', $max - strlen($label) - 9); echo " $info[message]\n"; break; case self::OPT_DBL: case self::OPT_FDBL: echo " $label=<real>" . str_repeat(' ', $max - strlen($label) - 6); echo " $info[message]\n"; break; case self::OPT_STR: case self::OPT_FSTR: echo " $label=<string>" . str_repeat(' ', $max - strlen($label) - 8); echo " $info[message]\n"; break; } } }
[ "function", "OptPrint", "(", ")", "{", "$", "max", "=", "0", ";", "foreach", "(", "self", "::", "$", "_options", "as", "$", "label", "=>", "$", "info", ")", "{", "$", "len", "=", "strlen", "(", "$", "label", ")", "+", "1", ";", "switch", "(", ...
Print out command-line options @return void
[ "Print", "out", "command", "-", "line", "options" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L360-L411
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator._handleDOption
private function _handleDOption($z) { if ($a = strstr($z, '=')) { $z = substr($a, 1); // strip first = } $this->azDefine[] = $z; }
php
private function _handleDOption($z) { if ($a = strstr($z, '=')) { $z = substr($a, 1); // strip first = } $this->azDefine[] = $z; }
[ "private", "function", "_handleDOption", "(", "$", "z", ")", "{", "if", "(", "$", "a", "=", "strstr", "(", "$", "z", ",", "'='", ")", ")", "{", "$", "z", "=", "substr", "(", "$", "a", ",", "1", ")", ";", "// strip first =", "}", "$", "this", ...
This routine is called with the argument to each -D command-line option. Add the macro defined to the azDefine array. @param string $z @return void
[ "This", "routine", "is", "called", "with", "the", "argument", "to", "each", "-", "D", "command", "-", "line", "option", ".", "Add", "the", "macro", "defined", "to", "the", "azDefine", "array", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L421-L427
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator.merge
static function merge($a, $b, $cmp, $offset) { if ($a === 0) { $head = $b; } elseif ($b === 0) { $head = $a; } else { if (call_user_func($cmp, $a, $b) < 0) { $ptr = $a; $a = $a->$offset; } else { $ptr = $b; $b = $b->$offset; } $head = $ptr; while ($a && $b) { if (call_user_func($cmp, $a, $b) < 0) { $ptr->$offset = $a; $ptr = $a; $a = $a->$offset; } else { $ptr->$offset = $b; $ptr = $b; $b = $b->$offset; } } if ($a !== 0) { $ptr->$offset = $a; } else { $ptr->$offset = $b; } } return $head; }
php
static function merge($a, $b, $cmp, $offset) { if ($a === 0) { $head = $b; } elseif ($b === 0) { $head = $a; } else { if (call_user_func($cmp, $a, $b) < 0) { $ptr = $a; $a = $a->$offset; } else { $ptr = $b; $b = $b->$offset; } $head = $ptr; while ($a && $b) { if (call_user_func($cmp, $a, $b) < 0) { $ptr->$offset = $a; $ptr = $a; $a = $a->$offset; } else { $ptr->$offset = $b; $ptr = $b; $b = $b->$offset; } } if ($a !== 0) { $ptr->$offset = $a; } else { $ptr->$offset = $b; } } return $head; }
[ "static", "function", "merge", "(", "$", "a", ",", "$", "b", ",", "$", "cmp", ",", "$", "offset", ")", "{", "if", "(", "$", "a", "===", "0", ")", "{", "$", "head", "=", "$", "b", ";", "}", "elseif", "(", "$", "b", "===", "0", ")", "{", ...
Merge in a merge sort for a linked list Side effects: The "next" pointers for elements in the lists a and b are changed. @param mixed $a A sorted, null-terminated linked list. (May be null). @param mixed $b A sorted, null-terminated linked list. (May be null). @param function $cmp A pointer to the comparison function. @param integer $offset Offset in the structure to the "next" field. @return mixed A pointer to the head of a sorted list containing the elements of both a and b.
[ "Merge", "in", "a", "merge", "sort", "for", "a", "linked", "list" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L611-L644
train
rodchyn/elephant-lang
lib/ParserGenerator/ParserGenerator.php
PHP_ParserGenerator.Reprint
function Reprint() { printf("// Reprint of input file \"%s\".\n// Symbols:\n", $this->filename); $maxlen = 10; for ($i = 0; $i < $this->nsymbol; $i++) { $sp = $this->symbols[$i]; $len = strlen($sp->name); if ($len > $maxlen ) { $maxlen = $len; } } $ncolumns = 76 / ($maxlen + 5); if ($ncolumns < 1) { $ncolumns = 1; } $skip = ($this->nsymbol + $ncolumns - 1) / $ncolumns; for ($i = 0; $i < $skip; $i++) { print "//"; for ($j = $i; $j < $this->nsymbol; $j += $skip) { $sp = $this->symbols[$j]; //assert( sp->index==j ); printf(" %3d %-${maxlen}.${maxlen}s", $j, $sp->name); } print "\n"; } for ($rp = $this->rule; $rp; $rp = $rp->next) { printf("%s", $rp->lhs->name); /*if ($rp->lhsalias) { printf("(%s)", $rp->lhsalias); }*/ print " ::="; for ($i = 0; $i < $rp->nrhs; $i++) { $sp = $rp->rhs[$i]; printf(" %s", $sp->name); if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($j = 1; $j < $sp->nsubsym; $j++) { printf("|%s", $sp->subsym[$j]->name); } } /*if ($rp->rhsalias[$i]) { printf("(%s)", $rp->rhsalias[$i]); }*/ } print "."; if ($rp->precsym) { printf(" [%s]", $rp->precsym->name); } /*if ($rp->code) { print "\n " . $rp->code); }*/ print "\n"; } }
php
function Reprint() { printf("// Reprint of input file \"%s\".\n// Symbols:\n", $this->filename); $maxlen = 10; for ($i = 0; $i < $this->nsymbol; $i++) { $sp = $this->symbols[$i]; $len = strlen($sp->name); if ($len > $maxlen ) { $maxlen = $len; } } $ncolumns = 76 / ($maxlen + 5); if ($ncolumns < 1) { $ncolumns = 1; } $skip = ($this->nsymbol + $ncolumns - 1) / $ncolumns; for ($i = 0; $i < $skip; $i++) { print "//"; for ($j = $i; $j < $this->nsymbol; $j += $skip) { $sp = $this->symbols[$j]; //assert( sp->index==j ); printf(" %3d %-${maxlen}.${maxlen}s", $j, $sp->name); } print "\n"; } for ($rp = $this->rule; $rp; $rp = $rp->next) { printf("%s", $rp->lhs->name); /*if ($rp->lhsalias) { printf("(%s)", $rp->lhsalias); }*/ print " ::="; for ($i = 0; $i < $rp->nrhs; $i++) { $sp = $rp->rhs[$i]; printf(" %s", $sp->name); if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($j = 1; $j < $sp->nsubsym; $j++) { printf("|%s", $sp->subsym[$j]->name); } } /*if ($rp->rhsalias[$i]) { printf("(%s)", $rp->rhsalias[$i]); }*/ } print "."; if ($rp->precsym) { printf(" [%s]", $rp->precsym->name); } /*if ($rp->code) { print "\n " . $rp->code); }*/ print "\n"; } }
[ "function", "Reprint", "(", ")", "{", "printf", "(", "\"// Reprint of input file \\\"%s\\\".\\n// Symbols:\\n\"", ",", "$", "this", "->", "filename", ")", ";", "$", "maxlen", "=", "10", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this"...
Duplicate the input file without comments and without actions on rules @return void
[ "Duplicate", "the", "input", "file", "without", "comments", "and", "without", "actions", "on", "rules" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L758-L810
train
rybakdigital/fapi
Component/Framework/Controller/Controller.php
Controller.passRequestData
public function passRequestData() { $this ->getValidator() ->setInputData($this ->getRequest() ->query ->all() ); $this ->getValidator() ->setInputData($this ->getRequest() ->request ->all() ); return $this; }
php
public function passRequestData() { $this ->getValidator() ->setInputData($this ->getRequest() ->query ->all() ); $this ->getValidator() ->setInputData($this ->getRequest() ->request ->all() ); return $this; }
[ "public", "function", "passRequestData", "(", ")", "{", "$", "this", "->", "getValidator", "(", ")", "->", "setInputData", "(", "$", "this", "->", "getRequest", "(", ")", "->", "query", "->", "all", "(", ")", ")", ";", "$", "this", "->", "getValidator"...
Helper method. Passes request data. @return Controller
[ "Helper", "method", ".", "Passes", "request", "data", "." ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L157-L176
train
rybakdigital/fapi
Component/Framework/Controller/Controller.php
Controller.getRepository
public function getRepository($name = null) { // Resolve repository class name $repositoryName = $this->resolveRepositoryClassName($name); return new $repositoryName($this->getValidator(), $this->config); }
php
public function getRepository($name = null) { // Resolve repository class name $repositoryName = $this->resolveRepositoryClassName($name); return new $repositoryName($this->getValidator(), $this->config); }
[ "public", "function", "getRepository", "(", "$", "name", "=", "null", ")", "{", "// Resolve repository class name", "$", "repositoryName", "=", "$", "this", "->", "resolveRepositoryClassName", "(", "$", "name", ")", ";", "return", "new", "$", "repositoryName", "...
Gets repository by name @param string $name Name of the repository to get
[ "Gets", "repository", "by", "name" ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L183-L189
train
rybakdigital/fapi
Component/Framework/Controller/Controller.php
Controller.getRepositoryClassnameByReference
public static function getRepositoryClassnameByReference($reference) { $parts = explode(':', $reference); // Check name is string if (!is_string($reference) || count($parts) !== 3) { throw new \Exception("Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository"); } return $parts[0] . '\\' . $parts[1] . '\\' . 'Entity\\' . $parts[2]; }
php
public static function getRepositoryClassnameByReference($reference) { $parts = explode(':', $reference); // Check name is string if (!is_string($reference) || count($parts) !== 3) { throw new \Exception("Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository"); } return $parts[0] . '\\' . $parts[1] . '\\' . 'Entity\\' . $parts[2]; }
[ "public", "static", "function", "getRepositoryClassnameByReference", "(", "$", "reference", ")", "{", "$", "parts", "=", "explode", "(", "':'", ",", "$", "reference", ")", ";", "// Check name is string", "if", "(", "!", "is_string", "(", "$", "reference", ")",...
Gets Repository class name by Reference @param string $reference Reference to Repository class. This should be in a form of {version}:{controller}:{repositoryName} For example: v1:Products:MyRepository Will resolve to: 'v1\Products\Entity\MyRepository' @return string
[ "Gets", "Repository", "class", "name", "by", "Reference" ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L233-L243
train
awjudd/l4-assetprocessor
src/Awjudd/AssetProcessor/Commands/CleanupCommand.php
CleanupCommand.removeFiles
private function removeFiles($files) { // Grab the duration $duration = $this->option('duration'); // Grab the minimum acceptable timestamp $timestamp = time() - $duration; // Cycle through the list checking their creation dates foreach($files as $file) { // Compare the file modification times if(filemtime($file) < $timestamp) { // It passes the acceptable, so remove it unlink($file); // Check if the directory containing this file is empty if(count(scandir(dirname($file))) == 2) { // It was empty, so just remove it rmdir(dirname($file)); } } } }
php
private function removeFiles($files) { // Grab the duration $duration = $this->option('duration'); // Grab the minimum acceptable timestamp $timestamp = time() - $duration; // Cycle through the list checking their creation dates foreach($files as $file) { // Compare the file modification times if(filemtime($file) < $timestamp) { // It passes the acceptable, so remove it unlink($file); // Check if the directory containing this file is empty if(count(scandir(dirname($file))) == 2) { // It was empty, so just remove it rmdir(dirname($file)); } } } }
[ "private", "function", "removeFiles", "(", "$", "files", ")", "{", "// Grab the duration", "$", "duration", "=", "$", "this", "->", "option", "(", "'duration'", ")", ";", "// Grab the minimum acceptable timestamp", "$", "timestamp", "=", "time", "(", ")", "-", ...
Used internally in order to cycle through all of the files and remove them. @return void
[ "Used", "internally", "in", "order", "to", "cycle", "through", "all", "of", "the", "files", "and", "remove", "them", "." ]
04045197ae1a81d77d0c8879dbc090bbd8a69307
https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/Commands/CleanupCommand.php#L66-L91
train
awjudd/l4-assetprocessor
src/Awjudd/AssetProcessor/Commands/CleanupCommand.php
CleanupCommand.buildFileList
private function buildFileList($folder) { // The list of files to use $files = array(); // Cycle through all of the files in our storage folder removing // any files that exceed the cache duration. $directory = new DirectoryIterator($folder); foreach ($directory as $file) { // Check if the file is the local file (i.e. dot) if($file->isDot()) { // We are the dot, so just skip continue; } // Check if the file is a directory if($file->isDir()) { // Recursively call this function $files = array_merge($files, $this->buildFileList($file->getRealPath())); } else { // Add in the file $files[] = $file->getRealPath(); } } return $files; }
php
private function buildFileList($folder) { // The list of files to use $files = array(); // Cycle through all of the files in our storage folder removing // any files that exceed the cache duration. $directory = new DirectoryIterator($folder); foreach ($directory as $file) { // Check if the file is the local file (i.e. dot) if($file->isDot()) { // We are the dot, so just skip continue; } // Check if the file is a directory if($file->isDir()) { // Recursively call this function $files = array_merge($files, $this->buildFileList($file->getRealPath())); } else { // Add in the file $files[] = $file->getRealPath(); } } return $files; }
[ "private", "function", "buildFileList", "(", "$", "folder", ")", "{", "// The list of files to use", "$", "files", "=", "array", "(", ")", ";", "// Cycle through all of the files in our storage folder removing", "// any files that exceed the cache duration.", "$", "directory", ...
Used internally in order to build a full list of all of the files to build. @param string $folder The folder to scan through @return array An array of all of the files to check.
[ "Used", "internally", "in", "order", "to", "build", "a", "full", "list", "of", "all", "of", "the", "files", "to", "build", "." ]
04045197ae1a81d77d0c8879dbc090bbd8a69307
https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/Commands/CleanupCommand.php#L99-L131
train
unimatrix/cake
src/Controller/Component/CookieComponent.php
CookieComponent.check
public function check($name) { // is in cache? if(isset($this->cache[$name])) return true; return $this->cookies->has($name); }
php
public function check($name) { // is in cache? if(isset($this->cache[$name])) return true; return $this->cookies->has($name); }
[ "public", "function", "check", "(", "$", "name", ")", "{", "// is in cache?", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "name", "]", ")", ")", "return", "true", ";", "return", "$", "this", "->", "cookies", "->", "has", "(", "$"...
Check if the cookie exists @param string $name The name of the cookie. @return boolean
[ "Check", "if", "the", "cookie", "exists" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Controller/Component/CookieComponent.php#L56-L62
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.init
public function init(){ $file= 'config'; //Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO if($this->multiDomain && $this->domain){ //Ya no importa el modo, se definio todo antes si busca o no por dominio //if(ENOLA_MODE == 'HTTP'){ $file= $this->getConfigFile(); //}else{ //reset($this->configFiles); //$file= next($this->configFiles); //} } $config= $this->readConfigurationFile($file); //Define si muestra o no los errores y en que nivel de detalle dependiendo en que fase se encuentre la aplicacion switch ($config['environment']){ case 'development': error_reporting(E_ALL); $this->error= 'ALL'; break; case 'production': error_reporting(0); $this->error= 'NONE'; break; default: //No realiza el llamado a funcion de error porque todavia no se cargo el modulo de errores $head= 'Configuration Error'; $message= 'The environment is not defined in configuration.json'; require $this->pathApp . 'errors/general_error.php'; exit; } //URL_APP: Url donde funciona la aplicacion $this->urlApp= $config['url_app']; //BASE_URL: Base relativa de la aplicacion - definida por el usuario en el archivo de configuracion $pos= strlen($config['relative_url']) - 1; if($config['relative_url'][$pos] != '/'){ $config['relative_url'] .= '/'; } $this->relativeUrl= $config['relative_url']; //INDEX_PAGE: Pagina inicial. En blanco si se utiliza mod_rewrite $this->indexPage= $config['index_page']; //SESSION_PROFILE: Setea la clave en la que se guarda el profile del usuario $this->sessionProfile= ""; if(isset($config['session-profile'])){ $this->sessionProfile= $config['session-profile']; } //ENVIRONMENT: Indica el ambiente de la aplicacion $this->environment= $config['environment']; //AUTHENTICATION: Indica el metodo de autenticacion de la aplicacion $this->authentication= $config['authentication']; //SESSION_AUTOSTART: Indica si el framework inicia automaticamente la session $this->sessionAutostart= $config['session_autostart']; //AUTHORIZATION_FILE: Indica el archivo que contiene la configuracion de autorizacion $this->authorizationFile= $config['authorization_file']; //CONFIG_BD: archivo de configuracion para la base de datos if(isset($config['database']) && $config['database'] != ''){ $this->databaseConfiguration= $config['database']; } //Internacionalizacion: En caso que se defina se setea el locale por defecto y todos los locales soportados if(isset($config['i18n'])){ $this->i18nDefaultLocale= $config['i18n']['default']; if(isset($config['i18n']['locales'])){ $locales= str_replace(" ", "", $config['i18n']['locales']); $this->i18nLocales= explode(",", $locales); } } //Diferentes definiciones $this->librariesDefinition= isset($config['libs']) ? $config['libs'] : []; $this->dependenciesFile= $config['dependency_injection']; $this->controllersFile= $config['controllers']; $this->middlewaresDefinition= $config['middlewares']; $this->filtersBeforeDefinition= $config['filters']; $this->filtersAfterDefinition= $config['filters_after_processing']; if(isset($config['vars'])){ $this->contextVars= $config['vars']; } }
php
public function init(){ $file= 'config'; //Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO if($this->multiDomain && $this->domain){ //Ya no importa el modo, se definio todo antes si busca o no por dominio //if(ENOLA_MODE == 'HTTP'){ $file= $this->getConfigFile(); //}else{ //reset($this->configFiles); //$file= next($this->configFiles); //} } $config= $this->readConfigurationFile($file); //Define si muestra o no los errores y en que nivel de detalle dependiendo en que fase se encuentre la aplicacion switch ($config['environment']){ case 'development': error_reporting(E_ALL); $this->error= 'ALL'; break; case 'production': error_reporting(0); $this->error= 'NONE'; break; default: //No realiza el llamado a funcion de error porque todavia no se cargo el modulo de errores $head= 'Configuration Error'; $message= 'The environment is not defined in configuration.json'; require $this->pathApp . 'errors/general_error.php'; exit; } //URL_APP: Url donde funciona la aplicacion $this->urlApp= $config['url_app']; //BASE_URL: Base relativa de la aplicacion - definida por el usuario en el archivo de configuracion $pos= strlen($config['relative_url']) - 1; if($config['relative_url'][$pos] != '/'){ $config['relative_url'] .= '/'; } $this->relativeUrl= $config['relative_url']; //INDEX_PAGE: Pagina inicial. En blanco si se utiliza mod_rewrite $this->indexPage= $config['index_page']; //SESSION_PROFILE: Setea la clave en la que se guarda el profile del usuario $this->sessionProfile= ""; if(isset($config['session-profile'])){ $this->sessionProfile= $config['session-profile']; } //ENVIRONMENT: Indica el ambiente de la aplicacion $this->environment= $config['environment']; //AUTHENTICATION: Indica el metodo de autenticacion de la aplicacion $this->authentication= $config['authentication']; //SESSION_AUTOSTART: Indica si el framework inicia automaticamente la session $this->sessionAutostart= $config['session_autostart']; //AUTHORIZATION_FILE: Indica el archivo que contiene la configuracion de autorizacion $this->authorizationFile= $config['authorization_file']; //CONFIG_BD: archivo de configuracion para la base de datos if(isset($config['database']) && $config['database'] != ''){ $this->databaseConfiguration= $config['database']; } //Internacionalizacion: En caso que se defina se setea el locale por defecto y todos los locales soportados if(isset($config['i18n'])){ $this->i18nDefaultLocale= $config['i18n']['default']; if(isset($config['i18n']['locales'])){ $locales= str_replace(" ", "", $config['i18n']['locales']); $this->i18nLocales= explode(",", $locales); } } //Diferentes definiciones $this->librariesDefinition= isset($config['libs']) ? $config['libs'] : []; $this->dependenciesFile= $config['dependency_injection']; $this->controllersFile= $config['controllers']; $this->middlewaresDefinition= $config['middlewares']; $this->filtersBeforeDefinition= $config['filters']; $this->filtersAfterDefinition= $config['filters_after_processing']; if(isset($config['vars'])){ $this->contextVars= $config['vars']; } }
[ "public", "function", "init", "(", ")", "{", "$", "file", "=", "'config'", ";", "//Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO", "if", "(", "$", "this", "->", "multiDomain", "&&", "$", "this", "->", "domain", ")", "{", "//Ya no i...
Carga la configuracion global de la aplicacion @param string $path_root @param string $path_framework @param string $path_application
[ "Carga", "la", "configuracion", "global", "de", "la", "aplicacion" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L196-L274
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.setBasicConstants
private function setBasicConstants(){ //Algunas constantes - La idea es ir sacandolas //PATHROOT: direccion de la carpeta del framework - definida en index.php define('PATHROOT', $this->getPathRoot()); //PATHFRA: direccion de la carpeta del framework - definida en index.php define('PATHFRA', $this->getPathFra()); //PATHAPP: direccion de la carpeta de la aplicacion - definida en index.php define('PATHAPP', $this->getPathApp()); //ENOLA_MODE: Indica si la aplicacion se esta ejecutando via HTTP o CLI if(PHP_SAPI == 'cli' || !filter_input(INPUT_SERVER, 'REQUEST_METHOD')){ define('ENOLA_MODE', 'CLI'); }else{ define('ENOLA_MODE', 'HTTP'); } }
php
private function setBasicConstants(){ //Algunas constantes - La idea es ir sacandolas //PATHROOT: direccion de la carpeta del framework - definida en index.php define('PATHROOT', $this->getPathRoot()); //PATHFRA: direccion de la carpeta del framework - definida en index.php define('PATHFRA', $this->getPathFra()); //PATHAPP: direccion de la carpeta de la aplicacion - definida en index.php define('PATHAPP', $this->getPathApp()); //ENOLA_MODE: Indica si la aplicacion se esta ejecutando via HTTP o CLI if(PHP_SAPI == 'cli' || !filter_input(INPUT_SERVER, 'REQUEST_METHOD')){ define('ENOLA_MODE', 'CLI'); }else{ define('ENOLA_MODE', 'HTTP'); } }
[ "private", "function", "setBasicConstants", "(", ")", "{", "//Algunas constantes - La idea es ir sacandolas", "//PATHROOT: direccion de la carpeta del framework - definida en index.php", "define", "(", "'PATHROOT'", ",", "$", "this", "->", "getPathRoot", "(", ")", ")", ";", "...
Establece las constantes basicas del sistema
[ "Establece", "las", "constantes", "basicas", "del", "sistema" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L278-L292
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.readConfigurationFile
public function readConfigurationFile($name, $cache = TRUE){ //Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc. $config= NULL; if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){ //Si esta en produccion y se encuentra en cache lo cargo $config= $this->app->getAttribute('C_' . $name); } if($config == NULL){ //Cargo la configuracion y guardo en cache si corresponde $config= $this->readFile($name); if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){ $this->app->setAttribute('C_' . $name, $config); } } if(! is_array($config)){ //Arma una respuesta de error de configuracion. \Enola\Support\Error::general_error('Configuration Error', 'The configuration file ' . $name . ' is not available or is misspelled'); //Cierra la aplicacion exit; } return $config; }
php
public function readConfigurationFile($name, $cache = TRUE){ //Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc. $config= NULL; if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){ //Si esta en produccion y se encuentra en cache lo cargo $config= $this->app->getAttribute('C_' . $name); } if($config == NULL){ //Cargo la configuracion y guardo en cache si corresponde $config= $this->readFile($name); if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){ $this->app->setAttribute('C_' . $name, $config); } } if(! is_array($config)){ //Arma una respuesta de error de configuracion. \Enola\Support\Error::general_error('Configuration Error', 'The configuration file ' . $name . ' is not available or is misspelled'); //Cierra la aplicacion exit; } return $config; }
[ "public", "function", "readConfigurationFile", "(", "$", "name", ",", "$", "cache", "=", "TRUE", ")", "{", "//Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc.", "$", "config", "=", "NULL", ";", "if", "(...
Devuelve un array con los valores del archivo de configuracion @param string $name @param boolean $cache @return array
[ "Devuelve", "un", "array", "con", "los", "valores", "del", "archivo", "de", "configuracion" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L440-L461
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.compileConfigurationFile
public function compileConfigurationFile($file){ //CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA require_once $this->pathFra . 'Support/Spyc.php'; $info= new \SplFileInfo($file); $path= $info->getPath() . '/'; $name= $info->getBasename('.' . $info->getExtension()); $config= $this->readFileSpecific($path . $name . '.' . $info->getExtension(), $info->getExtension()); file_put_contents($path . $name . '.php', '<?php $config = ' . var_export($config, true) . ';'); }
php
public function compileConfigurationFile($file){ //CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA require_once $this->pathFra . 'Support/Spyc.php'; $info= new \SplFileInfo($file); $path= $info->getPath() . '/'; $name= $info->getBasename('.' . $info->getExtension()); $config= $this->readFileSpecific($path . $name . '.' . $info->getExtension(), $info->getExtension()); file_put_contents($path . $name . '.php', '<?php $config = ' . var_export($config, true) . ';'); }
[ "public", "function", "compileConfigurationFile", "(", "$", "file", ")", "{", "//CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA", "require_once", "$", "this", "->", "pathFra", ".", "'Support/Spyc.php'", ";", "$", "info", "=", "new", "\\", "SplFileInfo", "(", "$", "file...
Compila archivos de configuracion. Es necesario indicar path absoluto @param type $name @param type $absolute Si es true hay que indicar el path absoluto del archivo
[ "Compila", "archivos", "de", "configuracion", ".", "Es", "necesario", "indicar", "path", "absoluto" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L467-L476
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.readFile
private function readFile($name, $folder = null){ $realConfig= NULL; $folder != null ?: $folder= $this->pathApp . $this->configurationFolder; if($this->configurationType == 'YAML'){ $realConfig = \Spyc::YAMLLoad($folder . $name . '.yml'); }else if($this->configurationType == 'PHP'){ include $folder . $name . '.php'; //La variable $config la define cada archivo incluido $realConfig= $config; }else{ $realConfig= json_decode(file_get_contents($folder . $name . '.json'), true); } return $realConfig; }
php
private function readFile($name, $folder = null){ $realConfig= NULL; $folder != null ?: $folder= $this->pathApp . $this->configurationFolder; if($this->configurationType == 'YAML'){ $realConfig = \Spyc::YAMLLoad($folder . $name . '.yml'); }else if($this->configurationType == 'PHP'){ include $folder . $name . '.php'; //La variable $config la define cada archivo incluido $realConfig= $config; }else{ $realConfig= json_decode(file_get_contents($folder . $name . '.json'), true); } return $realConfig; }
[ "private", "function", "readFile", "(", "$", "name", ",", "$", "folder", "=", "null", ")", "{", "$", "realConfig", "=", "NULL", ";", "$", "folder", "!=", "null", "?", ":", "$", "folder", "=", "$", "this", "->", "pathApp", ".", "$", "this", "->", ...
Lee un archivo y lo carga en un array @param string $name @param string $folder Si no se indica $folder se usa la carpeta de configuracion de la app @return array
[ "Lee", "un", "archivo", "y", "lo", "carga", "en", "un", "array" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L483-L496
train
edunola13/enolaphp-framework
src/EnolaContext.php
EnolaContext.readFileSpecific
public function readFileSpecific($path, $extension = 'yml'){ $realConfig= NULL; if($extension == 'yml'){ $realConfig = \Spyc::YAMLLoad($path); }else if($extension == 'php'){ include $path; //La variable $config la define cada archivo incluido $realConfig= $config; }else{ $realConfig= json_decode(file_get_contents($path), true); } return $realConfig; }
php
public function readFileSpecific($path, $extension = 'yml'){ $realConfig= NULL; if($extension == 'yml'){ $realConfig = \Spyc::YAMLLoad($path); }else if($extension == 'php'){ include $path; //La variable $config la define cada archivo incluido $realConfig= $config; }else{ $realConfig= json_decode(file_get_contents($path), true); } return $realConfig; }
[ "public", "function", "readFileSpecific", "(", "$", "path", ",", "$", "extension", "=", "'yml'", ")", "{", "$", "realConfig", "=", "NULL", ";", "if", "(", "$", "extension", "==", "'yml'", ")", "{", "$", "realConfig", "=", "\\", "Spyc", "::", "YAMLLoad"...
Lee un archivo y lo carga en un array A defirencia de readFile a este no le importa el tipo de configuracion ni la carpeta de este archivo. Toma un path completo y lo carga @param string $path @return array
[ "Lee", "un", "archivo", "y", "lo", "carga", "en", "un", "array", "A", "defirencia", "de", "readFile", "a", "este", "no", "le", "importa", "el", "tipo", "de", "configuracion", "ni", "la", "carpeta", "de", "este", "archivo", ".", "Toma", "un", "path", "c...
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L503-L515
train
wollanup/php-api-rest
src/Service/Request/QueryModifier/Modifier/FilterModifier.php
FilterModifier.hasAllRequiredData
protected function hasAllRequiredData(array $modifier) { if (array_key_exists('operator', $modifier) && !in_array($modifier['operator'], self::$allowedFilterOperators) ) { throw new ModifierException('The filter operator "' . $modifier['operator'] . '" is not allowed. You can only use one of the following: ' . implode(', ', self::$allowedFilterOperators)); } return array_key_exists('property', $modifier) && array_key_exists('value', $modifier); }
php
protected function hasAllRequiredData(array $modifier) { if (array_key_exists('operator', $modifier) && !in_array($modifier['operator'], self::$allowedFilterOperators) ) { throw new ModifierException('The filter operator "' . $modifier['operator'] . '" is not allowed. You can only use one of the following: ' . implode(', ', self::$allowedFilterOperators)); } return array_key_exists('property', $modifier) && array_key_exists('value', $modifier); }
[ "protected", "function", "hasAllRequiredData", "(", "array", "$", "modifier", ")", "{", "if", "(", "array_key_exists", "(", "'operator'", ",", "$", "modifier", ")", "&&", "!", "in_array", "(", "$", "modifier", "[", "'operator'", "]", ",", "self", "::", "$"...
Has the modifier all required data to be applied? @param array $modifier @return bool @throws ModifierException
[ "Has", "the", "modifier", "all", "required", "data", "to", "be", "applied?" ]
185eac8a8412e5997d8e292ebd0e38787ae4b949
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Service/Request/QueryModifier/Modifier/FilterModifier.php#L124-L135
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.register
public function register(\Silex\Application $app) { parent::register($app); // Register voters $app->extend('security.voters', function($voters) { return array_merge($voters, $this->voters); }); // Add reference to this in application instance $this->app = $app; $this->app['securilex'] = $this; }
php
public function register(\Silex\Application $app) { parent::register($app); // Register voters $app->extend('security.voters', function($voters) { return array_merge($voters, $this->voters); }); // Add reference to this in application instance $this->app = $app; $this->app['securilex'] = $this; }
[ "public", "function", "register", "(", "\\", "Silex", "\\", "Application", "$", "app", ")", "{", "parent", "::", "register", "(", "$", "app", ")", ";", "// Register voters", "$", "app", "->", "extend", "(", "'security.voters'", ",", "function", "(", "$", ...
Register with \Silex\Application. @param \Silex\Application $app
[ "Register", "with", "\\", "Silex", "\\", "Application", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L64-L76
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.boot
public function boot(\Silex\Application $app) { // Register firewalls foreach ($this->firewalls as $firewall) { $firewall->register($this); } $i = 0; $firewalls = array(); foreach ($this->unsecuredPatterns as $pattern => $v) { $firewalls['unsecured_'.($i++)] = array('pattern' => $pattern); } $finalConfig = array_merge($firewalls, $this->firewallConfig); $app['security.firewalls'] = $finalConfig; parent::boot($app); }
php
public function boot(\Silex\Application $app) { // Register firewalls foreach ($this->firewalls as $firewall) { $firewall->register($this); } $i = 0; $firewalls = array(); foreach ($this->unsecuredPatterns as $pattern => $v) { $firewalls['unsecured_'.($i++)] = array('pattern' => $pattern); } $finalConfig = array_merge($firewalls, $this->firewallConfig); $app['security.firewalls'] = $finalConfig; parent::boot($app); }
[ "public", "function", "boot", "(", "\\", "Silex", "\\", "Application", "$", "app", ")", "{", "// Register firewalls", "foreach", "(", "$", "this", "->", "firewalls", "as", "$", "firewall", ")", "{", "$", "firewall", "->", "register", "(", "$", "this", ")...
Boot with Silex Application @param \Silex\Application $app
[ "Boot", "with", "Silex", "Application" ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L82-L99
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.getFirewall
public function getFirewall($path = null) { if (!$path) { $path = $this->getCurrentPathRelativeToBase(); } foreach ($this->firewalls as $firewall) { if ($firewall->isPathCovered($path)) { return $firewall; } } return null; }
php
public function getFirewall($path = null) { if (!$path) { $path = $this->getCurrentPathRelativeToBase(); } foreach ($this->firewalls as $firewall) { if ($firewall->isPathCovered($path)) { return $firewall; } } return null; }
[ "public", "function", "getFirewall", "(", "$", "path", "=", "null", ")", "{", "if", "(", "!", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "getCurrentPathRelativeToBase", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "firewall...
Get the firewall with the specific path. @param string $path @return FirewallInterface
[ "Get", "the", "firewall", "with", "the", "specific", "path", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L119-L130
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.getLoginCheckPath
public function getLoginCheckPath() { $login_check = $this->app['request']->getBasePath(); if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) { $login_check .= $firewall->getLoginCheckPath(); } return $login_check; }
php
public function getLoginCheckPath() { $login_check = $this->app['request']->getBasePath(); if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) { $login_check .= $firewall->getLoginCheckPath(); } return $login_check; }
[ "public", "function", "getLoginCheckPath", "(", ")", "{", "$", "login_check", "=", "$", "this", "->", "app", "[", "'request'", "]", "->", "getBasePath", "(", ")", ";", "if", "(", "(", "$", "firewall", "=", "$", "this", "->", "getFirewall", "(", "$", ...
Get login check path. @return string
[ "Get", "login", "check", "path", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L136-L145
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.getLogoutPath
public function getLogoutPath() { $logout = $this->app['request']->getBasePath(); if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) { $logout .= $firewall->getLogoutPath(); } return $logout; }
php
public function getLogoutPath() { $logout = $this->app['request']->getBasePath(); if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) { $logout .= $firewall->getLogoutPath(); } return $logout; }
[ "public", "function", "getLogoutPath", "(", ")", "{", "$", "logout", "=", "$", "this", "->", "app", "[", "'request'", "]", "->", "getBasePath", "(", ")", ";", "if", "(", "(", "$", "firewall", "=", "$", "this", "->", "getFirewall", "(", "$", "this", ...
Get logout path. @return string
[ "Get", "logout", "path", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L151-L160
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.prependFirewallConfig
public function prependFirewallConfig($name, $config) { $this->firewallConfig = array_merge( array($name => $config), $this->firewallConfig); }
php
public function prependFirewallConfig($name, $config) { $this->firewallConfig = array_merge( array($name => $config), $this->firewallConfig); }
[ "public", "function", "prependFirewallConfig", "(", "$", "name", ",", "$", "config", ")", "{", "$", "this", "->", "firewallConfig", "=", "array_merge", "(", "array", "(", "$", "name", "=>", "$", "config", ")", ",", "$", "this", "->", "firewallConfig", ")...
Prepend additional data to firewall configuration. @param string $name @param mixed $config
[ "Prepend", "additional", "data", "to", "firewall", "configuration", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L185-L189
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.addAuthorizationVoter
public function addAuthorizationVoter(VoterInterface $voter) { if (!in_array($voter, $this->voters)) { $this->voters[] = $voter; } }
php
public function addAuthorizationVoter(VoterInterface $voter) { if (!in_array($voter, $this->voters)) { $this->voters[] = $voter; } }
[ "public", "function", "addAuthorizationVoter", "(", "VoterInterface", "$", "voter", ")", "{", "if", "(", "!", "in_array", "(", "$", "voter", ",", "$", "this", "->", "voters", ")", ")", "{", "$", "this", "->", "voters", "[", "]", "=", "$", "voter", ";...
Add additional voter to authorization module. @param VoterInterface $voter
[ "Add", "additional", "voter", "to", "authorization", "module", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L205-L210
train
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.isGranted
public function isGranted($attributes, $object = null, $catchException = true) { try { return $this->app['security.authorization_checker']->isGranted($attributes, $object); } catch (AuthenticationCredentialsNotFoundException $e) { if ($catchException) { return false; } throw $e; } }
php
public function isGranted($attributes, $object = null, $catchException = true) { try { return $this->app['security.authorization_checker']->isGranted($attributes, $object); } catch (AuthenticationCredentialsNotFoundException $e) { if ($catchException) { return false; } throw $e; } }
[ "public", "function", "isGranted", "(", "$", "attributes", ",", "$", "object", "=", "null", ",", "$", "catchException", "=", "true", ")", "{", "try", "{", "return", "$", "this", "->", "app", "[", "'security.authorization_checker'", "]", "->", "isGranted", ...
Check if the attributes are granted against the current authentication token and optionally supplied object. @param mixed $attributes @param mixed $object @param boolean $catchException @return boolean @throws AuthenticationCredentialsNotFoundException
[ "Check", "if", "the", "attributes", "are", "granted", "against", "the", "current", "authentication", "token", "and", "optionally", "supplied", "object", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L220-L231
train