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
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,800 | taskforcedev/gravatar | src/Gravatar.php | Gravatar.getAvatar | public function getAvatar($user, $options = [])
{
if (!isset($options['size'])) {
$options['size'] = 100;
}
if (!isset($options['secure'])) {
$options['secure'] = true;
}
try {
if (method_exists('getEmail', $user)) {
$email = $user->getEmail();
} elseif (isset($user->email)) {
$email = $user->email;
} elseif (isset($user['email'])) {
$email = $user['email'];
}
$hash = $this->getHash($email);
if ($options['secure']) {
$avatar_url = $this->https_url . $hash . '?s=' . $options['size'];
} else {
$avatar_url = $this->http_url . $hash . '?s=' . $options['size'];
}
return $avatar_url;
} catch(Exception $e) {
return false;
}
} | php | public function getAvatar($user, $options = [])
{
if (!isset($options['size'])) {
$options['size'] = 100;
}
if (!isset($options['secure'])) {
$options['secure'] = true;
}
try {
if (method_exists('getEmail', $user)) {
$email = $user->getEmail();
} elseif (isset($user->email)) {
$email = $user->email;
} elseif (isset($user['email'])) {
$email = $user['email'];
}
$hash = $this->getHash($email);
if ($options['secure']) {
$avatar_url = $this->https_url . $hash . '?s=' . $options['size'];
} else {
$avatar_url = $this->http_url . $hash . '?s=' . $options['size'];
}
return $avatar_url;
} catch(Exception $e) {
return false;
}
} | [
"public",
"function",
"getAvatar",
"(",
"$",
"user",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'size'",
"]",
"=",
"100",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'secure'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'secure'",
"]",
"=",
"true",
";",
"}",
"try",
"{",
"if",
"(",
"method_exists",
"(",
"'getEmail'",
",",
"$",
"user",
")",
")",
"{",
"$",
"email",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"user",
"->",
"email",
")",
")",
"{",
"$",
"email",
"=",
"$",
"user",
"->",
"email",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"user",
"[",
"'email'",
"]",
")",
")",
"{",
"$",
"email",
"=",
"$",
"user",
"[",
"'email'",
"]",
";",
"}",
"$",
"hash",
"=",
"$",
"this",
"->",
"getHash",
"(",
"$",
"email",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'secure'",
"]",
")",
"{",
"$",
"avatar_url",
"=",
"$",
"this",
"->",
"https_url",
".",
"$",
"hash",
".",
"'?s='",
".",
"$",
"options",
"[",
"'size'",
"]",
";",
"}",
"else",
"{",
"$",
"avatar_url",
"=",
"$",
"this",
"->",
"http_url",
".",
"$",
"hash",
".",
"'?s='",
".",
"$",
"options",
"[",
"'size'",
"]",
";",
"}",
"return",
"$",
"avatar_url",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Retrieves a users gravatar using their email address
@param mixed $user Accepts a laravel user object, an array or a php object.
@param array $options Check readme for full options.
@return bool|string | [
"Retrieves",
"a",
"users",
"gravatar",
"using",
"their",
"email",
"address"
] | 5707447921751e7ff00319d32bf307cdb216e0d0 | https://github.com/taskforcedev/gravatar/blob/5707447921751e7ff00319d32bf307cdb216e0d0/src/Gravatar.php#L22-L53 |
7,801 | taskforcedev/gravatar | src/Gravatar.php | Gravatar.getHash | private function getHash($email)
{
try {
$gravatar_hash = md5(strtolower(trim($email)));
return $gravatar_hash;
} catch(Exception $e) {
return false;
}
} | php | private function getHash($email)
{
try {
$gravatar_hash = md5(strtolower(trim($email)));
return $gravatar_hash;
} catch(Exception $e) {
return false;
}
} | [
"private",
"function",
"getHash",
"(",
"$",
"email",
")",
"{",
"try",
"{",
"$",
"gravatar_hash",
"=",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"email",
")",
")",
")",
";",
"return",
"$",
"gravatar_hash",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Get the gravatar hash from an email address.
@param $email
@return bool|string | [
"Get",
"the",
"gravatar",
"hash",
"from",
"an",
"email",
"address",
"."
] | 5707447921751e7ff00319d32bf307cdb216e0d0 | https://github.com/taskforcedev/gravatar/blob/5707447921751e7ff00319d32bf307cdb216e0d0/src/Gravatar.php#L62-L70 |
7,802 | Stratadox/Deserializer | src/ObjectDeserializer.php | ObjectDeserializer.forThe | public static function forThe(string $class): DeserializesObjects
{
return new ObjectDeserializer(
Instantiator::forThe($class),
empty(listOfParentsForThe($class))
? ObjectHydrator::default()
: ReflectiveHydrator::default()
);
} | php | public static function forThe(string $class): DeserializesObjects
{
return new ObjectDeserializer(
Instantiator::forThe($class),
empty(listOfParentsForThe($class))
? ObjectHydrator::default()
: ReflectiveHydrator::default()
);
} | [
"public",
"static",
"function",
"forThe",
"(",
"string",
"$",
"class",
")",
":",
"DeserializesObjects",
"{",
"return",
"new",
"ObjectDeserializer",
"(",
"Instantiator",
"::",
"forThe",
"(",
"$",
"class",
")",
",",
"empty",
"(",
"listOfParentsForThe",
"(",
"$",
"class",
")",
")",
"?",
"ObjectHydrator",
"::",
"default",
"(",
")",
":",
"ReflectiveHydrator",
"::",
"default",
"(",
")",
")",
";",
"}"
] | Makes a new deserializer for the class.
Produces a default instantiator and hydrator for the class. If the class
uses inheritance, a reflective hydrator is used by default. This may not
always be necessary. (ie. when not inheriting private properties) In such
cases, @see ObjectDeserializer::using can be used instead.
@param string $class The fully qualified collection class name.
@return DeserializesObjects The object deserializer.
@throws CannotInstantiateThis When the class cannot be instantiated. | [
"Makes",
"a",
"new",
"deserializer",
"for",
"the",
"class",
"."
] | 26f282837f310cc7eb1aec01579edde04c84a80c | https://github.com/Stratadox/Deserializer/blob/26f282837f310cc7eb1aec01579edde04c84a80c/src/ObjectDeserializer.php#L44-L52 |
7,803 | SergioMadness/framework | framework/components/eventhandler/traits/CallbackTrait.php | CallbackTrait.prepareCallback | public function prepareCallback($callback)
{
$result = $callback;
if (is_string($callback) && ($callbackInfo = $this->parseHandlerStr($callback))
&& class_exists($callbackInfo['class']) && method_exists(($controller
= new $callbackInfo['class']), $callbackInfo['method'])) {
$result = [$controller, $callbackInfo['method']];
} elseif (!is_callable($callback)) {
throw new \pwf\exception\HttpNotFoundException();
}
return $result;
} | php | public function prepareCallback($callback)
{
$result = $callback;
if (is_string($callback) && ($callbackInfo = $this->parseHandlerStr($callback))
&& class_exists($callbackInfo['class']) && method_exists(($controller
= new $callbackInfo['class']), $callbackInfo['method'])) {
$result = [$controller, $callbackInfo['method']];
} elseif (!is_callable($callback)) {
throw new \pwf\exception\HttpNotFoundException();
}
return $result;
} | [
"public",
"function",
"prepareCallback",
"(",
"$",
"callback",
")",
"{",
"$",
"result",
"=",
"$",
"callback",
";",
"if",
"(",
"is_string",
"(",
"$",
"callback",
")",
"&&",
"(",
"$",
"callbackInfo",
"=",
"$",
"this",
"->",
"parseHandlerStr",
"(",
"$",
"callback",
")",
")",
"&&",
"class_exists",
"(",
"$",
"callbackInfo",
"[",
"'class'",
"]",
")",
"&&",
"method_exists",
"(",
"(",
"$",
"controller",
"=",
"new",
"$",
"callbackInfo",
"[",
"'class'",
"]",
")",
",",
"$",
"callbackInfo",
"[",
"'method'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"[",
"$",
"controller",
",",
"$",
"callbackInfo",
"[",
"'method'",
"]",
"]",
";",
"}",
"elseif",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"pwf",
"\\",
"exception",
"\\",
"HttpNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Prepare handler for invokation
@param \Closure|string|array $callback
@return \Closure
@throws \pwf\exception\HttpNotFoundException | [
"Prepare",
"handler",
"for",
"invokation"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/eventhandler/traits/CallbackTrait.php#L43-L54 |
7,804 | gourmet/common | Model/CommonAppModel.php | CommonAppModel.edit | public function edit($id, $data) {
$record = $this->read(null, $id);
if (!$record) {
throw new OutOfBoundsException('view.fail');
}
if (empty($data)) {
return;
}
$data[$this->alias] = array_merge(
array_diff_key($data[$this->alias], $record[$this->alias]),
array_diff($data[$this->alias], $record[$this->alias])
);
$validate = $this->validate;
foreach (array_keys($this->validate) as $field) {
if (!isset($data[$this->alias][$field])) {
unset($this->validate[$field]);
}
}
$this->id = $id;
$this->data = $data;
$result = $this->save(null, false);
$this->validate = $validate;
$this->data = Hash::merge($record, $result);
if (!$result) {
return false;
}
$this->triggerEvent('Model.' . $this->name . '.afterEdit', $this);
return $data;
} | php | public function edit($id, $data) {
$record = $this->read(null, $id);
if (!$record) {
throw new OutOfBoundsException('view.fail');
}
if (empty($data)) {
return;
}
$data[$this->alias] = array_merge(
array_diff_key($data[$this->alias], $record[$this->alias]),
array_diff($data[$this->alias], $record[$this->alias])
);
$validate = $this->validate;
foreach (array_keys($this->validate) as $field) {
if (!isset($data[$this->alias][$field])) {
unset($this->validate[$field]);
}
}
$this->id = $id;
$this->data = $data;
$result = $this->save(null, false);
$this->validate = $validate;
$this->data = Hash::merge($record, $result);
if (!$result) {
return false;
}
$this->triggerEvent('Model.' . $this->name . '.afterEdit', $this);
return $data;
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"read",
"(",
"null",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"record",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'view.fail'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
";",
"}",
"$",
"data",
"[",
"$",
"this",
"->",
"alias",
"]",
"=",
"array_merge",
"(",
"array_diff_key",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"alias",
"]",
",",
"$",
"record",
"[",
"$",
"this",
"->",
"alias",
"]",
")",
",",
"array_diff",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"alias",
"]",
",",
"$",
"record",
"[",
"$",
"this",
"->",
"alias",
"]",
")",
")",
";",
"$",
"validate",
"=",
"$",
"this",
"->",
"validate",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"validate",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"alias",
"]",
"[",
"$",
"field",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"validate",
"[",
"$",
"field",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"id",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"save",
"(",
"null",
",",
"false",
")",
";",
"$",
"this",
"->",
"validate",
"=",
"$",
"validate",
";",
"$",
"this",
"->",
"data",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"record",
",",
"$",
"result",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"triggerEvent",
"(",
"'Model.'",
".",
"$",
"this",
"->",
"name",
".",
"'.afterEdit'",
",",
"$",
"this",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Common edit operation.
@param string $id Model record's primary key value.
@param array $data New model record's data.
@return boolean
@throws OutOfBoundsException If the record does not exist. | [
"Common",
"edit",
"operation",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/CommonAppModel.php#L139-L175 |
7,805 | gourmet/common | Model/CommonAppModel.php | CommonAppModel.getForeignModelDisplayField | public static function getForeignModelDisplayField($model, $foreignModel, $path = false) {
$_this = ClassRegistry::init($model);
$displayField = $_this->displayField;
if (is_bool($foreignModel)) {
$path = $foreignModel;
list(, $name) = pluginSplit($model);
} else {
list(, $name) = pluginSplit($foreignModel);
foreach (array_keys($_this->belongsToForeignModels) as $model) {
if ($name == $model) {
$displayField = $_this->{$model}->displayField;
break;
}
}
}
if (true === $path || (false !== $path && empty($path))) {
$displayField = "$name.$displayField";
} else if (false !== $path) {
$displayField = "$path.$name.$displayField";
}
return $displayField;
} | php | public static function getForeignModelDisplayField($model, $foreignModel, $path = false) {
$_this = ClassRegistry::init($model);
$displayField = $_this->displayField;
if (is_bool($foreignModel)) {
$path = $foreignModel;
list(, $name) = pluginSplit($model);
} else {
list(, $name) = pluginSplit($foreignModel);
foreach (array_keys($_this->belongsToForeignModels) as $model) {
if ($name == $model) {
$displayField = $_this->{$model}->displayField;
break;
}
}
}
if (true === $path || (false !== $path && empty($path))) {
$displayField = "$name.$displayField";
} else if (false !== $path) {
$displayField = "$path.$name.$displayField";
}
return $displayField;
} | [
"public",
"static",
"function",
"getForeignModelDisplayField",
"(",
"$",
"model",
",",
"$",
"foreignModel",
",",
"$",
"path",
"=",
"false",
")",
"{",
"$",
"_this",
"=",
"ClassRegistry",
"::",
"init",
"(",
"$",
"model",
")",
";",
"$",
"displayField",
"=",
"$",
"_this",
"->",
"displayField",
";",
"if",
"(",
"is_bool",
"(",
"$",
"foreignModel",
")",
")",
"{",
"$",
"path",
"=",
"$",
"foreignModel",
";",
"list",
"(",
",",
"$",
"name",
")",
"=",
"pluginSplit",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"list",
"(",
",",
"$",
"name",
")",
"=",
"pluginSplit",
"(",
"$",
"foreignModel",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"_this",
"->",
"belongsToForeignModels",
")",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"$",
"model",
")",
"{",
"$",
"displayField",
"=",
"$",
"_this",
"->",
"{",
"$",
"model",
"}",
"->",
"displayField",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"true",
"===",
"$",
"path",
"||",
"(",
"false",
"!==",
"$",
"path",
"&&",
"empty",
"(",
"$",
"path",
")",
")",
")",
"{",
"$",
"displayField",
"=",
"\"$name.$displayField\"",
";",
"}",
"else",
"if",
"(",
"false",
"!==",
"$",
"path",
")",
"{",
"$",
"displayField",
"=",
"\"$path.$name.$displayField\"",
";",
"}",
"return",
"$",
"displayField",
";",
"}"
] | Gets the foreign model's display field. Useful in views.
@param string $foreignModel Model's name (i.e. 'Model' or 'Plugin.Model').
@param boolean $path Return the array's path to the display field in the data
array or just the display field.
@return string | [
"Gets",
"the",
"foreign",
"model",
"s",
"display",
"field",
".",
"Useful",
"in",
"views",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/CommonAppModel.php#L216-L240 |
7,806 | gourmet/common | Model/CommonAppModel.php | CommonAppModel.triggerEvent | public function triggerEvent($event, $subject = null, $data = null) {
return $this->getEventManager()->trigger($event, $subject, $data);
} | php | public function triggerEvent($event, $subject = null, $data = null) {
return $this->getEventManager()->trigger($event, $subject, $data);
} | [
"public",
"function",
"triggerEvent",
"(",
"$",
"event",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"data",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"$",
"event",
",",
"$",
"subject",
",",
"$",
"data",
")",
";",
"}"
] | Trigger an event using the 'Model' instead of the `CommonEventManager`.
@param string|CakeEvent $event The event key name or instance of CakeEvent.
@param object $subject Optional. Event's subject.
@param mixed $data Optional. Event's data.
@return mixed Result of the event. | [
"Trigger",
"an",
"event",
"using",
"the",
"Model",
"instead",
"of",
"the",
"CommonEventManager",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/CommonAppModel.php#L303-L305 |
7,807 | gourmet/common | Model/CommonAppModel.php | CommonAppModel._containForeignModels | protected function _containForeignModels($query, $assoc = null) {
if (
(isset($query['contain']) && empty($query['contain']))
|| (isset($this->contain) && empty($this->contain))
) {
return $query;
}
if (!isset($query['contain'])) {
$query['contain'] = array();
} else if (!is_array($query['contain'])) {
$query['contain'] = (array) $query['contain'];
}
// Add the foreign models.
foreach (array_keys($this->belongsToForeignModels) as $model) {
if (!empty($assoc)) {
$model = "$assoc.$model";
}
if (!in_array($model, $query['contain']) && !isset($query['contain'][$model])) {
$query['contain'][] = $model;
}
}
return $query;
} | php | protected function _containForeignModels($query, $assoc = null) {
if (
(isset($query['contain']) && empty($query['contain']))
|| (isset($this->contain) && empty($this->contain))
) {
return $query;
}
if (!isset($query['contain'])) {
$query['contain'] = array();
} else if (!is_array($query['contain'])) {
$query['contain'] = (array) $query['contain'];
}
// Add the foreign models.
foreach (array_keys($this->belongsToForeignModels) as $model) {
if (!empty($assoc)) {
$model = "$assoc.$model";
}
if (!in_array($model, $query['contain']) && !isset($query['contain'][$model])) {
$query['contain'][] = $model;
}
}
return $query;
} | [
"protected",
"function",
"_containForeignModels",
"(",
"$",
"query",
",",
"$",
"assoc",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"isset",
"(",
"$",
"query",
"[",
"'contain'",
"]",
")",
"&&",
"empty",
"(",
"$",
"query",
"[",
"'contain'",
"]",
")",
")",
"||",
"(",
"isset",
"(",
"$",
"this",
"->",
"contain",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"contain",
")",
")",
")",
"{",
"return",
"$",
"query",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"query",
"[",
"'contain'",
"]",
")",
")",
"{",
"$",
"query",
"[",
"'contain'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"query",
"[",
"'contain'",
"]",
")",
")",
"{",
"$",
"query",
"[",
"'contain'",
"]",
"=",
"(",
"array",
")",
"$",
"query",
"[",
"'contain'",
"]",
";",
"}",
"// Add the foreign models.",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"belongsToForeignModels",
")",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"assoc",
")",
")",
"{",
"$",
"model",
"=",
"\"$assoc.$model\"",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"model",
",",
"$",
"query",
"[",
"'contain'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"query",
"[",
"'contain'",
"]",
"[",
"$",
"model",
"]",
")",
")",
"{",
"$",
"query",
"[",
"'contain'",
"]",
"[",
"]",
"=",
"$",
"model",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] | Adds the foreign models to the query's `contain`.
@param array $query Find query.
@return array Modified find query. | [
"Adds",
"the",
"foreign",
"models",
"to",
"the",
"query",
"s",
"contain",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/CommonAppModel.php#L313-L338 |
7,808 | gourmet/common | Model/CommonAppModel.php | CommonAppModel._filterForeignModels | protected function _filterForeignModels($result, $keep) {
foreach ($this->belongsToForeignModels as $name => $assoc) {
if ($keep === $assoc['className']) {
continue;
}
if (isset($result[$name])) {
unset($result[$name]);
}
}
return $result;
} | php | protected function _filterForeignModels($result, $keep) {
foreach ($this->belongsToForeignModels as $name => $assoc) {
if ($keep === $assoc['className']) {
continue;
}
if (isset($result[$name])) {
unset($result[$name]);
}
}
return $result;
} | [
"protected",
"function",
"_filterForeignModels",
"(",
"$",
"result",
",",
"$",
"keep",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"belongsToForeignModels",
"as",
"$",
"name",
"=>",
"$",
"assoc",
")",
"{",
"if",
"(",
"$",
"keep",
"===",
"$",
"assoc",
"[",
"'className'",
"]",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"result",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Loops through associated `belongsTo` foreign models to keep only the associated one.
@param array $result Original resultset containing all associated `belongsTo` foreign models.
@param string $keepModel Full name of the associated model to keep (i.e. 'Plugin.Model' or 'Model').
@return array Filtered resultset. | [
"Loops",
"through",
"associated",
"belongsTo",
"foreign",
"models",
"to",
"keep",
"only",
"the",
"associated",
"one",
"."
] | 53ad4e919c51606dc81f2c716267d01ee768ade5 | https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/CommonAppModel.php#L347-L359 |
7,809 | Silvestra/Silvestra | src/Silvestra/Component/Cache/Http/HttpCacheManager.php | HttpCacheManager.invalidateAll | public function invalidateAll()
{
if (true === $this->filesystem->exists($this->httpCacheDir)) {
$this->filesystem->remove($this->httpCacheDir);
}
} | php | public function invalidateAll()
{
if (true === $this->filesystem->exists($this->httpCacheDir)) {
$this->filesystem->remove($this->httpCacheDir);
}
} | [
"public",
"function",
"invalidateAll",
"(",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"filesystem",
"->",
"exists",
"(",
"$",
"this",
"->",
"httpCacheDir",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"remove",
"(",
"$",
"this",
"->",
"httpCacheDir",
")",
";",
"}",
"}"
] | Invalidate all http cache. | [
"Invalidate",
"all",
"http",
"cache",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Cache/Http/HttpCacheManager.php#L48-L53 |
7,810 | flipboxfactory/flux | src/filters/TransformFilter.php | TransformFilter.shouldTransform | public function shouldTransform($action, $data): bool
{
if ($this->matchData($data) &&
$this->matchCustom($action, $data)) {
return true;
}
return false;
} | php | public function shouldTransform($action, $data): bool
{
if ($this->matchData($data) &&
$this->matchCustom($action, $data)) {
return true;
}
return false;
} | [
"public",
"function",
"shouldTransform",
"(",
"$",
"action",
",",
"$",
"data",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"matchData",
"(",
"$",
"data",
")",
"&&",
"$",
"this",
"->",
"matchCustom",
"(",
"$",
"action",
",",
"$",
"data",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks whether this filter should transform the specified action data.
@param Action $action the action to be performed
@param mixed $data the data to be transformed
@return bool `true` if the transformer should be applied, `false` if the transformer should be ignored | [
"Checks",
"whether",
"this",
"filter",
"should",
"transform",
"the",
"specified",
"action",
"data",
"."
] | 1ac58b7f375d0fb129096fbc5d10f583420e7a2a | https://github.com/flipboxfactory/flux/blob/1ac58b7f375d0fb129096fbc5d10f583420e7a2a/src/filters/TransformFilter.php#L118-L126 |
7,811 | lemonphp/cli | src/Provider/ConsoleServiceProvider.php | ConsoleServiceProvider.register | public function register(Container $pimple)
{
$pimple['console'] = function ($pimple) {
$console = new ContainerAwareApplication($pimple['console.name'], $pimple['console.version']);
$console->setDispatcher($pimple['eventDispatcher']);
$console->setContainer($pimple);
return $console;
};
} | php | public function register(Container $pimple)
{
$pimple['console'] = function ($pimple) {
$console = new ContainerAwareApplication($pimple['console.name'], $pimple['console.version']);
$console->setDispatcher($pimple['eventDispatcher']);
$console->setContainer($pimple);
return $console;
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"pimple",
")",
"{",
"$",
"pimple",
"[",
"'console'",
"]",
"=",
"function",
"(",
"$",
"pimple",
")",
"{",
"$",
"console",
"=",
"new",
"ContainerAwareApplication",
"(",
"$",
"pimple",
"[",
"'console.name'",
"]",
",",
"$",
"pimple",
"[",
"'console.version'",
"]",
")",
";",
"$",
"console",
"->",
"setDispatcher",
"(",
"$",
"pimple",
"[",
"'eventDispatcher'",
"]",
")",
";",
"$",
"console",
"->",
"setContainer",
"(",
"$",
"pimple",
")",
";",
"return",
"$",
"console",
";",
"}",
";",
"}"
] | Registers console services on the given container.
@param Container $pimple A container instance | [
"Registers",
"console",
"services",
"on",
"the",
"given",
"container",
"."
] | 55b11789621f106ba33f6f6dec88d12ad953b625 | https://github.com/lemonphp/cli/blob/55b11789621f106ba33f6f6dec88d12ad953b625/src/Provider/ConsoleServiceProvider.php#L31-L40 |
7,812 | webriq/core | module/User/src/Grid/User/Model/Permissions/Model.php | Model.getRole | public function getRole()
{
if ( null === $this->role )
{
$auth = $this->getAuthenticationService();
if ( $auth->hasIdentity() )
{
$this->role = $auth->getIdentity();
}
else
{
$this->role = new Acl\Role\GenericRole( self::ROLE_GUEST_ID );
}
}
return $this->role;
} | php | public function getRole()
{
if ( null === $this->role )
{
$auth = $this->getAuthenticationService();
if ( $auth->hasIdentity() )
{
$this->role = $auth->getIdentity();
}
else
{
$this->role = new Acl\Role\GenericRole( self::ROLE_GUEST_ID );
}
}
return $this->role;
} | [
"public",
"function",
"getRole",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"role",
")",
"{",
"$",
"auth",
"=",
"$",
"this",
"->",
"getAuthenticationService",
"(",
")",
";",
"if",
"(",
"$",
"auth",
"->",
"hasIdentity",
"(",
")",
")",
"{",
"$",
"this",
"->",
"role",
"=",
"$",
"auth",
"->",
"getIdentity",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"role",
"=",
"new",
"Acl",
"\\",
"Role",
"\\",
"GenericRole",
"(",
"self",
"::",
"ROLE_GUEST_ID",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"role",
";",
"}"
] | Get inner acl-role
@return \Zend\Permissions\Acl\Role\RoleInterface | [
"Get",
"inner",
"acl",
"-",
"role"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Model/Permissions/Model.php#L69-L86 |
7,813 | webriq/core | module/User/src/Grid/User/Model/Permissions/Model.php | Model.setRole | public function setRole( Acl\Role\RoleInterface $role = null )
{
$this->role = $role;
return $this;
} | php | public function setRole( Acl\Role\RoleInterface $role = null )
{
$this->role = $role;
return $this;
} | [
"public",
"function",
"setRole",
"(",
"Acl",
"\\",
"Role",
"\\",
"RoleInterface",
"$",
"role",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"role",
"=",
"$",
"role",
";",
"return",
"$",
"this",
";",
"}"
] | Set inner acl-role
@param \Zend\Permissions\Acl\Role\RoleInterface $role
@return \User\Model\Permissions\Model | [
"Set",
"inner",
"acl",
"-",
"role"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Model/Permissions/Model.php#L94-L98 |
7,814 | webriq/core | module/User/src/Grid/User/Model/Permissions/Model.php | Model.checkResource | public function checkResource( $resource, $parent = null )
{
if ( null === $resource )
{
return null;
}
if ( $resource instanceof Acl\Resource\ResourceInterface )
{
$resource = $resource->getResourceId();
}
$acl = $this->getAcl();
if ( ! $acl->hasResource( $resource ) )
{
if ( null === $parent )
{
$parent = $this->getParentId( $resource );
}
elseif ( $parent instanceof Acl\Resource\ResourceInterface )
{
$parent = $parent->getResourceId();
}
$parent = $this->checkResource( $parent );
$acl->addResource( $resource, $parent );
}
return $resource;
} | php | public function checkResource( $resource, $parent = null )
{
if ( null === $resource )
{
return null;
}
if ( $resource instanceof Acl\Resource\ResourceInterface )
{
$resource = $resource->getResourceId();
}
$acl = $this->getAcl();
if ( ! $acl->hasResource( $resource ) )
{
if ( null === $parent )
{
$parent = $this->getParentId( $resource );
}
elseif ( $parent instanceof Acl\Resource\ResourceInterface )
{
$parent = $parent->getResourceId();
}
$parent = $this->checkResource( $parent );
$acl->addResource( $resource, $parent );
}
return $resource;
} | [
"public",
"function",
"checkResource",
"(",
"$",
"resource",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"resource",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"resource",
"instanceof",
"Acl",
"\\",
"Resource",
"\\",
"ResourceInterface",
")",
"{",
"$",
"resource",
"=",
"$",
"resource",
"->",
"getResourceId",
"(",
")",
";",
"}",
"$",
"acl",
"=",
"$",
"this",
"->",
"getAcl",
"(",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"hasResource",
"(",
"$",
"resource",
")",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"parent",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParentId",
"(",
"$",
"resource",
")",
";",
"}",
"elseif",
"(",
"$",
"parent",
"instanceof",
"Acl",
"\\",
"Resource",
"\\",
"ResourceInterface",
")",
"{",
"$",
"parent",
"=",
"$",
"parent",
"->",
"getResourceId",
"(",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"checkResource",
"(",
"$",
"parent",
")",
";",
"$",
"acl",
"->",
"addResource",
"(",
"$",
"resource",
",",
"$",
"parent",
")",
";",
"}",
"return",
"$",
"resource",
";",
"}"
] | Check existence of a resource
@param string|\Zend\Permissions\Acl\Resource\ResourceInterface $resource
@return string | [
"Check",
"existence",
"of",
"a",
"resource"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Model/Permissions/Model.php#L124-L154 |
7,815 | webriq/core | module/User/src/Grid/User/Model/Permissions/Model.php | Model.checkRole | public function checkRole( $role, $parent = null )
{
if ( null === $role )
{
return null;
}
if ( $role instanceof Acl\Role\RoleInterface )
{
$role = $role->getRoleId();
}
$acl = $this->getAcl();
if ( ! $acl->hasRole( $role ) )
{
if ( null === $parent )
{
$parent = $this->getParentId( $role );
}
elseif ( $parent instanceof Acl\Role\RoleInterface )
{
$parent = $parent->getRoleId();
}
$parent = $this->checkRole( $parent );
$acl->addRole( $role, (array) $parent );
$matches = array();
$structures = array();
if ( preg_match( '/^(\d+)$/', $role, $matches ) ) //group
{
$structures = $this->getMapper()
->findAllByGroupId( $matches[1] );
}
else if ( preg_match( '/^(\d+)\.(\d+)$/', $role, $matches ) ) //user
{
$structures = $this->getMapper()
->findAllByUserId( $matches[2] );
$resource = 'user.group.' . $matches[1] .
'.identity.' . $matches[2];
$this->checkResource( $resource );
$acl->allow( $role, $resource );
}
foreach ( $structures as $structure )
{
$this->checkResource( $structure->resource );
$acl->allow( $role, $structure->resource, $structure->privilege );
}
}
return $role;
} | php | public function checkRole( $role, $parent = null )
{
if ( null === $role )
{
return null;
}
if ( $role instanceof Acl\Role\RoleInterface )
{
$role = $role->getRoleId();
}
$acl = $this->getAcl();
if ( ! $acl->hasRole( $role ) )
{
if ( null === $parent )
{
$parent = $this->getParentId( $role );
}
elseif ( $parent instanceof Acl\Role\RoleInterface )
{
$parent = $parent->getRoleId();
}
$parent = $this->checkRole( $parent );
$acl->addRole( $role, (array) $parent );
$matches = array();
$structures = array();
if ( preg_match( '/^(\d+)$/', $role, $matches ) ) //group
{
$structures = $this->getMapper()
->findAllByGroupId( $matches[1] );
}
else if ( preg_match( '/^(\d+)\.(\d+)$/', $role, $matches ) ) //user
{
$structures = $this->getMapper()
->findAllByUserId( $matches[2] );
$resource = 'user.group.' . $matches[1] .
'.identity.' . $matches[2];
$this->checkResource( $resource );
$acl->allow( $role, $resource );
}
foreach ( $structures as $structure )
{
$this->checkResource( $structure->resource );
$acl->allow( $role, $structure->resource, $structure->privilege );
}
}
return $role;
} | [
"public",
"function",
"checkRole",
"(",
"$",
"role",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"role",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"role",
"instanceof",
"Acl",
"\\",
"Role",
"\\",
"RoleInterface",
")",
"{",
"$",
"role",
"=",
"$",
"role",
"->",
"getRoleId",
"(",
")",
";",
"}",
"$",
"acl",
"=",
"$",
"this",
"->",
"getAcl",
"(",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"hasRole",
"(",
"$",
"role",
")",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"parent",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParentId",
"(",
"$",
"role",
")",
";",
"}",
"elseif",
"(",
"$",
"parent",
"instanceof",
"Acl",
"\\",
"Role",
"\\",
"RoleInterface",
")",
"{",
"$",
"parent",
"=",
"$",
"parent",
"->",
"getRoleId",
"(",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"checkRole",
"(",
"$",
"parent",
")",
";",
"$",
"acl",
"->",
"addRole",
"(",
"$",
"role",
",",
"(",
"array",
")",
"$",
"parent",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"structures",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^(\\d+)$/'",
",",
"$",
"role",
",",
"$",
"matches",
")",
")",
"//group",
"{",
"$",
"structures",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"findAllByGroupId",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"else",
"if",
"(",
"preg_match",
"(",
"'/^(\\d+)\\.(\\d+)$/'",
",",
"$",
"role",
",",
"$",
"matches",
")",
")",
"//user",
"{",
"$",
"structures",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"findAllByUserId",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"$",
"resource",
"=",
"'user.group.'",
".",
"$",
"matches",
"[",
"1",
"]",
".",
"'.identity.'",
".",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"this",
"->",
"checkResource",
"(",
"$",
"resource",
")",
";",
"$",
"acl",
"->",
"allow",
"(",
"$",
"role",
",",
"$",
"resource",
")",
";",
"}",
"foreach",
"(",
"$",
"structures",
"as",
"$",
"structure",
")",
"{",
"$",
"this",
"->",
"checkResource",
"(",
"$",
"structure",
"->",
"resource",
")",
";",
"$",
"acl",
"->",
"allow",
"(",
"$",
"role",
",",
"$",
"structure",
"->",
"resource",
",",
"$",
"structure",
"->",
"privilege",
")",
";",
"}",
"}",
"return",
"$",
"role",
";",
"}"
] | Check existence of a role
@param string|\Zend\Permissions\Acl\Role\RoleInterface $role
@return string | [
"Check",
"existence",
"of",
"a",
"role"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Model/Permissions/Model.php#L162-L218 |
7,816 | mcrumley/uritemplate | src/UriTemplate/UriTemplate.php | UriTemplate.expand | public static function expand($template, $variables, array $options = array())
{
if (is_object($variables)) {
$variables = get_object_vars($variables);
} elseif (!is_array($variables)) {
throw new UriTemplateException('$variables must be an array or object');
}
$result = $template;
$errors = array();
$expressions = self::getExpressions($template, $options);
$i = count($expressions);
while ($i-- > 0) {
try {
$expression = $expressions[$i];
if (!$expression['valid']) {
throw new UriTemplateException('Malformed expression: "%s" at offset %d', array($expression['complete'], $expression['offset']));
}
$sub = UriTemplate::expandExpression($expression['expression'], $variables, isset($options['keySort']) ? (bool)$options['keySort'] : false);
$result = substr_replace($result, $sub, $expression['offset'], strlen($expression['complete']));
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
continue;
}
}
if ($errors) {
throw new UriTemplateException('Invalid URI Template string: "%s"', array($template), $errors);
}
return $result;
} | php | public static function expand($template, $variables, array $options = array())
{
if (is_object($variables)) {
$variables = get_object_vars($variables);
} elseif (!is_array($variables)) {
throw new UriTemplateException('$variables must be an array or object');
}
$result = $template;
$errors = array();
$expressions = self::getExpressions($template, $options);
$i = count($expressions);
while ($i-- > 0) {
try {
$expression = $expressions[$i];
if (!$expression['valid']) {
throw new UriTemplateException('Malformed expression: "%s" at offset %d', array($expression['complete'], $expression['offset']));
}
$sub = UriTemplate::expandExpression($expression['expression'], $variables, isset($options['keySort']) ? (bool)$options['keySort'] : false);
$result = substr_replace($result, $sub, $expression['offset'], strlen($expression['complete']));
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
continue;
}
}
if ($errors) {
throw new UriTemplateException('Invalid URI Template string: "%s"', array($template), $errors);
}
return $result;
} | [
"public",
"static",
"function",
"expand",
"(",
"$",
"template",
",",
"$",
"variables",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"variables",
"=",
"get_object_vars",
"(",
"$",
"variables",
")",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"variables",
")",
")",
"{",
"throw",
"new",
"UriTemplateException",
"(",
"'$variables must be an array or object'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"template",
";",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"$",
"expressions",
"=",
"self",
"::",
"getExpressions",
"(",
"$",
"template",
",",
"$",
"options",
")",
";",
"$",
"i",
"=",
"count",
"(",
"$",
"expressions",
")",
";",
"while",
"(",
"$",
"i",
"--",
">",
"0",
")",
"{",
"try",
"{",
"$",
"expression",
"=",
"$",
"expressions",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"!",
"$",
"expression",
"[",
"'valid'",
"]",
")",
"{",
"throw",
"new",
"UriTemplateException",
"(",
"'Malformed expression: \"%s\" at offset %d'",
",",
"array",
"(",
"$",
"expression",
"[",
"'complete'",
"]",
",",
"$",
"expression",
"[",
"'offset'",
"]",
")",
")",
";",
"}",
"$",
"sub",
"=",
"UriTemplate",
"::",
"expandExpression",
"(",
"$",
"expression",
"[",
"'expression'",
"]",
",",
"$",
"variables",
",",
"isset",
"(",
"$",
"options",
"[",
"'keySort'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"'keySort'",
"]",
":",
"false",
")",
";",
"$",
"result",
"=",
"substr_replace",
"(",
"$",
"result",
",",
"$",
"sub",
",",
"$",
"expression",
"[",
"'offset'",
"]",
",",
"strlen",
"(",
"$",
"expression",
"[",
"'complete'",
"]",
")",
")",
";",
"}",
"catch",
"(",
"UriTemplateException",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"errors",
")",
"{",
"throw",
"new",
"UriTemplateException",
"(",
"'Invalid URI Template string: \"%s\"'",
",",
"array",
"(",
"$",
"template",
")",
",",
"$",
"errors",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Expand template as a URI Template using variables.
Throws a UriTemplate exception if the template is invalid.
The exception object has a getErrors() method that returns a list of individual errors.
@param string $template URI template
@param mixed $variables Array or object containing values to insert
@param array $options Optional settings - open, close, sortKeys
open - string to mark the beginning of a substitution expression
close - string to mark the end of a substitution expression
sortKeys - sort arrays by key in output
@return string Expanded URI | [
"Expand",
"template",
"as",
"a",
"URI",
"Template",
"using",
"variables",
"."
] | 347d56ebc9a26d7095e887ad7f9f6173eb4c19a4 | https://github.com/mcrumley/uritemplate/blob/347d56ebc9a26d7095e887ad7f9f6173eb4c19a4/src/UriTemplate/UriTemplate.php#L49-L79 |
7,817 | mcrumley/uritemplate | src/UriTemplate/UriTemplate.php | UriTemplate.getErrors | public static function getErrors($template, array $options = array()) {
$errors = array();
foreach (self::getExpressions($template, $options) as $expression) {
if (!$expression['valid']) {
$errors[] = 'Malformed expression: "'.$expression['complete'].'" at offset '.$expression['offset'];
continue;
}
try {
$expression = self::parseExpression($expression['expression']);
foreach ($expression['varspecs'] as $varspec) {
try {
$varspec = self::parseVarspec($varspec);
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
}
}
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
}
}
return $errors;
} | php | public static function getErrors($template, array $options = array()) {
$errors = array();
foreach (self::getExpressions($template, $options) as $expression) {
if (!$expression['valid']) {
$errors[] = 'Malformed expression: "'.$expression['complete'].'" at offset '.$expression['offset'];
continue;
}
try {
$expression = self::parseExpression($expression['expression']);
foreach ($expression['varspecs'] as $varspec) {
try {
$varspec = self::parseVarspec($varspec);
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
}
}
} catch (UriTemplateException $e) {
$errors[] = $e->getMessage();
}
}
return $errors;
} | [
"public",
"static",
"function",
"getErrors",
"(",
"$",
"template",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"getExpressions",
"(",
"$",
"template",
",",
"$",
"options",
")",
"as",
"$",
"expression",
")",
"{",
"if",
"(",
"!",
"$",
"expression",
"[",
"'valid'",
"]",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'Malformed expression: \"'",
".",
"$",
"expression",
"[",
"'complete'",
"]",
".",
"'\" at offset '",
".",
"$",
"expression",
"[",
"'offset'",
"]",
";",
"continue",
";",
"}",
"try",
"{",
"$",
"expression",
"=",
"self",
"::",
"parseExpression",
"(",
"$",
"expression",
"[",
"'expression'",
"]",
")",
";",
"foreach",
"(",
"$",
"expression",
"[",
"'varspecs'",
"]",
"as",
"$",
"varspec",
")",
"{",
"try",
"{",
"$",
"varspec",
"=",
"self",
"::",
"parseVarspec",
"(",
"$",
"varspec",
")",
";",
"}",
"catch",
"(",
"UriTemplateException",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"UriTemplateException",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] | Get a list of errors in a URI Template.
Some errors can only be detected when processing the template.
E.g. using the prefix modifier on an array value ("{var:2}" where var is an array)
@param string $template URI template
@param array $options Optional settings - open, close
open - string to mark the beginning of a substitution expression
close - string to mark the end of a substitution expression
@return array List of parser errors (an empty array means there were no errors) | [
"Get",
"a",
"list",
"of",
"errors",
"in",
"a",
"URI",
"Template",
"."
] | 347d56ebc9a26d7095e887ad7f9f6173eb4c19a4 | https://github.com/mcrumley/uritemplate/blob/347d56ebc9a26d7095e887ad7f9f6173eb4c19a4/src/UriTemplate/UriTemplate.php#L93-L114 |
7,818 | mcrumley/uritemplate | src/UriTemplate/UriTemplate.php | UriTemplate.getVariables | public static function getVariables($template, array $options = array())
{
$varnames = array();
foreach (self::getExpressions($template, $options) as $expression) {
if ($expression['valid']) {
try {
$expression = self::parseExpression($expression['expression']);
foreach ($expression['varspecs'] as $varspec) {
try {
$varspec = self::parseVarspec($varspec);
$varnames[] = $varspec['varname'];
} catch (UriTemplateException $e) {
continue;
}
}
} catch (UriTemplateException $e) {
continue;
}
}
}
return array_unique($varnames);
} | php | public static function getVariables($template, array $options = array())
{
$varnames = array();
foreach (self::getExpressions($template, $options) as $expression) {
if ($expression['valid']) {
try {
$expression = self::parseExpression($expression['expression']);
foreach ($expression['varspecs'] as $varspec) {
try {
$varspec = self::parseVarspec($varspec);
$varnames[] = $varspec['varname'];
} catch (UriTemplateException $e) {
continue;
}
}
} catch (UriTemplateException $e) {
continue;
}
}
}
return array_unique($varnames);
} | [
"public",
"static",
"function",
"getVariables",
"(",
"$",
"template",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"varnames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"getExpressions",
"(",
"$",
"template",
",",
"$",
"options",
")",
"as",
"$",
"expression",
")",
"{",
"if",
"(",
"$",
"expression",
"[",
"'valid'",
"]",
")",
"{",
"try",
"{",
"$",
"expression",
"=",
"self",
"::",
"parseExpression",
"(",
"$",
"expression",
"[",
"'expression'",
"]",
")",
";",
"foreach",
"(",
"$",
"expression",
"[",
"'varspecs'",
"]",
"as",
"$",
"varspec",
")",
"{",
"try",
"{",
"$",
"varspec",
"=",
"self",
"::",
"parseVarspec",
"(",
"$",
"varspec",
")",
";",
"$",
"varnames",
"[",
"]",
"=",
"$",
"varspec",
"[",
"'varname'",
"]",
";",
"}",
"catch",
"(",
"UriTemplateException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"}",
"}",
"catch",
"(",
"UriTemplateException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"varnames",
")",
";",
"}"
] | Get a list of variables used in a URI Template.
@param string $template URI template
@param array $options Optional settings - open, close
open - string to mark the beginning of a substitution expression
close - string to mark the end of a substitution expression
@return array List of variables referenced by the template | [
"Get",
"a",
"list",
"of",
"variables",
"used",
"in",
"a",
"URI",
"Template",
"."
] | 347d56ebc9a26d7095e887ad7f9f6173eb4c19a4 | https://github.com/mcrumley/uritemplate/blob/347d56ebc9a26d7095e887ad7f9f6173eb4c19a4/src/UriTemplate/UriTemplate.php#L125-L146 |
7,819 | phramework/database | src/Operations/Delete.php | Delete.delete | public static function delete($id, $additionalAttributes, $table, $idAttribute = 'id', $limit = 1)
{
//force disable limit because they wont work with postgreqsql
$limit = null;
$queryValues = [$id];
$additional = [];
foreach ($additionalAttributes as $key => $value) {
//push to additional
$additional[] = sprintf(
'AND "%s"."%s" = ?',
$table,
$key
);
$queryValues[] = $value;
}
$tableName = '';
if (is_array($table) &&
isset($table['schema']) &&
isset($table['table'])) {
$tableName = '"' . $table['schema'] . '"'
.'."' . $table['table'] . '"';
} else {
$tableName = '"' . $table . '"';
}
$query = sprintf(
'DELETE FROM %s
WHERE "%s" = ?
%s
%s',
$tableName,
$idAttribute,
implode("\n", $additional),
(
$limit === null
? ''
: 'LIMIT ' . $limit
)
);
return Database::execute($query, $queryValues);
} | php | public static function delete($id, $additionalAttributes, $table, $idAttribute = 'id', $limit = 1)
{
//force disable limit because they wont work with postgreqsql
$limit = null;
$queryValues = [$id];
$additional = [];
foreach ($additionalAttributes as $key => $value) {
//push to additional
$additional[] = sprintf(
'AND "%s"."%s" = ?',
$table,
$key
);
$queryValues[] = $value;
}
$tableName = '';
if (is_array($table) &&
isset($table['schema']) &&
isset($table['table'])) {
$tableName = '"' . $table['schema'] . '"'
.'."' . $table['table'] . '"';
} else {
$tableName = '"' . $table . '"';
}
$query = sprintf(
'DELETE FROM %s
WHERE "%s" = ?
%s
%s',
$tableName,
$idAttribute,
implode("\n", $additional),
(
$limit === null
? ''
: 'LIMIT ' . $limit
)
);
return Database::execute($query, $queryValues);
} | [
"public",
"static",
"function",
"delete",
"(",
"$",
"id",
",",
"$",
"additionalAttributes",
",",
"$",
"table",
",",
"$",
"idAttribute",
"=",
"'id'",
",",
"$",
"limit",
"=",
"1",
")",
"{",
"//force disable limit because they wont work with postgreqsql",
"$",
"limit",
"=",
"null",
";",
"$",
"queryValues",
"=",
"[",
"$",
"id",
"]",
";",
"$",
"additional",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"additionalAttributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//push to additional",
"$",
"additional",
"[",
"]",
"=",
"sprintf",
"(",
"'AND \"%s\".\"%s\" = ?'",
",",
"$",
"table",
",",
"$",
"key",
")",
";",
"$",
"queryValues",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"tableName",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"table",
")",
"&&",
"isset",
"(",
"$",
"table",
"[",
"'schema'",
"]",
")",
"&&",
"isset",
"(",
"$",
"table",
"[",
"'table'",
"]",
")",
")",
"{",
"$",
"tableName",
"=",
"'\"'",
".",
"$",
"table",
"[",
"'schema'",
"]",
".",
"'\"'",
".",
"'.\"'",
".",
"$",
"table",
"[",
"'table'",
"]",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"tableName",
"=",
"'\"'",
".",
"$",
"table",
".",
"'\"'",
";",
"}",
"$",
"query",
"=",
"sprintf",
"(",
"'DELETE FROM %s\n WHERE \"%s\" = ?\n %s\n %s'",
",",
"$",
"tableName",
",",
"$",
"idAttribute",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"additional",
")",
",",
"(",
"$",
"limit",
"===",
"null",
"?",
"''",
":",
"'LIMIT '",
".",
"$",
"limit",
")",
")",
";",
"return",
"Database",
"::",
"execute",
"(",
"$",
"query",
",",
"$",
"queryValues",
")",
";",
"}"
] | Delete database records
@param string|integer $id
Id value
@param array|object $additionalAttributes
Additional attributes to use in WHERE $idAttribute
@param string|array $table Table's name
@param string $idAttribute **[Optional]**
Id attribute
@param null|integer $limit **[Optional]**
Limit clause, when null there is not limit.
@return integer Return number of affected records | [
"Delete",
"database",
"records"
] | 12726d81917981aa447bb58b76e21762592aab8f | https://github.com/phramework/database/blob/12726d81917981aa447bb58b76e21762592aab8f/src/Operations/Delete.php#L42-L87 |
7,820 | cerad/appx | src/KernelModule/KernelApp.php | KernelApp.boot | public function boot()
{
if ($this->booted) return;
$this->container = $container = new Container();
$this->registerServices ($container);
$this->registerRoutes ($container);
$this->registerEventListeners($container);
$this->booted = true;
} | php | public function boot()
{
if ($this->booted) return;
$this->container = $container = new Container();
$this->registerServices ($container);
$this->registerRoutes ($container);
$this->registerEventListeners($container);
$this->booted = true;
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"booted",
")",
"return",
";",
"$",
"this",
"->",
"container",
"=",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"$",
"this",
"->",
"registerServices",
"(",
"$",
"container",
")",
";",
"$",
"this",
"->",
"registerRoutes",
"(",
"$",
"container",
")",
";",
"$",
"this",
"->",
"registerEventListeners",
"(",
"$",
"container",
")",
";",
"$",
"this",
"->",
"booted",
"=",
"true",
";",
"}"
] | Make this public for testing | [
"Make",
"this",
"public",
"for",
"testing"
] | 79bbfbb2788568e30eb5a8608b7456a5fc8a8806 | https://github.com/cerad/appx/blob/79bbfbb2788568e30eb5a8608b7456a5fc8a8806/src/KernelModule/KernelApp.php#L31-L42 |
7,821 | vinala/kernel | src/MVC/Model/ModelArray.php | ModelArray.first | public function first()
{
if (!empty($this->data)) {
if (Collection::count($this->data) > 0) {
return $this->data[0];
} else {
return;
}
} else {
return;
}
} | php | public function first()
{
if (!empty($this->data)) {
if (Collection::count($this->data) > 0) {
return $this->data[0];
} else {
return;
}
} else {
return;
}
} | [
"public",
"function",
"first",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"if",
"(",
"Collection",
"::",
"count",
"(",
"$",
"this",
"->",
"data",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"return",
";",
"}",
"}"
] | Get first row of data selected by where clause. | [
"Get",
"first",
"row",
"of",
"data",
"selected",
"by",
"where",
"clause",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ModelArray.php#L52-L63 |
7,822 | lucidphp/xml | src/SimpleXMLElement.php | SimpleXMLElement.appendChildFromHtmlString | public function appendChildFromHtmlString($html)
{
$dom = new \DOMDocument;
$dom->loadHTML($html);
$element = simplexml_import_dom($dom);
$element = current($element->xPath('//body/*'));
$this->appendChildNode($element);
} | php | public function appendChildFromHtmlString($html)
{
$dom = new \DOMDocument;
$dom->loadHTML($html);
$element = simplexml_import_dom($dom);
$element = current($element->xPath('//body/*'));
$this->appendChildNode($element);
} | [
"public",
"function",
"appendChildFromHtmlString",
"(",
"$",
"html",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
";",
"$",
"dom",
"->",
"loadHTML",
"(",
"$",
"html",
")",
";",
"$",
"element",
"=",
"simplexml_import_dom",
"(",
"$",
"dom",
")",
";",
"$",
"element",
"=",
"current",
"(",
"$",
"element",
"->",
"xPath",
"(",
"'//body/*'",
")",
")",
";",
"$",
"this",
"->",
"appendChildNode",
"(",
"$",
"element",
")",
";",
"}"
] | Append a childelement from a well formed html string.
@param string a html string
@access public
@return void | [
"Append",
"a",
"childelement",
"from",
"a",
"well",
"formed",
"html",
"string",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/SimpleXMLElement.php#L102-L111 |
7,823 | lucidphp/xml | src/SimpleXMLElement.php | SimpleXMLElement.appendChildFromXmlString | public function appendChildFromXmlString($xml)
{
$dom = new \DOMDocument;
$dom->loadXML($xml);
$element = simplexml_import_dom($dom);
$this->appendChildNode($element);
} | php | public function appendChildFromXmlString($xml)
{
$dom = new \DOMDocument;
$dom->loadXML($xml);
$element = simplexml_import_dom($dom);
$this->appendChildNode($element);
} | [
"public",
"function",
"appendChildFromXmlString",
"(",
"$",
"xml",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
";",
"$",
"dom",
"->",
"loadXML",
"(",
"$",
"xml",
")",
";",
"$",
"element",
"=",
"simplexml_import_dom",
"(",
"$",
"dom",
")",
";",
"$",
"this",
"->",
"appendChildNode",
"(",
"$",
"element",
")",
";",
"}"
] | Append a childelement from a well formed xml string.
@param string $xml a well formed xml string
@access public
@return void | [
"Append",
"a",
"childelement",
"from",
"a",
"well",
"formed",
"xml",
"string",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/SimpleXMLElement.php#L120-L128 |
7,824 | lucidphp/xml | src/SimpleXMLElement.php | SimpleXMLElement.appendChildNode | public function appendChildNode(\SimpleXMLElement $element)
{
$target = dom_import_simplexml($this);
$insert = $target->ownerDocument->importNode(dom_import_simplexml($element), true);
$target->appendChild($insert);
} | php | public function appendChildNode(\SimpleXMLElement $element)
{
$target = dom_import_simplexml($this);
$insert = $target->ownerDocument->importNode(dom_import_simplexml($element), true);
$target->appendChild($insert);
} | [
"public",
"function",
"appendChildNode",
"(",
"\\",
"SimpleXMLElement",
"$",
"element",
")",
"{",
"$",
"target",
"=",
"dom_import_simplexml",
"(",
"$",
"this",
")",
";",
"$",
"insert",
"=",
"$",
"target",
"->",
"ownerDocument",
"->",
"importNode",
"(",
"dom_import_simplexml",
"(",
"$",
"element",
")",
",",
"true",
")",
";",
"$",
"target",
"->",
"appendChild",
"(",
"$",
"insert",
")",
";",
"}"
] | Append a SimpleXMLElement to the current SimpleXMLElement.
@param \SimpleXMLElement $element the element to be appended.
@access public
@return void | [
"Append",
"a",
"SimpleXMLElement",
"to",
"the",
"current",
"SimpleXMLElement",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/SimpleXMLElement.php#L138-L143 |
7,825 | radphp/stuff | src/Admin/Menu.php | Menu.generate | public static function generate()
{
self::dispatchEvent(self::EVENT_GET_MENU);
$return = '';
// sort menu by it's order
uksort(self::$menu, 'strnatcmp');;
/** @var Menu $item */
foreach (self::$menu as $item) {
if ($item->resources && !self::userHasResource($item->resources)) {
continue;
}
if ($children = $item->getChildren()) {
$subItems = '';
// sort menu by it's order
uksort($children, 'strnatcmp');;
/** @var Menu $child */
foreach ($children as $child) {
if ($child->resources && !self::userHasResource($child->resources)) {
continue;
}
$subItems .= '<li><a href="' . $child->getLink() . '">' . $child->getLabel() . '</a></li>';
}
$return .= '<li class="treeview">
<a href="#">
<i class="fa ' . $item->getIcon() . '"></i>
<span>' . $item->getLabel() . '</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
' . $subItems . '
</ul>
</li>';
} else {
$return .= '<li>
<a href="' . $item->getLink() . '">
<i class="fa ' . $item->getIcon() . ' fa-fw"></i> <span>' . $item->getLabel() . '</span>
</a>
</li>';
}
}
return $return;
} | php | public static function generate()
{
self::dispatchEvent(self::EVENT_GET_MENU);
$return = '';
// sort menu by it's order
uksort(self::$menu, 'strnatcmp');;
/** @var Menu $item */
foreach (self::$menu as $item) {
if ($item->resources && !self::userHasResource($item->resources)) {
continue;
}
if ($children = $item->getChildren()) {
$subItems = '';
// sort menu by it's order
uksort($children, 'strnatcmp');;
/** @var Menu $child */
foreach ($children as $child) {
if ($child->resources && !self::userHasResource($child->resources)) {
continue;
}
$subItems .= '<li><a href="' . $child->getLink() . '">' . $child->getLabel() . '</a></li>';
}
$return .= '<li class="treeview">
<a href="#">
<i class="fa ' . $item->getIcon() . '"></i>
<span>' . $item->getLabel() . '</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
' . $subItems . '
</ul>
</li>';
} else {
$return .= '<li>
<a href="' . $item->getLink() . '">
<i class="fa ' . $item->getIcon() . ' fa-fw"></i> <span>' . $item->getLabel() . '</span>
</a>
</li>';
}
}
return $return;
} | [
"public",
"static",
"function",
"generate",
"(",
")",
"{",
"self",
"::",
"dispatchEvent",
"(",
"self",
"::",
"EVENT_GET_MENU",
")",
";",
"$",
"return",
"=",
"''",
";",
"// sort menu by it's order",
"uksort",
"(",
"self",
"::",
"$",
"menu",
",",
"'strnatcmp'",
")",
";",
";",
"/** @var Menu $item */",
"foreach",
"(",
"self",
"::",
"$",
"menu",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"resources",
"&&",
"!",
"self",
"::",
"userHasResource",
"(",
"$",
"item",
"->",
"resources",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"children",
"=",
"$",
"item",
"->",
"getChildren",
"(",
")",
")",
"{",
"$",
"subItems",
"=",
"''",
";",
"// sort menu by it's order",
"uksort",
"(",
"$",
"children",
",",
"'strnatcmp'",
")",
";",
";",
"/** @var Menu $child */",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"resources",
"&&",
"!",
"self",
"::",
"userHasResource",
"(",
"$",
"child",
"->",
"resources",
")",
")",
"{",
"continue",
";",
"}",
"$",
"subItems",
".=",
"'<li><a href=\"'",
".",
"$",
"child",
"->",
"getLink",
"(",
")",
".",
"'\">'",
".",
"$",
"child",
"->",
"getLabel",
"(",
")",
".",
"'</a></li>'",
";",
"}",
"$",
"return",
".=",
"'<li class=\"treeview\">\n <a href=\"#\">\n <i class=\"fa '",
".",
"$",
"item",
"->",
"getIcon",
"(",
")",
".",
"'\"></i>\n <span>'",
".",
"$",
"item",
"->",
"getLabel",
"(",
")",
".",
"'</span>\n <i class=\"fa fa-angle-left pull-right\"></i>\n </a>\n <ul class=\"treeview-menu\">\n '",
".",
"$",
"subItems",
".",
"'\n </ul>\n </li>'",
";",
"}",
"else",
"{",
"$",
"return",
".=",
"'<li>\n <a href=\"'",
".",
"$",
"item",
"->",
"getLink",
"(",
")",
".",
"'\">\n <i class=\"fa '",
".",
"$",
"item",
"->",
"getIcon",
"(",
")",
".",
"' fa-fw\"></i> <span>'",
".",
"$",
"item",
"->",
"getLabel",
"(",
")",
".",
"'</span>\n </a>\n </li>'",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Generate menu, it's only used in this bundle!
@return string Menu HTML code
@todo return must be array, these HTML codes may be in twig template | [
"Generate",
"menu",
"it",
"s",
"only",
"used",
"in",
"this",
"bundle!"
] | 78be878a3607c2d069f276dc20a129750e4478bf | https://github.com/radphp/stuff/blob/78be878a3607c2d069f276dc20a129750e4478bf/src/Admin/Menu.php#L33-L83 |
7,826 | radphp/stuff | src/Admin/Menu.php | Menu.addChild | public function addChild(Menu $child)
{
$this->children[$child->getOrder() . '--' . $child->getLabel()] = $child;
return $this;
} | php | public function addChild(Menu $child)
{
$this->children[$child->getOrder() . '--' . $child->getLabel()] = $child;
return $this;
} | [
"public",
"function",
"addChild",
"(",
"Menu",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"$",
"child",
"->",
"getOrder",
"(",
")",
".",
"'--'",
".",
"$",
"child",
"->",
"getLabel",
"(",
")",
"]",
"=",
"$",
"child",
";",
"return",
"$",
"this",
";",
"}"
] | Add child to menu
@param Menu $child
@return $this | [
"Add",
"child",
"to",
"menu"
] | 78be878a3607c2d069f276dc20a129750e4478bf | https://github.com/radphp/stuff/blob/78be878a3607c2d069f276dc20a129750e4478bf/src/Admin/Menu.php#L148-L153 |
7,827 | aedart/model | src/Traits/Strings/PostalCodeTrait.php | PostalCodeTrait.getPostalCode | public function getPostalCode() : ?string
{
if ( ! $this->hasPostalCode()) {
$this->setPostalCode($this->getDefaultPostalCode());
}
return $this->postalCode;
} | php | public function getPostalCode() : ?string
{
if ( ! $this->hasPostalCode()) {
$this->setPostalCode($this->getDefaultPostalCode());
}
return $this->postalCode;
} | [
"public",
"function",
"getPostalCode",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPostalCode",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPostalCode",
"(",
"$",
"this",
"->",
"getDefaultPostalCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"postalCode",
";",
"}"
] | Get postal code
If no "postal code" value has been set, this method will
set and return a default "postal code" value,
if any such value is available
@see getDefaultPostalCode()
@return string|null postal code or null if no postal code has been set | [
"Get",
"postal",
"code"
] | 9a562c1c53a276d01ace0ab71f5305458bea542f | https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/PostalCodeTrait.php#L48-L54 |
7,828 | joffreydemetz/utilities | src/Date.php | Date.daySuffix | public function daySuffix($day)
{
$locale = \Locale::getDefault();
switch($day){
case 1:
$nf = new \NumberFormatter($locale, \NumberFormatter::ORDINAL);
$day = $nf->format($day);
}
return $day;
} | php | public function daySuffix($day)
{
$locale = \Locale::getDefault();
switch($day){
case 1:
$nf = new \NumberFormatter($locale, \NumberFormatter::ORDINAL);
$day = $nf->format($day);
}
return $day;
} | [
"public",
"function",
"daySuffix",
"(",
"$",
"day",
")",
"{",
"$",
"locale",
"=",
"\\",
"Locale",
"::",
"getDefault",
"(",
")",
";",
"switch",
"(",
"$",
"day",
")",
"{",
"case",
"1",
":",
"$",
"nf",
"=",
"new",
"\\",
"NumberFormatter",
"(",
"$",
"locale",
",",
"\\",
"NumberFormatter",
"::",
"ORDINAL",
")",
";",
"$",
"day",
"=",
"$",
"nf",
"->",
"format",
"(",
"$",
"day",
")",
";",
"}",
"return",
"$",
"day",
";",
"}"
] | Adds day suffix.
@param int $day The numeric day
@return string The suffixed day. | [
"Adds",
"day",
"suffix",
"."
] | aa62a178bc463c10067a2ff2992d39c6f0037b9f | https://github.com/joffreydemetz/utilities/blob/aa62a178bc463c10067a2ff2992d39c6f0037b9f/src/Date.php#L465-L476 |
7,829 | phlexible/phlexible | src/Phlexible/Bundle/MediaManagerBundle/Controller/UploadController.php | UploadController.uploadAction | public function uploadAction(Request $request)
{
$folderId = $request->get('folder_id', null);
try {
$volumeManager = $this->get('phlexible_media_manager.volume_manager');
$volume = $volumeManager->getByFolderId($folderId);
$folder = $volume->findFolder($folderId);
if (empty($folder)) {
return new ResultResponse(
false,
'Target folder not found.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
}
if (!$request->files->count()) {
return new ResultResponse(
false,
'No files received.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
}
$uploadHandler = $this->get('phlexible_media_manager.upload.handler');
$cnt = 0;
foreach ($request->files->all() as $uploadedFile) {
/* @var $uploadedFile UploadedFile */
$file = $uploadHandler->handle($uploadedFile, $folderId, $this->getUser()->getId());
if ($file) {
++$cnt;
$body = 'Filename: '.$uploadedFile->getClientOriginalName().PHP_EOL
.'Folder: '.$folder->getName().PHP_EOL
.'Filesize: '.$file->getSize().PHP_EOL
.'Filetype: '.$file->getMimeType().PHP_EOL;
$message = MediaManagerMessage::create('File "'.$file->getName().'" uploaded.', $body);
$this->get('phlexible_message.message_poster')->post($message);
}
}
return new ResultResponse(
true,
$cnt.' file(s) uploaded.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
} catch (\Exception $e) {
return new ResultResponse(
false,
$e->getMessage(),
[
'params' => $request->request->all(),
'files' => $request->files->all(),
'trace' => $e->getTraceAsString(),
'traceArray' => $e->getTrace(),
]
);
}
} | php | public function uploadAction(Request $request)
{
$folderId = $request->get('folder_id', null);
try {
$volumeManager = $this->get('phlexible_media_manager.volume_manager');
$volume = $volumeManager->getByFolderId($folderId);
$folder = $volume->findFolder($folderId);
if (empty($folder)) {
return new ResultResponse(
false,
'Target folder not found.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
}
if (!$request->files->count()) {
return new ResultResponse(
false,
'No files received.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
}
$uploadHandler = $this->get('phlexible_media_manager.upload.handler');
$cnt = 0;
foreach ($request->files->all() as $uploadedFile) {
/* @var $uploadedFile UploadedFile */
$file = $uploadHandler->handle($uploadedFile, $folderId, $this->getUser()->getId());
if ($file) {
++$cnt;
$body = 'Filename: '.$uploadedFile->getClientOriginalName().PHP_EOL
.'Folder: '.$folder->getName().PHP_EOL
.'Filesize: '.$file->getSize().PHP_EOL
.'Filetype: '.$file->getMimeType().PHP_EOL;
$message = MediaManagerMessage::create('File "'.$file->getName().'" uploaded.', $body);
$this->get('phlexible_message.message_poster')->post($message);
}
}
return new ResultResponse(
true,
$cnt.' file(s) uploaded.',
[
'params' => $request->request->all(),
'files' => $request->files->all(),
]
);
} catch (\Exception $e) {
return new ResultResponse(
false,
$e->getMessage(),
[
'params' => $request->request->all(),
'files' => $request->files->all(),
'trace' => $e->getTraceAsString(),
'traceArray' => $e->getTrace(),
]
);
}
} | [
"public",
"function",
"uploadAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"folderId",
"=",
"$",
"request",
"->",
"get",
"(",
"'folder_id'",
",",
"null",
")",
";",
"try",
"{",
"$",
"volumeManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_media_manager.volume_manager'",
")",
";",
"$",
"volume",
"=",
"$",
"volumeManager",
"->",
"getByFolderId",
"(",
"$",
"folderId",
")",
";",
"$",
"folder",
"=",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"folderId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"folder",
")",
")",
"{",
"return",
"new",
"ResultResponse",
"(",
"false",
",",
"'Target folder not found.'",
",",
"[",
"'params'",
"=>",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"'files'",
"=>",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
",",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"request",
"->",
"files",
"->",
"count",
"(",
")",
")",
"{",
"return",
"new",
"ResultResponse",
"(",
"false",
",",
"'No files received.'",
",",
"[",
"'params'",
"=>",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"'files'",
"=>",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"uploadHandler",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_media_manager.upload.handler'",
")",
";",
"$",
"cnt",
"=",
"0",
";",
"foreach",
"(",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
"as",
"$",
"uploadedFile",
")",
"{",
"/* @var $uploadedFile UploadedFile */",
"$",
"file",
"=",
"$",
"uploadHandler",
"->",
"handle",
"(",
"$",
"uploadedFile",
",",
"$",
"folderId",
",",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"++",
"$",
"cnt",
";",
"$",
"body",
"=",
"'Filename: '",
".",
"$",
"uploadedFile",
"->",
"getClientOriginalName",
"(",
")",
".",
"PHP_EOL",
".",
"'Folder: '",
".",
"$",
"folder",
"->",
"getName",
"(",
")",
".",
"PHP_EOL",
".",
"'Filesize: '",
".",
"$",
"file",
"->",
"getSize",
"(",
")",
".",
"PHP_EOL",
".",
"'Filetype: '",
".",
"$",
"file",
"->",
"getMimeType",
"(",
")",
".",
"PHP_EOL",
";",
"$",
"message",
"=",
"MediaManagerMessage",
"::",
"create",
"(",
"'File \"'",
".",
"$",
"file",
"->",
"getName",
"(",
")",
".",
"'\" uploaded.'",
",",
"$",
"body",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'phlexible_message.message_poster'",
")",
"->",
"post",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"$",
"cnt",
".",
"' file(s) uploaded.'",
",",
"[",
"'params'",
"=>",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"'files'",
"=>",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
",",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"new",
"ResultResponse",
"(",
"false",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"[",
"'params'",
"=>",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"'files'",
"=>",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
",",
"'trace'",
"=>",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
",",
"'traceArray'",
"=>",
"$",
"e",
"->",
"getTrace",
"(",
")",
",",
"]",
")",
";",
"}",
"}"
] | Upload File.
@param Request $request
@return ResultResponse
@Route("", name="mediamanager_upload") | [
"Upload",
"File",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MediaManagerBundle/Controller/UploadController.php#L47-L119 |
7,830 | jeromeklam/freefw | src/FreeFW/Router/Router.php | Router.findRoute | public function findRoute(\Psr\Http\Message\ServerRequestInterface &$p_request)
{
if ($this->routes instanceof \FreeFW\Router\RouteCollection) {
$params = $p_request->getServerParams();
$currentDir = '/';
$requestUrl = '';
if (array_key_exists('_request', $_GET)) {
$requestUrl = '/' . ltrim($_GET['_request'], '/');
}
if (($pos = strpos($requestUrl, '?')) !== false) {
if (array_key_exists('_url', $_GET)) {
$requestUrl = $_GET['_url'];
} else {
$requestUrl = substr($requestUrl, 0, $pos);
}
}
$currentDir = rtrim($this->base_path, '/');
$this->logger->debug('router.findRoute.request : ' . $requestUrl);
foreach ($this->routes->getRoutes() as $idx => $oneRoute) {
$this->logger->debug('router.findRoute.test : ' . $oneRoute->getUrl());
if (strtoupper($p_request->getMethod()) == strtoupper($oneRoute->getMethod())) {
if ($currentDir != '/') {
$requestUrl = str_replace($currentDir, '', $requestUrl);
}
$params = array();
if ($oneRoute->getUrl() == $requestUrl) {
// Ok, pas besoin de compliquer....
} else {
// @todo : ajouter la notion obligatoire pour les paramètres
if (!preg_match("#^" . $oneRoute->getRegex() . "$#", $requestUrl, $matches)) {
continue;
}
// Ok
// On a trouvé une route, on récupère les paramètres.
// On va en profiter pour les injecter dans la requête
$matchedText = array_shift($matches);
if (preg_match_all("/:([\w-\._@%]+)/", $oneRoute->getUrl(), $argument_keys)) {
$argument_keys = $argument_keys[1];
if (count($argument_keys) != count($matches)) {
continue;
}
foreach ($argument_keys as $key => $name) {
if (isset($matches[$key]) && $matches[$key] !== null
&& $matches[$key] != '' && $matches[$key] != '/'
) {
$params[$name] = ltrim($matches[$key], '/'); // Pour les paramètres optionnel
} else {
$params[$name] = '';
}
}
}
foreach ($params as $name => $value) {
$p_request = $p_request->withAttribute($name, $value);
}
}
$this->logger->debug('router.findRoute.match : ' . $oneRoute->getUrl());
return $oneRoute;
}
}
}
return false;
} | php | public function findRoute(\Psr\Http\Message\ServerRequestInterface &$p_request)
{
if ($this->routes instanceof \FreeFW\Router\RouteCollection) {
$params = $p_request->getServerParams();
$currentDir = '/';
$requestUrl = '';
if (array_key_exists('_request', $_GET)) {
$requestUrl = '/' . ltrim($_GET['_request'], '/');
}
if (($pos = strpos($requestUrl, '?')) !== false) {
if (array_key_exists('_url', $_GET)) {
$requestUrl = $_GET['_url'];
} else {
$requestUrl = substr($requestUrl, 0, $pos);
}
}
$currentDir = rtrim($this->base_path, '/');
$this->logger->debug('router.findRoute.request : ' . $requestUrl);
foreach ($this->routes->getRoutes() as $idx => $oneRoute) {
$this->logger->debug('router.findRoute.test : ' . $oneRoute->getUrl());
if (strtoupper($p_request->getMethod()) == strtoupper($oneRoute->getMethod())) {
if ($currentDir != '/') {
$requestUrl = str_replace($currentDir, '', $requestUrl);
}
$params = array();
if ($oneRoute->getUrl() == $requestUrl) {
// Ok, pas besoin de compliquer....
} else {
// @todo : ajouter la notion obligatoire pour les paramètres
if (!preg_match("#^" . $oneRoute->getRegex() . "$#", $requestUrl, $matches)) {
continue;
}
// Ok
// On a trouvé une route, on récupère les paramètres.
// On va en profiter pour les injecter dans la requête
$matchedText = array_shift($matches);
if (preg_match_all("/:([\w-\._@%]+)/", $oneRoute->getUrl(), $argument_keys)) {
$argument_keys = $argument_keys[1];
if (count($argument_keys) != count($matches)) {
continue;
}
foreach ($argument_keys as $key => $name) {
if (isset($matches[$key]) && $matches[$key] !== null
&& $matches[$key] != '' && $matches[$key] != '/'
) {
$params[$name] = ltrim($matches[$key], '/'); // Pour les paramètres optionnel
} else {
$params[$name] = '';
}
}
}
foreach ($params as $name => $value) {
$p_request = $p_request->withAttribute($name, $value);
}
}
$this->logger->debug('router.findRoute.match : ' . $oneRoute->getUrl());
return $oneRoute;
}
}
}
return false;
} | [
"public",
"function",
"findRoute",
"(",
"\\",
"Psr",
"\\",
"Http",
"\\",
"Message",
"\\",
"ServerRequestInterface",
"&",
"$",
"p_request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routes",
"instanceof",
"\\",
"FreeFW",
"\\",
"Router",
"\\",
"RouteCollection",
")",
"{",
"$",
"params",
"=",
"$",
"p_request",
"->",
"getServerParams",
"(",
")",
";",
"$",
"currentDir",
"=",
"'/'",
";",
"$",
"requestUrl",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'_request'",
",",
"$",
"_GET",
")",
")",
"{",
"$",
"requestUrl",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"_GET",
"[",
"'_request'",
"]",
",",
"'/'",
")",
";",
"}",
"if",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"requestUrl",
",",
"'?'",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'_url'",
",",
"$",
"_GET",
")",
")",
"{",
"$",
"requestUrl",
"=",
"$",
"_GET",
"[",
"'_url'",
"]",
";",
"}",
"else",
"{",
"$",
"requestUrl",
"=",
"substr",
"(",
"$",
"requestUrl",
",",
"0",
",",
"$",
"pos",
")",
";",
"}",
"}",
"$",
"currentDir",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"base_path",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'router.findRoute.request : '",
".",
"$",
"requestUrl",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"idx",
"=>",
"$",
"oneRoute",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'router.findRoute.test : '",
".",
"$",
"oneRoute",
"->",
"getUrl",
"(",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"p_request",
"->",
"getMethod",
"(",
")",
")",
"==",
"strtoupper",
"(",
"$",
"oneRoute",
"->",
"getMethod",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"currentDir",
"!=",
"'/'",
")",
"{",
"$",
"requestUrl",
"=",
"str_replace",
"(",
"$",
"currentDir",
",",
"''",
",",
"$",
"requestUrl",
")",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"oneRoute",
"->",
"getUrl",
"(",
")",
"==",
"$",
"requestUrl",
")",
"{",
"// Ok, pas besoin de compliquer....",
"}",
"else",
"{",
"// @todo : ajouter la notion obligatoire pour les paramètres",
"if",
"(",
"!",
"preg_match",
"(",
"\"#^\"",
".",
"$",
"oneRoute",
"->",
"getRegex",
"(",
")",
".",
"\"$#\"",
",",
"$",
"requestUrl",
",",
"$",
"matches",
")",
")",
"{",
"continue",
";",
"}",
"// Ok",
"// On a trouvé une route, on récupère les paramètres.",
"// On va en profiter pour les injecter dans la requête",
"$",
"matchedText",
"=",
"array_shift",
"(",
"$",
"matches",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"\"/:([\\w-\\._@%]+)/\"",
",",
"$",
"oneRoute",
"->",
"getUrl",
"(",
")",
",",
"$",
"argument_keys",
")",
")",
"{",
"$",
"argument_keys",
"=",
"$",
"argument_keys",
"[",
"1",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"argument_keys",
")",
"!=",
"count",
"(",
"$",
"matches",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"argument_keys",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"matches",
"[",
"$",
"key",
"]",
"!==",
"null",
"&&",
"$",
"matches",
"[",
"$",
"key",
"]",
"!=",
"''",
"&&",
"$",
"matches",
"[",
"$",
"key",
"]",
"!=",
"'/'",
")",
"{",
"$",
"params",
"[",
"$",
"name",
"]",
"=",
"ltrim",
"(",
"$",
"matches",
"[",
"$",
"key",
"]",
",",
"'/'",
")",
";",
"// Pour les paramètres optionnel",
"}",
"else",
"{",
"$",
"params",
"[",
"$",
"name",
"]",
"=",
"''",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"p_request",
"=",
"$",
"p_request",
"->",
"withAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'router.findRoute.match : '",
".",
"$",
"oneRoute",
"->",
"getUrl",
"(",
")",
")",
";",
"return",
"$",
"oneRoute",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Find called route
@param \Psr\Http\Message\ServerRequestInterface $p_request
@return \FreeFW\Router\Route | false | [
"Find",
"called",
"route"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Router/Router.php#L81-L142 |
7,831 | jeromeklam/freefw | src/FreeFW/Tools/Stream.php | Stream.copyToString | public static function copyToString(StreamInterface $stream, $maxLen = -1)
{
$buffer = '';
if ($maxLen === -1) {
while (!$stream->eof()) {
$buf = $stream->read(1048576);
// Using a loose equality here to match on '' and false.
if ($buf == null) {
break;
}
$buffer .= $buf;
}
return $buffer;
}
$len = 0;
while (!$stream->eof() && $len < $maxLen) {
$buf = $stream->read($maxLen - $len);
// Using a loose equality here to match on '' and false.
if ($buf == null) {
break;
}
$buffer .= $buf;
$len = strlen($buffer);
}
return $buffer;
} | php | public static function copyToString(StreamInterface $stream, $maxLen = -1)
{
$buffer = '';
if ($maxLen === -1) {
while (!$stream->eof()) {
$buf = $stream->read(1048576);
// Using a loose equality here to match on '' and false.
if ($buf == null) {
break;
}
$buffer .= $buf;
}
return $buffer;
}
$len = 0;
while (!$stream->eof() && $len < $maxLen) {
$buf = $stream->read($maxLen - $len);
// Using a loose equality here to match on '' and false.
if ($buf == null) {
break;
}
$buffer .= $buf;
$len = strlen($buffer);
}
return $buffer;
} | [
"public",
"static",
"function",
"copyToString",
"(",
"StreamInterface",
"$",
"stream",
",",
"$",
"maxLen",
"=",
"-",
"1",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"if",
"(",
"$",
"maxLen",
"===",
"-",
"1",
")",
"{",
"while",
"(",
"!",
"$",
"stream",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"buf",
"=",
"$",
"stream",
"->",
"read",
"(",
"1048576",
")",
";",
"// Using a loose equality here to match on '' and false.",
"if",
"(",
"$",
"buf",
"==",
"null",
")",
"{",
"break",
";",
"}",
"$",
"buffer",
".=",
"$",
"buf",
";",
"}",
"return",
"$",
"buffer",
";",
"}",
"$",
"len",
"=",
"0",
";",
"while",
"(",
"!",
"$",
"stream",
"->",
"eof",
"(",
")",
"&&",
"$",
"len",
"<",
"$",
"maxLen",
")",
"{",
"$",
"buf",
"=",
"$",
"stream",
"->",
"read",
"(",
"$",
"maxLen",
"-",
"$",
"len",
")",
";",
"// Using a loose equality here to match on '' and false.",
"if",
"(",
"$",
"buf",
"==",
"null",
")",
"{",
"break",
";",
"}",
"$",
"buffer",
".=",
"$",
"buf",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"buffer",
")",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
] | Copy the contents of a stream into a string until the given number of
bytes have been read.
@param StreamInterface $stream Stream to read
@param int $maxLen Maximum number of bytes to read. Pass -1
to read the entire stream.
@return string
@throws \RuntimeException on error. | [
"Copy",
"the",
"contents",
"of",
"a",
"stream",
"into",
"a",
"string",
"until",
"the",
"given",
"number",
"of",
"bytes",
"have",
"been",
"read",
"."
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/Stream.php#L74-L99 |
7,832 | jerel/quick-cache | core/Quick/Cache.php | Cache.method | public function method($class, $method, $args = array(), $ttl = null)
{
// Ensure that the class is a string
is_string($class) or $class = get_class($class);
$identifier = array(
'class' => $class,
'method' => $method,
'args' => $args
);
// do we have the data cached already?
$result = $this->driver->get_method($identifier);
if ($result['status']) {
// yep, we had it
return unserialize($result['data']);
}
// no data found, run the method
if (is_string($class)) {
$object = new $class;
}
$data = call_user_func_array(array($object, $method), $args);
$data_string = serialize($data);
// now cache the newfound data and return it
$this->driver->set_method($identifier, $data_string, $ttl);
// if we are testing we drop out of "return the correct data at any cost mode"
// and instead make sure that our write was successful
if ($this->strict) {
$result = $this->driver->get_method($identifier);
return unserialize($result['data']);
}
return $data;
} | php | public function method($class, $method, $args = array(), $ttl = null)
{
// Ensure that the class is a string
is_string($class) or $class = get_class($class);
$identifier = array(
'class' => $class,
'method' => $method,
'args' => $args
);
// do we have the data cached already?
$result = $this->driver->get_method($identifier);
if ($result['status']) {
// yep, we had it
return unserialize($result['data']);
}
// no data found, run the method
if (is_string($class)) {
$object = new $class;
}
$data = call_user_func_array(array($object, $method), $args);
$data_string = serialize($data);
// now cache the newfound data and return it
$this->driver->set_method($identifier, $data_string, $ttl);
// if we are testing we drop out of "return the correct data at any cost mode"
// and instead make sure that our write was successful
if ($this->strict) {
$result = $this->driver->get_method($identifier);
return unserialize($result['data']);
}
return $data;
} | [
"public",
"function",
"method",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"// Ensure that the class is a string",
"is_string",
"(",
"$",
"class",
")",
"or",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"$",
"identifier",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"class",
",",
"'method'",
"=>",
"$",
"method",
",",
"'args'",
"=>",
"$",
"args",
")",
";",
"// do we have the data cached already?",
"$",
"result",
"=",
"$",
"this",
"->",
"driver",
"->",
"get_method",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'status'",
"]",
")",
"{",
"// yep, we had it",
"return",
"unserialize",
"(",
"$",
"result",
"[",
"'data'",
"]",
")",
";",
"}",
"// no data found, run the method",
"if",
"(",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"$",
"object",
"=",
"new",
"$",
"class",
";",
"}",
"$",
"data",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"object",
",",
"$",
"method",
")",
",",
"$",
"args",
")",
";",
"$",
"data_string",
"=",
"serialize",
"(",
"$",
"data",
")",
";",
"// now cache the newfound data and return it",
"$",
"this",
"->",
"driver",
"->",
"set_method",
"(",
"$",
"identifier",
",",
"$",
"data_string",
",",
"$",
"ttl",
")",
";",
"// if we are testing we drop out of \"return the correct data at any cost mode\" ",
"// and instead make sure that our write was successful",
"if",
"(",
"$",
"this",
"->",
"strict",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"driver",
"->",
"get_method",
"(",
"$",
"identifier",
")",
";",
"return",
"unserialize",
"(",
"$",
"result",
"[",
"'data'",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Call a method, cache the result, and return the data
@param string|object $class Either a namespace class or an object
@param string $method The method to call
@param array $args The arguments to pass to the method
@param integer $ttl The time to live (seconds) will only be set on the first call for a method
@return | [
"Call",
"a",
"method",
"cache",
"the",
"result",
"and",
"return",
"the",
"data"
] | e5963482c5f90fe866d4e87545cb7eab5cc65c43 | https://github.com/jerel/quick-cache/blob/e5963482c5f90fe866d4e87545cb7eab5cc65c43/core/Quick/Cache.php#L105-L144 |
7,833 | Hexmedia/User-Bundle | EventListener/DiscriminatorListener.php | DiscriminatorListener.loadClassMetadata | public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$metadata = $eventArgs->getClassMetadata();
$class = $metadata->getReflectionClass();
if ($class === null) {
$class = new \ReflectionClass($metadata->getName());
}
if ($this->className && $class->getName() == "Hexmedia\\UserBundle\\Entity\\User") {
$reader = new AnnotationReader();
$discriminatorMap = [];
$discriminatorMapAnnotation = $reader->getClassAnnotation($class, 'Doctrine\ORM\Mapping\DiscriminatorMap');
if ($discriminatorMapAnnotation) {
$discriminatorMap = $discriminatorMapAnnotation->value;
}
$discriminatorMap['users'] = $this->className;
$discriminatorMap['users_base'] = "Hexmedia\\UserBundle\\Entity\\User";
$metadata->setDiscriminatorColumn(["name" => "type", "length" => 255]);
$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
$metadata->setDiscriminatorMap($discriminatorMap);
}
} | php | public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$metadata = $eventArgs->getClassMetadata();
$class = $metadata->getReflectionClass();
if ($class === null) {
$class = new \ReflectionClass($metadata->getName());
}
if ($this->className && $class->getName() == "Hexmedia\\UserBundle\\Entity\\User") {
$reader = new AnnotationReader();
$discriminatorMap = [];
$discriminatorMapAnnotation = $reader->getClassAnnotation($class, 'Doctrine\ORM\Mapping\DiscriminatorMap');
if ($discriminatorMapAnnotation) {
$discriminatorMap = $discriminatorMapAnnotation->value;
}
$discriminatorMap['users'] = $this->className;
$discriminatorMap['users_base'] = "Hexmedia\\UserBundle\\Entity\\User";
$metadata->setDiscriminatorColumn(["name" => "type", "length" => 255]);
$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
$metadata->setDiscriminatorMap($discriminatorMap);
}
} | [
"public",
"function",
"loadClassMetadata",
"(",
"LoadClassMetadataEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"metadata",
"=",
"$",
"eventArgs",
"->",
"getClassMetadata",
"(",
")",
";",
"$",
"class",
"=",
"$",
"metadata",
"->",
"getReflectionClass",
"(",
")",
";",
"if",
"(",
"$",
"class",
"===",
"null",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"metadata",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"className",
"&&",
"$",
"class",
"->",
"getName",
"(",
")",
"==",
"\"Hexmedia\\\\UserBundle\\\\Entity\\\\User\"",
")",
"{",
"$",
"reader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"$",
"discriminatorMap",
"=",
"[",
"]",
";",
"$",
"discriminatorMapAnnotation",
"=",
"$",
"reader",
"->",
"getClassAnnotation",
"(",
"$",
"class",
",",
"'Doctrine\\ORM\\Mapping\\DiscriminatorMap'",
")",
";",
"if",
"(",
"$",
"discriminatorMapAnnotation",
")",
"{",
"$",
"discriminatorMap",
"=",
"$",
"discriminatorMapAnnotation",
"->",
"value",
";",
"}",
"$",
"discriminatorMap",
"[",
"'users'",
"]",
"=",
"$",
"this",
"->",
"className",
";",
"$",
"discriminatorMap",
"[",
"'users_base'",
"]",
"=",
"\"Hexmedia\\\\UserBundle\\\\Entity\\\\User\"",
";",
"$",
"metadata",
"->",
"setDiscriminatorColumn",
"(",
"[",
"\"name\"",
"=>",
"\"type\"",
",",
"\"length\"",
"=>",
"255",
"]",
")",
";",
"$",
"metadata",
"->",
"setInheritanceType",
"(",
"ClassMetadataInfo",
"::",
"INHERITANCE_TYPE_SINGLE_TABLE",
")",
";",
"$",
"metadata",
"->",
"setDiscriminatorMap",
"(",
"$",
"discriminatorMap",
")",
";",
"}",
"}"
] | Sets the discriminator map according to the config
@param LoadClassMetadataEventArgs $eventArgs | [
"Sets",
"the",
"discriminator",
"map",
"according",
"to",
"the",
"config"
] | c729a92b905977c3e5c2ef4d77585647a2a31966 | https://github.com/Hexmedia/User-Bundle/blob/c729a92b905977c3e5c2ef4d77585647a2a31966/EventListener/DiscriminatorListener.php#L32-L58 |
7,834 | mmanos/laravel-metable | src/commands/MetasCommand.php | MetasCommand.getMigrationStub | protected function getMigrationStub()
{
$stub = file_get_contents(__DIR__.'/../Mmanos/Metable/Stubs/MetasMigration.stub.php');
$stub = str_replace('{{table}}', $this->tableName(), $stub);
$stub = str_replace(
'{{class}}',
'Create' . Str::studly($this->tableName()) . 'Table',
$stub
);
return $stub;
} | php | protected function getMigrationStub()
{
$stub = file_get_contents(__DIR__.'/../Mmanos/Metable/Stubs/MetasMigration.stub.php');
$stub = str_replace('{{table}}', $this->tableName(), $stub);
$stub = str_replace(
'{{class}}',
'Create' . Str::studly($this->tableName()) . 'Table',
$stub
);
return $stub;
} | [
"protected",
"function",
"getMigrationStub",
"(",
")",
"{",
"$",
"stub",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../Mmanos/Metable/Stubs/MetasMigration.stub.php'",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{table}}'",
",",
"$",
"this",
"->",
"tableName",
"(",
")",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{class}}'",
",",
"'Create'",
".",
"Str",
"::",
"studly",
"(",
"$",
"this",
"->",
"tableName",
"(",
")",
")",
".",
"'Table'",
",",
"$",
"stub",
")",
";",
"return",
"$",
"stub",
";",
"}"
] | Get the contents of the migration stub.
@return string | [
"Get",
"the",
"contents",
"of",
"the",
"migration",
"stub",
"."
] | f6a6bdcebcf7eefd42e9d58c37e3206361f147de | https://github.com/mmanos/laravel-metable/blob/f6a6bdcebcf7eefd42e9d58c37e3206361f147de/src/commands/MetasCommand.php#L72-L84 |
7,835 | mmanos/laravel-metable | src/commands/MetasCommand.php | MetasCommand.createBaseModel | protected function createBaseModel()
{
$name_parts = explode('_', $this->tableName());
$path = $this->laravel['path'].'/models';
for ($i = 0; $i < (count($name_parts) - 1); $i++) {
$path .= '/' . Str::studly(Str::singular($name_parts[$i]));
}
if (count($name_parts) > 1 && !File::exists($path)) {
File::makeDirectory($path, 0755, true);
}
$path .= '/' . Str::studly(Str::singular(end($name_parts))) . '.php';
return $path;
} | php | protected function createBaseModel()
{
$name_parts = explode('_', $this->tableName());
$path = $this->laravel['path'].'/models';
for ($i = 0; $i < (count($name_parts) - 1); $i++) {
$path .= '/' . Str::studly(Str::singular($name_parts[$i]));
}
if (count($name_parts) > 1 && !File::exists($path)) {
File::makeDirectory($path, 0755, true);
}
$path .= '/' . Str::studly(Str::singular(end($name_parts))) . '.php';
return $path;
} | [
"protected",
"function",
"createBaseModel",
"(",
")",
"{",
"$",
"name_parts",
"=",
"explode",
"(",
"'_'",
",",
"$",
"this",
"->",
"tableName",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'path'",
"]",
".",
"'/models'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"count",
"(",
"$",
"name_parts",
")",
"-",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"path",
".=",
"'/'",
".",
"Str",
"::",
"studly",
"(",
"Str",
"::",
"singular",
"(",
"$",
"name_parts",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"name_parts",
")",
">",
"1",
"&&",
"!",
"File",
"::",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"File",
"::",
"makeDirectory",
"(",
"$",
"path",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"path",
".=",
"'/'",
".",
"Str",
"::",
"studly",
"(",
"Str",
"::",
"singular",
"(",
"end",
"(",
"$",
"name_parts",
")",
")",
")",
".",
"'.php'",
";",
"return",
"$",
"path",
";",
"}"
] | Create a base model file.
@return string | [
"Create",
"a",
"base",
"model",
"file",
"."
] | f6a6bdcebcf7eefd42e9d58c37e3206361f147de | https://github.com/mmanos/laravel-metable/blob/f6a6bdcebcf7eefd42e9d58c37e3206361f147de/src/commands/MetasCommand.php#L91-L108 |
7,836 | mmanos/laravel-metable | src/commands/MetasCommand.php | MetasCommand.getModelStub | protected function getModelStub()
{
$stub = file_get_contents(__DIR__.'/../Mmanos/Metable/Stubs/MetaModel.stub.php');
$name_parts = explode('_', $this->tableName());
$namespace = '';
for ($i = 0; $i < (count($name_parts) - 1); $i++) {
$namespace .= '\\' . Str::studly(Str::singular($name_parts[$i]));
}
$namespace = trim($namespace, '\\');
$class = Str::studly(Str::singular(end($name_parts)));
$stub = str_replace('{{namespace}}', empty($namespace) ? '' : " namespace {$namespace};", $stub);
$stub = str_replace('{{class}}', $class, $stub);
$stub = str_replace('{{table}}', $this->tableName(), $stub);
return $stub;
} | php | protected function getModelStub()
{
$stub = file_get_contents(__DIR__.'/../Mmanos/Metable/Stubs/MetaModel.stub.php');
$name_parts = explode('_', $this->tableName());
$namespace = '';
for ($i = 0; $i < (count($name_parts) - 1); $i++) {
$namespace .= '\\' . Str::studly(Str::singular($name_parts[$i]));
}
$namespace = trim($namespace, '\\');
$class = Str::studly(Str::singular(end($name_parts)));
$stub = str_replace('{{namespace}}', empty($namespace) ? '' : " namespace {$namespace};", $stub);
$stub = str_replace('{{class}}', $class, $stub);
$stub = str_replace('{{table}}', $this->tableName(), $stub);
return $stub;
} | [
"protected",
"function",
"getModelStub",
"(",
")",
"{",
"$",
"stub",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../Mmanos/Metable/Stubs/MetaModel.stub.php'",
")",
";",
"$",
"name_parts",
"=",
"explode",
"(",
"'_'",
",",
"$",
"this",
"->",
"tableName",
"(",
")",
")",
";",
"$",
"namespace",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"count",
"(",
"$",
"name_parts",
")",
"-",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"namespace",
".=",
"'\\\\'",
".",
"Str",
"::",
"studly",
"(",
"Str",
"::",
"singular",
"(",
"$",
"name_parts",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"$",
"class",
"=",
"Str",
"::",
"studly",
"(",
"Str",
"::",
"singular",
"(",
"end",
"(",
"$",
"name_parts",
")",
")",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{namespace}}'",
",",
"empty",
"(",
"$",
"namespace",
")",
"?",
"''",
":",
"\" namespace {$namespace};\"",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{class}}'",
",",
"$",
"class",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'{{table}}'",
",",
"$",
"this",
"->",
"tableName",
"(",
")",
",",
"$",
"stub",
")",
";",
"return",
"$",
"stub",
";",
"}"
] | Get the contents of the model stub.
@return string | [
"Get",
"the",
"contents",
"of",
"the",
"model",
"stub",
"."
] | f6a6bdcebcf7eefd42e9d58c37e3206361f147de | https://github.com/mmanos/laravel-metable/blob/f6a6bdcebcf7eefd42e9d58c37e3206361f147de/src/commands/MetasCommand.php#L115-L132 |
7,837 | phossa2/libs | src/Phossa2/Logger/Logger.php | Logger.addHandler | public function addHandler(
/*# string */ $level,
callable $handler,
/*# string */ $channel = '*',
/*# int */ $priority = 0
) {
// check level
if (!isset(LogLevel::$levels[$level])) {
throw new InvalidArgumentException(
Message::get(Message::LOG_LEVEL_INVALID, $level),
Message::LOG_LEVEL_INVALID
);
}
return $this->addCallable(
'handlers',
$handler,
$channel,
$priority,
$level
);
} | php | public function addHandler(
/*# string */ $level,
callable $handler,
/*# string */ $channel = '*',
/*# int */ $priority = 0
) {
// check level
if (!isset(LogLevel::$levels[$level])) {
throw new InvalidArgumentException(
Message::get(Message::LOG_LEVEL_INVALID, $level),
Message::LOG_LEVEL_INVALID
);
}
return $this->addCallable(
'handlers',
$handler,
$channel,
$priority,
$level
);
} | [
"public",
"function",
"addHandler",
"(",
"/*# string */",
"$",
"level",
",",
"callable",
"$",
"handler",
",",
"/*# string */",
"$",
"channel",
"=",
"'*'",
",",
"/*# int */",
"$",
"priority",
"=",
"0",
")",
"{",
"// check level",
"if",
"(",
"!",
"isset",
"(",
"LogLevel",
"::",
"$",
"levels",
"[",
"$",
"level",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"LOG_LEVEL_INVALID",
",",
"$",
"level",
")",
",",
"Message",
"::",
"LOG_LEVEL_INVALID",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addCallable",
"(",
"'handlers'",
",",
"$",
"handler",
",",
"$",
"channel",
",",
"$",
"priority",
",",
"$",
"level",
")",
";",
"}"
] | Add handler to the channel with priority
@param string $level the level this handler is handling
@param callable $handler
@param string $channel channel to listen to
@param int $priority
@return $this
@access public
@since 2.0.1 added level param
@api | [
"Add",
"handler",
"to",
"the",
"channel",
"with",
"priority"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Logger.php#L113-L134 |
7,838 | dankempster/axstrad-content | src/Traits/CopyBasedIntroduction.php | CopyBasedIntroduction.getIntroduction | public function getIntroduction($ellipse = "...")
{
$intro = $this->internalGetIntroduction();
if ($intro === null && ($copy = $this->getCopy()) !== null) {
$copy = trim(strip_tags($this->getCopy()));
if ( ! empty($copy)) {
$intro = $this->truncateWords($copy, $ellipse);
}
}
return $intro;
} | php | public function getIntroduction($ellipse = "...")
{
$intro = $this->internalGetIntroduction();
if ($intro === null && ($copy = $this->getCopy()) !== null) {
$copy = trim(strip_tags($this->getCopy()));
if ( ! empty($copy)) {
$intro = $this->truncateWords($copy, $ellipse);
}
}
return $intro;
} | [
"public",
"function",
"getIntroduction",
"(",
"$",
"ellipse",
"=",
"\"...\"",
")",
"{",
"$",
"intro",
"=",
"$",
"this",
"->",
"internalGetIntroduction",
"(",
")",
";",
"if",
"(",
"$",
"intro",
"===",
"null",
"&&",
"(",
"$",
"copy",
"=",
"$",
"this",
"->",
"getCopy",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"copy",
"=",
"trim",
"(",
"strip_tags",
"(",
"$",
"this",
"->",
"getCopy",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"copy",
")",
")",
"{",
"$",
"intro",
"=",
"$",
"this",
"->",
"truncateWords",
"(",
"$",
"copy",
",",
"$",
"ellipse",
")",
";",
"}",
"}",
"return",
"$",
"intro",
";",
"}"
] | Get introduction.
If an introduction hasn't been set, the first {@see $copyIntroWordCount
X words} from the {@see getCopy copy} are returned.
@param string $ellipse
@return string | [
"Get",
"introduction",
"."
] | 700c3c2c1439129fdc54c9a899ccf5742f56e072 | https://github.com/dankempster/axstrad-content/blob/700c3c2c1439129fdc54c9a899ccf5742f56e072/src/Traits/CopyBasedIntroduction.php#L46-L59 |
7,839 | mickeyhead7/mickeyhead7-rsvp | src/Pagination/Pagination.php | Pagination.generateCollectionLinks | public function generateCollectionLinks()
{
$links = [
'self' => $this->getPaginator()->getSelf(),
];
if ($first = $this->getPaginator()->getFirst()) {
$links['first'] = $first;
}
if ($previous = $this->getPaginator()->getPrevious()) {
$links['previous'] = $previous;
}
if ($next = $this->getPaginator()->getNext()) {
$links['next'] = $next;
}
if ($last = $this->getPaginator()->getLast()) {
$links['last'] = $last;
}
return $links;
} | php | public function generateCollectionLinks()
{
$links = [
'self' => $this->getPaginator()->getSelf(),
];
if ($first = $this->getPaginator()->getFirst()) {
$links['first'] = $first;
}
if ($previous = $this->getPaginator()->getPrevious()) {
$links['previous'] = $previous;
}
if ($next = $this->getPaginator()->getNext()) {
$links['next'] = $next;
}
if ($last = $this->getPaginator()->getLast()) {
$links['last'] = $last;
}
return $links;
} | [
"public",
"function",
"generateCollectionLinks",
"(",
")",
"{",
"$",
"links",
"=",
"[",
"'self'",
"=>",
"$",
"this",
"->",
"getPaginator",
"(",
")",
"->",
"getSelf",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"first",
"=",
"$",
"this",
"->",
"getPaginator",
"(",
")",
"->",
"getFirst",
"(",
")",
")",
"{",
"$",
"links",
"[",
"'first'",
"]",
"=",
"$",
"first",
";",
"}",
"if",
"(",
"$",
"previous",
"=",
"$",
"this",
"->",
"getPaginator",
"(",
")",
"->",
"getPrevious",
"(",
")",
")",
"{",
"$",
"links",
"[",
"'previous'",
"]",
"=",
"$",
"previous",
";",
"}",
"if",
"(",
"$",
"next",
"=",
"$",
"this",
"->",
"getPaginator",
"(",
")",
"->",
"getNext",
"(",
")",
")",
"{",
"$",
"links",
"[",
"'next'",
"]",
"=",
"$",
"next",
";",
"}",
"if",
"(",
"$",
"last",
"=",
"$",
"this",
"->",
"getPaginator",
"(",
")",
"->",
"getLast",
"(",
")",
")",
"{",
"$",
"links",
"[",
"'last'",
"]",
"=",
"$",
"last",
";",
"}",
"return",
"$",
"links",
";",
"}"
] | Generate URL links for a resource collection
@return array | [
"Generate",
"URL",
"links",
"for",
"a",
"resource",
"collection"
] | 36a780acd8b26bc9f313d7d2ebe44250f1aa6731 | https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Pagination/Pagination.php#L40-L63 |
7,840 | Dhii/state-machine-abstract | src/TransitionListAwareTrait.php | TransitionListAwareTrait._getTransition | protected function _getTransition($key)
{
$sKey = (string) $key;
return array_key_exists($sKey, $this->transitions)
? $this->transitions[$sKey]
: null;
} | php | protected function _getTransition($key)
{
$sKey = (string) $key;
return array_key_exists($sKey, $this->transitions)
? $this->transitions[$sKey]
: null;
} | [
"protected",
"function",
"_getTransition",
"(",
"$",
"key",
")",
"{",
"$",
"sKey",
"=",
"(",
"string",
")",
"$",
"key",
";",
"return",
"array_key_exists",
"(",
"$",
"sKey",
",",
"$",
"this",
"->",
"transitions",
")",
"?",
"$",
"this",
"->",
"transitions",
"[",
"$",
"sKey",
"]",
":",
"null",
";",
"}"
] | Retrieves the transition with a specific key.
@since [*next-version*]
@param string|Stringable $key The transition key.
@return string|Stringable|null The transition, or null if no transition for the given key was found. | [
"Retrieves",
"the",
"transition",
"with",
"a",
"specific",
"key",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/TransitionListAwareTrait.php#L63-L70 |
7,841 | Dhii/state-machine-abstract | src/TransitionListAwareTrait.php | TransitionListAwareTrait._addTransition | protected function _addTransition($transition)
{
if (!is_string($transition) && !($transition instanceof Stringable)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid transition.'),
null,
null,
$transition
);
}
$this->transitions[(string) $transition] = $transition;
} | php | protected function _addTransition($transition)
{
if (!is_string($transition) && !($transition instanceof Stringable)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid transition.'),
null,
null,
$transition
);
}
$this->transitions[(string) $transition] = $transition;
} | [
"protected",
"function",
"_addTransition",
"(",
"$",
"transition",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"transition",
")",
"&&",
"!",
"(",
"$",
"transition",
"instanceof",
"Stringable",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Argument is not a valid transition.'",
")",
",",
"null",
",",
"null",
",",
"$",
"transition",
")",
";",
"}",
"$",
"this",
"->",
"transitions",
"[",
"(",
"string",
")",
"$",
"transition",
"]",
"=",
"$",
"transition",
";",
"}"
] | Adds a transition to this instance.
@since [*next-version*]
@param string|Stringable $transition The transition to add. | [
"Adds",
"a",
"transition",
"to",
"this",
"instance",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/TransitionListAwareTrait.php#L93-L105 |
7,842 | n0m4dz/laracasa | Zend/Gdata/App/LoggingHttpClientAdapterSocket.php | Zend_Gdata_App_LoggingHttpClientAdapterSocket.log | protected function log($message)
{
if ($this->log_handle == null) {
$this->log_handle = fopen($this->config['logfile'], 'a');
}
fwrite($this->log_handle, $message);
} | php | protected function log($message)
{
if ($this->log_handle == null) {
$this->log_handle = fopen($this->config['logfile'], 'a');
}
fwrite($this->log_handle, $message);
} | [
"protected",
"function",
"log",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"log_handle",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"log_handle",
"=",
"fopen",
"(",
"$",
"this",
"->",
"config",
"[",
"'logfile'",
"]",
",",
"'a'",
")",
";",
"}",
"fwrite",
"(",
"$",
"this",
"->",
"log_handle",
",",
"$",
"message",
")",
";",
"}"
] | Log the given message to the log file. The log file is configured
as the config param 'logfile'. This method opens the file for
writing if necessary.
@param string $message The message to log | [
"Log",
"the",
"given",
"message",
"to",
"the",
"log",
"file",
".",
"The",
"log",
"file",
"is",
"configured",
"as",
"the",
"config",
"param",
"logfile",
".",
"This",
"method",
"opens",
"the",
"file",
"for",
"writing",
"if",
"necessary",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/LoggingHttpClientAdapterSocket.php#L58-L64 |
7,843 | tomphp/exception-constructor-tools | src/ExceptionConstructorTools.php | ExceptionConstructorTools.create | protected static function create(
$message,
array $params = [],
$code = 0,
\Exception $previous = null
) {
return new static(sprintf($message, ...$params), $code, $previous);
} | php | protected static function create(
$message,
array $params = [],
$code = 0,
\Exception $previous = null
) {
return new static(sprintf($message, ...$params), $code, $previous);
} | [
"protected",
"static",
"function",
"create",
"(",
"$",
"message",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"code",
"=",
"0",
",",
"\\",
"Exception",
"$",
"previous",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"$",
"message",
",",
"...",
"$",
"params",
")",
",",
"$",
"code",
",",
"$",
"previous",
")",
";",
"}"
] | Create an instance of the exception with a formatted message.
@param string $message The exception message in sprintf format.
@param array $params The sprintf parameters for the message.
@param int $code Numeric exception code.
@param \Exception $previous The previous exception.
@return static | [
"Create",
"an",
"instance",
"of",
"the",
"exception",
"with",
"a",
"formatted",
"message",
"."
] | bae5a049cbee7ca402904f307d67403fc4be3602 | https://github.com/tomphp/exception-constructor-tools/blob/bae5a049cbee7ca402904f307d67403fc4be3602/src/ExceptionConstructorTools.php#L21-L28 |
7,844 | fratily/http-message | src/Message.php | Message.getNormalizedHeaderKey | protected static function getNormalizedHeaderKey(string $name){
static $convertCache = [];
if(!isset($convertCache[$name])){
$convertCache[$name] = ucfirst(ucwords($name, "-"));
}
return $convertCache[$name];
} | php | protected static function getNormalizedHeaderKey(string $name){
static $convertCache = [];
if(!isset($convertCache[$name])){
$convertCache[$name] = ucfirst(ucwords($name, "-"));
}
return $convertCache[$name];
} | [
"protected",
"static",
"function",
"getNormalizedHeaderKey",
"(",
"string",
"$",
"name",
")",
"{",
"static",
"$",
"convertCache",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"convertCache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"convertCache",
"[",
"$",
"name",
"]",
"=",
"ucfirst",
"(",
"ucwords",
"(",
"$",
"name",
",",
"\"-\"",
")",
")",
";",
"}",
"return",
"$",
"convertCache",
"[",
"$",
"name",
"]",
";",
"}"
] | Get normalized header key.
`content-type` to `Content-Type`.
@param string $name
@return string | [
"Get",
"normalized",
"header",
"key",
"."
] | 2005d2f2126527438af8eecdab0eebfec68dd0c1 | https://github.com/fratily/http-message/blob/2005d2f2126527438af8eecdab0eebfec68dd0c1/src/Message.php#L61-L69 |
7,845 | fratily/http-message | src/Message.php | Message.validateHeaderName | protected static function validateHeaderName(string $name){
static $validCache = [];
if(!isset($validCache[$name])){
if(1 !== preg_match(static::REGEX_HEADER_NAME, $name)){
throw new \InvalidArgumentException(
"Invalid Header name given."
);
}
}
$validCache[$name] = true;
} | php | protected static function validateHeaderName(string $name){
static $validCache = [];
if(!isset($validCache[$name])){
if(1 !== preg_match(static::REGEX_HEADER_NAME, $name)){
throw new \InvalidArgumentException(
"Invalid Header name given."
);
}
}
$validCache[$name] = true;
} | [
"protected",
"static",
"function",
"validateHeaderName",
"(",
"string",
"$",
"name",
")",
"{",
"static",
"$",
"validCache",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"validCache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"1",
"!==",
"preg_match",
"(",
"static",
"::",
"REGEX_HEADER_NAME",
",",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid Header name given.\"",
")",
";",
"}",
"}",
"$",
"validCache",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"}"
] | Validate header name.
@param string $name
@return void
@throws \InvalidArgumentException | [
"Validate",
"header",
"name",
"."
] | 2005d2f2126527438af8eecdab0eebfec68dd0c1 | https://github.com/fratily/http-message/blob/2005d2f2126527438af8eecdab0eebfec68dd0c1/src/Message.php#L80-L92 |
7,846 | fratily/http-message | src/Message.php | Message.validateHeaderValue | protected static function validateHeaderValue(array $values){
static $validCache = [];
foreach($values as $index => $value){
if(!is_string($value)){
throw new \InvalidArgumentException(
"Header value must be of the type string array, "
. gettype($value)
. " given at index of {$index}."
);
}
if(!isset($validCache[$value])){
if(1 !== preg_match(static::REGEX_HEADER_VALUE, $value)){
throw new \InvalidArgumentException(
"Invalid Header value given at index of {$index}."
);
}
}
$validCache[$value] = true;
}
} | php | protected static function validateHeaderValue(array $values){
static $validCache = [];
foreach($values as $index => $value){
if(!is_string($value)){
throw new \InvalidArgumentException(
"Header value must be of the type string array, "
. gettype($value)
. " given at index of {$index}."
);
}
if(!isset($validCache[$value])){
if(1 !== preg_match(static::REGEX_HEADER_VALUE, $value)){
throw new \InvalidArgumentException(
"Invalid Header value given at index of {$index}."
);
}
}
$validCache[$value] = true;
}
} | [
"protected",
"static",
"function",
"validateHeaderValue",
"(",
"array",
"$",
"values",
")",
"{",
"static",
"$",
"validCache",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Header value must be of the type string array, \"",
".",
"gettype",
"(",
"$",
"value",
")",
".",
"\" given at index of {$index}.\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"validCache",
"[",
"$",
"value",
"]",
")",
")",
"{",
"if",
"(",
"1",
"!==",
"preg_match",
"(",
"static",
"::",
"REGEX_HEADER_VALUE",
",",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid Header value given at index of {$index}.\"",
")",
";",
"}",
"}",
"$",
"validCache",
"[",
"$",
"value",
"]",
"=",
"true",
";",
"}",
"}"
] | Validate header value.
@param array $values
@return void
@throws \InvalidArgumentException | [
"Validate",
"header",
"value",
"."
] | 2005d2f2126527438af8eecdab0eebfec68dd0c1 | https://github.com/fratily/http-message/blob/2005d2f2126527438af8eecdab0eebfec68dd0c1/src/Message.php#L103-L125 |
7,847 | weew/console | src/Weew/Console/Console.php | Console.addDefaultCommands | protected function addDefaultCommands() {
$this->addCommands([
new GlobalVersionCommand(),
new GlobalFormatCommand(),
new GlobalSilentModeCommand(),
new GlobalNoInteractionCommand(),
new GlobalHelpCommand(),
new GlobalVerbosityCommand(),
new GlobalPassthroughCommand(),
new ListCommand(),
new HelpCommand(),
]);
} | php | protected function addDefaultCommands() {
$this->addCommands([
new GlobalVersionCommand(),
new GlobalFormatCommand(),
new GlobalSilentModeCommand(),
new GlobalNoInteractionCommand(),
new GlobalHelpCommand(),
new GlobalVerbosityCommand(),
new GlobalPassthroughCommand(),
new ListCommand(),
new HelpCommand(),
]);
} | [
"protected",
"function",
"addDefaultCommands",
"(",
")",
"{",
"$",
"this",
"->",
"addCommands",
"(",
"[",
"new",
"GlobalVersionCommand",
"(",
")",
",",
"new",
"GlobalFormatCommand",
"(",
")",
",",
"new",
"GlobalSilentModeCommand",
"(",
")",
",",
"new",
"GlobalNoInteractionCommand",
"(",
")",
",",
"new",
"GlobalHelpCommand",
"(",
")",
",",
"new",
"GlobalVerbosityCommand",
"(",
")",
",",
"new",
"GlobalPassthroughCommand",
"(",
")",
",",
"new",
"ListCommand",
"(",
")",
",",
"new",
"HelpCommand",
"(",
")",
",",
"]",
")",
";",
"}"
] | Register default command handlers. | [
"Register",
"default",
"command",
"handlers",
"."
] | 083703f21fdeff3cfe6036ebd21ab9cb84ca74c7 | https://github.com/weew/console/blob/083703f21fdeff3cfe6036ebd21ab9cb84ca74c7/src/Weew/Console/Console.php#L522-L534 |
7,848 | weew/console | src/Weew/Console/Console.php | Console.addDefaultStyles | protected function addDefaultStyles() {
$this->consoleFormatter->style('error')->parseStyle('clr=white bg=red');
$this->consoleFormatter->style('warning')->parseStyle('clr=black bg=yellow');
$this->consoleFormatter->style('success')->parseStyle('clr=black bg=green');
$this->consoleFormatter->style('question')->parseStyle('clr=green');
$this->consoleFormatter->style('header')->parseStyle('clr=yellow');
$this->consoleFormatter->style('title')->parseStyle('clr=yellow');
$this->consoleFormatter->style('keyword')->parseStyle('clr=green');
$this->consoleFormatter->style('green')->parseStyle('clr=green');
$this->consoleFormatter->style('yellow')->parseStyle('clr=yellow');
$this->consoleFormatter->style('red')->parseStyle('clr=red');
$this->consoleFormatter->style('white')->parseStyle('clr=white');
$this->consoleFormatter->style('blue')->parseStyle('clr=blue');
$this->consoleFormatter->style('gray')->parseStyle('clr=gray');
$this->consoleFormatter->style('black')->parseStyle('clr=black');
$this->consoleFormatter->style('bold')->parseStyle('fmt=bold');
$this->consoleFormatter->style('italic')->parseStyle('fmt=italic');
$this->consoleFormatter->style('underline')->parseStyle('fmt=underline');
$this->consoleFormatter->style('strikethrough')->parseStyle('fmt=strikethrough');
} | php | protected function addDefaultStyles() {
$this->consoleFormatter->style('error')->parseStyle('clr=white bg=red');
$this->consoleFormatter->style('warning')->parseStyle('clr=black bg=yellow');
$this->consoleFormatter->style('success')->parseStyle('clr=black bg=green');
$this->consoleFormatter->style('question')->parseStyle('clr=green');
$this->consoleFormatter->style('header')->parseStyle('clr=yellow');
$this->consoleFormatter->style('title')->parseStyle('clr=yellow');
$this->consoleFormatter->style('keyword')->parseStyle('clr=green');
$this->consoleFormatter->style('green')->parseStyle('clr=green');
$this->consoleFormatter->style('yellow')->parseStyle('clr=yellow');
$this->consoleFormatter->style('red')->parseStyle('clr=red');
$this->consoleFormatter->style('white')->parseStyle('clr=white');
$this->consoleFormatter->style('blue')->parseStyle('clr=blue');
$this->consoleFormatter->style('gray')->parseStyle('clr=gray');
$this->consoleFormatter->style('black')->parseStyle('clr=black');
$this->consoleFormatter->style('bold')->parseStyle('fmt=bold');
$this->consoleFormatter->style('italic')->parseStyle('fmt=italic');
$this->consoleFormatter->style('underline')->parseStyle('fmt=underline');
$this->consoleFormatter->style('strikethrough')->parseStyle('fmt=strikethrough');
} | [
"protected",
"function",
"addDefaultStyles",
"(",
")",
"{",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'error'",
")",
"->",
"parseStyle",
"(",
"'clr=white bg=red'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'warning'",
")",
"->",
"parseStyle",
"(",
"'clr=black bg=yellow'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'success'",
")",
"->",
"parseStyle",
"(",
"'clr=black bg=green'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'question'",
")",
"->",
"parseStyle",
"(",
"'clr=green'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'header'",
")",
"->",
"parseStyle",
"(",
"'clr=yellow'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'title'",
")",
"->",
"parseStyle",
"(",
"'clr=yellow'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'keyword'",
")",
"->",
"parseStyle",
"(",
"'clr=green'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'green'",
")",
"->",
"parseStyle",
"(",
"'clr=green'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'yellow'",
")",
"->",
"parseStyle",
"(",
"'clr=yellow'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'red'",
")",
"->",
"parseStyle",
"(",
"'clr=red'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'white'",
")",
"->",
"parseStyle",
"(",
"'clr=white'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'blue'",
")",
"->",
"parseStyle",
"(",
"'clr=blue'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'gray'",
")",
"->",
"parseStyle",
"(",
"'clr=gray'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'black'",
")",
"->",
"parseStyle",
"(",
"'clr=black'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'bold'",
")",
"->",
"parseStyle",
"(",
"'fmt=bold'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'italic'",
")",
"->",
"parseStyle",
"(",
"'fmt=italic'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'underline'",
")",
"->",
"parseStyle",
"(",
"'fmt=underline'",
")",
";",
"$",
"this",
"->",
"consoleFormatter",
"->",
"style",
"(",
"'strikethrough'",
")",
"->",
"parseStyle",
"(",
"'fmt=strikethrough'",
")",
";",
"}"
] | Register default formatter styles. | [
"Register",
"default",
"formatter",
"styles",
"."
] | 083703f21fdeff3cfe6036ebd21ab9cb84ca74c7 | https://github.com/weew/console/blob/083703f21fdeff3cfe6036ebd21ab9cb84ca74c7/src/Weew/Console/Console.php#L539-L561 |
7,849 | FuturaSoft/Pabana | src/Mvc/Controller.php | Controller.render | final public function render($action)
{
// Initialize view object if auto render is enable
if (Configuration::read('mvc.view.auto_render') === true) {
$this->setView($this->controller, $action);
}
// Initialize layout object if auto render is enable
if (Configuration::read('mvc.layout.auto_render') === true) {
// Get Layout default name from Configuration
$layoutName = Configuration::read('mvc.layout.default');
$this->setLayout($layoutName);
}
// Call initialize method in Controller if exists
if (method_exists($this, 'initialize')) {
$this->initialize();
}
// Launch action of controller
ob_start();
$actionResult = $this->$action();
echo PHP_EOL;
$bodyContent = ob_get_clean();
// If Controller's Action return false, disable Layout and View
if ($actionResult !== false) {
if (isset($this->layout) && $this->layout->getAutoRender()) {
// Get Layout and View if auto render of View enable
$bodyContent .= $this->layout->render();
} elseif (isset($this->view) && $this->view->getAutoRender()) {
// Get View only
$bodyContent .= $this->view->render();
}
}
return $bodyContent;
} | php | final public function render($action)
{
// Initialize view object if auto render is enable
if (Configuration::read('mvc.view.auto_render') === true) {
$this->setView($this->controller, $action);
}
// Initialize layout object if auto render is enable
if (Configuration::read('mvc.layout.auto_render') === true) {
// Get Layout default name from Configuration
$layoutName = Configuration::read('mvc.layout.default');
$this->setLayout($layoutName);
}
// Call initialize method in Controller if exists
if (method_exists($this, 'initialize')) {
$this->initialize();
}
// Launch action of controller
ob_start();
$actionResult = $this->$action();
echo PHP_EOL;
$bodyContent = ob_get_clean();
// If Controller's Action return false, disable Layout and View
if ($actionResult !== false) {
if (isset($this->layout) && $this->layout->getAutoRender()) {
// Get Layout and View if auto render of View enable
$bodyContent .= $this->layout->render();
} elseif (isset($this->view) && $this->view->getAutoRender()) {
// Get View only
$bodyContent .= $this->view->render();
}
}
return $bodyContent;
} | [
"final",
"public",
"function",
"render",
"(",
"$",
"action",
")",
"{",
"// Initialize view object if auto render is enable",
"if",
"(",
"Configuration",
"::",
"read",
"(",
"'mvc.view.auto_render'",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setView",
"(",
"$",
"this",
"->",
"controller",
",",
"$",
"action",
")",
";",
"}",
"// Initialize layout object if auto render is enable",
"if",
"(",
"Configuration",
"::",
"read",
"(",
"'mvc.layout.auto_render'",
")",
"===",
"true",
")",
"{",
"// Get Layout default name from Configuration",
"$",
"layoutName",
"=",
"Configuration",
"::",
"read",
"(",
"'mvc.layout.default'",
")",
";",
"$",
"this",
"->",
"setLayout",
"(",
"$",
"layoutName",
")",
";",
"}",
"// Call initialize method in Controller if exists",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'initialize'",
")",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"}",
"// Launch action of controller",
"ob_start",
"(",
")",
";",
"$",
"actionResult",
"=",
"$",
"this",
"->",
"$",
"action",
"(",
")",
";",
"echo",
"PHP_EOL",
";",
"$",
"bodyContent",
"=",
"ob_get_clean",
"(",
")",
";",
"// If Controller's Action return false, disable Layout and View",
"if",
"(",
"$",
"actionResult",
"!==",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"layout",
")",
"&&",
"$",
"this",
"->",
"layout",
"->",
"getAutoRender",
"(",
")",
")",
"{",
"// Get Layout and View if auto render of View enable",
"$",
"bodyContent",
".=",
"$",
"this",
"->",
"layout",
"->",
"render",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"view",
")",
"&&",
"$",
"this",
"->",
"view",
"->",
"getAutoRender",
"(",
")",
")",
"{",
"// Get View only",
"$",
"bodyContent",
".=",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
")",
";",
"}",
"}",
"return",
"$",
"bodyContent",
";",
"}"
] | Create the View and the Layout
Call initialize method if exist
Launch controller
Get Layout and View render if enable
@since 1.1
@param string $action Name of Action
@return string bodyContent of Controller, Layout and View | [
"Create",
"the",
"View",
"and",
"the",
"Layout",
"Call",
"initialize",
"method",
"if",
"exist",
"Launch",
"controller",
"Get",
"Layout",
"and",
"View",
"render",
"if",
"enable"
] | b3a95eeb976042ac2a393cc10755a7adbc164c24 | https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Mvc/Controller.php#L136-L168 |
7,850 | vip9008/yii2-googleapisclient | Client.php | Client.getClassConfig | public function getClassConfig($class, $key = null)
{
if (!is_string($class)) {
$class = get_class($class);
$class = substr($class, strrpos($class, '\\')+1);
}
return $this->config->getClassConfig($class, $key);
} | php | public function getClassConfig($class, $key = null)
{
if (!is_string($class)) {
$class = get_class($class);
$class = substr($class, strrpos($class, '\\')+1);
}
return $this->config->getClassConfig($class, $key);
} | [
"public",
"function",
"getClassConfig",
"(",
"$",
"class",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"$",
"class",
"=",
"substr",
"(",
"$",
"class",
",",
"strrpos",
"(",
"$",
"class",
",",
"'\\\\'",
")",
"+",
"1",
")",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"->",
"getClassConfig",
"(",
"$",
"class",
",",
"$",
"key",
")",
";",
"}"
] | Retrieve custom configuration for a specific class.
@param $class string|object - class or instance of class to retrieve
@param $key string optional - key to retrieve
@return array | [
"Retrieve",
"custom",
"configuration",
"for",
"a",
"specific",
"class",
"."
] | b6aae1c490d84a6004ed7dccb5d4176184032b57 | https://github.com/vip9008/yii2-googleapisclient/blob/b6aae1c490d84a6004ed7dccb5d4176184032b57/Client.php#L666-L673 |
7,851 | stubbles/stubbles-sequence | src/main/php/iterator/Limit.php | Limit.description | public function description(): string
{
if (0 === $this->offset) {
return 'limited to ' . $this->count . ' elements';
}
if (-1 === $this->count) {
return 'skipped until offset ' . $this->offset;
}
return 'limited to ' . $this->count
. ' elements starting from offset ' . $this->offset;
} | php | public function description(): string
{
if (0 === $this->offset) {
return 'limited to ' . $this->count . ' elements';
}
if (-1 === $this->count) {
return 'skipped until offset ' . $this->offset;
}
return 'limited to ' . $this->count
. ' elements starting from offset ' . $this->offset;
} | [
"public",
"function",
"description",
"(",
")",
":",
"string",
"{",
"if",
"(",
"0",
"===",
"$",
"this",
"->",
"offset",
")",
"{",
"return",
"'limited to '",
".",
"$",
"this",
"->",
"count",
".",
"' elements'",
";",
"}",
"if",
"(",
"-",
"1",
"===",
"$",
"this",
"->",
"count",
")",
"{",
"return",
"'skipped until offset '",
".",
"$",
"this",
"->",
"offset",
";",
"}",
"return",
"'limited to '",
".",
"$",
"this",
"->",
"count",
".",
"' elements starting from offset '",
".",
"$",
"this",
"->",
"offset",
";",
"}"
] | returns description of this iterator
@return string
@since 8.0.0 | [
"returns",
"description",
"of",
"this",
"iterator"
] | 258d2247f1cdd826818348fe15829d5a98a9de70 | https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/iterator/Limit.php#L36-L48 |
7,852 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/Session.php | Session.set | public static function set($key, $data, $type = 'ses')
{
$GLOBALS['TSFE']->fe_user->setKey(self::isType($type), $key, serialize($data));
$GLOBALS['TSFE']->fe_user->storeSessionData();
} | php | public static function set($key, $data, $type = 'ses')
{
$GLOBALS['TSFE']->fe_user->setKey(self::isType($type), $key, serialize($data));
$GLOBALS['TSFE']->fe_user->storeSessionData();
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"type",
"=",
"'ses'",
")",
"{",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"setKey",
"(",
"self",
"::",
"isType",
"(",
"$",
"type",
")",
",",
"$",
"key",
",",
"serialize",
"(",
"$",
"data",
")",
")",
";",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"storeSessionData",
"(",
")",
";",
"}"
] | Write data into fe_user session
@param string $key
@param mixed $data
@param string $type - possible values: ses|user | [
"Write",
"data",
"into",
"fe_user",
"session"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/Session.php#L21-L25 |
7,853 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/Session.php | Session.get | public static function get($key, $type = 'ses')
{
$sessionData = $GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key);
return unserialize($sessionData);
} | php | public static function get($key, $type = 'ses')
{
$sessionData = $GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key);
return unserialize($sessionData);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"type",
"=",
"'ses'",
")",
"{",
"$",
"sessionData",
"=",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"getKey",
"(",
"self",
"::",
"isType",
"(",
"$",
"type",
")",
",",
"$",
"key",
")",
";",
"return",
"unserialize",
"(",
"$",
"sessionData",
")",
";",
"}"
] | Restore data from fe_user session
@param string $key
@param string $type - possible values: ses|user
@return mixed | [
"Restore",
"data",
"from",
"fe_user",
"session"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/Session.php#L34-L39 |
7,854 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/Session.php | Session.has | public static function has($key, $type = 'ses')
{
return ($GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key)) ? true : false;
} | php | public static function has($key, $type = 'ses')
{
return ($GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key)) ? true : false;
} | [
"public",
"static",
"function",
"has",
"(",
"$",
"key",
",",
"$",
"type",
"=",
"'ses'",
")",
"{",
"return",
"(",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"getKey",
"(",
"self",
"::",
"isType",
"(",
"$",
"type",
")",
",",
"$",
"key",
")",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Checks whether a key in fe_user session exists
@param string $key
@param string $type - possible values: ses|user
@return boolean | [
"Checks",
"whether",
"a",
"key",
"in",
"fe_user",
"session",
"exists"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/Session.php#L48-L51 |
7,855 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/Session.php | Session.remove | public static function remove($key, $type = 'ses')
{
$GLOBALS['TSFE']->fe_user->setKey(self::isType($type), $key, null);
$GLOBALS['TSFE']->fe_user->storeSessionData();
} | php | public static function remove($key, $type = 'ses')
{
$GLOBALS['TSFE']->fe_user->setKey(self::isType($type), $key, null);
$GLOBALS['TSFE']->fe_user->storeSessionData();
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"key",
",",
"$",
"type",
"=",
"'ses'",
")",
"{",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"setKey",
"(",
"self",
"::",
"isType",
"(",
"$",
"type",
")",
",",
"$",
"key",
",",
"null",
")",
";",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"fe_user",
"->",
"storeSessionData",
"(",
")",
";",
"}"
] | Removes fe_user session data by key
@param string $key
@param string $type - possible values: ses|user | [
"Removes",
"fe_user",
"session",
"data",
"by",
"key"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/Session.php#L59-L63 |
7,856 | meliorframework/melior | Classes/Router/Router.php | Router.resolve | public function resolve(): array
{
$path = $this->request->query->get('path');
$method = $this->request->getMethod();
$result = $this->match("/$path", $method);
if (empty($result)) {
$fallback = $this->settings->get('Melior.Routing.fallbackRoute');
$result = [
'target' => $this->settings->get("Melior.Routing.routes.$fallback.target"),
'params' => [],
'name' => $fallback
];
}
return $result;
} | php | public function resolve(): array
{
$path = $this->request->query->get('path');
$method = $this->request->getMethod();
$result = $this->match("/$path", $method);
if (empty($result)) {
$fallback = $this->settings->get('Melior.Routing.fallbackRoute');
$result = [
'target' => $this->settings->get("Melior.Routing.routes.$fallback.target"),
'params' => [],
'name' => $fallback
];
}
return $result;
} | [
"public",
"function",
"resolve",
"(",
")",
":",
"array",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"request",
"->",
"query",
"->",
"get",
"(",
"'path'",
")",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"request",
"->",
"getMethod",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"match",
"(",
"\"/$path\"",
",",
"$",
"method",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"fallback",
"=",
"$",
"this",
"->",
"settings",
"->",
"get",
"(",
"'Melior.Routing.fallbackRoute'",
")",
";",
"$",
"result",
"=",
"[",
"'target'",
"=>",
"$",
"this",
"->",
"settings",
"->",
"get",
"(",
"\"Melior.Routing.routes.$fallback.target\"",
")",
",",
"'params'",
"=>",
"[",
"]",
",",
"'name'",
"=>",
"$",
"fallback",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Resolves the current route and returns it's configuration.
@return array | [
"Resolves",
"the",
"current",
"route",
"and",
"returns",
"it",
"s",
"configuration",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Router/Router.php#L86-L104 |
7,857 | atelierspierrot/webservices | src/WebServices/FrontController.php | FrontController.create | public static function create(Request $request = null, Response $response = null, array $user_options = array())
{
return self::getInstance($request, $response, $user_options);
} | php | public static function create(Request $request = null, Response $response = null, array $user_options = array())
{
return self::getInstance($request, $response, $user_options);
} | [
"public",
"static",
"function",
"create",
"(",
"Request",
"$",
"request",
"=",
"null",
",",
"Response",
"$",
"response",
"=",
"null",
",",
"array",
"$",
"user_options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"self",
"::",
"getInstance",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"user_options",
")",
";",
"}"
] | Creation of a singleton instance
@param object $request \Library\HttpFundamental\Request
@param object $response \Library\HttpFundamental\Response
@param array $user_options
@return self | [
"Creation",
"of",
"a",
"singleton",
"instance"
] | 7839c4762587fd815f2b2bd99f687897ebb82ea0 | https://github.com/atelierspierrot/webservices/blob/7839c4762587fd815f2b2bd99f687897ebb82ea0/src/WebServices/FrontController.php#L207-L210 |
7,858 | atelierspierrot/webservices | src/WebServices/FrontController.php | FrontController.log | public static function log($message, array $context = array(), $level = Logger::INFO, $logname = null)
{
$_this = self::getInstance();
if ($_this->getOption('enable_logging')===false) {
return;
}
$default_context = array(
'url' => $_this->getRequest()->getUrl()
);
return self::getInstance()->getLogger()
->log($level, $message, array_merge($default_context, $context), $logname);
} | php | public static function log($message, array $context = array(), $level = Logger::INFO, $logname = null)
{
$_this = self::getInstance();
if ($_this->getOption('enable_logging')===false) {
return;
}
$default_context = array(
'url' => $_this->getRequest()->getUrl()
);
return self::getInstance()->getLogger()
->log($level, $message, array_merge($default_context, $context), $logname);
} | [
"public",
"static",
"function",
"log",
"(",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
",",
"$",
"level",
"=",
"Logger",
"::",
"INFO",
",",
"$",
"logname",
"=",
"null",
")",
"{",
"$",
"_this",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"_this",
"->",
"getOption",
"(",
"'enable_logging'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"default_context",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"_this",
"->",
"getRequest",
"(",
")",
"->",
"getUrl",
"(",
")",
")",
";",
"return",
"self",
"::",
"getInstance",
"(",
")",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array_merge",
"(",
"$",
"default_context",
",",
"$",
"context",
")",
",",
"$",
"logname",
")",
";",
"}"
] | Shrotcut for logging message
@param string $message
@param array $context
@param int $level
@param string $logname
@return bool The result of `\Library\Logger::log()` | [
"Shrotcut",
"for",
"logging",
"message"
] | 7839c4762587fd815f2b2bd99f687897ebb82ea0 | https://github.com/atelierspierrot/webservices/blob/7839c4762587fd815f2b2bd99f687897ebb82ea0/src/WebServices/FrontController.php#L221-L232 |
7,859 | atelierspierrot/webservices | src/WebServices/FrontController.php | FrontController.display | public function display($return = false)
{
if ($this->getStatus()===null) {
$this->setStatus(self::STATUS_OK);
}
if ($this->getMessage()===null) {
$this->setMessage(
array_key_exists($this->getStatus(), self::$default_messages) ?
self::$default_messages[$this->getStatus()] : ''
);
}
if ($this->getResponse()->getStatus()===null) {
$this->getResponse()->setStatus(HttpStatus::OK);
}
$this->getResponse()->setHeaders($this->headers);
if ($return) {
return $this->getResponse();
} else {
$this->getResponse()->send();
}
} | php | public function display($return = false)
{
if ($this->getStatus()===null) {
$this->setStatus(self::STATUS_OK);
}
if ($this->getMessage()===null) {
$this->setMessage(
array_key_exists($this->getStatus(), self::$default_messages) ?
self::$default_messages[$this->getStatus()] : ''
);
}
if ($this->getResponse()->getStatus()===null) {
$this->getResponse()->setStatus(HttpStatus::OK);
}
$this->getResponse()->setHeaders($this->headers);
if ($return) {
return $this->getResponse();
} else {
$this->getResponse()->send();
}
} | [
"public",
"function",
"display",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"self",
"::",
"STATUS_OK",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setMessage",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
",",
"self",
"::",
"$",
"default_messages",
")",
"?",
"self",
"::",
"$",
"default_messages",
"[",
"$",
"this",
"->",
"getStatus",
"(",
")",
"]",
":",
"''",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getStatus",
"(",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatus",
"(",
"HttpStatus",
"::",
"OK",
")",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"send",
"(",
")",
";",
"}",
"}"
] | Displays the request result | [
"Displays",
"the",
"request",
"result"
] | 7839c4762587fd815f2b2bd99f687897ebb82ea0 | https://github.com/atelierspierrot/webservices/blob/7839c4762587fd815f2b2bd99f687897ebb82ea0/src/WebServices/FrontController.php#L265-L285 |
7,860 | webwarejp/OpenppOAuthServerBundle | EventListener/OAuthEventListener.php | OAuthEventListener.onPreAuthorizationProcess | public function onPreAuthorizationProcess(OAuthEvent $event)
{
/* @var $client Client */
if(null !== $client = $event->getClient())
{
if ($client->isPrivate())
{
$event->setAuthorizedClient(true);
}
}
} | php | public function onPreAuthorizationProcess(OAuthEvent $event)
{
/* @var $client Client */
if(null !== $client = $event->getClient())
{
if ($client->isPrivate())
{
$event->setAuthorizedClient(true);
}
}
} | [
"public",
"function",
"onPreAuthorizationProcess",
"(",
"OAuthEvent",
"$",
"event",
")",
"{",
"/* @var $client Client */",
"if",
"(",
"null",
"!==",
"$",
"client",
"=",
"$",
"event",
"->",
"getClient",
"(",
")",
")",
"{",
"if",
"(",
"$",
"client",
"->",
"isPrivate",
"(",
")",
")",
"{",
"$",
"event",
"->",
"setAuthorizedClient",
"(",
"true",
")",
";",
"}",
"}",
"}"
] | called fos_oauth_server.pre_authorization_process
client が isPrivate trueのとき認可する。
@param OAuthEvent $event | [
"called",
"fos_oauth_server",
".",
"pre_authorization_process"
] | 8c0ca026afaf319de0fa12b8492518dcd78e846f | https://github.com/webwarejp/OpenppOAuthServerBundle/blob/8c0ca026afaf319de0fa12b8492518dcd78e846f/EventListener/OAuthEventListener.php#L35-L45 |
7,861 | lukaszmakuch/math | src/Math.php | Math.gcd | public static function gcd($a, $b)
{
$ta = abs($a);
$tb = abs($b);
while ($tb != 0) {
$tmp = $tb;
$tb = $ta % $tb;
$ta = $tmp;
}
return $ta;
} | php | public static function gcd($a, $b)
{
$ta = abs($a);
$tb = abs($b);
while ($tb != 0) {
$tmp = $tb;
$tb = $ta % $tb;
$ta = $tmp;
}
return $ta;
} | [
"public",
"static",
"function",
"gcd",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"ta",
"=",
"abs",
"(",
"$",
"a",
")",
";",
"$",
"tb",
"=",
"abs",
"(",
"$",
"b",
")",
";",
"while",
"(",
"$",
"tb",
"!=",
"0",
")",
"{",
"$",
"tmp",
"=",
"$",
"tb",
";",
"$",
"tb",
"=",
"$",
"ta",
"%",
"$",
"tb",
";",
"$",
"ta",
"=",
"$",
"tmp",
";",
"}",
"return",
"$",
"ta",
";",
"}"
] | Computes the greatest common divisor.
Uses the Euclidean algorithm.
@param int $a
@param int $b
@return int the greatest common divisor | [
"Computes",
"the",
"greatest",
"common",
"divisor",
"."
] | 0b519820df9c5036bb6cbdffaf21921e6fe504b3 | https://github.com/lukaszmakuch/math/blob/0b519820df9c5036bb6cbdffaf21921e6fe504b3/src/Math.php#L29-L40 |
7,862 | lukaszmakuch/math | src/Math.php | Math.lcm | public static function lcm($a, $b)
{
return (abs($a * $b) / self::gcd($a, $b));
} | php | public static function lcm($a, $b)
{
return (abs($a * $b) / self::gcd($a, $b));
} | [
"public",
"static",
"function",
"lcm",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"(",
"abs",
"(",
"$",
"a",
"*",
"$",
"b",
")",
"/",
"self",
"::",
"gcd",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
";",
"}"
] | Computes the least common multiple.
It uses reduction by the greatest common divisor.
@param int $a
@param int $b
@return int the least common multiple | [
"Computes",
"the",
"least",
"common",
"multiple",
"."
] | 0b519820df9c5036bb6cbdffaf21921e6fe504b3 | https://github.com/lukaszmakuch/math/blob/0b519820df9c5036bb6cbdffaf21921e6fe504b3/src/Math.php#L52-L55 |
7,863 | WasabiLib/wasabilib | src/WasabiLib/Wizard/StepCollection.php | StepCollection.isPenultimate | public function isPenultimate($identifier) {
$this->getLast();
$iterator = $this->getIterator();
$iterator->seek($iterator->count() - 2);
$penultimate = $iterator->current();
if ($identifier instanceof StepController) {
$identifierName = $identifier->getName();
if ($identifierName == $penultimate->getName())
return true;
else return false;
}
return false;
} | php | public function isPenultimate($identifier) {
$this->getLast();
$iterator = $this->getIterator();
$iterator->seek($iterator->count() - 2);
$penultimate = $iterator->current();
if ($identifier instanceof StepController) {
$identifierName = $identifier->getName();
if ($identifierName == $penultimate->getName())
return true;
else return false;
}
return false;
} | [
"public",
"function",
"isPenultimate",
"(",
"$",
"identifier",
")",
"{",
"$",
"this",
"->",
"getLast",
"(",
")",
";",
"$",
"iterator",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
";",
"$",
"iterator",
"->",
"seek",
"(",
"$",
"iterator",
"->",
"count",
"(",
")",
"-",
"2",
")",
";",
"$",
"penultimate",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"identifier",
"instanceof",
"StepController",
")",
"{",
"$",
"identifierName",
"=",
"$",
"identifier",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"identifierName",
"==",
"$",
"penultimate",
"->",
"getName",
"(",
")",
")",
"return",
"true",
";",
"else",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] | return true if IdentifierStep is the penultimate Step
@param $identifier
@return bool | [
"return",
"true",
"if",
"IdentifierStep",
"is",
"the",
"penultimate",
"Step"
] | 5a55bfbea6b6ee10222c521112d469015db170b7 | https://github.com/WasabiLib/wasabilib/blob/5a55bfbea6b6ee10222c521112d469015db170b7/src/WasabiLib/Wizard/StepCollection.php#L160-L172 |
7,864 | GovTribe/laravel-kinvey | src/GovTribe/LaravelKinvey/Client/Plugins/KinveyInjectEntityIdPlugin.php | KinveyInjectEntityIdPlugin.beforePrepare | public function beforePrepare(Event $event)
{
$command = $event['command'];
$operation = $command->getOperation();
if ($command->getName() !== 'updateEntity' && $command->offsetExists('_id') === true) return;
$operation->addParam(new Parameter(array(
'name' => 'body_id',
'location' => 'json',
'type' => 'string',
'default' => $command->offsetGet('_id'),
'static' => true,
'sentAs' => '_id'
)));
} | php | public function beforePrepare(Event $event)
{
$command = $event['command'];
$operation = $command->getOperation();
if ($command->getName() !== 'updateEntity' && $command->offsetExists('_id') === true) return;
$operation->addParam(new Parameter(array(
'name' => 'body_id',
'location' => 'json',
'type' => 'string',
'default' => $command->offsetGet('_id'),
'static' => true,
'sentAs' => '_id'
)));
} | [
"public",
"function",
"beforePrepare",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"command",
"=",
"$",
"event",
"[",
"'command'",
"]",
";",
"$",
"operation",
"=",
"$",
"command",
"->",
"getOperation",
"(",
")",
";",
"if",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
"!==",
"'updateEntity'",
"&&",
"$",
"command",
"->",
"offsetExists",
"(",
"'_id'",
")",
"===",
"true",
")",
"return",
";",
"$",
"operation",
"->",
"addParam",
"(",
"new",
"Parameter",
"(",
"array",
"(",
"'name'",
"=>",
"'body_id'",
",",
"'location'",
"=>",
"'json'",
",",
"'type'",
"=>",
"'string'",
",",
"'default'",
"=>",
"$",
"command",
"->",
"offsetGet",
"(",
"'_id'",
")",
",",
"'static'",
"=>",
"true",
",",
"'sentAs'",
"=>",
"'_id'",
")",
")",
")",
";",
"}"
] | Add the entity's _id to the request body.
@param Guzzle\Common\Event
@return void | [
"Add",
"the",
"entity",
"s",
"_id",
"to",
"the",
"request",
"body",
"."
] | 8a25dafdf80a933384dfcfe8b70b0a7663fe9289 | https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Client/Plugins/KinveyInjectEntityIdPlugin.php#L25-L40 |
7,865 | imsamurai/cakephp-arraysort-utility | Utility/ArraySort.php | ArraySort.multisort | public static function multisort($array, $params) {
static::$_cache = array();
$isNumeric = is_numeric(implode('', array_keys($array)));
if (is_array($params)) {
static::_normalizeParams($params);
$callback = function($a, $b) use($params) {
$result = 0;
foreach ($params as $param) {
$valA = static::_getValue($param['field'], $a);
$valB = static::_getValue($param['field'], $b);
if ($valA > $valB) {
$result = 1;
} elseif ($valA < $valB) {
$result = -1;
}
if ($result !== 0) {
if (strtolower($param['direction']) === 'desc') {
$result *= -1;
}
break;
}
}
return $result;
};
if ($isNumeric) {
usort($array, $callback);
} else {
uasort($array, $callback);
}
} elseif (is_string($params)) {
if ($isNumeric) {
(strtolower($params) === 'desc') ? rsort($array) : sort($array);
} else {
(strtolower($params) === 'desc') ? arsort($array) : asort($array);
}
}
return $array;
} | php | public static function multisort($array, $params) {
static::$_cache = array();
$isNumeric = is_numeric(implode('', array_keys($array)));
if (is_array($params)) {
static::_normalizeParams($params);
$callback = function($a, $b) use($params) {
$result = 0;
foreach ($params as $param) {
$valA = static::_getValue($param['field'], $a);
$valB = static::_getValue($param['field'], $b);
if ($valA > $valB) {
$result = 1;
} elseif ($valA < $valB) {
$result = -1;
}
if ($result !== 0) {
if (strtolower($param['direction']) === 'desc') {
$result *= -1;
}
break;
}
}
return $result;
};
if ($isNumeric) {
usort($array, $callback);
} else {
uasort($array, $callback);
}
} elseif (is_string($params)) {
if ($isNumeric) {
(strtolower($params) === 'desc') ? rsort($array) : sort($array);
} else {
(strtolower($params) === 'desc') ? arsort($array) : asort($array);
}
}
return $array;
} | [
"public",
"static",
"function",
"multisort",
"(",
"$",
"array",
",",
"$",
"params",
")",
"{",
"static",
"::",
"$",
"_cache",
"=",
"array",
"(",
")",
";",
"$",
"isNumeric",
"=",
"is_numeric",
"(",
"implode",
"(",
"''",
",",
"array_keys",
"(",
"$",
"array",
")",
")",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"static",
"::",
"_normalizeParams",
"(",
"$",
"params",
")",
";",
"$",
"callback",
"=",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"params",
")",
"{",
"$",
"result",
"=",
"0",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"valA",
"=",
"static",
"::",
"_getValue",
"(",
"$",
"param",
"[",
"'field'",
"]",
",",
"$",
"a",
")",
";",
"$",
"valB",
"=",
"static",
"::",
"_getValue",
"(",
"$",
"param",
"[",
"'field'",
"]",
",",
"$",
"b",
")",
";",
"if",
"(",
"$",
"valA",
">",
"$",
"valB",
")",
"{",
"$",
"result",
"=",
"1",
";",
"}",
"elseif",
"(",
"$",
"valA",
"<",
"$",
"valB",
")",
"{",
"$",
"result",
"=",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"result",
"!==",
"0",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"param",
"[",
"'direction'",
"]",
")",
"===",
"'desc'",
")",
"{",
"$",
"result",
"*=",
"-",
"1",
";",
"}",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}",
";",
"if",
"(",
"$",
"isNumeric",
")",
"{",
"usort",
"(",
"$",
"array",
",",
"$",
"callback",
")",
";",
"}",
"else",
"{",
"uasort",
"(",
"$",
"array",
",",
"$",
"callback",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"$",
"isNumeric",
")",
"{",
"(",
"strtolower",
"(",
"$",
"params",
")",
"===",
"'desc'",
")",
"?",
"rsort",
"(",
"$",
"array",
")",
":",
"sort",
"(",
"$",
"array",
")",
";",
"}",
"else",
"{",
"(",
"strtolower",
"(",
"$",
"params",
")",
"===",
"'desc'",
")",
"?",
"arsort",
"(",
"$",
"array",
")",
":",
"asort",
"(",
"$",
"array",
")",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] | Sort array by multiple fields
@param array $array Array to sort
@param $params associative array key is field to sort by, value is desc or asc
you can yse Set (Hash) notation for fields | [
"Sort",
"array",
"by",
"multiple",
"fields"
] | 0bb61b2381c0005f2f03d3c0a25e43be96bf2589 | https://github.com/imsamurai/cakephp-arraysort-utility/blob/0bb61b2381c0005f2f03d3c0a25e43be96bf2589/Utility/ArraySort.php#L31-L68 |
7,866 | lasallecrm/lasallecrm-l5-listmanagement-pkg | src/Repositories/List_EmailRepository.php | List_EmailRepository.enabledFalse | public function enabledFalse($emailID, $listID) {
$this->model->where('list_id', $listID)
->where('email_id', $emailID)
->update(['enabled' => false])
;
} | php | public function enabledFalse($emailID, $listID) {
$this->model->where('list_id', $listID)
->where('email_id', $emailID)
->update(['enabled' => false])
;
} | [
"public",
"function",
"enabledFalse",
"(",
"$",
"emailID",
",",
"$",
"listID",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"'list_id'",
",",
"$",
"listID",
")",
"->",
"where",
"(",
"'email_id'",
",",
"$",
"emailID",
")",
"->",
"update",
"(",
"[",
"'enabled'",
"=>",
"false",
"]",
")",
";",
"}"
] | UPDATE a list_email record so that "enabled" is false
@param int $emailID
@param int $listID
@return void | [
"UPDATE",
"a",
"list_email",
"record",
"so",
"that",
"enabled",
"is",
"false"
] | 4b5da1af5d25d5fb4be5199f3cf22da313d475f3 | https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Repositories/List_EmailRepository.php#L70-L76 |
7,867 | lasallecrm/lasallecrm-l5-listmanagement-pkg | src/Repositories/List_EmailRepository.php | List_EmailRepository.getList_emailByEmailIdAndListId | public function getList_emailByEmailIdAndListId($emailID, $listID) {
return $this->model
->where('email_id', $emailID)
->where('list_id', $listID)
->first()
;
} | php | public function getList_emailByEmailIdAndListId($emailID, $listID) {
return $this->model
->where('email_id', $emailID)
->where('list_id', $listID)
->first()
;
} | [
"public",
"function",
"getList_emailByEmailIdAndListId",
"(",
"$",
"emailID",
",",
"$",
"listID",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"'email_id'",
",",
"$",
"emailID",
")",
"->",
"where",
"(",
"'list_id'",
",",
"$",
"listID",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Does the email AND list already exist in the "list_email" db table?
@param int $emailID The "emails" db table's ID field
@param int $listID The "lists" db table's ID field
@return bool | [
"Does",
"the",
"email",
"AND",
"list",
"already",
"exist",
"in",
"the",
"list_email",
"db",
"table?"
] | 4b5da1af5d25d5fb4be5199f3cf22da313d475f3 | https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Repositories/List_EmailRepository.php#L92-L98 |
7,868 | lasallecrm/lasallecrm-l5-listmanagement-pkg | src/Repositories/List_EmailRepository.php | List_EmailRepository.createNewRecord | public function createNewRecord($data) {
$list_email = new $this->model;
$list_email->title = $data['list_id']." ".$data['email_id'];
$list_email->list_id = $data['list_id'];
$list_email->email_id = $data['email_id'];
$list_email->comments = $data['comments'];
$list_email->enabled = $data['enabled'];
$list_email->created_at = $data['created_at'];
$list_email->created_by = $data['created_by'];
$list_email->updated_at = $data['updated_at'];
$list_email->updated_by = $data['updated_by'];
$list_email->locked_at = null;
$list_email->locked_by = null;
if ($list_email->save()) {
// Return the new ID
return $list_email->id;
}
return false;
} | php | public function createNewRecord($data) {
$list_email = new $this->model;
$list_email->title = $data['list_id']." ".$data['email_id'];
$list_email->list_id = $data['list_id'];
$list_email->email_id = $data['email_id'];
$list_email->comments = $data['comments'];
$list_email->enabled = $data['enabled'];
$list_email->created_at = $data['created_at'];
$list_email->created_by = $data['created_by'];
$list_email->updated_at = $data['updated_at'];
$list_email->updated_by = $data['updated_by'];
$list_email->locked_at = null;
$list_email->locked_by = null;
if ($list_email->save()) {
// Return the new ID
return $list_email->id;
}
return false;
} | [
"public",
"function",
"createNewRecord",
"(",
"$",
"data",
")",
"{",
"$",
"list_email",
"=",
"new",
"$",
"this",
"->",
"model",
";",
"$",
"list_email",
"->",
"title",
"=",
"$",
"data",
"[",
"'list_id'",
"]",
".",
"\" \"",
".",
"$",
"data",
"[",
"'email_id'",
"]",
";",
"$",
"list_email",
"->",
"list_id",
"=",
"$",
"data",
"[",
"'list_id'",
"]",
";",
"$",
"list_email",
"->",
"email_id",
"=",
"$",
"data",
"[",
"'email_id'",
"]",
";",
"$",
"list_email",
"->",
"comments",
"=",
"$",
"data",
"[",
"'comments'",
"]",
";",
"$",
"list_email",
"->",
"enabled",
"=",
"$",
"data",
"[",
"'enabled'",
"]",
";",
"$",
"list_email",
"->",
"created_at",
"=",
"$",
"data",
"[",
"'created_at'",
"]",
";",
"$",
"list_email",
"->",
"created_by",
"=",
"$",
"data",
"[",
"'created_by'",
"]",
";",
"$",
"list_email",
"->",
"updated_at",
"=",
"$",
"data",
"[",
"'updated_at'",
"]",
";",
"$",
"list_email",
"->",
"updated_by",
"=",
"$",
"data",
"[",
"'updated_by'",
"]",
";",
"$",
"list_email",
"->",
"locked_at",
"=",
"null",
";",
"$",
"list_email",
"->",
"locked_by",
"=",
"null",
";",
"if",
"(",
"$",
"list_email",
"->",
"save",
"(",
")",
")",
"{",
"// Return the new ID",
"return",
"$",
"list_email",
"->",
"id",
";",
"}",
"return",
"false",
";",
"}"
] | INSERT INTO 'list_email'
@param array $data The data to be saved, which is already validated, washed, & prepped.
@return mixed The new list_email.id when save is successful, false when save fails | [
"INSERT",
"INTO",
"list_email"
] | 4b5da1af5d25d5fb4be5199f3cf22da313d475f3 | https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Repositories/List_EmailRepository.php#L106-L128 |
7,869 | xinc-develop/xinc-core | src/Plugin/Builder/BaseTask.php | BaseTask.process | final public function process(BuildInterface $build)
{
if (($status = $this->build($build)) === true) {
$build->setStatus(BuildInterface::PASSED);
} elseif ($status == -1) {
$build->setStatus(BuildInterface::STOPPED);
} else {
$build->setStatus(BuildInterface::FAILED);
}
} | php | final public function process(BuildInterface $build)
{
if (($status = $this->build($build)) === true) {
$build->setStatus(BuildInterface::PASSED);
} elseif ($status == -1) {
$build->setStatus(BuildInterface::STOPPED);
} else {
$build->setStatus(BuildInterface::FAILED);
}
} | [
"final",
"public",
"function",
"process",
"(",
"BuildInterface",
"$",
"build",
")",
"{",
"if",
"(",
"(",
"$",
"status",
"=",
"$",
"this",
"->",
"build",
"(",
"$",
"build",
")",
")",
"===",
"true",
")",
"{",
"$",
"build",
"->",
"setStatus",
"(",
"BuildInterface",
"::",
"PASSED",
")",
";",
"}",
"elseif",
"(",
"$",
"status",
"==",
"-",
"1",
")",
"{",
"$",
"build",
"->",
"setStatus",
"(",
"BuildInterface",
"::",
"STOPPED",
")",
";",
"}",
"else",
"{",
"$",
"build",
"->",
"setStatus",
"(",
"BuildInterface",
"::",
"FAILED",
")",
";",
"}",
"}"
] | abstract process for a builder.
@param Xinc_Build_Interface $build | [
"abstract",
"process",
"for",
"a",
"builder",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/Builder/BaseTask.php#L39-L48 |
7,870 | metastore-libraries/lib-kernel | src/Token.php | Token.generator | public static function generator( $length = 32 ) {
$out = Hash::base64( Route::HTTP_HOST() . random_bytes( $length ), 1 );
return $out;
} | php | public static function generator( $length = 32 ) {
$out = Hash::base64( Route::HTTP_HOST() . random_bytes( $length ), 1 );
return $out;
} | [
"public",
"static",
"function",
"generator",
"(",
"$",
"length",
"=",
"32",
")",
"{",
"$",
"out",
"=",
"Hash",
"::",
"base64",
"(",
"Route",
"::",
"HTTP_HOST",
"(",
")",
".",
"random_bytes",
"(",
"$",
"length",
")",
",",
"1",
")",
";",
"return",
"$",
"out",
";",
"}"
] | Random token generator.
@param int $length
@return string
@throws \Exception | [
"Random",
"token",
"generator",
"."
] | 6fec041a3ad66d0761170a6a8c28c6cd85e2642c | https://github.com/metastore-libraries/lib-kernel/blob/6fec041a3ad66d0761170a6a8c28c6cd85e2642c/src/Token.php#L19-L23 |
7,871 | jmpantoja/planb-utils | src/Beautifier/Format/DataObjectFormat.php | DataObjectFormat.hasKeyLikeType | protected function hasKeyLikeType(Data $data): bool
{
return $data->isScalar() || $data->isConvertibleToString() || $data->isHashable();
} | php | protected function hasKeyLikeType(Data $data): bool
{
return $data->isScalar() || $data->isConvertibleToString() || $data->isHashable();
} | [
"protected",
"function",
"hasKeyLikeType",
"(",
"Data",
"$",
"data",
")",
":",
"bool",
"{",
"return",
"$",
"data",
"->",
"isScalar",
"(",
")",
"||",
"$",
"data",
"->",
"isConvertibleToString",
"(",
")",
"||",
"$",
"data",
"->",
"isHashable",
"(",
")",
";",
"}"
] | Indica si se debe usar el nombre de tipo como clave
@param \PlanB\Type\Data\Data $data
@return bool | [
"Indica",
"si",
"se",
"debe",
"usar",
"el",
"nombre",
"de",
"tipo",
"como",
"clave"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Format/DataObjectFormat.php#L66-L69 |
7,872 | encorephp/config | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
$this->container->bind('config', new Repository(
new FileLoader(
new Filesystem,
$this->container->appPath().'/config'
),
new Resolver,
$this->container->os()
));
} | php | public function register()
{
$this->container->bind('config', new Repository(
new FileLoader(
new Filesystem,
$this->container->appPath().'/config'
),
new Resolver,
$this->container->os()
));
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"bind",
"(",
"'config'",
",",
"new",
"Repository",
"(",
"new",
"FileLoader",
"(",
"new",
"Filesystem",
",",
"$",
"this",
"->",
"container",
"->",
"appPath",
"(",
")",
".",
"'/config'",
")",
",",
"new",
"Resolver",
",",
"$",
"this",
"->",
"container",
"->",
"os",
"(",
")",
")",
")",
";",
"}"
] | Register the config loader into the container.
@return void | [
"Register",
"the",
"config",
"loader",
"into",
"the",
"container",
"."
] | aa13e8f21068a1df5c21cec52b203c194d9fba59 | https://github.com/encorephp/config/blob/aa13e8f21068a1df5c21cec52b203c194d9fba59/src/ServiceProvider.php#L16-L26 |
7,873 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockLevelController.php | StockLevelController.newAction | public function newAction()
{
$stocklevel = new StockLevel();
$form = $this->createForm(new StockLevelType(), $stocklevel);
return array(
'stocklevel' => $stocklevel,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$stocklevel = new StockLevel();
$form = $this->createForm(new StockLevelType(), $stocklevel);
return array(
'stocklevel' => $stocklevel,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"stocklevel",
"=",
"new",
"StockLevel",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockLevelType",
"(",
")",
",",
"$",
"stocklevel",
")",
";",
"return",
"array",
"(",
"'stocklevel'",
"=>",
"$",
"stocklevel",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to create a new StockLevel entity.
@Route("/new", name="stock_stocklevel_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"StockLevel",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockLevelController.php#L71-L80 |
7,874 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockLevelController.php | StockLevelController.createAction | public function createAction(Request $request)
{
$stocklevel = new StockLevel();
$form = $this->createForm(new StockLevelType(), $stocklevel);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stocklevel);
$em->flush();
return $this->redirect($this->generateUrl('stock_stocklevel_show', array('id' => $stocklevel->getId())));
}
return array(
'stocklevel' => $stocklevel,
'form' => $form->createView(),
);
} | php | public function createAction(Request $request)
{
$stocklevel = new StockLevel();
$form = $this->createForm(new StockLevelType(), $stocklevel);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stocklevel);
$em->flush();
return $this->redirect($this->generateUrl('stock_stocklevel_show', array('id' => $stocklevel->getId())));
}
return array(
'stocklevel' => $stocklevel,
'form' => $form->createView(),
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"stocklevel",
"=",
"new",
"StockLevel",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockLevelType",
"(",
")",
",",
"$",
"stocklevel",
")",
";",
"if",
"(",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"stocklevel",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_stocklevel_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stocklevel",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'stocklevel'",
"=>",
"$",
"stocklevel",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Creates a new StockLevel entity.
@Route("/create", name="stock_stocklevel_create")
@Method("POST")
@Template("FlowerStockBundle:StockLevel:new.html.twig") | [
"Creates",
"a",
"new",
"StockLevel",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockLevelController.php#L89-L105 |
7,875 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockLevelController.php | StockLevelController.editAction | public function editAction(StockLevel $stocklevel)
{
$editForm = $this->createForm(new StockLevelType(), $stocklevel, array(
'action' => $this->generateUrl('stock_stocklevel_update', array('id' => $stocklevel->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stocklevel->getId(), 'stock_stocklevel_delete');
return array(
'stocklevel' => $stocklevel,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function editAction(StockLevel $stocklevel)
{
$editForm = $this->createForm(new StockLevelType(), $stocklevel, array(
'action' => $this->generateUrl('stock_stocklevel_update', array('id' => $stocklevel->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stocklevel->getId(), 'stock_stocklevel_delete');
return array(
'stocklevel' => $stocklevel,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"editAction",
"(",
"StockLevel",
"$",
"stocklevel",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockLevelType",
"(",
")",
",",
"$",
"stocklevel",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_stocklevel_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stocklevel",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"stocklevel",
"->",
"getId",
"(",
")",
",",
"'stock_stocklevel_delete'",
")",
";",
"return",
"array",
"(",
"'stocklevel'",
"=>",
"$",
"stocklevel",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to edit an existing StockLevel entity.
@Route("/{id}/edit", name="stock_stocklevel_edit", requirements={"id"="\d+"})
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"StockLevel",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockLevelController.php#L114-L127 |
7,876 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockLevelController.php | StockLevelController.updateAction | public function updateAction(StockLevel $stocklevel, Request $request)
{
$editForm = $this->createForm(new StockLevelType(), $stocklevel, array(
'action' => $this->generateUrl('stock_stocklevel_update', array('id' => $stocklevel->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_stocklevel_show', array('id' => $stocklevel->getId())));
}
$deleteForm = $this->createDeleteForm($stocklevel->getId(), 'stock_stocklevel_delete');
return array(
'stocklevel' => $stocklevel,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function updateAction(StockLevel $stocklevel, Request $request)
{
$editForm = $this->createForm(new StockLevelType(), $stocklevel, array(
'action' => $this->generateUrl('stock_stocklevel_update', array('id' => $stocklevel->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_stocklevel_show', array('id' => $stocklevel->getId())));
}
$deleteForm = $this->createDeleteForm($stocklevel->getId(), 'stock_stocklevel_delete');
return array(
'stocklevel' => $stocklevel,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"StockLevel",
"$",
"stocklevel",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockLevelType",
"(",
")",
",",
"$",
"stocklevel",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_stocklevel_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stocklevel",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_stocklevel_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stocklevel",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"stocklevel",
"->",
"getId",
"(",
")",
",",
"'stock_stocklevel_delete'",
")",
";",
"return",
"array",
"(",
"'stocklevel'",
"=>",
"$",
"stocklevel",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Edits an existing StockLevel entity.
@Route("/{id}/update", name="stock_stocklevel_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:StockLevel:edit.html.twig") | [
"Edits",
"an",
"existing",
"StockLevel",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockLevelController.php#L136-L154 |
7,877 | Puzzlout/FrameworkMvcLegacy | src/GeneratorEngine/Core/BaseClassGenerator.php | BaseClassGenerator.CleanAndBuildConstantKeyValue | protected function CleanAndBuildConstantKeyValue($rawValue, $valueToTrim) {
$valueCleaned = $this->RemoveExtensionFileName($rawValue, $valueToTrim);
return $this->BuildConstantKeyValue($valueCleaned);
} | php | protected function CleanAndBuildConstantKeyValue($rawValue, $valueToTrim) {
$valueCleaned = $this->RemoveExtensionFileName($rawValue, $valueToTrim);
return $this->BuildConstantKeyValue($valueCleaned);
} | [
"protected",
"function",
"CleanAndBuildConstantKeyValue",
"(",
"$",
"rawValue",
",",
"$",
"valueToTrim",
")",
"{",
"$",
"valueCleaned",
"=",
"$",
"this",
"->",
"RemoveExtensionFileName",
"(",
"$",
"rawValue",
",",
"$",
"valueToTrim",
")",
";",
"return",
"$",
"this",
"->",
"BuildConstantKeyValue",
"(",
"$",
"valueCleaned",
")",
";",
"}"
] | Cleans a file name from its extension and build the key string value to find
its value in the array of constants.
@param type $rawValue
@param type $valueToTrim
@return type | [
"Cleans",
"a",
"file",
"name",
"from",
"its",
"extension",
"and",
"build",
"the",
"key",
"string",
"value",
"to",
"find",
"its",
"value",
"in",
"the",
"array",
"of",
"constants",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/BaseClassGenerator.php#L48-L51 |
7,878 | Puzzlout/FrameworkMvcLegacy | src/GeneratorEngine/Core/BaseClassGenerator.php | BaseClassGenerator.WriteConstant | public function WriteConstant($value) {
$constantName = strtoupper($value);
$lineOfCode = PhpCodeSnippets::TAB2 .
"const " . $constantName .
" = '" .
$value . "';" .
PhpCodeSnippets::LF;
return $lineOfCode;
} | php | public function WriteConstant($value) {
$constantName = strtoupper($value);
$lineOfCode = PhpCodeSnippets::TAB2 .
"const " . $constantName .
" = '" .
$value . "';" .
PhpCodeSnippets::LF;
return $lineOfCode;
} | [
"public",
"function",
"WriteConstant",
"(",
"$",
"value",
")",
"{",
"$",
"constantName",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"$",
"lineOfCode",
"=",
"PhpCodeSnippets",
"::",
"TAB2",
".",
"\"const \"",
".",
"$",
"constantName",
".",
"\" = '\"",
".",
"$",
"value",
".",
"\"';\"",
".",
"PhpCodeSnippets",
"::",
"LF",
";",
"return",
"$",
"lineOfCode",
";",
"}"
] | Builds a line of code that declare a constant.
@param string $value
@return string a line of code representing a constant declaration | [
"Builds",
"a",
"line",
"of",
"code",
"that",
"declare",
"a",
"constant",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/BaseClassGenerator.php#L166-L174 |
7,879 | vincentchalamon/VinceTypeBundle | Controller/GeolocationController.php | GeolocationController.listAction | public function listAction(Request $request)
{
$objects = $this->get('doctrine.orm.default_entity_manager')->getRepository($request->get('class'))->findAll();
// Fix for FOSRestBundle use
if ($this->container->has('jms_serializer')) {
return new Response($this->get('jms_serializer')->serialize($objects, 'json', SerializationContext::create()->setGroups(array('Default'))));
}
return new JsonResponse($objects);
} | php | public function listAction(Request $request)
{
$objects = $this->get('doctrine.orm.default_entity_manager')->getRepository($request->get('class'))->findAll();
// Fix for FOSRestBundle use
if ($this->container->has('jms_serializer')) {
return new Response($this->get('jms_serializer')->serialize($objects, 'json', SerializationContext::create()->setGroups(array('Default'))));
}
return new JsonResponse($objects);
} | [
"public",
"function",
"listAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"objects",
"=",
"$",
"this",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
"->",
"getRepository",
"(",
"$",
"request",
"->",
"get",
"(",
"'class'",
")",
")",
"->",
"findAll",
"(",
")",
";",
"// Fix for FOSRestBundle use",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"'jms_serializer'",
")",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'jms_serializer'",
")",
"->",
"serialize",
"(",
"$",
"objects",
",",
"'json'",
",",
"SerializationContext",
"::",
"create",
"(",
")",
"->",
"setGroups",
"(",
"array",
"(",
"'Default'",
")",
")",
")",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"objects",
")",
";",
"}"
] | List objects for geolocation
@author Vincent Chalamon <[email protected]>
@param Request $request
@return JsonResponse
@throws \InvalidArgumentException | [
"List",
"objects",
"for",
"geolocation"
] | 358b6169d5594b1ee972c1c25e992695d9a26916 | https://github.com/vincentchalamon/VinceTypeBundle/blob/358b6169d5594b1ee972c1c25e992695d9a26916/Controller/GeolocationController.php#L34-L43 |
7,880 | setrun/setrun-component-user | src/components/Identity.php | Identity.checkUserInfo | private function checkUserInfo() : void
{
foreach ($this->user->getAttributes() as $key => $value) {
$this->{$key} = $value;
}
} | php | private function checkUserInfo() : void
{
foreach ($this->user->getAttributes() as $key => $value) {
$this->{$key} = $value;
}
} | [
"private",
"function",
"checkUserInfo",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"user",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"}"
] | Init user info.
@return void | [
"Init",
"user",
"info",
"."
] | 6aca4c62f099918032b66da1f94d7565694a0735 | https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/components/Identity.php#L110-L115 |
7,881 | metastore-libraries/lib-kernel | src/Parser.php | Parser.json | public static function json( $src, $encode = 0 ) {
$options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
$out = $encode ? json_encode( $src, $options ) : json_decode( $src, true );
return $out;
} | php | public static function json( $src, $encode = 0 ) {
$options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
$out = $encode ? json_encode( $src, $options ) : json_decode( $src, true );
return $out;
} | [
"public",
"static",
"function",
"json",
"(",
"$",
"src",
",",
"$",
"encode",
"=",
"0",
")",
"{",
"$",
"options",
"=",
"JSON_HEX_TAG",
"|",
"JSON_HEX_APOS",
"|",
"JSON_HEX_AMP",
"|",
"JSON_HEX_QUOT",
";",
"$",
"out",
"=",
"$",
"encode",
"?",
"json_encode",
"(",
"$",
"src",
",",
"$",
"options",
")",
":",
"json_decode",
"(",
"$",
"src",
",",
"true",
")",
";",
"return",
"$",
"out",
";",
"}"
] | Decode JSON data.
@param $src
@param int $encode
@return mixed|string | [
"Decode",
"JSON",
"data",
"."
] | 6fec041a3ad66d0761170a6a8c28c6cd85e2642c | https://github.com/metastore-libraries/lib-kernel/blob/6fec041a3ad66d0761170a6a8c28c6cd85e2642c/src/Parser.php#L47-L52 |
7,882 | fabsgc/framework | Core/Form/Validation/Element/Element.php | Element.custom | public function custom($name) {
if ($this->_exist) {
$class = 'Controller\Request\Custom\\' . ucfirst($name);
if (class_exists($class)) {
array_push($this->_constraints, ['type' => self::CUSTOM, 'value' => new $class($this->_field, $this->_label, $this->_data[$this->_field])]);
}
else {
throw new MissingClassException('The custom validation class "' . $class . '" was not found');
}
}
return $this;
} | php | public function custom($name) {
if ($this->_exist) {
$class = 'Controller\Request\Custom\\' . ucfirst($name);
if (class_exists($class)) {
array_push($this->_constraints, ['type' => self::CUSTOM, 'value' => new $class($this->_field, $this->_label, $this->_data[$this->_field])]);
}
else {
throw new MissingClassException('The custom validation class "' . $class . '" was not found');
}
}
return $this;
} | [
"public",
"function",
"custom",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_exist",
")",
"{",
"$",
"class",
"=",
"'Controller\\Request\\Custom\\\\'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"_constraints",
",",
"[",
"'type'",
"=>",
"self",
"::",
"CUSTOM",
",",
"'value'",
"=>",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"_field",
",",
"$",
"this",
"->",
"_label",
",",
"$",
"this",
"->",
"_data",
"[",
"$",
"this",
"->",
"_field",
"]",
")",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MissingClassException",
"(",
"'The custom validation class \"'",
".",
"$",
"class",
".",
"'\" was not found'",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | custom filter made by the user
@access public
@param $name string
@throws MissingClassException
@return \Gcs\Framework\Core\Form\Validation\Element\Element
@since 3.0
@package Gcs\Framework\Core\Form\Validation\Element | [
"custom",
"filter",
"made",
"by",
"the",
"user"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Form/Validation/Element/Element.php#L927-L940 |
7,883 | Sowapps/orpheus-inputcontroller | src/InputController/CLIController/CLIRequest.php | CLIRequest.generateFromEnvironment | public static function generateFromEnvironment() {
global $argc, $argv;
$stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
$data = stream_get_meta_data($stdin);
$input = null;
if( empty($data['seekable']) ) {
$input = trim(stream_get_contents($stdin));
}
/*
$path = '/';
if( $argc > 1 && $argv[1][0] !== '-' ) {
$path = $argv[1];
$parameters = array_slice($argv, 2);
} else {
$parameters = array_slice($argv, 1);
}
*/
$path = $argv[1];
$parameters = array_slice($argv, 2);
$request = new static($path, $parameters, $input);
// $request->setContent($input);
return $request;
} | php | public static function generateFromEnvironment() {
global $argc, $argv;
$stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
$data = stream_get_meta_data($stdin);
$input = null;
if( empty($data['seekable']) ) {
$input = trim(stream_get_contents($stdin));
}
/*
$path = '/';
if( $argc > 1 && $argv[1][0] !== '-' ) {
$path = $argv[1];
$parameters = array_slice($argv, 2);
} else {
$parameters = array_slice($argv, 1);
}
*/
$path = $argv[1];
$parameters = array_slice($argv, 2);
$request = new static($path, $parameters, $input);
// $request->setContent($input);
return $request;
} | [
"public",
"static",
"function",
"generateFromEnvironment",
"(",
")",
"{",
"global",
"$",
"argc",
",",
"$",
"argv",
";",
"$",
"stdin",
"=",
"defined",
"(",
"'STDIN'",
")",
"?",
"STDIN",
":",
"fopen",
"(",
"'php://stdin'",
",",
"'r'",
")",
";",
"$",
"data",
"=",
"stream_get_meta_data",
"(",
"$",
"stdin",
")",
";",
"$",
"input",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'seekable'",
"]",
")",
")",
"{",
"$",
"input",
"=",
"trim",
"(",
"stream_get_contents",
"(",
"$",
"stdin",
")",
")",
";",
"}",
"/*\n\t\t$path = '/';\n\t\tif( $argc > 1 && $argv[1][0] !== '-' ) {\n\t\t\t$path = $argv[1];\n\t\t\t$parameters = array_slice($argv, 2);\n\t\t} else {\n\t\t\t$parameters = array_slice($argv, 1);\n\t\t}\n\t\t*/",
"$",
"path",
"=",
"$",
"argv",
"[",
"1",
"]",
";",
"$",
"parameters",
"=",
"array_slice",
"(",
"$",
"argv",
",",
"2",
")",
";",
"$",
"request",
"=",
"new",
"static",
"(",
"$",
"path",
",",
"$",
"parameters",
",",
"$",
"input",
")",
";",
"// \t\t$request->setContent($input);",
"return",
"$",
"request",
";",
"}"
] | Generate CLIRequest from environment
@return CLIRequest | [
"Generate",
"CLIRequest",
"from",
"environment"
] | 91f848a42ac02ae4009ffb3e9a9b4e8c0731455e | https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/CLIController/CLIRequest.php#L51-L76 |
7,884 | Sowapps/orpheus-inputcontroller | src/InputController/CLIController/CLIRequest.php | CLIRequest.handleCurrentRequest | public static function handleCurrentRequest() {
try {
CLIRoute::initialize();
static::$mainRequest = static::generateFromEnvironment();
$response = static::$mainRequest->process();
} catch( \Exception $e ) {
$response = CLIResponse::generateFromException($e);
}
$response->process();
exit($response->getCode());
} | php | public static function handleCurrentRequest() {
try {
CLIRoute::initialize();
static::$mainRequest = static::generateFromEnvironment();
$response = static::$mainRequest->process();
} catch( \Exception $e ) {
$response = CLIResponse::generateFromException($e);
}
$response->process();
exit($response->getCode());
} | [
"public",
"static",
"function",
"handleCurrentRequest",
"(",
")",
"{",
"try",
"{",
"CLIRoute",
"::",
"initialize",
"(",
")",
";",
"static",
"::",
"$",
"mainRequest",
"=",
"static",
"::",
"generateFromEnvironment",
"(",
")",
";",
"$",
"response",
"=",
"static",
"::",
"$",
"mainRequest",
"->",
"process",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"CLIResponse",
"::",
"generateFromException",
"(",
"$",
"e",
")",
";",
"}",
"$",
"response",
"->",
"process",
"(",
")",
";",
"exit",
"(",
"$",
"response",
"->",
"getCode",
"(",
")",
")",
";",
"}"
] | Handle the current request as a CLIRequest one
This method ends the script | [
"Handle",
"the",
"current",
"request",
"as",
"a",
"CLIRequest",
"one",
"This",
"method",
"ends",
"the",
"script"
] | 91f848a42ac02ae4009ffb3e9a9b4e8c0731455e | https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/CLIController/CLIRequest.php#L82-L92 |
7,885 | zepi/turbo-base | Zepi/Web/UserInterface/src/EventHandler/LoadData.php | LoadData.execute | public function execute(Framework $framework, WebRequest $request, Response $response)
{
// Verify the session
if (!$request->hasSession() || $request->getRouteParam('token') == '') {
$response->redirectTo('/');
return;
}
$token = $request->getRouteParam('token');
// Verify the datatable session data
if (!$this->hasValidSessionData($request, $token)) {
$response->redirectTo('/');
return;
}
$class = $request->getSessionData('dt-class-' . $token);
$time = $request->getSessionData('dt-time-' . $token);
$options = json_decode($request->getSessionData('dt-options-' . $token), true);
if (!is_array($options)) {
$options = array();
}
// Session time expired
if ($time > time() + 600) {
$response->redirectTo('/');
return;
}
$table = new $class($framework, false);
$table->setOptions($options);
$generator = $this->getTableRenderer();
$preparedTable = $generator->prepareTable($request, $table, '');
$data = array('data' => array());
foreach ($preparedTable->getBody()->getRows() as $row) {
$data['data'][] = $row->toArray();
}
$response->setOutput(json_encode($data));
} | php | public function execute(Framework $framework, WebRequest $request, Response $response)
{
// Verify the session
if (!$request->hasSession() || $request->getRouteParam('token') == '') {
$response->redirectTo('/');
return;
}
$token = $request->getRouteParam('token');
// Verify the datatable session data
if (!$this->hasValidSessionData($request, $token)) {
$response->redirectTo('/');
return;
}
$class = $request->getSessionData('dt-class-' . $token);
$time = $request->getSessionData('dt-time-' . $token);
$options = json_decode($request->getSessionData('dt-options-' . $token), true);
if (!is_array($options)) {
$options = array();
}
// Session time expired
if ($time > time() + 600) {
$response->redirectTo('/');
return;
}
$table = new $class($framework, false);
$table->setOptions($options);
$generator = $this->getTableRenderer();
$preparedTable = $generator->prepareTable($request, $table, '');
$data = array('data' => array());
foreach ($preparedTable->getBody()->getRows() as $row) {
$data['data'][] = $row->toArray();
}
$response->setOutput(json_encode($data));
} | [
"public",
"function",
"execute",
"(",
"Framework",
"$",
"framework",
",",
"WebRequest",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// Verify the session",
"if",
"(",
"!",
"$",
"request",
"->",
"hasSession",
"(",
")",
"||",
"$",
"request",
"->",
"getRouteParam",
"(",
"'token'",
")",
"==",
"''",
")",
"{",
"$",
"response",
"->",
"redirectTo",
"(",
"'/'",
")",
";",
"return",
";",
"}",
"$",
"token",
"=",
"$",
"request",
"->",
"getRouteParam",
"(",
"'token'",
")",
";",
"// Verify the datatable session data",
"if",
"(",
"!",
"$",
"this",
"->",
"hasValidSessionData",
"(",
"$",
"request",
",",
"$",
"token",
")",
")",
"{",
"$",
"response",
"->",
"redirectTo",
"(",
"'/'",
")",
";",
"return",
";",
"}",
"$",
"class",
"=",
"$",
"request",
"->",
"getSessionData",
"(",
"'dt-class-'",
".",
"$",
"token",
")",
";",
"$",
"time",
"=",
"$",
"request",
"->",
"getSessionData",
"(",
"'dt-time-'",
".",
"$",
"token",
")",
";",
"$",
"options",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getSessionData",
"(",
"'dt-options-'",
".",
"$",
"token",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"}",
"// Session time expired",
"if",
"(",
"$",
"time",
">",
"time",
"(",
")",
"+",
"600",
")",
"{",
"$",
"response",
"->",
"redirectTo",
"(",
"'/'",
")",
";",
"return",
";",
"}",
"$",
"table",
"=",
"new",
"$",
"class",
"(",
"$",
"framework",
",",
"false",
")",
";",
"$",
"table",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"$",
"generator",
"=",
"$",
"this",
"->",
"getTableRenderer",
"(",
")",
";",
"$",
"preparedTable",
"=",
"$",
"generator",
"->",
"prepareTable",
"(",
"$",
"request",
",",
"$",
"table",
",",
"''",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'data'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"preparedTable",
"->",
"getBody",
"(",
")",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"data",
"[",
"'data'",
"]",
"[",
"]",
"=",
"$",
"row",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"response",
"->",
"setOutput",
"(",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"}"
] | Loads the data from the server
@access public
@param \Zepi\Turbo\Framework $framework
@param \Zepi\Turbo\Request\WebRequest $request
@param \Zepi\Turbo\Response\Response $response | [
"Loads",
"the",
"data",
"from",
"the",
"server"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/EventHandler/LoadData.php#L34-L75 |
7,886 | zepi/turbo-base | Zepi/Web/UserInterface/src/EventHandler/LoadData.php | LoadData.hasValidSessionData | protected function hasValidSessionData(WebRequest $request, $token)
{
return ($request->getSessionData('dt-class-' . $token) !== false && $request->getSessionData('dt-time-' . $token) !== false);
} | php | protected function hasValidSessionData(WebRequest $request, $token)
{
return ($request->getSessionData('dt-class-' . $token) !== false && $request->getSessionData('dt-time-' . $token) !== false);
} | [
"protected",
"function",
"hasValidSessionData",
"(",
"WebRequest",
"$",
"request",
",",
"$",
"token",
")",
"{",
"return",
"(",
"$",
"request",
"->",
"getSessionData",
"(",
"'dt-class-'",
".",
"$",
"token",
")",
"!==",
"false",
"&&",
"$",
"request",
"->",
"getSessionData",
"(",
"'dt-time-'",
".",
"$",
"token",
")",
"!==",
"false",
")",
";",
"}"
] | Returns true if the session data has the needed
token data
@param string $token
@return boolean | [
"Returns",
"true",
"if",
"the",
"session",
"data",
"has",
"the",
"needed",
"token",
"data"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/EventHandler/LoadData.php#L84-L87 |
7,887 | middleout/arhitect-http | src/Arhitect/Http/Request.php | Request.all | public function all()
{
$data = $this->attributes->all();
$data = $data + $this->query->all();
$data = $data + $this->request->all();
return $data;
} | php | public function all()
{
$data = $this->attributes->all();
$data = $data + $this->query->all();
$data = $data + $this->request->all();
return $data;
} | [
"public",
"function",
"all",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"attributes",
"->",
"all",
"(",
")",
";",
"$",
"data",
"=",
"$",
"data",
"+",
"$",
"this",
"->",
"query",
"->",
"all",
"(",
")",
";",
"$",
"data",
"=",
"$",
"data",
"+",
"$",
"this",
"->",
"request",
"->",
"all",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Returns all parameters, from request, query or post
@return array | [
"Returns",
"all",
"parameters",
"from",
"request",
"query",
"or",
"post"
] | 43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6 | https://github.com/middleout/arhitect-http/blob/43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6/src/Arhitect/Http/Request.php#L60-L67 |
7,888 | middleout/arhitect-http | src/Arhitect/Http/Request.php | Request.param | public function param($key = NULL, $default = NULL)
{
if ( !$key ) {
return $this->attributes->all();
}
$path = '';
$key = explode('.', $key);
foreach ($key as $item) {
if ( !$path ) {
$path .= $item;
continue;
}
$path .= '[' . $item . ']';
}
return $this->attributes->get($path, $default, TRUE);
} | php | public function param($key = NULL, $default = NULL)
{
if ( !$key ) {
return $this->attributes->all();
}
$path = '';
$key = explode('.', $key);
foreach ($key as $item) {
if ( !$path ) {
$path .= $item;
continue;
}
$path .= '[' . $item . ']';
}
return $this->attributes->get($path, $default, TRUE);
} | [
"public",
"function",
"param",
"(",
"$",
"key",
"=",
"NULL",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"->",
"all",
"(",
")",
";",
"}",
"$",
"path",
"=",
"''",
";",
"$",
"key",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"key",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"path",
".=",
"$",
"item",
";",
"continue",
";",
"}",
"$",
"path",
".=",
"'['",
".",
"$",
"item",
".",
"']'",
";",
"}",
"return",
"$",
"this",
"->",
"attributes",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"default",
",",
"TRUE",
")",
";",
"}"
] | Returns a certain parameter from Route Params
If key is NULL, returns all the data in the Route Params
@param null $key
@param null $default
@return string|array | [
"Returns",
"a",
"certain",
"parameter",
"from",
"Route",
"Params",
"If",
"key",
"is",
"NULL",
"returns",
"all",
"the",
"data",
"in",
"the",
"Route",
"Params"
] | 43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6 | https://github.com/middleout/arhitect-http/blob/43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6/src/Arhitect/Http/Request.php#L136-L153 |
7,889 | middleout/arhitect-http | src/Arhitect/Http/Request.php | Request.any | public function any($key, $default = NULL)
{
$item = $this->param($key, NULL);
if ( $item ) {
return $item;
}
$item = $this->post($key, NULL);
if ( $item ) {
return $item;
}
$item = $this->query($key, NULL);
if ( $item ) {
return $item;
}
return $default;
} | php | public function any($key, $default = NULL)
{
$item = $this->param($key, NULL);
if ( $item ) {
return $item;
}
$item = $this->post($key, NULL);
if ( $item ) {
return $item;
}
$item = $this->query($key, NULL);
if ( $item ) {
return $item;
}
return $default;
} | [
"public",
"function",
"any",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"param",
"(",
"$",
"key",
",",
"NULL",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
";",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"post",
"(",
"$",
"key",
",",
"NULL",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
";",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"key",
",",
"NULL",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Returns any parameter, from request, query or post
@param string $key
@param null $default
@return string | [
"Returns",
"any",
"parameter",
"from",
"request",
"query",
"or",
"post"
] | 43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6 | https://github.com/middleout/arhitect-http/blob/43f0bdf6b5f7fded49b2a7750aaa2bb7deaa5ab6/src/Arhitect/Http/Request.php#L163-L179 |
7,890 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/Whitelist.php | Whitelist.setList | public function setList($list = [])
{
if (!is_array($list)) {
$list = ArrayUtils::iteratorToArray($list);
}
$this->list = $list;
} | php | public function setList($list = [])
{
if (!is_array($list)) {
$list = ArrayUtils::iteratorToArray($list);
}
$this->list = $list;
} | [
"public",
"function",
"setList",
"(",
"$",
"list",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"list",
")",
")",
"{",
"$",
"list",
"=",
"ArrayUtils",
"::",
"iteratorToArray",
"(",
"$",
"list",
")",
";",
"}",
"$",
"this",
"->",
"list",
"=",
"$",
"list",
";",
"}"
] | Set the list of items to white-list.
@param array|Traversable $list | [
"Set",
"the",
"list",
"of",
"items",
"to",
"white",
"-",
"list",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Whitelist.php#L62-L69 |
7,891 | ncou/Chiron-Http | src/Psr/ServerRequest.php | ServerRequest.getQueryParam | public function getQueryParam(string $key, $default = null)
{
$getParams = $this->getQueryParams();
$result = $default;
if (isset($getParams[$key])) {
$result = $getParams[$key];
}
return $result;
} | php | public function getQueryParam(string $key, $default = null)
{
$getParams = $this->getQueryParams();
$result = $default;
if (isset($getParams[$key])) {
$result = $getParams[$key];
}
return $result;
} | [
"public",
"function",
"getQueryParam",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"getParams",
"=",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
";",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"isset",
"(",
"$",
"getParams",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"getParams",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Fetch parameter value from query string.
Note: This method is not part of the PSR-7 standard.
@param string $key
@param mixed $default
@return mixed | [
"Fetch",
"parameter",
"value",
"from",
"query",
"string",
"."
] | 3768f8f5f030ea0a06b1d7342157cd2a6cc24bb1 | https://github.com/ncou/Chiron-Http/blob/3768f8f5f030ea0a06b1d7342157cd2a6cc24bb1/src/Psr/ServerRequest.php#L550-L559 |
7,892 | Palmabit-IT/authenticator | src/Palmabit/Authentication/Repository/SentryUserRepository.php | SentryUserRepository.addGroup | public function addGroup($user_id, $group_id) {
try {
$group = Group::findOrFail($group_id);
$user = User::findOrFail($user_id);
$user->addGroup($group);
} catch (ModelNotFoundException $e) {
throw new NotFoundException;
}
} | php | public function addGroup($user_id, $group_id) {
try {
$group = Group::findOrFail($group_id);
$user = User::findOrFail($user_id);
$user->addGroup($group);
} catch (ModelNotFoundException $e) {
throw new NotFoundException;
}
} | [
"public",
"function",
"addGroup",
"(",
"$",
"user_id",
",",
"$",
"group_id",
")",
"{",
"try",
"{",
"$",
"group",
"=",
"Group",
"::",
"findOrFail",
"(",
"$",
"group_id",
")",
";",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user_id",
")",
";",
"$",
"user",
"->",
"addGroup",
"(",
"$",
"group",
")",
";",
"}",
"catch",
"(",
"ModelNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFoundException",
";",
"}",
"}"
] | Add a group to the user
@param $user_id
@param $group_id
@return mixed|void
@throws \Palmabit\Authentication\Exceptions\UserNotFoundException | [
"Add",
"a",
"group",
"to",
"the",
"user"
] | 986cfc7e666e0e1b0312e518d586ec61b08cdb42 | https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Repository/SentryUserRepository.php#L111-L119 |
7,893 | Palmabit-IT/authenticator | src/Palmabit/Authentication/Repository/SentryUserRepository.php | SentryUserRepository.findFromGroupName | public function findFromGroupName($group_name) {
$group = $this->sentry->findGroupByName($group_name);
if (!$group) {
throw new UserNotFoundException;
}
return $group->users;
} | php | public function findFromGroupName($group_name) {
$group = $this->sentry->findGroupByName($group_name);
if (!$group) {
throw new UserNotFoundException;
}
return $group->users;
} | [
"public",
"function",
"findFromGroupName",
"(",
"$",
"group_name",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"sentry",
"->",
"findGroupByName",
"(",
"$",
"group_name",
")",
";",
"if",
"(",
"!",
"$",
"group",
")",
"{",
"throw",
"new",
"UserNotFoundException",
";",
"}",
"return",
"$",
"group",
"->",
"users",
";",
"}"
] | Obtain a list of user from a given group
@param String $group_name
@return mixed
@throws \Cartalyst\Sentry\Users\UserNotFoundException | [
"Obtain",
"a",
"list",
"of",
"user",
"from",
"a",
"given",
"group"
] | 986cfc7e666e0e1b0312e518d586ec61b08cdb42 | https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Repository/SentryUserRepository.php#L178-L184 |
7,894 | SocietyCMS/Setting | Support/ThemeOptions.php | ThemeOptions.getOptions | public function getOptions()
{
if ($this->options) {
return $this->options;
}
return $this->options = (new \FloatingPoint\Stylist\Theme\Json($this->theme->getPath()))->getJsonAttribute('options');
} | php | public function getOptions()
{
if ($this->options) {
return $this->options;
}
return $this->options = (new \FloatingPoint\Stylist\Theme\Json($this->theme->getPath()))->getJsonAttribute('options');
} | [
"public",
"function",
"getOptions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
")",
"{",
"return",
"$",
"this",
"->",
"options",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"=",
"(",
"new",
"\\",
"FloatingPoint",
"\\",
"Stylist",
"\\",
"Theme",
"\\",
"Json",
"(",
"$",
"this",
"->",
"theme",
"->",
"getPath",
"(",
")",
")",
")",
"->",
"getJsonAttribute",
"(",
"'options'",
")",
";",
"}"
] | Get the options defined in the themes json file.
@return mixed | [
"Get",
"the",
"options",
"defined",
"in",
"the",
"themes",
"json",
"file",
"."
] | a2726098cd596d2979750cd47d6fcec61c77e391 | https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/ThemeOptions.php#L29-L36 |
7,895 | shov/wpci-core | Wordpress/WpProvider.php | WpProvider.newWpDb | public function newWpDb($dbuser, $dbpassword, $dbname, $dbhost)
{
$wpDbClass = '\wpdb';
return new $wpDbClass($dbuser, $dbpassword, $dbname, $dbhost);
} | php | public function newWpDb($dbuser, $dbpassword, $dbname, $dbhost)
{
$wpDbClass = '\wpdb';
return new $wpDbClass($dbuser, $dbpassword, $dbname, $dbhost);
} | [
"public",
"function",
"newWpDb",
"(",
"$",
"dbuser",
",",
"$",
"dbpassword",
",",
"$",
"dbname",
",",
"$",
"dbhost",
")",
"{",
"$",
"wpDbClass",
"=",
"'\\wpdb'",
";",
"return",
"new",
"$",
"wpDbClass",
"(",
"$",
"dbuser",
",",
"$",
"dbpassword",
",",
"$",
"dbname",
",",
"$",
"dbhost",
")",
";",
"}"
] | Return new wpdb instance
@param $dbuser
@param $dbpassword
@param $dbname
@param $dbhost
@return \wpdb | [
"Return",
"new",
"wpdb",
"instance"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Wordpress/WpProvider.php#L85-L89 |
7,896 | shov/wpci-core | Wordpress/WpProvider.php | WpProvider.addAction | public function addAction(string $tag, callable $callback, ?int $priority = null)
{
$args = [$tag, $callback];
if (!is_null($priority)) $args[] = $priority;
return $this->callGlobalFunction('add_action', $args);
} | php | public function addAction(string $tag, callable $callback, ?int $priority = null)
{
$args = [$tag, $callback];
if (!is_null($priority)) $args[] = $priority;
return $this->callGlobalFunction('add_action', $args);
} | [
"public",
"function",
"addAction",
"(",
"string",
"$",
"tag",
",",
"callable",
"$",
"callback",
",",
"?",
"int",
"$",
"priority",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"[",
"$",
"tag",
",",
"$",
"callback",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"priority",
")",
")",
"$",
"args",
"[",
"]",
"=",
"$",
"priority",
";",
"return",
"$",
"this",
"->",
"callGlobalFunction",
"(",
"'add_action'",
",",
"$",
"args",
")",
";",
"}"
] | Add action hook
@param string $tag
@param callable $callback
@param int|null $priority
@return mixed
@throws \ErrorException | [
"Add",
"action",
"hook"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Wordpress/WpProvider.php#L103-L109 |
7,897 | shov/wpci-core | Wordpress/WpProvider.php | WpProvider.doAction | public function doAction(string $tag, ...$params)
{
$args = [$tag];
if (!empty($params)) $args[] = $params;
return $this->callGlobalFunction('do_action', $args);
} | php | public function doAction(string $tag, ...$params)
{
$args = [$tag];
if (!empty($params)) $args[] = $params;
return $this->callGlobalFunction('do_action', $args);
} | [
"public",
"function",
"doAction",
"(",
"string",
"$",
"tag",
",",
"...",
"$",
"params",
")",
"{",
"$",
"args",
"=",
"[",
"$",
"tag",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"$",
"args",
"[",
"]",
"=",
"$",
"params",
";",
"return",
"$",
"this",
"->",
"callGlobalFunction",
"(",
"'do_action'",
",",
"$",
"args",
")",
";",
"}"
] | Call the hook
@param string $tag
@param array $params
@return mixed
@throws \ErrorException | [
"Call",
"the",
"hook"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Wordpress/WpProvider.php#L135-L141 |
7,898 | shov/wpci-core | Wordpress/WpProvider.php | WpProvider.wpRegisterStyle | public function wpRegisterStyle($handle, $src, $deps = [], $ver = false, $media = 'all')
{
return $this->callGlobalFunction('wp_register_style', [$handle, $src, $deps, $ver, $media]);
} | php | public function wpRegisterStyle($handle, $src, $deps = [], $ver = false, $media = 'all')
{
return $this->callGlobalFunction('wp_register_style', [$handle, $src, $deps, $ver, $media]);
} | [
"public",
"function",
"wpRegisterStyle",
"(",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"deps",
"=",
"[",
"]",
",",
"$",
"ver",
"=",
"false",
",",
"$",
"media",
"=",
"'all'",
")",
"{",
"return",
"$",
"this",
"->",
"callGlobalFunction",
"(",
"'wp_register_style'",
",",
"[",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"deps",
",",
"$",
"ver",
",",
"$",
"media",
"]",
")",
";",
"}"
] | Register a CSS stylesheet
@param $handle
@param $src
@param array $deps
@param bool $ver
@param string $media
@return mixed
@throws \ErrorException | [
"Register",
"a",
"CSS",
"stylesheet"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Wordpress/WpProvider.php#L370-L373 |
7,899 | shov/wpci-core | Wordpress/WpProvider.php | WpProvider.wpEnqueueScript | public function wpEnqueueScript($handle, $src = '', $deps = [], $ver = false, $inFooter = false)
{
return $this->callGlobalFunction('wp_enqueue_script', [$handle, $src, $deps, $ver, $inFooter]);
} | php | public function wpEnqueueScript($handle, $src = '', $deps = [], $ver = false, $inFooter = false)
{
return $this->callGlobalFunction('wp_enqueue_script', [$handle, $src, $deps, $ver, $inFooter]);
} | [
"public",
"function",
"wpEnqueueScript",
"(",
"$",
"handle",
",",
"$",
"src",
"=",
"''",
",",
"$",
"deps",
"=",
"[",
"]",
",",
"$",
"ver",
"=",
"false",
",",
"$",
"inFooter",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"callGlobalFunction",
"(",
"'wp_enqueue_script'",
",",
"[",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"deps",
",",
"$",
"ver",
",",
"$",
"inFooter",
"]",
")",
";",
"}"
] | Enqueue a script
@param $handle
@param string $src
@param array $deps
@param bool $ver
@param bool $inFooter
@return mixed
@throws \ErrorException | [
"Enqueue",
"a",
"script"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Wordpress/WpProvider.php#L385-L388 |
Subsets and Splits