id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
240,000 | 20centcroak/DBManagement | src/DbManagementTable.php | DbManagementTable.convertValue | private function convertValue($value, $type){
switch($type){
case "is_numeric":
$value = floatval($value);
break;
case "is_float":
$value = floatval($value);
break;
case "is_string":
$value = strval($value);
break;
default:
$value = strval($value);
}
return $value;
} | php | private function convertValue($value, $type){
switch($type){
case "is_numeric":
$value = floatval($value);
break;
case "is_float":
$value = floatval($value);
break;
case "is_string":
$value = strval($value);
break;
default:
$value = strval($value);
}
return $value;
} | [
"private",
"function",
"convertValue",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"\"is_numeric\"",
":",
"$",
"value",
"=",
"floatval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"\"is_float\"",
":",
"$",
"value",
"=",
"floatval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"\"is_string\"",
":",
"$",
"value",
"=",
"strval",
"(",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"strval",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | values are converted thanks to the given type
@param mixed $value the value to convert
@param String $type the function name for data type testing: "is_numeric" or "is_string"
@return the converted value | [
"values",
"are",
"converted",
"thanks",
"to",
"the",
"given",
"type"
] | 1c137bb284712c2830e8cf792237adcc1d86d6f4 | https://github.com/20centcroak/DBManagement/blob/1c137bb284712c2830e8cf792237adcc1d86d6f4/src/DbManagementTable.php#L191-L208 |
240,001 | novuso/common | src/Application/EventSourcing/EventProcessor.php | EventProcessor.process | public function process(EventRecord $eventRecord): void
{
$this->eventStore->append($eventRecord);
$this->eventDispatcher->dispatch($eventRecord->eventMessage());
} | php | public function process(EventRecord $eventRecord): void
{
$this->eventStore->append($eventRecord);
$this->eventDispatcher->dispatch($eventRecord->eventMessage());
} | [
"public",
"function",
"process",
"(",
"EventRecord",
"$",
"eventRecord",
")",
":",
"void",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"append",
"(",
"$",
"eventRecord",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"$",
"eventRecord",
"->",
"eventMessage",
"(",
")",
")",
";",
"}"
] | Processes an event record
Only dispatches an event if the event store does not throw an exception.
@param EventRecord $eventRecord The event record
@return void
@throws Throwable When an error occurs | [
"Processes",
"an",
"event",
"record"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/EventSourcing/EventProcessor.php#L56-L60 |
240,002 | ForceLabsDev/framework | src/Html/Html.php | Html.create | public static function create($name, $content = '', $singleTag = false): Element
{
return new Element($name, $content, $singleTag);
} | php | public static function create($name, $content = '', $singleTag = false): Element
{
return new Element($name, $content, $singleTag);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"content",
"=",
"''",
",",
"$",
"singleTag",
"=",
"false",
")",
":",
"Element",
"{",
"return",
"new",
"Element",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"singleTag",
")",
";",
"}"
] | creates a new Html object.
@param string $name
@param mixed $content string or Closure
@param bool $singleTag
@return Element | [
"creates",
"a",
"new",
"Html",
"object",
"."
] | e2288582432857771e85c9859acd6d32e5f2f9b7 | https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Html/Html.php#L16-L19 |
240,003 | flavorzyb/simple | src/Support/SimpleString.php | SimpleString.isSameString | public function isSameString($leftString, $rightString)
{
if (is_string($leftString) && is_string($rightString) &&
strlen($leftString) == strlen($rightString) &&
md5($leftString) == md5($rightString)
)
{
return true;
}
return false;
} | php | public function isSameString($leftString, $rightString)
{
if (is_string($leftString) && is_string($rightString) &&
strlen($leftString) == strlen($rightString) &&
md5($leftString) == md5($rightString)
)
{
return true;
}
return false;
} | [
"public",
"function",
"isSameString",
"(",
"$",
"leftString",
",",
"$",
"rightString",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"leftString",
")",
"&&",
"is_string",
"(",
"$",
"rightString",
")",
"&&",
"strlen",
"(",
"$",
"leftString",
")",
"==",
"strlen",
"(",
"$",
"rightString",
")",
"&&",
"md5",
"(",
"$",
"leftString",
")",
"==",
"md5",
"(",
"$",
"rightString",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | check the strings is the same or not
@param string $leftString
@param string $rightString
@return bool | [
"check",
"the",
"strings",
"is",
"the",
"same",
"or",
"not"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Support/SimpleString.php#L37-L48 |
240,004 | BudgeIt/composer-builder | src/Runner.php | Runner.runInstallers | public function runInstallers(PackageWrapper $package, $isDevMode)
{
foreach ($this->installers as $installer) {
if ($installer->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s installer for %s</info>',
$installer->getName(),
$package->getPackage()->getPrettyName()
)
);
$installer->install($package, $isDevMode);
}
}
} | php | public function runInstallers(PackageWrapper $package, $isDevMode)
{
foreach ($this->installers as $installer) {
if ($installer->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s installer for %s</info>',
$installer->getName(),
$package->getPackage()->getPrettyName()
)
);
$installer->install($package, $isDevMode);
}
}
} | [
"public",
"function",
"runInstallers",
"(",
"PackageWrapper",
"$",
"package",
",",
"$",
"isDevMode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"installers",
"as",
"$",
"installer",
")",
"{",
"if",
"(",
"$",
"installer",
"->",
"supports",
"(",
"$",
"package",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"sprintf",
"(",
"'<info>Running %s installer for %s</info>'",
",",
"$",
"installer",
"->",
"getName",
"(",
")",
",",
"$",
"package",
"->",
"getPackage",
"(",
")",
"->",
"getPrettyName",
"(",
")",
")",
")",
";",
"$",
"installer",
"->",
"install",
"(",
"$",
"package",
",",
"$",
"isDevMode",
")",
";",
"}",
"}",
"}"
] | Run the installers for a package
@param PackageWrapper $package
@param bool $isDevMode | [
"Run",
"the",
"installers",
"for",
"a",
"package"
] | ce39fdd501425cf87ec8b20d1db2700c77ee2563 | https://github.com/BudgeIt/composer-builder/blob/ce39fdd501425cf87ec8b20d1db2700c77ee2563/src/Runner.php#L61-L75 |
240,005 | BudgeIt/composer-builder | src/Runner.php | Runner.runBuildTools | public function runBuildTools(PackageWrapper $package, $isDevMode)
{
foreach ($this->buildTools as $buildTool) {
if ($buildTool->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s builder for %s</info>',
$buildTool->getName(),
$package->getPackage()->getPrettyName()
)
);
$buildTool->build($package, $isDevMode);
}
}
} | php | public function runBuildTools(PackageWrapper $package, $isDevMode)
{
foreach ($this->buildTools as $buildTool) {
if ($buildTool->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s builder for %s</info>',
$buildTool->getName(),
$package->getPackage()->getPrettyName()
)
);
$buildTool->build($package, $isDevMode);
}
}
} | [
"public",
"function",
"runBuildTools",
"(",
"PackageWrapper",
"$",
"package",
",",
"$",
"isDevMode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"buildTools",
"as",
"$",
"buildTool",
")",
"{",
"if",
"(",
"$",
"buildTool",
"->",
"supports",
"(",
"$",
"package",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"sprintf",
"(",
"'<info>Running %s builder for %s</info>'",
",",
"$",
"buildTool",
"->",
"getName",
"(",
")",
",",
"$",
"package",
"->",
"getPackage",
"(",
")",
"->",
"getPrettyName",
"(",
")",
")",
")",
";",
"$",
"buildTool",
"->",
"build",
"(",
"$",
"package",
",",
"$",
"isDevMode",
")",
";",
"}",
"}",
"}"
] | Run the build tools for a package
@param PackageWrapper $package
@param bool $isDevMode | [
"Run",
"the",
"build",
"tools",
"for",
"a",
"package"
] | ce39fdd501425cf87ec8b20d1db2700c77ee2563 | https://github.com/BudgeIt/composer-builder/blob/ce39fdd501425cf87ec8b20d1db2700c77ee2563/src/Runner.php#L83-L97 |
240,006 | liftkit/core | src/Application/Application.php | Application.registerHook | public function registerHook ($key, Hook $hook)
{
if (isset($this->hooks[$key])) {
throw new ReregisterHookException('Attempt to re-register hook ' . $key);
}
if (! $key || ! is_string($key)) {
throw new InvalidHookIdentifierException('Invalid hook identifier ' . var_export($key, true));
}
$this->hooks[$key] = $hook;
} | php | public function registerHook ($key, Hook $hook)
{
if (isset($this->hooks[$key])) {
throw new ReregisterHookException('Attempt to re-register hook ' . $key);
}
if (! $key || ! is_string($key)) {
throw new InvalidHookIdentifierException('Invalid hook identifier ' . var_export($key, true));
}
$this->hooks[$key] = $hook;
} | [
"public",
"function",
"registerHook",
"(",
"$",
"key",
",",
"Hook",
"$",
"hook",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"ReregisterHookException",
"(",
"'Attempt to re-register hook '",
".",
"$",
"key",
")",
";",
"}",
"if",
"(",
"!",
"$",
"key",
"||",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidHookIdentifierException",
"(",
"'Invalid hook identifier '",
".",
"var_export",
"(",
"$",
"key",
",",
"true",
")",
")",
";",
"}",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
"=",
"$",
"hook",
";",
"}"
] | Registers a hook with the application for future interactions.
@see Hook
@api
@param string $key String identifier for hook used in subsequent calls to bindHook() and triggerHook().
@param Hook $hook The hook to be registered.
@throws InvalidHookIdentifierException
@throws ReregisterHookException | [
"Registers",
"a",
"hook",
"with",
"the",
"application",
"for",
"future",
"interactions",
"."
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Application/Application.php#L48-L59 |
240,007 | liftkit/core | src/Application/Application.php | Application.bindHook | public function bindHook ($key, $closure, $precedence = 0)
{
if (isset($this->hooks[$key])) {
$this->hooks[$key]->bind($closure, $precedence);
} else {
throw new UnregisteredHookException('Attempt to bind unregistered hook ' . $key);
}
} | php | public function bindHook ($key, $closure, $precedence = 0)
{
if (isset($this->hooks[$key])) {
$this->hooks[$key]->bind($closure, $precedence);
} else {
throw new UnregisteredHookException('Attempt to bind unregistered hook ' . $key);
}
} | [
"public",
"function",
"bindHook",
"(",
"$",
"key",
",",
"$",
"closure",
",",
"$",
"precedence",
"=",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
"->",
"bind",
"(",
"$",
"closure",
",",
"$",
"precedence",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnregisteredHookException",
"(",
"'Attempt to bind unregistered hook '",
".",
"$",
"key",
")",
";",
"}",
"}"
] | Binds an action to be taken when a hook is triggered. The hook must be registered before it can be bound to an action.
@see Hook::bind()
@api
@param string $key String identifier of registered hook.
@param callable $closure A closure representing the action to be taken when the hook is triggered.
@param int $precedence Determines the order that the actions will occur in when the hook is triggered, lowest first.
@throws UnregisteredHookException | [
"Binds",
"an",
"action",
"to",
"be",
"taken",
"when",
"a",
"hook",
"is",
"triggered",
".",
"The",
"hook",
"must",
"be",
"registered",
"before",
"it",
"can",
"be",
"bound",
"to",
"an",
"action",
"."
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Application/Application.php#L74-L81 |
240,008 | liftkit/core | src/Application/Application.php | Application.triggerHook | public function triggerHook ($key, $args = array(), $precedence = null)
{
if (isset($this->hooks[$key])) {
return $this->hooks[$key]->trigger($args, $precedence);
} else {
throw new UnregisteredHookException('Attempt to trigger unregistered hook ' . $key);
}
} | php | public function triggerHook ($key, $args = array(), $precedence = null)
{
if (isset($this->hooks[$key])) {
return $this->hooks[$key]->trigger($args, $precedence);
} else {
throw new UnregisteredHookException('Attempt to trigger unregistered hook ' . $key);
}
} | [
"public",
"function",
"triggerHook",
"(",
"$",
"key",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"precedence",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"hooks",
"[",
"$",
"key",
"]",
"->",
"trigger",
"(",
"$",
"args",
",",
"$",
"precedence",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnregisteredHookException",
"(",
"'Attempt to trigger unregistered hook '",
".",
"$",
"key",
")",
";",
"}",
"}"
] | Will sequentially call each action bound to the hook. The hook must be registered before it can be bound to an action.
The format of the result of this call as well as the behavior from call to call varies by the type of hook.
@see Hook::trigger()
@api
@param string $key String identifier of registered hook.
@param array $args Arguments which will be passed to each callback.
@param null $precedence If supplied, the hook's actions will only be executed for a given precedence.
@return mixed
@throws UnregisteredHookException | [
"Will",
"sequentially",
"call",
"each",
"action",
"bound",
"to",
"the",
"hook",
".",
"The",
"hook",
"must",
"be",
"registered",
"before",
"it",
"can",
"be",
"bound",
"to",
"an",
"action",
"."
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Application/Application.php#L99-L106 |
240,009 | mattvb91/LightModel | src/LightModel.php | LightModel.typeCastModel | private static function typeCastModel(LightModel $model)
{
if (in_array(self::OPTIONS_TYPECAST, self::$initOptions))
{
foreach ($model->getTable()->getColumns() as $column)
{
/* @var $column Column */
if (in_array($column->getField(), get_object_vars($model)))
{
if ($column->getType() === Column::TYPE_INT)
{
$field = $column->getField();
settype($model->$field, Column::TYPE_INT);
}
}
}
}
return $model;
} | php | private static function typeCastModel(LightModel $model)
{
if (in_array(self::OPTIONS_TYPECAST, self::$initOptions))
{
foreach ($model->getTable()->getColumns() as $column)
{
/* @var $column Column */
if (in_array($column->getField(), get_object_vars($model)))
{
if ($column->getType() === Column::TYPE_INT)
{
$field = $column->getField();
settype($model->$field, Column::TYPE_INT);
}
}
}
}
return $model;
} | [
"private",
"static",
"function",
"typeCastModel",
"(",
"LightModel",
"$",
"model",
")",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"OPTIONS_TYPECAST",
",",
"self",
"::",
"$",
"initOptions",
")",
")",
"{",
"foreach",
"(",
"$",
"model",
"->",
"getTable",
"(",
")",
"->",
"getColumns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"/* @var $column Column */",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"getField",
"(",
")",
",",
"get_object_vars",
"(",
"$",
"model",
")",
")",
")",
"{",
"if",
"(",
"$",
"column",
"->",
"getType",
"(",
")",
"===",
"Column",
"::",
"TYPE_INT",
")",
"{",
"$",
"field",
"=",
"$",
"column",
"->",
"getField",
"(",
")",
";",
"settype",
"(",
"$",
"model",
"->",
"$",
"field",
",",
"Column",
"::",
"TYPE_INT",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"model",
";",
"}"
] | Typecast the models columns to the associated mysql data types.
@param LightModel $model
@return LightModel
TODO implement typecasting to other types | [
"Typecast",
"the",
"models",
"columns",
"to",
"the",
"associated",
"mysql",
"data",
"types",
"."
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L77-L96 |
240,010 | mattvb91/LightModel | src/LightModel.php | LightModel.init | public static function init(PDO $pdo, $options = [])
{
DB::init($pdo);
self::$initOptions = $options;
} | php | public static function init(PDO $pdo, $options = [])
{
DB::init($pdo);
self::$initOptions = $options;
} | [
"public",
"static",
"function",
"init",
"(",
"PDO",
"$",
"pdo",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"DB",
"::",
"init",
"(",
"$",
"pdo",
")",
";",
"self",
"::",
"$",
"initOptions",
"=",
"$",
"options",
";",
"}"
] | Set up our options and pass PDO to our DB Singleton
@param PDO $pdo
@param array $options | [
"Set",
"up",
"our",
"options",
"and",
"pass",
"PDO",
"to",
"our",
"DB",
"Singleton"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L116-L120 |
240,011 | mattvb91/LightModel | src/LightModel.php | LightModel.getTableName | public function getTableName(): string
{
if ($this->tableName === null)
{
$this->tableName = (new \ReflectionClass($this))->getShortName();
}
return $this->tableName;
} | php | public function getTableName(): string
{
if ($this->tableName === null)
{
$this->tableName = (new \ReflectionClass($this))->getShortName();
}
return $this->tableName;
} | [
"public",
"function",
"getTableName",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"tableName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"tableName",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getShortName",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tableName",
";",
"}"
] | Check if tableName has been set or return based on class;
@return String | [
"Check",
"if",
"tableName",
"has",
"been",
"set",
"or",
"return",
"based",
"on",
"class",
";"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L126-L134 |
240,012 | mattvb91/LightModel | src/LightModel.php | LightModel.handleFilter | private static function handleFilter(String &$sql, $filter, LightModel $class): array
{
$params = [];
if (isset($filter[self::FILTER_ORDER]))
{
$order = $filter[self::FILTER_ORDER];
unset($filter[self::FILTER_ORDER]);
}
if (isset($filter[self::FILTER_LIMIT]))
{
$limit = (int) $filter[self::FILTER_LIMIT];
unset($filter[self::FILTER_LIMIT]);
}
foreach ($filter as $filter => $value)
{
if (! $class->getTable()->hasColumn($filter))
continue;
//Default operator for all queries
$operator = '=';
//Check if the operator was passed in
if (is_array($value))
{
$operator = $value[0];
$value = $value[1];
}
switch ($class->getTable()->getColumn($filter)->getType())
{
case Column::TYPE_INT:
$value = (int) $value;
break;
default:
$value = (string) $value;
}
$sql .= ' AND `' . $filter . '` ' . $operator . ' :' . $filter;
$params[':' . $filter] = $value;
}
if (isset($order))
{
$sql .= ' ORDER BY ' . $order;
}
if (isset($limit))
{
$sql .= ' LIMIT ' . $limit;
}
return $params;
} | php | private static function handleFilter(String &$sql, $filter, LightModel $class): array
{
$params = [];
if (isset($filter[self::FILTER_ORDER]))
{
$order = $filter[self::FILTER_ORDER];
unset($filter[self::FILTER_ORDER]);
}
if (isset($filter[self::FILTER_LIMIT]))
{
$limit = (int) $filter[self::FILTER_LIMIT];
unset($filter[self::FILTER_LIMIT]);
}
foreach ($filter as $filter => $value)
{
if (! $class->getTable()->hasColumn($filter))
continue;
//Default operator for all queries
$operator = '=';
//Check if the operator was passed in
if (is_array($value))
{
$operator = $value[0];
$value = $value[1];
}
switch ($class->getTable()->getColumn($filter)->getType())
{
case Column::TYPE_INT:
$value = (int) $value;
break;
default:
$value = (string) $value;
}
$sql .= ' AND `' . $filter . '` ' . $operator . ' :' . $filter;
$params[':' . $filter] = $value;
}
if (isset($order))
{
$sql .= ' ORDER BY ' . $order;
}
if (isset($limit))
{
$sql .= ' LIMIT ' . $limit;
}
return $params;
} | [
"private",
"static",
"function",
"handleFilter",
"(",
"String",
"&",
"$",
"sql",
",",
"$",
"filter",
",",
"LightModel",
"$",
"class",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"filter",
"[",
"self",
"::",
"FILTER_ORDER",
"]",
")",
")",
"{",
"$",
"order",
"=",
"$",
"filter",
"[",
"self",
"::",
"FILTER_ORDER",
"]",
";",
"unset",
"(",
"$",
"filter",
"[",
"self",
"::",
"FILTER_ORDER",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"filter",
"[",
"self",
"::",
"FILTER_LIMIT",
"]",
")",
")",
"{",
"$",
"limit",
"=",
"(",
"int",
")",
"$",
"filter",
"[",
"self",
"::",
"FILTER_LIMIT",
"]",
";",
"unset",
"(",
"$",
"filter",
"[",
"self",
"::",
"FILTER_LIMIT",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"filter",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"class",
"->",
"getTable",
"(",
")",
"->",
"hasColumn",
"(",
"$",
"filter",
")",
")",
"continue",
";",
"//Default operator for all queries",
"$",
"operator",
"=",
"'='",
";",
"//Check if the operator was passed in",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"operator",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"value",
"[",
"1",
"]",
";",
"}",
"switch",
"(",
"$",
"class",
"->",
"getTable",
"(",
")",
"->",
"getColumn",
"(",
"$",
"filter",
")",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"Column",
"::",
"TYPE_INT",
":",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"sql",
".=",
"' AND `'",
".",
"$",
"filter",
".",
"'` '",
".",
"$",
"operator",
".",
"' :'",
".",
"$",
"filter",
";",
"$",
"params",
"[",
"':'",
".",
"$",
"filter",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"order",
")",
")",
"{",
"$",
"sql",
".=",
"' ORDER BY '",
".",
"$",
"order",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"sql",
".=",
"' LIMIT '",
".",
"$",
"limit",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Parse filters & return the associated params for passing into PDO query
@param String $sql
@param $filter
@param LightModel $class
@return array | [
"Parse",
"filters",
"&",
"return",
"the",
"associated",
"params",
"for",
"passing",
"into",
"PDO",
"query"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L198-L253 |
240,013 | mattvb91/LightModel | src/LightModel.php | LightModel.getItems | public static function getItems($filter = []): array
{
$res = [];
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$sql = 'SELECT * FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
foreach ($query->fetchAll(PDO::FETCH_CLASS, $className) as $item)
{
$res[] = self::typeCastModel($item);
}
return $res;
} | php | public static function getItems($filter = []): array
{
$res = [];
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$sql = 'SELECT * FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
foreach ($query->fetchAll(PDO::FETCH_CLASS, $className) as $item)
{
$res[] = self::typeCastModel($item);
}
return $res;
} | [
"public",
"static",
"function",
"getItems",
"(",
"$",
"filter",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"/* @var $class LightModel */",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"class",
"=",
"new",
"$",
"className",
";",
"$",
"sql",
"=",
"'SELECT * FROM '",
".",
"$",
"class",
"->",
"getTableName",
"(",
")",
".",
"' WHERE 1=1'",
";",
"$",
"params",
"=",
"self",
"::",
"handleFilter",
"(",
"$",
"sql",
",",
"$",
"filter",
",",
"$",
"class",
")",
";",
"$",
"query",
"=",
"DB",
"::",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"query",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"query",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"className",
")",
"as",
"$",
"item",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"self",
"::",
"typeCastModel",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Get all items based on filter
@param array $filter
@return array | [
"Get",
"all",
"items",
"based",
"on",
"filter"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L261-L281 |
240,014 | mattvb91/LightModel | src/LightModel.php | LightModel.getKeys | public static function getKeys($filter = []): array
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT ' . $tableKey . ' FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
$res = [];
foreach ($query->fetchAll() as $key => $value)
{
$res[] = $value[0];
}
return $res;
} | php | public static function getKeys($filter = []): array
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT ' . $tableKey . ' FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
$res = [];
foreach ($query->fetchAll() as $key => $value)
{
$res[] = $value[0];
}
return $res;
} | [
"public",
"static",
"function",
"getKeys",
"(",
"$",
"filter",
"=",
"[",
"]",
")",
":",
"array",
"{",
"/* @var $class LightModel */",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"class",
"=",
"new",
"$",
"className",
";",
"$",
"tableKey",
"=",
"$",
"class",
"->",
"getKeyName",
"(",
")",
";",
"$",
"sql",
"=",
"'SELECT '",
".",
"$",
"tableKey",
".",
"' FROM '",
".",
"$",
"class",
"->",
"getTableName",
"(",
")",
".",
"' WHERE 1=1'",
";",
"$",
"params",
"=",
"self",
"::",
"handleFilter",
"(",
"$",
"sql",
",",
"$",
"filter",
",",
"$",
"class",
")",
";",
"$",
"query",
"=",
"DB",
"::",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"query",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Get array of keys that match the specified filters.
Can be used when loading large quantities of models is not an option.
@param array $filter
@return array | [
"Get",
"array",
"of",
"keys",
"that",
"match",
"the",
"specified",
"filters",
".",
"Can",
"be",
"used",
"when",
"loading",
"large",
"quantities",
"of",
"models",
"is",
"not",
"an",
"option",
"."
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L290-L311 |
240,015 | mattvb91/LightModel | src/LightModel.php | LightModel.count | public static function count($filter = []): int
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
return (int) $query->fetchColumn(0);
} | php | public static function count($filter = []): int
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
return (int) $query->fetchColumn(0);
} | [
"public",
"static",
"function",
"count",
"(",
"$",
"filter",
"=",
"[",
"]",
")",
":",
"int",
"{",
"/* @var $class LightModel */",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"class",
"=",
"new",
"$",
"className",
";",
"$",
"tableKey",
"=",
"$",
"class",
"->",
"getKeyName",
"(",
")",
";",
"$",
"sql",
"=",
"'SELECT COUNT('",
".",
"$",
"tableKey",
".",
"') FROM '",
".",
"$",
"class",
"->",
"getTableName",
"(",
")",
".",
"' WHERE 1=1'",
";",
"$",
"params",
"=",
"self",
"::",
"handleFilter",
"(",
"$",
"sql",
",",
"$",
"filter",
",",
"$",
"class",
")",
";",
"$",
"query",
"=",
"DB",
"::",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"query",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"return",
"(",
"int",
")",
"$",
"query",
"->",
"fetchColumn",
"(",
"0",
")",
";",
"}"
] | Count items based on filter
@param array $filter
@return int | [
"Count",
"items",
"based",
"on",
"filter"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L319-L333 |
240,016 | mattvb91/LightModel | src/LightModel.php | LightModel.exists | public function exists(): bool
{
$tableKey = $this->getKeyName();
//If key isn't set we cant associate this record with DB
if (! isset($this->$tableKey))
{
return false;
}
$sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
$query = DB::getConnection()->prepare($sql);
$query->execute(['key' => $this->getKey()]);
return boolval($query->fetchColumn(0));
} | php | public function exists(): bool
{
$tableKey = $this->getKeyName();
//If key isn't set we cant associate this record with DB
if (! isset($this->$tableKey))
{
return false;
}
$sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
$query = DB::getConnection()->prepare($sql);
$query->execute(['key' => $this->getKey()]);
return boolval($query->fetchColumn(0));
} | [
"public",
"function",
"exists",
"(",
")",
":",
"bool",
"{",
"$",
"tableKey",
"=",
"$",
"this",
"->",
"getKeyName",
"(",
")",
";",
"//If key isn't set we cant associate this record with DB",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"$",
"tableKey",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"sql",
"=",
"'SELECT EXISTS(SELECT '",
".",
"$",
"tableKey",
".",
"' FROM '",
".",
"$",
"this",
"->",
"getTableName",
"(",
")",
".",
"' WHERE '",
".",
"$",
"this",
"->",
"getKeyName",
"(",
")",
".",
"' = :key LIMIT 1)'",
";",
"$",
"query",
"=",
"DB",
"::",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"query",
"->",
"execute",
"(",
"[",
"'key'",
"=>",
"$",
"this",
"->",
"getKey",
"(",
")",
"]",
")",
";",
"return",
"boolval",
"(",
"$",
"query",
"->",
"fetchColumn",
"(",
"0",
")",
")",
";",
"}"
] | Check does the current item exist.
@return bool | [
"Check",
"does",
"the",
"current",
"item",
"exist",
"."
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L341-L356 |
240,017 | mattvb91/LightModel | src/LightModel.php | LightModel.refresh | public function refresh()
{
$keyName = $this->keyName;
//If we don't have a key we cant refresh
if (! isset($this->$keyName))
{
return;
}
$dbItem = self::getOneByKey($this->getKey());
//Check if we are already the same
if ($dbItem == $this)
{
return;
}
//Get values from DB & check if they match. Update if needed
foreach (get_object_vars($dbItem) as $var => $val)
{
if ($this->$var !== $val)
{
$this->$var = $val;
}
}
} | php | public function refresh()
{
$keyName = $this->keyName;
//If we don't have a key we cant refresh
if (! isset($this->$keyName))
{
return;
}
$dbItem = self::getOneByKey($this->getKey());
//Check if we are already the same
if ($dbItem == $this)
{
return;
}
//Get values from DB & check if they match. Update if needed
foreach (get_object_vars($dbItem) as $var => $val)
{
if ($this->$var !== $val)
{
$this->$var = $val;
}
}
} | [
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"keyName",
"=",
"$",
"this",
"->",
"keyName",
";",
"//If we don't have a key we cant refresh",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"$",
"keyName",
")",
")",
"{",
"return",
";",
"}",
"$",
"dbItem",
"=",
"self",
"::",
"getOneByKey",
"(",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
";",
"//Check if we are already the same",
"if",
"(",
"$",
"dbItem",
"==",
"$",
"this",
")",
"{",
"return",
";",
"}",
"//Get values from DB & check if they match. Update if needed",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"dbItem",
")",
"as",
"$",
"var",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"$",
"var",
"!==",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"$",
"var",
"=",
"$",
"val",
";",
"}",
"}",
"}"
] | Reload the current Model
TODO fetchColumns instead of self::getOneByKey() to only update column values | [
"Reload",
"the",
"current",
"Model"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L363-L389 |
240,018 | mattvb91/LightModel | src/LightModel.php | LightModel.delete | public function delete(): bool
{
if (! $this->exists())
{
return false;
}
$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
$query = DB::getConnection()->prepare($sql);
return $query->execute(['key' => $this->getKey()]);
} | php | public function delete(): bool
{
if (! $this->exists())
{
return false;
}
$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
$query = DB::getConnection()->prepare($sql);
return $query->execute(['key' => $this->getKey()]);
} | [
"public",
"function",
"delete",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"sql",
"=",
"'DELETE FROM '",
".",
"$",
"this",
"->",
"getTableName",
"(",
")",
".",
"' WHERE '",
".",
"$",
"this",
"->",
"getKeyName",
"(",
")",
".",
"' = :key'",
";",
"$",
"query",
"=",
"DB",
"::",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"query",
"->",
"execute",
"(",
"[",
"'key'",
"=>",
"$",
"this",
"->",
"getKey",
"(",
")",
"]",
")",
";",
"}"
] | Delete a model from the DB
@return bool | [
"Delete",
"a",
"model",
"from",
"the",
"DB"
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L468-L479 |
240,019 | mattvb91/LightModel | src/LightModel.php | LightModel.belongsTo | protected function belongsTo($class, $foreignKey): ?LightModel
{
$identifier = implode('_', [$class, $foreignKey]);
if (! isset($this->_belongsTo[$identifier]))
{
if (! $this->getTable()->hasColumn($foreignKey))
{
throw new ColumnMissingException($this->getTableName() . ' does not have column: ' . $foreignKey);
}
$this->_belongsTo[$identifier] = $class::getOneByKey($this->$foreignKey);
}
return $this->_belongsTo[$identifier];
} | php | protected function belongsTo($class, $foreignKey): ?LightModel
{
$identifier = implode('_', [$class, $foreignKey]);
if (! isset($this->_belongsTo[$identifier]))
{
if (! $this->getTable()->hasColumn($foreignKey))
{
throw new ColumnMissingException($this->getTableName() . ' does not have column: ' . $foreignKey);
}
$this->_belongsTo[$identifier] = $class::getOneByKey($this->$foreignKey);
}
return $this->_belongsTo[$identifier];
} | [
"protected",
"function",
"belongsTo",
"(",
"$",
"class",
",",
"$",
"foreignKey",
")",
":",
"?",
"LightModel",
"{",
"$",
"identifier",
"=",
"implode",
"(",
"'_'",
",",
"[",
"$",
"class",
",",
"$",
"foreignKey",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_belongsTo",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"hasColumn",
"(",
"$",
"foreignKey",
")",
")",
"{",
"throw",
"new",
"ColumnMissingException",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
".",
"' does not have column: '",
".",
"$",
"foreignKey",
")",
";",
"}",
"$",
"this",
"->",
"_belongsTo",
"[",
"$",
"identifier",
"]",
"=",
"$",
"class",
"::",
"getOneByKey",
"(",
"$",
"this",
"->",
"$",
"foreignKey",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_belongsTo",
"[",
"$",
"identifier",
"]",
";",
"}"
] | Load the specified belongsTo relation model.
@param $class
@param $foreignKey
@return LightModel
@throws Exception | [
"Load",
"the",
"specified",
"belongsTo",
"relation",
"model",
"."
] | 139b50320bb88ce7618503bbabab8712510eb69f | https://github.com/mattvb91/LightModel/blob/139b50320bb88ce7618503bbabab8712510eb69f/src/LightModel.php#L489-L504 |
240,020 | dreadlokeur/Midi-ChloriansPHP | src/utility/Date.php | Date.getAge | public function getAge($day, $month, $year) {
$years = date('Y') - $year;
if (date('m') < $month)
$years--;
elseif (date('d') < $day && date('m') == $month)
$years--;
return $years;
} | php | public function getAge($day, $month, $year) {
$years = date('Y') - $year;
if (date('m') < $month)
$years--;
elseif (date('d') < $day && date('m') == $month)
$years--;
return $years;
} | [
"public",
"function",
"getAge",
"(",
"$",
"day",
",",
"$",
"month",
",",
"$",
"year",
")",
"{",
"$",
"years",
"=",
"date",
"(",
"'Y'",
")",
"-",
"$",
"year",
";",
"if",
"(",
"date",
"(",
"'m'",
")",
"<",
"$",
"month",
")",
"$",
"years",
"--",
";",
"elseif",
"(",
"date",
"(",
"'d'",
")",
"<",
"$",
"day",
"&&",
"date",
"(",
"'m'",
")",
"==",
"$",
"month",
")",
"$",
"years",
"--",
";",
"return",
"$",
"years",
";",
"}"
] | Permet de calculer un age depuis une date de naissance
@access public
@param string $day le jour de naissance
@param string $month le mois de naissance
@param string $year l'année de naissance
@return string $years l'age | [
"Permet",
"de",
"calculer",
"un",
"age",
"depuis",
"une",
"date",
"de",
"naissance"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/utility/Date.php#L144-L152 |
240,021 | hediet/php-type-reflection | src/Hediet/Types/ClassType.php | ClassType.getProperties | public function getProperties()
{
//todo cache
$result = array();
foreach ($this->getReflectionClass()->getProperties() as $m)
{
$result[] = PropertyInfo::__internal_create($this, $m);
}
return $result;
} | php | public function getProperties()
{
//todo cache
$result = array();
foreach ($this->getReflectionClass()->getProperties() as $m)
{
$result[] = PropertyInfo::__internal_create($this, $m);
}
return $result;
} | [
"public",
"function",
"getProperties",
"(",
")",
"{",
"//todo cache",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
"->",
"getProperties",
"(",
")",
"as",
"$",
"m",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"PropertyInfo",
"::",
"__internal_create",
"(",
"$",
"this",
",",
"$",
"m",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Gets a list of all defined properties.
@return PropertyInfo[] | [
"Gets",
"a",
"list",
"of",
"all",
"defined",
"properties",
"."
] | 4a049c0e35f35cf95769f3823c915a3c41d6a292 | https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ClassType.php#L37-L46 |
240,022 | hediet/php-type-reflection | src/Hediet/Types/ClassType.php | ClassType.getProperty | public function getProperty($name)
{
$m = $this->getReflectionClass()->getProperty($name);
return PropertyInfo::__internal_create($this, $m);
} | php | public function getProperty($name)
{
$m = $this->getReflectionClass()->getProperty($name);
return PropertyInfo::__internal_create($this, $m);
} | [
"public",
"function",
"getProperty",
"(",
"$",
"name",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
"->",
"getProperty",
"(",
"$",
"name",
")",
";",
"return",
"PropertyInfo",
"::",
"__internal_create",
"(",
"$",
"this",
",",
"$",
"m",
")",
";",
"}"
] | Gets a property by its name.
@param string $name
@return PropertyInfo
@throws ReflectionException A reflection exception will be thrown, if the property does not exist. | [
"Gets",
"a",
"property",
"by",
"its",
"name",
"."
] | 4a049c0e35f35cf95769f3823c915a3c41d6a292 | https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ClassType.php#L55-L59 |
240,023 | hediet/php-type-reflection | src/Hediet/Types/ClassType.php | ClassType.isAssignableFrom | public function isAssignableFrom(Type $type)
{
if ($type->getName() === $this->getName())
return true;
if (!($type instanceof ClassType))
return false;
return $type->isSubtypeOf($this);
} | php | public function isAssignableFrom(Type $type)
{
if ($type->getName() === $this->getName())
return true;
if (!($type instanceof ClassType))
return false;
return $type->isSubtypeOf($this);
} | [
"public",
"function",
"isAssignableFrom",
"(",
"Type",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"->",
"getName",
"(",
")",
"===",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"!",
"(",
"$",
"type",
"instanceof",
"ClassType",
")",
")",
"return",
"false",
";",
"return",
"$",
"type",
"->",
"isSubtypeOf",
"(",
"$",
"this",
")",
";",
"}"
] | Checks whether the provided type equals this type or is a subtype of this type.
@param Type $type
@return boolean | [
"Checks",
"whether",
"the",
"provided",
"type",
"equals",
"this",
"type",
"or",
"is",
"a",
"subtype",
"of",
"this",
"type",
"."
] | 4a049c0e35f35cf95769f3823c915a3c41d6a292 | https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ClassType.php#L78-L87 |
240,024 | hediet/php-type-reflection | src/Hediet/Types/ClassType.php | ClassType.isAssignableFromValue | public function isAssignableFromValue($value)
{
if (!is_object($value))
return false;
if (get_class($value) === $this->getName())
return true;
return is_subclass_of($value, $this->className);
} | php | public function isAssignableFromValue($value)
{
if (!is_object($value))
return false;
if (get_class($value) === $this->getName())
return true;
return is_subclass_of($value, $this->className);
} | [
"public",
"function",
"isAssignableFromValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"value",
")",
")",
"return",
"false",
";",
"if",
"(",
"get_class",
"(",
"$",
"value",
")",
"===",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"return",
"true",
";",
"return",
"is_subclass_of",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"className",
")",
";",
"}"
] | Checks whether the provided value is an instance of either this type or a subclass of this type.
@param mixed $value
@return boolean | [
"Checks",
"whether",
"the",
"provided",
"value",
"is",
"an",
"instance",
"of",
"either",
"this",
"type",
"or",
"a",
"subclass",
"of",
"this",
"type",
"."
] | 4a049c0e35f35cf95769f3823c915a3c41d6a292 | https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ClassType.php#L95-L104 |
240,025 | hediet/php-type-reflection | src/Hediet/Types/ClassType.php | ClassType.getImplementedInterfaces | public function getImplementedInterfaces()
{
$result = array();
foreach ($this->getReflectionClass()->getInterfaces() as $interface)
{
$result[] = Type::byReflectionClass($interface);
}
return $result;
} | php | public function getImplementedInterfaces()
{
$result = array();
foreach ($this->getReflectionClass()->getInterfaces() as $interface)
{
$result[] = Type::byReflectionClass($interface);
}
return $result;
} | [
"public",
"function",
"getImplementedInterfaces",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
"->",
"getInterfaces",
"(",
")",
"as",
"$",
"interface",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"Type",
"::",
"byReflectionClass",
"(",
"$",
"interface",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Gets all interfaces that were implemented by this class.
@return InterfaceType[] | [
"Gets",
"all",
"interfaces",
"that",
"were",
"implemented",
"by",
"this",
"class",
"."
] | 4a049c0e35f35cf95769f3823c915a3c41d6a292 | https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ClassType.php#L122-L130 |
240,026 | WellCommerce/Form | DataTransformer/DateTransformer.php | DateTransformer.reverseTransform | public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
{
if (false === $date = $this->createDateFromString($value)) {
$date = null;
}
$this->propertyAccessor->setValue($modelData, $propertyPath, $date);
} | php | public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
{
if (false === $date = $this->createDateFromString($value)) {
$date = null;
}
$this->propertyAccessor->setValue($modelData, $propertyPath, $date);
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"modelData",
",",
"PropertyPathInterface",
"$",
"propertyPath",
",",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"date",
"=",
"$",
"this",
"->",
"createDateFromString",
"(",
"$",
"value",
")",
")",
"{",
"$",
"date",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"propertyAccessor",
"->",
"setValue",
"(",
"$",
"modelData",
",",
"$",
"propertyPath",
",",
"$",
"date",
")",
";",
"}"
] | Transforms date string to DateTime object
@param object $modelData
@param PropertyPathInterface $propertyPath
@param mixed $value | [
"Transforms",
"date",
"string",
"to",
"DateTime",
"object"
] | dad15dbdcf1d13f927fa86f5198bcb6abed1974a | https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataTransformer/DateTransformer.php#L70-L77 |
240,027 | las93/apollina2 | Apollina/I18n.php | I18n.getText | public function getText($sValue)
{
//ad callback to add translation before Apollina - You could see the method use in Venus2
foreach (self::$_aCallbacks as $aOneCallback) {
$sValueReturn = $aOneCallback($sValue);
if ($sValueReturn !== '') { return $sValueReturn; }
}
if (file_exists($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json')) {
if (!Translator::isConfigurated()) {
Translator::setConfig($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json');
}
return Translator::_($sValue);
}
else if (!function_exists("gettext")) {
if (!Gettext::isConfigurated()) { Gettext::setConfig($this->getLanguage(), $this->getI18nDomain(), $this->getI18nDirectory()); }
return Gettext::_($sValue);
}
else {
return Mock::_($sValue);
}
} | php | public function getText($sValue)
{
//ad callback to add translation before Apollina - You could see the method use in Venus2
foreach (self::$_aCallbacks as $aOneCallback) {
$sValueReturn = $aOneCallback($sValue);
if ($sValueReturn !== '') { return $sValueReturn; }
}
if (file_exists($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json')) {
if (!Translator::isConfigurated()) {
Translator::setConfig($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json');
}
return Translator::_($sValue);
}
else if (!function_exists("gettext")) {
if (!Gettext::isConfigurated()) { Gettext::setConfig($this->getLanguage(), $this->getI18nDomain(), $this->getI18nDirectory()); }
return Gettext::_($sValue);
}
else {
return Mock::_($sValue);
}
} | [
"public",
"function",
"getText",
"(",
"$",
"sValue",
")",
"{",
"//ad callback to add translation before Apollina - You could see the method use in Venus2",
"foreach",
"(",
"self",
"::",
"$",
"_aCallbacks",
"as",
"$",
"aOneCallback",
")",
"{",
"$",
"sValueReturn",
"=",
"$",
"aOneCallback",
"(",
"$",
"sValue",
")",
";",
"if",
"(",
"$",
"sValueReturn",
"!==",
"''",
")",
"{",
"return",
"$",
"sValueReturn",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"getI18nDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getLanguage",
"(",
")",
".",
"$",
"this",
"->",
"getIntermediaiteDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getI18nDomain",
"(",
")",
".",
"'.json'",
")",
")",
"{",
"if",
"(",
"!",
"Translator",
"::",
"isConfigurated",
"(",
")",
")",
"{",
"Translator",
"::",
"setConfig",
"(",
"$",
"this",
"->",
"getI18nDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getLanguage",
"(",
")",
".",
"$",
"this",
"->",
"getIntermediaiteDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getI18nDomain",
"(",
")",
".",
"'.json'",
")",
";",
"}",
"return",
"Translator",
"::",
"_",
"(",
"$",
"sValue",
")",
";",
"}",
"else",
"if",
"(",
"!",
"function_exists",
"(",
"\"gettext\"",
")",
")",
"{",
"if",
"(",
"!",
"Gettext",
"::",
"isConfigurated",
"(",
")",
")",
"{",
"Gettext",
"::",
"setConfig",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
")",
",",
"$",
"this",
"->",
"getI18nDomain",
"(",
")",
",",
"$",
"this",
"->",
"getI18nDirectory",
"(",
")",
")",
";",
"}",
"return",
"Gettext",
"::",
"_",
"(",
"$",
"sValue",
")",
";",
"}",
"else",
"{",
"return",
"Mock",
"::",
"_",
"(",
"$",
"sValue",
")",
";",
"}",
"}"
] | get a translation
@access public
@param string $sValue text to translate
@return string | [
"get",
"a",
"translation"
] | 7567e35573d8b3133d49f98816d9f3314a1aaf6a | https://github.com/las93/apollina2/blob/7567e35573d8b3133d49f98816d9f3314a1aaf6a/Apollina/I18n.php#L205-L234 |
240,028 | nztim/input | src/BaseProcessor.php | BaseProcessor.normalize | protected function normalize(array $input) : array
{
$normalized = [];
foreach ($this->rules() as $field => $value) {
$normalized[$field] = $input[$field] ?? '';
}
return $normalized;
} | php | protected function normalize(array $input) : array
{
$normalized = [];
foreach ($this->rules() as $field => $value) {
$normalized[$field] = $input[$field] ?? '';
}
return $normalized;
} | [
"protected",
"function",
"normalize",
"(",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"normalized",
"[",
"$",
"field",
"]",
"=",
"$",
"input",
"[",
"$",
"field",
"]",
"??",
"''",
";",
"}",
"return",
"$",
"normalized",
";",
"}"
] | Remove unexpected fields and ensure all fields in rules array are present
@param $input
@return array | [
"Remove",
"unexpected",
"fields",
"and",
"ensure",
"all",
"fields",
"in",
"rules",
"array",
"are",
"present"
] | d64c9f853a84c256a1ae4ef934d2122a9acd5536 | https://github.com/nztim/input/blob/d64c9f853a84c256a1ae4ef934d2122a9acd5536/src/BaseProcessor.php#L105-L112 |
240,029 | appcia/utils | src/Appcia/Utils/Val.php | Val.prop | public static function prop($value, $chain)
{
if (empty($chain)) {
throw new \InvalidArgumentException("Value property name cannot be empty.");
}
if (!is_string($chain)) {
throw new \InvalidArgumentException(sprintf(
"Value property name must be a string, %s given.",
gettype($chain)
));
}
$chain = explode('.', $chain);
foreach ($chain as $property) {
if (is_object($value)) {
$getter = 'get' . ucfirst($property);
if (is_callable(array($value, $getter))) {
$value = $value->$getter();
} elseif (isset($value->{$property})) {
$value = $value->{$property};
} else {
return null;
}
} elseif (Arrays::isArray($value)) {
if (!isset($value[$property])) {
return null;
}
$value = $value[$property];
} elseif (is_null($value)) {
return null;
} else {
throw new \InvalidArgumentException(sprintf(
"Value property '%s' in chain '%s' has invalid type: '%s'.",
$property,
$chain,
gettype($value)
));
}
}
return $value;
} | php | public static function prop($value, $chain)
{
if (empty($chain)) {
throw new \InvalidArgumentException("Value property name cannot be empty.");
}
if (!is_string($chain)) {
throw new \InvalidArgumentException(sprintf(
"Value property name must be a string, %s given.",
gettype($chain)
));
}
$chain = explode('.', $chain);
foreach ($chain as $property) {
if (is_object($value)) {
$getter = 'get' . ucfirst($property);
if (is_callable(array($value, $getter))) {
$value = $value->$getter();
} elseif (isset($value->{$property})) {
$value = $value->{$property};
} else {
return null;
}
} elseif (Arrays::isArray($value)) {
if (!isset($value[$property])) {
return null;
}
$value = $value[$property];
} elseif (is_null($value)) {
return null;
} else {
throw new \InvalidArgumentException(sprintf(
"Value property '%s' in chain '%s' has invalid type: '%s'.",
$property,
$chain,
gettype($value)
));
}
}
return $value;
} | [
"public",
"static",
"function",
"prop",
"(",
"$",
"value",
",",
"$",
"chain",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"chain",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Value property name cannot be empty.\"",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"chain",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Value property name must be a string, %s given.\"",
",",
"gettype",
"(",
"$",
"chain",
")",
")",
")",
";",
"}",
"$",
"chain",
"=",
"explode",
"(",
"'.'",
",",
"$",
"chain",
")",
";",
"foreach",
"(",
"$",
"chain",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"getter",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"property",
")",
";",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"$",
"value",
",",
"$",
"getter",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"$",
"getter",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"value",
"->",
"{",
"$",
"property",
"}",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"{",
"$",
"property",
"}",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"elseif",
"(",
"Arrays",
"::",
"isArray",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
"[",
"$",
"property",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"value",
"=",
"$",
"value",
"[",
"$",
"property",
"]",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Value property '%s' in chain '%s' has invalid type: '%s'.\"",
",",
"$",
"property",
",",
"$",
"chain",
",",
"gettype",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Get chained property
@param mixed $value
@param string $chain Chain of properties (dot as separator)
@throws \InvalidArgumentException
@return mixed | [
"Get",
"chained",
"property"
] | 8f7874e2c6563bcac0be821381d0c3b541999e40 | https://github.com/appcia/utils/blob/8f7874e2c6563bcac0be821381d0c3b541999e40/src/Appcia/Utils/Val.php#L39-L81 |
240,030 | appcia/utils | src/Appcia/Utils/Val.php | Val.props | public static function props($value, array $chains)
{
$props = array();
foreach ($chains as $chain) {
$props[$chain] = static::prop($value, $chain);
}
return $props;
} | php | public static function props($value, array $chains)
{
$props = array();
foreach ($chains as $chain) {
$props[$chain] = static::prop($value, $chain);
}
return $props;
} | [
"public",
"static",
"function",
"props",
"(",
"$",
"value",
",",
"array",
"$",
"chains",
")",
"{",
"$",
"props",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"chains",
"as",
"$",
"chain",
")",
"{",
"$",
"props",
"[",
"$",
"chain",
"]",
"=",
"static",
"::",
"prop",
"(",
"$",
"value",
",",
"$",
"chain",
")",
";",
"}",
"return",
"$",
"props",
";",
"}"
] | Plural form of prop
@param mixed $value
@param array $chains
@see prop()
@return array | [
"Plural",
"form",
"of",
"prop"
] | 8f7874e2c6563bcac0be821381d0c3b541999e40 | https://github.com/appcia/utils/blob/8f7874e2c6563bcac0be821381d0c3b541999e40/src/Appcia/Utils/Val.php#L93-L101 |
240,031 | appcia/utils | src/Appcia/Utils/Val.php | Val.nulls | public static function nulls(array $data, $keys = null)
{
if ($keys === null) {
$keys = array_keys($data);
}
if (!Arrays::isArray($keys)) {
$keys = array($keys);
}
foreach ($keys as $key) {
if (array_key_exists($key, $data) && empty($data[$key])) {
$data[$key] = null;
}
}
return $data;
} | php | public static function nulls(array $data, $keys = null)
{
if ($keys === null) {
$keys = array_keys($data);
}
if (!Arrays::isArray($keys)) {
$keys = array($keys);
}
foreach ($keys as $key) {
if (array_key_exists($key, $data) && empty($data[$key])) {
$data[$key] = null;
}
}
return $data;
} | [
"public",
"static",
"function",
"nulls",
"(",
"array",
"$",
"data",
",",
"$",
"keys",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"keys",
"===",
"null",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"!",
"Arrays",
"::",
"isArray",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"keys",
"=",
"array",
"(",
"$",
"keys",
")",
";",
"}",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"data",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Filter empty values to be treated as nulls
@param mixed $keys
@param array $data
@return array | [
"Filter",
"empty",
"values",
"to",
"be",
"treated",
"as",
"nulls"
] | 8f7874e2c6563bcac0be821381d0c3b541999e40 | https://github.com/appcia/utils/blob/8f7874e2c6563bcac0be821381d0c3b541999e40/src/Appcia/Utils/Val.php#L111-L128 |
240,032 | appcia/utils | src/Appcia/Utils/Val.php | Val.string | public static function string($value)
{
if (static::stringable($value)) {
$value = (string) $value;
} else {
$value = null;
}
return $value;
} | php | public static function string($value)
{
if (static::stringable($value)) {
$value = (string) $value;
} else {
$value = null;
}
return $value;
} | [
"public",
"static",
"function",
"string",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"static",
"::",
"stringable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Get value treated as string
@param mixed $value Value
@return string|null | [
"Get",
"value",
"treated",
"as",
"string"
] | 8f7874e2c6563bcac0be821381d0c3b541999e40 | https://github.com/appcia/utils/blob/8f7874e2c6563bcac0be821381d0c3b541999e40/src/Appcia/Utils/Val.php#L150-L159 |
240,033 | appcia/utils | src/Appcia/Utils/Val.php | Val.hash | public static function hash($value)
{
$hash = is_object($value)
? spl_object_hash($value)
: md5(Php::encode($value));
return $hash;
} | php | public static function hash($value)
{
$hash = is_object($value)
? spl_object_hash($value)
: md5(Php::encode($value));
return $hash;
} | [
"public",
"static",
"function",
"hash",
"(",
"$",
"value",
")",
"{",
"$",
"hash",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"md5",
"(",
"Php",
"::",
"encode",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"hash",
";",
"}"
] | Get hash for value for any type
@param mixed $value
@return string | [
"Get",
"hash",
"for",
"value",
"for",
"any",
"type"
] | 8f7874e2c6563bcac0be821381d0c3b541999e40 | https://github.com/appcia/utils/blob/8f7874e2c6563bcac0be821381d0c3b541999e40/src/Appcia/Utils/Val.php#L194-L201 |
240,034 | tekkla/core-security | Core/Security/Token/ActivationToken.php | ActivationToken.generateSelector | private function generateSelector(): string
{
// Make sure the selector is not in use. Such case is very uncommon and rare but can happen.
$in_use = true;
while ($in_use == true) {
// Generate random selector and token
$this->setSize(6);
$this->generateRandomToken();
$selector = bin2hex($this->token);
// And check if it is already in use
$in_use = $this->db->count('core_activation_tokens', 'selector = :selector', [
'selector' => $selector
]) > 0;
}
$this->selector = $selector;
return $this->selector;
} | php | private function generateSelector(): string
{
// Make sure the selector is not in use. Such case is very uncommon and rare but can happen.
$in_use = true;
while ($in_use == true) {
// Generate random selector and token
$this->setSize(6);
$this->generateRandomToken();
$selector = bin2hex($this->token);
// And check if it is already in use
$in_use = $this->db->count('core_activation_tokens', 'selector = :selector', [
'selector' => $selector
]) > 0;
}
$this->selector = $selector;
return $this->selector;
} | [
"private",
"function",
"generateSelector",
"(",
")",
":",
"string",
"{",
"// Make sure the selector is not in use. Such case is very uncommon and rare but can happen.",
"$",
"in_use",
"=",
"true",
";",
"while",
"(",
"$",
"in_use",
"==",
"true",
")",
"{",
"// Generate random selector and token",
"$",
"this",
"->",
"setSize",
"(",
"6",
")",
";",
"$",
"this",
"->",
"generateRandomToken",
"(",
")",
";",
"$",
"selector",
"=",
"bin2hex",
"(",
"$",
"this",
"->",
"token",
")",
";",
"// And check if it is already in use",
"$",
"in_use",
"=",
"$",
"this",
"->",
"db",
"->",
"count",
"(",
"'core_activation_tokens'",
",",
"'selector = :selector'",
",",
"[",
"'selector'",
"=>",
"$",
"selector",
"]",
")",
">",
"0",
";",
"}",
"$",
"this",
"->",
"selector",
"=",
"$",
"selector",
";",
"return",
"$",
"this",
"->",
"selector",
";",
"}"
] | Creates a random and unique selector
@return string | [
"Creates",
"a",
"random",
"and",
"unique",
"selector"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/ActivationToken.php#L116-L138 |
240,035 | tekkla/core-security | Core/Security/Token/ActivationToken.php | ActivationToken.getSelector | public function getSelector(bool $refresh = false): string
{
if (!isset($this->selector) || $refresh) {
$this->generateSelector();
}
return $this->selector;
} | php | public function getSelector(bool $refresh = false): string
{
if (!isset($this->selector) || $refresh) {
$this->generateSelector();
}
return $this->selector;
} | [
"public",
"function",
"getSelector",
"(",
"bool",
"$",
"refresh",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"selector",
")",
"||",
"$",
"refresh",
")",
"{",
"$",
"this",
"->",
"generateSelector",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"selector",
";",
"}"
] | Returns the selector.
Will generate a random and unique selector when no selector is set.
@return string | [
"Returns",
"the",
"selector",
"."
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/ActivationToken.php#L147-L154 |
240,036 | tekkla/core-security | Core/Security/Token/ActivationToken.php | ActivationToken.generateActivationToken | private function generateActivationToken(): string
{
$this->setSize(32);
$this->generateRandomToken();
$this->activation_token = hash('sha256', $this->token);
return $this->activation_token;
} | php | private function generateActivationToken(): string
{
$this->setSize(32);
$this->generateRandomToken();
$this->activation_token = hash('sha256', $this->token);
return $this->activation_token;
} | [
"private",
"function",
"generateActivationToken",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"setSize",
"(",
"32",
")",
";",
"$",
"this",
"->",
"generateRandomToken",
"(",
")",
";",
"$",
"this",
"->",
"activation_token",
"=",
"hash",
"(",
"'sha256'",
",",
"$",
"this",
"->",
"token",
")",
";",
"return",
"$",
"this",
"->",
"activation_token",
";",
"}"
] | Generates a random sha265 token | [
"Generates",
"a",
"random",
"sha265",
"token"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Token/ActivationToken.php#L159-L167 |
240,037 | etcinit/tutum-php | src/Chromabits/TutumClient/Requests/CreateServiceRequest.php | CreateServiceRequest.linkTo | public function linkTo(Service $service, $name = null)
{
$link = [
'to_service' => $service->getResourceUri()
];
if (!is_null($name)) {
$link['name'] = $name;
}
$this->linked_to_service[] = $link;
} | php | public function linkTo(Service $service, $name = null)
{
$link = [
'to_service' => $service->getResourceUri()
];
if (!is_null($name)) {
$link['name'] = $name;
}
$this->linked_to_service[] = $link;
} | [
"public",
"function",
"linkTo",
"(",
"Service",
"$",
"service",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"link",
"=",
"[",
"'to_service'",
"=>",
"$",
"service",
"->",
"getResourceUri",
"(",
")",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"link",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"}",
"$",
"this",
"->",
"linked_to_service",
"[",
"]",
"=",
"$",
"link",
";",
"}"
] | Add a service to link to this service
@param Service $service
@param string $name | [
"Add",
"a",
"service",
"to",
"link",
"to",
"this",
"service"
] | 39fb3375e0d47109a5da70a0e441efb8fd4f4008 | https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/Requests/CreateServiceRequest.php#L284-L295 |
240,038 | erikkubica/netlime-theme-megamenu | ThemeMegaMenu.php | ThemeMegaMenu.registerFields | public function registerFields($id, $item, $depth, $args)
{
foreach ($this->fields as $_key => $data) :
$key = sprintf('menu-item-%s', $_key);
$id = sprintf('edit-%s-%s', $key, $item->ID);
$name = sprintf('%s[%s]', $key, $item->ID);
$value = get_post_meta($item->ID, $key, true);
$class = sprintf('field-%s', $_key);
?>
<p class="description description-wide <?php echo esc_attr($class) ?>">
<?php if ($data["type"] == "bool"): ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<select id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>">
<option value="0" <?= $value !== 1 ? " selected" : "" ?>><?= __("No", "theme") ?></option>
<option value="1" <?= $value == 1 ? " selected" : "" ?>><?= __("Yes", "theme") ?></option>
</select>
</label>
<?php else: ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<input type="text" id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>" value="<?= esc_attr($value) ?>"/>
</label>
<?php endif; ?>
</p>
<?php
endforeach;
} | php | public function registerFields($id, $item, $depth, $args)
{
foreach ($this->fields as $_key => $data) :
$key = sprintf('menu-item-%s', $_key);
$id = sprintf('edit-%s-%s', $key, $item->ID);
$name = sprintf('%s[%s]', $key, $item->ID);
$value = get_post_meta($item->ID, $key, true);
$class = sprintf('field-%s', $_key);
?>
<p class="description description-wide <?php echo esc_attr($class) ?>">
<?php if ($data["type"] == "bool"): ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<select id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>">
<option value="0" <?= $value !== 1 ? " selected" : "" ?>><?= __("No", "theme") ?></option>
<option value="1" <?= $value == 1 ? " selected" : "" ?>><?= __("Yes", "theme") ?></option>
</select>
</label>
<?php else: ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<input type="text" id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>" value="<?= esc_attr($value) ?>"/>
</label>
<?php endif; ?>
</p>
<?php
endforeach;
} | [
"public",
"function",
"registerFields",
"(",
"$",
"id",
",",
"$",
"item",
",",
"$",
"depth",
",",
"$",
"args",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"_key",
"=>",
"$",
"data",
")",
":",
"$",
"key",
"=",
"sprintf",
"(",
"'menu-item-%s'",
",",
"$",
"_key",
")",
";",
"$",
"id",
"=",
"sprintf",
"(",
"'edit-%s-%s'",
",",
"$",
"key",
",",
"$",
"item",
"->",
"ID",
")",
";",
"$",
"name",
"=",
"sprintf",
"(",
"'%s[%s]'",
",",
"$",
"key",
",",
"$",
"item",
"->",
"ID",
")",
";",
"$",
"value",
"=",
"get_post_meta",
"(",
"$",
"item",
"->",
"ID",
",",
"$",
"key",
",",
"true",
")",
";",
"$",
"class",
"=",
"sprintf",
"(",
"'field-%s'",
",",
"$",
"_key",
")",
";",
"?>\n <p class=\"description description-wide <?php",
"echo",
"esc_attr",
"(",
"$",
"class",
")",
"?>\">\n <?php",
"if",
"(",
"$",
"data",
"[",
"\"type\"",
"]",
"==",
"\"bool\"",
")",
":",
"?>\n <label>\n <?=",
"esc_html",
"(",
"$",
"data",
"[",
"\"name\"",
"]",
")",
"?><br/>\n <select id=\"<?=",
"esc_attr",
"(",
"$",
"id",
")",
"?>\" class=\"widefat <?=",
"esc_attr",
"(",
"$",
"id",
")",
"?>\" name=\"<?=",
"esc_attr",
"(",
"$",
"name",
")",
"?>\">\n <option value=\"0\" <?=",
"$",
"value",
"!==",
"1",
"?",
"\" selected\"",
":",
"\"\"",
"?>><?=",
"__",
"(",
"\"No\"",
",",
"\"theme\"",
")",
"?></option>\n <option value=\"1\" <?=",
"$",
"value",
"==",
"1",
"?",
"\" selected\"",
":",
"\"\"",
"?>><?=",
"__",
"(",
"\"Yes\"",
",",
"\"theme\"",
")",
"?></option>\n </select>\n </label>\n <?php",
"else",
":",
"?>\n <label>\n <?=",
"esc_html",
"(",
"$",
"data",
"[",
"\"name\"",
"]",
")",
"?><br/>\n <input type=\"text\" id=\"<?=",
"esc_attr",
"(",
"$",
"id",
")",
"?>\" class=\"widefat <?=",
"esc_attr",
"(",
"$",
"id",
")",
"?>\" name=\"<?=",
"esc_attr",
"(",
"$",
"name",
")",
"?>\" value=\"<?=",
"esc_attr",
"(",
"$",
"value",
")",
"?>\"/>\n </label>\n <?php",
"endif",
";",
"?>\n </p>\n <?php",
"endforeach",
";",
"}"
] | Register fields for menu item required for mega menu
@param $id
@param $item
@param $depth
@param $args | [
"Register",
"fields",
"for",
"menu",
"item",
"required",
"for",
"mega",
"menu"
] | cd9c364fa8fcf9ca63bb17935f5af215ad234cf1 | https://github.com/erikkubica/netlime-theme-megamenu/blob/cd9c364fa8fcf9ca63bb17935f5af215ad234cf1/ThemeMegaMenu.php#L46-L73 |
240,039 | tekkla/core-html | Core/Html/Bootstrap/Navbar/BrandElement.php | BrandElement.createImage | public function createImage($src, $alt = '')
{
/* @var $img \Core\Html\Elements\Img */
$img = $this->factory->create('Elements\Img');
$img->setSrc($src);
if (! empty($alt)) {
$img->setAlt($alt);
}
return $this->content = $img;
} | php | public function createImage($src, $alt = '')
{
/* @var $img \Core\Html\Elements\Img */
$img = $this->factory->create('Elements\Img');
$img->setSrc($src);
if (! empty($alt)) {
$img->setAlt($alt);
}
return $this->content = $img;
} | [
"public",
"function",
"createImage",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"''",
")",
"{",
"/* @var $img \\Core\\Html\\Elements\\Img */",
"$",
"img",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"'Elements\\Img'",
")",
";",
"$",
"img",
"->",
"setSrc",
"(",
"$",
"src",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"alt",
")",
")",
"{",
"$",
"img",
"->",
"setAlt",
"(",
"$",
"alt",
")",
";",
"}",
"return",
"$",
"this",
"->",
"content",
"=",
"$",
"img",
";",
"}"
] | Creates a brand imageobject and returns reference.
@param string $src
@param string $alt Optional
@return \Core\Html\Elements\Img | [
"Creates",
"a",
"brand",
"imageobject",
"and",
"returns",
"reference",
"."
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Navbar/BrandElement.php#L43-L54 |
240,040 | MarcusFulbright/represent | src/Represent/Serializer/RepresentSerializer.php | RepresentSerializer.toJson | private function toJson($object, $view = null)
{
return json_encode($this->builder->buildRepresentation($object, $view));
} | php | private function toJson($object, $view = null)
{
return json_encode($this->builder->buildRepresentation($object, $view));
} | [
"private",
"function",
"toJson",
"(",
"$",
"object",
",",
"$",
"view",
"=",
"null",
")",
"{",
"return",
"json_encode",
"(",
"$",
"this",
"->",
"builder",
"->",
"buildRepresentation",
"(",
"$",
"object",
",",
"$",
"view",
")",
")",
";",
"}"
] | Handles serializing an object to json
@param $object
@param null $view
@return string | [
"Handles",
"serializing",
"an",
"object",
"to",
"json"
] | f7b624f473a3247a29f05c4a694d04bba4038e59 | https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Serializer/RepresentSerializer.php#L47-L50 |
240,041 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Service/ProductService.php | ProductService.findAll | public function findAll($page = 1, $max = 50)
{
$offset = (($page - 1) * $max);
$products = $this->getEm()->getRepository("AmulenShopBundle:Product")->findBy(array(), array(), $max, $offset);
return $products;
} | php | public function findAll($page = 1, $max = 50)
{
$offset = (($page - 1) * $max);
$products = $this->getEm()->getRepository("AmulenShopBundle:Product")->findBy(array(), array(), $max, $offset);
return $products;
} | [
"public",
"function",
"findAll",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"max",
"=",
"50",
")",
"{",
"$",
"offset",
"=",
"(",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"max",
")",
";",
"$",
"products",
"=",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"getRepository",
"(",
"\"AmulenShopBundle:Product\"",
")",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"$",
"max",
",",
"$",
"offset",
")",
";",
"return",
"$",
"products",
";",
"}"
] | Find al Products with pagination options.
@param integer $page [description]
@param integer $max [description]
@return ArrayCollection Products. | [
"Find",
"al",
"Products",
"with",
"pagination",
"options",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductService.php#L36-L41 |
240,042 | linkorb/pushover | src/LinkORB/Pushover/Message.php | Message.send | public function send() {
$curl_handle = curl_init();
$postfields=array();
$postfields['token'] = $this->token;
$postfields['user'] = $this->userkey;
$postfields['message'] = $this->message;
$postfields['url'] = $this->url;
$postfields['priority'] = $this->priority;
$postfields['url_title'] = $this->url_title;
$postfields['retry'] = $this->retry;
$postfields['expire'] = $this->expire;
curl_setopt_array($curl_handle,
array(
CURLOPT_URL => $this->pushover_messages_url,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_RETURNTRANSFER => true,
));
$response = curl_exec($curl_handle);
curl_close($curl_handle);
if (isset($response['status']) && $response['status'] == 1) {
return true;
}
return false;
} | php | public function send() {
$curl_handle = curl_init();
$postfields=array();
$postfields['token'] = $this->token;
$postfields['user'] = $this->userkey;
$postfields['message'] = $this->message;
$postfields['url'] = $this->url;
$postfields['priority'] = $this->priority;
$postfields['url_title'] = $this->url_title;
$postfields['retry'] = $this->retry;
$postfields['expire'] = $this->expire;
curl_setopt_array($curl_handle,
array(
CURLOPT_URL => $this->pushover_messages_url,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_RETURNTRANSFER => true,
));
$response = curl_exec($curl_handle);
curl_close($curl_handle);
if (isset($response['status']) && $response['status'] == 1) {
return true;
}
return false;
} | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"curl_handle",
"=",
"curl_init",
"(",
")",
";",
"$",
"postfields",
"=",
"array",
"(",
")",
";",
"$",
"postfields",
"[",
"'token'",
"]",
"=",
"$",
"this",
"->",
"token",
";",
"$",
"postfields",
"[",
"'user'",
"]",
"=",
"$",
"this",
"->",
"userkey",
";",
"$",
"postfields",
"[",
"'message'",
"]",
"=",
"$",
"this",
"->",
"message",
";",
"$",
"postfields",
"[",
"'url'",
"]",
"=",
"$",
"this",
"->",
"url",
";",
"$",
"postfields",
"[",
"'priority'",
"]",
"=",
"$",
"this",
"->",
"priority",
";",
"$",
"postfields",
"[",
"'url_title'",
"]",
"=",
"$",
"this",
"->",
"url_title",
";",
"$",
"postfields",
"[",
"'retry'",
"]",
"=",
"$",
"this",
"->",
"retry",
";",
"$",
"postfields",
"[",
"'expire'",
"]",
"=",
"$",
"this",
"->",
"expire",
";",
"curl_setopt_array",
"(",
"$",
"curl_handle",
",",
"array",
"(",
"CURLOPT_URL",
"=>",
"$",
"this",
"->",
"pushover_messages_url",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"postfields",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
")",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"curl_handle",
")",
";",
"curl_close",
"(",
"$",
"curl_handle",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"'status'",
"]",
")",
"&&",
"$",
"response",
"[",
"'status'",
"]",
"==",
"1",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Send this message
@return bool Indicates the message was send successful. | [
"Send",
"this",
"message"
] | 2063a0d13f4e54199e911110fb1baba1460d2ec9 | https://github.com/linkorb/pushover/blob/2063a0d13f4e54199e911110fb1baba1460d2ec9/src/LinkORB/Pushover/Message.php#L176-L202 |
240,043 | crater-framework/crater-php-framework | Language.php | Language.get | public function get($value)
{
if (!empty($this->_array[$value])) {
return $this->_array[$value];
} else {
return $value;
}
} | php | public function get($value)
{
if (!empty($this->_array[$value])) {
return $this->_array[$value];
} else {
return $value;
}
} | [
"public",
"function",
"get",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_array",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_array",
"[",
"$",
"value",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"value",
";",
"}",
"}"
] | Get element from language array by key
@param string $value Key of string
@return string | [
"Get",
"element",
"from",
"language",
"array",
"by",
"key"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Language.php#L64-L73 |
240,044 | crater-framework/crater-php-framework | Language.php | Language.show | public static function show($value, $name, $code = null)
{
if (is_null($code)) $code = self::$_languageCode;
// Lang file
$file = "../App/Language/$code/$name.php";
// Check if is readable
if (is_readable($file)) {
// Require file
$_array = include($file);
} else {
// Display error
echo \Core\Error::display("Could not load language file '$code/$name.php'");
die;
}
if (!empty($_array[$value])) {
return $_array[$value];
} else {
return $value;
}
} | php | public static function show($value, $name, $code = null)
{
if (is_null($code)) $code = self::$_languageCode;
// Lang file
$file = "../App/Language/$code/$name.php";
// Check if is readable
if (is_readable($file)) {
// Require file
$_array = include($file);
} else {
// Display error
echo \Core\Error::display("Could not load language file '$code/$name.php'");
die;
}
if (!empty($_array[$value])) {
return $_array[$value];
} else {
return $value;
}
} | [
"public",
"static",
"function",
"show",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"code",
"=",
"self",
"::",
"$",
"_languageCode",
";",
"// Lang file",
"$",
"file",
"=",
"\"../App/Language/$code/$name.php\"",
";",
"// Check if is readable",
"if",
"(",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"// Require file",
"$",
"_array",
"=",
"include",
"(",
"$",
"file",
")",
";",
"}",
"else",
"{",
"// Display error",
"echo",
"\\",
"Core",
"\\",
"Error",
"::",
"display",
"(",
"\"Could not load language file '$code/$name.php'\"",
")",
";",
"die",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_array",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"$",
"_array",
"[",
"$",
"value",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"value",
";",
"}",
"}"
] | Get language for views
@param string $value this is "word" value from language file
@param string $name name of file with language
@param string $code optional, language code
@return string | [
"Get",
"language",
"for",
"views"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Language.php#L83-L110 |
240,045 | open-orchestra/open-orchestra-bbcode-bundle | BBcodeBundle/Definition/BBcodeDefinitionFactory.php | BBcodeDefinitionFactory.create | public function create(
$tag, $html, $useOption = false, $parseContent = true,
$nestLimit = -1, array $optionValidator = array(), InputValidator $bodyValidator = null
) {
return new $this->className($tag, $html, $useOption, $parseContent, $nestLimit, $optionValidator, $bodyValidator);
} | php | public function create(
$tag, $html, $useOption = false, $parseContent = true,
$nestLimit = -1, array $optionValidator = array(), InputValidator $bodyValidator = null
) {
return new $this->className($tag, $html, $useOption, $parseContent, $nestLimit, $optionValidator, $bodyValidator);
} | [
"public",
"function",
"create",
"(",
"$",
"tag",
",",
"$",
"html",
",",
"$",
"useOption",
"=",
"false",
",",
"$",
"parseContent",
"=",
"true",
",",
"$",
"nestLimit",
"=",
"-",
"1",
",",
"array",
"$",
"optionValidator",
"=",
"array",
"(",
")",
",",
"InputValidator",
"$",
"bodyValidator",
"=",
"null",
")",
"{",
"return",
"new",
"$",
"this",
"->",
"className",
"(",
"$",
"tag",
",",
"$",
"html",
",",
"$",
"useOption",
",",
"$",
"parseContent",
",",
"$",
"nestLimit",
",",
"$",
"optionValidator",
",",
"$",
"bodyValidator",
")",
";",
"}"
] | Create a new definition
@param string $tag
@param string $html
@param boolean $useOption
@param boolean $parseContent
@param integer $nestLimit
@param array $optionValidator
@param InputValidator $bodyValidator | [
"Create",
"a",
"new",
"definition"
] | 4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54 | https://github.com/open-orchestra/open-orchestra-bbcode-bundle/blob/4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54/BBcodeBundle/Definition/BBcodeDefinitionFactory.php#L33-L38 |
240,046 | aedart/overload | src/Traits/GetterInvokerTrait.php | GetterInvokerTrait.invokeGetter | protected function invokeGetter(ReflectionProperty $property)
{
$methodName = $this->generateGetterName($property->getName());
if ($this->hasInternalMethod($methodName)) {
return $this->$methodName();
}
throw new UndefinedPropertyException(sprintf(
'No "%s"() method available for property "%s"', $methodName,
$property->getName()
));
} | php | protected function invokeGetter(ReflectionProperty $property)
{
$methodName = $this->generateGetterName($property->getName());
if ($this->hasInternalMethod($methodName)) {
return $this->$methodName();
}
throw new UndefinedPropertyException(sprintf(
'No "%s"() method available for property "%s"', $methodName,
$property->getName()
));
} | [
"protected",
"function",
"invokeGetter",
"(",
"ReflectionProperty",
"$",
"property",
")",
"{",
"$",
"methodName",
"=",
"$",
"this",
"->",
"generateGetterName",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasInternalMethod",
"(",
"$",
"methodName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"methodName",
"(",
")",
";",
"}",
"throw",
"new",
"UndefinedPropertyException",
"(",
"sprintf",
"(",
"'No \"%s\"() method available for property \"%s\"'",
",",
"$",
"methodName",
",",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | Invoke and return the given property's getter-method
@param ReflectionProperty $property The property in question
@return mixed Property value
@throws UndefinedPropertyException If given property doesn't have a corresponding get | [
"Invoke",
"and",
"return",
"the",
"given",
"property",
"s",
"getter",
"-",
"method"
] | 530a5f71454e69c58107ae864d2aa473277dcdfd | https://github.com/aedart/overload/blob/530a5f71454e69c58107ae864d2aa473277dcdfd/src/Traits/GetterInvokerTrait.php#L69-L80 |
240,047 | aedart/overload | src/Traits/GetterInvokerTrait.php | GetterInvokerTrait.generateGetterName | protected function generateGetterName(string $propertyName) : string
{
static $methods = [];
if (isset($methods[$propertyName])) {
return $methods[$propertyName];
}
$method = 'get' . ucfirst(Str::camel($propertyName));
$methods[$propertyName] = $method;
return $method;
} | php | protected function generateGetterName(string $propertyName) : string
{
static $methods = [];
if (isset($methods[$propertyName])) {
return $methods[$propertyName];
}
$method = 'get' . ucfirst(Str::camel($propertyName));
$methods[$propertyName] = $method;
return $method;
} | [
"protected",
"function",
"generateGetterName",
"(",
"string",
"$",
"propertyName",
")",
":",
"string",
"{",
"static",
"$",
"methods",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"methods",
"[",
"$",
"propertyName",
"]",
")",
")",
"{",
"return",
"$",
"methods",
"[",
"$",
"propertyName",
"]",
";",
"}",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"Str",
"::",
"camel",
"(",
"$",
"propertyName",
")",
")",
";",
"$",
"methods",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"method",
";",
"return",
"$",
"method",
";",
"}"
] | Generate and return a 'getter' name, based upon the given
property name
<b>Example</b><br />
<pre>
$propertyName = 'logger';
return generateGetterName($propertyName) // Returns getLogger
</pre>
@param string $propertyName Name of a given property
@return string Getter method name | [
"Generate",
"and",
"return",
"a",
"getter",
"name",
"based",
"upon",
"the",
"given",
"property",
"name"
] | 530a5f71454e69c58107ae864d2aa473277dcdfd | https://github.com/aedart/overload/blob/530a5f71454e69c58107ae864d2aa473277dcdfd/src/Traits/GetterInvokerTrait.php#L96-L108 |
240,048 | pletfix/core | src/Services/Auth.php | Auth.loadPrincipalFromRememberMeCookie | private function loadPrincipalFromRememberMeCookie()
{
$hash = cookie('remember_me');
if ($hash === null) {
return;
}
try {
list($id, $token) = explode('|', base64_decode($hash));
}
catch (Exception $e) {
$this->deleteRememberMeCookie();
return;
}
/** @var Model $user */
$model = config('auth.model.class');
$user = call_user_func([$model, 'find'], $id);
//$user = User::find($id);
if ($user !== null && !empty($token) && $token === $user->getAttribute('remember_token')) {
$this->setPrincipal($user->getId(), $user->getAttribute('name'), $user->getAttribute('role'));
}
} | php | private function loadPrincipalFromRememberMeCookie()
{
$hash = cookie('remember_me');
if ($hash === null) {
return;
}
try {
list($id, $token) = explode('|', base64_decode($hash));
}
catch (Exception $e) {
$this->deleteRememberMeCookie();
return;
}
/** @var Model $user */
$model = config('auth.model.class');
$user = call_user_func([$model, 'find'], $id);
//$user = User::find($id);
if ($user !== null && !empty($token) && $token === $user->getAttribute('remember_token')) {
$this->setPrincipal($user->getId(), $user->getAttribute('name'), $user->getAttribute('role'));
}
} | [
"private",
"function",
"loadPrincipalFromRememberMeCookie",
"(",
")",
"{",
"$",
"hash",
"=",
"cookie",
"(",
"'remember_me'",
")",
";",
"if",
"(",
"$",
"hash",
"===",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"list",
"(",
"$",
"id",
",",
"$",
"token",
")",
"=",
"explode",
"(",
"'|'",
",",
"base64_decode",
"(",
"$",
"hash",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"deleteRememberMeCookie",
"(",
")",
";",
"return",
";",
"}",
"/** @var Model $user */",
"$",
"model",
"=",
"config",
"(",
"'auth.model.class'",
")",
";",
"$",
"user",
"=",
"call_user_func",
"(",
"[",
"$",
"model",
",",
"'find'",
"]",
",",
"$",
"id",
")",
";",
"//$user = User::find($id);",
"if",
"(",
"$",
"user",
"!==",
"null",
"&&",
"!",
"empty",
"(",
"$",
"token",
")",
"&&",
"$",
"token",
"===",
"$",
"user",
"->",
"getAttribute",
"(",
"'remember_token'",
")",
")",
"{",
"$",
"this",
"->",
"setPrincipal",
"(",
"$",
"user",
"->",
"getId",
"(",
")",
",",
"$",
"user",
"->",
"getAttribute",
"(",
"'name'",
")",
",",
"$",
"user",
"->",
"getAttribute",
"(",
"'role'",
")",
")",
";",
"}",
"}"
] | Read the "remember me" cookie if exist and store the principal into the session. | [
"Read",
"the",
"remember",
"me",
"cookie",
"if",
"exist",
"and",
"store",
"the",
"principal",
"into",
"the",
"session",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Auth.php#L98-L120 |
240,049 | pletfix/core | src/Services/Auth.php | Auth.getAbilities | private function getAbilities($role)
{
$abilities = [];
foreach (config('auth.acl') as $ability => $roles) {
if (in_array($role, $roles)) {
$abilities[] = $ability;
}
}
return $abilities;
} | php | private function getAbilities($role)
{
$abilities = [];
foreach (config('auth.acl') as $ability => $roles) {
if (in_array($role, $roles)) {
$abilities[] = $ability;
}
}
return $abilities;
} | [
"private",
"function",
"getAbilities",
"(",
"$",
"role",
")",
"{",
"$",
"abilities",
"=",
"[",
"]",
";",
"foreach",
"(",
"config",
"(",
"'auth.acl'",
")",
"as",
"$",
"ability",
"=>",
"$",
"roles",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"role",
",",
"$",
"roles",
")",
")",
"{",
"$",
"abilities",
"[",
"]",
"=",
"$",
"ability",
";",
"}",
"}",
"return",
"$",
"abilities",
";",
"}"
] | Read the abilities from the ACL for the given role.
@param $role
@return array | [
"Read",
"the",
"abilities",
"from",
"the",
"ACL",
"for",
"the",
"given",
"role",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Auth.php#L145-L155 |
240,050 | pletfix/core | src/Services/Auth.php | Auth.attribute | private function attribute($key)
{
if ($this->attributes === null) {
$this->attributes = session('_auth', []);
if (empty($this->attributes)) {
$this->loadPrincipalFromRememberMeCookie();
}
}
return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
} | php | private function attribute($key)
{
if ($this->attributes === null) {
$this->attributes = session('_auth', []);
if (empty($this->attributes)) {
$this->loadPrincipalFromRememberMeCookie();
}
}
return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
} | [
"private",
"function",
"attribute",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"attributes",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"session",
"(",
"'_auth'",
",",
"[",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"$",
"this",
"->",
"loadPrincipalFromRememberMeCookie",
"(",
")",
";",
"}",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Load the user attributes from the session and get the attribute.
@param string $key
@return mixed | [
"Load",
"the",
"user",
"attributes",
"from",
"the",
"session",
"and",
"get",
"the",
"attribute",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Auth.php#L163-L173 |
240,051 | n0m4dz/laracasa | Zend/Gdata/Books.php | Zend_Gdata_Books.getVolumeFeed | public function getVolumeFeed($location = null)
{
if ($location == null) {
$uri = self::VOLUME_FEED_URI;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | php | public function getVolumeFeed($location = null)
{
if ($location == null) {
$uri = self::VOLUME_FEED_URI;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | [
"public",
"function",
"getVolumeFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"==",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"VOLUME_FEED_URI",
";",
"}",
"else",
"if",
"(",
"$",
"location",
"instanceof",
"Zend_Gdata_Query",
")",
"{",
"$",
"uri",
"=",
"$",
"location",
"->",
"getQueryUrl",
"(",
")",
";",
"}",
"else",
"{",
"$",
"uri",
"=",
"$",
"location",
";",
"}",
"return",
"parent",
"::",
"getFeed",
"(",
"$",
"uri",
",",
"'Zend_Gdata_Books_VolumeFeed'",
")",
";",
"}"
] | Retrieves a feed of volumes.
@param Zend_Gdata_Query|string|null $location (optional) The URL to
query or a Zend_Gdata_Query object from which a URL can be
determined.
@return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
specified URL. | [
"Retrieves",
"a",
"feed",
"of",
"volumes",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Books.php#L104-L114 |
240,052 | n0m4dz/laracasa | Zend/Gdata/Books.php | Zend_Gdata_Books.getVolumeEntry | public function getVolumeEntry($volumeId = null, $location = null)
{
if ($volumeId !== null) {
$uri = self::VOLUME_FEED_URI . "/" . $volumeId;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
} | php | public function getVolumeEntry($volumeId = null, $location = null)
{
if ($volumeId !== null) {
$uri = self::VOLUME_FEED_URI . "/" . $volumeId;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
} | [
"public",
"function",
"getVolumeEntry",
"(",
"$",
"volumeId",
"=",
"null",
",",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"volumeId",
"!==",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"VOLUME_FEED_URI",
".",
"\"/\"",
".",
"$",
"volumeId",
";",
"}",
"else",
"if",
"(",
"$",
"location",
"instanceof",
"Zend_Gdata_Query",
")",
"{",
"$",
"uri",
"=",
"$",
"location",
"->",
"getQueryUrl",
"(",
")",
";",
"}",
"else",
"{",
"$",
"uri",
"=",
"$",
"location",
";",
"}",
"return",
"parent",
"::",
"getEntry",
"(",
"$",
"uri",
",",
"'Zend_Gdata_Books_VolumeEntry'",
")",
";",
"}"
] | Retrieves a specific volume entry.
@param string|null $volumeId The volumeId of interest.
@param Zend_Gdata_Query|string|null $location (optional) The URL to
query or a Zend_Gdata_Query object from which a URL can be
determined.
@return Zend_Gdata_Books_VolumeEntry The feed of volumes found at the
specified URL. | [
"Retrieves",
"a",
"specific",
"volume",
"entry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Books.php#L126-L136 |
240,053 | n0m4dz/laracasa | Zend/Gdata/Books.php | Zend_Gdata_Books.getUserLibraryFeed | public function getUserLibraryFeed($location = null)
{
if ($location == null) {
$uri = self::MY_LIBRARY_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | php | public function getUserLibraryFeed($location = null)
{
if ($location == null) {
$uri = self::MY_LIBRARY_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | [
"public",
"function",
"getUserLibraryFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"==",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"MY_LIBRARY_FEED_URI",
";",
"}",
"else",
"{",
"$",
"uri",
"=",
"$",
"location",
";",
"}",
"return",
"parent",
"::",
"getFeed",
"(",
"$",
"uri",
",",
"'Zend_Gdata_Books_VolumeFeed'",
")",
";",
"}"
] | Retrieves a feed of volumes, by default the User library feed.
@param Zend_Gdata_Query|string|null $location (optional) The URL to
query.
@return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
specified URL. | [
"Retrieves",
"a",
"feed",
"of",
"volumes",
"by",
"default",
"the",
"User",
"library",
"feed",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Books.php#L146-L154 |
240,054 | n0m4dz/laracasa | Zend/Gdata/Books.php | Zend_Gdata_Books.getUserAnnotationFeed | public function getUserAnnotationFeed($location = null)
{
if ($location == null) {
$uri = self::MY_ANNOTATION_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | php | public function getUserAnnotationFeed($location = null)
{
if ($location == null) {
$uri = self::MY_ANNOTATION_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
} | [
"public",
"function",
"getUserAnnotationFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"==",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"MY_ANNOTATION_FEED_URI",
";",
"}",
"else",
"{",
"$",
"uri",
"=",
"$",
"location",
";",
"}",
"return",
"parent",
"::",
"getFeed",
"(",
"$",
"uri",
",",
"'Zend_Gdata_Books_VolumeFeed'",
")",
";",
"}"
] | Retrieves a feed of volumes, by default the User annotation feed
@param Zend_Gdata_Query|string|null $location (optional) The URL to
query.
@return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
specified URL. | [
"Retrieves",
"a",
"feed",
"of",
"volumes",
"by",
"default",
"the",
"User",
"annotation",
"feed"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Books.php#L164-L172 |
240,055 | broeser/sanitor | src/Sanitizer.php | Sanitizer.findFilter | private function findFilter($filterId) {
foreach(filter_list() as $filterName) {
if(filter_id($filterName)===$filterId) {
return $filterName;
}
}
throw new \Exception('Could not find filter '.$filterId);
} | php | private function findFilter($filterId) {
foreach(filter_list() as $filterName) {
if(filter_id($filterName)===$filterId) {
return $filterName;
}
}
throw new \Exception('Could not find filter '.$filterId);
} | [
"private",
"function",
"findFilter",
"(",
"$",
"filterId",
")",
"{",
"foreach",
"(",
"filter_list",
"(",
")",
"as",
"$",
"filterName",
")",
"{",
"if",
"(",
"filter_id",
"(",
"$",
"filterName",
")",
"===",
"$",
"filterId",
")",
"{",
"return",
"$",
"filterName",
";",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could not find filter '",
".",
"$",
"filterId",
")",
";",
"}"
] | Finds the filter name by filter id
@param int $filterId
@return string
@throws SanitizationException | [
"Finds",
"the",
"filter",
"name",
"by",
"filter",
"id"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L102-L110 |
240,056 | broeser/sanitor | src/Sanitizer.php | Sanitizer.setSanitizeFilter | public function setSanitizeFilter($filter) {
$this->filterName = $this->findFilter($filter);
$this->sanitizeFilter = $filter;
} | php | public function setSanitizeFilter($filter) {
$this->filterName = $this->findFilter($filter);
$this->sanitizeFilter = $filter;
} | [
"public",
"function",
"setSanitizeFilter",
"(",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"filterName",
"=",
"$",
"this",
"->",
"findFilter",
"(",
"$",
"filter",
")",
";",
"$",
"this",
"->",
"sanitizeFilter",
"=",
"$",
"filter",
";",
"}"
] | Sets sanitization filter
@param int $filter | [
"Sets",
"sanitization",
"filter"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L117-L120 |
240,057 | broeser/sanitor | src/Sanitizer.php | Sanitizer.filter | public function filter($value) {
return $this->checkSanitizedValue(filter_var($value, $this->sanitizeFilter, $this->sanitizeFlags));
} | php | public function filter($value) {
return $this->checkSanitizedValue(filter_var($value, $this->sanitizeFilter, $this->sanitizeFlags));
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"checkSanitizedValue",
"(",
"filter_var",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"sanitizeFilter",
",",
"$",
"this",
"->",
"sanitizeFlags",
")",
")",
";",
"}"
] | Sanitizes the value with the sanitization filter and flags assigned to this sanitizer
@param mixed $value The value to filter
@return mixed
@throws SanitizationException | [
"Sanitizes",
"the",
"value",
"with",
"the",
"sanitization",
"filter",
"and",
"flags",
"assigned",
"to",
"this",
"sanitizer"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L176-L178 |
240,058 | broeser/sanitor | src/Sanitizer.php | Sanitizer.filterEnv | public function filterEnv($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!$this->filterHas(\INPUT_ENV, $variableName)) {
return null;
}
// Sadly INPUT_ENV is broken and does not work
// getenv() has to be used
return $this->filter(getenv($variableName));
} | php | public function filterEnv($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!$this->filterHas(\INPUT_ENV, $variableName)) {
return null;
}
// Sadly INPUT_ENV is broken and does not work
// getenv() has to be used
return $this->filter(getenv($variableName));
} | [
"public",
"function",
"filterEnv",
"(",
"$",
"variableName",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"variableName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Variable name expected as string'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"filterHas",
"(",
"\\",
"INPUT_ENV",
",",
"$",
"variableName",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Sadly INPUT_ENV is broken and does not work",
"// getenv() has to be used",
"return",
"$",
"this",
"->",
"filter",
"(",
"getenv",
"(",
"$",
"variableName",
")",
")",
";",
"}"
] | Sanitizes a ENV-variable
Returns null, if the variable does not exist
@param string $variableName
@return mixed | [
"Sanitizes",
"a",
"ENV",
"-",
"variable"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L261-L273 |
240,059 | broeser/sanitor | src/Sanitizer.php | Sanitizer.filterSession | public function filterSession($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_SESSION[$variableName])) {
return null;
}
return $this->filter($_SESSION[$variableName]);
} | php | public function filterSession($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_SESSION[$variableName])) {
return null;
}
return $this->filter($_SESSION[$variableName]);
} | [
"public",
"function",
"filterSession",
"(",
"$",
"variableName",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"variableName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Variable name expected as string'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"variableName",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"_SESSION",
"[",
"$",
"variableName",
"]",
")",
";",
"}"
] | Sanitizes a SESSION-variable
Experimental.
Returns null, if the variable does not exist
@param string $variableName
@return mixed | [
"Sanitizes",
"a",
"SESSION",
"-",
"variable"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L285-L295 |
240,060 | broeser/sanitor | src/Sanitizer.php | Sanitizer.filterRequest | public function filterRequest($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_REQUEST[$variableName])) {
return null;
}
return $this->filter($_REQUEST[$variableName]);
} | php | public function filterRequest($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_REQUEST[$variableName])) {
return null;
}
return $this->filter($_REQUEST[$variableName]);
} | [
"public",
"function",
"filterRequest",
"(",
"$",
"variableName",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"variableName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Variable name expected as string'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_REQUEST",
"[",
"$",
"variableName",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"_REQUEST",
"[",
"$",
"variableName",
"]",
")",
";",
"}"
] | Sanitizes a REQUEST-variable
Experimental.
Returns null, if the variable does not exist
@param string $variableName
@return mixed | [
"Sanitizes",
"a",
"REQUEST",
"-",
"variable"
] | 580e539a2747e3d66527cbbde968004743481a5c | https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/Sanitizer.php#L307-L317 |
240,061 | Flowpack/Flowpack.SingleSignOn.DemoInstance | Classes/Flowpack/SingleSignOn/DemoInstance/Controller/ConfigurationController.php | ConfigurationController.indexAction | public function indexAction() {
$clientSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Flowpack.SingleSignOn.Client');
$clientSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($clientSettings, 99, 2);
$this->view->assign('clientSettings', $clientSettingsYaml);
$authenticationSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.security.authentication');
$authenticationSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($authenticationSettings, 99, 2);
$this->view->assign('authenticationSettings', $authenticationSettingsYaml);
} | php | public function indexAction() {
$clientSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Flowpack.SingleSignOn.Client');
$clientSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($clientSettings, 99, 2);
$this->view->assign('clientSettings', $clientSettingsYaml);
$authenticationSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.security.authentication');
$authenticationSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($authenticationSettings, 99, 2);
$this->view->assign('authenticationSettings', $authenticationSettingsYaml);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"clientSettings",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration",
"(",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Configuration",
"\\",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'Flowpack.SingleSignOn.Client'",
")",
";",
"$",
"clientSettingsYaml",
"=",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Yaml",
"\\",
"Yaml",
"::",
"dump",
"(",
"$",
"clientSettings",
",",
"99",
",",
"2",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assign",
"(",
"'clientSettings'",
",",
"$",
"clientSettingsYaml",
")",
";",
"$",
"authenticationSettings",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration",
"(",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Configuration",
"\\",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'TYPO3.Flow.security.authentication'",
")",
";",
"$",
"authenticationSettingsYaml",
"=",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Yaml",
"\\",
"Yaml",
"::",
"dump",
"(",
"$",
"authenticationSettings",
",",
"99",
",",
"2",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assign",
"(",
"'authenticationSettings'",
",",
"$",
"authenticationSettingsYaml",
")",
";",
"}"
] | Display configuration of client | [
"Display",
"configuration",
"of",
"client"
] | a3de8fef092cec34e2577832576e32b37ca507c5 | https://github.com/Flowpack/Flowpack.SingleSignOn.DemoInstance/blob/a3de8fef092cec34e2577832576e32b37ca507c5/Classes/Flowpack/SingleSignOn/DemoInstance/Controller/ConfigurationController.php#L32-L40 |
240,062 | vinala/kernel | src/Atomium/Compiler/AtomiumCompileInstructions.php | AtomiumCompileInstructions.open | protected static function open($script, $openTag, $closeChar, $phpFunc, $phpClose)
{
//
$data = Strings::splite($script, $openTag);
//
$output = $data[0];
//
for ($i = 1; $i < Collection::count($data); $i++) {
$items = self::getParmas($data[$i], $closeChar);
//
$params = $items['params'];
$rest = $items['rest'];
//
$output .= self::compile($params, $phpFunc, $phpClose);
$output .= $rest;
}
//
return $output;
} | php | protected static function open($script, $openTag, $closeChar, $phpFunc, $phpClose)
{
//
$data = Strings::splite($script, $openTag);
//
$output = $data[0];
//
for ($i = 1; $i < Collection::count($data); $i++) {
$items = self::getParmas($data[$i], $closeChar);
//
$params = $items['params'];
$rest = $items['rest'];
//
$output .= self::compile($params, $phpFunc, $phpClose);
$output .= $rest;
}
//
return $output;
} | [
"protected",
"static",
"function",
"open",
"(",
"$",
"script",
",",
"$",
"openTag",
",",
"$",
"closeChar",
",",
"$",
"phpFunc",
",",
"$",
"phpClose",
")",
"{",
"//",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"script",
",",
"$",
"openTag",
")",
";",
"//",
"$",
"output",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"//",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"Collection",
"::",
"count",
"(",
"$",
"data",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"items",
"=",
"self",
"::",
"getParmas",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
",",
"$",
"closeChar",
")",
";",
"//",
"$",
"params",
"=",
"$",
"items",
"[",
"'params'",
"]",
";",
"$",
"rest",
"=",
"$",
"items",
"[",
"'rest'",
"]",
";",
"//",
"$",
"output",
".=",
"self",
"::",
"compile",
"(",
"$",
"params",
",",
"$",
"phpFunc",
",",
"$",
"phpClose",
")",
";",
"$",
"output",
".=",
"$",
"rest",
";",
"}",
"//",
"return",
"$",
"output",
";",
"}"
] | To compile de open tag.
@var string, string, string, string, string
@return string | [
"To",
"compile",
"de",
"open",
"tag",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Atomium/Compiler/AtomiumCompileInstructions.php#L47-L66 |
240,063 | vinala/kernel | src/Atomium/Compiler/AtomiumCompileInstructions.php | AtomiumCompileInstructions.getParmas | protected static function getParmas($row, $closeChar)
{
$params = '';
$rest = '';
$taken = false;
$string = false; // 1 "" - 2 ''
$opened = 0; // 1 "" - 2 ''
//
for ($j = 0; $j < strlen($row); $j++) {
//
if ($row[$j] == "'" && !$string) {
$string = 2;
} elseif ($row[$j] == '"' && !$string) {
$string = 1;
} elseif ($row[$j] == "'" && $string) {
$string = false;
} elseif ($row[$j] == '"' && $string) {
$string = false;
}
//
if ($row[$j] == '(') {
$opened++;
} elseif ($row[$j] == ')') {
$opened--;
}
//
if (!$string && $opened == 0 && $row[$j] == $closeChar && !$taken) {
$taken = true;
} elseif (!$taken) {
$params .= $row[$j];
} elseif ($taken) {
$rest .= $row[$j];
}
}
//
return ['params' => $params, 'rest' => $rest];
} | php | protected static function getParmas($row, $closeChar)
{
$params = '';
$rest = '';
$taken = false;
$string = false; // 1 "" - 2 ''
$opened = 0; // 1 "" - 2 ''
//
for ($j = 0; $j < strlen($row); $j++) {
//
if ($row[$j] == "'" && !$string) {
$string = 2;
} elseif ($row[$j] == '"' && !$string) {
$string = 1;
} elseif ($row[$j] == "'" && $string) {
$string = false;
} elseif ($row[$j] == '"' && $string) {
$string = false;
}
//
if ($row[$j] == '(') {
$opened++;
} elseif ($row[$j] == ')') {
$opened--;
}
//
if (!$string && $opened == 0 && $row[$j] == $closeChar && !$taken) {
$taken = true;
} elseif (!$taken) {
$params .= $row[$j];
} elseif ($taken) {
$rest .= $row[$j];
}
}
//
return ['params' => $params, 'rest' => $rest];
} | [
"protected",
"static",
"function",
"getParmas",
"(",
"$",
"row",
",",
"$",
"closeChar",
")",
"{",
"$",
"params",
"=",
"''",
";",
"$",
"rest",
"=",
"''",
";",
"$",
"taken",
"=",
"false",
";",
"$",
"string",
"=",
"false",
";",
"// 1 \"\" - 2 ''",
"$",
"opened",
"=",
"0",
";",
"// 1 \"\" - 2 ''",
"//",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"strlen",
"(",
"$",
"row",
")",
";",
"$",
"j",
"++",
")",
"{",
"//",
"if",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"\"'\"",
"&&",
"!",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"2",
";",
"}",
"elseif",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"'\"'",
"&&",
"!",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"1",
";",
"}",
"elseif",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"\"'\"",
"&&",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"'\"'",
"&&",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"false",
";",
"}",
"//",
"if",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"'('",
")",
"{",
"$",
"opened",
"++",
";",
"}",
"elseif",
"(",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"')'",
")",
"{",
"$",
"opened",
"--",
";",
"}",
"//",
"if",
"(",
"!",
"$",
"string",
"&&",
"$",
"opened",
"==",
"0",
"&&",
"$",
"row",
"[",
"$",
"j",
"]",
"==",
"$",
"closeChar",
"&&",
"!",
"$",
"taken",
")",
"{",
"$",
"taken",
"=",
"true",
";",
"}",
"elseif",
"(",
"!",
"$",
"taken",
")",
"{",
"$",
"params",
".=",
"$",
"row",
"[",
"$",
"j",
"]",
";",
"}",
"elseif",
"(",
"$",
"taken",
")",
"{",
"$",
"rest",
".=",
"$",
"row",
"[",
"$",
"j",
"]",
";",
"}",
"}",
"//",
"return",
"[",
"'params'",
"=>",
"$",
"params",
",",
"'rest'",
"=>",
"$",
"rest",
"]",
";",
"}"
] | Get Fucntion params and the rest of script.
@var string, string
@return array | [
"Get",
"Fucntion",
"params",
"and",
"the",
"rest",
"of",
"script",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Atomium/Compiler/AtomiumCompileInstructions.php#L75-L111 |
240,064 | BuildrPHP/Utils | src/Enumeration/EnumerationBase.php | EnumerationBase.toArray | public static function toArray() {
$enumClass = get_called_class();
if(!array_key_exists($enumClass, self::$cache)) {
$reflector = new ReflectionClass($enumClass);
self::$cache[$enumClass] = $reflector->getConstants();
}
return self::$cache[$enumClass];
} | php | public static function toArray() {
$enumClass = get_called_class();
if(!array_key_exists($enumClass, self::$cache)) {
$reflector = new ReflectionClass($enumClass);
self::$cache[$enumClass] = $reflector->getConstants();
}
return self::$cache[$enumClass];
} | [
"public",
"static",
"function",
"toArray",
"(",
")",
"{",
"$",
"enumClass",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"enumClass",
",",
"self",
"::",
"$",
"cache",
")",
")",
"{",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"enumClass",
")",
";",
"self",
"::",
"$",
"cache",
"[",
"$",
"enumClass",
"]",
"=",
"$",
"reflector",
"->",
"getConstants",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"cache",
"[",
"$",
"enumClass",
"]",
";",
"}"
] | Translate the current enumeration to an associative array
@return array | [
"Translate",
"the",
"current",
"enumeration",
"to",
"an",
"associative",
"array"
] | e3b1b9e58f3ebc644e1b9f3838c69936812fc53c | https://github.com/BuildrPHP/Utils/blob/e3b1b9e58f3ebc644e1b9f3838c69936812fc53c/src/Enumeration/EnumerationBase.php#L72-L81 |
240,065 | BuildrPHP/Utils | src/Enumeration/EnumerationBase.php | EnumerationBase.isValidKey | public static function isValidKey($key) {
if(!is_string($key)) {
throw EnumerationException::invalidKeyType(gettype($key));
}
return array_key_exists($key, self::toArray());
} | php | public static function isValidKey($key) {
if(!is_string($key)) {
throw EnumerationException::invalidKeyType(gettype($key));
}
return array_key_exists($key, self::toArray());
} | [
"public",
"static",
"function",
"isValidKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"EnumerationException",
"::",
"invalidKeyType",
"(",
"gettype",
"(",
"$",
"key",
")",
")",
";",
"}",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"toArray",
"(",
")",
")",
";",
"}"
] | Determines that the given key is exist in the current enumeration or not.
@param string $key
@return bool
@throws \BuildR\Utils\Enumeration\Exception\EnumerationException | [
"Determines",
"that",
"the",
"given",
"key",
"is",
"exist",
"in",
"the",
"current",
"enumeration",
"or",
"not",
"."
] | e3b1b9e58f3ebc644e1b9f3838c69936812fc53c | https://github.com/BuildrPHP/Utils/blob/e3b1b9e58f3ebc644e1b9f3838c69936812fc53c/src/Enumeration/EnumerationBase.php#L101-L107 |
240,066 | OWeb/OWeb-Framework | OWeb/manage/Template.php | Template.prepareDisplay | private function prepareDisplay()
{
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Start@OWeb\manage\Template');
//We save the content so that if there is an error we don't show half displayed codes
ob_start();
try {
\OWeb\manage\Controller::getInstance()->display();
} catch (\Exception $e) {
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Fail@OWeb\manage\Template');
ob_end_clean();
ob_start();
$ctr = \OWeb\manage\Controller::getInstance()->loadException($e);
$ctr->addParams("exception", $e);
\OWeb\manage\Controller::getInstance()->display();
}
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Succ@OWeb\manage\Template');
$this->content = ob_get_contents();
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_End@OWeb\manage\Template');
ob_end_clean();
//$this->content_heads = \OWeb\manage\Headers::getInstance()->toString();
// \OWeb\manage\Headers::getInstance()->reset();
} | php | private function prepareDisplay()
{
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Start@OWeb\manage\Template');
//We save the content so that if there is an error we don't show half displayed codes
ob_start();
try {
\OWeb\manage\Controller::getInstance()->display();
} catch (\Exception $e) {
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Fail@OWeb\manage\Template');
ob_end_clean();
ob_start();
$ctr = \OWeb\manage\Controller::getInstance()->loadException($e);
$ctr->addParams("exception", $e);
\OWeb\manage\Controller::getInstance()->display();
}
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Succ@OWeb\manage\Template');
$this->content = ob_get_contents();
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_End@OWeb\manage\Template');
ob_end_clean();
//$this->content_heads = \OWeb\manage\Headers::getInstance()->toString();
// \OWeb\manage\Headers::getInstance()->reset();
} | [
"private",
"function",
"prepareDisplay",
"(",
")",
"{",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'PrepareContent_Start@OWeb\\manage\\Template'",
")",
";",
"//We save the content so that if there is an error we don't show half displayed codes",
"ob_start",
"(",
")",
";",
"try",
"{",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Controller",
"::",
"getInstance",
"(",
")",
"->",
"display",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'PrepareContent_Fail@OWeb\\manage\\Template'",
")",
";",
"ob_end_clean",
"(",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"ctr",
"=",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Controller",
"::",
"getInstance",
"(",
")",
"->",
"loadException",
"(",
"$",
"e",
")",
";",
"$",
"ctr",
"->",
"addParams",
"(",
"\"exception\"",
",",
"$",
"e",
")",
";",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Controller",
"::",
"getInstance",
"(",
")",
"->",
"display",
"(",
")",
";",
"}",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'PrepareContent_Succ@OWeb\\manage\\Template'",
")",
";",
"$",
"this",
"->",
"content",
"=",
"ob_get_contents",
"(",
")",
";",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'PrepareContent_End@OWeb\\manage\\Template'",
")",
";",
"ob_end_clean",
"(",
")",
";",
"//$this->content_heads = \\OWeb\\manage\\Headers::getInstance()->toString();",
"// \\OWeb\\manage\\Headers::getInstance()->reset();",
"}"
] | Will get the output of the current controller to display it later on. | [
"Will",
"get",
"the",
"output",
"of",
"the",
"current",
"controller",
"to",
"display",
"it",
"later",
"on",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Template.php#L89-L117 |
240,067 | pdenis/SnideTravinizerBundle | DependencyInjection/SnideTravinizerExtension.php | SnideTravinizerExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('model.xml');
$loader->load('form.xml');
$loader->load('helper.xml');
$loader->load('reader.xml');
$loader->load('converter.xml');
$loader->load('loader.xml');
$loader->load('manager.xml');
$loader->load('twig_extension.xml');
$loader->load('validator.xml');
$loader->load('cache.xml');
$this->loadRepository($loader, $container, $config);
$this->loadManager($loader, $container, $config);
$this->loadRepoClass($loader, $container, $config);
$this->loadCachePath($container, $config);
$this->loadVersionEyeKey($container, $config);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('model.xml');
$loader->load('form.xml');
$loader->load('helper.xml');
$loader->load('reader.xml');
$loader->load('converter.xml');
$loader->load('loader.xml');
$loader->load('manager.xml');
$loader->load('twig_extension.xml');
$loader->load('validator.xml');
$loader->load('cache.xml');
$this->loadRepository($loader, $container, $config);
$this->loadManager($loader, $container, $config);
$this->loadRepoClass($loader, $container, $config);
$this->loadCachePath($container, $config);
$this->loadVersionEyeKey($container, $config);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'model.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'form.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'helper.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'reader.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'converter.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'loader.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'manager.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'twig_extension.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'validator.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'cache.xml'",
")",
";",
"$",
"this",
"->",
"loadRepository",
"(",
"$",
"loader",
",",
"$",
"container",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"loadManager",
"(",
"$",
"loader",
",",
"$",
"container",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"loadRepoClass",
"(",
"$",
"loader",
",",
"$",
"container",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"loadCachePath",
"(",
"$",
"container",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"loadVersionEyeKey",
"(",
"$",
"container",
",",
"$",
"config",
")",
";",
"}"
] | Load configuration of Bundle
@param array $configs Configuration parameters
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
@throws \Exception | [
"Load",
"configuration",
"of",
"Bundle"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/DependencyInjection/SnideTravinizerExtension.php#L34-L56 |
240,068 | pdenis/SnideTravinizerBundle | DependencyInjection/SnideTravinizerExtension.php | SnideTravinizerExtension.loadRepoClass | protected function loadRepoClass($loader, ContainerBuilder $container, array $config)
{
if (isset($config['repository']['repo']['class'])) {
$container->setParameter('snide_travinizer.model.repo.class', $config['repository']['repo']['class']);
}
} | php | protected function loadRepoClass($loader, ContainerBuilder $container, array $config)
{
if (isset($config['repository']['repo']['class'])) {
$container->setParameter('snide_travinizer.model.repo.class', $config['repository']['repo']['class']);
}
} | [
"protected",
"function",
"loadRepoClass",
"(",
"$",
"loader",
",",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'repository'",
"]",
"[",
"'repo'",
"]",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"'snide_travinizer.model.repo.class'",
",",
"$",
"config",
"[",
"'repository'",
"]",
"[",
"'repo'",
"]",
"[",
"'class'",
"]",
")",
";",
"}",
"}"
] | Load repoClass entity
@param XmlFileLoader $loader
@param ContainerBuilder $container
@param array $config
@throws \Exception | [
"Load",
"repoClass",
"entity"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/DependencyInjection/SnideTravinizerExtension.php#L114-L120 |
240,069 | shov/wpci-core | Render/View.php | View.display | public function display(string $key, array $data, int $status = RegularResponse::HTTP_OK): ResponseInterface
{
$content = $this->templateStrategy->render($key, $data);
$this->responseStrategy->setContent($content);
$this->responseStrategy->setStatusCode($status);
return $this->responseStrategy;
} | php | public function display(string $key, array $data, int $status = RegularResponse::HTTP_OK): ResponseInterface
{
$content = $this->templateStrategy->render($key, $data);
$this->responseStrategy->setContent($content);
$this->responseStrategy->setStatusCode($status);
return $this->responseStrategy;
} | [
"public",
"function",
"display",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"data",
",",
"int",
"$",
"status",
"=",
"RegularResponse",
"::",
"HTTP_OK",
")",
":",
"ResponseInterface",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"templateStrategy",
"->",
"render",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"responseStrategy",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"$",
"this",
"->",
"responseStrategy",
"->",
"setStatusCode",
"(",
"$",
"status",
")",
";",
"return",
"$",
"this",
"->",
"responseStrategy",
";",
"}"
] | Make templating and give the response
@param string $key
@param array $data
@param int $status
@return RegularResponse | [
"Make",
"templating",
"and",
"give",
"the",
"response"
] | e31084cbc2f310882df2b9b0548330ea5fdb4f26 | https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Render/View.php#L39-L46 |
240,070 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/orm/classes/observer/createdat.php | Observer_CreatedAt.before_insert | public function before_insert(Model $obj)
{
if ($this->_overwrite or empty($obj->{$this->_property}))
{
$obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
}
} | php | public function before_insert(Model $obj)
{
if ($this->_overwrite or empty($obj->{$this->_property}))
{
$obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
}
} | [
"public",
"function",
"before_insert",
"(",
"Model",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_overwrite",
"or",
"empty",
"(",
"$",
"obj",
"->",
"{",
"$",
"this",
"->",
"_property",
"}",
")",
")",
"{",
"$",
"obj",
"->",
"{",
"$",
"this",
"->",
"_property",
"}",
"=",
"$",
"this",
"->",
"_mysql_timestamp",
"?",
"\\",
"Date",
"::",
"time",
"(",
")",
"->",
"format",
"(",
"'mysql'",
")",
":",
"\\",
"Date",
"::",
"time",
"(",
")",
"->",
"get_timestamp",
"(",
")",
";",
"}",
"}"
] | Set the CreatedAt property to the current time.
@param Model Model object subject of this observer method | [
"Set",
"the",
"CreatedAt",
"property",
"to",
"the",
"current",
"time",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/createdat.php#L67-L73 |
240,071 | heyday/heystack-ecommerce-core | src/Transaction/Subscriber.php | Subscriber.getSubscribedEvents | public static function getSubscribedEvents()
{
return [
Events::UPDATE => ['onUpdate',0],
Events::STORE => ['onStore', 0],
sprintf('%s.%s', Backend::IDENTIFIER, TransactionEvents::STORED) => ['onTransactionStored', 0]
];
} | php | public static function getSubscribedEvents()
{
return [
Events::UPDATE => ['onUpdate',0],
Events::STORE => ['onStore', 0],
sprintf('%s.%s', Backend::IDENTIFIER, TransactionEvents::STORED) => ['onTransactionStored', 0]
];
} | [
"public",
"static",
"function",
"getSubscribedEvents",
"(",
")",
"{",
"return",
"[",
"Events",
"::",
"UPDATE",
"=>",
"[",
"'onUpdate'",
",",
"0",
"]",
",",
"Events",
"::",
"STORE",
"=>",
"[",
"'onStore'",
",",
"0",
"]",
",",
"sprintf",
"(",
"'%s.%s'",
",",
"Backend",
"::",
"IDENTIFIER",
",",
"TransactionEvents",
"::",
"STORED",
")",
"=>",
"[",
"'onTransactionStored'",
",",
"0",
"]",
"]",
";",
"}"
] | Returns an array of events to subscribe to and the methods to call when those events are fired
@return array | [
"Returns",
"an",
"array",
"of",
"events",
"to",
"subscribe",
"to",
"and",
"the",
"methods",
"to",
"call",
"when",
"those",
"events",
"are",
"fired"
] | b56c83839cd3396da6bc881d843fcb4f28b74685 | https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Subscriber.php#L68-L75 |
240,072 | glynnforrest/reform | src/Reform/Form/Row/AbstractRow.php | AbstractRow.submitForm | public function submitForm(array $values)
{
$this->value = isset($values[$this->name]) ? $values[$this->name] : null;
} | php | public function submitForm(array $values)
{
$this->value = isset($values[$this->name]) ? $values[$this->name] : null;
} | [
"public",
"function",
"submitForm",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"isset",
"(",
"$",
"values",
"[",
"$",
"this",
"->",
"name",
"]",
")",
"?",
"$",
"values",
"[",
"$",
"this",
"->",
"name",
"]",
":",
"null",
";",
"}"
] | Pass in submitted values to allow the row to assign any values
that are required.
@param array $values The values | [
"Pass",
"in",
"submitted",
"values",
"to",
"allow",
"the",
"row",
"to",
"assign",
"any",
"values",
"that",
"are",
"required",
"."
] | a2a33dfa73933875f9c1dd0691b21e678a541a9e | https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Row/AbstractRow.php#L213-L216 |
240,073 | jmpantoja/planb-utils | src/DS/Resolver/Rule/Loader.php | Loader.resolve | protected function resolve(Input $input): Input
{
$this->call($input->value());
$input->ignore();
return $input;
} | php | protected function resolve(Input $input): Input
{
$this->call($input->value());
$input->ignore();
return $input;
} | [
"protected",
"function",
"resolve",
"(",
"Input",
"$",
"input",
")",
":",
"Input",
"{",
"$",
"this",
"->",
"call",
"(",
"$",
"input",
"->",
"value",
"(",
")",
")",
";",
"$",
"input",
"->",
"ignore",
"(",
")",
";",
"return",
"$",
"input",
";",
"}"
] | Resuelve un input
@param \PlanB\DS\Resolver\Input $input
@return \PlanB\DS\Resolver\Input
@throws \Throwable | [
"Resuelve",
"un",
"input"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Resolver/Rule/Loader.php#L33-L39 |
240,074 | fireguard/form | src/Form/Elements/AbstractElement.php | AbstractElement.makeElement | protected function makeElement(array $options, $html)
{
if (isset($options['type']) && $options['type'] == 'hidden') return $html;
if (!empty($options['before-input'])) $html = $options['before-input'].$html;
$html = $this->getLabel($options).$html;
if (!empty($options['after-input'])) $html .= $options['after-input'];
$html .= $this->html->getDivError($options);
$html = $this->html->getFormGroup($options, $html);
if (!empty($options['script'])) $this->appendScript($options['script']);
if (!empty($options['mask'])) $this->appendScript($this->html->getMaskScript($options));
return $this->html->getGrid($options, $html);
} | php | protected function makeElement(array $options, $html)
{
if (isset($options['type']) && $options['type'] == 'hidden') return $html;
if (!empty($options['before-input'])) $html = $options['before-input'].$html;
$html = $this->getLabel($options).$html;
if (!empty($options['after-input'])) $html .= $options['after-input'];
$html .= $this->html->getDivError($options);
$html = $this->html->getFormGroup($options, $html);
if (!empty($options['script'])) $this->appendScript($options['script']);
if (!empty($options['mask'])) $this->appendScript($this->html->getMaskScript($options));
return $this->html->getGrid($options, $html);
} | [
"protected",
"function",
"makeElement",
"(",
"array",
"$",
"options",
",",
"$",
"html",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
"&&",
"$",
"options",
"[",
"'type'",
"]",
"==",
"'hidden'",
")",
"return",
"$",
"html",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'before-input'",
"]",
")",
")",
"$",
"html",
"=",
"$",
"options",
"[",
"'before-input'",
"]",
".",
"$",
"html",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getLabel",
"(",
"$",
"options",
")",
".",
"$",
"html",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'after-input'",
"]",
")",
")",
"$",
"html",
".=",
"$",
"options",
"[",
"'after-input'",
"]",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"html",
"->",
"getDivError",
"(",
"$",
"options",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"html",
"->",
"getFormGroup",
"(",
"$",
"options",
",",
"$",
"html",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'script'",
"]",
")",
")",
"$",
"this",
"->",
"appendScript",
"(",
"$",
"options",
"[",
"'script'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
")",
"$",
"this",
"->",
"appendScript",
"(",
"$",
"this",
"->",
"html",
"->",
"getMaskScript",
"(",
"$",
"options",
")",
")",
";",
"return",
"$",
"this",
"->",
"html",
"->",
"getGrid",
"(",
"$",
"options",
",",
"$",
"html",
")",
";",
"}"
] | Make an Element
@param array $options
@param $html
@return string | [
"Make",
"an",
"Element"
] | cae5b36e165083fd553e596171356284f6edc4d4 | https://github.com/fireguard/form/blob/cae5b36e165083fd553e596171356284f6edc4d4/src/Form/Elements/AbstractElement.php#L164-L178 |
240,075 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.Initialize | public static function Initialize($ForceEnable = FALSE, $ForceMethod = FALSE) {
$AllowCaching = self::ActiveEnabled($ForceEnable);
$ActiveCache = Gdn_Cache::ActiveCache();
if ($ForceMethod !== FALSE) $ActiveCache = $ForceMethod;
$ActiveCacheClass = 'Gdn_'.ucfirst($ActiveCache);
if (!$AllowCaching || !$ActiveCache || !class_exists($ActiveCacheClass)) {
$CacheObject = new Gdn_Dirtycache();
} else
$CacheObject = new $ActiveCacheClass();
if (method_exists($CacheObject,'Autorun'))
$CacheObject->Autorun();
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager)
Gdn::PluginManager()->FireEvent('AfterActiveCache');
return $CacheObject;
} | php | public static function Initialize($ForceEnable = FALSE, $ForceMethod = FALSE) {
$AllowCaching = self::ActiveEnabled($ForceEnable);
$ActiveCache = Gdn_Cache::ActiveCache();
if ($ForceMethod !== FALSE) $ActiveCache = $ForceMethod;
$ActiveCacheClass = 'Gdn_'.ucfirst($ActiveCache);
if (!$AllowCaching || !$ActiveCache || !class_exists($ActiveCacheClass)) {
$CacheObject = new Gdn_Dirtycache();
} else
$CacheObject = new $ActiveCacheClass();
if (method_exists($CacheObject,'Autorun'))
$CacheObject->Autorun();
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager)
Gdn::PluginManager()->FireEvent('AfterActiveCache');
return $CacheObject;
} | [
"public",
"static",
"function",
"Initialize",
"(",
"$",
"ForceEnable",
"=",
"FALSE",
",",
"$",
"ForceMethod",
"=",
"FALSE",
")",
"{",
"$",
"AllowCaching",
"=",
"self",
"::",
"ActiveEnabled",
"(",
"$",
"ForceEnable",
")",
";",
"$",
"ActiveCache",
"=",
"Gdn_Cache",
"::",
"ActiveCache",
"(",
")",
";",
"if",
"(",
"$",
"ForceMethod",
"!==",
"FALSE",
")",
"$",
"ActiveCache",
"=",
"$",
"ForceMethod",
";",
"$",
"ActiveCacheClass",
"=",
"'Gdn_'",
".",
"ucfirst",
"(",
"$",
"ActiveCache",
")",
";",
"if",
"(",
"!",
"$",
"AllowCaching",
"||",
"!",
"$",
"ActiveCache",
"||",
"!",
"class_exists",
"(",
"$",
"ActiveCacheClass",
")",
")",
"{",
"$",
"CacheObject",
"=",
"new",
"Gdn_Dirtycache",
"(",
")",
";",
"}",
"else",
"$",
"CacheObject",
"=",
"new",
"$",
"ActiveCacheClass",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"CacheObject",
",",
"'Autorun'",
")",
")",
"$",
"CacheObject",
"->",
"Autorun",
"(",
")",
";",
"// This should only fire when cache is loading automatically",
"if",
"(",
"!",
"func_num_args",
"(",
")",
"&&",
"Gdn",
"::",
"PluginManager",
"(",
")",
"instanceof",
"Gdn_PluginManager",
")",
"Gdn",
"::",
"PluginManager",
"(",
")",
"->",
"FireEvent",
"(",
"'AfterActiveCache'",
")",
";",
"return",
"$",
"CacheObject",
";",
"}"
] | Determines the currently installed cache solution and returns a fresh instance of its object
@return Gdn_Cache | [
"Determines",
"the",
"currently",
"installed",
"cache",
"solution",
"and",
"returns",
"a",
"fresh",
"instance",
"of",
"its",
"object"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L138-L159 |
240,076 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.ActiveCache | public static function ActiveCache() {
/*
* There is a catch 22 with caching the config file. We need
* an external way to define the cache layer before needing it
* in the config.
*/
if (defined('CACHE_METHOD_OVERRIDE'))
$ActiveCache = CACHE_METHOD_OVERRIDE;
else
$ActiveCache = C('Cache.Method', FALSE);
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager) {
Gdn::PluginManager()->EventArguments['ActiveCache'] = &$ActiveCache;
Gdn::PluginManager()->FireEvent('BeforeActiveCache');
}
return $ActiveCache;
} | php | public static function ActiveCache() {
/*
* There is a catch 22 with caching the config file. We need
* an external way to define the cache layer before needing it
* in the config.
*/
if (defined('CACHE_METHOD_OVERRIDE'))
$ActiveCache = CACHE_METHOD_OVERRIDE;
else
$ActiveCache = C('Cache.Method', FALSE);
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager) {
Gdn::PluginManager()->EventArguments['ActiveCache'] = &$ActiveCache;
Gdn::PluginManager()->FireEvent('BeforeActiveCache');
}
return $ActiveCache;
} | [
"public",
"static",
"function",
"ActiveCache",
"(",
")",
"{",
"/*\n * There is a catch 22 with caching the config file. We need\n * an external way to define the cache layer before needing it \n * in the config.\n */",
"if",
"(",
"defined",
"(",
"'CACHE_METHOD_OVERRIDE'",
")",
")",
"$",
"ActiveCache",
"=",
"CACHE_METHOD_OVERRIDE",
";",
"else",
"$",
"ActiveCache",
"=",
"C",
"(",
"'Cache.Method'",
",",
"FALSE",
")",
";",
"// This should only fire when cache is loading automatically",
"if",
"(",
"!",
"func_num_args",
"(",
")",
"&&",
"Gdn",
"::",
"PluginManager",
"(",
")",
"instanceof",
"Gdn_PluginManager",
")",
"{",
"Gdn",
"::",
"PluginManager",
"(",
")",
"->",
"EventArguments",
"[",
"'ActiveCache'",
"]",
"=",
"&",
"$",
"ActiveCache",
";",
"Gdn",
"::",
"PluginManager",
"(",
")",
"->",
"FireEvent",
"(",
"'BeforeActiveCache'",
")",
";",
"}",
"return",
"$",
"ActiveCache",
";",
"}"
] | Gets the shortname of the currently active cache
This method retrieves the name of the active cache according to the config file.
It fires an event thereafter, allowing that value to be overridden
by loaded plugins.
@return string shortname of current auto active cache | [
"Gets",
"the",
"shortname",
"of",
"the",
"currently",
"active",
"cache"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L170-L189 |
240,077 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.ActiveEnabled | public static function ActiveEnabled($ForceEnable = FALSE) {
$AllowCaching = FALSE;
if (defined('CACHE_ENABLED_OVERRIDE'))
$AllowCaching |= CACHE_ENABLED_OVERRIDE;
$AllowCaching |= C('Cache.Enabled', FALSE);
$AllowCaching |= $ForceEnable;
return (bool)$AllowCaching;
} | php | public static function ActiveEnabled($ForceEnable = FALSE) {
$AllowCaching = FALSE;
if (defined('CACHE_ENABLED_OVERRIDE'))
$AllowCaching |= CACHE_ENABLED_OVERRIDE;
$AllowCaching |= C('Cache.Enabled', FALSE);
$AllowCaching |= $ForceEnable;
return (bool)$AllowCaching;
} | [
"public",
"static",
"function",
"ActiveEnabled",
"(",
"$",
"ForceEnable",
"=",
"FALSE",
")",
"{",
"$",
"AllowCaching",
"=",
"FALSE",
";",
"if",
"(",
"defined",
"(",
"'CACHE_ENABLED_OVERRIDE'",
")",
")",
"$",
"AllowCaching",
"|=",
"CACHE_ENABLED_OVERRIDE",
";",
"$",
"AllowCaching",
"|=",
"C",
"(",
"'Cache.Enabled'",
",",
"FALSE",
")",
";",
"$",
"AllowCaching",
"|=",
"$",
"ForceEnable",
";",
"return",
"(",
"bool",
")",
"$",
"AllowCaching",
";",
"}"
] | Get the status of the active cache
Return whether or not the current cache method is enabled.
@param type $ForceEnable
@return bool status of active cache | [
"Get",
"the",
"status",
"of",
"the",
"active",
"cache"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L199-L209 |
240,078 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.ActiveStore | public static function ActiveStore($ForceMethod = NULL) {
// Get the active cache name
$ActiveCache = self::ActiveCache();
if (!is_null($ForceMethod))
$ActiveCache = $ForceMethod;
$ActiveCache = ucfirst($ActiveCache);
// Overrides
if (defined('CACHE_STORE_OVERRIDE') && defined('CACHE_METHOD_OVERRIDE') && CACHE_METHOD_OVERRIDE == $ActiveCache)
return unserialize(CACHE_STORE_OVERRIDE);
$apc = false;
if (C('Garden.Apc', false) && C('Garden.Cache.ApcPrecache', false) && function_exists('apc_fetch'))
$apc = true;
$LocalStore = null;
$ActiveStore = null;
$ActiveStoreKey = "Cache.{$ActiveCache}.Store";
// Check memory
if (is_null($LocalStore)) {
if (array_key_exists($ActiveCache, Gdn_Cache::$Stores)) {
$LocalStore = Gdn_Cache::$Stores[$ActiveCache];
}
}
// Check APC cache
if (is_null($LocalStore) && $apc) {
$LocalStore = apc_fetch($ActiveStoreKey);
if ($LocalStore) {
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
}
}
if (is_array($LocalStore)) {
// Convert to ActiveStore format (with 'Active' key)
$Save = false;
$ActiveStore = array();
foreach ($LocalStore as $StoreServerName => &$StoreServer) {
$IsDelayed = &$StoreServer['Delay'];
$IsActive = &$StoreServer['Active'];
if (is_numeric($IsDelayed)) {
if ($IsDelayed < time()) {
$IsActive = true;
$IsDelayed = false;
$StoreServer['Fails'] = 0;
$Save = true;
} else {
if ($IsActive) {
$IsActive = false;
$Save = true;
}
}
}
// Add active servers to ActiveStore array
if ($IsActive)
$ActiveStore[] = $StoreServer['Server'];
}
}
// No local copy, get from config
if (is_null($ActiveStore)) {
$ActiveStore = C($ActiveStoreKey, false);
// Convert to LocalStore format
$LocalStore = array();
$ActiveStore = (array)$ActiveStore;
foreach ($ActiveStore as $StoreServer) {
$StoreServerName = md5($StoreServer);
$LocalStore[$StoreServerName] = array(
'Server' => $StoreServer,
'Active' => true,
'Delay' => false,
'Fails' => 0
);
}
$Save = true;
}
if ($Save) {
// Save to memory
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
// Save back to APC for later
if ($apc) {
apc_store($ActiveStoreKey, $LocalStore, Gdn_Cache::APC_CACHE_DURATION);
}
}
return $ActiveStore;
} | php | public static function ActiveStore($ForceMethod = NULL) {
// Get the active cache name
$ActiveCache = self::ActiveCache();
if (!is_null($ForceMethod))
$ActiveCache = $ForceMethod;
$ActiveCache = ucfirst($ActiveCache);
// Overrides
if (defined('CACHE_STORE_OVERRIDE') && defined('CACHE_METHOD_OVERRIDE') && CACHE_METHOD_OVERRIDE == $ActiveCache)
return unserialize(CACHE_STORE_OVERRIDE);
$apc = false;
if (C('Garden.Apc', false) && C('Garden.Cache.ApcPrecache', false) && function_exists('apc_fetch'))
$apc = true;
$LocalStore = null;
$ActiveStore = null;
$ActiveStoreKey = "Cache.{$ActiveCache}.Store";
// Check memory
if (is_null($LocalStore)) {
if (array_key_exists($ActiveCache, Gdn_Cache::$Stores)) {
$LocalStore = Gdn_Cache::$Stores[$ActiveCache];
}
}
// Check APC cache
if (is_null($LocalStore) && $apc) {
$LocalStore = apc_fetch($ActiveStoreKey);
if ($LocalStore) {
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
}
}
if (is_array($LocalStore)) {
// Convert to ActiveStore format (with 'Active' key)
$Save = false;
$ActiveStore = array();
foreach ($LocalStore as $StoreServerName => &$StoreServer) {
$IsDelayed = &$StoreServer['Delay'];
$IsActive = &$StoreServer['Active'];
if (is_numeric($IsDelayed)) {
if ($IsDelayed < time()) {
$IsActive = true;
$IsDelayed = false;
$StoreServer['Fails'] = 0;
$Save = true;
} else {
if ($IsActive) {
$IsActive = false;
$Save = true;
}
}
}
// Add active servers to ActiveStore array
if ($IsActive)
$ActiveStore[] = $StoreServer['Server'];
}
}
// No local copy, get from config
if (is_null($ActiveStore)) {
$ActiveStore = C($ActiveStoreKey, false);
// Convert to LocalStore format
$LocalStore = array();
$ActiveStore = (array)$ActiveStore;
foreach ($ActiveStore as $StoreServer) {
$StoreServerName = md5($StoreServer);
$LocalStore[$StoreServerName] = array(
'Server' => $StoreServer,
'Active' => true,
'Delay' => false,
'Fails' => 0
);
}
$Save = true;
}
if ($Save) {
// Save to memory
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
// Save back to APC for later
if ($apc) {
apc_store($ActiveStoreKey, $LocalStore, Gdn_Cache::APC_CACHE_DURATION);
}
}
return $ActiveStore;
} | [
"public",
"static",
"function",
"ActiveStore",
"(",
"$",
"ForceMethod",
"=",
"NULL",
")",
"{",
"// Get the active cache name",
"$",
"ActiveCache",
"=",
"self",
"::",
"ActiveCache",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ForceMethod",
")",
")",
"$",
"ActiveCache",
"=",
"$",
"ForceMethod",
";",
"$",
"ActiveCache",
"=",
"ucfirst",
"(",
"$",
"ActiveCache",
")",
";",
"// Overrides",
"if",
"(",
"defined",
"(",
"'CACHE_STORE_OVERRIDE'",
")",
"&&",
"defined",
"(",
"'CACHE_METHOD_OVERRIDE'",
")",
"&&",
"CACHE_METHOD_OVERRIDE",
"==",
"$",
"ActiveCache",
")",
"return",
"unserialize",
"(",
"CACHE_STORE_OVERRIDE",
")",
";",
"$",
"apc",
"=",
"false",
";",
"if",
"(",
"C",
"(",
"'Garden.Apc'",
",",
"false",
")",
"&&",
"C",
"(",
"'Garden.Cache.ApcPrecache'",
",",
"false",
")",
"&&",
"function_exists",
"(",
"'apc_fetch'",
")",
")",
"$",
"apc",
"=",
"true",
";",
"$",
"LocalStore",
"=",
"null",
";",
"$",
"ActiveStore",
"=",
"null",
";",
"$",
"ActiveStoreKey",
"=",
"\"Cache.{$ActiveCache}.Store\"",
";",
"// Check memory",
"if",
"(",
"is_null",
"(",
"$",
"LocalStore",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"ActiveCache",
",",
"Gdn_Cache",
"::",
"$",
"Stores",
")",
")",
"{",
"$",
"LocalStore",
"=",
"Gdn_Cache",
"::",
"$",
"Stores",
"[",
"$",
"ActiveCache",
"]",
";",
"}",
"}",
"// Check APC cache",
"if",
"(",
"is_null",
"(",
"$",
"LocalStore",
")",
"&&",
"$",
"apc",
")",
"{",
"$",
"LocalStore",
"=",
"apc_fetch",
"(",
"$",
"ActiveStoreKey",
")",
";",
"if",
"(",
"$",
"LocalStore",
")",
"{",
"Gdn_Cache",
"::",
"$",
"Stores",
"[",
"$",
"ActiveCache",
"]",
"=",
"$",
"LocalStore",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"LocalStore",
")",
")",
"{",
"// Convert to ActiveStore format (with 'Active' key)",
"$",
"Save",
"=",
"false",
";",
"$",
"ActiveStore",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"LocalStore",
"as",
"$",
"StoreServerName",
"=>",
"&",
"$",
"StoreServer",
")",
"{",
"$",
"IsDelayed",
"=",
"&",
"$",
"StoreServer",
"[",
"'Delay'",
"]",
";",
"$",
"IsActive",
"=",
"&",
"$",
"StoreServer",
"[",
"'Active'",
"]",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"IsDelayed",
")",
")",
"{",
"if",
"(",
"$",
"IsDelayed",
"<",
"time",
"(",
")",
")",
"{",
"$",
"IsActive",
"=",
"true",
";",
"$",
"IsDelayed",
"=",
"false",
";",
"$",
"StoreServer",
"[",
"'Fails'",
"]",
"=",
"0",
";",
"$",
"Save",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"IsActive",
")",
"{",
"$",
"IsActive",
"=",
"false",
";",
"$",
"Save",
"=",
"true",
";",
"}",
"}",
"}",
"// Add active servers to ActiveStore array",
"if",
"(",
"$",
"IsActive",
")",
"$",
"ActiveStore",
"[",
"]",
"=",
"$",
"StoreServer",
"[",
"'Server'",
"]",
";",
"}",
"}",
"// No local copy, get from config",
"if",
"(",
"is_null",
"(",
"$",
"ActiveStore",
")",
")",
"{",
"$",
"ActiveStore",
"=",
"C",
"(",
"$",
"ActiveStoreKey",
",",
"false",
")",
";",
"// Convert to LocalStore format",
"$",
"LocalStore",
"=",
"array",
"(",
")",
";",
"$",
"ActiveStore",
"=",
"(",
"array",
")",
"$",
"ActiveStore",
";",
"foreach",
"(",
"$",
"ActiveStore",
"as",
"$",
"StoreServer",
")",
"{",
"$",
"StoreServerName",
"=",
"md5",
"(",
"$",
"StoreServer",
")",
";",
"$",
"LocalStore",
"[",
"$",
"StoreServerName",
"]",
"=",
"array",
"(",
"'Server'",
"=>",
"$",
"StoreServer",
",",
"'Active'",
"=>",
"true",
",",
"'Delay'",
"=>",
"false",
",",
"'Fails'",
"=>",
"0",
")",
";",
"}",
"$",
"Save",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"Save",
")",
"{",
"// Save to memory",
"Gdn_Cache",
"::",
"$",
"Stores",
"[",
"$",
"ActiveCache",
"]",
"=",
"$",
"LocalStore",
";",
"// Save back to APC for later",
"if",
"(",
"$",
"apc",
")",
"{",
"apc_store",
"(",
"$",
"ActiveStoreKey",
",",
"$",
"LocalStore",
",",
"Gdn_Cache",
"::",
"APC_CACHE_DURATION",
")",
";",
"}",
"}",
"return",
"$",
"ActiveStore",
";",
"}"
] | Returns the storage data for the active cache
For FileCache, the folder. For Memcache, the server(s).
@param type $ForceMethod
@return mixed Active Store Location | [
"Returns",
"the",
"storage",
"data",
"for",
"the",
"active",
"cache"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L219-L314 |
240,079 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.Fail | public function Fail($server) {
// Use APC?
$apc = false;
if (C('Garden.Apc', false) && function_exists('apc_fetch'))
$apc = true;
// Get the active cache name
$activeCache = Gdn_Cache::ActiveCache();
$activeCache = ucfirst($activeCache);
$sctiveStoreKey = "Cache.{$activeCache}.Store";
// Get the localstore
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
Gdn_Cache::ActiveStore();
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
return false;
}
}
$storeServerName = md5($server);
if (!array_key_exists($storeServerName, $localStore)) {
return false;
}
$storeServer = &$localStore[$storeServerName];
$isActive = &$storeServer['Active'];
if (!$isActive) return false;
$fails = &$storeServer['Fails'];
$fails++;
$active = $isActive ? 'active' : 'inactive';
// Check if we need to deactivate for 5 minutes
if ($isActive && $storeServer['Fails'] > 3) {
$isActive = false;
$storeServer['Delay'] = time() + Gdn_Cache::CACHE_EJECT_DURATION;
}
// Save
Gdn_Cache::$Stores[$activeCache] = $localStore;
// Save to APC
if ($apc) {
apc_store($sctiveStoreKey, $localStore, Gdn_Cache::APC_CACHE_DURATION);
}
return true;
} | php | public function Fail($server) {
// Use APC?
$apc = false;
if (C('Garden.Apc', false) && function_exists('apc_fetch'))
$apc = true;
// Get the active cache name
$activeCache = Gdn_Cache::ActiveCache();
$activeCache = ucfirst($activeCache);
$sctiveStoreKey = "Cache.{$activeCache}.Store";
// Get the localstore
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
Gdn_Cache::ActiveStore();
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
return false;
}
}
$storeServerName = md5($server);
if (!array_key_exists($storeServerName, $localStore)) {
return false;
}
$storeServer = &$localStore[$storeServerName];
$isActive = &$storeServer['Active'];
if (!$isActive) return false;
$fails = &$storeServer['Fails'];
$fails++;
$active = $isActive ? 'active' : 'inactive';
// Check if we need to deactivate for 5 minutes
if ($isActive && $storeServer['Fails'] > 3) {
$isActive = false;
$storeServer['Delay'] = time() + Gdn_Cache::CACHE_EJECT_DURATION;
}
// Save
Gdn_Cache::$Stores[$activeCache] = $localStore;
// Save to APC
if ($apc) {
apc_store($sctiveStoreKey, $localStore, Gdn_Cache::APC_CACHE_DURATION);
}
return true;
} | [
"public",
"function",
"Fail",
"(",
"$",
"server",
")",
"{",
"// Use APC?",
"$",
"apc",
"=",
"false",
";",
"if",
"(",
"C",
"(",
"'Garden.Apc'",
",",
"false",
")",
"&&",
"function_exists",
"(",
"'apc_fetch'",
")",
")",
"$",
"apc",
"=",
"true",
";",
"// Get the active cache name",
"$",
"activeCache",
"=",
"Gdn_Cache",
"::",
"ActiveCache",
"(",
")",
";",
"$",
"activeCache",
"=",
"ucfirst",
"(",
"$",
"activeCache",
")",
";",
"$",
"sctiveStoreKey",
"=",
"\"Cache.{$activeCache}.Store\"",
";",
"// Get the localstore",
"$",
"localStore",
"=",
"GetValue",
"(",
"$",
"activeCache",
",",
"Gdn_Cache",
"::",
"$",
"Stores",
",",
"null",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"localStore",
")",
")",
"{",
"Gdn_Cache",
"::",
"ActiveStore",
"(",
")",
";",
"$",
"localStore",
"=",
"GetValue",
"(",
"$",
"activeCache",
",",
"Gdn_Cache",
"::",
"$",
"Stores",
",",
"null",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"localStore",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"$",
"storeServerName",
"=",
"md5",
"(",
"$",
"server",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"storeServerName",
",",
"$",
"localStore",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"storeServer",
"=",
"&",
"$",
"localStore",
"[",
"$",
"storeServerName",
"]",
";",
"$",
"isActive",
"=",
"&",
"$",
"storeServer",
"[",
"'Active'",
"]",
";",
"if",
"(",
"!",
"$",
"isActive",
")",
"return",
"false",
";",
"$",
"fails",
"=",
"&",
"$",
"storeServer",
"[",
"'Fails'",
"]",
";",
"$",
"fails",
"++",
";",
"$",
"active",
"=",
"$",
"isActive",
"?",
"'active'",
":",
"'inactive'",
";",
"// Check if we need to deactivate for 5 minutes",
"if",
"(",
"$",
"isActive",
"&&",
"$",
"storeServer",
"[",
"'Fails'",
"]",
">",
"3",
")",
"{",
"$",
"isActive",
"=",
"false",
";",
"$",
"storeServer",
"[",
"'Delay'",
"]",
"=",
"time",
"(",
")",
"+",
"Gdn_Cache",
"::",
"CACHE_EJECT_DURATION",
";",
"}",
"// Save",
"Gdn_Cache",
"::",
"$",
"Stores",
"[",
"$",
"activeCache",
"]",
"=",
"$",
"localStore",
";",
"// Save to APC",
"if",
"(",
"$",
"apc",
")",
"{",
"apc_store",
"(",
"$",
"sctiveStoreKey",
",",
"$",
"localStore",
",",
"Gdn_Cache",
"::",
"APC_CACHE_DURATION",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Register a temporary server connection failure
This method will attempt to temporarily excise the offending server from
the connect roster for a period of time.
@param string $server | [
"Register",
"a",
"temporary",
"server",
"connection",
"failure"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L324-L374 |
240,080 | bishopb/vanilla | library/core/class.cache.php | Gdn_Cache.HasFeature | public function HasFeature($Feature) {
return isset($this->Features[$Feature]) ? $this->Features[$Feature] : Gdn_Cache::CACHEOP_FAILURE;
} | php | public function HasFeature($Feature) {
return isset($this->Features[$Feature]) ? $this->Features[$Feature] : Gdn_Cache::CACHEOP_FAILURE;
} | [
"public",
"function",
"HasFeature",
"(",
"$",
"Feature",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"Features",
"[",
"$",
"Feature",
"]",
")",
"?",
"$",
"this",
"->",
"Features",
"[",
"$",
"Feature",
"]",
":",
"Gdn_Cache",
"::",
"CACHEOP_FAILURE",
";",
"}"
] | Check whether this cache supports the specified feature
@param int $Feature feature constant
@return mixed $Meta returns the meta data supplied during RegisterFeature() | [
"Check",
"whether",
"this",
"cache",
"supports",
"the",
"specified",
"feature"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.cache.php#L742-L744 |
240,081 | agalbourdin/agl-core | src/Db/DbAbstract.php | DbAbstract.setConnection | public function setConnection($pHost, $pName, $pUser = NULL, $pPassword = NULL)
{
$this->_connection = $this->connect($pHost, $pName, $pUser, $pPassword);
$this->_dbName = $pName;
return $this;
} | php | public function setConnection($pHost, $pName, $pUser = NULL, $pPassword = NULL)
{
$this->_connection = $this->connect($pHost, $pName, $pUser, $pPassword);
$this->_dbName = $pName;
return $this;
} | [
"public",
"function",
"setConnection",
"(",
"$",
"pHost",
",",
"$",
"pName",
",",
"$",
"pUser",
"=",
"NULL",
",",
"$",
"pPassword",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"_connection",
"=",
"$",
"this",
"->",
"connect",
"(",
"$",
"pHost",
",",
"$",
"pName",
",",
"$",
"pUser",
",",
"$",
"pPassword",
")",
";",
"$",
"this",
"->",
"_dbName",
"=",
"$",
"pName",
";",
"return",
"$",
"this",
";",
"}"
] | Connect to database and register the connection.
@param string $pHost
@param string $pName
@param null|string $pUser
@param null|string $pPassword
@return Db | [
"Connect",
"to",
"database",
"and",
"register",
"the",
"connection",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Db/DbAbstract.php#L48-L53 |
240,082 | agalbourdin/agl-core | src/Db/DbAbstract.php | DbAbstract.getConnection | public function getConnection()
{
if (is_null($this->_connection)) {
$this->setConnection(
Agl::app()->getConfig('main/db/host'),
Agl::app()->getConfig('main/db/name'),
Agl::app()->getConfig('main/db/user'),
Agl::app()->getConfig('main/db/password')
);
}
return $this->_connection;
} | php | public function getConnection()
{
if (is_null($this->_connection)) {
$this->setConnection(
Agl::app()->getConfig('main/db/host'),
Agl::app()->getConfig('main/db/name'),
Agl::app()->getConfig('main/db/user'),
Agl::app()->getConfig('main/db/password')
);
}
return $this->_connection;
} | [
"public",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_connection",
")",
")",
"{",
"$",
"this",
"->",
"setConnection",
"(",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'main/db/host'",
")",
",",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'main/db/name'",
")",
",",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'main/db/user'",
")",
",",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'main/db/password'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_connection",
";",
"}"
] | Return the stored database connection.
@return mixed | [
"Return",
"the",
"stored",
"database",
"connection",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Db/DbAbstract.php#L60-L72 |
240,083 | Puzzlout/FrameworkMvcLegacy | src/Helpers/MapHelper.php | MapHelper.GetCoordinatesToCenterOverARegion | public static function GetCoordinatesToCenterOverARegion($configManager) {
return array(
"lat" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLat),
"lng" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLng)
);
} | php | public static function GetCoordinatesToCenterOverARegion($configManager) {
return array(
"lat" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLat),
"lng" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLng)
);
} | [
"public",
"static",
"function",
"GetCoordinatesToCenterOverARegion",
"(",
"$",
"configManager",
")",
"{",
"return",
"array",
"(",
"\"lat\"",
"=>",
"$",
"configManager",
"->",
"get",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"AppSettingKeys",
"::",
"GoogleMapsCenterLat",
")",
",",
"\"lng\"",
"=>",
"$",
"configManager",
"->",
"get",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"AppSettingKeys",
"::",
"GoogleMapsCenterLng",
")",
")",
";",
"}"
] | Retrieve the lattitude and longitude from the appsettings.xml
to build an associative array in the Google Maps API format
@param object $configManager
The object of Puzzlout\Framework\Config that read the appconfig.xml
@return array $coordinates
The array in Google Maps API format | [
"Retrieve",
"the",
"lattitude",
"and",
"longitude",
"from",
"the",
"appsettings",
".",
"xml",
"to",
"build",
"an",
"associative",
"array",
"in",
"the",
"Google",
"Maps",
"API",
"format"
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/MapHelper.php#L40-L45 |
240,084 | Puzzlout/FrameworkMvcLegacy | src/Helpers/MapHelper.php | MapHelper.BuildLatAndLongCoordFromGeoObjects | public static function BuildLatAndLongCoordFromGeoObjects($objects, $latPropName, $lngPropName) {
$coordinates = array();
foreach ($objects as $object) {
if (self::CheckCoordinateValue($object->$latPropName()) && self::CheckCoordinateValue($object->$lngPropName())) {
$coordinate = array(
"lat" => $object->$latPropName(),
"lng" => $object->$lngPropName()
);
array_push($coordinates, $coordinate);
}
}
return $coordinates;
} | php | public static function BuildLatAndLongCoordFromGeoObjects($objects, $latPropName, $lngPropName) {
$coordinates = array();
foreach ($objects as $object) {
if (self::CheckCoordinateValue($object->$latPropName()) && self::CheckCoordinateValue($object->$lngPropName())) {
$coordinate = array(
"lat" => $object->$latPropName(),
"lng" => $object->$lngPropName()
);
array_push($coordinates, $coordinate);
}
}
return $coordinates;
} | [
"public",
"static",
"function",
"BuildLatAndLongCoordFromGeoObjects",
"(",
"$",
"objects",
",",
"$",
"latPropName",
",",
"$",
"lngPropName",
")",
"{",
"$",
"coordinates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"self",
"::",
"CheckCoordinateValue",
"(",
"$",
"object",
"->",
"$",
"latPropName",
"(",
")",
")",
"&&",
"self",
"::",
"CheckCoordinateValue",
"(",
"$",
"object",
"->",
"$",
"lngPropName",
"(",
")",
")",
")",
"{",
"$",
"coordinate",
"=",
"array",
"(",
"\"lat\"",
"=>",
"$",
"object",
"->",
"$",
"latPropName",
"(",
")",
",",
"\"lng\"",
"=>",
"$",
"object",
"->",
"$",
"lngPropName",
"(",
")",
")",
";",
"array_push",
"(",
"$",
"coordinates",
",",
"$",
"coordinate",
")",
";",
"}",
"}",
"return",
"$",
"coordinates",
";",
"}"
] | Retrieve the lattitudes and longitudes from a list of objects
based the lattitude and longitude property names filter.
Build as an output an associative array in the Google Maps API format
@param array $objects
The array of objects of a given type
@param string $latPropName
The lattitude property name of a given object type
@param string $lngPropName
The longitude property name of a given object type
@return array $coordinates
The array in Google Maps API format | [
"Retrieve",
"the",
"lattitudes",
"and",
"longitudes",
"from",
"a",
"list",
"of",
"objects",
"based",
"the",
"lattitude",
"and",
"longitude",
"property",
"names",
"filter",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/MapHelper.php#L66-L78 |
240,085 | calgamo/getopt | src/Getopt.php | Getopt.addOptions | public function addOptions(array $options) : Getopt
{
if (!empty($this->options)){
$this->options = array_merge($this->options, $options);
}
else{
$this->options = $options;
}
return $this;
} | php | public function addOptions(array $options) : Getopt
{
if (!empty($this->options)){
$this->options = array_merge($this->options, $options);
}
else{
$this->options = $options;
}
return $this;
} | [
"public",
"function",
"addOptions",
"(",
"array",
"$",
"options",
")",
":",
"Getopt",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add short options
@param array $options
@return Getopt | [
"Add",
"short",
"options"
] | 88c05513e92e5de9f6a9b481174dfc953cb57aa1 | https://github.com/calgamo/getopt/blob/88c05513e92e5de9f6a9b481174dfc953cb57aa1/src/Getopt.php#L28-L37 |
240,086 | bariew/yii2-user-cms-module | Module.php | Module.hasUser | public static function hasUser()
{
if (!(Yii::$app instanceof Application)) {
return false;
}
if (!Yii::$app->db->getTableSchema(User::tableName())) {
return false;
}
try {
$identityClass = Yii::$app->user->identityClass;
} catch (\Exception $e) {
$identityClass = false;
}
if (!$identityClass) {
return false;
}
return !Yii::$app->user->isGuest;
} | php | public static function hasUser()
{
if (!(Yii::$app instanceof Application)) {
return false;
}
if (!Yii::$app->db->getTableSchema(User::tableName())) {
return false;
}
try {
$identityClass = Yii::$app->user->identityClass;
} catch (\Exception $e) {
$identityClass = false;
}
if (!$identityClass) {
return false;
}
return !Yii::$app->user->isGuest;
} | [
"public",
"static",
"function",
"hasUser",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"Yii",
"::",
"$",
"app",
"instanceof",
"Application",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"getTableSchema",
"(",
"User",
"::",
"tableName",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"identityClass",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identityClass",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"identityClass",
"=",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"identityClass",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
";",
"}"
] | We just check whether module is installed and user is logged in.
@return bool | [
"We",
"just",
"check",
"whether",
"module",
"is",
"installed",
"and",
"user",
"is",
"logged",
"in",
"."
] | d9f5658cae45308c0916bc99976272a4ec906490 | https://github.com/bariew/yii2-user-cms-module/blob/d9f5658cae45308c0916bc99976272a4ec906490/Module.php#L38-L58 |
240,087 | neomorina/core | Str.php | Str.StartsWith | public static function StartsWith($haystack, $needle)
{
$length = static::Length($needle);
return substr($haystack, 0, $length) === $needle;
} | php | public static function StartsWith($haystack, $needle)
{
$length = static::Length($needle);
return substr($haystack, 0, $length) === $needle;
} | [
"public",
"static",
"function",
"StartsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"$",
"length",
"=",
"static",
"::",
"Length",
"(",
"$",
"needle",
")",
";",
"return",
"substr",
"(",
"$",
"haystack",
",",
"0",
",",
"$",
"length",
")",
"===",
"$",
"needle",
";",
"}"
] | Determine if the given string starts with the given substring.
@param string $haystack string
@param string $needle substring
@return bool | [
"Determine",
"if",
"the",
"given",
"string",
"starts",
"with",
"the",
"given",
"substring",
"."
] | 5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a | https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L43-L48 |
240,088 | neomorina/core | Str.php | Str.EndsWith | public static function EndsWith($haystack, $needle)
{
$length = static::Length($needle);
return $length === 0 || (substr($haystack, -$length) === $needle);
} | php | public static function EndsWith($haystack, $needle)
{
$length = static::Length($needle);
return $length === 0 || (substr($haystack, -$length) === $needle);
} | [
"public",
"static",
"function",
"EndsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"$",
"length",
"=",
"static",
"::",
"Length",
"(",
"$",
"needle",
")",
";",
"return",
"$",
"length",
"===",
"0",
"||",
"(",
"substr",
"(",
"$",
"haystack",
",",
"-",
"$",
"length",
")",
"===",
"$",
"needle",
")",
";",
"}"
] | Determine if the given string ends with the given substring.
@param string $haystack string
@param string $needle substring
@return bool | [
"Determine",
"if",
"the",
"given",
"string",
"ends",
"with",
"the",
"given",
"substring",
"."
] | 5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a | https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L58-L63 |
240,089 | neomorina/core | Str.php | Str.Ucfirst | public static function Ucfirst($str)
{
return function_exists('ucfirst') ?
ucfirst($str) :
static::Upper(substr($str, 0, 1)).substr($str, 1);
} | php | public static function Ucfirst($str)
{
return function_exists('ucfirst') ?
ucfirst($str) :
static::Upper(substr($str, 0, 1)).substr($str, 1);
} | [
"public",
"static",
"function",
"Ucfirst",
"(",
"$",
"str",
")",
"{",
"return",
"function_exists",
"(",
"'ucfirst'",
")",
"?",
"ucfirst",
"(",
"$",
"str",
")",
":",
"static",
"::",
"Upper",
"(",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"1",
")",
")",
".",
"substr",
"(",
"$",
"str",
",",
"1",
")",
";",
"}"
] | Change string's first character uppercase.
@param string $str
@return string | [
"Change",
"string",
"s",
"first",
"character",
"uppercase",
"."
] | 5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a | https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L108-L113 |
240,090 | nonetallt/jinitialize-core | src/ProcedureFactory.php | ProcedureFactory.parseCommands | private function parseCommands(array $json, string $procedureName)
{
$factory = new CommandFactory($this->app);
$errors = [];
foreach($json as $commandString) {
/* Get the namespace of the command */
$plugin = explode(':', $commandString, 2)[0];
/* Check that the given plugin is installed */
if(! $this->app->getContainer()->hasPlugin($plugin)) {
$errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'.";
continue;
}
$parsedCommands[] = $factory->create($plugin, $commandString);
}
if(! empty($errors)) {
throw new PluginNotFoundException(implode(PHP_EOL, $errors));
}
return $parsedCommands;
} | php | private function parseCommands(array $json, string $procedureName)
{
$factory = new CommandFactory($this->app);
$errors = [];
foreach($json as $commandString) {
/* Get the namespace of the command */
$plugin = explode(':', $commandString, 2)[0];
/* Check that the given plugin is installed */
if(! $this->app->getContainer()->hasPlugin($plugin)) {
$errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'.";
continue;
}
$parsedCommands[] = $factory->create($plugin, $commandString);
}
if(! empty($errors)) {
throw new PluginNotFoundException(implode(PHP_EOL, $errors));
}
return $parsedCommands;
} | [
"private",
"function",
"parseCommands",
"(",
"array",
"$",
"json",
",",
"string",
"$",
"procedureName",
")",
"{",
"$",
"factory",
"=",
"new",
"CommandFactory",
"(",
"$",
"this",
"->",
"app",
")",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"json",
"as",
"$",
"commandString",
")",
"{",
"/* Get the namespace of the command */",
"$",
"plugin",
"=",
"explode",
"(",
"':'",
",",
"$",
"commandString",
",",
"2",
")",
"[",
"0",
"]",
";",
"/* Check that the given plugin is installed */",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"getContainer",
"(",
")",
"->",
"hasPlugin",
"(",
"$",
"plugin",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Plugin '$plugin' is required to run procedure '$procedureName'.\"",
";",
"continue",
";",
"}",
"$",
"parsedCommands",
"[",
"]",
"=",
"$",
"factory",
"->",
"create",
"(",
"$",
"plugin",
",",
"$",
"commandString",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"throw",
"new",
"PluginNotFoundException",
"(",
"implode",
"(",
"PHP_EOL",
",",
"$",
"errors",
")",
")",
";",
"}",
"return",
"$",
"parsedCommands",
";",
"}"
] | Create command classes from a json array | [
"Create",
"command",
"classes",
"from",
"a",
"json",
"array"
] | 284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f | https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L60-L82 |
240,091 | nonetallt/jinitialize-core | src/ProcedureFactory.php | ProcedureFactory.parseUntilFound | private function parseUntilFound(string $procedure)
{
/* First check if parsed content has the desired procedure */
foreach($this->parsed as $path => $json) {
if($this->hasProcedure($json, $procedure)) return $json;
}
/* Next, check if the most likely file has the procedure */
$json = $this->findMostLikelyFile($procedure);
if(! is_null($json)) return $json;
/* Lastly, check rest of the files one by one */
foreach($this->unparsedPaths() as $path) {
$json = $this->parsePath($path);
if($this->hasProcedure($json, $procedure)) return $json;
}
return null;
} | php | private function parseUntilFound(string $procedure)
{
/* First check if parsed content has the desired procedure */
foreach($this->parsed as $path => $json) {
if($this->hasProcedure($json, $procedure)) return $json;
}
/* Next, check if the most likely file has the procedure */
$json = $this->findMostLikelyFile($procedure);
if(! is_null($json)) return $json;
/* Lastly, check rest of the files one by one */
foreach($this->unparsedPaths() as $path) {
$json = $this->parsePath($path);
if($this->hasProcedure($json, $procedure)) return $json;
}
return null;
} | [
"private",
"function",
"parseUntilFound",
"(",
"string",
"$",
"procedure",
")",
"{",
"/* First check if parsed content has the desired procedure */",
"foreach",
"(",
"$",
"this",
"->",
"parsed",
"as",
"$",
"path",
"=>",
"$",
"json",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasProcedure",
"(",
"$",
"json",
",",
"$",
"procedure",
")",
")",
"return",
"$",
"json",
";",
"}",
"/* Next, check if the most likely file has the procedure */",
"$",
"json",
"=",
"$",
"this",
"->",
"findMostLikelyFile",
"(",
"$",
"procedure",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"json",
")",
")",
"return",
"$",
"json",
";",
"/* Lastly, check rest of the files one by one */",
"foreach",
"(",
"$",
"this",
"->",
"unparsedPaths",
"(",
")",
"as",
"$",
"path",
")",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parsePath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasProcedure",
"(",
"$",
"json",
",",
"$",
"procedure",
")",
")",
"return",
"$",
"json",
";",
"}",
"return",
"null",
";",
"}"
] | Parse paths until file containing the given procedure if found
or there is nothing left to parse. | [
"Parse",
"paths",
"until",
"file",
"containing",
"the",
"given",
"procedure",
"if",
"found",
"or",
"there",
"is",
"nothing",
"left",
"to",
"parse",
"."
] | 284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f | https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L89-L108 |
240,092 | nonetallt/jinitialize-core | src/ProcedureFactory.php | ProcedureFactory.findMostLikelyFile | private function findMostLikelyFile(string $procedure)
{
foreach($this->paths as $path) {
$filename = Strings::afterLast($path, '/');
$filenameWithoutExtension = Strings::untilLast($filename, '.');
if($procedure === $filenameWithoutExtension) {
return $filename;
}
}
return null;
} | php | private function findMostLikelyFile(string $procedure)
{
foreach($this->paths as $path) {
$filename = Strings::afterLast($path, '/');
$filenameWithoutExtension = Strings::untilLast($filename, '.');
if($procedure === $filenameWithoutExtension) {
return $filename;
}
}
return null;
} | [
"private",
"function",
"findMostLikelyFile",
"(",
"string",
"$",
"procedure",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"filename",
"=",
"Strings",
"::",
"afterLast",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"filenameWithoutExtension",
"=",
"Strings",
"::",
"untilLast",
"(",
"$",
"filename",
",",
"'.'",
")",
";",
"if",
"(",
"$",
"procedure",
"===",
"$",
"filenameWithoutExtension",
")",
"{",
"return",
"$",
"filename",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Find the file that is most likely to contain the given procedure.
Prioritizes files with the same name as the procedure. | [
"Find",
"the",
"file",
"that",
"is",
"most",
"likely",
"to",
"contain",
"the",
"given",
"procedure",
".",
"Prioritizes",
"files",
"with",
"the",
"same",
"name",
"as",
"the",
"procedure",
"."
] | 284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f | https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L115-L127 |
240,093 | jpcercal/resource-manager | src/Service/DoctrineResourceManager.php | DoctrineResourceManager.getQueryBuilder | protected function getQueryBuilder($repositoryMethod)
{
$repository = $this
->getDriver()
->getDoctrineOrmEm()
->getRepository($this->getDriver()->getEntityFqn())
;
$repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods();
if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) {
return $repository->createQueryBuilder($this->getDriver()->getEntityAlias());
}
$queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}();
if (!$queryBuilder instanceof QueryBuilder) {
throw new ResourceException(sprintf(
'The method "%s" of repository class must be return a %s instance',
$repositoryMethods[$repositoryMethod],
'\Doctrine\ORM\QueryBuilder'
));
}
return $queryBuilder;
} | php | protected function getQueryBuilder($repositoryMethod)
{
$repository = $this
->getDriver()
->getDoctrineOrmEm()
->getRepository($this->getDriver()->getEntityFqn())
;
$repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods();
if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) {
return $repository->createQueryBuilder($this->getDriver()->getEntityAlias());
}
$queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}();
if (!$queryBuilder instanceof QueryBuilder) {
throw new ResourceException(sprintf(
'The method "%s" of repository class must be return a %s instance',
$repositoryMethods[$repositoryMethod],
'\Doctrine\ORM\QueryBuilder'
));
}
return $queryBuilder;
} | [
"protected",
"function",
"getQueryBuilder",
"(",
"$",
"repositoryMethod",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"getDoctrineOrmEm",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"getEntityFqn",
"(",
")",
")",
";",
"$",
"repositoryMethods",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"getEntityRepositorySearchableMethods",
"(",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"repository",
",",
"$",
"repositoryMethods",
"[",
"$",
"repositoryMethod",
"]",
")",
")",
"{",
"return",
"$",
"repository",
"->",
"createQueryBuilder",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"getEntityAlias",
"(",
")",
")",
";",
"}",
"$",
"queryBuilder",
"=",
"$",
"repository",
"->",
"{",
"$",
"repositoryMethods",
"[",
"$",
"repositoryMethod",
"]",
"}",
"(",
")",
";",
"if",
"(",
"!",
"$",
"queryBuilder",
"instanceof",
"QueryBuilder",
")",
"{",
"throw",
"new",
"ResourceException",
"(",
"sprintf",
"(",
"'The method \"%s\" of repository class must be return a %s instance'",
",",
"$",
"repositoryMethods",
"[",
"$",
"repositoryMethod",
"]",
",",
"'\\Doctrine\\ORM\\QueryBuilder'",
")",
")",
";",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
] | Get the QueryBuilder instance.
@param string $repositoryMethod
@return QueryBuilder | [
"Get",
"the",
"QueryBuilder",
"instance",
"."
] | e3565eb1ce3c0f7f16188596f0a58a42a35baa64 | https://github.com/jpcercal/resource-manager/blob/e3565eb1ce3c0f7f16188596f0a58a42a35baa64/src/Service/DoctrineResourceManager.php#L63-L88 |
240,094 | weckx/wcx-syslog | library/Wcx/Syslog/Message/MessageAbstract.php | MessageAbstract.setTimestamp | public function setTimestamp($timestamp)
{
if (!$timestamp instanceof \DateTime) {
$date = new \DateTime();
$date->setTimestamp($timestamp);
} else {
$date = $timestamp;
}
$this->header['TIMESTAMP'] = $date->format('M d H:i:s');
return $this;
} | php | public function setTimestamp($timestamp)
{
if (!$timestamp instanceof \DateTime) {
$date = new \DateTime();
$date->setTimestamp($timestamp);
} else {
$date = $timestamp;
}
$this->header['TIMESTAMP'] = $date->format('M d H:i:s');
return $this;
} | [
"public",
"function",
"setTimestamp",
"(",
"$",
"timestamp",
")",
"{",
"if",
"(",
"!",
"$",
"timestamp",
"instanceof",
"\\",
"DateTime",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"date",
"->",
"setTimestamp",
"(",
"$",
"timestamp",
")",
";",
"}",
"else",
"{",
"$",
"date",
"=",
"$",
"timestamp",
";",
"}",
"$",
"this",
"->",
"header",
"[",
"'TIMESTAMP'",
"]",
"=",
"$",
"date",
"->",
"format",
"(",
"'M d H:i:s'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the timestamp of the message generation
@var int|\DateTime $timestamp UNIX Timestamp (as generated by time() or strtotime()) or a php DateTime object
@return Bsd | [
"Set",
"the",
"timestamp",
"of",
"the",
"message",
"generation"
] | 2ec40409a7b5393751ebf9051a33d829e6fc313e | https://github.com/weckx/wcx-syslog/blob/2ec40409a7b5393751ebf9051a33d829e6fc313e/library/Wcx/Syslog/Message/MessageAbstract.php#L168-L178 |
240,095 | tentwofour/twig | src/Ten24/Twig/Extension/NumberExtension.php | NumberExtension.formatNumberToHumanReadable | public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common')
{
if ($number >= 1000000) {
// Divide by 1000000 to get 1M, 1.23M, etc.
$value = $number / 1000000;
$extension = 'M';
} elseif ($number >= 1000 && $number < 1000000) {
// Divide by 1000, to get 1K, 1.33K, etc.
$value = $number / 1000;
$extension = 'K';
} else {
// Less than 1000, just return the number, unformatted, not rounded
$value = $number;
$extension = '';
}
if ('common' == $method) {
$value = round($value, $precision);
} else {
if ('ceil' != $method && 'floor' != $method) {
throw new \RuntimeException('The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.');
}
$value = $method($value * pow(10, $precision)) / pow(10, $precision);
}
return $value.$extension;
} | php | public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common')
{
if ($number >= 1000000) {
// Divide by 1000000 to get 1M, 1.23M, etc.
$value = $number / 1000000;
$extension = 'M';
} elseif ($number >= 1000 && $number < 1000000) {
// Divide by 1000, to get 1K, 1.33K, etc.
$value = $number / 1000;
$extension = 'K';
} else {
// Less than 1000, just return the number, unformatted, not rounded
$value = $number;
$extension = '';
}
if ('common' == $method) {
$value = round($value, $precision);
} else {
if ('ceil' != $method && 'floor' != $method) {
throw new \RuntimeException('The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.');
}
$value = $method($value * pow(10, $precision)) / pow(10, $precision);
}
return $value.$extension;
} | [
"public",
"function",
"formatNumberToHumanReadable",
"(",
"$",
"number",
",",
"$",
"precision",
"=",
"0",
",",
"$",
"method",
"=",
"'common'",
")",
"{",
"if",
"(",
"$",
"number",
">=",
"1000000",
")",
"{",
"// Divide by 1000000 to get 1M, 1.23M, etc.",
"$",
"value",
"=",
"$",
"number",
"/",
"1000000",
";",
"$",
"extension",
"=",
"'M'",
";",
"}",
"elseif",
"(",
"$",
"number",
">=",
"1000",
"&&",
"$",
"number",
"<",
"1000000",
")",
"{",
"// Divide by 1000, to get 1K, 1.33K, etc.",
"$",
"value",
"=",
"$",
"number",
"/",
"1000",
";",
"$",
"extension",
"=",
"'K'",
";",
"}",
"else",
"{",
"// Less than 1000, just return the number, unformatted, not rounded",
"$",
"value",
"=",
"$",
"number",
";",
"$",
"extension",
"=",
"''",
";",
"}",
"if",
"(",
"'common'",
"==",
"$",
"method",
")",
"{",
"$",
"value",
"=",
"round",
"(",
"$",
"value",
",",
"$",
"precision",
")",
";",
"}",
"else",
"{",
"if",
"(",
"'ceil'",
"!=",
"$",
"method",
"&&",
"'floor'",
"!=",
"$",
"method",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The number_to_human_readable filter only supports the \"common\", \"ceil\", and \"floor\" methods.'",
")",
";",
"}",
"$",
"value",
"=",
"$",
"method",
"(",
"$",
"value",
"*",
"pow",
"(",
"10",
",",
"$",
"precision",
")",
")",
"/",
"pow",
"(",
"10",
",",
"$",
"precision",
")",
";",
"}",
"return",
"$",
"value",
".",
"$",
"extension",
";",
"}"
] | Format a large number into the closest million or thousand
@param int|float $number The number to format
@param int $precision The precision to round with
@param string $method Possible values 'ceil'|'floor'|'common', default: 'common'
@return float | [
"Format",
"a",
"large",
"number",
"into",
"the",
"closest",
"million",
"or",
"thousand"
] | 4e3dba68508a242ac0b16fa3b02239178c4151f0 | https://github.com/tentwofour/twig/blob/4e3dba68508a242ac0b16fa3b02239178c4151f0/src/Ten24/Twig/Extension/NumberExtension.php#L26-L54 |
240,096 | znframework/package-language | Grid.php | Grid._styleElement | protected function _styleElement()
{
$styleElementConfig = $this->gridConfig['styleElement'] ?? NULL;
if( ! empty($styleElementConfig) )
{
$attributes = NULL;
$sheet = Singleton::class('ZN\Hypertext\Sheet');
$style = Singleton::class('ZN\Hypertext\Style');
foreach( $styleElementConfig as $selector => $attr )
{
$attributes .= $sheet->selector($selector)->attr($attr)->create();
}
return $style->open().$attributes.$style->close();
}
return NULL;
} | php | protected function _styleElement()
{
$styleElementConfig = $this->gridConfig['styleElement'] ?? NULL;
if( ! empty($styleElementConfig) )
{
$attributes = NULL;
$sheet = Singleton::class('ZN\Hypertext\Sheet');
$style = Singleton::class('ZN\Hypertext\Style');
foreach( $styleElementConfig as $selector => $attr )
{
$attributes .= $sheet->selector($selector)->attr($attr)->create();
}
return $style->open().$attributes.$style->close();
}
return NULL;
} | [
"protected",
"function",
"_styleElement",
"(",
")",
"{",
"$",
"styleElementConfig",
"=",
"$",
"this",
"->",
"gridConfig",
"[",
"'styleElement'",
"]",
"??",
"NULL",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"styleElementConfig",
")",
")",
"{",
"$",
"attributes",
"=",
"NULL",
";",
"$",
"sheet",
"=",
"Singleton",
"::",
"class",
"(",
"'ZN\\Hypertext\\Sheet'",
")",
";",
"$",
"style",
"=",
"Singleton",
"::",
"class",
"(",
"'ZN\\Hypertext\\Style'",
")",
";",
"foreach",
"(",
"$",
"styleElementConfig",
"as",
"$",
"selector",
"=>",
"$",
"attr",
")",
"{",
"$",
"attributes",
".=",
"$",
"sheet",
"->",
"selector",
"(",
"$",
"selector",
")",
"->",
"attr",
"(",
"$",
"attr",
")",
"->",
"create",
"(",
")",
";",
"}",
"return",
"$",
"style",
"->",
"open",
"(",
")",
".",
"$",
"attributes",
".",
"$",
"style",
"->",
"close",
"(",
")",
";",
"}",
"return",
"NULL",
";",
"}"
] | Protected Style Element | [
"Protected",
"Style",
"Element"
] | f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09 | https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Grid.php#L312-L332 |
240,097 | Dhii/state-machine-abstract | src/AbstractStateMachine.php | AbstractStateMachine._transition | protected function _transition($transition)
{
if (!$this->_canTransition($transition)) {
throw $this->_createCouldNotTransitionException(
$this->__('Cannot apply transition "%s"', $transition),
null,
null,
$transition
);
}
return $this->_applyTransition($transition);
} | php | protected function _transition($transition)
{
if (!$this->_canTransition($transition)) {
throw $this->_createCouldNotTransitionException(
$this->__('Cannot apply transition "%s"', $transition),
null,
null,
$transition
);
}
return $this->_applyTransition($transition);
} | [
"protected",
"function",
"_transition",
"(",
"$",
"transition",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_canTransition",
"(",
"$",
"transition",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_createCouldNotTransitionException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Cannot apply transition \"%s\"'",
",",
"$",
"transition",
")",
",",
"null",
",",
"null",
",",
"$",
"transition",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_applyTransition",
"(",
"$",
"transition",
")",
";",
"}"
] | Applies a transition.
@since [*next-version*]
@param string|Stringable $transition The transition code.
@throws CouldNotTransitionExceptionInterface If the transition failed or was aborted.
@throws StateMachineExceptionInterface If an error was encountered during transition.
@return StateMachineInterface The state machine with the new state. | [
"Applies",
"a",
"transition",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/AbstractStateMachine.php#L29-L41 |
240,098 | iwyg/template | AbstractPhpEngine.php | AbstractPhpEngine.loadTemplate | public function loadTemplate($template)
{
if (!$this->isLoaded($identity = $this->findIdentity($template))) {
if (!$this->supports($identity)) {
throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName()));
}
$this->setLoaded($identity, $this->getLoader()->load($identity));
}
return $this->getLoaded($identity);
} | php | public function loadTemplate($template)
{
if (!$this->isLoaded($identity = $this->findIdentity($template))) {
if (!$this->supports($identity)) {
throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName()));
}
$this->setLoaded($identity, $this->getLoader()->load($identity));
}
return $this->getLoaded($identity);
} | [
"public",
"function",
"loadTemplate",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLoaded",
"(",
"$",
"identity",
"=",
"$",
"this",
"->",
"findIdentity",
"(",
"$",
"template",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"identity",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unsupported template \"%s\".'",
",",
"$",
"identity",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"setLoaded",
"(",
"$",
"identity",
",",
"$",
"this",
"->",
"getLoader",
"(",
")",
"->",
"load",
"(",
"$",
"identity",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getLoaded",
"(",
"$",
"identity",
")",
";",
"}"
] | Try to load the given template
@param mixed $template
@return void | [
"Try",
"to",
"load",
"the",
"given",
"template"
] | ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e | https://github.com/iwyg/template/blob/ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e/AbstractPhpEngine.php#L136-L148 |
240,099 | manacode/php-helpers | src/DateTime.php | DateTime.now | function now() {
if (strtolower($this->timeReference) == 'gmt') {
$now = time();
$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
if (strlen($system_time) < 10) {
$system_time = time();
}
return $system_time;
} else {
return time();
}
} | php | function now() {
if (strtolower($this->timeReference) == 'gmt') {
$now = time();
$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
if (strlen($system_time) < 10) {
$system_time = time();
}
return $system_time;
} else {
return time();
}
} | [
"function",
"now",
"(",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"timeReference",
")",
"==",
"'gmt'",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"$",
"system_time",
"=",
"mktime",
"(",
"gmdate",
"(",
"\"H\"",
",",
"$",
"now",
")",
",",
"gmdate",
"(",
"\"i\"",
",",
"$",
"now",
")",
",",
"gmdate",
"(",
"\"s\"",
",",
"$",
"now",
")",
",",
"gmdate",
"(",
"\"m\"",
",",
"$",
"now",
")",
",",
"gmdate",
"(",
"\"d\"",
",",
"$",
"now",
")",
",",
"gmdate",
"(",
"\"Y\"",
",",
"$",
"now",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"system_time",
")",
"<",
"10",
")",
"{",
"$",
"system_time",
"=",
"time",
"(",
")",
";",
"}",
"return",
"$",
"system_time",
";",
"}",
"else",
"{",
"return",
"time",
"(",
")",
";",
"}",
"}"
] | Return current Unix timestamp or its GMT equivalent based on the time reference | [
"Return",
"current",
"Unix",
"timestamp",
"or",
"its",
"GMT",
"equivalent",
"based",
"on",
"the",
"time",
"reference"
] | 1e408e0935298753c0803ae0a8f9b12809652d6f | https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L79-L90 |