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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
PowerOnSystem/WebFramework | src/Routing/Dispatcher.php | Dispatcher.force | public function force($request_controller, $request_action = 'index') {
$this->controller = $request_controller;
$this->action = $request_action;
$handler = $this->loadController();
if ( !$handler ) {
throw new LogicException(sprintf('No se existe la clase del controlador (%s)', $this->controller));
}
if ( !method_exists($handler, $this->action) ) {
$reflection = new \ReflectionClass($handler);
throw new LogicException(sprintf('No existe el método (%s) del controlador (%s)',
$this->action, $reflection->getName()), ['controller' => $handler]);
}
return $handler;
} | php | public function force($request_controller, $request_action = 'index') {
$this->controller = $request_controller;
$this->action = $request_action;
$handler = $this->loadController();
if ( !$handler ) {
throw new LogicException(sprintf('No se existe la clase del controlador (%s)', $this->controller));
}
if ( !method_exists($handler, $this->action) ) {
$reflection = new \ReflectionClass($handler);
throw new LogicException(sprintf('No existe el método (%s) del controlador (%s)',
$this->action, $reflection->getName()), ['controller' => $handler]);
}
return $handler;
} | [
"public",
"function",
"force",
"(",
"$",
"request_controller",
",",
"$",
"request_action",
"=",
"'index'",
")",
"{",
"$",
"this",
"->",
"controller",
"=",
"$",
"request_controller",
";",
"$",
"this",
"->",
"action",
"=",
"$",
"request_action",
";",
"$",
"h... | Forza la carga de un controlador
@param string $request_controller
@param string $request_action
@return \PowerOn\Controller\Controller
@throws LogicException | [
"Forza",
"la",
"carga",
"de",
"un",
"controlador"
] | 3b885a390adc42d6ad93d7900d33d97c66a6c2a9 | https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L78-L96 | train |
PowerOnSystem/WebFramework | src/Routing/Dispatcher.php | Dispatcher.loadController | private function loadController() {
$controller_name = Inflector::classify($this->controller) . 'Controller';
$controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name;
if ( !class_exists($controller_class) ) {
return FALSE;
}
return new $controller_class();
} | php | private function loadController() {
$controller_name = Inflector::classify($this->controller) . 'Controller';
$controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name;
if ( !class_exists($controller_class) ) {
return FALSE;
}
return new $controller_class();
} | [
"private",
"function",
"loadController",
"(",
")",
"{",
"$",
"controller_name",
"=",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"controller",
")",
".",
"'Controller'",
";",
"$",
"controller_class",
"=",
"$",
"this",
"->",
"controller",
"===",
"'s... | Verifica la existencia del controlador solicitado y lo devuelve
@return \PowerOn\Controller\Controller Devuelve una instancia del controlador solicitado, devuelve FALSE si no existe | [
"Verifica",
"la",
"existencia",
"del",
"controlador",
"solicitado",
"y",
"lo",
"devuelve"
] | 3b885a390adc42d6ad93d7900d33d97c66a6c2a9 | https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L102-L111 | train |
emaphp/zenith-soap | src/Zenith/SOAP/Request.php | Request.getParameter | public function getParameter($as = self::AS_STRING) {
if ($as == self::AS_SIMPLEXML) {
//convert to SimpleXMLElement
$success = simplexml_load_string($this->parameter);
if ($success === false) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $success;
}
elseif ($as == self::AS_DOM) {
//convert to DOMDocument
$dom = new \DOMDocument();
if (!$dom->loadXML($this->parameter)) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $dom;
}
return $this->parameter;
} | php | public function getParameter($as = self::AS_STRING) {
if ($as == self::AS_SIMPLEXML) {
//convert to SimpleXMLElement
$success = simplexml_load_string($this->parameter);
if ($success === false) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $success;
}
elseif ($as == self::AS_DOM) {
//convert to DOMDocument
$dom = new \DOMDocument();
if (!$dom->loadXML($this->parameter)) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $dom;
}
return $this->parameter;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"as",
"=",
"self",
"::",
"AS_STRING",
")",
"{",
"if",
"(",
"$",
"as",
"==",
"self",
"::",
"AS_SIMPLEXML",
")",
"{",
"//convert to SimpleXMLElement",
"$",
"success",
"=",
"simplexml_load_string",
"(",
"$",
"this... | Obtains parameter in the specified format
@param int $as
@return SimpleXMLElement|\DOMDocument|string | [
"Obtains",
"parameter",
"in",
"the",
"specified",
"format"
] | 06622c2fcf0566e3f5c75cb5bc086e06823a5db5 | https://github.com/emaphp/zenith-soap/blob/06622c2fcf0566e3f5c75cb5bc086e06823a5db5/src/Zenith/SOAP/Request.php#L154-L179 | train |
OWeb/OWeb-Framework | OWeb/utils/js/jquery/HeaderOnReadyManager.php | HeaderOnReadyManager.makeAdd | public function makeAdd(){
if(OWEB_DEBUG > 0)
$code .= $this->makeAddNormal ();
else
$code .= $this->makeAddNormal ();
Headers::getInstance()->addHeader($code, Headers::jsCode);
} | php | public function makeAdd(){
if(OWEB_DEBUG > 0)
$code .= $this->makeAddNormal ();
else
$code .= $this->makeAddNormal ();
Headers::getInstance()->addHeader($code, Headers::jsCode);
} | [
"public",
"function",
"makeAdd",
"(",
")",
"{",
"if",
"(",
"OWEB_DEBUG",
">",
"0",
")",
"$",
"code",
".=",
"$",
"this",
"->",
"makeAddNormal",
"(",
")",
";",
"else",
"$",
"code",
".=",
"$",
"this",
"->",
"makeAddNormal",
"(",
")",
";",
"Headers",
"... | Will add the headers registered to the main Headers Manager | [
"Will",
"add",
"the",
"headers",
"registered",
"to",
"the",
"main",
"Headers",
"Manager"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L66-L73 | train |
OWeb/OWeb-Framework | OWeb/utils/js/jquery/HeaderOnReadyManager.php | HeaderOnReadyManager.makeAddDebug | public function makeAddDebug(){
$s = "";
foreach ($this->headers as $code){
$s .= '$( document ).ready(function() {'."\n";
$s .= $code;
$s .= "\n});\n\n";
}
return $s;
} | php | public function makeAddDebug(){
$s = "";
foreach ($this->headers as $code){
$s .= '$( document ).ready(function() {'."\n";
$s .= $code;
$s .= "\n});\n\n";
}
return $s;
} | [
"public",
"function",
"makeAddDebug",
"(",
")",
"{",
"$",
"s",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"code",
")",
"{",
"$",
"s",
".=",
"'$( document ).ready(function() {'",
".",
"\"\\n\"",
";",
"$",
"s",
".=",
"$",
... | If debug is active we should separate each JS function to prevent one
wrong code to brake all others
@return string | [
"If",
"debug",
"is",
"active",
"we",
"should",
"separate",
"each",
"JS",
"function",
"to",
"prevent",
"one",
"wrong",
"code",
"to",
"brake",
"all",
"others"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L81-L89 | train |
OWeb/OWeb-Framework | OWeb/utils/js/jquery/HeaderOnReadyManager.php | HeaderOnReadyManager.makeAddNormal | public function makeAddNormal(){
$s = "var oweb_ready = function (){";
foreach ($this->headers as $code)
$s .= $code."\n\n";
$s .= "}\n\n";
$s .= '$( document ).ready(function() {'."\n";
$s .= "oweb_ready(); \n";
$s .= "\n});\n\n";
return $s;
} | php | public function makeAddNormal(){
$s = "var oweb_ready = function (){";
foreach ($this->headers as $code)
$s .= $code."\n\n";
$s .= "}\n\n";
$s .= '$( document ).ready(function() {'."\n";
$s .= "oweb_ready(); \n";
$s .= "\n});\n\n";
return $s;
} | [
"public",
"function",
"makeAddNormal",
"(",
")",
"{",
"$",
"s",
"=",
"\"var oweb_ready = function (){\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"code",
")",
"$",
"s",
".=",
"$",
"code",
".",
"\"\\n\\n\"",
";",
"$",
"s",
".=",
"\... | If Debug isn't active we will put them all in 1 ready function to increase
performances and hope that all JS codes are okay.
@return string | [
"If",
"Debug",
"isn",
"t",
"active",
"we",
"will",
"put",
"them",
"all",
"in",
"1",
"ready",
"function",
"to",
"increase",
"performances",
"and",
"hope",
"that",
"all",
"JS",
"codes",
"are",
"okay",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L97-L108 | train |
ClassPreloader/Console | src/PreCompileCommand.php | PreCompileCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateCommand($input);
$output->writeln('> Loading configuration file');
$config = $input->getOption('config');
$files = (new ConfigResolver())->getFileList($config);
$output->writeLn('- Found '.count($files).' files');
$preloader = (new Factory())->create($this->getOptions($input));
$outputFile = $input->getOption('output');
$handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types'));
$output->writeln('> Compiling classes');
$count = 0;
$countSkipped = 0;
$comments = !$input->getOption('strip_comments');
foreach ($files as $file) {
$count++;
try {
$code = $preloader->getCode($file, $comments);
$output->writeln('- Writing '.$file);
fwrite($handle, $code."\n");
} catch (VisitorExceptionInterface $e) {
$countSkipped++;
$output->writeln('- Skipping '.$file);
}
}
fclose($handle);
$output->writeln("> Compiled loader written to $outputFile");
$output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')');
$output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateCommand($input);
$output->writeln('> Loading configuration file');
$config = $input->getOption('config');
$files = (new ConfigResolver())->getFileList($config);
$output->writeLn('- Found '.count($files).' files');
$preloader = (new Factory())->create($this->getOptions($input));
$outputFile = $input->getOption('output');
$handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types'));
$output->writeln('> Compiling classes');
$count = 0;
$countSkipped = 0;
$comments = !$input->getOption('strip_comments');
foreach ($files as $file) {
$count++;
try {
$code = $preloader->getCode($file, $comments);
$output->writeln('- Writing '.$file);
fwrite($handle, $code."\n");
} catch (VisitorExceptionInterface $e) {
$countSkipped++;
$output->writeln('- Skipping '.$file);
}
}
fclose($handle);
$output->writeln("> Compiled loader written to $outputFile");
$output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')');
$output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"validateCommand",
"(",
"$",
"input",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'> Loading configuration file'",
... | Executes the pre-compile command.
@param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return int|null | [
"Executes",
"the",
"pre",
"-",
"compile",
"command",
"."
] | 95935923e704ad4d0fb375e24849538405840ea5 | https://github.com/ClassPreloader/Console/blob/95935923e704ad4d0fb375e24849538405840ea5/src/PreCompileCommand.php#L64-L102 | train |
ClassPreloader/Console | src/PreCompileCommand.php | PreCompileCommand.getOptions | protected function getOptions(InputInterface $input)
{
return [
'dir' => (bool) $input->getOption('fix_dir'),
'file' => (bool) $input->getOption('fix_file'),
'skip' => (bool) $input->getOption('skip_dir_file'),
'strict' => (bool) $input->getOption('strict_types'),
];
} | php | protected function getOptions(InputInterface $input)
{
return [
'dir' => (bool) $input->getOption('fix_dir'),
'file' => (bool) $input->getOption('fix_file'),
'skip' => (bool) $input->getOption('skip_dir_file'),
'strict' => (bool) $input->getOption('strict_types'),
];
} | [
"protected",
"function",
"getOptions",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"return",
"[",
"'dir'",
"=>",
"(",
"bool",
")",
"$",
"input",
"->",
"getOption",
"(",
"'fix_dir'",
")",
",",
"'file'",
"=>",
"(",
"bool",
")",
"$",
"input",
"->",
"ge... | Get the options to pass to the factory.
@param \Symfony\Component\Console\Input\InputInterface $input
@return bool[] | [
"Get",
"the",
"options",
"to",
"pass",
"to",
"the",
"factory",
"."
] | 95935923e704ad4d0fb375e24849538405840ea5 | https://github.com/ClassPreloader/Console/blob/95935923e704ad4d0fb375e24849538405840ea5/src/PreCompileCommand.php#L131-L139 | train |
mvccore/ext-debug-tracy-auth | src/MvcCore/Ext/Debugs/Tracys/AuthPanel.php | AuthPanel.& | public function & getViewData () {
if ($this->view !== NULL) return $this->view;
$user = & \MvcCore\Ext\Auths\Basic::GetInstance()->GetUser();
$authenticated = $user instanceof \MvcCore\Ext\Auths\Basics\IUser;
$this->view = (object) [
'user' => $user,
'authenticated' => $authenticated,
];
return $this->view;
} | php | public function & getViewData () {
if ($this->view !== NULL) return $this->view;
$user = & \MvcCore\Ext\Auths\Basic::GetInstance()->GetUser();
$authenticated = $user instanceof \MvcCore\Ext\Auths\Basics\IUser;
$this->view = (object) [
'user' => $user,
'authenticated' => $authenticated,
];
return $this->view;
} | [
"public",
"function",
"&",
"getViewData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"view",
"!==",
"NULL",
")",
"return",
"$",
"this",
"->",
"view",
";",
"$",
"user",
"=",
"&",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Auths",
"\\",
"Basic",
"::",
... | Set up view data, if data are completed,
return them directly.
- complete basic \MvcCore core objects to complere other view data
- complete user and authorized boolean
- set result data into static field
@return object | [
"Set",
"up",
"view",
"data",
"if",
"data",
"are",
"completed",
"return",
"them",
"directly",
".",
"-",
"complete",
"basic",
"\\",
"MvcCore",
"core",
"objects",
"to",
"complere",
"other",
"view",
"data",
"-",
"complete",
"user",
"and",
"authorized",
"boolean"... | 3fc1abd6979914c062665841bb032ea57a07af30 | https://github.com/mvccore/ext-debug-tracy-auth/blob/3fc1abd6979914c062665841bb032ea57a07af30/src/MvcCore/Ext/Debugs/Tracys/AuthPanel.php#L82-L91 | train |
crip-laravel/core | src/Data/Repository.php | Repository.find | public function find($find, $column = 'id', array $relations = [], array $columns = ['*'])
{
$this->model = $this->where($column, $find);
$this->model = $this->relation->apply($this->model, $this, $relations);
return $this->model->firstOrFail($columns);
} | php | public function find($find, $column = 'id', array $relations = [], array $columns = ['*'])
{
$this->model = $this->where($column, $find);
$this->model = $this->relation->apply($this->model, $this, $relations);
return $this->model->firstOrFail($columns);
} | [
"public",
"function",
"find",
"(",
"$",
"find",
",",
"$",
"column",
"=",
"'id'",
",",
"array",
"$",
"relations",
"=",
"[",
"]",
",",
"array",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"this",
"->",
"w... | Find single record with secure relation keys only
Eager relations can be taken from request input
@param $find
@param string $column
@param array $relations
@param array $columns
@return Model | [
"Find",
"single",
"record",
"with",
"secure",
"relation",
"keys",
"only",
"Eager",
"relations",
"can",
"be",
"taken",
"from",
"request",
"input"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L158-L164 | train |
crip-laravel/core | src/Data/Repository.php | Repository.findWith | public function findWith($find, array $with = [], $column = 'id', array $columns = ['*'])
{
return $this->whereWith($find, $column, $with)->firstOrFail($columns);
} | php | public function findWith($find, array $with = [], $column = 'id', array $columns = ['*'])
{
return $this->whereWith($find, $column, $with)->firstOrFail($columns);
} | [
"public",
"function",
"findWith",
"(",
"$",
"find",
",",
"array",
"$",
"with",
"=",
"[",
"]",
",",
"$",
"column",
"=",
"'id'",
",",
"array",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"whereWith",
"(",
"$",
"find... | Find single record with custom relation query
@param $find
@param array $with
@param string $column
@param array $columns
@return Model | [
"Find",
"single",
"record",
"with",
"custom",
"relation",
"query"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L175-L178 | train |
crip-laravel/core | src/Data/Repository.php | Repository.onlyFillable | public function onlyFillable(array $input)
{
$result = array_intersect_key($input, array_flip($this->modelInstance->getFillable()));
foreach ($this->avoidEmptyUpdate as $avoid) {
if (array_key_exists($avoid, $result) && empty($result[$avoid])) {
unset($result[$avoid]);
}
}
return $result;
} | php | public function onlyFillable(array $input)
{
$result = array_intersect_key($input, array_flip($this->modelInstance->getFillable()));
foreach ($this->avoidEmptyUpdate as $avoid) {
if (array_key_exists($avoid, $result) && empty($result[$avoid])) {
unset($result[$avoid]);
}
}
return $result;
} | [
"public",
"function",
"onlyFillable",
"(",
"array",
"$",
"input",
")",
"{",
"$",
"result",
"=",
"array_intersect_key",
"(",
"$",
"input",
",",
"array_flip",
"(",
"$",
"this",
"->",
"modelInstance",
"->",
"getFillable",
"(",
")",
")",
")",
";",
"foreach",
... | Filter input from un allowed fields for model
@param array $input
@return array | [
"Filter",
"input",
"from",
"un",
"allowed",
"fields",
"for",
"model"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L353-L364 | train |
crip-laravel/core | src/Data/Repository.php | Repository.whereWith | protected function whereWith($find, $column, $with, $where_role = '=')
{
$this->where($column, $where_role, $find);
$this->with($with);
return $this->model;
} | php | protected function whereWith($find, $column, $with, $where_role = '=')
{
$this->where($column, $where_role, $find);
$this->with($with);
return $this->model;
} | [
"protected",
"function",
"whereWith",
"(",
"$",
"find",
",",
"$",
"column",
",",
"$",
"with",
",",
"$",
"where_role",
"=",
"'='",
")",
"{",
"$",
"this",
"->",
"where",
"(",
"$",
"column",
",",
"$",
"where_role",
",",
"$",
"find",
")",
";",
"$",
"... | Unfiltered querable with this model
@param $find
@param $column
@param $with
@param string $where_role
@return Builder | [
"Unfiltered",
"querable",
"with",
"this",
"model"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L403-L409 | train |
tux-rampage/rampage-php | library/rampage/core/PathManager.php | PathManager.get | public function get($type, $file = null)
{
if (!isset($this->paths[$type])) {
$method = 'get'.Utils::camelize($type).'Dir';
if (!method_exists($this, $method)) {
return null;
}
$this->set($type, $this->$method());
}
$path = $this->paths[$type];
if ($file) {
if ($path instanceof pathmanager\FallbackInterface) {
$path = $path->resolve($file);
} else {
$path .= '/' . ltrim($file, '/');
}
}
return $path;
} | php | public function get($type, $file = null)
{
if (!isset($this->paths[$type])) {
$method = 'get'.Utils::camelize($type).'Dir';
if (!method_exists($this, $method)) {
return null;
}
$this->set($type, $this->$method());
}
$path = $this->paths[$type];
if ($file) {
if ($path instanceof pathmanager\FallbackInterface) {
$path = $path->resolve($file);
} else {
$path .= '/' . ltrim($file, '/');
}
}
return $path;
} | [
"public",
"function",
"get",
"(",
"$",
"type",
",",
"$",
"file",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"paths",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"Utils",
"::",
"camelize",... | Returns a path
@param string $type
@param string $file | [
"Returns",
"a",
"path"
] | 1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf | https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/PathManager.php#L135-L157 | train |
o3co/query.extension.cql | Lexer.php | Lexer.isNextToken | public function isNextToken($token, $ignoreSpaces = true)
{
if($this->pos >= $this->len) {
return Tokens::T_END == $token;
}
switch($token) {
case Tokens::T_END:
return false;
case Tokens::T_OPERATOR:
return
$this->isNextToken(Tokens::T_LOGICAL_OP, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_COMPARISON_OP, $ignoreSpaces)
;
case Tokens::T_QUOTE:
return
$this->isNextToken(Tokens::T_SINGLE_QUOTE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_DOUBLE_QUOTE, $ignoreSpaces)
;
case Tokens::T_LOGICAL_OP:
return
$this->isNextToken(Tokens::T_AND, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_OR, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NOT, $ignoreSpaces)
;
break;
case Tokens::T_COMPARISON_OP:
return
$this->isNextToken(Tokens::T_EQ, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_NULL, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_ANY, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IN, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_RANGE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_MATCH, $ignoreSpaces)
;
break;
case Tokens::T_IDENTIFIER:
$pos = $this->pos;
if($ignoreSpaces) {
$pos = $this->getPosAfterSpaces($pos);
}
// if alphabet or '_' is following, then identifier.
return ctype_alpha($this->value[$pos]) || ('_' == $this->value[$pos]);
default:
$literal = $this->literals->getLiteralForToken($token);
if($this->literals->isSpace($literal)) {
$ignoreSpaces = false;
}
return $this->isNextLiteral($literal, $ignoreSpaces);
break;
}
} | php | public function isNextToken($token, $ignoreSpaces = true)
{
if($this->pos >= $this->len) {
return Tokens::T_END == $token;
}
switch($token) {
case Tokens::T_END:
return false;
case Tokens::T_OPERATOR:
return
$this->isNextToken(Tokens::T_LOGICAL_OP, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_COMPARISON_OP, $ignoreSpaces)
;
case Tokens::T_QUOTE:
return
$this->isNextToken(Tokens::T_SINGLE_QUOTE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_DOUBLE_QUOTE, $ignoreSpaces)
;
case Tokens::T_LOGICAL_OP:
return
$this->isNextToken(Tokens::T_AND, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_OR, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NOT, $ignoreSpaces)
;
break;
case Tokens::T_COMPARISON_OP:
return
$this->isNextToken(Tokens::T_EQ, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_NULL, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_ANY, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IN, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_RANGE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_MATCH, $ignoreSpaces)
;
break;
case Tokens::T_IDENTIFIER:
$pos = $this->pos;
if($ignoreSpaces) {
$pos = $this->getPosAfterSpaces($pos);
}
// if alphabet or '_' is following, then identifier.
return ctype_alpha($this->value[$pos]) || ('_' == $this->value[$pos]);
default:
$literal = $this->literals->getLiteralForToken($token);
if($this->literals->isSpace($literal)) {
$ignoreSpaces = false;
}
return $this->isNextLiteral($literal, $ignoreSpaces);
break;
}
} | [
"public",
"function",
"isNextToken",
"(",
"$",
"token",
",",
"$",
"ignoreSpaces",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pos",
">=",
"$",
"this",
"->",
"len",
")",
"{",
"return",
"Tokens",
"::",
"T_END",
"==",
"$",
"token",
";",
"}",... | isNextToken
Check the next token or literal
@param integer $token
@access public
@return void | [
"isNextToken",
"Check",
"the",
"next",
"token",
"or",
"literal"
] | 7fee694279db31364975d9e7f184a90f9e52f1e1 | https://github.com/o3co/query.extension.cql/blob/7fee694279db31364975d9e7f184a90f9e52f1e1/Lexer.php#L145-L201 | train |
xcitestudios/php-network | src/Email/EmailSerializable.php | EmailSerializable.setSender | public function setSender(ContactInterface $sender = null)
{
if ($sender !== null && !($sender instanceof Contact)) {
throw new InvalidArgumentException(
sprintf(
'%s expects an instance of %s.',
__FUNCTION__, Contact::class
)
);
}
$this->sender = $sender;
return $this;
} | php | public function setSender(ContactInterface $sender = null)
{
if ($sender !== null && !($sender instanceof Contact)) {
throw new InvalidArgumentException(
sprintf(
'%s expects an instance of %s.',
__FUNCTION__, Contact::class
)
);
}
$this->sender = $sender;
return $this;
} | [
"public",
"function",
"setSender",
"(",
"ContactInterface",
"$",
"sender",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"sender",
"!==",
"null",
"&&",
"!",
"(",
"$",
"sender",
"instanceof",
"Contact",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(... | Sets the sender.
Optional OR Required. Optional where From is one person. Required where From is multiple people.
@param Contact|null $sender
@throws InvalidArgumentException
@return static | [
"Sets",
"the",
"sender",
".",
"Optional",
"OR",
"Required",
".",
"Optional",
"where",
"From",
"is",
"one",
"person",
".",
"Required",
"where",
"From",
"is",
"multiple",
"people",
"."
] | 4278b7bd5b5cf64ceb08005f6bce18be79b76cd3 | https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailSerializable.php#L139-L152 | train |
xcitestudios/php-network | src/Email/EmailSerializable.php | EmailSerializable.setBodyParts | public function setBodyParts(array $bodyParts)
{
$collection = new EmailBodyPartCollection();
foreach ($bodyParts as $k => $v) {
$collection->add($v);
}
$this->bodyParts = $collection;
return $this;
} | php | public function setBodyParts(array $bodyParts)
{
$collection = new EmailBodyPartCollection();
foreach ($bodyParts as $k => $v) {
$collection->add($v);
}
$this->bodyParts = $collection;
return $this;
} | [
"public",
"function",
"setBodyParts",
"(",
"array",
"$",
"bodyParts",
")",
"{",
"$",
"collection",
"=",
"new",
"EmailBodyPartCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"bodyParts",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"collection",
"->",
... | Set the body of the email. For a single content-type email, just put one in this array.
It is presumed if you add multiple items to this array then it must be multipart.
For multipart/alternative (multiple versions of the body such as text / html) add in
one body part of type multipart/alternative which has multiple body parts.
@param EmailBodyPart[] $bodyParts
@throws InvalidArgumentException
@return static | [
"Set",
"the",
"body",
"of",
"the",
"email",
".",
"For",
"a",
"single",
"content",
"-",
"type",
"email",
"just",
"put",
"one",
"in",
"this",
"array",
".",
"It",
"is",
"presumed",
"if",
"you",
"add",
"multiple",
"items",
"to",
"this",
"array",
"then",
... | 4278b7bd5b5cf64ceb08005f6bce18be79b76cd3 | https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailSerializable.php#L347-L358 | train |
nirix/radium | src/Http/Controller.php | Controller.respondTo | public function respondTo($func)
{
$route = Router::currentRoute();
$response = $func($route['extension'], $this);
if ($response === null) {
return $this->show404();
}
return $response;
} | php | public function respondTo($func)
{
$route = Router::currentRoute();
$response = $func($route['extension'], $this);
if ($response === null) {
return $this->show404();
}
return $response;
} | [
"public",
"function",
"respondTo",
"(",
"$",
"func",
")",
"{",
"$",
"route",
"=",
"Router",
"::",
"currentRoute",
"(",
")",
";",
"$",
"response",
"=",
"$",
"func",
"(",
"$",
"route",
"[",
"'extension'",
"]",
",",
"$",
"this",
")",
";",
"if",
"(",
... | Easily respond to different request formats.
@param callable $func
@return object | [
"Easily",
"respond",
"to",
"different",
"request",
"formats",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L160-L170 | train |
nirix/radium | src/Http/Controller.php | Controller.show404 | public function show404()
{
$this->executeAction = false;
return new Response(function($resp){
$resp->status = 404;
$resp->body = $this->renderView($this->notFoundView, [
'_layout' => $this->layout
]);
});
} | php | public function show404()
{
$this->executeAction = false;
return new Response(function($resp){
$resp->status = 404;
$resp->body = $this->renderView($this->notFoundView, [
'_layout' => $this->layout
]);
});
} | [
"public",
"function",
"show404",
"(",
")",
"{",
"$",
"this",
"->",
"executeAction",
"=",
"false",
";",
"return",
"new",
"Response",
"(",
"function",
"(",
"$",
"resp",
")",
"{",
"$",
"resp",
"->",
"status",
"=",
"404",
";",
"$",
"resp",
"->",
"body",
... | Sets the response to a 404 Not Found | [
"Sets",
"the",
"response",
"to",
"a",
"404",
"Not",
"Found"
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L175-L184 | train |
nirix/radium | src/Http/Controller.php | Controller.addFilter | protected function addFilter($when, $action, $callback)
{
if (!is_callable($callback) && !is_array($callback)) {
$callback = [$this, $callback];
}
if (is_array($action)) {
foreach ($action as $method) {
$this->addFilter($when, $method, $callback);
}
} else {
EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback);
}
} | php | protected function addFilter($when, $action, $callback)
{
if (!is_callable($callback) && !is_array($callback)) {
$callback = [$this, $callback];
}
if (is_array($action)) {
foreach ($action as $method) {
$this->addFilter($when, $method, $callback);
}
} else {
EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback);
}
} | [
"protected",
"function",
"addFilter",
"(",
"$",
"when",
",",
"$",
"action",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
"&&",
"!",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"=",
... | Adds the filter to the event dispatcher.
@param string $when Either 'before' or 'after'
@param string $action
@param mixed $callback | [
"Adds",
"the",
"filter",
"to",
"the",
"event",
"dispatcher",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Controller.php#L222-L235 | train |
onesimus-systems/oslogger | src/Logger.php | Logger.addAdaptor | public function addAdaptor(AbstractAdaptor $adaptor)
{
// The key will be the adaptor's name or the next numerical
// count if a name is blank
$adaptorName = $adaptor->getName() ?: $this->adaptorCount;
$this->adaptors[$adaptorName] = $adaptor;
$this->adaptorCount++;
} | php | public function addAdaptor(AbstractAdaptor $adaptor)
{
// The key will be the adaptor's name or the next numerical
// count if a name is blank
$adaptorName = $adaptor->getName() ?: $this->adaptorCount;
$this->adaptors[$adaptorName] = $adaptor;
$this->adaptorCount++;
} | [
"public",
"function",
"addAdaptor",
"(",
"AbstractAdaptor",
"$",
"adaptor",
")",
"{",
"// The key will be the adaptor's name or the next numerical",
"// count if a name is blank",
"$",
"adaptorName",
"=",
"$",
"adaptor",
"->",
"getName",
"(",
")",
"?",
":",
"$",
"this",... | Add an adaptor to write logs
@param AbstractAdaptor $adaptor Adaptor to add to list | [
"Add",
"an",
"adaptor",
"to",
"write",
"logs"
] | 98138d4fbcae83b9cedac13ab173a3f8273de3e0 | https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/Logger.php#L64-L71 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockTransferController.php | StockTransferController.showAction | public function showAction(StockTransfer $stocktransfer)
{
$editForm = $this->createForm(new StockTransferType(), $stocktransfer, array(
'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete');
return array(
'stocktransfer' => $stocktransfer,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction(StockTransfer $stocktransfer)
{
$editForm = $this->createForm(new StockTransferType(), $stocktransfer, array(
'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete');
return array(
'stocktransfer' => $stocktransfer,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"StockTransfer",
"$",
"stocktransfer",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockTransferType",
"(",
")",
",",
"$",
"stocktransfer",
",",
"array",
"(",
"'action'",
"=>",
"$",
... | Finds and displays a StockTransfer entity.
@Route("/{id}/show", name="stock_transfers_show", requirements={"id"="\d+"})
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"StockTransfer",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L49-L64 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockTransferController.php | StockTransferController.newAction | public function newAction()
{
$stocktransfer = new StockTransfer();
$nextCode = $this->get('flower.stock.service.stock_transfer')->getNextCode();
$stocktransfer->setCode($nextCode);
$stocktransfer->setUser($this->getUser());
$form = $this->createForm(new StockTransferType(), $stocktransfer);
return array(
'stocktransfer' => $stocktransfer,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$stocktransfer = new StockTransfer();
$nextCode = $this->get('flower.stock.service.stock_transfer')->getNextCode();
$stocktransfer->setCode($nextCode);
$stocktransfer->setUser($this->getUser());
$form = $this->createForm(new StockTransferType(), $stocktransfer);
return array(
'stocktransfer' => $stocktransfer,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"stocktransfer",
"=",
"new",
"StockTransfer",
"(",
")",
";",
"$",
"nextCode",
"=",
"$",
"this",
"->",
"get",
"(",
"'flower.stock.service.stock_transfer'",
")",
"->",
"getNextCode",
"(",
")",
";",
"$",
... | Displays a form to create a new StockTransfer entity.
@Route("/new", name="stock_transfers_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"StockTransfer",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L73-L87 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockTransferController.php | StockTransferController.createAction | public function createAction(Request $request)
{
$stocktransfer = new StockTransfer();
$stocktransfer->setUser($this->getUser());
$form = $this->createForm(new StockTransferType(), $stocktransfer);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stocktransfer);
$em->flush();
return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId())));
}
return array(
'stocktransfer' => $stocktransfer,
'form' => $form->createView(),
);
} | php | public function createAction(Request $request)
{
$stocktransfer = new StockTransfer();
$stocktransfer->setUser($this->getUser());
$form = $this->createForm(new StockTransferType(), $stocktransfer);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stocktransfer);
$em->flush();
return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId())));
}
return array(
'stocktransfer' => $stocktransfer,
'form' => $form->createView(),
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"stocktransfer",
"=",
"new",
"StockTransfer",
"(",
")",
";",
"$",
"stocktransfer",
"->",
"setUser",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
";",
"$",
"form",
... | Creates a new StockTransfer entity.
@Route("/create", name="stock_transfers_create")
@Method("POST")
@Template("FlowerStockBundle:StockTransfer:new.html.twig") | [
"Creates",
"a",
"new",
"StockTransfer",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L96-L113 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/StockTransferController.php | StockTransferController.updateAction | public function updateAction(StockTransfer $stocktransfer, Request $request)
{
$editForm = $this->createForm(new StockTransferType(), $stocktransfer, array(
'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId())));
}
$deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete');
return array(
'stocktransfer' => $stocktransfer,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function updateAction(StockTransfer $stocktransfer, Request $request)
{
$editForm = $this->createForm(new StockTransferType(), $stocktransfer, array(
'action' => $this->generateUrl('stock_transfers_update', array('id' => $stocktransfer->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('stock_transfers_show', array('id' => $stocktransfer->getId())));
}
$deleteForm = $this->createDeleteForm($stocktransfer->getId(), 'stock_transfers_delete');
return array(
'stocktransfer' => $stocktransfer,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"StockTransfer",
"$",
"stocktransfer",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockTransferType",
"(",
")",
",",
"$",
"stocktransfer",
",",
"arr... | Edits an existing StockTransfer entity.
@Route("/{id}/update", name="stock_transfers_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:StockTransfer:edit.html.twig") | [
"Edits",
"an",
"existing",
"StockTransfer",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferController.php#L144-L162 | train |
asbsoft/yii2module-users_0_170112 | controllers/AdminController.php | AdminController.actionChangeStatus | public function actionChangeStatus($id, $value)
{
$model = $this->findModel($id);
if (empty($model)) {
Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'User {id} not found.', ['id' => $id]));
} else {
$model->status = $value;
$model->pageSize = intval($this->module->params['pageSizeAdmin']);
$result = $model->save(true, ['status']); // update only status field
if ($result) {
Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Status changed.'));
} else {
foreach ($model->errors as $attribute => $errors) {
Yii::$app->session->setFlash('error',
Yii::t($this->tcModule, "Status didn't change.")
. ' '
. Yii::t($this->tcModule, "Error on field: '{field}'.", ['field' => $attribute])
. ' ' . $errors[0]
);
break;
}
}
}
return $this->redirect(['index',
'id' => $id,
'page' => empty($model->page) ? 1 : $model->page,
]);
} | php | public function actionChangeStatus($id, $value)
{
$model = $this->findModel($id);
if (empty($model)) {
Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'User {id} not found.', ['id' => $id]));
} else {
$model->status = $value;
$model->pageSize = intval($this->module->params['pageSizeAdmin']);
$result = $model->save(true, ['status']); // update only status field
if ($result) {
Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Status changed.'));
} else {
foreach ($model->errors as $attribute => $errors) {
Yii::$app->session->setFlash('error',
Yii::t($this->tcModule, "Status didn't change.")
. ' '
. Yii::t($this->tcModule, "Error on field: '{field}'.", ['field' => $attribute])
. ' ' . $errors[0]
);
break;
}
}
}
return $this->redirect(['index',
'id' => $id,
'page' => empty($model->page) ? 1 : $model->page,
]);
} | [
"public",
"function",
"actionChangeStatus",
"(",
"$",
"id",
",",
"$",
"value",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"model",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
... | Change status of user.
@param integer $id
@param integer $value
@return mixed | [
"Change",
"status",
"of",
"user",
"."
] | 3906fdde2d5fdd54637f2b5246d52fe91ec5f648 | https://github.com/asbsoft/yii2module-users_0_170112/blob/3906fdde2d5fdd54637f2b5246d52fe91ec5f648/controllers/AdminController.php#L202-L229 | train |
flowcode/ceibo | src/flowcode/ceibo/domain/Mapper.php | Mapper.getRelation | public function getRelation($relationName) {
$relationInstance = null;
if (isset($this->relations[$relationName])) {
$relationInstance = $this->relations[$relationName];
}
return $relationInstance;
} | php | public function getRelation($relationName) {
$relationInstance = null;
if (isset($this->relations[$relationName])) {
$relationInstance = $this->relations[$relationName];
}
return $relationInstance;
} | [
"public",
"function",
"getRelation",
"(",
"$",
"relationName",
")",
"{",
"$",
"relationInstance",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"relations",
"[",
"$",
"relationName",
"]",
")",
")",
"{",
"$",
"relationInstance",
"=",
"$",
... | Get a relation bby its name.
@param string $relationName
@return Relation | [
"Get",
"a",
"relation",
"bby",
"its",
"name",
"."
] | ba264dc681a9d803885fd35d10b0e37776f66659 | https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Mapper.php#L101-L107 | train |
flowcode/ceibo | src/flowcode/ceibo/domain/Mapper.php | Mapper.getFilter | public function getFilter($filtername) {
$filter = null;
if (!is_null($this->filters) && isset($this->filters[$filtername])) {
$filter = $this->filters[$filtername];
}
return $filter;
} | php | public function getFilter($filtername) {
$filter = null;
if (!is_null($this->filters) && isset($this->filters[$filtername])) {
$filter = $this->filters[$filtername];
}
return $filter;
} | [
"public",
"function",
"getFilter",
"(",
"$",
"filtername",
")",
"{",
"$",
"filter",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"filters",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"filtername",
"]",
... | Return the filter or null.
@param String $filtername
@return Filter $filter. | [
"Return",
"the",
"filter",
"or",
"null",
"."
] | ba264dc681a9d803885fd35d10b0e37776f66659 | https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Mapper.php#L122-L128 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.getEntityNameFromClassName | public static function getEntityNameFromClassName(string $className)
{
$entityName = constant(sprintf(self::ENTITY_NAME_CONST_FORMAT, $className));
if ($entityName === AbstractEntity::ENTITY_NAME or !is_string($entityName)) {
throw new NoEntityNameException($className);
}
return $entityName;
} | php | public static function getEntityNameFromClassName(string $className)
{
$entityName = constant(sprintf(self::ENTITY_NAME_CONST_FORMAT, $className));
if ($entityName === AbstractEntity::ENTITY_NAME or !is_string($entityName)) {
throw new NoEntityNameException($className);
}
return $entityName;
} | [
"public",
"static",
"function",
"getEntityNameFromClassName",
"(",
"string",
"$",
"className",
")",
"{",
"$",
"entityName",
"=",
"constant",
"(",
"sprintf",
"(",
"self",
"::",
"ENTITY_NAME_CONST_FORMAT",
",",
"$",
"className",
")",
")",
";",
"if",
"(",
"$",
... | Gets an entity name from an entity class name if it provides an ENTITY_NAME constant
@param string $className
@return string | [
"Gets",
"an",
"entity",
"name",
"from",
"an",
"entity",
"class",
"name",
"if",
"it",
"provides",
"an",
"ENTITY_NAME",
"constant"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L83-L92 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.loadRegistries | public function loadRegistries()
{
$registries = $this->registryFactory->getDefaultRegistries();
foreach ($registries as $registry) {
$this->addRegistry($registry);
}
} | php | public function loadRegistries()
{
$registries = $this->registryFactory->getDefaultRegistries();
foreach ($registries as $registry) {
$this->addRegistry($registry);
}
} | [
"public",
"function",
"loadRegistries",
"(",
")",
"{",
"$",
"registries",
"=",
"$",
"this",
"->",
"registryFactory",
"->",
"getDefaultRegistries",
"(",
")",
";",
"foreach",
"(",
"$",
"registries",
"as",
"$",
"registry",
")",
"{",
"$",
"this",
"->",
"addReg... | Loads the registries | [
"Loads",
"the",
"registries"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L144-L151 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.getEntityName | public function getEntityName()
{
if (is_null($this->entityName)) {
$this->entityName = self::getEntityNameFromClassName($this->getEntityClass());
}
return $this->entityName;
} | php | public function getEntityName()
{
if (is_null($this->entityName)) {
$this->entityName = self::getEntityNameFromClassName($this->getEntityClass());
}
return $this->entityName;
} | [
"public",
"function",
"getEntityName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"entityName",
")",
")",
"{",
"$",
"this",
"->",
"entityName",
"=",
"self",
"::",
"getEntityNameFromClassName",
"(",
"$",
"this",
"->",
"getEntityClass",
"("... | Gets the entity name
@return string | [
"Gets",
"the",
"entity",
"name"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L158-L165 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.findById | public function findById(int $id)
{
$entity = null;
for ($i = 0; $i < count($this->registries); $i++) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $i ];
$entity = $registry->findByKey($id);
if ($entity instanceof AbstractEntity) {
$this->updateRegistries([$entity], $i - 1);
break;
}
}
return $entity;
} | php | public function findById(int $id)
{
$entity = null;
for ($i = 0; $i < count($this->registries); $i++) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $i ];
$entity = $registry->findByKey($id);
if ($entity instanceof AbstractEntity) {
$this->updateRegistries([$entity], $i - 1);
break;
}
}
return $entity;
} | [
"public",
"function",
"findById",
"(",
"int",
"$",
"id",
")",
"{",
"$",
"entity",
"=",
"null",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"registries",
")",
";",
"$",
"i",
"++",
")",
"{",
"/** @v... | Finds an entity by its id
@param int $id
@return AbstractEntity|null | [
"Finds",
"an",
"entity",
"by",
"its",
"id"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L237-L253 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.findByIds | public function findByIds(array $ids)
{
$entities = [];
for ($i = 0; $i < count($this->registries); $i++) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $i ];
$found = $registry->findByKeys($ids);
$entities = array_merge($entities, $found);
$this->updateRegistries($found, $i - 1);
if (count($entities) === count($ids)) {
break;
}
}
return $entities;
} | php | public function findByIds(array $ids)
{
$entities = [];
for ($i = 0; $i < count($this->registries); $i++) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $i ];
$found = $registry->findByKeys($ids);
$entities = array_merge($entities, $found);
$this->updateRegistries($found, $i - 1);
if (count($entities) === count($ids)) {
break;
}
}
return $entities;
} | [
"public",
"function",
"findByIds",
"(",
"array",
"$",
"ids",
")",
"{",
"$",
"entities",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"registries",
")",
";",
"$",
"i",
"++",
")",
"{",... | Finds a list of entities by their ids
@param array $ids
@return array | [
"Finds",
"a",
"list",
"of",
"entities",
"by",
"their",
"ids"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L262-L280 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.findOneBy | public function findOneBy(array $criteria = [], array $orders = [], $offset = null): ?AbstractEntity
{
$array = $this->findBy($criteria, $orders, 1, $offset);
return array_shift($array);
} | php | public function findOneBy(array $criteria = [], array $orders = [], $offset = null): ?AbstractEntity
{
$array = $this->findBy($criteria, $orders, 1, $offset);
return array_shift($array);
} | [
"public",
"function",
"findOneBy",
"(",
"array",
"$",
"criteria",
"=",
"[",
"]",
",",
"array",
"$",
"orders",
"=",
"[",
"]",
",",
"$",
"offset",
"=",
"null",
")",
":",
"?",
"AbstractEntity",
"{",
"$",
"array",
"=",
"$",
"this",
"->",
"findBy",
"(",... | Finds one entity from criteria
@param array $criteria
@param array $orders
@param null $offset
@return AbstractEntity | [
"Finds",
"one",
"entity",
"from",
"criteria"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L323-L328 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.matching | public function matching(Criteria $criteria): array
{
$queryBuilder = $this->entityManager->createQueryBuilder()
->select('e.id')
->from($this->getEntityName(), 'e');
$queryBuilder->addCriteria($criteria);
$ids = $queryBuilder->getQuery()->getResult(ColumnHydrator::HYDRATOR_MODE);
if (count($ids) === 0) {
return [];
}
return $this->findByIds($ids);
} | php | public function matching(Criteria $criteria): array
{
$queryBuilder = $this->entityManager->createQueryBuilder()
->select('e.id')
->from($this->getEntityName(), 'e');
$queryBuilder->addCriteria($criteria);
$ids = $queryBuilder->getQuery()->getResult(ColumnHydrator::HYDRATOR_MODE);
if (count($ids) === 0) {
return [];
}
return $this->findByIds($ids);
} | [
"public",
"function",
"matching",
"(",
"Criteria",
"$",
"criteria",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'e.id'",
")",
"->",
"from",
"(",
"$",
"t... | Gets all entities matching query criteria
@param Criteria $criteria
@return array | [
"Gets",
"all",
"entities",
"matching",
"query",
"criteria"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L337-L352 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.getEntityRepository | public function getEntityRepository()
{
$repository = $this->entityManager->getRepository($this->getEntityName());
if (!($repository instanceof EntityRepository)) {
throw new InvalidEntityNameException($this->getEntityName(), $this->getEntityClass());
}
return $repository;
} | php | public function getEntityRepository()
{
$repository = $this->entityManager->getRepository($this->getEntityName());
if (!($repository instanceof EntityRepository)) {
throw new InvalidEntityNameException($this->getEntityName(), $this->getEntityClass());
}
return $repository;
} | [
"public",
"function",
"getEntityRepository",
"(",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getEntityName",
"(",
")",
")",
";",
"if",
"(",
"!",
"(",
"$",
"repository",
"instanceof"... | Gets the doctrine's entity repository for the entity
@return \Doctrine\ORM\EntityRepository | [
"Gets",
"the",
"doctrine",
"s",
"entity",
"repository",
"for",
"the",
"entity"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L359-L368 | train |
Thuata/FrameworkBundle | Repository/AbstractRepository.php | AbstractRepository.updateRegistries | private function updateRegistries($entities, $from)
{
if (count($entities) >= 0) {
for ($j = $from; $j >= 0; $j--) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $j ];
/** @var AbstractEntity $entity */
foreach ($entities as $entity) {
$registry->add($entity->getId(), $entity);
}
}
}
} | php | private function updateRegistries($entities, $from)
{
if (count($entities) >= 0) {
for ($j = $from; $j >= 0; $j--) {
/** @var RegistryInterface $registry */
$registry = $this->registries[ $j ];
/** @var AbstractEntity $entity */
foreach ($entities as $entity) {
$registry->add($entity->getId(), $entity);
}
}
}
} | [
"private",
"function",
"updateRegistries",
"(",
"$",
"entities",
",",
"$",
"from",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"entities",
")",
">=",
"0",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"$",
"from",
";",
"$",
"j",
">=",
"0",
";",
"$",
"j",
... | Updates the registries
@param array $entities
@param int $from | [
"Updates",
"the",
"registries"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/AbstractRepository.php#L376-L388 | train |
arnold-almeida/UIKit | src/Almeida/UIKit/Lib/Base.php | Base.render | public function render()
{
$args = func_get_args();
foreach ($args as $arg) {
if(isset($this->output[$arg])) {
return $this->output[$arg];
}
throw new Exception("{$arg} is not set!", 1);
}
} | php | public function render()
{
$args = func_get_args();
foreach ($args as $arg) {
if(isset($this->output[$arg])) {
return $this->output[$arg];
}
throw new Exception("{$arg} is not set!", 1);
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"output",
"[",
"$",
"arg",
"]",
")",
")",
"{",... | Render compiled HTML | [
"Render",
"compiled",
"HTML"
] | cc52f46df011ec2f3676245c90c376da20c40e41 | https://github.com/arnold-almeida/UIKit/blob/cc52f46df011ec2f3676245c90c376da20c40e41/src/Almeida/UIKit/Lib/Base.php#L65-L76 | train |
popy-dev/popy-calendar | src/Parser/ResultMapper/Chain.php | Chain.addMapper | public function addMapper(ResultMapperInterface $mapper)
{
if ($mapper instanceof self) {
return $this->addMappers($mapper->mappers);
}
$this->mappers[] = $mapper;
return $this;
} | php | public function addMapper(ResultMapperInterface $mapper)
{
if ($mapper instanceof self) {
return $this->addMappers($mapper->mappers);
}
$this->mappers[] = $mapper;
return $this;
} | [
"public",
"function",
"addMapper",
"(",
"ResultMapperInterface",
"$",
"mapper",
")",
"{",
"if",
"(",
"$",
"mapper",
"instanceof",
"self",
")",
"{",
"return",
"$",
"this",
"->",
"addMappers",
"(",
"$",
"mapper",
"->",
"mappers",
")",
";",
"}",
"$",
"this"... | Adds a Mapper to the chain.
@param ResultMapperInterface $mapper | [
"Adds",
"a",
"Mapper",
"to",
"the",
"chain",
"."
] | 989048be18451c813cfce926229c6aaddd1b0639 | https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/ResultMapper/Chain.php#L36-L45 | train |
zerospam/sdk-framework | src/Request/Api/HasNullableFields.php | HasNullableFields.isValueChanged | public function isValueChanged($field)
{
if (!$this->IsNullable($field)) {
return false;
}
return isset($this->nullableChanged[$field]);
} | php | public function isValueChanged($field)
{
if (!$this->IsNullable($field)) {
return false;
}
return isset($this->nullableChanged[$field]);
} | [
"public",
"function",
"isValueChanged",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"IsNullable",
"(",
"$",
"field",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"nullableChanged",
"[",
"$... | Check if the given field is nullable and if it should be included in the request
@param $field
@return bool
@internal param $value | [
"Check",
"if",
"the",
"given",
"field",
"is",
"nullable",
"and",
"if",
"it",
"should",
"be",
"included",
"in",
"the",
"request"
] | 6780b81584619cb177d5d5e14fd7e87a9d8e48fd | https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/HasNullableFields.php#L40-L47 | train |
zerospam/sdk-framework | src/Request/Api/HasNullableFields.php | HasNullableFields.nullableChanged | protected function nullableChanged($field = null)
{
if (!$field) {
$function = debug_backtrace()[1]['function'];
$field = lcfirst(substr($function, 3));
}
$this->nullableChanged[$field] = true;
} | php | protected function nullableChanged($field = null)
{
if (!$field) {
$function = debug_backtrace()[1]['function'];
$field = lcfirst(substr($function, 3));
}
$this->nullableChanged[$field] = true;
} | [
"protected",
"function",
"nullableChanged",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"field",
")",
"{",
"$",
"function",
"=",
"debug_backtrace",
"(",
")",
"[",
"1",
"]",
"[",
"'function'",
"]",
";",
"$",
"field",
"=",
"lcfirst",... | Trigger the fact the nullable changed
@param null $field | [
"Trigger",
"the",
"fact",
"the",
"nullable",
"changed"
] | 6780b81584619cb177d5d5e14fd7e87a9d8e48fd | https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/HasNullableFields.php#L54-L62 | train |
vinala/kernel | src/Database/Database.php | Database.newConnection | public function newConnection($host, $database, $user, $password)
{
return self::$driver->connect($host, $database, $user, $password);
} | php | public function newConnection($host, $database, $user, $password)
{
return self::$driver->connect($host, $database, $user, $password);
} | [
"public",
"function",
"newConnection",
"(",
"$",
"host",
",",
"$",
"database",
",",
"$",
"user",
",",
"$",
"password",
")",
"{",
"return",
"self",
"::",
"$",
"driver",
"->",
"connect",
"(",
"$",
"host",
",",
"$",
"database",
",",
"$",
"user",
",",
... | Connect to another driver database server.
@param string, string, string, string
@return PDO | [
"Connect",
"to",
"another",
"driver",
"database",
"server",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Database.php#L109-L112 | train |
gibboncms/gibbon | src/Filesystems/FileCache.php | FileCache.persist | public function persist()
{
$parts = explode('/', $this->file);
array_pop($parts);
$dir = implode('/', $parts);
if (!is_dir($dir)) {
mkdir($dir, 493, true);
}
return file_put_contents($this->file, serialize($this->data));
} | php | public function persist()
{
$parts = explode('/', $this->file);
array_pop($parts);
$dir = implode('/', $parts);
if (!is_dir($dir)) {
mkdir($dir, 493, true);
}
return file_put_contents($this->file, serialize($this->data));
} | [
"public",
"function",
"persist",
"(",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"file",
")",
";",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"dir",
"=",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
";",
"... | Persist the cache data
@return bool | [
"Persist",
"the",
"cache",
"data"
] | 2905e90b2902149b3358b385264e98b97cf4fc00 | https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Filesystems/FileCache.php#L92-L104 | train |
gibboncms/gibbon | src/Filesystems/FileCache.php | FileCache.rebuild | public function rebuild()
{
if (file_exists($this->file)) {
try {
$this->data = unserialize(file_get_contents($this->file));
return true;
} catch (\Exception $e) {
// Try just used to suppress the exception. If the cache is corrupted we just start from scratch.
}
}
$this->data = [];
$this->persist();
return false;
} | php | public function rebuild()
{
if (file_exists($this->file)) {
try {
$this->data = unserialize(file_get_contents($this->file));
return true;
} catch (\Exception $e) {
// Try just used to suppress the exception. If the cache is corrupted we just start from scratch.
}
}
$this->data = [];
$this->persist();
return false;
} | [
"public",
"function",
"rebuild",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"data",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"file",
")",
")",
... | Try to unserialize the existing cache, if it's corrupted, it's lost, let it go.
@return bool | [
"Try",
"to",
"unserialize",
"the",
"existing",
"cache",
"if",
"it",
"s",
"corrupted",
"it",
"s",
"lost",
"let",
"it",
"go",
"."
] | 2905e90b2902149b3358b385264e98b97cf4fc00 | https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Filesystems/FileCache.php#L111-L125 | train |
phlexible/phlexible | src/Phlexible/Bundle/GuiBundle/Asset/IconsBuilder.php | IconsBuilder.build | public function build($basePath)
{
$cache = new PuliResourceCollectionCache($this->cacheDir.'gui-icons.css', $this->debug);
$resources = $this->resourceFinder->findByType('phlexible/icons');
if (!$cache->isFresh($resources)) {
$content = $this->buildIcons($resources, $basePath);
$cache->write($content);
if (!$this->debug) {
$this->compressor->compressFile((string) $cache);
}
}
return new Asset((string) $cache);
} | php | public function build($basePath)
{
$cache = new PuliResourceCollectionCache($this->cacheDir.'gui-icons.css', $this->debug);
$resources = $this->resourceFinder->findByType('phlexible/icons');
if (!$cache->isFresh($resources)) {
$content = $this->buildIcons($resources, $basePath);
$cache->write($content);
if (!$this->debug) {
$this->compressor->compressFile((string) $cache);
}
}
return new Asset((string) $cache);
} | [
"public",
"function",
"build",
"(",
"$",
"basePath",
")",
"{",
"$",
"cache",
"=",
"new",
"PuliResourceCollectionCache",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"'gui-icons.css'",
",",
"$",
"this",
"->",
"debug",
")",
";",
"$",
"resources",
"=",
"$",
"th... | Get all Stylesheets for the given section.
@param string $basePath
@return Asset | [
"Get",
"all",
"Stylesheets",
"for",
"the",
"given",
"section",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Asset/IconsBuilder.php#L72-L89 | train |
budkit/budkit-framework | src/Budkit/Parameter/Factory.php | Factory.getParameterListAsObject | public function getParameterListAsObject($name, $delimiter = ";")
{
$parameter = $this->getValidParameterOfType($name, "string");
$list = preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $parameter, null,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
//if emptyparameter return throw an exception because they'd be expecting an object;
$parameters = [];
$values = [];
foreach ($list as $itemValue) {
//if items have qualities associated with them we shall sort the parameter array by qualities;
$bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$value = array_shift($bits);
$attributes = [];
$lastNullAttribute = null;
foreach ($bits as $bit) {
if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1))
&& ($start === '"'
|| $start === '\'')
) {
$attributes[$lastNullAttribute] = substr($bit, 1, -1);
} elseif ('=' === $end) {
$lastNullAttribute = $bit = substr($bit, 0, -1);
$attributes[$bit] = null;
} else {
$parts = explode('=', $bit);
$attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : '';
}
}
$parameters[($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'')
? substr($value, 1, -1) : $value] = $attributes;
}
return new Factory($name, $parameters, static::$sanitizer, static::$validator, false);
} | php | public function getParameterListAsObject($name, $delimiter = ";")
{
$parameter = $this->getValidParameterOfType($name, "string");
$list = preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $parameter, null,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
//if emptyparameter return throw an exception because they'd be expecting an object;
$parameters = [];
$values = [];
foreach ($list as $itemValue) {
//if items have qualities associated with them we shall sort the parameter array by qualities;
$bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$value = array_shift($bits);
$attributes = [];
$lastNullAttribute = null;
foreach ($bits as $bit) {
if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1))
&& ($start === '"'
|| $start === '\'')
) {
$attributes[$lastNullAttribute] = substr($bit, 1, -1);
} elseif ('=' === $end) {
$lastNullAttribute = $bit = substr($bit, 0, -1);
$attributes[$bit] = null;
} else {
$parts = explode('=', $bit);
$attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : '';
}
}
$parameters[($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'')
? substr($value, 1, -1) : $value] = $attributes;
}
return new Factory($name, $parameters, static::$sanitizer, static::$validator, false);
} | [
"public",
"function",
"getParameterListAsObject",
"(",
"$",
"name",
",",
"$",
"delimiter",
"=",
"\";\"",
")",
"{",
"$",
"parameter",
"=",
"$",
"this",
"->",
"getValidParameterOfType",
"(",
"$",
"name",
",",
"\"string\"",
")",
";",
"$",
"list",
"=",
"preg_s... | Get a comma seperated list of params as a Parameter object;
e.g key1=value1;q=0.31,key2=value2....
@param $name | [
"Get",
"a",
"comma",
"seperated",
"list",
"of",
"params",
"as",
"a",
"Parameter",
"object",
";"
] | 0635061815fe07a8c63f9514b845d199b3c0d485 | https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Factory.php#L56-L97 | train |
strident/Trident | src/Trident/Component/Debug/Toolbar/Toolbar.php | Toolbar.removeExtension | public function removeExtension($name)
{
if (isset($this->extensions[$name])) {
unset($this->extensions[$name]);
}
return $this;
} | php | public function removeExtension($name)
{
if (isset($this->extensions[$name])) {
unset($this->extensions[$name]);
}
return $this;
} | [
"public",
"function",
"removeExtension",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"extensions",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"extensions",
"[",
"$",
"name",
"]",
")",
";",
"... | Remove an extension.
@param string $name
@return Toolbar | [
"Remove",
"an",
"extension",
"."
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Debug/Toolbar/Toolbar.php#L82-L89 | train |
iRAP-software/package-core-libs | src/Core.php | Core.javascriptRedirectUser | public static function javascriptRedirectUser($url, $numSeconds = 0)
{
$htmlString = '';
$htmlString .=
"<script type='text/javascript'>" .
"var redirectTime=" . $numSeconds * 1000 . ";" . PHP_EOL .
"var redirectURL='" . $url . "';" . PHP_EOL .
'setTimeout("location.href = redirectURL;", redirectTime);' . PHP_EOL .
"</script>";
return $htmlString;
} | php | public static function javascriptRedirectUser($url, $numSeconds = 0)
{
$htmlString = '';
$htmlString .=
"<script type='text/javascript'>" .
"var redirectTime=" . $numSeconds * 1000 . ";" . PHP_EOL .
"var redirectURL='" . $url . "';" . PHP_EOL .
'setTimeout("location.href = redirectURL;", redirectTime);' . PHP_EOL .
"</script>";
return $htmlString;
} | [
"public",
"static",
"function",
"javascriptRedirectUser",
"(",
"$",
"url",
",",
"$",
"numSeconds",
"=",
"0",
")",
"{",
"$",
"htmlString",
"=",
"''",
";",
"$",
"htmlString",
".=",
"\"<script type='text/javascript'>\"",
".",
"\"var redirectTime=\"",
".",
"$",
"num... | Allows us to re-direct the user using javascript when headers have
already been submitted.
@param string url that we want to re-direct the user to.
@param int numSeconds - optional integer specifying the number of
seconds to delay.
@return htmlString - the html to print out in order to redirect the user. | [
"Allows",
"us",
"to",
"re",
"-",
"direct",
"the",
"user",
"using",
"javascript",
"when",
"headers",
"have",
"already",
"been",
"submitted",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L116-L128 | train |
iRAP-software/package-core-libs | src/Core.php | Core.setCliTitle | public static function setCliTitle($nameingPrefix)
{
$succeeded = false;
$num_running = self::getNumProcRunning($nameingPrefix);
if (function_exists('cli_set_process_title'))
{
cli_set_process_title($nameingPrefix . $num_running);
$succeeded = true;
}
return $succeeded;
} | php | public static function setCliTitle($nameingPrefix)
{
$succeeded = false;
$num_running = self::getNumProcRunning($nameingPrefix);
if (function_exists('cli_set_process_title'))
{
cli_set_process_title($nameingPrefix . $num_running);
$succeeded = true;
}
return $succeeded;
} | [
"public",
"static",
"function",
"setCliTitle",
"(",
"$",
"nameingPrefix",
")",
"{",
"$",
"succeeded",
"=",
"false",
";",
"$",
"num_running",
"=",
"self",
"::",
"getNumProcRunning",
"(",
"$",
"nameingPrefix",
")",
";",
"if",
"(",
"function_exists",
"(",
"'cli... | Sets the title of the process and will append the appropriate number of
already existing processes with the same title.
WARNING - this will fail and return FALSE if you are on Windows
@param string $nameingPrefix - the name to give the process.
@return boolean - true if successfully set the title, false if not. | [
"Sets",
"the",
"title",
"of",
"the",
"process",
"and",
"will",
"append",
"the",
"appropriate",
"number",
"of",
"already",
"existing",
"processes",
"with",
"the",
"same",
"title",
".",
"WARNING",
"-",
"this",
"will",
"fail",
"and",
"return",
"FALSE",
"if",
... | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L138-L150 | train |
iRAP-software/package-core-libs | src/Core.php | Core.sendApiRequest | public static function sendApiRequest($url, array $parameters, $requestType="POST", $headers=array())
{
$allowedRequestTypes = array("GET", "POST", "PUT", "PATCH", "DELETE");
$requestTypeUpper = strtoupper($requestType);
if (!in_array($requestTypeUpper, $allowedRequestTypes))
{
throw new \Exception("API request needs to be one of GET, POST, PUT, PATCH, or DELETE.");
}
if ($requestType === "GET")
{
$ret = self::sendGetRequest($url, $parameters);
}
else
{
$query_string = http_build_query($parameters, '', '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
switch ($requestTypeUpper)
{
case "POST":
{
curl_setopt($ch, CURLOPT_POST, 1);
}
break;
case "PUT":
case "PATCH":
case "DELETE":
{
curl_setopt($this->m_ch, CURLOPT_CUSTOMREQUEST, $requestTypeUpper);
}
break;
default:
{
throw new \Exception("Unrecognized request type.");
}
}
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
// @TODO - S.P. to review...
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// Manage if user provided headers.
if (count($headers) > 0)
{
$headersStrings = array();
foreach ($headers as $key=>$value)
{
$headersStrings[] = "{$key}: {$value}";
}
curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $this->m_headers);
}
$jsondata = curl_exec($ch);
if (curl_error($ch))
{
$errMsg = "Connection Error: " . curl_errno($ch) .
' - ' . curl_error($ch);
throw new \Exception($errMsg);
}
curl_close($ch);
$ret = json_decode($jsondata); # Decode JSON String
if ($ret == null)
{
$errMsg = 'Recieved a non json response from API: ' . $jsondata;
throw new \Exception($errMsg);
}
}
return $ret;
} | php | public static function sendApiRequest($url, array $parameters, $requestType="POST", $headers=array())
{
$allowedRequestTypes = array("GET", "POST", "PUT", "PATCH", "DELETE");
$requestTypeUpper = strtoupper($requestType);
if (!in_array($requestTypeUpper, $allowedRequestTypes))
{
throw new \Exception("API request needs to be one of GET, POST, PUT, PATCH, or DELETE.");
}
if ($requestType === "GET")
{
$ret = self::sendGetRequest($url, $parameters);
}
else
{
$query_string = http_build_query($parameters, '', '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
switch ($requestTypeUpper)
{
case "POST":
{
curl_setopt($ch, CURLOPT_POST, 1);
}
break;
case "PUT":
case "PATCH":
case "DELETE":
{
curl_setopt($this->m_ch, CURLOPT_CUSTOMREQUEST, $requestTypeUpper);
}
break;
default:
{
throw new \Exception("Unrecognized request type.");
}
}
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
// @TODO - S.P. to review...
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// Manage if user provided headers.
if (count($headers) > 0)
{
$headersStrings = array();
foreach ($headers as $key=>$value)
{
$headersStrings[] = "{$key}: {$value}";
}
curl_setopt($this->m_ch, CURLOPT_HTTPHEADER, $this->m_headers);
}
$jsondata = curl_exec($ch);
if (curl_error($ch))
{
$errMsg = "Connection Error: " . curl_errno($ch) .
' - ' . curl_error($ch);
throw new \Exception($errMsg);
}
curl_close($ch);
$ret = json_decode($jsondata); # Decode JSON String
if ($ret == null)
{
$errMsg = 'Recieved a non json response from API: ' . $jsondata;
throw new \Exception($errMsg);
}
}
return $ret;
} | [
"public",
"static",
"function",
"sendApiRequest",
"(",
"$",
"url",
",",
"array",
"$",
"parameters",
",",
"$",
"requestType",
"=",
"\"POST\"",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"allowedRequestTypes",
"=",
"array",
"(",
"\"GET\"",
... | Sends an api request through the use of CURL
@param string url - the url where the api is located.
@param array parameters - name value pairs for sending to the api server
@param string $requestType - the request type. One of GET, POST, PUT, PATCH or DELETE
@param array $headers - name/value pairs for headers. Useful for authentication etc.
@return stdObject - json response object from the api server
@throws \Exception | [
"Sends",
"an",
"api",
"request",
"through",
"the",
"use",
"of",
"CURL"
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L190-L275 | train |
iRAP-software/package-core-libs | src/Core.php | Core.sendGetRequest | public static function sendGetRequest($url, array $parameters=array(), $arrayForm=false)
{
if (count($parameters) > 0)
{
$query_string = http_build_query($parameters, '', '&');
$url .= $query_string;
}
# Get cURL resource
$curl = curl_init();
# Set some options - we are passing in a useragent too here
$curlOptions = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
);
curl_setopt_array($curl, $curlOptions);
# Send the request
$rawResponse = curl_exec($curl);
# Close request to clear up some resources
curl_close($curl);
# Convert to json object.
$responseObj = json_decode($rawResponse, $arrayForm); # Decode JSON String
if ($responseObj == null)
{
$errMsg = 'Recieved a non json response from API: ' . $rawResponse;
throw new \Exception($errMsg);
}
return $responseObj;
} | php | public static function sendGetRequest($url, array $parameters=array(), $arrayForm=false)
{
if (count($parameters) > 0)
{
$query_string = http_build_query($parameters, '', '&');
$url .= $query_string;
}
# Get cURL resource
$curl = curl_init();
# Set some options - we are passing in a useragent too here
$curlOptions = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
);
curl_setopt_array($curl, $curlOptions);
# Send the request
$rawResponse = curl_exec($curl);
# Close request to clear up some resources
curl_close($curl);
# Convert to json object.
$responseObj = json_decode($rawResponse, $arrayForm); # Decode JSON String
if ($responseObj == null)
{
$errMsg = 'Recieved a non json response from API: ' . $rawResponse;
throw new \Exception($errMsg);
}
return $responseObj;
} | [
"public",
"static",
"function",
"sendGetRequest",
"(",
"$",
"url",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"arrayForm",
"=",
"false",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
">",
"0",
")",
"{",
"$",
"qu... | Sends a GET request to a RESTful API through cURL.
@param string url - the url where the api is located.
@param array parameters - optional array of name value pairs for sending to
the RESTful API.
@param bool arrayForm - optional - set to true to return an array instead of
a stdClass object.
@return stdObject - json response object from the api server | [
"Sends",
"a",
"GET",
"request",
"to",
"a",
"RESTful",
"API",
"through",
"cURL",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L289-L324 | train |
iRAP-software/package-core-libs | src/Core.php | Core.fetchArgs | public static function fetchArgs(array $reqArgs, array $optionalArgs)
{
$values = self::fetchReqArgs($reqArgs);
$values = array_merge($values, self::fetchOptionalArgs($optionalArgs));
return $values;
} | php | public static function fetchArgs(array $reqArgs, array $optionalArgs)
{
$values = self::fetchReqArgs($reqArgs);
$values = array_merge($values, self::fetchOptionalArgs($optionalArgs));
return $values;
} | [
"public",
"static",
"function",
"fetchArgs",
"(",
"array",
"$",
"reqArgs",
",",
"array",
"$",
"optionalArgs",
")",
"{",
"$",
"values",
"=",
"self",
"::",
"fetchReqArgs",
"(",
"$",
"reqArgs",
")",
";",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"values"... | Retrieves the specified arguments from REQUEST. This will throw an
exception if a required argument is not present, but not if an optional
argument is not.
@param array reqArgs - required arguments that must exist
@param array optionalArgs - arguments that should be retrieved if exist
@return values - map of argument name/value pairs retrieved. | [
"Retrieves",
"the",
"specified",
"arguments",
"from",
"REQUEST",
".",
"This",
"will",
"throw",
"an",
"exception",
"if",
"a",
"required",
"argument",
"is",
"not",
"present",
"but",
"not",
"if",
"an",
"optional",
"argument",
"is",
"not",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L525-L530 | train |
iRAP-software/package-core-libs | src/Core.php | Core.getCurrentUrl | public static function getCurrentUrl()
{
$pageURL = 'http';
if (isset($_SERVER["HTTPS"]))
{
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
{
$pageURL .= $_SERVER["SERVER_NAME"] . ":" .
$_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
}
else
{
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
} | php | public static function getCurrentUrl()
{
$pageURL = 'http';
if (isset($_SERVER["HTTPS"]))
{
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
{
$pageURL .= $_SERVER["SERVER_NAME"] . ":" .
$_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
}
else
{
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
} | [
"public",
"static",
"function",
"getCurrentUrl",
"(",
")",
"{",
"$",
"pageURL",
"=",
"'http'",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"HTTPS\"",
"]",
")",
")",
"{",
"$",
"pageURL",
".=",
"\"s\"",
";",
"}",
"$",
"pageURL",
".=",
"\"://\"... | Builds url of the current page, excluding any ?=&stuff,
@param void
@return pageURL - full page url of the current page
e.g. https://www.google.com/some-page | [
"Builds",
"url",
"of",
"the",
"current",
"page",
"excluding",
"any",
"?",
"=",
"&stuff"
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L539-L561 | train |
iRAP-software/package-core-libs | src/Core.php | Core.versionGuard | public static function versionGuard($reqVersion, $errMsg='')
{
if (version_compare(PHP_VERSION, $reqVersion) == -1)
{
if ($errMsg == '')
{
$errMsg = 'Required PHP version: ' . $reqVersion .
', current Version: ' . PHP_VERSION;
}
die($errMsg);
}
} | php | public static function versionGuard($reqVersion, $errMsg='')
{
if (version_compare(PHP_VERSION, $reqVersion) == -1)
{
if ($errMsg == '')
{
$errMsg = 'Required PHP version: ' . $reqVersion .
', current Version: ' . PHP_VERSION;
}
die($errMsg);
}
} | [
"public",
"static",
"function",
"versionGuard",
"(",
"$",
"reqVersion",
",",
"$",
"errMsg",
"=",
"''",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"$",
"reqVersion",
")",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"errMsg",
"==",
... | Implement a version guard. This will throw an exception if we do not
have the required version of PHP that is specified.
@param String $reqVersion - required version of php, e.g '5.4.0'
@throws an exception if we do not meet the required php
version. | [
"Implement",
"a",
"version",
"guard",
".",
"This",
"will",
"throw",
"an",
"exception",
"if",
"we",
"do",
"not",
"have",
"the",
"required",
"version",
"of",
"PHP",
"that",
"is",
"specified",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L744-L756 | train |
iRAP-software/package-core-libs | src/Core.php | Core.isPortOpen | public static function isPortOpen($host, $port, $protocol)
{
$protocol = strtolower($protocol);
if ($protocol != 'tcp' && $protocol != 'udp')
{
$errMsg = 'Unrecognized protocol [' . $protocol . '] ' .
'please specify [tcp] or [udp]';
throw new \Exception($errMsg);
}
if (empty($host))
{
$host = self::getPublicIp();
}
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port);
if (is_resource($connection))
{
$isOpen = true;
fclose($connection);
}
else
{
$isOpen = false;
}
}
return $isOpen;
} | php | public static function isPortOpen($host, $port, $protocol)
{
$protocol = strtolower($protocol);
if ($protocol != 'tcp' && $protocol != 'udp')
{
$errMsg = 'Unrecognized protocol [' . $protocol . '] ' .
'please specify [tcp] or [udp]';
throw new \Exception($errMsg);
}
if (empty($host))
{
$host = self::getPublicIp();
}
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port);
if (is_resource($connection))
{
$isOpen = true;
fclose($connection);
}
else
{
$isOpen = false;
}
}
return $isOpen;
} | [
"public",
"static",
"function",
"isPortOpen",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"protocol",
")",
"{",
"$",
"protocol",
"=",
"strtolower",
"(",
"$",
"protocol",
")",
";",
"if",
"(",
"$",
"protocol",
"!=",
"'tcp'",
"&&",
"$",
"protocol",
"!... | Checks to see if the specified port is open.
@param string $host - the host to check against.
@param int $port - the port to check
@return $isOpen - true if port is open, false if not. | [
"Checks",
"to",
"see",
"if",
"the",
"specified",
"port",
"is",
"open",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L804-L837 | train |
iRAP-software/package-core-libs | src/Core.php | Core.generateConfig | public static function generateConfig($settings, $variableName, $filePath)
{
$varStr = var_export($settings, true);
$output =
'<?php' . PHP_EOL .
'$' . $variableName . ' = ' . $varStr . ';';
# file_put_contents returns num bytes written or boolean false if fail
$wroteFile = file_put_contents($filePath, $output);
if ($wroteFile === FALSE)
{
$msg = "Failed to generate config file. Check permissions!";
throw new \Exception($msg);
}
} | php | public static function generateConfig($settings, $variableName, $filePath)
{
$varStr = var_export($settings, true);
$output =
'<?php' . PHP_EOL .
'$' . $variableName . ' = ' . $varStr . ';';
# file_put_contents returns num bytes written or boolean false if fail
$wroteFile = file_put_contents($filePath, $output);
if ($wroteFile === FALSE)
{
$msg = "Failed to generate config file. Check permissions!";
throw new \Exception($msg);
}
} | [
"public",
"static",
"function",
"generateConfig",
"(",
"$",
"settings",
",",
"$",
"variableName",
",",
"$",
"filePath",
")",
"{",
"$",
"varStr",
"=",
"var_export",
"(",
"$",
"settings",
",",
"true",
")",
";",
"$",
"output",
"=",
"'<?php'",
".",
"PHP_EOL"... | Generate a php config file to have the setting provided. This is useful
if we want to be able to update our config file through code, such as a
web ui to upadate settings. Platforms like wordpress allow updating the
settings, but do this through a database.
@param mixed $settings - array or variable that we want to save to
the file
@param string $variableName - name of the settings variable so that it
is reloaded correctly
@param string $filePath - path to the file where we want to save the
settings. (overwritten)
@return void - creates a config file, or throws an exception if failed.
@throws Exception if failed to write to the specified filePath, e.g dont
have permissions. | [
"Generate",
"a",
"php",
"config",
"file",
"to",
"have",
"the",
"setting",
"provided",
".",
"This",
"is",
"useful",
"if",
"we",
"want",
"to",
"be",
"able",
"to",
"update",
"our",
"config",
"file",
"through",
"code",
"such",
"as",
"a",
"web",
"ui",
"to",... | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L910-L926 | train |
iRAP-software/package-core-libs | src/Core.php | Core.generatePasswordHash | public static function generatePasswordHash($rawPassword, $cost=11)
{
$cost = intval($cost);
$cost = self::clampValue($cost, $max=31, $min=4);
# has to be 2 digits, eg. 04
if ($cost < 10)
{
$cost = "0" . $cost;
}
$options = array('cost' => $cost);
$hash = password_hash($rawPassword, PASSWORD_BCRYPT, $options);
return $hash;
} | php | public static function generatePasswordHash($rawPassword, $cost=11)
{
$cost = intval($cost);
$cost = self::clampValue($cost, $max=31, $min=4);
# has to be 2 digits, eg. 04
if ($cost < 10)
{
$cost = "0" . $cost;
}
$options = array('cost' => $cost);
$hash = password_hash($rawPassword, PASSWORD_BCRYPT, $options);
return $hash;
} | [
"public",
"static",
"function",
"generatePasswordHash",
"(",
"$",
"rawPassword",
",",
"$",
"cost",
"=",
"11",
")",
"{",
"$",
"cost",
"=",
"intval",
"(",
"$",
"cost",
")",
";",
"$",
"cost",
"=",
"self",
"::",
"clampValue",
"(",
"$",
"cost",
",",
"$",
... | Converts a raw password into a hash using PHP 5.5's new hashing method
@param String $rawPassword - the password we wish to hash
@param int $cost - The two digit cost parameter is the base-2 logarithm
of the iteration count for the underlying
Blowfish-based hashing algorithmeter and must be in
range 04-31
@return string - the generated hash | [
"Converts",
"a",
"raw",
"password",
"into",
"a",
"hash",
"using",
"PHP",
"5",
".",
"5",
"s",
"new",
"hashing",
"method"
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L938-L953 | train |
iRAP-software/package-core-libs | src/Core.php | Core.isValidSignedRequest | public static function isValidSignedRequest(array $data, string $signature)
{
$generated_signature = SiteSpecific::generateSignature($data);
return ($generated_signature == $signature);
} | php | public static function isValidSignedRequest(array $data, string $signature)
{
$generated_signature = SiteSpecific::generateSignature($data);
return ($generated_signature == $signature);
} | [
"public",
"static",
"function",
"isValidSignedRequest",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"signature",
")",
"{",
"$",
"generated_signature",
"=",
"SiteSpecific",
"::",
"generateSignature",
"(",
"$",
"data",
")",
";",
"return",
"(",
"$",
"generated... | Check if the provided data has the correct signature.
@param array $data - the data we recieved that was signed. The signature MUST NOT be in this
array.
@param string $signature - the signature that came with the data. This is what we will check
if is valid for the data recieved.
@return bool - true if the signature is correct for the data, or false if not (in which case
a user probably tried to manipulate the data). | [
"Check",
"if",
"the",
"provided",
"data",
"has",
"the",
"correct",
"signature",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/Core.php#L1003-L1007 | train |
osflab/view | Helper/Bootstrap/ButtonGroup.php | ButtonGroup.button | public function button(
$label = null,
$url = null,
$status = null,
$icon = null,
$block = false,
$disabled = false,
$flat = false,
$size = Button::SIZE_NORMAL)
{
$button = new Button($label, $url, $status, $icon, $block, $disabled, $flat, $size);
return $this->addButton($button);
} | php | public function button(
$label = null,
$url = null,
$status = null,
$icon = null,
$block = false,
$disabled = false,
$flat = false,
$size = Button::SIZE_NORMAL)
{
$button = new Button($label, $url, $status, $icon, $block, $disabled, $flat, $size);
return $this->addButton($button);
} | [
"public",
"function",
"button",
"(",
"$",
"label",
"=",
"null",
",",
"$",
"url",
"=",
"null",
",",
"$",
"status",
"=",
"null",
",",
"$",
"icon",
"=",
"null",
",",
"$",
"block",
"=",
"false",
",",
"$",
"disabled",
"=",
"false",
",",
"$",
"flat",
... | Create a new button
@param string $label
@param string $url
@param string $status
@param string $icon
@param bool $block
@param bool $disabled
@param bool $flat
@param string $size
@return $this | [
"Create",
"a",
"new",
"button"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/ButtonGroup.php#L66-L78 | train |
bfansports/CloudProcessingEngine-SDK | src/SA/CpeSdk/CpeLogger.php | CpeLogger.logOut | public function logOut(
$type,
$source,
$message,
$logKey = null,
$printOut = true)
{
$log = [
"time" => date("Y-m-d H:i:s", time()),
"source" => $source,
"type" => $type,
"message" => $message
];
if ($printOut)
$this->printOut = $printOut;
if ($logKey)
$log["logKey"] = $logKey;
// Set the log filaname based on the logkey If provided.
// If not then it will log in a file that has the name of the PHP activity file
$file = $this->activityName;
// Append progname to the path
$this->filePath = $this->logPath . "/" . $file.".log";
// Open Syslog. Use programe name as key
if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1))
throw new CpeException("Unable to connect to Syslog!",
OPENLOG_ERROR);
// Change Syslog priority level
switch ($type)
{
case "INFO":
$priority = LOG_INFO;
break;
case "ERROR":
$priority = LOG_ERR;
break;
case "FATAL":
$priority = LOG_ALERT;
break;
case "WARNING":
$priority = LOG_WARNING;
break;
case "DEBUG":
$priority = LOG_DEBUG;
break;
default:
throw new CpeException("Unknown log Type!",
LOG_TYPE_ERROR);
}
// Print log in file
$this->printToFile($log);
// Encode log message in JSON for better parsing
$out = json_encode($log);
// Send to syslog
syslog($priority, $out);
} | php | public function logOut(
$type,
$source,
$message,
$logKey = null,
$printOut = true)
{
$log = [
"time" => date("Y-m-d H:i:s", time()),
"source" => $source,
"type" => $type,
"message" => $message
];
if ($printOut)
$this->printOut = $printOut;
if ($logKey)
$log["logKey"] = $logKey;
// Set the log filaname based on the logkey If provided.
// If not then it will log in a file that has the name of the PHP activity file
$file = $this->activityName;
// Append progname to the path
$this->filePath = $this->logPath . "/" . $file.".log";
// Open Syslog. Use programe name as key
if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1))
throw new CpeException("Unable to connect to Syslog!",
OPENLOG_ERROR);
// Change Syslog priority level
switch ($type)
{
case "INFO":
$priority = LOG_INFO;
break;
case "ERROR":
$priority = LOG_ERR;
break;
case "FATAL":
$priority = LOG_ALERT;
break;
case "WARNING":
$priority = LOG_WARNING;
break;
case "DEBUG":
$priority = LOG_DEBUG;
break;
default:
throw new CpeException("Unknown log Type!",
LOG_TYPE_ERROR);
}
// Print log in file
$this->printToFile($log);
// Encode log message in JSON for better parsing
$out = json_encode($log);
// Send to syslog
syslog($priority, $out);
} | [
"public",
"function",
"logOut",
"(",
"$",
"type",
",",
"$",
"source",
",",
"$",
"message",
",",
"$",
"logKey",
"=",
"null",
",",
"$",
"printOut",
"=",
"true",
")",
"{",
"$",
"log",
"=",
"[",
"\"time\"",
"=>",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"t... | Log message to syslog and log file. Will print | [
"Log",
"message",
"to",
"syslog",
"and",
"log",
"file",
".",
"Will",
"print"
] | 8714d088a16c6dd4735df68e17256cc41bba2cfb | https://github.com/bfansports/CloudProcessingEngine-SDK/blob/8714d088a16c6dd4735df68e17256cc41bba2cfb/src/SA/CpeSdk/CpeLogger.php#L44-L105 | train |
bfansports/CloudProcessingEngine-SDK | src/SA/CpeSdk/CpeLogger.php | CpeLogger.printToFile | private function printToFile($log)
{
if (!is_string($log['message']))
$log['message'] = json_encode($log['message']);
$toPrint = $log['time'] . " [" . $log['type'] . "] [" . $log['source'] . "] ";
// If there is a workflow ID. We append it.
if (isset($log['logKey']) && $log['logKey'])
$toPrint .= "[".$log['logKey']."] ";
$toPrint .= $log['message'] . "\n";
if ($this->printout)
print $toPrint;
if (file_put_contents(
$this->filePath,
$toPrint,
FILE_APPEND) === false) {
throw new CpeException("Can't write into log file: $this->logPath",
LOGFILE_ERROR);
}
} | php | private function printToFile($log)
{
if (!is_string($log['message']))
$log['message'] = json_encode($log['message']);
$toPrint = $log['time'] . " [" . $log['type'] . "] [" . $log['source'] . "] ";
// If there is a workflow ID. We append it.
if (isset($log['logKey']) && $log['logKey'])
$toPrint .= "[".$log['logKey']."] ";
$toPrint .= $log['message'] . "\n";
if ($this->printout)
print $toPrint;
if (file_put_contents(
$this->filePath,
$toPrint,
FILE_APPEND) === false) {
throw new CpeException("Can't write into log file: $this->logPath",
LOGFILE_ERROR);
}
} | [
"private",
"function",
"printToFile",
"(",
"$",
"log",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"log",
"[",
"'message'",
"]",
")",
")",
"$",
"log",
"[",
"'message'",
"]",
"=",
"json_encode",
"(",
"$",
"log",
"[",
"'message'",
"]",
")",
";",... | Write log in file | [
"Write",
"log",
"in",
"file"
] | 8714d088a16c6dd4735df68e17256cc41bba2cfb | https://github.com/bfansports/CloudProcessingEngine-SDK/blob/8714d088a16c6dd4735df68e17256cc41bba2cfb/src/SA/CpeSdk/CpeLogger.php#L108-L129 | train |
novuso/system | src/Type/Enum.php | Enum.fromString | final public static function fromString(string $string): Enum
{
$parts = explode('::', $string);
return self::fromName(end($parts));
} | php | final public static function fromString(string $string): Enum
{
$parts = explode('::', $string);
return self::fromName(end($parts));
} | [
"final",
"public",
"static",
"function",
"fromString",
"(",
"string",
"$",
"string",
")",
":",
"Enum",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'::'",
",",
"$",
"string",
")",
";",
"return",
"self",
"::",
"fromName",
"(",
"end",
"(",
"$",
"parts",
")... | Creates instance from a string representation
@param string $string The string representation
@return Enum
@throws DomainException When the string is invalid | [
"Creates",
"instance",
"from",
"a",
"string",
"representation"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L113-L118 | train |
novuso/system | src/Type/Enum.php | Enum.fromName | final public static function fromName(string $name): Enum
{
$constName = sprintf('%s::%s', static::class, $name);
if (!defined($constName)) {
$message = sprintf('%s is not a member constant of enum %s', $name, static::class);
throw new DomainException($message);
}
return new static(constant($constName));
} | php | final public static function fromName(string $name): Enum
{
$constName = sprintf('%s::%s', static::class, $name);
if (!defined($constName)) {
$message = sprintf('%s is not a member constant of enum %s', $name, static::class);
throw new DomainException($message);
}
return new static(constant($constName));
} | [
"final",
"public",
"static",
"function",
"fromName",
"(",
"string",
"$",
"name",
")",
":",
"Enum",
"{",
"$",
"constName",
"=",
"sprintf",
"(",
"'%s::%s'",
",",
"static",
"::",
"class",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"defined",
"(",
"$",
... | Creates instance from an enum constant name
@param string $name The enum constant name
@return Enum
@throws DomainException When the name is invalid | [
"Creates",
"instance",
"from",
"an",
"enum",
"constant",
"name"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L129-L139 | train |
novuso/system | src/Type/Enum.php | Enum.fromOrdinal | final public static function fromOrdinal(int $ordinal): Enum
{
$constants = self::getMembers();
$item = array_slice($constants, $ordinal, 1, true);
if (!$item) {
$end = count($constants) - 1;
$message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end);
throw new DomainException($message);
}
return new static(current($item));
} | php | final public static function fromOrdinal(int $ordinal): Enum
{
$constants = self::getMembers();
$item = array_slice($constants, $ordinal, 1, true);
if (!$item) {
$end = count($constants) - 1;
$message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end);
throw new DomainException($message);
}
return new static(current($item));
} | [
"final",
"public",
"static",
"function",
"fromOrdinal",
"(",
"int",
"$",
"ordinal",
")",
":",
"Enum",
"{",
"$",
"constants",
"=",
"self",
"::",
"getMembers",
"(",
")",
";",
"$",
"item",
"=",
"array_slice",
"(",
"$",
"constants",
",",
"$",
"ordinal",
",... | Creates instance from an enum ordinal position
@param int $ordinal The enum ordinal position
@return Enum
@throws DomainException When the ordinal is invalid | [
"Creates",
"instance",
"from",
"an",
"enum",
"ordinal",
"position"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L150-L162 | train |
novuso/system | src/Type/Enum.php | Enum.getMembers | final public static function getMembers(): array
{
if (!isset(self::$constants[static::class])) {
$reflection = new ReflectionClass(static::class);
$constants = self::sortConstants($reflection);
self::guardConstants($constants);
self::$constants[static::class] = $constants;
}
return self::$constants[static::class];
} | php | final public static function getMembers(): array
{
if (!isset(self::$constants[static::class])) {
$reflection = new ReflectionClass(static::class);
$constants = self::sortConstants($reflection);
self::guardConstants($constants);
self::$constants[static::class] = $constants;
}
return self::$constants[static::class];
} | [
"final",
"public",
"static",
"function",
"getMembers",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"constants",
"[",
"static",
"::",
"class",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
... | Retrieves enum member names and values
@return array
@throws DomainException When more than one constant has the same value | [
"Retrieves",
"enum",
"member",
"names",
"and",
"values"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L171-L181 | train |
novuso/system | src/Type/Enum.php | Enum.name | final public function name(): string
{
if ($this->name === null) {
$constants = self::getMembers();
$this->name = array_search($this->value, $constants, true);
}
return $this->name;
} | php | final public function name(): string
{
if ($this->name === null) {
$constants = self::getMembers();
$this->name = array_search($this->value, $constants, true);
}
return $this->name;
} | [
"final",
"public",
"function",
"name",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"===",
"null",
")",
"{",
"$",
"constants",
"=",
"self",
"::",
"getMembers",
"(",
")",
";",
"$",
"this",
"->",
"name",
"=",
"array_search",
"(... | Retrieves the enum constant name
@return string | [
"Retrieves",
"the",
"enum",
"constant",
"name"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L198-L206 | train |
novuso/system | src/Type/Enum.php | Enum.ordinal | final public function ordinal(): int
{
if ($this->ordinal === null) {
$ordinal = 0;
foreach (self::getMembers() as $constValue) {
if ($this->value === $constValue) {
break;
}
$ordinal++;
}
$this->ordinal = $ordinal;
}
return $this->ordinal;
} | php | final public function ordinal(): int
{
if ($this->ordinal === null) {
$ordinal = 0;
foreach (self::getMembers() as $constValue) {
if ($this->value === $constValue) {
break;
}
$ordinal++;
}
$this->ordinal = $ordinal;
}
return $this->ordinal;
} | [
"final",
"public",
"function",
"ordinal",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"ordinal",
"===",
"null",
")",
"{",
"$",
"ordinal",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"getMembers",
"(",
")",
"as",
"$",
"constValue",
")"... | Retrieves the enum ordinal position
@return int | [
"Retrieves",
"the",
"enum",
"ordinal",
"position"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L213-L227 | train |
novuso/system | src/Type/Enum.php | Enum.guardConstants | final private static function guardConstants(array $constants): void
{
$duplicates = [];
foreach ($constants as $value) {
$names = array_keys($constants, $value, $strict = true);
if (count($names) > 1) {
$duplicates[VarPrinter::toString($value)] = $names;
}
}
if (!empty($duplicates)) {
$list = array_map(function ($names) use ($constants) {
return sprintf('(%s)=%s', implode('|', $names), VarPrinter::toString($constants[$names[0]]));
}, $duplicates);
$message = sprintf('Duplicate enum values: %s', implode(', ', $list));
throw new DomainException($message);
}
} | php | final private static function guardConstants(array $constants): void
{
$duplicates = [];
foreach ($constants as $value) {
$names = array_keys($constants, $value, $strict = true);
if (count($names) > 1) {
$duplicates[VarPrinter::toString($value)] = $names;
}
}
if (!empty($duplicates)) {
$list = array_map(function ($names) use ($constants) {
return sprintf('(%s)=%s', implode('|', $names), VarPrinter::toString($constants[$names[0]]));
}, $duplicates);
$message = sprintf('Duplicate enum values: %s', implode(', ', $list));
throw new DomainException($message);
}
} | [
"final",
"private",
"static",
"function",
"guardConstants",
"(",
"array",
"$",
"constants",
")",
":",
"void",
"{",
"$",
"duplicates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"constants",
"as",
"$",
"value",
")",
"{",
"$",
"names",
"=",
"array_keys",
"... | Validates enum constants
@param array $constants The enum constants
@return void
@throws DomainException When more than one constant has the same value | [
"Validates",
"enum",
"constants"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L332-L348 | train |
novuso/system | src/Type/Enum.php | Enum.sortConstants | final private static function sortConstants(ReflectionClass $reflection): array
{
$constants = [];
while ($reflection && __CLASS__ !== $reflection->getName()) {
$scope = [];
foreach ($reflection->getReflectionConstants() as $const) {
if ($const->isPublic()) {
$scope[$const->getName()] = $const->getValue();
}
}
$constants = $scope + $constants;
$reflection = $reflection->getParentClass();
}
return $constants;
} | php | final private static function sortConstants(ReflectionClass $reflection): array
{
$constants = [];
while ($reflection && __CLASS__ !== $reflection->getName()) {
$scope = [];
foreach ($reflection->getReflectionConstants() as $const) {
if ($const->isPublic()) {
$scope[$const->getName()] = $const->getValue();
}
}
$constants = $scope + $constants;
$reflection = $reflection->getParentClass();
}
return $constants;
} | [
"final",
"private",
"static",
"function",
"sortConstants",
"(",
"ReflectionClass",
"$",
"reflection",
")",
":",
"array",
"{",
"$",
"constants",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"reflection",
"&&",
"__CLASS__",
"!==",
"$",
"reflection",
"->",
"getName",... | Sorts member constants
@param ReflectionClass $reflection The reflection instance
@return array | [
"Sorts",
"member",
"constants"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Type/Enum.php#L357-L373 | train |
ntentan/utils | src/Validator.php | Validator.getValidation | private function getValidation(string $name): validator\Validation
{
if (!isset($this->validations[$name])) {
if (isset($this->validationRegister[$name])) {
$class = $this->validationRegister[$name];
} else {
throw new exceptions\ValidatorException("Validator [$name] not found");
}
$params = isset($this->validationData[$name]) ? $this->validationData[$name] : null;
$this->validations[$name] = new $class($params);
}
return $this->validations[$name];
} | php | private function getValidation(string $name): validator\Validation
{
if (!isset($this->validations[$name])) {
if (isset($this->validationRegister[$name])) {
$class = $this->validationRegister[$name];
} else {
throw new exceptions\ValidatorException("Validator [$name] not found");
}
$params = isset($this->validationData[$name]) ? $this->validationData[$name] : null;
$this->validations[$name] = new $class($params);
}
return $this->validations[$name];
} | [
"private",
"function",
"getValidation",
"(",
"string",
"$",
"name",
")",
":",
"validator",
"\\",
"Validation",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"validations",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
... | Get an instance of a validation class.
@param string $name
@return validator\Validation
@throws exceptions\ValidatorException | [
"Get",
"an",
"instance",
"of",
"a",
"validation",
"class",
"."
] | 151f3582ee6007ea77a38d2b6c590289331e19a1 | https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L87-L100 | train |
ntentan/utils | src/Validator.php | Validator.registerValidation | protected function registerValidation(string $name, string $class, $data = null)
{
$this->validationRegister[$name] = $class;
$this->validationData[$name] = $data;
} | php | protected function registerValidation(string $name, string $class, $data = null)
{
$this->validationRegister[$name] = $class;
$this->validationData[$name] = $data;
} | [
"protected",
"function",
"registerValidation",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"validationRegister",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"$",
"this",
"->",
... | Register a validation type.
@param string $name The name of the validation to be used in validation descriptions.
@param string $class The name of the validation class to load.
@param mixed $data Any extra validation data that would be necessary for the validation. | [
"Register",
"a",
"validation",
"type",
"."
] | 151f3582ee6007ea77a38d2b6c590289331e19a1 | https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L109-L113 | train |
ntentan/utils | src/Validator.php | Validator.getFieldInfo | private function getFieldInfo($key, $value): array
{
$name = null;
$options = [];
if (is_numeric($key) && is_string($value)) {
$name = $value;
} else if (is_numeric($key) && is_array($value)) {
$name = array_shift($value);
$options = $value;
} else if (is_string($key)) {
$name = $key;
$options = $value;
}
return ['name' => $name, 'options' => $options];
} | php | private function getFieldInfo($key, $value): array
{
$name = null;
$options = [];
if (is_numeric($key) && is_string($value)) {
$name = $value;
} else if (is_numeric($key) && is_array($value)) {
$name = array_shift($value);
$options = $value;
} else if (is_string($key)) {
$name = $key;
$options = $value;
}
return ['name' => $name, 'options' => $options];
} | [
"private",
"function",
"getFieldInfo",
"(",
"$",
"key",
",",
"$",
"value",
")",
":",
"array",
"{",
"$",
"name",
"=",
"null",
";",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
"&&",
"is_string",
"(",
"$",
"val... | Build a uniform field info array for various types of validations.
@param mixed $key
@param mixed $value
@return array | [
"Build",
"a",
"uniform",
"field",
"info",
"array",
"for",
"various",
"types",
"of",
"validations",
"."
] | 151f3582ee6007ea77a38d2b6c590289331e19a1 | https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L142-L156 | train |
ntentan/utils | src/Validator.php | Validator.validate | public function validate(array $data) : bool
{
$passed = true;
$this->invalidFields = [];
$rules = $this->getRules();
foreach ($rules as $validation => $fields) {
foreach ($fields as $key => $value) {
$field = $this->getFieldInfo($key, $value);
$validationInstance = $this->getValidation($validation);
$validationStatus = $validationInstance->run($field, $data);
$passed = $passed && $validationStatus;
$this->invalidFields = array_merge_recursive(
$this->invalidFields, $validationInstance->getMessages()
);
}
}
return $passed;
} | php | public function validate(array $data) : bool
{
$passed = true;
$this->invalidFields = [];
$rules = $this->getRules();
foreach ($rules as $validation => $fields) {
foreach ($fields as $key => $value) {
$field = $this->getFieldInfo($key, $value);
$validationInstance = $this->getValidation($validation);
$validationStatus = $validationInstance->run($field, $data);
$passed = $passed && $validationStatus;
$this->invalidFields = array_merge_recursive(
$this->invalidFields, $validationInstance->getMessages()
);
}
}
return $passed;
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"data",
")",
":",
"bool",
"{",
"$",
"passed",
"=",
"true",
";",
"$",
"this",
"->",
"invalidFields",
"=",
"[",
"]",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"getRules",
"(",
")",
";",
"foreach",... | Validate data according to validation rules that have been set into
this validator.
@param array $data The data to be validated
@return bool
@throws exceptions\ValidatorException | [
"Validate",
"data",
"according",
"to",
"validation",
"rules",
"that",
"have",
"been",
"set",
"into",
"this",
"validator",
"."
] | 151f3582ee6007ea77a38d2b6c590289331e19a1 | https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/Validator.php#L176-L193 | train |
lutsen/lagan-core | src/Lagan.php | Lagan.universalCreate | protected function universalCreate() {
$bean = \R::dispense($this->type);
$bean->created = \R::isoDateTime();
return $bean;
} | php | protected function universalCreate() {
$bean = \R::dispense($this->type);
$bean->created = \R::isoDateTime();
return $bean;
} | [
"protected",
"function",
"universalCreate",
"(",
")",
"{",
"$",
"bean",
"=",
"\\",
"R",
"::",
"dispense",
"(",
"$",
"this",
"->",
"type",
")",
";",
"$",
"bean",
"->",
"created",
"=",
"\\",
"R",
"::",
"isoDateTime",
"(",
")",
";",
"return",
"$",
"be... | Dispenses a Redbean bean ans sets it's creation date.
@return bean | [
"Dispenses",
"a",
"Redbean",
"bean",
"ans",
"sets",
"it",
"s",
"creation",
"date",
"."
] | 257244219a046293f506de68e54f0c16c35d8217 | https://github.com/lutsen/lagan-core/blob/257244219a046293f506de68e54f0c16c35d8217/src/Lagan.php#L30-L37 | train |
lutsen/lagan-core | src/Lagan.php | Lagan.set | public function set($data, $bean) {
// Add all properties to bean
foreach ( $this->properties as $property ) {
$value = false; // We need to clear possible previous $value
// Define property controller
$c = new $property['type'];
// New input for the property
if (
isset( $data[ $property['name'] ] )
||
( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 )
||
$property['autovalue'] == true
) {
// Check if specific set property type method exists
if ( method_exists( $c, 'set' ) ) {
$value = $c->set( $bean, $property, $data[ $property['name'] ] );
} else {
$value = $data[ $property['name'] ];
}
if ($value) {
$hasvalue = true;
} else {
$hasvalue = false;
}
// No new input for the property
} else {
// Check if property already has value for required validation
if ( isset( $property['required'] ) ) {
if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) {
$hasvalue = true;
} else if ( $bean->{ $property['name'] } ) {
$hasvalue = true;
} else {
$hasvalue = false;
}
}
}
// Check if property is required
if ( isset( $property['required'] ) ) {
if ( $property['required'] && !$hasvalue ) {
throw new \Exception('Validation error. '.$property['description'].' is required.');
}
}
// Results from methods that return boolean values are not stored.
// Many-to-many relations for example are stored in a seperate table.
if ( !is_bool($value) ) {
// Check if property value is unique
if ( isset( $property['unique'] ) ) {
$duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] );
if ( $duplicate && $duplicate->id != $bean->id ) {
throw new \Exception('Validation error. '.$property['description'].' should be unique.');
}
}
$bean->{ $property['name'] } = $value;
}
}
$bean->modified = \R::isoDateTime();
\R::store($bean);
return $bean;
} | php | public function set($data, $bean) {
// Add all properties to bean
foreach ( $this->properties as $property ) {
$value = false; // We need to clear possible previous $value
// Define property controller
$c = new $property['type'];
// New input for the property
if (
isset( $data[ $property['name'] ] )
||
( isset( $_FILES[ $property['name'] ] ) && $_FILES[ $property['name'] ]['size'] > 0 )
||
$property['autovalue'] == true
) {
// Check if specific set property type method exists
if ( method_exists( $c, 'set' ) ) {
$value = $c->set( $bean, $property, $data[ $property['name'] ] );
} else {
$value = $data[ $property['name'] ];
}
if ($value) {
$hasvalue = true;
} else {
$hasvalue = false;
}
// No new input for the property
} else {
// Check if property already has value for required validation
if ( isset( $property['required'] ) ) {
if ( method_exists( $c, 'read' ) && $c->read( $bean, $property ) ) {
$hasvalue = true;
} else if ( $bean->{ $property['name'] } ) {
$hasvalue = true;
} else {
$hasvalue = false;
}
}
}
// Check if property is required
if ( isset( $property['required'] ) ) {
if ( $property['required'] && !$hasvalue ) {
throw new \Exception('Validation error. '.$property['description'].' is required.');
}
}
// Results from methods that return boolean values are not stored.
// Many-to-many relations for example are stored in a seperate table.
if ( !is_bool($value) ) {
// Check if property value is unique
if ( isset( $property['unique'] ) ) {
$duplicate = \R::findOne( $this->type, $property['name'].' = :val ', [ ':val' => $value ] );
if ( $duplicate && $duplicate->id != $bean->id ) {
throw new \Exception('Validation error. '.$property['description'].' should be unique.');
}
}
$bean->{ $property['name'] } = $value;
}
}
$bean->modified = \R::isoDateTime();
\R::store($bean);
return $bean;
} | [
"public",
"function",
"set",
"(",
"$",
"data",
",",
"$",
"bean",
")",
"{",
"// Add all properties to bean",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"value",
"=",
"false",
";",
"// We need to clear possible previou... | Set values for a bean. Used by Create and Update.
Checks for each property if a "set" method exists for it's type.
If so, it executes it.
@param array $data The raw data, usually from the Slim $request->getParsedBody()
@param bean $bean
@return bean Bean with values based on $data. | [
"Set",
"values",
"for",
"a",
"bean",
".",
"Used",
"by",
"Create",
"and",
"Update",
".",
"Checks",
"for",
"each",
"property",
"if",
"a",
"set",
"method",
"exists",
"for",
"it",
"s",
"type",
".",
"If",
"so",
"it",
"executes",
"it",
"."
] | 257244219a046293f506de68e54f0c16c35d8217 | https://github.com/lutsen/lagan-core/blob/257244219a046293f506de68e54f0c16c35d8217/src/Lagan.php#L50-L133 | train |
MacFJA/value-provider | src/ChainProvider.php | ChainProvider.tryGetValue | protected static function tryGetValue($provider, $object, $propertyName, &$error)
{
try {
return call_user_func(array($provider, 'getValue'), $object, $propertyName);
} catch (\InvalidArgumentException $e) {
$error = $e;
return null;
}
} | php | protected static function tryGetValue($provider, $object, $propertyName, &$error)
{
try {
return call_user_func(array($provider, 'getValue'), $object, $propertyName);
} catch (\InvalidArgumentException $e) {
$error = $e;
return null;
}
} | [
"protected",
"static",
"function",
"tryGetValue",
"(",
"$",
"provider",
",",
"$",
"object",
",",
"$",
"propertyName",
",",
"&",
"$",
"error",
")",
"{",
"try",
"{",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"provider",
",",
"'getValue'",
")",
",... | Try to get the value of an object property with a specific provider
@param string|object $provider The provider class(name) to use
@param object $object The object to read
@param string $propertyName The name of the property to read
@param \InvalidArgumentException|mixed $error <p>
If an error occurs, this variable will be set to the error triggered
</p>
@return mixed|null <p>
The value of the object property, or <tt>null</tt> and an error in <tt>$error</tt> if an error occur.
</p> | [
"Try",
"to",
"get",
"the",
"value",
"of",
"an",
"object",
"property",
"with",
"a",
"specific",
"provider"
] | eab0d8a52062e21fa91041f9fb6df38fd9c0dd28 | https://github.com/MacFJA/value-provider/blob/eab0d8a52062e21fa91041f9fb6df38fd9c0dd28/src/ChainProvider.php#L119-L127 | train |
MacFJA/value-provider | src/ChainProvider.php | ChainProvider.trySetValue | protected static function trySetValue($provider, &$object, $propertyName, $value, &$error)
{
try {
return call_user_func(array($provider, 'setValue'), $object, $propertyName, $value);
} catch (\InvalidArgumentException $e) {
$error = $e;
return null;
}
} | php | protected static function trySetValue($provider, &$object, $propertyName, $value, &$error)
{
try {
return call_user_func(array($provider, 'setValue'), $object, $propertyName, $value);
} catch (\InvalidArgumentException $e) {
$error = $e;
return null;
}
} | [
"protected",
"static",
"function",
"trySetValue",
"(",
"$",
"provider",
",",
"&",
"$",
"object",
",",
"$",
"propertyName",
",",
"$",
"value",
",",
"&",
"$",
"error",
")",
"{",
"try",
"{",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"provider",
... | Try to set the value of an object property with a specific provider
@param string|object $provider The provider class(name) to use
@param object $object The object to write
@param string $propertyName The name of the property to write
@param mixed $value The value to set
@param \InvalidArgumentException|mixed $error <p>
If an error occurs, this variable will be set to the error triggered
</p>
@return mixed|null The object, or <tt>null</tt> and an error in <tt>$error</tt> if an error occur. | [
"Try",
"to",
"set",
"the",
"value",
"of",
"an",
"object",
"property",
"with",
"a",
"specific",
"provider"
] | eab0d8a52062e21fa91041f9fb6df38fd9c0dd28 | https://github.com/MacFJA/value-provider/blob/eab0d8a52062e21fa91041f9fb6df38fd9c0dd28/src/ChainProvider.php#L142-L150 | train |
dlds/yii2-rels | components/Behavior.php | Behavior.canGetProperty | public function canGetProperty($name, $checkVars = true)
{
if (!in_array($name, $this->attrs)) {
return parent::canGetProperty($name, $checkVars);
}
return true;
} | php | public function canGetProperty($name, $checkVars = true)
{
if (!in_array($name, $this->attrs)) {
return parent::canGetProperty($name, $checkVars);
}
return true;
} | [
"public",
"function",
"canGetProperty",
"(",
"$",
"name",
",",
"$",
"checkVars",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"attrs",
")",
")",
"{",
"return",
"parent",
"::",
"canGetProperty",
"(",
"$"... | Indicates whether a property can be read.
@param string $name the property name
@param boolean $checkVars whether to treat member variables as properties | [
"Indicates",
"whether",
"a",
"property",
"can",
"be",
"read",
"."
] | fb73064f2db98a751f9a93ab1146c0a133eba8f2 | https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L71-L78 | train |
dlds/yii2-rels | components/Behavior.php | Behavior.events | public function events()
{
return [
\yii\db\ActiveRecord::EVENT_BEFORE_VALIDATE => 'handleValidate',
\yii\db\ActiveRecord::EVENT_AFTER_INSERT => 'handleAfterSave',
\yii\db\ActiveRecord::EVENT_AFTER_UPDATE => 'handleAfterSave',
];
} | php | public function events()
{
return [
\yii\db\ActiveRecord::EVENT_BEFORE_VALIDATE => 'handleValidate',
\yii\db\ActiveRecord::EVENT_AFTER_INSERT => 'handleAfterSave',
\yii\db\ActiveRecord::EVENT_AFTER_UPDATE => 'handleAfterSave',
];
} | [
"public",
"function",
"events",
"(",
")",
"{",
"return",
"[",
"\\",
"yii",
"\\",
"db",
"\\",
"ActiveRecord",
"::",
"EVENT_BEFORE_VALIDATE",
"=>",
"'handleValidate'",
",",
"\\",
"yii",
"\\",
"db",
"\\",
"ActiveRecord",
"::",
"EVENT_AFTER_INSERT",
"=>",
"'handle... | Validates interpreter together with owner | [
"Validates",
"interpreter",
"together",
"with",
"owner"
] | fb73064f2db98a751f9a93ab1146c0a133eba8f2 | https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L83-L90 | train |
dlds/yii2-rels | components/Behavior.php | Behavior.interpreter | public function interpreter(array $restriction = [])
{
if (null === $this->_interpreter) {
$this->_interpreter = new Interpreter($this->owner, $this->config, $this->allowCache, $this->attrActive);
}
$this->_interpreter->setRestriction($restriction);
return $this->_interpreter;
} | php | public function interpreter(array $restriction = [])
{
if (null === $this->_interpreter) {
$this->_interpreter = new Interpreter($this->owner, $this->config, $this->allowCache, $this->attrActive);
}
$this->_interpreter->setRestriction($restriction);
return $this->_interpreter;
} | [
"public",
"function",
"interpreter",
"(",
"array",
"$",
"restriction",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_interpreter",
")",
"{",
"$",
"this",
"->",
"_interpreter",
"=",
"new",
"Interpreter",
"(",
"$",
"this",
"->",... | Retrieves instance to multilang interperter | [
"Retrieves",
"instance",
"to",
"multilang",
"interperter"
] | fb73064f2db98a751f9a93ab1146c0a133eba8f2 | https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Behavior.php#L188-L197 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.getUserFeed | public function getUserFeed($userName = null, $location = null)
{
if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
if ($userName !== null) {
$location->setUser($userName);
}
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
if ($userName !== null) {
$location->setUser($userName);
}
$uri = $location->getQueryUrl();
} else if ($location !== null) {
$uri = $location;
} else if ($userName !== null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
$userName;
} else {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
self::DEFAULT_USER;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed');
} | php | public function getUserFeed($userName = null, $location = null)
{
if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
if ($userName !== null) {
$location->setUser($userName);
}
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
if ($userName !== null) {
$location->setUser($userName);
}
$uri = $location->getQueryUrl();
} else if ($location !== null) {
$uri = $location;
} else if ($userName !== null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
$userName;
} else {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
self::DEFAULT_USER;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed');
} | [
"public",
"function",
"getUserFeed",
"(",
"$",
"userName",
"=",
"null",
",",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"instanceof",
"Zend_Gdata_Photos_UserQuery",
")",
"{",
"$",
"location",
"->",
"setType",
"(",
"'feed'",
")",
";... | Retrieve a UserFeed containing AlbumEntries, PhotoEntries and
TagEntries associated with a given user.
@param string $userName The userName of interest
@param mixed $location (optional) The location for the feed, as a URL
or Query. If not provided, a default URL will be used instead.
@return Zend_Gdata_Photos_UserFeed
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Retrieve",
"a",
"UserFeed",
"containing",
"AlbumEntries",
"PhotoEntries",
"and",
"TagEntries",
"associated",
"with",
"a",
"given",
"user",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L150-L176 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.getAlbumFeed | public function getAlbumFeed($location = null)
{
if ($location === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Location must not be null');
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed');
} | php | public function getAlbumFeed($location = null)
{
if ($location === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Location must not be null');
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed');
} | [
"public",
"function",
"getAlbumFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"===",
"null",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"("... | Retreive AlbumFeed object containing multiple PhotoEntry or TagEntry
objects.
@param mixed $location (optional) The location for the feed, as a URL or Query.
@return Zend_Gdata_Photos_AlbumFeed
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Retreive",
"AlbumFeed",
"object",
"containing",
"multiple",
"PhotoEntry",
"or",
"TagEntry",
"objects",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L187-L202 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.getPhotoFeed | public function getPhotoFeed($location = null)
{
if ($location === null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' .
self::COMMUNITY_SEARCH_PATH;
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed');
} | php | public function getPhotoFeed($location = null)
{
if ($location === null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' .
self::COMMUNITY_SEARCH_PATH;
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('feed');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed');
} | [
"public",
"function",
"getPhotoFeed",
"(",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"location",
"===",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"PICASA_BASE_FEED_URI",
".",
"'/'",
".",
"self",
"::",
"DEFAULT_PROJECTION",
".",
"'/'"... | Retreive PhotoFeed object containing comments and tags associated
with a given photo.
@param mixed $location (optional) The location for the feed, as a URL
or Query. If not specified, the community search feed will
be returned instead.
@return Zend_Gdata_Photos_PhotoFeed
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Retreive",
"PhotoFeed",
"object",
"containing",
"comments",
"and",
"tags",
"associated",
"with",
"a",
"given",
"photo",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L215-L230 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.getUserEntry | public function getUserEntry($location)
{
if ($location === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Location must not be null');
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('entry');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry');
} | php | public function getUserEntry($location)
{
if ($location === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Location must not be null');
} else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
$location->setType('entry');
$uri = $location->getQueryUrl();
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry');
} | [
"public",
"function",
"getUserEntry",
"(",
"$",
"location",
")",
"{",
"if",
"(",
"$",
"location",
"===",
"null",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Location mu... | Retreive a single UserEntry object.
@param mixed $location The location for the feed, as a URL or Query.
@return Zend_Gdata_Photos_UserEntry
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Retreive",
"a",
"single",
"UserEntry",
"object",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L240-L255 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.insertAlbumEntry | public function insertAlbumEntry($album, $uri = null)
{
if ($uri === null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
self::DEFAULT_USER;
}
$newEntry = $this->insertEntry($album, $uri, 'Zend_Gdata_Photos_AlbumEntry');
return $newEntry;
} | php | public function insertAlbumEntry($album, $uri = null)
{
if ($uri === null) {
$uri = self::PICASA_BASE_FEED_URI . '/' .
self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
self::DEFAULT_USER;
}
$newEntry = $this->insertEntry($album, $uri, 'Zend_Gdata_Photos_AlbumEntry');
return $newEntry;
} | [
"public",
"function",
"insertAlbumEntry",
"(",
"$",
"album",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"uri",
"===",
"null",
")",
"{",
"$",
"uri",
"=",
"self",
"::",
"PICASA_BASE_FEED_URI",
".",
"'/'",
".",
"self",
"::",
"DEFAULT_PROJECTI... | Create a new album from a AlbumEntry.
@param Zend_Gdata_Photos_AlbumEntry $album The album entry to
insert.
@param string $url (optional) The URI that the album should be
uploaded to. If null, the default album creation URI for
this domain will be used.
@return Zend_Gdata_Photos_AlbumEntry The inserted album entry as
returned by the server.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Create",
"a",
"new",
"album",
"from",
"a",
"AlbumEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L370-L379 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.insertPhotoEntry | public function insertPhotoEntry($photo, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_AlbumEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($photo, $uri, 'Zend_Gdata_Photos_PhotoEntry');
return $newEntry;
} | php | public function insertPhotoEntry($photo, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_AlbumEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($photo, $uri, 'Zend_Gdata_Photos_PhotoEntry');
return $newEntry;
} | [
"public",
"function",
"insertPhotoEntry",
"(",
"$",
"photo",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"uri",
"instanceof",
"Zend_Gdata_Photos_AlbumEntry",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"getLink",
"(",
"self",
"::",
"FEED_LIN... | Create a new photo from a PhotoEntry.
@param Zend_Gdata_Photos_PhotoEntry $photo The photo to insert.
@param string $url The URI that the photo should be uploaded
to. Alternatively, an AlbumEntry can be provided and the
photo will be added to that album.
@return Zend_Gdata_Photos_PhotoEntry The inserted photo entry
as returned by the server.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Create",
"a",
"new",
"photo",
"from",
"a",
"PhotoEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L393-L405 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.insertTagEntry | public function insertTagEntry($tag, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($tag, $uri, 'Zend_Gdata_Photos_TagEntry');
return $newEntry;
} | php | public function insertTagEntry($tag, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($tag, $uri, 'Zend_Gdata_Photos_TagEntry');
return $newEntry;
} | [
"public",
"function",
"insertTagEntry",
"(",
"$",
"tag",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"uri",
"instanceof",
"Zend_Gdata_Photos_PhotoEntry",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"getLink",
"(",
"self",
"::",
"FEED_LINK_PA... | Create a new tag from a TagEntry.
@param Zend_Gdata_Photos_TagEntry $tag The tag entry to insert.
@param string $url The URI where the tag should be
uploaded to. Alternatively, a PhotoEntry can be provided and
the tag will be added to that photo.
@return Zend_Gdata_Photos_TagEntry The inserted tag entry as returned
by the server.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Create",
"a",
"new",
"tag",
"from",
"a",
"TagEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L419-L431 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.insertCommentEntry | public function insertCommentEntry($comment, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($comment, $uri, 'Zend_Gdata_Photos_CommentEntry');
return $newEntry;
} | php | public function insertCommentEntry($comment, $uri = null)
{
if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
$uri = $uri->getLink(self::FEED_LINK_PATH)->href;
}
if ($uri === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'URI must not be null');
}
$newEntry = $this->insertEntry($comment, $uri, 'Zend_Gdata_Photos_CommentEntry');
return $newEntry;
} | [
"public",
"function",
"insertCommentEntry",
"(",
"$",
"comment",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"uri",
"instanceof",
"Zend_Gdata_Photos_PhotoEntry",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"getLink",
"(",
"self",
"::",
"FEED... | Create a new comment from a CommentEntry.
@param Zend_Gdata_Photos_CommentEntry $comment The comment entry to
insert.
@param string $url The URI where the comment should be uploaded to.
Alternatively, a PhotoEntry can be provided and
the comment will be added to that photo.
@return Zend_Gdata_Photos_CommentEntry The inserted comment entry
as returned by the server.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Create",
"a",
"new",
"comment",
"from",
"a",
"CommentEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L446-L458 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.deleteAlbumEntry | public function deleteAlbumEntry($album, $catch)
{
if ($catch) {
try {
$this->delete($album);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($album);
}
} | php | public function deleteAlbumEntry($album, $catch)
{
if ($catch) {
try {
$this->delete($album);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($album);
}
} | [
"public",
"function",
"deleteAlbumEntry",
"(",
"$",
"album",
",",
"$",
"catch",
")",
"{",
"if",
"(",
"$",
"catch",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"album",
")",
";",
"}",
"catch",
"(",
"Zend_Gdata_App_HttpException",
"$",
... | Delete an AlbumEntry.
@param Zend_Gdata_Photos_AlbumEntry $album The album entry to
delete.
@param boolean $catch Whether to catch an exception when
modified and re-delete or throw
@return void.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Delete",
"an",
"AlbumEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L471-L487 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.deletePhotoEntry | public function deletePhotoEntry($photo, $catch)
{
if ($catch) {
try {
$this->delete($photo);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_PhotoEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($photo);
}
} | php | public function deletePhotoEntry($photo, $catch)
{
if ($catch) {
try {
$this->delete($photo);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_PhotoEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($photo);
}
} | [
"public",
"function",
"deletePhotoEntry",
"(",
"$",
"photo",
",",
"$",
"catch",
")",
"{",
"if",
"(",
"$",
"catch",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"photo",
")",
";",
"}",
"catch",
"(",
"Zend_Gdata_App_HttpException",
"$",
... | Delete a PhotoEntry.
@param Zend_Gdata_Photos_PhotoEntry $photo The photo entry to
delete.
@param boolean $catch Whether to catch an exception when
modified and re-delete or throw
@return void.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Delete",
"a",
"PhotoEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L500-L516 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.deleteCommentEntry | public function deleteCommentEntry($comment, $catch)
{
if ($catch) {
try {
$this->delete($comment);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($comment);
}
} | php | public function deleteCommentEntry($comment, $catch)
{
if ($catch) {
try {
$this->delete($comment);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($comment);
}
} | [
"public",
"function",
"deleteCommentEntry",
"(",
"$",
"comment",
",",
"$",
"catch",
")",
"{",
"if",
"(",
"$",
"catch",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"comment",
")",
";",
"}",
"catch",
"(",
"Zend_Gdata_App_HttpException",
... | Delete a CommentEntry.
@param Zend_Gdata_Photos_CommentEntry $comment The comment entry to
delete.
@param boolean $catch Whether to catch an exception when
modified and re-delete or throw
@return void.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Delete",
"a",
"CommentEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L529-L545 | train |
n0m4dz/laracasa | Zend/Gdata/Photos.php | Zend_Gdata_Photos.deleteTagEntry | public function deleteTagEntry($tag, $catch)
{
if ($catch) {
try {
$this->delete($tag);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($tag);
}
} | php | public function deleteTagEntry($tag, $catch)
{
if ($catch) {
try {
$this->delete($tag);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() === 409) {
$entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}
} else {
$this->delete($tag);
}
} | [
"public",
"function",
"deleteTagEntry",
"(",
"$",
"tag",
",",
"$",
"catch",
")",
"{",
"if",
"(",
"$",
"catch",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"tag",
")",
";",
"}",
"catch",
"(",
"Zend_Gdata_App_HttpException",
"$",
"e",
... | Delete a TagEntry.
@param Zend_Gdata_Photos_TagEntry $tag The tag entry to
delete.
@param boolean $catch Whether to catch an exception when
modified and re-delete or throw
@return void.
@throws Zend_Gdata_App_Exception
@throws Zend_Gdata_App_HttpException | [
"Delete",
"a",
"TagEntry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Photos.php#L558-L574 | train |
edunola13/enolaphp-framework | src/Cron/Models/En_CronRequest.php | En_CronRequest.getParam | public function getParam($index){
if(isset($this->params[$index])){
return $this->params[$index];
}else{
return NULL;
}
} | php | public function getParam($index){
if(isset($this->params[$index])){
return $this->params[$index];
}else{
return NULL;
}
} | [
"public",
"function",
"getParam",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"index",
"]",
";",
"}",
"else",
"{",
"r... | Devuelve un parametro en base a un indice - solo parametros no utilizados por el framework
@param string $index
@return null o string | [
"Devuelve",
"un",
"parametro",
"en",
"base",
"a",
"un",
"indice",
"-",
"solo",
"parametros",
"no",
"utilizados",
"por",
"el",
"framework"
] | a962bfcd53d7bc129d8c9946aaa71d264285229d | https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L49-L55 | train |
edunola13/enolaphp-framework | src/Cron/Models/En_CronRequest.php | En_CronRequest.getParamClean | public function getParamClean($index){
if(isset($this->params[$index])){
return $this->params[$index];
}else{
return NULL;
}
} | php | public function getParamClean($index){
if(isset($this->params[$index])){
return $this->params[$index];
}else{
return NULL;
}
} | [
"public",
"function",
"getParamClean",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"index",
"]",
";",
"}",
"else",
"{",... | Devuelve un parametro limpiado en base a un indice - solo parametros no utilizados por el framework
@param string $index
@return null o string | [
"Devuelve",
"un",
"parametro",
"limpiado",
"en",
"base",
"a",
"un",
"indice",
"-",
"solo",
"parametros",
"no",
"utilizados",
"por",
"el",
"framework"
] | a962bfcd53d7bc129d8c9946aaa71d264285229d | https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L61-L67 | train |
edunola13/enolaphp-framework | src/Cron/Models/En_CronRequest.php | En_CronRequest.getParamAll | public function getParamAll($index){
if(isset($this->allParams[$index])){
return Security::clean_vars($this->allParams[$index]);
}
else{
return NULL;
}
} | php | public function getParamAll($index){
if(isset($this->allParams[$index])){
return Security::clean_vars($this->allParams[$index]);
}
else{
return NULL;
}
} | [
"public",
"function",
"getParamAll",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"allParams",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"Security",
"::",
"clean_vars",
"(",
"$",
"this",
"->",
"allParams",
"[",
"$",... | Devuelve un parametro en base a un indice - incluye todos los parametros
@param string $index
@return null o string | [
"Devuelve",
"un",
"parametro",
"en",
"base",
"a",
"un",
"indice",
"-",
"incluye",
"todos",
"los",
"parametros"
] | a962bfcd53d7bc129d8c9946aaa71d264285229d | https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L73-L80 | train |
edunola13/enolaphp-framework | src/Cron/Models/En_CronRequest.php | En_CronRequest.getParamAllClean | public function getParamAllClean($index){
if(isset($this->allParams[$index])){
return Security::clean_vars($this->allParams[$index]);
}
else{
return NULL;
}
} | php | public function getParamAllClean($index){
if(isset($this->allParams[$index])){
return Security::clean_vars($this->allParams[$index]);
}
else{
return NULL;
}
} | [
"public",
"function",
"getParamAllClean",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"allParams",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"Security",
"::",
"clean_vars",
"(",
"$",
"this",
"->",
"allParams",
"[",
... | Devuelve un parametro limpiado en base a un indice - incluye todos los parametros
@param string $index
@return null o string | [
"Devuelve",
"un",
"parametro",
"limpiado",
"en",
"base",
"a",
"un",
"indice",
"-",
"incluye",
"todos",
"los",
"parametros"
] | a962bfcd53d7bc129d8c9946aaa71d264285229d | https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Cron/Models/En_CronRequest.php#L86-L93 | train |
gplcart/xss | helpers/Filter.php | Filter.build | protected function build($m)
{
$string = $m[1];
if (substr($string, 0, 1) != '<') {
// We matched a lone ">" character.
return '>';
} elseif (strlen($string) == 1) {
// We matched a lone "<" character.
return '<';
}
if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
// Seriously malformed.
return '';
}
$slash = trim($matches[1]);
$elem = &$matches[2];
$attrlist = &$matches[3];
$comment = &$matches[4];
if ($comment) {
$elem = '!--';
}
if (!in_array(strtolower($elem), $this->tags, true)) {
return ''; // Disallowed HTML element.
}
if ($comment) {
return $comment;
}
if ($slash != '') {
return "</$elem>";
}
// Is there a closing XHTML slash at the end of the attributes?
$attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist, -1, $count);
$xhtml_slash = $count ? ' /' : '';
// Clean up attributes.
$attr2 = implode(' ', $this->explodeAttributes($attrlist));
$attr2 = preg_replace('/[<>]/', '', $attr2);
$attr2 = strlen($attr2) ? ' ' . $attr2 : '';
return "<$elem$attr2$xhtml_slash>";
} | php | protected function build($m)
{
$string = $m[1];
if (substr($string, 0, 1) != '<') {
// We matched a lone ">" character.
return '>';
} elseif (strlen($string) == 1) {
// We matched a lone "<" character.
return '<';
}
if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
// Seriously malformed.
return '';
}
$slash = trim($matches[1]);
$elem = &$matches[2];
$attrlist = &$matches[3];
$comment = &$matches[4];
if ($comment) {
$elem = '!--';
}
if (!in_array(strtolower($elem), $this->tags, true)) {
return ''; // Disallowed HTML element.
}
if ($comment) {
return $comment;
}
if ($slash != '') {
return "</$elem>";
}
// Is there a closing XHTML slash at the end of the attributes?
$attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist, -1, $count);
$xhtml_slash = $count ? ' /' : '';
// Clean up attributes.
$attr2 = implode(' ', $this->explodeAttributes($attrlist));
$attr2 = preg_replace('/[<>]/', '', $attr2);
$attr2 = strlen($attr2) ? ' ' . $attr2 : '';
return "<$elem$attr2$xhtml_slash>";
} | [
"protected",
"function",
"build",
"(",
"$",
"m",
")",
"{",
"$",
"string",
"=",
"$",
"m",
"[",
"1",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
"!=",
"'<'",
")",
"{",
"// We matched a lone \">\" character.",
"return",
... | Build a filtered tag
@param array $m
@return string | [
"Build",
"a",
"filtered",
"tag"
] | 85c98028b28da188a0a4e415df32b0c3e3761524 | https://github.com/gplcart/xss/blob/85c98028b28da188a0a4e415df32b0c3e3761524/helpers/Filter.php#L124-L172 | train |
soloproyectos-php/array | src/arr/arguments/ArrArgumentsDescriptor.php | ArrArgumentsDescriptor.match | public function match($var)
{
$ret = false;
foreach ($this->_types as $type) {
if (array_search($type, array("*", "mixed")) !== false) {
$ret = true;
} elseif (array_search($type, array("number", "numeric")) !== false) {
$ret = is_numeric($var);
} elseif (array_search($type, array("bool", "boolean")) !== false) {
$ret = is_bool($var);
} elseif ($type == "string") {
$ret = is_string($var);
} elseif ($type == "array") {
$ret = is_array($var);
} elseif ($type == "object") {
$ret = is_object($var);
} elseif ($type == "resource") {
$ret = is_resource($var);
} elseif ($type == "function") {
$ret = is_callable($var);
} elseif ($type == "scalar") {
$ret = is_scalar($var);
} else {
$ret = is_a($var, $type);
}
if ($ret) {
break;
}
}
return $ret;
} | php | public function match($var)
{
$ret = false;
foreach ($this->_types as $type) {
if (array_search($type, array("*", "mixed")) !== false) {
$ret = true;
} elseif (array_search($type, array("number", "numeric")) !== false) {
$ret = is_numeric($var);
} elseif (array_search($type, array("bool", "boolean")) !== false) {
$ret = is_bool($var);
} elseif ($type == "string") {
$ret = is_string($var);
} elseif ($type == "array") {
$ret = is_array($var);
} elseif ($type == "object") {
$ret = is_object($var);
} elseif ($type == "resource") {
$ret = is_resource($var);
} elseif ($type == "function") {
$ret = is_callable($var);
} elseif ($type == "scalar") {
$ret = is_scalar($var);
} else {
$ret = is_a($var, $type);
}
if ($ret) {
break;
}
}
return $ret;
} | [
"public",
"function",
"match",
"(",
"$",
"var",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"_types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"array_search",
"(",
"$",
"type",
",",
"array",
"(",
"\"*\"",
",",
"\"mi... | Does the variable match with this descriptor?
@param mixed $var Arbitrary variable
@return boolean | [
"Does",
"the",
"variable",
"match",
"with",
"this",
"descriptor?"
] | de38c800f3388005cbd37e70ab055f22609a5eae | https://github.com/soloproyectos-php/array/blob/de38c800f3388005cbd37e70ab055f22609a5eae/src/arr/arguments/ArrArgumentsDescriptor.php#L82-L115 | train |
arvici/framework | src/Arvici/Heart/Router/Middleware.php | Middleware.execute | public function execute()
{
if (is_string($this->callback)) {
// Will call the controller here
$parts = explode('::', $this->callback);
$className = $parts[0];
$classMethod = $parts[1];
if (! class_exists($className)) {
throw new RouterException("The callback class declared in your middleware is not found: '{$className}'");
}
$class = new $className();
if (! $class instanceof BaseMiddleware) {
throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore
}
if (! method_exists($class, $classMethod)) {
throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}");
}
// Call the method. Catch return
$result = call_user_func(array($class, $classMethod));
} elseif (is_callable($this->callback)) {
$result = call_user_func($this->callback);
} else {
throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore
}
// See if we got a boolean back.
if ($result === false && $this->position === 'before') {
// We should stop!
return false;
}
return true;
} | php | public function execute()
{
if (is_string($this->callback)) {
// Will call the controller here
$parts = explode('::', $this->callback);
$className = $parts[0];
$classMethod = $parts[1];
if (! class_exists($className)) {
throw new RouterException("The callback class declared in your middleware is not found: '{$className}'");
}
$class = new $className();
if (! $class instanceof BaseMiddleware) {
throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore
}
if (! method_exists($class, $classMethod)) {
throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}");
}
// Call the method. Catch return
$result = call_user_func(array($class, $classMethod));
} elseif (is_callable($this->callback)) {
$result = call_user_func($this->callback);
} else {
throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore
}
// See if we got a boolean back.
if ($result === false && $this->position === 'before') {
// We should stop!
return false;
}
return true;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"callback",
")",
")",
"{",
"// Will call the controller here",
"$",
"parts",
"=",
"explode",
"(",
"'::'",
",",
"$",
"this",
"->",
"callback",
")",
";",
"$",
... | Execute Callback in middleware, capture the output of it.
@return bool can we continue?
@throws RouterException | [
"Execute",
"Callback",
"in",
"middleware",
"capture",
"the",
"output",
"of",
"it",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Middleware.php#L105-L143 | train |
samsonos/social_network | Network.php | Network.prepare | public function prepare()
{
$class = get_class($this);
// Check table
if (!isset($this->dbTable)) {
return e('Cannot load "'.$class.'" module - no $dbTable is configured');
}
// Social system specific configuration check
if ($class != __CLASS__) {
db()->createField($this, $this->dbTable, 'dbIdField', 'VARCHAR(50)');
}
// Create and check general database table fields configuration
db()->createField($this, $this->dbTable, 'dbNameField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbSurnameField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbEmailField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbGenderField', 'VARCHAR(10)');
db()->createField($this, $this->dbTable, 'dbBirthdayField', 'DATE');
db()->createField($this, $this->dbTable, 'dbPhotoField', 'VARCHAR(125)');
return parent::prepare();
} | php | public function prepare()
{
$class = get_class($this);
// Check table
if (!isset($this->dbTable)) {
return e('Cannot load "'.$class.'" module - no $dbTable is configured');
}
// Social system specific configuration check
if ($class != __CLASS__) {
db()->createField($this, $this->dbTable, 'dbIdField', 'VARCHAR(50)');
}
// Create and check general database table fields configuration
db()->createField($this, $this->dbTable, 'dbNameField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbSurnameField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbEmailField', 'VARCHAR(50)');
db()->createField($this, $this->dbTable, 'dbGenderField', 'VARCHAR(10)');
db()->createField($this, $this->dbTable, 'dbBirthdayField', 'DATE');
db()->createField($this, $this->dbTable, 'dbPhotoField', 'VARCHAR(125)');
return parent::prepare();
} | [
"public",
"function",
"prepare",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"// Check table",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dbTable",
")",
")",
"{",
"return",
"e",
"(",
"'Cannot load \"'",
".",
"$",... | Prepare module data | [
"Prepare",
"module",
"data"
] | 3700cf526fa58692d89247141e3f0f04bb5ec759 | https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L76-L99 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.