id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
23,700
|
alevilar/ristorantino-vendor
|
Acl/Controller/Component/AclManagerComponent.php
|
AclManagerComponent.get_model_instance
|
private function get_model_instance($model_classname)
{
if(!isset($this->controller->{$model_classname}))
{
/*
* Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors
*/
$model_instance = ClassRegistry :: init($model_classname);
}
else
{
$model_instance = $this->controller->{$model_classname};
}
return $model_instance;
}
|
php
|
private function get_model_instance($model_classname)
{
if(!isset($this->controller->{$model_classname}))
{
/*
* Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors
*/
$model_instance = ClassRegistry :: init($model_classname);
}
else
{
$model_instance = $this->controller->{$model_classname};
}
return $model_instance;
}
|
[
"private",
"function",
"get_model_instance",
"(",
"$",
"model_classname",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"controller",
"->",
"{",
"$",
"model_classname",
"}",
")",
")",
"{",
"/*\n\t\t\t * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors\n\t\t\t */",
"$",
"model_instance",
"=",
"ClassRegistry",
"::",
"init",
"(",
"$",
"model_classname",
")",
";",
"}",
"else",
"{",
"$",
"model_instance",
"=",
"$",
"this",
"->",
"controller",
"->",
"{",
"$",
"model_classname",
"}",
";",
"}",
"return",
"$",
"model_instance",
";",
"}"
] |
Return an instance of the given model name
@param string $model_classname
@return Model
|
[
"Return",
"an",
"instance",
"of",
"the",
"given",
"model",
"name"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L136-L151
|
23,701
|
alevilar/ristorantino-vendor
|
Acl/Controller/Component/AclManagerComponent.php
|
AclManagerComponent.get_stored_controllers_hashes
|
public function get_stored_controllers_hashes()
{
$file = new File($this->controllers_hash_file);
$file_content = $file->read();
if(!empty($file_content))
{
$stored_controller_hashes = unserialize($file_content);
}
else
{
$stored_controller_hashes = array();
}
return $stored_controller_hashes;
}
|
php
|
public function get_stored_controllers_hashes()
{
$file = new File($this->controllers_hash_file);
$file_content = $file->read();
if(!empty($file_content))
{
$stored_controller_hashes = unserialize($file_content);
}
else
{
$stored_controller_hashes = array();
}
return $stored_controller_hashes;
}
|
[
"public",
"function",
"get_stored_controllers_hashes",
"(",
")",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"this",
"->",
"controllers_hash_file",
")",
";",
"$",
"file_content",
"=",
"$",
"file",
"->",
"read",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file_content",
")",
")",
"{",
"$",
"stored_controller_hashes",
"=",
"unserialize",
"(",
"$",
"file_content",
")",
";",
"}",
"else",
"{",
"$",
"stored_controller_hashes",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"stored_controller_hashes",
";",
"}"
] |
return the stored array of controllers hashes
@return array
|
[
"return",
"the",
"stored",
"array",
"of",
"controllers",
"hashes"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L158-L173
|
23,702
|
alevilar/ristorantino-vendor
|
Acl/Controller/Component/AclManagerComponent.php
|
AclManagerComponent.get_current_controllers_hashes
|
public function get_current_controllers_hashes()
{
$controllers = $this->AclReflector->get_all_controllers();
$current_controller_hashes = array();
foreach($controllers as $controller)
{
$ctler_file = new File($controller['file']);
$current_controller_hashes[$controller['name']] = $ctler_file->md5();
}
return $current_controller_hashes;
}
|
php
|
public function get_current_controllers_hashes()
{
$controllers = $this->AclReflector->get_all_controllers();
$current_controller_hashes = array();
foreach($controllers as $controller)
{
$ctler_file = new File($controller['file']);
$current_controller_hashes[$controller['name']] = $ctler_file->md5();
}
return $current_controller_hashes;
}
|
[
"public",
"function",
"get_current_controllers_hashes",
"(",
")",
"{",
"$",
"controllers",
"=",
"$",
"this",
"->",
"AclReflector",
"->",
"get_all_controllers",
"(",
")",
";",
"$",
"current_controller_hashes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"controllers",
"as",
"$",
"controller",
")",
"{",
"$",
"ctler_file",
"=",
"new",
"File",
"(",
"$",
"controller",
"[",
"'file'",
"]",
")",
";",
"$",
"current_controller_hashes",
"[",
"$",
"controller",
"[",
"'name'",
"]",
"]",
"=",
"$",
"ctler_file",
"->",
"md5",
"(",
")",
";",
"}",
"return",
"$",
"current_controller_hashes",
";",
"}"
] |
return an array of all controllers hashes
@return array
|
[
"return",
"an",
"array",
"of",
"all",
"controllers",
"hashes"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L180-L193
|
23,703
|
alevilar/ristorantino-vendor
|
Acl/Controller/Component/AclManagerComponent.php
|
AclManagerComponent.get_missing_acos
|
public function get_missing_acos($update_hash_file = true)
{
if($this->check_controller_hash_tmp_file())
{
$missing_aco_nodes = array();
$stored_controller_hashes = $this->get_stored_controllers_hashes();
$current_controller_hashes = $this->get_current_controllers_hashes();
/*
* Store current controllers hashes on disk
*/
if($update_hash_file)
{
$file = new File($this->controllers_hash_file);
$file->write(serialize($current_controller_hashes));
}
/*
* Check what controllers have changed
*/
$updated_controllers = array_keys(Set :: diff($current_controller_hashes, $stored_controller_hashes));
if(!empty($updated_controllers))
{
$aco =& $this->Acl->Aco;
foreach($updated_controllers as $controller_name)
{
if($controller_name !== 'App')
{
$controller_classname = $this->AclReflector->get_controller_classname($controller_name);
$methods = $this->AclReflector->get_controller_actions($controller_classname);
$aco =& $this->Acl->Aco;
foreach($methods as $method)
{
$methodNode = $aco->node('controllers/' . $controller_name . '/' . $method);
if(empty($methodNode))
{
$missing_aco_nodes[] = $controller_name . '/' . $method;
}
}
}
}
}
return $missing_aco_nodes;
}
}
|
php
|
public function get_missing_acos($update_hash_file = true)
{
if($this->check_controller_hash_tmp_file())
{
$missing_aco_nodes = array();
$stored_controller_hashes = $this->get_stored_controllers_hashes();
$current_controller_hashes = $this->get_current_controllers_hashes();
/*
* Store current controllers hashes on disk
*/
if($update_hash_file)
{
$file = new File($this->controllers_hash_file);
$file->write(serialize($current_controller_hashes));
}
/*
* Check what controllers have changed
*/
$updated_controllers = array_keys(Set :: diff($current_controller_hashes, $stored_controller_hashes));
if(!empty($updated_controllers))
{
$aco =& $this->Acl->Aco;
foreach($updated_controllers as $controller_name)
{
if($controller_name !== 'App')
{
$controller_classname = $this->AclReflector->get_controller_classname($controller_name);
$methods = $this->AclReflector->get_controller_actions($controller_classname);
$aco =& $this->Acl->Aco;
foreach($methods as $method)
{
$methodNode = $aco->node('controllers/' . $controller_name . '/' . $method);
if(empty($methodNode))
{
$missing_aco_nodes[] = $controller_name . '/' . $method;
}
}
}
}
}
return $missing_aco_nodes;
}
}
|
[
"public",
"function",
"get_missing_acos",
"(",
"$",
"update_hash_file",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"check_controller_hash_tmp_file",
"(",
")",
")",
"{",
"$",
"missing_aco_nodes",
"=",
"array",
"(",
")",
";",
"$",
"stored_controller_hashes",
"=",
"$",
"this",
"->",
"get_stored_controllers_hashes",
"(",
")",
";",
"$",
"current_controller_hashes",
"=",
"$",
"this",
"->",
"get_current_controllers_hashes",
"(",
")",
";",
"/*\n \t\t * Store current controllers hashes on disk\n \t\t */",
"if",
"(",
"$",
"update_hash_file",
")",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"this",
"->",
"controllers_hash_file",
")",
";",
"$",
"file",
"->",
"write",
"(",
"serialize",
"(",
"$",
"current_controller_hashes",
")",
")",
";",
"}",
"/*\n \t\t * Check what controllers have changed\n \t\t */",
"$",
"updated_controllers",
"=",
"array_keys",
"(",
"Set",
"::",
"diff",
"(",
"$",
"current_controller_hashes",
",",
"$",
"stored_controller_hashes",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"updated_controllers",
")",
")",
"{",
"$",
"aco",
"=",
"&",
"$",
"this",
"->",
"Acl",
"->",
"Aco",
";",
"foreach",
"(",
"$",
"updated_controllers",
"as",
"$",
"controller_name",
")",
"{",
"if",
"(",
"$",
"controller_name",
"!==",
"'App'",
")",
"{",
"$",
"controller_classname",
"=",
"$",
"this",
"->",
"AclReflector",
"->",
"get_controller_classname",
"(",
"$",
"controller_name",
")",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"AclReflector",
"->",
"get_controller_actions",
"(",
"$",
"controller_classname",
")",
";",
"$",
"aco",
"=",
"&",
"$",
"this",
"->",
"Acl",
"->",
"Aco",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"methodNode",
"=",
"$",
"aco",
"->",
"node",
"(",
"'controllers/'",
".",
"$",
"controller_name",
".",
"'/'",
".",
"$",
"method",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"methodNode",
")",
")",
"{",
"$",
"missing_aco_nodes",
"[",
"]",
"=",
"$",
"controller_name",
".",
"'/'",
".",
"$",
"method",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"missing_aco_nodes",
";",
"}",
"}"
] |
Get a list of plugins, controllers and actions that don't have any corresponding ACO.
To run faster, the method only checks controllers that have not already been checked or that have been modified.
Depending on the $update_hash_file, the method may return the missing ACOs only once
(in order to show the alert message only once in the view)
@param boolean $update_hash_file If true, the method update the controller hash file, making the method returning missing ACOs only once
@return array Array of missing ACO nodes by comparing with each existing plugin, controller and action
|
[
"Get",
"a",
"list",
"of",
"plugins",
"controllers",
"and",
"actions",
"that",
"don",
"t",
"have",
"any",
"corresponding",
"ACO",
".",
"To",
"run",
"faster",
"the",
"method",
"only",
"checks",
"controllers",
"that",
"have",
"not",
"already",
"been",
"checked",
"or",
"that",
"have",
"been",
"modified",
"."
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L205-L255
|
23,704
|
gedex/php-janrain-api
|
lib/Janrain/Api/Engage/LegacySharing.php
|
LegacySharing.setStatus
|
public function setStatus(array $params)
{
if (!isset($params['identifier'])) {
throw new MissingArgumentException('identifier');
}
if (!isset($params['status'])) {
throw new MissingArgumentException('status');
}
return $this->post('set_status', $params);
}
|
php
|
public function setStatus(array $params)
{
if (!isset($params['identifier'])) {
throw new MissingArgumentException('identifier');
}
if (!isset($params['status'])) {
throw new MissingArgumentException('status');
}
return $this->post('set_status', $params);
}
|
[
"public",
"function",
"setStatus",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'identifier'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'identifier'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'status'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'status'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'set_status'",
",",
"$",
"params",
")",
";",
"}"
] |
Updates the user status using the current signed in identity provider.
@param array $params
@link http://developers.janrain.com/documentation/api-methods/engage/legacy/set_status/
|
[
"Updates",
"the",
"user",
"status",
"using",
"the",
"current",
"signed",
"in",
"identity",
"provider",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/LegacySharing.php#L51-L62
|
23,705
|
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
|
PdoSessionRegistryStorage.createTable
|
public function createTable()
{
// connect if we are not yet
$this->getConnection();
switch ($this->driver) {
case 'mysql':
// We use varbinary for the ID column because it prevents unwanted conversions:
// - character set conversions between server and client
// - trailing space removal
// - case-insensitivity
// - language processing like é == e
$sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB";
break;
case 'sqlite':
$sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'pgsql':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'oci':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'sqlsrv':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
default:
throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
}
try {
$this->getConnection()->exec($sql);
} catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e);
}
}
|
php
|
public function createTable()
{
// connect if we are not yet
$this->getConnection();
switch ($this->driver) {
case 'mysql':
// We use varbinary for the ID column because it prevents unwanted conversions:
// - character set conversions between server and client
// - trailing space removal
// - case-insensitivity
// - language processing like é == e
$sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB";
break;
case 'sqlite':
$sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'pgsql':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'oci':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
case 'sqlsrv':
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
break;
default:
throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
}
try {
$this->getConnection()->exec($sql);
} catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e);
}
}
|
[
"public",
"function",
"createTable",
"(",
")",
"{",
"// connect if we are not yet",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"driver",
")",
"{",
"case",
"'mysql'",
":",
"// We use varbinary for the ID column because it prevents unwanted conversions:",
"// - character set conversions between server and client",
"// - trailing space removal",
"// - case-insensitivity",
"// - language processing like é == e",
"$",
"sql",
"=",
"\"CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB\"",
";",
"break",
";",
"case",
"'sqlite'",
":",
"$",
"sql",
"=",
"\"CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"",
";",
"break",
";",
"case",
"'pgsql'",
":",
"$",
"sql",
"=",
"\"CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"",
";",
"break",
";",
"case",
"'oci'",
":",
"$",
"sql",
"=",
"\"CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"",
";",
"break",
";",
"case",
"'sqlsrv'",
":",
"$",
"sql",
"=",
"\"CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"'Creating the session table is currently not implemented for PDO driver \"%s\".'",
",",
"$",
"this",
"->",
"driver",
")",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"exec",
"(",
"$",
"sql",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'PDOException was thrown when trying to create sessions info table: %s'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Creates the table to store sessions which can be called once for setup.
Session ID is saved in a column of maximum length 128 because that is enough even
for a 512 bit configured session.hash_function like Whirlpool. Session username is
saved in a varchar of maximun length 256 because any valid email should fit into it.
One could also use a larger column if one was sure the data dfits into it.
@throws \RuntimeException When the table cannot be created
@throws \DomainException When an unsupported PDO driver is used
|
[
"Creates",
"the",
"table",
"to",
"store",
"sessions",
"which",
"can",
"be",
"called",
"once",
"for",
"setup",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php#L134-L169
|
23,706
|
zeropingheroes/steam-browser-protocol
|
src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php
|
SteamBrowserProtocol.connectToServer
|
public function connectToServer($address, $options = array())
{
$parameters = NULL;
if ( array_key_exists('port', $options) )
{
$parameters = ':'.$options['port'];
}
if ( array_key_exists('password', $options) )
{
$parameters .= '/'.$options['password'];
}
return $this->protocol.'connect/'.$address.$parameters;
}
|
php
|
public function connectToServer($address, $options = array())
{
$parameters = NULL;
if ( array_key_exists('port', $options) )
{
$parameters = ':'.$options['port'];
}
if ( array_key_exists('password', $options) )
{
$parameters .= '/'.$options['password'];
}
return $this->protocol.'connect/'.$address.$parameters;
}
|
[
"public",
"function",
"connectToServer",
"(",
"$",
"address",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"parameters",
"=",
"NULL",
";",
"if",
"(",
"array_key_exists",
"(",
"'port'",
",",
"$",
"options",
")",
")",
"{",
"$",
"parameters",
"=",
"':'",
".",
"$",
"options",
"[",
"'port'",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'password'",
",",
"$",
"options",
")",
")",
"{",
"$",
"parameters",
".=",
"'/'",
".",
"$",
"options",
"[",
"'password'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"protocol",
".",
"'connect/'",
".",
"$",
"address",
".",
"$",
"parameters",
";",
"}"
] |
Generates a link to connecto the specified server
@param string $address Server IP or hostname
@param array $options Server port and password
@return string
|
[
"Generates",
"a",
"link",
"to",
"connecto",
"the",
"specified",
"server"
] |
1fce6740f2aed27480be5231351656aadcbf1d39
|
https://github.com/zeropingheroes/steam-browser-protocol/blob/1fce6740f2aed27480be5231351656aadcbf1d39/src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php#L112-L125
|
23,707
|
zeropingheroes/steam-browser-protocol
|
src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php
|
SteamBrowserProtocol.openSteamPage
|
public function openSteamPage($page, $parameter = NULL)
{
if( in_array($page, $this->steamPages) )
{
return $this->protocol.'url/'.$page.'/'.$parameter;
}
}
|
php
|
public function openSteamPage($page, $parameter = NULL)
{
if( in_array($page, $this->steamPages) )
{
return $this->protocol.'url/'.$page.'/'.$parameter;
}
}
|
[
"public",
"function",
"openSteamPage",
"(",
"$",
"page",
",",
"$",
"parameter",
"=",
"NULL",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"page",
",",
"$",
"this",
"->",
"steamPages",
")",
")",
"{",
"return",
"$",
"this",
"->",
"protocol",
".",
"'url/'",
".",
"$",
"page",
".",
"'/'",
".",
"$",
"parameter",
";",
"}",
"}"
] |
Generates a link to open the specified named page
@param string $page Page
@param array $parameter Additional parameter
@return string
|
[
"Generates",
"a",
"link",
"to",
"open",
"the",
"specified",
"named",
"page"
] |
1fce6740f2aed27480be5231351656aadcbf1d39
|
https://github.com/zeropingheroes/steam-browser-protocol/blob/1fce6740f2aed27480be5231351656aadcbf1d39/src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php#L295-L301
|
23,708
|
songshenzong/log
|
src/DataCollector/QueryCollector.php
|
QueryCollector.findSource
|
protected function findSource()
{
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
$sources = [];
foreach ($stack as $index => $trace) {
$sources[] = $this->parseTrace($index, $trace);
}
return array_filter($sources);
}
|
php
|
protected function findSource()
{
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
$sources = [];
foreach ($stack as $index => $trace) {
$sources[] = $this->parseTrace($index, $trace);
}
return array_filter($sources);
}
|
[
"protected",
"function",
"findSource",
"(",
")",
"{",
"$",
"stack",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
"|",
"DEBUG_BACKTRACE_PROVIDE_OBJECT",
")",
";",
"$",
"sources",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"stack",
"as",
"$",
"index",
"=>",
"$",
"trace",
")",
"{",
"$",
"sources",
"[",
"]",
"=",
"$",
"this",
"->",
"parseTrace",
"(",
"$",
"index",
",",
"$",
"trace",
")",
";",
"}",
"return",
"array_filter",
"(",
"$",
"sources",
")",
";",
"}"
] |
Use a backtrace to search for the origins of the query.
@return array
|
[
"Use",
"a",
"backtrace",
"to",
"search",
"for",
"the",
"origins",
"of",
"the",
"query",
"."
] |
b1e01f7994da47737866eabf82367490eab17c46
|
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/QueryCollector.php#L215-L226
|
23,709
|
songshenzong/log
|
src/DataCollector/QueryCollector.php
|
QueryCollector.parseTrace
|
protected function parseTrace($index, array $trace)
{
$frame = (object) [
'index' => $index,
'namespace' => null,
'name' => null,
'line' => isset($trace['line']) ? $trace['line'] : '?',
];
if (isset($trace['function']) && $trace['function'] == 'substituteBindings') {
$frame->name = 'Route binding';
return $frame;
}
if (isset($trace['class']) && isset($trace['file']) && strpos(
$trace['file'],
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework'
) === false && strpos(
$trace['file'],
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar'
) === false
) {
$file = $trace['file'];
if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) {
list($file, $frame->line) = $this->getTwigInfo($trace);
} elseif (strpos($file, storage_path()) !== false) {
$hash = pathinfo($file, PATHINFO_FILENAME);
if (!$frame->name = $this->findViewFromHash($hash)) {
$frame->name = $hash;
}
$frame->namespace = 'view';
return $frame;
} elseif (strpos($file, 'Middleware') !== false) {
$frame->name = $this->findMiddlewareFromFile($file);
if ($frame->name) {
$frame->namespace = 'middleware';
} else {
$frame->name = $this->normalizeFilename($file);
}
return $frame;
}
$frame->name = $this->normalizeFilename($file);
return $frame;
}
return false;
}
|
php
|
protected function parseTrace($index, array $trace)
{
$frame = (object) [
'index' => $index,
'namespace' => null,
'name' => null,
'line' => isset($trace['line']) ? $trace['line'] : '?',
];
if (isset($trace['function']) && $trace['function'] == 'substituteBindings') {
$frame->name = 'Route binding';
return $frame;
}
if (isset($trace['class']) && isset($trace['file']) && strpos(
$trace['file'],
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework'
) === false && strpos(
$trace['file'],
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar'
) === false
) {
$file = $trace['file'];
if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) {
list($file, $frame->line) = $this->getTwigInfo($trace);
} elseif (strpos($file, storage_path()) !== false) {
$hash = pathinfo($file, PATHINFO_FILENAME);
if (!$frame->name = $this->findViewFromHash($hash)) {
$frame->name = $hash;
}
$frame->namespace = 'view';
return $frame;
} elseif (strpos($file, 'Middleware') !== false) {
$frame->name = $this->findMiddlewareFromFile($file);
if ($frame->name) {
$frame->namespace = 'middleware';
} else {
$frame->name = $this->normalizeFilename($file);
}
return $frame;
}
$frame->name = $this->normalizeFilename($file);
return $frame;
}
return false;
}
|
[
"protected",
"function",
"parseTrace",
"(",
"$",
"index",
",",
"array",
"$",
"trace",
")",
"{",
"$",
"frame",
"=",
"(",
"object",
")",
"[",
"'index'",
"=>",
"$",
"index",
",",
"'namespace'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'line'",
"=>",
"isset",
"(",
"$",
"trace",
"[",
"'line'",
"]",
")",
"?",
"$",
"trace",
"[",
"'line'",
"]",
":",
"'?'",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"'function'",
"]",
")",
"&&",
"$",
"trace",
"[",
"'function'",
"]",
"==",
"'substituteBindings'",
")",
"{",
"$",
"frame",
"->",
"name",
"=",
"'Route binding'",
";",
"return",
"$",
"frame",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"'class'",
"]",
")",
"&&",
"isset",
"(",
"$",
"trace",
"[",
"'file'",
"]",
")",
"&&",
"strpos",
"(",
"$",
"trace",
"[",
"'file'",
"]",
",",
"DIRECTORY_SEPARATOR",
".",
"'vendor'",
".",
"DIRECTORY_SEPARATOR",
".",
"'laravel'",
".",
"DIRECTORY_SEPARATOR",
".",
"'framework'",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"trace",
"[",
"'file'",
"]",
",",
"DIRECTORY_SEPARATOR",
".",
"'vendor'",
".",
"DIRECTORY_SEPARATOR",
".",
"'barryvdh'",
".",
"DIRECTORY_SEPARATOR",
".",
"'laravel-debugbar'",
")",
"===",
"false",
")",
"{",
"$",
"file",
"=",
"$",
"trace",
"[",
"'file'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"'object'",
"]",
")",
"&&",
"is_a",
"(",
"$",
"trace",
"[",
"'object'",
"]",
",",
"'Twig_Template'",
")",
")",
"{",
"list",
"(",
"$",
"file",
",",
"$",
"frame",
"->",
"line",
")",
"=",
"$",
"this",
"->",
"getTwigInfo",
"(",
"$",
"trace",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"file",
",",
"storage_path",
"(",
")",
")",
"!==",
"false",
")",
"{",
"$",
"hash",
"=",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_FILENAME",
")",
";",
"if",
"(",
"!",
"$",
"frame",
"->",
"name",
"=",
"$",
"this",
"->",
"findViewFromHash",
"(",
"$",
"hash",
")",
")",
"{",
"$",
"frame",
"->",
"name",
"=",
"$",
"hash",
";",
"}",
"$",
"frame",
"->",
"namespace",
"=",
"'view'",
";",
"return",
"$",
"frame",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"file",
",",
"'Middleware'",
")",
"!==",
"false",
")",
"{",
"$",
"frame",
"->",
"name",
"=",
"$",
"this",
"->",
"findMiddlewareFromFile",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"frame",
"->",
"name",
")",
"{",
"$",
"frame",
"->",
"namespace",
"=",
"'middleware'",
";",
"}",
"else",
"{",
"$",
"frame",
"->",
"name",
"=",
"$",
"this",
"->",
"normalizeFilename",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"frame",
";",
"}",
"$",
"frame",
"->",
"name",
"=",
"$",
"this",
"->",
"normalizeFilename",
"(",
"$",
"file",
")",
";",
"return",
"$",
"frame",
";",
"}",
"return",
"false",
";",
"}"
] |
Parse a trace element from the backtrace stack.
@param int $index
@param array $trace
@return object|bool
|
[
"Parse",
"a",
"trace",
"element",
"from",
"the",
"backtrace",
"stack",
"."
] |
b1e01f7994da47737866eabf82367490eab17c46
|
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/QueryCollector.php#L236-L292
|
23,710
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.find
|
public function find($key, $default = null) {
$key = $this->formatKey($key);
$headers = array_get($this->headers, $key, $default);
if (is_array($headers)) {
$headers = array_pop($headers);
}
return $headers;
}
|
php
|
public function find($key, $default = null) {
$key = $this->formatKey($key);
$headers = array_get($this->headers, $key, $default);
if (is_array($headers)) {
$headers = array_pop($headers);
}
return $headers;
}
|
[
"public",
"function",
"find",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"formatKey",
"(",
"$",
"key",
")",
";",
"$",
"headers",
"=",
"array_get",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"=",
"array_pop",
"(",
"$",
"headers",
")",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Find the last added header.
@param $key
@param null $default
@return string
|
[
"Find",
"the",
"last",
"added",
"header",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L56-L65
|
23,711
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.set
|
public function set($key, $value) {
$key = $this->formatKey($key);
array_set($this->headers, $key, [$value]);
}
|
php
|
public function set($key, $value) {
$key = $this->formatKey($key);
array_set($this->headers, $key, [$value]);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"formatKey",
"(",
"$",
"key",
")",
";",
"array_set",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"key",
",",
"[",
"$",
"value",
"]",
")",
";",
"}"
] |
Replace all previous headers with this one.
@param $key
@param $value
|
[
"Replace",
"all",
"previous",
"headers",
"with",
"this",
"one",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L73-L76
|
23,712
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.get
|
public function get($key) {
$key = $this->formatKey($key);
return array_get($this->headers, $key, []);
}
|
php
|
public function get($key) {
$key = $this->formatKey($key);
return array_get($this->headers, $key, []);
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"formatKey",
"(",
"$",
"key",
")",
";",
"return",
"array_get",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"key",
",",
"[",
"]",
")",
";",
"}"
] |
Get all headers by key.
@param $key
@return array
|
[
"Get",
"all",
"headers",
"by",
"key",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L85-L88
|
23,713
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.has
|
public function has($key) {
$key = $this->formatKey($key);
return array_has($this->headers, $key);
}
|
php
|
public function has($key) {
$key = $this->formatKey($key);
return array_has($this->headers, $key);
}
|
[
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"formatKey",
"(",
"$",
"key",
")",
";",
"return",
"array_has",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"key",
")",
";",
"}"
] |
Check if there are any headers.
@param $key
@return bool
|
[
"Check",
"if",
"there",
"are",
"any",
"headers",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L97-L100
|
23,714
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.remove
|
public function remove($key) {
$key = $this->formatKey($key);
array_remove($this->headers, $key);
}
|
php
|
public function remove($key) {
$key = $this->formatKey($key);
array_remove($this->headers, $key);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"formatKey",
"(",
"$",
"key",
")",
";",
"array_remove",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"key",
")",
";",
"}"
] |
Remove all registered headers.
@param $key
|
[
"Remove",
"all",
"registered",
"headers",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L107-L110
|
23,715
|
weew/http
|
src/Weew/Http/HttpHeaders.php
|
HttpHeaders.toFlatArray
|
public function toFlatArray() {
$array = [];
foreach ($this->headers as $key => $headers) {
foreach ($headers as $header) {
$array[] = $this->formatHeader($key, $header);
}
}
return $array;
}
|
php
|
public function toFlatArray() {
$array = [];
foreach ($this->headers as $key => $headers) {
foreach ($headers as $header) {
$array[] = $this->formatHeader($key, $header);
}
}
return $array;
}
|
[
"public",
"function",
"toFlatArray",
"(",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"key",
"=>",
"$",
"headers",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"this",
"->",
"formatHeader",
"(",
"$",
"key",
",",
"$",
"header",
")",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Get a list of formatted header strings.
@return array
|
[
"Get",
"a",
"list",
"of",
"formatted",
"header",
"strings",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L160-L170
|
23,716
|
SporkCode/Spork
|
src/Mvc/Controller/AbstractRestfulTableController.php
|
AbstractRestfulTableController.toArray
|
protected function toArray($data)
{
if (is_array($data)) {
return $data;
}
if (is_object($data)) {
if (method_exists($data, 'toArray')) {
return $data->toArray();
}
if ($data instanceof \Traversable) {
return iterator_to_array($data);
}
}
return (array) $data;
}
|
php
|
protected function toArray($data)
{
if (is_array($data)) {
return $data;
}
if (is_object($data)) {
if (method_exists($data, 'toArray')) {
return $data->toArray();
}
if ($data instanceof \Traversable) {
return iterator_to_array($data);
}
}
return (array) $data;
}
|
[
"protected",
"function",
"toArray",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"data",
",",
"'toArray'",
")",
")",
"{",
"return",
"$",
"data",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"$",
"data",
"instanceof",
"\\",
"Traversable",
")",
"{",
"return",
"iterator_to_array",
"(",
"$",
"data",
")",
";",
"}",
"}",
"return",
"(",
"array",
")",
"$",
"data",
";",
"}"
] |
Convert a result set to an array
@param unknown $data
|
[
"Convert",
"a",
"result",
"set",
"to",
"an",
"array"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Controller/AbstractRestfulTableController.php#L120-L136
|
23,717
|
loevgaard/altapay-php-sdk
|
src/Payload/PaymentRequest.php
|
PaymentRequest.parseCookieParts
|
public static function parseCookieParts(array $cookieParts)
{
$cookie = '';
foreach ($cookieParts as $key => $val) {
$cookie .= $key.'='.rawurlencode($val).';';
}
$cookie = trim($cookie, ';');
return $cookie;
}
|
php
|
public static function parseCookieParts(array $cookieParts)
{
$cookie = '';
foreach ($cookieParts as $key => $val) {
$cookie .= $key.'='.rawurlencode($val).';';
}
$cookie = trim($cookie, ';');
return $cookie;
}
|
[
"public",
"static",
"function",
"parseCookieParts",
"(",
"array",
"$",
"cookieParts",
")",
"{",
"$",
"cookie",
"=",
"''",
";",
"foreach",
"(",
"$",
"cookieParts",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"cookie",
".=",
"$",
"key",
".",
"'='",
".",
"rawurlencode",
"(",
"$",
"val",
")",
".",
"';'",
";",
"}",
"$",
"cookie",
"=",
"trim",
"(",
"$",
"cookie",
",",
"';'",
")",
";",
"return",
"$",
"cookie",
";",
"}"
] |
Takes an array of cookie parts and returns an urlencoded string ready to send
@param array $cookieParts
@return string
|
[
"Takes",
"an",
"array",
"of",
"cookie",
"parts",
"and",
"returns",
"an",
"urlencoded",
"string",
"ready",
"to",
"send"
] |
476664e8725407249c04ca7ae76f92882e4f4583
|
https://github.com/loevgaard/altapay-php-sdk/blob/476664e8725407249c04ca7ae76f92882e4f4583/src/Payload/PaymentRequest.php#L212-L221
|
23,718
|
heidelpay/PhpDoc
|
src/phpDocumentor/Translator/ServiceProvider.php
|
ServiceProvider.register
|
public function register(Application $app)
{
/** @var ApplicationConfiguration $config */
$config = $app['config'];
$app['translator.locale'] = $config->getTranslator()->getLocale();
$app['translator'] = $app->share(
function ($app) {
$translator = new Translator();
$translator->setLocale($app['translator.locale']);
return $translator;
}
);
}
|
php
|
public function register(Application $app)
{
/** @var ApplicationConfiguration $config */
$config = $app['config'];
$app['translator.locale'] = $config->getTranslator()->getLocale();
$app['translator'] = $app->share(
function ($app) {
$translator = new Translator();
$translator->setLocale($app['translator.locale']);
return $translator;
}
);
}
|
[
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"/** @var ApplicationConfiguration $config */",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"$",
"app",
"[",
"'translator.locale'",
"]",
"=",
"$",
"config",
"->",
"getTranslator",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"$",
"app",
"[",
"'translator'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"translator",
"=",
"new",
"Translator",
"(",
")",
";",
"$",
"translator",
"->",
"setLocale",
"(",
"$",
"app",
"[",
"'translator.locale'",
"]",
")",
";",
"return",
"$",
"translator",
";",
"}",
")",
";",
"}"
] |
Registers the translator using the currently active locale.
@param Application $app
|
[
"Registers",
"the",
"translator",
"using",
"the",
"currently",
"active",
"locale",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/ServiceProvider.php#L36-L51
|
23,719
|
lukasz-adamski/teamspeak3-framework
|
src/TeamSpeak3/Node/Channel.php
|
Channel.clientGetById
|
public function clientGetById($clid)
{
if(!array_key_exists($clid, $this->clientList()))
{
throw new Exception("invalid clientID", 0x200);
}
return $this->clientList[intval($clid)];
}
|
php
|
public function clientGetById($clid)
{
if(!array_key_exists($clid, $this->clientList()))
{
throw new Exception("invalid clientID", 0x200);
}
return $this->clientList[intval($clid)];
}
|
[
"public",
"function",
"clientGetById",
"(",
"$",
"clid",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"clid",
",",
"$",
"this",
"->",
"clientList",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"invalid clientID\"",
",",
"0x200",
")",
";",
"}",
"return",
"$",
"this",
"->",
"clientList",
"[",
"intval",
"(",
"$",
"clid",
")",
"]",
";",
"}"
] |
Returns the Client object matching the given ID.
@param integer $clid
@throws Exception
@return Client
|
[
"Returns",
"the",
"Client",
"object",
"matching",
"the",
"given",
"ID",
"."
] |
39a56eca608da6b56b6aa386a7b5b31dc576c41a
|
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Channel.php#L146-L154
|
23,720
|
xiewulong/yii2-fileupload
|
oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
|
ContainerAwareEventDispatcher.lazyLoad
|
protected function lazyLoad($eventName)
{
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $args) {
list($serviceId, $method, $priority) = $args;
$listener = $this->container->get($serviceId);
$key = $serviceId.'.'.$method;
if (!isset($this->listeners[$eventName][$key])) {
$this->addListener($eventName, array($listener, $method), $priority);
} elseif ($listener !== $this->listeners[$eventName][$key]) {
parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
$this->addListener($eventName, array($listener, $method), $priority);
}
$this->listeners[$eventName][$key] = $listener;
}
}
}
|
php
|
protected function lazyLoad($eventName)
{
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $args) {
list($serviceId, $method, $priority) = $args;
$listener = $this->container->get($serviceId);
$key = $serviceId.'.'.$method;
if (!isset($this->listeners[$eventName][$key])) {
$this->addListener($eventName, array($listener, $method), $priority);
} elseif ($listener !== $this->listeners[$eventName][$key]) {
parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
$this->addListener($eventName, array($listener, $method), $priority);
}
$this->listeners[$eventName][$key] = $listener;
}
}
}
|
[
"protected",
"function",
"lazyLoad",
"(",
"$",
"eventName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listenerIds",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listenerIds",
"[",
"$",
"eventName",
"]",
"as",
"$",
"args",
")",
"{",
"list",
"(",
"$",
"serviceId",
",",
"$",
"method",
",",
"$",
"priority",
")",
"=",
"$",
"args",
";",
"$",
"listener",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
")",
";",
"$",
"key",
"=",
"$",
"serviceId",
".",
"'.'",
".",
"$",
"method",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addListener",
"(",
"$",
"eventName",
",",
"array",
"(",
"$",
"listener",
",",
"$",
"method",
")",
",",
"$",
"priority",
")",
";",
"}",
"elseif",
"(",
"$",
"listener",
"!==",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"[",
"$",
"key",
"]",
")",
"{",
"parent",
"::",
"removeListener",
"(",
"$",
"eventName",
",",
"array",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"addListener",
"(",
"$",
"eventName",
",",
"array",
"(",
"$",
"listener",
",",
"$",
"method",
")",
",",
"$",
"priority",
")",
";",
"}",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"listener",
";",
"}",
"}",
"}"
] |
Lazily loads listeners for this event from the dependency injection
container.
@param string $eventName The name of the event to dispatch. The name of
the event is the name of the method that is
invoked on listeners.
|
[
"Lazily",
"loads",
"listeners",
"for",
"this",
"event",
"from",
"the",
"dependency",
"injection",
"container",
"."
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php#L183-L201
|
23,721
|
CalderaWP/metaplate-core
|
src/render.php
|
render.helpers
|
private function helpers( $handlebars ) {
$helpers = $this->default_helpers();
/**
*
* @param array $helpers {
* Name, class & callback for the helper.
*
* @type string $name Name of helper to use in Handlebars.
* @type string $class Class containing callback function.
* @type string $callback. Optional. The name of the callback function. If not set, "helper" will be used.
* }
* @param obj|\Handlebars\Handlebars $handlebars Handlebars.php class instance
*
*/
$helpers = apply_filters( 'caldera_metaplate_handlebars_helpers', $helpers, $handlebars );
$handlebars = new helper_loader( $handlebars, $helpers );
if ( isset( $handlebars->handlebars ) ) {
$handlebars = $handlebars->handlebars;
}
return $handlebars;
}
|
php
|
private function helpers( $handlebars ) {
$helpers = $this->default_helpers();
/**
*
* @param array $helpers {
* Name, class & callback for the helper.
*
* @type string $name Name of helper to use in Handlebars.
* @type string $class Class containing callback function.
* @type string $callback. Optional. The name of the callback function. If not set, "helper" will be used.
* }
* @param obj|\Handlebars\Handlebars $handlebars Handlebars.php class instance
*
*/
$helpers = apply_filters( 'caldera_metaplate_handlebars_helpers', $helpers, $handlebars );
$handlebars = new helper_loader( $handlebars, $helpers );
if ( isset( $handlebars->handlebars ) ) {
$handlebars = $handlebars->handlebars;
}
return $handlebars;
}
|
[
"private",
"function",
"helpers",
"(",
"$",
"handlebars",
")",
"{",
"$",
"helpers",
"=",
"$",
"this",
"->",
"default_helpers",
"(",
")",
";",
"/**\n\t\t *\n\t\t * @param array $helpers {\n\t\t * Name, class & callback for the helper.\n\t\t *\n\t\t * @type string $name Name of helper to use in Handlebars.\n\t\t * @type string $class Class containing callback function.\n\t\t * @type string $callback. Optional. The name of the callback function. If not set, \"helper\" will be used.\n\t\t * }\n\t\t * @param obj|\\Handlebars\\Handlebars $handlebars Handlebars.php class instance\n\t\t *\n\t\t */",
"$",
"helpers",
"=",
"apply_filters",
"(",
"'caldera_metaplate_handlebars_helpers'",
",",
"$",
"helpers",
",",
"$",
"handlebars",
")",
";",
"$",
"handlebars",
"=",
"new",
"helper_loader",
"(",
"$",
"handlebars",
",",
"$",
"helpers",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"handlebars",
"->",
"handlebars",
")",
")",
"{",
"$",
"handlebars",
"=",
"$",
"handlebars",
"->",
"handlebars",
";",
"}",
"return",
"$",
"handlebars",
";",
"}"
] |
Register helpers.
Adds the default helpers, plus any set on "caldera_metaplate_handlebars_helpers" filter.
@param obj|\Handlebars\Handlebars $handlebars Current instance of Handlebars.
@return \Handlebars\Handlebars Current instance of Handlebars with the additional helpers added on.
|
[
"Register",
"helpers",
"."
] |
15ede9c4250ab23112a32f8e45d5393f8278bbb8
|
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/render.php#L183-L207
|
23,722
|
oroinc/OroLayoutComponent
|
Extension/AbstractExtension.php
|
AbstractExtension.initTypes
|
private function initTypes()
{
$this->types = [];
foreach ($this->loadTypes() as $type) {
if (!$type instanceof BlockTypeInterface) {
throw new Exception\UnexpectedTypeException(
$type,
'Oro\Component\Layout\BlockTypeInterface'
);
}
$this->types[$type->getName()] = $type;
}
}
|
php
|
private function initTypes()
{
$this->types = [];
foreach ($this->loadTypes() as $type) {
if (!$type instanceof BlockTypeInterface) {
throw new Exception\UnexpectedTypeException(
$type,
'Oro\Component\Layout\BlockTypeInterface'
);
}
$this->types[$type->getName()] = $type;
}
}
|
[
"private",
"function",
"initTypes",
"(",
")",
"{",
"$",
"this",
"->",
"types",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"loadTypes",
"(",
")",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"type",
"instanceof",
"BlockTypeInterface",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"type",
",",
"'Oro\\Component\\Layout\\BlockTypeInterface'",
")",
";",
"}",
"$",
"this",
"->",
"types",
"[",
"$",
"type",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"type",
";",
"}",
"}"
] |
Initializes block types.
@throws Exception\UnexpectedTypeException if any registered block type is not
an instance of BlockTypeInterface
|
[
"Initializes",
"block",
"types",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/AbstractExtension.php#L278-L292
|
23,723
|
oroinc/OroLayoutComponent
|
Extension/AbstractExtension.php
|
AbstractExtension.initTypeExtensions
|
private function initTypeExtensions()
{
$this->typeExtensions = [];
foreach ($this->loadTypeExtensions() as $extension) {
if (!$extension instanceof BlockTypeExtensionInterface) {
throw new Exception\UnexpectedTypeException(
$extension,
'Oro\Component\Layout\BlockTypeExtensionInterface'
);
}
$type = $extension->getExtendedType();
$this->typeExtensions[$type][] = $extension;
}
}
|
php
|
private function initTypeExtensions()
{
$this->typeExtensions = [];
foreach ($this->loadTypeExtensions() as $extension) {
if (!$extension instanceof BlockTypeExtensionInterface) {
throw new Exception\UnexpectedTypeException(
$extension,
'Oro\Component\Layout\BlockTypeExtensionInterface'
);
}
$type = $extension->getExtendedType();
$this->typeExtensions[$type][] = $extension;
}
}
|
[
"private",
"function",
"initTypeExtensions",
"(",
")",
"{",
"$",
"this",
"->",
"typeExtensions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"loadTypeExtensions",
"(",
")",
"as",
"$",
"extension",
")",
"{",
"if",
"(",
"!",
"$",
"extension",
"instanceof",
"BlockTypeExtensionInterface",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"extension",
",",
"'Oro\\Component\\Layout\\BlockTypeExtensionInterface'",
")",
";",
"}",
"$",
"type",
"=",
"$",
"extension",
"->",
"getExtendedType",
"(",
")",
";",
"$",
"this",
"->",
"typeExtensions",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"extension",
";",
"}",
"}"
] |
Initializes block type extensions.
@throws Exception\UnexpectedTypeException if any registered block type extension is not
an instance of BlockTypeExtensionInterface
|
[
"Initializes",
"block",
"type",
"extensions",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/AbstractExtension.php#L300-L316
|
23,724
|
oroinc/OroLayoutComponent
|
Extension/AbstractExtension.php
|
AbstractExtension.initLayoutUpdates
|
private function initLayoutUpdates(ContextInterface $context)
{
$loadedLayoutUpdates = $this->loadLayoutUpdates($context);
foreach ($loadedLayoutUpdates as $id => $layoutUpdates) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException(
$id,
'string',
'layout item id'
);
}
if (!is_array($layoutUpdates)) {
throw new Exception\UnexpectedTypeException(
$layoutUpdates,
'array',
sprintf('layout updates for item "%s"', $id)
);
}
foreach ($layoutUpdates as $layoutUpdate) {
if (!$layoutUpdate instanceof LayoutUpdateInterface) {
throw new Exception\UnexpectedTypeException(
$layoutUpdate,
'Oro\Component\Layout\LayoutUpdateInterface'
);
}
}
}
$this->layoutUpdates = $loadedLayoutUpdates;
}
|
php
|
private function initLayoutUpdates(ContextInterface $context)
{
$loadedLayoutUpdates = $this->loadLayoutUpdates($context);
foreach ($loadedLayoutUpdates as $id => $layoutUpdates) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException(
$id,
'string',
'layout item id'
);
}
if (!is_array($layoutUpdates)) {
throw new Exception\UnexpectedTypeException(
$layoutUpdates,
'array',
sprintf('layout updates for item "%s"', $id)
);
}
foreach ($layoutUpdates as $layoutUpdate) {
if (!$layoutUpdate instanceof LayoutUpdateInterface) {
throw new Exception\UnexpectedTypeException(
$layoutUpdate,
'Oro\Component\Layout\LayoutUpdateInterface'
);
}
}
}
$this->layoutUpdates = $loadedLayoutUpdates;
}
|
[
"private",
"function",
"initLayoutUpdates",
"(",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"loadedLayoutUpdates",
"=",
"$",
"this",
"->",
"loadLayoutUpdates",
"(",
"$",
"context",
")",
";",
"foreach",
"(",
"$",
"loadedLayoutUpdates",
"as",
"$",
"id",
"=>",
"$",
"layoutUpdates",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"id",
",",
"'string'",
",",
"'layout item id'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"layoutUpdates",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"layoutUpdates",
",",
"'array'",
",",
"sprintf",
"(",
"'layout updates for item \"%s\"'",
",",
"$",
"id",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"layoutUpdates",
"as",
"$",
"layoutUpdate",
")",
"{",
"if",
"(",
"!",
"$",
"layoutUpdate",
"instanceof",
"LayoutUpdateInterface",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"layoutUpdate",
",",
"'Oro\\Component\\Layout\\LayoutUpdateInterface'",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"layoutUpdates",
"=",
"$",
"loadedLayoutUpdates",
";",
"}"
] |
Initializes layout updates.
@param ContextInterface $context
@throws Exception\UnexpectedTypeException if any registered layout update is not
an instance of LayoutUpdateInterface
or layout item id is not a string
|
[
"Initializes",
"layout",
"updates",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/AbstractExtension.php#L327-L355
|
23,725
|
oroinc/OroLayoutComponent
|
Extension/AbstractExtension.php
|
AbstractExtension.initContextConfigurators
|
private function initContextConfigurators()
{
$this->contextConfigurators = [];
foreach ($this->loadContextConfigurators() as $configurator) {
if (!$configurator instanceof ContextConfiguratorInterface) {
throw new Exception\UnexpectedTypeException(
$configurator,
'Oro\Component\Layout\ContextConfiguratorInterface'
);
}
$this->contextConfigurators[] = $configurator;
}
}
|
php
|
private function initContextConfigurators()
{
$this->contextConfigurators = [];
foreach ($this->loadContextConfigurators() as $configurator) {
if (!$configurator instanceof ContextConfiguratorInterface) {
throw new Exception\UnexpectedTypeException(
$configurator,
'Oro\Component\Layout\ContextConfiguratorInterface'
);
}
$this->contextConfigurators[] = $configurator;
}
}
|
[
"private",
"function",
"initContextConfigurators",
"(",
")",
"{",
"$",
"this",
"->",
"contextConfigurators",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"loadContextConfigurators",
"(",
")",
"as",
"$",
"configurator",
")",
"{",
"if",
"(",
"!",
"$",
"configurator",
"instanceof",
"ContextConfiguratorInterface",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"configurator",
",",
"'Oro\\Component\\Layout\\ContextConfiguratorInterface'",
")",
";",
"}",
"$",
"this",
"->",
"contextConfigurators",
"[",
"]",
"=",
"$",
"configurator",
";",
"}",
"}"
] |
Initializes layout context configurators.
@throws Exception\UnexpectedTypeException if any registered context configurators is not
an instance of ContextConfiguratorInterface
|
[
"Initializes",
"layout",
"context",
"configurators",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/AbstractExtension.php#L363-L377
|
23,726
|
oroinc/OroLayoutComponent
|
Extension/AbstractExtension.php
|
AbstractExtension.initDataProviders
|
private function initDataProviders()
{
$this->dataProviders = [];
foreach ($this->loadDataProviders() as $name => $dataProvider) {
$this->dataProviders[$name] = $dataProvider;
}
}
|
php
|
private function initDataProviders()
{
$this->dataProviders = [];
foreach ($this->loadDataProviders() as $name => $dataProvider) {
$this->dataProviders[$name] = $dataProvider;
}
}
|
[
"private",
"function",
"initDataProviders",
"(",
")",
"{",
"$",
"this",
"->",
"dataProviders",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"loadDataProviders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"dataProvider",
")",
"{",
"$",
"this",
"->",
"dataProviders",
"[",
"$",
"name",
"]",
"=",
"$",
"dataProvider",
";",
"}",
"}"
] |
Initializes data providers.
|
[
"Initializes",
"data",
"providers",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/AbstractExtension.php#L382-L389
|
23,727
|
josh-taylor/migrations-generator
|
src/SchemaArgumentBuilder.php
|
SchemaArgumentBuilder.create
|
public function create($schema)
{
$types = array_map(function ($column) {
return $column['name'] . ':' . $column['type'];
}, $schema);
return implode(', ', $types);
}
|
php
|
public function create($schema)
{
$types = array_map(function ($column) {
return $column['name'] . ':' . $column['type'];
}, $schema);
return implode(', ', $types);
}
|
[
"public",
"function",
"create",
"(",
"$",
"schema",
")",
"{",
"$",
"types",
"=",
"array_map",
"(",
"function",
"(",
"$",
"column",
")",
"{",
"return",
"$",
"column",
"[",
"'name'",
"]",
".",
"':'",
".",
"$",
"column",
"[",
"'type'",
"]",
";",
"}",
",",
"$",
"schema",
")",
";",
"return",
"implode",
"(",
"', '",
",",
"$",
"types",
")",
";",
"}"
] |
Return the argument string to use for the migration command.
@param $schema
@return string
|
[
"Return",
"the",
"argument",
"string",
"to",
"use",
"for",
"the",
"migration",
"command",
"."
] |
bb6edc78773d11491881f12265a658bf058cb218
|
https://github.com/josh-taylor/migrations-generator/blob/bb6edc78773d11491881f12265a658bf058cb218/src/SchemaArgumentBuilder.php#L13-L20
|
23,728
|
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Parser/Scanner.php
|
HTML5_Parser_Scanner.next
|
public function next() {
$this->is->next();
if ($this->is->valid()) {
if ($this->debug)
fprintf(STDOUT, "> %s\n", $this->is->current());
return $this->is->current();
}
return false;
}
|
php
|
public function next() {
$this->is->next();
if ($this->is->valid()) {
if ($this->debug)
fprintf(STDOUT, "> %s\n", $this->is->current());
return $this->is->current();
}
return false;
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"$",
"this",
"->",
"is",
"->",
"next",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"is",
"->",
"valid",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"fprintf",
"(",
"STDOUT",
",",
"\"> %s\\n\"",
",",
"$",
"this",
"->",
"is",
"->",
"current",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"is",
"->",
"current",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get the next character.
Note: This advances the pointer.
@return string The next character.
|
[
"Get",
"the",
"next",
"character",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/Scanner.php#L138-L147
|
23,729
|
i-lateral/silverstripe-users
|
code/control/Users_Account_Controller.php
|
Users_Account_Controller.init
|
public function init()
{
parent::init();
// Check we are logged in as a user who can access front end management
if (!Permission::check("USERS_MANAGE_ACCOUNT")) {
Security::permissionFailure();
}
// Set our member object
$member = Member::currentUser();
if ($member instanceof Member) {
$this->member = $member;
}
}
|
php
|
public function init()
{
parent::init();
// Check we are logged in as a user who can access front end management
if (!Permission::check("USERS_MANAGE_ACCOUNT")) {
Security::permissionFailure();
}
// Set our member object
$member = Member::currentUser();
if ($member instanceof Member) {
$this->member = $member;
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// Check we are logged in as a user who can access front end management",
"if",
"(",
"!",
"Permission",
"::",
"check",
"(",
"\"USERS_MANAGE_ACCOUNT\"",
")",
")",
"{",
"Security",
"::",
"permissionFailure",
"(",
")",
";",
"}",
"// Set our member object",
"$",
"member",
"=",
"Member",
"::",
"currentUser",
"(",
")",
";",
"if",
"(",
"$",
"member",
"instanceof",
"Member",
")",
"{",
"$",
"this",
"->",
"member",
"=",
"$",
"member",
";",
"}",
"}"
] |
Perorm setup when this controller is initialised
@return void
|
[
"Perorm",
"setup",
"when",
"this",
"controller",
"is",
"initialised"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Account_Controller.php#L83-L98
|
23,730
|
i-lateral/silverstripe-users
|
code/control/Users_Account_Controller.php
|
Users_Account_Controller.index
|
public function index()
{
// Setup default profile summary sections
$sections = ArrayList::create();
$sections->push(
ArrayData::create(
array(
"Title" => "",
"Content" => $this->renderWith(
"UsersProfileSummary",
array("CurrentUser" => Member::currentUser())
)
)
)
);
// Allow users to add extra content sections to the
// summary
$this->extend("updateIndexSections", $sections);
$this->customise(
array(
"Title" => _t('Users.ProfileSummary', 'Profile Summary'),
"MetaTitle" => _t('Users.ProfileSummary', 'Profile Summary'),
"Content" => $this->renderWith(
"UsersAccountSections",
array("Sections" => $sections)
)
)
);
$this->extend("onBeforeIndex");
return $this->renderWith(
array(
"UserAccount",
"Page"
)
);
}
|
php
|
public function index()
{
// Setup default profile summary sections
$sections = ArrayList::create();
$sections->push(
ArrayData::create(
array(
"Title" => "",
"Content" => $this->renderWith(
"UsersProfileSummary",
array("CurrentUser" => Member::currentUser())
)
)
)
);
// Allow users to add extra content sections to the
// summary
$this->extend("updateIndexSections", $sections);
$this->customise(
array(
"Title" => _t('Users.ProfileSummary', 'Profile Summary'),
"MetaTitle" => _t('Users.ProfileSummary', 'Profile Summary'),
"Content" => $this->renderWith(
"UsersAccountSections",
array("Sections" => $sections)
)
)
);
$this->extend("onBeforeIndex");
return $this->renderWith(
array(
"UserAccount",
"Page"
)
);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"// Setup default profile summary sections",
"$",
"sections",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"$",
"sections",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"Title\"",
"=>",
"\"\"",
",",
"\"Content\"",
"=>",
"$",
"this",
"->",
"renderWith",
"(",
"\"UsersProfileSummary\"",
",",
"array",
"(",
"\"CurrentUser\"",
"=>",
"Member",
"::",
"currentUser",
"(",
")",
")",
")",
")",
")",
")",
";",
"// Allow users to add extra content sections to the",
"// summary",
"$",
"this",
"->",
"extend",
"(",
"\"updateIndexSections\"",
",",
"$",
"sections",
")",
";",
"$",
"this",
"->",
"customise",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.ProfileSummary'",
",",
"'Profile Summary'",
")",
",",
"\"MetaTitle\"",
"=>",
"_t",
"(",
"'Users.ProfileSummary'",
",",
"'Profile Summary'",
")",
",",
"\"Content\"",
"=>",
"$",
"this",
"->",
"renderWith",
"(",
"\"UsersAccountSections\"",
",",
"array",
"(",
"\"Sections\"",
"=>",
"$",
"sections",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"onBeforeIndex\"",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"\"UserAccount\"",
",",
"\"Page\"",
")",
")",
";",
"}"
] |
Display the currently outstanding orders for the current user
@return HTMLText
|
[
"Display",
"the",
"currently",
"outstanding",
"orders",
"for",
"the",
"current",
"user"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Account_Controller.php#L174-L214
|
23,731
|
i-lateral/silverstripe-users
|
code/control/Users_Account_Controller.php
|
Users_Account_Controller.ChangePasswordForm
|
public function ChangePasswordForm()
{
$form = ChangePasswordForm::create($this, "ChangePasswordForm");
$form
->Actions()
->find("name", "action_doChangePassword")
->addExtraClass("btn")
->addExtraClass("btn-green");
$cancel_btn = LiteralField::create(
"CancelLink",
'<a href="' . $this->Link() . '" class="btn btn-red">'. _t("Users.CANCEL", "Cancel") .'</a>'
);
$form
->Actions()
->insertBefore($cancel_btn, "action_doChangePassword");
$this->extend("updateChangePasswordForm", $form);
return $form;
}
|
php
|
public function ChangePasswordForm()
{
$form = ChangePasswordForm::create($this, "ChangePasswordForm");
$form
->Actions()
->find("name", "action_doChangePassword")
->addExtraClass("btn")
->addExtraClass("btn-green");
$cancel_btn = LiteralField::create(
"CancelLink",
'<a href="' . $this->Link() . '" class="btn btn-red">'. _t("Users.CANCEL", "Cancel") .'</a>'
);
$form
->Actions()
->insertBefore($cancel_btn, "action_doChangePassword");
$this->extend("updateChangePasswordForm", $form);
return $form;
}
|
[
"public",
"function",
"ChangePasswordForm",
"(",
")",
"{",
"$",
"form",
"=",
"ChangePasswordForm",
"::",
"create",
"(",
"$",
"this",
",",
"\"ChangePasswordForm\"",
")",
";",
"$",
"form",
"->",
"Actions",
"(",
")",
"->",
"find",
"(",
"\"name\"",
",",
"\"action_doChangePassword\"",
")",
"->",
"addExtraClass",
"(",
"\"btn\"",
")",
"->",
"addExtraClass",
"(",
"\"btn-green\"",
")",
";",
"$",
"cancel_btn",
"=",
"LiteralField",
"::",
"create",
"(",
"\"CancelLink\"",
",",
"'<a href=\"'",
".",
"$",
"this",
"->",
"Link",
"(",
")",
".",
"'\" class=\"btn btn-red\">'",
".",
"_t",
"(",
"\"Users.CANCEL\"",
",",
"\"Cancel\"",
")",
".",
"'</a>'",
")",
";",
"$",
"form",
"->",
"Actions",
"(",
")",
"->",
"insertBefore",
"(",
"$",
"cancel_btn",
",",
"\"action_doChangePassword\"",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateChangePasswordForm\"",
",",
"$",
"form",
")",
";",
"return",
"$",
"form",
";",
"}"
] |
Factory for generating a change password form. The form can be expanded
using an extension class and calling the updateChangePasswordForm method.
@return Form
|
[
"Factory",
"for",
"generating",
"a",
"change",
"password",
"form",
".",
"The",
"form",
"can",
"be",
"expanded",
"using",
"an",
"extension",
"class",
"and",
"calling",
"the",
"updateChangePasswordForm",
"method",
"."
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Account_Controller.php#L305-L327
|
23,732
|
i-lateral/silverstripe-users
|
code/control/Users_Account_Controller.php
|
Users_Account_Controller.getAccountMenu
|
public function getAccountMenu()
{
$menu = ArrayList::create();
$curr_action = $this->request->param("Action");
$menu->add(
ArrayData::create(
array(
"ID" => 0,
"Title" => _t('Users.PROFILESUMMARY', "Profile Summary"),
"Link" => $this->Link(),
"LinkingMode" => (!$curr_action) ? "current" : "link"
)
)
);
$menu->add(
ArrayData::create(
array(
"ID" => 10,
"Title" => _t('Users.EDITDETAILS', "Edit account details"),
"Link" => $this->Link("edit"),
"LinkingMode" => ($curr_action == "edit") ? "current" : "link"
)
)
);
$menu->add(
ArrayData::create(
array(
"ID" => 30,
"Title" => _t('Users.CHANGEPASSWORD', "Change password"),
"Link" => $this->Link("changepassword"),
"LinkingMode" => ($curr_action == "changepassword") ? "current" : "link"
)
)
);
$this->extend("updateAccountMenu", $menu);
return $menu->sort("ID", "ASC");
}
|
php
|
public function getAccountMenu()
{
$menu = ArrayList::create();
$curr_action = $this->request->param("Action");
$menu->add(
ArrayData::create(
array(
"ID" => 0,
"Title" => _t('Users.PROFILESUMMARY', "Profile Summary"),
"Link" => $this->Link(),
"LinkingMode" => (!$curr_action) ? "current" : "link"
)
)
);
$menu->add(
ArrayData::create(
array(
"ID" => 10,
"Title" => _t('Users.EDITDETAILS', "Edit account details"),
"Link" => $this->Link("edit"),
"LinkingMode" => ($curr_action == "edit") ? "current" : "link"
)
)
);
$menu->add(
ArrayData::create(
array(
"ID" => 30,
"Title" => _t('Users.CHANGEPASSWORD', "Change password"),
"Link" => $this->Link("changepassword"),
"LinkingMode" => ($curr_action == "changepassword") ? "current" : "link"
)
)
);
$this->extend("updateAccountMenu", $menu);
return $menu->sort("ID", "ASC");
}
|
[
"public",
"function",
"getAccountMenu",
"(",
")",
"{",
"$",
"menu",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"$",
"curr_action",
"=",
"$",
"this",
"->",
"request",
"->",
"param",
"(",
"\"Action\"",
")",
";",
"$",
"menu",
"->",
"add",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"ID\"",
"=>",
"0",
",",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.PROFILESUMMARY'",
",",
"\"Profile Summary\"",
")",
",",
"\"Link\"",
"=>",
"$",
"this",
"->",
"Link",
"(",
")",
",",
"\"LinkingMode\"",
"=>",
"(",
"!",
"$",
"curr_action",
")",
"?",
"\"current\"",
":",
"\"link\"",
")",
")",
")",
";",
"$",
"menu",
"->",
"add",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"ID\"",
"=>",
"10",
",",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.EDITDETAILS'",
",",
"\"Edit account details\"",
")",
",",
"\"Link\"",
"=>",
"$",
"this",
"->",
"Link",
"(",
"\"edit\"",
")",
",",
"\"LinkingMode\"",
"=>",
"(",
"$",
"curr_action",
"==",
"\"edit\"",
")",
"?",
"\"current\"",
":",
"\"link\"",
")",
")",
")",
";",
"$",
"menu",
"->",
"add",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"ID\"",
"=>",
"30",
",",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.CHANGEPASSWORD'",
",",
"\"Change password\"",
")",
",",
"\"Link\"",
"=>",
"$",
"this",
"->",
"Link",
"(",
"\"changepassword\"",
")",
",",
"\"LinkingMode\"",
"=>",
"(",
"$",
"curr_action",
"==",
"\"changepassword\"",
")",
"?",
"\"current\"",
":",
"\"link\"",
")",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateAccountMenu\"",
",",
"$",
"menu",
")",
";",
"return",
"$",
"menu",
"->",
"sort",
"(",
"\"ID\"",
",",
"\"ASC\"",
")",
";",
"}"
] |
Return a list of nav items for managing a users profile. You can add new
items to this menu using the "updateAccountMenu" extension
@return ArrayList
|
[
"Return",
"a",
"list",
"of",
"nav",
"items",
"for",
"managing",
"a",
"users",
"profile",
".",
"You",
"can",
"add",
"new",
"items",
"to",
"this",
"menu",
"using",
"the",
"updateAccountMenu",
"extension"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Account_Controller.php#L335-L377
|
23,733
|
arndtteunissen/column-layout
|
Classes/Hook/ColumnConfigurationGridsystemFlexFormHook.php
|
ColumnConfigurationGridsystemFlexFormHook.getDataStructureIdentifierPreProcess
|
public function getDataStructureIdentifierPreProcess(array $fieldTca, string $tableName, string $fieldName, array $row): array
{
if ($tableName != 'tt_content' || $fieldName != 'tx_column_layout_column_config') {
return [];
}
return [
'type' => 'tca',
'tableName' => $tableName,
'fieldName' => $fieldName,
'dataStructureKey' => ColumnLayoutUtility::getColumnLayoutSettings($row['_tx_column_layout_orig_pid'] ?? $row['pid'])['flexFormKey']
];
}
|
php
|
public function getDataStructureIdentifierPreProcess(array $fieldTca, string $tableName, string $fieldName, array $row): array
{
if ($tableName != 'tt_content' || $fieldName != 'tx_column_layout_column_config') {
return [];
}
return [
'type' => 'tca',
'tableName' => $tableName,
'fieldName' => $fieldName,
'dataStructureKey' => ColumnLayoutUtility::getColumnLayoutSettings($row['_tx_column_layout_orig_pid'] ?? $row['pid'])['flexFormKey']
];
}
|
[
"public",
"function",
"getDataStructureIdentifierPreProcess",
"(",
"array",
"$",
"fieldTca",
",",
"string",
"$",
"tableName",
",",
"string",
"$",
"fieldName",
",",
"array",
"$",
"row",
")",
":",
"array",
"{",
"if",
"(",
"$",
"tableName",
"!=",
"'tt_content'",
"||",
"$",
"fieldName",
"!=",
"'tx_column_layout_column_config'",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"[",
"'type'",
"=>",
"'tca'",
",",
"'tableName'",
"=>",
"$",
"tableName",
",",
"'fieldName'",
"=>",
"$",
"fieldName",
",",
"'dataStructureKey'",
"=>",
"ColumnLayoutUtility",
"::",
"getColumnLayoutSettings",
"(",
"$",
"row",
"[",
"'_tx_column_layout_orig_pid'",
"]",
"??",
"$",
"row",
"[",
"'pid'",
"]",
")",
"[",
"'flexFormKey'",
"]",
"]",
";",
"}"
] |
Generates a DataStructureIdentifier for the flexform in column configuration field
@param array $fieldTca
@param string $tableName
@param string $fieldName
@param array $row
@return array
@throws \TYPO3\CMS\Core\Exception
|
[
"Generates",
"a",
"DataStructureIdentifier",
"for",
"the",
"flexform",
"in",
"column",
"configuration",
"field"
] |
ad737068eef3b084d4d0e3a48e6a3d8277af9560
|
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Hook/ColumnConfigurationGridsystemFlexFormHook.php#L32-L44
|
23,734
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php
|
Xsl.transform
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$structure = $this->loadAst($this->getAstPath($transformation));
$proc = $this->getXslProcessor($transformation);
$proc->registerPHPFunctions();
$this->registerDefaultVariables($transformation, $proc, $structure);
$this->setProcessorParameters($transformation, $proc);
$artifact = $this->getArtifactPath($transformation);
$this->checkForSpacesInPath($artifact);
// if a query is given, then apply a transformation to the artifact
// location by replacing ($<var>} with the sluggified node-value of the
// search result
if ($transformation->getQuery() !== '') {
$xpath = new \DOMXPath($structure);
/** @var \DOMNodeList $qry */
$qry = $xpath->query($transformation->getQuery());
$count = $qry->length;
foreach ($qry as $key => $element) {
Dispatcher::getInstance()->dispatch(
'transformer.writer.xsl.pre',
PreXslWriterEvent::createInstance($this)->setElement($element)->setProgress(array($key+1, $count))
);
$proc->setParameter('', $element->nodeName, $element->nodeValue);
$file_name = $transformation->getTransformer()->generateFilename(
$element->nodeValue
);
if (! $artifact) {
$url = $this->generateUrlForXmlElement($project, $element);
if ($url === false || $url[0] !== DIRECTORY_SEPARATOR) {
continue;
}
$filename = $transformation->getTransformer()->getTarget()
. str_replace('/', DIRECTORY_SEPARATOR, $url);
} else {
$filename = str_replace('{$' . $element->nodeName . '}', $file_name, $artifact);
}
$relativeFileName = substr($filename, strlen($transformation->getTransformer()->getTarget()) + 1);
$proc->setParameter('', 'root', str_repeat('../', substr_count($relativeFileName, '/')));
$this->writeToFile($filename, $proc, $structure);
}
} else {
if (substr($transformation->getArtifact(), 0, 1) == '$') {
// not a file, it must become a variable!
$variable_name = substr($transformation->getArtifact(), 1);
$this->xsl_variables[$variable_name] = $proc->transformToXml($structure);
} else {
$relativeFileName = substr($artifact, strlen($transformation->getTransformer()->getTarget()) + 1);
$proc->setParameter('', 'root', str_repeat('../', substr_count($relativeFileName, '/')));
$this->writeToFile($artifact, $proc, $structure);
}
}
}
|
php
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$structure = $this->loadAst($this->getAstPath($transformation));
$proc = $this->getXslProcessor($transformation);
$proc->registerPHPFunctions();
$this->registerDefaultVariables($transformation, $proc, $structure);
$this->setProcessorParameters($transformation, $proc);
$artifact = $this->getArtifactPath($transformation);
$this->checkForSpacesInPath($artifact);
// if a query is given, then apply a transformation to the artifact
// location by replacing ($<var>} with the sluggified node-value of the
// search result
if ($transformation->getQuery() !== '') {
$xpath = new \DOMXPath($structure);
/** @var \DOMNodeList $qry */
$qry = $xpath->query($transformation->getQuery());
$count = $qry->length;
foreach ($qry as $key => $element) {
Dispatcher::getInstance()->dispatch(
'transformer.writer.xsl.pre',
PreXslWriterEvent::createInstance($this)->setElement($element)->setProgress(array($key+1, $count))
);
$proc->setParameter('', $element->nodeName, $element->nodeValue);
$file_name = $transformation->getTransformer()->generateFilename(
$element->nodeValue
);
if (! $artifact) {
$url = $this->generateUrlForXmlElement($project, $element);
if ($url === false || $url[0] !== DIRECTORY_SEPARATOR) {
continue;
}
$filename = $transformation->getTransformer()->getTarget()
. str_replace('/', DIRECTORY_SEPARATOR, $url);
} else {
$filename = str_replace('{$' . $element->nodeName . '}', $file_name, $artifact);
}
$relativeFileName = substr($filename, strlen($transformation->getTransformer()->getTarget()) + 1);
$proc->setParameter('', 'root', str_repeat('../', substr_count($relativeFileName, '/')));
$this->writeToFile($filename, $proc, $structure);
}
} else {
if (substr($transformation->getArtifact(), 0, 1) == '$') {
// not a file, it must become a variable!
$variable_name = substr($transformation->getArtifact(), 1);
$this->xsl_variables[$variable_name] = $proc->transformToXml($structure);
} else {
$relativeFileName = substr($artifact, strlen($transformation->getTransformer()->getTarget()) + 1);
$proc->setParameter('', 'root', str_repeat('../', substr_count($relativeFileName, '/')));
$this->writeToFile($artifact, $proc, $structure);
}
}
}
|
[
"public",
"function",
"transform",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"structure",
"=",
"$",
"this",
"->",
"loadAst",
"(",
"$",
"this",
"->",
"getAstPath",
"(",
"$",
"transformation",
")",
")",
";",
"$",
"proc",
"=",
"$",
"this",
"->",
"getXslProcessor",
"(",
"$",
"transformation",
")",
";",
"$",
"proc",
"->",
"registerPHPFunctions",
"(",
")",
";",
"$",
"this",
"->",
"registerDefaultVariables",
"(",
"$",
"transformation",
",",
"$",
"proc",
",",
"$",
"structure",
")",
";",
"$",
"this",
"->",
"setProcessorParameters",
"(",
"$",
"transformation",
",",
"$",
"proc",
")",
";",
"$",
"artifact",
"=",
"$",
"this",
"->",
"getArtifactPath",
"(",
"$",
"transformation",
")",
";",
"$",
"this",
"->",
"checkForSpacesInPath",
"(",
"$",
"artifact",
")",
";",
"// if a query is given, then apply a transformation to the artifact",
"// location by replacing ($<var>} with the sluggified node-value of the",
"// search result",
"if",
"(",
"$",
"transformation",
"->",
"getQuery",
"(",
")",
"!==",
"''",
")",
"{",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"structure",
")",
";",
"/** @var \\DOMNodeList $qry */",
"$",
"qry",
"=",
"$",
"xpath",
"->",
"query",
"(",
"$",
"transformation",
"->",
"getQuery",
"(",
")",
")",
";",
"$",
"count",
"=",
"$",
"qry",
"->",
"length",
";",
"foreach",
"(",
"$",
"qry",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"Dispatcher",
"::",
"getInstance",
"(",
")",
"->",
"dispatch",
"(",
"'transformer.writer.xsl.pre'",
",",
"PreXslWriterEvent",
"::",
"createInstance",
"(",
"$",
"this",
")",
"->",
"setElement",
"(",
"$",
"element",
")",
"->",
"setProgress",
"(",
"array",
"(",
"$",
"key",
"+",
"1",
",",
"$",
"count",
")",
")",
")",
";",
"$",
"proc",
"->",
"setParameter",
"(",
"''",
",",
"$",
"element",
"->",
"nodeName",
",",
"$",
"element",
"->",
"nodeValue",
")",
";",
"$",
"file_name",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"generateFilename",
"(",
"$",
"element",
"->",
"nodeValue",
")",
";",
"if",
"(",
"!",
"$",
"artifact",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"generateUrlForXmlElement",
"(",
"$",
"project",
",",
"$",
"element",
")",
";",
"if",
"(",
"$",
"url",
"===",
"false",
"||",
"$",
"url",
"[",
"0",
"]",
"!==",
"DIRECTORY_SEPARATOR",
")",
"{",
"continue",
";",
"}",
"$",
"filename",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"filename",
"=",
"str_replace",
"(",
"'{$'",
".",
"$",
"element",
"->",
"nodeName",
".",
"'}'",
",",
"$",
"file_name",
",",
"$",
"artifact",
")",
";",
"}",
"$",
"relativeFileName",
"=",
"substr",
"(",
"$",
"filename",
",",
"strlen",
"(",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
")",
"+",
"1",
")",
";",
"$",
"proc",
"->",
"setParameter",
"(",
"''",
",",
"'root'",
",",
"str_repeat",
"(",
"'../'",
",",
"substr_count",
"(",
"$",
"relativeFileName",
",",
"'/'",
")",
")",
")",
";",
"$",
"this",
"->",
"writeToFile",
"(",
"$",
"filename",
",",
"$",
"proc",
",",
"$",
"structure",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
",",
"0",
",",
"1",
")",
"==",
"'$'",
")",
"{",
"// not a file, it must become a variable!",
"$",
"variable_name",
"=",
"substr",
"(",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
",",
"1",
")",
";",
"$",
"this",
"->",
"xsl_variables",
"[",
"$",
"variable_name",
"]",
"=",
"$",
"proc",
"->",
"transformToXml",
"(",
"$",
"structure",
")",
";",
"}",
"else",
"{",
"$",
"relativeFileName",
"=",
"substr",
"(",
"$",
"artifact",
",",
"strlen",
"(",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
")",
"+",
"1",
")",
";",
"$",
"proc",
"->",
"setParameter",
"(",
"''",
",",
"'root'",
",",
"str_repeat",
"(",
"'../'",
",",
"substr_count",
"(",
"$",
"relativeFileName",
",",
"'/'",
")",
")",
")",
";",
"$",
"this",
"->",
"writeToFile",
"(",
"$",
"artifact",
",",
"$",
"proc",
",",
"$",
"structure",
")",
";",
"}",
"}",
"}"
] |
This method combines the structure.xml and the given target template
and creates a static html page at the artifact location.
@param ProjectDescriptor $project Document containing the structure.
@param Transformation $transformation Transformation to execute.
@throws \RuntimeException if the structure.xml file could not be found.
@throws Exception if the structure.xml file's documentRoot could not be read because of encoding issues
or because it was absent.
@return void
|
[
"This",
"method",
"combines",
"the",
"structure",
".",
"xml",
"and",
"the",
"given",
"target",
"template",
"and",
"creates",
"a",
"static",
"html",
"page",
"at",
"the",
"artifact",
"location",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L96-L158
|
23,735
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php
|
Xsl.getXsltUriFromFilename
|
protected function getXsltUriFromFilename($filename)
{
// Windows requires an additional / after the scheme. If not provided then errno 22 (I/O Error: Invalid
// Argument) will be raised. Thanks to @FnTmLV for finding the cause. See issue #284 for more information.
// An exception to the above is when running from a Phar file; in this case the stream is handled as if on
// linux; see issue #713 for more information on this exception.
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && ! \Phar::running()) {
$filename = '/' . $filename;
}
return 'file://' . $filename;
}
|
php
|
protected function getXsltUriFromFilename($filename)
{
// Windows requires an additional / after the scheme. If not provided then errno 22 (I/O Error: Invalid
// Argument) will be raised. Thanks to @FnTmLV for finding the cause. See issue #284 for more information.
// An exception to the above is when running from a Phar file; in this case the stream is handled as if on
// linux; see issue #713 for more information on this exception.
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && ! \Phar::running()) {
$filename = '/' . $filename;
}
return 'file://' . $filename;
}
|
[
"protected",
"function",
"getXsltUriFromFilename",
"(",
"$",
"filename",
")",
"{",
"// Windows requires an additional / after the scheme. If not provided then errno 22 (I/O Error: Invalid",
"// Argument) will be raised. Thanks to @FnTmLV for finding the cause. See issue #284 for more information.",
"// An exception to the above is when running from a Phar file; in this case the stream is handled as if on",
"// linux; see issue #713 for more information on this exception.",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"==",
"'WIN'",
"&&",
"!",
"\\",
"Phar",
"::",
"running",
"(",
")",
")",
"{",
"$",
"filename",
"=",
"'/'",
".",
"$",
"filename",
";",
"}",
"return",
"'file://'",
".",
"$",
"filename",
";",
"}"
] |
Takes the filename and converts it into a correct URI for XSLTProcessor.
@param string $filename
@return string
|
[
"Takes",
"the",
"filename",
"and",
"converts",
"it",
"into",
"a",
"correct",
"URI",
"for",
"XSLTProcessor",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L167-L178
|
23,736
|
david-mk/mail-map
|
src/MailMap/ConnectionFactory.php
|
ConnectionFactory.create
|
public function create($inbox = 'INBOX')
{
$stream = imap_open($this->connectionString($inbox), $this->user, $this->password);
return new Connection($stream);
}
|
php
|
public function create($inbox = 'INBOX')
{
$stream = imap_open($this->connectionString($inbox), $this->user, $this->password);
return new Connection($stream);
}
|
[
"public",
"function",
"create",
"(",
"$",
"inbox",
"=",
"'INBOX'",
")",
"{",
"$",
"stream",
"=",
"imap_open",
"(",
"$",
"this",
"->",
"connectionString",
"(",
"$",
"inbox",
")",
",",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"password",
")",
";",
"return",
"new",
"Connection",
"(",
"$",
"stream",
")",
";",
"}"
] |
Create new IMAP connection
@param string $inbox
@return \MailMap\Contracts\ConnectionContract
|
[
"Create",
"new",
"IMAP",
"connection"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/ConnectionFactory.php#L88-L93
|
23,737
|
david-mk/mail-map
|
src/MailMap/ConnectionFactory.php
|
ConnectionFactory.mailboxes
|
public function mailboxes($mailboxSearch = '*', $withConnection = false)
{
$connectionString = $this->connectionString();
$stream = imap_open($connectionString, $this->user, $this->password);
$mailboxes = imap_list($stream, $connectionString, $mailboxSearch);
if ($withConnection) {
return $mailboxes;
}
return array_map(function ($mailbox) use ($connectionString) {
return str_replace($connectionString, '', $mailbox);
}, $mailboxes);
}
|
php
|
public function mailboxes($mailboxSearch = '*', $withConnection = false)
{
$connectionString = $this->connectionString();
$stream = imap_open($connectionString, $this->user, $this->password);
$mailboxes = imap_list($stream, $connectionString, $mailboxSearch);
if ($withConnection) {
return $mailboxes;
}
return array_map(function ($mailbox) use ($connectionString) {
return str_replace($connectionString, '', $mailbox);
}, $mailboxes);
}
|
[
"public",
"function",
"mailboxes",
"(",
"$",
"mailboxSearch",
"=",
"'*'",
",",
"$",
"withConnection",
"=",
"false",
")",
"{",
"$",
"connectionString",
"=",
"$",
"this",
"->",
"connectionString",
"(",
")",
";",
"$",
"stream",
"=",
"imap_open",
"(",
"$",
"connectionString",
",",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"password",
")",
";",
"$",
"mailboxes",
"=",
"imap_list",
"(",
"$",
"stream",
",",
"$",
"connectionString",
",",
"$",
"mailboxSearch",
")",
";",
"if",
"(",
"$",
"withConnection",
")",
"{",
"return",
"$",
"mailboxes",
";",
"}",
"return",
"array_map",
"(",
"function",
"(",
"$",
"mailbox",
")",
"use",
"(",
"$",
"connectionString",
")",
"{",
"return",
"str_replace",
"(",
"$",
"connectionString",
",",
"''",
",",
"$",
"mailbox",
")",
";",
"}",
",",
"$",
"mailboxes",
")",
";",
"}"
] |
Get a list of mailboxes on the mail server.
@param string $mailboxSearch Pattern from http://php.net/manual/en/function.imap-list.php
@param bool $withConnection Will strip off connection string from mailboxes by default
@return array List of mailboxes
|
[
"Get",
"a",
"list",
"of",
"mailboxes",
"on",
"the",
"mail",
"server",
"."
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/ConnectionFactory.php#L102-L115
|
23,738
|
david-mk/mail-map
|
src/MailMap/ConnectionFactory.php
|
ConnectionFactory.connectionString
|
protected function connectionString($inbox = '')
{
return sprintf(static::$connectionFormat, $this->host, $this->port, $this->service, $this->enc, $inbox);
}
|
php
|
protected function connectionString($inbox = '')
{
return sprintf(static::$connectionFormat, $this->host, $this->port, $this->service, $this->enc, $inbox);
}
|
[
"protected",
"function",
"connectionString",
"(",
"$",
"inbox",
"=",
"''",
")",
"{",
"return",
"sprintf",
"(",
"static",
"::",
"$",
"connectionFormat",
",",
"$",
"this",
"->",
"host",
",",
"$",
"this",
"->",
"port",
",",
"$",
"this",
"->",
"service",
",",
"$",
"this",
"->",
"enc",
",",
"$",
"inbox",
")",
";",
"}"
] |
Make the IMAP connection string from configuration
@param string $inbox
@return string The connection string
|
[
"Make",
"the",
"IMAP",
"connection",
"string",
"from",
"configuration"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/ConnectionFactory.php#L123-L126
|
23,739
|
mridang/magazine
|
lib/magento/Archive/Helper/File.php
|
Mage_Archive_Helper_File.read
|
public function read($length = 4096)
{
$data = false;
$this->_checkFileOpened();
if ($length > 0) {
$data = $this->_read($length);
}
return $data;
}
|
php
|
public function read($length = 4096)
{
$data = false;
$this->_checkFileOpened();
if ($length > 0) {
$data = $this->_read($length);
}
return $data;
}
|
[
"public",
"function",
"read",
"(",
"$",
"length",
"=",
"4096",
")",
"{",
"$",
"data",
"=",
"false",
";",
"$",
"this",
"->",
"_checkFileOpened",
"(",
")",
";",
"if",
"(",
"$",
"length",
">",
"0",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_read",
"(",
"$",
"length",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Read data from file
@param int $length
@return string|boolean
|
[
"Read",
"data",
"from",
"file"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File.php#L146-L155
|
23,740
|
mridang/magazine
|
lib/magento/Archive/Helper/File.php
|
Mage_Archive_Helper_File._open
|
protected function _open($mode)
{
$this->_fileHandler = @fopen($this->_filePath, $mode);
if (false === $this->_fileHandler) {
throw new Mage_Exception('Failed to open file ' . $this->_filePath);
}
}
|
php
|
protected function _open($mode)
{
$this->_fileHandler = @fopen($this->_filePath, $mode);
if (false === $this->_fileHandler) {
throw new Mage_Exception('Failed to open file ' . $this->_filePath);
}
}
|
[
"protected",
"function",
"_open",
"(",
"$",
"mode",
")",
"{",
"$",
"this",
"->",
"_fileHandler",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"_filePath",
",",
"$",
"mode",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"_fileHandler",
")",
"{",
"throw",
"new",
"Mage_Exception",
"(",
"'Failed to open file '",
".",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"}"
] |
Implementation of file opening
@param string $mode
@throws Mage_Exception
|
[
"Implementation",
"of",
"file",
"opening"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File.php#L185-L192
|
23,741
|
mridang/magazine
|
lib/magento/Archive/Helper/File.php
|
Mage_Archive_Helper_File._write
|
protected function _write($data)
{
$result = @fwrite($this->_fileHandler, $data);
if (false === $result) {
throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
}
}
|
php
|
protected function _write($data)
{
$result = @fwrite($this->_fileHandler, $data);
if (false === $result) {
throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
}
}
|
[
"protected",
"function",
"_write",
"(",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"@",
"fwrite",
"(",
"$",
"this",
"->",
"_fileHandler",
",",
"$",
"data",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"throw",
"new",
"Mage_Exception",
"(",
"'Failed to write data to '",
".",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"}"
] |
Implementation of writing data to file
@param string $data
@throws Mage_Exception
|
[
"Implementation",
"of",
"writing",
"data",
"to",
"file"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File.php#L200-L207
|
23,742
|
mridang/magazine
|
lib/magento/Archive/Helper/File.php
|
Mage_Archive_Helper_File._read
|
protected function _read($length)
{
$result = fread($this->_fileHandler, $length);
if (false === $result) {
throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
}
return $result;
}
|
php
|
protected function _read($length)
{
$result = fread($this->_fileHandler, $length);
if (false === $result) {
throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
}
return $result;
}
|
[
"protected",
"function",
"_read",
"(",
"$",
"length",
")",
"{",
"$",
"result",
"=",
"fread",
"(",
"$",
"this",
"->",
"_fileHandler",
",",
"$",
"length",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"throw",
"new",
"Mage_Exception",
"(",
"'Failed to read data from '",
".",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Implementation of file reading
@param int $length
@throws Mage_Exception
|
[
"Implementation",
"of",
"file",
"reading"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File.php#L215-L224
|
23,743
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multipart.php
|
ezcMailMultipart.generateBody
|
public function generateBody()
{
$data = $this->noMimeMessage . ezcMailTools::lineBreak();
foreach ( $this->parts as $part )
{
$data .= ezcMailTools::lineBreak() . '--' . $this->boundary . ezcMailTools::lineBreak();
$data .= $part->generate();
}
$data .= ezcMailTools::lineBreak() . '--' . $this->boundary . '--';
return $data;
}
|
php
|
public function generateBody()
{
$data = $this->noMimeMessage . ezcMailTools::lineBreak();
foreach ( $this->parts as $part )
{
$data .= ezcMailTools::lineBreak() . '--' . $this->boundary . ezcMailTools::lineBreak();
$data .= $part->generate();
}
$data .= ezcMailTools::lineBreak() . '--' . $this->boundary . '--';
return $data;
}
|
[
"public",
"function",
"generateBody",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"noMimeMessage",
".",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"data",
".=",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
".",
"'--'",
".",
"$",
"this",
"->",
"boundary",
".",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"$",
"data",
".=",
"$",
"part",
"->",
"generate",
"(",
")",
";",
"}",
"$",
"data",
".=",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
".",
"'--'",
".",
"$",
"this",
"->",
"boundary",
".",
"'--'",
";",
"return",
"$",
"data",
";",
"}"
] |
Returns the generated body for all multipart types.
@return string
|
[
"Returns",
"the",
"generated",
"body",
"for",
"all",
"multipart",
"types",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multipart.php#L167-L177
|
23,744
|
Laralum/Events
|
src/Models/Event.php
|
Event.hasResponsible
|
public function hasResponsible($user)
{
return $this->users()->where('user_id', $user->id)->first()->pivot->responsible;
}
|
php
|
public function hasResponsible($user)
{
return $this->users()->where('user_id', $user->id)->first()->pivot->responsible;
}
|
[
"public",
"function",
"hasResponsible",
"(",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"users",
"(",
")",
"->",
"where",
"(",
"'user_id'",
",",
"$",
"user",
"->",
"id",
")",
"->",
"first",
"(",
")",
"->",
"pivot",
"->",
"responsible",
";",
"}"
] |
Returns true if the event have the specified user as responsible.
@param mixed $user
|
[
"Returns",
"true",
"if",
"the",
"event",
"have",
"the",
"specified",
"user",
"as",
"responsible",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Models/Event.php#L58-L61
|
23,745
|
Laralum/Events
|
src/Models/Event.php
|
Event.startDatetime
|
public function startDatetime()
{
$date = explode('-', $this->start_date);
$time = explode(':', $this->start_time);
$start_datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $start_datetime;
}
|
php
|
public function startDatetime()
{
$date = explode('-', $this->start_date);
$time = explode(':', $this->start_time);
$start_datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $start_datetime;
}
|
[
"public",
"function",
"startDatetime",
"(",
")",
"{",
"$",
"date",
"=",
"explode",
"(",
"'-'",
",",
"$",
"this",
"->",
"start_date",
")",
";",
"$",
"time",
"=",
"explode",
"(",
"':'",
",",
"$",
"this",
"->",
"start_time",
")",
";",
"$",
"start_datetime",
"=",
"Carbon",
"::",
"create",
"(",
"$",
"date",
"[",
"0",
"]",
",",
"$",
"date",
"[",
"1",
"]",
",",
"$",
"date",
"[",
"2",
"]",
",",
"$",
"time",
"[",
"0",
"]",
",",
"$",
"time",
"[",
"1",
"]",
")",
";",
"return",
"$",
"start_datetime",
";",
"}"
] |
Get Carbon start datetime.
@return \Carbon\Carbon
|
[
"Get",
"Carbon",
"start",
"datetime",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Models/Event.php#L150-L157
|
23,746
|
Laralum/Events
|
src/Models/Event.php
|
Event.endDatetime
|
public function endDatetime()
{
$date = explode('-', $this->end_date);
$time = explode(':', $this->end_time);
$end_datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $end_datetime;
}
|
php
|
public function endDatetime()
{
$date = explode('-', $this->end_date);
$time = explode(':', $this->end_time);
$end_datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $end_datetime;
}
|
[
"public",
"function",
"endDatetime",
"(",
")",
"{",
"$",
"date",
"=",
"explode",
"(",
"'-'",
",",
"$",
"this",
"->",
"end_date",
")",
";",
"$",
"time",
"=",
"explode",
"(",
"':'",
",",
"$",
"this",
"->",
"end_time",
")",
";",
"$",
"end_datetime",
"=",
"Carbon",
"::",
"create",
"(",
"$",
"date",
"[",
"0",
"]",
",",
"$",
"date",
"[",
"1",
"]",
",",
"$",
"date",
"[",
"2",
"]",
",",
"$",
"time",
"[",
"0",
"]",
",",
"$",
"time",
"[",
"1",
"]",
")",
";",
"return",
"$",
"end_datetime",
";",
"}"
] |
Get Carbon end datetime.
@return \Carbon\Carbon
|
[
"Get",
"Carbon",
"end",
"datetime",
"."
] |
9dc36468f4253e7d040863a115ea94cded0e6aa5
|
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Models/Event.php#L164-L171
|
23,747
|
lukasz-adamski/teamspeak3-framework
|
src/TeamSpeak3/Adapter/ServerQuery.php
|
ServerQuery.syn
|
protected function syn()
{
$this->initTransport($this->options);
$this->transport->setAdapter($this);
Profiler::init(spl_object_hash($this));
$rdy = $this->getTransport()->readLine();
if(!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT)))
{
throw new AdapterException("invalid reply from the server (" . $rdy . ")");
}
Signal::getInstance()->emit("serverqueryConnected", $this);
}
|
php
|
protected function syn()
{
$this->initTransport($this->options);
$this->transport->setAdapter($this);
Profiler::init(spl_object_hash($this));
$rdy = $this->getTransport()->readLine();
if(!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT)))
{
throw new AdapterException("invalid reply from the server (" . $rdy . ")");
}
Signal::getInstance()->emit("serverqueryConnected", $this);
}
|
[
"protected",
"function",
"syn",
"(",
")",
"{",
"$",
"this",
"->",
"initTransport",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"transport",
"->",
"setAdapter",
"(",
"$",
"this",
")",
";",
"Profiler",
"::",
"init",
"(",
"spl_object_hash",
"(",
"$",
"this",
")",
")",
";",
"$",
"rdy",
"=",
"$",
"this",
"->",
"getTransport",
"(",
")",
"->",
"readLine",
"(",
")",
";",
"if",
"(",
"!",
"$",
"rdy",
"->",
"startsWith",
"(",
"TeamSpeak3",
"::",
"TS3_PROTO_IDENT",
")",
"&&",
"!",
"$",
"rdy",
"->",
"startsWith",
"(",
"TeamSpeak3",
"::",
"TEA_PROTO_IDENT",
")",
"&&",
"!",
"(",
"defined",
"(",
"\"CUSTOM_PROTO_IDENT\"",
")",
"&&",
"$",
"rdy",
"->",
"startsWith",
"(",
"CUSTOM_PROTO_IDENT",
")",
")",
")",
"{",
"throw",
"new",
"AdapterException",
"(",
"\"invalid reply from the server (\"",
".",
"$",
"rdy",
".",
"\")\"",
")",
";",
"}",
"Signal",
"::",
"getInstance",
"(",
")",
"->",
"emit",
"(",
"\"serverqueryConnected\"",
",",
"$",
"this",
")",
";",
"}"
] |
Connects the Transport object and performs initial actions on the remote
server.
@throws AdapterException
@return void
|
[
"Connects",
"the",
"Transport",
"object",
"and",
"performs",
"initial",
"actions",
"on",
"the",
"remote",
"server",
"."
] |
39a56eca608da6b56b6aa386a7b5b31dc576c41a
|
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Adapter/ServerQuery.php#L81-L96
|
23,748
|
ronaldborla/chikka
|
src/Borla/Chikka/Models/Cost.php
|
Cost.adjust
|
public function adjust(Carrier $carrier = null) {
// If there's carrier
if ($carrier !== null) {
// Set carrier
$this->carrier = $carrier;
}
// If there's no carrier
if ( ! isset($this->carrier)) {
// Throw error
throw new MissingCarrier('Carrier is required to adjust cost');
}
// Get costs
$costs = $this->getPossibleCostsPerCarrier()[$this->carrier->network];
// Loop through costs per carrier
foreach ($costs as $i=> $cost) {
// If cost equals
if ($this->amount == $cost) {
// Quit
break;
}
// If amount is less than cost
if ($this->amount < $cost || ! isset($costs[$i + 1])) {
// Use previous
$this->amount = $cost;
// Break
break;
}
}
// Return self
return $this;
}
|
php
|
public function adjust(Carrier $carrier = null) {
// If there's carrier
if ($carrier !== null) {
// Set carrier
$this->carrier = $carrier;
}
// If there's no carrier
if ( ! isset($this->carrier)) {
// Throw error
throw new MissingCarrier('Carrier is required to adjust cost');
}
// Get costs
$costs = $this->getPossibleCostsPerCarrier()[$this->carrier->network];
// Loop through costs per carrier
foreach ($costs as $i=> $cost) {
// If cost equals
if ($this->amount == $cost) {
// Quit
break;
}
// If amount is less than cost
if ($this->amount < $cost || ! isset($costs[$i + 1])) {
// Use previous
$this->amount = $cost;
// Break
break;
}
}
// Return self
return $this;
}
|
[
"public",
"function",
"adjust",
"(",
"Carrier",
"$",
"carrier",
"=",
"null",
")",
"{",
"// If there's carrier",
"if",
"(",
"$",
"carrier",
"!==",
"null",
")",
"{",
"// Set carrier",
"$",
"this",
"->",
"carrier",
"=",
"$",
"carrier",
";",
"}",
"// If there's no carrier",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"carrier",
")",
")",
"{",
"// Throw error",
"throw",
"new",
"MissingCarrier",
"(",
"'Carrier is required to adjust cost'",
")",
";",
"}",
"// Get costs",
"$",
"costs",
"=",
"$",
"this",
"->",
"getPossibleCostsPerCarrier",
"(",
")",
"[",
"$",
"this",
"->",
"carrier",
"->",
"network",
"]",
";",
"// Loop through costs per carrier",
"foreach",
"(",
"$",
"costs",
"as",
"$",
"i",
"=>",
"$",
"cost",
")",
"{",
"// If cost equals",
"if",
"(",
"$",
"this",
"->",
"amount",
"==",
"$",
"cost",
")",
"{",
"// Quit",
"break",
";",
"}",
"// If amount is less than cost",
"if",
"(",
"$",
"this",
"->",
"amount",
"<",
"$",
"cost",
"||",
"!",
"isset",
"(",
"$",
"costs",
"[",
"$",
"i",
"+",
"1",
"]",
")",
")",
"{",
"// Use previous",
"$",
"this",
"->",
"amount",
"=",
"$",
"cost",
";",
"// Break",
"break",
";",
"}",
"}",
"// Return self",
"return",
"$",
"this",
";",
"}"
] |
Adjust cost amount for a given carrier
|
[
"Adjust",
"cost",
"amount",
"for",
"a",
"given",
"carrier"
] |
446987706f81d5a0efbc8bd6b7d3b259d0527719
|
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Cost.php#L79-L109
|
23,749
|
ronaldborla/chikka
|
src/Borla/Chikka/Models/Cost.php
|
Cost.fix
|
public function fix($mobileOrCarrier) {
// If instance of carrier
if ($mobileOrCarrier instanceof Carrier) {
// Use
$this->carrier = $mobileOrCarrier;
}
// If instance of mobile
elseif ($mobileOrCarrier instanceof Mobile) {
// Get carrier
$this->carrier = $mobileOrCarrier->carrier;
}
// Else
else {
// Get carrier
$this->carrier = Loader::mobile($mobileOrCarrier)->carrier;
}
// Adjust and return
return $this->adjust();
}
|
php
|
public function fix($mobileOrCarrier) {
// If instance of carrier
if ($mobileOrCarrier instanceof Carrier) {
// Use
$this->carrier = $mobileOrCarrier;
}
// If instance of mobile
elseif ($mobileOrCarrier instanceof Mobile) {
// Get carrier
$this->carrier = $mobileOrCarrier->carrier;
}
// Else
else {
// Get carrier
$this->carrier = Loader::mobile($mobileOrCarrier)->carrier;
}
// Adjust and return
return $this->adjust();
}
|
[
"public",
"function",
"fix",
"(",
"$",
"mobileOrCarrier",
")",
"{",
"// If instance of carrier",
"if",
"(",
"$",
"mobileOrCarrier",
"instanceof",
"Carrier",
")",
"{",
"// Use",
"$",
"this",
"->",
"carrier",
"=",
"$",
"mobileOrCarrier",
";",
"}",
"// If instance of mobile",
"elseif",
"(",
"$",
"mobileOrCarrier",
"instanceof",
"Mobile",
")",
"{",
"// Get carrier",
"$",
"this",
"->",
"carrier",
"=",
"$",
"mobileOrCarrier",
"->",
"carrier",
";",
"}",
"// Else ",
"else",
"{",
"// Get carrier",
"$",
"this",
"->",
"carrier",
"=",
"Loader",
"::",
"mobile",
"(",
"$",
"mobileOrCarrier",
")",
"->",
"carrier",
";",
"}",
"// Adjust and return",
"return",
"$",
"this",
"->",
"adjust",
"(",
")",
";",
"}"
] |
Fix cost by mobile or carrier
@param int|string|Mobile|Carrier $mobileOrCarrier Can be mobile number or instance of Mobile or Carrier
|
[
"Fix",
"cost",
"by",
"mobile",
"or",
"carrier"
] |
446987706f81d5a0efbc8bd6b7d3b259d0527719
|
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Cost.php#L115-L133
|
23,750
|
KodiComponents/Support
|
src/Http/CollectionFilters.php
|
CollectionFilters.apply
|
public function apply(Collection $collection)
{
$this->collection = $collection;
foreach ($this->filters() as $name => $value) {
if (! method_exists($this, $name)) {
continue;
}
if (is_array($value) or trim($value)) {
$this->collection = $this->$name($value);
} else {
$this->collection = $this->$name();
}
}
return $this->collection;
}
|
php
|
public function apply(Collection $collection)
{
$this->collection = $collection;
foreach ($this->filters() as $name => $value) {
if (! method_exists($this, $name)) {
continue;
}
if (is_array($value) or trim($value)) {
$this->collection = $this->$name($value);
} else {
$this->collection = $this->$name();
}
}
return $this->collection;
}
|
[
"public",
"function",
"apply",
"(",
"Collection",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"collection",
"=",
"$",
"collection",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"or",
"trim",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"collection",
"=",
"$",
"this",
"->",
"$",
"name",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"collection",
"=",
"$",
"this",
"->",
"$",
"name",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collection",
";",
"}"
] |
Apply the filters to the collection.
@param Collection $collection
@return Collection
|
[
"Apply",
"the",
"filters",
"to",
"the",
"collection",
"."
] |
9090543605a2354c7454d707650a0abdb815b60a
|
https://github.com/KodiComponents/Support/blob/9090543605a2354c7454d707650a0abdb815b60a/src/Http/CollectionFilters.php#L41-L58
|
23,751
|
ekuiter/feature-php
|
FeaturePhp/Generator/FileGenerator.php
|
FileGenerator.getFileOrDirectorySettings
|
private function getFileOrDirectorySettings($settings, $key) {
$filesOrDirectories = $settings->getOptional($key, array());
if (!is_array($filesOrDirectories))
$filesOrDirectories = array($filesOrDirectories);
return $filesOrDirectories;
}
|
php
|
private function getFileOrDirectorySettings($settings, $key) {
$filesOrDirectories = $settings->getOptional($key, array());
if (!is_array($filesOrDirectories))
$filesOrDirectories = array($filesOrDirectories);
return $filesOrDirectories;
}
|
[
"private",
"function",
"getFileOrDirectorySettings",
"(",
"$",
"settings",
",",
"$",
"key",
")",
"{",
"$",
"filesOrDirectories",
"=",
"$",
"settings",
"->",
"getOptional",
"(",
"$",
"key",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"filesOrDirectories",
")",
")",
"$",
"filesOrDirectories",
"=",
"array",
"(",
"$",
"filesOrDirectories",
")",
";",
"return",
"$",
"filesOrDirectories",
";",
"}"
] |
Returns plain settings arrays with file or directory specifications.
@param Settings $settings
@param string $key
@return array[]
|
[
"Returns",
"plain",
"settings",
"arrays",
"with",
"file",
"or",
"directory",
"specifications",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/FileGenerator.php#L35-L40
|
23,752
|
ekuiter/feature-php
|
FeaturePhp/Generator/FileGenerator.php
|
FileGenerator._generateFiles
|
protected function _generateFiles() {
foreach ($this->selectedArtifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach ($this->getFileOrDirectorySettings($settings, "files") as $file)
$this->_processFileSpecification(
$artifact, fphp\Specification\FileSpecification::fromArrayAndSettings($file, $settings));
foreach ($this->getFileOrDirectorySettings($settings, "directories") as $directory) {
$directorySpecification = fphp\Specification\DirectorySpecification::fromArrayAndSettings($directory, $settings);
foreach ($directorySpecification->getFileSpecifications() as $fileSpecification)
$this->_processFileSpecification($artifact, $fileSpecification);
}
}
}
|
php
|
protected function _generateFiles() {
foreach ($this->selectedArtifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach ($this->getFileOrDirectorySettings($settings, "files") as $file)
$this->_processFileSpecification(
$artifact, fphp\Specification\FileSpecification::fromArrayAndSettings($file, $settings));
foreach ($this->getFileOrDirectorySettings($settings, "directories") as $directory) {
$directorySpecification = fphp\Specification\DirectorySpecification::fromArrayAndSettings($directory, $settings);
foreach ($directorySpecification->getFileSpecifications() as $fileSpecification)
$this->_processFileSpecification($artifact, $fileSpecification);
}
}
}
|
[
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"selectedArtifacts",
"as",
"$",
"artifact",
")",
"{",
"$",
"settings",
"=",
"$",
"artifact",
"->",
"getGeneratorSettings",
"(",
"static",
"::",
"getKey",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFileOrDirectorySettings",
"(",
"$",
"settings",
",",
"\"files\"",
")",
"as",
"$",
"file",
")",
"$",
"this",
"->",
"_processFileSpecification",
"(",
"$",
"artifact",
",",
"fphp",
"\\",
"Specification",
"\\",
"FileSpecification",
"::",
"fromArrayAndSettings",
"(",
"$",
"file",
",",
"$",
"settings",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFileOrDirectorySettings",
"(",
"$",
"settings",
",",
"\"directories\"",
")",
"as",
"$",
"directory",
")",
"{",
"$",
"directorySpecification",
"=",
"fphp",
"\\",
"Specification",
"\\",
"DirectorySpecification",
"::",
"fromArrayAndSettings",
"(",
"$",
"directory",
",",
"$",
"settings",
")",
";",
"foreach",
"(",
"$",
"directorySpecification",
"->",
"getFileSpecifications",
"(",
")",
"as",
"$",
"fileSpecification",
")",
"$",
"this",
"->",
"_processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
";",
"}",
"}",
"}"
] |
Processes the files and directories.
|
[
"Processes",
"the",
"files",
"and",
"directories",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/FileGenerator.php#L45-L60
|
23,753
|
ekuiter/feature-php
|
FeaturePhp/Generator/FileGenerator.php
|
FileGenerator._processFileSpecification
|
private function _processFileSpecification($artifact, $fileSpecification) {
if (!in_array(basename($fileSpecification->getSource()), $this->exclude))
$this->processFileSpecification($artifact, $fileSpecification);
}
|
php
|
private function _processFileSpecification($artifact, $fileSpecification) {
if (!in_array(basename($fileSpecification->getSource()), $this->exclude))
$this->processFileSpecification($artifact, $fileSpecification);
}
|
[
"private",
"function",
"_processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"basename",
"(",
"$",
"fileSpecification",
"->",
"getSource",
"(",
")",
")",
",",
"$",
"this",
"->",
"exclude",
")",
")",
"$",
"this",
"->",
"processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
";",
"}"
] |
Processes a file from a specification.
Considers globally excluded files. Only exact file names are supported.
@param \FeaturePhp\Artifact\Artifact $artifact
@param \FeaturePhp\Specification\FileSpecification $fileSpecification
|
[
"Processes",
"a",
"file",
"from",
"a",
"specification",
".",
"Considers",
"globally",
"excluded",
"files",
".",
"Only",
"exact",
"file",
"names",
"are",
"supported",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/FileGenerator.php#L68-L71
|
23,754
|
inhere/php-librarys
|
src/Traits/LiteContainerStaticTrait.php
|
LiteContainerStaticTrait.get
|
public static function get($name, $call = true)
{
if (!isset(self::$services[$name])) {
throw new \RuntimeException("The service [$name] don't register.");
}
$service = self::$services[$name];
if (\is_object($service) && $service instanceof \Closure && $call) {
if (!isset(self::$instances[$name])) {
self::$instances[$name] = $service();
}
return self::$instances[$name];
}
return $service;
}
|
php
|
public static function get($name, $call = true)
{
if (!isset(self::$services[$name])) {
throw new \RuntimeException("The service [$name] don't register.");
}
$service = self::$services[$name];
if (\is_object($service) && $service instanceof \Closure && $call) {
if (!isset(self::$instances[$name])) {
self::$instances[$name] = $service();
}
return self::$instances[$name];
}
return $service;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"call",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"The service [$name] don't register.\"",
")",
";",
"}",
"$",
"service",
"=",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"service",
")",
"&&",
"$",
"service",
"instanceof",
"\\",
"Closure",
"&&",
"$",
"call",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"$",
"service",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"service",
";",
"}"
] |
get a app service by name
if is a closure, only run once.
@param string $name
@param bool $call if service is 'Closure', call it.
@return mixed
@throws \RuntimeException
|
[
"get",
"a",
"app",
"service",
"by",
"name",
"if",
"is",
"a",
"closure",
"only",
"run",
"once",
"."
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/LiteContainerStaticTrait.php#L76-L93
|
23,755
|
inhere/php-librarys
|
src/Traits/LiteContainerStaticTrait.php
|
LiteContainerStaticTrait.factory
|
public static function factory($name)
{
if (!isset(self::$services[$name])) {
throw new \RuntimeException("The service [$name] don't register.");
}
$service = self::$services[$name];
if (\is_object($service) && method_exists($service, '__invoke')) {
return $service();
}
return $service;
}
|
php
|
public static function factory($name)
{
if (!isset(self::$services[$name])) {
throw new \RuntimeException("The service [$name] don't register.");
}
$service = self::$services[$name];
if (\is_object($service) && method_exists($service, '__invoke')) {
return $service();
}
return $service;
}
|
[
"public",
"static",
"function",
"factory",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"The service [$name] don't register.\"",
")",
";",
"}",
"$",
"service",
"=",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"service",
")",
"&&",
"method_exists",
"(",
"$",
"service",
",",
"'__invoke'",
")",
")",
"{",
"return",
"$",
"service",
"(",
")",
";",
"}",
"return",
"$",
"service",
";",
"}"
] |
create a app service by name
it always return a new instance.
@param string $name
@return mixed
@throws \RuntimeException
|
[
"create",
"a",
"app",
"service",
"by",
"name",
"it",
"always",
"return",
"a",
"new",
"instance",
"."
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/LiteContainerStaticTrait.php#L116-L129
|
23,756
|
i-lateral/silverstripe-modeladminplus
|
src/ModelAdminSnippet.php
|
ModelAdminSnippet.addExtraClasses
|
public function addExtraClasses($classes)
{
if (!is_array($classes)) {
$classes = explode(" ", $classes);
}
$this->extra_classes = array_merge(
$this->extra_classes,
$classes
);
return $this;
}
|
php
|
public function addExtraClasses($classes)
{
if (!is_array($classes)) {
$classes = explode(" ", $classes);
}
$this->extra_classes = array_merge(
$this->extra_classes,
$classes
);
return $this;
}
|
[
"public",
"function",
"addExtraClasses",
"(",
"$",
"classes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"classes",
")",
";",
"}",
"$",
"this",
"->",
"extra_classes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"extra_classes",
",",
"$",
"classes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add additional css classes
@param array|string $extra_classes extra CSS classes
@return self
|
[
"Add",
"additional",
"css",
"classes"
] |
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
|
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/ModelAdminSnippet.php#L170-L182
|
23,757
|
i-lateral/silverstripe-modeladminplus
|
src/ModelAdminSnippet.php
|
ModelAdminSnippet.removeExtraClasses
|
public function removeExtraClasses($classes)
{
if (!is_array($classes)) {
$classes = explode(" ", $classes);
}
foreach ($classes as $class) {
if (isset($this->extra_classes[$class])) {
unset($this->extra_classes[$class]);
}
}
return $this;
}
|
php
|
public function removeExtraClasses($classes)
{
if (!is_array($classes)) {
$classes = explode(" ", $classes);
}
foreach ($classes as $class) {
if (isset($this->extra_classes[$class])) {
unset($this->extra_classes[$class]);
}
}
return $this;
}
|
[
"public",
"function",
"removeExtraClasses",
"(",
"$",
"classes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"classes",
")",
";",
"}",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"extra_classes",
"[",
"$",
"class",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"extra_classes",
"[",
"$",
"class",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove provided CSS classes
@param array|string $extra_classes extra CSS classes
@return self
|
[
"Remove",
"provided",
"CSS",
"classes"
] |
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
|
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/ModelAdminSnippet.php#L191-L204
|
23,758
|
kusanagi/katana-sdk-php7
|
src/Api/Factory/MiddlewareApiFactory.php
|
MiddlewareApiFactory.build
|
public function build(
$action,
array $data,
CliInput $input,
Mapping $mapping
)
{
$payloadMeta = $this->mapper->getPayloadMeta($data);
if ($action === 'request') {
return new RequestApi(
$this->logger->getRequestLogger($payloadMeta->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$this->mapper->getHttpRequest($data),
$this->mapper->getServiceCall($data),
$payloadMeta,
$this->mapper->getRequestAttributes($data)
);
} elseif($action === 'response') {
return new ResponseApi(
$this->logger->getRequestLogger($payloadMeta->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$this->mapper->getHttpRequest($data),
$this->mapper->getHttpResponse($data),
$this->mapper->getTransport($data),
$this->mapper->getPayloadMeta($data),
$this->mapper->getReturnValue($data)
);
}
}
|
php
|
public function build(
$action,
array $data,
CliInput $input,
Mapping $mapping
)
{
$payloadMeta = $this->mapper->getPayloadMeta($data);
if ($action === 'request') {
return new RequestApi(
$this->logger->getRequestLogger($payloadMeta->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$this->mapper->getHttpRequest($data),
$this->mapper->getServiceCall($data),
$payloadMeta,
$this->mapper->getRequestAttributes($data)
);
} elseif($action === 'response') {
return new ResponseApi(
$this->logger->getRequestLogger($payloadMeta->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$this->mapper->getHttpRequest($data),
$this->mapper->getHttpResponse($data),
$this->mapper->getTransport($data),
$this->mapper->getPayloadMeta($data),
$this->mapper->getReturnValue($data)
);
}
}
|
[
"public",
"function",
"build",
"(",
"$",
"action",
",",
"array",
"$",
"data",
",",
"CliInput",
"$",
"input",
",",
"Mapping",
"$",
"mapping",
")",
"{",
"$",
"payloadMeta",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getPayloadMeta",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"action",
"===",
"'request'",
")",
"{",
"return",
"new",
"RequestApi",
"(",
"$",
"this",
"->",
"logger",
"->",
"getRequestLogger",
"(",
"$",
"payloadMeta",
"->",
"getId",
"(",
")",
")",
",",
"$",
"this",
"->",
"component",
",",
"$",
"mapping",
",",
"dirname",
"(",
"realpath",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
")",
",",
"$",
"input",
"->",
"getName",
"(",
")",
",",
"$",
"input",
"->",
"getVersion",
"(",
")",
",",
"$",
"input",
"->",
"getFrameworkVersion",
"(",
")",
",",
"$",
"input",
"->",
"getVariables",
"(",
")",
",",
"$",
"input",
"->",
"isDebug",
"(",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getHttpRequest",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getServiceCall",
"(",
"$",
"data",
")",
",",
"$",
"payloadMeta",
",",
"$",
"this",
"->",
"mapper",
"->",
"getRequestAttributes",
"(",
"$",
"data",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"action",
"===",
"'response'",
")",
"{",
"return",
"new",
"ResponseApi",
"(",
"$",
"this",
"->",
"logger",
"->",
"getRequestLogger",
"(",
"$",
"payloadMeta",
"->",
"getId",
"(",
")",
")",
",",
"$",
"this",
"->",
"component",
",",
"$",
"mapping",
",",
"dirname",
"(",
"realpath",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
")",
",",
"$",
"input",
"->",
"getName",
"(",
")",
",",
"$",
"input",
"->",
"getVersion",
"(",
")",
",",
"$",
"input",
"->",
"getFrameworkVersion",
"(",
")",
",",
"$",
"input",
"->",
"getVariables",
"(",
")",
",",
"$",
"input",
"->",
"isDebug",
"(",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getHttpRequest",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getHttpResponse",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getTransport",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getPayloadMeta",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getReturnValue",
"(",
"$",
"data",
")",
")",
";",
"}",
"}"
] |
Build a Request Api class instance
@param string $action
@param array $data
@param CliInput $input
@param Mapping $mapping
@return Api
|
[
"Build",
"a",
"Request",
"Api",
"class",
"instance"
] |
91e7860a1852c3ce79a7034f8c36f41840e69e1f
|
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/Factory/MiddlewareApiFactory.php#L38-L82
|
23,759
|
NuclearCMS/Hierarchy
|
src/NodeSourceExtension.php
|
NodeSourceExtension.getAttribute
|
public function getAttribute($key)
{
if (isset($this->mutations[$key]))
{
return $this->mutations[$key];
}
if (array_key_exists($key, $mutatables = static::getMutatables()))
{
return $this->mutateExtensionAttribute($key, $mutatables[$key]);
}
return parent::getAttribute($key);
}
|
php
|
public function getAttribute($key)
{
if (isset($this->mutations[$key]))
{
return $this->mutations[$key];
}
if (array_key_exists($key, $mutatables = static::getMutatables()))
{
return $this->mutateExtensionAttribute($key, $mutatables[$key]);
}
return parent::getAttribute($key);
}
|
[
"public",
"function",
"getAttribute",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"mutations",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mutations",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"mutatables",
"=",
"static",
"::",
"getMutatables",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mutateExtensionAttribute",
"(",
"$",
"key",
",",
"$",
"mutatables",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"parent",
"::",
"getAttribute",
"(",
"$",
"key",
")",
";",
"}"
] |
Get an attribute from the model with custom accessor.
@param string $key
@return mixed
|
[
"Get",
"an",
"attribute",
"from",
"the",
"model",
"with",
"custom",
"accessor",
"."
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSourceExtension.php#L42-L55
|
23,760
|
NuclearCMS/Hierarchy
|
src/NodeSourceExtension.php
|
NodeSourceExtension.mutateExtensionAttribute
|
protected function mutateExtensionAttribute($key, $type)
{
$value = $this->getAttributeFromArray($key);
$mutation = $this->{'make' . studly_case($type) . 'TypeMutation'}($value);
$this->mutations[$key] = $mutation;
return $mutation;
}
|
php
|
protected function mutateExtensionAttribute($key, $type)
{
$value = $this->getAttributeFromArray($key);
$mutation = $this->{'make' . studly_case($type) . 'TypeMutation'}($value);
$this->mutations[$key] = $mutation;
return $mutation;
}
|
[
"protected",
"function",
"mutateExtensionAttribute",
"(",
"$",
"key",
",",
"$",
"type",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getAttributeFromArray",
"(",
"$",
"key",
")",
";",
"$",
"mutation",
"=",
"$",
"this",
"->",
"{",
"'make'",
".",
"studly_case",
"(",
"$",
"type",
")",
".",
"'TypeMutation'",
"}",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"mutations",
"[",
"$",
"key",
"]",
"=",
"$",
"mutation",
";",
"return",
"$",
"mutation",
";",
"}"
] |
Mutates and stores an attribute in array
@param string $key
@param string $type
@return mixed
|
[
"Mutates",
"and",
"stores",
"an",
"attribute",
"in",
"array"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSourceExtension.php#L81-L90
|
23,761
|
surebert/surebert-framework
|
src/sb/Controller/Command/Line.php
|
Line.setLogger
|
public function setLogger(\sb\Logger\Base $logger, $logname=''){
$this->logger = $logger;
$this->log_name = $logname ? $logname : get_called_class();
$this->log_name = preg_replace("~[^\w+]~", "_", $this->log_name);
}
|
php
|
public function setLogger(\sb\Logger\Base $logger, $logname=''){
$this->logger = $logger;
$this->log_name = $logname ? $logname : get_called_class();
$this->log_name = preg_replace("~[^\w+]~", "_", $this->log_name);
}
|
[
"public",
"function",
"setLogger",
"(",
"\\",
"sb",
"\\",
"Logger",
"\\",
"Base",
"$",
"logger",
",",
"$",
"logname",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"logger",
"=",
"$",
"logger",
";",
"$",
"this",
"->",
"log_name",
"=",
"$",
"logname",
"?",
"$",
"logname",
":",
"get_called_class",
"(",
")",
";",
"$",
"this",
"->",
"log_name",
"=",
"preg_replace",
"(",
"\"~[^\\w+]~\"",
",",
"\"_\"",
",",
"$",
"this",
"->",
"log_name",
")",
";",
"}"
] |
Set the logger that logs the full log message stream
when the destructor runs
@param \sb\Logger\Base $logger
|
[
"Set",
"the",
"logger",
"that",
"logs",
"the",
"full",
"log",
"message",
"stream",
"when",
"the",
"destructor",
"runs"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Command/Line.php#L141-L145
|
23,762
|
surebert/surebert-framework
|
src/sb/Controller/Command/Line.php
|
Line.log
|
public function log($message, $type = "MESSAGE", $text_attributes = [])
{
$type = strtoupper($type);
switch ($type) {
case 'RAW':
break;
case 'ERROR':
$this->number_of_errors++;
$this->onError($message);
default:
$message = $type . ': ' . $message;
}
$this->logToFile($message);
if(empty($text_attributes)){
file_put_contents("php://stdout", "\n".$message);
return $message;
}
if(is_array($text_attributes)){
if(isset($text_attributes['bold']) && $text_attributes['bold']){
file_put_contents("php://stdout", "\033[1m");
}
if(isset($text_attributes['underline']) && $text_attributes['underline']){
file_put_contents("php://stdout","\033[4m");
}
if(isset($text_attributes['fgcolor']) && isset($this->fgcolors[$text_attributes['fgcolor']])){
file_put_contents("php://stdout", "\033[".$this->fgcolors[$text_attributes['fgcolor']]."m");
}
if(isset($text_attributes['bgcolor']) && isset($this->fgcolors[$text_attributes['bgcolor']])){
file_put_contents("php://stdout", "\033[".$this->bgcolors[$bgcolor]."m");
}
if(isset($text_attributes['underline']) && $text_attributes['underline']){
file_put_contents("php://stdout","\033[4m");
}
if(isset($text_attributes['overwrite']) && $text_attributes['overwrite']){
file_put_contents("php://stdout", "\033[2K\033[A");
}
} else if(is_string($text_attributes) && isset($this->fgcolors[$text_attributes])){
file_put_contents("php://stdout", "\033[".$this->fgcolors[$text_attributes]."m");
}
file_put_contents("php://stdout", "\n".$message);
if(!is_array($text_attributes) || !isset($text_attributes['keep']) || !$text_attributes['keep']){
file_put_contents("php://stdout","\033[0m");
}
return $message;
}
|
php
|
public function log($message, $type = "MESSAGE", $text_attributes = [])
{
$type = strtoupper($type);
switch ($type) {
case 'RAW':
break;
case 'ERROR':
$this->number_of_errors++;
$this->onError($message);
default:
$message = $type . ': ' . $message;
}
$this->logToFile($message);
if(empty($text_attributes)){
file_put_contents("php://stdout", "\n".$message);
return $message;
}
if(is_array($text_attributes)){
if(isset($text_attributes['bold']) && $text_attributes['bold']){
file_put_contents("php://stdout", "\033[1m");
}
if(isset($text_attributes['underline']) && $text_attributes['underline']){
file_put_contents("php://stdout","\033[4m");
}
if(isset($text_attributes['fgcolor']) && isset($this->fgcolors[$text_attributes['fgcolor']])){
file_put_contents("php://stdout", "\033[".$this->fgcolors[$text_attributes['fgcolor']]."m");
}
if(isset($text_attributes['bgcolor']) && isset($this->fgcolors[$text_attributes['bgcolor']])){
file_put_contents("php://stdout", "\033[".$this->bgcolors[$bgcolor]."m");
}
if(isset($text_attributes['underline']) && $text_attributes['underline']){
file_put_contents("php://stdout","\033[4m");
}
if(isset($text_attributes['overwrite']) && $text_attributes['overwrite']){
file_put_contents("php://stdout", "\033[2K\033[A");
}
} else if(is_string($text_attributes) && isset($this->fgcolors[$text_attributes])){
file_put_contents("php://stdout", "\033[".$this->fgcolors[$text_attributes]."m");
}
file_put_contents("php://stdout", "\n".$message);
if(!is_array($text_attributes) || !isset($text_attributes['keep']) || !$text_attributes['keep']){
file_put_contents("php://stdout","\033[0m");
}
return $message;
}
|
[
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"type",
"=",
"\"MESSAGE\"",
",",
"$",
"text_attributes",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"strtoupper",
"(",
"$",
"type",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'RAW'",
":",
"break",
";",
"case",
"'ERROR'",
":",
"$",
"this",
"->",
"number_of_errors",
"++",
";",
"$",
"this",
"->",
"onError",
"(",
"$",
"message",
")",
";",
"default",
":",
"$",
"message",
"=",
"$",
"type",
".",
"': '",
".",
"$",
"message",
";",
"}",
"$",
"this",
"->",
"logToFile",
"(",
"$",
"message",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"text_attributes",
")",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\n\"",
".",
"$",
"message",
")",
";",
"return",
"$",
"message",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"text_attributes",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'bold'",
"]",
")",
"&&",
"$",
"text_attributes",
"[",
"'bold'",
"]",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[1m\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'underline'",
"]",
")",
"&&",
"$",
"text_attributes",
"[",
"'underline'",
"]",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[4m\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'fgcolor'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"fgcolors",
"[",
"$",
"text_attributes",
"[",
"'fgcolor'",
"]",
"]",
")",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[\"",
".",
"$",
"this",
"->",
"fgcolors",
"[",
"$",
"text_attributes",
"[",
"'fgcolor'",
"]",
"]",
".",
"\"m\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'bgcolor'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"fgcolors",
"[",
"$",
"text_attributes",
"[",
"'bgcolor'",
"]",
"]",
")",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[\"",
".",
"$",
"this",
"->",
"bgcolors",
"[",
"$",
"bgcolor",
"]",
".",
"\"m\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'underline'",
"]",
")",
"&&",
"$",
"text_attributes",
"[",
"'underline'",
"]",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[4m\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"text_attributes",
"[",
"'overwrite'",
"]",
")",
"&&",
"$",
"text_attributes",
"[",
"'overwrite'",
"]",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[2K\\033[A\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"text_attributes",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"fgcolors",
"[",
"$",
"text_attributes",
"]",
")",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[\"",
".",
"$",
"this",
"->",
"fgcolors",
"[",
"$",
"text_attributes",
"]",
".",
"\"m\"",
")",
";",
"}",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\n\"",
".",
"$",
"message",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"text_attributes",
")",
"||",
"!",
"isset",
"(",
"$",
"text_attributes",
"[",
"'keep'",
"]",
")",
"||",
"!",
"$",
"text_attributes",
"[",
"'keep'",
"]",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"\"\\033[0m\"",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] |
Logs to std out
@param string $message The message of the line
@param string $type The prefix of the line, if ERROR, encrements error count
@param array|string $text_attributes, used to describe how output should look
e.g. ['fgcolor' => 'red', 'bgcolor' => 'yellow', 'bold' => true, 'underline' => true, 'keep' => false]
if keep is true then it keeps the style until you call a line with another
style or you call $this->setNormalText()
if string then its just the foreground color
|
[
"Logs",
"to",
"std",
"out"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Command/Line.php#L202-L262
|
23,763
|
surebert/surebert-framework
|
src/sb/Controller/Command/Line.php
|
Line.logToFile
|
protected function logToFile($message){
if(isset($this->logger) && $this->logger instanceof \sb\Logger\Base){
return $this->logger->{$this->log_name}($message);
}
}
|
php
|
protected function logToFile($message){
if(isset($this->logger) && $this->logger instanceof \sb\Logger\Base){
return $this->logger->{$this->log_name}($message);
}
}
|
[
"protected",
"function",
"logToFile",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"logger",
")",
"&&",
"$",
"this",
"->",
"logger",
"instanceof",
"\\",
"sb",
"\\",
"Logger",
"\\",
"Base",
")",
"{",
"return",
"$",
"this",
"->",
"logger",
"->",
"{",
"$",
"this",
"->",
"log_name",
"}",
"(",
"$",
"message",
")",
";",
"}",
"}"
] |
Logs to file
@param string $message
@return string
|
[
"Logs",
"to",
"file"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Command/Line.php#L269-L273
|
23,764
|
surebert/surebert-framework
|
src/sb/Controller/Command/Line.php
|
Line.getCommandlineInvocation
|
public function getCommandlineInvocation($method_name, $http_host=null, $http_args=[])
{
$command_prefix = "php " . ROOT . "/public/index.php";
// Match fully-qualified method name: e.g. \Foo\Controllers\Jobs\Bar::baz()
preg_match('/Controllers.([^:]+)::([A-Za-z_]+)/', $method_name, $matches);
if (count($matches) !== 3) {
return '';
}
$class_name = strtolower($matches[1]);
$class_name = preg_replace('/\\\/', '_', $class_name);
$method_name = strtolower($matches[2]);
// Build argument for --request opt
$request_arg = "/$class_name/$method_name";
if (!empty($http_args)) {
$request_arg .= "?" . http_build_query($http_args);
}
// Build argument for --http_host opt
if (is_null($http_host)) {
$http_host = \sb\Gateway::$http_host;
}
return "$command_prefix --request=$request_arg --http_host=$http_host";
}
|
php
|
public function getCommandlineInvocation($method_name, $http_host=null, $http_args=[])
{
$command_prefix = "php " . ROOT . "/public/index.php";
// Match fully-qualified method name: e.g. \Foo\Controllers\Jobs\Bar::baz()
preg_match('/Controllers.([^:]+)::([A-Za-z_]+)/', $method_name, $matches);
if (count($matches) !== 3) {
return '';
}
$class_name = strtolower($matches[1]);
$class_name = preg_replace('/\\\/', '_', $class_name);
$method_name = strtolower($matches[2]);
// Build argument for --request opt
$request_arg = "/$class_name/$method_name";
if (!empty($http_args)) {
$request_arg .= "?" . http_build_query($http_args);
}
// Build argument for --http_host opt
if (is_null($http_host)) {
$http_host = \sb\Gateway::$http_host;
}
return "$command_prefix --request=$request_arg --http_host=$http_host";
}
|
[
"public",
"function",
"getCommandlineInvocation",
"(",
"$",
"method_name",
",",
"$",
"http_host",
"=",
"null",
",",
"$",
"http_args",
"=",
"[",
"]",
")",
"{",
"$",
"command_prefix",
"=",
"\"php \"",
".",
"ROOT",
".",
"\"/public/index.php\"",
";",
"// Match fully-qualified method name: e.g. \\Foo\\Controllers\\Jobs\\Bar::baz()",
"preg_match",
"(",
"'/Controllers.([^:]+)::([A-Za-z_]+)/'",
",",
"$",
"method_name",
",",
"$",
"matches",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"!==",
"3",
")",
"{",
"return",
"''",
";",
"}",
"$",
"class_name",
"=",
"strtolower",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"class_name",
"=",
"preg_replace",
"(",
"'/\\\\\\/'",
",",
"'_'",
",",
"$",
"class_name",
")",
";",
"$",
"method_name",
"=",
"strtolower",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"// Build argument for --request opt",
"$",
"request_arg",
"=",
"\"/$class_name/$method_name\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"http_args",
")",
")",
"{",
"$",
"request_arg",
".=",
"\"?\"",
".",
"http_build_query",
"(",
"$",
"http_args",
")",
";",
"}",
"// Build argument for --http_host opt",
"if",
"(",
"is_null",
"(",
"$",
"http_host",
")",
")",
"{",
"$",
"http_host",
"=",
"\\",
"sb",
"\\",
"Gateway",
"::",
"$",
"http_host",
";",
"}",
"return",
"\"$command_prefix --request=$request_arg --http_host=$http_host\"",
";",
"}"
] |
Returns the name of a controller method in a format that can
be used in a commandline invocation.
@param string $method_name Fully qualified name to method whose invocation is being generated
@param string $http_host --http_host arg, optional, defaults to Gateway::$http_host
@param array $http_args Query string args, optional, defaults to empty array
@return string The commandline invocation for the given args
e.g. php /var/www/html/enterpriseteam/public/index.php '--request=/jobs_invision/load?doctype=obmt85' --http_host=enterpriseteam.roswellpark.org
Note: It is up to client code to add any bash redirects
|
[
"Returns",
"the",
"name",
"of",
"a",
"controller",
"method",
"in",
"a",
"format",
"that",
"can",
"be",
"used",
"in",
"a",
"commandline",
"invocation",
"."
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Command/Line.php#L316-L341
|
23,765
|
technote-space/wordpress-plugin-base
|
src/traits/hook.php
|
Hook.load_cache_settings
|
private function load_cache_settings() {
if ( $this->app->isset_shared_object( 'is_valid_hook_cache' ) ) {
return;
}
$this->app->set_shared_object( 'is_valid_hook_cache', ! empty( $this->app->get_config( 'config', 'cache_filter_result' ) ) );
$prevent_cache = $this->app->get_config( 'config', 'cache_filter_exclude_list', [] );
$prevent_cache = empty( $prevent_cache ) ? [] : array_combine(
$prevent_cache,
array_fill( 0, count( $prevent_cache ), true )
);
$this->app->set_shared_object( 'prevent_hook_cache', $prevent_cache );
$this->app->set_shared_object( 'hook_cache', [] );
}
|
php
|
private function load_cache_settings() {
if ( $this->app->isset_shared_object( 'is_valid_hook_cache' ) ) {
return;
}
$this->app->set_shared_object( 'is_valid_hook_cache', ! empty( $this->app->get_config( 'config', 'cache_filter_result' ) ) );
$prevent_cache = $this->app->get_config( 'config', 'cache_filter_exclude_list', [] );
$prevent_cache = empty( $prevent_cache ) ? [] : array_combine(
$prevent_cache,
array_fill( 0, count( $prevent_cache ), true )
);
$this->app->set_shared_object( 'prevent_hook_cache', $prevent_cache );
$this->app->set_shared_object( 'hook_cache', [] );
}
|
[
"private",
"function",
"load_cache_settings",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"isset_shared_object",
"(",
"'is_valid_hook_cache'",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"set_shared_object",
"(",
"'is_valid_hook_cache'",
",",
"!",
"empty",
"(",
"$",
"this",
"->",
"app",
"->",
"get_config",
"(",
"'config'",
",",
"'cache_filter_result'",
")",
")",
")",
";",
"$",
"prevent_cache",
"=",
"$",
"this",
"->",
"app",
"->",
"get_config",
"(",
"'config'",
",",
"'cache_filter_exclude_list'",
",",
"[",
"]",
")",
";",
"$",
"prevent_cache",
"=",
"empty",
"(",
"$",
"prevent_cache",
")",
"?",
"[",
"]",
":",
"array_combine",
"(",
"$",
"prevent_cache",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"prevent_cache",
")",
",",
"true",
")",
")",
";",
"$",
"this",
"->",
"app",
"->",
"set_shared_object",
"(",
"'prevent_hook_cache'",
",",
"$",
"prevent_cache",
")",
";",
"$",
"this",
"->",
"app",
"->",
"set_shared_object",
"(",
"'hook_cache'",
",",
"[",
"]",
")",
";",
"}"
] |
load cache settings
|
[
"load",
"cache",
"settings"
] |
02cfcba358432a2539af07a69d9db00ff7c14eac
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/hook.php#L30-L43
|
23,766
|
mslib/resource-proxy
|
Msl/ResourceProxy/Source/SourceFactory.php
|
SourceFactory.getSourceInstance
|
public function getSourceInstance($type, $name, array $parameters, array $globalParameters = array())
{
// The source object variable
$sourceObj = null;
// Getting SourceConfig object for an Imap Source object
$sourceConfig = $this->getSourceConfig($name, $type, $parameters, $globalParameters);
// Creating a Source object with the given source config object
if ($sourceConfig instanceof SourceConfig ) {
// Creating a Source object instance according to the given type
switch ($type) {
case SourceConfig::SOURCE_TYPE_IMAP:
// Initializing an Imap Source object
$sourceObj = new Imap();
break;
case SourceConfig::SOURCE_TYPE_POP:
// Initializing a Pop Source object
$sourceObj = new Pop();
break;
default:
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unrecognized Parser Source type '%s'. Accepted values are: '%s'",
$type,
SourceConfig::SOURCE_TYPE_IMAP
)
);
}
// Setting the source config to the new source object
if ($sourceObj instanceof SourceInterface) {
$sourceObj->setConfig($sourceConfig);
} else {
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unexpected object type: expected 'Msl\ResourceProxy\Source\SourceInterface' for type '%s' but got '%s'.",
$type,
get_class($sourceObj)
)
);
}
} else {
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unexpected object type: expected 'Msl\ResourceProxy\Source\SourceConfig' for type '%s' but got '%s'.",
$type,
get_class($sourceConfig)
)
);
}
// Returning result
return $sourceObj;
}
|
php
|
public function getSourceInstance($type, $name, array $parameters, array $globalParameters = array())
{
// The source object variable
$sourceObj = null;
// Getting SourceConfig object for an Imap Source object
$sourceConfig = $this->getSourceConfig($name, $type, $parameters, $globalParameters);
// Creating a Source object with the given source config object
if ($sourceConfig instanceof SourceConfig ) {
// Creating a Source object instance according to the given type
switch ($type) {
case SourceConfig::SOURCE_TYPE_IMAP:
// Initializing an Imap Source object
$sourceObj = new Imap();
break;
case SourceConfig::SOURCE_TYPE_POP:
// Initializing a Pop Source object
$sourceObj = new Pop();
break;
default:
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unrecognized Parser Source type '%s'. Accepted values are: '%s'",
$type,
SourceConfig::SOURCE_TYPE_IMAP
)
);
}
// Setting the source config to the new source object
if ($sourceObj instanceof SourceInterface) {
$sourceObj->setConfig($sourceConfig);
} else {
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unexpected object type: expected 'Msl\ResourceProxy\Source\SourceInterface' for type '%s' but got '%s'.",
$type,
get_class($sourceObj)
)
);
}
} else {
throw new Exception\BadSourceConfigConfigurationException(
sprintf(
"Unexpected object type: expected 'Msl\ResourceProxy\Source\SourceConfig' for type '%s' but got '%s'.",
$type,
get_class($sourceConfig)
)
);
}
// Returning result
return $sourceObj;
}
|
[
"public",
"function",
"getSourceInstance",
"(",
"$",
"type",
",",
"$",
"name",
",",
"array",
"$",
"parameters",
",",
"array",
"$",
"globalParameters",
"=",
"array",
"(",
")",
")",
"{",
"// The source object variable",
"$",
"sourceObj",
"=",
"null",
";",
"// Getting SourceConfig object for an Imap Source object",
"$",
"sourceConfig",
"=",
"$",
"this",
"->",
"getSourceConfig",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"parameters",
",",
"$",
"globalParameters",
")",
";",
"// Creating a Source object with the given source config object",
"if",
"(",
"$",
"sourceConfig",
"instanceof",
"SourceConfig",
")",
"{",
"// Creating a Source object instance according to the given type",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"SourceConfig",
"::",
"SOURCE_TYPE_IMAP",
":",
"// Initializing an Imap Source object",
"$",
"sourceObj",
"=",
"new",
"Imap",
"(",
")",
";",
"break",
";",
"case",
"SourceConfig",
"::",
"SOURCE_TYPE_POP",
":",
"// Initializing a Pop Source object",
"$",
"sourceObj",
"=",
"new",
"Pop",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"\\",
"BadSourceConfigConfigurationException",
"(",
"sprintf",
"(",
"\"Unrecognized Parser Source type '%s'. Accepted values are: '%s'\"",
",",
"$",
"type",
",",
"SourceConfig",
"::",
"SOURCE_TYPE_IMAP",
")",
")",
";",
"}",
"// Setting the source config to the new source object",
"if",
"(",
"$",
"sourceObj",
"instanceof",
"SourceInterface",
")",
"{",
"$",
"sourceObj",
"->",
"setConfig",
"(",
"$",
"sourceConfig",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"BadSourceConfigConfigurationException",
"(",
"sprintf",
"(",
"\"Unexpected object type: expected 'Msl\\ResourceProxy\\Source\\SourceInterface' for type '%s' but got '%s'.\"",
",",
"$",
"type",
",",
"get_class",
"(",
"$",
"sourceObj",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"BadSourceConfigConfigurationException",
"(",
"sprintf",
"(",
"\"Unexpected object type: expected 'Msl\\ResourceProxy\\Source\\SourceConfig' for type '%s' but got '%s'.\"",
",",
"$",
"type",
",",
"get_class",
"(",
"$",
"sourceConfig",
")",
")",
")",
";",
"}",
"// Returning result",
"return",
"$",
"sourceObj",
";",
"}"
] |
Gets a Source instance according to the type.
@param string $type type of the required Source instance (e.g. 'imap')
@param string $name name of the returned Source instance (e.g. 'imap.main.account')
@param array $parameters configuration parameters to initialize a Source instance
@param array $globalParameters Global configuration array: if required parameters are not specified in the parameters array, then we check if they are defined in this array
@return \Msl\ResourceProxy\Source\SourceInterface
@throws \Msl\ResourceProxy\Exception\BadSourceConfigConfigurationException
|
[
"Gets",
"a",
"Source",
"instance",
"according",
"to",
"the",
"type",
"."
] |
be3f8589753f738f5114443a3465f5e84aecd156
|
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/SourceFactory.php#L36-L90
|
23,767
|
shabbyrobe/amiss
|
src/Sql/Query/Select.php
|
Select.buildOrder
|
public function buildOrder($meta, $tableAlias=null)
{
// Careful! $meta might be null.
$metaFields = $meta ? $meta->fields : null;
$order = $this->order;
if ($meta && $meta->defaultOrder && $order !== null) {
$order = $meta->defaultOrder;
}
if ($order) {
if (is_array($order)) {
$oClauses = '';
foreach ($order as $field=>$dir) {
if ($oClauses) {
$oClauses .= ', ';
}
if (!is_string($field)) {
$field = $dir; $dir = '';
}
$name = (isset($metaFields[$field]) ? $metaFields[$field]['name'] : $field);
$qname = $name[0] == '`' ? $name : '`'.$name.'`';
$qname = ($tableAlias ? $tableAlias.'.' : '').$qname;
$oClauses .= $qname;
if ($dir) {
if ($dir === true) {
$dir = 'asc';
}
// strpos(strtolower($dir), 'desc') === 0;
if (isset($dir[3]) && ($dir[0] == 'd' || $dir[0] == 'D') && ($dir[1] == 'e' || $dir[1] == 'E') && ($dir[2] == 's' || $dir[2] == 'S') && ($dir[3] == 'c' || $dir[3] == 'C')) {
$oClauses .= ' desc';
}
elseif (!isset($dir[2]) || !(($dir[0] == 'a' || $dir[0] == 'A') && ($dir[1] == 's' || $dir[1] == 'S') && ($dir[2] == 'c' || $dir[2] == 'C'))) {
throw new \UnexpectedValueException("Order direction must be 'asc' or 'desc', found ".$dir);
}
}
}
$order = $oClauses;
}
else {
if ($metaFields && strpos($order, '{') !== false) {
$order = static::replaceFields($meta, $order, $tableAlias);
}
}
}
return $order;
}
|
php
|
public function buildOrder($meta, $tableAlias=null)
{
// Careful! $meta might be null.
$metaFields = $meta ? $meta->fields : null;
$order = $this->order;
if ($meta && $meta->defaultOrder && $order !== null) {
$order = $meta->defaultOrder;
}
if ($order) {
if (is_array($order)) {
$oClauses = '';
foreach ($order as $field=>$dir) {
if ($oClauses) {
$oClauses .= ', ';
}
if (!is_string($field)) {
$field = $dir; $dir = '';
}
$name = (isset($metaFields[$field]) ? $metaFields[$field]['name'] : $field);
$qname = $name[0] == '`' ? $name : '`'.$name.'`';
$qname = ($tableAlias ? $tableAlias.'.' : '').$qname;
$oClauses .= $qname;
if ($dir) {
if ($dir === true) {
$dir = 'asc';
}
// strpos(strtolower($dir), 'desc') === 0;
if (isset($dir[3]) && ($dir[0] == 'd' || $dir[0] == 'D') && ($dir[1] == 'e' || $dir[1] == 'E') && ($dir[2] == 's' || $dir[2] == 'S') && ($dir[3] == 'c' || $dir[3] == 'C')) {
$oClauses .= ' desc';
}
elseif (!isset($dir[2]) || !(($dir[0] == 'a' || $dir[0] == 'A') && ($dir[1] == 's' || $dir[1] == 'S') && ($dir[2] == 'c' || $dir[2] == 'C'))) {
throw new \UnexpectedValueException("Order direction must be 'asc' or 'desc', found ".$dir);
}
}
}
$order = $oClauses;
}
else {
if ($metaFields && strpos($order, '{') !== false) {
$order = static::replaceFields($meta, $order, $tableAlias);
}
}
}
return $order;
}
|
[
"public",
"function",
"buildOrder",
"(",
"$",
"meta",
",",
"$",
"tableAlias",
"=",
"null",
")",
"{",
"// Careful! $meta might be null.",
"$",
"metaFields",
"=",
"$",
"meta",
"?",
"$",
"meta",
"->",
"fields",
":",
"null",
";",
"$",
"order",
"=",
"$",
"this",
"->",
"order",
";",
"if",
"(",
"$",
"meta",
"&&",
"$",
"meta",
"->",
"defaultOrder",
"&&",
"$",
"order",
"!==",
"null",
")",
"{",
"$",
"order",
"=",
"$",
"meta",
"->",
"defaultOrder",
";",
"}",
"if",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"order",
")",
")",
"{",
"$",
"oClauses",
"=",
"''",
";",
"foreach",
"(",
"$",
"order",
"as",
"$",
"field",
"=>",
"$",
"dir",
")",
"{",
"if",
"(",
"$",
"oClauses",
")",
"{",
"$",
"oClauses",
".=",
"', '",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"$",
"field",
"=",
"$",
"dir",
";",
"$",
"dir",
"=",
"''",
";",
"}",
"$",
"name",
"=",
"(",
"isset",
"(",
"$",
"metaFields",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"metaFields",
"[",
"$",
"field",
"]",
"[",
"'name'",
"]",
":",
"$",
"field",
")",
";",
"$",
"qname",
"=",
"$",
"name",
"[",
"0",
"]",
"==",
"'`'",
"?",
"$",
"name",
":",
"'`'",
".",
"$",
"name",
".",
"'`'",
";",
"$",
"qname",
"=",
"(",
"$",
"tableAlias",
"?",
"$",
"tableAlias",
".",
"'.'",
":",
"''",
")",
".",
"$",
"qname",
";",
"$",
"oClauses",
".=",
"$",
"qname",
";",
"if",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"$",
"dir",
"===",
"true",
")",
"{",
"$",
"dir",
"=",
"'asc'",
";",
"}",
"// strpos(strtolower($dir), 'desc') === 0;",
"if",
"(",
"isset",
"(",
"$",
"dir",
"[",
"3",
"]",
")",
"&&",
"(",
"$",
"dir",
"[",
"0",
"]",
"==",
"'d'",
"||",
"$",
"dir",
"[",
"0",
"]",
"==",
"'D'",
")",
"&&",
"(",
"$",
"dir",
"[",
"1",
"]",
"==",
"'e'",
"||",
"$",
"dir",
"[",
"1",
"]",
"==",
"'E'",
")",
"&&",
"(",
"$",
"dir",
"[",
"2",
"]",
"==",
"'s'",
"||",
"$",
"dir",
"[",
"2",
"]",
"==",
"'S'",
")",
"&&",
"(",
"$",
"dir",
"[",
"3",
"]",
"==",
"'c'",
"||",
"$",
"dir",
"[",
"3",
"]",
"==",
"'C'",
")",
")",
"{",
"$",
"oClauses",
".=",
"' desc'",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"dir",
"[",
"2",
"]",
")",
"||",
"!",
"(",
"(",
"$",
"dir",
"[",
"0",
"]",
"==",
"'a'",
"||",
"$",
"dir",
"[",
"0",
"]",
"==",
"'A'",
")",
"&&",
"(",
"$",
"dir",
"[",
"1",
"]",
"==",
"'s'",
"||",
"$",
"dir",
"[",
"1",
"]",
"==",
"'S'",
")",
"&&",
"(",
"$",
"dir",
"[",
"2",
"]",
"==",
"'c'",
"||",
"$",
"dir",
"[",
"2",
"]",
"==",
"'C'",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Order direction must be 'asc' or 'desc', found \"",
".",
"$",
"dir",
")",
";",
"}",
"}",
"}",
"$",
"order",
"=",
"$",
"oClauses",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"metaFields",
"&&",
"strpos",
"(",
"$",
"order",
",",
"'{'",
")",
"!==",
"false",
")",
"{",
"$",
"order",
"=",
"static",
"::",
"replaceFields",
"(",
"$",
"meta",
",",
"$",
"order",
",",
"$",
"tableAlias",
")",
";",
"}",
"}",
"}",
"return",
"$",
"order",
";",
"}"
] |
damn, this is pretty much identical to the above. FIXME, etc.
|
[
"damn",
"this",
"is",
"pretty",
"much",
"identical",
"to",
"the",
"above",
".",
"FIXME",
"etc",
"."
] |
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
|
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Sql/Query/Select.php#L94-L143
|
23,768
|
zhouyl/mellivora
|
Mellivora/Events/Dispatcher.php
|
Dispatcher.queueHandler
|
protected function queueHandler($class, $method, $arguments)
{
list($listener, $job) = $this->createListenerAndJob($class, $method, $arguments);
$connection = $this->resolveQueue()->connection(
isset($listener->connection) ? $listener->connection : null
);
$queue = isset($listener->queue) ? $listener->queue : null;
isset($listener->delay)
? $connection->laterOn($queue, $listener->delay, $job)
: $connection->pushOn($queue, $job);
}
|
php
|
protected function queueHandler($class, $method, $arguments)
{
list($listener, $job) = $this->createListenerAndJob($class, $method, $arguments);
$connection = $this->resolveQueue()->connection(
isset($listener->connection) ? $listener->connection : null
);
$queue = isset($listener->queue) ? $listener->queue : null;
isset($listener->delay)
? $connection->laterOn($queue, $listener->delay, $job)
: $connection->pushOn($queue, $job);
}
|
[
"protected",
"function",
"queueHandler",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"list",
"(",
"$",
"listener",
",",
"$",
"job",
")",
"=",
"$",
"this",
"->",
"createListenerAndJob",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"arguments",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"resolveQueue",
"(",
")",
"->",
"connection",
"(",
"isset",
"(",
"$",
"listener",
"->",
"connection",
")",
"?",
"$",
"listener",
"->",
"connection",
":",
"null",
")",
";",
"$",
"queue",
"=",
"isset",
"(",
"$",
"listener",
"->",
"queue",
")",
"?",
"$",
"listener",
"->",
"queue",
":",
"null",
";",
"isset",
"(",
"$",
"listener",
"->",
"delay",
")",
"?",
"$",
"connection",
"->",
"laterOn",
"(",
"$",
"queue",
",",
"$",
"listener",
"->",
"delay",
",",
"$",
"job",
")",
":",
"$",
"connection",
"->",
"pushOn",
"(",
"$",
"queue",
",",
"$",
"job",
")",
";",
"}"
] |
Queue the handler class.
@param string $class
@param string $method
@param array $arguments
@return void
|
[
"Queue",
"the",
"handler",
"class",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/Dispatcher.php#L448-L461
|
23,769
|
zhouyl/mellivora
|
Mellivora/Events/Dispatcher.php
|
Dispatcher.createListenerAndJob
|
protected function createListenerAndJob($class, $method, $arguments)
{
$listener = (new ReflectionClass($class))->newInstanceWithoutConstructor();
return [$listener, $this->propogateListenerOptions(
$listener,
new CallQueuedListener($class, $method, $arguments)
)];
}
|
php
|
protected function createListenerAndJob($class, $method, $arguments)
{
$listener = (new ReflectionClass($class))->newInstanceWithoutConstructor();
return [$listener, $this->propogateListenerOptions(
$listener,
new CallQueuedListener($class, $method, $arguments)
)];
}
|
[
"protected",
"function",
"createListenerAndJob",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"$",
"listener",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
")",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"return",
"[",
"$",
"listener",
",",
"$",
"this",
"->",
"propogateListenerOptions",
"(",
"$",
"listener",
",",
"new",
"CallQueuedListener",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"arguments",
")",
")",
"]",
";",
"}"
] |
Create the listener and job for a queued listener.
@param string $class
@param string $method
@param array $arguments
@return array
|
[
"Create",
"the",
"listener",
"and",
"job",
"for",
"a",
"queued",
"listener",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/Dispatcher.php#L472-L480
|
23,770
|
zhouyl/mellivora
|
Mellivora/Events/Dispatcher.php
|
Dispatcher.propogateListenerOptions
|
protected function propogateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = isset($listener->tries) ? $listener->tries : null;
$job->timeout = isset($listener->timeout) ? $listener->timeout : null;
});
}
|
php
|
protected function propogateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = isset($listener->tries) ? $listener->tries : null;
$job->timeout = isset($listener->timeout) ? $listener->timeout : null;
});
}
|
[
"protected",
"function",
"propogateListenerOptions",
"(",
"$",
"listener",
",",
"$",
"job",
")",
"{",
"return",
"tap",
"(",
"$",
"job",
",",
"function",
"(",
"$",
"job",
")",
"use",
"(",
"$",
"listener",
")",
"{",
"$",
"job",
"->",
"tries",
"=",
"isset",
"(",
"$",
"listener",
"->",
"tries",
")",
"?",
"$",
"listener",
"->",
"tries",
":",
"null",
";",
"$",
"job",
"->",
"timeout",
"=",
"isset",
"(",
"$",
"listener",
"->",
"timeout",
")",
"?",
"$",
"listener",
"->",
"timeout",
":",
"null",
";",
"}",
")",
";",
"}"
] |
Propogate listener options to the job.
@param mixed $listener
@param mixed $job
@return mixed
|
[
"Propogate",
"listener",
"options",
"to",
"the",
"job",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/Dispatcher.php#L490-L496
|
23,771
|
ClementIV/yii-rest-rbac2.0
|
models/User.php
|
User.isAccessTokenValid
|
public static function isAccessTokenValid($token)
{
if (empty($token)) {
return false;
}
$data = Yii::$app->jwt->getValidationData(); // It will use the current time to validate (iat, nbf and exp)
$data->setIssuer(Yii::getAlias("@restIssuer"));
$data->setAudience(Yii::getAlias("@restAudience"));
$data->setId(Yii::getAlias("@restId")+strtotime(date('Y-m-d',time())), true);
if (is_string($token))
$token = Yii::$app->jwt->getParser()->parse($token);
return $token->validate($data);
}
|
php
|
public static function isAccessTokenValid($token)
{
if (empty($token)) {
return false;
}
$data = Yii::$app->jwt->getValidationData(); // It will use the current time to validate (iat, nbf and exp)
$data->setIssuer(Yii::getAlias("@restIssuer"));
$data->setAudience(Yii::getAlias("@restAudience"));
$data->setId(Yii::getAlias("@restId")+strtotime(date('Y-m-d',time())), true);
if (is_string($token))
$token = Yii::$app->jwt->getParser()->parse($token);
return $token->validate($data);
}
|
[
"public",
"static",
"function",
"isAccessTokenValid",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"Yii",
"::",
"$",
"app",
"->",
"jwt",
"->",
"getValidationData",
"(",
")",
";",
"// It will use the current time to validate (iat, nbf and exp)",
"$",
"data",
"->",
"setIssuer",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restIssuer\"",
")",
")",
";",
"$",
"data",
"->",
"setAudience",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restAudience\"",
")",
")",
";",
"$",
"data",
"->",
"setId",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restId\"",
")",
"+",
"strtotime",
"(",
"date",
"(",
"'Y-m-d'",
",",
"time",
"(",
")",
")",
")",
",",
"true",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"token",
")",
")",
"$",
"token",
"=",
"Yii",
"::",
"$",
"app",
"->",
"jwt",
"->",
"getParser",
"(",
")",
"->",
"parse",
"(",
"$",
"token",
")",
";",
"return",
"$",
"token",
"->",
"validate",
"(",
"$",
"data",
")",
";",
"}"
] |
Validates access_token.
@param string $token token to validate
@return bool if token provided is valid for current user
|
[
"Validates",
"access_token",
"."
] |
435ffceca8d51b4d369182db3a06c20f336e9ac4
|
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/models/User.php#L151-L164
|
23,772
|
ClementIV/yii-rest-rbac2.0
|
models/User.php
|
User.generateAccessToken
|
public function generateAccessToken()
{
// $this->access_token = Yii::$app->security->generateRandomString() . '_' . time();
$signer = new Sha256();
$token = Yii::$app->jwt->getBuilder()->setIssuer(Yii::getAlias("@restIssuer"))// Configures the issuer (iss claim)
->setAudience(Yii::getAlias("@restAudience"))// Configures the audience (aud claim)
->setId(Yii::getAlias("@restId")+ strtotime(date('Y-m-d',time())), true)
->setExpiration(time() + Yii::$app->params['accessTokenExpire'])// Configures exp time
->setIssuedAt(time())// Configures the time that the token was issue (iat claim)
->sign($signer, Yii::$app->jwt->key)
->getToken(); // Retrieves the generated token
//$this->auth_key=$this->id;
$this->access_token = (string)$token;
}
|
php
|
public function generateAccessToken()
{
// $this->access_token = Yii::$app->security->generateRandomString() . '_' . time();
$signer = new Sha256();
$token = Yii::$app->jwt->getBuilder()->setIssuer(Yii::getAlias("@restIssuer"))// Configures the issuer (iss claim)
->setAudience(Yii::getAlias("@restAudience"))// Configures the audience (aud claim)
->setId(Yii::getAlias("@restId")+ strtotime(date('Y-m-d',time())), true)
->setExpiration(time() + Yii::$app->params['accessTokenExpire'])// Configures exp time
->setIssuedAt(time())// Configures the time that the token was issue (iat claim)
->sign($signer, Yii::$app->jwt->key)
->getToken(); // Retrieves the generated token
//$this->auth_key=$this->id;
$this->access_token = (string)$token;
}
|
[
"public",
"function",
"generateAccessToken",
"(",
")",
"{",
"// $this->access_token = Yii::$app->security->generateRandomString() . '_' . time();",
"$",
"signer",
"=",
"new",
"Sha256",
"(",
")",
";",
"$",
"token",
"=",
"Yii",
"::",
"$",
"app",
"->",
"jwt",
"->",
"getBuilder",
"(",
")",
"->",
"setIssuer",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restIssuer\"",
")",
")",
"// Configures the issuer (iss claim)",
"->",
"setAudience",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restAudience\"",
")",
")",
"// Configures the audience (aud claim)",
"->",
"setId",
"(",
"Yii",
"::",
"getAlias",
"(",
"\"@restId\"",
")",
"+",
"strtotime",
"(",
"date",
"(",
"'Y-m-d'",
",",
"time",
"(",
")",
")",
")",
",",
"true",
")",
"->",
"setExpiration",
"(",
"time",
"(",
")",
"+",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'accessTokenExpire'",
"]",
")",
"// Configures exp time",
"->",
"setIssuedAt",
"(",
"time",
"(",
")",
")",
"// Configures the time that the token was issue (iat claim)",
"->",
"sign",
"(",
"$",
"signer",
",",
"Yii",
"::",
"$",
"app",
"->",
"jwt",
"->",
"key",
")",
"->",
"getToken",
"(",
")",
";",
"// Retrieves the generated token",
"//$this->auth_key=$this->id;",
"$",
"this",
"->",
"access_token",
"=",
"(",
"string",
")",
"$",
"token",
";",
"}"
] |
Generates new api access token.
|
[
"Generates",
"new",
"api",
"access",
"token",
"."
] |
435ffceca8d51b4d369182db3a06c20f336e9ac4
|
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/models/User.php#L231-L246
|
23,773
|
zicht/z
|
src/Zicht/Tool/Script/Dumper.php
|
Dumper.getAst
|
public function getAst(Node\Node $b, $path = '')
{
$ret = array(
'type' => str_replace('Zicht\Tool\Script\Node\\', '', get_class($b))
);
if ($b instanceof Node\Branch) {
if (count($b->nodes)) {
$ret['nodes'] = array();
foreach ($b->nodes as $n) {
if (null === $n) {
$ret['nodes'][] = $n;
} else {
if (!$n instanceof Node\Node) {
throw new \InvalidArgumentException("Invalid child node in " . Util::toPhp($path));
}
$ret['nodes'][] = $this->getAst($n);
}
}
}
}
return $ret;
}
|
php
|
public function getAst(Node\Node $b, $path = '')
{
$ret = array(
'type' => str_replace('Zicht\Tool\Script\Node\\', '', get_class($b))
);
if ($b instanceof Node\Branch) {
if (count($b->nodes)) {
$ret['nodes'] = array();
foreach ($b->nodes as $n) {
if (null === $n) {
$ret['nodes'][] = $n;
} else {
if (!$n instanceof Node\Node) {
throw new \InvalidArgumentException("Invalid child node in " . Util::toPhp($path));
}
$ret['nodes'][] = $this->getAst($n);
}
}
}
}
return $ret;
}
|
[
"public",
"function",
"getAst",
"(",
"Node",
"\\",
"Node",
"$",
"b",
",",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
"'type'",
"=>",
"str_replace",
"(",
"'Zicht\\Tool\\Script\\Node\\\\'",
",",
"''",
",",
"get_class",
"(",
"$",
"b",
")",
")",
")",
";",
"if",
"(",
"$",
"b",
"instanceof",
"Node",
"\\",
"Branch",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"b",
"->",
"nodes",
")",
")",
"{",
"$",
"ret",
"[",
"'nodes'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"b",
"->",
"nodes",
"as",
"$",
"n",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"n",
")",
"{",
"$",
"ret",
"[",
"'nodes'",
"]",
"[",
"]",
"=",
"$",
"n",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"n",
"instanceof",
"Node",
"\\",
"Node",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid child node in \"",
".",
"Util",
"::",
"toPhp",
"(",
"$",
"path",
")",
")",
";",
"}",
"$",
"ret",
"[",
"'nodes'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getAst",
"(",
"$",
"n",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns the AST for a specified node as an array representation
@param Node\Node $b
@param string $path
@return array
|
[
"Returns",
"the",
"AST",
"for",
"a",
"specified",
"node",
"as",
"an",
"array",
"representation"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Dumper.php#L24-L47
|
23,774
|
Smile-SA/CronBundle
|
Cron/CronAbstract.php
|
CronAbstract.isDue
|
public function isDue()
{
$expression = $this->getExpression();
$cron = CronExpression::factory($expression);
return $cron->isDue();
}
|
php
|
public function isDue()
{
$expression = $this->getExpression();
$cron = CronExpression::factory($expression);
return $cron->isDue();
}
|
[
"public",
"function",
"isDue",
"(",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"getExpression",
"(",
")",
";",
"$",
"cron",
"=",
"CronExpression",
"::",
"factory",
"(",
"$",
"expression",
")",
";",
"return",
"$",
"cron",
"->",
"isDue",
"(",
")",
";",
"}"
] |
Check cron expression
@return bool true if cron should be executed
|
[
"Check",
"cron",
"expression"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Cron/CronAbstract.php#L68-L73
|
23,775
|
Smile-SA/CronBundle
|
Cron/CronAbstract.php
|
CronAbstract.getExpression
|
public function getExpression()
{
$expression = array(
$this->minute,
$this->hour,
$this->dayOfMonth,
$this->month,
$this->dayOfWeek
);
return implode(' ', $expression);
}
|
php
|
public function getExpression()
{
$expression = array(
$this->minute,
$this->hour,
$this->dayOfMonth,
$this->month,
$this->dayOfWeek
);
return implode(' ', $expression);
}
|
[
"public",
"function",
"getExpression",
"(",
")",
"{",
"$",
"expression",
"=",
"array",
"(",
"$",
"this",
"->",
"minute",
",",
"$",
"this",
"->",
"hour",
",",
"$",
"this",
"->",
"dayOfMonth",
",",
"$",
"this",
"->",
"month",
",",
"$",
"this",
"->",
"dayOfWeek",
")",
";",
"return",
"implode",
"(",
"' '",
",",
"$",
"expression",
")",
";",
"}"
] |
Return the cron expression
@return string cron expression
|
[
"Return",
"the",
"cron",
"expression"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Cron/CronAbstract.php#L80-L91
|
23,776
|
Smile-SA/CronBundle
|
Cron/CronAbstract.php
|
CronAbstract.getArgument
|
public function getArgument(InputInterface $input, $key)
{
if ($input->hasArgument($key)) {
return $input->getArgument($key);
}
if (isset($this->arguments[$key])) {
return $this->arguments[$key];
}
return false;
}
|
php
|
public function getArgument(InputInterface $input, $key)
{
if ($input->hasArgument($key)) {
return $input->getArgument($key);
}
if (isset($this->arguments[$key])) {
return $this->arguments[$key];
}
return false;
}
|
[
"public",
"function",
"getArgument",
"(",
"InputInterface",
"$",
"input",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"hasArgument",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"input",
"->",
"getArgument",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arguments",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
] |
Get Cron arguments
@param InputInterface $input Input interface
@param string $key
@return mixed return argument from input or tag settings
|
[
"Get",
"Cron",
"arguments"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Cron/CronAbstract.php#L143-L154
|
23,777
|
zicht/z
|
src/Zicht/Tool/Container/Executor.php
|
Executor.execute
|
public function execute($cmd, &$captureOutput = null)
{
$isInteractive = $this->container->get('INTERACTIVE');
$process = $this->createProcess($isInteractive);
if ($isInteractive) {
$process->setCommandLine(sprintf('/bin/bash -c \'%s\'', $cmd));
} else {
$process->setInput($cmd);
}
if (null !== $captureOutput && false === $isInteractive) {
$process->run(function ($type, $data) use(&$captureOutput) {
$captureOutput .= $data;
});
} else {
$process->run(array($this, 'processCallback'));
}
$ret = $process->getExitCode();
if ($ret != 0) {
if ((int)$ret == Container::ABORT_EXIT_CODE) {
throw new ExecutionAbortedException("Command '$cmd' was aborted");
} else {
throw new \UnexpectedValueException("Command '$cmd' failed with exit code {$ret}");
}
}
return $ret;
}
|
php
|
public function execute($cmd, &$captureOutput = null)
{
$isInteractive = $this->container->get('INTERACTIVE');
$process = $this->createProcess($isInteractive);
if ($isInteractive) {
$process->setCommandLine(sprintf('/bin/bash -c \'%s\'', $cmd));
} else {
$process->setInput($cmd);
}
if (null !== $captureOutput && false === $isInteractive) {
$process->run(function ($type, $data) use(&$captureOutput) {
$captureOutput .= $data;
});
} else {
$process->run(array($this, 'processCallback'));
}
$ret = $process->getExitCode();
if ($ret != 0) {
if ((int)$ret == Container::ABORT_EXIT_CODE) {
throw new ExecutionAbortedException("Command '$cmd' was aborted");
} else {
throw new \UnexpectedValueException("Command '$cmd' failed with exit code {$ret}");
}
}
return $ret;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"cmd",
",",
"&",
"$",
"captureOutput",
"=",
"null",
")",
"{",
"$",
"isInteractive",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'INTERACTIVE'",
")",
";",
"$",
"process",
"=",
"$",
"this",
"->",
"createProcess",
"(",
"$",
"isInteractive",
")",
";",
"if",
"(",
"$",
"isInteractive",
")",
"{",
"$",
"process",
"->",
"setCommandLine",
"(",
"sprintf",
"(",
"'/bin/bash -c \\'%s\\''",
",",
"$",
"cmd",
")",
")",
";",
"}",
"else",
"{",
"$",
"process",
"->",
"setInput",
"(",
"$",
"cmd",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"captureOutput",
"&&",
"false",
"===",
"$",
"isInteractive",
")",
"{",
"$",
"process",
"->",
"run",
"(",
"function",
"(",
"$",
"type",
",",
"$",
"data",
")",
"use",
"(",
"&",
"$",
"captureOutput",
")",
"{",
"$",
"captureOutput",
".=",
"$",
"data",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"process",
"->",
"run",
"(",
"array",
"(",
"$",
"this",
",",
"'processCallback'",
")",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"process",
"->",
"getExitCode",
"(",
")",
";",
"if",
"(",
"$",
"ret",
"!=",
"0",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"ret",
"==",
"Container",
"::",
"ABORT_EXIT_CODE",
")",
"{",
"throw",
"new",
"ExecutionAbortedException",
"(",
"\"Command '$cmd' was aborted\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Command '$cmd' failed with exit code {$ret}\"",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Executes the passed command line in the shell.
@param string $cmd
@param null &$captureOutput
@param string $captureOutput
@return int
@throws ExecutionAbortedException
@throws \UnexpectedValueException
|
[
"Executes",
"the",
"passed",
"command",
"line",
"in",
"the",
"shell",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Executor.php#L38-L67
|
23,778
|
zicht/z
|
src/Zicht/Tool/Container/Executor.php
|
Executor.createProcess
|
protected function createProcess($interactive = false)
{
$process = new Process($this->container->resolve('SHELL'), null, null, null, null, []);
if ($interactive) {
$process->setTty(true);
} else {
if ($this->container->has('TIMEOUT') && $timeout = $this->container->get('TIMEOUT')) {
$process->setTimeout($this->container->get('TIMEOUT'));
}
}
return $process;
}
|
php
|
protected function createProcess($interactive = false)
{
$process = new Process($this->container->resolve('SHELL'), null, null, null, null, []);
if ($interactive) {
$process->setTty(true);
} else {
if ($this->container->has('TIMEOUT') && $timeout = $this->container->get('TIMEOUT')) {
$process->setTimeout($this->container->get('TIMEOUT'));
}
}
return $process;
}
|
[
"protected",
"function",
"createProcess",
"(",
"$",
"interactive",
"=",
"false",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
"->",
"container",
"->",
"resolve",
"(",
"'SHELL'",
")",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"[",
"]",
")",
";",
"if",
"(",
"$",
"interactive",
")",
"{",
"$",
"process",
"->",
"setTty",
"(",
"true",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"'TIMEOUT'",
")",
"&&",
"$",
"timeout",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'TIMEOUT'",
")",
")",
"{",
"$",
"process",
"->",
"setTimeout",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'TIMEOUT'",
")",
")",
";",
"}",
"}",
"return",
"$",
"process",
";",
"}"
] |
Create the process instance to use for non-interactive handling
@var bool $interactive
@return \Symfony\Component\Process\Process
|
[
"Create",
"the",
"process",
"instance",
"to",
"use",
"for",
"non",
"-",
"interactive",
"handling"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Executor.php#L76-L89
|
23,779
|
zicht/z
|
src/Zicht/Tool/Container/Executor.php
|
Executor.processCallback
|
public function processCallback($mode, $data)
{
if (isset($this->container->output)) {
$this->container->output->write($data);
}
}
|
php
|
public function processCallback($mode, $data)
{
if (isset($this->container->output)) {
$this->container->output->write($data);
}
}
|
[
"public",
"function",
"processCallback",
"(",
"$",
"mode",
",",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"container",
"->",
"output",
")",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"output",
"->",
"write",
"(",
"$",
"data",
")",
";",
"}",
"}"
] |
The callback used for the process executed by Process
@param mixed $mode
@param string $data
@return void
|
[
"The",
"callback",
"used",
"for",
"the",
"process",
"executed",
"by",
"Process"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Executor.php#L99-L104
|
23,780
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Scrybe/ServiceProvider.php
|
ServiceProvider.addCommands
|
protected function addCommands(Application $app)
{
$app->command(
new Command\Manual\ToHtmlCommand(null, $app[self::TEMPLATE_FACTORY], $app[self::CONVERTER_FACTORY])
);
// FIXME: Disabled the ToLatex and ToPdf commands for now to prevent confusion of users.
// $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToLatexCommand());
// $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToPdfCommand());
}
|
php
|
protected function addCommands(Application $app)
{
$app->command(
new Command\Manual\ToHtmlCommand(null, $app[self::TEMPLATE_FACTORY], $app[self::CONVERTER_FACTORY])
);
// FIXME: Disabled the ToLatex and ToPdf commands for now to prevent confusion of users.
// $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToLatexCommand());
// $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToPdfCommand());
}
|
[
"protected",
"function",
"addCommands",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"command",
"(",
"new",
"Command",
"\\",
"Manual",
"\\",
"ToHtmlCommand",
"(",
"null",
",",
"$",
"app",
"[",
"self",
"::",
"TEMPLATE_FACTORY",
"]",
",",
"$",
"app",
"[",
"self",
"::",
"CONVERTER_FACTORY",
"]",
")",
")",
";",
"// FIXME: Disabled the ToLatex and ToPdf commands for now to prevent confusion of users.",
"// $this->command(new \\phpDocumentor\\Plugin\\Scrybe\\Command\\Manual\\ToLatexCommand());",
"// $this->command(new \\phpDocumentor\\Plugin\\Scrybe\\Command\\Manual\\ToPdfCommand());",
"}"
] |
Method responsible for adding the commands for this application.
@param Application $app
@return void
|
[
"Method",
"responsible",
"for",
"adding",
"the",
"commands",
"for",
"this",
"application",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/ServiceProvider.php#L83-L92
|
23,781
|
brick/di
|
src/Definition.php
|
Definition.get
|
public function get(Container $container)
{
if ($this->scope === null) {
$this->scope = $this->getDefaultScope();
}
return $this->scope->get($this, $container);
}
|
php
|
public function get(Container $container)
{
if ($this->scope === null) {
$this->scope = $this->getDefaultScope();
}
return $this->scope->get($this, $container);
}
|
[
"public",
"function",
"get",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scope",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"scope",
"=",
"$",
"this",
"->",
"getDefaultScope",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"scope",
"->",
"get",
"(",
"$",
"this",
",",
"$",
"container",
")",
";",
"}"
] |
Resolves the value of this definition, according to the current scope.
This method is for internal use by the Container.
@internal
@param Container $container
@return mixed
|
[
"Resolves",
"the",
"value",
"of",
"this",
"definition",
"according",
"to",
"the",
"current",
"scope",
"."
] |
6ced82ab3623b8f1470317d38cbd2de855e7aa3d
|
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Definition.php#L42-L49
|
23,782
|
bpolaszek/simple-dbal
|
src/Model/Adapter/PDO/PDOAdapter.php
|
PDOAdapter.reconnect
|
private function reconnect()
{
if (0 === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
throw new MaxConnectAttempsException("Connection lost.");
} elseif ($this->reconnectAttempts === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
throw new MaxConnectAttempsException("Max attempts to connect to database has been reached.");
}
if (null === $this->credentials) {
throw new AccessDeniedException("Unable to reconnect: credentials not provided.");
}
try {
if (0 !== $this->reconnectAttempts) {
usleep((int) $this->getOption(self::OPT_USLEEP_AFTER_FIRST_ATTEMPT));
}
$this->cnx = self::createLink($this->getCredentials(), $this->options);
if ($this->isConnected()) {
$this->reconnectAttempts = 0;
} else {
$this->reconnect();
}
} catch (Throwable $e) {
$this->reconnectAttempts++;
}
}
|
php
|
private function reconnect()
{
if (0 === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
throw new MaxConnectAttempsException("Connection lost.");
} elseif ($this->reconnectAttempts === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
throw new MaxConnectAttempsException("Max attempts to connect to database has been reached.");
}
if (null === $this->credentials) {
throw new AccessDeniedException("Unable to reconnect: credentials not provided.");
}
try {
if (0 !== $this->reconnectAttempts) {
usleep((int) $this->getOption(self::OPT_USLEEP_AFTER_FIRST_ATTEMPT));
}
$this->cnx = self::createLink($this->getCredentials(), $this->options);
if ($this->isConnected()) {
$this->reconnectAttempts = 0;
} else {
$this->reconnect();
}
} catch (Throwable $e) {
$this->reconnectAttempts++;
}
}
|
[
"private",
"function",
"reconnect",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPT_MAX_RECONNECT_ATTEMPTS",
")",
")",
"{",
"throw",
"new",
"MaxConnectAttempsException",
"(",
"\"Connection lost.\"",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"reconnectAttempts",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPT_MAX_RECONNECT_ATTEMPTS",
")",
")",
"{",
"throw",
"new",
"MaxConnectAttempsException",
"(",
"\"Max attempts to connect to database has been reached.\"",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"credentials",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
"\"Unable to reconnect: credentials not provided.\"",
")",
";",
"}",
"try",
"{",
"if",
"(",
"0",
"!==",
"$",
"this",
"->",
"reconnectAttempts",
")",
"{",
"usleep",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPT_USLEEP_AFTER_FIRST_ATTEMPT",
")",
")",
";",
"}",
"$",
"this",
"->",
"cnx",
"=",
"self",
"::",
"createLink",
"(",
"$",
"this",
"->",
"getCredentials",
"(",
")",
",",
"$",
"this",
"->",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"reconnectAttempts",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"reconnect",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"reconnectAttempts",
"++",
";",
"}",
"}"
] |
Tries to reconnect to database.
|
[
"Tries",
"to",
"reconnect",
"to",
"database",
"."
] |
52cb50d326ba5854191814b470f5e84950ebb6e6
|
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/PDO/PDOAdapter.php#L101-L126
|
23,783
|
interactivesolutions/honeycomb-core
|
src/models/HCMultiLanguageModel.php
|
HCMultiLanguageModel.translation
|
public function translation()
{
if (is_null($this->translationsClass))
$this->translationsClass = get_class($this) . 'Translations';
return $this->hasOne($this->translationsClass, 'record_id', 'id')->where('language_code', app()->getLocale());
}
|
php
|
public function translation()
{
if (is_null($this->translationsClass))
$this->translationsClass = get_class($this) . 'Translations';
return $this->hasOne($this->translationsClass, 'record_id', 'id')->where('language_code', app()->getLocale());
}
|
[
"public",
"function",
"translation",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"translationsClass",
")",
")",
"$",
"this",
"->",
"translationsClass",
"=",
"get_class",
"(",
"$",
"this",
")",
".",
"'Translations'",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"$",
"this",
"->",
"translationsClass",
",",
"'record_id'",
",",
"'id'",
")",
"->",
"where",
"(",
"'language_code'",
",",
"app",
"(",
")",
"->",
"getLocale",
"(",
")",
")",
";",
"}"
] |
Single translation only
@return \Illuminate\Database\Eloquent\Relations\HasOne
|
[
"Single",
"translation",
"only"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/HCMultiLanguageModel.php#L32-L38
|
23,784
|
interactivesolutions/honeycomb-core
|
src/models/HCMultiLanguageModel.php
|
HCMultiLanguageModel.translatedList
|
public static function translatedList(string $nameKey = "name")
{
return (new static())->with('translations')->get()->map(function ($item, $key) use ($nameKey) {
return [
'id' => $item->id,
'label' => get_translation_name(
$nameKey, app()->getLocale(), array_get($item, 'translations')
),
];
});
}
|
php
|
public static function translatedList(string $nameKey = "name")
{
return (new static())->with('translations')->get()->map(function ($item, $key) use ($nameKey) {
return [
'id' => $item->id,
'label' => get_translation_name(
$nameKey, app()->getLocale(), array_get($item, 'translations')
),
];
});
}
|
[
"public",
"static",
"function",
"translatedList",
"(",
"string",
"$",
"nameKey",
"=",
"\"name\"",
")",
"{",
"return",
"(",
"new",
"static",
"(",
")",
")",
"->",
"with",
"(",
"'translations'",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
",",
"$",
"key",
")",
"use",
"(",
"$",
"nameKey",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"item",
"->",
"id",
",",
"'label'",
"=>",
"get_translation_name",
"(",
"$",
"nameKey",
",",
"app",
"(",
")",
"->",
"getLocale",
"(",
")",
",",
"array_get",
"(",
"$",
"item",
",",
"'translations'",
")",
")",
",",
"]",
";",
"}",
")",
";",
"}"
] |
Get translated id -> value names
@param string $nameKey
@return mixed
|
[
"Get",
"translated",
"id",
"-",
">",
"value",
"names"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/HCMultiLanguageModel.php#L79-L89
|
23,785
|
inhere/php-librarys
|
src/Components/DatabaseClient.php
|
DatabaseClient.insert
|
public function insert(string $from, array $data, array $options = [])
{
if (!$data) {
throw new \RuntimeException('The data inserted into the database cannot be empty');
}
list($statement, $bindings) = $this->compileInsert($from, $data);
if (isset($options['dumpSql'])) {
return [$statement, $bindings];
}
$this->fetchAffected($statement, $bindings);
// 'sequence' For special driver, like PgSQL
return isset($options['sequence']) ? $this->lastInsertId($options['sequence']) : $this->lastInsertId();
}
|
php
|
public function insert(string $from, array $data, array $options = [])
{
if (!$data) {
throw new \RuntimeException('The data inserted into the database cannot be empty');
}
list($statement, $bindings) = $this->compileInsert($from, $data);
if (isset($options['dumpSql'])) {
return [$statement, $bindings];
}
$this->fetchAffected($statement, $bindings);
// 'sequence' For special driver, like PgSQL
return isset($options['sequence']) ? $this->lastInsertId($options['sequence']) : $this->lastInsertId();
}
|
[
"public",
"function",
"insert",
"(",
"string",
"$",
"from",
",",
"array",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The data inserted into the database cannot be empty'",
")",
";",
"}",
"list",
"(",
"$",
"statement",
",",
"$",
"bindings",
")",
"=",
"$",
"this",
"->",
"compileInsert",
"(",
"$",
"from",
",",
"$",
"data",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'dumpSql'",
"]",
")",
")",
"{",
"return",
"[",
"$",
"statement",
",",
"$",
"bindings",
"]",
";",
"}",
"$",
"this",
"->",
"fetchAffected",
"(",
"$",
"statement",
",",
"$",
"bindings",
")",
";",
"// 'sequence' For special driver, like PgSQL",
"return",
"isset",
"(",
"$",
"options",
"[",
"'sequence'",
"]",
")",
"?",
"$",
"this",
"->",
"lastInsertId",
"(",
"$",
"options",
"[",
"'sequence'",
"]",
")",
":",
"$",
"this",
"->",
"lastInsertId",
"(",
")",
";",
"}"
] |
Run a statement for insert a row
@param string $from
@param array $data <column => value>
@param array $options
@return int|array
@throws \RuntimeException
|
[
"Run",
"a",
"statement",
"for",
"insert",
"a",
"row"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/DatabaseClient.php#L378-L394
|
23,786
|
inhere/php-librarys
|
src/Components/DatabaseClient.php
|
DatabaseClient.ping
|
public function ping()
{
try {
$this->connect();
$this->pdo->query('select 1')->fetchColumn();
} catch (\PDOException $e) {
if (strpos($e->getMessage(), 'server has gone away') !== false) {
return false;
}
}
return true;
}
|
php
|
public function ping()
{
try {
$this->connect();
$this->pdo->query('select 1')->fetchColumn();
} catch (\PDOException $e) {
if (strpos($e->getMessage(), 'server has gone away') !== false) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"ping",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"this",
"->",
"pdo",
"->",
"query",
"(",
"'select 1'",
")",
"->",
"fetchColumn",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'server has gone away'",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check whether the connection is available
@return bool
@throws \PDOException
@throws \RuntimeException
|
[
"Check",
"whether",
"the",
"connection",
"is",
"available"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/DatabaseClient.php#L1025-L1037
|
23,787
|
songshenzong/log
|
src/ServiceProvider.php
|
ServiceProvider.isEnabled
|
public function isEnabled()
{
if ($this->enabled === null) {
$environments = config('songshenzong-log.env', ['dev', 'local', 'production']);
$this->enabled = in_array(env('APP_ENV'), $environments, true);
}
return $this->enabled;
}
|
php
|
public function isEnabled()
{
if ($this->enabled === null) {
$environments = config('songshenzong-log.env', ['dev', 'local', 'production']);
$this->enabled = in_array(env('APP_ENV'), $environments, true);
}
return $this->enabled;
}
|
[
"public",
"function",
"isEnabled",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"enabled",
"===",
"null",
")",
"{",
"$",
"environments",
"=",
"config",
"(",
"'songshenzong-log.env'",
",",
"[",
"'dev'",
",",
"'local'",
",",
"'production'",
"]",
")",
";",
"$",
"this",
"->",
"enabled",
"=",
"in_array",
"(",
"env",
"(",
"'APP_ENV'",
")",
",",
"$",
"environments",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"enabled",
";",
"}"
] |
Check if is enabled
@return boolean
|
[
"Check",
"if",
"is",
"enabled"
] |
b1e01f7994da47737866eabf82367490eab17c46
|
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/ServiceProvider.php#L62-L70
|
23,788
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.getProcesses
|
protected function getProcesses()
{
$data = $this->getCommand()->run();
$parser = new TopProcessParser($data);
$parser->parse();
return $parser->getProcesses();
}
|
php
|
protected function getProcesses()
{
$data = $this->getCommand()->run();
$parser = new TopProcessParser($data);
$parser->parse();
return $parser->getProcesses();
}
|
[
"protected",
"function",
"getProcesses",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getCommand",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"parser",
"=",
"new",
"TopProcessParser",
"(",
"$",
"data",
")",
";",
"$",
"parser",
"->",
"parse",
"(",
")",
";",
"return",
"$",
"parser",
"->",
"getProcesses",
"(",
")",
";",
"}"
] |
Return parsed data for processes
|
[
"Return",
"parsed",
"data",
"for",
"processes"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L96-L104
|
23,789
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.aggregateCpu
|
protected function aggregateCpu($processes)
{
$cpus = array();
foreach ($processes as $process) {
if (isset($cpus[$process->getName()])) {
$cpus[$process->getName()] += $process->getCpu();
}
else {
$cpus[$process->getName()] = $process->getCpu();
}
}
return $cpus;
}
|
php
|
protected function aggregateCpu($processes)
{
$cpus = array();
foreach ($processes as $process) {
if (isset($cpus[$process->getName()])) {
$cpus[$process->getName()] += $process->getCpu();
}
else {
$cpus[$process->getName()] = $process->getCpu();
}
}
return $cpus;
}
|
[
"protected",
"function",
"aggregateCpu",
"(",
"$",
"processes",
")",
"{",
"$",
"cpus",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"process",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cpus",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"cpus",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
"+=",
"$",
"process",
"->",
"getCpu",
"(",
")",
";",
"}",
"else",
"{",
"$",
"cpus",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"process",
"->",
"getCpu",
"(",
")",
";",
"}",
"}",
"return",
"$",
"cpus",
";",
"}"
] |
Aggregate CPU for processes with the same name
@param $processes Process[]
|
[
"Aggregate",
"CPU",
"for",
"processes",
"with",
"the",
"same",
"name"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L124-L138
|
23,790
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.aggregateMemory
|
protected function aggregateMemory($processes)
{
$memory = array();
foreach ($processes as $process) {
if (isset($memory[$process->getName()])) {
$memory[$process->getName()] += $process->getMemory();
}
else {
$memory[$process->getName()] = $process->getMemory();
}
}
return $memory;
}
|
php
|
protected function aggregateMemory($processes)
{
$memory = array();
foreach ($processes as $process) {
if (isset($memory[$process->getName()])) {
$memory[$process->getName()] += $process->getMemory();
}
else {
$memory[$process->getName()] = $process->getMemory();
}
}
return $memory;
}
|
[
"protected",
"function",
"aggregateMemory",
"(",
"$",
"processes",
")",
"{",
"$",
"memory",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"process",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"memory",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"memory",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
"+=",
"$",
"process",
"->",
"getMemory",
"(",
")",
";",
"}",
"else",
"{",
"$",
"memory",
"[",
"$",
"process",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"process",
"->",
"getMemory",
"(",
")",
";",
"}",
"}",
"return",
"$",
"memory",
";",
"}"
] |
Aggregate memory for processes with the same name
@param $processes Process[]
@return array
|
[
"Aggregate",
"memory",
"for",
"processes",
"with",
"the",
"same",
"name"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L146-L160
|
23,791
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.persistCollection
|
protected function persistCollection($collection)
{
$cache = new FilesystemAdapter($this->namespace);
$item = $cache->getItem('collection');
$item->set($collection);
$cache->save($item);
}
|
php
|
protected function persistCollection($collection)
{
$cache = new FilesystemAdapter($this->namespace);
$item = $cache->getItem('collection');
$item->set($collection);
$cache->save($item);
}
|
[
"protected",
"function",
"persistCollection",
"(",
"$",
"collection",
")",
"{",
"$",
"cache",
"=",
"new",
"FilesystemAdapter",
"(",
"$",
"this",
"->",
"namespace",
")",
";",
"$",
"item",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"'collection'",
")",
";",
"$",
"item",
"->",
"set",
"(",
"$",
"collection",
")",
";",
"$",
"cache",
"->",
"save",
"(",
"$",
"item",
")",
";",
"}"
] |
Persist collection values to a temporary storage
key is the command string value
@param $collection
|
[
"Persist",
"collection",
"values",
"to",
"a",
"temporary",
"storage",
"key",
"is",
"the",
"command",
"string",
"value"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L178-L184
|
23,792
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.retrieveCollection
|
protected function retrieveCollection()
{
$cache = new FilesystemAdapter($this->namespace);
$item = $cache->getItem('collection');
$collection = null;
if ($item->isHit()) {
$collection = $item->get('collection');
}
if (empty($collection) || !$collection instanceof ValuesCollection) {
$collection = new ValuesCollection();
}
return $collection;
}
|
php
|
protected function retrieveCollection()
{
$cache = new FilesystemAdapter($this->namespace);
$item = $cache->getItem('collection');
$collection = null;
if ($item->isHit()) {
$collection = $item->get('collection');
}
if (empty($collection) || !$collection instanceof ValuesCollection) {
$collection = new ValuesCollection();
}
return $collection;
}
|
[
"protected",
"function",
"retrieveCollection",
"(",
")",
"{",
"$",
"cache",
"=",
"new",
"FilesystemAdapter",
"(",
"$",
"this",
"->",
"namespace",
")",
";",
"$",
"item",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"'collection'",
")",
";",
"$",
"collection",
"=",
"null",
";",
"if",
"(",
"$",
"item",
"->",
"isHit",
"(",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"item",
"->",
"get",
"(",
"'collection'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"collection",
")",
"||",
"!",
"$",
"collection",
"instanceof",
"ValuesCollection",
")",
"{",
"$",
"collection",
"=",
"new",
"ValuesCollection",
"(",
")",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] |
\
Retrieve a new collection of a previous collection
@return mixed|ValuesCollection
|
[
"\\",
"Retrieve",
"a",
"new",
"collection",
"of",
"a",
"previous",
"collection"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L191-L206
|
23,793
|
petrica/php-statsd-system
|
Gauge/ProcessesGauge.php
|
ProcessesGauge.removeEmpty
|
protected function removeEmpty($collection) {
foreach ($collection as $key => $value) {
if (empty($value)) {
unset($collection[$key]);
}
}
return $collection;
}
|
php
|
protected function removeEmpty($collection) {
foreach ($collection as $key => $value) {
if (empty($value)) {
unset($collection[$key]);
}
}
return $collection;
}
|
[
"protected",
"function",
"removeEmpty",
"(",
"$",
"collection",
")",
"{",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"unset",
"(",
"$",
"collection",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Remove empty values from collection
@param $collection
|
[
"Remove",
"empty",
"values",
"from",
"collection"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Gauge/ProcessesGauge.php#L228-L236
|
23,794
|
raideer/twitch-api
|
src/Resources/Teams.php
|
Teams.getTeams
|
public function getTeams($params = [])
{
$defaults = [
'limit' => 25,
'offset' => 0,
];
return $this->wrapper->request('GET', 'teams', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
php
|
public function getTeams($params = [])
{
$defaults = [
'limit' => 25,
'offset' => 0,
];
return $this->wrapper->request('GET', 'teams', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
[
"public",
"function",
"getTeams",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'teams'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] |
Returns a list of active teams.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teams
@param array $params Optiona params
@return array
|
[
"Returns",
"a",
"list",
"of",
"active",
"teams",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Teams.php#L30-L38
|
23,795
|
hametuha/wpametu
|
src/WPametu/UI/Field/Text.php
|
Text.build_input
|
protected function build_input($data, array $fields = [] ){
return parent::build_input($data, $fields).$this->length_helper($data);
}
|
php
|
protected function build_input($data, array $fields = [] ){
return parent::build_input($data, $fields).$this->length_helper($data);
}
|
[
"protected",
"function",
"build_input",
"(",
"$",
"data",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"return",
"parent",
"::",
"build_input",
"(",
"$",
"data",
",",
"$",
"fields",
")",
".",
"$",
"this",
"->",
"length_helper",
"(",
"$",
"data",
")",
";",
"}"
] |
Return input field
@param mixed $data
@param array $fields
@return string
|
[
"Return",
"input",
"field"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Text.php#L46-L48
|
23,796
|
hametuha/wpametu
|
src/WPametu/UI/Field/Text.php
|
Text.length_helper
|
protected function length_helper($data){
if ( ($this->min || $this->max) && $this->length_helper ){
$notice = [];
$class_name = 'ok';
if( $this->min ){
$notice[] = sprintf($this->__('%s chars or more'), number_format($this->min));
if( $this->min > mb_strlen($data, 'utf-8') ){
$class_name = 'ng';
}
}
if( $this->max ){
$notice[] = sprintf($this->__('%s chars or less'), number_format($this->max));
if( $this->max < mb_strlen($data, 'utf-8') ){
$class_name = 'ng';
}
}
return sprintf('<p class="char-counter %s"><i class="dashicons"></i> <strong>%s</strong><span> %s</span><small>%s</small></p>',
$class_name, mb_strlen($data, 'utf-8'), $this->__('Letters'), implode(', ', $notice));
}else{
return '';
}
}
|
php
|
protected function length_helper($data){
if ( ($this->min || $this->max) && $this->length_helper ){
$notice = [];
$class_name = 'ok';
if( $this->min ){
$notice[] = sprintf($this->__('%s chars or more'), number_format($this->min));
if( $this->min > mb_strlen($data, 'utf-8') ){
$class_name = 'ng';
}
}
if( $this->max ){
$notice[] = sprintf($this->__('%s chars or less'), number_format($this->max));
if( $this->max < mb_strlen($data, 'utf-8') ){
$class_name = 'ng';
}
}
return sprintf('<p class="char-counter %s"><i class="dashicons"></i> <strong>%s</strong><span> %s</span><small>%s</small></p>',
$class_name, mb_strlen($data, 'utf-8'), $this->__('Letters'), implode(', ', $notice));
}else{
return '';
}
}
|
[
"protected",
"function",
"length_helper",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"min",
"||",
"$",
"this",
"->",
"max",
")",
"&&",
"$",
"this",
"->",
"length_helper",
")",
"{",
"$",
"notice",
"=",
"[",
"]",
";",
"$",
"class_name",
"=",
"'ok'",
";",
"if",
"(",
"$",
"this",
"->",
"min",
")",
"{",
"$",
"notice",
"[",
"]",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'%s chars or more'",
")",
",",
"number_format",
"(",
"$",
"this",
"->",
"min",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"min",
">",
"mb_strlen",
"(",
"$",
"data",
",",
"'utf-8'",
")",
")",
"{",
"$",
"class_name",
"=",
"'ng'",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"max",
")",
"{",
"$",
"notice",
"[",
"]",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'%s chars or less'",
")",
",",
"number_format",
"(",
"$",
"this",
"->",
"max",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"max",
"<",
"mb_strlen",
"(",
"$",
"data",
",",
"'utf-8'",
")",
")",
"{",
"$",
"class_name",
"=",
"'ng'",
";",
"}",
"}",
"return",
"sprintf",
"(",
"'<p class=\"char-counter %s\"><i class=\"dashicons\"></i> <strong>%s</strong><span> %s</span><small>%s</small></p>'",
",",
"$",
"class_name",
",",
"mb_strlen",
"(",
"$",
"data",
",",
"'utf-8'",
")",
",",
"$",
"this",
"->",
"__",
"(",
"'Letters'",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"notice",
")",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] |
Returns length helper
@param string $data
@return string
|
[
"Returns",
"length",
"helper"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Text.php#L56-L78
|
23,797
|
mr-luke/configuration
|
src/Host.php
|
Host.get
|
public function get(string $key, $default = null)
{
$result = $this->iterateConfig($key);
return is_null($result) ? $default : $result;
}
|
php
|
public function get(string $key, $default = null)
{
$result = $this->iterateConfig($key);
return is_null($result) ? $default : $result;
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"iterateConfig",
"(",
"$",
"key",
")",
";",
"return",
"is_null",
"(",
"$",
"result",
")",
"?",
"$",
"default",
":",
"$",
"result",
";",
"}"
] |
Return given key from array.
@param string $key
@param mixed $default
@return mixed
|
[
"Return",
"given",
"key",
"from",
"array",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Host.php#L43-L48
|
23,798
|
mr-luke/configuration
|
src/Host.php
|
Host.has
|
public function has(string $key): bool
{
$result = $this->iterateConfig($key);
return !($result === null);
}
|
php
|
public function has(string $key): bool
{
$result = $this->iterateConfig($key);
return !($result === null);
}
|
[
"public",
"function",
"has",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"iterateConfig",
"(",
"$",
"key",
")",
";",
"return",
"!",
"(",
"$",
"result",
"===",
"null",
")",
";",
"}"
] |
Return of givent key is present.
@param string $key
@return boolean
|
[
"Return",
"of",
"givent",
"key",
"is",
"present",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Host.php#L56-L61
|
23,799
|
mr-luke/configuration
|
src/Host.php
|
Host.iterateConfig
|
protected function iterateConfig(string $key)
{
$result = $this->config;
foreach (explode('.', $key) as $p) {
if (!isset($result[$p])) {
return null;
}
$result = $result[$p];
}
return $result;
}
|
php
|
protected function iterateConfig(string $key)
{
$result = $this->config;
foreach (explode('.', $key) as $p) {
if (!isset($result[$p])) {
return null;
}
$result = $result[$p];
}
return $result;
}
|
[
"protected",
"function",
"iterateConfig",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"config",
";",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"p",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"result",
"[",
"$",
"p",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Iterate through configuration.
@param string $key
@return mixed
|
[
"Iterate",
"through",
"configuration",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Host.php#L90-L103
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.