id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,500
|
extendsframework/extends-router
|
src/Routes.php
|
Routes.getRoutes
|
protected function getRoutes(): array
{
uasort($this->routes, function (RouteInterface $left, RouteInterface $right) {
if ($left instanceof GroupRoute || $right instanceof GroupRoute) {
return 1;
}
return 0;
});
return $this->routes;
}
|
php
|
protected function getRoutes(): array
{
uasort($this->routes, function (RouteInterface $left, RouteInterface $right) {
if ($left instanceof GroupRoute || $right instanceof GroupRoute) {
return 1;
}
return 0;
});
return $this->routes;
}
|
[
"protected",
"function",
"getRoutes",
"(",
")",
":",
"array",
"{",
"uasort",
"(",
"$",
"this",
"->",
"routes",
",",
"function",
"(",
"RouteInterface",
"$",
"left",
",",
"RouteInterface",
"$",
"right",
")",
"{",
"if",
"(",
"$",
"left",
"instanceof",
"GroupRoute",
"||",
"$",
"right",
"instanceof",
"GroupRoute",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"routes",
";",
"}"
] |
Get routes.
Sort children that group routes will be matched first, nested routes before flat routes.
@return RouteInterface[]
|
[
"Get",
"routes",
"."
] |
7c142749635c6fb1c58508bf3c8f594529e136d9
|
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Routes.php#L80-L91
|
239,501
|
Stratadox/Hydrator
|
src/HydrationFailed.php
|
HydrationFailed.encountered
|
public static function encountered(
Throwable $exception,
object $target
): CannotHydrate {
return new HydrationFailed(withMessage(
'Could not hydrate the `%s`: %s',
theClassOfThe($target),
$exception->getMessage()
), 0, $exception);
}
|
php
|
public static function encountered(
Throwable $exception,
object $target
): CannotHydrate {
return new HydrationFailed(withMessage(
'Could not hydrate the `%s`: %s',
theClassOfThe($target),
$exception->getMessage()
), 0, $exception);
}
|
[
"public",
"static",
"function",
"encountered",
"(",
"Throwable",
"$",
"exception",
",",
"object",
"$",
"target",
")",
":",
"CannotHydrate",
"{",
"return",
"new",
"HydrationFailed",
"(",
"withMessage",
"(",
"'Could not hydrate the `%s`: %s'",
",",
"theClassOfThe",
"(",
"$",
"target",
")",
",",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
",",
"0",
",",
"$",
"exception",
")",
";",
"}"
] |
Notifies the client code that an exception was encountered during the
hydration process.
@param Throwable $exception The exception that was thrown.
@param object $target The object that was being hydrated.
@return CannotHydrate The exception to throw.
|
[
"Notifies",
"the",
"client",
"code",
"that",
"an",
"exception",
"was",
"encountered",
"during",
"the",
"hydration",
"process",
"."
] |
6895b1a39d84a157e3454be28bdef8e31359b3cd
|
https://github.com/Stratadox/Hydrator/blob/6895b1a39d84a157e3454be28bdef8e31359b3cd/src/HydrationFailed.php#L27-L36
|
239,502
|
webignition/web-resource-service
|
src/Service/Configuration.php
|
Configuration.getWebResourceClassName
|
public function getWebResourceClassName($contentType)
{
return ($this->hasMappedWebResourceClassName($contentType))
? $this->contentTypeWebResourceMap[(string)$contentType]
: self::DEFAULT_WEB_RESOURCE_MODEL;
}
|
php
|
public function getWebResourceClassName($contentType)
{
return ($this->hasMappedWebResourceClassName($contentType))
? $this->contentTypeWebResourceMap[(string)$contentType]
: self::DEFAULT_WEB_RESOURCE_MODEL;
}
|
[
"public",
"function",
"getWebResourceClassName",
"(",
"$",
"contentType",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"hasMappedWebResourceClassName",
"(",
"$",
"contentType",
")",
")",
"?",
"$",
"this",
"->",
"contentTypeWebResourceMap",
"[",
"(",
"string",
")",
"$",
"contentType",
"]",
":",
"self",
"::",
"DEFAULT_WEB_RESOURCE_MODEL",
";",
"}"
] |
Get the WebResource subclass name for a given content type
@param string $contentType
@return string
|
[
"Get",
"the",
"WebResource",
"subclass",
"name",
"for",
"a",
"given",
"content",
"type"
] |
1789ff5e770daf326bccb6ac9e7b598fc2626b25
|
https://github.com/webignition/web-resource-service/blob/1789ff5e770daf326bccb6ac9e7b598fc2626b25/src/Service/Configuration.php#L110-L115
|
239,503
|
ischenko/yii2-jsloader
|
src/base/Loader.php
|
Loader.setConfig
|
public function setConfig($config)
{
$configObject = $this->getConfig();
if (is_object($config)) {
$config = get_object_vars($config);
}
foreach ((array)$config as $key => $value) {
$configObject->$key = $value;
}
return $this;
}
|
php
|
public function setConfig($config)
{
$configObject = $this->getConfig();
if (is_object($config)) {
$config = get_object_vars($config);
}
foreach ((array)$config as $key => $value) {
$configObject->$key = $value;
}
return $this;
}
|
[
"public",
"function",
"setConfig",
"(",
"$",
"config",
")",
"{",
"$",
"configObject",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"get_object_vars",
"(",
"$",
"config",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"configObject",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets new configuration for the loader
@param ConfigInterface|array $config
@return $this
|
[
"Sets",
"new",
"configuration",
"for",
"the",
"loader"
] |
873242c4ab80eb160519d8ba0c4afb92aa89edfb
|
https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L110-L123
|
239,504
|
ischenko/yii2-jsloader
|
src/base/Loader.php
|
Loader.registerAssetBundle
|
public function registerAssetBundle($name)
{
if (($bundle = $this->getAssetBundleFromView($name)) === false) {
return $bundle;
}
$config = $this->getConfig();
if (!($module = $config->getModule($name))) {
$module = $config->addModule($name);
}
$options = $bundle->jsOptions;
if (!isset($options['position'])) {
$options['position'] = View::POS_END;
}
$options['baseUrl'] = $bundle->baseUrl;
$module->setOptions($options);
// TODO: think about optimization
foreach ($bundle->depends as $dependency) {
if (($dependency = $this->registerAssetBundle($dependency)) !== false) {
$module->addDependency($dependency);
}
}
$this->importJsFilesFromBundle($bundle, $module);
return $module;
}
|
php
|
public function registerAssetBundle($name)
{
if (($bundle = $this->getAssetBundleFromView($name)) === false) {
return $bundle;
}
$config = $this->getConfig();
if (!($module = $config->getModule($name))) {
$module = $config->addModule($name);
}
$options = $bundle->jsOptions;
if (!isset($options['position'])) {
$options['position'] = View::POS_END;
}
$options['baseUrl'] = $bundle->baseUrl;
$module->setOptions($options);
// TODO: think about optimization
foreach ($bundle->depends as $dependency) {
if (($dependency = $this->registerAssetBundle($dependency)) !== false) {
$module->addDependency($dependency);
}
}
$this->importJsFilesFromBundle($bundle, $module);
return $module;
}
|
[
"public",
"function",
"registerAssetBundle",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"(",
"$",
"bundle",
"=",
"$",
"this",
"->",
"getAssetBundleFromView",
"(",
"$",
"name",
")",
")",
"===",
"false",
")",
"{",
"return",
"$",
"bundle",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"module",
"=",
"$",
"config",
"->",
"getModule",
"(",
"$",
"name",
")",
")",
")",
"{",
"$",
"module",
"=",
"$",
"config",
"->",
"addModule",
"(",
"$",
"name",
")",
";",
"}",
"$",
"options",
"=",
"$",
"bundle",
"->",
"jsOptions",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'position'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'position'",
"]",
"=",
"View",
"::",
"POS_END",
";",
"}",
"$",
"options",
"[",
"'baseUrl'",
"]",
"=",
"$",
"bundle",
"->",
"baseUrl",
";",
"$",
"module",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"// TODO: think about optimization",
"foreach",
"(",
"$",
"bundle",
"->",
"depends",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"(",
"$",
"dependency",
"=",
"$",
"this",
"->",
"registerAssetBundle",
"(",
"$",
"dependency",
")",
")",
"!==",
"false",
")",
"{",
"$",
"module",
"->",
"addDependency",
"(",
"$",
"dependency",
")",
";",
"}",
"}",
"$",
"this",
"->",
"importJsFilesFromBundle",
"(",
"$",
"bundle",
",",
"$",
"module",
")",
";",
"return",
"$",
"module",
";",
"}"
] |
Registers asset bundle in the loader
@param string $name
@return ModuleInterface|false an instance of registered module or false if asset bundle was not registered
|
[
"Registers",
"asset",
"bundle",
"in",
"the",
"loader"
] |
873242c4ab80eb160519d8ba0c4afb92aa89edfb
|
https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L132-L164
|
239,505
|
ischenko/yii2-jsloader
|
src/base/Loader.php
|
Loader.processAssets
|
public function processAssets()
{
$jsExpressions = [];
foreach ([
View::POS_HEAD,
View::POS_BEGIN,
View::POS_END,
View::POS_LOAD,
View::POS_READY
] as $position
) {
if ($this->ignoredPositions->match($position)) {
continue;
}
if (($jsExpression = $this->createJsExpression($position)) === null) {
continue;
}
$jsExpressions[$position] = $jsExpression;
}
$this->doRender($jsExpressions);
}
|
php
|
public function processAssets()
{
$jsExpressions = [];
foreach ([
View::POS_HEAD,
View::POS_BEGIN,
View::POS_END,
View::POS_LOAD,
View::POS_READY
] as $position
) {
if ($this->ignoredPositions->match($position)) {
continue;
}
if (($jsExpression = $this->createJsExpression($position)) === null) {
continue;
}
$jsExpressions[$position] = $jsExpression;
}
$this->doRender($jsExpressions);
}
|
[
"public",
"function",
"processAssets",
"(",
")",
"{",
"$",
"jsExpressions",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"View",
"::",
"POS_HEAD",
",",
"View",
"::",
"POS_BEGIN",
",",
"View",
"::",
"POS_END",
",",
"View",
"::",
"POS_LOAD",
",",
"View",
"::",
"POS_READY",
"]",
"as",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ignoredPositions",
"->",
"match",
"(",
"$",
"position",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"(",
"$",
"jsExpression",
"=",
"$",
"this",
"->",
"createJsExpression",
"(",
"$",
"position",
")",
")",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"jsExpressions",
"[",
"$",
"position",
"]",
"=",
"$",
"jsExpression",
";",
"}",
"$",
"this",
"->",
"doRender",
"(",
"$",
"jsExpressions",
")",
";",
"}"
] |
Performs processing of assets registered in the view
@return void
|
[
"Performs",
"processing",
"of",
"assets",
"registered",
"in",
"the",
"view"
] |
873242c4ab80eb160519d8ba0c4afb92aa89edfb
|
https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L171-L195
|
239,506
|
InnoGr/FivePercent-Cache
|
src/ArrayCache.php
|
ArrayCache.set
|
public function set($key, $data, $ttl = null)
{
if ($ttl) {
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$expire = (int) $now->format('U') + $ttl;
} else {
$expire = 0;
}
$entry = array(
'expire' => $expire,
'value' => $data
);
$this->storage[$key] = $entry;
return true;
}
|
php
|
public function set($key, $data, $ttl = null)
{
if ($ttl) {
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$expire = (int) $now->format('U') + $ttl;
} else {
$expire = 0;
}
$entry = array(
'expire' => $expire,
'value' => $data
);
$this->storage[$key] = $entry;
return true;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"ttl",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"expire",
"=",
"(",
"int",
")",
"$",
"now",
"->",
"format",
"(",
"'U'",
")",
"+",
"$",
"ttl",
";",
"}",
"else",
"{",
"$",
"expire",
"=",
"0",
";",
"}",
"$",
"entry",
"=",
"array",
"(",
"'expire'",
"=>",
"$",
"expire",
",",
"'value'",
"=>",
"$",
"data",
")",
";",
"$",
"this",
"->",
"storage",
"[",
"$",
"key",
"]",
"=",
"$",
"entry",
";",
"return",
"true",
";",
"}"
] |
Set data to cache storage
@param string $key
@param mixed $data
@param int $ttl
@return bool
|
[
"Set",
"data",
"to",
"cache",
"storage"
] |
0849e495bd440ce5faf0f8a5f6e66d93485f7627
|
https://github.com/InnoGr/FivePercent-Cache/blob/0849e495bd440ce5faf0f8a5f6e66d93485f7627/src/ArrayCache.php#L71-L88
|
239,507
|
ivoba/stop
|
src/Stop/Stop.php
|
Stop.json
|
public static function json($var, $continue = false, $hide = false, $return = false){
$Stop = new \Stop\Dumper\Json($hide, $continue, $return, Dumper\AbstractDumper::FORMAT_JSON);
$Stop->var_dump($var);
}
|
php
|
public static function json($var, $continue = false, $hide = false, $return = false){
$Stop = new \Stop\Dumper\Json($hide, $continue, $return, Dumper\AbstractDumper::FORMAT_JSON);
$Stop->var_dump($var);
}
|
[
"public",
"static",
"function",
"json",
"(",
"$",
"var",
",",
"$",
"continue",
"=",
"false",
",",
"$",
"hide",
"=",
"false",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"Stop",
"=",
"new",
"\\",
"Stop",
"\\",
"Dumper",
"\\",
"Json",
"(",
"$",
"hide",
",",
"$",
"continue",
",",
"$",
"return",
",",
"Dumper",
"\\",
"AbstractDumper",
"::",
"FORMAT_JSON",
")",
";",
"$",
"Stop",
"->",
"var_dump",
"(",
"$",
"var",
")",
";",
"}"
] |
dump a variable as json
@param $var
@param bool $continue
@param bool $hide
@param bool $return
|
[
"dump",
"a",
"variable",
"as",
"json"
] |
e534554c5cb203cd39767c3055fa767356617de7
|
https://github.com/ivoba/stop/blob/e534554c5cb203cd39767c3055fa767356617de7/src/Stop/Stop.php#L128-L131
|
239,508
|
phossa2/libs
|
src/Phossa2/Query/Traits/StatementAbstract.php
|
StatementAbstract.buildSql
|
protected function buildSql(array $settings)/*# : string */
{
$result = $this->getType(); // type
$settings['join'] = $settings['seperator'] . $settings['indent'];
$result .= $this->buildBeforeAfter('AFTER', 'TYPE', $settings); // hint
foreach ($this->getConfigs() as $pos => $prefix) {
// before
$result .= $this->buildBeforeAfter('BEFORE', $pos, $settings);
$method = 'build' . ucfirst(strtolower($pos));
$result .= $this->{$method}($prefix, $settings);
// after
$result .= $this->buildBeforeAfter('AFTER', $pos, $settings);
}
$result .= $this->buildBeforeAfter('AFTER', 'STMT', $settings);
return $result;
}
|
php
|
protected function buildSql(array $settings)/*# : string */
{
$result = $this->getType(); // type
$settings['join'] = $settings['seperator'] . $settings['indent'];
$result .= $this->buildBeforeAfter('AFTER', 'TYPE', $settings); // hint
foreach ($this->getConfigs() as $pos => $prefix) {
// before
$result .= $this->buildBeforeAfter('BEFORE', $pos, $settings);
$method = 'build' . ucfirst(strtolower($pos));
$result .= $this->{$method}($prefix, $settings);
// after
$result .= $this->buildBeforeAfter('AFTER', $pos, $settings);
}
$result .= $this->buildBeforeAfter('AFTER', 'STMT', $settings);
return $result;
}
|
[
"protected",
"function",
"buildSql",
"(",
"array",
"$",
"settings",
")",
"/*# : string */",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"// type",
"$",
"settings",
"[",
"'join'",
"]",
"=",
"$",
"settings",
"[",
"'seperator'",
"]",
".",
"$",
"settings",
"[",
"'indent'",
"]",
";",
"$",
"result",
".=",
"$",
"this",
"->",
"buildBeforeAfter",
"(",
"'AFTER'",
",",
"'TYPE'",
",",
"$",
"settings",
")",
";",
"// hint",
"foreach",
"(",
"$",
"this",
"->",
"getConfigs",
"(",
")",
"as",
"$",
"pos",
"=>",
"$",
"prefix",
")",
"{",
"// before",
"$",
"result",
".=",
"$",
"this",
"->",
"buildBeforeAfter",
"(",
"'BEFORE'",
",",
"$",
"pos",
",",
"$",
"settings",
")",
";",
"$",
"method",
"=",
"'build'",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"pos",
")",
")",
";",
"$",
"result",
".=",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"prefix",
",",
"$",
"settings",
")",
";",
"// after",
"$",
"result",
".=",
"$",
"this",
"->",
"buildBeforeAfter",
"(",
"'AFTER'",
",",
"$",
"pos",
",",
"$",
"settings",
")",
";",
"}",
"$",
"result",
".=",
"$",
"this",
"->",
"buildBeforeAfter",
"(",
"'AFTER'",
",",
"'STMT'",
",",
"$",
"settings",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Build SQL statement clauses
@param array $settings
@param string
@access protected
|
[
"Build",
"SQL",
"statement",
"clauses"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/StatementAbstract.php#L143-L162
|
239,509
|
SymBB/symbb
|
src/Symbb/Core/AdminBundle/Controller/Base/CrudController.php
|
CrudController.getFormEntity
|
protected function getFormEntity(Request $request)
{
if ($this->formEntity === null) {
$entityId = $request->get('id');
$repository = $this->getRepository();
$entity = null;
$id = 0;
if (!empty($entityId) && $entityId !== null) {
$entity = $repository->findOneById($entityId);
$id = $entity->getId();
}
if (!is_object($entity) || empty($id)) {
// new form, return empty entity
$entity_class_name = $repository->getClassName();
$entity = new $entity_class_name();
}
$this->formEntity = $entity;
}
return $this->formEntity;
}
|
php
|
protected function getFormEntity(Request $request)
{
if ($this->formEntity === null) {
$entityId = $request->get('id');
$repository = $this->getRepository();
$entity = null;
$id = 0;
if (!empty($entityId) && $entityId !== null) {
$entity = $repository->findOneById($entityId);
$id = $entity->getId();
}
if (!is_object($entity) || empty($id)) {
// new form, return empty entity
$entity_class_name = $repository->getClassName();
$entity = new $entity_class_name();
}
$this->formEntity = $entity;
}
return $this->formEntity;
}
|
[
"protected",
"function",
"getFormEntity",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formEntity",
"===",
"null",
")",
"{",
"$",
"entityId",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"entity",
"=",
"null",
";",
"$",
"id",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"entityId",
")",
"&&",
"$",
"entityId",
"!==",
"null",
")",
"{",
"$",
"entity",
"=",
"$",
"repository",
"->",
"findOneById",
"(",
"$",
"entityId",
")",
";",
"$",
"id",
"=",
"$",
"entity",
"->",
"getId",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"entity",
")",
"||",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"// new form, return empty entity",
"$",
"entity_class_name",
"=",
"$",
"repository",
"->",
"getClassName",
"(",
")",
";",
"$",
"entity",
"=",
"new",
"$",
"entity_class_name",
"(",
")",
";",
"}",
"$",
"this",
"->",
"formEntity",
"=",
"$",
"entity",
";",
"}",
"return",
"$",
"this",
"->",
"formEntity",
";",
"}"
] |
Entity object for the form
Dont load the object twice and load from this method
@return Object
|
[
"Entity",
"object",
"for",
"the",
"form",
"Dont",
"load",
"the",
"object",
"twice",
"and",
"load",
"from",
"this",
"method"
] |
be25357502e6a51016fa0b128a46c2dc87fa8fb2
|
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/AdminBundle/Controller/Base/CrudController.php#L188-L211
|
239,510
|
canis-io/yii2-key-provider
|
lib/providers/BaseFlysystemProvider.php
|
BaseFlysystemProvider.getFilesystem
|
protected function getFilesystem()
{
if (!isset($this->filesystem)) {
$this->filesystem = new Filesystem($this->getAdapter());
}
return $this->filesystem;
}
|
php
|
protected function getFilesystem()
{
if (!isset($this->filesystem)) {
$this->filesystem = new Filesystem($this->getAdapter());
}
return $this->filesystem;
}
|
[
"protected",
"function",
"getFilesystem",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filesystem",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"$",
"this",
"->",
"getAdapter",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"filesystem",
";",
"}"
] |
Retrives the Filesystem object. Instantiate if it hasn't already been.
@return \League\Flysystem\Filesystem Flysystem filesystem object
@see http://flysystem.thephpleague.com/api
|
[
"Retrives",
"the",
"Filesystem",
"object",
".",
"Instantiate",
"if",
"it",
"hasn",
"t",
"already",
"been",
"."
] |
c54f1c8af812bddf48872a05bc1d1e02112decc9
|
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseFlysystemProvider.php#L36-L42
|
239,511
|
kpacha/php-benchmark-tool
|
src/Kpacha/BenchmarkTool/Helper/GnuplotFactory.php
|
GnuplotFactory.create
|
public function create($template)
{
if (!isset($this->plotters[$template])) {
throw new \InvalidArgumentException("Unknown template [$template]");
}
$className = $this->plotters[$template];
return new $className($this->finderFactory);
}
|
php
|
public function create($template)
{
if (!isset($this->plotters[$template])) {
throw new \InvalidArgumentException("Unknown template [$template]");
}
$className = $this->plotters[$template];
return new $className($this->finderFactory);
}
|
[
"public",
"function",
"create",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"plotters",
"[",
"$",
"template",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unknown template [$template]\"",
")",
";",
"}",
"$",
"className",
"=",
"$",
"this",
"->",
"plotters",
"[",
"$",
"template",
"]",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"finderFactory",
")",
";",
"}"
] |
Just get a new plotter by template!
@param string $template
@return \Kpacha\BenchmarkTool\Processor\Gnuplot
@throws \InvalidArgumentException
|
[
"Just",
"get",
"a",
"new",
"plotter",
"by",
"template!"
] |
71c73feadb01ba4c36d9df5ac947c07a7120c732
|
https://github.com/kpacha/php-benchmark-tool/blob/71c73feadb01ba4c36d9df5ac947c07a7120c732/src/Kpacha/BenchmarkTool/Helper/GnuplotFactory.php#L31-L38
|
239,512
|
buybrain/nervus-php
|
src/Buybrain/Nervus/Util/TypedUtils.php
|
TypedUtils.groupByType
|
public static function groupByType(array $objects)
{
$perType = [];
foreach ($objects as $object) {
$type = $object->getType();
if (!isset($perType[$type])) {
$perType[$type] = [];
}
$perType[$type][] = $object;
}
return $perType;
}
|
php
|
public static function groupByType(array $objects)
{
$perType = [];
foreach ($objects as $object) {
$type = $object->getType();
if (!isset($perType[$type])) {
$perType[$type] = [];
}
$perType[$type][] = $object;
}
return $perType;
}
|
[
"public",
"static",
"function",
"groupByType",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"perType",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"type",
"=",
"$",
"object",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"perType",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"perType",
"[",
"$",
"type",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"perType",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"return",
"$",
"perType",
";",
"}"
] |
Group typed objects by their type
@param Typed[] $objects
@return Typed[][] map indexed by types and lists of objects as values
|
[
"Group",
"typed",
"objects",
"by",
"their",
"type"
] |
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
|
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Util/TypedUtils.php#L28-L39
|
239,513
|
lamoni/restlyte
|
RESTLyte.php
|
RESTLyte.request
|
public function request($verb, $path, $accept, array $customCURLOptions=[])
{
$verb = strtoupper(
trim(
$verb
)
);
$instantiateClass = "\\Lamoni\\RESTLyte\\RESTLyteRequest\\RESTLyteRequest{$this->getResponseType()}";
$request = new $instantiateClass(
$this->getServer(),
$verb,
$path,
$this->getAuthCredentials(),
$accept,
$this->getVerifySSLPeer(),
$this->getHTTPHeaders(),
$customCURLOptions
);
return $request->getResponse();
}
|
php
|
public function request($verb, $path, $accept, array $customCURLOptions=[])
{
$verb = strtoupper(
trim(
$verb
)
);
$instantiateClass = "\\Lamoni\\RESTLyte\\RESTLyteRequest\\RESTLyteRequest{$this->getResponseType()}";
$request = new $instantiateClass(
$this->getServer(),
$verb,
$path,
$this->getAuthCredentials(),
$accept,
$this->getVerifySSLPeer(),
$this->getHTTPHeaders(),
$customCURLOptions
);
return $request->getResponse();
}
|
[
"public",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"path",
",",
"$",
"accept",
",",
"array",
"$",
"customCURLOptions",
"=",
"[",
"]",
")",
"{",
"$",
"verb",
"=",
"strtoupper",
"(",
"trim",
"(",
"$",
"verb",
")",
")",
";",
"$",
"instantiateClass",
"=",
"\"\\\\Lamoni\\\\RESTLyte\\\\RESTLyteRequest\\\\RESTLyteRequest{$this->getResponseType()}\"",
";",
"$",
"request",
"=",
"new",
"$",
"instantiateClass",
"(",
"$",
"this",
"->",
"getServer",
"(",
")",
",",
"$",
"verb",
",",
"$",
"path",
",",
"$",
"this",
"->",
"getAuthCredentials",
"(",
")",
",",
"$",
"accept",
",",
"$",
"this",
"->",
"getVerifySSLPeer",
"(",
")",
",",
"$",
"this",
"->",
"getHTTPHeaders",
"(",
")",
",",
"$",
"customCURLOptions",
")",
";",
"return",
"$",
"request",
"->",
"getResponse",
"(",
")",
";",
"}"
] |
Base for REST requests
@param $verb
@param $path
@param $accept
@param array $customCURLOptions
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract
|
[
"Base",
"for",
"REST",
"requests"
] |
10800f8ecc6efd43c6bd67a656c3a967758504cc
|
https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L242-L265
|
239,514
|
lamoni/restlyte
|
RESTLyte.php
|
RESTLyte.post
|
public function post($path, $postData, $accept="")
{
return $this->request(
'POST',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
php
|
public function post($path, $postData, $accept="")
{
return $this->request(
'POST',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
[
"public",
"function",
"post",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"postData",
"]",
")",
";",
"}"
] |
Launches a POST request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract
|
[
"Launches",
"a",
"POST",
"request",
"to",
"the",
"server"
] |
10800f8ecc6efd43c6bd67a656c3a967758504cc
|
https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L291-L302
|
239,515
|
lamoni/restlyte
|
RESTLyte.php
|
RESTLyte.put
|
public function put($path, $postData, $accept="")
{
return $this->request(
'PUT',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
php
|
public function put($path, $postData, $accept="")
{
return $this->request(
'PUT',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
[
"public",
"function",
"put",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'PUT'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"postData",
"]",
")",
";",
"}"
] |
Launches a PUT request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract
|
[
"Launches",
"a",
"PUT",
"request",
"to",
"the",
"server"
] |
10800f8ecc6efd43c6bd67a656c3a967758504cc
|
https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L312-L323
|
239,516
|
lamoni/restlyte
|
RESTLyte.php
|
RESTLyte.patch
|
public function patch($path, $postData, $accept="")
{
return $this->request(
'PATCH',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
php
|
public function patch($path, $postData, $accept="")
{
return $this->request(
'PATCH',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
[
"public",
"function",
"patch",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'PATCH'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"postData",
"]",
")",
";",
"}"
] |
Launches a PATCH request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract
|
[
"Launches",
"a",
"PATCH",
"request",
"to",
"the",
"server"
] |
10800f8ecc6efd43c6bd67a656c3a967758504cc
|
https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L333-L344
|
239,517
|
lamoni/restlyte
|
RESTLyte.php
|
RESTLyte.delete
|
public function delete($path, $postData, $accept="")
{
return $this->request(
'DELETE',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
php
|
public function delete($path, $postData, $accept="")
{
return $this->request(
'DELETE',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"postData",
"]",
")",
";",
"}"
] |
Launches a DELETE request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract
|
[
"Launches",
"a",
"DELETE",
"request",
"to",
"the",
"server"
] |
10800f8ecc6efd43c6bd67a656c3a967758504cc
|
https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L354-L365
|
239,518
|
webignition/node-jslint-output-parser
|
src/DecodedRawOutput.php
|
DecodedRawOutput.isWellFormed
|
public function isWellFormed()
{
if (!is_array($this->decodedRawOutput)) {
return false;
}
if (!isset($this->decodedRawOutput[0]) || !is_string($this->decodedRawOutput[0])) {
return false;
}
if (!isset($this->decodedRawOutput[1]) || !is_array($this->decodedRawOutput[1])) {
return false;
}
return true;
}
|
php
|
public function isWellFormed()
{
if (!is_array($this->decodedRawOutput)) {
return false;
}
if (!isset($this->decodedRawOutput[0]) || !is_string($this->decodedRawOutput[0])) {
return false;
}
if (!isset($this->decodedRawOutput[1]) || !is_array($this->decodedRawOutput[1])) {
return false;
}
return true;
}
|
[
"public",
"function",
"isWellFormed",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"decodedRawOutput",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"decodedRawOutput",
"[",
"0",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"this",
"->",
"decodedRawOutput",
"[",
"0",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"decodedRawOutput",
"[",
"1",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"decodedRawOutput",
"[",
"1",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Is the decoded output of the format we expect?
Should be a two-element array with item zero being the path
of the file that was linted and the item one being the result set
@return bool
|
[
"Is",
"the",
"decoded",
"output",
"of",
"the",
"format",
"we",
"expect?",
"Should",
"be",
"a",
"two",
"-",
"element",
"array",
"with",
"item",
"zero",
"being",
"the",
"path",
"of",
"the",
"file",
"that",
"was",
"linted",
"and",
"the",
"item",
"one",
"being",
"the",
"result",
"set"
] |
eb546e0922ea3e4d8d37987f54822a447e2e7610
|
https://github.com/webignition/node-jslint-output-parser/blob/eb546e0922ea3e4d8d37987f54822a447e2e7610/src/DecodedRawOutput.php#L51-L66
|
239,519
|
orkestra/orkestra-transactor
|
lib/Orkestra/Transactor/Entity/Result.php
|
Result.setStatus
|
public function setStatus(Result\ResultStatus $status)
{
if (Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transacted = true;
$this->dateTransacted = new DateTime();
}
if (!$this->transaction->isParent()
&& Result\ResultStatus::ERROR !== $status->getValue()
&& Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transaction->getParent()->setStatus($status);
}
$this->transaction->setStatus($status);
$this->status = $status;
}
|
php
|
public function setStatus(Result\ResultStatus $status)
{
if (Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transacted = true;
$this->dateTransacted = new DateTime();
}
if (!$this->transaction->isParent()
&& Result\ResultStatus::ERROR !== $status->getValue()
&& Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transaction->getParent()->setStatus($status);
}
$this->transaction->setStatus($status);
$this->status = $status;
}
|
[
"public",
"function",
"setStatus",
"(",
"Result",
"\\",
"ResultStatus",
"$",
"status",
")",
"{",
"if",
"(",
"Result",
"\\",
"ResultStatus",
"::",
"UNPROCESSED",
"!==",
"$",
"status",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"transacted",
"=",
"true",
";",
"$",
"this",
"->",
"dateTransacted",
"=",
"new",
"DateTime",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"transaction",
"->",
"isParent",
"(",
")",
"&&",
"Result",
"\\",
"ResultStatus",
"::",
"ERROR",
"!==",
"$",
"status",
"->",
"getValue",
"(",
")",
"&&",
"Result",
"\\",
"ResultStatus",
"::",
"UNPROCESSED",
"!==",
"$",
"status",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"transaction",
"->",
"getParent",
"(",
")",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"}",
"$",
"this",
"->",
"transaction",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"this",
"->",
"status",
"=",
"$",
"status",
";",
"}"
] |
Sets the result type
@param \Orkestra\Transactor\Entity\Result\ResultStatus $status
|
[
"Sets",
"the",
"result",
"type"
] |
0edaeb756f22c2d25d6fa2da4793df9b343f8811
|
https://github.com/orkestra/orkestra-transactor/blob/0edaeb756f22c2d25d6fa2da4793df9b343f8811/lib/Orkestra/Transactor/Entity/Result.php#L206-L221
|
239,520
|
gossi/trixionary
|
src/model/Map/GroupTableMap.php
|
GroupTableMap.doInsert
|
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from Group object
}
if ($criteria->containsKey(GroupTableMap::COL_ID) && $criteria->keyContainsValue(GroupTableMap::COL_ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::COL_ID.')');
}
// Set the correct dbName
$query = GroupQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
}
|
php
|
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from Group object
}
if ($criteria->containsKey(GroupTableMap::COL_ID) && $criteria->keyContainsValue(GroupTableMap::COL_ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::COL_ID.')');
}
// Set the correct dbName
$query = GroupQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
}
|
[
"public",
"static",
"function",
"doInsert",
"(",
"$",
"criteria",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"GroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"criteria",
"=",
"clone",
"$",
"criteria",
";",
"// rename for clarity",
"}",
"else",
"{",
"$",
"criteria",
"=",
"$",
"criteria",
"->",
"buildCriteria",
"(",
")",
";",
"// build Criteria from Group object",
"}",
"if",
"(",
"$",
"criteria",
"->",
"containsKey",
"(",
"GroupTableMap",
"::",
"COL_ID",
")",
"&&",
"$",
"criteria",
"->",
"keyContainsValue",
"(",
"GroupTableMap",
"::",
"COL_ID",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"GroupTableMap",
"::",
"COL_ID",
".",
"')'",
")",
";",
"}",
"// Set the correct dbName",
"$",
"query",
"=",
"GroupQuery",
"::",
"create",
"(",
")",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"// use transaction because $criteria could contain info",
"// for more than one table (I guess, conceivably)",
"return",
"$",
"con",
"->",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"con",
",",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"doInsert",
"(",
"$",
"con",
")",
";",
"}",
")",
";",
"}"
] |
Performs an INSERT on the database, given a Group or Criteria object.
@param mixed $criteria Criteria or Group object containing data that is used to create the INSERT statement.
@param ConnectionInterface $con the ConnectionInterface connection to use
@return mixed The new primary key.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException.
|
[
"Performs",
"an",
"INSERT",
"on",
"the",
"database",
"given",
"a",
"Group",
"or",
"Criteria",
"object",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/GroupTableMap.php#L447-L472
|
239,521
|
apitude/apitude
|
src/Email/EmailService.php
|
EmailService.queueEmail
|
public function queueEmail(
$type,
$to,
$fromEmail,
$fromName,
$subject,
$body = null,
$contentType = 'text/html',
$template = null,
$parameters = [],
$cc = [],
$bcc = [],
$delaySeconds = 0
) {
$payload = [
'to' => $to,
'fromName' => $fromName,
'fromEmail' => $fromEmail,
'subject' => $subject,
'cc' => $cc,
'bcc' => $bcc,
];
if ($type === self::SEND_TEMPLATE) {
$method = 'performSendTemplate';
$payload['template'] = $template;
$payload['parameters'] = $parameters;
} else {
$method = 'performSend';
$payload['body'] = $body;
$payload['contentType'] = $contentType;
}
return $this->addJob('email', $payload, self::class, $delaySeconds, $method);
}
|
php
|
public function queueEmail(
$type,
$to,
$fromEmail,
$fromName,
$subject,
$body = null,
$contentType = 'text/html',
$template = null,
$parameters = [],
$cc = [],
$bcc = [],
$delaySeconds = 0
) {
$payload = [
'to' => $to,
'fromName' => $fromName,
'fromEmail' => $fromEmail,
'subject' => $subject,
'cc' => $cc,
'bcc' => $bcc,
];
if ($type === self::SEND_TEMPLATE) {
$method = 'performSendTemplate';
$payload['template'] = $template;
$payload['parameters'] = $parameters;
} else {
$method = 'performSend';
$payload['body'] = $body;
$payload['contentType'] = $contentType;
}
return $this->addJob('email', $payload, self::class, $delaySeconds, $method);
}
|
[
"public",
"function",
"queueEmail",
"(",
"$",
"type",
",",
"$",
"to",
",",
"$",
"fromEmail",
",",
"$",
"fromName",
",",
"$",
"subject",
",",
"$",
"body",
"=",
"null",
",",
"$",
"contentType",
"=",
"'text/html'",
",",
"$",
"template",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"cc",
"=",
"[",
"]",
",",
"$",
"bcc",
"=",
"[",
"]",
",",
"$",
"delaySeconds",
"=",
"0",
")",
"{",
"$",
"payload",
"=",
"[",
"'to'",
"=>",
"$",
"to",
",",
"'fromName'",
"=>",
"$",
"fromName",
",",
"'fromEmail'",
"=>",
"$",
"fromEmail",
",",
"'subject'",
"=>",
"$",
"subject",
",",
"'cc'",
"=>",
"$",
"cc",
",",
"'bcc'",
"=>",
"$",
"bcc",
",",
"]",
";",
"if",
"(",
"$",
"type",
"===",
"self",
"::",
"SEND_TEMPLATE",
")",
"{",
"$",
"method",
"=",
"'performSendTemplate'",
";",
"$",
"payload",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"$",
"payload",
"[",
"'parameters'",
"]",
"=",
"$",
"parameters",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"'performSend'",
";",
"$",
"payload",
"[",
"'body'",
"]",
"=",
"$",
"body",
";",
"$",
"payload",
"[",
"'contentType'",
"]",
"=",
"$",
"contentType",
";",
"}",
"return",
"$",
"this",
"->",
"addJob",
"(",
"'email'",
",",
"$",
"payload",
",",
"self",
"::",
"class",
",",
"$",
"delaySeconds",
",",
"$",
"method",
")",
";",
"}"
] |
Queues an email to be sent
@param string $type (SEND_BODY|SEND_TEMPLATE)
@param array $to
@param string $fromEmail
@param string $fromName
@param string $subject
@param null|string $body
@param string $contentType
@param null|string $template
@param array $parameters
@param array $cc
@param array $bcc
@param int $delaySeconds
@return string
|
[
"Queues",
"an",
"email",
"to",
"be",
"sent"
] |
ccf503e42214184f96cd73b4e0fc5d06c377bce5
|
https://github.com/apitude/apitude/blob/ccf503e42214184f96cd73b4e0fc5d06c377bce5/src/Email/EmailService.php#L129-L163
|
239,522
|
sbruggmann/WebExcess.Flow.Backup
|
Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php
|
BackupCommandController.restoreCommand
|
public function restoreCommand($selectedBackup = null)
{
$this->initialize();
if (is_null($selectedBackup)) {
$availableVersions = $this->backupService->getAvailableVersions();
if ( count($availableVersions)<=0 ) {
$this->output->outputLine();
$this->output->outputLine('<b>You have no Backups!</b>');
$this->output->outputLine();
$this->output->outputLine('Call \'./flow backup:now\' and create one.');
$this->output->outputLine();
return;
}
$selectedBackup = $this->askWithSelectForVersion($availableVersions);
}
$this->backupService->restoreBackup($selectedBackup);
}
|
php
|
public function restoreCommand($selectedBackup = null)
{
$this->initialize();
if (is_null($selectedBackup)) {
$availableVersions = $this->backupService->getAvailableVersions();
if ( count($availableVersions)<=0 ) {
$this->output->outputLine();
$this->output->outputLine('<b>You have no Backups!</b>');
$this->output->outputLine();
$this->output->outputLine('Call \'./flow backup:now\' and create one.');
$this->output->outputLine();
return;
}
$selectedBackup = $this->askWithSelectForVersion($availableVersions);
}
$this->backupService->restoreBackup($selectedBackup);
}
|
[
"public",
"function",
"restoreCommand",
"(",
"$",
"selectedBackup",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"selectedBackup",
")",
")",
"{",
"$",
"availableVersions",
"=",
"$",
"this",
"->",
"backupService",
"->",
"getAvailableVersions",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"availableVersions",
")",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"'<b>You have no Backups!</b>'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"'Call \\'./flow backup:now\\' and create one.'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"return",
";",
"}",
"$",
"selectedBackup",
"=",
"$",
"this",
"->",
"askWithSelectForVersion",
"(",
"$",
"availableVersions",
")",
";",
"}",
"$",
"this",
"->",
"backupService",
"->",
"restoreBackup",
"(",
"$",
"selectedBackup",
")",
";",
"}"
] |
Select & restore a Backup
@param string $selectedBackup
@return void
|
[
"Select",
"&",
"restore",
"a",
"Backup"
] |
3165300c554da7ef9d67c4b5a7f1a22ba08035b4
|
https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L46-L66
|
239,523
|
sbruggmann/WebExcess.Flow.Backup
|
Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php
|
BackupCommandController.listCommand
|
public function listCommand()
{
$this->output->outputLine();
$this->output->outputLine('<b>Available Backups</b>');
$this->output->outputLine();
$this->output->outputLine('<b>Identifier Date Time</b>');
$this->initialize();
$availableVersions = $this->backupService->getAvailableVersions();
foreach ($availableVersions as $version) {
if ( is_numeric($version) ) {
$this->output->outputLine($version . ': ' . date('d.m.Y H:i', $version * 1));
}
}
$this->output->outputLine();
}
|
php
|
public function listCommand()
{
$this->output->outputLine();
$this->output->outputLine('<b>Available Backups</b>');
$this->output->outputLine();
$this->output->outputLine('<b>Identifier Date Time</b>');
$this->initialize();
$availableVersions = $this->backupService->getAvailableVersions();
foreach ($availableVersions as $version) {
if ( is_numeric($version) ) {
$this->output->outputLine($version . ': ' . date('d.m.Y H:i', $version * 1));
}
}
$this->output->outputLine();
}
|
[
"public",
"function",
"listCommand",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"'<b>Available Backups</b>'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"'<b>Identifier Date Time</b>'",
")",
";",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"availableVersions",
"=",
"$",
"this",
"->",
"backupService",
"->",
"getAvailableVersions",
"(",
")",
";",
"foreach",
"(",
"$",
"availableVersions",
"as",
"$",
"version",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"version",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"$",
"version",
".",
"': '",
".",
"date",
"(",
"'d.m.Y H:i'",
",",
"$",
"version",
"*",
"1",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"}"
] |
Show available Backups
@return void
|
[
"Show",
"available",
"Backups"
] |
3165300c554da7ef9d67c4b5a7f1a22ba08035b4
|
https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L84-L100
|
239,524
|
sbruggmann/WebExcess.Flow.Backup
|
Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php
|
BackupCommandController.clearCommand
|
public function clearCommand($force = null)
{
$this->initialize();
$this->backupService->removeAllBackups();
if ( $force===true ) {
$this->backupService->removeKeyfile();
}
}
|
php
|
public function clearCommand($force = null)
{
$this->initialize();
$this->backupService->removeAllBackups();
if ( $force===true ) {
$this->backupService->removeKeyfile();
}
}
|
[
"public",
"function",
"clearCommand",
"(",
"$",
"force",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"backupService",
"->",
"removeAllBackups",
"(",
")",
";",
"if",
"(",
"$",
"force",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"backupService",
"->",
"removeKeyfile",
"(",
")",
";",
"}",
"}"
] |
Remove all Backups
@param boolean $force
@return void
|
[
"Remove",
"all",
"Backups"
] |
3165300c554da7ef9d67c4b5a7f1a22ba08035b4
|
https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L108-L115
|
239,525
|
Jinxes/layton
|
Layton/Services/RouteService.php
|
RouteService.attach
|
public function attach($methods, $match, $callable)
{
if (is_string($methods)) {
$methods = [$methods];
}
$route = new Route($methods, $callable);
$this->storage[$match] = $route;
return $route;
}
|
php
|
public function attach($methods, $match, $callable)
{
if (is_string($methods)) {
$methods = [$methods];
}
$route = new Route($methods, $callable);
$this->storage[$match] = $route;
return $route;
}
|
[
"public",
"function",
"attach",
"(",
"$",
"methods",
",",
"$",
"match",
",",
"$",
"callable",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"methods",
")",
")",
"{",
"$",
"methods",
"=",
"[",
"$",
"methods",
"]",
";",
"}",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"methods",
",",
"$",
"callable",
")",
";",
"$",
"this",
"->",
"storage",
"[",
"$",
"match",
"]",
"=",
"$",
"route",
";",
"return",
"$",
"route",
";",
"}"
] |
Attach a route field to storage.
@param string $method Http method.
@param string $match
@param callback $callable
@return Route
|
[
"Attach",
"a",
"route",
"field",
"to",
"storage",
"."
] |
27b8eab2c59b9887eb93e40a533eb77cc5690584
|
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Services/RouteService.php#L36-L44
|
239,526
|
thecmsthread/classes
|
src/Services.php
|
Services.registerCoreClass
|
public static function registerCoreClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Core") === true) {
self::$core_class = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerCoreClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Core") === true) {
self::$core_class = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerCoreClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Core\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"core_class",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register a core framework class
@param string $class The class name being registered
@return bool
|
[
"Register",
"a",
"core",
"framework",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L70-L82
|
239,527
|
thecmsthread/classes
|
src/Services.php
|
Services.registerModulesClass
|
public static function registerModulesClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
self::$modules_class = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerModulesClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
self::$modules_class = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerModulesClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Modules\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"modules_class",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register a modules framework class
@param string $class The class name being registered
@return bool
|
[
"Register",
"a",
"modules",
"framework",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L101-L113
|
239,528
|
thecmsthread/classes
|
src/Services.php
|
Services.registerThemeClass
|
public static function registerThemeClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Theme") === true) {
self::$theme_class = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerThemeClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Theme") === true) {
self::$theme_class = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerThemeClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Theme\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"theme_class",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register a theme class
@param string $class The class name being registered
@return bool
|
[
"Register",
"a",
"theme",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L132-L144
|
239,529
|
thecmsthread/classes
|
src/Services.php
|
Services.registerPluginClass
|
public static function registerPluginClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$plugin_classes === null) {
self::$plugin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
self::$plugin_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerPluginClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$plugin_classes === null) {
self::$plugin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
self::$plugin_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerPluginClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"plugin_classes",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"plugin_classes",
"=",
"[",
"]",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Plugin\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"plugin_classes",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register a plugin class
@param string $name The name the class is registered under
@param string $class The class name
@return bool
|
[
"Register",
"a",
"plugin",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L164-L179
|
239,530
|
thecmsthread/classes
|
src/Services.php
|
Services.getPluginClass
|
public static function getPluginClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$plugin_classes[$name]) === false) {
$class = self::$plugin_classes[$name];
}
return $class;
}
|
php
|
public static function getPluginClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$plugin_classes[$name]) === false) {
$class = self::$plugin_classes[$name];
}
return $class;
}
|
[
"public",
"static",
"function",
"getPluginClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"plugin_classes",
"[",
"$",
"name",
"]",
")",
"===",
"false",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"$",
"plugin_classes",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Return a plugin class name registered under a given name
@param string $name The name the class is registered under
@return string
|
[
"Return",
"a",
"plugin",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L188-L195
|
239,531
|
thecmsthread/classes
|
src/Services.php
|
Services.registerExtensionClass
|
public static function registerExtensionClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$extension_classes === null) {
self::$extension_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
self::$extension_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerExtensionClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$extension_classes === null) {
self::$extension_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
self::$extension_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerExtensionClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"extension_classes",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"extension_classes",
"=",
"[",
"]",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Extension\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"extension_classes",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register an extension framework class
@param string $name The name the class is registered under
@param string $class The class name
@return bool
|
[
"Register",
"an",
"extension",
"framework",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L215-L230
|
239,532
|
thecmsthread/classes
|
src/Services.php
|
Services.getExtensionClass
|
public static function getExtensionClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$extension_classes[$name]) === false) {
$class = self::$extension_classes[$name];
}
return $class;
}
|
php
|
public static function getExtensionClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$extension_classes[$name]) === false) {
$class = self::$extension_classes[$name];
}
return $class;
}
|
[
"public",
"static",
"function",
"getExtensionClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"extension_classes",
"[",
"$",
"name",
"]",
")",
"===",
"false",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"$",
"extension_classes",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Return a extension framework class name registered under a given name
@param string $name The name the class is registered under
@return string
|
[
"Return",
"a",
"extension",
"framework",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L239-L246
|
239,533
|
thecmsthread/classes
|
src/Services.php
|
Services.registerAdminClass
|
public static function registerAdminClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$admin_classes === null) {
self::$admin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Admin") === true) {
self::$admin_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
php
|
public static function registerAdminClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$admin_classes === null) {
self::$admin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Admin") === true) {
self::$admin_classes[$name] = $class;
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"registerAdminClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"admin_classes",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"admin_classes",
"=",
"[",
"]",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"check",
"->",
"implementsInterface",
"(",
"\"TheCMSThread\\\\Classes\\\\Admin\"",
")",
"===",
"true",
")",
"{",
"self",
"::",
"$",
"admin_classes",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Register an admin class
@param string $name The name the class is registered under
@param string $class The class name
@return bool
|
[
"Register",
"an",
"admin",
"class"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L266-L281
|
239,534
|
thecmsthread/classes
|
src/Services.php
|
Services.getAdminClass
|
public static function getAdminClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$admin_classes[$name]) === false) {
$class = self::$admin_classes[$name];
}
return $class;
}
|
php
|
public static function getAdminClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$admin_classes[$name]) === false) {
$class = self::$admin_classes[$name];
}
return $class;
}
|
[
"public",
"static",
"function",
"getAdminClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"admin_classes",
"[",
"$",
"name",
"]",
")",
"===",
"false",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"$",
"admin_classes",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Return a admin class name registered under a given name
@param string $name The name the class is registered under
@return string
|
[
"Return",
"a",
"admin",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] |
d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c
|
https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L290-L297
|
239,535
|
vinala/kernel
|
src/Event/Event.php
|
Event.register
|
public static function register()
{
$namespace = "Vinala\App\Events";
foreach (get_declared_classes() as $value) {
if (Strings::contains($value, $namespace)) {
$name = self::getName($value);
$events = $value::getEvents();
if (!is_null($events)) {
foreach ($events as $key => $value) {
$data[$name.'.'.$key] = $value;
}
}
self::$listners = array_collapse([$data, self::$listners]);
}
}
}
|
php
|
public static function register()
{
$namespace = "Vinala\App\Events";
foreach (get_declared_classes() as $value) {
if (Strings::contains($value, $namespace)) {
$name = self::getName($value);
$events = $value::getEvents();
if (!is_null($events)) {
foreach ($events as $key => $value) {
$data[$name.'.'.$key] = $value;
}
}
self::$listners = array_collapse([$data, self::$listners]);
}
}
}
|
[
"public",
"static",
"function",
"register",
"(",
")",
"{",
"$",
"namespace",
"=",
"\"Vinala\\App\\Events\"",
";",
"foreach",
"(",
"get_declared_classes",
"(",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"Strings",
"::",
"contains",
"(",
"$",
"value",
",",
"$",
"namespace",
")",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"getName",
"(",
"$",
"value",
")",
";",
"$",
"events",
"=",
"$",
"value",
"::",
"getEvents",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"events",
")",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"name",
".",
"'.'",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"self",
"::",
"$",
"listners",
"=",
"array_collapse",
"(",
"[",
"$",
"data",
",",
"self",
"::",
"$",
"listners",
"]",
")",
";",
"}",
"}",
"}"
] |
Register all listners.
@return null
|
[
"Register",
"all",
"listners",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L22-L41
|
239,536
|
vinala/kernel
|
src/Event/Event.php
|
Event.trigger
|
public static function trigger()
{
$args = func_get_args();
//Check if trigger have parrams
$haveParams = count($args) > 1 ? true : false;
//Get events
$events = self::splite($args[0]);
if ($haveParams && count($events) > 1) {
throw new ManyListenersArgumentsException();
}
if (count($events) > 1) {
self::runMany($events);
} elseif (count($events) == 1) {
self::runOne($events, array_except($args, 0));
}
return true;
}
|
php
|
public static function trigger()
{
$args = func_get_args();
//Check if trigger have parrams
$haveParams = count($args) > 1 ? true : false;
//Get events
$events = self::splite($args[0]);
if ($haveParams && count($events) > 1) {
throw new ManyListenersArgumentsException();
}
if (count($events) > 1) {
self::runMany($events);
} elseif (count($events) == 1) {
self::runOne($events, array_except($args, 0));
}
return true;
}
|
[
"public",
"static",
"function",
"trigger",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"//Check if trigger have parrams",
"$",
"haveParams",
"=",
"count",
"(",
"$",
"args",
")",
">",
"1",
"?",
"true",
":",
"false",
";",
"//Get events",
"$",
"events",
"=",
"self",
"::",
"splite",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"haveParams",
"&&",
"count",
"(",
"$",
"events",
")",
">",
"1",
")",
"{",
"throw",
"new",
"ManyListenersArgumentsException",
"(",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"events",
")",
">",
"1",
")",
"{",
"self",
"::",
"runMany",
"(",
"$",
"events",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"events",
")",
"==",
"1",
")",
"{",
"self",
"::",
"runOne",
"(",
"$",
"events",
",",
"array_except",
"(",
"$",
"args",
",",
"0",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Fire a trigger.
@param
@param
@return
|
[
"Fire",
"a",
"trigger",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L65-L86
|
239,537
|
vinala/kernel
|
src/Event/Event.php
|
Event.splite
|
protected static function splite($pattern)
{
if (is_array($pattern)) {
$events = [];
foreach ($pattern as $value) {
$events = array_collapse([$events, self::extract($value)]);
}
return $events;
} elseif (is_string($pattern)) {
return self::extract($pattern);
}
}
|
php
|
protected static function splite($pattern)
{
if (is_array($pattern)) {
$events = [];
foreach ($pattern as $value) {
$events = array_collapse([$events, self::extract($value)]);
}
return $events;
} elseif (is_string($pattern)) {
return self::extract($pattern);
}
}
|
[
"protected",
"static",
"function",
"splite",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pattern",
")",
")",
"{",
"$",
"events",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pattern",
"as",
"$",
"value",
")",
"{",
"$",
"events",
"=",
"array_collapse",
"(",
"[",
"$",
"events",
",",
"self",
"::",
"extract",
"(",
"$",
"value",
")",
"]",
")",
";",
"}",
"return",
"$",
"events",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"pattern",
")",
")",
"{",
"return",
"self",
"::",
"extract",
"(",
"$",
"pattern",
")",
";",
"}",
"}"
] |
Get events from event pattern.
@param mixed $pattern
@return array
|
[
"Get",
"events",
"from",
"event",
"pattern",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L95-L108
|
239,538
|
vinala/kernel
|
src/Event/Event.php
|
Event.extract
|
protected static function extract($pattern)
{
if (str_contains($pattern, '|')) {
$segements = explode('|', $pattern);
$events[$segements[0]] = explode('.', $segements[1]);
} else {
$segements = explode('.', $pattern);
$events[$segements[0]] = $segements[1];
}
return $events;
}
|
php
|
protected static function extract($pattern)
{
if (str_contains($pattern, '|')) {
$segements = explode('|', $pattern);
$events[$segements[0]] = explode('.', $segements[1]);
} else {
$segements = explode('.', $pattern);
$events[$segements[0]] = $segements[1];
}
return $events;
}
|
[
"protected",
"static",
"function",
"extract",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"pattern",
",",
"'|'",
")",
")",
"{",
"$",
"segements",
"=",
"explode",
"(",
"'|'",
",",
"$",
"pattern",
")",
";",
"$",
"events",
"[",
"$",
"segements",
"[",
"0",
"]",
"]",
"=",
"explode",
"(",
"'.'",
",",
"$",
"segements",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"segements",
"=",
"explode",
"(",
"'.'",
",",
"$",
"pattern",
")",
";",
"$",
"events",
"[",
"$",
"segements",
"[",
"0",
"]",
"]",
"=",
"$",
"segements",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"events",
";",
"}"
] |
Extract events from string pattern.
@param string $pattern
@return array
|
[
"Extract",
"events",
"from",
"string",
"pattern",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L117-L130
|
239,539
|
vinala/kernel
|
src/Event/Event.php
|
Event.runMany
|
public static function runMany($events)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
if (is_array($value)) {
foreach ($value as $function) {
$function = self::$listners[$key.'.'.$function];
$object->$function();
}
} elseif (is_string($value)) {
$function = self::$listners[$key.'.'.$value];
$object->$function();
}
}
return true;
}
|
php
|
public static function runMany($events)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
if (is_array($value)) {
foreach ($value as $function) {
$function = self::$listners[$key.'.'.$function];
$object->$function();
}
} elseif (is_string($value)) {
$function = self::$listners[$key.'.'.$value];
$object->$function();
}
}
return true;
}
|
[
"public",
"static",
"function",
"runMany",
"(",
"$",
"events",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'\\Vinala\\App\\Events\\\\'",
".",
"$",
"key",
";",
"$",
"object",
"=",
"new",
"$",
"name",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"function",
")",
"{",
"$",
"function",
"=",
"self",
"::",
"$",
"listners",
"[",
"$",
"key",
".",
"'.'",
".",
"$",
"function",
"]",
";",
"$",
"object",
"->",
"$",
"function",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"function",
"=",
"self",
"::",
"$",
"listners",
"[",
"$",
"key",
".",
"'.'",
".",
"$",
"value",
"]",
";",
"$",
"object",
"->",
"$",
"function",
"(",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Run and execute many events trigger.
@param array $events
@return bool
|
[
"Run",
"and",
"execute",
"many",
"events",
"trigger",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L139-L160
|
239,540
|
vinala/kernel
|
src/Event/Event.php
|
Event.runOne
|
public static function runOne($events, $args)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
$function = self::$listners[$key.'.'.$value];
call_user_func_array([$object, $function], $args);
}
return true;
}
|
php
|
public static function runOne($events, $args)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
$function = self::$listners[$key.'.'.$value];
call_user_func_array([$object, $function], $args);
}
return true;
}
|
[
"public",
"static",
"function",
"runOne",
"(",
"$",
"events",
",",
"$",
"args",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'\\Vinala\\App\\Events\\\\'",
".",
"$",
"key",
";",
"$",
"object",
"=",
"new",
"$",
"name",
"(",
")",
";",
"$",
"function",
"=",
"self",
"::",
"$",
"listners",
"[",
"$",
"key",
".",
"'.'",
".",
"$",
"value",
"]",
";",
"call_user_func_array",
"(",
"[",
"$",
"object",
",",
"$",
"function",
"]",
",",
"$",
"args",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Run and execute one event trigger.
@param array $events
@return bool
|
[
"Run",
"and",
"execute",
"one",
"event",
"trigger",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L169-L182
|
239,541
|
mszewcz/php-light-framework
|
src/Log/Backend/Filesystem.php
|
Filesystem.rawLog
|
public function rawLog(string $type = '', string $message = '', ?string $source = null, ?string $excp = null): bool
{
$src = $source !== null
? \sprintf('[%s] ', \is_object($source) ? '\\'.\get_class($source) : (string)$source)
: '';
$exc = $excp !== null && ($excp instanceof \Exception) ? \sprintf('[Ex: %s] ', $excp->getMessage()) : '';
$exc = \str_replace(["\r", "\n", "\t"], '', $exc);
$msg = \sprintf('%s %s %s%s%s%s', \date('d-m-Y H:i:s'), $type, $src, $exc, $message, Tags::CRLF);
return File::append($this->logFile, $msg);
}
|
php
|
public function rawLog(string $type = '', string $message = '', ?string $source = null, ?string $excp = null): bool
{
$src = $source !== null
? \sprintf('[%s] ', \is_object($source) ? '\\'.\get_class($source) : (string)$source)
: '';
$exc = $excp !== null && ($excp instanceof \Exception) ? \sprintf('[Ex: %s] ', $excp->getMessage()) : '';
$exc = \str_replace(["\r", "\n", "\t"], '', $exc);
$msg = \sprintf('%s %s %s%s%s%s', \date('d-m-Y H:i:s'), $type, $src, $exc, $message, Tags::CRLF);
return File::append($this->logFile, $msg);
}
|
[
"public",
"function",
"rawLog",
"(",
"string",
"$",
"type",
"=",
"''",
",",
"string",
"$",
"message",
"=",
"''",
",",
"?",
"string",
"$",
"source",
"=",
"null",
",",
"?",
"string",
"$",
"excp",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"src",
"=",
"$",
"source",
"!==",
"null",
"?",
"\\",
"sprintf",
"(",
"'[%s] '",
",",
"\\",
"is_object",
"(",
"$",
"source",
")",
"?",
"'\\\\'",
".",
"\\",
"get_class",
"(",
"$",
"source",
")",
":",
"(",
"string",
")",
"$",
"source",
")",
":",
"''",
";",
"$",
"exc",
"=",
"$",
"excp",
"!==",
"null",
"&&",
"(",
"$",
"excp",
"instanceof",
"\\",
"Exception",
")",
"?",
"\\",
"sprintf",
"(",
"'[Ex: %s] '",
",",
"$",
"excp",
"->",
"getMessage",
"(",
")",
")",
":",
"''",
";",
"$",
"exc",
"=",
"\\",
"str_replace",
"(",
"[",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
"]",
",",
"''",
",",
"$",
"exc",
")",
";",
"$",
"msg",
"=",
"\\",
"sprintf",
"(",
"'%s %s %s%s%s%s'",
",",
"\\",
"date",
"(",
"'d-m-Y H:i:s'",
")",
",",
"$",
"type",
",",
"$",
"src",
",",
"$",
"exc",
",",
"$",
"message",
",",
"Tags",
"::",
"CRLF",
")",
";",
"return",
"File",
"::",
"append",
"(",
"$",
"this",
"->",
"logFile",
",",
"$",
"msg",
")",
";",
"}"
] |
Logs message to file
@param string $type
@param string $message
@param null|string $source
@param null|string $excp
@return bool
|
[
"Logs",
"message",
"to",
"file"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Log/Backend/Filesystem.php#L50-L60
|
239,542
|
mszewcz/php-light-framework
|
src/Log/Backend/Filesystem.php
|
Filesystem.logDebug
|
public function logDebug(string $message = '', ?string $source = null, ?string $exception = null): bool
{
$ret = false;
if ($this->logLevel & Log::LOG_DEBUG) {
$ret = $this->rawLog('[ DEBUG]', $message, $source, $exception);
}
return $ret;
}
|
php
|
public function logDebug(string $message = '', ?string $source = null, ?string $exception = null): bool
{
$ret = false;
if ($this->logLevel & Log::LOG_DEBUG) {
$ret = $this->rawLog('[ DEBUG]', $message, $source, $exception);
}
return $ret;
}
|
[
"public",
"function",
"logDebug",
"(",
"string",
"$",
"message",
"=",
"''",
",",
"?",
"string",
"$",
"source",
"=",
"null",
",",
"?",
"string",
"$",
"exception",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"ret",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"logLevel",
"&",
"Log",
"::",
"LOG_DEBUG",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"rawLog",
"(",
"'[ DEBUG]'",
",",
"$",
"message",
",",
"$",
"source",
",",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Logs debug information
@param string $message
@param null|string $source
@param null|string $exception
@return bool
|
[
"Logs",
"debug",
"information"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Log/Backend/Filesystem.php#L70-L77
|
239,543
|
vpg/titon.common
|
src/Titon/Common/Augment/InfoAugment.php
|
InfoAugment.methods
|
public function methods() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicMethods(),
$this->protectedMethods(),
$this->privateMethods(),
$this->staticMethods()
));
});
}
|
php
|
public function methods() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicMethods(),
$this->protectedMethods(),
$this->privateMethods(),
$this->staticMethods()
));
});
}
|
[
"public",
"function",
"methods",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"return",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"publicMethods",
"(",
")",
",",
"$",
"this",
"->",
"protectedMethods",
"(",
")",
",",
"$",
"this",
"->",
"privateMethods",
"(",
")",
",",
"$",
"this",
"->",
"staticMethods",
"(",
")",
")",
")",
";",
"}",
")",
";",
"}"
] |
Return an array of public, protected, private and static methods.
@return string[]
|
[
"Return",
"an",
"array",
"of",
"public",
"protected",
"private",
"and",
"static",
"methods",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L118-L127
|
239,544
|
vpg/titon.common
|
src/Titon/Common/Augment/InfoAugment.php
|
InfoAugment.properties
|
public function properties() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicProperties(),
$this->protectedProperties(),
$this->privateProperties(),
$this->staticProperties()
));
});
}
|
php
|
public function properties() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicProperties(),
$this->protectedProperties(),
$this->privateProperties(),
$this->staticProperties()
));
});
}
|
[
"public",
"function",
"properties",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"return",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"publicProperties",
"(",
")",
",",
"$",
"this",
"->",
"protectedProperties",
"(",
")",
",",
"$",
"this",
"->",
"privateProperties",
"(",
")",
",",
"$",
"this",
"->",
"staticProperties",
"(",
")",
")",
")",
";",
"}",
")",
";",
"}"
] |
Return an array of public, protected, private and static properties.
@return string[]
|
[
"Return",
"an",
"array",
"of",
"public",
"protected",
"private",
"and",
"static",
"properties",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L170-L179
|
239,545
|
vpg/titon.common
|
src/Titon/Common/Augment/InfoAugment.php
|
InfoAugment.traits
|
public function traits() {
$traits = $this->reflection()->getTraitNames();
$parent = get_parent_class($this->_class);
while ($parent) {
$traits = array_merge($traits, class_uses($parent));
$parent = get_parent_class($parent);
}
return array_values($traits);
}
|
php
|
public function traits() {
$traits = $this->reflection()->getTraitNames();
$parent = get_parent_class($this->_class);
while ($parent) {
$traits = array_merge($traits, class_uses($parent));
$parent = get_parent_class($parent);
}
return array_values($traits);
}
|
[
"public",
"function",
"traits",
"(",
")",
"{",
"$",
"traits",
"=",
"$",
"this",
"->",
"reflection",
"(",
")",
"->",
"getTraitNames",
"(",
")",
";",
"$",
"parent",
"=",
"get_parent_class",
"(",
"$",
"this",
"->",
"_class",
")",
";",
"while",
"(",
"$",
"parent",
")",
"{",
"$",
"traits",
"=",
"array_merge",
"(",
"$",
"traits",
",",
"class_uses",
"(",
"$",
"parent",
")",
")",
";",
"$",
"parent",
"=",
"get_parent_class",
"(",
"$",
"parent",
")",
";",
"}",
"return",
"array_values",
"(",
"$",
"traits",
")",
";",
"}"
] |
Return an array of traits that the class implements.
@return string[]
|
[
"Return",
"an",
"array",
"of",
"traits",
"that",
"the",
"class",
"implements",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L240-L250
|
239,546
|
vpg/titon.common
|
src/Titon/Common/Augment/InfoAugment.php
|
InfoAugment._methods
|
protected function _methods($key, $scope) {
return $this->cache($key, function() use ($scope) {
$methods = [];
foreach ($this->reflection()->getMethods($scope) as $method) {
$methods[] = $method->getName();
}
return $methods;
});
}
|
php
|
protected function _methods($key, $scope) {
return $this->cache($key, function() use ($scope) {
$methods = [];
foreach ($this->reflection()->getMethods($scope) as $method) {
$methods[] = $method->getName();
}
return $methods;
});
}
|
[
"protected",
"function",
"_methods",
"(",
"$",
"key",
",",
"$",
"scope",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"$",
"key",
",",
"function",
"(",
")",
"use",
"(",
"$",
"scope",
")",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"reflection",
"(",
")",
"->",
"getMethods",
"(",
"$",
"scope",
")",
"as",
"$",
"method",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"}",
"return",
"$",
"methods",
";",
"}",
")",
";",
"}"
] |
Return an array of methods for the defined scope.
@param string $key
@param int $scope
@return string[]
|
[
"Return",
"an",
"array",
"of",
"methods",
"for",
"the",
"defined",
"scope",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L268-L278
|
239,547
|
vpg/titon.common
|
src/Titon/Common/Augment/InfoAugment.php
|
InfoAugment._properties
|
protected function _properties($key, $scope) {
return $this->cache($key, function() use ($scope) {
$props = [];
foreach ($this->reflection()->getProperties($scope) as $prop) {
$props[] = $prop->getName();
}
return $props;
});
}
|
php
|
protected function _properties($key, $scope) {
return $this->cache($key, function() use ($scope) {
$props = [];
foreach ($this->reflection()->getProperties($scope) as $prop) {
$props[] = $prop->getName();
}
return $props;
});
}
|
[
"protected",
"function",
"_properties",
"(",
"$",
"key",
",",
"$",
"scope",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"$",
"key",
",",
"function",
"(",
")",
"use",
"(",
"$",
"scope",
")",
"{",
"$",
"props",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"reflection",
"(",
")",
"->",
"getProperties",
"(",
"$",
"scope",
")",
"as",
"$",
"prop",
")",
"{",
"$",
"props",
"[",
"]",
"=",
"$",
"prop",
"->",
"getName",
"(",
")",
";",
"}",
"return",
"$",
"props",
";",
"}",
")",
";",
"}"
] |
Return an array of properties for the defined scope.
@param string $key
@param int $scope
@return string[]
|
[
"Return",
"an",
"array",
"of",
"properties",
"for",
"the",
"defined",
"scope",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L287-L297
|
239,548
|
indigophp/indigo-skeleton
|
classes/Controller.php
|
Controller.check_access
|
protected function check_access($action = null)
{
is_null($action) and $action = $this->request->action;
if ($this->has_access($action) === false)
{
$context = array(
'form' => array(
'%action%' => $action,
'%items%' => $this->get_name(999),
)
);
\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);
return \Response::redirect_back(\Uri::admin(false));
}
}
|
php
|
protected function check_access($action = null)
{
is_null($action) and $action = $this->request->action;
if ($this->has_access($action) === false)
{
$context = array(
'form' => array(
'%action%' => $action,
'%items%' => $this->get_name(999),
)
);
\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);
return \Response::redirect_back(\Uri::admin(false));
}
}
|
[
"protected",
"function",
"check_access",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"is_null",
"(",
"$",
"action",
")",
"and",
"$",
"action",
"=",
"$",
"this",
"->",
"request",
"->",
"action",
";",
"if",
"(",
"$",
"this",
"->",
"has_access",
"(",
"$",
"action",
")",
"===",
"false",
")",
"{",
"$",
"context",
"=",
"array",
"(",
"'form'",
"=>",
"array",
"(",
"'%action%'",
"=>",
"$",
"action",
",",
"'%items%'",
"=>",
"$",
"this",
"->",
"get_name",
"(",
"999",
")",
",",
")",
")",
";",
"\\",
"Logger",
"::",
"instance",
"(",
"'alert'",
")",
"->",
"error",
"(",
"gettext",
"(",
"'You are not authorized to %action% %items%.'",
")",
",",
"$",
"context",
")",
";",
"return",
"\\",
"Response",
"::",
"redirect_back",
"(",
"\\",
"Uri",
"::",
"admin",
"(",
"false",
")",
")",
";",
"}",
"}"
] |
Checks whether user has access to an action
|
[
"Checks",
"whether",
"user",
"has",
"access",
"to",
"an",
"action"
] |
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
|
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L83-L100
|
239,549
|
indigophp/indigo-skeleton
|
classes/Controller.php
|
Controller.find
|
protected function find($id = null)
{
$query = $this->query();
$query->where('id', $id);
if (is_null($id) or is_null($model = $query->get_one()))
{
throw new \HttpNotFoundException();
}
return $model;
}
|
php
|
protected function find($id = null)
{
$query = $this->query();
$query->where('id', $id);
if (is_null($id) or is_null($model = $query->get_one()))
{
throw new \HttpNotFoundException();
}
return $model;
}
|
[
"protected",
"function",
"find",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"id",
")",
"or",
"is_null",
"(",
"$",
"model",
"=",
"$",
"query",
"->",
"get_one",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"HttpNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] |
Finds an entity of model
@param integer $id
@return Model
|
[
"Finds",
"an",
"entity",
"of",
"model"
] |
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
|
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L147-L158
|
239,550
|
indigophp/indigo-skeleton
|
classes/Controller.php
|
Controller.forge
|
protected function forge($data = [], $new = true, $view = null, $cache = true)
{
return call_user_func([$this->get_model(), 'forge'], $data, $new, $view, $cache);
}
|
php
|
protected function forge($data = [], $new = true, $view = null, $cache = true)
{
return call_user_func([$this->get_model(), 'forge'], $data, $new, $view, $cache);
}
|
[
"protected",
"function",
"forge",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"new",
"=",
"true",
",",
"$",
"view",
"=",
"null",
",",
"$",
"cache",
"=",
"true",
")",
"{",
"return",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"get_model",
"(",
")",
",",
"'forge'",
"]",
",",
"$",
"data",
",",
"$",
"new",
",",
"$",
"view",
",",
"$",
"cache",
")",
";",
"}"
] |
Forge a new Model
@see Model::forge
@return Model
|
[
"Forge",
"a",
"new",
"Model"
] |
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
|
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L167-L170
|
239,551
|
vinala/kernel
|
src/Processes/Exception.php
|
Exception.create
|
public static function create($name, $message, $view)
{
$root = Process::root;
$name = ucfirst($name);
$path = $root."app/exceptions/$name.php";
//
if (!File::exists($path)) {
File::put($path, self::set($name, $message, $view));
return true;
} else {
return false;
}
}
|
php
|
public static function create($name, $message, $view)
{
$root = Process::root;
$name = ucfirst($name);
$path = $root."app/exceptions/$name.php";
//
if (!File::exists($path)) {
File::put($path, self::set($name, $message, $view));
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"message",
",",
"$",
"view",
")",
"{",
"$",
"root",
"=",
"Process",
"::",
"root",
";",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"name",
")",
";",
"$",
"path",
"=",
"$",
"root",
".",
"\"app/exceptions/$name.php\"",
";",
"//",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"File",
"::",
"put",
"(",
"$",
"path",
",",
"self",
"::",
"set",
"(",
"$",
"name",
",",
"$",
"message",
",",
"$",
"view",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Create exception.
@param string $name
@param string $message
@param string $view
@return bool
|
[
"Create",
"exception",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Exception.php#L22-L36
|
239,552
|
LasseHaslev/api-response
|
src/Transformers/TransformerTrait.php
|
TransformerTrait.includeDefaultIncludes
|
protected function includeDefaultIncludes($model, $data)
{
// Create an return array
$returnData = [];
// If we have default includes
if ( ! empty( $this->defaultIncludes ) ) {
// Loop through all includes
foreach ($this->defaultIncludes as $include) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
// Return data
return array_merge( $data, $returnData );
}
|
php
|
protected function includeDefaultIncludes($model, $data)
{
// Create an return array
$returnData = [];
// If we have default includes
if ( ! empty( $this->defaultIncludes ) ) {
// Loop through all includes
foreach ($this->defaultIncludes as $include) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
// Return data
return array_merge( $data, $returnData );
}
|
[
"protected",
"function",
"includeDefaultIncludes",
"(",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// Create an return array",
"$",
"returnData",
"=",
"[",
"]",
";",
"// If we have default includes",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"defaultIncludes",
")",
")",
"{",
"// Loop through all includes",
"foreach",
"(",
"$",
"this",
"->",
"defaultIncludes",
"as",
"$",
"include",
")",
"{",
"// Add the new data",
"$",
"returnData",
"[",
"$",
"include",
"]",
"=",
"$",
"this",
"->",
"includeByName",
"(",
"$",
"include",
",",
"$",
"model",
")",
";",
"}",
"}",
"// Return data",
"return",
"array_merge",
"(",
"$",
"data",
",",
"$",
"returnData",
")",
";",
"}"
] |
Include default includes
@return Array
|
[
"Include",
"default",
"includes"
] |
323be67cb1013d7ef73b8175a139f3e5937fa90f
|
https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L115-L135
|
239,553
|
LasseHaslev/api-response
|
src/Transformers/TransformerTrait.php
|
TransformerTrait.includeAvailableIncludes
|
protected function includeAvailableIncludes($model, $data )
{
// Get available includes from url parameters
$includes = $this->getAvailableIncludesFromUrlParameters();
// Create an return array
$returnData = [];
// Check if we have includes and include parameter values
if ( ! empty( $includes ) && ! empty( $this->availableIncludes ) ) {
// Loop through all includes
foreach ($this->availableIncludes as $include) {
// If the words exists in both includes
if ( in_array( $include, $includes ) ) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
}
// Return data
return array_merge( $data, $returnData );
}
|
php
|
protected function includeAvailableIncludes($model, $data )
{
// Get available includes from url parameters
$includes = $this->getAvailableIncludesFromUrlParameters();
// Create an return array
$returnData = [];
// Check if we have includes and include parameter values
if ( ! empty( $includes ) && ! empty( $this->availableIncludes ) ) {
// Loop through all includes
foreach ($this->availableIncludes as $include) {
// If the words exists in both includes
if ( in_array( $include, $includes ) ) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
}
// Return data
return array_merge( $data, $returnData );
}
|
[
"protected",
"function",
"includeAvailableIncludes",
"(",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// Get available includes from url parameters",
"$",
"includes",
"=",
"$",
"this",
"->",
"getAvailableIncludesFromUrlParameters",
"(",
")",
";",
"// Create an return array",
"$",
"returnData",
"=",
"[",
"]",
";",
"// Check if we have includes and include parameter values",
"if",
"(",
"!",
"empty",
"(",
"$",
"includes",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"availableIncludes",
")",
")",
"{",
"// Loop through all includes",
"foreach",
"(",
"$",
"this",
"->",
"availableIncludes",
"as",
"$",
"include",
")",
"{",
"// If the words exists in both includes",
"if",
"(",
"in_array",
"(",
"$",
"include",
",",
"$",
"includes",
")",
")",
"{",
"// Add the new data",
"$",
"returnData",
"[",
"$",
"include",
"]",
"=",
"$",
"this",
"->",
"includeByName",
"(",
"$",
"include",
",",
"$",
"model",
")",
";",
"}",
"}",
"}",
"// Return data",
"return",
"array_merge",
"(",
"$",
"data",
",",
"$",
"returnData",
")",
";",
"}"
] |
Include available includes
@return Array
|
[
"Include",
"available",
"includes"
] |
323be67cb1013d7ef73b8175a139f3e5937fa90f
|
https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L142-L169
|
239,554
|
LasseHaslev/api-response
|
src/Transformers/TransformerTrait.php
|
TransformerTrait.includeByName
|
protected function includeByName( $name, $model )
{
$functionName = sprintf( 'include%s', ucfirst( $name ) );
if ( ! method_exists( static::class, $functionName ) ) {
throw new \Exception(sprintf( 'The function name "%s" does not exists on %s', $functionName, static::class ));
}
return $this->{$functionName}( $model );
}
|
php
|
protected function includeByName( $name, $model )
{
$functionName = sprintf( 'include%s', ucfirst( $name ) );
if ( ! method_exists( static::class, $functionName ) ) {
throw new \Exception(sprintf( 'The function name "%s" does not exists on %s', $functionName, static::class ));
}
return $this->{$functionName}( $model );
}
|
[
"protected",
"function",
"includeByName",
"(",
"$",
"name",
",",
"$",
"model",
")",
"{",
"$",
"functionName",
"=",
"sprintf",
"(",
"'include%s'",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"static",
"::",
"class",
",",
"$",
"functionName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The function name \"%s\" does not exists on %s'",
",",
"$",
"functionName",
",",
"static",
"::",
"class",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"{",
"$",
"functionName",
"}",
"(",
"$",
"model",
")",
";",
"}"
] |
Call the include function thats equal to the name
@return Array
|
[
"Call",
"the",
"include",
"function",
"thats",
"equal",
"to",
"the",
"name"
] |
323be67cb1013d7ef73b8175a139f3e5937fa90f
|
https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L176-L187
|
239,555
|
factorio-item-browser/api-database
|
src/Repository/IconFileRepository.php
|
IconFileRepository.findByHashes
|
public function findByHashes(array $hashes): array
{
$result = [];
if (count($hashes) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if')
->from(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values(array_map('hex2bin', $hashes)));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
}
|
php
|
public function findByHashes(array $hashes): array
{
$result = [];
if (count($hashes) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if')
->from(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values(array_map('hex2bin', $hashes)));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
}
|
[
"public",
"function",
"findByHashes",
"(",
"array",
"$",
"hashes",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"hashes",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'if'",
")",
"->",
"from",
"(",
"IconFile",
"::",
"class",
",",
"'if'",
")",
"->",
"andWhere",
"(",
"'if.hash IN (:hashes)'",
")",
"->",
"setParameter",
"(",
"'hashes'",
",",
"array_values",
"(",
"array_map",
"(",
"'hex2bin'",
",",
"$",
"hashes",
")",
")",
")",
";",
"$",
"result",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Finds the icon files with the specified hashes.
@param array|string[] $hashes
@return array|IconFile[]
|
[
"Finds",
"the",
"icon",
"files",
"with",
"the",
"specified",
"hashes",
"."
] |
c3a27e5673462a58b5afafc0ea0e0002f6db9803
|
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L22-L35
|
239,556
|
factorio-item-browser/api-database
|
src/Repository/IconFileRepository.php
|
IconFileRepository.removeOrphans
|
public function removeOrphans(): void
{
$hashes = $this->findOrphanedHashes();
if (count($hashes) > 0) {
$this->removeHashes($hashes);
}
}
|
php
|
public function removeOrphans(): void
{
$hashes = $this->findOrphanedHashes();
if (count($hashes) > 0) {
$this->removeHashes($hashes);
}
}
|
[
"public",
"function",
"removeOrphans",
"(",
")",
":",
"void",
"{",
"$",
"hashes",
"=",
"$",
"this",
"->",
"findOrphanedHashes",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"hashes",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"removeHashes",
"(",
"$",
"hashes",
")",
";",
"}",
"}"
] |
Removes any orphaned icon files, i.e. icon files no longer used by any icon.
|
[
"Removes",
"any",
"orphaned",
"icon",
"files",
"i",
".",
"e",
".",
"icon",
"files",
"no",
"longer",
"used",
"by",
"any",
"icon",
"."
] |
c3a27e5673462a58b5afafc0ea0e0002f6db9803
|
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L40-L46
|
239,557
|
factorio-item-browser/api-database
|
src/Repository/IconFileRepository.php
|
IconFileRepository.findOrphanedHashes
|
protected function findOrphanedHashes(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if.hash AS hash')
->from(IconFile::class, 'if')
->leftJoin('if.icons', 'i')
->andWhere('i.id IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = $data['hash'];
}
return $result;
}
|
php
|
protected function findOrphanedHashes(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if.hash AS hash')
->from(IconFile::class, 'if')
->leftJoin('if.icons', 'i')
->andWhere('i.id IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = $data['hash'];
}
return $result;
}
|
[
"protected",
"function",
"findOrphanedHashes",
"(",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'if.hash AS hash'",
")",
"->",
"from",
"(",
"IconFile",
"::",
"class",
",",
"'if'",
")",
"->",
"leftJoin",
"(",
"'if.icons'",
",",
"'i'",
")",
"->",
"andWhere",
"(",
"'i.id IS NULL'",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
"as",
"$",
"data",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"data",
"[",
"'hash'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the hashes of orphaned icon files, which are no longer used by any icon.
@return array|string[]
|
[
"Returns",
"the",
"hashes",
"of",
"orphaned",
"icon",
"files",
"which",
"are",
"no",
"longer",
"used",
"by",
"any",
"icon",
"."
] |
c3a27e5673462a58b5afafc0ea0e0002f6db9803
|
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L52-L65
|
239,558
|
factorio-item-browser/api-database
|
src/Repository/IconFileRepository.php
|
IconFileRepository.removeHashes
|
protected function removeHashes(array $hashes): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values($hashes));
$queryBuilder->getQuery()->execute();
}
|
php
|
protected function removeHashes(array $hashes): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values($hashes));
$queryBuilder->getQuery()->execute();
}
|
[
"protected",
"function",
"removeHashes",
"(",
"array",
"$",
"hashes",
")",
":",
"void",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"delete",
"(",
"IconFile",
"::",
"class",
",",
"'if'",
")",
"->",
"andWhere",
"(",
"'if.hash IN (:hashes)'",
")",
"->",
"setParameter",
"(",
"'hashes'",
",",
"array_values",
"(",
"$",
"hashes",
")",
")",
";",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Removes the icon files with the specified hashes from the database.
@param array|string[] $hashes
|
[
"Removes",
"the",
"icon",
"files",
"with",
"the",
"specified",
"hashes",
"from",
"the",
"database",
"."
] |
c3a27e5673462a58b5afafc0ea0e0002f6db9803
|
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L71-L79
|
239,559
|
loopsframework/base
|
src/Loops/Application/LoopsAdmin.php
|
LoopsAdmin.exec
|
public function exec($arguments) {
//parse
$options = $this->parse();
// check if help was requested
if(is_integer($options)) {
return $options;
}
// extract and remove special vars
$instance = $options["__instance"];
$method = $options["__method"];
unset($options["__instance"]);
unset($options["__method"]);
// execute action - print error on failure
try {
return (int)Misc::reflectionFunction([ $instance, $method ], self::adjustOptions($options));
}
catch(Exception $e) {
return $this->printError($e->getMessage());
}
}
|
php
|
public function exec($arguments) {
//parse
$options = $this->parse();
// check if help was requested
if(is_integer($options)) {
return $options;
}
// extract and remove special vars
$instance = $options["__instance"];
$method = $options["__method"];
unset($options["__instance"]);
unset($options["__method"]);
// execute action - print error on failure
try {
return (int)Misc::reflectionFunction([ $instance, $method ], self::adjustOptions($options));
}
catch(Exception $e) {
return $this->printError($e->getMessage());
}
}
|
[
"public",
"function",
"exec",
"(",
"$",
"arguments",
")",
"{",
"//parse",
"$",
"options",
"=",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"// check if help was requested",
"if",
"(",
"is_integer",
"(",
"$",
"options",
")",
")",
"{",
"return",
"$",
"options",
";",
"}",
"// extract and remove special vars",
"$",
"instance",
"=",
"$",
"options",
"[",
"\"__instance\"",
"]",
";",
"$",
"method",
"=",
"$",
"options",
"[",
"\"__method\"",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"\"__instance\"",
"]",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"\"__method\"",
"]",
")",
";",
"// execute action - print error on failure",
"try",
"{",
"return",
"(",
"int",
")",
"Misc",
"::",
"reflectionFunction",
"(",
"[",
"$",
"instance",
",",
"$",
"method",
"]",
",",
"self",
"::",
"adjustOptions",
"(",
"$",
"options",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"printError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Forwards the call to parsed module name and action
See class documentation for details.
|
[
"Forwards",
"the",
"call",
"to",
"parsed",
"module",
"name",
"and",
"action"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L193-L216
|
239,560
|
loopsframework/base
|
src/Loops/Application/LoopsAdmin.php
|
LoopsAdmin.adjustOptions
|
private static function adjustOptions(array $options) {
$result = [];
foreach($options as $key => $value) {
$result[str_replace("-", "_", $key)] = $value;
}
return $result;
}
|
php
|
private static function adjustOptions(array $options) {
$result = [];
foreach($options as $key => $value) {
$result[str_replace("-", "_", $key)] = $value;
}
return $result;
}
|
[
"private",
"static",
"function",
"adjustOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"str_replace",
"(",
"\"-\"",
",",
"\"_\"",
",",
"$",
"key",
")",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
replaces dashes with underscore in keys of an array
|
[
"replaces",
"dashes",
"with",
"underscore",
"in",
"keys",
"of",
"an",
"array"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L221-L229
|
239,561
|
loopsframework/base
|
src/Loops/Application/LoopsAdmin.php
|
LoopsAdmin.ident
|
private function ident($text, $length = 4, $chunk = 76, $break = "\n") {
$lines = [];
foreach(explode($break, $text) as $line) {
$text = trim(wordwrap($line, $chunk - $length, $break));
foreach(explode($break, $text) as $part) {
$lines[] = str_repeat(" ", $length).$part;
}
}
return implode($break, $lines);
}
|
php
|
private function ident($text, $length = 4, $chunk = 76, $break = "\n") {
$lines = [];
foreach(explode($break, $text) as $line) {
$text = trim(wordwrap($line, $chunk - $length, $break));
foreach(explode($break, $text) as $part) {
$lines[] = str_repeat(" ", $length).$part;
}
}
return implode($break, $lines);
}
|
[
"private",
"function",
"ident",
"(",
"$",
"text",
",",
"$",
"length",
"=",
"4",
",",
"$",
"chunk",
"=",
"76",
",",
"$",
"break",
"=",
"\"\\n\"",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"break",
",",
"$",
"text",
")",
"as",
"$",
"line",
")",
"{",
"$",
"text",
"=",
"trim",
"(",
"wordwrap",
"(",
"$",
"line",
",",
"$",
"chunk",
"-",
"$",
"length",
",",
"$",
"break",
")",
")",
";",
"foreach",
"(",
"explode",
"(",
"$",
"break",
",",
"$",
"text",
")",
"as",
"$",
"part",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"str_repeat",
"(",
"\" \"",
",",
"$",
"length",
")",
".",
"$",
"part",
";",
"}",
"}",
"return",
"implode",
"(",
"$",
"break",
",",
"$",
"lines",
")",
";",
"}"
] |
Idents and chunk splits a text
|
[
"Idents",
"and",
"chunk",
"splits",
"a",
"text"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L234-L245
|
239,562
|
slickframework/i18n
|
src/TranslateMethods.php
|
TranslateMethods.translatePlural
|
public function translatePlural($singular, $plural, $number)
{
$this->checkTranslator();
return $this->translator->translatePlural($singular, $plural, $number);
}
|
php
|
public function translatePlural($singular, $plural, $number)
{
$this->checkTranslator();
return $this->translator->translatePlural($singular, $plural, $number);
}
|
[
"public",
"function",
"translatePlural",
"(",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"number",
")",
"{",
"$",
"this",
"->",
"checkTranslator",
"(",
")",
";",
"return",
"$",
"this",
"->",
"translator",
"->",
"translatePlural",
"(",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"number",
")",
";",
"}"
] |
Translates the provided message to singular or plural according to the number
@param string $singular
@param string $plural
@param integer $number
@return string
|
[
"Translates",
"the",
"provided",
"message",
"to",
"singular",
"or",
"plural",
"according",
"to",
"the",
"number"
] |
3d6d9bad8e0f7ac02f6e9919821cf49371fc9353
|
https://github.com/slickframework/i18n/blob/3d6d9bad8e0f7ac02f6e9919821cf49371fc9353/src/TranslateMethods.php#L49-L53
|
239,563
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.showAction
|
public function showAction(MeasureUnit $measureunit)
{
$editForm = $this->createForm(MeasureUnitType::class, $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function showAction(MeasureUnit $measureunit)
{
$editForm = $this->createForm(MeasureUnitType::class, $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"showAction",
"(",
"MeasureUnit",
"$",
"measureunit",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"MeasureUnitType",
"::",
"class",
",",
"$",
"measureunit",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"measureunit",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"measureunit",
"->",
"getId",
"(",
")",
",",
"'admin_shop_measure_unit_delete'",
")",
";",
"return",
"array",
"(",
"'measureunit'",
"=>",
"$",
"measureunit",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Finds and displays a MeasureUnit entity.
@Route("/{id}/show", name="admin_shop_measure_unit_show", requirements={"id"="\d+"})
@Method("GET")
@Template()
|
[
"Finds",
"and",
"displays",
"a",
"MeasureUnit",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L47-L62
|
239,564
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.newAction
|
public function newAction()
{
$measureunit = new MeasureUnit();
$form = $this->createForm(MeasureUnitType::class, $measureunit);
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
}
|
php
|
public function newAction()
{
$measureunit = new MeasureUnit();
$form = $this->createForm(MeasureUnitType::class, $measureunit);
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"measureunit",
"=",
"new",
"MeasureUnit",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"MeasureUnitType",
"::",
"class",
",",
"$",
"measureunit",
")",
";",
"return",
"array",
"(",
"'measureunit'",
"=>",
"$",
"measureunit",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to create a new MeasureUnit entity.
@Route("/new", name="admin_shop_measure_unit_new")
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"MeasureUnit",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L71-L80
|
239,565
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.createAction
|
public function createAction(Request $request)
{
$measureunit = new MeasureUnit();
$form = $this->createForm(new MeasureUnitType(), $measureunit);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($measureunit);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
}
|
php
|
public function createAction(Request $request)
{
$measureunit = new MeasureUnit();
$form = $this->createForm(new MeasureUnitType(), $measureunit);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($measureunit);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"measureunit",
"=",
"new",
"MeasureUnit",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"MeasureUnitType",
"(",
")",
",",
"$",
"measureunit",
")",
";",
"if",
"(",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"measureunit",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"measureunit",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'measureunit'",
"=>",
"$",
"measureunit",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new MeasureUnit entity.
@Route("/create", name="admin_shop_measure_unit_create")
@Method("POST")
@Template("FlowerStockBundle:MeasureUnit:new.html.twig")
|
[
"Creates",
"a",
"new",
"MeasureUnit",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L89-L105
|
239,566
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.updateAction
|
public function updateAction(MeasureUnit $measureunit, Request $request)
{
$editForm = $this->createForm(new MeasureUnitType(), $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function updateAction(MeasureUnit $measureunit, Request $request)
{
$editForm = $this->createForm(new MeasureUnitType(), $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"updateAction",
"(",
"MeasureUnit",
"$",
"measureunit",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"MeasureUnitType",
"(",
")",
",",
"$",
"measureunit",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"measureunit",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"measureunit",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"measureunit",
"->",
"getId",
"(",
")",
",",
"'admin_shop_measure_unit_delete'",
")",
";",
"return",
"array",
"(",
"'measureunit'",
"=>",
"$",
"measureunit",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Edits an existing MeasureUnit entity.
@Route("/{id}/update", name="admin_shop_measure_unit_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:MeasureUnit:edit.html.twig")
|
[
"Edits",
"an",
"existing",
"MeasureUnit",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L136-L154
|
239,567
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.sortAction
|
public function sortAction($field, $type)
{
$this->setOrder('measureunit', $field, $type);
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
}
|
php
|
public function sortAction($field, $type)
{
$this->setOrder('measureunit', $field, $type);
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
}
|
[
"public",
"function",
"sortAction",
"(",
"$",
"field",
",",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"setOrder",
"(",
"'measureunit'",
",",
"$",
"field",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit'",
")",
")",
";",
"}"
] |
Save order.
@Route("/order/{field}/{type}", name="admin_shop_measure_unit_sort")
|
[
"Save",
"order",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L162-L167
|
239,568
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php
|
AdminMeasureUnitController.deleteAction
|
public function deleteAction(MeasureUnit $measureunit, Request $request)
{
$form = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($measureunit);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
}
|
php
|
public function deleteAction(MeasureUnit $measureunit, Request $request)
{
$form = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($measureunit);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
}
|
[
"public",
"function",
"deleteAction",
"(",
"MeasureUnit",
"$",
"measureunit",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"measureunit",
"->",
"getId",
"(",
")",
",",
"'admin_shop_measure_unit_delete'",
")",
";",
"if",
"(",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"remove",
"(",
"$",
"measureunit",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_measure_unit'",
")",
")",
";",
"}"
] |
Deletes a MeasureUnit entity.
@Route("/{id}/delete", name="admin_shop_measure_unit_delete", requirements={"id"="\d+"})
@Method("DELETE")
|
[
"Deletes",
"a",
"MeasureUnit",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L208-L218
|
239,569
|
lciolecki/zf-extensions-library
|
library/Extlib/Mail/Message/Html.php
|
Html.getScript
|
protected function getScript()
{
if (null === $this->getScriptName()) {
$request = $this->frontController->getRequest();
$this->setScriptName($request->getControllerName() . DIRECTORY_SEPARATOR . $request->getActionName());
}
return $this->getScriptName() . '.' . $this->getViewSuffix();
}
|
php
|
protected function getScript()
{
if (null === $this->getScriptName()) {
$request = $this->frontController->getRequest();
$this->setScriptName($request->getControllerName() . DIRECTORY_SEPARATOR . $request->getActionName());
}
return $this->getScriptName() . '.' . $this->getViewSuffix();
}
|
[
"protected",
"function",
"getScript",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"getScriptName",
"(",
")",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"frontController",
"->",
"getRequest",
"(",
")",
";",
"$",
"this",
"->",
"setScriptName",
"(",
"$",
"request",
"->",
"getControllerName",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"request",
"->",
"getActionName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getScriptName",
"(",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"getViewSuffix",
"(",
")",
";",
"}"
] |
Get full name of script to render
@return string
|
[
"Get",
"full",
"name",
"of",
"script",
"to",
"render"
] |
f479a63188d17f1488b392d4fc14fe47a417ea55
|
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Mail/Message/Html.php#L100-L108
|
239,570
|
lciolecki/zf-extensions-library
|
library/Extlib/Mail/Message/Html.php
|
Html.setData
|
public function setData(array $data)
{
foreach ($data as $name => $value) {
if (is_string($name)) {
$this->__set($name, $value);
}
}
return $this;
}
|
php
|
public function setData(array $data)
{
foreach ($data as $name => $value) {
if (is_string($name)) {
$this->__set($name, $value);
}
}
return $this;
}
|
[
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"__set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set data collections in View
@param array $data
@return \Extlib\Mail\Message\Html
|
[
"Set",
"data",
"collections",
"in",
"View"
] |
f479a63188d17f1488b392d4fc14fe47a417ea55
|
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Mail/Message/Html.php#L182-L191
|
239,571
|
Consumerr/php
|
src/Consumerr/Configuration.php
|
Configuration.getSenderClass
|
public function getSenderClass($options)
{
if (empty($options['sender'])) {
if (function_exists('extension_loaded') && extension_loaded('curl') && PHP_VERSION_ID >= 50300) {
return /**/
'Consumerr\Sender\CurlSender' /**/ /*5.2*'Consumerr_CurlSender'*/
;
} else {
return /**/
'Consumerr\Sender\PhpSender' /**/ /*5.2*'Consumerr_PhpSender'*/
;
}
} else {
if (isset($this->senderAlias[$options['sender']])) {
return $this->senderAlias[$options['sender']];
} else {
if (!class_exists($options['sender'])) {
throw new AssertionException("Sender class {$options['sender']} was not found.");
}
return $options['sender'];
}
}
}
|
php
|
public function getSenderClass($options)
{
if (empty($options['sender'])) {
if (function_exists('extension_loaded') && extension_loaded('curl') && PHP_VERSION_ID >= 50300) {
return /**/
'Consumerr\Sender\CurlSender' /**/ /*5.2*'Consumerr_CurlSender'*/
;
} else {
return /**/
'Consumerr\Sender\PhpSender' /**/ /*5.2*'Consumerr_PhpSender'*/
;
}
} else {
if (isset($this->senderAlias[$options['sender']])) {
return $this->senderAlias[$options['sender']];
} else {
if (!class_exists($options['sender'])) {
throw new AssertionException("Sender class {$options['sender']} was not found.");
}
return $options['sender'];
}
}
}
|
[
"public",
"function",
"getSenderClass",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'sender'",
"]",
")",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'extension_loaded'",
")",
"&&",
"extension_loaded",
"(",
"'curl'",
")",
"&&",
"PHP_VERSION_ID",
">=",
"50300",
")",
"{",
"return",
"/**/",
"'Consumerr\\Sender\\CurlSender'",
"/**/",
"/*5.2*'Consumerr_CurlSender'*/",
";",
"}",
"else",
"{",
"return",
"/**/",
"'Consumerr\\Sender\\PhpSender'",
"/**/",
"/*5.2*'Consumerr_PhpSender'*/",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"senderAlias",
"[",
"$",
"options",
"[",
"'sender'",
"]",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"senderAlias",
"[",
"$",
"options",
"[",
"'sender'",
"]",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"options",
"[",
"'sender'",
"]",
")",
")",
"{",
"throw",
"new",
"AssertionException",
"(",
"\"Sender class {$options['sender']} was not found.\"",
")",
";",
"}",
"return",
"$",
"options",
"[",
"'sender'",
"]",
";",
"}",
"}",
"}"
] |
Determine sender handler from configuration
@internal
@param array $options
@return string
|
[
"Determine",
"sender",
"handler",
"from",
"configuration"
] |
2a33401e70d1309b1e0669160044350a881e6603
|
https://github.com/Consumerr/php/blob/2a33401e70d1309b1e0669160044350a881e6603/src/Consumerr/Configuration.php#L133-L156
|
239,572
|
krutush/krutush
|
src/Router.php
|
Router.add
|
public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
}
|
php
|
public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
}
|
[
"public",
"function",
"add",
"(",
"string",
"$",
"path",
",",
"$",
"callable",
")",
":",
"Route",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"callable",
")",
";",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"route",
";",
"return",
"$",
"route",
";",
"}"
] |
Register a new Route
@param string $path Url from Root
@param callable|string $callable Function to run or 'Controller#function'
@return Route
|
[
"Register",
"a",
"new",
"Route"
] |
3c42b524d7bd199d43fb3a5035b9e1bb39f5575b
|
https://github.com/krutush/krutush/blob/3c42b524d7bd199d43fb3a5035b9e1bb39f5575b/src/Router.php#L34-L38
|
239,573
|
jmpantoja/planb-utils
|
src/Type/Path/PathNormalizer.php
|
PathNormalizer.configureSlashPrefix
|
private function configureSlashPrefix(array $pieces): self
{
$first = array_shift($pieces);
$pattern = sprintf('#^%s#', DIRECTORY_SEPARATOR);
if (preg_match($pattern, $first)) {
$this->prefix .= DIRECTORY_SEPARATOR;
}
return $this;
}
|
php
|
private function configureSlashPrefix(array $pieces): self
{
$first = array_shift($pieces);
$pattern = sprintf('#^%s#', DIRECTORY_SEPARATOR);
if (preg_match($pattern, $first)) {
$this->prefix .= DIRECTORY_SEPARATOR;
}
return $this;
}
|
[
"private",
"function",
"configureSlashPrefix",
"(",
"array",
"$",
"pieces",
")",
":",
"self",
"{",
"$",
"first",
"=",
"array_shift",
"(",
"$",
"pieces",
")",
";",
"$",
"pattern",
"=",
"sprintf",
"(",
"'#^%s#'",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"first",
")",
")",
"{",
"$",
"this",
"->",
"prefix",
".=",
"DIRECTORY_SEPARATOR",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Configura el normalizer para tratar con rutas absolutas
@param string[] $pieces
@return \PlanB\Type\Path\PathNormalizer
|
[
"Configura",
"el",
"normalizer",
"para",
"tratar",
"con",
"rutas",
"absolutas"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L62-L72
|
239,574
|
jmpantoja/planb-utils
|
src/Type/Path/PathNormalizer.php
|
PathNormalizer.getPartsFromSegment
|
private function getPartsFromSegment(string $segment): array
{
$parts = explode(DIRECTORY_SEPARATOR, $segment);
return array_filter($parts, function ($part) {
return $this->isNotEmpty($part);
});
}
|
php
|
private function getPartsFromSegment(string $segment): array
{
$parts = explode(DIRECTORY_SEPARATOR, $segment);
return array_filter($parts, function ($part) {
return $this->isNotEmpty($part);
});
}
|
[
"private",
"function",
"getPartsFromSegment",
"(",
"string",
"$",
"segment",
")",
":",
"array",
"{",
"$",
"parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"segment",
")",
";",
"return",
"array_filter",
"(",
"$",
"parts",
",",
"function",
"(",
"$",
"part",
")",
"{",
"return",
"$",
"this",
"->",
"isNotEmpty",
"(",
"$",
"part",
")",
";",
"}",
")",
";",
"}"
] |
Separa un segmento en varias partes, cortando por DIRECTORY_SEPARATOR
@param string $segment
@return string[]
|
[
"Separa",
"un",
"segmento",
"en",
"varias",
"partes",
"cortando",
"por",
"DIRECTORY_SEPARATOR"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L100-L107
|
239,575
|
jmpantoja/planb-utils
|
src/Type/Path/PathNormalizer.php
|
PathNormalizer.toString
|
protected function toString(): string
{
$normalized = sprintf('%s%s', $this->prefix, implode(DIRECTORY_SEPARATOR, $this->stack));
return trim($normalized);
}
|
php
|
protected function toString(): string
{
$normalized = sprintf('%s%s', $this->prefix, implode(DIRECTORY_SEPARATOR, $this->stack));
return trim($normalized);
}
|
[
"protected",
"function",
"toString",
"(",
")",
":",
"string",
"{",
"$",
"normalized",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"this",
"->",
"prefix",
",",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"stack",
")",
")",
";",
"return",
"trim",
"(",
"$",
"normalized",
")",
";",
"}"
] |
Devuelve la ruta normalizada
@return string
|
[
"Devuelve",
"la",
"ruta",
"normalizada"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L197-L202
|
239,576
|
vox-tecnologia/functions
|
src/Functions/ServiceFunctions.php
|
ServiceFunctions.isValidEmail
|
public function isValidEmail(string $email): bool
{
return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL) !== false;
}
|
php
|
public function isValidEmail(string $email): bool
{
return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL) !== false;
}
|
[
"public",
"function",
"isValidEmail",
"(",
"string",
"$",
"email",
")",
":",
"bool",
"{",
"return",
"filter_var",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_SANITIZE_EMAIL",
")",
",",
"FILTER_VALIDATE_EMAIL",
")",
"!==",
"false",
";",
"}"
] |
Validate a email address.
@param string $email The email address to validate
@return bool
|
[
"Validate",
"a",
"email",
"address",
"."
] |
1da249ac87f9d7c46d1c714d65443cda9face807
|
https://github.com/vox-tecnologia/functions/blob/1da249ac87f9d7c46d1c714d65443cda9face807/src/Functions/ServiceFunctions.php#L294-L297
|
239,577
|
encorephp/repl
|
src/Command.php
|
Command.repl
|
public function repl()
{
$input = $this->prompt();
$buffer = null;
while ($input != 'exit;') {
try {
$buffer .= $input;
if ((new ShallowParser)->statements($buffer)) {
ob_start();
$app = $this->container;
eval($buffer);
$response = ob_get_clean();
if ( ! empty($response)) $this->output->writeln(trim($response));
$buffer = null;
}
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$input = $this->prompt($buffer !== null);
}
if ($input == 'exit;') exit;
}
|
php
|
public function repl()
{
$input = $this->prompt();
$buffer = null;
while ($input != 'exit;') {
try {
$buffer .= $input;
if ((new ShallowParser)->statements($buffer)) {
ob_start();
$app = $this->container;
eval($buffer);
$response = ob_get_clean();
if ( ! empty($response)) $this->output->writeln(trim($response));
$buffer = null;
}
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$input = $this->prompt($buffer !== null);
}
if ($input == 'exit;') exit;
}
|
[
"public",
"function",
"repl",
"(",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"prompt",
"(",
")",
";",
"$",
"buffer",
"=",
"null",
";",
"while",
"(",
"$",
"input",
"!=",
"'exit;'",
")",
"{",
"try",
"{",
"$",
"buffer",
".=",
"$",
"input",
";",
"if",
"(",
"(",
"new",
"ShallowParser",
")",
"->",
"statements",
"(",
"$",
"buffer",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"app",
"=",
"$",
"this",
"->",
"container",
";",
"eval",
"(",
"$",
"buffer",
")",
";",
"$",
"response",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"response",
")",
")",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"trim",
"(",
"$",
"response",
")",
")",
";",
"$",
"buffer",
"=",
"null",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"input",
"=",
"$",
"this",
"->",
"prompt",
"(",
"$",
"buffer",
"!==",
"null",
")",
";",
"}",
"if",
"(",
"$",
"input",
"==",
"'exit;'",
")",
"exit",
";",
"}"
] |
Run the REPL loop
@return void
|
[
"Run",
"the",
"REPL",
"loop"
] |
c53973941b8741a3ccac5b1f95e426f72ee04727
|
https://github.com/encorephp/repl/blob/c53973941b8741a3ccac5b1f95e426f72ee04727/src/Command.php#L36-L63
|
239,578
|
encorephp/repl
|
src/Command.php
|
Command.prompt
|
protected function prompt($indent = false)
{
$dialog = $this->getHelperSet()->get('dialog');
$indent = $indent ? '*' : null;
return $dialog->ask($this->output, "<info>encore{$indent}></info>", null);
}
|
php
|
protected function prompt($indent = false)
{
$dialog = $this->getHelperSet()->get('dialog');
$indent = $indent ? '*' : null;
return $dialog->ask($this->output, "<info>encore{$indent}></info>", null);
}
|
[
"protected",
"function",
"prompt",
"(",
"$",
"indent",
"=",
"false",
")",
"{",
"$",
"dialog",
"=",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"get",
"(",
"'dialog'",
")",
";",
"$",
"indent",
"=",
"$",
"indent",
"?",
"'*'",
":",
"null",
";",
"return",
"$",
"dialog",
"->",
"ask",
"(",
"$",
"this",
"->",
"output",
",",
"\"<info>encore{$indent}></info>\"",
",",
"null",
")",
";",
"}"
] |
Prompt the user for an input
@param boolean $indent
@return string
|
[
"Prompt",
"the",
"user",
"for",
"an",
"input"
] |
c53973941b8741a3ccac5b1f95e426f72ee04727
|
https://github.com/encorephp/repl/blob/c53973941b8741a3ccac5b1f95e426f72ee04727/src/Command.php#L71-L78
|
239,579
|
Silvestra/Silvestra
|
src/Silvestra/Component/Media/Filesystem.php
|
Filesystem.getActualFileDir
|
public function getActualFileDir($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getPath(array($this->getMediaRootDir(), $subDir, $this->getFileDirPrefix($filename)));
}
|
php
|
public function getActualFileDir($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getPath(array($this->getMediaRootDir(), $subDir, $this->getFileDirPrefix($filename)));
}
|
[
"public",
"function",
"getActualFileDir",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"return",
"$",
"this",
"->",
"getPath",
"(",
"array",
"(",
"$",
"this",
"->",
"getMediaRootDir",
"(",
")",
",",
"$",
"subDir",
",",
"$",
"this",
"->",
"getFileDirPrefix",
"(",
"$",
"filename",
")",
")",
")",
";",
"}"
] |
Get actual file dir.
@param string $filename
@param string $subDir
@return string
|
[
"Get",
"actual",
"file",
"dir",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L83-L86
|
239,580
|
Silvestra/Silvestra
|
src/Silvestra/Component/Media/Filesystem.php
|
Filesystem.getFileDirPrefix
|
public function getFileDirPrefix($filename)
{
if (empty($filename)) {
throw new InvalidArgumentException('Invalid filename argument');
}
$path = array();
$parts = explode('.', $filename);
for ($i = 0; $i < min(strlen($parts[0]), $this->prefixSize); $i++) {
$path[] = $filename[$i];
}
$path = $this->getPath($path);
return $path;
}
|
php
|
public function getFileDirPrefix($filename)
{
if (empty($filename)) {
throw new InvalidArgumentException('Invalid filename argument');
}
$path = array();
$parts = explode('.', $filename);
for ($i = 0; $i < min(strlen($parts[0]), $this->prefixSize); $i++) {
$path[] = $filename[$i];
}
$path = $this->getPath($path);
return $path;
}
|
[
"public",
"function",
"getFileDirPrefix",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid filename argument'",
")",
";",
"}",
"$",
"path",
"=",
"array",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"filename",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"min",
"(",
"strlen",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"$",
"this",
"->",
"prefixSize",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"filename",
"[",
"$",
"i",
"]",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] |
Get file dir prefix.
@param string $filename
@return string
@throws InvalidArgumentException
|
[
"Get",
"file",
"dir",
"prefix",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L97-L113
|
239,581
|
Silvestra/Silvestra
|
src/Silvestra/Component/Media/Filesystem.php
|
Filesystem.getAbsoluteFilePath
|
public function getAbsoluteFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getRootDir() . $this->getRelativeFilePath($filename, $subDir);
}
|
php
|
public function getAbsoluteFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getRootDir() . $this->getRelativeFilePath($filename, $subDir);
}
|
[
"public",
"function",
"getAbsoluteFilePath",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"return",
"$",
"this",
"->",
"getRootDir",
"(",
")",
".",
"$",
"this",
"->",
"getRelativeFilePath",
"(",
"$",
"filename",
",",
"$",
"subDir",
")",
";",
"}"
] |
Get absolute file path.
@param string $filename
@param string $subDir
@return string
|
[
"Get",
"absolute",
"file",
"path",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L168-L171
|
239,582
|
Silvestra/Silvestra
|
src/Silvestra/Component/Media/Filesystem.php
|
Filesystem.getRelativeFilePath
|
public function getRelativeFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
$pathParts = array(Media::NAME, $subDir, $this->getFileDirPrefix($filename), $filename);
return DIRECTORY_SEPARATOR . $this->getPath($pathParts);
}
|
php
|
public function getRelativeFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
$pathParts = array(Media::NAME, $subDir, $this->getFileDirPrefix($filename), $filename);
return DIRECTORY_SEPARATOR . $this->getPath($pathParts);
}
|
[
"public",
"function",
"getRelativeFilePath",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"$",
"pathParts",
"=",
"array",
"(",
"Media",
"::",
"NAME",
",",
"$",
"subDir",
",",
"$",
"this",
"->",
"getFileDirPrefix",
"(",
"$",
"filename",
")",
",",
"$",
"filename",
")",
";",
"return",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getPath",
"(",
"$",
"pathParts",
")",
";",
"}"
] |
Get relative file path.
@param string $filename
@param string $subDir
@return string
|
[
"Get",
"relative",
"file",
"path",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L181-L186
|
239,583
|
Ara95/user
|
src/User/User.php
|
User.verifyPassword
|
public function verifyPassword($email, $password)
{
$this->find("email", $email);
return password_verify($password, $this->password);
}
|
php
|
public function verifyPassword($email, $password)
{
$this->find("email", $email);
return password_verify($password, $this->password);
}
|
[
"public",
"function",
"verifyPassword",
"(",
"$",
"email",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"email",
")",
";",
"return",
"password_verify",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"password",
")",
";",
"}"
] |
Verify the acronym and the password, if successful the object contains
all details from the database row.
@param string $acronym acronym to check.
@param string $password the password to use.
@return boolean true if acronym and password matches, else false.
|
[
"Verify",
"the",
"acronym",
"and",
"the",
"password",
"if",
"successful",
"the",
"object",
"contains",
"all",
"details",
"from",
"the",
"database",
"row",
"."
] |
96e15a19906562a689abedf6bcf4818ad8437a3b
|
https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/User/User.php#L54-L58
|
239,584
|
Ara95/user
|
src/User/User.php
|
User.isEmailUnique
|
public function isEmailUnique($email)
{
$this->find("email", $email);
if (isset($this->id)) {
return false;
}
return true;
}
|
php
|
public function isEmailUnique($email)
{
$this->find("email", $email);
if (isset($this->id)) {
return false;
}
return true;
}
|
[
"public",
"function",
"isEmailUnique",
"(",
"$",
"email",
")",
"{",
"$",
"this",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"email",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check whether the user is an Admin
@return boolean true if user is an Admin
|
[
"Check",
"whether",
"the",
"user",
"is",
"an",
"Admin"
] |
96e15a19906562a689abedf6bcf4818ad8437a3b
|
https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/User/User.php#L86-L93
|
239,585
|
unyx/console
|
input/parameter/Values.php
|
Values.finalize
|
public function finalize() : Values
{
/* @var input\Parameter $parameter */
foreach ($this->definitions as $name => $parameter) {
if (isset($this->items[$name])) {
continue;
}
// In the case of Parameters which do not accept values (ie. optional flags), we explicitly default them
// to a boolean false, opposed to a boolean true when they are actually set in input.
$this->items[$name] = ($value = $parameter->getValue()) ? $value->getDefault() : false;
}
return $this;
}
|
php
|
public function finalize() : Values
{
/* @var input\Parameter $parameter */
foreach ($this->definitions as $name => $parameter) {
if (isset($this->items[$name])) {
continue;
}
// In the case of Parameters which do not accept values (ie. optional flags), we explicitly default them
// to a boolean false, opposed to a boolean true when they are actually set in input.
$this->items[$name] = ($value = $parameter->getValue()) ? $value->getDefault() : false;
}
return $this;
}
|
[
"public",
"function",
"finalize",
"(",
")",
":",
"Values",
"{",
"/* @var input\\Parameter $parameter */",
"foreach",
"(",
"$",
"this",
"->",
"definitions",
"as",
"$",
"name",
"=>",
"$",
"parameter",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// In the case of Parameters which do not accept values (ie. optional flags), we explicitly default them",
"// to a boolean false, opposed to a boolean true when they are actually set in input.",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
"=",
"(",
"$",
"value",
"=",
"$",
"parameter",
"->",
"getValue",
"(",
")",
")",
"?",
"$",
"value",
"->",
"getDefault",
"(",
")",
":",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Finalizes the Collection, populating it with Parameters that have not been explicitly set, but
have defined default values.
@return $this
|
[
"Finalizes",
"the",
"Collection",
"populating",
"it",
"with",
"Parameters",
"that",
"have",
"not",
"been",
"explicitly",
"set",
"but",
"have",
"defined",
"default",
"values",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/input/parameter/Values.php#L80-L94
|
239,586
|
unyx/console
|
input/parameter/Values.php
|
Values.assertIsDefined
|
protected function assertIsDefined(string $name) : input\Parameter
{
/* @var input\Parameter $parameter */
if (!$parameter = $this->definitions->get($name)) {
throw new \OutOfBoundsException("The parameter [$name] is not defined.");
}
return $parameter;
}
|
php
|
protected function assertIsDefined(string $name) : input\Parameter
{
/* @var input\Parameter $parameter */
if (!$parameter = $this->definitions->get($name)) {
throw new \OutOfBoundsException("The parameter [$name] is not defined.");
}
return $parameter;
}
|
[
"protected",
"function",
"assertIsDefined",
"(",
"string",
"$",
"name",
")",
":",
"input",
"\\",
"Parameter",
"{",
"/* @var input\\Parameter $parameter */",
"if",
"(",
"!",
"$",
"parameter",
"=",
"$",
"this",
"->",
"definitions",
"->",
"get",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"The parameter [$name] is not defined.\"",
")",
";",
"}",
"return",
"$",
"parameter",
";",
"}"
] |
Asserts a Parameter with the given name is defined for this collection and returns it.
@param string $name The name of the Parameter.
@throws \OutOfBoundsException When no Parameter with the given name has been defined.
@return input\Parameter
|
[
"Asserts",
"a",
"Parameter",
"with",
"the",
"given",
"name",
"is",
"defined",
"for",
"this",
"collection",
"and",
"returns",
"it",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/input/parameter/Values.php#L103-L111
|
239,587
|
Dhii/container-helper-base
|
src/NormalizeKeyCapableTrait.php
|
NormalizeKeyCapableTrait._normalizeKey
|
protected function _normalizeKey($key)
{
try {
return $this->_normalizeString($key);
} catch (InvalidArgumentException $e) {
throw $this->_createOutOfRangeException($this->__('Invalid key'), null, $e, $key);
}
}
|
php
|
protected function _normalizeKey($key)
{
try {
return $this->_normalizeString($key);
} catch (InvalidArgumentException $e) {
throw $this->_createOutOfRangeException($this->__('Invalid key'), null, $e, $key);
}
}
|
[
"protected",
"function",
"_normalizeKey",
"(",
"$",
"key",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"_normalizeString",
"(",
"$",
"key",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"_createOutOfRangeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid key'",
")",
",",
"null",
",",
"$",
"e",
",",
"$",
"key",
")",
";",
"}",
"}"
] |
Normalizes a key.
Treats it as one of many keys, throwing a more appropriate exception.
@param string|int|float|bool|Stringable $key The key to normalize.
@throws OutOfRangeException If key cannot be normalized.
@return string The normalized key.
|
[
"Normalizes",
"a",
"key",
"."
] |
ccb2f56971d70cf203baa596cd14fdf91be6bfae
|
https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/NormalizeKeyCapableTrait.php#L28-L35
|
239,588
|
lciolecki/zf-extensions-library
|
library/Extlib/Session/SaveHandler/Doctrine.php
|
Doctrine._getLifetime
|
public function _getLifetime(\Doctrine_Record $record)
{
$return = $this->_lifetime;
if (!$this->_overrideLifetime) {
$return = (int) $record->{$this->_lifetimeColumn};
}
return $return;
}
|
php
|
public function _getLifetime(\Doctrine_Record $record)
{
$return = $this->_lifetime;
if (!$this->_overrideLifetime) {
$return = (int) $record->{$this->_lifetimeColumn};
}
return $return;
}
|
[
"public",
"function",
"_getLifetime",
"(",
"\\",
"Doctrine_Record",
"$",
"record",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"_lifetime",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_overrideLifetime",
")",
"{",
"$",
"return",
"=",
"(",
"int",
")",
"$",
"record",
"->",
"{",
"$",
"this",
"->",
"_lifetimeColumn",
"}",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Retrieve session lifetime
@param \Doctrine_Record $record
@return int
|
[
"Retrieve",
"session",
"lifetime"
] |
f479a63188d17f1488b392d4fc14fe47a417ea55
|
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Session/SaveHandler/Doctrine.php#L283-L292
|
239,589
|
cityware/city-wmi
|
src/Query/Operator.php
|
Operator.get
|
public static function get()
{
return [
self::$equals,
self::$lessThan,
self::$lessThanEqualTo,
self::$greaterThan,
self::$greaterThanEqualTo,
self::$doesNotEqual,
self::$doesNotEqualAlt,
self::$is,
self::$isA,
self::$isNot,
self::$like,
];
}
|
php
|
public static function get()
{
return [
self::$equals,
self::$lessThan,
self::$lessThanEqualTo,
self::$greaterThan,
self::$greaterThanEqualTo,
self::$doesNotEqual,
self::$doesNotEqualAlt,
self::$is,
self::$isA,
self::$isNot,
self::$like,
];
}
|
[
"public",
"static",
"function",
"get",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"$",
"equals",
",",
"self",
"::",
"$",
"lessThan",
",",
"self",
"::",
"$",
"lessThanEqualTo",
",",
"self",
"::",
"$",
"greaterThan",
",",
"self",
"::",
"$",
"greaterThanEqualTo",
",",
"self",
"::",
"$",
"doesNotEqual",
",",
"self",
"::",
"$",
"doesNotEqualAlt",
",",
"self",
"::",
"$",
"is",
",",
"self",
"::",
"$",
"isA",
",",
"self",
"::",
"$",
"isNot",
",",
"self",
"::",
"$",
"like",
",",
"]",
";",
"}"
] |
Returns all available operators.
@return array
|
[
"Returns",
"all",
"available",
"operators",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Operator.php#L96-L111
|
239,590
|
jivoo/core
|
src/Assume.php
|
Assume.that
|
public static function that($condition, $message = null)
{
if ($condition === true) {
return;
}
if (isset($message)) {
throw new InvalidArgumentException($message);
}
$bt = debug_backtrace();
$call = $bt[0];
$lines = file($call['file']);
preg_match('/' . $call['function'] . '\((.+)\)/', $lines[$call['line'] - 1], $matches);
throw new InvalidArgumentException('Assumption failed: ' . $matches[1]);
}
|
php
|
public static function that($condition, $message = null)
{
if ($condition === true) {
return;
}
if (isset($message)) {
throw new InvalidArgumentException($message);
}
$bt = debug_backtrace();
$call = $bt[0];
$lines = file($call['file']);
preg_match('/' . $call['function'] . '\((.+)\)/', $lines[$call['line'] - 1], $matches);
throw new InvalidArgumentException('Assumption failed: ' . $matches[1]);
}
|
[
"public",
"static",
"function",
"that",
"(",
"$",
"condition",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"condition",
"===",
"true",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"$",
"bt",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"call",
"=",
"$",
"bt",
"[",
"0",
"]",
";",
"$",
"lines",
"=",
"file",
"(",
"$",
"call",
"[",
"'file'",
"]",
")",
";",
"preg_match",
"(",
"'/'",
".",
"$",
"call",
"[",
"'function'",
"]",
".",
"'\\((.+)\\)/'",
",",
"$",
"lines",
"[",
"$",
"call",
"[",
"'line'",
"]",
"-",
"1",
"]",
",",
"$",
"matches",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Assumption failed: '",
".",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}"
] |
Precondition function that can be used to add additional constraints to
function parameters.
@param bool $condition
Condition.
@param string $message
Failure message.
@throws InvalidArgumentException If condition is false.
|
[
"Precondition",
"function",
"that",
"can",
"be",
"used",
"to",
"add",
"additional",
"constraints",
"to",
"function",
"parameters",
"."
] |
4ef3445068f0ff9c0a6512cb741831a847013b76
|
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Assume.php#L31-L44
|
239,591
|
silverorange/Net_Notifier
|
Net/Notifier/Listener.php
|
Net_Notifier_Listener.run
|
public function run()
{
$this->connect();
// tell server we want to listen
$this->connection->writeText('{ "action" : "listen" }');
while (!$this->moribund) {
$read = array($this->connection->getSocket()->getRawSocket());
// Suppressing warnings for stream_select() because it will raise
// a warning if interrupted by a signal.
$result = @stream_select(
$read,
$write = null,
$except = null,
null
);
if ($result === false || $result < 1) {
continue;
}
$moribund = false;
// check if server closed connection
$bytes = $this->connection->getSocket()->peek(1);
if (mb_strlen($bytes, '8bit') === 0) {
$this->log(
'server closed connection.' . PHP_EOL,
Net_Notifier_Logger::VERBOSITY_CLIENT
);
$moribund = true;
}
try {
if ($this->connection->read(Net_Notifier_Client::READ_BUFFER_LENGTH)) {
if ($this->connection->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) {
$messages = $this->connection->getTextMessages();
foreach ($messages as $message) {
if (mb_strlen($message, '8bit') > 0) {
$this->log(
sprintf(
'received message: "%s"' . PHP_EOL,
$message
),
Net_Notifier_Logger::VERBOSITY_MESSAGES
);
$this->handleMessage($message);
}
}
}
} else {
$this->log(
'got a message chunk from server' . PHP_EOL,
Net_Notifier_Logger::VERBOSITY_CLIENT
);
}
} catch (Net_Notifier_WebSocket_HandshakeFailureException $e) {
$this->log(
sprintf(
'failed server handshake: %s' . PHP_EOL,
$e->getMessage()
),
Net_Notifier_Logger::VERBOSITY_CLIENT
);
}
if ($moribund) {
$this->connection->close();
break;
}
}
if ($this->connection->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) {
$this->disconnect();
}
}
|
php
|
public function run()
{
$this->connect();
// tell server we want to listen
$this->connection->writeText('{ "action" : "listen" }');
while (!$this->moribund) {
$read = array($this->connection->getSocket()->getRawSocket());
// Suppressing warnings for stream_select() because it will raise
// a warning if interrupted by a signal.
$result = @stream_select(
$read,
$write = null,
$except = null,
null
);
if ($result === false || $result < 1) {
continue;
}
$moribund = false;
// check if server closed connection
$bytes = $this->connection->getSocket()->peek(1);
if (mb_strlen($bytes, '8bit') === 0) {
$this->log(
'server closed connection.' . PHP_EOL,
Net_Notifier_Logger::VERBOSITY_CLIENT
);
$moribund = true;
}
try {
if ($this->connection->read(Net_Notifier_Client::READ_BUFFER_LENGTH)) {
if ($this->connection->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) {
$messages = $this->connection->getTextMessages();
foreach ($messages as $message) {
if (mb_strlen($message, '8bit') > 0) {
$this->log(
sprintf(
'received message: "%s"' . PHP_EOL,
$message
),
Net_Notifier_Logger::VERBOSITY_MESSAGES
);
$this->handleMessage($message);
}
}
}
} else {
$this->log(
'got a message chunk from server' . PHP_EOL,
Net_Notifier_Logger::VERBOSITY_CLIENT
);
}
} catch (Net_Notifier_WebSocket_HandshakeFailureException $e) {
$this->log(
sprintf(
'failed server handshake: %s' . PHP_EOL,
$e->getMessage()
),
Net_Notifier_Logger::VERBOSITY_CLIENT
);
}
if ($moribund) {
$this->connection->close();
break;
}
}
if ($this->connection->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) {
$this->disconnect();
}
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"// tell server we want to listen",
"$",
"this",
"->",
"connection",
"->",
"writeText",
"(",
"'{ \"action\" : \"listen\" }'",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"moribund",
")",
"{",
"$",
"read",
"=",
"array",
"(",
"$",
"this",
"->",
"connection",
"->",
"getSocket",
"(",
")",
"->",
"getRawSocket",
"(",
")",
")",
";",
"// Suppressing warnings for stream_select() because it will raise",
"// a warning if interrupted by a signal.",
"$",
"result",
"=",
"@",
"stream_select",
"(",
"$",
"read",
",",
"$",
"write",
"=",
"null",
",",
"$",
"except",
"=",
"null",
",",
"null",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
"||",
"$",
"result",
"<",
"1",
")",
"{",
"continue",
";",
"}",
"$",
"moribund",
"=",
"false",
";",
"// check if server closed connection",
"$",
"bytes",
"=",
"$",
"this",
"->",
"connection",
"->",
"getSocket",
"(",
")",
"->",
"peek",
"(",
"1",
")",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"bytes",
",",
"'8bit'",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'server closed connection.'",
".",
"PHP_EOL",
",",
"Net_Notifier_Logger",
"::",
"VERBOSITY_CLIENT",
")",
";",
"$",
"moribund",
"=",
"true",
";",
"}",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"read",
"(",
"Net_Notifier_Client",
"::",
"READ_BUFFER_LENGTH",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"getState",
"(",
")",
"<",
"Net_Notifier_WebSocket_Connection",
"::",
"STATE_CLOSING",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"connection",
"->",
"getTextMessages",
"(",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"mb_strlen",
"(",
"$",
"message",
",",
"'8bit'",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'received message: \"%s\"'",
".",
"PHP_EOL",
",",
"$",
"message",
")",
",",
"Net_Notifier_Logger",
"::",
"VERBOSITY_MESSAGES",
")",
";",
"$",
"this",
"->",
"handleMessage",
"(",
"$",
"message",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"'got a message chunk from server'",
".",
"PHP_EOL",
",",
"Net_Notifier_Logger",
"::",
"VERBOSITY_CLIENT",
")",
";",
"}",
"}",
"catch",
"(",
"Net_Notifier_WebSocket_HandshakeFailureException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'failed server handshake: %s'",
".",
"PHP_EOL",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"Net_Notifier_Logger",
"::",
"VERBOSITY_CLIENT",
")",
";",
"}",
"if",
"(",
"$",
"moribund",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"getState",
"(",
")",
"<",
"Net_Notifier_WebSocket_Connection",
"::",
"STATE_CLOSING",
")",
"{",
"$",
"this",
"->",
"disconnect",
"(",
")",
";",
"}",
"}"
] |
Runs this listen client
This client listens for messages relayed from the server.
@return void
|
[
"Runs",
"this",
"listen",
"client"
] |
b446e27cd1bebd58ba89243cde1272c5d281d3fb
|
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Listener.php#L99-L187
|
239,592
|
smartsolutionsitaly/cakephp-locale-type
|
src/Database/Locale.php
|
Locale.parse
|
public static function parse($value)
{
if (is_array($value)) {
return static::fromArray((array)$value);
} elseif (is_string($value)) {
return static::fromString((string)$value);
} else {
return null;
}
}
|
php
|
public static function parse($value)
{
if (is_array($value)) {
return static::fromArray((array)$value);
} elseif (is_string($value)) {
return static::fromString((string)$value);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"parse",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"static",
"::",
"fromArray",
"(",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"static",
"::",
"fromString",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Parses a value and returns its Locale representation.
@param $value The value to parse
@return null|Locale The Locale representation of the given value or a null value.
|
[
"Parses",
"a",
"value",
"and",
"returns",
"its",
"Locale",
"representation",
"."
] |
d773fac38357f1f330ed5bb25e80fafb6feca91a
|
https://github.com/smartsolutionsitaly/cakephp-locale-type/blob/d773fac38357f1f330ed5bb25e80fafb6feca91a/src/Database/Locale.php#L53-L62
|
239,593
|
smartsolutionsitaly/cakephp-locale-type
|
src/Database/Locale.php
|
Locale.fromArray
|
public static function fromArray(array $value)
{
$language = null;
$culture = null;
if (!empty($value['language'])) {
$language = $value['language'];
} elseif ($value[0]) {
$language = $value[0];
}
if (!empty($value['culture'])) {
$culture = $value['culture'];
} elseif ($value[1]) {
$culture = $value[1];
}
return new static($language, $culture);
}
|
php
|
public static function fromArray(array $value)
{
$language = null;
$culture = null;
if (!empty($value['language'])) {
$language = $value['language'];
} elseif ($value[0]) {
$language = $value[0];
}
if (!empty($value['culture'])) {
$culture = $value['culture'];
} elseif ($value[1]) {
$culture = $value[1];
}
return new static($language, $culture);
}
|
[
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"value",
")",
"{",
"$",
"language",
"=",
"null",
";",
"$",
"culture",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
"[",
"'language'",
"]",
")",
")",
"{",
"$",
"language",
"=",
"$",
"value",
"[",
"'language'",
"]",
";",
"}",
"elseif",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"{",
"$",
"language",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
"[",
"'culture'",
"]",
")",
")",
"{",
"$",
"culture",
"=",
"$",
"value",
"[",
"'culture'",
"]",
";",
"}",
"elseif",
"(",
"$",
"value",
"[",
"1",
"]",
")",
"{",
"$",
"culture",
"=",
"$",
"value",
"[",
"1",
"]",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"language",
",",
"$",
"culture",
")",
";",
"}"
] |
Parses the given array and returns its Locale representation.
@param array $value The value to parse.
@return Locale The Locale representation of the given value or a null value.
|
[
"Parses",
"the",
"given",
"array",
"and",
"returns",
"its",
"Locale",
"representation",
"."
] |
d773fac38357f1f330ed5bb25e80fafb6feca91a
|
https://github.com/smartsolutionsitaly/cakephp-locale-type/blob/d773fac38357f1f330ed5bb25e80fafb6feca91a/src/Database/Locale.php#L70-L88
|
239,594
|
smartsolutionsitaly/cakephp-locale-type
|
src/Database/Locale.php
|
Locale.fromString
|
public static function fromString(string $value)
{
$locale = preg_split('/-|_/', $value, 2);
$language = null;
$culture = null;
if (isset($locale[0])) {
$language = $locale[0];
}
if (isset($locale[1])) {
$culture = $locale[1];
}
return new static($language, $culture);
}
|
php
|
public static function fromString(string $value)
{
$locale = preg_split('/-|_/', $value, 2);
$language = null;
$culture = null;
if (isset($locale[0])) {
$language = $locale[0];
}
if (isset($locale[1])) {
$culture = $locale[1];
}
return new static($language, $culture);
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"string",
"$",
"value",
")",
"{",
"$",
"locale",
"=",
"preg_split",
"(",
"'/-|_/'",
",",
"$",
"value",
",",
"2",
")",
";",
"$",
"language",
"=",
"null",
";",
"$",
"culture",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"locale",
"[",
"0",
"]",
")",
")",
"{",
"$",
"language",
"=",
"$",
"locale",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"locale",
"[",
"1",
"]",
")",
")",
"{",
"$",
"culture",
"=",
"$",
"locale",
"[",
"1",
"]",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"language",
",",
"$",
"culture",
")",
";",
"}"
] |
Parses the given string and returns its Locale representation.
@param string $value The value to parse.
@return Locale The Locale representation of the given value or a null value.
|
[
"Parses",
"the",
"given",
"string",
"and",
"returns",
"its",
"Locale",
"representation",
"."
] |
d773fac38357f1f330ed5bb25e80fafb6feca91a
|
https://github.com/smartsolutionsitaly/cakephp-locale-type/blob/d773fac38357f1f330ed5bb25e80fafb6feca91a/src/Database/Locale.php#L96-L111
|
239,595
|
smartsolutionsitaly/cakephp-locale-type
|
src/Database/Locale.php
|
Locale.toString
|
public function toString()
{
if ($this->_language && $this->_culture) {
return (string)$this->_language . '_' . (string)$this->_culture;
} else {
return (string)$this->_language;
}
}
|
php
|
public function toString()
{
if ($this->_language && $this->_culture) {
return (string)$this->_language . '_' . (string)$this->_culture;
} else {
return (string)$this->_language;
}
}
|
[
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_language",
"&&",
"$",
"this",
"->",
"_culture",
")",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"_language",
".",
"'_'",
".",
"(",
"string",
")",
"$",
"this",
"->",
"_culture",
";",
"}",
"else",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"_language",
";",
"}",
"}"
] |
Convert the current Locale to its string representation.
@return string A string representation of the current Locale object.
|
[
"Convert",
"the",
"current",
"Locale",
"to",
"its",
"string",
"representation",
"."
] |
d773fac38357f1f330ed5bb25e80fafb6feca91a
|
https://github.com/smartsolutionsitaly/cakephp-locale-type/blob/d773fac38357f1f330ed5bb25e80fafb6feca91a/src/Database/Locale.php#L175-L182
|
239,596
|
routegroup/native-media
|
src/Traits/Imageable.php
|
Imageable.image
|
public function image()
{
if ($this->relationLoaded('mediables')) {
return $this->mediables->where('type', 'image')->first();
}
return $this->mediables()
->where('media.type', 'image')
->whereNull('mediables.type')
->first();
}
|
php
|
public function image()
{
if ($this->relationLoaded('mediables')) {
return $this->mediables->where('type', 'image')->first();
}
return $this->mediables()
->where('media.type', 'image')
->whereNull('mediables.type')
->first();
}
|
[
"public",
"function",
"image",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relationLoaded",
"(",
"'mediables'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mediables",
"->",
"where",
"(",
"'type'",
",",
"'image'",
")",
"->",
"first",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mediables",
"(",
")",
"->",
"where",
"(",
"'media.type'",
",",
"'image'",
")",
"->",
"whereNull",
"(",
"'mediables.type'",
")",
"->",
"first",
"(",
")",
";",
"}"
] |
Image object.
@return \Routegroup\Media\File
|
[
"Image",
"object",
"."
] |
5ea35c46c2ac1019e277ec4fe698f17581524631
|
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Imageable.php#L36-L46
|
239,597
|
routegroup/native-media
|
src/Traits/Imageable.php
|
Imageable.setImageAttribute
|
public function setImageAttribute($value)
{
$value = $this->resolveMediableValue($value);
// Dont store or make lazy store
// if current model doesn't exists in database.
if (!$this->exists && $value) {
return $this->attributes['image'] = $value;
} elseif (!$this->exists) {
return;
}
$this->mediables()->sync($value);
$this->touch();
}
|
php
|
public function setImageAttribute($value)
{
$value = $this->resolveMediableValue($value);
// Dont store or make lazy store
// if current model doesn't exists in database.
if (!$this->exists && $value) {
return $this->attributes['image'] = $value;
} elseif (!$this->exists) {
return;
}
$this->mediables()->sync($value);
$this->touch();
}
|
[
"public",
"function",
"setImageAttribute",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"resolveMediableValue",
"(",
"$",
"value",
")",
";",
"// Dont store or make lazy store",
"// if current model doesn't exists in database.",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"&&",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'image'",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"mediables",
"(",
")",
"->",
"sync",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"touch",
"(",
")",
";",
"}"
] |
Image setter.
@param \Routegroup\Media\File|\Illuminate\Http\UploadedFile|integer $value
|
[
"Image",
"setter",
"."
] |
5ea35c46c2ac1019e277ec4fe698f17581524631
|
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Imageable.php#L53-L68
|
239,598
|
routegroup/native-media
|
src/Traits/Imageable.php
|
Imageable.getImageAttribute
|
public function getImageAttribute()
{
// It should have image
if ($this->exists) {
return $this->image();
}
return isset($this->attributes['image']) ? $this->attributes['image'] : null;
}
|
php
|
public function getImageAttribute()
{
// It should have image
if ($this->exists) {
return $this->image();
}
return isset($this->attributes['image']) ? $this->attributes['image'] : null;
}
|
[
"public",
"function",
"getImageAttribute",
"(",
")",
"{",
"// It should have image",
"if",
"(",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
"$",
"this",
"->",
"image",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'image'",
"]",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"'image'",
"]",
":",
"null",
";",
"}"
] |
Image getter.
@return \Routegroup\Media\File|null
|
[
"Image",
"getter",
"."
] |
5ea35c46c2ac1019e277ec4fe698f17581524631
|
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Imageable.php#L75-L83
|
239,599
|
routegroup/native-media
|
src/Traits/Imageable.php
|
Imageable.getImageUrlAttribute
|
public function getImageUrlAttribute()
{
if ($this->exists) {
$image = $this->image();
if ($image) {
return $image->url;
}
return config('media.image.default');
}
return config('media.image.default');
}
|
php
|
public function getImageUrlAttribute()
{
if ($this->exists) {
$image = $this->image();
if ($image) {
return $image->url;
}
return config('media.image.default');
}
return config('media.image.default');
}
|
[
"public",
"function",
"getImageUrlAttribute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"image",
"(",
")",
";",
"if",
"(",
"$",
"image",
")",
"{",
"return",
"$",
"image",
"->",
"url",
";",
"}",
"return",
"config",
"(",
"'media.image.default'",
")",
";",
"}",
"return",
"config",
"(",
"'media.image.default'",
")",
";",
"}"
] |
Default image url attribute.
@return string|null
|
[
"Default",
"image",
"url",
"attribute",
"."
] |
5ea35c46c2ac1019e277ec4fe698f17581524631
|
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Imageable.php#L90-L103
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.