id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,700 | MINISTRYGmbH/morrow-core | src/Factory.php | Factory.load | public static function load($instance_identifier) {
$args = func_get_args();
$instance_identifier = array_shift($args);
$factory_args = $args;
// get factory config
$instance_identifier = explode(':', $instance_identifier);
// create a fully namespaced class path
$classname = $instance_identifier[0];
if ($classname{0} != '\\') {
$classname = '\\Morrow\\' . $classname;
}
// set the instancename we need to get possible parameters from prepare
$instancename = (isset($instance_identifier[1])) ? $instance_identifier[1] : '_morrow_default';
// if there were no constructor parameters passed look for prepared parameters
if (count($factory_args) === 0) {
if (isset(self::$_params[$classname][$instancename])) {
$classname = self::$_params[$classname][$instancename]['classname'];
$factory_args = self::$_params[$classname][$instancename]['args'];
} else {
$factory_args = [];
}
}
// if the instance was already instantiated return it, otherwise create it
$instance =& self::$_instances[$classname][$instancename];
if (isset($instance)) {
if ($instance instanceof $classname) return $instance;
else {
throw new \Exception('instance "'.$instancename.'" already defined of class "'.get_class($instance).'"');
return false;
}
}
// create object
if (empty($factory_args)) {
$instance = new $classname;
} else {
// check the parameters for instances of class Factoryproxy
$factory_args = array_map(function($param){
if (!is_object($param) || get_class($param) !== 'Morrow\\Factory') return $param;
return call_user_func_array('\\Morrow\\Factory::load', $param->_getProxyParameters());
}, $factory_args);
// use reflection class to inject the args as single parameters
$ref = new \ReflectionClass($classname);
$instance = $ref->newInstanceArgs($factory_args);
}
// first execute onload callback for all instances, then for the specific instance
if (isset(self::$_onload_callbacks[$classname])) {
foreach (self::$_onload_callbacks[$classname] as $callback) {
call_user_func($callback, $instance);
}
}
if (isset(self::$_onload_callbacks[$classname . ':' . $instancename])) {
foreach (self::$_onload_callbacks[$classname . ':' . $instancename] as $callback) {
call_user_func($callback, $instance);
}
}
return $instance;
} | php | public static function load($instance_identifier) {
$args = func_get_args();
$instance_identifier = array_shift($args);
$factory_args = $args;
// get factory config
$instance_identifier = explode(':', $instance_identifier);
// create a fully namespaced class path
$classname = $instance_identifier[0];
if ($classname{0} != '\\') {
$classname = '\\Morrow\\' . $classname;
}
// set the instancename we need to get possible parameters from prepare
$instancename = (isset($instance_identifier[1])) ? $instance_identifier[1] : '_morrow_default';
// if there were no constructor parameters passed look for prepared parameters
if (count($factory_args) === 0) {
if (isset(self::$_params[$classname][$instancename])) {
$classname = self::$_params[$classname][$instancename]['classname'];
$factory_args = self::$_params[$classname][$instancename]['args'];
} else {
$factory_args = [];
}
}
// if the instance was already instantiated return it, otherwise create it
$instance =& self::$_instances[$classname][$instancename];
if (isset($instance)) {
if ($instance instanceof $classname) return $instance;
else {
throw new \Exception('instance "'.$instancename.'" already defined of class "'.get_class($instance).'"');
return false;
}
}
// create object
if (empty($factory_args)) {
$instance = new $classname;
} else {
// check the parameters for instances of class Factoryproxy
$factory_args = array_map(function($param){
if (!is_object($param) || get_class($param) !== 'Morrow\\Factory') return $param;
return call_user_func_array('\\Morrow\\Factory::load', $param->_getProxyParameters());
}, $factory_args);
// use reflection class to inject the args as single parameters
$ref = new \ReflectionClass($classname);
$instance = $ref->newInstanceArgs($factory_args);
}
// first execute onload callback for all instances, then for the specific instance
if (isset(self::$_onload_callbacks[$classname])) {
foreach (self::$_onload_callbacks[$classname] as $callback) {
call_user_func($callback, $instance);
}
}
if (isset(self::$_onload_callbacks[$classname . ':' . $instancename])) {
foreach (self::$_onload_callbacks[$classname . ':' . $instancename] as $callback) {
call_user_func($callback, $instance);
}
}
return $instance;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"instance_identifier",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"instance_identifier",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"factory_args",
"=",
"$",
"args",
";",
"// get factory config",
"$",
"instance_identifier",
"=",
"explode",
"(",
"':'",
",",
"$",
"instance_identifier",
")",
";",
"// create a fully namespaced class path",
"$",
"classname",
"=",
"$",
"instance_identifier",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"classname",
"{",
"0",
"}",
"!=",
"'\\\\'",
")",
"{",
"$",
"classname",
"=",
"'\\\\Morrow\\\\'",
".",
"$",
"classname",
";",
"}",
"// set the instancename we need to get possible parameters from prepare",
"$",
"instancename",
"=",
"(",
"isset",
"(",
"$",
"instance_identifier",
"[",
"1",
"]",
")",
")",
"?",
"$",
"instance_identifier",
"[",
"1",
"]",
":",
"'_morrow_default'",
";",
"// if there were no constructor parameters passed look for prepared parameters",
"if",
"(",
"count",
"(",
"$",
"factory_args",
")",
"===",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_params",
"[",
"$",
"classname",
"]",
"[",
"$",
"instancename",
"]",
")",
")",
"{",
"$",
"classname",
"=",
"self",
"::",
"$",
"_params",
"[",
"$",
"classname",
"]",
"[",
"$",
"instancename",
"]",
"[",
"'classname'",
"]",
";",
"$",
"factory_args",
"=",
"self",
"::",
"$",
"_params",
"[",
"$",
"classname",
"]",
"[",
"$",
"instancename",
"]",
"[",
"'args'",
"]",
";",
"}",
"else",
"{",
"$",
"factory_args",
"=",
"[",
"]",
";",
"}",
"}",
"// if the instance was already instantiated return it, otherwise create it",
"$",
"instance",
"=",
"&",
"self",
"::",
"$",
"_instances",
"[",
"$",
"classname",
"]",
"[",
"$",
"instancename",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"instance",
")",
")",
"{",
"if",
"(",
"$",
"instance",
"instanceof",
"$",
"classname",
")",
"return",
"$",
"instance",
";",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'instance \"'",
".",
"$",
"instancename",
".",
"'\" already defined of class \"'",
".",
"get_class",
"(",
"$",
"instance",
")",
".",
"'\"'",
")",
";",
"return",
"false",
";",
"}",
"}",
"// create object",
"if",
"(",
"empty",
"(",
"$",
"factory_args",
")",
")",
"{",
"$",
"instance",
"=",
"new",
"$",
"classname",
";",
"}",
"else",
"{",
"// check the parameters for instances of class Factoryproxy",
"$",
"factory_args",
"=",
"array_map",
"(",
"function",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"param",
")",
"||",
"get_class",
"(",
"$",
"param",
")",
"!==",
"'Morrow\\\\Factory'",
")",
"return",
"$",
"param",
";",
"return",
"call_user_func_array",
"(",
"'\\\\Morrow\\\\Factory::load'",
",",
"$",
"param",
"->",
"_getProxyParameters",
"(",
")",
")",
";",
"}",
",",
"$",
"factory_args",
")",
";",
"// use reflection class to inject the args as single parameters",
"$",
"ref",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"classname",
")",
";",
"$",
"instance",
"=",
"$",
"ref",
"->",
"newInstanceArgs",
"(",
"$",
"factory_args",
")",
";",
"}",
"// first execute onload callback for all instances, then for the specific instance",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
"]",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
"]",
"as",
"$",
"callback",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"instance",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
".",
"':'",
".",
"$",
"instancename",
"]",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
".",
"':'",
".",
"$",
"instancename",
"]",
"as",
"$",
"callback",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"instance",
")",
";",
"}",
"}",
"return",
"$",
"instance",
";",
"}"
] | Initializes a class with optionally prepared constructor parameters and returns the instance.
@param string $instance_identifier The instance identifier.
@return object | [
"Initializes",
"a",
"class",
"with",
"optionally",
"prepared",
"constructor",
"parameters",
"and",
"returns",
"the",
"instance",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Factory.php#L239-L306 |
2,701 | MINISTRYGmbH/morrow-core | src/Factory.php | Factory.prepare | public static function prepare($instance_identifier, $parameters = null) {
$args = func_get_args();
// get instance name in params string
$params = explode(':', $instance_identifier);
$classname = $params[0];
// we always have to create a fully namespaced class path
if ($classname{0} !== '\\') {
$classname = '\\Morrow\\' . $classname;
}
// use the instancename or the last part of the classname for saving the args
$instancename = (isset($params[1])) ? $params[1] : '_morrow_default';
// save params for later
self::$_params[$classname][$instancename] = [
'classname' => $classname,
'args' => array_slice($args, 1),
];
} | php | public static function prepare($instance_identifier, $parameters = null) {
$args = func_get_args();
// get instance name in params string
$params = explode(':', $instance_identifier);
$classname = $params[0];
// we always have to create a fully namespaced class path
if ($classname{0} !== '\\') {
$classname = '\\Morrow\\' . $classname;
}
// use the instancename or the last part of the classname for saving the args
$instancename = (isset($params[1])) ? $params[1] : '_morrow_default';
// save params for later
self::$_params[$classname][$instancename] = [
'classname' => $classname,
'args' => array_slice($args, 1),
];
} | [
"public",
"static",
"function",
"prepare",
"(",
"$",
"instance_identifier",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"// get instance name in params string",
"$",
"params",
"=",
"explode",
"(",
"':'",
",",
"$",
"instance_identifier",
")",
";",
"$",
"classname",
"=",
"$",
"params",
"[",
"0",
"]",
";",
"// we always have to create a fully namespaced class path",
"if",
"(",
"$",
"classname",
"{",
"0",
"}",
"!==",
"'\\\\'",
")",
"{",
"$",
"classname",
"=",
"'\\\\Morrow\\\\'",
".",
"$",
"classname",
";",
"}",
"// use the instancename or the last part of the classname for saving the args",
"$",
"instancename",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"1",
"]",
")",
")",
"?",
"$",
"params",
"[",
"1",
"]",
":",
"'_morrow_default'",
";",
"// save params for later",
"self",
"::",
"$",
"_params",
"[",
"$",
"classname",
"]",
"[",
"$",
"instancename",
"]",
"=",
"[",
"'classname'",
"=>",
"$",
"classname",
",",
"'args'",
"=>",
"array_slice",
"(",
"$",
"args",
",",
"1",
")",
",",
"]",
";",
"}"
] | Handles the preparation of class instantiation by deposit the constructor parameters. That allows the lazy loading functionality.
@param string $instance_identifier The instance identifier.
@param mixed $parameters Any number of constructor parameters.
@return null | [
"Handles",
"the",
"preparation",
"of",
"class",
"instantiation",
"by",
"deposit",
"the",
"constructor",
"parameters",
".",
"That",
"allows",
"the",
"lazy",
"loading",
"functionality",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Factory.php#L315-L335 |
2,702 | MINISTRYGmbH/morrow-core | src/Factory.php | Factory.onload | public static function onload($instance_identifier, $callback, $ignore_instancename = false) {
$args = func_get_args();
// get instance name in params string
$params = explode(':', $instance_identifier);
$classname = $params[0];
// we always have to create a fully namespaced class path
if ($classname{0} !== '\\') {
$classname = '\\Morrow\\' . $classname;
}
// use the instancename or the last part of the classname for saving the args
$instancename = (isset($params[1])) ? $params[1] : '_morrow_default';
// save callback
if ($ignore_instancename) {
self::$_onload_callbacks[$classname][] = $callback;
} else {
self::$_onload_callbacks[$classname . ':' . $instancename][] = $callback;
}
} | php | public static function onload($instance_identifier, $callback, $ignore_instancename = false) {
$args = func_get_args();
// get instance name in params string
$params = explode(':', $instance_identifier);
$classname = $params[0];
// we always have to create a fully namespaced class path
if ($classname{0} !== '\\') {
$classname = '\\Morrow\\' . $classname;
}
// use the instancename or the last part of the classname for saving the args
$instancename = (isset($params[1])) ? $params[1] : '_morrow_default';
// save callback
if ($ignore_instancename) {
self::$_onload_callbacks[$classname][] = $callback;
} else {
self::$_onload_callbacks[$classname . ':' . $instancename][] = $callback;
}
} | [
"public",
"static",
"function",
"onload",
"(",
"$",
"instance_identifier",
",",
"$",
"callback",
",",
"$",
"ignore_instancename",
"=",
"false",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"// get instance name in params string",
"$",
"params",
"=",
"explode",
"(",
"':'",
",",
"$",
"instance_identifier",
")",
";",
"$",
"classname",
"=",
"$",
"params",
"[",
"0",
"]",
";",
"// we always have to create a fully namespaced class path",
"if",
"(",
"$",
"classname",
"{",
"0",
"}",
"!==",
"'\\\\'",
")",
"{",
"$",
"classname",
"=",
"'\\\\Morrow\\\\'",
".",
"$",
"classname",
";",
"}",
"// use the instancename or the last part of the classname for saving the args",
"$",
"instancename",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"1",
"]",
")",
")",
"?",
"$",
"params",
"[",
"1",
"]",
":",
"'_morrow_default'",
";",
"// save callback",
"if",
"(",
"$",
"ignore_instancename",
")",
"{",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"_onload_callbacks",
"[",
"$",
"classname",
".",
"':'",
".",
"$",
"instancename",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"}"
] | Registers a callback that is executed when an instance is created.
@param string $instance_identifier The instance identifier.
@param callable $callback A PHP callback.
@param boolean $ignore_instancename Set to true if you want all instances of the class to execute the callback.
@return null | [
"Registers",
"a",
"callback",
"that",
"is",
"executed",
"when",
"an",
"instance",
"is",
"created",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Factory.php#L345-L366 |
2,703 | eix/core | src/php/main/Eix/Services/Net/Socket.php | Socket.open | public function open()
{
// Connect the socket.
if (@!socket_connect($this->socket, $this->host, $this->port)) {
Logger::get()->error(socket_strerror(socket_last_error()));
throw new Exception('Socket connection error: ' . socket_strerror(socket_last_error()));
}
} | php | public function open()
{
// Connect the socket.
if (@!socket_connect($this->socket, $this->host, $this->port)) {
Logger::get()->error(socket_strerror(socket_last_error()));
throw new Exception('Socket connection error: ' . socket_strerror(socket_last_error()));
}
} | [
"public",
"function",
"open",
"(",
")",
"{",
"// Connect the socket.",
"if",
"(",
"@",
"!",
"socket_connect",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"this",
"->",
"host",
",",
"$",
"this",
"->",
"port",
")",
")",
"{",
"Logger",
"::",
"get",
"(",
")",
"->",
"error",
"(",
"socket_strerror",
"(",
"socket_last_error",
"(",
")",
")",
")",
";",
"throw",
"new",
"Exception",
"(",
"'Socket connection error: '",
".",
"socket_strerror",
"(",
"socket_last_error",
"(",
")",
")",
")",
";",
"}",
"}"
] | Open the connection to the socket. | [
"Open",
"the",
"connection",
"to",
"the",
"socket",
"."
] | a5b4c09cc168221e85804fdfeb78e519a0415466 | https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Net/Socket.php#L65-L72 |
2,704 | nodes-php/core | src/Exceptions/Exception.php | Exception.setStatusCode | public function setStatusCode($statusCode, $message = null)
{
$this->statusCode = (int) $statusCode;
// Add status message to meta array
$this->addMeta(['status' => ['code' => (int) $statusCode]]);
// Set optional status message if present
if (!empty($message)) {
$this->setStatusMessage($message);
}
return $this;
} | php | public function setStatusCode($statusCode, $message = null)
{
$this->statusCode = (int) $statusCode;
// Add status message to meta array
$this->addMeta(['status' => ['code' => (int) $statusCode]]);
// Set optional status message if present
if (!empty($message)) {
$this->setStatusMessage($message);
}
return $this;
} | [
"public",
"function",
"setStatusCode",
"(",
"$",
"statusCode",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"statusCode",
"=",
"(",
"int",
")",
"$",
"statusCode",
";",
"// Add status message to meta array",
"$",
"this",
"->",
"addMeta",
"(",
"[",
"'status'",
"=>",
"[",
"'code'",
"=>",
"(",
"int",
")",
"$",
"statusCode",
"]",
"]",
")",
";",
"// Set optional status message if present",
"if",
"(",
"!",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"$",
"this",
"->",
"setStatusMessage",
"(",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set status code.
@author Morten Rugaard <[email protected]>
@param int $statusCode
@param string $message
@return $this | [
"Set",
"status",
"code",
"."
] | fc788bb3e9668872573838099f868ab162eb8a96 | https://github.com/nodes-php/core/blob/fc788bb3e9668872573838099f868ab162eb8a96/src/Exceptions/Exception.php#L236-L249 |
2,705 | nodes-php/core | src/Exceptions/Exception.php | Exception.setErrors | public function setErrors(MessageBag $errors)
{
$this->errors = $errors;
// Add status message to meta array
if (!$errors->isEmpty()) {
$this->addMeta(['errors' => $errors->all()]);
}
return $this;
} | php | public function setErrors(MessageBag $errors)
{
$this->errors = $errors;
// Add status message to meta array
if (!$errors->isEmpty()) {
$this->addMeta(['errors' => $errors->all()]);
}
return $this;
} | [
"public",
"function",
"setErrors",
"(",
"MessageBag",
"$",
"errors",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"$",
"errors",
";",
"// Add status message to meta array",
"if",
"(",
"!",
"$",
"errors",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addMeta",
"(",
"[",
"'errors'",
"=>",
"$",
"errors",
"->",
"all",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set a message bag of errors.
@author Morten Rugaard <[email protected]>
@param \Illuminate\Support\MessageBag $errors
@return $this | [
"Set",
"a",
"message",
"bag",
"of",
"errors",
"."
] | fc788bb3e9668872573838099f868ab162eb8a96 | https://github.com/nodes-php/core/blob/fc788bb3e9668872573838099f868ab162eb8a96/src/Exceptions/Exception.php#L502-L512 |
2,706 | jivoo/core | src/Store/Config.php | Config.reload | public function reload()
{
if ($this->root !== $this) {
$this->root->reload();
return;
}
if (! isset($this->store)) {
return;
}
if (! $this->store->touch()) {
return;
}
try {
$this->store->open(false);
$this->data = $this->store->read();
} catch (AccessException $e) {
throw new AccessException('Could not read configration: ' . $e->getMessage(), null, $e);
}
$this->store->close();
} | php | public function reload()
{
if ($this->root !== $this) {
$this->root->reload();
return;
}
if (! isset($this->store)) {
return;
}
if (! $this->store->touch()) {
return;
}
try {
$this->store->open(false);
$this->data = $this->store->read();
} catch (AccessException $e) {
throw new AccessException('Could not read configration: ' . $e->getMessage(), null, $e);
}
$this->store->close();
} | [
"public",
"function",
"reload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
"!==",
"$",
"this",
")",
"{",
"$",
"this",
"->",
"root",
"->",
"reload",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"store",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"store",
"->",
"touch",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"store",
"->",
"open",
"(",
"false",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"store",
"->",
"read",
"(",
")",
";",
"}",
"catch",
"(",
"AccessException",
"$",
"e",
")",
"{",
"throw",
"new",
"AccessException",
"(",
"'Could not read configration: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"store",
"->",
"close",
"(",
")",
";",
"}"
] | Reload configuration document from store.
@throws AccessException If file could not be read. | [
"Reload",
"configuration",
"document",
"from",
"store",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Store/Config.php#L51-L70 |
2,707 | jivoo/core | src/Store/Config.php | Config.save | public function save()
{
if ($this->root !== $this) {
return $this->root->save();
}
if (! isset($this->store)) {
return false;
}
if (! $this->updated) {
return true;
}
$this->store->open(true);
$this->store->write($this->data);
$this->store->close();
$this->updated = false;
return true;
} | php | public function save()
{
if ($this->root !== $this) {
return $this->root->save();
}
if (! isset($this->store)) {
return false;
}
if (! $this->updated) {
return true;
}
$this->store->open(true);
$this->store->write($this->data);
$this->store->close();
$this->updated = false;
return true;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
"!==",
"$",
"this",
")",
"{",
"return",
"$",
"this",
"->",
"root",
"->",
"save",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"store",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"updated",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"store",
"->",
"open",
"(",
"true",
")",
";",
"$",
"this",
"->",
"store",
"->",
"write",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"store",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"updated",
"=",
"false",
";",
"return",
"true",
";",
"}"
] | Save configuration.
If this is not the root configuration, the root configuration will be
saved instead.
@return boolean True if the configuration was saved. | [
"Save",
"configuration",
".",
"If",
"this",
"is",
"not",
"the",
"root",
"configuration",
"the",
"root",
"configuration",
"will",
"be",
"saved",
"instead",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Store/Config.php#L79-L95 |
2,708 | BudgeIt/composer-builder | src/BuildTools/Grunt.php | Grunt.build | public function build(PackageWrapper $package, $isDev)
{
$this->execute('grunt', [], $this->io, $package->getPath());
} | php | public function build(PackageWrapper $package, $isDev)
{
$this->execute('grunt', [], $this->io, $package->getPath());
} | [
"public",
"function",
"build",
"(",
"PackageWrapper",
"$",
"package",
",",
"$",
"isDev",
")",
"{",
"$",
"this",
"->",
"execute",
"(",
"'grunt'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"io",
",",
"$",
"package",
"->",
"getPath",
"(",
")",
")",
";",
"}"
] | Run this build tool for this package
@param PackageWrapper $package
@param bool $isDev | [
"Run",
"this",
"build",
"tool",
"for",
"this",
"package"
] | ce39fdd501425cf87ec8b20d1db2700c77ee2563 | https://github.com/BudgeIt/composer-builder/blob/ce39fdd501425cf87ec8b20d1db2700c77ee2563/src/BuildTools/Grunt.php#L48-L51 |
2,709 | ironedgesoftware/graphs | src/Node/Node.php | Node.setId | public function setId(string $id): NodeInterface
{
$this->_id = $id;
if ($this->_name === null) {
$this->setName($id);
}
return $this;
} | php | public function setId(string $id): NodeInterface
{
$this->_id = $id;
if ($this->_name === null) {
$this->setName($id);
}
return $this;
} | [
"public",
"function",
"setId",
"(",
"string",
"$",
"id",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"_id",
"=",
"$",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"_name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the value of field id.
@param string $id - id.
@return NodeInterface | [
"Sets",
"the",
"value",
"of",
"field",
"id",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L121-L130 |
2,710 | ironedgesoftware/graphs | src/Node/Node.php | Node.getMetadata | public function getMetadata(): Data
{
if ($this->_metadata === null) {
$this->_metadata = new Data();
$this->setMetadata([]);
}
return $this->_metadata;
} | php | public function getMetadata(): Data
{
if ($this->_metadata === null) {
$this->_metadata = new Data();
$this->setMetadata([]);
}
return $this->_metadata;
} | [
"public",
"function",
"getMetadata",
"(",
")",
":",
"Data",
"{",
"if",
"(",
"$",
"this",
"->",
"_metadata",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_metadata",
"=",
"new",
"Data",
"(",
")",
";",
"$",
"this",
"->",
"setMetadata",
"(",
"[",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_metadata",
";",
"}"
] | Returns the value of field _metadata.
@return Data | [
"Returns",
"the",
"value",
"of",
"field",
"_metadata",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L185-L194 |
2,711 | ironedgesoftware/graphs | src/Node/Node.php | Node.setMetadata | public function setMetadata(array $metadata)
{
$this->getMetadata()->setData(
array_replace_recursive(
$this->getDefaultMetadata(),
$metadata
)
);
return $this;
} | php | public function setMetadata(array $metadata)
{
$this->getMetadata()->setData(
array_replace_recursive(
$this->getDefaultMetadata(),
$metadata
)
);
return $this;
} | [
"public",
"function",
"setMetadata",
"(",
"array",
"$",
"metadata",
")",
"{",
"$",
"this",
"->",
"getMetadata",
"(",
")",
"->",
"setData",
"(",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"getDefaultMetadata",
"(",
")",
",",
"$",
"metadata",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the value of field metadata.
@param array $metadata - metadata.
@return NodeInterface | [
"Sets",
"the",
"value",
"of",
"field",
"metadata",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L203-L213 |
2,712 | ironedgesoftware/graphs | src/Node/Node.php | Node.setMetadataAttr | public function setMetadataAttr(string $attr, $value, array $options = [])
{
$this->getMetadata()->set($attr, $value, $options);
return $this;
} | php | public function setMetadataAttr(string $attr, $value, array $options = [])
{
$this->getMetadata()->set($attr, $value, $options);
return $this;
} | [
"public",
"function",
"setMetadataAttr",
"(",
"string",
"$",
"attr",
",",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getMetadata",
"(",
")",
"->",
"set",
"(",
"$",
"attr",
",",
"$",
"value",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a metadata attribute.
@param string $attr - Attribute.
@param mixed $value - Value.
@param array $options - Options.
@return $this | [
"Sets",
"a",
"metadata",
"attribute",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L236-L241 |
2,713 | ironedgesoftware/graphs | src/Node/Node.php | Node.getMetadataAttr | public function getMetadataAttr(string $attr, $defaultValue = null, array $options = [])
{
return $this->getMetadata()->get($attr, $defaultValue, $options);
} | php | public function getMetadataAttr(string $attr, $defaultValue = null, array $options = [])
{
return $this->getMetadata()->get($attr, $defaultValue, $options);
} | [
"public",
"function",
"getMetadataAttr",
"(",
"string",
"$",
"attr",
",",
"$",
"defaultValue",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getMetadata",
"(",
")",
"->",
"get",
"(",
"$",
"attr",
",",
"$",
"defaultValue",
",",
"$",
"options",
")",
";",
"}"
] | Returns a metadata attribute.
@param string $attr - Attribute.
@param mixed $defaultValue - Default value.
@param array $options - Options.
@return mixed | [
"Returns",
"a",
"metadata",
"attribute",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L252-L255 |
2,714 | ironedgesoftware/graphs | src/Node/Node.php | Node.findParents | public function findParents(array $filters = [], array $options = [])
{
$options = array_replace(
[
'returnFirstResult' => false,
'indexById' => false
],
$options
);
$parents = $this->getAllParents($options);
if ($parents && $filters) {
$result = [];
/** @var NodeInterface $parent */
foreach ($parents as $i => $parent) {
foreach ($filters as $f => $v) {
$method = 'get' . ucfirst($f);
if (!method_exists($parent, $method) || $parent->$method() !== $v) {
continue 2;
}
}
if ($options['indexById']) {
$result[$i] = $parent;
} else {
$result[] = $parent;
}
}
} else {
$result = $parents;
}
return $options['returnFirstResult'] && $result ?
array_values($result)[0] :
$result;
} | php | public function findParents(array $filters = [], array $options = [])
{
$options = array_replace(
[
'returnFirstResult' => false,
'indexById' => false
],
$options
);
$parents = $this->getAllParents($options);
if ($parents && $filters) {
$result = [];
/** @var NodeInterface $parent */
foreach ($parents as $i => $parent) {
foreach ($filters as $f => $v) {
$method = 'get' . ucfirst($f);
if (!method_exists($parent, $method) || $parent->$method() !== $v) {
continue 2;
}
}
if ($options['indexById']) {
$result[$i] = $parent;
} else {
$result[] = $parent;
}
}
} else {
$result = $parents;
}
return $options['returnFirstResult'] && $result ?
array_values($result)[0] :
$result;
} | [
"public",
"function",
"findParents",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_replace",
"(",
"[",
"'returnFirstResult'",
"=>",
"false",
",",
"'indexById'",
"=>",
"false",
"]",
",",
"$",
"options",
")",
";",
"$",
"parents",
"=",
"$",
"this",
"->",
"getAllParents",
"(",
"$",
"options",
")",
";",
"if",
"(",
"$",
"parents",
"&&",
"$",
"filters",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var NodeInterface $parent */",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"i",
"=>",
"$",
"parent",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"f",
"=>",
"$",
"v",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"f",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"parent",
",",
"$",
"method",
")",
"||",
"$",
"parent",
"->",
"$",
"method",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"continue",
"2",
";",
"}",
"}",
"if",
"(",
"$",
"options",
"[",
"'indexById'",
"]",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"parent",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"parent",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"parents",
";",
"}",
"return",
"$",
"options",
"[",
"'returnFirstResult'",
"]",
"&&",
"$",
"result",
"?",
"array_values",
"(",
"$",
"result",
")",
"[",
"0",
"]",
":",
"$",
"result",
";",
"}"
] | Finds parent nodes all the way up until we reach the root node.
@param array $filters - Filters.
@param array $options - Options.
@return array|NodeInterface | [
"Finds",
"parent",
"nodes",
"all",
"the",
"way",
"up",
"until",
"we",
"reach",
"the",
"root",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L277-L314 |
2,715 | ironedgesoftware/graphs | src/Node/Node.php | Node.getAllParents | public function getAllParents(array $options = []): array
{
$options = array_replace(
[
'indexById' => false,
'skipIds' => []
],
$options
);
$parents = [];
$ids = [$this->getId()];
/** @var NodeInterface $parent */
foreach ($this->getParents() as $id => $parent) {
if (in_array($id, $options['skipIds'])) {
continue;
}
$ids[] = $id;
if ($options['indexById']) {
$parents[$id] = $parent;
} else {
$parents[] = $parent;
}
$parents = array_merge(
$parents,
$parent->getAllParents(array_merge($options, ['skipIds' => $ids]))
);
}
return $parents;
} | php | public function getAllParents(array $options = []): array
{
$options = array_replace(
[
'indexById' => false,
'skipIds' => []
],
$options
);
$parents = [];
$ids = [$this->getId()];
/** @var NodeInterface $parent */
foreach ($this->getParents() as $id => $parent) {
if (in_array($id, $options['skipIds'])) {
continue;
}
$ids[] = $id;
if ($options['indexById']) {
$parents[$id] = $parent;
} else {
$parents[] = $parent;
}
$parents = array_merge(
$parents,
$parent->getAllParents(array_merge($options, ['skipIds' => $ids]))
);
}
return $parents;
} | [
"public",
"function",
"getAllParents",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"options",
"=",
"array_replace",
"(",
"[",
"'indexById'",
"=>",
"false",
",",
"'skipIds'",
"=>",
"[",
"]",
"]",
",",
"$",
"options",
")",
";",
"$",
"parents",
"=",
"[",
"]",
";",
"$",
"ids",
"=",
"[",
"$",
"this",
"->",
"getId",
"(",
")",
"]",
";",
"/** @var NodeInterface $parent */",
"foreach",
"(",
"$",
"this",
"->",
"getParents",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"parent",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"options",
"[",
"'skipIds'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"ids",
"[",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"$",
"options",
"[",
"'indexById'",
"]",
")",
"{",
"$",
"parents",
"[",
"$",
"id",
"]",
"=",
"$",
"parent",
";",
"}",
"else",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"parent",
";",
"}",
"$",
"parents",
"=",
"array_merge",
"(",
"$",
"parents",
",",
"$",
"parent",
"->",
"getAllParents",
"(",
"array_merge",
"(",
"$",
"options",
",",
"[",
"'skipIds'",
"=>",
"$",
"ids",
"]",
")",
")",
")",
";",
"}",
"return",
"$",
"parents",
";",
"}"
] | Returns all parents from this node.
@param array $options - Options.
@return array | [
"Returns",
"all",
"parents",
"from",
"this",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L323-L356 |
2,716 | ironedgesoftware/graphs | src/Node/Node.php | Node.getParent | public function getParent(string $id = null)
{
if (!$this->_parents || ($id !== null && !isset($this->_parents[$id]))) {
return null;
}
return $id !== null ?
$this->_parents[$id] :
$this->_parents[array_rand($this->_parents)];
} | php | public function getParent(string $id = null)
{
if (!$this->_parents || ($id !== null && !isset($this->_parents[$id]))) {
return null;
}
return $id !== null ?
$this->_parents[$id] :
$this->_parents[array_rand($this->_parents)];
} | [
"public",
"function",
"getParent",
"(",
"string",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_parents",
"||",
"(",
"$",
"id",
"!==",
"null",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"_parents",
"[",
"$",
"id",
"]",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"id",
"!==",
"null",
"?",
"$",
"this",
"->",
"_parents",
"[",
"$",
"id",
"]",
":",
"$",
"this",
"->",
"_parents",
"[",
"array_rand",
"(",
"$",
"this",
"->",
"_parents",
")",
"]",
";",
"}"
] | Returns the value of field _parent.
@param string|null $id - Parent ID.
@return NodeInterface|null | [
"Returns",
"the",
"value",
"of",
"field",
"_parent",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L380-L389 |
2,717 | ironedgesoftware/graphs | src/Node/Node.php | Node.addParent | public function addParent(NodeInterface $parent, bool $setParentsChild = true): NodeInterface
{
if (!$this->supportsParent($parent)) {
throw ParentTypeNotSupportedException::create($this, $parent);
}
$this->_parents[$parent->getId()] = $parent;
if ($setParentsChild) {
$parent->addChild($this, false);
}
$this->notifySubscribers(
self::EVENT_ADD_PARENT,
['oldParents' => $this->_parents, 'newParent' => $parent, 'child' => $this]
);
return $this;
} | php | public function addParent(NodeInterface $parent, bool $setParentsChild = true): NodeInterface
{
if (!$this->supportsParent($parent)) {
throw ParentTypeNotSupportedException::create($this, $parent);
}
$this->_parents[$parent->getId()] = $parent;
if ($setParentsChild) {
$parent->addChild($this, false);
}
$this->notifySubscribers(
self::EVENT_ADD_PARENT,
['oldParents' => $this->_parents, 'newParent' => $parent, 'child' => $this]
);
return $this;
} | [
"public",
"function",
"addParent",
"(",
"NodeInterface",
"$",
"parent",
",",
"bool",
"$",
"setParentsChild",
"=",
"true",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supportsParent",
"(",
"$",
"parent",
")",
")",
"{",
"throw",
"ParentTypeNotSupportedException",
"::",
"create",
"(",
"$",
"this",
",",
"$",
"parent",
")",
";",
"}",
"$",
"this",
"->",
"_parents",
"[",
"$",
"parent",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"parent",
";",
"if",
"(",
"$",
"setParentsChild",
")",
"{",
"$",
"parent",
"->",
"addChild",
"(",
"$",
"this",
",",
"false",
")",
";",
"}",
"$",
"this",
"->",
"notifySubscribers",
"(",
"self",
"::",
"EVENT_ADD_PARENT",
",",
"[",
"'oldParents'",
"=>",
"$",
"this",
"->",
"_parents",
",",
"'newParent'",
"=>",
"$",
"parent",
",",
"'child'",
"=>",
"$",
"this",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the value of field parent.
@param NodeInterface $parent - Parent.
@param bool $setParentsChild - Set parent's child.
@throws ParentTypeNotSupportedException
@return NodeInterface | [
"Sets",
"the",
"value",
"of",
"field",
"parent",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L411-L429 |
2,718 | ironedgesoftware/graphs | src/Node/Node.php | Node.removeParent | public function removeParent(string $parentId, bool $setParentsChild = true): NodeInterface
{
if (isset($this->_parents[$parentId])) {
$parent = $this->getParent($parentId);
$this->notifySubscribers(
self::EVENT_REMOVE_PARENT,
['oldParents' => $this->_parents, 'parentToRemove' => $parent, 'child' => $this]
);
if ($setParentsChild) {
$parent->removeChild($this->getId(), false);
}
unset($this->_parents[$parentId]);
}
return $this;
} | php | public function removeParent(string $parentId, bool $setParentsChild = true): NodeInterface
{
if (isset($this->_parents[$parentId])) {
$parent = $this->getParent($parentId);
$this->notifySubscribers(
self::EVENT_REMOVE_PARENT,
['oldParents' => $this->_parents, 'parentToRemove' => $parent, 'child' => $this]
);
if ($setParentsChild) {
$parent->removeChild($this->getId(), false);
}
unset($this->_parents[$parentId]);
}
return $this;
} | [
"public",
"function",
"removeParent",
"(",
"string",
"$",
"parentId",
",",
"bool",
"$",
"setParentsChild",
"=",
"true",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_parents",
"[",
"$",
"parentId",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
"$",
"parentId",
")",
";",
"$",
"this",
"->",
"notifySubscribers",
"(",
"self",
"::",
"EVENT_REMOVE_PARENT",
",",
"[",
"'oldParents'",
"=>",
"$",
"this",
"->",
"_parents",
",",
"'parentToRemove'",
"=>",
"$",
"parent",
",",
"'child'",
"=>",
"$",
"this",
"]",
")",
";",
"if",
"(",
"$",
"setParentsChild",
")",
"{",
"$",
"parent",
"->",
"removeChild",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"false",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"_parents",
"[",
"$",
"parentId",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a parent from this node.
@param string $parentId - Parent.
@param bool $setParentsChild - Set parent's child.
@return NodeInterface | [
"Removes",
"a",
"parent",
"from",
"this",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L439-L457 |
2,719 | ironedgesoftware/graphs | src/Node/Node.php | Node.clearParents | public function clearParents(): NodeInterface
{
/** @var NodeInterface $parent */
foreach ($this->getParents() as $parent) {
$this->removeParent($parent->getId());
}
return $this;
} | php | public function clearParents(): NodeInterface
{
/** @var NodeInterface $parent */
foreach ($this->getParents() as $parent) {
$this->removeParent($parent->getId());
}
return $this;
} | [
"public",
"function",
"clearParents",
"(",
")",
":",
"NodeInterface",
"{",
"/** @var NodeInterface $parent */",
"foreach",
"(",
"$",
"this",
"->",
"getParents",
"(",
")",
"as",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"removeParent",
"(",
"$",
"parent",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Clears all parents of this node.
@return NodeInterface | [
"Clears",
"all",
"parents",
"of",
"this",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L464-L472 |
2,720 | ironedgesoftware/graphs | src/Node/Node.php | Node.setChildren | public function setChildren(array $children): NodeInterface
{
foreach ($this->getChildren() as $node) {
$this->removeChild($node->getId());
}
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
} | php | public function setChildren(array $children): NodeInterface
{
foreach ($this->getChildren() as $node) {
$this->removeChild($node->getId());
}
foreach ($children as $child) {
$this->addChild($child);
}
return $this;
} | [
"public",
"function",
"setChildren",
"(",
"array",
"$",
"children",
")",
":",
"NodeInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
"as",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"removeChild",
"(",
"$",
"node",
"->",
"getId",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"addChild",
"(",
"$",
"child",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the value of field children.
@param array $children - children.
@return NodeInterface | [
"Sets",
"the",
"value",
"of",
"field",
"children",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L493-L504 |
2,721 | ironedgesoftware/graphs | src/Node/Node.php | Node.addChild | public function addChild(NodeInterface $child, bool $setParent = true): NodeInterface
{
if (!$this->supportsChild($child)) {
throw ChildTypeNotSupportedException::create($this, $child);
}
$this->_children[$child->getId()] = $child;
if ($setParent) {
$child->addParent($this, false);
}
/** @var NodeInterface $parent */
foreach ($this->getAllParentsAndCurrentNode() as $parent) {
$child->addSubscriber($parent);
}
$this->notifySubscribers(
self::EVENT_ADD_CHILD,
['parent' => $this, 'child' => $child]
);
return $this;
} | php | public function addChild(NodeInterface $child, bool $setParent = true): NodeInterface
{
if (!$this->supportsChild($child)) {
throw ChildTypeNotSupportedException::create($this, $child);
}
$this->_children[$child->getId()] = $child;
if ($setParent) {
$child->addParent($this, false);
}
/** @var NodeInterface $parent */
foreach ($this->getAllParentsAndCurrentNode() as $parent) {
$child->addSubscriber($parent);
}
$this->notifySubscribers(
self::EVENT_ADD_CHILD,
['parent' => $this, 'child' => $child]
);
return $this;
} | [
"public",
"function",
"addChild",
"(",
"NodeInterface",
"$",
"child",
",",
"bool",
"$",
"setParent",
"=",
"true",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supportsChild",
"(",
"$",
"child",
")",
")",
"{",
"throw",
"ChildTypeNotSupportedException",
"::",
"create",
"(",
"$",
"this",
",",
"$",
"child",
")",
";",
"}",
"$",
"this",
"->",
"_children",
"[",
"$",
"child",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"child",
";",
"if",
"(",
"$",
"setParent",
")",
"{",
"$",
"child",
"->",
"addParent",
"(",
"$",
"this",
",",
"false",
")",
";",
"}",
"/** @var NodeInterface $parent */",
"foreach",
"(",
"$",
"this",
"->",
"getAllParentsAndCurrentNode",
"(",
")",
"as",
"$",
"parent",
")",
"{",
"$",
"child",
"->",
"addSubscriber",
"(",
"$",
"parent",
")",
";",
"}",
"$",
"this",
"->",
"notifySubscribers",
"(",
"self",
"::",
"EVENT_ADD_CHILD",
",",
"[",
"'parent'",
"=>",
"$",
"this",
",",
"'child'",
"=>",
"$",
"child",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a child to this node.
@param NodeInterface $child - Child.
@param bool $setChildParent - Set child's parent.
@throws ChildTypeNotSupportedException
@return NodeInterface | [
"Adds",
"a",
"child",
"to",
"this",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L516-L539 |
2,722 | ironedgesoftware/graphs | src/Node/Node.php | Node.removeChild | public function removeChild(string $childId, bool $setParent = true): NodeInterface
{
if ($this->hasChild($childId)) {
$child = $this->getChild($childId);
if ($setParent) {
$child->removeParent($this->getId(), false);
}
unset($this->_children[$childId]);
$this->notifySubscribers(
self::EVENT_REMOVE_CHILD,
['parent' => $this, 'child' => $child]
);
/** @var NodeInterface $parent */
foreach ($this->getAllParents() as $parent) {
$child->removeSubscriber($parent->getId());
}
}
return $this;
} | php | public function removeChild(string $childId, bool $setParent = true): NodeInterface
{
if ($this->hasChild($childId)) {
$child = $this->getChild($childId);
if ($setParent) {
$child->removeParent($this->getId(), false);
}
unset($this->_children[$childId]);
$this->notifySubscribers(
self::EVENT_REMOVE_CHILD,
['parent' => $this, 'child' => $child]
);
/** @var NodeInterface $parent */
foreach ($this->getAllParents() as $parent) {
$child->removeSubscriber($parent->getId());
}
}
return $this;
} | [
"public",
"function",
"removeChild",
"(",
"string",
"$",
"childId",
",",
"bool",
"$",
"setParent",
"=",
"true",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"hasChild",
"(",
"$",
"childId",
")",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"getChild",
"(",
"$",
"childId",
")",
";",
"if",
"(",
"$",
"setParent",
")",
"{",
"$",
"child",
"->",
"removeParent",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"false",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"_children",
"[",
"$",
"childId",
"]",
")",
";",
"$",
"this",
"->",
"notifySubscribers",
"(",
"self",
"::",
"EVENT_REMOVE_CHILD",
",",
"[",
"'parent'",
"=>",
"$",
"this",
",",
"'child'",
"=>",
"$",
"child",
"]",
")",
";",
"/** @var NodeInterface $parent */",
"foreach",
"(",
"$",
"this",
"->",
"getAllParents",
"(",
")",
"as",
"$",
"parent",
")",
"{",
"$",
"child",
"->",
"removeSubscriber",
"(",
"$",
"parent",
"->",
"getId",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a child.
@param string $childId - Child ID.
@param bool $setParent - Set parent?
@return NodeInterface | [
"Removes",
"a",
"child",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L549-L572 |
2,723 | ironedgesoftware/graphs | src/Node/Node.php | Node.getChild | public function getChild(string $id): NodeInterface
{
if (!$this->hasChild($id)) {
throw ChildDoesNotExistException::create($this->getId(), $id);
}
return $this->_children[$id];
} | php | public function getChild(string $id): NodeInterface
{
if (!$this->hasChild($id)) {
throw ChildDoesNotExistException::create($this->getId(), $id);
}
return $this->_children[$id];
} | [
"public",
"function",
"getChild",
"(",
"string",
"$",
"id",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasChild",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"ChildDoesNotExistException",
"::",
"create",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_children",
"[",
"$",
"id",
"]",
";",
"}"
] | Returns a child by ID.
@param string $id - Node ID.
@throws ChildDoesNotExistException
@return NodeInterface | [
"Returns",
"a",
"child",
"by",
"ID",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L583-L590 |
2,724 | ironedgesoftware/graphs | src/Node/Node.php | Node.findChildren | public function findChildren(array $filters = [], array $options = [])
{
$options = array_replace(
[
'returnFirstResult' => false
],
$options
);
if (empty($filters)) {
$result = array_values($this->_nodes);
} else if (count($filters) === 1
&& isset($filters['id'])
) {
$result = $this->hasNode($filters['id']) ?
[$this->getNode($filters['id'])] :
[];
} else {
$result = [];
/** @var NodeInterface $child */
foreach ($this->getNodes() as $child) {
foreach ($filters as $f => $v) {
$method = 'get'.ucfirst($f);
if (!method_exists($child, $method) || $child->$method() !== $v) {
continue 2;
}
}
$result[] = $child;
}
}
return $options['returnFirstResult'] && $result ?
$result[0] :
$result;
} | php | public function findChildren(array $filters = [], array $options = [])
{
$options = array_replace(
[
'returnFirstResult' => false
],
$options
);
if (empty($filters)) {
$result = array_values($this->_nodes);
} else if (count($filters) === 1
&& isset($filters['id'])
) {
$result = $this->hasNode($filters['id']) ?
[$this->getNode($filters['id'])] :
[];
} else {
$result = [];
/** @var NodeInterface $child */
foreach ($this->getNodes() as $child) {
foreach ($filters as $f => $v) {
$method = 'get'.ucfirst($f);
if (!method_exists($child, $method) || $child->$method() !== $v) {
continue 2;
}
}
$result[] = $child;
}
}
return $options['returnFirstResult'] && $result ?
$result[0] :
$result;
} | [
"public",
"function",
"findChildren",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_replace",
"(",
"[",
"'returnFirstResult'",
"=>",
"false",
"]",
",",
"$",
"options",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"$",
"result",
"=",
"array_values",
"(",
"$",
"this",
"->",
"_nodes",
")",
";",
"}",
"else",
"if",
"(",
"count",
"(",
"$",
"filters",
")",
"===",
"1",
"&&",
"isset",
"(",
"$",
"filters",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"hasNode",
"(",
"$",
"filters",
"[",
"'id'",
"]",
")",
"?",
"[",
"$",
"this",
"->",
"getNode",
"(",
"$",
"filters",
"[",
"'id'",
"]",
")",
"]",
":",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var NodeInterface $child */",
"foreach",
"(",
"$",
"this",
"->",
"getNodes",
"(",
")",
"as",
"$",
"child",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"f",
"=>",
"$",
"v",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"f",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"child",
",",
"$",
"method",
")",
"||",
"$",
"child",
"->",
"$",
"method",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"continue",
"2",
";",
"}",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"}",
"return",
"$",
"options",
"[",
"'returnFirstResult'",
"]",
"&&",
"$",
"result",
"?",
"$",
"result",
"[",
"0",
"]",
":",
"$",
"result",
";",
"}"
] | Finds children.
@param array $filters - Filters.
@param array $options - Options.
@return array|NodeInterface | [
"Finds",
"children",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L612-L649 |
2,725 | ironedgesoftware/graphs | src/Node/Node.php | Node.addNode | public function addNode(NodeInterface $node): NodeInterface
{
$this->_nodes[$node->getId()] = $node;
if ($this->getParent()) {
$this->getParent()->addNode($node);
}
return $this;
} | php | public function addNode(NodeInterface $node): NodeInterface
{
$this->_nodes[$node->getId()] = $node;
if ($this->getParent()) {
$this->getParent()->addNode($node);
}
return $this;
} | [
"public",
"function",
"addNode",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"_nodes",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"node",
";",
"if",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"addNode",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a node to this graph.
@param NodeInterface $node - Node.
@return NodeInterface | [
"Adds",
"a",
"node",
"to",
"this",
"graph",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L708-L717 |
2,726 | ironedgesoftware/graphs | src/Node/Node.php | Node.removeNode | public function removeNode(NodeInterface $node): NodeInterface
{
unset($this->_nodes[$node->getId()]);
if ($this->getParent()) {
$this->getParent()->removeNode($node);
}
return $this;
} | php | public function removeNode(NodeInterface $node): NodeInterface
{
unset($this->_nodes[$node->getId()]);
if ($this->getParent()) {
$this->getParent()->removeNode($node);
}
return $this;
} | [
"public",
"function",
"removeNode",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"NodeInterface",
"{",
"unset",
"(",
"$",
"this",
"->",
"_nodes",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"removeNode",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a node.
@param NodeInterface $node - Node.
@return NodeInterface | [
"Removes",
"a",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L726-L735 |
2,727 | ironedgesoftware/graphs | src/Node/Node.php | Node.validate | public function validate(array $options = [])
{
$options = array_replace(
[
'validateMinChildren' => true,
'validateMaxChildren' => true,
'validateParentMandatory' => true,
'validateParentMustNotBeSet' => true
],
$options
);
$countChildren = $this->countChildren();
if ($options['validateMinChildren']
&& ($min = $this->getValidationConfig('minChildren')) !== null
&& $min > $countChildren
) {
throw ValidationException::create(
'Children must be, at least, ' . $min . '. Currently, node "' . $this->getId() . '" has ' .
$countChildren . ' children.'
);
}
if ($options['validateMaxChildren']
&& ($max = $this->getValidationConfig('maxChildren')) !== null
&& $max < $countChildren
) {
throw ValidationException::create(
'Children cannot exceed a maximum of ' . $max . '. Currently, node "' . $this->getId() . '" has ' .
$countChildren . ' children.'
);
}
if ($options['validateParentMandatory']
&& $this->getValidationConfig('parentMandatory')
&& $this->getParent() === null
) {
throw ValidationException::create(
'Node "' . $this->getId() . '" must have a Parent!'
);
}
if ($options['validateParentMustNotBeSet']
&& $this->getValidationConfig('parentMustNotBeSet')
&& $this->getParent() !== null
) {
throw ValidationException::create(
'Node "' . $this->getId() . '" must NOT have a Parent!'
);
}
} | php | public function validate(array $options = [])
{
$options = array_replace(
[
'validateMinChildren' => true,
'validateMaxChildren' => true,
'validateParentMandatory' => true,
'validateParentMustNotBeSet' => true
],
$options
);
$countChildren = $this->countChildren();
if ($options['validateMinChildren']
&& ($min = $this->getValidationConfig('minChildren')) !== null
&& $min > $countChildren
) {
throw ValidationException::create(
'Children must be, at least, ' . $min . '. Currently, node "' . $this->getId() . '" has ' .
$countChildren . ' children.'
);
}
if ($options['validateMaxChildren']
&& ($max = $this->getValidationConfig('maxChildren')) !== null
&& $max < $countChildren
) {
throw ValidationException::create(
'Children cannot exceed a maximum of ' . $max . '. Currently, node "' . $this->getId() . '" has ' .
$countChildren . ' children.'
);
}
if ($options['validateParentMandatory']
&& $this->getValidationConfig('parentMandatory')
&& $this->getParent() === null
) {
throw ValidationException::create(
'Node "' . $this->getId() . '" must have a Parent!'
);
}
if ($options['validateParentMustNotBeSet']
&& $this->getValidationConfig('parentMustNotBeSet')
&& $this->getParent() !== null
) {
throw ValidationException::create(
'Node "' . $this->getId() . '" must NOT have a Parent!'
);
}
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_replace",
"(",
"[",
"'validateMinChildren'",
"=>",
"true",
",",
"'validateMaxChildren'",
"=>",
"true",
",",
"'validateParentMandatory'",
"=>",
"true",
",",
"'validateParentMustNotBeSet'",
"=>",
"true",
"]",
",",
"$",
"options",
")",
";",
"$",
"countChildren",
"=",
"$",
"this",
"->",
"countChildren",
"(",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'validateMinChildren'",
"]",
"&&",
"(",
"$",
"min",
"=",
"$",
"this",
"->",
"getValidationConfig",
"(",
"'minChildren'",
")",
")",
"!==",
"null",
"&&",
"$",
"min",
">",
"$",
"countChildren",
")",
"{",
"throw",
"ValidationException",
"::",
"create",
"(",
"'Children must be, at least, '",
".",
"$",
"min",
".",
"'. Currently, node \"'",
".",
"$",
"this",
"->",
"getId",
"(",
")",
".",
"'\" has '",
".",
"$",
"countChildren",
".",
"' children.'",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'validateMaxChildren'",
"]",
"&&",
"(",
"$",
"max",
"=",
"$",
"this",
"->",
"getValidationConfig",
"(",
"'maxChildren'",
")",
")",
"!==",
"null",
"&&",
"$",
"max",
"<",
"$",
"countChildren",
")",
"{",
"throw",
"ValidationException",
"::",
"create",
"(",
"'Children cannot exceed a maximum of '",
".",
"$",
"max",
".",
"'. Currently, node \"'",
".",
"$",
"this",
"->",
"getId",
"(",
")",
".",
"'\" has '",
".",
"$",
"countChildren",
".",
"' children.'",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'validateParentMandatory'",
"]",
"&&",
"$",
"this",
"->",
"getValidationConfig",
"(",
"'parentMandatory'",
")",
"&&",
"$",
"this",
"->",
"getParent",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"ValidationException",
"::",
"create",
"(",
"'Node \"'",
".",
"$",
"this",
"->",
"getId",
"(",
")",
".",
"'\" must have a Parent!'",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'validateParentMustNotBeSet'",
"]",
"&&",
"$",
"this",
"->",
"getValidationConfig",
"(",
"'parentMustNotBeSet'",
")",
"&&",
"$",
"this",
"->",
"getParent",
"(",
")",
"!==",
"null",
")",
"{",
"throw",
"ValidationException",
"::",
"create",
"(",
"'Node \"'",
".",
"$",
"this",
"->",
"getId",
"(",
")",
".",
"'\" must NOT have a Parent!'",
")",
";",
"}",
"}"
] | This method is called after initializing the data.
@param array $options - Options.
@throws ValidationException
@return void | [
"This",
"method",
"is",
"called",
"after",
"initializing",
"the",
"data",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L846-L897 |
2,728 | ironedgesoftware/graphs | src/Node/Node.php | Node.setValidationConfig | public function setValidationConfig(string $name, $value): NodeInterface
{
$this->setMetadataAttr('validations.'.$name, $value);
return $this;
} | php | public function setValidationConfig(string $name, $value): NodeInterface
{
$this->setMetadataAttr('validations.'.$name, $value);
return $this;
} | [
"public",
"function",
"setValidationConfig",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"setMetadataAttr",
"(",
"'validations.'",
".",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a validation config.
@param string $name - Validation name.
@param mixed $value - Validation value.
@return NodeInterface | [
"Sets",
"a",
"validation",
"config",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L944-L949 |
2,729 | ironedgesoftware/graphs | src/Node/Node.php | Node.setSubscribers | public function setSubscribers(array $subscribers): NodeInterface
{
$this->_subscribers = [];
foreach ($subscribers as $subscriber) {
$this->addSubscriber($subscriber);
}
return $this;
} | php | public function setSubscribers(array $subscribers): NodeInterface
{
$this->_subscribers = [];
foreach ($subscribers as $subscriber) {
$this->addSubscriber($subscriber);
}
return $this;
} | [
"public",
"function",
"setSubscribers",
"(",
"array",
"$",
"subscribers",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"_subscribers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"subscribers",
"as",
"$",
"subscriber",
")",
"{",
"$",
"this",
"->",
"addSubscriber",
"(",
"$",
"subscriber",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the value of field subscribers.
@param array $subscribers - subscribers.
@return NodeInterface | [
"Sets",
"the",
"value",
"of",
"field",
"subscribers",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L985-L994 |
2,730 | ironedgesoftware/graphs | src/Node/Node.php | Node.addSubscriber | public function addSubscriber(SubscriberInterface $subscriber): NodeInterface
{
$this->_subscribers[$subscriber->getId()] = $subscriber;
return $this;
} | php | public function addSubscriber(SubscriberInterface $subscriber): NodeInterface
{
$this->_subscribers[$subscriber->getId()] = $subscriber;
return $this;
} | [
"public",
"function",
"addSubscriber",
"(",
"SubscriberInterface",
"$",
"subscriber",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"_subscribers",
"[",
"$",
"subscriber",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"subscriber",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a subscriber.
@param SubscriberInterface $subscriber - Subscriber.
@return NodeInterface | [
"Adds",
"a",
"subscriber",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L1003-L1008 |
2,731 | ironedgesoftware/graphs | src/Node/Node.php | Node.removeSubscriber | public function removeSubscriber($idOrSubscriber): NodeInterface
{
if (!is_string($idOrSubscriber)
&& (!is_object($idOrSubscriber) || !($idOrSubscriber instanceof SubscriberInterface))
) {
throw new \InvalidArgumentException(
'Argument "$idOrSubscriber" must be a string or an instance of '.
'IronEdge\Component\Graph\Event\SubscriberInterface.'
);
}
$id = is_string($idOrSubscriber) ?
$idOrSubscriber :
$idOrSubscriber->getId();
unset($this->_subscribers[$id]);
return $this;
} | php | public function removeSubscriber($idOrSubscriber): NodeInterface
{
if (!is_string($idOrSubscriber)
&& (!is_object($idOrSubscriber) || !($idOrSubscriber instanceof SubscriberInterface))
) {
throw new \InvalidArgumentException(
'Argument "$idOrSubscriber" must be a string or an instance of '.
'IronEdge\Component\Graph\Event\SubscriberInterface.'
);
}
$id = is_string($idOrSubscriber) ?
$idOrSubscriber :
$idOrSubscriber->getId();
unset($this->_subscribers[$id]);
return $this;
} | [
"public",
"function",
"removeSubscriber",
"(",
"$",
"idOrSubscriber",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"idOrSubscriber",
")",
"&&",
"(",
"!",
"is_object",
"(",
"$",
"idOrSubscriber",
")",
"||",
"!",
"(",
"$",
"idOrSubscriber",
"instanceof",
"SubscriberInterface",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument \"$idOrSubscriber\" must be a string or an instance of '",
".",
"'IronEdge\\Component\\Graph\\Event\\SubscriberInterface.'",
")",
";",
"}",
"$",
"id",
"=",
"is_string",
"(",
"$",
"idOrSubscriber",
")",
"?",
"$",
"idOrSubscriber",
":",
"$",
"idOrSubscriber",
"->",
"getId",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_subscribers",
"[",
"$",
"id",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes a subscriber.
@param string|SubscriberInterface $idOrSubscriber - Subscriber or ID.
@return NodeInterface | [
"Removes",
"a",
"subscriber",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L1017-L1035 |
2,732 | ironedgesoftware/graphs | src/Node/Node.php | Node.handleEvent | public function handleEvent(string $eventId, array $eventData)
{
switch ($eventId) {
case self::EVENT_ADD_CHILD:
/** @var NodeInterface $node */
$node = $eventData['child'];
$this->addNode($node);
break;
case self::EVENT_REMOVE_CHILD:
/** @var NodeInterface $node */
$node = $eventData['child'];
$this->removeNode($node);
break;
case self::EVENT_ADD_PARENT:
/** @var NodeInterface $child */
$child = $eventData['child'];
/** @var NodeInterface $newParent */
$newParent = $eventData['newParent'];
$nodes = $child->getNodes() + [$child];
/** @var NodeInterface $n */
foreach ($nodes as $n) {
$n->addSubscriber($newParent);
$newParent->addNode($n);
}
break;
case self::EVENT_REMOVE_PARENT:
/** @var NodeInterface $child */
$child = $eventData['child'];
/** @var NodeInterface $oldParent */
$oldParent = $eventData['parentToRemove'];
$nodes = $child->getNodes() + [$child];
/** @var NodeInterface $n */
foreach ($nodes as $n) {
$n->removeSubscriber($oldParent);
$oldParent->removeNode($n);
}
break;
default:
break;
}
} | php | public function handleEvent(string $eventId, array $eventData)
{
switch ($eventId) {
case self::EVENT_ADD_CHILD:
/** @var NodeInterface $node */
$node = $eventData['child'];
$this->addNode($node);
break;
case self::EVENT_REMOVE_CHILD:
/** @var NodeInterface $node */
$node = $eventData['child'];
$this->removeNode($node);
break;
case self::EVENT_ADD_PARENT:
/** @var NodeInterface $child */
$child = $eventData['child'];
/** @var NodeInterface $newParent */
$newParent = $eventData['newParent'];
$nodes = $child->getNodes() + [$child];
/** @var NodeInterface $n */
foreach ($nodes as $n) {
$n->addSubscriber($newParent);
$newParent->addNode($n);
}
break;
case self::EVENT_REMOVE_PARENT:
/** @var NodeInterface $child */
$child = $eventData['child'];
/** @var NodeInterface $oldParent */
$oldParent = $eventData['parentToRemove'];
$nodes = $child->getNodes() + [$child];
/** @var NodeInterface $n */
foreach ($nodes as $n) {
$n->removeSubscriber($oldParent);
$oldParent->removeNode($n);
}
break;
default:
break;
}
} | [
"public",
"function",
"handleEvent",
"(",
"string",
"$",
"eventId",
",",
"array",
"$",
"eventData",
")",
"{",
"switch",
"(",
"$",
"eventId",
")",
"{",
"case",
"self",
"::",
"EVENT_ADD_CHILD",
":",
"/** @var NodeInterface $node */",
"$",
"node",
"=",
"$",
"eventData",
"[",
"'child'",
"]",
";",
"$",
"this",
"->",
"addNode",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"self",
"::",
"EVENT_REMOVE_CHILD",
":",
"/** @var NodeInterface $node */",
"$",
"node",
"=",
"$",
"eventData",
"[",
"'child'",
"]",
";",
"$",
"this",
"->",
"removeNode",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"self",
"::",
"EVENT_ADD_PARENT",
":",
"/** @var NodeInterface $child */",
"$",
"child",
"=",
"$",
"eventData",
"[",
"'child'",
"]",
";",
"/** @var NodeInterface $newParent */",
"$",
"newParent",
"=",
"$",
"eventData",
"[",
"'newParent'",
"]",
";",
"$",
"nodes",
"=",
"$",
"child",
"->",
"getNodes",
"(",
")",
"+",
"[",
"$",
"child",
"]",
";",
"/** @var NodeInterface $n */",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"n",
")",
"{",
"$",
"n",
"->",
"addSubscriber",
"(",
"$",
"newParent",
")",
";",
"$",
"newParent",
"->",
"addNode",
"(",
"$",
"n",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"EVENT_REMOVE_PARENT",
":",
"/** @var NodeInterface $child */",
"$",
"child",
"=",
"$",
"eventData",
"[",
"'child'",
"]",
";",
"/** @var NodeInterface $oldParent */",
"$",
"oldParent",
"=",
"$",
"eventData",
"[",
"'parentToRemove'",
"]",
";",
"$",
"nodes",
"=",
"$",
"child",
"->",
"getNodes",
"(",
")",
"+",
"[",
"$",
"child",
"]",
";",
"/** @var NodeInterface $n */",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"n",
")",
"{",
"$",
"n",
"->",
"removeSubscriber",
"(",
"$",
"oldParent",
")",
";",
"$",
"oldParent",
"->",
"removeNode",
"(",
"$",
"n",
")",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | This method is called when an event is fired.
@param string $eventId - Event ID.
@param array $eventData - Event Data.
@return void | [
"This",
"method",
"is",
"called",
"when",
"an",
"event",
"is",
"fired",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L1045-L1093 |
2,733 | ironedgesoftware/graphs | src/Node/Node.php | Node.notifySubscribers | public function notifySubscribers(string $eventId, array $eventData)
{
/** @var SubscriberInterface $subscriber */
foreach ($this->getSubscribers() as $subscriber) {
$subscriber->handleEvent($eventId, $eventData);
}
} | php | public function notifySubscribers(string $eventId, array $eventData)
{
/** @var SubscriberInterface $subscriber */
foreach ($this->getSubscribers() as $subscriber) {
$subscriber->handleEvent($eventId, $eventData);
}
} | [
"public",
"function",
"notifySubscribers",
"(",
"string",
"$",
"eventId",
",",
"array",
"$",
"eventData",
")",
"{",
"/** @var SubscriberInterface $subscriber */",
"foreach",
"(",
"$",
"this",
"->",
"getSubscribers",
"(",
")",
"as",
"$",
"subscriber",
")",
"{",
"$",
"subscriber",
"->",
"handleEvent",
"(",
"$",
"eventId",
",",
"$",
"eventData",
")",
";",
"}",
"}"
] | Fires an event. Subscribers gets notified about this event.
@param string $eventId - Event ID.
@param array $eventData - Event Data.
@return void | [
"Fires",
"an",
"event",
".",
"Subscribers",
"gets",
"notified",
"about",
"this",
"event",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L1103-L1109 |
2,734 | ironedgesoftware/graphs | src/Node/Node.php | Node.toArray | public function toArray(array $options = [])
{
$childrenIds = [];
/** @var NodeInterface $child */
foreach ($this->getChildren() as $child) {
$childrenIds[] = $child->getId();
}
return [
'id' => $this->getId(),
'name' => $this->getName(),
'type' => $this->getType(),
'metadata' => $this->getMetadata()->getData(),
'parentId' => $this->getParent() ?
$this->getParent()->getId() :
null,
'childrenIds' => $childrenIds
];
} | php | public function toArray(array $options = [])
{
$childrenIds = [];
/** @var NodeInterface $child */
foreach ($this->getChildren() as $child) {
$childrenIds[] = $child->getId();
}
return [
'id' => $this->getId(),
'name' => $this->getName(),
'type' => $this->getType(),
'metadata' => $this->getMetadata()->getData(),
'parentId' => $this->getParent() ?
$this->getParent()->getId() :
null,
'childrenIds' => $childrenIds
];
} | [
"public",
"function",
"toArray",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"childrenIds",
"=",
"[",
"]",
";",
"/** @var NodeInterface $child */",
"foreach",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"childrenIds",
"[",
"]",
"=",
"$",
"child",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"'metadata'",
"=>",
"$",
"this",
"->",
"getMetadata",
"(",
")",
"->",
"getData",
"(",
")",
",",
"'parentId'",
"=>",
"$",
"this",
"->",
"getParent",
"(",
")",
"?",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getId",
"(",
")",
":",
"null",
",",
"'childrenIds'",
"=>",
"$",
"childrenIds",
"]",
";",
"}"
] | Returns an array representation of this node.
@param array $options - Options.
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"this",
"node",
"."
] | c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0 | https://github.com/ironedgesoftware/graphs/blob/c1cc2347e7ba1935fe6b06356a74f0cf3101f5a0/src/Node/Node.php#L1118-L1137 |
2,735 | consigliere/components | src/Repository.php | Repository.scan | public function scan()
{
$paths = $this->getScanPaths();
$components = [];
foreach ($paths as $key => $path) {
$manifests = $this->app['files']->glob("{$path}/component.json");
is_array($manifests) || $manifests = [];
foreach ($manifests as $manifest) {
$name = Json::make($manifest)->get('name');
$components[$name] = new Component($this->app, $name, dirname($manifest));
}
}
return $components;
} | php | public function scan()
{
$paths = $this->getScanPaths();
$components = [];
foreach ($paths as $key => $path) {
$manifests = $this->app['files']->glob("{$path}/component.json");
is_array($manifests) || $manifests = [];
foreach ($manifests as $manifest) {
$name = Json::make($manifest)->get('name');
$components[$name] = new Component($this->app, $name, dirname($manifest));
}
}
return $components;
} | [
"public",
"function",
"scan",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getScanPaths",
"(",
")",
";",
"$",
"components",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"$",
"manifests",
"=",
"$",
"this",
"->",
"app",
"[",
"'files'",
"]",
"->",
"glob",
"(",
"\"{$path}/component.json\"",
")",
";",
"is_array",
"(",
"$",
"manifests",
")",
"||",
"$",
"manifests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"manifests",
"as",
"$",
"manifest",
")",
"{",
"$",
"name",
"=",
"Json",
"::",
"make",
"(",
"$",
"manifest",
")",
"->",
"get",
"(",
"'name'",
")",
";",
"$",
"components",
"[",
"$",
"name",
"]",
"=",
"new",
"Component",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"name",
",",
"dirname",
"(",
"$",
"manifest",
")",
")",
";",
"}",
"}",
"return",
"$",
"components",
";",
"}"
] | Get & scan all components.
@return array | [
"Get",
"&",
"scan",
"all",
"components",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L112-L131 |
2,736 | consigliere/components | src/Repository.php | Repository.formatCached | protected function formatCached($cached)
{
$components = [];
foreach ($cached as $name => $component) {
$path = $this->config('paths.components') . '/' . $name;
$components[$name] = new Component($this->app, $name, $path);
}
return $components;
} | php | protected function formatCached($cached)
{
$components = [];
foreach ($cached as $name => $component) {
$path = $this->config('paths.components') . '/' . $name;
$components[$name] = new Component($this->app, $name, $path);
}
return $components;
} | [
"protected",
"function",
"formatCached",
"(",
"$",
"cached",
")",
"{",
"$",
"components",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cached",
"as",
"$",
"name",
"=>",
"$",
"component",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"config",
"(",
"'paths.components'",
")",
".",
"'/'",
".",
"$",
"name",
";",
"$",
"components",
"[",
"$",
"name",
"]",
"=",
"new",
"Component",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"name",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"components",
";",
"}"
] | Format the cached data as array of components.
@param array $cached
@return array | [
"Format",
"the",
"cached",
"data",
"as",
"array",
"of",
"components",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L154-L165 |
2,737 | consigliere/components | src/Repository.php | Repository.getByStatus | public function getByStatus($status)
{
$components = [];
foreach ($this->all() as $name => $component) {
if ($component->isStatus($status)) {
$components[$name] = $component;
}
}
return $components;
} | php | public function getByStatus($status)
{
$components = [];
foreach ($this->all() as $name => $component) {
if ($component->isStatus($status)) {
$components[$name] = $component;
}
}
return $components;
} | [
"public",
"function",
"getByStatus",
"(",
"$",
"status",
")",
"{",
"$",
"components",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"all",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"component",
")",
"{",
"if",
"(",
"$",
"component",
"->",
"isStatus",
"(",
"$",
"status",
")",
")",
"{",
"$",
"components",
"[",
"$",
"name",
"]",
"=",
"$",
"component",
";",
"}",
"}",
"return",
"$",
"components",
";",
"}"
] | Get components by status.
@param $status
@return array | [
"Get",
"components",
"by",
"status",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L196-L207 |
2,738 | consigliere/components | src/Repository.php | Repository.getOrdered | public function getOrdered($direction = 'asc')
{
$components = $this->enabled();
uasort($components, function(Component $a, Component $b) use ($direction) {
if ($a->order == $b->order) {
return 0;
}
if ($direction == 'desc') {
return $a->order < $b->order ? 1 : -1;
}
return $a->order > $b->order ? 1 : -1;
});
return $components;
} | php | public function getOrdered($direction = 'asc')
{
$components = $this->enabled();
uasort($components, function(Component $a, Component $b) use ($direction) {
if ($a->order == $b->order) {
return 0;
}
if ($direction == 'desc') {
return $a->order < $b->order ? 1 : -1;
}
return $a->order > $b->order ? 1 : -1;
});
return $components;
} | [
"public",
"function",
"getOrdered",
"(",
"$",
"direction",
"=",
"'asc'",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"enabled",
"(",
")",
";",
"uasort",
"(",
"$",
"components",
",",
"function",
"(",
"Component",
"$",
"a",
",",
"Component",
"$",
"b",
")",
"use",
"(",
"$",
"direction",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"order",
"==",
"$",
"b",
"->",
"order",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"direction",
"==",
"'desc'",
")",
"{",
"return",
"$",
"a",
"->",
"order",
"<",
"$",
"b",
"->",
"order",
"?",
"1",
":",
"-",
"1",
";",
"}",
"return",
"$",
"a",
"->",
"order",
">",
"$",
"b",
"->",
"order",
"?",
"1",
":",
"-",
"1",
";",
"}",
")",
";",
"return",
"$",
"components",
";",
"}"
] | Get all ordered components.
@param string $direction
@return array | [
"Get",
"all",
"ordered",
"components",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L258-L275 |
2,739 | consigliere/components | src/Repository.php | Repository.find | public function find($name)
{
foreach ($this->all() as $component) {
if ($component->getLowerName() === strtolower($name)) {
return $component;
}
}
return;
} | php | public function find($name)
{
foreach ($this->all() as $component) {
if ($component->getLowerName() === strtolower($name)) {
return $component;
}
}
return;
} | [
"public",
"function",
"find",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"all",
"(",
")",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"$",
"component",
"->",
"getLowerName",
"(",
")",
"===",
"strtolower",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"component",
";",
"}",
"}",
"return",
";",
"}"
] | Find a specific component.
@param $name
@return mixed|void | [
"Find",
"a",
"specific",
"component",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L314-L323 |
2,740 | consigliere/components | src/Repository.php | Repository.findOrFail | public function findOrFail($name)
{
$component = $this->find($name);
if ($component !== null) {
return $component;
}
throw new ComponentNotFoundException("Component [{$name}] does not exist!");
} | php | public function findOrFail($name)
{
$component = $this->find($name);
if ($component !== null) {
return $component;
}
throw new ComponentNotFoundException("Component [{$name}] does not exist!");
} | [
"public",
"function",
"findOrFail",
"(",
"$",
"name",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"component",
"!==",
"null",
")",
"{",
"return",
"$",
"component",
";",
"}",
"throw",
"new",
"ComponentNotFoundException",
"(",
"\"Component [{$name}] does not exist!\"",
")",
";",
"}"
] | Find a specific component, if there return that, otherwise throw exception.
@param $name
@return Component
@throws ComponentNotFoundException | [
"Find",
"a",
"specific",
"component",
"if",
"there",
"return",
"that",
"otherwise",
"throw",
"exception",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L346-L355 |
2,741 | consigliere/components | src/Repository.php | Repository.getComponentPath | public function getComponentPath($component)
{
try {
return $this->findOrFail($component)->getPath() . '/';
} catch (ComponentNotFoundException $e) {
return $this->getPath() . '/' . Str::studly($component) . '/';
}
} | php | public function getComponentPath($component)
{
try {
return $this->findOrFail($component)->getPath() . '/';
} catch (ComponentNotFoundException $e) {
return $this->getPath() . '/' . Str::studly($component) . '/';
}
} | [
"public",
"function",
"getComponentPath",
"(",
"$",
"component",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"component",
")",
"->",
"getPath",
"(",
")",
".",
"'/'",
";",
"}",
"catch",
"(",
"ComponentNotFoundException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"Str",
"::",
"studly",
"(",
"$",
"component",
")",
".",
"'/'",
";",
"}",
"}"
] | Get component path for a specific component.
@param $component
@return string | [
"Get",
"component",
"path",
"for",
"a",
"specific",
"component",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L374-L381 |
2,742 | consigliere/components | src/Repository.php | Repository.setUsed | public function setUsed($name)
{
$component = $this->findOrFail($name);
$this->app['files']->put($this->getUsedStoragePath(), $component);
} | php | public function setUsed($name)
{
$component = $this->findOrFail($name);
$this->app['files']->put($this->getUsedStoragePath(), $component);
} | [
"public",
"function",
"setUsed",
"(",
"$",
"name",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"app",
"[",
"'files'",
"]",
"->",
"put",
"(",
"$",
"this",
"->",
"getUsedStoragePath",
"(",
")",
",",
"$",
"component",
")",
";",
"}"
] | Set component used for cli session.
@param $name
@throws ComponentNotFoundException | [
"Set",
"component",
"used",
"for",
"cli",
"session",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Repository.php#L430-L435 |
2,743 | cityware/city-snmp | src/MIBS/MAU.php | MAU.states | public function states($translate = false) {
$states = $this->getSNMP()->subOidWalk(self::OID_STATUS, 12);
if (!$translate)
return $states;
return $this->getSNMP()->translate($states, self::$STATES);
} | php | public function states($translate = false) {
$states = $this->getSNMP()->subOidWalk(self::OID_STATUS, 12);
if (!$translate)
return $states;
return $this->getSNMP()->translate($states, self::$STATES);
} | [
"public",
"function",
"states",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"subOidWalk",
"(",
"self",
"::",
"OID_STATUS",
",",
"12",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"return",
"$",
"states",
";",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"states",
",",
"self",
"::",
"$",
"STATES",
")",
";",
"}"
] | Get an array of device interface states
@see $STATES
@param boolean $translate If true, return the string representation
@return array An array of interface states | [
"Get",
"an",
"array",
"of",
"device",
"interface",
"states"
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/MAU.php#L662-L669 |
2,744 | cityware/city-snmp | src/MIBS/MAU.php | MAU.jabberStates | public function jabberStates($translate = false) {
$states = $this->getSNMP()->subOidWalk(self::OID_JABBER_STATE, 12);
if (!$translate)
return $states;
return $this->getSNMP()->translate($states, self::$JABBER_STATES);
} | php | public function jabberStates($translate = false) {
$states = $this->getSNMP()->subOidWalk(self::OID_JABBER_STATE, 12);
if (!$translate)
return $states;
return $this->getSNMP()->translate($states, self::$JABBER_STATES);
} | [
"public",
"function",
"jabberStates",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"subOidWalk",
"(",
"self",
"::",
"OID_JABBER_STATE",
",",
"12",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"return",
"$",
"states",
";",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"states",
",",
"self",
"::",
"$",
"JABBER_STATES",
")",
";",
"}"
] | Get an array of device interface jabber states
@see $JABBER_STATES
@param boolean $translate If true, return the string representation
@return array An array of interface jabber states | [
"Get",
"an",
"array",
"of",
"device",
"interface",
"jabber",
"states"
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/MAU.php#L891-L898 |
2,745 | cityware/city-snmp | src/MIBS/MAU.php | MAU.jackTypes | public function jackTypes($translate = false) {
$types = $this->getSNMP()->subOidWalk(self::OID_JACK_TYPE, 12);
if (!$translate)
return $types;
return $this->getSNMP()->translate($types, self::$JACK_TYPES);
} | php | public function jackTypes($translate = false) {
$types = $this->getSNMP()->subOidWalk(self::OID_JACK_TYPE, 12);
if (!$translate)
return $types;
return $this->getSNMP()->translate($types, self::$JACK_TYPES);
} | [
"public",
"function",
"jackTypes",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"subOidWalk",
"(",
"self",
"::",
"OID_JACK_TYPE",
",",
"12",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"return",
"$",
"types",
";",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"types",
",",
"self",
"::",
"$",
"JACK_TYPES",
")",
";",
"}"
] | Get an array of device jack types
@see $JACK_TYPES
@param boolean $translate If true, return the string representation
@return array An array of interface jack types | [
"Get",
"an",
"array",
"of",
"device",
"jack",
"types"
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/MAU.php#L1065-L1072 |
2,746 | Smile-SA/EzToolsBundle | Command/Content/GenerateCommand.php | GenerateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
/** @var $repository Repository */
$repository = $this->getContainer()->get('ezpublish.api.repository');
/** @var $contentService ContentService */
$contentService = $repository->getContentService();
/** @var $contentTypeService ContentTypeService*/
$contentTypeService = $repository->getContentTypeService();
/** @var $locationService LocationService */
$locationService = $repository->getLocationService();
/** @var $questionHelper QuestionHelper */
$questionHelper = $this->getHelper('question');
$struct = array();
$struct['parentLocationID'] = $this->getParentLocationID($locationService, $questionHelper);
$struct['contentTypeIdentifier'] = $this->getContentTypeIdentifier($contentTypeService, $questionHelper);
$contentType = $contentTypeService->loadContentTypeByIdentifier($struct['contentTypeIdentifier']);
$languageCode = $contentType->mainLanguageCode;
$struct['languageCode'] = $languageCode;
$struct['fields'] = array();
$fields = $contentType->getFieldDefinitions();
foreach ($fields as $field) {
$fieldName = $field->getName($languageCode);
$fieldIdentifier = $field->identifier;
$fieldValue = $this->getFieldValue($questionHelper, $fieldName);
$struct['fields'][] = array(
'identifier' => $fieldIdentifier,
'value' => $fieldValue
);
}
/** @var $configResolver ConfigResolver */
$configResolver = $this->getContainer()->get('ezpublish.config.resolver');
$adminID = $this->getContainer()->getParameter('smile_ez_tools.adminid');
$smileEzContentService = new Content($repository);
$smileEzContentService->setAdminID($adminID);
try {
$smileEzContentService->add($struct);
$output->writeln("<info>Content created</info>");
} catch (UnauthorizedException $e) {
$output->writeln("<error>" . $e->getMessage() . "</error>");
} catch (ForbiddenException $e ) {
$output->writeln("<error>" . $e->getMessage() . "</error>");
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
/** @var $repository Repository */
$repository = $this->getContainer()->get('ezpublish.api.repository');
/** @var $contentService ContentService */
$contentService = $repository->getContentService();
/** @var $contentTypeService ContentTypeService*/
$contentTypeService = $repository->getContentTypeService();
/** @var $locationService LocationService */
$locationService = $repository->getLocationService();
/** @var $questionHelper QuestionHelper */
$questionHelper = $this->getHelper('question');
$struct = array();
$struct['parentLocationID'] = $this->getParentLocationID($locationService, $questionHelper);
$struct['contentTypeIdentifier'] = $this->getContentTypeIdentifier($contentTypeService, $questionHelper);
$contentType = $contentTypeService->loadContentTypeByIdentifier($struct['contentTypeIdentifier']);
$languageCode = $contentType->mainLanguageCode;
$struct['languageCode'] = $languageCode;
$struct['fields'] = array();
$fields = $contentType->getFieldDefinitions();
foreach ($fields as $field) {
$fieldName = $field->getName($languageCode);
$fieldIdentifier = $field->identifier;
$fieldValue = $this->getFieldValue($questionHelper, $fieldName);
$struct['fields'][] = array(
'identifier' => $fieldIdentifier,
'value' => $fieldValue
);
}
/** @var $configResolver ConfigResolver */
$configResolver = $this->getContainer()->get('ezpublish.config.resolver');
$adminID = $this->getContainer()->getParameter('smile_ez_tools.adminid');
$smileEzContentService = new Content($repository);
$smileEzContentService->setAdminID($adminID);
try {
$smileEzContentService->add($struct);
$output->writeln("<info>Content created</info>");
} catch (UnauthorizedException $e) {
$output->writeln("<error>" . $e->getMessage() . "</error>");
} catch (ForbiddenException $e ) {
$output->writeln("<error>" . $e->getMessage() . "</error>");
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"/** @var $repository Repository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'ezpublish.api.repository'",
")",
";",
"/** @var $contentService ContentService */",
"$",
"contentService",
"=",
"$",
"repository",
"->",
"getContentService",
"(",
")",
";",
"/** @var $contentTypeService ContentTypeService*/",
"$",
"contentTypeService",
"=",
"$",
"repository",
"->",
"getContentTypeService",
"(",
")",
";",
"/** @var $locationService LocationService */",
"$",
"locationService",
"=",
"$",
"repository",
"->",
"getLocationService",
"(",
")",
";",
"/** @var $questionHelper QuestionHelper */",
"$",
"questionHelper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"$",
"struct",
"=",
"array",
"(",
")",
";",
"$",
"struct",
"[",
"'parentLocationID'",
"]",
"=",
"$",
"this",
"->",
"getParentLocationID",
"(",
"$",
"locationService",
",",
"$",
"questionHelper",
")",
";",
"$",
"struct",
"[",
"'contentTypeIdentifier'",
"]",
"=",
"$",
"this",
"->",
"getContentTypeIdentifier",
"(",
"$",
"contentTypeService",
",",
"$",
"questionHelper",
")",
";",
"$",
"contentType",
"=",
"$",
"contentTypeService",
"->",
"loadContentTypeByIdentifier",
"(",
"$",
"struct",
"[",
"'contentTypeIdentifier'",
"]",
")",
";",
"$",
"languageCode",
"=",
"$",
"contentType",
"->",
"mainLanguageCode",
";",
"$",
"struct",
"[",
"'languageCode'",
"]",
"=",
"$",
"languageCode",
";",
"$",
"struct",
"[",
"'fields'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"contentType",
"->",
"getFieldDefinitions",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"$",
"field",
"->",
"getName",
"(",
"$",
"languageCode",
")",
";",
"$",
"fieldIdentifier",
"=",
"$",
"field",
"->",
"identifier",
";",
"$",
"fieldValue",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"questionHelper",
",",
"$",
"fieldName",
")",
";",
"$",
"struct",
"[",
"'fields'",
"]",
"[",
"]",
"=",
"array",
"(",
"'identifier'",
"=>",
"$",
"fieldIdentifier",
",",
"'value'",
"=>",
"$",
"fieldValue",
")",
";",
"}",
"/** @var $configResolver ConfigResolver */",
"$",
"configResolver",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'ezpublish.config.resolver'",
")",
";",
"$",
"adminID",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'smile_ez_tools.adminid'",
")",
";",
"$",
"smileEzContentService",
"=",
"new",
"Content",
"(",
"$",
"repository",
")",
";",
"$",
"smileEzContentService",
"->",
"setAdminID",
"(",
"$",
"adminID",
")",
";",
"try",
"{",
"$",
"smileEzContentService",
"->",
"add",
"(",
"$",
"struct",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"\"<info>Content created</info>\"",
")",
";",
"}",
"catch",
"(",
"UnauthorizedException",
"$",
"e",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"\"<error>\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"</error>\"",
")",
";",
"}",
"catch",
"(",
"ForbiddenException",
"$",
"e",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"\"<error>\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"</error>\"",
")",
";",
"}",
"}"
] | Execute Content generate command
@param InputInterface $input
@param OutputInterface $output
@return int|null|void | [
"Execute",
"Content",
"generate",
"command"
] | 5f384f552a83dd723fb4dca468ac0a2e56442be8 | https://github.com/Smile-SA/EzToolsBundle/blob/5f384f552a83dd723fb4dca468ac0a2e56442be8/Command/Content/GenerateCommand.php#L45-L98 |
2,747 | ntentan/ntentan | src/sessions/SessionContainerFactory.php | SessionContainerFactory.createSessionContainer | public function createSessionContainer()
{
// Check and start a default session if a custom session container is not supplied
if(!isset($this->config['container'])) {
session_start();
return;
}
// Create an instance of the session container. Session containers are responsible for starting the session.
$sessionContainerType = $this->config['container'];
$className = '\ntentan\sessions\containers\\' . Text::ucamelize($sessionContainerType) . 'SessionContainer';
$sessionContainer = new $className($this->config);
return $sessionContainer;
} | php | public function createSessionContainer()
{
// Check and start a default session if a custom session container is not supplied
if(!isset($this->config['container'])) {
session_start();
return;
}
// Create an instance of the session container. Session containers are responsible for starting the session.
$sessionContainerType = $this->config['container'];
$className = '\ntentan\sessions\containers\\' . Text::ucamelize($sessionContainerType) . 'SessionContainer';
$sessionContainer = new $className($this->config);
return $sessionContainer;
} | [
"public",
"function",
"createSessionContainer",
"(",
")",
"{",
"// Check and start a default session if a custom session container is not supplied",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'container'",
"]",
")",
")",
"{",
"session_start",
"(",
")",
";",
"return",
";",
"}",
"// Create an instance of the session container. Session containers are responsible for starting the session.",
"$",
"sessionContainerType",
"=",
"$",
"this",
"->",
"config",
"[",
"'container'",
"]",
";",
"$",
"className",
"=",
"'\\ntentan\\sessions\\containers\\\\'",
".",
"Text",
"::",
"ucamelize",
"(",
"$",
"sessionContainerType",
")",
".",
"'SessionContainer'",
";",
"$",
"sessionContainer",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"config",
")",
";",
"return",
"$",
"sessionContainer",
";",
"}"
] | Create and return an instance of the custom session container if required. | [
"Create",
"and",
"return",
"an",
"instance",
"of",
"the",
"custom",
"session",
"container",
"if",
"required",
"."
] | a6e89de5999bfafe5be9152bcd51ecfef3e928fb | https://github.com/ntentan/ntentan/blob/a6e89de5999bfafe5be9152bcd51ecfef3e928fb/src/sessions/SessionContainerFactory.php#L20-L32 |
2,748 | rinvex/obsolete-attributable | src/Events/EntityWasDeleted.php | EntityWasDeleted.handle | public function handle(Entity $entity)
{
// We will initially check if the model is using soft deletes. If so,
// the attribute values will remain untouched as they should sill
// be available till the entity is truly deleted from database.
if (in_array(SoftDeletes::class, class_uses_recursive(get_class($entity))) && ! $entity->isForceDeleting()) {
return;
}
foreach ($entity->getEntityAttributes() as $attribute) {
if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))
&& ($values = $entity->getRelationValue($relation)) && ! $values->isEmpty()) {
// Calling the `destroy` method from the given $type model class name
// will finally delete the records from database if any was found.
// We'll just provide an array containing the ids to be deleted.
forward_static_call_array([$attribute->getAttribute('type'), 'destroy'], [$values->pluck('id')->toArray()]);
}
}
} | php | public function handle(Entity $entity)
{
// We will initially check if the model is using soft deletes. If so,
// the attribute values will remain untouched as they should sill
// be available till the entity is truly deleted from database.
if (in_array(SoftDeletes::class, class_uses_recursive(get_class($entity))) && ! $entity->isForceDeleting()) {
return;
}
foreach ($entity->getEntityAttributes() as $attribute) {
if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))
&& ($values = $entity->getRelationValue($relation)) && ! $values->isEmpty()) {
// Calling the `destroy` method from the given $type model class name
// will finally delete the records from database if any was found.
// We'll just provide an array containing the ids to be deleted.
forward_static_call_array([$attribute->getAttribute('type'), 'destroy'], [$values->pluck('id')->toArray()]);
}
}
} | [
"public",
"function",
"handle",
"(",
"Entity",
"$",
"entity",
")",
"{",
"// We will initially check if the model is using soft deletes. If so,",
"// the attribute values will remain untouched as they should sill",
"// be available till the entity is truly deleted from database.",
"if",
"(",
"in_array",
"(",
"SoftDeletes",
"::",
"class",
",",
"class_uses_recursive",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
")",
"&&",
"!",
"$",
"entity",
"->",
"isForceDeleting",
"(",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"entity",
"->",
"getEntityAttributes",
"(",
")",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"relationLoaded",
"(",
"$",
"relation",
"=",
"$",
"attribute",
"->",
"getAttribute",
"(",
"'slug'",
")",
")",
"&&",
"(",
"$",
"values",
"=",
"$",
"entity",
"->",
"getRelationValue",
"(",
"$",
"relation",
")",
")",
"&&",
"!",
"$",
"values",
"->",
"isEmpty",
"(",
")",
")",
"{",
"// Calling the `destroy` method from the given $type model class name",
"// will finally delete the records from database if any was found.",
"// We'll just provide an array containing the ids to be deleted.",
"forward_static_call_array",
"(",
"[",
"$",
"attribute",
"->",
"getAttribute",
"(",
"'type'",
")",
",",
"'destroy'",
"]",
",",
"[",
"$",
"values",
"->",
"pluck",
"(",
"'id'",
")",
"->",
"toArray",
"(",
")",
"]",
")",
";",
"}",
"}",
"}"
] | Handle the entity deletion.
@param \Illuminate\Database\Eloquent\Model $entity
@return void | [
"Handle",
"the",
"entity",
"deletion",
"."
] | 23fa78efda9c24e2e1579917967537a3b3b9e4ce | https://github.com/rinvex/obsolete-attributable/blob/23fa78efda9c24e2e1579917967537a3b3b9e4ce/src/Events/EntityWasDeleted.php#L19-L37 |
2,749 | bushbaby/BsbDoctrineTranslationLoader | src/BsbDoctrineTranslationLoader/Util/ConfigManipulate.php | ConfigManipulate.replaceKey | final protected static function replaceKey($data, $search, $replace)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$data[$key] = $value = self::replaceKey($data[$key], $search, $replace);
}
if ($key == $search) {
$data[$replace] = $value;
unset($data[$search]);
}
}
return $data;
} | php | final protected static function replaceKey($data, $search, $replace)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$data[$key] = $value = self::replaceKey($data[$key], $search, $replace);
}
if ($key == $search) {
$data[$replace] = $value;
unset($data[$search]);
}
}
return $data;
} | [
"final",
"protected",
"static",
"function",
"replaceKey",
"(",
"$",
"data",
",",
"$",
"search",
",",
"$",
"replace",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"=",
"self",
"::",
"replaceKey",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
",",
"$",
"search",
",",
"$",
"replace",
")",
";",
"}",
"if",
"(",
"$",
"key",
"==",
"$",
"search",
")",
"{",
"$",
"data",
"[",
"$",
"replace",
"]",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"search",
"]",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Recursively replace keys of associative arrays
@param array $data
@param string $search
@param string $replace
@return array | [
"Recursively",
"replace",
"keys",
"of",
"associative",
"arrays"
] | a80309522bf4fe118a3e66d86d5344407068f27b | https://github.com/bushbaby/BsbDoctrineTranslationLoader/blob/a80309522bf4fe118a3e66d86d5344407068f27b/src/BsbDoctrineTranslationLoader/Util/ConfigManipulate.php#L40-L53 |
2,750 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php | StringUtils.getRegisteredWrappers | public static function getRegisteredWrappers()
{
if (static::$wrapperRegistry === null) {
static::$wrapperRegistry = [];
if (extension_loaded('intl')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Intl';
}
if (extension_loaded('mbstring')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\MbString';
}
if (extension_loaded('iconv')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Iconv';
}
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Native';
}
return static::$wrapperRegistry;
} | php | public static function getRegisteredWrappers()
{
if (static::$wrapperRegistry === null) {
static::$wrapperRegistry = [];
if (extension_loaded('intl')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Intl';
}
if (extension_loaded('mbstring')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\MbString';
}
if (extension_loaded('iconv')) {
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Iconv';
}
static::$wrapperRegistry[] = 'Zend\Stdlib\StringWrapper\Native';
}
return static::$wrapperRegistry;
} | [
"public",
"static",
"function",
"getRegisteredWrappers",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"wrapperRegistry",
"===",
"null",
")",
"{",
"static",
"::",
"$",
"wrapperRegistry",
"=",
"[",
"]",
";",
"if",
"(",
"extension_loaded",
"(",
"'intl'",
")",
")",
"{",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"]",
"=",
"'Zend\\Stdlib\\StringWrapper\\Intl'",
";",
"}",
"if",
"(",
"extension_loaded",
"(",
"'mbstring'",
")",
")",
"{",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"]",
"=",
"'Zend\\Stdlib\\StringWrapper\\MbString'",
";",
"}",
"if",
"(",
"extension_loaded",
"(",
"'iconv'",
")",
")",
"{",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"]",
"=",
"'Zend\\Stdlib\\StringWrapper\\Iconv'",
";",
"}",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"]",
"=",
"'Zend\\Stdlib\\StringWrapper\\Native'",
";",
"}",
"return",
"static",
"::",
"$",
"wrapperRegistry",
";",
"}"
] | Get registered wrapper classes
@return string[] | [
"Get",
"registered",
"wrapper",
"classes"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php#L55-L76 |
2,751 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php | StringUtils.registerWrapper | public static function registerWrapper($wrapper)
{
$wrapper = (string) $wrapper;
if (!in_array($wrapper, static::$wrapperRegistry, true)) {
static::$wrapperRegistry[] = $wrapper;
}
} | php | public static function registerWrapper($wrapper)
{
$wrapper = (string) $wrapper;
if (!in_array($wrapper, static::$wrapperRegistry, true)) {
static::$wrapperRegistry[] = $wrapper;
}
} | [
"public",
"static",
"function",
"registerWrapper",
"(",
"$",
"wrapper",
")",
"{",
"$",
"wrapper",
"=",
"(",
"string",
")",
"$",
"wrapper",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"wrapper",
",",
"static",
"::",
"$",
"wrapperRegistry",
",",
"true",
")",
")",
"{",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"]",
"=",
"$",
"wrapper",
";",
"}",
"}"
] | Register a string wrapper class
@param string $wrapper
@return void | [
"Register",
"a",
"string",
"wrapper",
"class"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php#L84-L90 |
2,752 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php | StringUtils.unregisterWrapper | public static function unregisterWrapper($wrapper)
{
$index = array_search((string) $wrapper, static::$wrapperRegistry, true);
if ($index !== false) {
unset(static::$wrapperRegistry[$index]);
}
} | php | public static function unregisterWrapper($wrapper)
{
$index = array_search((string) $wrapper, static::$wrapperRegistry, true);
if ($index !== false) {
unset(static::$wrapperRegistry[$index]);
}
} | [
"public",
"static",
"function",
"unregisterWrapper",
"(",
"$",
"wrapper",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"(",
"string",
")",
"$",
"wrapper",
",",
"static",
"::",
"$",
"wrapperRegistry",
",",
"true",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"unset",
"(",
"static",
"::",
"$",
"wrapperRegistry",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}"
] | Unregister a string wrapper class
@param string $wrapper
@return void | [
"Unregister",
"a",
"string",
"wrapper",
"class"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php#L98-L104 |
2,753 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php | StringUtils.getWrapper | public static function getWrapper($encoding = 'UTF-8', $convertEncoding = null)
{
foreach (static::getRegisteredWrappers() as $wrapperClass) {
if ($wrapperClass::isSupported($encoding, $convertEncoding)) {
$wrapper = new $wrapperClass($encoding, $convertEncoding);
$wrapper->setEncoding($encoding, $convertEncoding);
return $wrapper;
}
}
throw new Exception\RuntimeException(
'No wrapper found supporting "' . $encoding . '"'
. (($convertEncoding !== null) ? ' and "' . $convertEncoding . '"' : '')
);
} | php | public static function getWrapper($encoding = 'UTF-8', $convertEncoding = null)
{
foreach (static::getRegisteredWrappers() as $wrapperClass) {
if ($wrapperClass::isSupported($encoding, $convertEncoding)) {
$wrapper = new $wrapperClass($encoding, $convertEncoding);
$wrapper->setEncoding($encoding, $convertEncoding);
return $wrapper;
}
}
throw new Exception\RuntimeException(
'No wrapper found supporting "' . $encoding . '"'
. (($convertEncoding !== null) ? ' and "' . $convertEncoding . '"' : '')
);
} | [
"public",
"static",
"function",
"getWrapper",
"(",
"$",
"encoding",
"=",
"'UTF-8'",
",",
"$",
"convertEncoding",
"=",
"null",
")",
"{",
"foreach",
"(",
"static",
"::",
"getRegisteredWrappers",
"(",
")",
"as",
"$",
"wrapperClass",
")",
"{",
"if",
"(",
"$",
"wrapperClass",
"::",
"isSupported",
"(",
"$",
"encoding",
",",
"$",
"convertEncoding",
")",
")",
"{",
"$",
"wrapper",
"=",
"new",
"$",
"wrapperClass",
"(",
"$",
"encoding",
",",
"$",
"convertEncoding",
")",
";",
"$",
"wrapper",
"->",
"setEncoding",
"(",
"$",
"encoding",
",",
"$",
"convertEncoding",
")",
";",
"return",
"$",
"wrapper",
";",
"}",
"}",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'No wrapper found supporting \"'",
".",
"$",
"encoding",
".",
"'\"'",
".",
"(",
"(",
"$",
"convertEncoding",
"!==",
"null",
")",
"?",
"' and \"'",
".",
"$",
"convertEncoding",
".",
"'\"'",
":",
"''",
")",
")",
";",
"}"
] | Get the first string wrapper supporting the given character encoding
and supports to convert into the given convert encoding.
@param string $encoding Character encoding to support
@param string|null $convertEncoding OPTIONAL character encoding to convert in
@return StringWrapperInterface
@throws Exception\RuntimeException If no wrapper supports given character encodings | [
"Get",
"the",
"first",
"string",
"wrapper",
"supporting",
"the",
"given",
"character",
"encoding",
"and",
"supports",
"to",
"convert",
"into",
"the",
"given",
"convert",
"encoding",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringUtils.php#L125-L139 |
2,754 | tentwofour/formatter | src/Ten24/Component/Formatter/PhoneNumberFormatter.php | PhoneNumberFormatter.format | public function format()
{
if (strlen($this->phoneNumber) >= 7)
{
return sprintf($this->format,
$this->getCountryCode(),
$this->getAreaCode(),
$this->getPrefix(),
$this->getLineNumber());
}
return null;
} | php | public function format()
{
if (strlen($this->phoneNumber) >= 7)
{
return sprintf($this->format,
$this->getCountryCode(),
$this->getAreaCode(),
$this->getPrefix(),
$this->getLineNumber());
}
return null;
} | [
"public",
"function",
"format",
"(",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"phoneNumber",
")",
">=",
"7",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"format",
",",
"$",
"this",
"->",
"getCountryCode",
"(",
")",
",",
"$",
"this",
"->",
"getAreaCode",
"(",
")",
",",
"$",
"this",
"->",
"getPrefix",
"(",
")",
",",
"$",
"this",
"->",
"getLineNumber",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get formatted phone number for display
This assumes a flattened format like 11235551234
@return string | [
"Get",
"formatted",
"phone",
"number",
"for",
"display",
"This",
"assumes",
"a",
"flattened",
"format",
"like",
"11235551234"
] | 6474284a75f2c29f92a795c296cbcd4dedd6f751 | https://github.com/tentwofour/formatter/blob/6474284a75f2c29f92a795c296cbcd4dedd6f751/src/Ten24/Component/Formatter/PhoneNumberFormatter.php#L103-L115 |
2,755 | tentwofour/formatter | src/Ten24/Component/Formatter/PhoneNumberFormatter.php | PhoneNumberFormatter.getComponent | public function getComponent($component = null)
{
if (null === $this->components)
{
$pattern = '/
(?<countryCode>(\+?\d{1,2})?\D*) # optional country code
(?<areaCode>(\d{3})?\D*) # optional area code
(?<prefix>(\d{3})\D*) # first three (prefix)
(?<lineNumber>(\d{4})) # last four (line number)
(?<extensionDelimiter>(?:\D+|$)) # extension delimiter or EOL
(?<extension>(\d*)) # optional extension
/x';
if (preg_match($pattern, $this->phoneNumber, $matches))
{
// Matches will be
// Array
//(
// [0] => +11235551234x999
// [1] => +1
// [2] => 123
// [3] => 555
// [4] => 1234
// [5] => x
// [6] => 999
//)
$this->components = $matches;
}
}
switch ($component)
{
case self::COUNTRY_CODE:
return !empty($this->components['countryCode']) ? $this->components['countryCode'] : '+1';
break;
case self::AREA_CODE:
return $this->components['areaCode'];
break;
case self::PREFIX:
return $this->components['prefix'];
break;
case self::LINE_NUMBER:
return $this->components['lineNumber'];
break;
case self::EXTENSION_DELIMITER:
return $this->components['extensionDelimiter'];
break;
case self::EXTENSION:
return $this->components['extension'];
break;
default:
return null;
}
} | php | public function getComponent($component = null)
{
if (null === $this->components)
{
$pattern = '/
(?<countryCode>(\+?\d{1,2})?\D*) # optional country code
(?<areaCode>(\d{3})?\D*) # optional area code
(?<prefix>(\d{3})\D*) # first three (prefix)
(?<lineNumber>(\d{4})) # last four (line number)
(?<extensionDelimiter>(?:\D+|$)) # extension delimiter or EOL
(?<extension>(\d*)) # optional extension
/x';
if (preg_match($pattern, $this->phoneNumber, $matches))
{
// Matches will be
// Array
//(
// [0] => +11235551234x999
// [1] => +1
// [2] => 123
// [3] => 555
// [4] => 1234
// [5] => x
// [6] => 999
//)
$this->components = $matches;
}
}
switch ($component)
{
case self::COUNTRY_CODE:
return !empty($this->components['countryCode']) ? $this->components['countryCode'] : '+1';
break;
case self::AREA_CODE:
return $this->components['areaCode'];
break;
case self::PREFIX:
return $this->components['prefix'];
break;
case self::LINE_NUMBER:
return $this->components['lineNumber'];
break;
case self::EXTENSION_DELIMITER:
return $this->components['extensionDelimiter'];
break;
case self::EXTENSION:
return $this->components['extension'];
break;
default:
return null;
}
} | [
"public",
"function",
"getComponent",
"(",
"$",
"component",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"components",
")",
"{",
"$",
"pattern",
"=",
"'/\n (?<countryCode>(\\+?\\d{1,2})?\\D*) # optional country code\n (?<areaCode>(\\d{3})?\\D*) # optional area code\n (?<prefix>(\\d{3})\\D*) # first three (prefix)\n (?<lineNumber>(\\d{4})) # last four (line number)\n (?<extensionDelimiter>(?:\\D+|$)) # extension delimiter or EOL\n (?<extension>(\\d*)) # optional extension\n /x'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"phoneNumber",
",",
"$",
"matches",
")",
")",
"{",
"// Matches will be",
"// Array",
"//(",
"// [0] => +11235551234x999",
"// [1] => +1",
"// [2] => 123",
"// [3] => 555",
"// [4] => 1234",
"// [5] => x",
"// [6] => 999",
"//)",
"$",
"this",
"->",
"components",
"=",
"$",
"matches",
";",
"}",
"}",
"switch",
"(",
"$",
"component",
")",
"{",
"case",
"self",
"::",
"COUNTRY_CODE",
":",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"components",
"[",
"'countryCode'",
"]",
")",
"?",
"$",
"this",
"->",
"components",
"[",
"'countryCode'",
"]",
":",
"'+1'",
";",
"break",
";",
"case",
"self",
"::",
"AREA_CODE",
":",
"return",
"$",
"this",
"->",
"components",
"[",
"'areaCode'",
"]",
";",
"break",
";",
"case",
"self",
"::",
"PREFIX",
":",
"return",
"$",
"this",
"->",
"components",
"[",
"'prefix'",
"]",
";",
"break",
";",
"case",
"self",
"::",
"LINE_NUMBER",
":",
"return",
"$",
"this",
"->",
"components",
"[",
"'lineNumber'",
"]",
";",
"break",
";",
"case",
"self",
"::",
"EXTENSION_DELIMITER",
":",
"return",
"$",
"this",
"->",
"components",
"[",
"'extensionDelimiter'",
"]",
";",
"break",
";",
"case",
"self",
"::",
"EXTENSION",
":",
"return",
"$",
"this",
"->",
"components",
"[",
"'extension'",
"]",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"}",
"}"
] | Get phone number component
@param null $component
@return null | [
"Get",
"phone",
"number",
"component"
] | 6474284a75f2c29f92a795c296cbcd4dedd6f751 | https://github.com/tentwofour/formatter/blob/6474284a75f2c29f92a795c296cbcd4dedd6f751/src/Ten24/Component/Formatter/PhoneNumberFormatter.php#L177-L230 |
2,756 | tentwofour/formatter | src/Ten24/Component/Formatter/PhoneNumberFormatter.php | PhoneNumberFormatter.setDisplayFormat | public function setDisplayFormat($displayFormat = self::FORMAT_NA)
{
if (substr_count($displayFormat, '%d') !== 4)
{
throw new \BadFunctionCallException('The format passed must be passed in the sprintf() format, and have exactly 4 digit components');
}
$this->displayFormat = $displayFormat;
} | php | public function setDisplayFormat($displayFormat = self::FORMAT_NA)
{
if (substr_count($displayFormat, '%d') !== 4)
{
throw new \BadFunctionCallException('The format passed must be passed in the sprintf() format, and have exactly 4 digit components');
}
$this->displayFormat = $displayFormat;
} | [
"public",
"function",
"setDisplayFormat",
"(",
"$",
"displayFormat",
"=",
"self",
"::",
"FORMAT_NA",
")",
"{",
"if",
"(",
"substr_count",
"(",
"$",
"displayFormat",
",",
"'%d'",
")",
"!==",
"4",
")",
"{",
"throw",
"new",
"\\",
"BadFunctionCallException",
"(",
"'The format passed must be passed in the sprintf() format, and have exactly 4 digit components'",
")",
";",
"}",
"$",
"this",
"->",
"displayFormat",
"=",
"$",
"displayFormat",
";",
"}"
] | Sets the display format
@param string $displayFormat
@throws \BadFunctionCallException | [
"Sets",
"the",
"display",
"format"
] | 6474284a75f2c29f92a795c296cbcd4dedd6f751 | https://github.com/tentwofour/formatter/blob/6474284a75f2c29f92a795c296cbcd4dedd6f751/src/Ten24/Component/Formatter/PhoneNumberFormatter.php#L268-L276 |
2,757 | tourze/model | src/Support/ActiveRecord.php | ActiveRecord.labels | public function labels($labels = null)
{
if ($labels === null)
{
return $this->_labels;
}
$this->_labels = $labels;
return $this;
} | php | public function labels($labels = null)
{
if ($labels === null)
{
return $this->_labels;
}
$this->_labels = $labels;
return $this;
} | [
"public",
"function",
"labels",
"(",
"$",
"labels",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"labels",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_labels",
";",
"}",
"$",
"this",
"->",
"_labels",
"=",
"$",
"labels",
";",
"return",
"$",
"this",
";",
"}"
] | Label definitions for validation
@param null $labels
@return array | [
"Label",
"definitions",
"for",
"validation"
] | 1fd8fb141f47f320f3f20b369d127b0b89f82986 | https://github.com/tourze/model/blob/1fd8fb141f47f320f3f20b369d127b0b89f82986/src/Support/ActiveRecord.php#L106-L115 |
2,758 | tourze/model | src/Support/ActiveRecord.php | ActiveRecord.param | public function param($param, $value, $type = null)
{
return $this->setParameter($param, $value, $type);
} | php | public function param($param, $value, $type = null)
{
return $this->setParameter($param, $value, $type);
} | [
"public",
"function",
"param",
"(",
"$",
"param",
",",
"$",
"value",
",",
"$",
"type",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"param",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}"
] | Set the value of a parameter in the query.
@param string $param parameter key to replace
@param mixed $value value to use
@param null $type
@return $this | [
"Set",
"the",
"value",
"of",
"a",
"parameter",
"in",
"the",
"query",
"."
] | 1fd8fb141f47f320f3f20b369d127b0b89f82986 | https://github.com/tourze/model/blob/1fd8fb141f47f320f3f20b369d127b0b89f82986/src/Support/ActiveRecord.php#L1066-L1069 |
2,759 | phlexible/phlexible | src/Phlexible/Component/MediaExtractor/Transmutor.php | Transmutor.transmute | public function transmute(InputDescriptor $input, $targetFormat)
{
if (!in_array($targetFormat, array('image', 'audio', 'video', 'flash', 'text'))) {
return null;
}
$mediaType = $this->mediaTypeManager->find($input->getMediaType());
return $this->extractor->extract($input, $mediaType, $targetFormat);
} | php | public function transmute(InputDescriptor $input, $targetFormat)
{
if (!in_array($targetFormat, array('image', 'audio', 'video', 'flash', 'text'))) {
return null;
}
$mediaType = $this->mediaTypeManager->find($input->getMediaType());
return $this->extractor->extract($input, $mediaType, $targetFormat);
} | [
"public",
"function",
"transmute",
"(",
"InputDescriptor",
"$",
"input",
",",
"$",
"targetFormat",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"targetFormat",
",",
"array",
"(",
"'image'",
",",
"'audio'",
",",
"'video'",
",",
"'flash'",
",",
"'text'",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"mediaType",
"=",
"$",
"this",
"->",
"mediaTypeManager",
"->",
"find",
"(",
"$",
"input",
"->",
"getMediaType",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"extractor",
"->",
"extract",
"(",
"$",
"input",
",",
"$",
"mediaType",
",",
"$",
"targetFormat",
")",
";",
"}"
] | Transmute file to target format.
@param InputDescriptor $input
@param string $targetFormat
@return string | [
"Transmute",
"file",
"to",
"target",
"format",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MediaExtractor/Transmutor.php#L53-L62 |
2,760 | laradic/service-provider | src/Plugins/Bindings.php | Bindings.startBindingsPlugin | protected function startBindingsPlugin($app)
{
/* @var \Illuminate\Foundation\Application $app */
$this->requiresPlugins(Commands::class, Events::class);
$this->onRegister('bindings', function (Application $app) {
// Container bindings and aliases
$legacy = ! class_exists('Illuminate\Foundation\Application') || version_compare(\Illuminate\Foundation\Application::VERSION, '5.7.0', '<');
if ($legacy) {
foreach ($this->bindings as $binding => $class) {
$this->app->bind($binding, $class);
}
}
foreach ($this->weaklings as $binding => $class) {
$this->bindIf($binding, $class);
}
foreach ([ 'share' => $this->share, 'shared' => $this->shared ] as $type => $bindings) {
foreach ($bindings as $binding => $class) {
$this->share($binding, $class, [], $type === 'shared');
}
}
if ($legacy) {
foreach ($this->singletons as $binding => $class) {
if ($this->strict && ! class_exists($class) && ! interface_exists($class)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->singleton($binding, $class);
}
}
foreach ($this->aliases as $alias => $full) {
if ($this->strict && ! class_exists($full) && ! interface_exists($full)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->alias($alias, $full);
}
});
} | php | protected function startBindingsPlugin($app)
{
/* @var \Illuminate\Foundation\Application $app */
$this->requiresPlugins(Commands::class, Events::class);
$this->onRegister('bindings', function (Application $app) {
// Container bindings and aliases
$legacy = ! class_exists('Illuminate\Foundation\Application') || version_compare(\Illuminate\Foundation\Application::VERSION, '5.7.0', '<');
if ($legacy) {
foreach ($this->bindings as $binding => $class) {
$this->app->bind($binding, $class);
}
}
foreach ($this->weaklings as $binding => $class) {
$this->bindIf($binding, $class);
}
foreach ([ 'share' => $this->share, 'shared' => $this->shared ] as $type => $bindings) {
foreach ($bindings as $binding => $class) {
$this->share($binding, $class, [], $type === 'shared');
}
}
if ($legacy) {
foreach ($this->singletons as $binding => $class) {
if ($this->strict && ! class_exists($class) && ! interface_exists($class)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->singleton($binding, $class);
}
}
foreach ($this->aliases as $alias => $full) {
if ($this->strict && ! class_exists($full) && ! interface_exists($full)) {
throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled");
}
$this->app->alias($alias, $full);
}
});
} | [
"protected",
"function",
"startBindingsPlugin",
"(",
"$",
"app",
")",
"{",
"/* @var \\Illuminate\\Foundation\\Application $app */",
"$",
"this",
"->",
"requiresPlugins",
"(",
"Commands",
"::",
"class",
",",
"Events",
"::",
"class",
")",
";",
"$",
"this",
"->",
"onRegister",
"(",
"'bindings'",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"// Container bindings and aliases",
"$",
"legacy",
"=",
"!",
"class_exists",
"(",
"'Illuminate\\Foundation\\Application'",
")",
"||",
"version_compare",
"(",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"Application",
"::",
"VERSION",
",",
"'5.7.0'",
",",
"'<'",
")",
";",
"if",
"(",
"$",
"legacy",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"bindings",
"as",
"$",
"binding",
"=>",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"$",
"binding",
",",
"$",
"class",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"weaklings",
"as",
"$",
"binding",
"=>",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"bindIf",
"(",
"$",
"binding",
",",
"$",
"class",
")",
";",
"}",
"foreach",
"(",
"[",
"'share'",
"=>",
"$",
"this",
"->",
"share",
",",
"'shared'",
"=>",
"$",
"this",
"->",
"shared",
"]",
"as",
"$",
"type",
"=>",
"$",
"bindings",
")",
"{",
"foreach",
"(",
"$",
"bindings",
"as",
"$",
"binding",
"=>",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"share",
"(",
"$",
"binding",
",",
"$",
"class",
",",
"[",
"]",
",",
"$",
"type",
"===",
"'shared'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"legacy",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"singletons",
"as",
"$",
"binding",
"=>",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"strict",
"&&",
"!",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"get_called_class",
"(",
")",
".",
"\": Could not find alias class [{$class}]. This exception is only thrown when \\$strict checking is enabled\"",
")",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"$",
"binding",
",",
"$",
"class",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"aliases",
"as",
"$",
"alias",
"=>",
"$",
"full",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"strict",
"&&",
"!",
"class_exists",
"(",
"$",
"full",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"full",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"get_called_class",
"(",
")",
".",
"\": Could not find alias class [{$full}]. This exception is only thrown when \\$strict checking is enabled\"",
")",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"$",
"alias",
",",
"$",
"full",
")",
";",
"}",
"}",
")",
";",
"}"
] | startBindingsPlugin method.
@param \Illuminate\Foundation\Application $app | [
"startBindingsPlugin",
"method",
"."
] | b1428d566b97b3662b405c64ff0cad8a89102033 | https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Bindings.php#L85-L126 |
2,761 | laradic/service-provider | src/Plugins/Bindings.php | Bindings.bindIf | protected function bindIf($abstract, $concrete = null, $shared = true, $alias = null)
{
if ( ! $this->app->bound($abstract)) {
$concrete = $concrete ?: $abstract;
$this->app->bind($abstract, $concrete, $shared);
}
} | php | protected function bindIf($abstract, $concrete = null, $shared = true, $alias = null)
{
if ( ! $this->app->bound($abstract)) {
$concrete = $concrete ?: $abstract;
$this->app->bind($abstract, $concrete, $shared);
}
} | [
"protected",
"function",
"bindIf",
"(",
"$",
"abstract",
",",
"$",
"concrete",
"=",
"null",
",",
"$",
"shared",
"=",
"true",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"bound",
"(",
"$",
"abstract",
")",
")",
"{",
"$",
"concrete",
"=",
"$",
"concrete",
"?",
":",
"$",
"abstract",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"$",
"abstract",
",",
"$",
"concrete",
",",
"$",
"shared",
")",
";",
"}",
"}"
] | Registers a binding if it hasn't already been registered.
@param string $abstract
@param \Closure|string|null $concrete
@param bool $shared
@param bool|string|null $alias | [
"Registers",
"a",
"binding",
"if",
"it",
"hasn",
"t",
"already",
"been",
"registered",
"."
] | b1428d566b97b3662b405c64ff0cad8a89102033 | https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Bindings.php#L136-L143 |
2,762 | inceddy/everest-http | src/Everest/Http/RoutingContext.php | RoutingContext.getPrefixedPath | public function getPrefixedPath(string $path = '') : string
{
return trim($this->parent ?
($this->parent->getPrefixedPath($this->prefix ? $this->prefix . '/' . $path : $path)) :
($this->prefix ? $this->prefix . '/' . $path : $path), '/');
} | php | public function getPrefixedPath(string $path = '') : string
{
return trim($this->parent ?
($this->parent->getPrefixedPath($this->prefix ? $this->prefix . '/' . $path : $path)) :
($this->prefix ? $this->prefix . '/' . $path : $path), '/');
} | [
"public",
"function",
"getPrefixedPath",
"(",
"string",
"$",
"path",
"=",
"''",
")",
":",
"string",
"{",
"return",
"trim",
"(",
"$",
"this",
"->",
"parent",
"?",
"(",
"$",
"this",
"->",
"parent",
"->",
"getPrefixedPath",
"(",
"$",
"this",
"->",
"prefix",
"?",
"$",
"this",
"->",
"prefix",
".",
"'/'",
".",
"$",
"path",
":",
"$",
"path",
")",
")",
":",
"(",
"$",
"this",
"->",
"prefix",
"?",
"$",
"this",
"->",
"prefix",
".",
"'/'",
".",
"$",
"path",
":",
"$",
"path",
")",
",",
"'/'",
")",
";",
"}"
] | Gets path prefix of this context and all its parents
@param string $path (optional)
The parents prefix
@return string
The prefixed path | [
"Gets",
"path",
"prefix",
"of",
"this",
"context",
"and",
"all",
"its",
"parents"
] | b0f6cbb6723aa96213d28c35b52e03833113be0e | https://github.com/inceddy/everest-http/blob/b0f6cbb6723aa96213d28c35b52e03833113be0e/src/Everest/Http/RoutingContext.php#L171-L176 |
2,763 | inceddy/everest-http | src/Everest/Http/RoutingContext.php | RoutingContext.addMiddleware | public function addMiddleware(callable $middleware, string $type = self::BEFORE)
{
; $type = self::validateMiddlewareType($type);
$this->middlewares[$type][] = $middleware;
} | php | public function addMiddleware(callable $middleware, string $type = self::BEFORE)
{
; $type = self::validateMiddlewareType($type);
$this->middlewares[$type][] = $middleware;
} | [
"public",
"function",
"addMiddleware",
"(",
"callable",
"$",
"middleware",
",",
"string",
"$",
"type",
"=",
"self",
"::",
"BEFORE",
")",
"{",
";",
"$",
"type",
"=",
"self",
"::",
"validateMiddlewareType",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"middlewares",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"middleware",
";",
"}"
] | Adds a new middleware to this context
@param callable $middleware
The middleware
@return void | [
"Adds",
"a",
"new",
"middleware",
"to",
"this",
"context"
] | b0f6cbb6723aa96213d28c35b52e03833113be0e | https://github.com/inceddy/everest-http/blob/b0f6cbb6723aa96213d28c35b52e03833113be0e/src/Everest/Http/RoutingContext.php#L218-L222 |
2,764 | inceddy/everest-http | src/Everest/Http/RoutingContext.php | RoutingContext.addSubContext | public function addSubContext(string $prefix, Closure $invoker) : RoutingContext
{
return $this->contexts[] = new RoutingContext($prefix, $invoker, $this);
} | php | public function addSubContext(string $prefix, Closure $invoker) : RoutingContext
{
return $this->contexts[] = new RoutingContext($prefix, $invoker, $this);
} | [
"public",
"function",
"addSubContext",
"(",
"string",
"$",
"prefix",
",",
"Closure",
"$",
"invoker",
")",
":",
"RoutingContext",
"{",
"return",
"$",
"this",
"->",
"contexts",
"[",
"]",
"=",
"new",
"RoutingContext",
"(",
"$",
"prefix",
",",
"$",
"invoker",
",",
"$",
"this",
")",
";",
"}"
] | Adds a new sub context to this context
@param string $prefix
The path prefix of this context
@param Closure $invoker
The closure invoking the new sub context
@return Everest\Http\RoutingContext
The new sub context | [
"Adds",
"a",
"new",
"sub",
"context",
"to",
"this",
"context"
] | b0f6cbb6723aa96213d28c35b52e03833113be0e | https://github.com/inceddy/everest-http/blob/b0f6cbb6723aa96213d28c35b52e03833113be0e/src/Everest/Http/RoutingContext.php#L285-L288 |
2,765 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme | function it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme()
{
$original_uri = (string) $this->getWrappedObject();
$new_scheme = $this->withScheme("http");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme()
{
$original_uri = (string) $this->getWrappedObject();
$new_scheme = $this->withScheme("http");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_scheme",
"=",
"$",
"this",
"->",
"withScheme",
"(",
"\"http\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified scheme. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"scheme",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L438-L445 |
2,766 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_new_authority | function it_retains_the_original_state_of_the_instance_duplicated_with_new_authority()
{
$original_uri = (string) $this->getWrappedObject();
$new_authority = $this->withAuthority("corge:[email protected]:9999");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_new_authority()
{
$original_uri = (string) $this->getWrappedObject();
$new_authority = $this->withAuthority("corge:[email protected]:9999");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_new_authority",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_authority",
"=",
"$",
"this",
"->",
"withAuthority",
"(",
"\"corge:[email protected]:9999\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified authority. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"authority",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L508-L515 |
2,767 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_replaces_authority_components_with_new_authority | function it_replaces_authority_components_with_new_authority()
{
$new_authority = $this->withAuthority("corge:[email protected]:9999");
$new_authority->getAuthority()->shouldReturn("corge:[email protected]:9999");
$new_authority->getUserInfo()->shouldReturn("corge:grault");
$new_authority->getHost()->shouldReturn("quux.qux");
$new_authority->getPort()->shouldReturn(9999);
} | php | function it_replaces_authority_components_with_new_authority()
{
$new_authority = $this->withAuthority("corge:[email protected]:9999");
$new_authority->getAuthority()->shouldReturn("corge:[email protected]:9999");
$new_authority->getUserInfo()->shouldReturn("corge:grault");
$new_authority->getHost()->shouldReturn("quux.qux");
$new_authority->getPort()->shouldReturn(9999);
} | [
"function",
"it_replaces_authority_components_with_new_authority",
"(",
")",
"{",
"$",
"new_authority",
"=",
"$",
"this",
"->",
"withAuthority",
"(",
"\"corge:[email protected]:9999\"",
")",
";",
"$",
"new_authority",
"->",
"getAuthority",
"(",
")",
"->",
"shouldReturn",
"(",
"\"corge:[email protected]:9999\"",
")",
";",
"$",
"new_authority",
"->",
"getUserInfo",
"(",
")",
"->",
"shouldReturn",
"(",
"\"corge:grault\"",
")",
";",
"$",
"new_authority",
"->",
"getHost",
"(",
")",
"->",
"shouldReturn",
"(",
"\"quux.qux\"",
")",
";",
"$",
"new_authority",
"->",
"getPort",
"(",
")",
"->",
"shouldReturn",
"(",
"9999",
")",
";",
"}"
] | Replacing the authority is equivalent to replacing or removing all authority components depending upon the
composition of the authority. | [
"Replacing",
"the",
"authority",
"is",
"equivalent",
"to",
"replacing",
"or",
"removing",
"all",
"authority",
"components",
"depending",
"upon",
"the",
"composition",
"of",
"the",
"authority",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L521-L529 |
2,768 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_removes_authority_components_with_empty_authority | function it_removes_authority_components_with_empty_authority()
{
$new_authority = $this->withAuthority("");
$new_authority->getAuthority()->shouldReturn("");
$new_authority->getUserInfo()->shouldReturn("");
$new_authority->getHost()->shouldReturn("");
$new_authority->getPort()->shouldReturn(null);
} | php | function it_removes_authority_components_with_empty_authority()
{
$new_authority = $this->withAuthority("");
$new_authority->getAuthority()->shouldReturn("");
$new_authority->getUserInfo()->shouldReturn("");
$new_authority->getHost()->shouldReturn("");
$new_authority->getPort()->shouldReturn(null);
} | [
"function",
"it_removes_authority_components_with_empty_authority",
"(",
")",
"{",
"$",
"new_authority",
"=",
"$",
"this",
"->",
"withAuthority",
"(",
"\"\"",
")",
";",
"$",
"new_authority",
"->",
"getAuthority",
"(",
")",
"->",
"shouldReturn",
"(",
"\"\"",
")",
";",
"$",
"new_authority",
"->",
"getUserInfo",
"(",
")",
"->",
"shouldReturn",
"(",
"\"\"",
")",
";",
"$",
"new_authority",
"->",
"getHost",
"(",
")",
"->",
"shouldReturn",
"(",
"\"\"",
")",
";",
"$",
"new_authority",
"->",
"getPort",
"(",
")",
"->",
"shouldReturn",
"(",
"null",
")",
";",
"}"
] | An empty authority is equivalent to removing the authority and all authority components. | [
"An",
"empty",
"authority",
"is",
"equivalent",
"to",
"removing",
"the",
"authority",
"and",
"all",
"authority",
"components",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L534-L542 |
2,769 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_new_user_info | function it_retains_the_original_state_of_the_instance_duplicated_with_new_user_info()
{
$original_uri = (string) $this->getWrappedObject();
$new_user_info = $this->withUserInfo("corge", "grault");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_new_user_info()
{
$original_uri = (string) $this->getWrappedObject();
$new_user_info = $this->withUserInfo("corge", "grault");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_new_user_info",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_user_info",
"=",
"$",
"this",
"->",
"withUserInfo",
"(",
"\"corge\"",
",",
"\"grault\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified user information. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"user",
"information",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L577-L584 |
2,770 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_a_new_host | function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_host()
{
$original_uri = (string) $this->getWrappedObject();
$new_host = $this->withHost("quux.qux");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_host()
{
$original_uri = (string) $this->getWrappedObject();
$new_host = $this->withHost("quux.qux");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_a_new_host",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_host",
"=",
"$",
"this",
"->",
"withHost",
"(",
"\"quux.qux\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified host. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"host",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L635-L642 |
2,771 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_a_new_port | function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_port()
{
$original_uri = (string) $this->getWrappedObject();
$new_port = $this->withPort(9999);
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_port()
{
$original_uri = (string) $this->getWrappedObject();
$new_port = $this->withPort(9999);
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_a_new_port",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_port",
"=",
"$",
"this",
"->",
"withPort",
"(",
"9999",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified port. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"port",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L696-L703 |
2,772 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_new_path | function it_retains_the_original_state_of_the_instance_duplicated_with_new_path()
{
$original_uri = (string) $this->getWrappedObject();
$new_path = $this->withPath("/quux/quuz");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_new_path()
{
$original_uri = (string) $this->getWrappedObject();
$new_path = $this->withPath("/quux/quuz");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_new_path",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_path",
"=",
"$",
"this",
"->",
"withPath",
"(",
"\"/quux/quuz\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified path. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"path",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L764-L771 |
2,773 | ddehart/dilmun | spec/Anshar/Http/UriSpec.php | UriSpec.it_retains_the_original_state_of_the_instance_duplicated_with_new_query | function it_retains_the_original_state_of_the_instance_duplicated_with_new_query()
{
$original_uri = (string) $this->getWrappedObject();
$new_query = $this->withQuery("garply");
$this->__toString()->shouldReturn($original_uri);
} | php | function it_retains_the_original_state_of_the_instance_duplicated_with_new_query()
{
$original_uri = (string) $this->getWrappedObject();
$new_query = $this->withQuery("garply");
$this->__toString()->shouldReturn($original_uri);
} | [
"function",
"it_retains_the_original_state_of_the_instance_duplicated_with_new_query",
"(",
")",
"{",
"$",
"original_uri",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getWrappedObject",
"(",
")",
";",
"$",
"new_query",
"=",
"$",
"this",
"->",
"withQuery",
"(",
"\"garply\"",
")",
";",
"$",
"this",
"->",
"__toString",
"(",
")",
"->",
"shouldReturn",
"(",
"$",
"original_uri",
")",
";",
"}"
] | This method MUST retain the state of the current instance, and return
an instance that contains the specified query string. | [
"This",
"method",
"MUST",
"retain",
"the",
"state",
"of",
"the",
"current",
"instance",
"and",
"return",
"an",
"instance",
"that",
"contains",
"the",
"specified",
"query",
"string",
"."
] | e2a294dbcd4c6754063c247be64930c5ee91378f | https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/spec/Anshar/Http/UriSpec.php#L868-L875 |
2,774 | nirix/radium | src/Templating/Engines/DelegationEngine.php | DelegationEngine.supports | public function supports($template)
{
foreach ($this->engines as $engine) {
if ($engine->supports($template)) {
return true;
}
}
return false;
} | php | public function supports($template)
{
foreach ($this->engines as $engine) {
if ($engine->supports($template)) {
return true;
}
}
return false;
} | [
"public",
"function",
"supports",
"(",
"$",
"template",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"engines",
"as",
"$",
"engine",
")",
"{",
"if",
"(",
"$",
"engine",
"->",
"supports",
"(",
"$",
"template",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if any of the engines can render the template.
@param string $template
@return bool | [
"Checks",
"if",
"any",
"of",
"the",
"engines",
"can",
"render",
"the",
"template",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Templating/Engines/DelegationEngine.php#L102-L111 |
2,775 | nirix/radium | src/Templating/Engines/DelegationEngine.php | DelegationEngine.exists | public function exists($template)
{
foreach ($this->engines as $engine) {
if ($engine->supports($template)) {
return $engine->exists($template);
}
}
return false;
} | php | public function exists($template)
{
foreach ($this->engines as $engine) {
if ($engine->supports($template)) {
return $engine->exists($template);
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"$",
"template",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"engines",
"as",
"$",
"engine",
")",
"{",
"if",
"(",
"$",
"engine",
"->",
"supports",
"(",
"$",
"template",
")",
")",
"{",
"return",
"$",
"engine",
"->",
"exists",
"(",
"$",
"template",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if the template exists.
@param string $template
@return bool | [
"Checks",
"if",
"the",
"template",
"exists",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Templating/Engines/DelegationEngine.php#L120-L129 |
2,776 | Puzzlout/FrameworkMvcLegacy | src/GeneratorEngine/Core/ConstantsClassEngineBase.php | ConstantsClassEngineBase.GenerateConstantsClass | protected function GenerateConstantsClass($files) {
if (count($files) > 0) {
$classGen = new ConstantsClassGeneratorBase($this->params, $files);
$classGen->BuildClass();
return str_replace('\\', '/', "file://" . "APP_ROOT_DIR" . $this->params[BaseClassGenerator::NameSpaceKey] . "/" . $classGen->fileName);
} else {
return "No class to generate.";
}
} | php | protected function GenerateConstantsClass($files) {
if (count($files) > 0) {
$classGen = new ConstantsClassGeneratorBase($this->params, $files);
$classGen->BuildClass();
return str_replace('\\', '/', "file://" . "APP_ROOT_DIR" . $this->params[BaseClassGenerator::NameSpaceKey] . "/" . $classGen->fileName);
} else {
return "No class to generate.";
}
} | [
"protected",
"function",
"GenerateConstantsClass",
"(",
"$",
"files",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"files",
")",
">",
"0",
")",
"{",
"$",
"classGen",
"=",
"new",
"ConstantsClassGeneratorBase",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"files",
")",
";",
"$",
"classGen",
"->",
"BuildClass",
"(",
")",
";",
"return",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"\"file://\"",
".",
"\"APP_ROOT_DIR\"",
".",
"$",
"this",
"->",
"params",
"[",
"BaseClassGenerator",
"::",
"NameSpaceKey",
"]",
".",
"\"/\"",
".",
"$",
"classGen",
"->",
"fileName",
")",
";",
"}",
"else",
"{",
"return",
"\"No class to generate.\"",
";",
"}",
"}"
] | Generate the Constant Class list the framework.
@param assoc array $params the params composed the namespace and name of the class.
@param array(of String) $files the list of framework files that will make the list of constants | [
"Generate",
"the",
"Constant",
"Class",
"list",
"the",
"framework",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/ConstantsClassEngineBase.php#L47-L55 |
2,777 | Puzzlout/FrameworkMvcLegacy | src/GeneratorEngine/Core/ConstantsClassEngineBase.php | ConstantsClassEngineBase.GenerateFrameworkFile | protected function GenerateFrameworkFile($files) {
$filePath = $this->GenerateConstantsClass($files);
array_push($this->filesGenerated, $filePath);
return $filePath;
} | php | protected function GenerateFrameworkFile($files) {
$filePath = $this->GenerateConstantsClass($files);
array_push($this->filesGenerated, $filePath);
return $filePath;
} | [
"protected",
"function",
"GenerateFrameworkFile",
"(",
"$",
"files",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"GenerateConstantsClass",
"(",
"$",
"files",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"filesGenerated",
",",
"$",
"filePath",
")",
";",
"return",
"$",
"filePath",
";",
"}"
] | Generate the FrameworkControllers.php class.
@param array $files list of filenames | [
"Generate",
"the",
"FrameworkControllers",
".",
"php",
"class",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/ConstantsClassEngineBase.php#L72-L76 |
2,778 | marando/phpSOFA | src/Marando/IAU/iauEform.php | iauEform.Eform | public static function Eform(iauRefEllips $n, &$a, &$f) {
/* Look up a and f for the specified reference ellipsoid. */
switch ($n->value) {
case WGS84:
$a = 6378137.0;
$f = 1.0 / 298.257223563;
break;
case GRS80:
$a = 6378137.0;
$f = 1.0 / 298.257222101;
break;
case WGS72:
$a = 6378135.0;
$f = 1.0 / 298.26;
break;
default:
/* Invalid identifier. */
$a = 0.0;
$f = 0.0;
return -1;
}
/* OK status. */
return 0;
} | php | public static function Eform(iauRefEllips $n, &$a, &$f) {
/* Look up a and f for the specified reference ellipsoid. */
switch ($n->value) {
case WGS84:
$a = 6378137.0;
$f = 1.0 / 298.257223563;
break;
case GRS80:
$a = 6378137.0;
$f = 1.0 / 298.257222101;
break;
case WGS72:
$a = 6378135.0;
$f = 1.0 / 298.26;
break;
default:
/* Invalid identifier. */
$a = 0.0;
$f = 0.0;
return -1;
}
/* OK status. */
return 0;
} | [
"public",
"static",
"function",
"Eform",
"(",
"iauRefEllips",
"$",
"n",
",",
"&",
"$",
"a",
",",
"&",
"$",
"f",
")",
"{",
"/* Look up a and f for the specified reference ellipsoid. */",
"switch",
"(",
"$",
"n",
"->",
"value",
")",
"{",
"case",
"WGS84",
":",
"$",
"a",
"=",
"6378137.0",
";",
"$",
"f",
"=",
"1.0",
"/",
"298.257223563",
";",
"break",
";",
"case",
"GRS80",
":",
"$",
"a",
"=",
"6378137.0",
";",
"$",
"f",
"=",
"1.0",
"/",
"298.257222101",
";",
"break",
";",
"case",
"WGS72",
":",
"$",
"a",
"=",
"6378135.0",
";",
"$",
"f",
"=",
"1.0",
"/",
"298.26",
";",
"break",
";",
"default",
":",
"/* Invalid identifier. */",
"$",
"a",
"=",
"0.0",
";",
"$",
"f",
"=",
"0.0",
";",
"return",
"-",
"1",
";",
"}",
"/* OK status. */",
"return",
"0",
";",
"}"
] | - - - - - - - - -
i a u E f o r m
- - - - - - - - -
Earth reference ellipsoids.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: canonical.
Given:
n int ellipsoid identifier (Note 1)
Returned:
a double equatorial radius (meters, Note 2)
f double flattening (Note 2)
Returned (function value):
int status: 0 = OK
-1 = illegal identifier (Note 3)
Notes:
1) The identifier n is a number that specifies the choice of
reference ellipsoid. The following are supported:
n ellipsoid
1 WGS84
2 GRS80
3 WGS72
The n value has no significance outside the SOFA software. For
convenience, symbols WGS84 etc. are defined in sofam.h.
2) The ellipsoid parameters are returned in the form of equatorial
radius in meters (a) and flattening (f). The latter is a number
around 0.00335, i.e. around 1/298.
3) For the case where an unsupported n value is supplied, zero a and
f are returned, as well as error status.
References:
Department of Defense World Geodetic System 1984, National
Imagery and Mapping Agency Technical Report 8350.2, Third
Edition, p3-2.
Moritz, H., Bull. Geodesique 66-2, 187 (1992).
The Department of Defense World Geodetic System 1972, World
Geodetic System Committee, May 1974.
Explanatory Supplement to the Astronomical Almanac,
P. Kenneth Seidelmann (ed), University Science Books (1992),
p220.
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"E",
"f",
"o",
"r",
"m",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauEform.php#L74-L103 |
2,779 | Subscribo/support | src/Subscribo/Support/Arr.php | Arr.mergeNatural | public static function mergeNatural(array $array1, array $array2)
{
if (empty($array1)) {
return $array2;
}
$result = $array1;
foreach ($array2 as $key => $value) {
if (isset($result[$key]) and is_array($result[$key]) and is_array($value)) {
$result[$key] = static::mergeNatural($result[$key], $value);
} elseif ( ( ! isset($result[$key]) or ( ! is_null($value)))) {
$result[$key] = $value;
}
}
return $result;
} | php | public static function mergeNatural(array $array1, array $array2)
{
if (empty($array1)) {
return $array2;
}
$result = $array1;
foreach ($array2 as $key => $value) {
if (isset($result[$key]) and is_array($result[$key]) and is_array($value)) {
$result[$key] = static::mergeNatural($result[$key], $value);
} elseif ( ( ! isset($result[$key]) or ( ! is_null($value)))) {
$result[$key] = $value;
}
}
return $result;
} | [
"public",
"static",
"function",
"mergeNatural",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array1",
")",
")",
"{",
"return",
"$",
"array2",
";",
"}",
"$",
"result",
"=",
"$",
"array1",
";",
"foreach",
"(",
"$",
"array2",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"and",
"is_array",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"and",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"mergeNatural",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"or",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Merges two arrays recursive "naturally"
Second array values takes precedence, with exception that its value on particular place is null
@param array $array1
@param array $array2
@return array | [
"Merges",
"two",
"arrays",
"recursive",
"naturally",
"Second",
"array",
"values",
"takes",
"precedence",
"with",
"exception",
"that",
"its",
"value",
"on",
"particular",
"place",
"is",
"null"
] | eb9265ecdcc2dc04a4ddc9f18bf41d7221ed02df | https://github.com/Subscribo/support/blob/eb9265ecdcc2dc04a4ddc9f18bf41d7221ed02df/src/Subscribo/Support/Arr.php#L19-L33 |
2,780 | Subscribo/support | src/Subscribo/Support/Arr.php | Arr.filterCaseInsensitively | public static function filterCaseInsensitively(array $needles, array $haystack)
{
$result = array();
$modifiedHaystack = array_change_key_case($haystack, CASE_LOWER);
foreach ($needles as $needle) {
$modifiedNeedle = strtolower($needle);
if (array_key_exists($needle, $haystack)) {
$result[$needle] = $haystack[$needle];
} elseif (array_key_exists($modifiedNeedle, $modifiedHaystack)) {
$result[$needle] = $modifiedHaystack[$modifiedNeedle];
}
}
return $result;
} | php | public static function filterCaseInsensitively(array $needles, array $haystack)
{
$result = array();
$modifiedHaystack = array_change_key_case($haystack, CASE_LOWER);
foreach ($needles as $needle) {
$modifiedNeedle = strtolower($needle);
if (array_key_exists($needle, $haystack)) {
$result[$needle] = $haystack[$needle];
} elseif (array_key_exists($modifiedNeedle, $modifiedHaystack)) {
$result[$needle] = $modifiedHaystack[$modifiedNeedle];
}
}
return $result;
} | [
"public",
"static",
"function",
"filterCaseInsensitively",
"(",
"array",
"$",
"needles",
",",
"array",
"$",
"haystack",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"modifiedHaystack",
"=",
"array_change_key_case",
"(",
"$",
"haystack",
",",
"CASE_LOWER",
")",
";",
"foreach",
"(",
"$",
"needles",
"as",
"$",
"needle",
")",
"{",
"$",
"modifiedNeedle",
"=",
"strtolower",
"(",
"$",
"needle",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"needle",
",",
"$",
"haystack",
")",
")",
"{",
"$",
"result",
"[",
"$",
"needle",
"]",
"=",
"$",
"haystack",
"[",
"$",
"needle",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"modifiedNeedle",
",",
"$",
"modifiedHaystack",
")",
")",
"{",
"$",
"result",
"[",
"$",
"needle",
"]",
"=",
"$",
"modifiedHaystack",
"[",
"$",
"modifiedNeedle",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Filter haystack using values in needles in case insensitive manner if needed
Exact match takes precedence,
If exact match is not found, then case insensitive comparison is made
@param array $needles
@param array $haystack
@return array | [
"Filter",
"haystack",
"using",
"values",
"in",
"needles",
"in",
"case",
"insensitive",
"manner",
"if",
"needed"
] | eb9265ecdcc2dc04a4ddc9f18bf41d7221ed02df | https://github.com/Subscribo/support/blob/eb9265ecdcc2dc04a4ddc9f18bf41d7221ed02df/src/Subscribo/Support/Arr.php#L45-L58 |
2,781 | tadcka/Mapper | src/Tadcka/Mapper/Mapping/MappingProvider.php | MappingProvider.getItemBySource | private function getItemBySource(MappingInterface $mapping, $sourceSlug)
{
if ($sourceSlug === $mapping->getLeftItem()->getSource()->getSlug()) {
return $mapping->getLeftItem();
}
return $mapping->getRightItem();
} | php | private function getItemBySource(MappingInterface $mapping, $sourceSlug)
{
if ($sourceSlug === $mapping->getLeftItem()->getSource()->getSlug()) {
return $mapping->getLeftItem();
}
return $mapping->getRightItem();
} | [
"private",
"function",
"getItemBySource",
"(",
"MappingInterface",
"$",
"mapping",
",",
"$",
"sourceSlug",
")",
"{",
"if",
"(",
"$",
"sourceSlug",
"===",
"$",
"mapping",
"->",
"getLeftItem",
"(",
")",
"->",
"getSource",
"(",
")",
"->",
"getSlug",
"(",
")",
")",
"{",
"return",
"$",
"mapping",
"->",
"getLeftItem",
"(",
")",
";",
"}",
"return",
"$",
"mapping",
"->",
"getRightItem",
"(",
")",
";",
"}"
] | Get item by source.
@param MappingInterface $mapping
@param string $sourceSlug
@return MappingItemInterface | [
"Get",
"item",
"by",
"source",
"."
] | 6853a2be08dcd35a1013c0a4aba9b71a727ff7da | https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Mapping/MappingProvider.php#L96-L103 |
2,782 | tokenly/xcaller-client | src/Tokenly/XcallerClient/Client.php | Client._loadNotificationIntoQueue | public function _loadNotificationIntoQueue($notification_entry) {
$this->queue_manager
->connection($this->queue_connection)
->pushRaw(json_encode($notification_entry), $this->queue_name);
} | php | public function _loadNotificationIntoQueue($notification_entry) {
$this->queue_manager
->connection($this->queue_connection)
->pushRaw(json_encode($notification_entry), $this->queue_name);
} | [
"public",
"function",
"_loadNotificationIntoQueue",
"(",
"$",
"notification_entry",
")",
"{",
"$",
"this",
"->",
"queue_manager",
"->",
"connection",
"(",
"$",
"this",
"->",
"queue_connection",
")",
"->",
"pushRaw",
"(",
"json_encode",
"(",
"$",
"notification_entry",
")",
",",
"$",
"this",
"->",
"queue_name",
")",
";",
"}"
] | public for testing purposes | [
"public",
"for",
"testing",
"purposes"
] | 5205676eff3a3deb99b52d4d54476b7c1d24eea5 | https://github.com/tokenly/xcaller-client/blob/5205676eff3a3deb99b52d4d54476b7c1d24eea5/src/Tokenly/XcallerClient/Client.php#L69-L73 |
2,783 | tadcka/Mapper | src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeItem.php | MapperTreeItem.sortChildren | private function sortChildren()
{
uasort(
$this->children,
function (MapperTreeItemInterface $first, MapperTreeItemInterface $second) {
if ($first->getPriority() >= $second->getPriority()) {
return 1;
}
if ($first->getPriority() < $second->getPriority()) {
return -1;
}
}
);
} | php | private function sortChildren()
{
uasort(
$this->children,
function (MapperTreeItemInterface $first, MapperTreeItemInterface $second) {
if ($first->getPriority() >= $second->getPriority()) {
return 1;
}
if ($first->getPriority() < $second->getPriority()) {
return -1;
}
}
);
} | [
"private",
"function",
"sortChildren",
"(",
")",
"{",
"uasort",
"(",
"$",
"this",
"->",
"children",
",",
"function",
"(",
"MapperTreeItemInterface",
"$",
"first",
",",
"MapperTreeItemInterface",
"$",
"second",
")",
"{",
"if",
"(",
"$",
"first",
"->",
"getPriority",
"(",
")",
">=",
"$",
"second",
"->",
"getPriority",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"first",
"->",
"getPriority",
"(",
")",
"<",
"$",
"second",
"->",
"getPriority",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
")",
";",
"}"
] | Sort item children. | [
"Sort",
"item",
"children",
"."
] | 6853a2be08dcd35a1013c0a4aba9b71a727ff7da | https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Extension/Source/Tree/MapperTreeItem.php#L144-L158 |
2,784 | colorium/arraydot | src/Colorium/Tools/ArrayDot.php | ArrayDot.get | public static function get(array $array, $key, $fallback = null)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
return $fallback;
}
$array = $array[$key];
}
return $array;
} | php | public static function get(array $array, $key, $fallback = null)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
return $fallback;
}
$array = $array[$key];
}
return $array;
} | [
"public",
"static",
"function",
"get",
"(",
"array",
"$",
"array",
",",
"$",
"key",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"fallback",
";",
"}",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Get value from array
@param array $array
@param string $key
@param mixed $fallback
@return mixed | [
"Get",
"value",
"from",
"array"
] | 0751aba4e1e1993bc276b842696ef77e5dca2ec4 | https://github.com/colorium/arraydot/blob/0751aba4e1e1993bc276b842696ef77e5dca2ec4/src/Colorium/Tools/ArrayDot.php#L155-L166 |
2,785 | colorium/arraydot | src/Colorium/Tools/ArrayDot.php | ArrayDot.pop | public static function pop(array $array, $key)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
return null;
}
$array = $array[$key];
}
if(!is_array($array)) {
return null;
}
return array_pop($array);
} | php | public static function pop(array $array, $key)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
return null;
}
$array = $array[$key];
}
if(!is_array($array)) {
return null;
}
return array_pop($array);
} | [
"public",
"static",
"function",
"pop",
"(",
"array",
"$",
"array",
",",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"array_pop",
"(",
"$",
"array",
")",
";",
"}"
] | Pop value from sub-array
@param array $array
@param string $key
@return mixed | [
"Pop",
"value",
"from",
"sub",
"-",
"array"
] | 0751aba4e1e1993bc276b842696ef77e5dca2ec4 | https://github.com/colorium/arraydot/blob/0751aba4e1e1993bc276b842696ef77e5dca2ec4/src/Colorium/Tools/ArrayDot.php#L176-L191 |
2,786 | colorium/arraydot | src/Colorium/Tools/ArrayDot.php | ArrayDot.set | public static function set(array &$array, $key, $value)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
$array = $value;
} | php | public static function set(array &$array, $key, $value)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
$array = $value;
} | [
"public",
"static",
"function",
"set",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"array",
"=",
"$",
"value",
";",
"}"
] | Set value in array
@param array $array
@param string $key
@param $value | [
"Set",
"value",
"in",
"array"
] | 0751aba4e1e1993bc276b842696ef77e5dca2ec4 | https://github.com/colorium/arraydot/blob/0751aba4e1e1993bc276b842696ef77e5dca2ec4/src/Colorium/Tools/ArrayDot.php#L201-L212 |
2,787 | colorium/arraydot | src/Colorium/Tools/ArrayDot.php | ArrayDot.push | public static function push(array &$array, $key, $value)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
if(!is_array($array)) {
$array = [];
}
array_push($array, $value);
} | php | public static function push(array &$array, $key, $value)
{
$keys = explode('.', $key);
foreach($keys as $key) {
if(!isset($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
if(!is_array($array)) {
$array = [];
}
array_push($array, $value);
} | [
"public",
"static",
"function",
"push",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"}",
"array_push",
"(",
"$",
"array",
",",
"$",
"value",
")",
";",
"}"
] | Push value in sub-array
@param array $array
@param string $key
@param $value | [
"Push",
"value",
"in",
"sub",
"-",
"array"
] | 0751aba4e1e1993bc276b842696ef77e5dca2ec4 | https://github.com/colorium/arraydot/blob/0751aba4e1e1993bc276b842696ef77e5dca2ec4/src/Colorium/Tools/ArrayDot.php#L222-L237 |
2,788 | colorium/arraydot | src/Colorium/Tools/ArrayDot.php | ArrayDot.drop | public static function drop(array &$array, $key)
{
$keys = explode('.', $key);
$last = array_pop($keys);
foreach($keys as $key) {
if(!isset($array[$key])) {
return false;
}
$array = &$array[$key];
}
if(isset($array[$last])) {
unset($array[$last]);
return true;
}
return false;
} | php | public static function drop(array &$array, $key)
{
$keys = explode('.', $key);
$last = array_pop($keys);
foreach($keys as $key) {
if(!isset($array[$key])) {
return false;
}
$array = &$array[$key];
}
if(isset($array[$last])) {
unset($array[$last]);
return true;
}
return false;
} | [
"public",
"static",
"function",
"drop",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"keys",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"last",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"last",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Delete key in array
@param array $array
@param string $key
@return bool | [
"Delete",
"key",
"in",
"array"
] | 0751aba4e1e1993bc276b842696ef77e5dca2ec4 | https://github.com/colorium/arraydot/blob/0751aba4e1e1993bc276b842696ef77e5dca2ec4/src/Colorium/Tools/ArrayDot.php#L247-L264 |
2,789 | psychoticmeow/nbsp-peek | src/nbsp/Peek/Utilities/QueryableAbstract.php | QueryableAbstract.query | public function query($query_string, Closure $callback) {
$query = $this->getQuery($query_string);
$query->execute($this, $callback);
} | php | public function query($query_string, Closure $callback) {
$query = $this->getQuery($query_string);
$query->execute($this, $callback);
} | [
"public",
"function",
"query",
"(",
"$",
"query_string",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
"$",
"query_string",
")",
";",
"$",
"query",
"->",
"execute",
"(",
"$",
"this",
",",
"$",
"callback",
")",
";",
"}"
] | Execute a query using a closure to capture the results.
@param string $query_string
@param Closure $callback
Called with two parameters, `$name` and `$value`. | [
"Execute",
"a",
"query",
"using",
"a",
"closure",
"to",
"capture",
"the",
"results",
"."
] | 2cb4cb2e4047ae9fa49cdf4d8d4a3a12488fe8fd | https://github.com/psychoticmeow/nbsp-peek/blob/2cb4cb2e4047ae9fa49cdf4d8d4a3a12488fe8fd/src/nbsp/Peek/Utilities/QueryableAbstract.php#L24-L27 |
2,790 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.register | public function register($identifier, $value)
{
parent::register($identifier, $value);
$sql = sprintf(
'INSERT INTO %s (`entityId`, `data`) set (`%s`, `%s`);',
$this->mysql->quote($this->section),
$this->mysql->quote($identifier),
$this->decorator->normalizeValue($value)
);
$result = $this->mysql->query($sql);
if (false === $result) {
$this->registry[$this->section][$identifier] = null;
$this->throwException(
'Error occurred while registering an entity: ',
$this->mysql->errorInfo()
);
}
} | php | public function register($identifier, $value)
{
parent::register($identifier, $value);
$sql = sprintf(
'INSERT INTO %s (`entityId`, `data`) set (`%s`, `%s`);',
$this->mysql->quote($this->section),
$this->mysql->quote($identifier),
$this->decorator->normalizeValue($value)
);
$result = $this->mysql->query($sql);
if (false === $result) {
$this->registry[$this->section][$identifier] = null;
$this->throwException(
'Error occurred while registering an entity: ',
$this->mysql->errorInfo()
);
}
} | [
"public",
"function",
"register",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"parent",
"::",
"register",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO %s (`entityId`, `data`) set (`%s`, `%s`);'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"identifier",
")",
",",
"$",
"this",
"->",
"decorator",
"->",
"normalizeValue",
"(",
"$",
"value",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"mysql",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"throwException",
"(",
"'Error occurred while registering an entity: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"}"
] | Registers the provided value.
@param string $identifier
@param string $value | [
"Registers",
"the",
"provided",
"value",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L44-L65 |
2,791 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.getContentById | public function getContentById($identifier, $default = null)
{
if (empty($this->registry[$this->section][$identifier])) {
$this->registry[$this->section][$identifier] = $this->getContentByIds(array($identifier));
if (empty($this->registry[$this->section][$identifier])) {
return $default;
}
}
return $this->registry[$this->section][$identifier];
} | php | public function getContentById($identifier, $default = null)
{
if (empty($this->registry[$this->section][$identifier])) {
$this->registry[$this->section][$identifier] = $this->getContentByIds(array($identifier));
if (empty($this->registry[$this->section][$identifier])) {
return $default;
}
}
return $this->registry[$this->section][$identifier];
} | [
"public",
"function",
"getContentById",
"(",
"$",
"identifier",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
"=",
"$",
"this",
"->",
"getContentByIds",
"(",
"array",
"(",
"$",
"identifier",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
";",
"}"
] | Provides the registry content identified by its ID.
@param string $identifier
@param null $default
@throws \Liip\Drupal\Modules\Registry\RegistryException
@return array | [
"Provides",
"the",
"registry",
"content",
"identified",
"by",
"its",
"ID",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L111-L123 |
2,792 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.getContentByIds | public function getContentByIds(array $identifiers)
{
$sql = sprintf(
'SELECT * FROM %s WHERE entityId IN (`%s`);',
$this->mysql->quote($this->section),
implode('`,`', $identifiers)
);
$result = $this->mysql->query($sql);
if (false === $result) {
$this->throwException(
'Error occurred while querying the registry: ',
$this->mysql->errorInfo()
);
}
$content = $result->fetchAll(\PDO::FETCH_ASSOC);
$this->registry[$this->section] = array_merge($this->registry[$this->section], $content);
return $content;
} | php | public function getContentByIds(array $identifiers)
{
$sql = sprintf(
'SELECT * FROM %s WHERE entityId IN (`%s`);',
$this->mysql->quote($this->section),
implode('`,`', $identifiers)
);
$result = $this->mysql->query($sql);
if (false === $result) {
$this->throwException(
'Error occurred while querying the registry: ',
$this->mysql->errorInfo()
);
}
$content = $result->fetchAll(\PDO::FETCH_ASSOC);
$this->registry[$this->section] = array_merge($this->registry[$this->section], $content);
return $content;
} | [
"public",
"function",
"getContentByIds",
"(",
"array",
"$",
"identifiers",
")",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"'SELECT * FROM %s WHERE entityId IN (`%s`);'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
",",
"implode",
"(",
"'`,`'",
",",
"$",
"identifiers",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"mysql",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"'Error occurred while querying the registry: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"$",
"content",
"=",
"$",
"result",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
",",
"$",
"content",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Provides a set of registry items.
@param array $identifiers
@throws \Liip\Drupal\Modules\Registry\RegistryException
@return array | [
"Provides",
"a",
"set",
"of",
"registry",
"items",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L133-L154 |
2,793 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.replace | public function replace($identifier, $value)
{
// store current data to be able to restore on error;
$oldValue = @$this->registry[$this->section][$identifier];
parent::replace($identifier, $value);
$sql = sprintf(
'UPDATE %s SET `data`=`%s` WHERE `entityId`=`%s`;',
$this->mysql->quote($this->section),
$this->mysql->quote($value),
$this->mysql->quote($identifier)
);
$result = $this->mysql->exec($sql);
if (false === $result) {
$this->registry[$this->section][$identifier] = $oldValue;
$this->throwException(
'Failed to fetch information from the registry: ',
$this->mysql->errorInfo()
);
}
} | php | public function replace($identifier, $value)
{
// store current data to be able to restore on error;
$oldValue = @$this->registry[$this->section][$identifier];
parent::replace($identifier, $value);
$sql = sprintf(
'UPDATE %s SET `data`=`%s` WHERE `entityId`=`%s`;',
$this->mysql->quote($this->section),
$this->mysql->quote($value),
$this->mysql->quote($identifier)
);
$result = $this->mysql->exec($sql);
if (false === $result) {
$this->registry[$this->section][$identifier] = $oldValue;
$this->throwException(
'Failed to fetch information from the registry: ',
$this->mysql->errorInfo()
);
}
} | [
"public",
"function",
"replace",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"// store current data to be able to restore on error;",
"$",
"oldValue",
"=",
"@",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
";",
"parent",
"::",
"replace",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"$",
"sql",
"=",
"sprintf",
"(",
"'UPDATE %s SET `data`=`%s` WHERE `entityId`=`%s`;'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"value",
")",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"identifier",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"mysql",
"->",
"exec",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"[",
"$",
"identifier",
"]",
"=",
"$",
"oldValue",
";",
"$",
"this",
"->",
"throwException",
"(",
"'Failed to fetch information from the registry: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"}"
] | Replaces the identified entity with the provided one.
@param string $identifier
@param mixed $value | [
"Replaces",
"the",
"identified",
"entity",
"with",
"the",
"provided",
"one",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L162-L187 |
2,794 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.destroy | public function destroy()
{
// delete DB
$sql = sprintf(
'DROP TABLE `%s`;',
$this->mysql->quote($this->section)
);
if (false === $this->mysql->exec($sql)) {
$this->throwException(
'Unable to delete the database: ',
$this->mysql->errorInfo()
);
}
$this->registry[$this->section] = array();
} | php | public function destroy()
{
// delete DB
$sql = sprintf(
'DROP TABLE `%s`;',
$this->mysql->quote($this->section)
);
if (false === $this->mysql->exec($sql)) {
$this->throwException(
'Unable to delete the database: ',
$this->mysql->errorInfo()
);
}
$this->registry[$this->section] = array();
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"// delete DB",
"$",
"sql",
"=",
"sprintf",
"(",
"'DROP TABLE `%s`;'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mysql",
"->",
"exec",
"(",
"$",
"sql",
")",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"'Unable to delete the database: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"=",
"array",
"(",
")",
";",
"}"
] | Shall delete the current registry from the database.
@throws RegistryException in case the deletion of the database failed. | [
"Shall",
"delete",
"the",
"current",
"registry",
"from",
"the",
"database",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L223-L240 |
2,795 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.init | public function init()
{
$this->registryTableExists();
if (empty($this->registry[$this->section])) {
$this->registry[$this->section] = $this->getContent();
}
return $this->registry[$this->section];
} | php | public function init()
{
$this->registryTableExists();
if (empty($this->registry[$this->section])) {
$this->registry[$this->section] = $this->getContent();
}
return $this->registry[$this->section];
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"registryTableExists",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
";",
"}"
] | Shall register a new section in the registry
@return array | [
"Shall",
"register",
"a",
"new",
"section",
"in",
"the",
"registry"
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L246-L256 |
2,796 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.registryTableExists | protected function registryTableExists()
{
$sql = sprintf(
'SHOW CREATE TABLE `%s`;',
$this->mysql->quote($this->section)
);
if (false === $this->mysql->query($sql)) {
$this->throwException(
'The registry table does not exists: ',
$this->mysql->errorInfo()
);
}
} | php | protected function registryTableExists()
{
$sql = sprintf(
'SHOW CREATE TABLE `%s`;',
$this->mysql->quote($this->section)
);
if (false === $this->mysql->query($sql)) {
$this->throwException(
'The registry table does not exists: ',
$this->mysql->errorInfo()
);
}
} | [
"protected",
"function",
"registryTableExists",
"(",
")",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"'SHOW CREATE TABLE `%s`;'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mysql",
"->",
"query",
"(",
"$",
"sql",
")",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"'The registry table does not exists: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"}"
] | Validates that the registry table exists.
@throws \Liip\Drupal\Modules\Registry\RegistryException | [
"Validates",
"that",
"the",
"registry",
"table",
"exists",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L262-L276 |
2,797 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.getContent | public function getContent($limit = 0)
{
$this->registry[$this->section] = parent::getContent();
if (empty($this->registry[$this->section])) {
$sql = sprintf('SELECT * FROM `%s`;', $this->mysql->quote($this->section));
$result = $this->mysql->query($sql);
if (false === $result) {
$this->throwException(
'Failed to fetch information from the registry: ',
$this->mysql->errorInfo()
);
}
$this->registry[$this->section] = $this->processResult($result->fetchAll(\PDO::FETCH_ASSOC));
}
return $this->registry[$this->section];
} | php | public function getContent($limit = 0)
{
$this->registry[$this->section] = parent::getContent();
if (empty($this->registry[$this->section])) {
$sql = sprintf('SELECT * FROM `%s`;', $this->mysql->quote($this->section));
$result = $this->mysql->query($sql);
if (false === $result) {
$this->throwException(
'Failed to fetch information from the registry: ',
$this->mysql->errorInfo()
);
}
$this->registry[$this->section] = $this->processResult($result->fetchAll(\PDO::FETCH_ASSOC));
}
return $this->registry[$this->section];
} | [
"public",
"function",
"getContent",
"(",
"$",
"limit",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"=",
"parent",
"::",
"getContent",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
")",
")",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"'SELECT * FROM `%s`;'",
",",
"$",
"this",
"->",
"mysql",
"->",
"quote",
"(",
"$",
"this",
"->",
"section",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"mysql",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"'Failed to fetch information from the registry: '",
",",
"$",
"this",
"->",
"mysql",
"->",
"errorInfo",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
"=",
"$",
"this",
"->",
"processResult",
"(",
"$",
"result",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"registry",
"[",
"$",
"this",
"->",
"section",
"]",
";",
"}"
] | Provides the current content of the registry.
NOTICE:
Setting $limit to anything else than 0 (zero) currently not have any affect on the amount of returned results.
This functionality is due to be implemented.
@param integer $limit Amount of documents to be returned in result set. If set to 0 (zero) all documents of the result set will be returned. Defaults to 0.
@throws \Liip\Drupal\Modules\Registry\RegistryException
@return array | [
"Provides",
"the",
"current",
"content",
"of",
"the",
"registry",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L292-L313 |
2,798 | liip/LiipDrupalRegistryModule | src/Liip/Drupal/Modules/Registry/Database/MySql.php | MySql.processResult | protected function processResult(array $results)
{
foreach ($results as $key => $entity) {
if (!empty($entity['data'])) {
$entity['data'] = $this->decorator->denormalizeValue($entity['data']);
$results[$key] = $entity;
}
}
return $results;
} | php | protected function processResult(array $results)
{
foreach ($results as $key => $entity) {
if (!empty($entity['data'])) {
$entity['data'] = $this->decorator->denormalizeValue($entity['data']);
$results[$key] = $entity;
}
}
return $results;
} | [
"protected",
"function",
"processResult",
"(",
"array",
"$",
"results",
")",
"{",
"foreach",
"(",
"$",
"results",
"as",
"$",
"key",
"=>",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"entity",
"[",
"'data'",
"]",
")",
")",
"{",
"$",
"entity",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"decorator",
"->",
"denormalizeValue",
"(",
"$",
"entity",
"[",
"'data'",
"]",
")",
";",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"entity",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] | Processes the results to return a denormalized entity set.
@param array $results
@return array | [
"Processes",
"the",
"results",
"to",
"return",
"a",
"denormalized",
"entity",
"set",
"."
] | 2d860c1f88ef91d9af91909d8711ffbb6e2a1eab | https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Database/MySql.php#L322-L334 |
2,799 | firstcomputer/seeme | src/Assertion.php | Assertion.allInRangeOrAll | public static function allInRangeOrAll($value, $minValue, $maxValue)
{
if (is_array($value)) {
static::allRange($value, $minValue, $maxValue);
return;
}
static::eq($value, 'all');
} | php | public static function allInRangeOrAll($value, $minValue, $maxValue)
{
if (is_array($value)) {
static::allRange($value, $minValue, $maxValue);
return;
}
static::eq($value, 'all');
} | [
"public",
"static",
"function",
"allInRangeOrAll",
"(",
"$",
"value",
",",
"$",
"minValue",
",",
"$",
"maxValue",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"static",
"::",
"allRange",
"(",
"$",
"value",
",",
"$",
"minValue",
",",
"$",
"maxValue",
")",
";",
"return",
";",
"}",
"static",
"::",
"eq",
"(",
"$",
"value",
",",
"'all'",
")",
";",
"}"
] | Assert that value is a range of numbers or the string 'all'
@param mixed $value
@param integer $minValue
@param integer $maxValue
@throws Assert\AssertionFailedException | [
"Assert",
"that",
"value",
"is",
"a",
"range",
"of",
"numbers",
"or",
"the",
"string",
"all"
] | 09954a110e44afe34bb03c87d2a7cbf0a3be86b3 | https://github.com/firstcomputer/seeme/blob/09954a110e44afe34bb03c87d2a7cbf0a3be86b3/src/Assertion.php#L51-L60 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.