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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
237,000
|
kuria/enum
|
src/EnumObject.php
|
EnumObject.all
|
static function all(): array
{
$instances = [];
foreach (static::getMap() as $key => $value) {
$instances[$key] = self::$instanceCache[static::class][$key]
?? (self::$instanceCache[static::class][$key] = new static($key, $value));
}
return $instances;
}
|
php
|
static function all(): array
{
$instances = [];
foreach (static::getMap() as $key => $value) {
$instances[$key] = self::$instanceCache[static::class][$key]
?? (self::$instanceCache[static::class][$key] = new static($key, $value));
}
return $instances;
}
|
[
"static",
"function",
"all",
"(",
")",
":",
"array",
"{",
"$",
"instances",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"getMap",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"instances",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"$",
"instanceCache",
"[",
"static",
"::",
"class",
"]",
"[",
"$",
"key",
"]",
"??",
"(",
"self",
"::",
"$",
"instanceCache",
"[",
"static",
"::",
"class",
"]",
"[",
"$",
"key",
"]",
"=",
"new",
"static",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"instances",
";",
"}"
] |
Get instance for each defined key-value pair
@return static[]
|
[
"Get",
"instance",
"for",
"each",
"defined",
"key",
"-",
"value",
"pair"
] |
9d9c1907f8a6910552b50b175398393909028eaa
|
https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/EnumObject.php#L112-L122
|
237,001
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.numeroFormatoBrParaSql
|
public function numeroFormatoBrParaSql($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com o ponto
$numero = str_replace(".", "", $numero);
//Substitui separador de decimal de virgula para ponto
$numero = str_replace(",", ".", $numero);
if (!is_numeric($numero)) {
return false;
}
return $numero;
}
|
php
|
public function numeroFormatoBrParaSql($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com o ponto
$numero = str_replace(".", "", $numero);
//Substitui separador de decimal de virgula para ponto
$numero = str_replace(",", ".", $numero);
if (!is_numeric($numero)) {
return false;
}
return $numero;
}
|
[
"public",
"function",
"numeroFormatoBrParaSql",
"(",
"$",
"numero",
")",
"{",
"//Retira espaços",
"$",
"numero",
"=",
"trim",
"(",
"$",
"numero",
")",
";",
"//Retira separador de milhar com o ponto",
"$",
"numero",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\"",
",",
"$",
"numero",
")",
";",
"//Substitui separador de decimal de virgula para ponto",
"$",
"numero",
"=",
"str_replace",
"(",
"\",\"",
",",
"\".\"",
",",
"$",
"numero",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"numero",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"numero",
";",
"}"
] |
Converter um numero de um formato '12.345.678,00' para um formato '12345678.00'.
@param string $numero
@return false|mixed
|
[
"Converter",
"um",
"numero",
"de",
"um",
"formato",
"12",
".",
"345",
".",
"678",
"00",
"para",
"um",
"formato",
"12345678",
".",
"00",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L127-L143
|
237,002
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.numeroFormatoSqlParaBr
|
public function numeroFormatoSqlParaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(",", "", $numero);
if (!is_numeric($numero)) {
return false;
}
//Se não tiver ponto
if (strpos($numero, '.') === false) {
return number_format($numero, 0, ",", ".");
}
return number_format($numero, 2, ",", ".");
}
|
php
|
public function numeroFormatoSqlParaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(",", "", $numero);
if (!is_numeric($numero)) {
return false;
}
//Se não tiver ponto
if (strpos($numero, '.') === false) {
return number_format($numero, 0, ",", ".");
}
return number_format($numero, 2, ",", ".");
}
|
[
"public",
"function",
"numeroFormatoSqlParaBr",
"(",
"$",
"numero",
")",
"{",
"//Retira espaços",
"$",
"numero",
"=",
"trim",
"(",
"$",
"numero",
")",
";",
"//Retira separador de milhar com a virgula",
"$",
"numero",
"=",
"str_replace",
"(",
"\",\"",
",",
"\"\"",
",",
"$",
"numero",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"numero",
")",
")",
"{",
"return",
"false",
";",
"}",
"//Se não tiver ponto",
"if",
"(",
"strpos",
"(",
"$",
"numero",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"return",
"number_format",
"(",
"$",
"numero",
",",
"0",
",",
"\",\"",
",",
"\".\"",
")",
";",
"}",
"return",
"number_format",
"(",
"$",
"numero",
",",
"2",
",",
"\",\"",
",",
"\".\"",
")",
";",
"}"
] |
Converter um numero de um formato '12345678.00' para um formato '12.345.678,00' com ou sem casas decimais.
@param $numero
@return false|string
|
[
"Converter",
"um",
"numero",
"de",
"um",
"formato",
"12345678",
".",
"00",
"para",
"um",
"formato",
"12",
".",
"345",
".",
"678",
"00",
"com",
"ou",
"sem",
"casas",
"decimais",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L151-L169
|
237,003
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.numeroFormatoSqlParaMoedaBr
|
public function numeroFormatoSqlParaMoedaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(",", "", $numero);
if(!is_numeric($numero)){
return false;
}
return number_format($numero, 2, ",", ".");
}
|
php
|
public function numeroFormatoSqlParaMoedaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(",", "", $numero);
if(!is_numeric($numero)){
return false;
}
return number_format($numero, 2, ",", ".");
}
|
[
"public",
"function",
"numeroFormatoSqlParaMoedaBr",
"(",
"$",
"numero",
")",
"{",
"//Retira espaços",
"$",
"numero",
"=",
"trim",
"(",
"$",
"numero",
")",
";",
"//Retira separador de milhar com a virgula",
"$",
"numero",
"=",
"str_replace",
"(",
"\",\"",
",",
"\"\"",
",",
"$",
"numero",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"numero",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"number_format",
"(",
"$",
"numero",
",",
"2",
",",
"\",\"",
",",
"\".\"",
")",
";",
"}"
] |
Converter um numero de um formato '12345678' para um formato '12.345.678,00' sempre com casas decimais.
@param $numero
@return false|string
|
[
"Converter",
"um",
"numero",
"de",
"um",
"formato",
"12345678",
"para",
"um",
"formato",
"12",
".",
"345",
".",
"678",
"00",
"sempre",
"com",
"casas",
"decimais",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L177-L190
|
237,004
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.numeroFormatoBrParaMoedaBr
|
public function numeroFormatoBrParaMoedaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(".", "", $numero);
//transforma para numero
$numero = str_replace(",", ".", $numero);
if(!is_numeric($numero)){
return false;
}
return number_format($numero, 2, ",", ".");
}
|
php
|
public function numeroFormatoBrParaMoedaBr($numero)
{
//Retira espaços
$numero = trim($numero);
//Retira separador de milhar com a virgula
$numero = str_replace(".", "", $numero);
//transforma para numero
$numero = str_replace(",", ".", $numero);
if(!is_numeric($numero)){
return false;
}
return number_format($numero, 2, ",", ".");
}
|
[
"public",
"function",
"numeroFormatoBrParaMoedaBr",
"(",
"$",
"numero",
")",
"{",
"//Retira espaços",
"$",
"numero",
"=",
"trim",
"(",
"$",
"numero",
")",
";",
"//Retira separador de milhar com a virgula",
"$",
"numero",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\"",
",",
"$",
"numero",
")",
";",
"//transforma para numero",
"$",
"numero",
"=",
"str_replace",
"(",
"\",\"",
",",
"\".\"",
",",
"$",
"numero",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"numero",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"number_format",
"(",
"$",
"numero",
",",
"2",
",",
"\",\"",
",",
"\".\"",
")",
";",
"}"
] |
Converter um numero de um formato '2345678,00' para um formato '12.345.678,00' sempre com casas decimais.
@param string $numero
@return false|mixed
|
[
"Converter",
"um",
"numero",
"de",
"um",
"formato",
"2345678",
"00",
"para",
"um",
"formato",
"12",
".",
"345",
".",
"678",
"00",
"sempre",
"com",
"casas",
"decimais",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L198-L213
|
237,005
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.checarValorArrayMultidimensional
|
public function checarValorArrayMultidimensional($key, $value, array $array)
{
foreach ($array as $a) {
if (isset($a[$key]) && $a[$key] == $value) {
return true;
}
}
return false;
}
|
php
|
public function checarValorArrayMultidimensional($key, $value, array $array)
{
foreach ($array as $a) {
if (isset($a[$key]) && $a[$key] == $value) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"checarValorArrayMultidimensional",
"(",
"$",
"key",
",",
"$",
"value",
",",
"array",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"a",
"[",
"$",
"key",
"]",
"==",
"$",
"value",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checar se um valor existe em um array multidimensional
@param string $key
@param string $value
@param array $array
@return bool
|
[
"Checar",
"se",
"um",
"valor",
"existe",
"em",
"um",
"array",
"multidimensional"
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L223-L231
|
237,006
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.formatarIeCpfCnpj
|
function formatarIeCpfCnpj($valor)
{
if (strlen($valor) == 9) {
return $this->formatarIe($valor);
}
if (strlen($valor) == 11) {
return $this->formatarCpf($valor);
}
return $this->formatarCnpj($valor);
}
|
php
|
function formatarIeCpfCnpj($valor)
{
if (strlen($valor) == 9) {
return $this->formatarIe($valor);
}
if (strlen($valor) == 11) {
return $this->formatarCpf($valor);
}
return $this->formatarCnpj($valor);
}
|
[
"function",
"formatarIeCpfCnpj",
"(",
"$",
"valor",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"valor",
")",
"==",
"9",
")",
"{",
"return",
"$",
"this",
"->",
"formatarIe",
"(",
"$",
"valor",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"valor",
")",
"==",
"11",
")",
"{",
"return",
"$",
"this",
"->",
"formatarCpf",
"(",
"$",
"valor",
")",
";",
"}",
"return",
"$",
"this",
"->",
"formatarCnpj",
"(",
"$",
"valor",
")",
";",
"}"
] |
Converter um numero para os formatos de Inscricao Estadual, Cpf ou Cnpj, de acordo com o tamanho do parametro informado.
@param $valor
@return string
|
[
"Converter",
"um",
"numero",
"para",
"os",
"formatos",
"de",
"Inscricao",
"Estadual",
"Cpf",
"ou",
"Cnpj",
"de",
"acordo",
"com",
"o",
"tamanho",
"do",
"parametro",
"informado",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L314-L325
|
237,007
|
motamonteiro/helpers
|
src/Traits/StringHelper.php
|
StringHelper.formatarTelefone
|
function formatarTelefone($valor)
{
if (strlen($valor) < 10) {
return $this->formatarValor($valor, '####-####');
}
if (strlen($valor) == 10) {
return $this->formatarValor($valor, '(##) ####-####');
}
return $this->formatarValor($valor, '(##) #####-####');
}
|
php
|
function formatarTelefone($valor)
{
if (strlen($valor) < 10) {
return $this->formatarValor($valor, '####-####');
}
if (strlen($valor) == 10) {
return $this->formatarValor($valor, '(##) ####-####');
}
return $this->formatarValor($valor, '(##) #####-####');
}
|
[
"function",
"formatarTelefone",
"(",
"$",
"valor",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"valor",
")",
"<",
"10",
")",
"{",
"return",
"$",
"this",
"->",
"formatarValor",
"(",
"$",
"valor",
",",
"'####-####'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"valor",
")",
"==",
"10",
")",
"{",
"return",
"$",
"this",
"->",
"formatarValor",
"(",
"$",
"valor",
",",
"'(##) ####-####'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"formatarValor",
"(",
"$",
"valor",
",",
"'(##) #####-####'",
")",
";",
"}"
] |
Converter um numero para os formatos de telefone simples, telefone com ddd ou telefone celular, de acordo com o tamanho do parametro informado.
@param $valor
@return string
|
[
"Converter",
"um",
"numero",
"para",
"os",
"formatos",
"de",
"telefone",
"simples",
"telefone",
"com",
"ddd",
"ou",
"telefone",
"celular",
"de",
"acordo",
"com",
"o",
"tamanho",
"do",
"parametro",
"informado",
"."
] |
4cd246d454968865758e74c5be383063e0f7ccd4
|
https://github.com/motamonteiro/helpers/blob/4cd246d454968865758e74c5be383063e0f7ccd4/src/Traits/StringHelper.php#L333-L344
|
237,008
|
MadrakIO/extendable-configuration-bundle
|
Controller/AbstractExtendableConfigurationController.php
|
AbstractExtendableConfigurationController.indexAction
|
public function indexAction(Request $request)
{
$form = $this->createForm(new ExtendableConfigurationType($this->get('madrak_io_extendable_configuration.extendable_configuration_chain')->getBuiltConfiguration()));
$form->setData($this->get('madrak_io_extendable_configuration.configuration_service')->getAll());
$form->handleRequest($request);
if ($form->isValid() === true) {
$entityClass = $this->getParameter('madrak_io_extendable_configuration.configuration_class');
$entityManager = $this->get('doctrine.orm.default_entity_manager');
$repository = $entityManager->getRepository($entityClass);
$recursiveIteratorIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($form->getData()['configuration']));
foreach ($recursiveIteratorIterator as $configurationValue) {
$keys = [];
for ($depth = 0; $depth <= $recursiveIteratorIterator->getDepth(); ++$depth) {
$keys[] = $recursiveIteratorIterator->getSubIterator($depth)->key();
}
$configurationField = implode('.', $keys);
$configurationEntity = $repository->findOneBy(['field' => $configurationField]);
if (($configurationEntity instanceof $entityClass) === false) {
$configurationEntity = new $entityClass();
$configurationEntity->setField($configurationField);
}
$configurationEntity->setValue($configurationValue);
$entityManager->persist($configurationEntity);
}
$entityManager->flush();
}
return $this->render('MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig',
[
'parent_template' => $this->getParentTemplate(),
'form' => $form->createView(),
]);
}
|
php
|
public function indexAction(Request $request)
{
$form = $this->createForm(new ExtendableConfigurationType($this->get('madrak_io_extendable_configuration.extendable_configuration_chain')->getBuiltConfiguration()));
$form->setData($this->get('madrak_io_extendable_configuration.configuration_service')->getAll());
$form->handleRequest($request);
if ($form->isValid() === true) {
$entityClass = $this->getParameter('madrak_io_extendable_configuration.configuration_class');
$entityManager = $this->get('doctrine.orm.default_entity_manager');
$repository = $entityManager->getRepository($entityClass);
$recursiveIteratorIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($form->getData()['configuration']));
foreach ($recursiveIteratorIterator as $configurationValue) {
$keys = [];
for ($depth = 0; $depth <= $recursiveIteratorIterator->getDepth(); ++$depth) {
$keys[] = $recursiveIteratorIterator->getSubIterator($depth)->key();
}
$configurationField = implode('.', $keys);
$configurationEntity = $repository->findOneBy(['field' => $configurationField]);
if (($configurationEntity instanceof $entityClass) === false) {
$configurationEntity = new $entityClass();
$configurationEntity->setField($configurationField);
}
$configurationEntity->setValue($configurationValue);
$entityManager->persist($configurationEntity);
}
$entityManager->flush();
}
return $this->render('MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig',
[
'parent_template' => $this->getParentTemplate(),
'form' => $form->createView(),
]);
}
|
[
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"ExtendableConfigurationType",
"(",
"$",
"this",
"->",
"get",
"(",
"'madrak_io_extendable_configuration.extendable_configuration_chain'",
")",
"->",
"getBuiltConfiguration",
"(",
")",
")",
")",
";",
"$",
"form",
"->",
"setData",
"(",
"$",
"this",
"->",
"get",
"(",
"'madrak_io_extendable_configuration.configuration_service'",
")",
"->",
"getAll",
"(",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
"===",
"true",
")",
"{",
"$",
"entityClass",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'madrak_io_extendable_configuration.configuration_class'",
")",
";",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
";",
"$",
"repository",
"=",
"$",
"entityManager",
"->",
"getRepository",
"(",
"$",
"entityClass",
")",
";",
"$",
"recursiveIteratorIterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveArrayIterator",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
"[",
"'configuration'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"recursiveIteratorIterator",
"as",
"$",
"configurationValue",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"depth",
"=",
"0",
";",
"$",
"depth",
"<=",
"$",
"recursiveIteratorIterator",
"->",
"getDepth",
"(",
")",
";",
"++",
"$",
"depth",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"recursiveIteratorIterator",
"->",
"getSubIterator",
"(",
"$",
"depth",
")",
"->",
"key",
"(",
")",
";",
"}",
"$",
"configurationField",
"=",
"implode",
"(",
"'.'",
",",
"$",
"keys",
")",
";",
"$",
"configurationEntity",
"=",
"$",
"repository",
"->",
"findOneBy",
"(",
"[",
"'field'",
"=>",
"$",
"configurationField",
"]",
")",
";",
"if",
"(",
"(",
"$",
"configurationEntity",
"instanceof",
"$",
"entityClass",
")",
"===",
"false",
")",
"{",
"$",
"configurationEntity",
"=",
"new",
"$",
"entityClass",
"(",
")",
";",
"$",
"configurationEntity",
"->",
"setField",
"(",
"$",
"configurationField",
")",
";",
"}",
"$",
"configurationEntity",
"->",
"setValue",
"(",
"$",
"configurationValue",
")",
";",
"$",
"entityManager",
"->",
"persist",
"(",
"$",
"configurationEntity",
")",
";",
"}",
"$",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig'",
",",
"[",
"'parent_template'",
"=>",
"$",
"this",
"->",
"getParentTemplate",
"(",
")",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Lists all available configurations.
@Route("/")
@Method("GET|POST")
|
[
"Lists",
"all",
"available",
"configurations",
"."
] |
f6fec2913a52ad634852df41b29a0dbbf16eeb47
|
https://github.com/MadrakIO/extendable-configuration-bundle/blob/f6fec2913a52ad634852df41b29a0dbbf16eeb47/Controller/AbstractExtendableConfigurationController.php#L23-L63
|
237,009
|
juanparati/Emoji
|
src/Emoji.php
|
Emoji.char
|
public static function char($symbol)
{
if (is_string($symbol) && EmojiDictionary::get($symbol))
$symbol = EmojiDictionary::get($symbol);
// In case that multiple unicode sequences are used
if (is_array($symbol))
{
$output = '';
foreach ($symbol as $sequence)
$output .= self::char($sequence);
return $output;
}
return self::uni2utf8($symbol);
// Another alternative solution is to use mb_convert_encoding (Slow and it requires MB)
// echo mb_convert_encoding('😀', 'UTF-8', 'HTML-ENTITIES');
}
|
php
|
public static function char($symbol)
{
if (is_string($symbol) && EmojiDictionary::get($symbol))
$symbol = EmojiDictionary::get($symbol);
// In case that multiple unicode sequences are used
if (is_array($symbol))
{
$output = '';
foreach ($symbol as $sequence)
$output .= self::char($sequence);
return $output;
}
return self::uni2utf8($symbol);
// Another alternative solution is to use mb_convert_encoding (Slow and it requires MB)
// echo mb_convert_encoding('😀', 'UTF-8', 'HTML-ENTITIES');
}
|
[
"public",
"static",
"function",
"char",
"(",
"$",
"symbol",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"symbol",
")",
"&&",
"EmojiDictionary",
"::",
"get",
"(",
"$",
"symbol",
")",
")",
"$",
"symbol",
"=",
"EmojiDictionary",
"::",
"get",
"(",
"$",
"symbol",
")",
";",
"// In case that multiple unicode sequences are used",
"if",
"(",
"is_array",
"(",
"$",
"symbol",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"symbol",
"as",
"$",
"sequence",
")",
"$",
"output",
".=",
"self",
"::",
"char",
"(",
"$",
"sequence",
")",
";",
"return",
"$",
"output",
";",
"}",
"return",
"self",
"::",
"uni2utf8",
"(",
"$",
"symbol",
")",
";",
"// Another alternative solution is to use mb_convert_encoding (Slow and it requires MB)",
"// echo mb_convert_encoding('😀', 'UTF-8', 'HTML-ENTITIES');",
"}"
] |
Return an emoji as char
@param $symbol
@return bool|string
|
[
"Return",
"an",
"emoji",
"as",
"char"
] |
53a34e1d3714f2a11ddc0451030eee06ea2f8f21
|
https://github.com/juanparati/Emoji/blob/53a34e1d3714f2a11ddc0451030eee06ea2f8f21/src/Emoji.php#L18-L40
|
237,010
|
juanparati/Emoji
|
src/Emoji.php
|
Emoji.html
|
public static function html($symbol)
{
if (is_string($symbol) && EmojiDictionary::get($symbol))
$symbol = EmojiDictionary::get($symbol);
// In case that multiple unicode sequences are used
if (is_array($symbol))
{
$output = '';
foreach ($symbol as $sequence)
$output .= self::html($sequence);
return $output;
}
$symbol = dechex($symbol);
return '&#x' . $symbol;
}
|
php
|
public static function html($symbol)
{
if (is_string($symbol) && EmojiDictionary::get($symbol))
$symbol = EmojiDictionary::get($symbol);
// In case that multiple unicode sequences are used
if (is_array($symbol))
{
$output = '';
foreach ($symbol as $sequence)
$output .= self::html($sequence);
return $output;
}
$symbol = dechex($symbol);
return '&#x' . $symbol;
}
|
[
"public",
"static",
"function",
"html",
"(",
"$",
"symbol",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"symbol",
")",
"&&",
"EmojiDictionary",
"::",
"get",
"(",
"$",
"symbol",
")",
")",
"$",
"symbol",
"=",
"EmojiDictionary",
"::",
"get",
"(",
"$",
"symbol",
")",
";",
"// In case that multiple unicode sequences are used",
"if",
"(",
"is_array",
"(",
"$",
"symbol",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"symbol",
"as",
"$",
"sequence",
")",
"$",
"output",
".=",
"self",
"::",
"html",
"(",
"$",
"sequence",
")",
";",
"return",
"$",
"output",
";",
"}",
"$",
"symbol",
"=",
"dechex",
"(",
"$",
"symbol",
")",
";",
"return",
"'&#x'",
".",
"$",
"symbol",
";",
"}"
] |
Return an emoji as a html entity
@param $symbol
@return string
|
[
"Return",
"an",
"emoji",
"as",
"a",
"html",
"entity"
] |
53a34e1d3714f2a11ddc0451030eee06ea2f8f21
|
https://github.com/juanparati/Emoji/blob/53a34e1d3714f2a11ddc0451030eee06ea2f8f21/src/Emoji.php#L49-L71
|
237,011
|
Morannon/Morannon
|
src/Morannon/Base/Utils/UrlUtils.php
|
UrlUtils.removeTrainingSlash
|
public function removeTrainingSlash($url)
{
if (null === $url || strlen($url) <= 2) {
return $url;
}
return (substr($url, -1, 1) == '/')? substr($url, 0, -1) : $url;
}
|
php
|
public function removeTrainingSlash($url)
{
if (null === $url || strlen($url) <= 2) {
return $url;
}
return (substr($url, -1, 1) == '/')? substr($url, 0, -1) : $url;
}
|
[
"public",
"function",
"removeTrainingSlash",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"url",
"||",
"strlen",
"(",
"$",
"url",
")",
"<=",
"2",
")",
"{",
"return",
"$",
"url",
";",
"}",
"return",
"(",
"substr",
"(",
"$",
"url",
",",
"-",
"1",
",",
"1",
")",
"==",
"'/'",
")",
"?",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"-",
"1",
")",
":",
"$",
"url",
";",
"}"
] |
Removes a trailing slash from an url string.
@param string $url
@return string
|
[
"Removes",
"a",
"trailing",
"slash",
"from",
"an",
"url",
"string",
"."
] |
1990d830452625c41eb4c1d1ff3313fb892b12f3
|
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L14-L21
|
237,012
|
Morannon/Morannon
|
src/Morannon/Base/Utils/UrlUtils.php
|
UrlUtils.buildUrlString
|
public function buildUrlString($baseUrl, $resource)
{
if (null === $baseUrl || '' == $baseUrl) {
return null;
}
if (null === $resource || '' == $resource) {
return $baseUrl;
}
$baseUrl = $this->removeTrainingSlash($baseUrl);
if (!substr($resource, 0, 1) == '/') {
$resource = '/' . $resource;
}
return $baseUrl . $resource;
}
|
php
|
public function buildUrlString($baseUrl, $resource)
{
if (null === $baseUrl || '' == $baseUrl) {
return null;
}
if (null === $resource || '' == $resource) {
return $baseUrl;
}
$baseUrl = $this->removeTrainingSlash($baseUrl);
if (!substr($resource, 0, 1) == '/') {
$resource = '/' . $resource;
}
return $baseUrl . $resource;
}
|
[
"public",
"function",
"buildUrlString",
"(",
"$",
"baseUrl",
",",
"$",
"resource",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"baseUrl",
"||",
"''",
"==",
"$",
"baseUrl",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"resource",
"||",
"''",
"==",
"$",
"resource",
")",
"{",
"return",
"$",
"baseUrl",
";",
"}",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"removeTrainingSlash",
"(",
"$",
"baseUrl",
")",
";",
"if",
"(",
"!",
"substr",
"(",
"$",
"resource",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"resource",
"=",
"'/'",
".",
"$",
"resource",
";",
"}",
"return",
"$",
"baseUrl",
".",
"$",
"resource",
";",
"}"
] |
Returns either the concatenated string or null on wrong params.
@param string $baseUrl
@param string $resource
@return string|null Null on invalid {$baseUrl}
|
[
"Returns",
"either",
"the",
"concatenated",
"string",
"or",
"null",
"on",
"wrong",
"params",
"."
] |
1990d830452625c41eb4c1d1ff3313fb892b12f3
|
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L30-L46
|
237,013
|
Morannon/Morannon
|
src/Morannon/Base/Utils/UrlUtils.php
|
UrlUtils.parseNewLineSeparatedBody
|
public function parseNewLineSeparatedBody($body)
{
$data = array();
if (!$body) {
return $data;
}
$parts = preg_split("/\\r?\\n/", $body);
foreach ($parts as $str) {
if (!$str) {
continue;
}
list ($key, $value) = explode('=', $str);
$data[$key] = $value;
}
return $data;
}
|
php
|
public function parseNewLineSeparatedBody($body)
{
$data = array();
if (!$body) {
return $data;
}
$parts = preg_split("/\\r?\\n/", $body);
foreach ($parts as $str) {
if (!$str) {
continue;
}
list ($key, $value) = explode('=', $str);
$data[$key] = $value;
}
return $data;
}
|
[
"public",
"function",
"parseNewLineSeparatedBody",
"(",
"$",
"body",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"body",
")",
"{",
"return",
"$",
"data",
";",
"}",
"$",
"parts",
"=",
"preg_split",
"(",
"\"/\\\\r?\\\\n/\"",
",",
"$",
"body",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"$",
"str",
")",
"{",
"continue",
";",
"}",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"str",
")",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Separates given string in key value parts.
@param string $body
@return array
|
[
"Separates",
"given",
"string",
"in",
"key",
"value",
"parts",
"."
] |
1990d830452625c41eb4c1d1ff3313fb892b12f3
|
https://github.com/Morannon/Morannon/blob/1990d830452625c41eb4c1d1ff3313fb892b12f3/src/Morannon/Base/Utils/UrlUtils.php#L54-L73
|
237,014
|
ItalyStrap/debug
|
src/Debug/Asset_Queued.php
|
Asset_Queued.make_output
|
private function make_output( $assets, $type ) {
$output = '';
$output .= '<pre>' . $type . ' trovati in coda'."\r\n";
foreach ( $assets->queue as $asset ) {
if ( ! isset( $assets->registered[ $asset ] ) ) {
continue;
}
$output .= "\r\nHandle: <strong>" . $asset . "</strong>\n";
$output .= "<i class='small'>URL: " . $assets->registered[ $asset ]->src . "</i class='small'>\r\n";
$deps = $assets->registered[ $asset ]->deps;
if ( $deps ) {
$output .= 'Dipende da >>>>>>> ';
// $output .= print_r( $deps, true );
foreach ( $deps as $dep ) {
$output .= '<strong>' . $dep . '</strong>, ';
}
$output .= "\r\n";
} else {
$output .= "Non dipende da nessuno\r\n";
}
}
$output .= "\r\n</pre>";
return $output;
}
|
php
|
private function make_output( $assets, $type ) {
$output = '';
$output .= '<pre>' . $type . ' trovati in coda'."\r\n";
foreach ( $assets->queue as $asset ) {
if ( ! isset( $assets->registered[ $asset ] ) ) {
continue;
}
$output .= "\r\nHandle: <strong>" . $asset . "</strong>\n";
$output .= "<i class='small'>URL: " . $assets->registered[ $asset ]->src . "</i class='small'>\r\n";
$deps = $assets->registered[ $asset ]->deps;
if ( $deps ) {
$output .= 'Dipende da >>>>>>> ';
// $output .= print_r( $deps, true );
foreach ( $deps as $dep ) {
$output .= '<strong>' . $dep . '</strong>, ';
}
$output .= "\r\n";
} else {
$output .= "Non dipende da nessuno\r\n";
}
}
$output .= "\r\n</pre>";
return $output;
}
|
[
"private",
"function",
"make_output",
"(",
"$",
"assets",
",",
"$",
"type",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"'<pre>'",
".",
"$",
"type",
".",
"' trovati in coda'",
".",
"\"\\r\\n\"",
";",
"foreach",
"(",
"$",
"assets",
"->",
"queue",
"as",
"$",
"asset",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"assets",
"->",
"registered",
"[",
"$",
"asset",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"output",
".=",
"\"\\r\\nHandle: <strong>\"",
".",
"$",
"asset",
".",
"\"</strong>\\n\"",
";",
"$",
"output",
".=",
"\"<i class='small'>URL: \"",
".",
"$",
"assets",
"->",
"registered",
"[",
"$",
"asset",
"]",
"->",
"src",
".",
"\"</i class='small'>\\r\\n\"",
";",
"$",
"deps",
"=",
"$",
"assets",
"->",
"registered",
"[",
"$",
"asset",
"]",
"->",
"deps",
";",
"if",
"(",
"$",
"deps",
")",
"{",
"$",
"output",
".=",
"'Dipende da >>>>>>> '",
";",
"// $output .= print_r( $deps, true );",
"foreach",
"(",
"$",
"deps",
"as",
"$",
"dep",
")",
"{",
"$",
"output",
".=",
"'<strong>'",
".",
"$",
"dep",
".",
"'</strong>, '",
";",
"}",
"$",
"output",
".=",
"\"\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"\"Non dipende da nessuno\\r\\n\"",
";",
"}",
"}",
"$",
"output",
".=",
"\"\\r\\n</pre>\"",
";",
"return",
"$",
"output",
";",
"}"
] |
Make the list assets output.
@param WP_Style|WP_Script $assets WP_Style or WP_Script object.
@return string Return the list of asset enqueued.
|
[
"Make",
"the",
"list",
"assets",
"output",
"."
] |
955951b3df3a5c91bdc4cba51348645ccca6bddd
|
https://github.com/ItalyStrap/debug/blob/955951b3df3a5c91bdc4cba51348645ccca6bddd/src/Debug/Asset_Queued.php#L63-L91
|
237,015
|
AlcyZ/Alcys-ORM
|
src/Core/Db/Factory/ExpressionBuilderFactory.php
|
ExpressionBuilderFactory.create
|
public function create(ExpressionInterface $expression = null)
{
if($expression instanceof ConditionInterface)
{
return new ConditionBuilder($expression);
}
elseif($expression instanceof JoinInterface)
{
return new JoinBuilder($expression);
}
else
{
return new NullBuilder();
}
}
|
php
|
public function create(ExpressionInterface $expression = null)
{
if($expression instanceof ConditionInterface)
{
return new ConditionBuilder($expression);
}
elseif($expression instanceof JoinInterface)
{
return new JoinBuilder($expression);
}
else
{
return new NullBuilder();
}
}
|
[
"public",
"function",
"create",
"(",
"ExpressionInterface",
"$",
"expression",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"expression",
"instanceof",
"ConditionInterface",
")",
"{",
"return",
"new",
"ConditionBuilder",
"(",
"$",
"expression",
")",
";",
"}",
"elseif",
"(",
"$",
"expression",
"instanceof",
"JoinInterface",
")",
"{",
"return",
"new",
"JoinBuilder",
"(",
"$",
"expression",
")",
";",
"}",
"else",
"{",
"return",
"new",
"NullBuilder",
"(",
")",
";",
"}",
"}"
] |
Create and return an instance of a specific expression builder.
@param ExpressionInterface|JoinInterface|ConditionInterface $expression
@return ConditionBuilder|JoinBuilder|NullBuilder
|
[
"Create",
"and",
"return",
"an",
"instance",
"of",
"a",
"specific",
"expression",
"builder",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Factory/ExpressionBuilderFactory.php#L47-L61
|
237,016
|
kyoya-de/php-job-runner
|
src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php
|
PhpSerialize.persist
|
public function persist($identifier, ParameterBagInterface $parameterBag)
{
$stateFilename = $this->getStateFilename($identifier);
if (!touch($stateFilename) || (file_exists($stateFilename) && !is_writable($stateFilename))) {
throw new IOException("State isn't writable!");
}
file_put_contents($stateFilename, serialize($parameterBag));
}
|
php
|
public function persist($identifier, ParameterBagInterface $parameterBag)
{
$stateFilename = $this->getStateFilename($identifier);
if (!touch($stateFilename) || (file_exists($stateFilename) && !is_writable($stateFilename))) {
throw new IOException("State isn't writable!");
}
file_put_contents($stateFilename, serialize($parameterBag));
}
|
[
"public",
"function",
"persist",
"(",
"$",
"identifier",
",",
"ParameterBagInterface",
"$",
"parameterBag",
")",
"{",
"$",
"stateFilename",
"=",
"$",
"this",
"->",
"getStateFilename",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"!",
"touch",
"(",
"$",
"stateFilename",
")",
"||",
"(",
"file_exists",
"(",
"$",
"stateFilename",
")",
"&&",
"!",
"is_writable",
"(",
"$",
"stateFilename",
")",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"State isn't writable!\"",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"stateFilename",
",",
"serialize",
"(",
"$",
"parameterBag",
")",
")",
";",
"}"
] |
Puts the parameter bag to a persistent storage.
@param string $identifier
@param ParameterBagInterface $parameterBag
@throws IOException If the state file isn't writable.
@return void
|
[
"Puts",
"the",
"parameter",
"bag",
"to",
"a",
"persistent",
"storage",
"."
] |
c161c1e391d857ecd19e256593ced671bc13f5ff
|
https://github.com/kyoya-de/php-job-runner/blob/c161c1e391d857ecd19e256593ced671bc13f5ff/src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php#L32-L40
|
237,017
|
kyoya-de/php-job-runner
|
src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php
|
PhpSerialize.load
|
public function load($identifier, ParameterBagInterface $parameterBag)
{
$stateFilename = $this->getStateFilename($identifier);
if (!file_exists($stateFilename)) {
throw new IOException("State file {$stateFilename} doesn't exist!");
}
$stateFileContent = file_get_contents($stateFilename);
$parameterBag->add(unserialize($stateFileContent));
}
|
php
|
public function load($identifier, ParameterBagInterface $parameterBag)
{
$stateFilename = $this->getStateFilename($identifier);
if (!file_exists($stateFilename)) {
throw new IOException("State file {$stateFilename} doesn't exist!");
}
$stateFileContent = file_get_contents($stateFilename);
$parameterBag->add(unserialize($stateFileContent));
}
|
[
"public",
"function",
"load",
"(",
"$",
"identifier",
",",
"ParameterBagInterface",
"$",
"parameterBag",
")",
"{",
"$",
"stateFilename",
"=",
"$",
"this",
"->",
"getStateFilename",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"stateFilename",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"State file {$stateFilename} doesn't exist!\"",
")",
";",
"}",
"$",
"stateFileContent",
"=",
"file_get_contents",
"(",
"$",
"stateFilename",
")",
";",
"$",
"parameterBag",
"->",
"add",
"(",
"unserialize",
"(",
"$",
"stateFileContent",
")",
")",
";",
"}"
] |
Loads the parameter bag from a persistent storage.
@param string $identifier
@param ParameterBagInterface $parameterBag
@throws IOException If state file doesn't exist.
@return void
|
[
"Loads",
"the",
"parameter",
"bag",
"from",
"a",
"persistent",
"storage",
"."
] |
c161c1e391d857ecd19e256593ced671bc13f5ff
|
https://github.com/kyoya-de/php-job-runner/blob/c161c1e391d857ecd19e256593ced671bc13f5ff/src/Kyoya/PhpJobRunner/StorageProvider/PhpSerialize.php#L52-L62
|
237,018
|
chemel/addic7ed-cli
|
src/Scrapper/Addic7edScrapper.php
|
Addic7edScrapper.parse
|
protected function parse($url)
{
$html = $this->get($url)->getBody()->getContents();
$parser = $this->getParser($html);
return $parser;
}
|
php
|
protected function parse($url)
{
$html = $this->get($url)->getBody()->getContents();
$parser = $this->getParser($html);
return $parser;
}
|
[
"protected",
"function",
"parse",
"(",
"$",
"url",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"url",
")",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"$",
"parser",
"=",
"$",
"this",
"->",
"getParser",
"(",
"$",
"html",
")",
";",
"return",
"$",
"parser",
";",
"}"
] |
Parse HTML page
@param string url
@return Crawler parser
|
[
"Parse",
"HTML",
"page"
] |
e10ff6f4a3a37151b9141f15c231ba480aa1c78c
|
https://github.com/chemel/addic7ed-cli/blob/e10ff6f4a3a37151b9141f15c231ba480aa1c78c/src/Scrapper/Addic7edScrapper.php#L68-L75
|
237,019
|
mszewcz/php-light-framework
|
src/Db/MySQL/Query/Insert.php
|
Insert.into
|
public function into($table = null): Insert
{
$this->into = [];
if (!\is_string($table) && !\is_array($table)) {
throw new InvalidArgumentException('$table has to be an array or a string');
}
$this->into = $this->namesClass->parse($table, true);
return $this;
}
|
php
|
public function into($table = null): Insert
{
$this->into = [];
if (!\is_string($table) && !\is_array($table)) {
throw new InvalidArgumentException('$table has to be an array or a string');
}
$this->into = $this->namesClass->parse($table, true);
return $this;
}
|
[
"public",
"function",
"into",
"(",
"$",
"table",
"=",
"null",
")",
":",
"Insert",
"{",
"$",
"this",
"->",
"into",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"table",
")",
"&&",
"!",
"\\",
"is_array",
"(",
"$",
"table",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$table has to be an array or a string'",
")",
";",
"}",
"$",
"this",
"->",
"into",
"=",
"$",
"this",
"->",
"namesClass",
"->",
"parse",
"(",
"$",
"table",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds table names for insert
@param mixed|null $table
@return Insert
|
[
"Adds",
"table",
"names",
"for",
"insert"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Insert.php#L54-L63
|
237,020
|
konservs/brilliant.framework
|
libraries/Items/BItemsItemRTree.php
|
BItemsItemRTree.getCollection
|
public function getCollection() {
$collectionName = $this->collectionName;
if(empty($collectionName)){
return NULL;
}
$collection = $collectionName::getInstance();
return $collection;
}
|
php
|
public function getCollection() {
$collectionName = $this->collectionName;
if(empty($collectionName)){
return NULL;
}
$collection = $collectionName::getInstance();
return $collection;
}
|
[
"public",
"function",
"getCollection",
"(",
")",
"{",
"$",
"collectionName",
"=",
"$",
"this",
"->",
"collectionName",
";",
"if",
"(",
"empty",
"(",
"$",
"collectionName",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"collection",
"=",
"$",
"collectionName",
"::",
"getInstance",
"(",
")",
";",
"return",
"$",
"collection",
";",
"}"
] |
Get collection of such elements
@return BItemsRTree
|
[
"Get",
"collection",
"of",
"such",
"elements"
] |
95f03f1917f746fee98bea8a906ba0588c87762d
|
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItemRTree.php#L49-L56
|
237,021
|
konservs/brilliant.framework
|
libraries/Items/BItemsItemRTree.php
|
BItemsItemRTree.getfieldsvalues
|
protected function getfieldsvalues(&$qr_fields, &$qr_values) {
$qr_fields = array();
$qr_values = array();
parent::getfieldsvalues($qr_fields, $qr_values);
if (empty($this->{$this->parentKeyName})) {
$qr_fields[] = '`' . $this->parentKeyName . '`';
$qr_values[] = 'NULL';
} else {
$qr_fields[] = '`' . $this->parentKeyName . '`';
$qr_values[] = $this->{$this->parentKeyName};
}
$qr_fields[] = '`' . $this->leftKeyName . '`';
$qr_values[] = $this->{$this->leftKeyName};
$qr_fields[] = '`' . $this->rightKeyName . '`';
$qr_values[] = $this->{$this->rightKeyName};
$qr_fields[] = '`' . $this->levelKeyName . '`';
$qr_values[] = $this->{$this->levelKeyName};
$qr_fields[] = '`' . $this->groupKeyName . '`';
$qr_values[] = $this->{$this->groupKeyName};
return true;
}
|
php
|
protected function getfieldsvalues(&$qr_fields, &$qr_values) {
$qr_fields = array();
$qr_values = array();
parent::getfieldsvalues($qr_fields, $qr_values);
if (empty($this->{$this->parentKeyName})) {
$qr_fields[] = '`' . $this->parentKeyName . '`';
$qr_values[] = 'NULL';
} else {
$qr_fields[] = '`' . $this->parentKeyName . '`';
$qr_values[] = $this->{$this->parentKeyName};
}
$qr_fields[] = '`' . $this->leftKeyName . '`';
$qr_values[] = $this->{$this->leftKeyName};
$qr_fields[] = '`' . $this->rightKeyName . '`';
$qr_values[] = $this->{$this->rightKeyName};
$qr_fields[] = '`' . $this->levelKeyName . '`';
$qr_values[] = $this->{$this->levelKeyName};
$qr_fields[] = '`' . $this->groupKeyName . '`';
$qr_values[] = $this->{$this->groupKeyName};
return true;
}
|
[
"protected",
"function",
"getfieldsvalues",
"(",
"&",
"$",
"qr_fields",
",",
"&",
"$",
"qr_values",
")",
"{",
"$",
"qr_fields",
"=",
"array",
"(",
")",
";",
"$",
"qr_values",
"=",
"array",
"(",
")",
";",
"parent",
"::",
"getfieldsvalues",
"(",
"$",
"qr_fields",
",",
"$",
"qr_values",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"parentKeyName",
"}",
")",
")",
"{",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"parentKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"'NULL'",
";",
"}",
"else",
"{",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"parentKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"parentKeyName",
"}",
";",
"}",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"leftKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"leftKeyName",
"}",
";",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"rightKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"rightKeyName",
"}",
";",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"levelKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"levelKeyName",
"}",
";",
"$",
"qr_fields",
"[",
"]",
"=",
"'`'",
".",
"$",
"this",
"->",
"groupKeyName",
".",
"'`'",
";",
"$",
"qr_values",
"[",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"groupKeyName",
"}",
";",
"return",
"true",
";",
"}"
] |
Get values of fields.
@param $qr_fields
@param $qr_values
@return bool
|
[
"Get",
"values",
"of",
"fields",
"."
] |
95f03f1917f746fee98bea8a906ba0588c87762d
|
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItemRTree.php#L65-L87
|
237,022
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
|
InventoryItemController.newAction
|
public function newAction(Inventory $inventory)
{
$inventoryitem = new InventoryItem();
$inventoryitem->setInventory($inventory);
$form = $this->createForm(new InventoryItemType(), $inventoryitem);
return array(
'inventoryitem' => $inventoryitem,
'form' => $form->createView(),
);
}
|
php
|
public function newAction(Inventory $inventory)
{
$inventoryitem = new InventoryItem();
$inventoryitem->setInventory($inventory);
$form = $this->createForm(new InventoryItemType(), $inventoryitem);
return array(
'inventoryitem' => $inventoryitem,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
"Inventory",
"$",
"inventory",
")",
"{",
"$",
"inventoryitem",
"=",
"new",
"InventoryItem",
"(",
")",
";",
"$",
"inventoryitem",
"->",
"setInventory",
"(",
"$",
"inventory",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"InventoryItemType",
"(",
")",
",",
"$",
"inventoryitem",
")",
";",
"return",
"array",
"(",
"'inventoryitem'",
"=>",
"$",
"inventoryitem",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to create a new InventoryItem entity.
@Route("/inventory/{id}/new", name="stock_inventoryitem_new")
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"InventoryItem",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L72-L82
|
237,023
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
|
InventoryItemController.createAction
|
public function createAction(Request $request)
{
$inventoryitem = new InventoryItem();
$form = $this->createForm(new InventoryItemType(), $inventoryitem);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($inventoryitem);
$em->flush();
return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventoryitem->getInventory()->getId())));
}
return array(
'inventoryitem' => $inventoryitem,
'form' => $form->createView(),
);
}
|
php
|
public function createAction(Request $request)
{
$inventoryitem = new InventoryItem();
$form = $this->createForm(new InventoryItemType(), $inventoryitem);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($inventoryitem);
$em->flush();
return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventoryitem->getInventory()->getId())));
}
return array(
'inventoryitem' => $inventoryitem,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"inventoryitem",
"=",
"new",
"InventoryItem",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"InventoryItemType",
"(",
")",
",",
"$",
"inventoryitem",
")",
";",
"if",
"(",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"inventoryitem",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_inventory_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"inventoryitem",
"->",
"getInventory",
"(",
")",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'inventoryitem'",
"=>",
"$",
"inventoryitem",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new InventoryItem entity.
@Route("/create", name="stock_inventoryitem_create")
@Method("POST")
@Template("FlowerStockBundle:InventoryItem:new.html.twig")
|
[
"Creates",
"a",
"new",
"InventoryItem",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L91-L107
|
237,024
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
|
InventoryItemController.editAction
|
public function editAction(InventoryItem $inventoryitem)
{
$editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array(
'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete');
return array(
'inventoryitem' => $inventoryitem,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function editAction(InventoryItem $inventoryitem)
{
$editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array(
'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete');
return array(
'inventoryitem' => $inventoryitem,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"editAction",
"(",
"InventoryItem",
"$",
"inventoryitem",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"InventoryItemType",
"(",
")",
",",
"$",
"inventoryitem",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_inventoryitem_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"inventoryitem",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"inventoryitem",
"->",
"getId",
"(",
")",
",",
"'stock_inventoryitem_delete'",
")",
";",
"return",
"array",
"(",
"'inventoryitem'",
"=>",
"$",
"inventoryitem",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to edit an existing InventoryItem entity.
@Route("/{id}/edit", name="stock_inventoryitem_edit", requirements={"id"="\d+"})
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"InventoryItem",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L116-L129
|
237,025
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/InventoryItemController.php
|
InventoryItemController.updateAction
|
public function updateAction(InventoryItem $inventoryitem, Request $request)
{
$editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array(
'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_inventoryitem_show', array('id' => $inventoryitem->getId())));
}
$deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete');
return array(
'inventoryitem' => $inventoryitem,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function updateAction(InventoryItem $inventoryitem, Request $request)
{
$editForm = $this->createForm(new InventoryItemType(), $inventoryitem, array(
'action' => $this->generateUrl('stock_inventoryitem_update', array('id' => $inventoryitem->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_inventoryitem_show', array('id' => $inventoryitem->getId())));
}
$deleteForm = $this->createDeleteForm($inventoryitem->getId(), 'stock_inventoryitem_delete');
return array(
'inventoryitem' => $inventoryitem,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"updateAction",
"(",
"InventoryItem",
"$",
"inventoryitem",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"InventoryItemType",
"(",
")",
",",
"$",
"inventoryitem",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_inventoryitem_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"inventoryitem",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'stock_inventoryitem_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"inventoryitem",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"inventoryitem",
"->",
"getId",
"(",
")",
",",
"'stock_inventoryitem_delete'",
")",
";",
"return",
"array",
"(",
"'inventoryitem'",
"=>",
"$",
"inventoryitem",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Edits an existing InventoryItem entity.
@Route("/{id}/update", name="stock_inventoryitem_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:InventoryItem:edit.html.twig")
|
[
"Edits",
"an",
"existing",
"InventoryItem",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/InventoryItemController.php#L138-L156
|
237,026
|
asika32764/joomla-framework-console
|
Descriptor/Text/TextDescriptorHelper.php
|
TextDescriptorHelper.describe
|
public function describe(AbstractCommand $command)
{
// Describe Options
$options = $command->getAllOptions();
$optionDescriptor = $this->getOptionDescriptor();
foreach ($options as $option)
{
$optionDescriptor->addItem($option);
}
$render['option'] = count($options) ? "\n\nOptions:\n\n" . $optionDescriptor->render() : '';
// Describe Commands
$commands = $command->getChildren();
$commandDescriptor = $this->getCommandDescriptor();
foreach ($commands as $cmd)
{
$commandDescriptor->addItem($cmd);
}
$render['command'] = count($commands) ? "\nAvailable commands:\n\n" . $commandDescriptor->render() : '';
// Render Help template
/** @var Console $console */
$console = $command->getApplication();
if (!($console instanceof Console))
{
throw new \RuntimeException(sprintf('Help descriptor need Console object in %s command.', get_class($command)));
}
$consoleName = $console->getName();
$version = $console->getVersion();
$commandName = $command->getName();
$description = $command->getDescription();
$usage = $command->getUsage();
$help = $command->getHelp();
// Clean line indent of description
$description = explode("\n", $description);
foreach ($description as &$line)
{
$line = trim($line);
}
$description = implode("\n", $description);
$description = $description ? $description . "\n" : '';
$template = sprintf(
$this->template,
$consoleName,
$version,
$commandName,
$description,
$usage,
$help
);
return str_replace(
array('{OPTIONS}', '{COMMANDS}'),
$render,
$template
);
}
|
php
|
public function describe(AbstractCommand $command)
{
// Describe Options
$options = $command->getAllOptions();
$optionDescriptor = $this->getOptionDescriptor();
foreach ($options as $option)
{
$optionDescriptor->addItem($option);
}
$render['option'] = count($options) ? "\n\nOptions:\n\n" . $optionDescriptor->render() : '';
// Describe Commands
$commands = $command->getChildren();
$commandDescriptor = $this->getCommandDescriptor();
foreach ($commands as $cmd)
{
$commandDescriptor->addItem($cmd);
}
$render['command'] = count($commands) ? "\nAvailable commands:\n\n" . $commandDescriptor->render() : '';
// Render Help template
/** @var Console $console */
$console = $command->getApplication();
if (!($console instanceof Console))
{
throw new \RuntimeException(sprintf('Help descriptor need Console object in %s command.', get_class($command)));
}
$consoleName = $console->getName();
$version = $console->getVersion();
$commandName = $command->getName();
$description = $command->getDescription();
$usage = $command->getUsage();
$help = $command->getHelp();
// Clean line indent of description
$description = explode("\n", $description);
foreach ($description as &$line)
{
$line = trim($line);
}
$description = implode("\n", $description);
$description = $description ? $description . "\n" : '';
$template = sprintf(
$this->template,
$consoleName,
$version,
$commandName,
$description,
$usage,
$help
);
return str_replace(
array('{OPTIONS}', '{COMMANDS}'),
$render,
$template
);
}
|
[
"public",
"function",
"describe",
"(",
"AbstractCommand",
"$",
"command",
")",
"{",
"// Describe Options",
"$",
"options",
"=",
"$",
"command",
"->",
"getAllOptions",
"(",
")",
";",
"$",
"optionDescriptor",
"=",
"$",
"this",
"->",
"getOptionDescriptor",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"optionDescriptor",
"->",
"addItem",
"(",
"$",
"option",
")",
";",
"}",
"$",
"render",
"[",
"'option'",
"]",
"=",
"count",
"(",
"$",
"options",
")",
"?",
"\"\\n\\nOptions:\\n\\n\"",
".",
"$",
"optionDescriptor",
"->",
"render",
"(",
")",
":",
"''",
";",
"// Describe Commands",
"$",
"commands",
"=",
"$",
"command",
"->",
"getChildren",
"(",
")",
";",
"$",
"commandDescriptor",
"=",
"$",
"this",
"->",
"getCommandDescriptor",
"(",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"cmd",
")",
"{",
"$",
"commandDescriptor",
"->",
"addItem",
"(",
"$",
"cmd",
")",
";",
"}",
"$",
"render",
"[",
"'command'",
"]",
"=",
"count",
"(",
"$",
"commands",
")",
"?",
"\"\\nAvailable commands:\\n\\n\"",
".",
"$",
"commandDescriptor",
"->",
"render",
"(",
")",
":",
"''",
";",
"// Render Help template",
"/** @var Console $console */",
"$",
"console",
"=",
"$",
"command",
"->",
"getApplication",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"console",
"instanceof",
"Console",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Help descriptor need Console object in %s command.'",
",",
"get_class",
"(",
"$",
"command",
")",
")",
")",
";",
"}",
"$",
"consoleName",
"=",
"$",
"console",
"->",
"getName",
"(",
")",
";",
"$",
"version",
"=",
"$",
"console",
"->",
"getVersion",
"(",
")",
";",
"$",
"commandName",
"=",
"$",
"command",
"->",
"getName",
"(",
")",
";",
"$",
"description",
"=",
"$",
"command",
"->",
"getDescription",
"(",
")",
";",
"$",
"usage",
"=",
"$",
"command",
"->",
"getUsage",
"(",
")",
";",
"$",
"help",
"=",
"$",
"command",
"->",
"getHelp",
"(",
")",
";",
"// Clean line indent of description",
"$",
"description",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"description",
")",
";",
"foreach",
"(",
"$",
"description",
"as",
"&",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"}",
"$",
"description",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"description",
")",
";",
"$",
"description",
"=",
"$",
"description",
"?",
"$",
"description",
".",
"\"\\n\"",
":",
"''",
";",
"$",
"template",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"$",
"consoleName",
",",
"$",
"version",
",",
"$",
"commandName",
",",
"$",
"description",
",",
"$",
"usage",
",",
"$",
"help",
")",
";",
"return",
"str_replace",
"(",
"array",
"(",
"'{OPTIONS}'",
",",
"'{COMMANDS}'",
")",
",",
"$",
"render",
",",
"$",
"template",
")",
";",
"}"
] |
Describe a command detail.
@param AbstractCommand $command The command to described.
@return string Return the described text.
@throws \RuntimeException
@since 1.0
|
[
"Describe",
"a",
"command",
"detail",
"."
] |
fe28cf9e1c694049e015121e2bd041268e814249
|
https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Descriptor/Text/TextDescriptorHelper.php#L55-L122
|
237,027
|
matryoshka-model/rest-wrapper
|
library/Paginator/RestPaginatorAdapter.php
|
RestPaginatorAdapter.getItems
|
public function getItems($offset, $itemCountPerPage)
{
$cacheKey = $offset . '-' . $itemCountPerPage;
if (isset($this->preloadCache[$cacheKey])) {
return $this->preloadCache[$cacheKey];
}
return $this->loadItems($offset, $itemCountPerPage);
}
|
php
|
public function getItems($offset, $itemCountPerPage)
{
$cacheKey = $offset . '-' . $itemCountPerPage;
if (isset($this->preloadCache[$cacheKey])) {
return $this->preloadCache[$cacheKey];
}
return $this->loadItems($offset, $itemCountPerPage);
}
|
[
"public",
"function",
"getItems",
"(",
"$",
"offset",
",",
"$",
"itemCountPerPage",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"offset",
".",
"'-'",
".",
"$",
"itemCountPerPage",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"preloadCache",
"[",
"$",
"cacheKey",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"preloadCache",
"[",
"$",
"cacheKey",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"loadItems",
"(",
"$",
"offset",
",",
"$",
"itemCountPerPage",
")",
";",
"}"
] |
Returns an result set of items for a page
@param int $offset Page offset
@param int $itemCountPerPage Number of items per page
@return HydratingResultSet
|
[
"Returns",
"an",
"result",
"set",
"of",
"items",
"for",
"a",
"page"
] |
a612f2a998f37717ac9fbddf3080ce275e4c8ade
|
https://github.com/matryoshka-model/rest-wrapper/blob/a612f2a998f37717ac9fbddf3080ce275e4c8ade/library/Paginator/RestPaginatorAdapter.php#L175-L184
|
237,028
|
aedart/model
|
src/Traits/Strings/CardNumberTrait.php
|
CardNumberTrait.getCardNumber
|
public function getCardNumber() : ?string
{
if ( ! $this->hasCardNumber()) {
$this->setCardNumber($this->getDefaultCardNumber());
}
return $this->cardNumber;
}
|
php
|
public function getCardNumber() : ?string
{
if ( ! $this->hasCardNumber()) {
$this->setCardNumber($this->getDefaultCardNumber());
}
return $this->cardNumber;
}
|
[
"public",
"function",
"getCardNumber",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCardNumber",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setCardNumber",
"(",
"$",
"this",
"->",
"getDefaultCardNumber",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cardNumber",
";",
"}"
] |
Get card number
If no "card number" value has been set, this method will
set and return a default "card number" value,
if any such value is available
@see getDefaultCardNumber()
@return string|null card number or null if no card number has been set
|
[
"Get",
"card",
"number"
] |
9a562c1c53a276d01ace0ab71f5305458bea542f
|
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/CardNumberTrait.php#L48-L54
|
237,029
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Element.php
|
WebDriver_Element.getElementId
|
public function getElementId()
{
if ($this->elementId === null) {
$param = WebDriver_Util::parseLocator($this->locator);
$commandUri = (null === $this->parent) ? 'element' : "element/{$this->parent->getElementId()}/element";
$command = $this->driver->factoryCommand($commandUri, WebDriver_Command::METHOD_POST, $param);
try {
$result = $this->driver->curl($command);
} catch (WebDriver_Exception $e) {
$parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})";
$e->setMessage("Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}");
throw $e;
}
if (!isset($result['value']['ELEMENT'])) {
$parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})";
throw new WebDriver_Exception("Element not found: {$this->locator}{$parentText}");
}
$this->elementId = $result['value']['ELEMENT'];
}
return $this->elementId;
}
|
php
|
public function getElementId()
{
if ($this->elementId === null) {
$param = WebDriver_Util::parseLocator($this->locator);
$commandUri = (null === $this->parent) ? 'element' : "element/{$this->parent->getElementId()}/element";
$command = $this->driver->factoryCommand($commandUri, WebDriver_Command::METHOD_POST, $param);
try {
$result = $this->driver->curl($command);
} catch (WebDriver_Exception $e) {
$parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})";
$e->setMessage("Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}");
throw $e;
}
if (!isset($result['value']['ELEMENT'])) {
$parentText = (null === $this->parent) ? '' : " (parent: {$this->parent->getLocator()})";
throw new WebDriver_Exception("Element not found: {$this->locator}{$parentText}");
}
$this->elementId = $result['value']['ELEMENT'];
}
return $this->elementId;
}
|
[
"public",
"function",
"getElementId",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"elementId",
"===",
"null",
")",
"{",
"$",
"param",
"=",
"WebDriver_Util",
"::",
"parseLocator",
"(",
"$",
"this",
"->",
"locator",
")",
";",
"$",
"commandUri",
"=",
"(",
"null",
"===",
"$",
"this",
"->",
"parent",
")",
"?",
"'element'",
":",
"\"element/{$this->parent->getElementId()}/element\"",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"driver",
"->",
"factoryCommand",
"(",
"$",
"commandUri",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
",",
"$",
"param",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"driver",
"->",
"curl",
"(",
"$",
"command",
")",
";",
"}",
"catch",
"(",
"WebDriver_Exception",
"$",
"e",
")",
"{",
"$",
"parentText",
"=",
"(",
"null",
"===",
"$",
"this",
"->",
"parent",
")",
"?",
"''",
":",
"\" (parent: {$this->parent->getLocator()})\"",
";",
"$",
"e",
"->",
"setMessage",
"(",
"\"Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}\"",
")",
";",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"'value'",
"]",
"[",
"'ELEMENT'",
"]",
")",
")",
"{",
"$",
"parentText",
"=",
"(",
"null",
"===",
"$",
"this",
"->",
"parent",
")",
"?",
"''",
":",
"\" (parent: {$this->parent->getLocator()})\"",
";",
"throw",
"new",
"WebDriver_Exception",
"(",
"\"Element not found: {$this->locator}{$parentText}\"",
")",
";",
"}",
"$",
"this",
"->",
"elementId",
"=",
"$",
"result",
"[",
"'value'",
"]",
"[",
"'ELEMENT'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"elementId",
";",
"}"
] |
Get element Id from webdriver
@return int
@throws WebDriver_Exception
|
[
"Get",
"element",
"Id",
"from",
"webdriver"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L84-L104
|
237,030
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Element.php
|
WebDriver_Element.tagName
|
public function tagName()
{
if (!$this->state['tagName']) {
$result = $this->sendCommand('element/:id/name', WebDriver_Command::METHOD_GET);
$this->state['tagName'] = strtolower($result['value']);
}
return $this->state['tagName'];
}
|
php
|
public function tagName()
{
if (!$this->state['tagName']) {
$result = $this->sendCommand('element/:id/name', WebDriver_Command::METHOD_GET);
$this->state['tagName'] = strtolower($result['value']);
}
return $this->state['tagName'];
}
|
[
"public",
"function",
"tagName",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"state",
"[",
"'tagName'",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sendCommand",
"(",
"'element/:id/name'",
",",
"WebDriver_Command",
"::",
"METHOD_GET",
")",
";",
"$",
"this",
"->",
"state",
"[",
"'tagName'",
"]",
"=",
"strtolower",
"(",
"$",
"result",
"[",
"'value'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"state",
"[",
"'tagName'",
"]",
";",
"}"
] |
Get element tag name
@return mixed
|
[
"Get",
"element",
"tag",
"name"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L395-L402
|
237,031
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Element.php
|
WebDriver_Element.location
|
public function location()
{
$result = $this->sendCommand('element/:id/location', WebDriver_Command::METHOD_GET);
$value = $result['value'];
return ['x' => $value['x'], 'y' => $value['y']];
}
|
php
|
public function location()
{
$result = $this->sendCommand('element/:id/location', WebDriver_Command::METHOD_GET);
$value = $result['value'];
return ['x' => $value['x'], 'y' => $value['y']];
}
|
[
"public",
"function",
"location",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sendCommand",
"(",
"'element/:id/location'",
",",
"WebDriver_Command",
"::",
"METHOD_GET",
")",
";",
"$",
"value",
"=",
"$",
"result",
"[",
"'value'",
"]",
";",
"return",
"[",
"'x'",
"=>",
"$",
"value",
"[",
"'x'",
"]",
",",
"'y'",
"=>",
"$",
"value",
"[",
"'y'",
"]",
"]",
";",
"}"
] |
Get element upper-left corner of the page
|
[
"Get",
"element",
"upper",
"-",
"left",
"corner",
"of",
"the",
"page"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Element.php#L474-L479
|
237,032
|
ricardoh/wurfl-php-api
|
WURFL/Request/UserAgentNormalizer/Specific/Chrome.php
|
WURFL_Request_UserAgentNormalizer_Specific_Chrome.chromeWithMajorVersion
|
private function chromeWithMajorVersion($userAgent) {
$start_idx = strpos($userAgent, 'Chrome');
$end_idx = strpos($userAgent, '.', $start_idx);
if ($end_idx === false) {
return substr($userAgent, $start_idx);
} else {
return substr($userAgent, $start_idx, ($end_idx - $start_idx));
}
}
|
php
|
private function chromeWithMajorVersion($userAgent) {
$start_idx = strpos($userAgent, 'Chrome');
$end_idx = strpos($userAgent, '.', $start_idx);
if ($end_idx === false) {
return substr($userAgent, $start_idx);
} else {
return substr($userAgent, $start_idx, ($end_idx - $start_idx));
}
}
|
[
"private",
"function",
"chromeWithMajorVersion",
"(",
"$",
"userAgent",
")",
"{",
"$",
"start_idx",
"=",
"strpos",
"(",
"$",
"userAgent",
",",
"'Chrome'",
")",
";",
"$",
"end_idx",
"=",
"strpos",
"(",
"$",
"userAgent",
",",
"'.'",
",",
"$",
"start_idx",
")",
";",
"if",
"(",
"$",
"end_idx",
"===",
"false",
")",
"{",
"return",
"substr",
"(",
"$",
"userAgent",
",",
"$",
"start_idx",
")",
";",
"}",
"else",
"{",
"return",
"substr",
"(",
"$",
"userAgent",
",",
"$",
"start_idx",
",",
"(",
"$",
"end_idx",
"-",
"$",
"start_idx",
")",
")",
";",
"}",
"}"
] |
Returns Google Chrome's Major version number
@param string $userAgent
@return string|int Version number
|
[
"Returns",
"Google",
"Chrome",
"s",
"Major",
"version",
"number"
] |
1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546
|
https://github.com/ricardoh/wurfl-php-api/blob/1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546/WURFL/Request/UserAgentNormalizer/Specific/Chrome.php#L34-L42
|
237,033
|
laravelflare/cms
|
src/Cms/Tree/TreeManager.php
|
TreeManager.findOrFail
|
public function findOrFail($fullslug)
{
if (!$tree = $this->find($fullslug)) {
throw (new ModelNotFoundException)->setModel(Tree::class);
}
return $tree;
}
|
php
|
public function findOrFail($fullslug)
{
if (!$tree = $this->find($fullslug)) {
throw (new ModelNotFoundException)->setModel(Tree::class);
}
return $tree;
}
|
[
"public",
"function",
"findOrFail",
"(",
"$",
"fullslug",
")",
"{",
"if",
"(",
"!",
"$",
"tree",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"fullslug",
")",
")",
"{",
"throw",
"(",
"new",
"ModelNotFoundException",
")",
"->",
"setModel",
"(",
"Tree",
"::",
"class",
")",
";",
"}",
"return",
"$",
"tree",
";",
"}"
] |
Find a Tree Item by Slug or throw an exception.
@param string $fullslug
@return \LaravelFlare\Cms\Tree\Tree
@throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
[
"Find",
"a",
"Tree",
"Item",
"by",
"Slug",
"or",
"throw",
"an",
"exception",
"."
] |
fe94b922c5b1232ea7ab63abd47dbbe34e47ad2f
|
https://github.com/laravelflare/cms/blob/fe94b922c5b1232ea7ab63abd47dbbe34e47ad2f/src/Cms/Tree/TreeManager.php#L48-L55
|
237,034
|
glynnforrest/speedy-config
|
src/Processor/ReferenceProcessor.php
|
ReferenceProcessor.resolveValue
|
protected function resolveValue(Config $config, $key)
{
$value = $config->getRequired($key);
if (is_array($value)) {
throw new KeyException(sprintf('Referenced configuration key "%s" must not be an array.', $key));
}
if (in_array($key, $this->referenceStack)) {
throw new KeyException(sprintf('Circular reference detected resolving configuration key "%s"', $key));
}
$this->referenceStack[] = $key;
preg_match_all('/%([^%]+)%/', $value, $matches);
if (!$matches) {
return;
}
foreach ($matches[1] as $referenceKey) {
$replacement = $this->resolveValue($config, $referenceKey);
$value = str_replace('%'.$referenceKey.'%', $replacement, $value);
}
array_pop($this->referenceStack);
return $value;
}
|
php
|
protected function resolveValue(Config $config, $key)
{
$value = $config->getRequired($key);
if (is_array($value)) {
throw new KeyException(sprintf('Referenced configuration key "%s" must not be an array.', $key));
}
if (in_array($key, $this->referenceStack)) {
throw new KeyException(sprintf('Circular reference detected resolving configuration key "%s"', $key));
}
$this->referenceStack[] = $key;
preg_match_all('/%([^%]+)%/', $value, $matches);
if (!$matches) {
return;
}
foreach ($matches[1] as $referenceKey) {
$replacement = $this->resolveValue($config, $referenceKey);
$value = str_replace('%'.$referenceKey.'%', $replacement, $value);
}
array_pop($this->referenceStack);
return $value;
}
|
[
"protected",
"function",
"resolveValue",
"(",
"Config",
"$",
"config",
",",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"config",
"->",
"getRequired",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"KeyException",
"(",
"sprintf",
"(",
"'Referenced configuration key \"%s\" must not be an array.'",
",",
"$",
"key",
")",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"referenceStack",
")",
")",
"{",
"throw",
"new",
"KeyException",
"(",
"sprintf",
"(",
"'Circular reference detected resolving configuration key \"%s\"'",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"this",
"->",
"referenceStack",
"[",
"]",
"=",
"$",
"key",
";",
"preg_match_all",
"(",
"'/%([^%]+)%/'",
",",
"$",
"value",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"$",
"matches",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"referenceKey",
")",
"{",
"$",
"replacement",
"=",
"$",
"this",
"->",
"resolveValue",
"(",
"$",
"config",
",",
"$",
"referenceKey",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"'%'",
".",
"$",
"referenceKey",
".",
"'%'",
",",
"$",
"replacement",
",",
"$",
"value",
")",
";",
"}",
"array_pop",
"(",
"$",
"this",
"->",
"referenceStack",
")",
";",
"return",
"$",
"value",
";",
"}"
] |
Resolve a configuration value by replacing any %tokens% with
their substituted values.
@param Config $config
@param string $key
|
[
"Resolve",
"a",
"configuration",
"value",
"by",
"replacing",
"any",
"%tokens%",
"with",
"their",
"substituted",
"values",
"."
] |
613995cd89b6212f2beca50f646a36a08e4dcaf7
|
https://github.com/glynnforrest/speedy-config/blob/613995cd89b6212f2beca50f646a36a08e4dcaf7/src/Processor/ReferenceProcessor.php#L37-L61
|
237,035
|
kevindierkx/elicit
|
src/Connector/BasicAuthConnector.php
|
BasicAuthConnector.connect
|
public function connect(array $config)
{
$connection = $this->createConnection($config);
$this->validateCredentials($config);
// For basic authentication we need an Authorization
// header to be set. We add it to the request here.
$this->addHeader(
'Authorization',
'Basic ' . base64_encode(
array_get($config, 'identifier') . ':' . array_get($config, 'secret')
)
);
return $connection;
}
|
php
|
public function connect(array $config)
{
$connection = $this->createConnection($config);
$this->validateCredentials($config);
// For basic authentication we need an Authorization
// header to be set. We add it to the request here.
$this->addHeader(
'Authorization',
'Basic ' . base64_encode(
array_get($config, 'identifier') . ':' . array_get($config, 'secret')
)
);
return $connection;
}
|
[
"public",
"function",
"connect",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"createConnection",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"validateCredentials",
"(",
"$",
"config",
")",
";",
"// For basic authentication we need an Authorization",
"// header to be set. We add it to the request here.",
"$",
"this",
"->",
"addHeader",
"(",
"'Authorization'",
",",
"'Basic '",
".",
"base64_encode",
"(",
"array_get",
"(",
"$",
"config",
",",
"'identifier'",
")",
".",
"':'",
".",
"array_get",
"(",
"$",
"config",
",",
"'secret'",
")",
")",
")",
";",
"return",
"$",
"connection",
";",
"}"
] |
Establish an API connection.
@param array $config
@return self
|
[
"Establish",
"an",
"API",
"connection",
"."
] |
c277942f5f5f63b175bc37e9d392faa946888f65
|
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/BasicAuthConnector.php#L15-L31
|
237,036
|
nachonerd/silex_finder_provider
|
src/Extensions/Finder.php
|
Finder.sortByNameDesc
|
public function sortByNameDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return strcmp($b->getRealpath(), $a->getRealpath());
}
);
return $this;
}
|
php
|
public function sortByNameDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return strcmp($b->getRealpath(), $a->getRealpath());
}
);
return $this;
}
|
[
"public",
"function",
"sortByNameDesc",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"(",
"function",
"(",
"SplFileInfo",
"$",
"a",
",",
"SplFileInfo",
"$",
"b",
")",
"{",
"return",
"strcmp",
"(",
"$",
"b",
"->",
"getRealpath",
"(",
")",
",",
"$",
"a",
"->",
"getRealpath",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sorts files and directories by name DESC.
This can be slow as all the matching files and directories must
be retrieved for comparison.
@return Finder The current Finder instance
@see SortableIterator
@api
|
[
"Sorts",
"files",
"and",
"directories",
"by",
"name",
"DESC",
"."
] |
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
|
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L58-L66
|
237,037
|
nachonerd/silex_finder_provider
|
src/Extensions/Finder.php
|
Finder.sortByAccessedTimeDesc
|
public function sortByAccessedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getATime() - $a->getATime());
}
);
return $this;
}
|
php
|
public function sortByAccessedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getATime() - $a->getATime());
}
);
return $this;
}
|
[
"public",
"function",
"sortByAccessedTimeDesc",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"(",
"function",
"(",
"SplFileInfo",
"$",
"a",
",",
"SplFileInfo",
"$",
"b",
")",
"{",
"return",
"(",
"$",
"b",
"->",
"getATime",
"(",
")",
"-",
"$",
"a",
"->",
"getATime",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sorts files and directories by the last accessed time desc.
This is the time that the file was last accessed, read or written to.
This can be slow as all the matching files and directories must be
retrieved for comparison.
@return Finder The current Finder instance
@see SortableIterator
@api
|
[
"Sorts",
"files",
"and",
"directories",
"by",
"the",
"last",
"accessed",
"time",
"desc",
"."
] |
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
|
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L111-L119
|
237,038
|
nachonerd/silex_finder_provider
|
src/Extensions/Finder.php
|
Finder.sortByChangedTimeDesc
|
public function sortByChangedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getCTime() - $a->getCTime());
}
);
return $this;
}
|
php
|
public function sortByChangedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getCTime() - $a->getCTime());
}
);
return $this;
}
|
[
"public",
"function",
"sortByChangedTimeDesc",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"(",
"function",
"(",
"SplFileInfo",
"$",
"a",
",",
"SplFileInfo",
"$",
"b",
")",
"{",
"return",
"(",
"$",
"b",
"->",
"getCTime",
"(",
")",
"-",
"$",
"a",
"->",
"getCTime",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sorts files and directories by the last inode changed time Desc.
This is the time that the inode information was last modified
(permissions, owner, group or other metadata).
On Windows, since inode is not available, changed time is actually the
file creation time.
This can be slow as all the matching files and directories must be
retrieved for comparison.
@return Finder The current Finder instance
@see SortableIterator
@api
|
[
"Sorts",
"files",
"and",
"directories",
"by",
"the",
"last",
"inode",
"changed",
"time",
"Desc",
"."
] |
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
|
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L139-L147
|
237,039
|
nachonerd/silex_finder_provider
|
src/Extensions/Finder.php
|
Finder.sortByModifiedTimeDesc
|
public function sortByModifiedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getMTime() - $a->getMTime());
}
);
return $this;
}
|
php
|
public function sortByModifiedTimeDesc()
{
$this->sort(
function (SplFileInfo $a, SplFileInfo $b) {
return ($b->getMTime() - $a->getMTime());
}
);
return $this;
}
|
[
"public",
"function",
"sortByModifiedTimeDesc",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"(",
"function",
"(",
"SplFileInfo",
"$",
"a",
",",
"SplFileInfo",
"$",
"b",
")",
"{",
"return",
"(",
"$",
"b",
"->",
"getMTime",
"(",
")",
"-",
"$",
"a",
"->",
"getMTime",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sorts files and directories by the last modified time Desc.
This is the last time the actual contents of the file were
last modified.
This can be slow as all the matching files and directories must be
retrieved for comparison.
@return Finder The current Finder instance
@see SortableIterator
@api
|
[
"Sorts",
"files",
"and",
"directories",
"by",
"the",
"last",
"modified",
"time",
"Desc",
"."
] |
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
|
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L164-L172
|
237,040
|
nachonerd/silex_finder_provider
|
src/Extensions/Finder.php
|
Finder.getNFirst
|
public function getNFirst($n)
{
$it = new \ArrayIterator();
$j = 0;
foreach ($this as $file) {
if ($j == $n) {
break;
}
$j++;
$it->append($file);
}
$finder = new static();
$finder->append($it);
return $finder;
}
|
php
|
public function getNFirst($n)
{
$it = new \ArrayIterator();
$j = 0;
foreach ($this as $file) {
if ($j == $n) {
break;
}
$j++;
$it->append($file);
}
$finder = new static();
$finder->append($it);
return $finder;
}
|
[
"public",
"function",
"getNFirst",
"(",
"$",
"n",
")",
"{",
"$",
"it",
"=",
"new",
"\\",
"ArrayIterator",
"(",
")",
";",
"$",
"j",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"j",
"==",
"$",
"n",
")",
"{",
"break",
";",
"}",
"$",
"j",
"++",
";",
"$",
"it",
"->",
"append",
"(",
"$",
"file",
")",
";",
"}",
"$",
"finder",
"=",
"new",
"static",
"(",
")",
";",
"$",
"finder",
"->",
"append",
"(",
"$",
"it",
")",
";",
"return",
"$",
"finder",
";",
"}"
] |
Get First N Files or Dirs
@param integer $n Umpteenth Number
@return Return a new Finder instance
@see SortableIterator
@api
|
[
"Get",
"First",
"N",
"Files",
"or",
"Dirs"
] |
4956c471a2a63ae3fa29bd035311c6dafba7d0b7
|
https://github.com/nachonerd/silex_finder_provider/blob/4956c471a2a63ae3fa29bd035311c6dafba7d0b7/src/Extensions/Finder.php#L185-L201
|
237,041
|
weew/app-monolog
|
src/Weew/App/Monolog/MonologChannelManager.php
|
MonologChannelManager.getAllLoggers
|
public function getAllLoggers() {
// instantiate all loggers
foreach ($this->config->getChannelConfigs() as $name => $config) {
$this->getLogger($name);
}
return $this->getLoggers();
}
|
php
|
public function getAllLoggers() {
// instantiate all loggers
foreach ($this->config->getChannelConfigs() as $name => $config) {
$this->getLogger($name);
}
return $this->getLoggers();
}
|
[
"public",
"function",
"getAllLoggers",
"(",
")",
"{",
"// instantiate all loggers",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getChannelConfigs",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getLoggers",
"(",
")",
";",
"}"
] |
Get all registered loggers. Instantiate if necessary.
@return Logger[]
@throws UndefinedChannelException
|
[
"Get",
"all",
"registered",
"loggers",
".",
"Instantiate",
"if",
"necessary",
"."
] |
8bb5c502900736d961b735b664e0f365b87dce3d
|
https://github.com/weew/app-monolog/blob/8bb5c502900736d961b735b664e0f365b87dce3d/src/Weew/App/Monolog/MonologChannelManager.php#L80-L87
|
237,042
|
aedart/model
|
src/Traits/Strings/InvoiceAddressTrait.php
|
InvoiceAddressTrait.getInvoiceAddress
|
public function getInvoiceAddress() : ?string
{
if ( ! $this->hasInvoiceAddress()) {
$this->setInvoiceAddress($this->getDefaultInvoiceAddress());
}
return $this->invoiceAddress;
}
|
php
|
public function getInvoiceAddress() : ?string
{
if ( ! $this->hasInvoiceAddress()) {
$this->setInvoiceAddress($this->getDefaultInvoiceAddress());
}
return $this->invoiceAddress;
}
|
[
"public",
"function",
"getInvoiceAddress",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasInvoiceAddress",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setInvoiceAddress",
"(",
"$",
"this",
"->",
"getDefaultInvoiceAddress",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"invoiceAddress",
";",
"}"
] |
Get invoice address
If no "invoice address" value has been set, this method will
set and return a default "invoice address" value,
if any such value is available
@see getDefaultInvoiceAddress()
@return string|null invoice address or null if no invoice address has been set
|
[
"Get",
"invoice",
"address"
] |
9a562c1c53a276d01ace0ab71f5305458bea542f
|
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/InvoiceAddressTrait.php#L48-L54
|
237,043
|
interactivesolutions/honeycomb-pages
|
src/app/http/controllers/HCPagesController.php
|
HCPagesController.options
|
public function options()
{
if (request()->has('language')) {
$pages = HCPagesTranslations::select('record_id as id', 'title', 'language_code')
->where('language_code', request('language'));
if (request()->has('type')) {
$pages->whereHas('record', function ($query) {
$query->where('type', strtoupper(request('type')));
});
}
if (request()->has('q')) {
$pages->where('title', 'LIKE', '%' . request('q') . '%');
}
return $pages->get();
}
return [];
}
|
php
|
public function options()
{
if (request()->has('language')) {
$pages = HCPagesTranslations::select('record_id as id', 'title', 'language_code')
->where('language_code', request('language'));
if (request()->has('type')) {
$pages->whereHas('record', function ($query) {
$query->where('type', strtoupper(request('type')));
});
}
if (request()->has('q')) {
$pages->where('title', 'LIKE', '%' . request('q') . '%');
}
return $pages->get();
}
return [];
}
|
[
"public",
"function",
"options",
"(",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"'language'",
")",
")",
"{",
"$",
"pages",
"=",
"HCPagesTranslations",
"::",
"select",
"(",
"'record_id as id'",
",",
"'title'",
",",
"'language_code'",
")",
"->",
"where",
"(",
"'language_code'",
",",
"request",
"(",
"'language'",
")",
")",
";",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"'type'",
")",
")",
"{",
"$",
"pages",
"->",
"whereHas",
"(",
"'record'",
",",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'type'",
",",
"strtoupper",
"(",
"request",
"(",
"'type'",
")",
")",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"'q'",
")",
")",
"{",
"$",
"pages",
"->",
"where",
"(",
"'title'",
",",
"'LIKE'",
",",
"'%'",
".",
"request",
"(",
"'q'",
")",
".",
"'%'",
")",
";",
"}",
"return",
"$",
"pages",
"->",
"get",
"(",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Get options by request data
@return array
|
[
"Get",
"options",
"by",
"request",
"data"
] |
f628e4df80589f6e86099fb2d4fcf0fc520e8228
|
https://github.com/interactivesolutions/honeycomb-pages/blob/f628e4df80589f6e86099fb2d4fcf0fc520e8228/src/app/http/controllers/HCPagesController.php#L310-L330
|
237,044
|
crater-framework/crater-php-framework
|
Error.php
|
Error.indexAction
|
public function indexAction()
{
header("HTTP/1.0 404 Not Found");
$data['title'] = '404';
$data['error'] = $this->_error;
$this->view->render('error/404', $data);
}
|
php
|
public function indexAction()
{
header("HTTP/1.0 404 Not Found");
$data['title'] = '404';
$data['error'] = $this->_error;
$this->view->render('error/404', $data);
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"header",
"(",
"\"HTTP/1.0 404 Not Found\"",
")",
";",
"$",
"data",
"[",
"'title'",
"]",
"=",
"'404'",
";",
"$",
"data",
"[",
"'error'",
"]",
"=",
"$",
"this",
"->",
"_error",
";",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
"'error/404'",
",",
"$",
"data",
")",
";",
"}"
] |
404 page Action
load a 404 page with the error message
|
[
"404",
"page",
"Action",
"load",
"a",
"404",
"page",
"with",
"the",
"error",
"message"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Error.php#L31-L40
|
237,045
|
osflab/controller
|
Request.php
|
Request.getUri
|
public function getUri($withBaseUrl = false)
{
$prefix = $withBaseUrl ? $this->getBaseUrl() : '';
$uri = $prefix . $this->uri;
$uri = '/' . ltrim($uri, '/');
return $uri;
}
|
php
|
public function getUri($withBaseUrl = false)
{
$prefix = $withBaseUrl ? $this->getBaseUrl() : '';
$uri = $prefix . $this->uri;
$uri = '/' . ltrim($uri, '/');
return $uri;
}
|
[
"public",
"function",
"getUri",
"(",
"$",
"withBaseUrl",
"=",
"false",
")",
"{",
"$",
"prefix",
"=",
"$",
"withBaseUrl",
"?",
"$",
"this",
"->",
"getBaseUrl",
"(",
")",
":",
"''",
";",
"$",
"uri",
"=",
"$",
"prefix",
".",
"$",
"this",
"->",
"uri",
";",
"$",
"uri",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"uri",
",",
"'/'",
")",
";",
"return",
"$",
"uri",
";",
"}"
] |
Get URI without baseurl
@return string
@task [URI] Voir comment gérer le baseUrl '/'
|
[
"Get",
"URI",
"without",
"baseurl"
] |
d59344fc204a74995224e3da39b9debd78fdb974
|
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L36-L42
|
237,046
|
osflab/controller
|
Request.php
|
Request.getParams
|
public function getParams($withActionParams = false)
{
return $withActionParams ? array_merge($this->actionParams, $this->params) : $this->params;
}
|
php
|
public function getParams($withActionParams = false)
{
return $withActionParams ? array_merge($this->actionParams, $this->params) : $this->params;
}
|
[
"public",
"function",
"getParams",
"(",
"$",
"withActionParams",
"=",
"false",
")",
"{",
"return",
"$",
"withActionParams",
"?",
"array_merge",
"(",
"$",
"this",
"->",
"actionParams",
",",
"$",
"this",
"->",
"params",
")",
":",
"$",
"this",
"->",
"params",
";",
"}"
] |
Get current params
@return multitype:
|
[
"Get",
"current",
"params"
] |
d59344fc204a74995224e3da39b9debd78fdb974
|
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L77-L80
|
237,047
|
osflab/controller
|
Request.php
|
Request.getParam
|
public function getParam(string $key)
{
$isActionParam = in_array($key, [self::PARAM_CONTROLLER, self::PARAM_ACTION]);
$params = $isActionParam ? $this->actionParams: $this->params;
return array_key_exists($key, $params) ? $params[$key] : null;
}
|
php
|
public function getParam(string $key)
{
$isActionParam = in_array($key, [self::PARAM_CONTROLLER, self::PARAM_ACTION]);
$params = $isActionParam ? $this->actionParams: $this->params;
return array_key_exists($key, $params) ? $params[$key] : null;
}
|
[
"public",
"function",
"getParam",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"isActionParam",
"=",
"in_array",
"(",
"$",
"key",
",",
"[",
"self",
"::",
"PARAM_CONTROLLER",
",",
"self",
"::",
"PARAM_ACTION",
"]",
")",
";",
"$",
"params",
"=",
"$",
"isActionParam",
"?",
"$",
"this",
"->",
"actionParams",
":",
"$",
"this",
"->",
"params",
";",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"params",
")",
"?",
"$",
"params",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] |
Get param value. Get action param if key = controller or action
@param string $key
@return string|null
|
[
"Get",
"param",
"value",
".",
"Get",
"action",
"param",
"if",
"key",
"=",
"controller",
"or",
"action"
] |
d59344fc204a74995224e3da39b9debd78fdb974
|
https://github.com/osflab/controller/blob/d59344fc204a74995224e3da39b9debd78fdb974/Request.php#L87-L92
|
237,048
|
codebobbly/dvoconnector
|
Classes/Domain/Filter/GenericFilter.php
|
GenericFilter.getURLQuery
|
public function getURLQuery()
{
$qstr = '?';
$params = $this->getParametersArray();
$paramCount = count($params);
$i = 0;
foreach ($params as $key => $value) {
if ($value === null) {
continue;
}
$qstr .= $key . '=' . rawurlencode($value);
if ($i < $paramCount - 1) {
$qstr .= '&';
}
$i++;
}
return $qstr;
}
|
php
|
public function getURLQuery()
{
$qstr = '?';
$params = $this->getParametersArray();
$paramCount = count($params);
$i = 0;
foreach ($params as $key => $value) {
if ($value === null) {
continue;
}
$qstr .= $key . '=' . rawurlencode($value);
if ($i < $paramCount - 1) {
$qstr .= '&';
}
$i++;
}
return $qstr;
}
|
[
"public",
"function",
"getURLQuery",
"(",
")",
"{",
"$",
"qstr",
"=",
"'?'",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"getParametersArray",
"(",
")",
";",
"$",
"paramCount",
"=",
"count",
"(",
"$",
"params",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"qstr",
".=",
"$",
"key",
".",
"'='",
".",
"rawurlencode",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"i",
"<",
"$",
"paramCount",
"-",
"1",
")",
"{",
"$",
"qstr",
".=",
"'&'",
";",
"}",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"qstr",
";",
"}"
] |
Builds a query string from an array and takes care of proper url-encoding
@return string Query string including the '?'
|
[
"Builds",
"a",
"query",
"string",
"from",
"an",
"array",
"and",
"takes",
"care",
"of",
"proper",
"url",
"-",
"encoding"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Domain/Filter/GenericFilter.php#L26-L49
|
237,049
|
marando/phpSOFA
|
src/Marando/IAU/iauGst06.php
|
iauGst06.Gst06
|
public static function Gst06($uta, $utb, $tta, $ttb, array $rnpb) {
$x;
$y;
$s;
$era;
$eors;
$gst;
/* Extract CIP coordinates. */
IAU::Bpn2xy($rnpb, $x, $y);
/* The CIO locator, s. */
$s = IAU::S06($tta, $ttb, $x, $y);
/* Greenwich apparent sidereal time. */
$era = IAU::Era00($uta, $utb);
$eors = IAU::Eors($rnpb, $s);
$gst = IAU::Anp($era - $eors);
return $gst;
}
|
php
|
public static function Gst06($uta, $utb, $tta, $ttb, array $rnpb) {
$x;
$y;
$s;
$era;
$eors;
$gst;
/* Extract CIP coordinates. */
IAU::Bpn2xy($rnpb, $x, $y);
/* The CIO locator, s. */
$s = IAU::S06($tta, $ttb, $x, $y);
/* Greenwich apparent sidereal time. */
$era = IAU::Era00($uta, $utb);
$eors = IAU::Eors($rnpb, $s);
$gst = IAU::Anp($era - $eors);
return $gst;
}
|
[
"public",
"static",
"function",
"Gst06",
"(",
"$",
"uta",
",",
"$",
"utb",
",",
"$",
"tta",
",",
"$",
"ttb",
",",
"array",
"$",
"rnpb",
")",
"{",
"$",
"x",
";",
"$",
"y",
";",
"$",
"s",
";",
"$",
"era",
";",
"$",
"eors",
";",
"$",
"gst",
";",
"/* Extract CIP coordinates. */",
"IAU",
"::",
"Bpn2xy",
"(",
"$",
"rnpb",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"/* The CIO locator, s. */",
"$",
"s",
"=",
"IAU",
"::",
"S06",
"(",
"$",
"tta",
",",
"$",
"ttb",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"/* Greenwich apparent sidereal time. */",
"$",
"era",
"=",
"IAU",
"::",
"Era00",
"(",
"$",
"uta",
",",
"$",
"utb",
")",
";",
"$",
"eors",
"=",
"IAU",
"::",
"Eors",
"(",
"$",
"rnpb",
",",
"$",
"s",
")",
";",
"$",
"gst",
"=",
"IAU",
"::",
"Anp",
"(",
"$",
"era",
"-",
"$",
"eors",
")",
";",
"return",
"$",
"gst",
";",
"}"
] |
- - - - - - - - -
i a u G s t 0 6
- - - - - - - - -
Greenwich apparent sidereal time, IAU 2006, given the NPB matrix.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: support function.
Given:
uta,utb double UT1 as a 2-part Julian Date (Notes 1,2)
tta,ttb double TT as a 2-part Julian Date (Notes 1,2)
rnpb double[3][3] nutation x precession x bias matrix
Returned (function value):
double Greenwich apparent sidereal time (radians)
Notes:
1) The UT1 and TT dates uta+utb and tta+ttb respectively, are both
Julian Dates, apportioned in any convenient way between the
argument pairs. For example, JD=2450123.7 could be expressed in
any of these ways, among others:
Part A Part B
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable (in the case of UT; the TT is not at all critical
in this respect). The J2000 and MJD methods are good compromises
between resolution and convenience. For UT, the date & time
method is best matched to the algorithm that is used by the Earth
rotation angle function, called internally: maximum precision is
delivered when the uta argument is for 0hrs UT1 on the day in
question and the utb argument lies in the range 0 to 1, or vice
versa.
2) Both UT1 and TT are required, UT1 to predict the Earth rotation
and TT to predict the effects of precession-nutation. If UT1 is
used for both purposes, errors of order 100 microarcseconds
result.
3) Although the function uses the IAU 2006 series for s+XY/2, it is
otherwise independent of the precession-nutation model and can in
practice be used with any equinox-based NPB matrix.
4) The result is returned in the range 0 to 2pi.
Called:
iauBpn2xy extract CIP X,Y coordinates from NPB matrix
iauS06 the CIO locator s, given X,Y, IAU 2006
iauAnp normalize angle into range 0 to 2pi
iauEra00 Earth rotation angle, IAU 2000
iauEors equation of the origins, given NPB matrix and s
Reference:
Wallace, P.T. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"G",
"s",
"t",
"0",
"6",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGst06.php#L80-L100
|
237,050
|
DevGroup-ru/yii2-admin-utils
|
src/traits/BackendRedirect.php
|
BackendRedirect.redirectUser
|
public function redirectUser(
$id,
$setFlash = true,
$indexAction = ['index'],
$editAction = ['edit'],
$overrideReturnUrl = false
) {
/** @var \yii\web\Controller $this */
if ($setFlash === true) {
Yii::$app->session->setFlash('success', AdminModule::t('app', 'Object saved'));
} elseif (is_string($setFlash)) {
Yii::$app->session->setFlash('success', $setFlash);
}
if ($overrideReturnUrl === false) {
$returnUrl = Yii::$app->request->get(
'returnUrl',
Yii::$app->request->getReferrer() === null ? Url::to([$indexAction]) : Yii::$app->request->getReferrer()
);
} else {
$returnUrl = $overrideReturnUrl;
}
switch (Yii::$app->request->post('action', 'save')) {
case 'save-and-next':
// as you can see there's no id param here and there should be no such in $editAction
$url = $editAction;
$url['returnUrl'] = $returnUrl;
return $this->redirect($url);
case 'save-and-back':
return $this->redirect($returnUrl);
default:
$url = $editAction;
$url['returnUrl'] = $returnUrl;
$url['id'] = $id;
return $this->redirect($url);
}
}
|
php
|
public function redirectUser(
$id,
$setFlash = true,
$indexAction = ['index'],
$editAction = ['edit'],
$overrideReturnUrl = false
) {
/** @var \yii\web\Controller $this */
if ($setFlash === true) {
Yii::$app->session->setFlash('success', AdminModule::t('app', 'Object saved'));
} elseif (is_string($setFlash)) {
Yii::$app->session->setFlash('success', $setFlash);
}
if ($overrideReturnUrl === false) {
$returnUrl = Yii::$app->request->get(
'returnUrl',
Yii::$app->request->getReferrer() === null ? Url::to([$indexAction]) : Yii::$app->request->getReferrer()
);
} else {
$returnUrl = $overrideReturnUrl;
}
switch (Yii::$app->request->post('action', 'save')) {
case 'save-and-next':
// as you can see there's no id param here and there should be no such in $editAction
$url = $editAction;
$url['returnUrl'] = $returnUrl;
return $this->redirect($url);
case 'save-and-back':
return $this->redirect($returnUrl);
default:
$url = $editAction;
$url['returnUrl'] = $returnUrl;
$url['id'] = $id;
return $this->redirect($url);
}
}
|
[
"public",
"function",
"redirectUser",
"(",
"$",
"id",
",",
"$",
"setFlash",
"=",
"true",
",",
"$",
"indexAction",
"=",
"[",
"'index'",
"]",
",",
"$",
"editAction",
"=",
"[",
"'edit'",
"]",
",",
"$",
"overrideReturnUrl",
"=",
"false",
")",
"{",
"/** @var \\yii\\web\\Controller $this */",
"if",
"(",
"$",
"setFlash",
"===",
"true",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"AdminModule",
"::",
"t",
"(",
"'app'",
",",
"'Object saved'",
")",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"setFlash",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"$",
"setFlash",
")",
";",
"}",
"if",
"(",
"$",
"overrideReturnUrl",
"===",
"false",
")",
"{",
"$",
"returnUrl",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'returnUrl'",
",",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getReferrer",
"(",
")",
"===",
"null",
"?",
"Url",
"::",
"to",
"(",
"[",
"$",
"indexAction",
"]",
")",
":",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getReferrer",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"returnUrl",
"=",
"$",
"overrideReturnUrl",
";",
"}",
"switch",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'action'",
",",
"'save'",
")",
")",
"{",
"case",
"'save-and-next'",
":",
"// as you can see there's no id param here and there should be no such in $editAction",
"$",
"url",
"=",
"$",
"editAction",
";",
"$",
"url",
"[",
"'returnUrl'",
"]",
"=",
"$",
"returnUrl",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"url",
")",
";",
"case",
"'save-and-back'",
":",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"returnUrl",
")",
";",
"default",
":",
"$",
"url",
"=",
"$",
"editAction",
";",
"$",
"url",
"[",
"'returnUrl'",
"]",
"=",
"$",
"returnUrl",
";",
"$",
"url",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"url",
")",
";",
"}",
"}"
] |
Redirects user as was specified by his action and returnUrl variable on successful record saving.
@param string|integer $id Id of model
@param bool|string $setFlash True if set standard flash, string for custom flash, false for not setting any flash
@param array $indexAction URL route array to index action, must include route and can include additional params
@param array $editAction URL route array to edit action, must include route and can include additional params
@param array|boolean $overrideReturnUrl false to use default returnUrl from _GET or array to create new url
@return \yii\web\Response
|
[
"Redirects",
"user",
"as",
"was",
"specified",
"by",
"his",
"action",
"and",
"returnUrl",
"variable",
"on",
"successful",
"record",
"saving",
"."
] |
15c1853a5ec264602de3ad82dbf70f85de66adff
|
https://github.com/DevGroup-ru/yii2-admin-utils/blob/15c1853a5ec264602de3ad82dbf70f85de66adff/src/traits/BackendRedirect.php#L32-L69
|
237,051
|
Kagency/http-replay
|
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
|
Symfony2.convertFromRequest
|
public function convertFromRequest(SimplifiedRequest $request)
{
return Request::create(
$request->path,
$request->method,
array(),
array(),
array(),
$this->mapHeaderKeys($request->headers),
$request->content
);
}
|
php
|
public function convertFromRequest(SimplifiedRequest $request)
{
return Request::create(
$request->path,
$request->method,
array(),
array(),
array(),
$this->mapHeaderKeys($request->headers),
$request->content
);
}
|
[
"public",
"function",
"convertFromRequest",
"(",
"SimplifiedRequest",
"$",
"request",
")",
"{",
"return",
"Request",
"::",
"create",
"(",
"$",
"request",
"->",
"path",
",",
"$",
"request",
"->",
"method",
",",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"$",
"this",
"->",
"mapHeaderKeys",
"(",
"$",
"request",
"->",
"headers",
")",
",",
"$",
"request",
"->",
"content",
")",
";",
"}"
] |
Convert from simplified request
Converts a simplified request into the request structure you need for
your current framework.
@param SimplifiedRequest $request
@return mixed
|
[
"Convert",
"from",
"simplified",
"request"
] |
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
|
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L23-L34
|
237,052
|
Kagency/http-replay
|
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
|
Symfony2.mapHeaderKeys
|
protected function mapHeaderKeys(array $headers)
{
$phpHeaders = array();
foreach ($headers as $key => $value) {
$phpHeaders['HTTP_' . str_replace('-', '_', strtoupper($key))] = $value;
}
return $phpHeaders;
}
|
php
|
protected function mapHeaderKeys(array $headers)
{
$phpHeaders = array();
foreach ($headers as $key => $value) {
$phpHeaders['HTTP_' . str_replace('-', '_', strtoupper($key))] = $value;
}
return $phpHeaders;
}
|
[
"protected",
"function",
"mapHeaderKeys",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"phpHeaders",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"phpHeaders",
"[",
"'HTTP_'",
".",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"strtoupper",
"(",
"$",
"key",
")",
")",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"phpHeaders",
";",
"}"
] |
Map header keys
@param array $headers
@return array
|
[
"Map",
"header",
"keys"
] |
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
|
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L42-L50
|
237,053
|
Kagency/http-replay
|
src/Kagency/HttpReplay/MessageHandler/Symfony2.php
|
Symfony2.convertFromResponse
|
public function convertFromResponse(SimplifiedResponse $response)
{
return Response::create(
$response->content,
$response->status,
$response->headers
);
}
|
php
|
public function convertFromResponse(SimplifiedResponse $response)
{
return Response::create(
$response->content,
$response->status,
$response->headers
);
}
|
[
"public",
"function",
"convertFromResponse",
"(",
"SimplifiedResponse",
"$",
"response",
")",
"{",
"return",
"Response",
"::",
"create",
"(",
"$",
"response",
"->",
"content",
",",
"$",
"response",
"->",
"status",
",",
"$",
"response",
"->",
"headers",
")",
";",
"}"
] |
Convert from simplified response
Converts a simplified response into the response structure you need for
your current framework.
@param SimplifiedResponse $response
@return mixed
|
[
"Convert",
"from",
"simplified",
"response"
] |
333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5
|
https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/MessageHandler/Symfony2.php#L61-L68
|
237,054
|
mgufrone/silex-assets-provider
|
src/Gufy/Service/Provider/AssetsMinifier.php
|
AssetsMinifier.compress
|
public function compress($type, $files, $file)
{
// files have been updated so update the minified file
if($this->isUpdated($files))
{
$content = $this->getFileContents($files);
switch($type){
case 'css':
$content = $this->minifyCSS($content);
break;
case 'js':
$content = $this->minifyJS($content);
break;
}
$this->saveFile($file, $content);
}
return str_replace($this->scriptPath,$this->coreUrl,$file);
}
|
php
|
public function compress($type, $files, $file)
{
// files have been updated so update the minified file
if($this->isUpdated($files))
{
$content = $this->getFileContents($files);
switch($type){
case 'css':
$content = $this->minifyCSS($content);
break;
case 'js':
$content = $this->minifyJS($content);
break;
}
$this->saveFile($file, $content);
}
return str_replace($this->scriptPath,$this->coreUrl,$file);
}
|
[
"public",
"function",
"compress",
"(",
"$",
"type",
",",
"$",
"files",
",",
"$",
"file",
")",
"{",
"// files have been updated so update the minified file",
"if",
"(",
"$",
"this",
"->",
"isUpdated",
"(",
"$",
"files",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getFileContents",
"(",
"$",
"files",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'css'",
":",
"$",
"content",
"=",
"$",
"this",
"->",
"minifyCSS",
"(",
"$",
"content",
")",
";",
"break",
";",
"case",
"'js'",
":",
"$",
"content",
"=",
"$",
"this",
"->",
"minifyJS",
"(",
"$",
"content",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"file",
",",
"$",
"content",
")",
";",
"}",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"scriptPath",
",",
"$",
"this",
"->",
"coreUrl",
",",
"$",
"file",
")",
";",
"}"
] |
get all contents and process the whole contents
@param string $type compress by type
@param array $files files that will be compressed
@param string $file
@return string return cache url of
|
[
"get",
"all",
"contents",
"and",
"process",
"the",
"whole",
"contents"
] |
072ca09f997225f1f298ca5f77dc23280dd6aa7a
|
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsMinifier.php#L96-L113
|
237,055
|
mgufrone/silex-assets-provider
|
src/Gufy/Service/Provider/AssetsMinifier.php
|
AssetsMinifier.getFileContents
|
private function getFileContents($files)
{
$content = '';
$basePath = $this->basePath;
array_walk($files,function(&$value, $key) use(&$content, $basePath){
if(file_exists($basePath.$value))
$content .= file_get_contents($basePath.$value);
});
return $content;
}
|
php
|
private function getFileContents($files)
{
$content = '';
$basePath = $this->basePath;
array_walk($files,function(&$value, $key) use(&$content, $basePath){
if(file_exists($basePath.$value))
$content .= file_get_contents($basePath.$value);
});
return $content;
}
|
[
"private",
"function",
"getFileContents",
"(",
"$",
"files",
")",
"{",
"$",
"content",
"=",
"''",
";",
"$",
"basePath",
"=",
"$",
"this",
"->",
"basePath",
";",
"array_walk",
"(",
"$",
"files",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"&",
"$",
"content",
",",
"$",
"basePath",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"basePath",
".",
"$",
"value",
")",
")",
"$",
"content",
".=",
"file_get_contents",
"(",
"$",
"basePath",
".",
"$",
"value",
")",
";",
"}",
")",
";",
"return",
"$",
"content",
";",
"}"
] |
get contents of all registered files, it is also check whether file is exist or not
@param array $files all files that will be retrieved
@return strign return mixed of all contents
|
[
"get",
"contents",
"of",
"all",
"registered",
"files",
"it",
"is",
"also",
"check",
"whether",
"file",
"is",
"exist",
"or",
"not"
] |
072ca09f997225f1f298ca5f77dc23280dd6aa7a
|
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsMinifier.php#L154-L164
|
237,056
|
douyacun/dyc-pay-supports
|
src/Traits/HasHttpRequest.php
|
HasHttpRequest.getBaseOptions
|
protected function getBaseOptions()
{
$options = [
'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
'connect_timeout' => property_exists($this, 'connect_timeout') ? $this->connect_timeout : 5.0,
];
return $options;
}
|
php
|
protected function getBaseOptions()
{
$options = [
'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
'connect_timeout' => property_exists($this, 'connect_timeout') ? $this->connect_timeout : 5.0,
];
return $options;
}
|
[
"protected",
"function",
"getBaseOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"'base_uri'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'baseUri'",
")",
"?",
"$",
"this",
"->",
"baseUri",
":",
"''",
",",
"'timeout'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'timeout'",
")",
"?",
"$",
"this",
"->",
"timeout",
":",
"5.0",
",",
"'connect_timeout'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'connect_timeout'",
")",
"?",
"$",
"this",
"->",
"connect_timeout",
":",
"5.0",
",",
"]",
";",
"return",
"$",
"options",
";",
"}"
] |
Get base options.
@author yansongda <me@yansongda.cn>
@return array
|
[
"Get",
"base",
"options",
"."
] |
d676c7f0b8ac2da2954b4b76448af18c9953381e
|
https://github.com/douyacun/dyc-pay-supports/blob/d676c7f0b8ac2da2954b4b76448af18c9953381e/src/Traits/HasHttpRequest.php#L74-L83
|
237,057
|
slickframework/mvc
|
src/Controller/EntityCreateMethods.php
|
EntityCreateMethods.add
|
public function add()
{
$form = $this->getForm();
$this->set(compact('form'));
if (!$form->wasSubmitted()) {
return;
}
try {
$this->getUpdateService()
->setForm($form)
->update();
;
} catch (InvalidFormDataException $caught) {
Log::logger()->addNotice($caught->getMessage(), $form->getData());
$this->addErrorMessage($this->getInvalidFormDataMessage());
return;
} catch (\Exception $caught) {
Log::logger()->addCritical(
$caught->getMessage(),
$form->getData()
);
$this->addErrorMessage($this->getGeneralErrorMessage($caught));
return;
}
$this->addSuccessMessage(
$this->getCreateSuccessMessage(
$this->getUpdateService()->getEntity()
)
);
$this->redirectFromCreated($this->getUpdateService()->getEntity());
}
|
php
|
public function add()
{
$form = $this->getForm();
$this->set(compact('form'));
if (!$form->wasSubmitted()) {
return;
}
try {
$this->getUpdateService()
->setForm($form)
->update();
;
} catch (InvalidFormDataException $caught) {
Log::logger()->addNotice($caught->getMessage(), $form->getData());
$this->addErrorMessage($this->getInvalidFormDataMessage());
return;
} catch (\Exception $caught) {
Log::logger()->addCritical(
$caught->getMessage(),
$form->getData()
);
$this->addErrorMessage($this->getGeneralErrorMessage($caught));
return;
}
$this->addSuccessMessage(
$this->getCreateSuccessMessage(
$this->getUpdateService()->getEntity()
)
);
$this->redirectFromCreated($this->getUpdateService()->getEntity());
}
|
[
"public",
"function",
"add",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'form'",
")",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"wasSubmitted",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"getUpdateService",
"(",
")",
"->",
"setForm",
"(",
"$",
"form",
")",
"->",
"update",
"(",
")",
";",
";",
"}",
"catch",
"(",
"InvalidFormDataException",
"$",
"caught",
")",
"{",
"Log",
"::",
"logger",
"(",
")",
"->",
"addNotice",
"(",
"$",
"caught",
"->",
"getMessage",
"(",
")",
",",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"$",
"this",
"->",
"addErrorMessage",
"(",
"$",
"this",
"->",
"getInvalidFormDataMessage",
"(",
")",
")",
";",
"return",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"caught",
")",
"{",
"Log",
"::",
"logger",
"(",
")",
"->",
"addCritical",
"(",
"$",
"caught",
"->",
"getMessage",
"(",
")",
",",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"$",
"this",
"->",
"addErrorMessage",
"(",
"$",
"this",
"->",
"getGeneralErrorMessage",
"(",
"$",
"caught",
")",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"addSuccessMessage",
"(",
"$",
"this",
"->",
"getCreateSuccessMessage",
"(",
"$",
"this",
"->",
"getUpdateService",
"(",
")",
"->",
"getEntity",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"redirectFromCreated",
"(",
"$",
"this",
"->",
"getUpdateService",
"(",
")",
"->",
"getEntity",
"(",
")",
")",
";",
"}"
] |
Handle the add entity request
|
[
"Handle",
"the",
"add",
"entity",
"request"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/EntityCreateMethods.php#L33-L66
|
237,058
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator.handleflags
|
function handleflags($i, $argv)
{
if (!isset($argv[1]) || !isset(self::$_options[$argv[$i][1]])) {
throw new Exception('Command line syntax error: undefined option "' . $argv[$i] . '"');
}
$v = self::$_options[$argv[$i][1]] == '-';
if (self::$_options[$argv[$i][1]]['type'] == self::OPT_FLAG) {
$this->{self::$_options[$argv[$i][1]]['arg']} = 1;
} elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FFLAG) {
$this->{self::$_options[$argv[$i][1]]['arg']}($v);
} elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FSTR) {
$this->{self::$_options[$argv[$i][1]]['arg']}(substr($v, 2));
} else {
throw new Exception('Command line syntax error: missing argument on switch: "' . $argv[$i] . '"');
}
return 0;
}
|
php
|
function handleflags($i, $argv)
{
if (!isset($argv[1]) || !isset(self::$_options[$argv[$i][1]])) {
throw new Exception('Command line syntax error: undefined option "' . $argv[$i] . '"');
}
$v = self::$_options[$argv[$i][1]] == '-';
if (self::$_options[$argv[$i][1]]['type'] == self::OPT_FLAG) {
$this->{self::$_options[$argv[$i][1]]['arg']} = 1;
} elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FFLAG) {
$this->{self::$_options[$argv[$i][1]]['arg']}($v);
} elseif (self::$_options[$argv[$i][1]]['type'] == self::OPT_FSTR) {
$this->{self::$_options[$argv[$i][1]]['arg']}(substr($v, 2));
} else {
throw new Exception('Command line syntax error: missing argument on switch: "' . $argv[$i] . '"');
}
return 0;
}
|
[
"function",
"handleflags",
"(",
"$",
"i",
",",
"$",
"argv",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"argv",
"[",
"1",
"]",
")",
"||",
"!",
"isset",
"(",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Command line syntax error: undefined option \"'",
".",
"$",
"argv",
"[",
"$",
"i",
"]",
".",
"'\"'",
")",
";",
"}",
"$",
"v",
"=",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"==",
"'-'",
";",
"if",
"(",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'type'",
"]",
"==",
"self",
"::",
"OPT_FLAG",
")",
"{",
"$",
"this",
"->",
"{",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'arg'",
"]",
"}",
"=",
"1",
";",
"}",
"elseif",
"(",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'type'",
"]",
"==",
"self",
"::",
"OPT_FFLAG",
")",
"{",
"$",
"this",
"->",
"{",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'arg'",
"]",
"}",
"(",
"$",
"v",
")",
";",
"}",
"elseif",
"(",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'type'",
"]",
"==",
"self",
"::",
"OPT_FSTR",
")",
"{",
"$",
"this",
"->",
"{",
"self",
"::",
"$",
"_options",
"[",
"$",
"argv",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"]",
"[",
"'arg'",
"]",
"}",
"(",
"substr",
"(",
"$",
"v",
",",
"2",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Command line syntax error: missing argument on switch: \"'",
".",
"$",
"argv",
"[",
"$",
"i",
"]",
".",
"'\"'",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Process a flag command line argument.
@param int $i
@param array $argv
@return int
|
[
"Process",
"a",
"flag",
"command",
"line",
"argument",
"."
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L171-L187
|
237,059
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator._argindex
|
private function _argindex($n, $a)
{
$dashdash = 0;
if (!is_array($a) || !count($a)) {
return -1;
}
for ($i=1; $i < count($a); $i++) {
if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' || strchr($a[$i], '='))) {
if ($n == 0) {
return $i;
}
$n--;
}
if ($_SERVER['argv'][$i] == '--') {
$dashdash = 1;
}
}
return -1;
}
|
php
|
private function _argindex($n, $a)
{
$dashdash = 0;
if (!is_array($a) || !count($a)) {
return -1;
}
for ($i=1; $i < count($a); $i++) {
if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' || strchr($a[$i], '='))) {
if ($n == 0) {
return $i;
}
$n--;
}
if ($_SERVER['argv'][$i] == '--') {
$dashdash = 1;
}
}
return -1;
}
|
[
"private",
"function",
"_argindex",
"(",
"$",
"n",
",",
"$",
"a",
")",
"{",
"$",
"dashdash",
"=",
"0",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"a",
")",
"||",
"!",
"count",
"(",
"$",
"a",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"a",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"dashdash",
"||",
"!",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"'-'",
"||",
"$",
"a",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
"==",
"'+'",
"||",
"strchr",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
",",
"'='",
")",
")",
")",
"{",
"if",
"(",
"$",
"n",
"==",
"0",
")",
"{",
"return",
"$",
"i",
";",
"}",
"$",
"n",
"--",
";",
"}",
"if",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"$",
"i",
"]",
"==",
"'--'",
")",
"{",
"$",
"dashdash",
"=",
"1",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Return the index of the N-th non-switch argument. Return -1
if N is out of range.
@param int $n
@param int $a
@return int
|
[
"Return",
"the",
"index",
"of",
"the",
"N",
"-",
"th",
"non",
"-",
"switch",
"argument",
".",
"Return",
"-",
"1",
"if",
"N",
"is",
"out",
"of",
"range",
"."
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L296-L314
|
237,060
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator.OptPrint
|
function OptPrint()
{
$max = 0;
foreach (self::$_options as $label => $info) {
$len = strlen($label) + 1;
switch ($info['type']) {
case self::OPT_FLAG:
case self::OPT_FFLAG:
break;
case self::OPT_INT:
case self::OPT_FINT:
$len += 9; /* length of "<integer>" */
break;
case self::OPT_DBL:
case self::OPT_FDBL:
$len += 6; /* length of "<real>" */
break;
case self::OPT_STR:
case self::OPT_FSTR:
$len += 8; /* length of "<string>" */
break;
}
if ($len > $max) {
$max = $len;
}
}
foreach (self::$_options as $label => $info) {
switch ($info['type']) {
case self::OPT_FLAG:
case self::OPT_FFLAG:
echo " -$label";
echo str_repeat(' ', $max - strlen($label));
echo " $info[message]\n";
break;
case self::OPT_INT:
case self::OPT_FINT:
echo " $label=<integer>" . str_repeat(' ', $max - strlen($label) - 9);
echo " $info[message]\n";
break;
case self::OPT_DBL:
case self::OPT_FDBL:
echo " $label=<real>" . str_repeat(' ', $max - strlen($label) - 6);
echo " $info[message]\n";
break;
case self::OPT_STR:
case self::OPT_FSTR:
echo " $label=<string>" . str_repeat(' ', $max - strlen($label) - 8);
echo " $info[message]\n";
break;
}
}
}
|
php
|
function OptPrint()
{
$max = 0;
foreach (self::$_options as $label => $info) {
$len = strlen($label) + 1;
switch ($info['type']) {
case self::OPT_FLAG:
case self::OPT_FFLAG:
break;
case self::OPT_INT:
case self::OPT_FINT:
$len += 9; /* length of "<integer>" */
break;
case self::OPT_DBL:
case self::OPT_FDBL:
$len += 6; /* length of "<real>" */
break;
case self::OPT_STR:
case self::OPT_FSTR:
$len += 8; /* length of "<string>" */
break;
}
if ($len > $max) {
$max = $len;
}
}
foreach (self::$_options as $label => $info) {
switch ($info['type']) {
case self::OPT_FLAG:
case self::OPT_FFLAG:
echo " -$label";
echo str_repeat(' ', $max - strlen($label));
echo " $info[message]\n";
break;
case self::OPT_INT:
case self::OPT_FINT:
echo " $label=<integer>" . str_repeat(' ', $max - strlen($label) - 9);
echo " $info[message]\n";
break;
case self::OPT_DBL:
case self::OPT_FDBL:
echo " $label=<real>" . str_repeat(' ', $max - strlen($label) - 6);
echo " $info[message]\n";
break;
case self::OPT_STR:
case self::OPT_FSTR:
echo " $label=<string>" . str_repeat(' ', $max - strlen($label) - 8);
echo " $info[message]\n";
break;
}
}
}
|
[
"function",
"OptPrint",
"(",
")",
"{",
"$",
"max",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"$",
"_options",
"as",
"$",
"label",
"=>",
"$",
"info",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"label",
")",
"+",
"1",
";",
"switch",
"(",
"$",
"info",
"[",
"'type'",
"]",
")",
"{",
"case",
"self",
"::",
"OPT_FLAG",
":",
"case",
"self",
"::",
"OPT_FFLAG",
":",
"break",
";",
"case",
"self",
"::",
"OPT_INT",
":",
"case",
"self",
"::",
"OPT_FINT",
":",
"$",
"len",
"+=",
"9",
";",
"/* length of \"<integer>\" */",
"break",
";",
"case",
"self",
"::",
"OPT_DBL",
":",
"case",
"self",
"::",
"OPT_FDBL",
":",
"$",
"len",
"+=",
"6",
";",
"/* length of \"<real>\" */",
"break",
";",
"case",
"self",
"::",
"OPT_STR",
":",
"case",
"self",
"::",
"OPT_FSTR",
":",
"$",
"len",
"+=",
"8",
";",
"/* length of \"<string>\" */",
"break",
";",
"}",
"if",
"(",
"$",
"len",
">",
"$",
"max",
")",
"{",
"$",
"max",
"=",
"$",
"len",
";",
"}",
"}",
"foreach",
"(",
"self",
"::",
"$",
"_options",
"as",
"$",
"label",
"=>",
"$",
"info",
")",
"{",
"switch",
"(",
"$",
"info",
"[",
"'type'",
"]",
")",
"{",
"case",
"self",
"::",
"OPT_FLAG",
":",
"case",
"self",
"::",
"OPT_FFLAG",
":",
"echo",
"\" -$label\"",
";",
"echo",
"str_repeat",
"(",
"' '",
",",
"$",
"max",
"-",
"strlen",
"(",
"$",
"label",
")",
")",
";",
"echo",
"\" $info[message]\\n\"",
";",
"break",
";",
"case",
"self",
"::",
"OPT_INT",
":",
"case",
"self",
"::",
"OPT_FINT",
":",
"echo",
"\" $label=<integer>\"",
".",
"str_repeat",
"(",
"' '",
",",
"$",
"max",
"-",
"strlen",
"(",
"$",
"label",
")",
"-",
"9",
")",
";",
"echo",
"\" $info[message]\\n\"",
";",
"break",
";",
"case",
"self",
"::",
"OPT_DBL",
":",
"case",
"self",
"::",
"OPT_FDBL",
":",
"echo",
"\" $label=<real>\"",
".",
"str_repeat",
"(",
"' '",
",",
"$",
"max",
"-",
"strlen",
"(",
"$",
"label",
")",
"-",
"6",
")",
";",
"echo",
"\" $info[message]\\n\"",
";",
"break",
";",
"case",
"self",
"::",
"OPT_STR",
":",
"case",
"self",
"::",
"OPT_FSTR",
":",
"echo",
"\" $label=<string>\"",
".",
"str_repeat",
"(",
"' '",
",",
"$",
"max",
"-",
"strlen",
"(",
"$",
"label",
")",
"-",
"8",
")",
";",
"echo",
"\" $info[message]\\n\"",
";",
"break",
";",
"}",
"}",
"}"
] |
Print out command-line options
@return void
|
[
"Print",
"out",
"command",
"-",
"line",
"options"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L360-L411
|
237,061
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator._handleDOption
|
private function _handleDOption($z)
{
if ($a = strstr($z, '=')) {
$z = substr($a, 1); // strip first =
}
$this->azDefine[] = $z;
}
|
php
|
private function _handleDOption($z)
{
if ($a = strstr($z, '=')) {
$z = substr($a, 1); // strip first =
}
$this->azDefine[] = $z;
}
|
[
"private",
"function",
"_handleDOption",
"(",
"$",
"z",
")",
"{",
"if",
"(",
"$",
"a",
"=",
"strstr",
"(",
"$",
"z",
",",
"'='",
")",
")",
"{",
"$",
"z",
"=",
"substr",
"(",
"$",
"a",
",",
"1",
")",
";",
"// strip first =",
"}",
"$",
"this",
"->",
"azDefine",
"[",
"]",
"=",
"$",
"z",
";",
"}"
] |
This routine is called with the argument to each -D command-line option.
Add the macro defined to the azDefine array.
@param string $z
@return void
|
[
"This",
"routine",
"is",
"called",
"with",
"the",
"argument",
"to",
"each",
"-",
"D",
"command",
"-",
"line",
"option",
".",
"Add",
"the",
"macro",
"defined",
"to",
"the",
"azDefine",
"array",
"."
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L421-L427
|
237,062
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator.merge
|
static function merge($a, $b, $cmp, $offset)
{
if ($a === 0) {
$head = $b;
} elseif ($b === 0) {
$head = $a;
} else {
if (call_user_func($cmp, $a, $b) < 0) {
$ptr = $a;
$a = $a->$offset;
} else {
$ptr = $b;
$b = $b->$offset;
}
$head = $ptr;
while ($a && $b) {
if (call_user_func($cmp, $a, $b) < 0) {
$ptr->$offset = $a;
$ptr = $a;
$a = $a->$offset;
} else {
$ptr->$offset = $b;
$ptr = $b;
$b = $b->$offset;
}
}
if ($a !== 0) {
$ptr->$offset = $a;
} else {
$ptr->$offset = $b;
}
}
return $head;
}
|
php
|
static function merge($a, $b, $cmp, $offset)
{
if ($a === 0) {
$head = $b;
} elseif ($b === 0) {
$head = $a;
} else {
if (call_user_func($cmp, $a, $b) < 0) {
$ptr = $a;
$a = $a->$offset;
} else {
$ptr = $b;
$b = $b->$offset;
}
$head = $ptr;
while ($a && $b) {
if (call_user_func($cmp, $a, $b) < 0) {
$ptr->$offset = $a;
$ptr = $a;
$a = $a->$offset;
} else {
$ptr->$offset = $b;
$ptr = $b;
$b = $b->$offset;
}
}
if ($a !== 0) {
$ptr->$offset = $a;
} else {
$ptr->$offset = $b;
}
}
return $head;
}
|
[
"static",
"function",
"merge",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"cmp",
",",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"a",
"===",
"0",
")",
"{",
"$",
"head",
"=",
"$",
"b",
";",
"}",
"elseif",
"(",
"$",
"b",
"===",
"0",
")",
"{",
"$",
"head",
"=",
"$",
"a",
";",
"}",
"else",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"cmp",
",",
"$",
"a",
",",
"$",
"b",
")",
"<",
"0",
")",
"{",
"$",
"ptr",
"=",
"$",
"a",
";",
"$",
"a",
"=",
"$",
"a",
"->",
"$",
"offset",
";",
"}",
"else",
"{",
"$",
"ptr",
"=",
"$",
"b",
";",
"$",
"b",
"=",
"$",
"b",
"->",
"$",
"offset",
";",
"}",
"$",
"head",
"=",
"$",
"ptr",
";",
"while",
"(",
"$",
"a",
"&&",
"$",
"b",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"cmp",
",",
"$",
"a",
",",
"$",
"b",
")",
"<",
"0",
")",
"{",
"$",
"ptr",
"->",
"$",
"offset",
"=",
"$",
"a",
";",
"$",
"ptr",
"=",
"$",
"a",
";",
"$",
"a",
"=",
"$",
"a",
"->",
"$",
"offset",
";",
"}",
"else",
"{",
"$",
"ptr",
"->",
"$",
"offset",
"=",
"$",
"b",
";",
"$",
"ptr",
"=",
"$",
"b",
";",
"$",
"b",
"=",
"$",
"b",
"->",
"$",
"offset",
";",
"}",
"}",
"if",
"(",
"$",
"a",
"!==",
"0",
")",
"{",
"$",
"ptr",
"->",
"$",
"offset",
"=",
"$",
"a",
";",
"}",
"else",
"{",
"$",
"ptr",
"->",
"$",
"offset",
"=",
"$",
"b",
";",
"}",
"}",
"return",
"$",
"head",
";",
"}"
] |
Merge in a merge sort for a linked list
Side effects:
The "next" pointers for elements in the lists a and b are
changed.
@param mixed $a A sorted, null-terminated linked list. (May be null).
@param mixed $b A sorted, null-terminated linked list. (May be null).
@param function $cmp A pointer to the comparison function.
@param integer $offset Offset in the structure to the "next" field.
@return mixed A pointer to the head of a sorted list containing the
elements of both a and b.
|
[
"Merge",
"in",
"a",
"merge",
"sort",
"for",
"a",
"linked",
"list"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L611-L644
|
237,063
|
rodchyn/elephant-lang
|
lib/ParserGenerator/ParserGenerator.php
|
PHP_ParserGenerator.Reprint
|
function Reprint()
{
printf("// Reprint of input file \"%s\".\n// Symbols:\n", $this->filename);
$maxlen = 10;
for ($i = 0; $i < $this->nsymbol; $i++) {
$sp = $this->symbols[$i];
$len = strlen($sp->name);
if ($len > $maxlen ) {
$maxlen = $len;
}
}
$ncolumns = 76 / ($maxlen + 5);
if ($ncolumns < 1) {
$ncolumns = 1;
}
$skip = ($this->nsymbol + $ncolumns - 1) / $ncolumns;
for ($i = 0; $i < $skip; $i++) {
print "//";
for ($j = $i; $j < $this->nsymbol; $j += $skip) {
$sp = $this->symbols[$j];
//assert( sp->index==j );
printf(" %3d %-${maxlen}.${maxlen}s", $j, $sp->name);
}
print "\n";
}
for ($rp = $this->rule; $rp; $rp = $rp->next) {
printf("%s", $rp->lhs->name);
/*if ($rp->lhsalias) {
printf("(%s)", $rp->lhsalias);
}*/
print " ::=";
for ($i = 0; $i < $rp->nrhs; $i++) {
$sp = $rp->rhs[$i];
printf(" %s", $sp->name);
if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
for ($j = 1; $j < $sp->nsubsym; $j++) {
printf("|%s", $sp->subsym[$j]->name);
}
}
/*if ($rp->rhsalias[$i]) {
printf("(%s)", $rp->rhsalias[$i]);
}*/
}
print ".";
if ($rp->precsym) {
printf(" [%s]", $rp->precsym->name);
}
/*if ($rp->code) {
print "\n " . $rp->code);
}*/
print "\n";
}
}
|
php
|
function Reprint()
{
printf("// Reprint of input file \"%s\".\n// Symbols:\n", $this->filename);
$maxlen = 10;
for ($i = 0; $i < $this->nsymbol; $i++) {
$sp = $this->symbols[$i];
$len = strlen($sp->name);
if ($len > $maxlen ) {
$maxlen = $len;
}
}
$ncolumns = 76 / ($maxlen + 5);
if ($ncolumns < 1) {
$ncolumns = 1;
}
$skip = ($this->nsymbol + $ncolumns - 1) / $ncolumns;
for ($i = 0; $i < $skip; $i++) {
print "//";
for ($j = $i; $j < $this->nsymbol; $j += $skip) {
$sp = $this->symbols[$j];
//assert( sp->index==j );
printf(" %3d %-${maxlen}.${maxlen}s", $j, $sp->name);
}
print "\n";
}
for ($rp = $this->rule; $rp; $rp = $rp->next) {
printf("%s", $rp->lhs->name);
/*if ($rp->lhsalias) {
printf("(%s)", $rp->lhsalias);
}*/
print " ::=";
for ($i = 0; $i < $rp->nrhs; $i++) {
$sp = $rp->rhs[$i];
printf(" %s", $sp->name);
if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
for ($j = 1; $j < $sp->nsubsym; $j++) {
printf("|%s", $sp->subsym[$j]->name);
}
}
/*if ($rp->rhsalias[$i]) {
printf("(%s)", $rp->rhsalias[$i]);
}*/
}
print ".";
if ($rp->precsym) {
printf(" [%s]", $rp->precsym->name);
}
/*if ($rp->code) {
print "\n " . $rp->code);
}*/
print "\n";
}
}
|
[
"function",
"Reprint",
"(",
")",
"{",
"printf",
"(",
"\"// Reprint of input file \\\"%s\\\".\\n// Symbols:\\n\"",
",",
"$",
"this",
"->",
"filename",
")",
";",
"$",
"maxlen",
"=",
"10",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"nsymbol",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sp",
"=",
"$",
"this",
"->",
"symbols",
"[",
"$",
"i",
"]",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"sp",
"->",
"name",
")",
";",
"if",
"(",
"$",
"len",
">",
"$",
"maxlen",
")",
"{",
"$",
"maxlen",
"=",
"$",
"len",
";",
"}",
"}",
"$",
"ncolumns",
"=",
"76",
"/",
"(",
"$",
"maxlen",
"+",
"5",
")",
";",
"if",
"(",
"$",
"ncolumns",
"<",
"1",
")",
"{",
"$",
"ncolumns",
"=",
"1",
";",
"}",
"$",
"skip",
"=",
"(",
"$",
"this",
"->",
"nsymbol",
"+",
"$",
"ncolumns",
"-",
"1",
")",
"/",
"$",
"ncolumns",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"skip",
";",
"$",
"i",
"++",
")",
"{",
"print",
"\"//\"",
";",
"for",
"(",
"$",
"j",
"=",
"$",
"i",
";",
"$",
"j",
"<",
"$",
"this",
"->",
"nsymbol",
";",
"$",
"j",
"+=",
"$",
"skip",
")",
"{",
"$",
"sp",
"=",
"$",
"this",
"->",
"symbols",
"[",
"$",
"j",
"]",
";",
"//assert( sp->index==j );",
"printf",
"(",
"\" %3d %-${maxlen}.${maxlen}s\"",
",",
"$",
"j",
",",
"$",
"sp",
"->",
"name",
")",
";",
"}",
"print",
"\"\\n\"",
";",
"}",
"for",
"(",
"$",
"rp",
"=",
"$",
"this",
"->",
"rule",
";",
"$",
"rp",
";",
"$",
"rp",
"=",
"$",
"rp",
"->",
"next",
")",
"{",
"printf",
"(",
"\"%s\"",
",",
"$",
"rp",
"->",
"lhs",
"->",
"name",
")",
";",
"/*if ($rp->lhsalias) {\n printf(\"(%s)\", $rp->lhsalias);\n }*/",
"print",
"\" ::=\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"rp",
"->",
"nrhs",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sp",
"=",
"$",
"rp",
"->",
"rhs",
"[",
"$",
"i",
"]",
";",
"printf",
"(",
"\" %s\"",
",",
"$",
"sp",
"->",
"name",
")",
";",
"if",
"(",
"$",
"sp",
"->",
"type",
"==",
"PHP_ParserGenerator_Symbol",
"::",
"MULTITERMINAL",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"1",
";",
"$",
"j",
"<",
"$",
"sp",
"->",
"nsubsym",
";",
"$",
"j",
"++",
")",
"{",
"printf",
"(",
"\"|%s\"",
",",
"$",
"sp",
"->",
"subsym",
"[",
"$",
"j",
"]",
"->",
"name",
")",
";",
"}",
"}",
"/*if ($rp->rhsalias[$i]) {\n printf(\"(%s)\", $rp->rhsalias[$i]);\n }*/",
"}",
"print",
"\".\"",
";",
"if",
"(",
"$",
"rp",
"->",
"precsym",
")",
"{",
"printf",
"(",
"\" [%s]\"",
",",
"$",
"rp",
"->",
"precsym",
"->",
"name",
")",
";",
"}",
"/*if ($rp->code) {\n print \"\\n \" . $rp->code);\n }*/",
"print",
"\"\\n\"",
";",
"}",
"}"
] |
Duplicate the input file without comments and without actions
on rules
@return void
|
[
"Duplicate",
"the",
"input",
"file",
"without",
"comments",
"and",
"without",
"actions",
"on",
"rules"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/ParserGenerator.php#L758-L810
|
237,064
|
rybakdigital/fapi
|
Component/Framework/Controller/Controller.php
|
Controller.passRequestData
|
public function passRequestData()
{
$this
->getValidator()
->setInputData($this
->getRequest()
->query
->all()
);
$this
->getValidator()
->setInputData($this
->getRequest()
->request
->all()
);
return $this;
}
|
php
|
public function passRequestData()
{
$this
->getValidator()
->setInputData($this
->getRequest()
->query
->all()
);
$this
->getValidator()
->setInputData($this
->getRequest()
->request
->all()
);
return $this;
}
|
[
"public",
"function",
"passRequestData",
"(",
")",
"{",
"$",
"this",
"->",
"getValidator",
"(",
")",
"->",
"setInputData",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"$",
"this",
"->",
"getValidator",
"(",
")",
"->",
"setInputData",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"all",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Helper method. Passes request data.
@return Controller
|
[
"Helper",
"method",
".",
"Passes",
"request",
"data",
"."
] |
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
|
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L157-L176
|
237,065
|
rybakdigital/fapi
|
Component/Framework/Controller/Controller.php
|
Controller.getRepository
|
public function getRepository($name = null)
{
// Resolve repository class name
$repositoryName = $this->resolveRepositoryClassName($name);
return new $repositoryName($this->getValidator(), $this->config);
}
|
php
|
public function getRepository($name = null)
{
// Resolve repository class name
$repositoryName = $this->resolveRepositoryClassName($name);
return new $repositoryName($this->getValidator(), $this->config);
}
|
[
"public",
"function",
"getRepository",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"// Resolve repository class name",
"$",
"repositoryName",
"=",
"$",
"this",
"->",
"resolveRepositoryClassName",
"(",
"$",
"name",
")",
";",
"return",
"new",
"$",
"repositoryName",
"(",
"$",
"this",
"->",
"getValidator",
"(",
")",
",",
"$",
"this",
"->",
"config",
")",
";",
"}"
] |
Gets repository by name
@param string $name Name of the repository to get
|
[
"Gets",
"repository",
"by",
"name"
] |
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
|
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L183-L189
|
237,066
|
rybakdigital/fapi
|
Component/Framework/Controller/Controller.php
|
Controller.getRepositoryClassnameByReference
|
public static function getRepositoryClassnameByReference($reference)
{
$parts = explode(':', $reference);
// Check name is string
if (!is_string($reference) || count($parts) !== 3) {
throw new \Exception("Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository");
}
return $parts[0] . '\\' . $parts[1] . '\\' . 'Entity\\' . $parts[2];
}
|
php
|
public static function getRepositoryClassnameByReference($reference)
{
$parts = explode(':', $reference);
// Check name is string
if (!is_string($reference) || count($parts) !== 3) {
throw new \Exception("Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository");
}
return $parts[0] . '\\' . $parts[1] . '\\' . 'Entity\\' . $parts[2];
}
|
[
"public",
"static",
"function",
"getRepositoryClassnameByReference",
"(",
"$",
"reference",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"reference",
")",
";",
"// Check name is string",
"if",
"(",
"!",
"is_string",
"(",
"$",
"reference",
")",
"||",
"count",
"(",
"$",
"parts",
")",
"!==",
"3",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository\"",
")",
";",
"}",
"return",
"$",
"parts",
"[",
"0",
"]",
".",
"'\\\\'",
".",
"$",
"parts",
"[",
"1",
"]",
".",
"'\\\\'",
".",
"'Entity\\\\'",
".",
"$",
"parts",
"[",
"2",
"]",
";",
"}"
] |
Gets Repository class name by Reference
@param string $reference Reference to Repository class.
This should be in a form of {version}:{controller}:{repositoryName}
For example: v1:Products:MyRepository
Will resolve to: 'v1\Products\Entity\MyRepository'
@return string
|
[
"Gets",
"Repository",
"class",
"name",
"by",
"Reference"
] |
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
|
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Framework/Controller/Controller.php#L233-L243
|
237,067
|
awjudd/l4-assetprocessor
|
src/Awjudd/AssetProcessor/Commands/CleanupCommand.php
|
CleanupCommand.removeFiles
|
private function removeFiles($files)
{
// Grab the duration
$duration = $this->option('duration');
// Grab the minimum acceptable timestamp
$timestamp = time() - $duration;
// Cycle through the list checking their creation dates
foreach($files as $file)
{
// Compare the file modification times
if(filemtime($file) < $timestamp)
{
// It passes the acceptable, so remove it
unlink($file);
// Check if the directory containing this file is empty
if(count(scandir(dirname($file))) == 2)
{
// It was empty, so just remove it
rmdir(dirname($file));
}
}
}
}
|
php
|
private function removeFiles($files)
{
// Grab the duration
$duration = $this->option('duration');
// Grab the minimum acceptable timestamp
$timestamp = time() - $duration;
// Cycle through the list checking their creation dates
foreach($files as $file)
{
// Compare the file modification times
if(filemtime($file) < $timestamp)
{
// It passes the acceptable, so remove it
unlink($file);
// Check if the directory containing this file is empty
if(count(scandir(dirname($file))) == 2)
{
// It was empty, so just remove it
rmdir(dirname($file));
}
}
}
}
|
[
"private",
"function",
"removeFiles",
"(",
"$",
"files",
")",
"{",
"// Grab the duration",
"$",
"duration",
"=",
"$",
"this",
"->",
"option",
"(",
"'duration'",
")",
";",
"// Grab the minimum acceptable timestamp",
"$",
"timestamp",
"=",
"time",
"(",
")",
"-",
"$",
"duration",
";",
"// Cycle through the list checking their creation dates",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// Compare the file modification times",
"if",
"(",
"filemtime",
"(",
"$",
"file",
")",
"<",
"$",
"timestamp",
")",
"{",
"// It passes the acceptable, so remove it",
"unlink",
"(",
"$",
"file",
")",
";",
"// Check if the directory containing this file is empty",
"if",
"(",
"count",
"(",
"scandir",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
"==",
"2",
")",
"{",
"// It was empty, so just remove it",
"rmdir",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Used internally in order to cycle through all of the files and remove them.
@return void
|
[
"Used",
"internally",
"in",
"order",
"to",
"cycle",
"through",
"all",
"of",
"the",
"files",
"and",
"remove",
"them",
"."
] |
04045197ae1a81d77d0c8879dbc090bbd8a69307
|
https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/Commands/CleanupCommand.php#L66-L91
|
237,068
|
awjudd/l4-assetprocessor
|
src/Awjudd/AssetProcessor/Commands/CleanupCommand.php
|
CleanupCommand.buildFileList
|
private function buildFileList($folder)
{
// The list of files to use
$files = array();
// Cycle through all of the files in our storage folder removing
// any files that exceed the cache duration.
$directory = new DirectoryIterator($folder);
foreach ($directory as $file)
{
// Check if the file is the local file (i.e. dot)
if($file->isDot())
{
// We are the dot, so just skip
continue;
}
// Check if the file is a directory
if($file->isDir())
{
// Recursively call this function
$files = array_merge($files, $this->buildFileList($file->getRealPath()));
}
else
{
// Add in the file
$files[] = $file->getRealPath();
}
}
return $files;
}
|
php
|
private function buildFileList($folder)
{
// The list of files to use
$files = array();
// Cycle through all of the files in our storage folder removing
// any files that exceed the cache duration.
$directory = new DirectoryIterator($folder);
foreach ($directory as $file)
{
// Check if the file is the local file (i.e. dot)
if($file->isDot())
{
// We are the dot, so just skip
continue;
}
// Check if the file is a directory
if($file->isDir())
{
// Recursively call this function
$files = array_merge($files, $this->buildFileList($file->getRealPath()));
}
else
{
// Add in the file
$files[] = $file->getRealPath();
}
}
return $files;
}
|
[
"private",
"function",
"buildFileList",
"(",
"$",
"folder",
")",
"{",
"// The list of files to use",
"$",
"files",
"=",
"array",
"(",
")",
";",
"// Cycle through all of the files in our storage folder removing",
"// any files that exceed the cache duration.",
"$",
"directory",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"folder",
")",
";",
"foreach",
"(",
"$",
"directory",
"as",
"$",
"file",
")",
"{",
"// Check if the file is the local file (i.e. dot)",
"if",
"(",
"$",
"file",
"->",
"isDot",
"(",
")",
")",
"{",
"// We are the dot, so just skip",
"continue",
";",
"}",
"// Check if the file is a directory",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"// Recursively call this function",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"this",
"->",
"buildFileList",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"// Add in the file",
"$",
"files",
"[",
"]",
"=",
"$",
"file",
"->",
"getRealPath",
"(",
")",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Used internally in order to build a full list of all of the files to build.
@param string $folder The folder to scan through
@return array An array of all of the files to check.
|
[
"Used",
"internally",
"in",
"order",
"to",
"build",
"a",
"full",
"list",
"of",
"all",
"of",
"the",
"files",
"to",
"build",
"."
] |
04045197ae1a81d77d0c8879dbc090bbd8a69307
|
https://github.com/awjudd/l4-assetprocessor/blob/04045197ae1a81d77d0c8879dbc090bbd8a69307/src/Awjudd/AssetProcessor/Commands/CleanupCommand.php#L99-L131
|
237,069
|
unimatrix/cake
|
src/Controller/Component/CookieComponent.php
|
CookieComponent.check
|
public function check($name) {
// is in cache?
if(isset($this->cache[$name]))
return true;
return $this->cookies->has($name);
}
|
php
|
public function check($name) {
// is in cache?
if(isset($this->cache[$name]))
return true;
return $this->cookies->has($name);
}
|
[
"public",
"function",
"check",
"(",
"$",
"name",
")",
"{",
"// is in cache?",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"name",
"]",
")",
")",
"return",
"true",
";",
"return",
"$",
"this",
"->",
"cookies",
"->",
"has",
"(",
"$",
"name",
")",
";",
"}"
] |
Check if the cookie exists
@param string $name The name of the cookie.
@return boolean
|
[
"Check",
"if",
"the",
"cookie",
"exists"
] |
23003aba497822bd473fdbf60514052dda1874fc
|
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Controller/Component/CookieComponent.php#L56-L62
|
237,070
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.init
|
public function init(){
$file= 'config';
//Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO
if($this->multiDomain && $this->domain){
//Ya no importa el modo, se definio todo antes si busca o no por dominio
//if(ENOLA_MODE == 'HTTP'){
$file= $this->getConfigFile();
//}else{
//reset($this->configFiles);
//$file= next($this->configFiles);
//}
}
$config= $this->readConfigurationFile($file);
//Define si muestra o no los errores y en que nivel de detalle dependiendo en que fase se encuentre la aplicacion
switch ($config['environment']){
case 'development':
error_reporting(E_ALL);
$this->error= 'ALL';
break;
case 'production':
error_reporting(0);
$this->error= 'NONE';
break;
default:
//No realiza el llamado a funcion de error porque todavia no se cargo el modulo de errores
$head= 'Configuration Error';
$message= 'The environment is not defined in configuration.json';
require $this->pathApp . 'errors/general_error.php';
exit;
}
//URL_APP: Url donde funciona la aplicacion
$this->urlApp= $config['url_app'];
//BASE_URL: Base relativa de la aplicacion - definida por el usuario en el archivo de configuracion
$pos= strlen($config['relative_url']) - 1;
if($config['relative_url'][$pos] != '/'){
$config['relative_url'] .= '/';
}
$this->relativeUrl= $config['relative_url'];
//INDEX_PAGE: Pagina inicial. En blanco si se utiliza mod_rewrite
$this->indexPage= $config['index_page'];
//SESSION_PROFILE: Setea la clave en la que se guarda el profile del usuario
$this->sessionProfile= "";
if(isset($config['session-profile'])){
$this->sessionProfile= $config['session-profile'];
}
//ENVIRONMENT: Indica el ambiente de la aplicacion
$this->environment= $config['environment'];
//AUTHENTICATION: Indica el metodo de autenticacion de la aplicacion
$this->authentication= $config['authentication'];
//SESSION_AUTOSTART: Indica si el framework inicia automaticamente la session
$this->sessionAutostart= $config['session_autostart'];
//AUTHORIZATION_FILE: Indica el archivo que contiene la configuracion de autorizacion
$this->authorizationFile= $config['authorization_file'];
//CONFIG_BD: archivo de configuracion para la base de datos
if(isset($config['database']) && $config['database'] != ''){
$this->databaseConfiguration= $config['database'];
}
//Internacionalizacion: En caso que se defina se setea el locale por defecto y todos los locales soportados
if(isset($config['i18n'])){
$this->i18nDefaultLocale= $config['i18n']['default'];
if(isset($config['i18n']['locales'])){
$locales= str_replace(" ", "", $config['i18n']['locales']);
$this->i18nLocales= explode(",", $locales);
}
}
//Diferentes definiciones
$this->librariesDefinition= isset($config['libs']) ? $config['libs'] : [];
$this->dependenciesFile= $config['dependency_injection'];
$this->controllersFile= $config['controllers'];
$this->middlewaresDefinition= $config['middlewares'];
$this->filtersBeforeDefinition= $config['filters'];
$this->filtersAfterDefinition= $config['filters_after_processing'];
if(isset($config['vars'])){
$this->contextVars= $config['vars'];
}
}
|
php
|
public function init(){
$file= 'config';
//Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO
if($this->multiDomain && $this->domain){
//Ya no importa el modo, se definio todo antes si busca o no por dominio
//if(ENOLA_MODE == 'HTTP'){
$file= $this->getConfigFile();
//}else{
//reset($this->configFiles);
//$file= next($this->configFiles);
//}
}
$config= $this->readConfigurationFile($file);
//Define si muestra o no los errores y en que nivel de detalle dependiendo en que fase se encuentre la aplicacion
switch ($config['environment']){
case 'development':
error_reporting(E_ALL);
$this->error= 'ALL';
break;
case 'production':
error_reporting(0);
$this->error= 'NONE';
break;
default:
//No realiza el llamado a funcion de error porque todavia no se cargo el modulo de errores
$head= 'Configuration Error';
$message= 'The environment is not defined in configuration.json';
require $this->pathApp . 'errors/general_error.php';
exit;
}
//URL_APP: Url donde funciona la aplicacion
$this->urlApp= $config['url_app'];
//BASE_URL: Base relativa de la aplicacion - definida por el usuario en el archivo de configuracion
$pos= strlen($config['relative_url']) - 1;
if($config['relative_url'][$pos] != '/'){
$config['relative_url'] .= '/';
}
$this->relativeUrl= $config['relative_url'];
//INDEX_PAGE: Pagina inicial. En blanco si se utiliza mod_rewrite
$this->indexPage= $config['index_page'];
//SESSION_PROFILE: Setea la clave en la que se guarda el profile del usuario
$this->sessionProfile= "";
if(isset($config['session-profile'])){
$this->sessionProfile= $config['session-profile'];
}
//ENVIRONMENT: Indica el ambiente de la aplicacion
$this->environment= $config['environment'];
//AUTHENTICATION: Indica el metodo de autenticacion de la aplicacion
$this->authentication= $config['authentication'];
//SESSION_AUTOSTART: Indica si el framework inicia automaticamente la session
$this->sessionAutostart= $config['session_autostart'];
//AUTHORIZATION_FILE: Indica el archivo que contiene la configuracion de autorizacion
$this->authorizationFile= $config['authorization_file'];
//CONFIG_BD: archivo de configuracion para la base de datos
if(isset($config['database']) && $config['database'] != ''){
$this->databaseConfiguration= $config['database'];
}
//Internacionalizacion: En caso que se defina se setea el locale por defecto y todos los locales soportados
if(isset($config['i18n'])){
$this->i18nDefaultLocale= $config['i18n']['default'];
if(isset($config['i18n']['locales'])){
$locales= str_replace(" ", "", $config['i18n']['locales']);
$this->i18nLocales= explode(",", $locales);
}
}
//Diferentes definiciones
$this->librariesDefinition= isset($config['libs']) ? $config['libs'] : [];
$this->dependenciesFile= $config['dependency_injection'];
$this->controllersFile= $config['controllers'];
$this->middlewaresDefinition= $config['middlewares'];
$this->filtersBeforeDefinition= $config['filters'];
$this->filtersAfterDefinition= $config['filters_after_processing'];
if(isset($config['vars'])){
$this->contextVars= $config['vars'];
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"$",
"file",
"=",
"'config'",
";",
"//Seleccion el archivo de configuracion correspondiente segun el MODO y el DOMINIO",
"if",
"(",
"$",
"this",
"->",
"multiDomain",
"&&",
"$",
"this",
"->",
"domain",
")",
"{",
"//Ya no importa el modo, se definio todo antes si busca o no por dominio",
"//if(ENOLA_MODE == 'HTTP'){",
"$",
"file",
"=",
"$",
"this",
"->",
"getConfigFile",
"(",
")",
";",
"//}else{",
"//reset($this->configFiles);",
"//$file= next($this->configFiles);",
"//}",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"readConfigurationFile",
"(",
"$",
"file",
")",
";",
"//Define si muestra o no los errores y en que nivel de detalle dependiendo en que fase se encuentre la aplicacion",
"switch",
"(",
"$",
"config",
"[",
"'environment'",
"]",
")",
"{",
"case",
"'development'",
":",
"error_reporting",
"(",
"E_ALL",
")",
";",
"$",
"this",
"->",
"error",
"=",
"'ALL'",
";",
"break",
";",
"case",
"'production'",
":",
"error_reporting",
"(",
"0",
")",
";",
"$",
"this",
"->",
"error",
"=",
"'NONE'",
";",
"break",
";",
"default",
":",
"//No realiza el llamado a funcion de error porque todavia no se cargo el modulo de errores",
"$",
"head",
"=",
"'Configuration Error'",
";",
"$",
"message",
"=",
"'The environment is not defined in configuration.json'",
";",
"require",
"$",
"this",
"->",
"pathApp",
".",
"'errors/general_error.php'",
";",
"exit",
";",
"}",
"//URL_APP: Url donde funciona la aplicacion",
"$",
"this",
"->",
"urlApp",
"=",
"$",
"config",
"[",
"'url_app'",
"]",
";",
"//BASE_URL: Base relativa de la aplicacion - definida por el usuario en el archivo de configuracion ",
"$",
"pos",
"=",
"strlen",
"(",
"$",
"config",
"[",
"'relative_url'",
"]",
")",
"-",
"1",
";",
"if",
"(",
"$",
"config",
"[",
"'relative_url'",
"]",
"[",
"$",
"pos",
"]",
"!=",
"'/'",
")",
"{",
"$",
"config",
"[",
"'relative_url'",
"]",
".=",
"'/'",
";",
"}",
"$",
"this",
"->",
"relativeUrl",
"=",
"$",
"config",
"[",
"'relative_url'",
"]",
";",
"//INDEX_PAGE: Pagina inicial. En blanco si se utiliza mod_rewrite",
"$",
"this",
"->",
"indexPage",
"=",
"$",
"config",
"[",
"'index_page'",
"]",
";",
"//SESSION_PROFILE: Setea la clave en la que se guarda el profile del usuario",
"$",
"this",
"->",
"sessionProfile",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'session-profile'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sessionProfile",
"=",
"$",
"config",
"[",
"'session-profile'",
"]",
";",
"}",
"//ENVIRONMENT: Indica el ambiente de la aplicacion",
"$",
"this",
"->",
"environment",
"=",
"$",
"config",
"[",
"'environment'",
"]",
";",
"//AUTHENTICATION: Indica el metodo de autenticacion de la aplicacion",
"$",
"this",
"->",
"authentication",
"=",
"$",
"config",
"[",
"'authentication'",
"]",
";",
"//SESSION_AUTOSTART: Indica si el framework inicia automaticamente la session",
"$",
"this",
"->",
"sessionAutostart",
"=",
"$",
"config",
"[",
"'session_autostart'",
"]",
";",
"//AUTHORIZATION_FILE: Indica el archivo que contiene la configuracion de autorizacion",
"$",
"this",
"->",
"authorizationFile",
"=",
"$",
"config",
"[",
"'authorization_file'",
"]",
";",
"//CONFIG_BD: archivo de configuracion para la base de datos",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'database'",
"]",
")",
"&&",
"$",
"config",
"[",
"'database'",
"]",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"databaseConfiguration",
"=",
"$",
"config",
"[",
"'database'",
"]",
";",
"}",
"//Internacionalizacion: En caso que se defina se setea el locale por defecto y todos los locales soportados",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'i18n'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"i18nDefaultLocale",
"=",
"$",
"config",
"[",
"'i18n'",
"]",
"[",
"'default'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'i18n'",
"]",
"[",
"'locales'",
"]",
")",
")",
"{",
"$",
"locales",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"\"",
",",
"$",
"config",
"[",
"'i18n'",
"]",
"[",
"'locales'",
"]",
")",
";",
"$",
"this",
"->",
"i18nLocales",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"locales",
")",
";",
"}",
"}",
"//Diferentes definiciones",
"$",
"this",
"->",
"librariesDefinition",
"=",
"isset",
"(",
"$",
"config",
"[",
"'libs'",
"]",
")",
"?",
"$",
"config",
"[",
"'libs'",
"]",
":",
"[",
"]",
";",
"$",
"this",
"->",
"dependenciesFile",
"=",
"$",
"config",
"[",
"'dependency_injection'",
"]",
";",
"$",
"this",
"->",
"controllersFile",
"=",
"$",
"config",
"[",
"'controllers'",
"]",
";",
"$",
"this",
"->",
"middlewaresDefinition",
"=",
"$",
"config",
"[",
"'middlewares'",
"]",
";",
"$",
"this",
"->",
"filtersBeforeDefinition",
"=",
"$",
"config",
"[",
"'filters'",
"]",
";",
"$",
"this",
"->",
"filtersAfterDefinition",
"=",
"$",
"config",
"[",
"'filters_after_processing'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'vars'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"contextVars",
"=",
"$",
"config",
"[",
"'vars'",
"]",
";",
"}",
"}"
] |
Carga la configuracion global de la aplicacion
@param string $path_root
@param string $path_framework
@param string $path_application
|
[
"Carga",
"la",
"configuracion",
"global",
"de",
"la",
"aplicacion"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L196-L274
|
237,071
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.setBasicConstants
|
private function setBasicConstants(){
//Algunas constantes - La idea es ir sacandolas
//PATHROOT: direccion de la carpeta del framework - definida en index.php
define('PATHROOT', $this->getPathRoot());
//PATHFRA: direccion de la carpeta del framework - definida en index.php
define('PATHFRA', $this->getPathFra());
//PATHAPP: direccion de la carpeta de la aplicacion - definida en index.php
define('PATHAPP', $this->getPathApp());
//ENOLA_MODE: Indica si la aplicacion se esta ejecutando via HTTP o CLI
if(PHP_SAPI == 'cli' || !filter_input(INPUT_SERVER, 'REQUEST_METHOD')){
define('ENOLA_MODE', 'CLI');
}else{
define('ENOLA_MODE', 'HTTP');
}
}
|
php
|
private function setBasicConstants(){
//Algunas constantes - La idea es ir sacandolas
//PATHROOT: direccion de la carpeta del framework - definida en index.php
define('PATHROOT', $this->getPathRoot());
//PATHFRA: direccion de la carpeta del framework - definida en index.php
define('PATHFRA', $this->getPathFra());
//PATHAPP: direccion de la carpeta de la aplicacion - definida en index.php
define('PATHAPP', $this->getPathApp());
//ENOLA_MODE: Indica si la aplicacion se esta ejecutando via HTTP o CLI
if(PHP_SAPI == 'cli' || !filter_input(INPUT_SERVER, 'REQUEST_METHOD')){
define('ENOLA_MODE', 'CLI');
}else{
define('ENOLA_MODE', 'HTTP');
}
}
|
[
"private",
"function",
"setBasicConstants",
"(",
")",
"{",
"//Algunas constantes - La idea es ir sacandolas",
"//PATHROOT: direccion de la carpeta del framework - definida en index.php",
"define",
"(",
"'PATHROOT'",
",",
"$",
"this",
"->",
"getPathRoot",
"(",
")",
")",
";",
"//PATHFRA: direccion de la carpeta del framework - definida en index.php",
"define",
"(",
"'PATHFRA'",
",",
"$",
"this",
"->",
"getPathFra",
"(",
")",
")",
";",
"//PATHAPP: direccion de la carpeta de la aplicacion - definida en index.php",
"define",
"(",
"'PATHAPP'",
",",
"$",
"this",
"->",
"getPathApp",
"(",
")",
")",
";",
"//ENOLA_MODE: Indica si la aplicacion se esta ejecutando via HTTP o CLI",
"if",
"(",
"PHP_SAPI",
"==",
"'cli'",
"||",
"!",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'REQUEST_METHOD'",
")",
")",
"{",
"define",
"(",
"'ENOLA_MODE'",
",",
"'CLI'",
")",
";",
"}",
"else",
"{",
"define",
"(",
"'ENOLA_MODE'",
",",
"'HTTP'",
")",
";",
"}",
"}"
] |
Establece las constantes basicas del sistema
|
[
"Establece",
"las",
"constantes",
"basicas",
"del",
"sistema"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L278-L292
|
237,072
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.readConfigurationFile
|
public function readConfigurationFile($name, $cache = TRUE){
//Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc.
$config= NULL;
if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){
//Si esta en produccion y se encuentra en cache lo cargo
$config= $this->app->getAttribute('C_' . $name);
}
if($config == NULL){
//Cargo la configuracion y guardo en cache si corresponde
$config= $this->readFile($name);
if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){
$this->app->setAttribute('C_' . $name, $config);
}
}
if(! is_array($config)){
//Arma una respuesta de error de configuracion.
\Enola\Support\Error::general_error('Configuration Error', 'The configuration file ' . $name . ' is not available or is misspelled');
//Cierra la aplicacion
exit;
}
return $config;
}
|
php
|
public function readConfigurationFile($name, $cache = TRUE){
//Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc.
$config= NULL;
if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){
//Si esta en produccion y se encuentra en cache lo cargo
$config= $this->app->getAttribute('C_' . $name);
}
if($config == NULL){
//Cargo la configuracion y guardo en cache si corresponde
$config= $this->readFile($name);
if($this->cacheConfigFiles && $cache && $this->app->cache != NULL){
$this->app->setAttribute('C_' . $name, $config);
}
}
if(! is_array($config)){
//Arma una respuesta de error de configuracion.
\Enola\Support\Error::general_error('Configuration Error', 'The configuration file ' . $name . ' is not available or is misspelled');
//Cierra la aplicacion
exit;
}
return $config;
}
|
[
"public",
"function",
"readConfigurationFile",
"(",
"$",
"name",
",",
"$",
"cache",
"=",
"TRUE",
")",
"{",
"//Lee archivo de configuracion principal donde se encuentra toda la configuracion de variables, filtros, controladores, etc.",
"$",
"config",
"=",
"NULL",
";",
"if",
"(",
"$",
"this",
"->",
"cacheConfigFiles",
"&&",
"$",
"cache",
"&&",
"$",
"this",
"->",
"app",
"->",
"cache",
"!=",
"NULL",
")",
"{",
"//Si esta en produccion y se encuentra en cache lo cargo",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"getAttribute",
"(",
"'C_'",
".",
"$",
"name",
")",
";",
"}",
"if",
"(",
"$",
"config",
"==",
"NULL",
")",
"{",
"//Cargo la configuracion y guardo en cache si corresponde",
"$",
"config",
"=",
"$",
"this",
"->",
"readFile",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cacheConfigFiles",
"&&",
"$",
"cache",
"&&",
"$",
"this",
"->",
"app",
"->",
"cache",
"!=",
"NULL",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"setAttribute",
"(",
"'C_'",
".",
"$",
"name",
",",
"$",
"config",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"//Arma una respuesta de error de configuracion.",
"\\",
"Enola",
"\\",
"Support",
"\\",
"Error",
"::",
"general_error",
"(",
"'Configuration Error'",
",",
"'The configuration file '",
".",
"$",
"name",
".",
"' is not available or is misspelled'",
")",
";",
"//Cierra la aplicacion",
"exit",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Devuelve un array con los valores del archivo de configuracion
@param string $name
@param boolean $cache
@return array
|
[
"Devuelve",
"un",
"array",
"con",
"los",
"valores",
"del",
"archivo",
"de",
"configuracion"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L440-L461
|
237,073
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.compileConfigurationFile
|
public function compileConfigurationFile($file){
//CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA
require_once $this->pathFra . 'Support/Spyc.php';
$info= new \SplFileInfo($file);
$path= $info->getPath() . '/';
$name= $info->getBasename('.' . $info->getExtension());
$config= $this->readFileSpecific($path . $name . '.' . $info->getExtension(), $info->getExtension());
file_put_contents($path . $name . '.php', '<?php $config = ' . var_export($config, true) . ';');
}
|
php
|
public function compileConfigurationFile($file){
//CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA
require_once $this->pathFra . 'Support/Spyc.php';
$info= new \SplFileInfo($file);
$path= $info->getPath() . '/';
$name= $info->getBasename('.' . $info->getExtension());
$config= $this->readFileSpecific($path . $name . '.' . $info->getExtension(), $info->getExtension());
file_put_contents($path . $name . '.php', '<?php $config = ' . var_export($config, true) . ';');
}
|
[
"public",
"function",
"compileConfigurationFile",
"(",
"$",
"file",
")",
"{",
"//CARGAMOS LA DEPENDENCIA POR SI ES NECESARIA",
"require_once",
"$",
"this",
"->",
"pathFra",
".",
"'Support/Spyc.php'",
";",
"$",
"info",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"file",
")",
";",
"$",
"path",
"=",
"$",
"info",
"->",
"getPath",
"(",
")",
".",
"'/'",
";",
"$",
"name",
"=",
"$",
"info",
"->",
"getBasename",
"(",
"'.'",
".",
"$",
"info",
"->",
"getExtension",
"(",
")",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"readFileSpecific",
"(",
"$",
"path",
".",
"$",
"name",
".",
"'.'",
".",
"$",
"info",
"->",
"getExtension",
"(",
")",
",",
"$",
"info",
"->",
"getExtension",
"(",
")",
")",
";",
"file_put_contents",
"(",
"$",
"path",
".",
"$",
"name",
".",
"'.php'",
",",
"'<?php $config = '",
".",
"var_export",
"(",
"$",
"config",
",",
"true",
")",
".",
"';'",
")",
";",
"}"
] |
Compila archivos de configuracion. Es necesario indicar path absoluto
@param type $name
@param type $absolute Si es true hay que indicar el path absoluto del archivo
|
[
"Compila",
"archivos",
"de",
"configuracion",
".",
"Es",
"necesario",
"indicar",
"path",
"absoluto"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L467-L476
|
237,074
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.readFile
|
private function readFile($name, $folder = null){
$realConfig= NULL;
$folder != null ?: $folder= $this->pathApp . $this->configurationFolder;
if($this->configurationType == 'YAML'){
$realConfig = \Spyc::YAMLLoad($folder . $name . '.yml');
}else if($this->configurationType == 'PHP'){
include $folder . $name . '.php';
//La variable $config la define cada archivo incluido
$realConfig= $config;
}else{
$realConfig= json_decode(file_get_contents($folder . $name . '.json'), true);
}
return $realConfig;
}
|
php
|
private function readFile($name, $folder = null){
$realConfig= NULL;
$folder != null ?: $folder= $this->pathApp . $this->configurationFolder;
if($this->configurationType == 'YAML'){
$realConfig = \Spyc::YAMLLoad($folder . $name . '.yml');
}else if($this->configurationType == 'PHP'){
include $folder . $name . '.php';
//La variable $config la define cada archivo incluido
$realConfig= $config;
}else{
$realConfig= json_decode(file_get_contents($folder . $name . '.json'), true);
}
return $realConfig;
}
|
[
"private",
"function",
"readFile",
"(",
"$",
"name",
",",
"$",
"folder",
"=",
"null",
")",
"{",
"$",
"realConfig",
"=",
"NULL",
";",
"$",
"folder",
"!=",
"null",
"?",
":",
"$",
"folder",
"=",
"$",
"this",
"->",
"pathApp",
".",
"$",
"this",
"->",
"configurationFolder",
";",
"if",
"(",
"$",
"this",
"->",
"configurationType",
"==",
"'YAML'",
")",
"{",
"$",
"realConfig",
"=",
"\\",
"Spyc",
"::",
"YAMLLoad",
"(",
"$",
"folder",
".",
"$",
"name",
".",
"'.yml'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"configurationType",
"==",
"'PHP'",
")",
"{",
"include",
"$",
"folder",
".",
"$",
"name",
".",
"'.php'",
";",
"//La variable $config la define cada archivo incluido",
"$",
"realConfig",
"=",
"$",
"config",
";",
"}",
"else",
"{",
"$",
"realConfig",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"folder",
".",
"$",
"name",
".",
"'.json'",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"realConfig",
";",
"}"
] |
Lee un archivo y lo carga en un array
@param string $name
@param string $folder Si no se indica $folder se usa la carpeta de configuracion de la app
@return array
|
[
"Lee",
"un",
"archivo",
"y",
"lo",
"carga",
"en",
"un",
"array"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L483-L496
|
237,075
|
edunola13/enolaphp-framework
|
src/EnolaContext.php
|
EnolaContext.readFileSpecific
|
public function readFileSpecific($path, $extension = 'yml'){
$realConfig= NULL;
if($extension == 'yml'){
$realConfig = \Spyc::YAMLLoad($path);
}else if($extension == 'php'){
include $path;
//La variable $config la define cada archivo incluido
$realConfig= $config;
}else{
$realConfig= json_decode(file_get_contents($path), true);
}
return $realConfig;
}
|
php
|
public function readFileSpecific($path, $extension = 'yml'){
$realConfig= NULL;
if($extension == 'yml'){
$realConfig = \Spyc::YAMLLoad($path);
}else if($extension == 'php'){
include $path;
//La variable $config la define cada archivo incluido
$realConfig= $config;
}else{
$realConfig= json_decode(file_get_contents($path), true);
}
return $realConfig;
}
|
[
"public",
"function",
"readFileSpecific",
"(",
"$",
"path",
",",
"$",
"extension",
"=",
"'yml'",
")",
"{",
"$",
"realConfig",
"=",
"NULL",
";",
"if",
"(",
"$",
"extension",
"==",
"'yml'",
")",
"{",
"$",
"realConfig",
"=",
"\\",
"Spyc",
"::",
"YAMLLoad",
"(",
"$",
"path",
")",
";",
"}",
"else",
"if",
"(",
"$",
"extension",
"==",
"'php'",
")",
"{",
"include",
"$",
"path",
";",
"//La variable $config la define cada archivo incluido",
"$",
"realConfig",
"=",
"$",
"config",
";",
"}",
"else",
"{",
"$",
"realConfig",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"realConfig",
";",
"}"
] |
Lee un archivo y lo carga en un array
A defirencia de readFile a este no le importa el tipo de configuracion ni la carpeta de este archivo. Toma un path completo y lo carga
@param string $path
@return array
|
[
"Lee",
"un",
"archivo",
"y",
"lo",
"carga",
"en",
"un",
"array",
"A",
"defirencia",
"de",
"readFile",
"a",
"este",
"no",
"le",
"importa",
"el",
"tipo",
"de",
"configuracion",
"ni",
"la",
"carpeta",
"de",
"este",
"archivo",
".",
"Toma",
"un",
"path",
"completo",
"y",
"lo",
"carga"
] |
a962bfcd53d7bc129d8c9946aaa71d264285229d
|
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/EnolaContext.php#L503-L515
|
237,076
|
wollanup/php-api-rest
|
src/Service/Request/QueryModifier/Modifier/FilterModifier.php
|
FilterModifier.hasAllRequiredData
|
protected function hasAllRequiredData(array $modifier)
{
if (array_key_exists('operator', $modifier)
&& !in_array($modifier['operator'],
self::$allowedFilterOperators)
) {
throw new ModifierException('The filter operator "' . $modifier['operator'] . '" is not allowed. You can only use one of the following:
' . implode(', ', self::$allowedFilterOperators));
}
return array_key_exists('property', $modifier) && array_key_exists('value', $modifier);
}
|
php
|
protected function hasAllRequiredData(array $modifier)
{
if (array_key_exists('operator', $modifier)
&& !in_array($modifier['operator'],
self::$allowedFilterOperators)
) {
throw new ModifierException('The filter operator "' . $modifier['operator'] . '" is not allowed. You can only use one of the following:
' . implode(', ', self::$allowedFilterOperators));
}
return array_key_exists('property', $modifier) && array_key_exists('value', $modifier);
}
|
[
"protected",
"function",
"hasAllRequiredData",
"(",
"array",
"$",
"modifier",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'operator'",
",",
"$",
"modifier",
")",
"&&",
"!",
"in_array",
"(",
"$",
"modifier",
"[",
"'operator'",
"]",
",",
"self",
"::",
"$",
"allowedFilterOperators",
")",
")",
"{",
"throw",
"new",
"ModifierException",
"(",
"'The filter operator \"'",
".",
"$",
"modifier",
"[",
"'operator'",
"]",
".",
"'\" is not allowed. You can only use one of the following:\n '",
".",
"implode",
"(",
"', '",
",",
"self",
"::",
"$",
"allowedFilterOperators",
")",
")",
";",
"}",
"return",
"array_key_exists",
"(",
"'property'",
",",
"$",
"modifier",
")",
"&&",
"array_key_exists",
"(",
"'value'",
",",
"$",
"modifier",
")",
";",
"}"
] |
Has the modifier all required data to be applied?
@param array $modifier
@return bool
@throws ModifierException
|
[
"Has",
"the",
"modifier",
"all",
"required",
"data",
"to",
"be",
"applied?"
] |
185eac8a8412e5997d8e292ebd0e38787ae4b949
|
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Service/Request/QueryModifier/Modifier/FilterModifier.php#L124-L135
|
237,077
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.register
|
public function register(\Silex\Application $app)
{
parent::register($app);
// Register voters
$app->extend('security.voters', function($voters) {
return array_merge($voters, $this->voters);
});
// Add reference to this in application instance
$this->app = $app;
$this->app['securilex'] = $this;
}
|
php
|
public function register(\Silex\Application $app)
{
parent::register($app);
// Register voters
$app->extend('security.voters', function($voters) {
return array_merge($voters, $this->voters);
});
// Add reference to this in application instance
$this->app = $app;
$this->app['securilex'] = $this;
}
|
[
"public",
"function",
"register",
"(",
"\\",
"Silex",
"\\",
"Application",
"$",
"app",
")",
"{",
"parent",
"::",
"register",
"(",
"$",
"app",
")",
";",
"// Register voters",
"$",
"app",
"->",
"extend",
"(",
"'security.voters'",
",",
"function",
"(",
"$",
"voters",
")",
"{",
"return",
"array_merge",
"(",
"$",
"voters",
",",
"$",
"this",
"->",
"voters",
")",
";",
"}",
")",
";",
"// Add reference to this in application instance",
"$",
"this",
"->",
"app",
"=",
"$",
"app",
";",
"$",
"this",
"->",
"app",
"[",
"'securilex'",
"]",
"=",
"$",
"this",
";",
"}"
] |
Register with \Silex\Application.
@param \Silex\Application $app
|
[
"Register",
"with",
"\\",
"Silex",
"\\",
"Application",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L64-L76
|
237,078
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.boot
|
public function boot(\Silex\Application $app)
{
// Register firewalls
foreach ($this->firewalls as $firewall) {
$firewall->register($this);
}
$i = 0;
$firewalls = array();
foreach ($this->unsecuredPatterns as $pattern => $v) {
$firewalls['unsecured_'.($i++)] = array('pattern' => $pattern);
}
$finalConfig = array_merge($firewalls, $this->firewallConfig);
$app['security.firewalls'] = $finalConfig;
parent::boot($app);
}
|
php
|
public function boot(\Silex\Application $app)
{
// Register firewalls
foreach ($this->firewalls as $firewall) {
$firewall->register($this);
}
$i = 0;
$firewalls = array();
foreach ($this->unsecuredPatterns as $pattern => $v) {
$firewalls['unsecured_'.($i++)] = array('pattern' => $pattern);
}
$finalConfig = array_merge($firewalls, $this->firewallConfig);
$app['security.firewalls'] = $finalConfig;
parent::boot($app);
}
|
[
"public",
"function",
"boot",
"(",
"\\",
"Silex",
"\\",
"Application",
"$",
"app",
")",
"{",
"// Register firewalls",
"foreach",
"(",
"$",
"this",
"->",
"firewalls",
"as",
"$",
"firewall",
")",
"{",
"$",
"firewall",
"->",
"register",
"(",
"$",
"this",
")",
";",
"}",
"$",
"i",
"=",
"0",
";",
"$",
"firewalls",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"unsecuredPatterns",
"as",
"$",
"pattern",
"=>",
"$",
"v",
")",
"{",
"$",
"firewalls",
"[",
"'unsecured_'",
".",
"(",
"$",
"i",
"++",
")",
"]",
"=",
"array",
"(",
"'pattern'",
"=>",
"$",
"pattern",
")",
";",
"}",
"$",
"finalConfig",
"=",
"array_merge",
"(",
"$",
"firewalls",
",",
"$",
"this",
"->",
"firewallConfig",
")",
";",
"$",
"app",
"[",
"'security.firewalls'",
"]",
"=",
"$",
"finalConfig",
";",
"parent",
"::",
"boot",
"(",
"$",
"app",
")",
";",
"}"
] |
Boot with Silex Application
@param \Silex\Application $app
|
[
"Boot",
"with",
"Silex",
"Application"
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L82-L99
|
237,079
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.getFirewall
|
public function getFirewall($path = null)
{
if (!$path) {
$path = $this->getCurrentPathRelativeToBase();
}
foreach ($this->firewalls as $firewall) {
if ($firewall->isPathCovered($path)) {
return $firewall;
}
}
return null;
}
|
php
|
public function getFirewall($path = null)
{
if (!$path) {
$path = $this->getCurrentPathRelativeToBase();
}
foreach ($this->firewalls as $firewall) {
if ($firewall->isPathCovered($path)) {
return $firewall;
}
}
return null;
}
|
[
"public",
"function",
"getFirewall",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getCurrentPathRelativeToBase",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"firewalls",
"as",
"$",
"firewall",
")",
"{",
"if",
"(",
"$",
"firewall",
"->",
"isPathCovered",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"firewall",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the firewall with the specific path.
@param string $path
@return FirewallInterface
|
[
"Get",
"the",
"firewall",
"with",
"the",
"specific",
"path",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L119-L130
|
237,080
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.getLoginCheckPath
|
public function getLoginCheckPath()
{
$login_check = $this->app['request']->getBasePath();
if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) {
$login_check .= $firewall->getLoginCheckPath();
}
return $login_check;
}
|
php
|
public function getLoginCheckPath()
{
$login_check = $this->app['request']->getBasePath();
if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) {
$login_check .= $firewall->getLoginCheckPath();
}
return $login_check;
}
|
[
"public",
"function",
"getLoginCheckPath",
"(",
")",
"{",
"$",
"login_check",
"=",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
"->",
"getBasePath",
"(",
")",
";",
"if",
"(",
"(",
"$",
"firewall",
"=",
"$",
"this",
"->",
"getFirewall",
"(",
"$",
"this",
"->",
"getCurrentPathRelativeToBase",
"(",
")",
")",
")",
")",
"{",
"$",
"login_check",
".=",
"$",
"firewall",
"->",
"getLoginCheckPath",
"(",
")",
";",
"}",
"return",
"$",
"login_check",
";",
"}"
] |
Get login check path.
@return string
|
[
"Get",
"login",
"check",
"path",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L136-L145
|
237,081
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.getLogoutPath
|
public function getLogoutPath()
{
$logout = $this->app['request']->getBasePath();
if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) {
$logout .= $firewall->getLogoutPath();
}
return $logout;
}
|
php
|
public function getLogoutPath()
{
$logout = $this->app['request']->getBasePath();
if (($firewall = $this->getFirewall($this->getCurrentPathRelativeToBase()))) {
$logout .= $firewall->getLogoutPath();
}
return $logout;
}
|
[
"public",
"function",
"getLogoutPath",
"(",
")",
"{",
"$",
"logout",
"=",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
"->",
"getBasePath",
"(",
")",
";",
"if",
"(",
"(",
"$",
"firewall",
"=",
"$",
"this",
"->",
"getFirewall",
"(",
"$",
"this",
"->",
"getCurrentPathRelativeToBase",
"(",
")",
")",
")",
")",
"{",
"$",
"logout",
".=",
"$",
"firewall",
"->",
"getLogoutPath",
"(",
")",
";",
"}",
"return",
"$",
"logout",
";",
"}"
] |
Get logout path.
@return string
|
[
"Get",
"logout",
"path",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L151-L160
|
237,082
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.prependFirewallConfig
|
public function prependFirewallConfig($name, $config)
{
$this->firewallConfig = array_merge(
array($name => $config), $this->firewallConfig);
}
|
php
|
public function prependFirewallConfig($name, $config)
{
$this->firewallConfig = array_merge(
array($name => $config), $this->firewallConfig);
}
|
[
"public",
"function",
"prependFirewallConfig",
"(",
"$",
"name",
",",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"firewallConfig",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"name",
"=>",
"$",
"config",
")",
",",
"$",
"this",
"->",
"firewallConfig",
")",
";",
"}"
] |
Prepend additional data to firewall configuration.
@param string $name
@param mixed $config
|
[
"Prepend",
"additional",
"data",
"to",
"firewall",
"configuration",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L185-L189
|
237,083
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.addAuthorizationVoter
|
public function addAuthorizationVoter(VoterInterface $voter)
{
if (!in_array($voter, $this->voters)) {
$this->voters[] = $voter;
}
}
|
php
|
public function addAuthorizationVoter(VoterInterface $voter)
{
if (!in_array($voter, $this->voters)) {
$this->voters[] = $voter;
}
}
|
[
"public",
"function",
"addAuthorizationVoter",
"(",
"VoterInterface",
"$",
"voter",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"voter",
",",
"$",
"this",
"->",
"voters",
")",
")",
"{",
"$",
"this",
"->",
"voters",
"[",
"]",
"=",
"$",
"voter",
";",
"}",
"}"
] |
Add additional voter to authorization module.
@param VoterInterface $voter
|
[
"Add",
"additional",
"voter",
"to",
"authorization",
"module",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L205-L210
|
237,084
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.isGranted
|
public function isGranted($attributes, $object = null,
$catchException = true)
{
try {
return $this->app['security.authorization_checker']->isGranted($attributes, $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
if ($catchException) {
return false;
}
throw $e;
}
}
|
php
|
public function isGranted($attributes, $object = null,
$catchException = true)
{
try {
return $this->app['security.authorization_checker']->isGranted($attributes, $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
if ($catchException) {
return false;
}
throw $e;
}
}
|
[
"public",
"function",
"isGranted",
"(",
"$",
"attributes",
",",
"$",
"object",
"=",
"null",
",",
"$",
"catchException",
"=",
"true",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"app",
"[",
"'security.authorization_checker'",
"]",
"->",
"isGranted",
"(",
"$",
"attributes",
",",
"$",
"object",
")",
";",
"}",
"catch",
"(",
"AuthenticationCredentialsNotFoundException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"catchException",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Check if the attributes are granted against the current authentication token and optionally supplied object.
@param mixed $attributes
@param mixed $object
@param boolean $catchException
@return boolean
@throws AuthenticationCredentialsNotFoundException
|
[
"Check",
"if",
"the",
"attributes",
"are",
"granted",
"against",
"the",
"current",
"authentication",
"token",
"and",
"optionally",
"supplied",
"object",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L220-L231
|
237,085
|
MLukman/Securilex
|
src/SecurityServiceProvider.php
|
SecurityServiceProvider.getCurrentPathRelativeToBase
|
protected function getCurrentPathRelativeToBase($path = null)
{
if (!$path) {
// using $_SERVER instead of using Request method
// to get original request path instead of any forwarded request
$path = $_SERVER['REQUEST_URI'];
}
$base_path = $this->app['request']->getBasePath();
return substr(strtok($path, '?'), strlen($base_path));
}
|
php
|
protected function getCurrentPathRelativeToBase($path = null)
{
if (!$path) {
// using $_SERVER instead of using Request method
// to get original request path instead of any forwarded request
$path = $_SERVER['REQUEST_URI'];
}
$base_path = $this->app['request']->getBasePath();
return substr(strtok($path, '?'), strlen($base_path));
}
|
[
"protected",
"function",
"getCurrentPathRelativeToBase",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"// using $_SERVER instead of using Request method",
"// to get original request path instead of any forwarded request",
"$",
"path",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
";",
"}",
"$",
"base_path",
"=",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
"->",
"getBasePath",
"(",
")",
";",
"return",
"substr",
"(",
"strtok",
"(",
"$",
"path",
",",
"'?'",
")",
",",
"strlen",
"(",
"$",
"base_path",
")",
")",
";",
"}"
] |
Get current path relative to base path.
@param string $path Path to process. Optional, default to current path
@return string
|
[
"Get",
"current",
"path",
"relative",
"to",
"base",
"path",
"."
] |
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
|
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L238-L247
|
237,086
|
erickmcarvalho/likepdo
|
src/LikePDO/Instances/LikePDOStatement.php
|
LikePDOStatement.debugDumpParams
|
public function debugDumpParams()
{
if(!is_resource($this->resource))
{
throw new LikePDOException("There is no active statement");
return false;
}
else
{
$parameters = array();
if(count($this->parametersBound) > 0)
{
foreach($this->parametersBound as $key => $param)
{
if(!isset($this->parameters[$key]))
{
$parameters[] = array
(
"key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key,
"paramno" => is_string($key) == true ? -1 : $key,
"name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"",
"is_param" => 1,
"param_type" => $param['data_type']
);
}
}
}
if(count($this->parameters) > 0)
{
foreach($this->parameters as $key => $param)
{
if(!isset($this->parametersBound[$key]))
{
$parameters[] = array
(
"key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key.":",
"paramno" => is_string($key) == true ? -1 : $key,
"name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"",
"is_param" => 1,
"param_type" => $param['data_type']
);
}
}
}
printf("SQL: [%d] %s".PHP_EOL."Params: %d".PHP_EOL.PHP_EOL, strlen($this->queryString), $this->queryString, count($parameters));
if(count($parameters) > 0)
{
foreach($parameters as $param)
{
printf("Key: %s".PHP_EOL, $param['key']);
printf("paramno=%d".PHP_EOL, $param['paramno']);
printf("name=%s".PHP_EOL, $param['name']);
printf("is_param=%d".PHP_EOL, $param['is_param']);
printf("param_type=%d".PHP_EOL, $param['param_type']);
}
}
return true;
}
}
|
php
|
public function debugDumpParams()
{
if(!is_resource($this->resource))
{
throw new LikePDOException("There is no active statement");
return false;
}
else
{
$parameters = array();
if(count($this->parametersBound) > 0)
{
foreach($this->parametersBound as $key => $param)
{
if(!isset($this->parameters[$key]))
{
$parameters[] = array
(
"key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key,
"paramno" => is_string($key) == true ? -1 : $key,
"name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"",
"is_param" => 1,
"param_type" => $param['data_type']
);
}
}
}
if(count($this->parameters) > 0)
{
foreach($this->parameters as $key => $param)
{
if(!isset($this->parametersBound[$key]))
{
$parameters[] = array
(
"key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key.":",
"paramno" => is_string($key) == true ? -1 : $key,
"name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"",
"is_param" => 1,
"param_type" => $param['data_type']
);
}
}
}
printf("SQL: [%d] %s".PHP_EOL."Params: %d".PHP_EOL.PHP_EOL, strlen($this->queryString), $this->queryString, count($parameters));
if(count($parameters) > 0)
{
foreach($parameters as $param)
{
printf("Key: %s".PHP_EOL, $param['key']);
printf("paramno=%d".PHP_EOL, $param['paramno']);
printf("name=%s".PHP_EOL, $param['name']);
printf("is_param=%d".PHP_EOL, $param['is_param']);
printf("param_type=%d".PHP_EOL, $param['param_type']);
}
}
return true;
}
}
|
[
"public",
"function",
"debugDumpParams",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"LikePDOException",
"(",
"\"There is no active statement\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"parametersBound",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parametersBound",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"]",
"=",
"array",
"(",
"\"key\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"\"Name: [\"",
".",
"strlen",
"(",
"$",
"key",
")",
".",
"\"] \"",
".",
"$",
"key",
":",
"\"Position #\"",
".",
"$",
"key",
",",
"\"paramno\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"-",
"1",
":",
"$",
"key",
",",
"\"name\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"\"[\"",
".",
"strlen",
"(",
"$",
"key",
")",
".",
"\"] \\\"\"",
".",
"$",
"key",
".",
"\"\\\"\"",
":",
"\"[0] \\\"\\\"\"",
",",
"\"is_param\"",
"=>",
"1",
",",
"\"param_type\"",
"=>",
"$",
"param",
"[",
"'data_type'",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"parameters",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parametersBound",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"]",
"=",
"array",
"(",
"\"key\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"\"Name: [\"",
".",
"strlen",
"(",
"$",
"key",
")",
".",
"\"] \"",
".",
"$",
"key",
":",
"\"Position #\"",
".",
"$",
"key",
".",
"\":\"",
",",
"\"paramno\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"-",
"1",
":",
"$",
"key",
",",
"\"name\"",
"=>",
"is_string",
"(",
"$",
"key",
")",
"==",
"true",
"?",
"\"[\"",
".",
"strlen",
"(",
"$",
"key",
")",
".",
"\"] \\\"\"",
".",
"$",
"key",
".",
"\"\\\"\"",
":",
"\"[0] \\\"\\\"\"",
",",
"\"is_param\"",
"=>",
"1",
",",
"\"param_type\"",
"=>",
"$",
"param",
"[",
"'data_type'",
"]",
")",
";",
"}",
"}",
"}",
"printf",
"(",
"\"SQL: [%d] %s\"",
".",
"PHP_EOL",
".",
"\"Params: %d\"",
".",
"PHP_EOL",
".",
"PHP_EOL",
",",
"strlen",
"(",
"$",
"this",
"->",
"queryString",
")",
",",
"$",
"this",
"->",
"queryString",
",",
"count",
"(",
"$",
"parameters",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"param",
")",
"{",
"printf",
"(",
"\"Key: %s\"",
".",
"PHP_EOL",
",",
"$",
"param",
"[",
"'key'",
"]",
")",
";",
"printf",
"(",
"\"paramno=%d\"",
".",
"PHP_EOL",
",",
"$",
"param",
"[",
"'paramno'",
"]",
")",
";",
"printf",
"(",
"\"name=%s\"",
".",
"PHP_EOL",
",",
"$",
"param",
"[",
"'name'",
"]",
")",
";",
"printf",
"(",
"\"is_param=%d\"",
".",
"PHP_EOL",
",",
"$",
"param",
"[",
"'is_param'",
"]",
")",
";",
"printf",
"(",
"\"param_type=%d\"",
".",
"PHP_EOL",
",",
"$",
"param",
"[",
"'param_type'",
"]",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}"
] |
Dump an SQL prepared command
@return void
|
[
"Dump",
"an",
"SQL",
"prepared",
"command"
] |
469f82f63d98fbabacdcdc27cb770b112428e4e5
|
https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/Instances/LikePDOStatement.php#L328-L391
|
237,087
|
erickmcarvalho/likepdo
|
src/LikePDO/Instances/LikePDOStatement.php
|
LikePDOStatement.nextRowset
|
public function nextRowset()
{
if(!is_resource($this->resource))
{
throw new LikePDOException("There is no active statement");
return false;
}
else
{
return $this->pdo->driver->nextResult($this->resource);
}
}
|
php
|
public function nextRowset()
{
if(!is_resource($this->resource))
{
throw new LikePDOException("There is no active statement");
return false;
}
else
{
return $this->pdo->driver->nextResult($this->resource);
}
}
|
[
"public",
"function",
"nextRowset",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"LikePDOException",
"(",
"\"There is no active statement\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"pdo",
"->",
"driver",
"->",
"nextResult",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"}",
"}"
] |
Advances to the next rowset in a multi-rowset statement handle
@return boolean
|
[
"Advances",
"to",
"the",
"next",
"rowset",
"in",
"a",
"multi",
"-",
"rowset",
"statement",
"handle"
] |
469f82f63d98fbabacdcdc27cb770b112428e4e5
|
https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/Instances/LikePDOStatement.php#L1302-L1313
|
237,088
|
samurai-fw/samurai
|
src/Samurai/Controller/Controller.php
|
Controller.getFilters
|
public function getFilters()
{
$filters = [];
$names = explode('_', $this->name);
$base = '';
$filters = [];
while ($name = array_shift($names)) {
$filter = $this->_searchInControllerDir($base, 'filter.yml');
if ($filter) $filters[] = $filter;
// when has rest.
if (count($names) > 0) {
$base = $base . DS . ucfirst($name);
// when last.
} else {
$filter = $this->_searchInControllerDir($base, "{$name}.filter.yml");
if ($filter) $filters[] = $filter;
}
}
return $filters;
}
|
php
|
public function getFilters()
{
$filters = [];
$names = explode('_', $this->name);
$base = '';
$filters = [];
while ($name = array_shift($names)) {
$filter = $this->_searchInControllerDir($base, 'filter.yml');
if ($filter) $filters[] = $filter;
// when has rest.
if (count($names) > 0) {
$base = $base . DS . ucfirst($name);
// when last.
} else {
$filter = $this->_searchInControllerDir($base, "{$name}.filter.yml");
if ($filter) $filters[] = $filter;
}
}
return $filters;
}
|
[
"public",
"function",
"getFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"$",
"names",
"=",
"explode",
"(",
"'_'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"base",
"=",
"''",
";",
"$",
"filters",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"names",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"_searchInControllerDir",
"(",
"$",
"base",
",",
"'filter.yml'",
")",
";",
"if",
"(",
"$",
"filter",
")",
"$",
"filters",
"[",
"]",
"=",
"$",
"filter",
";",
"// when has rest.",
"if",
"(",
"count",
"(",
"$",
"names",
")",
">",
"0",
")",
"{",
"$",
"base",
"=",
"$",
"base",
".",
"DS",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"// when last.",
"}",
"else",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"_searchInControllerDir",
"(",
"$",
"base",
",",
"\"{$name}.filter.yml\"",
")",
";",
"if",
"(",
"$",
"filter",
")",
"$",
"filters",
"[",
"]",
"=",
"$",
"filter",
";",
"}",
"}",
"return",
"$",
"filters",
";",
"}"
] |
Get filter paths
1. Controller/filter.yml
2. Controller/foo.filter.yml
|
[
"Get",
"filter",
"paths"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L117-L140
|
237,089
|
samurai-fw/samurai
|
src/Samurai/Controller/Controller.php
|
Controller.getFilterKey
|
public function getFilterKey($action = null)
{
// controller.action
$controller = $this->getName();
return $action ? $controller . '.' . $action : $controller;
}
|
php
|
public function getFilterKey($action = null)
{
// controller.action
$controller = $this->getName();
return $action ? $controller . '.' . $action : $controller;
}
|
[
"public",
"function",
"getFilterKey",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"// controller.action",
"$",
"controller",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"action",
"?",
"$",
"controller",
".",
"'.'",
".",
"$",
"action",
":",
"$",
"controller",
";",
"}"
] |
Get filter key
@param string $action
@return string
|
[
"Get",
"filter",
"key"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L149-L154
|
237,090
|
samurai-fw/samurai
|
src/Samurai/Controller/Controller.php
|
Controller.task
|
public function task($name, array $options = [])
{
$this->taskProcessor->setOutput($this);
$this->taskProcessor->execute($name, $options);
}
|
php
|
public function task($name, array $options = [])
{
$this->taskProcessor->setOutput($this);
$this->taskProcessor->execute($name, $options);
}
|
[
"public",
"function",
"task",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"taskProcessor",
"->",
"setOutput",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"taskProcessor",
"->",
"execute",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"}"
] |
get a task.
@access public
@param string $name
@return Samurai\Console\Task\Task
|
[
"get",
"a",
"task",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L207-L211
|
237,091
|
samurai-fw/samurai
|
src/Samurai/Controller/Controller.php
|
Controller._searchInControllerDir
|
private function _searchInControllerDir($base_dir, $file_name)
{
$dirs = $this->application->getControllerDirectories();
foreach ($dirs as $dir) {
$filter = $this->finder->path($dir . $base_dir)->name($file_name)->find()->first();
if ($filter) return $filter;
}
}
|
php
|
private function _searchInControllerDir($base_dir, $file_name)
{
$dirs = $this->application->getControllerDirectories();
foreach ($dirs as $dir) {
$filter = $this->finder->path($dir . $base_dir)->name($file_name)->find()->first();
if ($filter) return $filter;
}
}
|
[
"private",
"function",
"_searchInControllerDir",
"(",
"$",
"base_dir",
",",
"$",
"file_name",
")",
"{",
"$",
"dirs",
"=",
"$",
"this",
"->",
"application",
"->",
"getControllerDirectories",
"(",
")",
";",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"finder",
"->",
"path",
"(",
"$",
"dir",
".",
"$",
"base_dir",
")",
"->",
"name",
"(",
"$",
"file_name",
")",
"->",
"find",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"filter",
")",
"return",
"$",
"filter",
";",
"}",
"}"
] |
search in controller dirs
@param string $base_dir
@param string $file_name
@return Samurai\Samurai\Component\FileSystem\Finder\Iterator\Iterator
|
[
"search",
"in",
"controller",
"dirs"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L259-L266
|
237,092
|
bernardosecades/packagist-security-checker
|
src/Compiler/Compiler.php
|
Compiler.addPHPFiles
|
private function addPHPFiles(Phar $phar)
{
$finder = new Finder();
$finder
->files()
->ignoreVCS(true)
->name('*.php')
->notName('Compiler.php')
->in(realpath(__DIR__.'/../../src'));
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
return $this;
}
|
php
|
private function addPHPFiles(Phar $phar)
{
$finder = new Finder();
$finder
->files()
->ignoreVCS(true)
->name('*.php')
->notName('Compiler.php')
->in(realpath(__DIR__.'/../../src'));
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
return $this;
}
|
[
"private",
"function",
"addPHPFiles",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"ignoreVCS",
"(",
"true",
")",
"->",
"name",
"(",
"'*.php'",
")",
"->",
"notName",
"(",
"'Compiler.php'",
")",
"->",
"in",
"(",
"realpath",
"(",
"__DIR__",
".",
"'/../../src'",
")",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"addFile",
"(",
"$",
"phar",
",",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add php files
@param Phar $phar Phar instance
@return Compiler self Object
|
[
"Add",
"php",
"files"
] |
da8212da47f3e0c08ec4a226496788853e9879d9
|
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L159-L174
|
237,093
|
bernardosecades/packagist-security-checker
|
src/Compiler/Compiler.php
|
Compiler.addVendorFiles
|
private function addVendorFiles(Phar $phar)
{
$vendorPath = __DIR__.'/../../vendor/';
$requiredDependencies = [
realpath($vendorPath.'symfony/'),
realpath($vendorPath.'doctrine/'),
realpath($vendorPath.'guzzlehttp'),
realpath($vendorPath.'psr'),
];
$finder = new Finder();
$finder
->files()
->ignoreVCS(true)
->name('*.php')
->exclude(['Tests', 'tests'])
->in($requiredDependencies);
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
return $this;
}
|
php
|
private function addVendorFiles(Phar $phar)
{
$vendorPath = __DIR__.'/../../vendor/';
$requiredDependencies = [
realpath($vendorPath.'symfony/'),
realpath($vendorPath.'doctrine/'),
realpath($vendorPath.'guzzlehttp'),
realpath($vendorPath.'psr'),
];
$finder = new Finder();
$finder
->files()
->ignoreVCS(true)
->name('*.php')
->exclude(['Tests', 'tests'])
->in($requiredDependencies);
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
return $this;
}
|
[
"private",
"function",
"addVendorFiles",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"vendorPath",
"=",
"__DIR__",
".",
"'/../../vendor/'",
";",
"$",
"requiredDependencies",
"=",
"[",
"realpath",
"(",
"$",
"vendorPath",
".",
"'symfony/'",
")",
",",
"realpath",
"(",
"$",
"vendorPath",
".",
"'doctrine/'",
")",
",",
"realpath",
"(",
"$",
"vendorPath",
".",
"'guzzlehttp'",
")",
",",
"realpath",
"(",
"$",
"vendorPath",
".",
"'psr'",
")",
",",
"]",
";",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"ignoreVCS",
"(",
"true",
")",
"->",
"name",
"(",
"'*.php'",
")",
"->",
"exclude",
"(",
"[",
"'Tests'",
",",
"'tests'",
"]",
")",
"->",
"in",
"(",
"$",
"requiredDependencies",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"addFile",
"(",
"$",
"phar",
",",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add vendor files
@param Phar $phar Phar instance
@return Compiler self Object
|
[
"Add",
"vendor",
"files"
] |
da8212da47f3e0c08ec4a226496788853e9879d9
|
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L183-L207
|
237,094
|
bernardosecades/packagist-security-checker
|
src/Compiler/Compiler.php
|
Compiler.addComposerVendorFiles
|
private function addComposerVendorFiles(Phar $phar)
{
$vendorPath = __DIR__.'/../../vendor/';
$this
->addFile($phar, new \SplFileInfo($vendorPath.'autoload.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_namespaces.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_psr4.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_classmap.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_real.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_static.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/ClassLoader.php'));
return $this;
}
|
php
|
private function addComposerVendorFiles(Phar $phar)
{
$vendorPath = __DIR__.'/../../vendor/';
$this
->addFile($phar, new \SplFileInfo($vendorPath.'autoload.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_namespaces.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_psr4.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_classmap.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_real.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_static.php'))
->addFile($phar, new \SplFileInfo($vendorPath.'composer/ClassLoader.php'));
return $this;
}
|
[
"private",
"function",
"addComposerVendorFiles",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"vendorPath",
"=",
"__DIR__",
".",
"'/../../vendor/'",
";",
"$",
"this",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'autoload.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/autoload_namespaces.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/autoload_psr4.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/autoload_classmap.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/autoload_real.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/autoload_static.php'",
")",
")",
"->",
"addFile",
"(",
"$",
"phar",
",",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"vendorPath",
".",
"'composer/ClassLoader.php'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add composer vendor files
@param Phar $phar Phar
@return Compiler self Object
|
[
"Add",
"composer",
"vendor",
"files"
] |
da8212da47f3e0c08ec4a226496788853e9879d9
|
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L216-L230
|
237,095
|
marando/phpSOFA
|
src/Marando/IAU/iauEe00a.php
|
iauEe00a.Ee00a
|
public static function Ee00a($date1, $date2) {
$dpsipr;
$depspr;
$epsa;
$dpsi;
$deps;
$ee;
/* IAU 2000 precession-rate adjustments. */
IAU::Pr00($date1, $date2, $dpsipr, $depspr);
/* Mean obliquity, consistent with IAU 2000 precession-nutation. */
$epsa = IAU::Obl80($date1, $date2) + $depspr;
/* Nutation in longitude. */
IAU::Nut00a($date1, $date2, $dpsi, $deps);
/* Equation of the equinoxes. */
$ee = IAU::Ee00($date1, $date2, $epsa, $dpsi);
return $ee;
}
|
php
|
public static function Ee00a($date1, $date2) {
$dpsipr;
$depspr;
$epsa;
$dpsi;
$deps;
$ee;
/* IAU 2000 precession-rate adjustments. */
IAU::Pr00($date1, $date2, $dpsipr, $depspr);
/* Mean obliquity, consistent with IAU 2000 precession-nutation. */
$epsa = IAU::Obl80($date1, $date2) + $depspr;
/* Nutation in longitude. */
IAU::Nut00a($date1, $date2, $dpsi, $deps);
/* Equation of the equinoxes. */
$ee = IAU::Ee00($date1, $date2, $epsa, $dpsi);
return $ee;
}
|
[
"public",
"static",
"function",
"Ee00a",
"(",
"$",
"date1",
",",
"$",
"date2",
")",
"{",
"$",
"dpsipr",
";",
"$",
"depspr",
";",
"$",
"epsa",
";",
"$",
"dpsi",
";",
"$",
"deps",
";",
"$",
"ee",
";",
"/* IAU 2000 precession-rate adjustments. */",
"IAU",
"::",
"Pr00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"dpsipr",
",",
"$",
"depspr",
")",
";",
"/* Mean obliquity, consistent with IAU 2000 precession-nutation. */",
"$",
"epsa",
"=",
"IAU",
"::",
"Obl80",
"(",
"$",
"date1",
",",
"$",
"date2",
")",
"+",
"$",
"depspr",
";",
"/* Nutation in longitude. */",
"IAU",
"::",
"Nut00a",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"dpsi",
",",
"$",
"deps",
")",
";",
"/* Equation of the equinoxes. */",
"$",
"ee",
"=",
"IAU",
"::",
"Ee00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"epsa",
",",
"$",
"dpsi",
")",
";",
"return",
"$",
"ee",
";",
"}"
] |
- - - - - - - - -
i a u E e 0 0 a
- - - - - - - - -
Equation of the equinoxes, compatible with IAU 2000 resolutions.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: support function.
Given:
date1,date2 double TT as a 2-part Julian Date (Note 1)
Returned (function value):
double equation of the equinoxes (Note 2)
Notes:
1) The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways,
among others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable. The J2000 method is best matched to the way
the argument is handled internally and will deliver the
optimum resolution. The MJD method and the date & time methods
are both good compromises between resolution and convenience.
2) The result, which is in radians, operates in the following sense:
Greenwich apparent ST = GMST + equation of the equinoxes
3) The result is compatible with the IAU 2000 resolutions. For
further details, see IERS Conventions 2003 and Capitaine et al.
(2002).
Called:
iauPr00 IAU 2000 precession adjustments
iauObl80 mean obliquity, IAU 1980
iauNut00a nutation, IAU 2000A
iauEe00 equation of the equinoxes, IAU 2000
References:
Capitaine, N., Wallace, P.T. and McCarthy, D.D., "Expressions to
implement the IAU 2000 definition of UT1", Astronomy &
Astrophysics, 406, 1135-1149 (2003).
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004).
This revision: 2008 May 16
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"E",
"e",
"0",
"0",
"a",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauEe00a.php#L75-L96
|
237,096
|
MehrAlsNix/Assumptions
|
src/Extensions/Network.php
|
Network.assumeSocket
|
public static function assumeSocket($address, $port = 0): void
{
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
assumeThat($socket, is(not(false)), self::$SOCK_ERR_MSG . socket_last_error($socket));
assumeThat(
@socket_connect($socket, $address, $port),
is(not(false)),
'Unable to connect: ' . $address . ':' . $port
);
}
|
php
|
public static function assumeSocket($address, $port = 0): void
{
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
assumeThat($socket, is(not(false)), self::$SOCK_ERR_MSG . socket_last_error($socket));
assumeThat(
@socket_connect($socket, $address, $port),
is(not(false)),
'Unable to connect: ' . $address . ':' . $port
);
}
|
[
"public",
"static",
"function",
"assumeSocket",
"(",
"$",
"address",
",",
"$",
"port",
"=",
"0",
")",
":",
"void",
"{",
"$",
"socket",
"=",
"@",
"socket_create",
"(",
"AF_INET",
",",
"SOCK_STREAM",
",",
"SOL_TCP",
")",
";",
"assumeThat",
"(",
"$",
"socket",
",",
"is",
"(",
"not",
"(",
"false",
")",
")",
",",
"self",
"::",
"$",
"SOCK_ERR_MSG",
".",
"socket_last_error",
"(",
"$",
"socket",
")",
")",
";",
"assumeThat",
"(",
"@",
"socket_connect",
"(",
"$",
"socket",
",",
"$",
"address",
",",
"$",
"port",
")",
",",
"is",
"(",
"not",
"(",
"false",
")",
")",
",",
"'Unable to connect: '",
".",
"$",
"address",
".",
"':'",
".",
"$",
"port",
")",
";",
"}"
] |
Assumes that a specified socket connection could be established.
@param string $address
@param int $port
@return void
@throws AssumptionViolatedException
|
[
"Assumes",
"that",
"a",
"specified",
"socket",
"connection",
"could",
"be",
"established",
"."
] |
5d28349354bc80409beeac52df79e57d1d52bcf2
|
https://github.com/MehrAlsNix/Assumptions/blob/5d28349354bc80409beeac52df79e57d1d52bcf2/src/Extensions/Network.php#L44-L54
|
237,097
|
axypro/creator
|
helpers/PointerFormat.php
|
PointerFormat.normalize
|
public static function normalize($pointer, array $context = null)
{
if (is_object($pointer)) {
return ['value' => $pointer];
}
if (is_string($pointer)) {
return ['classname' => $pointer];
}
if ($pointer === null) {
return [];
}
if ($pointer === false) {
throw new Disabled('');
}
if (!is_array($pointer)) {
throw new InvalidPointer('invalid pointer type');
}
if (!isset($pointer[0])) {
return $pointer;
}
return self::normalizeNumeric($pointer, $context);
}
|
php
|
public static function normalize($pointer, array $context = null)
{
if (is_object($pointer)) {
return ['value' => $pointer];
}
if (is_string($pointer)) {
return ['classname' => $pointer];
}
if ($pointer === null) {
return [];
}
if ($pointer === false) {
throw new Disabled('');
}
if (!is_array($pointer)) {
throw new InvalidPointer('invalid pointer type');
}
if (!isset($pointer[0])) {
return $pointer;
}
return self::normalizeNumeric($pointer, $context);
}
|
[
"public",
"static",
"function",
"normalize",
"(",
"$",
"pointer",
",",
"array",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"pointer",
")",
")",
"{",
"return",
"[",
"'value'",
"=>",
"$",
"pointer",
"]",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"pointer",
")",
")",
"{",
"return",
"[",
"'classname'",
"=>",
"$",
"pointer",
"]",
";",
"}",
"if",
"(",
"$",
"pointer",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"pointer",
"===",
"false",
")",
"{",
"throw",
"new",
"Disabled",
"(",
"''",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"pointer",
")",
")",
"{",
"throw",
"new",
"InvalidPointer",
"(",
"'invalid pointer type'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"pointer",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"pointer",
";",
"}",
"return",
"self",
"::",
"normalizeNumeric",
"(",
"$",
"pointer",
",",
"$",
"context",
")",
";",
"}"
] |
Normalizes the pointer format
@param mixed $pointer
@param array $context [optional]
@return array
@throws \axy\creator\errors\InvalidPointer
@throws \axy\creator\errors\Disabled
|
[
"Normalizes",
"the",
"pointer",
"format"
] |
3d74e2201cdb93912d32b1d80d1fdc44018f132a
|
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/PointerFormat.php#L26-L47
|
237,098
|
lasallecrm/lasallecrm-l5-listmanagement-pkg
|
src/Http/Controllers/FrontendListUnsubscribeController.php
|
FrontendListUnsubscribeController.unsubscribe
|
public function unsubscribe($token) {
// Does the token exist in the list_unsubscribe_token database table?
if (!$this->model->isTokenValid($token)) {
return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid', [
'title' => 'Invalid Unsubscribe Token',
]);
}
$emailID = $this->model->getEmailIdByToken($token);
$listID = $this->model->getListIdByToken($token);
// email address
$email = $this->emailRepository->getEmailByEmailId($emailID);
// list's name
$listName = $this->listRepository->getListnameByListId($listID);
// Delete all list_unsubscribe_token records for this email_id and list_id
$this->model->deleteAllTokensForListIDandEmailID($listID,$emailID);
// un-enabled (ie, disable) the list_email database record for this email_id and list_id
$this->list_EmailRepository->enabledFalse($emailID, $listID);
return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success', [
'title' => 'Unsubscribe Successful',
'email' => $email,
'listName' => $listName
]);
}
|
php
|
public function unsubscribe($token) {
// Does the token exist in the list_unsubscribe_token database table?
if (!$this->model->isTokenValid($token)) {
return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid', [
'title' => 'Invalid Unsubscribe Token',
]);
}
$emailID = $this->model->getEmailIdByToken($token);
$listID = $this->model->getListIdByToken($token);
// email address
$email = $this->emailRepository->getEmailByEmailId($emailID);
// list's name
$listName = $this->listRepository->getListnameByListId($listID);
// Delete all list_unsubscribe_token records for this email_id and list_id
$this->model->deleteAllTokensForListIDandEmailID($listID,$emailID);
// un-enabled (ie, disable) the list_email database record for this email_id and list_id
$this->list_EmailRepository->enabledFalse($emailID, $listID);
return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success', [
'title' => 'Unsubscribe Successful',
'email' => $email,
'listName' => $listName
]);
}
|
[
"public",
"function",
"unsubscribe",
"(",
"$",
"token",
")",
"{",
"// Does the token exist in the list_unsubscribe_token database table?",
"if",
"(",
"!",
"$",
"this",
"->",
"model",
"->",
"isTokenValid",
"(",
"$",
"token",
")",
")",
"{",
"return",
"view",
"(",
"'lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid'",
",",
"[",
"'title'",
"=>",
"'Invalid Unsubscribe Token'",
",",
"]",
")",
";",
"}",
"$",
"emailID",
"=",
"$",
"this",
"->",
"model",
"->",
"getEmailIdByToken",
"(",
"$",
"token",
")",
";",
"$",
"listID",
"=",
"$",
"this",
"->",
"model",
"->",
"getListIdByToken",
"(",
"$",
"token",
")",
";",
"// email address",
"$",
"email",
"=",
"$",
"this",
"->",
"emailRepository",
"->",
"getEmailByEmailId",
"(",
"$",
"emailID",
")",
";",
"// list's name",
"$",
"listName",
"=",
"$",
"this",
"->",
"listRepository",
"->",
"getListnameByListId",
"(",
"$",
"listID",
")",
";",
"// Delete all list_unsubscribe_token records for this email_id and list_id",
"$",
"this",
"->",
"model",
"->",
"deleteAllTokensForListIDandEmailID",
"(",
"$",
"listID",
",",
"$",
"emailID",
")",
";",
"// un-enabled (ie, disable) the list_email database record for this email_id and list_id",
"$",
"this",
"->",
"list_EmailRepository",
"->",
"enabledFalse",
"(",
"$",
"emailID",
",",
"$",
"listID",
")",
";",
"return",
"view",
"(",
"'lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success'",
",",
"[",
"'title'",
"=>",
"'Unsubscribe Successful'",
",",
"'email'",
"=>",
"$",
"email",
",",
"'listName'",
"=>",
"$",
"listName",
"]",
")",
";",
"}"
] |
Unsubscribe from a LaSalleCRM email list
@param $token
|
[
"Unsubscribe",
"from",
"a",
"LaSalleCRM",
"email",
"list"
] |
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
|
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Http/Controllers/FrontendListUnsubscribeController.php#L98-L127
|
237,099
|
elcodi/Configuration
|
Services/ConfigurationManager.php
|
ConfigurationManager.get
|
public function get($configurationIdentifier, $defaultValue = null)
{
/**
* Checks if the value is defined in the configuration elements.
*/
if (!array_key_exists($configurationIdentifier, $this->configurationElements)) {
if (!is_null($defaultValue)) {
return $defaultValue;
}
throw new ConfigurationParameterNotFoundException();
}
$valueIsCached = $this
->cache
->contains($configurationIdentifier);
/**
* The value is cached, so we can securely return its value.
* We must unserialize the value if needed.
*/
if (false !== $valueIsCached) {
return $this
->cache
->fetch($configurationIdentifier);
}
list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier);
$configurationLoaded = $this->loadConfiguration(
$configurationNamespace,
$configurationKey
);
if (!($configurationLoaded instanceof ConfigurationInterface)) {
$configurationElement = $this->configurationElements[$configurationIdentifier];
$configurationValue = isset($configurationElement['reference'])
? $this->parameterBag->get($configurationElement['reference'])
: $configurationElement['default_value'];
if (empty($configurationValue) && !$configurationElement['can_be_empty']) {
$message = $configurationElement['empty_message']
?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved';
throw new Exception($message);
}
$configurationLoaded = $this
->createConfigurationInstance(
$configurationIdentifier,
$configurationNamespace,
$configurationKey,
$configurationValue
);
$this->flushConfiguration($configurationLoaded);
}
$configurationValueUnserialized = $this->flushConfigurationToCache(
$configurationLoaded,
$configurationIdentifier
);
return $configurationValueUnserialized;
}
|
php
|
public function get($configurationIdentifier, $defaultValue = null)
{
/**
* Checks if the value is defined in the configuration elements.
*/
if (!array_key_exists($configurationIdentifier, $this->configurationElements)) {
if (!is_null($defaultValue)) {
return $defaultValue;
}
throw new ConfigurationParameterNotFoundException();
}
$valueIsCached = $this
->cache
->contains($configurationIdentifier);
/**
* The value is cached, so we can securely return its value.
* We must unserialize the value if needed.
*/
if (false !== $valueIsCached) {
return $this
->cache
->fetch($configurationIdentifier);
}
list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier);
$configurationLoaded = $this->loadConfiguration(
$configurationNamespace,
$configurationKey
);
if (!($configurationLoaded instanceof ConfigurationInterface)) {
$configurationElement = $this->configurationElements[$configurationIdentifier];
$configurationValue = isset($configurationElement['reference'])
? $this->parameterBag->get($configurationElement['reference'])
: $configurationElement['default_value'];
if (empty($configurationValue) && !$configurationElement['can_be_empty']) {
$message = $configurationElement['empty_message']
?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved';
throw new Exception($message);
}
$configurationLoaded = $this
->createConfigurationInstance(
$configurationIdentifier,
$configurationNamespace,
$configurationKey,
$configurationValue
);
$this->flushConfiguration($configurationLoaded);
}
$configurationValueUnserialized = $this->flushConfigurationToCache(
$configurationLoaded,
$configurationIdentifier
);
return $configurationValueUnserialized;
}
|
[
"public",
"function",
"get",
"(",
"$",
"configurationIdentifier",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"/**\n * Checks if the value is defined in the configuration elements.\n */",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"configurationIdentifier",
",",
"$",
"this",
"->",
"configurationElements",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"defaultValue",
")",
")",
"{",
"return",
"$",
"defaultValue",
";",
"}",
"throw",
"new",
"ConfigurationParameterNotFoundException",
"(",
")",
";",
"}",
"$",
"valueIsCached",
"=",
"$",
"this",
"->",
"cache",
"->",
"contains",
"(",
"$",
"configurationIdentifier",
")",
";",
"/**\n * The value is cached, so we can securely return its value.\n * We must unserialize the value if needed.\n */",
"if",
"(",
"false",
"!==",
"$",
"valueIsCached",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"fetch",
"(",
"$",
"configurationIdentifier",
")",
";",
"}",
"list",
"(",
"$",
"configurationNamespace",
",",
"$",
"configurationKey",
")",
"=",
"$",
"this",
"->",
"splitConfigurationKey",
"(",
"$",
"configurationIdentifier",
")",
";",
"$",
"configurationLoaded",
"=",
"$",
"this",
"->",
"loadConfiguration",
"(",
"$",
"configurationNamespace",
",",
"$",
"configurationKey",
")",
";",
"if",
"(",
"!",
"(",
"$",
"configurationLoaded",
"instanceof",
"ConfigurationInterface",
")",
")",
"{",
"$",
"configurationElement",
"=",
"$",
"this",
"->",
"configurationElements",
"[",
"$",
"configurationIdentifier",
"]",
";",
"$",
"configurationValue",
"=",
"isset",
"(",
"$",
"configurationElement",
"[",
"'reference'",
"]",
")",
"?",
"$",
"this",
"->",
"parameterBag",
"->",
"get",
"(",
"$",
"configurationElement",
"[",
"'reference'",
"]",
")",
":",
"$",
"configurationElement",
"[",
"'default_value'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"configurationValue",
")",
"&&",
"!",
"$",
"configurationElement",
"[",
"'can_be_empty'",
"]",
")",
"{",
"$",
"message",
"=",
"$",
"configurationElement",
"[",
"'empty_message'",
"]",
"?",
":",
"'The configuration element \"'",
".",
"$",
"configurationIdentifier",
".",
"'\" cannot be resolved'",
";",
"throw",
"new",
"Exception",
"(",
"$",
"message",
")",
";",
"}",
"$",
"configurationLoaded",
"=",
"$",
"this",
"->",
"createConfigurationInstance",
"(",
"$",
"configurationIdentifier",
",",
"$",
"configurationNamespace",
",",
"$",
"configurationKey",
",",
"$",
"configurationValue",
")",
";",
"$",
"this",
"->",
"flushConfiguration",
"(",
"$",
"configurationLoaded",
")",
";",
"}",
"$",
"configurationValueUnserialized",
"=",
"$",
"this",
"->",
"flushConfigurationToCache",
"(",
"$",
"configurationLoaded",
",",
"$",
"configurationIdentifier",
")",
";",
"return",
"$",
"configurationValueUnserialized",
";",
"}"
] |
Loads a parameter given the format "namespace.key".
@param string $configurationIdentifier Configuration identifier
@param string|null $defaultValue Default value
@return null|string|bool Configuration parameter value
@throws ConfigurationParameterNotFoundException Configuration parameter not found
@throws Exception Configuration cannot be resolved
|
[
"Loads",
"a",
"parameter",
"given",
"the",
"format",
"namespace",
".",
"key",
"."
] |
1e416269c2e1bd957f98c6b1845dffb218794c55
|
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L171-L234
|
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.