id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,800
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.filterNullValues
|
public static function filterNullValues($properties, array $allowed = null)
{
// If provided, only use allowed properties
$properties = static::only($properties, $allowed);
return array_filter(
$properties,
function ($value) {
return !is_null($value);
}
);
}
|
php
|
public static function filterNullValues($properties, array $allowed = null)
{
// If provided, only use allowed properties
$properties = static::only($properties, $allowed);
return array_filter(
$properties,
function ($value) {
return !is_null($value);
}
);
}
|
[
"public",
"static",
"function",
"filterNullValues",
"(",
"$",
"properties",
",",
"array",
"$",
"allowed",
"=",
"null",
")",
"{",
"// If provided, only use allowed properties",
"$",
"properties",
"=",
"static",
"::",
"only",
"(",
"$",
"properties",
",",
"$",
"allowed",
")",
";",
"return",
"array_filter",
"(",
"$",
"properties",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
] |
Get array elements that are not null.
@param array $properties
@param array|null $allowed
@return array
|
[
"Get",
"array",
"elements",
"that",
"are",
"not",
"null",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L241-L252
|
239,801
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.filterKeys
|
public static function filterKeys(array $input, $included = [])
{
if (is_null($included) || count($included) == 0) {
return $input;
}
return array_intersect_key($input, array_flip($included));
}
|
php
|
public static function filterKeys(array $input, $included = [])
{
if (is_null($included) || count($included) == 0) {
return $input;
}
return array_intersect_key($input, array_flip($included));
}
|
[
"public",
"static",
"function",
"filterKeys",
"(",
"array",
"$",
"input",
",",
"$",
"included",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"included",
")",
"||",
"count",
"(",
"$",
"included",
")",
"==",
"0",
")",
"{",
"return",
"$",
"input",
";",
"}",
"return",
"array_intersect_key",
"(",
"$",
"input",
",",
"array_flip",
"(",
"$",
"included",
")",
")",
";",
"}"
] |
Filter the keys of an array to only the allowed set.
@param array $input
@param array $included
@throws InvalidArgumentException
@return array
@deprecated
|
[
"Filter",
"the",
"keys",
"of",
"an",
"array",
"to",
"only",
"the",
"allowed",
"set",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L295-L302
|
239,802
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.except
|
public static function except(array $input, $excluded = [])
{
Arguments::define(Boa::arrOf(Boa::either(
Boa::string(),
Boa::integer()
)))->check($excluded);
return Std::filter(function ($_, $key) use ($excluded) {
return !in_array($key, $excluded);
},
$input);
}
|
php
|
public static function except(array $input, $excluded = [])
{
Arguments::define(Boa::arrOf(Boa::either(
Boa::string(),
Boa::integer()
)))->check($excluded);
return Std::filter(function ($_, $key) use ($excluded) {
return !in_array($key, $excluded);
},
$input);
}
|
[
"public",
"static",
"function",
"except",
"(",
"array",
"$",
"input",
",",
"$",
"excluded",
"=",
"[",
"]",
")",
"{",
"Arguments",
"::",
"define",
"(",
"Boa",
"::",
"arrOf",
"(",
"Boa",
"::",
"either",
"(",
"Boa",
"::",
"string",
"(",
")",
",",
"Boa",
"::",
"integer",
"(",
")",
")",
")",
")",
"->",
"check",
"(",
"$",
"excluded",
")",
";",
"return",
"Std",
"::",
"filter",
"(",
"function",
"(",
"$",
"_",
",",
"$",
"key",
")",
"use",
"(",
"$",
"excluded",
")",
"{",
"return",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"excluded",
")",
";",
"}",
",",
"$",
"input",
")",
";",
"}"
] |
Get a copy of the provided array excluding the specified keys.
@param array $input
@param array $excluded
@throws InvalidArgumentException
@return array
|
[
"Get",
"a",
"copy",
"of",
"the",
"provided",
"array",
"excluding",
"the",
"specified",
"keys",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L313-L324
|
239,803
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.exchange
|
public static function exchange(array &$elements, $indexA, $indexB)
{
$count = count($elements);
if (($indexA < 0 || $indexA > ($count - 1))
|| $indexB < 0
|| $indexB > ($count - 1)
) {
throw new IndexOutOfBoundsException();
}
$temp = $elements[$indexA];
$elements[$indexA] = $elements[$indexB];
$elements[$indexB] = $temp;
}
|
php
|
public static function exchange(array &$elements, $indexA, $indexB)
{
$count = count($elements);
if (($indexA < 0 || $indexA > ($count - 1))
|| $indexB < 0
|| $indexB > ($count - 1)
) {
throw new IndexOutOfBoundsException();
}
$temp = $elements[$indexA];
$elements[$indexA] = $elements[$indexB];
$elements[$indexB] = $temp;
}
|
[
"public",
"static",
"function",
"exchange",
"(",
"array",
"&",
"$",
"elements",
",",
"$",
"indexA",
",",
"$",
"indexB",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"elements",
")",
";",
"if",
"(",
"(",
"$",
"indexA",
"<",
"0",
"||",
"$",
"indexA",
">",
"(",
"$",
"count",
"-",
"1",
")",
")",
"||",
"$",
"indexB",
"<",
"0",
"||",
"$",
"indexB",
">",
"(",
"$",
"count",
"-",
"1",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"$",
"temp",
"=",
"$",
"elements",
"[",
"$",
"indexA",
"]",
";",
"$",
"elements",
"[",
"$",
"indexA",
"]",
"=",
"$",
"elements",
"[",
"$",
"indexB",
"]",
";",
"$",
"elements",
"[",
"$",
"indexB",
"]",
"=",
"$",
"temp",
";",
"}"
] |
Exchange two elements in an array.
@param array $elements
@param int $indexA
@param int $indexB
@throws IndexOutOfBoundsException
|
[
"Exchange",
"two",
"elements",
"in",
"an",
"array",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L357-L373
|
239,804
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Arr.php
|
Arr.indexOf
|
public static function indexOf(array $input, $value)
{
foreach ($input as $key => $inputValue) {
if ($inputValue === $value) {
return $key;
}
}
return false;
}
|
php
|
public static function indexOf(array $input, $value)
{
foreach ($input as $key => $inputValue) {
if ($inputValue === $value) {
return $key;
}
}
return false;
}
|
[
"public",
"static",
"function",
"indexOf",
"(",
"array",
"$",
"input",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"inputValue",
")",
"{",
"if",
"(",
"$",
"inputValue",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns the index of the first occurrence of a value in the provided
array.
If the value is not found, false is returned.
@param array $input
@param mixed $value
@return int|string|bool
|
[
"Returns",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"of",
"a",
"value",
"in",
"the",
"provided",
"array",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Arr.php#L541-L550
|
239,805
|
pletfix/core
|
src/Services/CacheFactory.php
|
CacheFactory.store
|
public function store($name = null)
{
if (is_null($name)) {
$name = $this->defaultStore;
}
if (isset($this->caches[$name])) {
return $this->caches[$name];
}
$config = config('cache.stores.' . $name);
if ($config === null) {
throw new InvalidArgumentException('Cache store "' . $name . '" is not defined.');
}
if (!isset($config['driver'])) {
throw new InvalidArgumentException('Cache driver for store "' . $name . '" is not specified.');
}
switch ($config['driver']) {
case 'APCu':
$provider = new ApcuCache;
break;
case 'Array':
$provider = new ArrayCache;
break;
case 'File':
$provider = new FilesystemCache($config['path']);
break;
case 'Memcached':
$memcached = new Memcached();
$memcached->addServer($config['host'], $config['port'], $config['weight']);
$provider = new MemcachedCache();
$provider->setMemcached($memcached);
break;
case 'Redis':
$redis = new Redis;
$redis->connect($config['host'], $config['port'], $config['timeout']);
$provider = new RedisCache;
$provider->setRedis($redis);
break;
default:
throw new InvalidArgumentException('Cache driver "' . $config['driver'] . '" is not supported.');
}
return $this->caches[$name] = new Cache($provider);
}
|
php
|
public function store($name = null)
{
if (is_null($name)) {
$name = $this->defaultStore;
}
if (isset($this->caches[$name])) {
return $this->caches[$name];
}
$config = config('cache.stores.' . $name);
if ($config === null) {
throw new InvalidArgumentException('Cache store "' . $name . '" is not defined.');
}
if (!isset($config['driver'])) {
throw new InvalidArgumentException('Cache driver for store "' . $name . '" is not specified.');
}
switch ($config['driver']) {
case 'APCu':
$provider = new ApcuCache;
break;
case 'Array':
$provider = new ArrayCache;
break;
case 'File':
$provider = new FilesystemCache($config['path']);
break;
case 'Memcached':
$memcached = new Memcached();
$memcached->addServer($config['host'], $config['port'], $config['weight']);
$provider = new MemcachedCache();
$provider->setMemcached($memcached);
break;
case 'Redis':
$redis = new Redis;
$redis->connect($config['host'], $config['port'], $config['timeout']);
$provider = new RedisCache;
$provider->setRedis($redis);
break;
default:
throw new InvalidArgumentException('Cache driver "' . $config['driver'] . '" is not supported.');
}
return $this->caches[$name] = new Cache($provider);
}
|
[
"public",
"function",
"store",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"defaultStore",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"caches",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"caches",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"config",
"=",
"config",
"(",
"'cache.stores.'",
".",
"$",
"name",
")",
";",
"if",
"(",
"$",
"config",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cache store \"'",
".",
"$",
"name",
".",
"'\" is not defined.'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cache driver for store \"'",
".",
"$",
"name",
".",
"'\" is not specified.'",
")",
";",
"}",
"switch",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
"{",
"case",
"'APCu'",
":",
"$",
"provider",
"=",
"new",
"ApcuCache",
";",
"break",
";",
"case",
"'Array'",
":",
"$",
"provider",
"=",
"new",
"ArrayCache",
";",
"break",
";",
"case",
"'File'",
":",
"$",
"provider",
"=",
"new",
"FilesystemCache",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
";",
"break",
";",
"case",
"'Memcached'",
":",
"$",
"memcached",
"=",
"new",
"Memcached",
"(",
")",
";",
"$",
"memcached",
"->",
"addServer",
"(",
"$",
"config",
"[",
"'host'",
"]",
",",
"$",
"config",
"[",
"'port'",
"]",
",",
"$",
"config",
"[",
"'weight'",
"]",
")",
";",
"$",
"provider",
"=",
"new",
"MemcachedCache",
"(",
")",
";",
"$",
"provider",
"->",
"setMemcached",
"(",
"$",
"memcached",
")",
";",
"break",
";",
"case",
"'Redis'",
":",
"$",
"redis",
"=",
"new",
"Redis",
";",
"$",
"redis",
"->",
"connect",
"(",
"$",
"config",
"[",
"'host'",
"]",
",",
"$",
"config",
"[",
"'port'",
"]",
",",
"$",
"config",
"[",
"'timeout'",
"]",
")",
";",
"$",
"provider",
"=",
"new",
"RedisCache",
";",
"$",
"provider",
"->",
"setRedis",
"(",
"$",
"redis",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cache driver \"'",
".",
"$",
"config",
"[",
"'driver'",
"]",
".",
"'\" is not supported.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"caches",
"[",
"$",
"name",
"]",
"=",
"new",
"Cache",
"(",
"$",
"provider",
")",
";",
"}"
] |
Get a Cache instance by given store name.
@param string|null $name
@return \Core\Services\Contracts\Cache
@throws \InvalidArgumentException
|
[
"Get",
"a",
"Cache",
"instance",
"by",
"given",
"store",
"name",
"."
] |
974945500f278eb6c1779832e08bbfca1007a7b3
|
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CacheFactory.php#L58-L104
|
239,806
|
dflydev/dflydev-github-gist-twig-extension
|
src/Dflydev/Twig/Extension/GitHubGist/Cache/FilesystemCache.php
|
FilesystemCache.generatePathname
|
protected function generatePathname($id)
{
if (!file_exists($this->basePath)) {
mkdir($this->basePath, 0777, true);
}
return $this->basePath.'/'.$id;
}
|
php
|
protected function generatePathname($id)
{
if (!file_exists($this->basePath)) {
mkdir($this->basePath, 0777, true);
}
return $this->basePath.'/'.$id;
}
|
[
"protected",
"function",
"generatePathname",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"basePath",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"basePath",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"id",
";",
"}"
] |
Generate a pathname for an ID
@param string $id ID
@return string
|
[
"Generate",
"a",
"pathname",
"for",
"an",
"ID"
] |
c324152707397472bed8548ca98cee6c12f215f0
|
https://github.com/dflydev/dflydev-github-gist-twig-extension/blob/c324152707397472bed8548ca98cee6c12f215f0/src/Dflydev/Twig/Extension/GitHubGist/Cache/FilesystemCache.php#L77-L84
|
239,807
|
mvccore/ext-form
|
src/MvcCore/Ext/Forms/Field/Props/GroupCssClasses.php
|
GroupLabelCssClasses.&
|
public function & SetGroupLabelCssClasses ($groupLabelCssClasses) {
/** @var $this \MvcCore\Ext\Forms\IField */
if (gettype($groupLabelCssClasses) == 'array') {
$this->groupLabelCssClasses = $groupLabelCssClasses;
} else {
$this->groupLabelCssClasses = explode(' ', (string) $groupLabelCssClasses);
}
return $this;
}
|
php
|
public function & SetGroupLabelCssClasses ($groupLabelCssClasses) {
/** @var $this \MvcCore\Ext\Forms\IField */
if (gettype($groupLabelCssClasses) == 'array') {
$this->groupLabelCssClasses = $groupLabelCssClasses;
} else {
$this->groupLabelCssClasses = explode(' ', (string) $groupLabelCssClasses);
}
return $this;
}
|
[
"public",
"function",
"&",
"SetGroupLabelCssClasses",
"(",
"$",
"groupLabelCssClasses",
")",
"{",
"/** @var $this \\MvcCore\\Ext\\Forms\\IField */",
"if",
"(",
"gettype",
"(",
"$",
"groupLabelCssClasses",
")",
"==",
"'array'",
")",
"{",
"$",
"this",
"->",
"groupLabelCssClasses",
"=",
"$",
"groupLabelCssClasses",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"groupLabelCssClasses",
"=",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"groupLabelCssClasses",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set css class or classes for group label,
as array of strings or string with classes
separated by space. Any previously defined
group css classes will be replaced.
@param string|\string[] $groupLabelCssClasses
@return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField
|
[
"Set",
"css",
"class",
"or",
"classes",
"for",
"group",
"label",
"as",
"array",
"of",
"strings",
"or",
"string",
"with",
"classes",
"separated",
"by",
"space",
".",
"Any",
"previously",
"defined",
"group",
"css",
"classes",
"will",
"be",
"replaced",
"."
] |
8d81a3c7326236702f37dc4b9d968907b3230b9f
|
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/Field/Props/GroupCssClasses.php#L46-L54
|
239,808
|
mvccore/ext-form
|
src/MvcCore/Ext/Forms/Field/Props/GroupCssClasses.php
|
GroupLabelCssClasses.AddGroupLabelCssClasses
|
public function AddGroupLabelCssClasses ($groupLabelCssClasses) {
/** @var $this \MvcCore\Ext\Forms\IField */
if (gettype($groupLabelCssClasses) == 'array') {
$groupCssClasses = $groupLabelCssClasses;
} else {
$groupCssClasses = explode(' ', (string) $groupLabelCssClasses);
}
$this->groupLabelCssClasses = array_merge($this->groupLabelCssClasses, $groupCssClasses);
return $this;
}
|
php
|
public function AddGroupLabelCssClasses ($groupLabelCssClasses) {
/** @var $this \MvcCore\Ext\Forms\IField */
if (gettype($groupLabelCssClasses) == 'array') {
$groupCssClasses = $groupLabelCssClasses;
} else {
$groupCssClasses = explode(' ', (string) $groupLabelCssClasses);
}
$this->groupLabelCssClasses = array_merge($this->groupLabelCssClasses, $groupCssClasses);
return $this;
}
|
[
"public",
"function",
"AddGroupLabelCssClasses",
"(",
"$",
"groupLabelCssClasses",
")",
"{",
"/** @var $this \\MvcCore\\Ext\\Forms\\IField */",
"if",
"(",
"gettype",
"(",
"$",
"groupLabelCssClasses",
")",
"==",
"'array'",
")",
"{",
"$",
"groupCssClasses",
"=",
"$",
"groupLabelCssClasses",
";",
"}",
"else",
"{",
"$",
"groupCssClasses",
"=",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"groupLabelCssClasses",
")",
";",
"}",
"$",
"this",
"->",
"groupLabelCssClasses",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"groupLabelCssClasses",
",",
"$",
"groupCssClasses",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add css class or classes for group label as array of
strings or string with classes separated by space.
@param string|\string[] $groupLabelCssClasses
@return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField
|
[
"Add",
"css",
"class",
"or",
"classes",
"for",
"group",
"label",
"as",
"array",
"of",
"strings",
"or",
"string",
"with",
"classes",
"separated",
"by",
"space",
"."
] |
8d81a3c7326236702f37dc4b9d968907b3230b9f
|
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/Field/Props/GroupCssClasses.php#L62-L71
|
239,809
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.changeUserMode
|
public function changeUserMode(EventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$params = $event->getParams();
$logger->debug('Changing user mode', array('params' => $params));
// Disregard mode changes without both an associated channel and user
if (!isset($params['channel']) || !isset($params['user'])) {
$logger->debug('Missing channel or user, skipping');
return;
}
$connectionMask = $this->getConnectionMask($event->getConnection());
$channel = $params['channel'];
$nick = $params['user'];
$modes = str_split($params['mode']);
$operation = array_shift($modes);
$logger->debug('Extracted event data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
'operation' => $operation,
'modes' => $modes,
));
foreach ($modes as $mode) {
switch ($operation) {
case '+':
if (!isset($this->modes[$connectionMask])) {
$this->modes[$connectionMask] = array();
}
if (!isset($this->modes[$connectionMask][$channel])) {
$this->modes[$connectionMask][$channel] = array();
}
if (!isset($this->modes[$connectionMask][$channel][$nick])) {
$this->modes[$connectionMask][$channel][$nick] = array();
}
$this->modes[$connectionMask][$channel][$nick][$mode] = true;
break;
case '-':
unset($this->modes[$connectionMask][$channel][$nick][$mode]);
break;
default:
$logger->warning('Encountered unknown operation', array(
'operation' => $operation,
));
break;
}
}
}
|
php
|
public function changeUserMode(EventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$params = $event->getParams();
$logger->debug('Changing user mode', array('params' => $params));
// Disregard mode changes without both an associated channel and user
if (!isset($params['channel']) || !isset($params['user'])) {
$logger->debug('Missing channel or user, skipping');
return;
}
$connectionMask = $this->getConnectionMask($event->getConnection());
$channel = $params['channel'];
$nick = $params['user'];
$modes = str_split($params['mode']);
$operation = array_shift($modes);
$logger->debug('Extracted event data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
'operation' => $operation,
'modes' => $modes,
));
foreach ($modes as $mode) {
switch ($operation) {
case '+':
if (!isset($this->modes[$connectionMask])) {
$this->modes[$connectionMask] = array();
}
if (!isset($this->modes[$connectionMask][$channel])) {
$this->modes[$connectionMask][$channel] = array();
}
if (!isset($this->modes[$connectionMask][$channel][$nick])) {
$this->modes[$connectionMask][$channel][$nick] = array();
}
$this->modes[$connectionMask][$channel][$nick][$mode] = true;
break;
case '-':
unset($this->modes[$connectionMask][$channel][$nick][$mode]);
break;
default:
$logger->warning('Encountered unknown operation', array(
'operation' => $operation,
));
break;
}
}
}
|
[
"public",
"function",
"changeUserMode",
"(",
"EventInterface",
"$",
"event",
",",
"EventQueueInterface",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Changing user mode'",
",",
"array",
"(",
"'params'",
"=>",
"$",
"params",
")",
")",
";",
"// Disregard mode changes without both an associated channel and user",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'channel'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"params",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Missing channel or user, skipping'",
")",
";",
"return",
";",
"}",
"$",
"connectionMask",
"=",
"$",
"this",
"->",
"getConnectionMask",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
")",
";",
"$",
"channel",
"=",
"$",
"params",
"[",
"'channel'",
"]",
";",
"$",
"nick",
"=",
"$",
"params",
"[",
"'user'",
"]",
";",
"$",
"modes",
"=",
"str_split",
"(",
"$",
"params",
"[",
"'mode'",
"]",
")",
";",
"$",
"operation",
"=",
"array_shift",
"(",
"$",
"modes",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Extracted event data'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'operation'",
"=>",
"$",
"operation",
",",
"'modes'",
"=>",
"$",
"modes",
",",
")",
")",
";",
"foreach",
"(",
"$",
"modes",
"as",
"$",
"mode",
")",
"{",
"switch",
"(",
"$",
"operation",
")",
"{",
"case",
"'+'",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
")",
")",
"{",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
")",
")",
"{",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
")",
"{",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
"[",
"$",
"mode",
"]",
"=",
"true",
";",
"break",
";",
"case",
"'-'",
":",
"unset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
"[",
"$",
"mode",
"]",
")",
";",
"break",
";",
"default",
":",
"$",
"logger",
"->",
"warning",
"(",
"'Encountered unknown operation'",
",",
"array",
"(",
"'operation'",
"=>",
"$",
"operation",
",",
")",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Monitors use mode changes.
@param \Phergie\Irc\Event\EventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Monitors",
"use",
"mode",
"changes",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L89-L140
|
239,810
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.removeUserData
|
protected function removeUserData($connectionMask, array $channels, $nick)
{
$logger = $this->getLogger();
foreach ($channels as $channel) {
$logger->debug('Removing user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
));
unset($this->modes[$connectionMask][$channel][$nick]);
}
}
|
php
|
protected function removeUserData($connectionMask, array $channels, $nick)
{
$logger = $this->getLogger();
foreach ($channels as $channel) {
$logger->debug('Removing user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
));
unset($this->modes[$connectionMask][$channel][$nick]);
}
}
|
[
"protected",
"function",
"removeUserData",
"(",
"$",
"connectionMask",
",",
"array",
"$",
"channels",
",",
"$",
"nick",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"foreach",
"(",
"$",
"channels",
"as",
"$",
"channel",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Removing user mode data'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
";",
"}",
"}"
] |
Removes mode data for a user and list of channels.
@param string $connectionMask
@param array $channels
@param string $nick
|
[
"Removes",
"mode",
"data",
"for",
"a",
"user",
"and",
"list",
"of",
"channels",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L188-L199
|
239,811
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.changeUserNick
|
public function changeUserNick(UserEventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$connectionMask = $this->getConnectionMask($event->getConnection());
$old = $event->getNick();
$params = $event->getParams();
$new = $params['nickname'];
$logger->debug('Changing user nick', array(
'connectionMask' => $connectionMask,
'oldNick' => $old,
'newNick' => $new,
));
foreach (array_keys($this->modes[$connectionMask]) as $channel) {
if (!isset($this->modes[$connectionMask][$channel][$old])) {
continue;
}
$logger->debug('Moving user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'oldNick' => $old,
'newNick' => $new,
));
$this->modes[$connectionMask][$channel][$new] = $this->modes[$connectionMask][$channel][$old];
unset($this->modes[$connectionMask][$channel][$old]);
}
}
|
php
|
public function changeUserNick(UserEventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$connectionMask = $this->getConnectionMask($event->getConnection());
$old = $event->getNick();
$params = $event->getParams();
$new = $params['nickname'];
$logger->debug('Changing user nick', array(
'connectionMask' => $connectionMask,
'oldNick' => $old,
'newNick' => $new,
));
foreach (array_keys($this->modes[$connectionMask]) as $channel) {
if (!isset($this->modes[$connectionMask][$channel][$old])) {
continue;
}
$logger->debug('Moving user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'oldNick' => $old,
'newNick' => $new,
));
$this->modes[$connectionMask][$channel][$new] = $this->modes[$connectionMask][$channel][$old];
unset($this->modes[$connectionMask][$channel][$old]);
}
}
|
[
"public",
"function",
"changeUserNick",
"(",
"UserEventInterface",
"$",
"event",
",",
"EventQueueInterface",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"connectionMask",
"=",
"$",
"this",
"->",
"getConnectionMask",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
")",
";",
"$",
"old",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"new",
"=",
"$",
"params",
"[",
"'nickname'",
"]",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Changing user nick'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'oldNick'",
"=>",
"$",
"old",
",",
"'newNick'",
"=>",
"$",
"new",
",",
")",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
")",
"as",
"$",
"channel",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"old",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"logger",
"->",
"debug",
"(",
"'Moving user mode data'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'oldNick'",
"=>",
"$",
"old",
",",
"'newNick'",
"=>",
"$",
"new",
",",
")",
")",
";",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"new",
"]",
"=",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"old",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"old",
"]",
")",
";",
"}",
"}"
] |
Accounts for user nick changes in stored data.
@param \Phergie\Irc\Event\EventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Accounts",
"for",
"user",
"nick",
"changes",
"in",
"stored",
"data",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L207-L234
|
239,812
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.loadUserModes
|
public function loadUserModes(EventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$connectionMask = $this->getConnectionMask($event->getConnection());
$params = $event->getParams();
$channel = $params[1];
$validPrefixes = implode('', array_keys($this->prefixes));
$pattern = '/^([' . preg_quote($validPrefixes) . ']+)(.+)$/';
$logger->debug('Gathering initial user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
));
foreach ($params['iterable'] as $fullNick) {
if (!preg_match($pattern, $fullNick, $match)) {
continue;
}
$nickPrefixes = str_split($match[1]);
$nick = $match[2];
foreach ($nickPrefixes as $prefix) {
$mode = $this->prefixes[$prefix];
$logger->debug('Recording user mode', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
'mode' => $mode,
));
$this->modes[$connectionMask][$channel][$nick][$mode] = true;
}
}
}
|
php
|
public function loadUserModes(EventInterface $event, EventQueueInterface $queue)
{
$logger = $this->getLogger();
$connectionMask = $this->getConnectionMask($event->getConnection());
$params = $event->getParams();
$channel = $params[1];
$validPrefixes = implode('', array_keys($this->prefixes));
$pattern = '/^([' . preg_quote($validPrefixes) . ']+)(.+)$/';
$logger->debug('Gathering initial user mode data', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
));
foreach ($params['iterable'] as $fullNick) {
if (!preg_match($pattern, $fullNick, $match)) {
continue;
}
$nickPrefixes = str_split($match[1]);
$nick = $match[2];
foreach ($nickPrefixes as $prefix) {
$mode = $this->prefixes[$prefix];
$logger->debug('Recording user mode', array(
'connectionMask' => $connectionMask,
'channel' => $channel,
'nick' => $nick,
'mode' => $mode,
));
$this->modes[$connectionMask][$channel][$nick][$mode] = true;
}
}
}
|
[
"public",
"function",
"loadUserModes",
"(",
"EventInterface",
"$",
"event",
",",
"EventQueueInterface",
"$",
"queue",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"connectionMask",
"=",
"$",
"this",
"->",
"getConnectionMask",
"(",
"$",
"event",
"->",
"getConnection",
"(",
")",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"channel",
"=",
"$",
"params",
"[",
"1",
"]",
";",
"$",
"validPrefixes",
"=",
"implode",
"(",
"''",
",",
"array_keys",
"(",
"$",
"this",
"->",
"prefixes",
")",
")",
";",
"$",
"pattern",
"=",
"'/^(['",
".",
"preg_quote",
"(",
"$",
"validPrefixes",
")",
".",
"']+)(.+)$/'",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Gathering initial user mode data'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'channel'",
"=>",
"$",
"channel",
",",
")",
")",
";",
"foreach",
"(",
"$",
"params",
"[",
"'iterable'",
"]",
"as",
"$",
"fullNick",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"fullNick",
",",
"$",
"match",
")",
")",
"{",
"continue",
";",
"}",
"$",
"nickPrefixes",
"=",
"str_split",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"nick",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"foreach",
"(",
"$",
"nickPrefixes",
"as",
"$",
"prefix",
")",
"{",
"$",
"mode",
"=",
"$",
"this",
"->",
"prefixes",
"[",
"$",
"prefix",
"]",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Recording user mode'",
",",
"array",
"(",
"'connectionMask'",
"=>",
"$",
"connectionMask",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'nick'",
"=>",
"$",
"nick",
",",
"'mode'",
"=>",
"$",
"mode",
",",
")",
")",
";",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
"[",
"$",
"mode",
"]",
"=",
"true",
";",
"}",
"}",
"}"
] |
Loads initial user mode data when the bot joins a channel.
@param \Phergie\Irc\Event\EventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Loads",
"initial",
"user",
"mode",
"data",
"when",
"the",
"bot",
"joins",
"a",
"channel",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L242-L273
|
239,813
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.userHasMode
|
public function userHasMode(ConnectionInterface $connection, $channel, $nick, $mode)
{
$connectionMask = $this->getConnectionMask($connection);
return isset($this->modes[$connectionMask][$channel][$nick][$mode]);
}
|
php
|
public function userHasMode(ConnectionInterface $connection, $channel, $nick, $mode)
{
$connectionMask = $this->getConnectionMask($connection);
return isset($this->modes[$connectionMask][$channel][$nick][$mode]);
}
|
[
"public",
"function",
"userHasMode",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"$",
"channel",
",",
"$",
"nick",
",",
"$",
"mode",
")",
"{",
"$",
"connectionMask",
"=",
"$",
"this",
"->",
"getConnectionMask",
"(",
"$",
"connection",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
"[",
"$",
"mode",
"]",
")",
";",
"}"
] |
Returns whether a user has a particular mode in a particular channel.
@param \Phergie\Irc\ConnectionInterface $connection
@param string $channel
@param string $nick
@param string $mode
@return boolean
|
[
"Returns",
"whether",
"a",
"user",
"has",
"a",
"particular",
"mode",
"in",
"a",
"particular",
"channel",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L284-L288
|
239,814
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.getUserModes
|
public function getUserModes(ConnectionInterface $connection, $channel, $nick)
{
$connectionMask = $this->getConnectionMask($connection);
if (isset($this->modes[$connectionMask][$channel][$nick])) {
return array_keys($this->modes[$connectionMask][$channel][$nick]);
}
return array();
}
|
php
|
public function getUserModes(ConnectionInterface $connection, $channel, $nick)
{
$connectionMask = $this->getConnectionMask($connection);
if (isset($this->modes[$connectionMask][$channel][$nick])) {
return array_keys($this->modes[$connectionMask][$channel][$nick]);
}
return array();
}
|
[
"public",
"function",
"getUserModes",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"$",
"channel",
",",
"$",
"nick",
")",
"{",
"$",
"connectionMask",
"=",
"$",
"this",
"->",
"getConnectionMask",
"(",
"$",
"connection",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
")",
"{",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"connectionMask",
"]",
"[",
"$",
"channel",
"]",
"[",
"$",
"nick",
"]",
")",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] |
Returns a list of modes for a user in a particular channel.
@param \Phergie\Irc\ConnectionInterface $connection
@param string $channel
@param string $nick
@return array Enumerated array of mode letters or an empty array if the
user has no modes in the specified channel
|
[
"Returns",
"a",
"list",
"of",
"modes",
"for",
"a",
"user",
"in",
"a",
"particular",
"channel",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L299-L306
|
239,815
|
phergie/phergie-irc-plugin-react-usermode
|
src/Plugin.php
|
Plugin.getConnectionMask
|
protected function getConnectionMask(ConnectionInterface $connection)
{
return strtolower(sprintf(
'%s!%s@%s',
$connection->getNickname(),
$connection->getUsername(),
$connection->getServerHostname()
));
}
|
php
|
protected function getConnectionMask(ConnectionInterface $connection)
{
return strtolower(sprintf(
'%s!%s@%s',
$connection->getNickname(),
$connection->getUsername(),
$connection->getServerHostname()
));
}
|
[
"protected",
"function",
"getConnectionMask",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"return",
"strtolower",
"(",
"sprintf",
"(",
"'%s!%s@%s'",
",",
"$",
"connection",
"->",
"getNickname",
"(",
")",
",",
"$",
"connection",
"->",
"getUsername",
"(",
")",
",",
"$",
"connection",
"->",
"getServerHostname",
"(",
")",
")",
")",
";",
"}"
] |
Returns the mask string for a given connection.
@param \Phergie\Irc\ConnectionInterface $connection
@return string
|
[
"Returns",
"the",
"mask",
"string",
"for",
"a",
"given",
"connection",
"."
] |
4bf3b75cda6f4dd66513ee4d62b0a436e24645e5
|
https://github.com/phergie/phergie-irc-plugin-react-usermode/blob/4bf3b75cda6f4dd66513ee4d62b0a436e24645e5/src/Plugin.php#L314-L322
|
239,816
|
twister-php/twister
|
src/Container.php
|
Container.make
|
public function make(string $name, array $params = null)
{
if (isset($this->bindings[$name]))
return $this->bindings[$name];
// cached constructor lists
static $constructors = null;
if (isset($constructors[$name])) {
$constructor = $constructors[$name];
}
else {
$constructors[$name] = $constructor = method_exists($name, '__construct') ? new \ReflectionMethod($name, '__construct') : null;
}
return $constructor ?
(new \ReflectionClass($name))->newInstanceArgs($this->_buildArgList($constructor, $params)) :
(new \ReflectionClass($name))->newInstance();
}
|
php
|
public function make(string $name, array $params = null)
{
if (isset($this->bindings[$name]))
return $this->bindings[$name];
// cached constructor lists
static $constructors = null;
if (isset($constructors[$name])) {
$constructor = $constructors[$name];
}
else {
$constructors[$name] = $constructor = method_exists($name, '__construct') ? new \ReflectionMethod($name, '__construct') : null;
}
return $constructor ?
(new \ReflectionClass($name))->newInstanceArgs($this->_buildArgList($constructor, $params)) :
(new \ReflectionClass($name))->newInstance();
}
|
[
"public",
"function",
"make",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"bindings",
"[",
"$",
"name",
"]",
";",
"//\tcached constructor lists\r",
"static",
"$",
"constructors",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"constructors",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"constructor",
"=",
"$",
"constructors",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"constructors",
"[",
"$",
"name",
"]",
"=",
"$",
"constructor",
"=",
"method_exists",
"(",
"$",
"name",
",",
"'__construct'",
")",
"?",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"name",
",",
"'__construct'",
")",
":",
"null",
";",
"}",
"return",
"$",
"constructor",
"?",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"name",
")",
")",
"->",
"newInstanceArgs",
"(",
"$",
"this",
"->",
"_buildArgList",
"(",
"$",
"constructor",
",",
"$",
"params",
")",
")",
":",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"name",
")",
")",
"->",
"newInstance",
"(",
")",
";",
"}"
] |
Build an object by its name.
This method behaves like get() except resolves the entry again every time.
For example if the entry is a class then a new instance will be created each time.
This method makes the container behave like a factory.
@param string $name Entry name or a class name.
@param array $parameters Optional parameters to use to build the entry.
Use this to force specific parameters to specific values.
Parameters not defined in this array will be resolved using the container.
@throws InvalidArgumentException The name parameter must be of type string.
@throws DependencyException Error while resolving the entry.
@throws NotFoundException No entry found for the given name.
@return mixed
|
[
"Build",
"an",
"object",
"by",
"its",
"name",
"."
] |
c06ea2650331faf11590c017c850dc5f0bbc5c13
|
https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/Container.php#L176-L194
|
239,817
|
FuturaSoft/Pabana
|
src/Core/Configuration.php
|
Configuration.base
|
public static function base()
{
// Charset by default
self::write('application.encoding', 'UTF8');
// Application environnement
self::write('application.env', 'dev');
// Application name
self::write('application.name', 'Awesome Application');
// Namespace for application
self::write('application.namespace', '\App');
// Absolute path to application
self::write('application.path', 'auto');
// Defined if bootstrap is use by application
self::write('bootstrap.enable', true);
// Set config file for route collection
self::write('database.config.enable', true);
// Set config file for route collection
self::write('database.config.file', 'databases.php');
// Set debug level to all
self::write('debug.level', E_ALL);
// Define if script file existence is tested
self::write('html.script.test_file_existance', true);
// Define if css file existence is tested
self::write('html.css.test_file_existance', true);
// Set autoloading of shared var between componant
self::write('mvc.autoload_shared_var', true);
// Set namespace for controller
self::write('mvc.controller.namespace', '\App\Controller');
// Set namespace for layout
self::write('mvc.layout.namespace', '\App\Layout');
// Set path for Layout
self::write('mvc.layout.path', '/src/Layout');
// Set default layout
self::write('mvc.layout.default', 'Application');
// Set extension for layout
self::write('mvc.layout.extension', 'php');
// Set auto render for layout
self::write('mvc.layout.auto_render', true);
// Set namespace for model
self::write('mvc.model.namespace', '\App\Model');
// Set auto render for view
self::write('mvc.view.auto_render', true);
// Set extension for view
self::write('mvc.view.extension', 'php');
// Set path for view
self::write('mvc.view.path', '/src/View');
// Set auto routing
self::write('routing.auto', true);
// Set config file for route collection
self::write('routing.config.enable', true);
// Set config file for route collection
self::write('routing.config.file', 'routes.php');
// Set error action (if not route is avaiable)
self::write('routing.fallback.action', 'index');
// Set error controller (if not route is avaiable)
self::write('routing.fallback.controller', 'Error');
// Set config file for route collection
self::write('routing.default_separator', '/');
}
|
php
|
public static function base()
{
// Charset by default
self::write('application.encoding', 'UTF8');
// Application environnement
self::write('application.env', 'dev');
// Application name
self::write('application.name', 'Awesome Application');
// Namespace for application
self::write('application.namespace', '\App');
// Absolute path to application
self::write('application.path', 'auto');
// Defined if bootstrap is use by application
self::write('bootstrap.enable', true);
// Set config file for route collection
self::write('database.config.enable', true);
// Set config file for route collection
self::write('database.config.file', 'databases.php');
// Set debug level to all
self::write('debug.level', E_ALL);
// Define if script file existence is tested
self::write('html.script.test_file_existance', true);
// Define if css file existence is tested
self::write('html.css.test_file_existance', true);
// Set autoloading of shared var between componant
self::write('mvc.autoload_shared_var', true);
// Set namespace for controller
self::write('mvc.controller.namespace', '\App\Controller');
// Set namespace for layout
self::write('mvc.layout.namespace', '\App\Layout');
// Set path for Layout
self::write('mvc.layout.path', '/src/Layout');
// Set default layout
self::write('mvc.layout.default', 'Application');
// Set extension for layout
self::write('mvc.layout.extension', 'php');
// Set auto render for layout
self::write('mvc.layout.auto_render', true);
// Set namespace for model
self::write('mvc.model.namespace', '\App\Model');
// Set auto render for view
self::write('mvc.view.auto_render', true);
// Set extension for view
self::write('mvc.view.extension', 'php');
// Set path for view
self::write('mvc.view.path', '/src/View');
// Set auto routing
self::write('routing.auto', true);
// Set config file for route collection
self::write('routing.config.enable', true);
// Set config file for route collection
self::write('routing.config.file', 'routes.php');
// Set error action (if not route is avaiable)
self::write('routing.fallback.action', 'index');
// Set error controller (if not route is avaiable)
self::write('routing.fallback.controller', 'Error');
// Set config file for route collection
self::write('routing.default_separator', '/');
}
|
[
"public",
"static",
"function",
"base",
"(",
")",
"{",
"// Charset by default",
"self",
"::",
"write",
"(",
"'application.encoding'",
",",
"'UTF8'",
")",
";",
"// Application environnement",
"self",
"::",
"write",
"(",
"'application.env'",
",",
"'dev'",
")",
";",
"// Application name",
"self",
"::",
"write",
"(",
"'application.name'",
",",
"'Awesome Application'",
")",
";",
"// Namespace for application",
"self",
"::",
"write",
"(",
"'application.namespace'",
",",
"'\\App'",
")",
";",
"// Absolute path to application",
"self",
"::",
"write",
"(",
"'application.path'",
",",
"'auto'",
")",
";",
"// Defined if bootstrap is use by application",
"self",
"::",
"write",
"(",
"'bootstrap.enable'",
",",
"true",
")",
";",
"// Set config file for route collection",
"self",
"::",
"write",
"(",
"'database.config.enable'",
",",
"true",
")",
";",
"// Set config file for route collection",
"self",
"::",
"write",
"(",
"'database.config.file'",
",",
"'databases.php'",
")",
";",
"// Set debug level to all",
"self",
"::",
"write",
"(",
"'debug.level'",
",",
"E_ALL",
")",
";",
"// Define if script file existence is tested",
"self",
"::",
"write",
"(",
"'html.script.test_file_existance'",
",",
"true",
")",
";",
"// Define if css file existence is tested",
"self",
"::",
"write",
"(",
"'html.css.test_file_existance'",
",",
"true",
")",
";",
"// Set autoloading of shared var between componant",
"self",
"::",
"write",
"(",
"'mvc.autoload_shared_var'",
",",
"true",
")",
";",
"// Set namespace for controller",
"self",
"::",
"write",
"(",
"'mvc.controller.namespace'",
",",
"'\\App\\Controller'",
")",
";",
"// Set namespace for layout",
"self",
"::",
"write",
"(",
"'mvc.layout.namespace'",
",",
"'\\App\\Layout'",
")",
";",
"// Set path for Layout",
"self",
"::",
"write",
"(",
"'mvc.layout.path'",
",",
"'/src/Layout'",
")",
";",
"// Set default layout",
"self",
"::",
"write",
"(",
"'mvc.layout.default'",
",",
"'Application'",
")",
";",
"// Set extension for layout",
"self",
"::",
"write",
"(",
"'mvc.layout.extension'",
",",
"'php'",
")",
";",
"// Set auto render for layout",
"self",
"::",
"write",
"(",
"'mvc.layout.auto_render'",
",",
"true",
")",
";",
"// Set namespace for model",
"self",
"::",
"write",
"(",
"'mvc.model.namespace'",
",",
"'\\App\\Model'",
")",
";",
"// Set auto render for view",
"self",
"::",
"write",
"(",
"'mvc.view.auto_render'",
",",
"true",
")",
";",
"// Set extension for view",
"self",
"::",
"write",
"(",
"'mvc.view.extension'",
",",
"'php'",
")",
";",
"// Set path for view",
"self",
"::",
"write",
"(",
"'mvc.view.path'",
",",
"'/src/View'",
")",
";",
"// Set auto routing",
"self",
"::",
"write",
"(",
"'routing.auto'",
",",
"true",
")",
";",
"// Set config file for route collection",
"self",
"::",
"write",
"(",
"'routing.config.enable'",
",",
"true",
")",
";",
"// Set config file for route collection",
"self",
"::",
"write",
"(",
"'routing.config.file'",
",",
"'routes.php'",
")",
";",
"// Set error action (if not route is avaiable)",
"self",
"::",
"write",
"(",
"'routing.fallback.action'",
",",
"'index'",
")",
";",
"// Set error controller (if not route is avaiable)",
"self",
"::",
"write",
"(",
"'routing.fallback.controller'",
",",
"'Error'",
")",
";",
"// Set config file for route collection",
"self",
"::",
"write",
"(",
"'routing.default_separator'",
",",
"'/'",
")",
";",
"}"
] |
Get base configuration of Pabana
This method defined default key and value for using Pabana
@since 1.0
@return void
|
[
"Get",
"base",
"configuration",
"of",
"Pabana"
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Core/Configuration.php#L40-L98
|
239,818
|
FuturaSoft/Pabana
|
src/Core/Configuration.php
|
Configuration.prepare
|
public static function prepare($key, $value)
{
if ($value == 'true') {
return true;
} elseif ($value == 'false') {
return false;
} elseif ($key == 'debug.level' && substr($value, 0, 2) == "E_") {
return eval('return ' . $value . ';');
} elseif ($key == 'application.path' && ($value === false || $value === 'false' || $value === 'auto')) {
$sLibraryPath = DS . 'vendor' . DS . 'pabana' . DS . 'pabana' . DS . 'src' . DS . 'Core';
return str_replace($sLibraryPath, '', __DIR__);
}
return $value;
}
|
php
|
public static function prepare($key, $value)
{
if ($value == 'true') {
return true;
} elseif ($value == 'false') {
return false;
} elseif ($key == 'debug.level' && substr($value, 0, 2) == "E_") {
return eval('return ' . $value . ';');
} elseif ($key == 'application.path' && ($value === false || $value === 'false' || $value === 'auto')) {
$sLibraryPath = DS . 'vendor' . DS . 'pabana' . DS . 'pabana' . DS . 'src' . DS . 'Core';
return str_replace($sLibraryPath, '', __DIR__);
}
return $value;
}
|
[
"public",
"static",
"function",
"prepare",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"'true'",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"value",
"==",
"'false'",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'debug.level'",
"&&",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"2",
")",
"==",
"\"E_\"",
")",
"{",
"return",
"eval",
"(",
"'return '",
".",
"$",
"value",
".",
"';'",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'application.path'",
"&&",
"(",
"$",
"value",
"===",
"false",
"||",
"$",
"value",
"===",
"'false'",
"||",
"$",
"value",
"===",
"'auto'",
")",
")",
"{",
"$",
"sLibraryPath",
"=",
"DS",
".",
"'vendor'",
".",
"DS",
".",
"'pabana'",
".",
"DS",
".",
"'pabana'",
".",
"DS",
".",
"'src'",
".",
"DS",
".",
"'Core'",
";",
"return",
"str_replace",
"(",
"$",
"sLibraryPath",
",",
"''",
",",
"__DIR__",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Prepare a configuration value
This method is used to modify a configuration value
For exemple change 'true' string to true boolean
@since 1.0
@param string $key Key to prepare
@param mixed $value Value to prepare.
@return mixed Value prepared
|
[
"Prepare",
"a",
"configuration",
"value"
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Core/Configuration.php#L216-L229
|
239,819
|
FuturaSoft/Pabana
|
src/Core/Configuration.php
|
Configuration.prepareArray
|
public static function prepareArray($configList)
{
$preparedConfigList = array();
foreach ($configList as $key => $value) {
$preparedConfigList[$key] = self::prepare($key, $value);
}
return $preparedConfigList;
}
|
php
|
public static function prepareArray($configList)
{
$preparedConfigList = array();
foreach ($configList as $key => $value) {
$preparedConfigList[$key] = self::prepare($key, $value);
}
return $preparedConfigList;
}
|
[
"public",
"static",
"function",
"prepareArray",
"(",
"$",
"configList",
")",
"{",
"$",
"preparedConfigList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"configList",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"preparedConfigList",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"prepare",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"preparedConfigList",
";",
"}"
] |
Prepare a configuration array
Parse array and prepare all of their value
@since 1.0
@param array $configList Array of key and value to prepare
@return array Array of key and value prepared
|
[
"Prepare",
"a",
"configuration",
"array"
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Core/Configuration.php#L240-L247
|
239,820
|
FuturaSoft/Pabana
|
src/Core/Configuration.php
|
Configuration.read
|
public static function read($key)
{
// Check key existence
if (!self::check($key)) {
throw new \Exception('Configuration key "' . $key . '" doesn\'t exists');
return false;
}
// Get value of key
return self::$configList[$key];
}
|
php
|
public static function read($key)
{
// Check key existence
if (!self::check($key)) {
throw new \Exception('Configuration key "' . $key . '" doesn\'t exists');
return false;
}
// Get value of key
return self::$configList[$key];
}
|
[
"public",
"static",
"function",
"read",
"(",
"$",
"key",
")",
"{",
"// Check key existence",
"if",
"(",
"!",
"self",
"::",
"check",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Configuration key \"'",
".",
"$",
"key",
".",
"'\" doesn\\'t exists'",
")",
";",
"return",
"false",
";",
"}",
"// Get value of key",
"return",
"self",
"::",
"$",
"configList",
"[",
"$",
"key",
"]",
";",
"}"
] |
Read a configuration key
This method is used to read a key from Configuration
Key existance is checked first
@since 1.0
@param string $key Key to read.
@return mixed|bool Value of Configuration parameter or false if configuration key doesn't exist
|
[
"Read",
"a",
"configuration",
"key"
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Core/Configuration.php#L259-L268
|
239,821
|
FuturaSoft/Pabana
|
src/Core/Configuration.php
|
Configuration.write
|
public static function write($key, $value, $force = true)
{
// Check key existence
if (self::check($key) && $force === false) {
throw new \Exception('Configuration key "' . $key . '" already exist (use force argument to modify an already defined key).');
return false;
}
// Prepare value (transform 'true' to true, etc...)
$preparedValue = self::prepare($key, $value);
// Write value content
self::$configList[$key] = $preparedValue;
return true;
}
|
php
|
public static function write($key, $value, $force = true)
{
// Check key existence
if (self::check($key) && $force === false) {
throw new \Exception('Configuration key "' . $key . '" already exist (use force argument to modify an already defined key).');
return false;
}
// Prepare value (transform 'true' to true, etc...)
$preparedValue = self::prepare($key, $value);
// Write value content
self::$configList[$key] = $preparedValue;
return true;
}
|
[
"public",
"static",
"function",
"write",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"force",
"=",
"true",
")",
"{",
"// Check key existence",
"if",
"(",
"self",
"::",
"check",
"(",
"$",
"key",
")",
"&&",
"$",
"force",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Configuration key \"'",
".",
"$",
"key",
".",
"'\" already exist (use force argument to modify an already defined key).'",
")",
";",
"return",
"false",
";",
"}",
"// Prepare value (transform 'true' to true, etc...)",
"$",
"preparedValue",
"=",
"self",
"::",
"prepare",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"// Write value content",
"self",
"::",
"$",
"configList",
"[",
"$",
"key",
"]",
"=",
"$",
"preparedValue",
";",
"return",
"true",
";",
"}"
] |
Write a configuration key
This method is used to write a key and a value
First value is prepare by prepare method
@since 1.0
@param string $key Key to read.
@param string $value Value of key.
@param bool $force Force writing of key even is already defined.
@return bool Return true if success else return false;.
|
[
"Write",
"a",
"configuration",
"key"
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Core/Configuration.php#L334-L346
|
239,822
|
undefined-exception-coders/UECMediaBundle
|
Path/MediaPathGenerator.php
|
MediaPathGenerator.generate
|
public function generate(MediaProviderInterface $mediaProvider)
{
$path = rtrim($this->basePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR .
$mediaProvider->getMedia()->getContext() . DIRECTORY_SEPARATOR .
date('Y') . DIRECTORY_SEPARATOR .
date('m') . DIRECTORY_SEPARATOR .
date('d')
;
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
return $path;
}
|
php
|
public function generate(MediaProviderInterface $mediaProvider)
{
$path = rtrim($this->basePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR .
$mediaProvider->getMedia()->getContext() . DIRECTORY_SEPARATOR .
date('Y') . DIRECTORY_SEPARATOR .
date('m') . DIRECTORY_SEPARATOR .
date('d')
;
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
return $path;
}
|
[
"public",
"function",
"generate",
"(",
"MediaProviderInterface",
"$",
"mediaProvider",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"basePath",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"mediaProvider",
"->",
"getMedia",
"(",
")",
"->",
"getContext",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"date",
"(",
"'Y'",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"date",
"(",
"'m'",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"date",
"(",
"'d'",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"mkdir",
"(",
"$",
"path",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Generate path for Media
@param MediaProviderInterface $mediaProvider
@return string
|
[
"Generate",
"path",
"for",
"Media"
] |
93c7bd6b3e1185ef716c26368677c08f95200f0b
|
https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Path/MediaPathGenerator.php#L15-L29
|
239,823
|
meliorframework/melior
|
Classes/Helper/GUIDGenerator.php
|
GUIDGenerator.generate
|
public function generate(string $content = null): string
{
if (empty($content)) {
$guid = Uuid::uuid4();
} else {
$guid = Uuid::uuid5(Uuid::NAMESPACE_DNS, $content);
}
return $guid->toString();
}
|
php
|
public function generate(string $content = null): string
{
if (empty($content)) {
$guid = Uuid::uuid4();
} else {
$guid = Uuid::uuid5(Uuid::NAMESPACE_DNS, $content);
}
return $guid->toString();
}
|
[
"public",
"function",
"generate",
"(",
"string",
"$",
"content",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"$",
"guid",
"=",
"Uuid",
"::",
"uuid4",
"(",
")",
";",
"}",
"else",
"{",
"$",
"guid",
"=",
"Uuid",
"::",
"uuid5",
"(",
"Uuid",
"::",
"NAMESPACE_DNS",
",",
"$",
"content",
")",
";",
"}",
"return",
"$",
"guid",
"->",
"toString",
"(",
")",
";",
"}"
] |
Generates a GUID, optionally from specified Content.
@param string|null $content
@return string
|
[
"Generates",
"a",
"GUID",
"optionally",
"from",
"specified",
"Content",
"."
] |
f6469fa6e85f66a0507ae13603d19d78f2774e0b
|
https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Helper/GUIDGenerator.php#L35-L44
|
239,824
|
aloframework/handlers
|
src/class/Output/Dump.php
|
Dump.html
|
public static function html() {
$fargs = func_get_args();
$mode = self::enabled();
self::enabled(self::MODE_RICH);
$ret = self::dump(empty($fargs) ? null : $fargs[0]);
self::enabled($mode);
return $ret;
}
|
php
|
public static function html() {
$fargs = func_get_args();
$mode = self::enabled();
self::enabled(self::MODE_RICH);
$ret = self::dump(empty($fargs) ? null : $fargs[0]);
self::enabled($mode);
return $ret;
}
|
[
"public",
"static",
"function",
"html",
"(",
")",
"{",
"$",
"fargs",
"=",
"func_get_args",
"(",
")",
";",
"$",
"mode",
"=",
"self",
"::",
"enabled",
"(",
")",
";",
"self",
"::",
"enabled",
"(",
"self",
"::",
"MODE_RICH",
")",
";",
"$",
"ret",
"=",
"self",
"::",
"dump",
"(",
"empty",
"(",
"$",
"fargs",
")",
"?",
"null",
":",
"$",
"fargs",
"[",
"0",
"]",
")",
";",
"self",
"::",
"enabled",
"(",
"$",
"mode",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Dumps in HTML mode
@author Art <a.molcanovas@gmail.com>
@return string The output
|
[
"Dumps",
"in",
"HTML",
"mode"
] |
3f17510c5e9221855d39c332710d0e512ec8b42d
|
https://github.com/aloframework/handlers/blob/3f17510c5e9221855d39c332710d0e512ec8b42d/src/class/Output/Dump.php#L37-L45
|
239,825
|
iJos/iForms
|
src/iForm.php
|
iForm.addFormField
|
public function addFormField($type, $params = array()) {
$namespace = "\\iJos\\iForms\\Fields\\" . ucfirst($type);
$field = new $namespace( $params );
array_push($this -> form_fields, $field);
}
|
php
|
public function addFormField($type, $params = array()) {
$namespace = "\\iJos\\iForms\\Fields\\" . ucfirst($type);
$field = new $namespace( $params );
array_push($this -> form_fields, $field);
}
|
[
"public",
"function",
"addFormField",
"(",
"$",
"type",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"namespace",
"=",
"\"\\\\iJos\\\\iForms\\\\Fields\\\\\"",
".",
"ucfirst",
"(",
"$",
"type",
")",
";",
"$",
"field",
"=",
"new",
"$",
"namespace",
"(",
"$",
"params",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"form_fields",
",",
"$",
"field",
")",
";",
"}"
] |
Add a Field to the curent form
@param string $type
@param array $params
|
[
"Add",
"a",
"Field",
"to",
"the",
"curent",
"form"
] |
9ccae9bc624a749f18cddcac59bb41cec3ed22b8
|
https://github.com/iJos/iForms/blob/9ccae9bc624a749f18cddcac59bb41cec3ed22b8/src/iForm.php#L46-L50
|
239,826
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/FormTagTrait.php
|
FormTagTrait.normalizeFormFieldTagParams
|
public function normalizeFormFieldTagParams($name, $value, array $attributes, $fieldType = null)
{
if (!isset($attributes['id'])) {
$attributes['id'] = trim(
str_replace(['[', ']', '()', '__'], ['_', '_', '', '_'], $name),
'_'
);
}
if ($name) {
$attributes['name'] = $name;
}
return [$name, (string)$value, $attributes];
}
|
php
|
public function normalizeFormFieldTagParams($name, $value, array $attributes, $fieldType = null)
{
if (!isset($attributes['id'])) {
$attributes['id'] = trim(
str_replace(['[', ']', '()', '__'], ['_', '_', '', '_'], $name),
'_'
);
}
if ($name) {
$attributes['name'] = $name;
}
return [$name, (string)$value, $attributes];
}
|
[
"public",
"function",
"normalizeFormFieldTagParams",
"(",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"attributes",
",",
"$",
"fieldType",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"trim",
"(",
"str_replace",
"(",
"[",
"'['",
",",
"']'",
",",
"'()'",
",",
"'__'",
"]",
",",
"[",
"'_'",
",",
"'_'",
",",
"''",
",",
"'_'",
"]",
",",
"$",
"name",
")",
",",
"'_'",
")",
";",
"}",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"}",
"return",
"[",
"$",
"name",
",",
"(",
"string",
")",
"$",
"value",
",",
"$",
"attributes",
"]",
";",
"}"
] |
This method can be "extended" to edit attributes for form-related tags.
|
[
"This",
"method",
"can",
"be",
"extended",
"to",
"edit",
"attributes",
"for",
"form",
"-",
"related",
"tags",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/FormTagTrait.php#L392-L404
|
239,827
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/FormTagTrait.php
|
FormTagTrait.normalizeFormTagOptions
|
public function normalizeFormTagOptions($urlOptions, $options, $block)
{
if (!$urlOptions || !$options || !$block) {
if ($urlOptions instanceof Closure) {
$block = $urlOptions;
$urlOptions = null;
$options = [];
} elseif (is_array($urlOptions) && is_string(key($urlOptions))) {
$block = $options;
$options = $urlOptions;
$urlOptions = null;
} elseif ($options instanceof Closure) {
$block = $options;
$options = [];
}
}
if (!$block instanceof Closure) {
throw new Exception\BadMethodCallException(
"One of the arguments for formTag must be a Closure"
);
}
if (empty($options['method'])) {
$options['method'] = 'post';
}
if (!empty($options['multipart'])) {
$options['enctype'] = 'multipart/form-data';
unset($options['multipart']);
}
if ($urlOptions) {
if (!$this->isUrl($urlOptions)) {
$options['action'] = $this->urlFor($urlOptions);
} else {
$options['action'] = $urlOptions;
}
}
return [$urlOptions, $options, $block];
}
|
php
|
public function normalizeFormTagOptions($urlOptions, $options, $block)
{
if (!$urlOptions || !$options || !$block) {
if ($urlOptions instanceof Closure) {
$block = $urlOptions;
$urlOptions = null;
$options = [];
} elseif (is_array($urlOptions) && is_string(key($urlOptions))) {
$block = $options;
$options = $urlOptions;
$urlOptions = null;
} elseif ($options instanceof Closure) {
$block = $options;
$options = [];
}
}
if (!$block instanceof Closure) {
throw new Exception\BadMethodCallException(
"One of the arguments for formTag must be a Closure"
);
}
if (empty($options['method'])) {
$options['method'] = 'post';
}
if (!empty($options['multipart'])) {
$options['enctype'] = 'multipart/form-data';
unset($options['multipart']);
}
if ($urlOptions) {
if (!$this->isUrl($urlOptions)) {
$options['action'] = $this->urlFor($urlOptions);
} else {
$options['action'] = $urlOptions;
}
}
return [$urlOptions, $options, $block];
}
|
[
"public",
"function",
"normalizeFormTagOptions",
"(",
"$",
"urlOptions",
",",
"$",
"options",
",",
"$",
"block",
")",
"{",
"if",
"(",
"!",
"$",
"urlOptions",
"||",
"!",
"$",
"options",
"||",
"!",
"$",
"block",
")",
"{",
"if",
"(",
"$",
"urlOptions",
"instanceof",
"Closure",
")",
"{",
"$",
"block",
"=",
"$",
"urlOptions",
";",
"$",
"urlOptions",
"=",
"null",
";",
"$",
"options",
"=",
"[",
"]",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"urlOptions",
")",
"&&",
"is_string",
"(",
"key",
"(",
"$",
"urlOptions",
")",
")",
")",
"{",
"$",
"block",
"=",
"$",
"options",
";",
"$",
"options",
"=",
"$",
"urlOptions",
";",
"$",
"urlOptions",
"=",
"null",
";",
"}",
"elseif",
"(",
"$",
"options",
"instanceof",
"Closure",
")",
"{",
"$",
"block",
"=",
"$",
"options",
";",
"$",
"options",
"=",
"[",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"block",
"instanceof",
"Closure",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"BadMethodCallException",
"(",
"\"One of the arguments for formTag must be a Closure\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'method'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'method'",
"]",
"=",
"'post'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'multipart'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'enctype'",
"]",
"=",
"'multipart/form-data'",
";",
"unset",
"(",
"$",
"options",
"[",
"'multipart'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"urlOptions",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isUrl",
"(",
"$",
"urlOptions",
")",
")",
"{",
"$",
"options",
"[",
"'action'",
"]",
"=",
"$",
"this",
"->",
"urlFor",
"(",
"$",
"urlOptions",
")",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'action'",
"]",
"=",
"$",
"urlOptions",
";",
"}",
"}",
"return",
"[",
"$",
"urlOptions",
",",
"$",
"options",
",",
"$",
"block",
"]",
";",
"}"
] |
This method may be "extended" to customize form options such as HTML attributes.
|
[
"This",
"method",
"may",
"be",
"extended",
"to",
"customize",
"form",
"options",
"such",
"as",
"HTML",
"attributes",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/FormTagTrait.php#L443-L484
|
239,828
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/FormTagTrait.php
|
FormTagTrait.runContentBlock
|
protected function runContentBlock(Closure $block)
{
ob_start();
$result = $block();
$contents = ob_get_clean();
return $result ?: $contents;
}
|
php
|
protected function runContentBlock(Closure $block)
{
ob_start();
$result = $block();
$contents = ob_get_clean();
return $result ?: $contents;
}
|
[
"protected",
"function",
"runContentBlock",
"(",
"Closure",
"$",
"block",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"result",
"=",
"$",
"block",
"(",
")",
";",
"$",
"contents",
"=",
"ob_get_clean",
"(",
")",
";",
"return",
"$",
"result",
"?",
":",
"$",
"contents",
";",
"}"
] |
Runs a Closure that can either output content itself or
return the content as a string.
@param Closure $block
@return string
|
[
"Runs",
"a",
"Closure",
"that",
"can",
"either",
"output",
"content",
"itself",
"or",
"return",
"the",
"content",
"as",
"a",
"string",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/FormTagTrait.php#L566-L572
|
239,829
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/FormTagTrait.php
|
FormTagTrait.normalizeSizeOption
|
protected function normalizeSizeOption(array &$options)
{
if (isset($options['size'])) {
$size = explode('x', $options['size']);
if (
isset($size[0]) &&
isset($size[1])
) {
list($options['cols'], $options['rows']) = $size;
}
unset($options['size']);
}
}
|
php
|
protected function normalizeSizeOption(array &$options)
{
if (isset($options['size'])) {
$size = explode('x', $options['size']);
if (
isset($size[0]) &&
isset($size[1])
) {
list($options['cols'], $options['rows']) = $size;
}
unset($options['size']);
}
}
|
[
"protected",
"function",
"normalizeSizeOption",
"(",
"array",
"&",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
")",
"{",
"$",
"size",
"=",
"explode",
"(",
"'x'",
",",
"$",
"options",
"[",
"'size'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"size",
"[",
"0",
"]",
")",
"&&",
"isset",
"(",
"$",
"size",
"[",
"1",
"]",
")",
")",
"{",
"list",
"(",
"$",
"options",
"[",
"'cols'",
"]",
",",
"$",
"options",
"[",
"'rows'",
"]",
")",
"=",
"$",
"size",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
";",
"}",
"}"
] |
Checks for the "size" option, which is expected to be something like
`50x20`, and is splitted into "cols" and "rows".
@return void
|
[
"Checks",
"for",
"the",
"size",
"option",
"which",
"is",
"expected",
"to",
"be",
"something",
"like",
"50x20",
"and",
"is",
"splitted",
"into",
"cols",
"and",
"rows",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/FormTagTrait.php#L600-L612
|
239,830
|
tekkla/core-asset
|
Core/Asset/Javascript/JavascriptHandler.php
|
JavascriptHandler.&
|
public function &createScript($content, $defer = true, $combine = true, $minify = true): JavascriptObjectInterface
{
$obj = new JavascriptObject();
$obj->setType($obj::TYPE_SCRIPT);
$obj->setContent($content);
$obj->setDefer($defer);
$obj->setCombine($combine);
$obj->setMinify($minify);
$this->addObject($obj);
return $obj;
}
|
php
|
public function &createScript($content, $defer = true, $combine = true, $minify = true): JavascriptObjectInterface
{
$obj = new JavascriptObject();
$obj->setType($obj::TYPE_SCRIPT);
$obj->setContent($content);
$obj->setDefer($defer);
$obj->setCombine($combine);
$obj->setMinify($minify);
$this->addObject($obj);
return $obj;
}
|
[
"public",
"function",
"&",
"createScript",
"(",
"$",
"content",
",",
"$",
"defer",
"=",
"true",
",",
"$",
"combine",
"=",
"true",
",",
"$",
"minify",
"=",
"true",
")",
":",
"JavascriptObjectInterface",
"{",
"$",
"obj",
"=",
"new",
"JavascriptObject",
"(",
")",
";",
"$",
"obj",
"->",
"setType",
"(",
"$",
"obj",
"::",
"TYPE_SCRIPT",
")",
";",
"$",
"obj",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"$",
"obj",
"->",
"setDefer",
"(",
"$",
"defer",
")",
";",
"$",
"obj",
"->",
"setCombine",
"(",
"$",
"combine",
")",
";",
"$",
"obj",
"->",
"setMinify",
"(",
"$",
"minify",
")",
";",
"$",
"this",
"->",
"addObject",
"(",
"$",
"obj",
")",
";",
"return",
"$",
"obj",
";",
"}"
] |
Adds an script javascript object to the output queue
@param string $content
Objects content
@param boolean $defer
Optional flag to put objects output right before the closing body tag. (Default: true)
@param boolean $combine
Optional flag to switch combining for this object on or off. (Default: true)
@param boolean $minify
Optional flag to switch minifying for this object on or off. (Default: true)
Applies only when $combine argument is set to true.
@return JavascriptObjectInterface
|
[
"Adds",
"an",
"script",
"javascript",
"object",
"to",
"the",
"output",
"queue"
] |
7dec00b51627dd8201a7e1cbc349d85abed84063
|
https://github.com/tekkla/core-asset/blob/7dec00b51627dd8201a7e1cbc349d85abed84063/Core/Asset/Javascript/JavascriptHandler.php#L169-L182
|
239,831
|
tekkla/core-asset
|
Core/Asset/Javascript/JavascriptHandler.php
|
JavascriptHandler.&
|
public function &createBlock($content, $defer = true, $combine = true, $minify = true): JavascriptObjectInterface
{
$obj = new JavascriptObject();
$obj->setType($obj::TYPE_BLOCK);
$obj->setContent($content);
$obj->setDefer($defer);
$obj->setCombine($combine);
$obj->setMinify($minify);
$this->addObject($obj);
return $obj;
}
|
php
|
public function &createBlock($content, $defer = true, $combine = true, $minify = true): JavascriptObjectInterface
{
$obj = new JavascriptObject();
$obj->setType($obj::TYPE_BLOCK);
$obj->setContent($content);
$obj->setDefer($defer);
$obj->setCombine($combine);
$obj->setMinify($minify);
$this->addObject($obj);
return $obj;
}
|
[
"public",
"function",
"&",
"createBlock",
"(",
"$",
"content",
",",
"$",
"defer",
"=",
"true",
",",
"$",
"combine",
"=",
"true",
",",
"$",
"minify",
"=",
"true",
")",
":",
"JavascriptObjectInterface",
"{",
"$",
"obj",
"=",
"new",
"JavascriptObject",
"(",
")",
";",
"$",
"obj",
"->",
"setType",
"(",
"$",
"obj",
"::",
"TYPE_BLOCK",
")",
";",
"$",
"obj",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"$",
"obj",
"->",
"setDefer",
"(",
"$",
"defer",
")",
";",
"$",
"obj",
"->",
"setCombine",
"(",
"$",
"combine",
")",
";",
"$",
"obj",
"->",
"setMinify",
"(",
"$",
"minify",
")",
";",
"$",
"this",
"->",
"addObject",
"(",
"$",
"obj",
")",
";",
"return",
"$",
"obj",
";",
"}"
] |
Blocks with complete code
Use this for conditional scripts!
@param string $content
Objects content
@param boolean $defer
Optional flag to put objects output right before the closing body tag. (Default: true)
@param boolean $combine
Optional flag to switch combining for this object on or off. (Default: true)
@param boolean $minify
Optional flag to switch minifying for this object on or off. (Default: true)
Applies only when $combine argument is set to true.g.
@return JavascriptObjectInterface
|
[
"Blocks",
"with",
"complete",
"code"
] |
7dec00b51627dd8201a7e1cbc349d85abed84063
|
https://github.com/tekkla/core-asset/blob/7dec00b51627dd8201a7e1cbc349d85abed84063/Core/Asset/Javascript/JavascriptHandler.php#L229-L242
|
239,832
|
Webiny/Hrc
|
src/Webiny/Hrc/Request.php
|
Request.matchUrl
|
public function matchUrl($pattern)
{
if ($this->matchValue($this->getUrl(), $pattern)) {
return $this->getUrl();
}
return false;
}
|
php
|
public function matchUrl($pattern)
{
if ($this->matchValue($this->getUrl(), $pattern)) {
return $this->getUrl();
}
return false;
}
|
[
"public",
"function",
"matchUrl",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchValue",
"(",
"$",
"this",
"->",
"getUrl",
"(",
")",
",",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the url matches the given pattern.
@param string $pattern Pattern to match.
@return bool|null|string Url value if pattern matches, otherwise false.
|
[
"Check",
"if",
"the",
"url",
"matches",
"the",
"given",
"pattern",
"."
] |
2594d645dd79a579916d90ec93ce815bd413558f
|
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/Request.php#L144-L151
|
239,833
|
Webiny/Hrc
|
src/Webiny/Hrc/Request.php
|
Request.matchHeader
|
public function matchHeader($name, $pattern = null)
{
if (isset($this->getHeaders()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getHeaders()[$name], $pattern)) {
return $this->getHeaders()[$name];
}
} else {
if (empty($this->getHeaders()[$name])) {
return true;
} else {
return $this->getHeaders()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
php
|
public function matchHeader($name, $pattern = null)
{
if (isset($this->getHeaders()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getHeaders()[$name], $pattern)) {
return $this->getHeaders()[$name];
}
} else {
if (empty($this->getHeaders()[$name])) {
return true;
} else {
return $this->getHeaders()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
[
"public",
"function",
"matchHeader",
"(",
"$",
"name",
",",
"$",
"pattern",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchValue",
"(",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"[",
"$",
"name",
"]",
",",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"pattern",
"==",
"'?'",
")",
"{",
"// in case of optional pattern we just return true",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the given header exists, and optionally if the pattern matches the header value.
@param string $name Header name to match.
@param string|null $pattern Optional pattern that needs to match the header value.
@return bool|string False if the header doesn't exist, or the pattern doesn't match.
If the header exists and pattern matched, the header value is returned.
|
[
"Check",
"if",
"the",
"given",
"header",
"exists",
"and",
"optionally",
"if",
"the",
"pattern",
"matches",
"the",
"header",
"value",
"."
] |
2594d645dd79a579916d90ec93ce815bd413558f
|
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/Request.php#L162-L182
|
239,834
|
Webiny/Hrc
|
src/Webiny/Hrc/Request.php
|
Request.matchCookie
|
public function matchCookie($name, $pattern = null)
{
if (isset($this->getCookies()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getCookies()[$name], $pattern)) {
return $this->getCookies()[$name];
}
} else {
if (empty($this->getCookies()[$name])) {
return true;
} else {
return $this->getCookies()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
php
|
public function matchCookie($name, $pattern = null)
{
if (isset($this->getCookies()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getCookies()[$name], $pattern)) {
return $this->getCookies()[$name];
}
} else {
if (empty($this->getCookies()[$name])) {
return true;
} else {
return $this->getCookies()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
[
"public",
"function",
"matchCookie",
"(",
"$",
"name",
",",
"$",
"pattern",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getCookies",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchValue",
"(",
"$",
"this",
"->",
"getCookies",
"(",
")",
"[",
"$",
"name",
"]",
",",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getCookies",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"getCookies",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getCookies",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"pattern",
"==",
"'?'",
")",
"{",
"// in case of optional pattern we just return true",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the given cookie exists, and optionally if the pattern matches the cookie value.
@param string $name Cookie name to match.
@param string|null $pattern Optional pattern that needs to match the cookie value.
@return bool|string False if the cookie doesn't exist, or the pattern doesn't match.
If the cookie exists and pattern matched, the cookie value is returned.
|
[
"Check",
"if",
"the",
"given",
"cookie",
"exists",
"and",
"optionally",
"if",
"the",
"pattern",
"matches",
"the",
"cookie",
"value",
"."
] |
2594d645dd79a579916d90ec93ce815bd413558f
|
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/Request.php#L193-L213
|
239,835
|
Webiny/Hrc
|
src/Webiny/Hrc/Request.php
|
Request.matchQueryParam
|
public function matchQueryParam($name, $pattern = null)
{
if (isset($this->getQueryParams()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getQueryParams()[$name], $pattern)) {
return $this->getQueryParams()[$name];
}
} else {
if (empty($this->getQueryParams()[$name])) {
return true;
} else {
return $this->getQueryParams()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
php
|
public function matchQueryParam($name, $pattern = null)
{
if (isset($this->getQueryParams()[$name])) {
if (!empty($pattern)) {
if ($this->matchValue($this->getQueryParams()[$name], $pattern)) {
return $this->getQueryParams()[$name];
}
} else {
if (empty($this->getQueryParams()[$name])) {
return true;
} else {
return $this->getQueryParams()[$name];
}
}
} elseif ($pattern == '?') {
// in case of optional pattern we just return true
return true;
}
return false;
}
|
[
"public",
"function",
"matchQueryParam",
"(",
"$",
"name",
",",
"$",
"pattern",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchValue",
"(",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"name",
"]",
",",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"pattern",
"==",
"'?'",
")",
"{",
"// in case of optional pattern we just return true",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the given query param exists, and optionally if the pattern matches the query param value.
@param string $name Query param name to match.
@param string|null $pattern Optional pattern that needs to match the query param value.
@return bool|string False if the query param doesn't exist, or the pattern doesn't match.
If the query param exists and pattern matched, the query param value is returned.
|
[
"Check",
"if",
"the",
"given",
"query",
"param",
"exists",
"and",
"optionally",
"if",
"the",
"pattern",
"matches",
"the",
"query",
"param",
"value",
"."
] |
2594d645dd79a579916d90ec93ce815bd413558f
|
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/Request.php#L224-L244
|
239,836
|
Webiny/Hrc
|
src/Webiny/Hrc/Request.php
|
Request.matchValue
|
private function matchValue($value, $pattern)
{
// basic check
if ($value == $pattern) {
return true;
}
// simple check in case of optional param
if ($pattern == '?') {
return true;
}
// simple match in case pattern is just "*"
if ($pattern == '*' && $value != '') {
return true;
}
// more complex match in case when wildcard is part of a larger match
$pattern = str_replace('*', '(.+)', $pattern);
// regex match
if (strpos($pattern, '(') !== false || strpos($pattern, '[') !== false || strpos($pattern, '\\') !== false) {
return preg_match('#^' . $pattern . '$#', $value);
}
return false;
}
|
php
|
private function matchValue($value, $pattern)
{
// basic check
if ($value == $pattern) {
return true;
}
// simple check in case of optional param
if ($pattern == '?') {
return true;
}
// simple match in case pattern is just "*"
if ($pattern == '*' && $value != '') {
return true;
}
// more complex match in case when wildcard is part of a larger match
$pattern = str_replace('*', '(.+)', $pattern);
// regex match
if (strpos($pattern, '(') !== false || strpos($pattern, '[') !== false || strpos($pattern, '\\') !== false) {
return preg_match('#^' . $pattern . '$#', $value);
}
return false;
}
|
[
"private",
"function",
"matchValue",
"(",
"$",
"value",
",",
"$",
"pattern",
")",
"{",
"// basic check",
"if",
"(",
"$",
"value",
"==",
"$",
"pattern",
")",
"{",
"return",
"true",
";",
"}",
"// simple check in case of optional param",
"if",
"(",
"$",
"pattern",
"==",
"'?'",
")",
"{",
"return",
"true",
";",
"}",
"// simple match in case pattern is just \"*\"",
"if",
"(",
"$",
"pattern",
"==",
"'*'",
"&&",
"$",
"value",
"!=",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// more complex match in case when wildcard is part of a larger match",
"$",
"pattern",
"=",
"str_replace",
"(",
"'*'",
",",
"'(.+)'",
",",
"$",
"pattern",
")",
";",
"// regex match",
"if",
"(",
"strpos",
"(",
"$",
"pattern",
",",
"'('",
")",
"!==",
"false",
"||",
"strpos",
"(",
"$",
"pattern",
",",
"'['",
")",
"!==",
"false",
"||",
"strpos",
"(",
"$",
"pattern",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"return",
"preg_match",
"(",
"'#^'",
".",
"$",
"pattern",
".",
"'$#'",
",",
"$",
"value",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Method that tries to match the given pattern to the given value.
@param string $value Value where the pattern match will be performed.
@param string $pattern Pattern to match.
@return bool True if pattern matched the value, otherwise false.
|
[
"Method",
"that",
"tries",
"to",
"match",
"the",
"given",
"pattern",
"to",
"the",
"given",
"value",
"."
] |
2594d645dd79a579916d90ec93ce815bd413558f
|
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/Request.php#L281-L307
|
239,837
|
xaamin/encoding
|
src/Encode.php
|
Encode.strlen
|
protected static function strlen($text)
{
$exits = (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload')) & 2);
return $exits ? mb_strlen($text,'8bit') : strlen($text);
}
|
php
|
protected static function strlen($text)
{
$exits = (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload')) & 2);
return $exits ? mb_strlen($text,'8bit') : strlen($text);
}
|
[
"protected",
"static",
"function",
"strlen",
"(",
"$",
"text",
")",
"{",
"$",
"exits",
"=",
"(",
"function_exists",
"(",
"'mb_strlen'",
")",
"&&",
"(",
"(",
"int",
")",
"ini_get",
"(",
"'mbstring.func_overload'",
")",
")",
"&",
"2",
")",
";",
"return",
"$",
"exits",
"?",
"mb_strlen",
"(",
"$",
"text",
",",
"'8bit'",
")",
":",
"strlen",
"(",
"$",
"text",
")",
";",
"}"
] |
Calculates the length from given string
@param string $text
@return int
|
[
"Calculates",
"the",
"length",
"from",
"given",
"string"
] |
b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4
|
https://github.com/xaamin/encoding/blob/b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4/src/Encode.php#L319-L324
|
239,838
|
xaamin/encoding
|
src/Encode.php
|
Encode.normalizeEncoding
|
protected static function normalizeEncoding($encodingLabel)
{
$encoding = strtoupper($encodingLabel);
$encoding = preg_replace('/[^a-zA-Z0-9\s]/', '', $encoding);
$equivalences = [
'ISO88591' => 'ISO-8859-1',
'ISO8859' => 'ISO-8859-1',
'ISO' => 'ISO-8859-1',
'LATIN1' => 'ISO-8859-1',
'LATIN' => 'ISO-8859-1',
'UTF8' => 'UTF-8',
'UTF' => 'UTF-8',
'WIN1252' => 'ISO-8859-1',
'WINDOWS1252' => 'ISO-8859-1'
];
if (empty($equivalences[$encoding])) {
return 'UTF-8';
}
return $equivalences[$encoding];
}
|
php
|
protected static function normalizeEncoding($encodingLabel)
{
$encoding = strtoupper($encodingLabel);
$encoding = preg_replace('/[^a-zA-Z0-9\s]/', '', $encoding);
$equivalences = [
'ISO88591' => 'ISO-8859-1',
'ISO8859' => 'ISO-8859-1',
'ISO' => 'ISO-8859-1',
'LATIN1' => 'ISO-8859-1',
'LATIN' => 'ISO-8859-1',
'UTF8' => 'UTF-8',
'UTF' => 'UTF-8',
'WIN1252' => 'ISO-8859-1',
'WINDOWS1252' => 'ISO-8859-1'
];
if (empty($equivalences[$encoding])) {
return 'UTF-8';
}
return $equivalences[$encoding];
}
|
[
"protected",
"static",
"function",
"normalizeEncoding",
"(",
"$",
"encodingLabel",
")",
"{",
"$",
"encoding",
"=",
"strtoupper",
"(",
"$",
"encodingLabel",
")",
";",
"$",
"encoding",
"=",
"preg_replace",
"(",
"'/[^a-zA-Z0-9\\s]/'",
",",
"''",
",",
"$",
"encoding",
")",
";",
"$",
"equivalences",
"=",
"[",
"'ISO88591'",
"=>",
"'ISO-8859-1'",
",",
"'ISO8859'",
"=>",
"'ISO-8859-1'",
",",
"'ISO'",
"=>",
"'ISO-8859-1'",
",",
"'LATIN1'",
"=>",
"'ISO-8859-1'",
",",
"'LATIN'",
"=>",
"'ISO-8859-1'",
",",
"'UTF8'",
"=>",
"'UTF-8'",
",",
"'UTF'",
"=>",
"'UTF-8'",
",",
"'WIN1252'",
"=>",
"'ISO-8859-1'",
",",
"'WINDOWS1252'",
"=>",
"'ISO-8859-1'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"equivalences",
"[",
"$",
"encoding",
"]",
")",
")",
"{",
"return",
"'UTF-8'",
";",
"}",
"return",
"$",
"equivalences",
"[",
"$",
"encoding",
"]",
";",
"}"
] |
Returns normalized encoding name from common aliases
@param string $encodingLabel
@return string
|
[
"Returns",
"normalized",
"encoding",
"name",
"from",
"common",
"aliases"
] |
b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4
|
https://github.com/xaamin/encoding/blob/b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4/src/Encode.php#L332-L354
|
239,839
|
xaamin/encoding
|
src/Encode.php
|
Encode.to
|
public static function to($encodingLabel, $text)
{
$encodingLabel = static::normalizeEncoding($encodingLabel);
if ($encodingLabel == 'ISO-8859-1') {
return static::toLatin1($text);
}
return static::toUTF8($text);
}
|
php
|
public static function to($encodingLabel, $text)
{
$encodingLabel = static::normalizeEncoding($encodingLabel);
if ($encodingLabel == 'ISO-8859-1') {
return static::toLatin1($text);
}
return static::toUTF8($text);
}
|
[
"public",
"static",
"function",
"to",
"(",
"$",
"encodingLabel",
",",
"$",
"text",
")",
"{",
"$",
"encodingLabel",
"=",
"static",
"::",
"normalizeEncoding",
"(",
"$",
"encodingLabel",
")",
";",
"if",
"(",
"$",
"encodingLabel",
"==",
"'ISO-8859-1'",
")",
"{",
"return",
"static",
"::",
"toLatin1",
"(",
"$",
"text",
")",
";",
"}",
"return",
"static",
"::",
"toUTF8",
"(",
"$",
"text",
")",
";",
"}"
] |
Encode to supported encoding types aliases
ISO88591
ISO8859
ISO
LATIN1
LATIN
UTF8
UTF
WIN1252
WINDOWS1252
@param string $encodingLabel Encoding name
@param string|array $text
@return string|array
|
[
"Encode",
"to",
"supported",
"encoding",
"types",
"aliases",
"ISO88591",
"ISO8859",
"ISO",
"LATIN1",
"LATIN",
"UTF8",
"UTF",
"WIN1252",
"WINDOWS1252"
] |
b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4
|
https://github.com/xaamin/encoding/blob/b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4/src/Encode.php#L372-L381
|
239,840
|
xaamin/encoding
|
src/Encode.php
|
Encode.utf8Decode
|
protected static function utf8Decode($text, $option)
{
if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
$decoded = utf8_decode(
str_replace(array_keys(static::$utf8ToWin1252), array_values(static::$utf8ToWin1252), static::toUTF8($text))
);
} else {
$decoded = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
}
return $decoded;
}
|
php
|
protected static function utf8Decode($text, $option)
{
if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
$decoded = utf8_decode(
str_replace(array_keys(static::$utf8ToWin1252), array_values(static::$utf8ToWin1252), static::toUTF8($text))
);
} else {
$decoded = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
}
return $decoded;
}
|
[
"protected",
"static",
"function",
"utf8Decode",
"(",
"$",
"text",
",",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"==",
"self",
"::",
"WITHOUT_ICONV",
"||",
"!",
"function_exists",
"(",
"'iconv'",
")",
")",
"{",
"$",
"decoded",
"=",
"utf8_decode",
"(",
"str_replace",
"(",
"array_keys",
"(",
"static",
"::",
"$",
"utf8ToWin1252",
")",
",",
"array_values",
"(",
"static",
"::",
"$",
"utf8ToWin1252",
")",
",",
"static",
"::",
"toUTF8",
"(",
"$",
"text",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"decoded",
"=",
"iconv",
"(",
"\"UTF-8\"",
",",
"\"Windows-1252\"",
".",
"(",
"$",
"option",
"==",
"self",
"::",
"ICONV_TRANSLIT",
"?",
"'//TRANSLIT'",
":",
"(",
"$",
"option",
"==",
"self",
"::",
"ICONV_IGNORE",
"?",
"'//IGNORE'",
":",
"''",
")",
")",
",",
"$",
"text",
")",
";",
"}",
"return",
"$",
"decoded",
";",
"}"
] |
Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte Windows-1252
@param string $text
@param string $option How to convert if use iconv function (TRANSLIT or IGNORE)
@return string
|
[
"Converts",
"a",
"string",
"with",
"ISO",
"-",
"8859",
"-",
"1",
"characters",
"encoded",
"with",
"UTF",
"-",
"8",
"to",
"single",
"-",
"byte",
"Windows",
"-",
"1252"
] |
b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4
|
https://github.com/xaamin/encoding/blob/b2572676fb9f0a8cb81b3f2dbf2d63801bfe3be4/src/Encode.php#L390-L401
|
239,841
|
rseyferth/chickenwire
|
src/ChickenWire/Core/Configuration.php
|
Configuration.allFor
|
public function allFor($name) {
// Loop through environments
$result = array();
foreach ($this->_envSettings as $env => $settings) {
$result[$env] = $settings[$name];
}
return $result;
}
|
php
|
public function allFor($name) {
// Loop through environments
$result = array();
foreach ($this->_envSettings as $env => $settings) {
$result[$env] = $settings[$name];
}
return $result;
}
|
[
"public",
"function",
"allFor",
"(",
"$",
"name",
")",
"{",
"// Loop through environments",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_envSettings",
"as",
"$",
"env",
"=>",
"$",
"settings",
")",
"{",
"$",
"result",
"[",
"$",
"env",
"]",
"=",
"$",
"settings",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the values of the given setting for each environment
@param string $name The settings to retrieve
@return array
|
[
"Get",
"the",
"values",
"of",
"the",
"given",
"setting",
"for",
"each",
"environment"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Core/Configuration.php#L99-L108
|
239,842
|
SergioMadness/framework
|
framework/components/datamapper/traits/ErrorTrait.php
|
ErrorTrait.getError
|
public function getError($attribute)
{
$result = null;
if ($this->isErrorExists($attribute)) {
$result = $this->errors[$attribute];
}
return $result;
}
|
php
|
public function getError($attribute)
{
$result = null;
if ($this->isErrorExists($attribute)) {
$result = $this->errors[$attribute];
}
return $result;
}
|
[
"public",
"function",
"getError",
"(",
"$",
"attribute",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"isErrorExists",
"(",
"$",
"attribute",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"errors",
"[",
"$",
"attribute",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get error by attribute name
@param string $attribute
@return string
|
[
"Get",
"error",
"by",
"attribute",
"name"
] |
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
|
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/datamapper/traits/ErrorTrait.php#L28-L37
|
239,843
|
osflab/view
|
Helper/AbstractViewHelper.php
|
AbstractViewHelper.html
|
protected function html($newLine, $condition = true)
{
if ($condition) {
$this->lines[] = ltrim($newLine);
}
return $this;
}
|
php
|
protected function html($newLine, $condition = true)
{
if ($condition) {
$this->lines[] = ltrim($newLine);
}
return $this;
}
|
[
"protected",
"function",
"html",
"(",
"$",
"newLine",
",",
"$",
"condition",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"condition",
")",
"{",
"$",
"this",
"->",
"lines",
"[",
"]",
"=",
"ltrim",
"(",
"$",
"newLine",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Cumulate HTML code in order to restitute it
@param string $newLine
@param bool $condition ignored if false
@return $this
|
[
"Cumulate",
"HTML",
"code",
"in",
"order",
"to",
"restitute",
"it"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/AbstractViewHelper.php#L58-L64
|
239,844
|
jamesmcfadden/gen
|
src/Publisher.php
|
Publisher.getPageUrl
|
public function getPageUrl(Page $page)
{
return $this->config['base_url'].'/'.
($page->getSubFolder() === null ? '' : $page->getSubFolder().'/').
$this->getPagePublishFilename($page);
}
|
php
|
public function getPageUrl(Page $page)
{
return $this->config['base_url'].'/'.
($page->getSubFolder() === null ? '' : $page->getSubFolder().'/').
$this->getPagePublishFilename($page);
}
|
[
"public",
"function",
"getPageUrl",
"(",
"Page",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"'base_url'",
"]",
".",
"'/'",
".",
"(",
"$",
"page",
"->",
"getSubFolder",
"(",
")",
"===",
"null",
"?",
"''",
":",
"$",
"page",
"->",
"getSubFolder",
"(",
")",
".",
"'/'",
")",
".",
"$",
"this",
"->",
"getPagePublishFilename",
"(",
"$",
"page",
")",
";",
"}"
] |
Return the page URL.
@return string
|
[
"Return",
"the",
"page",
"URL",
"."
] |
2c7a7da1c3a04e10463c956722f85f5da13dc179
|
https://github.com/jamesmcfadden/gen/blob/2c7a7da1c3a04e10463c956722f85f5da13dc179/src/Publisher.php#L225-L230
|
239,845
|
jamesmcfadden/gen
|
src/Publisher.php
|
Publisher.getPagePublishDirectory
|
public function getPagePublishDirectory(Page $page)
{
return $this->getPublishDirectory().
rtrim(DIRECTORY_SEPARATOR.$page->getSubFolder(), DIRECTORY_SEPARATOR);
}
|
php
|
public function getPagePublishDirectory(Page $page)
{
return $this->getPublishDirectory().
rtrim(DIRECTORY_SEPARATOR.$page->getSubFolder(), DIRECTORY_SEPARATOR);
}
|
[
"public",
"function",
"getPagePublishDirectory",
"(",
"Page",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"getPublishDirectory",
"(",
")",
".",
"rtrim",
"(",
"DIRECTORY_SEPARATOR",
".",
"$",
"page",
"->",
"getSubFolder",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"}"
] |
Return the directory to which the page should be published.
@return string
|
[
"Return",
"the",
"directory",
"to",
"which",
"the",
"page",
"should",
"be",
"published",
"."
] |
2c7a7da1c3a04e10463c956722f85f5da13dc179
|
https://github.com/jamesmcfadden/gen/blob/2c7a7da1c3a04e10463c956722f85f5da13dc179/src/Publisher.php#L237-L241
|
239,846
|
jamesmcfadden/gen
|
src/Publisher.php
|
Publisher.getPagePublishPath
|
public function getPagePublishPath(Page $page)
{
return $this->getPagePublishDirectory($page).
DIRECTORY_SEPARATOR.
$this->getPagePublishFilename($page);
}
|
php
|
public function getPagePublishPath(Page $page)
{
return $this->getPagePublishDirectory($page).
DIRECTORY_SEPARATOR.
$this->getPagePublishFilename($page);
}
|
[
"public",
"function",
"getPagePublishPath",
"(",
"Page",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"getPagePublishDirectory",
"(",
"$",
"page",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getPagePublishFilename",
"(",
"$",
"page",
")",
";",
"}"
] |
Return the full page publish path.
@return string
|
[
"Return",
"the",
"full",
"page",
"publish",
"path",
"."
] |
2c7a7da1c3a04e10463c956722f85f5da13dc179
|
https://github.com/jamesmcfadden/gen/blob/2c7a7da1c3a04e10463c956722f85f5da13dc179/src/Publisher.php#L248-L253
|
239,847
|
morrelinko/simple-photo
|
src/Toolbox/PhotoCollection.php
|
PhotoCollection.transform
|
public function transform(\Closure $callback)
{
$this->photos = array_map($callback, $this->photos);
return $this;
}
|
php
|
public function transform(\Closure $callback)
{
$this->photos = array_map($callback, $this->photos);
return $this;
}
|
[
"public",
"function",
"transform",
"(",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"photos",
"=",
"array_map",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"photos",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Executes a callback on each photo in the collection
Setting each item to the result from the callback.
@param callable $callback
@return PhotoCollection
|
[
"Executes",
"a",
"callback",
"on",
"each",
"photo",
"in",
"the",
"collection",
"Setting",
"each",
"item",
"to",
"the",
"result",
"from",
"the",
"callback",
"."
] |
be1fbe3139d32eb39e88cff93f847154bb6a8cb2
|
https://github.com/morrelinko/simple-photo/blob/be1fbe3139d32eb39e88cff93f847154bb6a8cb2/src/Toolbox/PhotoCollection.php#L89-L94
|
239,848
|
veridu/idos-sdk-php
|
src/idOS/Endpoint/Company/Settings.php
|
Settings.createNew
|
public function createNew(
string $section,
string $property,
string $value,
bool $protected
) : array {
return $this->sendPost(
sprintf('/companies/%s/settings', $this->companySlug),
[],
[
'section' => $section,
'property' => $property,
'value' => $value,
'protected' => $protected
]
);
}
|
php
|
public function createNew(
string $section,
string $property,
string $value,
bool $protected
) : array {
return $this->sendPost(
sprintf('/companies/%s/settings', $this->companySlug),
[],
[
'section' => $section,
'property' => $property,
'value' => $value,
'protected' => $protected
]
);
}
|
[
"public",
"function",
"createNew",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"property",
",",
"string",
"$",
"value",
",",
"bool",
"$",
"protected",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"sendPost",
"(",
"sprintf",
"(",
"'/companies/%s/settings'",
",",
"$",
"this",
"->",
"companySlug",
")",
",",
"[",
"]",
",",
"[",
"'section'",
"=>",
"$",
"section",
",",
"'property'",
"=>",
"$",
"property",
",",
"'value'",
"=>",
"$",
"value",
",",
"'protected'",
"=>",
"$",
"protected",
"]",
")",
";",
"}"
] |
Creates a new setting for the given company.
@param string $section
@param string $property
@param string $value
@param bool $protected
@return array Response
|
[
"Creates",
"a",
"new",
"setting",
"for",
"the",
"given",
"company",
"."
] |
e56757bed10404756f2f0485a4b7f55794192008
|
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Company/Settings.php#L35-L52
|
239,849
|
phPoirot/Module-Authorization
|
src/Authorization/Guard/GuardRoute.php
|
GuardRoute._verifyIsBannedRoute
|
function _verifyIsBannedRoute($currentRoute)
{
$r = false;
$currentRoute = rtrim($currentRoute, '/');
foreach ($this->routesDenied as $deniedRoute) {
$deniedRoute = rtrim($deniedRoute, '/');
$allowLeft = false;
if (substr($deniedRoute, -1) == '*') {
// remove star
$allowLeft = true;
$deniedRoute = substr($deniedRoute, 0, strlen($deniedRoute) -1 );
}
if ( ($left = str_replace($deniedRoute, '', $currentRoute)) !== $currentRoute ) {
if ($allowLeft || $left == '')
return true;
}
}
return $r;
}
|
php
|
function _verifyIsBannedRoute($currentRoute)
{
$r = false;
$currentRoute = rtrim($currentRoute, '/');
foreach ($this->routesDenied as $deniedRoute) {
$deniedRoute = rtrim($deniedRoute, '/');
$allowLeft = false;
if (substr($deniedRoute, -1) == '*') {
// remove star
$allowLeft = true;
$deniedRoute = substr($deniedRoute, 0, strlen($deniedRoute) -1 );
}
if ( ($left = str_replace($deniedRoute, '', $currentRoute)) !== $currentRoute ) {
if ($allowLeft || $left == '')
return true;
}
}
return $r;
}
|
[
"function",
"_verifyIsBannedRoute",
"(",
"$",
"currentRoute",
")",
"{",
"$",
"r",
"=",
"false",
";",
"$",
"currentRoute",
"=",
"rtrim",
"(",
"$",
"currentRoute",
",",
"'/'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"routesDenied",
"as",
"$",
"deniedRoute",
")",
"{",
"$",
"deniedRoute",
"=",
"rtrim",
"(",
"$",
"deniedRoute",
",",
"'/'",
")",
";",
"$",
"allowLeft",
"=",
"false",
";",
"if",
"(",
"substr",
"(",
"$",
"deniedRoute",
",",
"-",
"1",
")",
"==",
"'*'",
")",
"{",
"// remove star",
"$",
"allowLeft",
"=",
"true",
";",
"$",
"deniedRoute",
"=",
"substr",
"(",
"$",
"deniedRoute",
",",
"0",
",",
"strlen",
"(",
"$",
"deniedRoute",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"(",
"$",
"left",
"=",
"str_replace",
"(",
"$",
"deniedRoute",
",",
"''",
",",
"$",
"currentRoute",
")",
")",
"!==",
"$",
"currentRoute",
")",
"{",
"if",
"(",
"$",
"allowLeft",
"||",
"$",
"left",
"==",
"''",
")",
"return",
"true",
";",
"}",
"}",
"return",
"$",
"r",
";",
"}"
] |
Check given route name is in banned list
@param string $currentRoute
@return bool
|
[
"Check",
"given",
"route",
"name",
"is",
"in",
"banned",
"list"
] |
1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06
|
https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Guard/GuardRoute.php#L162-L183
|
239,850
|
judus/minimal-minimal
|
src/ArrayLoader.php
|
ArrayLoader.minimal
|
public static function minimal(string $filePath = null)
{
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
!is_array($configItems) || Config::items($configItems);
ini_set('error_reporting',
Config::exists('errors.error_reporting', 0));
ini_set('display_errors',
Config::exists('errors.display_errors', 0));
Event::dispatch('minimal.loaded.minimal', [
$filePath,
is_array($configItems) ? $configItems : []
]);
}
}
|
php
|
public static function minimal(string $filePath = null)
{
if (is_file($filePath)) {
/** @noinspection PhpIncludeInspection */
$configItems = require_once $filePath;
!is_array($configItems) || Config::items($configItems);
ini_set('error_reporting',
Config::exists('errors.error_reporting', 0));
ini_set('display_errors',
Config::exists('errors.display_errors', 0));
Event::dispatch('minimal.loaded.minimal', [
$filePath,
is_array($configItems) ? $configItems : []
]);
}
}
|
[
"public",
"static",
"function",
"minimal",
"(",
"string",
"$",
"filePath",
"=",
"null",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"configItems",
"=",
"require_once",
"$",
"filePath",
";",
"!",
"is_array",
"(",
"$",
"configItems",
")",
"||",
"Config",
"::",
"items",
"(",
"$",
"configItems",
")",
";",
"ini_set",
"(",
"'error_reporting'",
",",
"Config",
"::",
"exists",
"(",
"'errors.error_reporting'",
",",
"0",
")",
")",
";",
"ini_set",
"(",
"'display_errors'",
",",
"Config",
"::",
"exists",
"(",
"'errors.display_errors'",
",",
"0",
")",
")",
";",
"Event",
"::",
"dispatch",
"(",
"'minimal.loaded.minimal'",
",",
"[",
"$",
"filePath",
",",
"is_array",
"(",
"$",
"configItems",
")",
"?",
"$",
"configItems",
":",
"[",
"]",
"]",
")",
";",
"}",
"}"
] |
Registers the minimal config file.
It stores the array items from the minimal config file in the Config
object and eventually sets the php.ini error_reporting and display_errors.
@param string|null $filePath
|
[
"Registers",
"the",
"minimal",
"config",
"file",
".",
"It",
"stores",
"the",
"array",
"items",
"from",
"the",
"minimal",
"config",
"file",
"in",
"the",
"Config",
"object",
"and",
"eventually",
"sets",
"the",
"php",
".",
"ini",
"error_reporting",
"and",
"display_errors",
"."
] |
36db55c537175cead2ab412f166bf2574d0f9597
|
https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/ArrayLoader.php#L18-L36
|
239,851
|
jonneyless/yii2-helper-extend
|
helpers/Zip.php
|
Zip.dir
|
public static function dir($sourcePath, $outZipPath)
{
$sourcePath = rtrim($sourcePath, "/");
$zip = new ZipArchive();
$zip->open($outZipPath, ZipArchive::CREATE);
self::folderToZip($sourcePath, $zip, strlen($sourcePath . "/"));
$zip->close();
}
|
php
|
public static function dir($sourcePath, $outZipPath)
{
$sourcePath = rtrim($sourcePath, "/");
$zip = new ZipArchive();
$zip->open($outZipPath, ZipArchive::CREATE);
self::folderToZip($sourcePath, $zip, strlen($sourcePath . "/"));
$zip->close();
}
|
[
"public",
"static",
"function",
"dir",
"(",
"$",
"sourcePath",
",",
"$",
"outZipPath",
")",
"{",
"$",
"sourcePath",
"=",
"rtrim",
"(",
"$",
"sourcePath",
",",
"\"/\"",
")",
";",
"$",
"zip",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"$",
"zip",
"->",
"open",
"(",
"$",
"outZipPath",
",",
"ZipArchive",
"::",
"CREATE",
")",
";",
"self",
"::",
"folderToZip",
"(",
"$",
"sourcePath",
",",
"$",
"zip",
",",
"strlen",
"(",
"$",
"sourcePath",
".",
"\"/\"",
")",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"}"
] |
Zip a folder
@param string $sourcePath Path of directory to be zip.
@param string $outZipPath Path of output zip file.
|
[
"Zip",
"a",
"folder"
] |
1c1afa051e219865f52d40c728c0a95f1ae54106
|
https://github.com/jonneyless/yii2-helper-extend/blob/1c1afa051e219865f52d40c728c0a95f1ae54106/helpers/Zip.php#L20-L27
|
239,852
|
dshovchko/debulog
|
src/Logger.php
|
Logger.add
|
public function add($message)
{
$this->_messages[] = $this->log_timestamp() . $message . PHP_EOL;
$this->debug($message);
}
|
php
|
public function add($message)
{
$this->_messages[] = $this->log_timestamp() . $message . PHP_EOL;
$this->debug($message);
}
|
[
"public",
"function",
"add",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"_messages",
"[",
"]",
"=",
"$",
"this",
"->",
"log_timestamp",
"(",
")",
".",
"$",
"message",
".",
"PHP_EOL",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"message",
")",
";",
"}"
] |
Add message to logger buffer
@param string $message Message text
|
[
"Add",
"message",
"to",
"logger",
"buffer"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L70-L74
|
239,853
|
dshovchko/debulog
|
src/Logger.php
|
Logger.error
|
public function error($message)
{
$this->_errors[] = $this->log_timestamp() . $message . PHP_EOL;
$this->debug('ERROR: '.$message);
}
|
php
|
public function error($message)
{
$this->_errors[] = $this->log_timestamp() . $message . PHP_EOL;
$this->debug('ERROR: '.$message);
}
|
[
"public",
"function",
"error",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"_errors",
"[",
"]",
"=",
"$",
"this",
"->",
"log_timestamp",
"(",
")",
".",
"$",
"message",
".",
"PHP_EOL",
";",
"$",
"this",
"->",
"debug",
"(",
"'ERROR: '",
".",
"$",
"message",
")",
";",
"}"
] |
Add error message to logger buffer
@param string $message Message text
|
[
"Add",
"error",
"message",
"to",
"logger",
"buffer"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L82-L86
|
239,854
|
dshovchko/debulog
|
src/Logger.php
|
Logger.shutdown
|
public function shutdown()
{
if ($this->ondebug === TRUE)
{
$this->_debugs[] = $this->log_debug_event('end') . PHP_EOL;
}
$this->sync();
}
|
php
|
public function shutdown()
{
if ($this->ondebug === TRUE)
{
$this->_debugs[] = $this->log_debug_event('end') . PHP_EOL;
}
$this->sync();
}
|
[
"public",
"function",
"shutdown",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ondebug",
"===",
"TRUE",
")",
"{",
"$",
"this",
"->",
"_debugs",
"[",
"]",
"=",
"$",
"this",
"->",
"log_debug_event",
"(",
"'end'",
")",
".",
"PHP_EOL",
";",
"}",
"$",
"this",
"->",
"sync",
"(",
")",
";",
"}"
] |
Finish and sync all buffers to files
|
[
"Finish",
"and",
"sync",
"all",
"buffers",
"to",
"files"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L106-L113
|
239,855
|
dshovchko/debulog
|
src/Logger.php
|
Logger.sync
|
public function sync()
{
$this->sync_single_log($this->_messages, '');
$this->sync_single_log($this->_debugs, '_debug');
$this->sync_single_log($this->_errors, '_error');
}
|
php
|
public function sync()
{
$this->sync_single_log($this->_messages, '');
$this->sync_single_log($this->_debugs, '_debug');
$this->sync_single_log($this->_errors, '_error');
}
|
[
"public",
"function",
"sync",
"(",
")",
"{",
"$",
"this",
"->",
"sync_single_log",
"(",
"$",
"this",
"->",
"_messages",
",",
"''",
")",
";",
"$",
"this",
"->",
"sync_single_log",
"(",
"$",
"this",
"->",
"_debugs",
",",
"'_debug'",
")",
";",
"$",
"this",
"->",
"sync_single_log",
"(",
"$",
"this",
"->",
"_errors",
",",
"'_error'",
")",
";",
"}"
] |
Sync all buffers to files
|
[
"Sync",
"all",
"buffers",
"to",
"files"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L118-L123
|
239,856
|
dshovchko/debulog
|
src/Logger.php
|
Logger.sync_single_log
|
protected function sync_single_log(&$buffer, $suffix)
{
if ( ! empty($buffer))
{
$this->write($buffer, $this->dir . $this->prefix . $suffix . '.log');
$buffer = array();
}
}
|
php
|
protected function sync_single_log(&$buffer, $suffix)
{
if ( ! empty($buffer))
{
$this->write($buffer, $this->dir . $this->prefix . $suffix . '.log');
$buffer = array();
}
}
|
[
"protected",
"function",
"sync_single_log",
"(",
"&",
"$",
"buffer",
",",
"$",
"suffix",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"buffer",
")",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"$",
"buffer",
",",
"$",
"this",
"->",
"dir",
".",
"$",
"this",
"->",
"prefix",
".",
"$",
"suffix",
".",
"'.log'",
")",
";",
"$",
"buffer",
"=",
"array",
"(",
")",
";",
"}",
"}"
] |
Sync specific buffer to file
@param array $buffer
@param string $suffix log filename suffix
|
[
"Sync",
"specific",
"buffer",
"to",
"file"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L131-L138
|
239,857
|
dshovchko/debulog
|
src/Logger.php
|
Logger.write
|
protected function write($messages, $file)
{
$f = @fopen($file, 'a');
if ($f === false)
{
throw new \Exception("Logfile $file is not writeable!");
}
foreach($messages as $msg)
{
fwrite($f, $msg);
}
fclose($f);
}
|
php
|
protected function write($messages, $file)
{
$f = @fopen($file, 'a');
if ($f === false)
{
throw new \Exception("Logfile $file is not writeable!");
}
foreach($messages as $msg)
{
fwrite($f, $msg);
}
fclose($f);
}
|
[
"protected",
"function",
"write",
"(",
"$",
"messages",
",",
"$",
"file",
")",
"{",
"$",
"f",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"'a'",
")",
";",
"if",
"(",
"$",
"f",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Logfile $file is not writeable!\"",
")",
";",
"}",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"msg",
")",
"{",
"fwrite",
"(",
"$",
"f",
",",
"$",
"msg",
")",
";",
"}",
"fclose",
"(",
"$",
"f",
")",
";",
"}"
] |
Write text to file
@param array $messages
@param string $file
@throws Exception
|
[
"Write",
"text",
"to",
"file"
] |
eb48c5c409b2ff2b023f6c65c46af3364ae98e7e
|
https://github.com/dshovchko/debulog/blob/eb48c5c409b2ff2b023f6c65c46af3364ae98e7e/src/Logger.php#L170-L184
|
239,858
|
cundd/test-flight
|
src/Configuration/ConfigurationProvider.php
|
ConfigurationProvider.setConfiguration
|
public function setConfiguration(array $configuration): ConfigurationProviderInterface
{
if (isset($configuration['configuration']) && $configuration['configuration']) {
$configuration = array_merge(
$configuration,
$this->load($configuration['configuration']),
array_filter($configuration)
);
}
$this->configuration = $configuration;
return $this;
}
|
php
|
public function setConfiguration(array $configuration): ConfigurationProviderInterface
{
if (isset($configuration['configuration']) && $configuration['configuration']) {
$configuration = array_merge(
$configuration,
$this->load($configuration['configuration']),
array_filter($configuration)
);
}
$this->configuration = $configuration;
return $this;
}
|
[
"public",
"function",
"setConfiguration",
"(",
"array",
"$",
"configuration",
")",
":",
"ConfigurationProviderInterface",
"{",
"if",
"(",
"isset",
"(",
"$",
"configuration",
"[",
"'configuration'",
"]",
")",
"&&",
"$",
"configuration",
"[",
"'configuration'",
"]",
")",
"{",
"$",
"configuration",
"=",
"array_merge",
"(",
"$",
"configuration",
",",
"$",
"this",
"->",
"load",
"(",
"$",
"configuration",
"[",
"'configuration'",
"]",
")",
",",
"array_filter",
"(",
"$",
"configuration",
")",
")",
";",
"}",
"$",
"this",
"->",
"configuration",
"=",
"$",
"configuration",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the underlying configuration
@param array $configuration
@return ConfigurationProviderInterface
|
[
"Sets",
"the",
"underlying",
"configuration"
] |
9d8424dfb586f823f9dad2dcb81ff3986e255d56
|
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Configuration/ConfigurationProvider.php#L40-L53
|
239,859
|
droid-php/droid-mysql
|
src/Db/Config.php
|
Config.initConnectionData
|
protected function initConnectionData()
{
if ($this->connectionData) {
return;
}
if (!$this->connectionUrl) {
throw new \UnexpectedValueException(
'Expected a connectionUrl, got nowt.'
);
}
$parsed = parse_url($this->connectionUrl);
if ($parsed === false) {
throw new UnexpectedValueException(
'Expected a sensible connectionUrl, got nowt but rubbish.'
);
}
$this->connectionData = $parsed;
}
|
php
|
protected function initConnectionData()
{
if ($this->connectionData) {
return;
}
if (!$this->connectionUrl) {
throw new \UnexpectedValueException(
'Expected a connectionUrl, got nowt.'
);
}
$parsed = parse_url($this->connectionUrl);
if ($parsed === false) {
throw new UnexpectedValueException(
'Expected a sensible connectionUrl, got nowt but rubbish.'
);
}
$this->connectionData = $parsed;
}
|
[
"protected",
"function",
"initConnectionData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connectionData",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"connectionUrl",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Expected a connectionUrl, got nowt.'",
")",
";",
"}",
"$",
"parsed",
"=",
"parse_url",
"(",
"$",
"this",
"->",
"connectionUrl",
")",
";",
"if",
"(",
"$",
"parsed",
"===",
"false",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Expected a sensible connectionUrl, got nowt but rubbish.'",
")",
";",
"}",
"$",
"this",
"->",
"connectionData",
"=",
"$",
"parsed",
";",
"}"
] |
Parse a connection url and populate connectionData with the result.
@throws \UnexpectedValueException
|
[
"Parse",
"a",
"connection",
"url",
"and",
"populate",
"connectionData",
"with",
"the",
"result",
"."
] |
d363ec067495073469a25b48b97d460b6fba938a
|
https://github.com/droid-php/droid-mysql/blob/d363ec067495073469a25b48b97d460b6fba938a/src/Db/Config.php#L102-L121
|
239,860
|
PHPComponent/AtomicFile
|
src/AtomicFileReader.php
|
AtomicFileReader.readFileLine
|
public function readFileLine($length = null)
{
$this->openFile();
//gets warning "fgets(): Length parameter must be greater than 0" when parameter is null and is passed to function
if($length === null)
{
$line = fgets($this->getFile());
}
else
{
$line = fgets($this->getFile(), $length);
}
return $line;
}
|
php
|
public function readFileLine($length = null)
{
$this->openFile();
//gets warning "fgets(): Length parameter must be greater than 0" when parameter is null and is passed to function
if($length === null)
{
$line = fgets($this->getFile());
}
else
{
$line = fgets($this->getFile(), $length);
}
return $line;
}
|
[
"public",
"function",
"readFileLine",
"(",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"openFile",
"(",
")",
";",
"//gets warning \"fgets(): Length parameter must be greater than 0\" when parameter is null and is passed to function",
"if",
"(",
"$",
"length",
"===",
"null",
")",
"{",
"$",
"line",
"=",
"fgets",
"(",
"$",
"this",
"->",
"getFile",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"line",
"=",
"fgets",
"(",
"$",
"this",
"->",
"getFile",
"(",
")",
",",
"$",
"length",
")",
";",
"}",
"return",
"$",
"line",
";",
"}"
] |
Read line from file
@param null|int $length
@return bool|string
|
[
"Read",
"line",
"from",
"file"
] |
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
|
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileReader.php#L86-L100
|
239,861
|
slickframework/orm
|
src/Mapper/Relation/RelationsUtilityMethods.php
|
RelationsUtilityMethods.getParentRepository
|
public function getParentRepository()
{
if (null == $this->parentRepository) {
$this->setParentRepository(
Orm::getRepository($this->getParentEntity())
);
}
return $this->parentRepository;
}
|
php
|
public function getParentRepository()
{
if (null == $this->parentRepository) {
$this->setParentRepository(
Orm::getRepository($this->getParentEntity())
);
}
return $this->parentRepository;
}
|
[
"public",
"function",
"getParentRepository",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"parentRepository",
")",
"{",
"$",
"this",
"->",
"setParentRepository",
"(",
"Orm",
"::",
"getRepository",
"(",
"$",
"this",
"->",
"getParentEntity",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parentRepository",
";",
"}"
] |
Gets parent entity repository
@return \Slick\Orm\Repository\EntityRepository
|
[
"Gets",
"parent",
"entity",
"repository"
] |
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
|
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/RelationsUtilityMethods.php#L63-L71
|
239,862
|
calgamo/collection
|
src/Queue.php
|
Queue.dequeue
|
public function dequeue(&$item) : Queue
{
$values = $this->_shift($item);
$this->setValues($values);
return $this;
}
|
php
|
public function dequeue(&$item) : Queue
{
$values = $this->_shift($item);
$this->setValues($values);
return $this;
}
|
[
"public",
"function",
"dequeue",
"(",
"&",
"$",
"item",
")",
":",
"Queue",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"_shift",
"(",
"$",
"item",
")",
";",
"$",
"this",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Take item from the queue
@param mixed &$item
@return Queue
|
[
"Take",
"item",
"from",
"the",
"queue"
] |
65b2efa612bc8250cbe0e1749c7d77176bd0c3c5
|
https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Queue.php#L28-L33
|
239,863
|
calgamo/collection
|
src/Queue.php
|
Queue.enqueue
|
public function enqueue(... $items) : Queue
{
$values = $this->_pushAll($items);
$this->setValues($values);
return $this;
}
|
php
|
public function enqueue(... $items) : Queue
{
$values = $this->_pushAll($items);
$this->setValues($values);
return $this;
}
|
[
"public",
"function",
"enqueue",
"(",
"...",
"$",
"items",
")",
":",
"Queue",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"_pushAll",
"(",
"$",
"items",
")",
";",
"$",
"this",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add item to the queue
@param mixed $items
@return Queue
|
[
"Add",
"item",
"to",
"the",
"queue"
] |
65b2efa612bc8250cbe0e1749c7d77176bd0c3c5
|
https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Queue.php#L42-L47
|
239,864
|
kambo-1st/HttpMessage
|
src/Message.php
|
Message.normalizeBody
|
private function normalizeBody($body = null)
{
$body = $body ? $body : new Stream(fopen('php://temp', 'r+'));
if (is_string($body)) {
$memoryStream = fopen('php://temp', 'r+');
fwrite($memoryStream, $body);
rewind($memoryStream);
$body = new Stream($memoryStream);
} elseif (!($body instanceof StreamInterface)) {
throw new InvalidArgumentException(
'Body must be a string, null or implement Psr\Http\Message\StreamInterface'
);
}
return $body;
}
|
php
|
private function normalizeBody($body = null)
{
$body = $body ? $body : new Stream(fopen('php://temp', 'r+'));
if (is_string($body)) {
$memoryStream = fopen('php://temp', 'r+');
fwrite($memoryStream, $body);
rewind($memoryStream);
$body = new Stream($memoryStream);
} elseif (!($body instanceof StreamInterface)) {
throw new InvalidArgumentException(
'Body must be a string, null or implement Psr\Http\Message\StreamInterface'
);
}
return $body;
}
|
[
"private",
"function",
"normalizeBody",
"(",
"$",
"body",
"=",
"null",
")",
"{",
"$",
"body",
"=",
"$",
"body",
"?",
"$",
"body",
":",
"new",
"Stream",
"(",
"fopen",
"(",
"'php://temp'",
",",
"'r+'",
")",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"body",
")",
")",
"{",
"$",
"memoryStream",
"=",
"fopen",
"(",
"'php://temp'",
",",
"'r+'",
")",
";",
"fwrite",
"(",
"$",
"memoryStream",
",",
"$",
"body",
")",
";",
"rewind",
"(",
"$",
"memoryStream",
")",
";",
"$",
"body",
"=",
"new",
"Stream",
"(",
"$",
"memoryStream",
")",
";",
"}",
"elseif",
"(",
"!",
"(",
"$",
"body",
"instanceof",
"StreamInterface",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Body must be a string, null or implement Psr\\Http\\Message\\StreamInterface'",
")",
";",
"}",
"return",
"$",
"body",
";",
"}"
] |
Normalize provided body and ensure that the result object is Stream.
@param StreamInterface|string|null $body The request body object
@return Stream Normalized body
@throws \InvalidArgumentException If an unsupported argument type is provided.
|
[
"Normalize",
"provided",
"body",
"and",
"ensure",
"that",
"the",
"result",
"object",
"is",
"Stream",
"."
] |
38877b9d895f279fdd5bdf957d8f23f9808a940a
|
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Message.php#L325-L340
|
239,865
|
kambo-1st/HttpMessage
|
src/Message.php
|
Message.normalizeHeaders
|
private function normalizeHeaders($headers)
{
if (is_array($headers)) {
$headers = new Headers($headers);
} elseif (!($headers instanceof Headers)) {
throw new InvalidArgumentException(
'Headers must be an array or instance of Headers'
);
}
return $headers;
}
|
php
|
private function normalizeHeaders($headers)
{
if (is_array($headers)) {
$headers = new Headers($headers);
} elseif (!($headers instanceof Headers)) {
throw new InvalidArgumentException(
'Headers must be an array or instance of Headers'
);
}
return $headers;
}
|
[
"private",
"function",
"normalizeHeaders",
"(",
"$",
"headers",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"=",
"new",
"Headers",
"(",
"$",
"headers",
")",
";",
"}",
"elseif",
"(",
"!",
"(",
"$",
"headers",
"instanceof",
"Headers",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Headers must be an array or instance of Headers'",
")",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Normalize provided headers and ensure that the result object is Headers.
@param Headers|array $headers The request body object
@return Headers Normalized headers
@throws \InvalidArgumentException If an unsupported argument type is provided.
|
[
"Normalize",
"provided",
"headers",
"and",
"ensure",
"that",
"the",
"result",
"object",
"is",
"Headers",
"."
] |
38877b9d895f279fdd5bdf957d8f23f9808a940a
|
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Message.php#L351-L362
|
239,866
|
kambo-1st/HttpMessage
|
src/Message.php
|
Message.validateProtocol
|
private function validateProtocol($version)
{
$valid = [
'1.0' => true,
'1.1' => true,
'2.0' => true,
];
if (!isset($valid[$version])) {
throw new InvalidArgumentException('Invalid HTTP version. Must be one of: 1.0, 1.1, 2.0');
}
}
|
php
|
private function validateProtocol($version)
{
$valid = [
'1.0' => true,
'1.1' => true,
'2.0' => true,
];
if (!isset($valid[$version])) {
throw new InvalidArgumentException('Invalid HTTP version. Must be one of: 1.0, 1.1, 2.0');
}
}
|
[
"private",
"function",
"validateProtocol",
"(",
"$",
"version",
")",
"{",
"$",
"valid",
"=",
"[",
"'1.0'",
"=>",
"true",
",",
"'1.1'",
"=>",
"true",
",",
"'2.0'",
"=>",
"true",
",",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"valid",
"[",
"$",
"version",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid HTTP version. Must be one of: 1.0, 1.1, 2.0'",
")",
";",
"}",
"}"
] |
Validate version of the HTTP protocol.
@param string $version Version of the HTTP protocol.
@throws \InvalidArgumentException When the protocol version is not valid.
|
[
"Validate",
"version",
"of",
"the",
"HTTP",
"protocol",
"."
] |
38877b9d895f279fdd5bdf957d8f23f9808a940a
|
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Message.php#L385-L396
|
239,867
|
teamelf/core
|
src/Extension/ExtensionManager.php
|
ExtensionManager.getPackages
|
public function getPackages()
{
$filename = $this->vendorPath . '/composer/installed.json';
if (!file_exists($filename)) {
throw new Exception($filename . ' not exists!');
}
$packages = [];
foreach (json_decode(file_get_contents($filename), true) as $package) {
if ($package['type'] === 'teamelf-extension') {
$packages[] = $package;
}
}
return $packages;
}
|
php
|
public function getPackages()
{
$filename = $this->vendorPath . '/composer/installed.json';
if (!file_exists($filename)) {
throw new Exception($filename . ' not exists!');
}
$packages = [];
foreach (json_decode(file_get_contents($filename), true) as $package) {
if ($package['type'] === 'teamelf-extension') {
$packages[] = $package;
}
}
return $packages;
}
|
[
"public",
"function",
"getPackages",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"vendorPath",
".",
"'/composer/installed.json'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"filename",
".",
"' not exists!'",
")",
";",
"}",
"$",
"packages",
"=",
"[",
"]",
";",
"foreach",
"(",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
",",
"true",
")",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"$",
"package",
"[",
"'type'",
"]",
"===",
"'teamelf-extension'",
")",
"{",
"$",
"packages",
"[",
"]",
"=",
"$",
"package",
";",
"}",
"}",
"return",
"$",
"packages",
";",
"}"
] |
get install packages
@return array
@throws Exception
|
[
"get",
"install",
"packages"
] |
653fc6e27f42239c2a8998a5fea325480e9dd39e
|
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Extension/ExtensionManager.php#L50-L63
|
239,868
|
teamelf/core
|
src/Extension/ExtensionManager.php
|
ExtensionManager.load
|
public function load()
{
$this->extensions = [];
foreach ($this->getPackages() as $package) {
[$v, $p] = explode('/', $package['name']);
$extension = Extension::findBy([
'vendor' => $v,
'package' => $p
]);
if (!$extension) {
$extension = (new Extension())
->vendor($v)
->package($p);
}
$extension
->version($package['version'] ?? '')
->description($package['description'] ?? '')
->save();
$this->extensions[] = $extension;
}
return $this;
}
|
php
|
public function load()
{
$this->extensions = [];
foreach ($this->getPackages() as $package) {
[$v, $p] = explode('/', $package['name']);
$extension = Extension::findBy([
'vendor' => $v,
'package' => $p
]);
if (!$extension) {
$extension = (new Extension())
->vendor($v)
->package($p);
}
$extension
->version($package['version'] ?? '')
->description($package['description'] ?? '')
->save();
$this->extensions[] = $extension;
}
return $this;
}
|
[
"public",
"function",
"load",
"(",
")",
"{",
"$",
"this",
"->",
"extensions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPackages",
"(",
")",
"as",
"$",
"package",
")",
"{",
"[",
"$",
"v",
",",
"$",
"p",
"]",
"=",
"explode",
"(",
"'/'",
",",
"$",
"package",
"[",
"'name'",
"]",
")",
";",
"$",
"extension",
"=",
"Extension",
"::",
"findBy",
"(",
"[",
"'vendor'",
"=>",
"$",
"v",
",",
"'package'",
"=>",
"$",
"p",
"]",
")",
";",
"if",
"(",
"!",
"$",
"extension",
")",
"{",
"$",
"extension",
"=",
"(",
"new",
"Extension",
"(",
")",
")",
"->",
"vendor",
"(",
"$",
"v",
")",
"->",
"package",
"(",
"$",
"p",
")",
";",
"}",
"$",
"extension",
"->",
"version",
"(",
"$",
"package",
"[",
"'version'",
"]",
"??",
"''",
")",
"->",
"description",
"(",
"$",
"package",
"[",
"'description'",
"]",
"??",
"''",
")",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"extensions",
"[",
"]",
"=",
"$",
"extension",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
sync install packages with extension repository
@return $this
|
[
"sync",
"install",
"packages",
"with",
"extension",
"repository"
] |
653fc6e27f42239c2a8998a5fea325480e9dd39e
|
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Extension/ExtensionManager.php#L70-L91
|
239,869
|
gossi/trixionary
|
src/model/Base/Group.php
|
Group.countSkillGroups
|
public function countSkillGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collSkillGroupsPartial && !$this->isNew();
if (null === $this->collSkillGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collSkillGroups) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getSkillGroups());
}
$query = ChildSkillGroupQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByGroup($this)
->count($con);
}
return count($this->collSkillGroups);
}
|
php
|
public function countSkillGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collSkillGroupsPartial && !$this->isNew();
if (null === $this->collSkillGroups || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collSkillGroups) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getSkillGroups());
}
$query = ChildSkillGroupQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByGroup($this)
->count($con);
}
return count($this->collSkillGroups);
}
|
[
"public",
"function",
"countSkillGroups",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collSkillGroupsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collSkillGroups",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collSkillGroups",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getSkillGroups",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"ChildSkillGroupQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByGroup",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collSkillGroups",
")",
";",
"}"
] |
Returns the number of related SkillGroup objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related SkillGroup objects.
@throws PropelException
|
[
"Returns",
"the",
"number",
"of",
"related",
"SkillGroup",
"objects",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Group.php#L1572-L1595
|
239,870
|
gossi/trixionary
|
src/model/Base/Group.php
|
Group.initSkills
|
public function initSkills()
{
$this->collSkills = new ObjectCollection();
$this->collSkillsPartial = true;
$this->collSkills->setModel('\gossi\trixionary\model\Skill');
}
|
php
|
public function initSkills()
{
$this->collSkills = new ObjectCollection();
$this->collSkillsPartial = true;
$this->collSkills->setModel('\gossi\trixionary\model\Skill');
}
|
[
"public",
"function",
"initSkills",
"(",
")",
"{",
"$",
"this",
"->",
"collSkills",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collSkillsPartial",
"=",
"true",
";",
"$",
"this",
"->",
"collSkills",
"->",
"setModel",
"(",
"'\\gossi\\trixionary\\model\\Skill'",
")",
";",
"}"
] |
Initializes the collSkills crossRef collection.
By default this just sets the collSkills collection to an empty collection (like clearSkills());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@return void
|
[
"Initializes",
"the",
"collSkills",
"crossRef",
"collection",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Group.php#L1695-L1701
|
239,871
|
gossi/trixionary
|
src/model/Base/Group.php
|
Group.countSkills
|
public function countSkills(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collSkillsPartial && !$this->isNew();
if (null === $this->collSkills || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collSkills) {
return 0;
} else {
if ($partial && !$criteria) {
return count($this->getSkills());
}
$query = ChildSkillQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByGroup($this)
->count($con);
}
} else {
return count($this->collSkills);
}
}
|
php
|
public function countSkills(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collSkillsPartial && !$this->isNew();
if (null === $this->collSkills || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collSkills) {
return 0;
} else {
if ($partial && !$criteria) {
return count($this->getSkills());
}
$query = ChildSkillQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByGroup($this)
->count($con);
}
} else {
return count($this->collSkills);
}
}
|
[
"public",
"function",
"countSkills",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collSkillsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collSkills",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collSkills",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getSkills",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"ChildSkillQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByGroup",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"}",
"else",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"collSkills",
")",
";",
"}",
"}"
] |
Gets the number of Skill objects related by a many-to-many relationship
to the current object by way of the kk_trixionary_skill_group cross-reference table.
@param Criteria $criteria Optional query object to filter the query
@param boolean $distinct Set to true to force count distinct
@param ConnectionInterface $con Optional connection object
@return int the number of related Skill objects
|
[
"Gets",
"the",
"number",
"of",
"Skill",
"objects",
"related",
"by",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
"by",
"way",
"of",
"the",
"kk_trixionary_skill_group",
"cross",
"-",
"reference",
"table",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Group.php#L1806-L1830
|
239,872
|
gossi/trixionary
|
src/model/Base/Group.php
|
Group.addSkill
|
public function addSkill(ChildSkill $skill)
{
if ($this->collSkills === null) {
$this->initSkills();
}
if (!$this->getSkills()->contains($skill)) {
// only add it if the **same** object is not already associated
$this->collSkills->push($skill);
$this->doAddSkill($skill);
}
return $this;
}
|
php
|
public function addSkill(ChildSkill $skill)
{
if ($this->collSkills === null) {
$this->initSkills();
}
if (!$this->getSkills()->contains($skill)) {
// only add it if the **same** object is not already associated
$this->collSkills->push($skill);
$this->doAddSkill($skill);
}
return $this;
}
|
[
"public",
"function",
"addSkill",
"(",
"ChildSkill",
"$",
"skill",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collSkills",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initSkills",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getSkills",
"(",
")",
"->",
"contains",
"(",
"$",
"skill",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"collSkills",
"->",
"push",
"(",
"$",
"skill",
")",
";",
"$",
"this",
"->",
"doAddSkill",
"(",
"$",
"skill",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Associate a ChildSkill to this object
through the kk_trixionary_skill_group cross reference table.
@param ChildSkill $skill
@return ChildGroup The current object (for fluent API support)
|
[
"Associate",
"a",
"ChildSkill",
"to",
"this",
"object",
"through",
"the",
"kk_trixionary_skill_group",
"cross",
"reference",
"table",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Group.php#L1839-L1852
|
239,873
|
gossi/trixionary
|
src/model/Base/Group.php
|
Group.removeSkill
|
public function removeSkill(ChildSkill $skill)
{
if ($this->getSkills()->contains($skill)) { $skillGroup = new ChildSkillGroup();
$skillGroup->setSkill($skill);
if ($skill->isGroupsLoaded()) {
//remove the back reference if available
$skill->getGroups()->removeObject($this);
}
$skillGroup->setGroup($this);
$this->removeSkillGroup(clone $skillGroup);
$skillGroup->clear();
$this->collSkills->remove($this->collSkills->search($skill));
if (null === $this->skillsScheduledForDeletion) {
$this->skillsScheduledForDeletion = clone $this->collSkills;
$this->skillsScheduledForDeletion->clear();
}
$this->skillsScheduledForDeletion->push($skill);
}
return $this;
}
|
php
|
public function removeSkill(ChildSkill $skill)
{
if ($this->getSkills()->contains($skill)) { $skillGroup = new ChildSkillGroup();
$skillGroup->setSkill($skill);
if ($skill->isGroupsLoaded()) {
//remove the back reference if available
$skill->getGroups()->removeObject($this);
}
$skillGroup->setGroup($this);
$this->removeSkillGroup(clone $skillGroup);
$skillGroup->clear();
$this->collSkills->remove($this->collSkills->search($skill));
if (null === $this->skillsScheduledForDeletion) {
$this->skillsScheduledForDeletion = clone $this->collSkills;
$this->skillsScheduledForDeletion->clear();
}
$this->skillsScheduledForDeletion->push($skill);
}
return $this;
}
|
[
"public",
"function",
"removeSkill",
"(",
"ChildSkill",
"$",
"skill",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getSkills",
"(",
")",
"->",
"contains",
"(",
"$",
"skill",
")",
")",
"{",
"$",
"skillGroup",
"=",
"new",
"ChildSkillGroup",
"(",
")",
";",
"$",
"skillGroup",
"->",
"setSkill",
"(",
"$",
"skill",
")",
";",
"if",
"(",
"$",
"skill",
"->",
"isGroupsLoaded",
"(",
")",
")",
"{",
"//remove the back reference if available",
"$",
"skill",
"->",
"getGroups",
"(",
")",
"->",
"removeObject",
"(",
"$",
"this",
")",
";",
"}",
"$",
"skillGroup",
"->",
"setGroup",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"removeSkillGroup",
"(",
"clone",
"$",
"skillGroup",
")",
";",
"$",
"skillGroup",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"collSkills",
"->",
"remove",
"(",
"$",
"this",
"->",
"collSkills",
"->",
"search",
"(",
"$",
"skill",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"skillsScheduledForDeletion",
")",
"{",
"$",
"this",
"->",
"skillsScheduledForDeletion",
"=",
"clone",
"$",
"this",
"->",
"collSkills",
";",
"$",
"this",
"->",
"skillsScheduledForDeletion",
"->",
"clear",
"(",
")",
";",
"}",
"$",
"this",
"->",
"skillsScheduledForDeletion",
"->",
"push",
"(",
"$",
"skill",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove skill of this object
through the kk_trixionary_skill_group cross reference table.
@param ChildSkill $skill
@return ChildGroup The current object (for fluent API support)
|
[
"Remove",
"skill",
"of",
"this",
"object",
"through",
"the",
"kk_trixionary_skill_group",
"cross",
"reference",
"table",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Group.php#L1886-L1912
|
239,874
|
WellCommerce/DataGrid
|
Configuration/EventHandlers.php
|
EventHandlers.get
|
public function get(string $name) : EventHandlerInterface
{
if (!isset($this->eventHandlers[$name])) {
throw new \InvalidArgumentException(sprintf('DataGrid event handler %s not found', $name));
}
return $this->eventHandlers[$name];
}
|
php
|
public function get(string $name) : EventHandlerInterface
{
if (!isset($this->eventHandlers[$name])) {
throw new \InvalidArgumentException(sprintf('DataGrid event handler %s not found', $name));
}
return $this->eventHandlers[$name];
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
":",
"EventHandlerInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventHandlers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'DataGrid event handler %s not found'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"eventHandlers",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns chosen event handler by its function name
@param $name
@return EventHandlerInterface
@throws \InvalidArgumentException
|
[
"Returns",
"chosen",
"event",
"handler",
"by",
"its",
"function",
"name"
] |
5ce3cd47c7902aaeb07c343a76574399286f56ff
|
https://github.com/WellCommerce/DataGrid/blob/5ce3cd47c7902aaeb07c343a76574399286f56ff/Configuration/EventHandlers.php#L77-L84
|
239,875
|
aruberutochan/repository
|
src/Http/Controllers/AbstractController.php
|
AbstractController.makeRequest
|
protected function makeRequest($type) {
if(isset($this->{$type . 'Request'}) && $this->{$type . 'Request'}) {
$request = app()->make($this->{$type . 'Request'});
if (!$request instanceof Request) {
throw new \Exception("Class {$this->{$type . 'Request'}} must be an instance of Illuminate\\Http\\Request");
}
return $request;
}
}
|
php
|
protected function makeRequest($type) {
if(isset($this->{$type . 'Request'}) && $this->{$type . 'Request'}) {
$request = app()->make($this->{$type . 'Request'});
if (!$request instanceof Request) {
throw new \Exception("Class {$this->{$type . 'Request'}} must be an instance of Illuminate\\Http\\Request");
}
return $request;
}
}
|
[
"protected",
"function",
"makeRequest",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
".",
"'Request'",
"}",
")",
"&&",
"$",
"this",
"->",
"{",
"$",
"type",
".",
"'Request'",
"}",
")",
"{",
"$",
"request",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
".",
"'Request'",
"}",
")",
";",
"if",
"(",
"!",
"$",
"request",
"instanceof",
"Request",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Class {$this->{$type . 'Request'}} must be an instance of Illuminate\\\\Http\\\\Request\"",
")",
";",
"}",
"return",
"$",
"request",
";",
"}",
"}"
] |
Create a FormRequest declared in property type
@param string $type
@return Illuminate\Http\Request | void
|
[
"Create",
"a",
"FormRequest",
"declared",
"in",
"property",
"type"
] |
4ecc5eb37377af8f000af76c886c217479dcf454
|
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Http/Controllers/AbstractController.php#L15-L25
|
239,876
|
aruberutochan/repository
|
src/Http/Controllers/AbstractController.php
|
AbstractController.maybeMakeResource
|
protected function maybeMakeResource($type, $data, $status = 200) {
$resourceName = $type . 'Resource';
if(isset($this->$resourceName) && $this->$resourceName) {
$class = $this->$resourceName;
return (new $class($data))->response()
->setStatusCode($status);
} elseif(is_bool($data)){
return strval($data);
} else {
return $data;
}
}
|
php
|
protected function maybeMakeResource($type, $data, $status = 200) {
$resourceName = $type . 'Resource';
if(isset($this->$resourceName) && $this->$resourceName) {
$class = $this->$resourceName;
return (new $class($data))->response()
->setStatusCode($status);
} elseif(is_bool($data)){
return strval($data);
} else {
return $data;
}
}
|
[
"protected",
"function",
"maybeMakeResource",
"(",
"$",
"type",
",",
"$",
"data",
",",
"$",
"status",
"=",
"200",
")",
"{",
"$",
"resourceName",
"=",
"$",
"type",
".",
"'Resource'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"resourceName",
")",
"&&",
"$",
"this",
"->",
"$",
"resourceName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"$",
"resourceName",
";",
"return",
"(",
"new",
"$",
"class",
"(",
"$",
"data",
")",
")",
"->",
"response",
"(",
")",
"->",
"setStatusCode",
"(",
"$",
"status",
")",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"data",
")",
")",
"{",
"return",
"strval",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"return",
"$",
"data",
";",
"}",
"}"
] |
If is defined return a Api Resource object
@param string $type
@param collection $data
@return Resource | Model
|
[
"If",
"is",
"defined",
"return",
"a",
"Api",
"Resource",
"object"
] |
4ecc5eb37377af8f000af76c886c217479dcf454
|
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Http/Controllers/AbstractController.php#L34-L45
|
239,877
|
smeeckaert/di
|
src/DI/AutoBuild.php
|
AutoBuild.getDefaultParameters
|
public static function getDefaultParameters($className)
{
if (!isset(static::$registeredClasses[$className])) {
return null;
}
$params = static::$registeredClasses[$className];
if (is_callable($params)) {
$params = $params();
}
return $params;
}
|
php
|
public static function getDefaultParameters($className)
{
if (!isset(static::$registeredClasses[$className])) {
return null;
}
$params = static::$registeredClasses[$className];
if (is_callable($params)) {
$params = $params();
}
return $params;
}
|
[
"public",
"static",
"function",
"getDefaultParameters",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"registeredClasses",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"params",
"=",
"static",
"::",
"$",
"registeredClasses",
"[",
"$",
"className",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"$",
"params",
"(",
")",
";",
"}",
"return",
"$",
"params",
";",
"}"
] |
Get the registered parameters for a given class
@param $className
@return mixed|null
|
[
"Get",
"the",
"registered",
"parameters",
"for",
"a",
"given",
"class"
] |
3d5e3ed20038bed9a42fcd2821970f77112b8d3c
|
https://github.com/smeeckaert/di/blob/3d5e3ed20038bed9a42fcd2821970f77112b8d3c/src/DI/AutoBuild.php#L42-L52
|
239,878
|
smeeckaert/di
|
src/DI/AutoBuild.php
|
AutoBuild.getInstance
|
public static function getInstance($className)
{
if (!isset(static::$registeredClasses[$className])) {
return null;
}
/** @var DI $object */
$object = $className::build()->auto();
return $object;
}
|
php
|
public static function getInstance($className)
{
if (!isset(static::$registeredClasses[$className])) {
return null;
}
/** @var DI $object */
$object = $className::build()->auto();
return $object;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"registeredClasses",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"/** @var DI $object */",
"$",
"object",
"=",
"$",
"className",
"::",
"build",
"(",
")",
"->",
"auto",
"(",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Get a new instance of a registered class, returns null if the class is not registered
@param $className
@return DI
|
[
"Get",
"a",
"new",
"instance",
"of",
"a",
"registered",
"class",
"returns",
"null",
"if",
"the",
"class",
"is",
"not",
"registered"
] |
3d5e3ed20038bed9a42fcd2821970f77112b8d3c
|
https://github.com/smeeckaert/di/blob/3d5e3ed20038bed9a42fcd2821970f77112b8d3c/src/DI/AutoBuild.php#L60-L68
|
239,879
|
Xannn94/support
|
src/Providers/AuthorizationServiceProvider.php
|
AuthorizationServiceProvider.defineMany
|
protected function defineMany($gate, $class, array $policies)
{
foreach ($policies as $method => $ability) {
$gate->define($ability, "$class@$method");
}
}
|
php
|
protected function defineMany($gate, $class, array $policies)
{
foreach ($policies as $method => $ability) {
$gate->define($ability, "$class@$method");
}
}
|
[
"protected",
"function",
"defineMany",
"(",
"$",
"gate",
",",
"$",
"class",
",",
"array",
"$",
"policies",
")",
"{",
"foreach",
"(",
"$",
"policies",
"as",
"$",
"method",
"=>",
"$",
"ability",
")",
"{",
"$",
"gate",
"->",
"define",
"(",
"$",
"ability",
",",
"\"$class@$method\"",
")",
";",
"}",
"}"
] |
Define policies.
@param \Illuminate\Contracts\Auth\Access\Gate $gate
@param string $class
@param array $policies
|
[
"Define",
"policies",
"."
] |
92f4da1b0d47b769af3c65cd1d672b68809262c8
|
https://github.com/Xannn94/support/blob/92f4da1b0d47b769af3c65cd1d672b68809262c8/src/Providers/AuthorizationServiceProvider.php#L24-L29
|
239,880
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.normalize
|
public static function normalize($pattern)
{
//normalize the string pattern and return safe pattern for use
return self::$delimiter.trim($pattern, self::$delimiter).self::$delimiter;
}
|
php
|
public static function normalize($pattern)
{
//normalize the string pattern and return safe pattern for use
return self::$delimiter.trim($pattern, self::$delimiter).self::$delimiter;
}
|
[
"public",
"static",
"function",
"normalize",
"(",
"$",
"pattern",
")",
"{",
"//normalize the string pattern and return safe pattern for use",
"return",
"self",
"::",
"$",
"delimiter",
".",
"trim",
"(",
"$",
"pattern",
",",
"self",
"::",
"$",
"delimiter",
")",
".",
"self",
"::",
"$",
"delimiter",
";",
"}"
] |
This method normalizes the regular expression pattern before we use it
@param string $pattern The regular expression string to be used
@return string Normalized/Sanitized regular expression string
@throws This method does not throw an error
|
[
"This",
"method",
"normalizes",
"the",
"regular",
"expression",
"pattern",
"before",
"we",
"use",
"it"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L58-L63
|
239,881
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.sanitize
|
public static function sanitize($string, $mask)
{
//check if the input mask is an array
if( is_array($mask))
{
//assign value to parts
$parts = $mask;
}
//check if $mask is a string
else if( is_string($mask))
{
//divide string into substrings
$parts = str_split($mask);
}
//not any of the above, return the string
else
{
//return string
return $string;
}
//loop through the parts array normalizing each part
foreach ($parts as $part)
{
//normalize the part
$normalized = self::normalize("\\{$part}");
//search string and replace normalized string in place of original string from input $string
$string = preg_replace("{$normalized}m", "\\{$part}", $string);
}
//return the string after sanitizing is complete
return $string;
}
|
php
|
public static function sanitize($string, $mask)
{
//check if the input mask is an array
if( is_array($mask))
{
//assign value to parts
$parts = $mask;
}
//check if $mask is a string
else if( is_string($mask))
{
//divide string into substrings
$parts = str_split($mask);
}
//not any of the above, return the string
else
{
//return string
return $string;
}
//loop through the parts array normalizing each part
foreach ($parts as $part)
{
//normalize the part
$normalized = self::normalize("\\{$part}");
//search string and replace normalized string in place of original string from input $string
$string = preg_replace("{$normalized}m", "\\{$part}", $string);
}
//return the string after sanitizing is complete
return $string;
}
|
[
"public",
"static",
"function",
"sanitize",
"(",
"$",
"string",
",",
"$",
"mask",
")",
"{",
"//check if the input mask is an array",
"if",
"(",
"is_array",
"(",
"$",
"mask",
")",
")",
"{",
"//assign value to parts",
"$",
"parts",
"=",
"$",
"mask",
";",
"}",
"//check if $mask is a string",
"else",
"if",
"(",
"is_string",
"(",
"$",
"mask",
")",
")",
"{",
"//divide string into substrings",
"$",
"parts",
"=",
"str_split",
"(",
"$",
"mask",
")",
";",
"}",
"//not any of the above, return the string ",
"else",
"{",
"//return string",
"return",
"$",
"string",
";",
"}",
"//loop through the parts array normalizing each part",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"//normalize the part",
"$",
"normalized",
"=",
"self",
"::",
"normalize",
"(",
"\"\\\\{$part}\"",
")",
";",
"//search string and replace normalized string in place of original string from input $string",
"$",
"string",
"=",
"preg_replace",
"(",
"\"{$normalized}m\"",
",",
"\"\\\\{$part}\"",
",",
"$",
"string",
")",
";",
"}",
"//return the string after sanitizing is complete",
"return",
"$",
"string",
";",
"}"
] |
This method loops through the characters of a string, replacing them with regualar expression friendly
character representations.
@param string $string The string to be converted
@param string $mask
@return string The string after it has been sanitized
|
[
"This",
"method",
"loops",
"through",
"the",
"characters",
"of",
"a",
"string",
"replacing",
"them",
"with",
"regualar",
"expression",
"friendly",
"character",
"representations",
"."
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L168-L208
|
239,882
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.unique
|
public static function unique($string)
{
//set intitial unique var sting as empty
$unique = '';
//split the string into substrings
$parts = str_split($string);
//loop through the sting parts array removing duplicated characters
foreach ($parts as $part)
{
//add this character if it doesnt exist yet
if( ! strstr($unique, $part) )
{
//add this character to the main unique array
$unique .= $part;
}
}
//return the unique string
return $unique;
}
|
php
|
public static function unique($string)
{
//set intitial unique var sting as empty
$unique = '';
//split the string into substrings
$parts = str_split($string);
//loop through the sting parts array removing duplicated characters
foreach ($parts as $part)
{
//add this character if it doesnt exist yet
if( ! strstr($unique, $part) )
{
//add this character to the main unique array
$unique .= $part;
}
}
//return the unique string
return $unique;
}
|
[
"public",
"static",
"function",
"unique",
"(",
"$",
"string",
")",
"{",
"//set intitial unique var sting as empty",
"$",
"unique",
"=",
"''",
";",
"//split the string into substrings",
"$",
"parts",
"=",
"str_split",
"(",
"$",
"string",
")",
";",
"//loop through the sting parts array removing duplicated characters",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"//add this character if it doesnt exist yet",
"if",
"(",
"!",
"strstr",
"(",
"$",
"unique",
",",
"$",
"part",
")",
")",
"{",
"//add this character to the main unique array",
"$",
"unique",
".=",
"$",
"part",
";",
"}",
"}",
"//return the unique string",
"return",
"$",
"unique",
";",
"}"
] |
This method removes duplicates from a string
@param string $string The string for which duplicates are to be removed
@return string String with only unique values
|
[
"This",
"method",
"removes",
"duplicates",
"from",
"a",
"string"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L216-L240
|
239,883
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.indexOf
|
public static function indexOf($string, $substring, $offset = null)
{
//get the position of this string in the main string
$position = strpos($string, $substring, $offset);
//return -1 of the substring was not found
if( ! is_int($position) )
{
//return string position as -1
return -1;
}
//return actual string position if found
return $position;
}
|
php
|
public static function indexOf($string, $substring, $offset = null)
{
//get the position of this string in the main string
$position = strpos($string, $substring, $offset);
//return -1 of the substring was not found
if( ! is_int($position) )
{
//return string position as -1
return -1;
}
//return actual string position if found
return $position;
}
|
[
"public",
"static",
"function",
"indexOf",
"(",
"$",
"string",
",",
"$",
"substring",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"//get the position of this string in the main string",
"$",
"position",
"=",
"strpos",
"(",
"$",
"string",
",",
"$",
"substring",
",",
"$",
"offset",
")",
";",
"//return -1 of the substring was not found",
"if",
"(",
"!",
"is_int",
"(",
"$",
"position",
")",
")",
"{",
"//return string position as -1",
"return",
"-",
"1",
";",
"}",
"//return actual string position if found",
"return",
"$",
"position",
";",
"}"
] |
This method determines substrings within larger strings
@param string $string The main sting against which to check for substring
@param string $substring The substring to check for
@param int $offset The offset value to start from
@return int The position of the substring in the main string
|
[
"This",
"method",
"determines",
"substrings",
"within",
"larger",
"strings"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L250-L265
|
239,884
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.singular
|
public static function singular($string)
{
//assing the input string to a result variable
$result = $string;
//loop through the array of singular patterns, getting the regular exppression patters
foreach ($self::$singulars as $rule => $replacement)
{
//get the regular expression friendly pattern
$rule = self::normalize($rule);
//check if there is a matching pattern in the input string
if ( preg_match($rule, $string) )
{
//replace with the appropriate string and return
$result = preg_replace($rule, $replacement, $string);
//once a replacement is found, break out of the loop
break;
}
}
//return the result that was found
return $result;
}
|
php
|
public static function singular($string)
{
//assing the input string to a result variable
$result = $string;
//loop through the array of singular patterns, getting the regular exppression patters
foreach ($self::$singulars as $rule => $replacement)
{
//get the regular expression friendly pattern
$rule = self::normalize($rule);
//check if there is a matching pattern in the input string
if ( preg_match($rule, $string) )
{
//replace with the appropriate string and return
$result = preg_replace($rule, $replacement, $string);
//once a replacement is found, break out of the loop
break;
}
}
//return the result that was found
return $result;
}
|
[
"public",
"static",
"function",
"singular",
"(",
"$",
"string",
")",
"{",
"//assing the input string to a result variable",
"$",
"result",
"=",
"$",
"string",
";",
"//loop through the array of singular patterns, getting the regular exppression patters",
"foreach",
"(",
"$",
"self",
"::",
"$",
"singulars",
"as",
"$",
"rule",
"=>",
"$",
"replacement",
")",
"{",
"//get the regular expression friendly pattern",
"$",
"rule",
"=",
"self",
"::",
"normalize",
"(",
"$",
"rule",
")",
";",
"//check if there is a matching pattern in the input string",
"if",
"(",
"preg_match",
"(",
"$",
"rule",
",",
"$",
"string",
")",
")",
"{",
"//replace with the appropriate string and return",
"$",
"result",
"=",
"preg_replace",
"(",
"$",
"rule",
",",
"$",
"replacement",
",",
"$",
"string",
")",
";",
"//once a replacement is found, break out of the loop",
"break",
";",
"}",
"}",
"//return the result that was found",
"return",
"$",
"result",
";",
"}"
] |
This method gets the singular form of an input string
@param string $string The input string for which an singular term is to be found.
@return string The output string after appropriate replacement has been done.
|
[
"This",
"method",
"gets",
"the",
"singular",
"form",
"of",
"an",
"input",
"string"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L328-L355
|
239,885
|
gliverphp/helpers
|
src/StringHelper/StringHelper.php
|
StringHelper.plural
|
public static function plural($string)
{
//assign the input string to a result variable
$result = $string;
//loop through the array of plural patterns, getting the regular exppression friendly pattern
foreach (self::$plurals as $rule => $replacement)
{
//get the regular axpression friendlt pattern
$result = $string;
//check if there is a match for this pattern in the input string
if ( preg_match($rule, $string) )
{
//if match found, replace rule with the replacement string
$result = preg_replace($rule, $replacement, $string);
//break out of loop once match is found
break;
}
}
//return the new string contained in result
return $result;
}
|
php
|
public static function plural($string)
{
//assign the input string to a result variable
$result = $string;
//loop through the array of plural patterns, getting the regular exppression friendly pattern
foreach (self::$plurals as $rule => $replacement)
{
//get the regular axpression friendlt pattern
$result = $string;
//check if there is a match for this pattern in the input string
if ( preg_match($rule, $string) )
{
//if match found, replace rule with the replacement string
$result = preg_replace($rule, $replacement, $string);
//break out of loop once match is found
break;
}
}
//return the new string contained in result
return $result;
}
|
[
"public",
"static",
"function",
"plural",
"(",
"$",
"string",
")",
"{",
"//assign the input string to a result variable",
"$",
"result",
"=",
"$",
"string",
";",
"//loop through the array of plural patterns, getting the regular exppression friendly pattern",
"foreach",
"(",
"self",
"::",
"$",
"plurals",
"as",
"$",
"rule",
"=>",
"$",
"replacement",
")",
"{",
"//get the regular axpression friendlt pattern",
"$",
"result",
"=",
"$",
"string",
";",
"//check if there is a match for this pattern in the input string",
"if",
"(",
"preg_match",
"(",
"$",
"rule",
",",
"$",
"string",
")",
")",
"{",
"//if match found, replace rule with the replacement string",
"$",
"result",
"=",
"preg_replace",
"(",
"$",
"rule",
",",
"$",
"replacement",
",",
"$",
"string",
")",
";",
"//break out of loop once match is found",
"break",
";",
"}",
"}",
"//return the new string contained in result",
"return",
"$",
"result",
";",
"}"
] |
This method gets the plural form of an input string
@param string $string Input string for which to find plural
@return string The output string after chaning to plural
|
[
"This",
"method",
"gets",
"the",
"plural",
"form",
"of",
"an",
"input",
"string"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L363-L390
|
239,886
|
kaecyra/app-common
|
src/ConfigCollection.php
|
ConfigCollection.addConfig
|
public function addConfig(ConfigInterface $config) {
// Add to config list
$this->configs->attach($config);
// If collection is in merge mode, add config data to common store
$this->store->merge($config->dump());
return $this;
}
|
php
|
public function addConfig(ConfigInterface $config) {
// Add to config list
$this->configs->attach($config);
// If collection is in merge mode, add config data to common store
$this->store->merge($config->dump());
return $this;
}
|
[
"public",
"function",
"addConfig",
"(",
"ConfigInterface",
"$",
"config",
")",
"{",
"// Add to config list",
"$",
"this",
"->",
"configs",
"->",
"attach",
"(",
"$",
"config",
")",
";",
"// If collection is in merge mode, add config data to common store",
"$",
"this",
"->",
"store",
"->",
"merge",
"(",
"$",
"config",
"->",
"dump",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a ConfigInterface object to collection
@param \Kaecyra\AppCommon\ConfigInterface $config
@return ConfigCollection
|
[
"Add",
"a",
"ConfigInterface",
"object",
"to",
"collection"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L38-L45
|
239,887
|
kaecyra/app-common
|
src/ConfigCollection.php
|
ConfigCollection.removeConfig
|
public function removeConfig(ConfigInterface $config) {
// If collection is in merge mode, don't permit removing configs (cannot unmerge)
if ($this->merge) {
throw new Exception("Cannot remove configs from merged collection.");
}
$this->configs->detach($config);
return $this;
}
|
php
|
public function removeConfig(ConfigInterface $config) {
// If collection is in merge mode, don't permit removing configs (cannot unmerge)
if ($this->merge) {
throw new Exception("Cannot remove configs from merged collection.");
}
$this->configs->detach($config);
return $this;
}
|
[
"public",
"function",
"removeConfig",
"(",
"ConfigInterface",
"$",
"config",
")",
"{",
"// If collection is in merge mode, don't permit removing configs (cannot unmerge)",
"if",
"(",
"$",
"this",
"->",
"merge",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot remove configs from merged collection.\"",
")",
";",
"}",
"$",
"this",
"->",
"configs",
"->",
"detach",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove ConfigInterface object from collection
@param \Kaecyra\AppCommon\ConfigInterface $config
@return ConfigCollection
|
[
"Remove",
"ConfigInterface",
"object",
"from",
"collection"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L53-L63
|
239,888
|
kaecyra/app-common
|
src/ConfigCollection.php
|
ConfigCollection.addFile
|
public function addFile($file, $writeable = false): ConfigCollection {
$config = FileConfig::load($file, $writeable);
if ($config) {
$this->addConfig($config);
}
return $this;
}
|
php
|
public function addFile($file, $writeable = false): ConfigCollection {
$config = FileConfig::load($file, $writeable);
if ($config) {
$this->addConfig($config);
}
return $this;
}
|
[
"public",
"function",
"addFile",
"(",
"$",
"file",
",",
"$",
"writeable",
"=",
"false",
")",
":",
"ConfigCollection",
"{",
"$",
"config",
"=",
"FileConfig",
"::",
"load",
"(",
"$",
"file",
",",
"$",
"writeable",
")",
";",
"if",
"(",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"addConfig",
"(",
"$",
"config",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a physical config file
@param string $file
@param bool $writeable
@return ConfigCollection
|
[
"Add",
"a",
"physical",
"config",
"file"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L72-L78
|
239,889
|
kaecyra/app-common
|
src/ConfigCollection.php
|
ConfigCollection.addVirtual
|
public function addVirtual($data): ConfigCollection {
$config = VirtualConfig::load($data);
if ($config) {
$this->addConfig($config);
}
return $this;
}
|
php
|
public function addVirtual($data): ConfigCollection {
$config = VirtualConfig::load($data);
if ($config) {
$this->addConfig($config);
}
return $this;
}
|
[
"public",
"function",
"addVirtual",
"(",
"$",
"data",
")",
":",
"ConfigCollection",
"{",
"$",
"config",
"=",
"VirtualConfig",
"::",
"load",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"addConfig",
"(",
"$",
"config",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a virtual config
@param string|array $data
@return ConfigCollection
|
[
"Add",
"a",
"virtual",
"config"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L86-L92
|
239,890
|
kaecyra/app-common
|
src/ConfigCollection.php
|
ConfigCollection.addFolder
|
public function addFolder($folder, $extension): ConfigCollection {
$extLen = strlen($extension);
$files = scandir($folder, SCANDIR_SORT_ASCENDING);
foreach ($files as $file) {
if (in_array($file, ['.','..'])) {
continue;
}
if (substr($file, -$extLen) != $extension) {
continue;
}
$config = FileConfig::load(paths($folder, $file), false);
if ($config) {
$this->addConfig($config);
}
}
return $this;
}
|
php
|
public function addFolder($folder, $extension): ConfigCollection {
$extLen = strlen($extension);
$files = scandir($folder, SCANDIR_SORT_ASCENDING);
foreach ($files as $file) {
if (in_array($file, ['.','..'])) {
continue;
}
if (substr($file, -$extLen) != $extension) {
continue;
}
$config = FileConfig::load(paths($folder, $file), false);
if ($config) {
$this->addConfig($config);
}
}
return $this;
}
|
[
"public",
"function",
"addFolder",
"(",
"$",
"folder",
",",
"$",
"extension",
")",
":",
"ConfigCollection",
"{",
"$",
"extLen",
"=",
"strlen",
"(",
"$",
"extension",
")",
";",
"$",
"files",
"=",
"scandir",
"(",
"$",
"folder",
",",
"SCANDIR_SORT_ASCENDING",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
",",
"[",
"'.'",
",",
"'..'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"-",
"$",
"extLen",
")",
"!=",
"$",
"extension",
")",
"{",
"continue",
";",
"}",
"$",
"config",
"=",
"FileConfig",
"::",
"load",
"(",
"paths",
"(",
"$",
"folder",
",",
"$",
"file",
")",
",",
"false",
")",
";",
"if",
"(",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"addConfig",
"(",
"$",
"config",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a folder of config files
@param string $folder
@param string $extension
@return ConfigCollection
|
[
"Add",
"a",
"folder",
"of",
"config",
"files"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L101-L117
|
239,891
|
arvici/framework
|
src/Arvici/Heart/Cache/Cache.php
|
Cache.getPool
|
public function getPool ($name = 'default')
{
if (isset($this->pools[$name])) {
return $this->pools[$name];
}
throw new NotFoundException('Caching Pool not found with given name \''.$name.'\'');
}
|
php
|
public function getPool ($name = 'default')
{
if (isset($this->pools[$name])) {
return $this->pools[$name];
}
throw new NotFoundException('Caching Pool not found with given name \''.$name.'\'');
}
|
[
"public",
"function",
"getPool",
"(",
"$",
"name",
"=",
"'default'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pools",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pools",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"new",
"NotFoundException",
"(",
"'Caching Pool not found with given name \\''",
".",
"$",
"name",
".",
"'\\''",
")",
";",
"}"
] |
Get pool instance.
@param string $name
@return Pool
@throws NotFoundException
|
[
"Get",
"pool",
"instance",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Cache/Cache.php#L70-L76
|
239,892
|
arvici/framework
|
src/Arvici/Heart/Cache/Cache.php
|
Cache.initiatePools
|
protected function initiatePools ()
{
foreach ($this->configuration['pools'] as $name => $poolConfiguration) {
// Try to get the driver class. Will throw an exception if not exists.
new \ReflectionClass($poolConfiguration['driver']);
$options = $poolConfiguration['options'];
/** @var DriverInterface $driverInstance */
$driverInstance = new $poolConfiguration['driver']($options);
$poolInstance = new Pool($driverInstance, $name);
// Register in the local instance holding variable.
$this->pools[$name] = $poolInstance;
}
}
|
php
|
protected function initiatePools ()
{
foreach ($this->configuration['pools'] as $name => $poolConfiguration) {
// Try to get the driver class. Will throw an exception if not exists.
new \ReflectionClass($poolConfiguration['driver']);
$options = $poolConfiguration['options'];
/** @var DriverInterface $driverInstance */
$driverInstance = new $poolConfiguration['driver']($options);
$poolInstance = new Pool($driverInstance, $name);
// Register in the local instance holding variable.
$this->pools[$name] = $poolInstance;
}
}
|
[
"protected",
"function",
"initiatePools",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'pools'",
"]",
"as",
"$",
"name",
"=>",
"$",
"poolConfiguration",
")",
"{",
"// Try to get the driver class. Will throw an exception if not exists.",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"poolConfiguration",
"[",
"'driver'",
"]",
")",
";",
"$",
"options",
"=",
"$",
"poolConfiguration",
"[",
"'options'",
"]",
";",
"/** @var DriverInterface $driverInstance */",
"$",
"driverInstance",
"=",
"new",
"$",
"poolConfiguration",
"[",
"'driver'",
"]",
"(",
"$",
"options",
")",
";",
"$",
"poolInstance",
"=",
"new",
"Pool",
"(",
"$",
"driverInstance",
",",
"$",
"name",
")",
";",
"// Register in the local instance holding variable.",
"$",
"this",
"->",
"pools",
"[",
"$",
"name",
"]",
"=",
"$",
"poolInstance",
";",
"}",
"}"
] |
Initiate Pools.
|
[
"Initiate",
"Pools",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Cache/Cache.php#L92-L108
|
239,893
|
Bulveyz/Bulveyz
|
src/Bulveyz/Middleware/Middleware.php
|
Middleware.fatalAccess
|
public static function fatalAccess(string $userGroup, string $error)
{
if (!isset($_SESSION[$userGroup])) {
exit($error);
}
}
|
php
|
public static function fatalAccess(string $userGroup, string $error)
{
if (!isset($_SESSION[$userGroup])) {
exit($error);
}
}
|
[
"public",
"static",
"function",
"fatalAccess",
"(",
"string",
"$",
"userGroup",
",",
"string",
"$",
"error",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"userGroup",
"]",
")",
")",
"{",
"exit",
"(",
"$",
"error",
")",
";",
"}",
"}"
] |
Return Fatal Error
|
[
"Return",
"Fatal",
"Error"
] |
62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15
|
https://github.com/Bulveyz/Bulveyz/blob/62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15/src/Bulveyz/Middleware/Middleware.php#L22-L27
|
239,894
|
Bulveyz/Bulveyz
|
src/Bulveyz/Middleware/Middleware.php
|
Middleware.fatalElseAccess
|
public static function fatalElseAccess(string $userGroup, string $error)
{
if (isset($_SESSION[$userGroup])) {
exit($error);
}
}
|
php
|
public static function fatalElseAccess(string $userGroup, string $error)
{
if (isset($_SESSION[$userGroup])) {
exit($error);
}
}
|
[
"public",
"static",
"function",
"fatalElseAccess",
"(",
"string",
"$",
"userGroup",
",",
"string",
"$",
"error",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"userGroup",
"]",
")",
")",
"{",
"exit",
"(",
"$",
"error",
")",
";",
"}",
"}"
] |
Return Fatal Error for one users group
|
[
"Return",
"Fatal",
"Error",
"for",
"one",
"users",
"group"
] |
62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15
|
https://github.com/Bulveyz/Bulveyz/blob/62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15/src/Bulveyz/Middleware/Middleware.php#L38-L43
|
239,895
|
PandaPlatform/helpers
|
ArrayHelper.php
|
ArrayHelper.set
|
public static function set($array, $key, $value = null, $useDotSyntax = false)
{
// Normalize array
$array = $array ?: [];
// Check if key is empty
if (StringHelper::emptyString($key, true)) {
throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty');
}
/**
* Split name using dots.
*
* Just checking whether the key doesn't have any dots
* but $useDotSyntax is true by default.
*/
$keyParts = explode('.', $key);
$useDotSyntax = $useDotSyntax && count($keyParts) > 1;
// Set simple value, without dot syntax
if (!$useDotSyntax) {
if (is_null($value) && isset($array[$key])) {
unset($array[$key]);
} elseif (!is_null($value)) {
$array[$key] = $value;
}
} else {
// Recursive call
$base = $keyParts[0];
unset($keyParts[0]);
// Check if the base array exists
if (!isset($array[$base])) {
$array[$base] = [];
}
// Get key, base array and continue
$key = implode('.', $keyParts);
$innerArray = $array[$base];
$array[$base] = static::set($innerArray, $key, $value, $useDotSyntax);
}
return $array;
}
|
php
|
public static function set($array, $key, $value = null, $useDotSyntax = false)
{
// Normalize array
$array = $array ?: [];
// Check if key is empty
if (StringHelper::emptyString($key, true)) {
throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty');
}
/**
* Split name using dots.
*
* Just checking whether the key doesn't have any dots
* but $useDotSyntax is true by default.
*/
$keyParts = explode('.', $key);
$useDotSyntax = $useDotSyntax && count($keyParts) > 1;
// Set simple value, without dot syntax
if (!$useDotSyntax) {
if (is_null($value) && isset($array[$key])) {
unset($array[$key]);
} elseif (!is_null($value)) {
$array[$key] = $value;
}
} else {
// Recursive call
$base = $keyParts[0];
unset($keyParts[0]);
// Check if the base array exists
if (!isset($array[$base])) {
$array[$base] = [];
}
// Get key, base array and continue
$key = implode('.', $keyParts);
$innerArray = $array[$base];
$array[$base] = static::set($innerArray, $key, $value, $useDotSyntax);
}
return $array;
}
|
[
"public",
"static",
"function",
"set",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"// Normalize array",
"$",
"array",
"=",
"$",
"array",
"?",
":",
"[",
"]",
";",
"// Check if key is empty",
"if",
"(",
"StringHelper",
"::",
"emptyString",
"(",
"$",
"key",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"': Key cannot be empty'",
")",
";",
"}",
"/**\n * Split name using dots.\n *\n * Just checking whether the key doesn't have any dots\n * but $useDotSyntax is true by default.\n */",
"$",
"keyParts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"useDotSyntax",
"=",
"$",
"useDotSyntax",
"&&",
"count",
"(",
"$",
"keyParts",
")",
">",
"1",
";",
"// Set simple value, without dot syntax",
"if",
"(",
"!",
"$",
"useDotSyntax",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"&&",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"// Recursive call",
"$",
"base",
"=",
"$",
"keyParts",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"keyParts",
"[",
"0",
"]",
")",
";",
"// Check if the base array exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"base",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"base",
"]",
"=",
"[",
"]",
";",
"}",
"// Get key, base array and continue",
"$",
"key",
"=",
"implode",
"(",
"'.'",
",",
"$",
"keyParts",
")",
";",
"$",
"innerArray",
"=",
"$",
"array",
"[",
"$",
"base",
"]",
";",
"$",
"array",
"[",
"$",
"base",
"]",
"=",
"static",
"::",
"set",
"(",
"$",
"innerArray",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"useDotSyntax",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Set an item in the given array.
@param array $array
@param string $key
@param mixed $value
@param bool $useDotSyntax
@return array
@throws InvalidArgumentException
|
[
"Set",
"an",
"item",
"in",
"the",
"given",
"array",
"."
] |
a319d861d5e34e24a68a8e6db0c14cba888bc8a2
|
https://github.com/PandaPlatform/helpers/blob/a319d861d5e34e24a68a8e6db0c14cba888bc8a2/ArrayHelper.php#L87-L131
|
239,896
|
EmanueleMinotto/Gravatar
|
Client.php
|
Client.getProfile
|
public function getProfile($email)
{
$url = $this->getProfileUrl($email);
$httpClient = &$this->httpClient;
$response = $httpClient->get($url);
$data = $response->json();
return $data['entry'][0];
}
|
php
|
public function getProfile($email)
{
$url = $this->getProfileUrl($email);
$httpClient = &$this->httpClient;
$response = $httpClient->get($url);
$data = $response->json();
return $data['entry'][0];
}
|
[
"public",
"function",
"getProfile",
"(",
"$",
"email",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getProfileUrl",
"(",
"$",
"email",
")",
";",
"$",
"httpClient",
"=",
"&",
"$",
"this",
"->",
"httpClient",
";",
"$",
"response",
"=",
"$",
"httpClient",
"->",
"get",
"(",
"$",
"url",
")",
";",
"$",
"data",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"return",
"$",
"data",
"[",
"'entry'",
"]",
"[",
"0",
"]",
";",
"}"
] |
Get user profile data.
@param string $email User email.
@return array
|
[
"Get",
"user",
"profile",
"data",
"."
] |
661da058c2348a605393653a72543b7b384ca903
|
https://github.com/EmanueleMinotto/Gravatar/blob/661da058c2348a605393653a72543b7b384ca903/Client.php#L89-L99
|
239,897
|
EmanueleMinotto/Gravatar
|
Client.php
|
Client.getAvatarUrl
|
public function getAvatarUrl($email, $size = 80, $extension = 'jpg', $default = 404, $rating = 'g')
{
$url = 'https://www.gravatar.com/avatar/';
$url .= md5(strtolower(trim($email))).'.'.$extension;
$url .= '?'.http_build_query([
'd' => $default,
'r' => $rating,
's' => $size,
]);
return $url;
}
|
php
|
public function getAvatarUrl($email, $size = 80, $extension = 'jpg', $default = 404, $rating = 'g')
{
$url = 'https://www.gravatar.com/avatar/';
$url .= md5(strtolower(trim($email))).'.'.$extension;
$url .= '?'.http_build_query([
'd' => $default,
'r' => $rating,
's' => $size,
]);
return $url;
}
|
[
"public",
"function",
"getAvatarUrl",
"(",
"$",
"email",
",",
"$",
"size",
"=",
"80",
",",
"$",
"extension",
"=",
"'jpg'",
",",
"$",
"default",
"=",
"404",
",",
"$",
"rating",
"=",
"'g'",
")",
"{",
"$",
"url",
"=",
"'https://www.gravatar.com/avatar/'",
";",
"$",
"url",
".=",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"email",
")",
")",
")",
".",
"'.'",
".",
"$",
"extension",
";",
"$",
"url",
".=",
"'?'",
".",
"http_build_query",
"(",
"[",
"'d'",
"=>",
"$",
"default",
",",
"'r'",
"=>",
"$",
"rating",
",",
"'s'",
"=>",
"$",
"size",
",",
"]",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
Get user avatar image URL.
@param string $email User email.
@param int $size Image size (default 80).
@param string $extension Image extension (default jpg).
@param int $default Error response (default 404).
@param string $rating Image rating (default G).
@return string
|
[
"Get",
"user",
"avatar",
"image",
"URL",
"."
] |
661da058c2348a605393653a72543b7b384ca903
|
https://github.com/EmanueleMinotto/Gravatar/blob/661da058c2348a605393653a72543b7b384ca903/Client.php#L112-L125
|
239,898
|
Opifer/Revisions
|
src/Opifer/Revisions/Mapping/AnnotationReader.php
|
AnnotationReader.get
|
public function get($entity, $annotation)
{
$properties = $this->getProperties($entity);
$return = array();
foreach ($properties as $reflectionProperty) {
$propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $annotation);
if (!is_null($propertyAnnotation) && get_class($propertyAnnotation) == $annotation) {
$return[$reflectionProperty->name] = $reflectionProperty;
}
}
return $return;
}
|
php
|
public function get($entity, $annotation)
{
$properties = $this->getProperties($entity);
$return = array();
foreach ($properties as $reflectionProperty) {
$propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $annotation);
if (!is_null($propertyAnnotation) && get_class($propertyAnnotation) == $annotation) {
$return[$reflectionProperty->name] = $reflectionProperty;
}
}
return $return;
}
|
[
"public",
"function",
"get",
"(",
"$",
"entity",
",",
"$",
"annotation",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getProperties",
"(",
"$",
"entity",
")",
";",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"reflectionProperty",
")",
"{",
"$",
"propertyAnnotation",
"=",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotation",
"(",
"$",
"reflectionProperty",
",",
"$",
"annotation",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"propertyAnnotation",
")",
"&&",
"get_class",
"(",
"$",
"propertyAnnotation",
")",
"==",
"$",
"annotation",
")",
"{",
"$",
"return",
"[",
"$",
"reflectionProperty",
"->",
"name",
"]",
"=",
"$",
"reflectionProperty",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Get annotations by entity and annotation
@param Object $entity
@param string $annotation
@return array
|
[
"Get",
"annotations",
"by",
"entity",
"and",
"annotation"
] |
da1f15a9abcc083c9db7f8459f1af661937454ea
|
https://github.com/Opifer/Revisions/blob/da1f15a9abcc083c9db7f8459f1af661937454ea/src/Opifer/Revisions/Mapping/AnnotationReader.php#L32-L45
|
239,899
|
Opifer/Revisions
|
src/Opifer/Revisions/Mapping/AnnotationReader.php
|
AnnotationReader.all
|
public function all($entity)
{
$reflectionClass = new \ReflectionClass($entity);
$properties = $reflectionClass->getProperties();
$class = new \ReflectionClass($entity);
while ($parent = $class->getParentClass()) {
$parentProperties = $parent->getProperties();
$properties = array_merge($parentProperties, $properties);
$class = $parent;
}
$return = array();
foreach ($properties as $reflectionProperty) {
$propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $this->annotationClass);
if (!is_null($propertyAnnotation) && $propertyAnnotation->listable) {
$return[] = array(
'property' => $reflectionProperty->name,
'type' => $propertyAnnotation->type
);
}
}
return $return;
}
|
php
|
public function all($entity)
{
$reflectionClass = new \ReflectionClass($entity);
$properties = $reflectionClass->getProperties();
$class = new \ReflectionClass($entity);
while ($parent = $class->getParentClass()) {
$parentProperties = $parent->getProperties();
$properties = array_merge($parentProperties, $properties);
$class = $parent;
}
$return = array();
foreach ($properties as $reflectionProperty) {
$propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $this->annotationClass);
if (!is_null($propertyAnnotation) && $propertyAnnotation->listable) {
$return[] = array(
'property' => $reflectionProperty->name,
'type' => $propertyAnnotation->type
);
}
}
return $return;
}
|
[
"public",
"function",
"all",
"(",
"$",
"entity",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entity",
")",
";",
"$",
"properties",
"=",
"$",
"reflectionClass",
"->",
"getProperties",
"(",
")",
";",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entity",
")",
";",
"while",
"(",
"$",
"parent",
"=",
"$",
"class",
"->",
"getParentClass",
"(",
")",
")",
"{",
"$",
"parentProperties",
"=",
"$",
"parent",
"->",
"getProperties",
"(",
")",
";",
"$",
"properties",
"=",
"array_merge",
"(",
"$",
"parentProperties",
",",
"$",
"properties",
")",
";",
"$",
"class",
"=",
"$",
"parent",
";",
"}",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"reflectionProperty",
")",
"{",
"$",
"propertyAnnotation",
"=",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotation",
"(",
"$",
"reflectionProperty",
",",
"$",
"this",
"->",
"annotationClass",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"propertyAnnotation",
")",
"&&",
"$",
"propertyAnnotation",
"->",
"listable",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"array",
"(",
"'property'",
"=>",
"$",
"reflectionProperty",
"->",
"name",
",",
"'type'",
"=>",
"$",
"propertyAnnotation",
"->",
"type",
")",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Gets all annotations
@param [type] $entity [description]
@return [type] [description]
|
[
"Gets",
"all",
"annotations"
] |
da1f15a9abcc083c9db7f8459f1af661937454ea
|
https://github.com/Opifer/Revisions/blob/da1f15a9abcc083c9db7f8459f1af661937454ea/src/Opifer/Revisions/Mapping/AnnotationReader.php#L131-L156
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.