repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
chilimatic/chilimatic-framework | lib/file/File.php | File._get_path | private function _get_path()
{
if (empty($this->file) && is_string($this->file)) return false;
if (strpos($this->file, '/') !== false) {
$path = explode('/', $this->file);
array_pop($path);
$this->path = (string)implode('/', $path) . '/';
} elseif (strpos('\\', $this->file) !== false) {
$path = explode('\\', $this->file);
array_pop($path);
$this->path = (string)implode('\\', $path) . '\\';
} else {
$this->path = getcwd() . '/';
}
return true;
} | php | private function _get_path()
{
if (empty($this->file) && is_string($this->file)) return false;
if (strpos($this->file, '/') !== false) {
$path = explode('/', $this->file);
array_pop($path);
$this->path = (string)implode('/', $path) . '/';
} elseif (strpos('\\', $this->file) !== false) {
$path = explode('\\', $this->file);
array_pop($path);
$this->path = (string)implode('\\', $path) . '\\';
} else {
$this->path = getcwd() . '/';
}
return true;
} | [
"private",
"function",
"_get_path",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"file",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"file",
")",
")",
"return",
"false",
";",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"file",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"file",
")",
";",
"array_pop",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"path",
"=",
"(",
"string",
")",
"implode",
"(",
"'/'",
",",
"$",
"path",
")",
".",
"'/'",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"file",
")",
"!==",
"false",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"file",
")",
";",
"array_pop",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"path",
"=",
"(",
"string",
")",
"implode",
"(",
"'\\\\'",
",",
"$",
"path",
")",
".",
"'\\\\'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"path",
"=",
"getcwd",
"(",
")",
".",
"'/'",
";",
"}",
"return",
"true",
";",
"}"
] | gets the filename out of the entered path
@return bool | [
"gets",
"the",
"filename",
"out",
"of",
"the",
"entered",
"path"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L405-L423 | train |
chilimatic/chilimatic-framework | lib/file/File.php | File.open | public function open($filename)
{
if (!is_file($filename)) return false;
$this->file = @(string)$filename;
$this->group = @(int)filegroup($filename);
$this->owner = @(int)fileowner($filename);
$this->size = @(int)filesize($filename);
$this->type = @(string)filetype($filename);
$this->accessed = @(int)fileatime($filename);
$this->changed = @(int)filectime($filename);
$this->modified = @(int)filemtime($filename);
$this->permission = @(int)fileperms($filename);
$this->f_inode = @ fileinode($filename);
$this->writeable = @(bool)is_writable($filename);
$this->readable = @(bool)is_readable($filename);
$this->mime_type = @(string)mime_content_type($filename);
$this->_get_path();
$this->_extract_filename();
$this->_extract_file_extension();
return true;
} | php | public function open($filename)
{
if (!is_file($filename)) return false;
$this->file = @(string)$filename;
$this->group = @(int)filegroup($filename);
$this->owner = @(int)fileowner($filename);
$this->size = @(int)filesize($filename);
$this->type = @(string)filetype($filename);
$this->accessed = @(int)fileatime($filename);
$this->changed = @(int)filectime($filename);
$this->modified = @(int)filemtime($filename);
$this->permission = @(int)fileperms($filename);
$this->f_inode = @ fileinode($filename);
$this->writeable = @(bool)is_writable($filename);
$this->readable = @(bool)is_readable($filename);
$this->mime_type = @(string)mime_content_type($filename);
$this->_get_path();
$this->_extract_filename();
$this->_extract_file_extension();
return true;
} | [
"public",
"function",
"open",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filename",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"file",
"=",
"@",
"(",
"string",
")",
"$",
"filename",
";",
"$",
"this",
"->",
"group",
"=",
"@",
"(",
"int",
")",
"filegroup",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"owner",
"=",
"@",
"(",
"int",
")",
"fileowner",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"size",
"=",
"@",
"(",
"int",
")",
"filesize",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"type",
"=",
"@",
"(",
"string",
")",
"filetype",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"accessed",
"=",
"@",
"(",
"int",
")",
"fileatime",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"changed",
"=",
"@",
"(",
"int",
")",
"filectime",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"modified",
"=",
"@",
"(",
"int",
")",
"filemtime",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"permission",
"=",
"@",
"(",
"int",
")",
"fileperms",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"f_inode",
"=",
"@",
"fileinode",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"writeable",
"=",
"@",
"(",
"bool",
")",
"is_writable",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"readable",
"=",
"@",
"(",
"bool",
")",
"is_readable",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"mime_type",
"=",
"@",
"(",
"string",
")",
"mime_content_type",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"_get_path",
"(",
")",
";",
"$",
"this",
"->",
"_extract_filename",
"(",
")",
";",
"$",
"this",
"->",
"_extract_file_extension",
"(",
")",
";",
"return",
"true",
";",
"}"
] | gets all the information about the file
@param $filename string
@return bool | [
"gets",
"all",
"the",
"information",
"about",
"the",
"file"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L433-L456 | train |
chilimatic/chilimatic-framework | lib/file/File.php | File.open_fp | function open_fp($option = 'r')
{
if (empty($option) || !is_string($option)) return false;
switch (true) {
case (strpos($option, 'r') !== false) :
$mode = LOCK_SH;
break;
case (strpos($option, 'a') !== false || strpos($option, 'w') !== false) :
$mode = LOCK_EX;
break;
default :
$mode = LOCK_EX;
break;
}
$this->readable = true;
if (($this->fp = fopen($this->file, $option)) !== false) {
$this->lock($mode);
// sets the fopen option based on it reduces
// reopening of a file
$this->_option = (string)$option;
return true;
}
return false;
} | php | function open_fp($option = 'r')
{
if (empty($option) || !is_string($option)) return false;
switch (true) {
case (strpos($option, 'r') !== false) :
$mode = LOCK_SH;
break;
case (strpos($option, 'a') !== false || strpos($option, 'w') !== false) :
$mode = LOCK_EX;
break;
default :
$mode = LOCK_EX;
break;
}
$this->readable = true;
if (($this->fp = fopen($this->file, $option)) !== false) {
$this->lock($mode);
// sets the fopen option based on it reduces
// reopening of a file
$this->_option = (string)$option;
return true;
}
return false;
} | [
"function",
"open_fp",
"(",
"$",
"option",
"=",
"'r'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"option",
")",
"||",
"!",
"is_string",
"(",
"$",
"option",
")",
")",
"return",
"false",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"strpos",
"(",
"$",
"option",
",",
"'r'",
")",
"!==",
"false",
")",
":",
"$",
"mode",
"=",
"LOCK_SH",
";",
"break",
";",
"case",
"(",
"strpos",
"(",
"$",
"option",
",",
"'a'",
")",
"!==",
"false",
"||",
"strpos",
"(",
"$",
"option",
",",
"'w'",
")",
"!==",
"false",
")",
":",
"$",
"mode",
"=",
"LOCK_EX",
";",
"break",
";",
"default",
":",
"$",
"mode",
"=",
"LOCK_EX",
";",
"break",
";",
"}",
"$",
"this",
"->",
"readable",
"=",
"true",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"fp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"option",
")",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"lock",
"(",
"$",
"mode",
")",
";",
"// sets the fopen option based on it reduces",
"// reopening of a file",
"$",
"this",
"->",
"_option",
"=",
"(",
"string",
")",
"$",
"option",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | opens a filepointer
@param $option string
@return bool | [
"opens",
"a",
"filepointer"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L466-L494 | train |
chilimatic/chilimatic-framework | lib/file/File.php | File.read | public function read()
{
// if file is readable
if ($this->readable !== true) return false;
if (!empty($this->fp) && is_resource($this->fp)) fclose($this->fp);
$this->open_fp('r');
if (filesize($this->file) == 0) return false;
$this->lock(LOCK_SH);
$content = (string)fread($this->fp, ($this->size >= 0) ? $this->size : 1);
$this->lock(LOCK_UN);
return $content;
} | php | public function read()
{
// if file is readable
if ($this->readable !== true) return false;
if (!empty($this->fp) && is_resource($this->fp)) fclose($this->fp);
$this->open_fp('r');
if (filesize($this->file) == 0) return false;
$this->lock(LOCK_SH);
$content = (string)fread($this->fp, ($this->size >= 0) ? $this->size : 1);
$this->lock(LOCK_UN);
return $content;
} | [
"public",
"function",
"read",
"(",
")",
"{",
"// if file is readable",
"if",
"(",
"$",
"this",
"->",
"readable",
"!==",
"true",
")",
"return",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"fp",
")",
"&&",
"is_resource",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"open_fp",
"(",
"'r'",
")",
";",
"if",
"(",
"filesize",
"(",
"$",
"this",
"->",
"file",
")",
"==",
"0",
")",
"return",
"false",
";",
"$",
"this",
"->",
"lock",
"(",
"LOCK_SH",
")",
";",
"$",
"content",
"=",
"(",
"string",
")",
"fread",
"(",
"$",
"this",
"->",
"fp",
",",
"(",
"$",
"this",
"->",
"size",
">=",
"0",
")",
"?",
"$",
"this",
"->",
"size",
":",
"1",
")",
";",
"$",
"this",
"->",
"lock",
"(",
"LOCK_UN",
")",
";",
"return",
"$",
"content",
";",
"}"
] | read the current content of the file
@return string | [
"read",
"the",
"current",
"content",
"of",
"the",
"file"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/file/File.php#L502-L520 | train |
phramework/testphase | src/Binary.php | Binary.getArgumentSpecifications | public static function getArgumentSpecifications()
{
$specs = new OptionCollection;
$specs->add('d|dir:', 'Tests directory path')
->isa('String');
$specs->add('s|subdir+', 'Optional, subdirectory pattern, can be used multiple times as OR expression')
->isa('String')
->defaultValue(null);
$specs->add('b|bootstrap?', 'Bootstrap file path')
->isa('File')
->defaultValue(null);
$specs->add('v|verbose', 'Verbose output')
->defaultValue(false);
$specs->add('show-globals', 'Show values of global variables')->defaultValue(false);
$specs->add('debug', 'Show debug messages')->defaultValue(false);
$specs->add('h|help', 'Show help')->defaultValue(false);
$specs->add('no-colors', 'No colors')->defaultValue(false);
$specs->add('i|immediate', 'Show error output immediately as it appears')->defaultValue(false);
$specs->add('server-host?', 'Server host')->defaultValue(null);
$specs->add('server-root', 'Server root path, default is ./public')->defaultValue('./public');
return $specs;
} | php | public static function getArgumentSpecifications()
{
$specs = new OptionCollection;
$specs->add('d|dir:', 'Tests directory path')
->isa('String');
$specs->add('s|subdir+', 'Optional, subdirectory pattern, can be used multiple times as OR expression')
->isa('String')
->defaultValue(null);
$specs->add('b|bootstrap?', 'Bootstrap file path')
->isa('File')
->defaultValue(null);
$specs->add('v|verbose', 'Verbose output')
->defaultValue(false);
$specs->add('show-globals', 'Show values of global variables')->defaultValue(false);
$specs->add('debug', 'Show debug messages')->defaultValue(false);
$specs->add('h|help', 'Show help')->defaultValue(false);
$specs->add('no-colors', 'No colors')->defaultValue(false);
$specs->add('i|immediate', 'Show error output immediately as it appears')->defaultValue(false);
$specs->add('server-host?', 'Server host')->defaultValue(null);
$specs->add('server-root', 'Server root path, default is ./public')->defaultValue('./public');
return $specs;
} | [
"public",
"static",
"function",
"getArgumentSpecifications",
"(",
")",
"{",
"$",
"specs",
"=",
"new",
"OptionCollection",
";",
"$",
"specs",
"->",
"add",
"(",
"'d|dir:'",
",",
"'Tests directory path'",
")",
"->",
"isa",
"(",
"'String'",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'s|subdir+'",
",",
"'Optional, subdirectory pattern, can be used multiple times as OR expression'",
")",
"->",
"isa",
"(",
"'String'",
")",
"->",
"defaultValue",
"(",
"null",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'b|bootstrap?'",
",",
"'Bootstrap file path'",
")",
"->",
"isa",
"(",
"'File'",
")",
"->",
"defaultValue",
"(",
"null",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'v|verbose'",
",",
"'Verbose output'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'show-globals'",
",",
"'Show values of global variables'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'debug'",
",",
"'Show debug messages'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'h|help'",
",",
"'Show help'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'no-colors'",
",",
"'No colors'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'i|immediate'",
",",
"'Show error output immediately as it appears'",
")",
"->",
"defaultValue",
"(",
"false",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'server-host?'",
",",
"'Server host'",
")",
"->",
"defaultValue",
"(",
"null",
")",
";",
"$",
"specs",
"->",
"add",
"(",
"'server-root'",
",",
"'Server root path, default is ./public'",
")",
"->",
"defaultValue",
"(",
"'./public'",
")",
";",
"return",
"$",
"specs",
";",
"}"
] | Get argument specifications
@return OptionCollection | [
"Get",
"argument",
"specifications"
] | b00107b7a37cf1a1b9b8860b3eb031aacfa2634c | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Binary.php#L52-L79 | train |
phramework/testphase | src/Binary.php | Binary.colored | public function colored($text, $color)
{
$colors = [
'black' => '0;30',
'red' => '0;31',
'green' => '0;32',
'blue' => '1;34',
'yellow' => '1;33'
];
$c = (
array_key_exists($color, $colors)
? $colors[$color]
: $colors['black']
);
if ($this->arguments->{'no-colors'}) {
return $text;
} else {
return "\033[". $c . 'm' . $text . "\033[0m";
}
} | php | public function colored($text, $color)
{
$colors = [
'black' => '0;30',
'red' => '0;31',
'green' => '0;32',
'blue' => '1;34',
'yellow' => '1;33'
];
$c = (
array_key_exists($color, $colors)
? $colors[$color]
: $colors['black']
);
if ($this->arguments->{'no-colors'}) {
return $text;
} else {
return "\033[". $c . 'm' . $text . "\033[0m";
}
} | [
"public",
"function",
"colored",
"(",
"$",
"text",
",",
"$",
"color",
")",
"{",
"$",
"colors",
"=",
"[",
"'black'",
"=>",
"'0;30'",
",",
"'red'",
"=>",
"'0;31'",
",",
"'green'",
"=>",
"'0;32'",
",",
"'blue'",
"=>",
"'1;34'",
",",
"'yellow'",
"=>",
"'1;33'",
"]",
";",
"$",
"c",
"=",
"(",
"array_key_exists",
"(",
"$",
"color",
",",
"$",
"colors",
")",
"?",
"$",
"colors",
"[",
"$",
"color",
"]",
":",
"$",
"colors",
"[",
"'black'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"arguments",
"->",
"{",
"'no-colors'",
"}",
")",
"{",
"return",
"$",
"text",
";",
"}",
"else",
"{",
"return",
"\"\\033[\"",
".",
"$",
"c",
".",
"'m'",
".",
"$",
"text",
".",
"\"\\033[0m\"",
";",
"}",
"}"
] | Returned colored text
@param string $text
@param string $color
@return string | [
"Returned",
"colored",
"text"
] | b00107b7a37cf1a1b9b8860b3eb031aacfa2634c | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Binary.php#L504-L525 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergePackageLoader | public function mergePackageLoader($directory)
{
if ($vendor = $this->findVendor($directory)) {
$this->mergeComposerNamespaces($vendor);
$this->mergeComposerPsr4($vendor);
$this->mergeComposerClassMap($vendor);
}
} | php | public function mergePackageLoader($directory)
{
if ($vendor = $this->findVendor($directory)) {
$this->mergeComposerNamespaces($vendor);
$this->mergeComposerPsr4($vendor);
$this->mergeComposerClassMap($vendor);
}
} | [
"public",
"function",
"mergePackageLoader",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"$",
"vendor",
"=",
"$",
"this",
"->",
"findVendor",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"mergeComposerNamespaces",
"(",
"$",
"vendor",
")",
";",
"$",
"this",
"->",
"mergeComposerPsr4",
"(",
"$",
"vendor",
")",
";",
"$",
"this",
"->",
"mergeComposerClassMap",
"(",
"$",
"vendor",
")",
";",
"}",
"}"
] | Autoloads a packages dependencies by merging them with the current auto-loader.
@param $directory | [
"Autoloads",
"a",
"packages",
"dependencies",
"by",
"merging",
"them",
"with",
"the",
"current",
"auto",
"-",
"loader",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L48-L55 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerNamespaces | private function mergeComposerNamespaces($vendor)
{
if ($namespaceFile = $this->findComposerDirectory($vendor, 'autoload_namespaces.php')) {
$this->log->debug('Located autoload_namespaces.php file', ['path' => $namespaceFile]);
$map = require $namespaceFile;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->set($namespace, $path);
}
}
} | php | private function mergeComposerNamespaces($vendor)
{
if ($namespaceFile = $this->findComposerDirectory($vendor, 'autoload_namespaces.php')) {
$this->log->debug('Located autoload_namespaces.php file', ['path' => $namespaceFile]);
$map = require $namespaceFile;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->set($namespace, $path);
}
}
} | [
"private",
"function",
"mergeComposerNamespaces",
"(",
"$",
"vendor",
")",
"{",
"if",
"(",
"$",
"namespaceFile",
"=",
"$",
"this",
"->",
"findComposerDirectory",
"(",
"$",
"vendor",
",",
"'autoload_namespaces.php'",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Located autoload_namespaces.php file'",
",",
"[",
"'path'",
"=>",
"$",
"namespaceFile",
"]",
")",
";",
"$",
"map",
"=",
"require",
"$",
"namespaceFile",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Autoloading namespace'",
",",
"[",
"'namespace'",
"=>",
"$",
"namespace",
",",
"'path'",
"=>",
"$",
"path",
"]",
")",
";",
"$",
"this",
"->",
"app",
"->",
"getLoader",
"(",
")",
"->",
"set",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}",
"}",
"}"
] | Merges the dependencies namespaces.
@param $vendor | [
"Merges",
"the",
"dependencies",
"namespaces",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L62-L72 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerPsr4 | private function mergeComposerPsr4($vendor)
{
if ($psr4Autoload = $this->findComposerDirectory($vendor, 'autoload_psr4.php')) {
$this->log->debug('Located autoload_psr4.php file', ['path' => $psr4Autoload]);
$map = require $psr4Autoload;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading PSR-4 namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->setPsr4($namespace, $path);
}
}
} | php | private function mergeComposerPsr4($vendor)
{
if ($psr4Autoload = $this->findComposerDirectory($vendor, 'autoload_psr4.php')) {
$this->log->debug('Located autoload_psr4.php file', ['path' => $psr4Autoload]);
$map = require $psr4Autoload;
foreach ($map as $namespace => $path) {
$this->log->debug('Autoloading PSR-4 namespace', ['namespace' => $namespace, 'path' => $path]);
$this->app->getLoader()->setPsr4($namespace, $path);
}
}
} | [
"private",
"function",
"mergeComposerPsr4",
"(",
"$",
"vendor",
")",
"{",
"if",
"(",
"$",
"psr4Autoload",
"=",
"$",
"this",
"->",
"findComposerDirectory",
"(",
"$",
"vendor",
",",
"'autoload_psr4.php'",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Located autoload_psr4.php file'",
",",
"[",
"'path'",
"=>",
"$",
"psr4Autoload",
"]",
")",
";",
"$",
"map",
"=",
"require",
"$",
"psr4Autoload",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Autoloading PSR-4 namespace'",
",",
"[",
"'namespace'",
"=>",
"$",
"namespace",
",",
"'path'",
"=>",
"$",
"path",
"]",
")",
";",
"$",
"this",
"->",
"app",
"->",
"getLoader",
"(",
")",
"->",
"setPsr4",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}",
"}",
"}"
] | Merges the dependencies PSR-4 namespaces.
@param $vendor | [
"Merges",
"the",
"dependencies",
"PSR",
"-",
"4",
"namespaces",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L79-L89 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.mergeComposerClassMap | private function mergeComposerClassMap($vendor)
{
if ($composerClassMap = $this->findComposerDirectory($vendor, 'autoload_classmap.php')) {
$this->log->debug('Located autoload_classmap.php file', ['path' => $composerClassMap]);
$classMap = require $composerClassMap;
if ($classMap) {
$this->app->getLoader()->addClassMap($classMap);
}
}
} | php | private function mergeComposerClassMap($vendor)
{
if ($composerClassMap = $this->findComposerDirectory($vendor, 'autoload_classmap.php')) {
$this->log->debug('Located autoload_classmap.php file', ['path' => $composerClassMap]);
$classMap = require $composerClassMap;
if ($classMap) {
$this->app->getLoader()->addClassMap($classMap);
}
}
} | [
"private",
"function",
"mergeComposerClassMap",
"(",
"$",
"vendor",
")",
"{",
"if",
"(",
"$",
"composerClassMap",
"=",
"$",
"this",
"->",
"findComposerDirectory",
"(",
"$",
"vendor",
",",
"'autoload_classmap.php'",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"'Located autoload_classmap.php file'",
",",
"[",
"'path'",
"=>",
"$",
"composerClassMap",
"]",
")",
";",
"$",
"classMap",
"=",
"require",
"$",
"composerClassMap",
";",
"if",
"(",
"$",
"classMap",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"getLoader",
"(",
")",
"->",
"addClassMap",
"(",
"$",
"classMap",
")",
";",
"}",
"}",
"}"
] | Merges the dependencies class maps.
@param $vendor | [
"Merges",
"the",
"dependencies",
"class",
"maps",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L96-L105 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.findComposerDirectory | private function findComposerDirectory($vendor, $file = '')
{
$composerDirectory = $this->normalizePath($vendor . '/composer/' . $file);
if ($this->files->exists($composerDirectory)) {
return $composerDirectory;
}
return false;
} | php | private function findComposerDirectory($vendor, $file = '')
{
$composerDirectory = $this->normalizePath($vendor . '/composer/' . $file);
if ($this->files->exists($composerDirectory)) {
return $composerDirectory;
}
return false;
} | [
"private",
"function",
"findComposerDirectory",
"(",
"$",
"vendor",
",",
"$",
"file",
"=",
"''",
")",
"{",
"$",
"composerDirectory",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"vendor",
".",
"'/composer/'",
".",
"$",
"file",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"composerDirectory",
")",
")",
"{",
"return",
"$",
"composerDirectory",
";",
"}",
"return",
"false",
";",
"}"
] | Finds the composer directory.
Returns false if the directory does not exist.
@param $vendor The vendor directory.
@param string $file An optional file to look for.
@return bool|string | [
"Finds",
"the",
"composer",
"directory",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L116-L125 | train |
newup/core | src/Foundation/Composer/AutoLoaderManager.php | AutoLoaderManager.findVendor | private function findVendor($directory)
{
$vendorDirectory = $this->normalizePath($directory . '/_newup_vendor');
if ($this->files->exists($vendorDirectory) && $this->files->isDirectory($vendorDirectory)) {
return $vendorDirectory;
}
return false;
} | php | private function findVendor($directory)
{
$vendorDirectory = $this->normalizePath($directory . '/_newup_vendor');
if ($this->files->exists($vendorDirectory) && $this->files->isDirectory($vendorDirectory)) {
return $vendorDirectory;
}
return false;
} | [
"private",
"function",
"findVendor",
"(",
"$",
"directory",
")",
"{",
"$",
"vendorDirectory",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"directory",
".",
"'/_newup_vendor'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"vendorDirectory",
")",
"&&",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"vendorDirectory",
")",
")",
"{",
"return",
"$",
"vendorDirectory",
";",
"}",
"return",
"false",
";",
"}"
] | Gets the vendor directory location if it exists.
Returns false if the vendor directory does not exist.
@param $directory
@return bool|string | [
"Gets",
"the",
"vendor",
"directory",
"location",
"if",
"it",
"exists",
"."
] | 54128903e7775e67d63284d958b46862c8df71f9 | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Foundation/Composer/AutoLoaderManager.php#L135-L144 | train |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.disconnect | public function disconnect($drop = false)
{
$this->handler->onClose($this);
parent::disconnect($drop);
} | php | public function disconnect($drop = false)
{
$this->handler->onClose($this);
parent::disconnect($drop);
} | [
"public",
"function",
"disconnect",
"(",
"$",
"drop",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"handler",
"->",
"onClose",
"(",
"$",
"this",
")",
";",
"parent",
"::",
"disconnect",
"(",
"$",
"drop",
")",
";",
"}"
] | Disconnects client from server.
It also notifies clients handler about that fact.
@param bool $drop By default client is disconnected after delivering output buffer contents. Set to true to drop
it immediately.
@return void | [
"Disconnects",
"client",
"from",
"server",
".",
"It",
"also",
"notifies",
"clients",
"handler",
"about",
"that",
"fact",
"."
] | 85f0335b87b3ec73ab47f5a5631eb86ba70b64a1 | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L52-L56 | train |
kiler129/TinyWs | src/WebSocketClient.php | WebSocketClient.ping | public function ping($payload = null)
{
if ($payload === null) {
$payload = microtime(true);
} elseif (isset($payload[125])) { //Much faster than strlen($payload) > 125
throw new LengthException("Ping payload cannot be larger than 125 bytes");
}
$this->currentPingFrame = new DataFrame($this->logger);
$this->currentPingFrame->setOpcode(DataFrame::OPCODE_PING);
$this->currentPingFrame->setPayload($payload);
$this->pushData($this->currentPingFrame);
return $payload;
} | php | public function ping($payload = null)
{
if ($payload === null) {
$payload = microtime(true);
} elseif (isset($payload[125])) { //Much faster than strlen($payload) > 125
throw new LengthException("Ping payload cannot be larger than 125 bytes");
}
$this->currentPingFrame = new DataFrame($this->logger);
$this->currentPingFrame->setOpcode(DataFrame::OPCODE_PING);
$this->currentPingFrame->setPayload($payload);
$this->pushData($this->currentPingFrame);
return $payload;
} | [
"public",
"function",
"ping",
"(",
"$",
"payload",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"payload",
"===",
"null",
")",
"{",
"$",
"payload",
"=",
"microtime",
"(",
"true",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"payload",
"[",
"125",
"]",
")",
")",
"{",
"//Much faster than strlen($payload) > 125",
"throw",
"new",
"LengthException",
"(",
"\"Ping payload cannot be larger than 125 bytes\"",
")",
";",
"}",
"$",
"this",
"->",
"currentPingFrame",
"=",
"new",
"DataFrame",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"$",
"this",
"->",
"currentPingFrame",
"->",
"setOpcode",
"(",
"DataFrame",
"::",
"OPCODE_PING",
")",
";",
"$",
"this",
"->",
"currentPingFrame",
"->",
"setPayload",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"pushData",
"(",
"$",
"this",
"->",
"currentPingFrame",
")",
";",
"return",
"$",
"payload",
";",
"}"
] | Sends "PING" frame to connected client.
@param mixed|null $payload Maximum of 125 bytes. If set to null current time will be used. It's possible to use
empty string.
@return string Used payload value
@throws LengthException In case of payload exceed 125 bytes. | [
"Sends",
"PING",
"frame",
"to",
"connected",
"client",
"."
] | 85f0335b87b3ec73ab47f5a5631eb86ba70b64a1 | https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/WebSocketClient.php#L81-L96 | train |
cityware/city-format | src/Stringy.php | Stringy.isJson | public function isJson() {
if (!$this->endsWith('}') && !$this->endsWith(']')) {
return false;
}
return !is_null(json_decode($this->str));
} | php | public function isJson() {
if (!$this->endsWith('}') && !$this->endsWith(']')) {
return false;
}
return !is_null(json_decode($this->str));
} | [
"public",
"function",
"isJson",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"endsWith",
"(",
"'}'",
")",
"&&",
"!",
"$",
"this",
"->",
"endsWith",
"(",
"']'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"is_null",
"(",
"json_decode",
"(",
"$",
"this",
"->",
"str",
")",
")",
";",
"}"
] | Returns true if the string is JSON, false otherwise.
@return bool Whether or not $str is JSON | [
"Returns",
"true",
"if",
"the",
"string",
"is",
"JSON",
"false",
"otherwise",
"."
] | 1e292670639a950ecf561b545462427512950c74 | https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L1052-L1058 | train |
dankempster/axstrad-filesystem | Scanner/BaseIteratorScanner.php | BaseIteratorScanner.setFileClassname | public function setFileClassname($classname = null)
{
if ($classname === null) {
$this->fileClass = null;
}
elseif ( ! class_exists($classname)) {
throw ClassDoesNotExistException::create($classname);
}
else {
$this->fileClass = (string) $classname;
}
return $this;
} | php | public function setFileClassname($classname = null)
{
if ($classname === null) {
$this->fileClass = null;
}
elseif ( ! class_exists($classname)) {
throw ClassDoesNotExistException::create($classname);
}
else {
$this->fileClass = (string) $classname;
}
return $this;
} | [
"public",
"function",
"setFileClassname",
"(",
"$",
"classname",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"classname",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"fileClass",
"=",
"null",
";",
"}",
"elseif",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"throw",
"ClassDoesNotExistException",
"::",
"create",
"(",
"$",
"classname",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fileClass",
"=",
"(",
"string",
")",
"$",
"classname",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set file classname
If set, an instance of the class will be created for each file during
iteration. It is that object that will be added to the FileBag.
@param null|string $classname The classname of the File objects to create
@return self
@see getFileClassname
@throws ClassDoesNotExistException If $classname does not exist. | [
"Set",
"file",
"classname"
] | f47e52fcf093dc64cf54bc5702100ea881d0b010 | https://github.com/dankempster/axstrad-filesystem/blob/f47e52fcf093dc64cf54bc5702100ea881d0b010/Scanner/BaseIteratorScanner.php#L65-L77 | train |
phpalchemy/phpalchemy | Alchemy/Kernel/Event/ControllerEvent.php | ControllerEvent.setController | public function setController($controller)
{
// controller must be a callable
if (!is_callable($controller)) {
throw new \LogicException(sprintf(
'The controller must be a callable (%s given).',
gettype($controller)
));
}
$this->controller = $controller;
} | php | public function setController($controller)
{
// controller must be a callable
if (!is_callable($controller)) {
throw new \LogicException(sprintf(
'The controller must be a callable (%s given).',
gettype($controller)
));
}
$this->controller = $controller;
} | [
"public",
"function",
"setController",
"(",
"$",
"controller",
")",
"{",
"// controller must be a callable",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"controller",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The controller must be a callable (%s given).'",
",",
"gettype",
"(",
"$",
"controller",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"controller",
"=",
"$",
"controller",
";",
"}"
] | Sets a controller
@param callable $controller | [
"Sets",
"a",
"controller"
] | 5b7e9b13acfda38c61b2da2639e8a56f298dc32e | https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Kernel/Event/ControllerEvent.php#L38-L49 | train |
gluephp/glue | src/Http/Request.php | Request.headers | public function headers($key = null, $fallback = null)
{
return $key
? $this->request->headers->get($key, $fallback)
: $this->request->headers;
} | php | public function headers($key = null, $fallback = null)
{
return $key
? $this->request->headers->get($key, $fallback)
: $this->request->headers;
} | [
"public",
"function",
"headers",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"return",
"$",
"key",
"?",
"$",
"this",
"->",
"request",
"->",
"headers",
"->",
"get",
"(",
"$",
"key",
",",
"$",
"fallback",
")",
":",
"$",
"this",
"->",
"request",
"->",
"headers",
";",
"}"
] | Get a request header value
@param string $key
@param mixed $fallback
@return mixed | [
"Get",
"a",
"request",
"header",
"value"
] | d54e0905dfe74d1c114c04f33fa89a60e2651562 | https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L104-L109 | train |
selikhovleonid/nadir | src/core/CtrlWrapper.php | CtrlWrapper.callActon | private function callActon($sName, array $aArgs)
{
if (empty($aArgs)) {
$this->ctrl->{$sName}();
} else {
$oMethod = new \ReflectionMethod($this->ctrl, $sName);
$oMethod->invokeArgs($this->ctrl, $aArgs);
}
} | php | private function callActon($sName, array $aArgs)
{
if (empty($aArgs)) {
$this->ctrl->{$sName}();
} else {
$oMethod = new \ReflectionMethod($this->ctrl, $sName);
$oMethod->invokeArgs($this->ctrl, $aArgs);
}
} | [
"private",
"function",
"callActon",
"(",
"$",
"sName",
",",
"array",
"$",
"aArgs",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"aArgs",
")",
")",
"{",
"$",
"this",
"->",
"ctrl",
"->",
"{",
"$",
"sName",
"}",
"(",
")",
";",
"}",
"else",
"{",
"$",
"oMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"this",
"->",
"ctrl",
",",
"$",
"sName",
")",
";",
"$",
"oMethod",
"->",
"invokeArgs",
"(",
"$",
"this",
"->",
"ctrl",
",",
"$",
"aArgs",
")",
";",
"}",
"}"
] | It calls the controller action with passage the parameters if necessary.
@param string $sName The action name of target controller.
@param array $aArgs The action parameters. | [
"It",
"calls",
"the",
"controller",
"action",
"with",
"passage",
"the",
"parameters",
"if",
"necessary",
"."
] | 47545fccd8516c8f0a20c02ba62f68269c7199da | https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/CtrlWrapper.php#L30-L38 | train |
selikhovleonid/nadir | src/core/CtrlWrapper.php | CtrlWrapper.processAuth | protected function processAuth($sName, array $aArgs)
{
if (class_exists('\extensions\core\Auth')) {
$oAuth = new \extensions\core\Auth($this->ctrl->getRequest());
$oAuth->run();
if ($oAuth->isValid()) {
$this->callActon($sName, $aArgs);
} else {
$oAuth->onFail();
}
} else {
$this->callActon($sName, $aArgs);
}
} | php | protected function processAuth($sName, array $aArgs)
{
if (class_exists('\extensions\core\Auth')) {
$oAuth = new \extensions\core\Auth($this->ctrl->getRequest());
$oAuth->run();
if ($oAuth->isValid()) {
$this->callActon($sName, $aArgs);
} else {
$oAuth->onFail();
}
} else {
$this->callActon($sName, $aArgs);
}
} | [
"protected",
"function",
"processAuth",
"(",
"$",
"sName",
",",
"array",
"$",
"aArgs",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'\\extensions\\core\\Auth'",
")",
")",
"{",
"$",
"oAuth",
"=",
"new",
"\\",
"extensions",
"\\",
"core",
"\\",
"Auth",
"(",
"$",
"this",
"->",
"ctrl",
"->",
"getRequest",
"(",
")",
")",
";",
"$",
"oAuth",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"oAuth",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"callActon",
"(",
"$",
"sName",
",",
"$",
"aArgs",
")",
";",
"}",
"else",
"{",
"$",
"oAuth",
"->",
"onFail",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"callActon",
"(",
"$",
"sName",
",",
"$",
"aArgs",
")",
";",
"}",
"}"
] | The method calls user's auth checking, on successful complition of which
it invokes the target controller and the onFail method of Auth class in
other case.
@param string $sName The action name.
@param mixed[] $aArgs The action parameters. | [
"The",
"method",
"calls",
"user",
"s",
"auth",
"checking",
"on",
"successful",
"complition",
"of",
"which",
"it",
"invokes",
"the",
"target",
"controller",
"and",
"the",
"onFail",
"method",
"of",
"Auth",
"class",
"in",
"other",
"case",
"."
] | 47545fccd8516c8f0a20c02ba62f68269c7199da | https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/CtrlWrapper.php#L47-L60 | train |
deweller/php-cliopts | src/CLIOpts/Values/ArgumentValues.php | ArgumentValues.getValidator | public function getValidator() {
if (!isset($this->validator)) {
$this->validator = new ArgsValidator($this->arguments_spec, $this->parsed_args);
}
return $this->validator;
} | php | public function getValidator() {
if (!isset($this->validator)) {
$this->validator = new ArgsValidator($this->arguments_spec, $this->parsed_args);
}
return $this->validator;
} | [
"public",
"function",
"getValidator",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"validator",
")",
")",
"{",
"$",
"this",
"->",
"validator",
"=",
"new",
"ArgsValidator",
"(",
"$",
"this",
"->",
"arguments_spec",
",",
"$",
"this",
"->",
"parsed_args",
")",
";",
"}",
"return",
"$",
"this",
"->",
"validator",
";",
"}"
] | get the validator for these values
@return ArgsValidator the validator | [
"get",
"the",
"validator",
"for",
"these",
"values"
] | 1923f3a7ad24062c6279c725579ff3af15141dec | https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L80-L85 | train |
deweller/php-cliopts | src/CLIOpts/Values/ArgumentValues.php | ArgumentValues.offsetGet | public function offsetGet($key) {
$resolved_key = $this->arguments_spec->normalizeOptionName($key);
if ($resolved_key === null) {
if (isset($this->merged_arg_values[$key])) {
return parent::offsetGet($key);
}
}
if (isset($this->merged_arg_values[$resolved_key])) {
return parent::offsetGet($resolved_key);
}
return null;
} | php | public function offsetGet($key) {
$resolved_key = $this->arguments_spec->normalizeOptionName($key);
if ($resolved_key === null) {
if (isset($this->merged_arg_values[$key])) {
return parent::offsetGet($key);
}
}
if (isset($this->merged_arg_values[$resolved_key])) {
return parent::offsetGet($resolved_key);
}
return null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"key",
")",
"{",
"$",
"resolved_key",
"=",
"$",
"this",
"->",
"arguments_spec",
"->",
"normalizeOptionName",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"resolved_key",
"===",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"merged_arg_values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"parent",
"::",
"offsetGet",
"(",
"$",
"key",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"merged_arg_values",
"[",
"$",
"resolved_key",
"]",
")",
")",
"{",
"return",
"parent",
"::",
"offsetGet",
"(",
"$",
"resolved_key",
")",
";",
"}",
"return",
"null",
";",
"}"
] | returns the argument or option value
@param string $key argument name or long option name
@return string argument or option value | [
"returns",
"the",
"argument",
"or",
"option",
"value"
] | 1923f3a7ad24062c6279c725579ff3af15141dec | https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L96-L110 | train |
deweller/php-cliopts | src/CLIOpts/Values/ArgumentValues.php | ArgumentValues.offsetExists | public function offsetExists($key) {
$resolved_key = $this->arguments_spec->normalizeOptionName($key);
if ($resolved_key === null) {
return isset($this->merged_arg_values[$key]);
}
return isset($this->merged_arg_values[$resolved_key]);
} | php | public function offsetExists($key) {
$resolved_key = $this->arguments_spec->normalizeOptionName($key);
if ($resolved_key === null) {
return isset($this->merged_arg_values[$key]);
}
return isset($this->merged_arg_values[$resolved_key]);
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"key",
")",
"{",
"$",
"resolved_key",
"=",
"$",
"this",
"->",
"arguments_spec",
"->",
"normalizeOptionName",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"resolved_key",
"===",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"merged_arg_values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"merged_arg_values",
"[",
"$",
"resolved_key",
"]",
")",
";",
"}"
] | returns true if the argument or option value exists
@param string $key argument name or long option name
@return bool true if the argument or option value exists | [
"returns",
"true",
"if",
"the",
"argument",
"or",
"option",
"value",
"exists"
] | 1923f3a7ad24062c6279c725579ff3af15141dec | https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L120-L127 | train |
deweller/php-cliopts | src/CLIOpts/Values/ArgumentValues.php | ArgumentValues.extractAllLongOpts | protected function extractAllLongOpts(ArgumentsSpec $arguments_spec, $parsed_args) {
$long_opts = array();
foreach ($parsed_args['options'] as $option_name => $value) {
if ($long_option_name = $arguments_spec->normalizeOptionName($option_name)) {
$long_opts[$long_option_name] = $value;
}
}
return $long_opts;
} | php | protected function extractAllLongOpts(ArgumentsSpec $arguments_spec, $parsed_args) {
$long_opts = array();
foreach ($parsed_args['options'] as $option_name => $value) {
if ($long_option_name = $arguments_spec->normalizeOptionName($option_name)) {
$long_opts[$long_option_name] = $value;
}
}
return $long_opts;
} | [
"protected",
"function",
"extractAllLongOpts",
"(",
"ArgumentsSpec",
"$",
"arguments_spec",
",",
"$",
"parsed_args",
")",
"{",
"$",
"long_opts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parsed_args",
"[",
"'options'",
"]",
"as",
"$",
"option_name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"long_option_name",
"=",
"$",
"arguments_spec",
"->",
"normalizeOptionName",
"(",
"$",
"option_name",
")",
")",
"{",
"$",
"long_opts",
"[",
"$",
"long_option_name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"long_opts",
";",
"}"
] | builds argument values by long option name
@param ArgumentsSpec $arguments_spec The arguments specification
@param array $parsed_args data parsed by the ArgumentsParser
@return array argument values by long option name | [
"builds",
"argument",
"values",
"by",
"long",
"option",
"name"
] | 1923f3a7ad24062c6279c725579ff3af15141dec | https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L152-L162 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Config/Registry.php | Radial_Core_Model_Config_Registry._getStoreConfigValue | protected function _getStoreConfigValue($configKey, $store, $asFlag)
{
foreach ($this->_configModels as $configModel) {
if ($configModel->hasKey($configKey)) {
$configMethod = $asFlag ? 'getStoreConfigFlag' : 'getStoreConfig';
return Mage::$configMethod($configModel->getPathForKey($configKey), $store);
}
}
throw Mage::exception('Mage_Core', "Configuration path specified by '$configKey' was not found.");
} | php | protected function _getStoreConfigValue($configKey, $store, $asFlag)
{
foreach ($this->_configModels as $configModel) {
if ($configModel->hasKey($configKey)) {
$configMethod = $asFlag ? 'getStoreConfigFlag' : 'getStoreConfig';
return Mage::$configMethod($configModel->getPathForKey($configKey), $store);
}
}
throw Mage::exception('Mage_Core', "Configuration path specified by '$configKey' was not found.");
} | [
"protected",
"function",
"_getStoreConfigValue",
"(",
"$",
"configKey",
",",
"$",
"store",
",",
"$",
"asFlag",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_configModels",
"as",
"$",
"configModel",
")",
"{",
"if",
"(",
"$",
"configModel",
"->",
"hasKey",
"(",
"$",
"configKey",
")",
")",
"{",
"$",
"configMethod",
"=",
"$",
"asFlag",
"?",
"'getStoreConfigFlag'",
":",
"'getStoreConfig'",
";",
"return",
"Mage",
"::",
"$",
"configMethod",
"(",
"$",
"configModel",
"->",
"getPathForKey",
"(",
"$",
"configKey",
")",
",",
"$",
"store",
")",
";",
"}",
"}",
"throw",
"Mage",
"::",
"exception",
"(",
"'Mage_Core'",
",",
"\"Configuration path specified by '$configKey' was not found.\"",
")",
";",
"}"
] | Search through registered config models for one that knows about the key
and get the actual config path from it for the lookup.
@param string $configKey
@param null|string|bool|int|Mage_Core_Model_Store $store
@param bool $asFlag
@throws Mage_Core_Exception if the config path is not found.
@return string|bool | [
"Search",
"through",
"registered",
"config",
"models",
"for",
"one",
"that",
"knows",
"about",
"the",
"key",
"and",
"get",
"the",
"actual",
"config",
"path",
"from",
"it",
"for",
"the",
"lookup",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L77-L86 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Config/Registry.php | Radial_Core_Model_Config_Registry.getConfigFlag | public function getConfigFlag($configKey, $store = null)
{
// if a value is given store, use it, even if it is null/false/empty string/whatever
$store = count(func_get_args()) > 1 ? $store : $this->getStore();
return $this->_getStoreConfigValue($configKey, $store, true);
} | php | public function getConfigFlag($configKey, $store = null)
{
// if a value is given store, use it, even if it is null/false/empty string/whatever
$store = count(func_get_args()) > 1 ? $store : $this->getStore();
return $this->_getStoreConfigValue($configKey, $store, true);
} | [
"public",
"function",
"getConfigFlag",
"(",
"$",
"configKey",
",",
"$",
"store",
"=",
"null",
")",
"{",
"// if a value is given store, use it, even if it is null/false/empty string/whatever",
"$",
"store",
"=",
"count",
"(",
"func_get_args",
"(",
")",
")",
">",
"1",
"?",
"$",
"store",
":",
"$",
"this",
"->",
"getStore",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_getStoreConfigValue",
"(",
"$",
"configKey",
",",
"$",
"store",
",",
"true",
")",
";",
"}"
] | Get the configuration value represented by the given configKey
@param string $configKey
@param null|string|bool|int|Mage_Core_Model_Store $store
@return string | [
"Get",
"the",
"configuration",
"value",
"represented",
"by",
"the",
"given",
"configKey"
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L94-L99 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Config/Registry.php | Radial_Core_Model_Config_Registry.getConfig | public function getConfig($configKey, $store = null)
{
// if a value is given store, use it, even if it is null/false/empty string/whatever
$store = count(func_get_args()) > 1 ? $store : $this->getStore();
return $this->_getStoreConfigValue($configKey, $store, false);
} | php | public function getConfig($configKey, $store = null)
{
// if a value is given store, use it, even if it is null/false/empty string/whatever
$store = count(func_get_args()) > 1 ? $store : $this->getStore();
return $this->_getStoreConfigValue($configKey, $store, false);
} | [
"public",
"function",
"getConfig",
"(",
"$",
"configKey",
",",
"$",
"store",
"=",
"null",
")",
"{",
"// if a value is given store, use it, even if it is null/false/empty string/whatever",
"$",
"store",
"=",
"count",
"(",
"func_get_args",
"(",
")",
")",
">",
"1",
"?",
"$",
"store",
":",
"$",
"this",
"->",
"getStore",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_getStoreConfigValue",
"(",
"$",
"configKey",
",",
"$",
"store",
",",
"false",
")",
";",
"}"
] | Get the configuration flag value represented by the given configKey
@param string $configKey
@param null|string|bool|int|Mage_Core_Model_Store $store
@return bool | [
"Get",
"the",
"configuration",
"flag",
"value",
"represented",
"by",
"the",
"given",
"configKey"
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L107-L112 | train |
Phpillip/phpillip | src/Console/Command/BuildCommand.php | BuildCommand.dump | protected function dump(Route $route, $name)
{
if (!$route->isVisible()) {
return;
}
if (!in_array('GET', $route->getMethods())) {
throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name));
}
if ($route->hasContent()) {
if ($route->isList()) {
if ($route->isPaginated()) {
$this->buildPaginatedRoute($route, $name);
} else {
$this->buildListRoute($route, $name);
}
} else {
$this->buildContentRoute($route, $name);
}
} else {
$this->logger->log(sprintf('Building route <comment>%s</comment>', $name));
$this->builder->build($route, $name);
}
} | php | protected function dump(Route $route, $name)
{
if (!$route->isVisible()) {
return;
}
if (!in_array('GET', $route->getMethods())) {
throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name));
}
if ($route->hasContent()) {
if ($route->isList()) {
if ($route->isPaginated()) {
$this->buildPaginatedRoute($route, $name);
} else {
$this->buildListRoute($route, $name);
}
} else {
$this->buildContentRoute($route, $name);
}
} else {
$this->logger->log(sprintf('Building route <comment>%s</comment>', $name));
$this->builder->build($route, $name);
}
} | [
"protected",
"function",
"dump",
"(",
"Route",
"$",
"route",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"route",
"->",
"isVisible",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'GET'",
",",
"$",
"route",
"->",
"getMethods",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Only GET mehtod supported, \"%s\" given.'",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"route",
"->",
"hasContent",
"(",
")",
")",
"{",
"if",
"(",
"$",
"route",
"->",
"isList",
"(",
")",
")",
"{",
"if",
"(",
"$",
"route",
"->",
"isPaginated",
"(",
")",
")",
"{",
"$",
"this",
"->",
"buildPaginatedRoute",
"(",
"$",
"route",
",",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"buildListRoute",
"(",
"$",
"route",
",",
"$",
"name",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"buildContentRoute",
"(",
"$",
"route",
",",
"$",
"name",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"sprintf",
"(",
"'Building route <comment>%s</comment>'",
",",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"route",
",",
"$",
"name",
")",
";",
"}",
"}"
] | Dump route content to destination file
@param Route $route
@param string $name | [
"Dump",
"route",
"content",
"to",
"destination",
"file"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L142-L166 | train |
Phpillip/phpillip | src/Console/Command/BuildCommand.php | BuildCommand.buildPaginatedRoute | protected function buildPaginatedRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$paginator = new Paginator($contents, $route->getPerPage());
$this->logger->log(sprintf(
'Building route <comment>%s</comment> for <info>%s</info> pages',
$name,
$paginator->count()
));
$this->logger->getProgress($paginator->count());
$this->logger->start();
foreach ($paginator as $index => $contents) {
$this->builder->build($route, $name, ['page' => $index + 1]);
$this->logger->advance();
}
$this->logger->finish();
} | php | protected function buildPaginatedRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$paginator = new Paginator($contents, $route->getPerPage());
$this->logger->log(sprintf(
'Building route <comment>%s</comment> for <info>%s</info> pages',
$name,
$paginator->count()
));
$this->logger->getProgress($paginator->count());
$this->logger->start();
foreach ($paginator as $index => $contents) {
$this->builder->build($route, $name, ['page' => $index + 1]);
$this->logger->advance();
}
$this->logger->finish();
} | [
"protected",
"function",
"buildPaginatedRoute",
"(",
"Route",
"$",
"route",
",",
"$",
"name",
")",
"{",
"$",
"contentType",
"=",
"$",
"route",
"->",
"getContent",
"(",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"app",
"[",
"'content_repository'",
"]",
"->",
"listContents",
"(",
"$",
"contentType",
")",
";",
"$",
"paginator",
"=",
"new",
"Paginator",
"(",
"$",
"contents",
",",
"$",
"route",
"->",
"getPerPage",
"(",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"sprintf",
"(",
"'Building route <comment>%s</comment> for <info>%s</info> pages'",
",",
"$",
"name",
",",
"$",
"paginator",
"->",
"count",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"getProgress",
"(",
"$",
"paginator",
"->",
"count",
"(",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"start",
"(",
")",
";",
"foreach",
"(",
"$",
"paginator",
"as",
"$",
"index",
"=>",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"route",
",",
"$",
"name",
",",
"[",
"'page'",
"=>",
"$",
"index",
"+",
"1",
"]",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"advance",
"(",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"finish",
"(",
")",
";",
"}"
] | Build paginated route
@param Route $route
@param string $name | [
"Build",
"paginated",
"route"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L174-L194 | train |
Phpillip/phpillip | src/Console/Command/BuildCommand.php | BuildCommand.buildListRoute | protected function buildListRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$this->logger->log(sprintf(
'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>',
$name,
count($contents),
$contentType
));
$this->builder->build($route, $name);
} | php | protected function buildListRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$this->logger->log(sprintf(
'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>',
$name,
count($contents),
$contentType
));
$this->builder->build($route, $name);
} | [
"protected",
"function",
"buildListRoute",
"(",
"Route",
"$",
"route",
",",
"$",
"name",
")",
"{",
"$",
"contentType",
"=",
"$",
"route",
"->",
"getContent",
"(",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"app",
"[",
"'content_repository'",
"]",
"->",
"listContents",
"(",
"$",
"contentType",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"sprintf",
"(",
"'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>'",
",",
"$",
"name",
",",
"count",
"(",
"$",
"contents",
")",
",",
"$",
"contentType",
")",
")",
";",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"route",
",",
"$",
"name",
")",
";",
"}"
] | Build list route
@param Route $route
@param string $name | [
"Build",
"list",
"route"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L202-L214 | train |
Phpillip/phpillip | src/Console/Command/BuildCommand.php | BuildCommand.buildContentRoute | protected function buildContentRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$this->logger->log(sprintf(
'Building route <comment>%s</comment> for <info>%s</info> <comment>%s(s)</comment>',
$name,
count($contents),
$route->getContent()
));
$this->logger->getProgress(count($contents));
$this->logger->start();
foreach ($contents as $content) {
$this->builder->build($route, $name, [$contentType => $content]);
$this->logger->advance();
}
$this->logger->finish();
} | php | protected function buildContentRoute(Route $route, $name)
{
$contentType = $route->getContent();
$contents = $this->app['content_repository']->listContents($contentType);
$this->logger->log(sprintf(
'Building route <comment>%s</comment> for <info>%s</info> <comment>%s(s)</comment>',
$name,
count($contents),
$route->getContent()
));
$this->logger->getProgress(count($contents));
$this->logger->start();
foreach ($contents as $content) {
$this->builder->build($route, $name, [$contentType => $content]);
$this->logger->advance();
}
$this->logger->finish();
} | [
"protected",
"function",
"buildContentRoute",
"(",
"Route",
"$",
"route",
",",
"$",
"name",
")",
"{",
"$",
"contentType",
"=",
"$",
"route",
"->",
"getContent",
"(",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"app",
"[",
"'content_repository'",
"]",
"->",
"listContents",
"(",
"$",
"contentType",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"sprintf",
"(",
"'Building route <comment>%s</comment> for <info>%s</info> <comment>%s(s)</comment>'",
",",
"$",
"name",
",",
"count",
"(",
"$",
"contents",
")",
",",
"$",
"route",
"->",
"getContent",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"getProgress",
"(",
"count",
"(",
"$",
"contents",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"start",
"(",
")",
";",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"route",
",",
"$",
"name",
",",
"[",
"$",
"contentType",
"=>",
"$",
"content",
"]",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"advance",
"(",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"finish",
"(",
")",
";",
"}"
] | Build content route
@param Route $route
@param string $name | [
"Build",
"content",
"route"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L222-L242 | train |
Phpillip/phpillip | src/Console/Command/BuildCommand.php | BuildCommand.buildSitemap | protected function buildSitemap(Sitemap $sitemap)
{
$content = $this->app['twig']->render('@phpillip/sitemap.xml.twig', ['sitemap' => $sitemap]);
$this->builder->write('/', $content, 'xml', 'sitemap');
} | php | protected function buildSitemap(Sitemap $sitemap)
{
$content = $this->app['twig']->render('@phpillip/sitemap.xml.twig', ['sitemap' => $sitemap]);
$this->builder->write('/', $content, 'xml', 'sitemap');
} | [
"protected",
"function",
"buildSitemap",
"(",
"Sitemap",
"$",
"sitemap",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"app",
"[",
"'twig'",
"]",
"->",
"render",
"(",
"'@phpillip/sitemap.xml.twig'",
",",
"[",
"'sitemap'",
"=>",
"$",
"sitemap",
"]",
")",
";",
"$",
"this",
"->",
"builder",
"->",
"write",
"(",
"'/'",
",",
"$",
"content",
",",
"'xml'",
",",
"'sitemap'",
")",
";",
"}"
] | Build sitemap xml file from Sitemap
@param Sitemap $sitemap | [
"Build",
"sitemap",
"xml",
"file",
"from",
"Sitemap"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L249-L253 | train |
keeko/framework | src/security/AuthManager.php | AuthManager.authCookie | private function authCookie(Request $request) {
if ($request->cookies->has(self::COOKIE_TOKEN_NAME)) {
$token = $request->cookies->get(self::COOKIE_TOKEN_NAME);
return $this->authToken($token);
}
return null;
} | php | private function authCookie(Request $request) {
if ($request->cookies->has(self::COOKIE_TOKEN_NAME)) {
$token = $request->cookies->get(self::COOKIE_TOKEN_NAME);
return $this->authToken($token);
}
return null;
} | [
"private",
"function",
"authCookie",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"cookies",
"->",
"has",
"(",
"self",
"::",
"COOKIE_TOKEN_NAME",
")",
")",
"{",
"$",
"token",
"=",
"$",
"request",
"->",
"cookies",
"->",
"get",
"(",
"self",
"::",
"COOKIE_TOKEN_NAME",
")",
";",
"return",
"$",
"this",
"->",
"authToken",
"(",
"$",
"token",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Authenticates a user by a token in a cookie
@param Request $request
@return Session|null | [
"Authenticates",
"a",
"user",
"by",
"a",
"token",
"in",
"a",
"cookie"
] | a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac | https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L71-L77 | train |
keeko/framework | src/security/AuthManager.php | AuthManager.authHeader | private function authHeader(Request $request) {
if ($request->headers->has('authorization')) {
$auth = $request->headers->get('authorization');
if (!empty($auth)) {
list(, $token) = explode(' ', $auth);
if (empty($token)) {
return null;
}
return $this->authToken($token);
}
}
return null;
} | php | private function authHeader(Request $request) {
if ($request->headers->has('authorization')) {
$auth = $request->headers->get('authorization');
if (!empty($auth)) {
list(, $token) = explode(' ', $auth);
if (empty($token)) {
return null;
}
return $this->authToken($token);
}
}
return null;
} | [
"private",
"function",
"authHeader",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"'authorization'",
")",
")",
"{",
"$",
"auth",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'authorization'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"auth",
")",
")",
"{",
"list",
"(",
",",
"$",
"token",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"auth",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"authToken",
"(",
"$",
"token",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Authenticates a user by an authorization header
@param Request $request
@return Session|null | [
"Authenticates",
"a",
"user",
"by",
"an",
"authorization",
"header"
] | a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac | https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L85-L97 | train |
keeko/framework | src/security/AuthManager.php | AuthManager.authBasic | private function authBasic(Request $request) {
$user = $this->findUser($request->getUser());
if ($user !== null && $this->verifyUser($user, $request->getPassword())) {
$session = $this->findSession($user);
if ($session === null) {
$session = $this->createSession($user);
}
$this->authenticated = true;
return $session;
}
return null;
} | php | private function authBasic(Request $request) {
$user = $this->findUser($request->getUser());
if ($user !== null && $this->verifyUser($user, $request->getPassword())) {
$session = $this->findSession($user);
if ($session === null) {
$session = $this->createSession($user);
}
$this->authenticated = true;
return $session;
}
return null;
} | [
"private",
"function",
"authBasic",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findUser",
"(",
"$",
"request",
"->",
"getUser",
"(",
")",
")",
";",
"if",
"(",
"$",
"user",
"!==",
"null",
"&&",
"$",
"this",
"->",
"verifyUser",
"(",
"$",
"user",
",",
"$",
"request",
"->",
"getPassword",
"(",
")",
")",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"findSession",
"(",
"$",
"user",
")",
";",
"if",
"(",
"$",
"session",
"===",
"null",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"createSession",
"(",
"$",
"user",
")",
";",
"}",
"$",
"this",
"->",
"authenticated",
"=",
"true",
";",
"return",
"$",
"session",
";",
"}",
"return",
"null",
";",
"}"
] | Authenticates a user by basic authentication
@param Request $request
@return Session|null | [
"Authenticates",
"a",
"user",
"by",
"basic",
"authentication"
] | a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac | https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L115-L127 | train |
valu-digital/valuso | src/ValuSo/Queue/Job/ServiceJob.php | ServiceJob.resolveIdentity | protected function resolveIdentity($username, $accountId)
{
$identitySeed = $this->getServiceBroker()
->service('User')
->resolveIdentity($username);
$accountIds = isset($identitySeed['accountIds']) ? $identitySeed['accountIds'] : [];
if (in_array($accountId, $accountIds)) {
$identitySeed['account'] = $accountId;
$identitySeed['accountId'] = $accountId;
}
if ($identitySeed) {
return $this->prepareIdentity($identitySeed);
} else {
return false;
}
} | php | protected function resolveIdentity($username, $accountId)
{
$identitySeed = $this->getServiceBroker()
->service('User')
->resolveIdentity($username);
$accountIds = isset($identitySeed['accountIds']) ? $identitySeed['accountIds'] : [];
if (in_array($accountId, $accountIds)) {
$identitySeed['account'] = $accountId;
$identitySeed['accountId'] = $accountId;
}
if ($identitySeed) {
return $this->prepareIdentity($identitySeed);
} else {
return false;
}
} | [
"protected",
"function",
"resolveIdentity",
"(",
"$",
"username",
",",
"$",
"accountId",
")",
"{",
"$",
"identitySeed",
"=",
"$",
"this",
"->",
"getServiceBroker",
"(",
")",
"->",
"service",
"(",
"'User'",
")",
"->",
"resolveIdentity",
"(",
"$",
"username",
")",
";",
"$",
"accountIds",
"=",
"isset",
"(",
"$",
"identitySeed",
"[",
"'accountIds'",
"]",
")",
"?",
"$",
"identitySeed",
"[",
"'accountIds'",
"]",
":",
"[",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"accountId",
",",
"$",
"accountIds",
")",
")",
"{",
"$",
"identitySeed",
"[",
"'account'",
"]",
"=",
"$",
"accountId",
";",
"$",
"identitySeed",
"[",
"'accountId'",
"]",
"=",
"$",
"accountId",
";",
"}",
"if",
"(",
"$",
"identitySeed",
")",
"{",
"return",
"$",
"this",
"->",
"prepareIdentity",
"(",
"$",
"identitySeed",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Resolve identity based on username
@param string $username
@param string $accountId
@return boolean | [
"Resolve",
"identity",
"based",
"on",
"username"
] | c96bed0f6bd21551822334fe6cfe913a7436dd17 | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L154-L172 | train |
valu-digital/valuso | src/ValuSo/Queue/Job/ServiceJob.php | ServiceJob.prepareIdentity | protected function prepareIdentity($identitySeed)
{
$this->getServiceBroker()
->service('Identity')
->setIdentity($identitySeed);
$identity = $this->getServiceBroker()
->service('Identity')
->getIdentity();
$this->getServiceBroker()
->setDefaultIdentity($identity);
return $identity;
} | php | protected function prepareIdentity($identitySeed)
{
$this->getServiceBroker()
->service('Identity')
->setIdentity($identitySeed);
$identity = $this->getServiceBroker()
->service('Identity')
->getIdentity();
$this->getServiceBroker()
->setDefaultIdentity($identity);
return $identity;
} | [
"protected",
"function",
"prepareIdentity",
"(",
"$",
"identitySeed",
")",
"{",
"$",
"this",
"->",
"getServiceBroker",
"(",
")",
"->",
"service",
"(",
"'Identity'",
")",
"->",
"setIdentity",
"(",
"$",
"identitySeed",
")",
";",
"$",
"identity",
"=",
"$",
"this",
"->",
"getServiceBroker",
"(",
")",
"->",
"service",
"(",
"'Identity'",
")",
"->",
"getIdentity",
"(",
")",
";",
"$",
"this",
"->",
"getServiceBroker",
"(",
")",
"->",
"setDefaultIdentity",
"(",
"$",
"identity",
")",
";",
"return",
"$",
"identity",
";",
"}"
] | Build new identity from identity seed
@param array $identitySeed | [
"Build",
"new",
"identity",
"from",
"identity",
"seed"
] | c96bed0f6bd21551822334fe6cfe913a7436dd17 | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L179-L193 | train |
zbox/UnifiedPush | src/Zbox/UnifiedPush/NotificationService/NotificationServices.php | NotificationServices.validateServiceName | public static function validateServiceName($serviceName)
{
if (!in_array($serviceName, self::getAvailableServices())) {
throw new DomainException(sprintf("Notification service '%s' is not supported.", $serviceName));
}
return $serviceName;
} | php | public static function validateServiceName($serviceName)
{
if (!in_array($serviceName, self::getAvailableServices())) {
throw new DomainException(sprintf("Notification service '%s' is not supported.", $serviceName));
}
return $serviceName;
} | [
"public",
"static",
"function",
"validateServiceName",
"(",
"$",
"serviceName",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"serviceName",
",",
"self",
"::",
"getAvailableServices",
"(",
")",
")",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"sprintf",
"(",
"\"Notification service '%s' is not supported.\"",
",",
"$",
"serviceName",
")",
")",
";",
"}",
"return",
"$",
"serviceName",
";",
"}"
] | Checks if notification service is supported
@param string $serviceName
@return string
@throws DomainException | [
"Checks",
"if",
"notification",
"service",
"is",
"supported"
] | 47da2d0577b18ac709cd947c68541014001e1866 | https://github.com/zbox/UnifiedPush/blob/47da2d0577b18ac709cd947c68541014001e1866/src/Zbox/UnifiedPush/NotificationService/NotificationServices.php#L50-L56 | train |
denkfabrik-neueMedien/silverstripe-siteinfo | src/extension/SiteInfo.php | SiteInfo._typesNice | protected function _typesNice() {
$enumValues = singleton("SilverStripe\SiteConfig\SiteConfig")->dbObject("Type")->enumValues();
$values = array();
foreach($enumValues as $enumValue) {
$values[$enumValue] = _t("SiteInfo.TYPE" . strtoupper($enumValue), $enumValue);
}
return $values;
} | php | protected function _typesNice() {
$enumValues = singleton("SilverStripe\SiteConfig\SiteConfig")->dbObject("Type")->enumValues();
$values = array();
foreach($enumValues as $enumValue) {
$values[$enumValue] = _t("SiteInfo.TYPE" . strtoupper($enumValue), $enumValue);
}
return $values;
} | [
"protected",
"function",
"_typesNice",
"(",
")",
"{",
"$",
"enumValues",
"=",
"singleton",
"(",
"\"SilverStripe\\SiteConfig\\SiteConfig\"",
")",
"->",
"dbObject",
"(",
"\"Type\"",
")",
"->",
"enumValues",
"(",
")",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"enumValues",
"as",
"$",
"enumValue",
")",
"{",
"$",
"values",
"[",
"$",
"enumValue",
"]",
"=",
"_t",
"(",
"\"SiteInfo.TYPE\"",
".",
"strtoupper",
"(",
"$",
"enumValue",
")",
",",
"$",
"enumValue",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Add translated labels for the dropdown field
@return array | [
"Add",
"translated",
"labels",
"for",
"the",
"dropdown",
"field"
] | cd59ea0cf5c13678ff8efd93028d35c726670c25 | https://github.com/denkfabrik-neueMedien/silverstripe-siteinfo/blob/cd59ea0cf5c13678ff8efd93028d35c726670c25/src/extension/SiteInfo.php#L214-L224 | train |
luoxiaojun1992/lb_framework | components/db/mysql/ActiveRecord.php | ActiveRecord.incrementByPk | public function incrementByPk($primary_key, $keys, $step = 1)
{
if ($this->is_single) {
return $this->incrementOrDecrementByPk($primary_key, $keys, $step);
}
return false;
} | php | public function incrementByPk($primary_key, $keys, $step = 1)
{
if ($this->is_single) {
return $this->incrementOrDecrementByPk($primary_key, $keys, $step);
}
return false;
} | [
"public",
"function",
"incrementByPk",
"(",
"$",
"primary_key",
",",
"$",
"keys",
",",
"$",
"step",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_single",
")",
"{",
"return",
"$",
"this",
"->",
"incrementOrDecrementByPk",
"(",
"$",
"primary_key",
",",
"$",
"keys",
",",
"$",
"step",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Increase key or keys by primary key
@param $primary_key
@param $keys
@param int $step
@return bool | [
"Increase",
"key",
"or",
"keys",
"by",
"primary",
"key"
] | 12a865729e7738d7d1e07371ad7203243c4571fa | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L501-L507 | train |
luoxiaojun1992/lb_framework | components/db/mysql/ActiveRecord.php | ActiveRecord.decrementByPk | public function decrementByPk($primary_key, $keys, $step = 1)
{
if ($this->is_single) {
return $this->incrementOrDecrementByPk($primary_key, $keys, $step, self::MINUS_NOTIFICATION);
}
return false;
} | php | public function decrementByPk($primary_key, $keys, $step = 1)
{
if ($this->is_single) {
return $this->incrementOrDecrementByPk($primary_key, $keys, $step, self::MINUS_NOTIFICATION);
}
return false;
} | [
"public",
"function",
"decrementByPk",
"(",
"$",
"primary_key",
",",
"$",
"keys",
",",
"$",
"step",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_single",
")",
"{",
"return",
"$",
"this",
"->",
"incrementOrDecrementByPk",
"(",
"$",
"primary_key",
",",
"$",
"keys",
",",
"$",
"step",
",",
"self",
"::",
"MINUS_NOTIFICATION",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Decrease key or keys by primary key
@param $primary_key
@param $keys
@param int $step
@return bool | [
"Decrease",
"key",
"or",
"keys",
"by",
"primary",
"key"
] | 12a865729e7738d7d1e07371ad7203243c4571fa | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L517-L523 | train |
luoxiaojun1992/lb_framework | components/db/mysql/ActiveRecord.php | ActiveRecord.incrementOrDecrementByPk | public function incrementOrDecrementByPk($primary_key, $keys, $steps = 1, $op = self::PLUS_NOTIFICATION)
{
if ($this->is_single) {
$values = [];
if (is_array($keys)) {
foreach ($keys as $k => $key) {
if (is_array($steps) && isset($steps[$k])) {
$values[$key] = [$op => $steps[$k]];
} else {
$values[$key] = [$op => $steps];
}
}
} else {
$values[$keys] = [$op => $steps];
}
return Dao::component()
->where(
[
$this->_primary_key => $primary_key,
]
)
->update(static::TABLE_NAME, $values);
}
return false;
} | php | public function incrementOrDecrementByPk($primary_key, $keys, $steps = 1, $op = self::PLUS_NOTIFICATION)
{
if ($this->is_single) {
$values = [];
if (is_array($keys)) {
foreach ($keys as $k => $key) {
if (is_array($steps) && isset($steps[$k])) {
$values[$key] = [$op => $steps[$k]];
} else {
$values[$key] = [$op => $steps];
}
}
} else {
$values[$keys] = [$op => $steps];
}
return Dao::component()
->where(
[
$this->_primary_key => $primary_key,
]
)
->update(static::TABLE_NAME, $values);
}
return false;
} | [
"public",
"function",
"incrementOrDecrementByPk",
"(",
"$",
"primary_key",
",",
"$",
"keys",
",",
"$",
"steps",
"=",
"1",
",",
"$",
"op",
"=",
"self",
"::",
"PLUS_NOTIFICATION",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_single",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"keys",
")",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"k",
"=>",
"$",
"key",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"steps",
")",
"&&",
"isset",
"(",
"$",
"steps",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"[",
"$",
"op",
"=>",
"$",
"steps",
"[",
"$",
"k",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"[",
"$",
"op",
"=>",
"$",
"steps",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"values",
"[",
"$",
"keys",
"]",
"=",
"[",
"$",
"op",
"=>",
"$",
"steps",
"]",
";",
"}",
"return",
"Dao",
"::",
"component",
"(",
")",
"->",
"where",
"(",
"[",
"$",
"this",
"->",
"_primary_key",
"=>",
"$",
"primary_key",
",",
"]",
")",
"->",
"update",
"(",
"static",
"::",
"TABLE_NAME",
",",
"$",
"values",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Increase or decrease key or keys by primary key
@param $primary_key
@param $keys
@param int $steps
@param string $op
@return bool | [
"Increase",
"or",
"decrease",
"key",
"or",
"keys",
"by",
"primary",
"key"
] | 12a865729e7738d7d1e07371ad7203243c4571fa | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L534-L559 | train |
nasumilu/geometry | src/Operation/AbstractLinearReferenceOpSubscriber.php | AbstractLinearReferenceOpSubscriber.locateAlong | public function locateAlong(LinearReferenceOpEvent $evt) {
$geometry = $evt->getGeometry();
$this->validGeometry($geometry);
$mValue = $evt['mValue'];
$offset = $evt['offset'];
try {
$results = $this->getLocateAlong($geometry, $mValue, $offset);
$evt->setResults($results, true);
} catch (OperationError $error) {
$evt->addError($error);
}
} | php | public function locateAlong(LinearReferenceOpEvent $evt) {
$geometry = $evt->getGeometry();
$this->validGeometry($geometry);
$mValue = $evt['mValue'];
$offset = $evt['offset'];
try {
$results = $this->getLocateAlong($geometry, $mValue, $offset);
$evt->setResults($results, true);
} catch (OperationError $error) {
$evt->addError($error);
}
} | [
"public",
"function",
"locateAlong",
"(",
"LinearReferenceOpEvent",
"$",
"evt",
")",
"{",
"$",
"geometry",
"=",
"$",
"evt",
"->",
"getGeometry",
"(",
")",
";",
"$",
"this",
"->",
"validGeometry",
"(",
"$",
"geometry",
")",
";",
"$",
"mValue",
"=",
"$",
"evt",
"[",
"'mValue'",
"]",
";",
"$",
"offset",
"=",
"$",
"evt",
"[",
"'offset'",
"]",
";",
"try",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getLocateAlong",
"(",
"$",
"geometry",
",",
"$",
"mValue",
",",
"$",
"offset",
")",
";",
"$",
"evt",
"->",
"setResults",
"(",
"$",
"results",
",",
"true",
")",
";",
"}",
"catch",
"(",
"OperationError",
"$",
"error",
")",
"{",
"$",
"evt",
"->",
"addError",
"(",
"$",
"error",
")",
";",
"}",
"}"
] | Gets the derived geometry collection with elements that match the specified
measure.
@param LinearReferenceOpEvent | [
"Gets",
"the",
"derived",
"geometry",
"collection",
"with",
"elements",
"that",
"match",
"the",
"specified",
"measure",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractLinearReferenceOpSubscriber.php#L86-L97 | train |
nasumilu/geometry | src/Operation/AbstractLinearReferenceOpSubscriber.php | AbstractLinearReferenceOpSubscriber.locateBetween | public function locateBetween(LinearReferenceOpEvent $evt) {
$geometry = $evt->getGeometry();
$this->validGeometry($geometry);
$mStart = $evt['mStart'];
$mEnd = $evt['mEnd'];
$offset = $evt['offset'];
try {
$results = $this->getLocateBetween($geometry, $mStart, $mEnd, $offset);
$evt->setResults($results, true);
} catch (OperationError $error) {
$evt->addError($error);
}
} | php | public function locateBetween(LinearReferenceOpEvent $evt) {
$geometry = $evt->getGeometry();
$this->validGeometry($geometry);
$mStart = $evt['mStart'];
$mEnd = $evt['mEnd'];
$offset = $evt['offset'];
try {
$results = $this->getLocateBetween($geometry, $mStart, $mEnd, $offset);
$evt->setResults($results, true);
} catch (OperationError $error) {
$evt->addError($error);
}
} | [
"public",
"function",
"locateBetween",
"(",
"LinearReferenceOpEvent",
"$",
"evt",
")",
"{",
"$",
"geometry",
"=",
"$",
"evt",
"->",
"getGeometry",
"(",
")",
";",
"$",
"this",
"->",
"validGeometry",
"(",
"$",
"geometry",
")",
";",
"$",
"mStart",
"=",
"$",
"evt",
"[",
"'mStart'",
"]",
";",
"$",
"mEnd",
"=",
"$",
"evt",
"[",
"'mEnd'",
"]",
";",
"$",
"offset",
"=",
"$",
"evt",
"[",
"'offset'",
"]",
";",
"try",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getLocateBetween",
"(",
"$",
"geometry",
",",
"$",
"mStart",
",",
"$",
"mEnd",
",",
"$",
"offset",
")",
";",
"$",
"evt",
"->",
"setResults",
"(",
"$",
"results",
",",
"true",
")",
";",
"}",
"catch",
"(",
"OperationError",
"$",
"error",
")",
"{",
"$",
"evt",
"->",
"addError",
"(",
"$",
"error",
")",
";",
"}",
"}"
] | Gets the derived geometry collection with elements that match the specified
range of measured inclusively.
@param LinearReferenceOpEvent | [
"Gets",
"the",
"derived",
"geometry",
"collection",
"with",
"elements",
"that",
"match",
"the",
"specified",
"range",
"of",
"measured",
"inclusively",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractLinearReferenceOpSubscriber.php#L105-L117 | train |
UnionOfRAD/li3_quality | qa/rules/syntax/WeakComparisonOperators.php | WeakComparisonOperators.apply | public function apply($testable, array $config = array()) {
$tokens = $testable->tokens();
$message = 'Weak comparison operator {:key} used, try {:value} instead';
$filtered = $testable->findAll(array_keys($this->inspectableTokens));
foreach ($filtered as $id) {
$token = $tokens[$id];
$this->addWarning(array(
'message' => String::insert($message, array(
'key' => token_name($token['id']),
'value' => $this->inspectableTokens[$token['id']],
)),
'line' => $token['line'],
));
}
} | php | public function apply($testable, array $config = array()) {
$tokens = $testable->tokens();
$message = 'Weak comparison operator {:key} used, try {:value} instead';
$filtered = $testable->findAll(array_keys($this->inspectableTokens));
foreach ($filtered as $id) {
$token = $tokens[$id];
$this->addWarning(array(
'message' => String::insert($message, array(
'key' => token_name($token['id']),
'value' => $this->inspectableTokens[$token['id']],
)),
'line' => $token['line'],
));
}
} | [
"public",
"function",
"apply",
"(",
"$",
"testable",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tokens",
"=",
"$",
"testable",
"->",
"tokens",
"(",
")",
";",
"$",
"message",
"=",
"'Weak comparison operator {:key} used, try {:value} instead'",
";",
"$",
"filtered",
"=",
"$",
"testable",
"->",
"findAll",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"inspectableTokens",
")",
")",
";",
"foreach",
"(",
"$",
"filtered",
"as",
"$",
"id",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"id",
"]",
";",
"$",
"this",
"->",
"addWarning",
"(",
"array",
"(",
"'message'",
"=>",
"String",
"::",
"insert",
"(",
"$",
"message",
",",
"array",
"(",
"'key'",
"=>",
"token_name",
"(",
"$",
"token",
"[",
"'id'",
"]",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"inspectableTokens",
"[",
"$",
"token",
"[",
"'id'",
"]",
"]",
",",
")",
")",
",",
"'line'",
"=>",
"$",
"token",
"[",
"'line'",
"]",
",",
")",
")",
";",
"}",
"}"
] | Will iterate over each line checking if any weak comparison operators
are used within the code.
@param Testable $testable The testable object
@return void | [
"Will",
"iterate",
"over",
"each",
"line",
"checking",
"if",
"any",
"weak",
"comparison",
"operators",
"are",
"used",
"within",
"the",
"code",
"."
] | acb72a43ae835e6d200bc0eba1a61aee610e36bf | https://github.com/UnionOfRAD/li3_quality/blob/acb72a43ae835e6d200bc0eba1a61aee610e36bf/qa/rules/syntax/WeakComparisonOperators.php#L32-L47 | train |
apishka/easy-extend | source/Builder.php | Builder.addFindersByConfigs | protected function addFindersByConfigs(array $configs): self
{
foreach ($configs as $package => $path)
{
$data = @include $path;
if ($data && isset($data['easy-extend']))
{
$config = $data['easy-extend'];
if ($config)
{
if (isset($config['finder']))
{
$finder_callbacks = $config['finder'];
if (!is_array($finder_callbacks))
$finder_callbacks = array($finder_callbacks);
foreach ($finder_callbacks as $callback)
{
$finder = new Finder();
$finder = $callback($finder);
$this->addFinder($finder);
}
}
if (isset($config['bootstrap']))
{
$config['bootstrap']();
}
}
}
}
return $this;
} | php | protected function addFindersByConfigs(array $configs): self
{
foreach ($configs as $package => $path)
{
$data = @include $path;
if ($data && isset($data['easy-extend']))
{
$config = $data['easy-extend'];
if ($config)
{
if (isset($config['finder']))
{
$finder_callbacks = $config['finder'];
if (!is_array($finder_callbacks))
$finder_callbacks = array($finder_callbacks);
foreach ($finder_callbacks as $callback)
{
$finder = new Finder();
$finder = $callback($finder);
$this->addFinder($finder);
}
}
if (isset($config['bootstrap']))
{
$config['bootstrap']();
}
}
}
}
return $this;
} | [
"protected",
"function",
"addFindersByConfigs",
"(",
"array",
"$",
"configs",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"configs",
"as",
"$",
"package",
"=>",
"$",
"path",
")",
"{",
"$",
"data",
"=",
"@",
"include",
"$",
"path",
";",
"if",
"(",
"$",
"data",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'easy-extend'",
"]",
")",
")",
"{",
"$",
"config",
"=",
"$",
"data",
"[",
"'easy-extend'",
"]",
";",
"if",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'finder'",
"]",
")",
")",
"{",
"$",
"finder_callbacks",
"=",
"$",
"config",
"[",
"'finder'",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"finder_callbacks",
")",
")",
"$",
"finder_callbacks",
"=",
"array",
"(",
"$",
"finder_callbacks",
")",
";",
"foreach",
"(",
"$",
"finder_callbacks",
"as",
"$",
"callback",
")",
"{",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"=",
"$",
"callback",
"(",
"$",
"finder",
")",
";",
"$",
"this",
"->",
"addFinder",
"(",
"$",
"finder",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'bootstrap'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'bootstrap'",
"]",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Add finders by configs
@param array $configs
@return Builder this | [
"Add",
"finders",
"by",
"configs"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L90-L127 | train |
apishka/easy-extend | source/Builder.php | Builder.getConfigFilesByComposer | protected function getConfigFilesByComposer(): array
{
$this->getLogger()->write('<info>Searching for ".apishka" files</info>');
if ($this->getEvent() === null)
throw new \LogicException('Event not exists');
$configs = array();
if ($this->isDependantPackage($this->getEvent()->getComposer()->getPackage()))
{
$path = $this->getConfigPackagePath(
rtrim($this->getRootPackagePath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
$this->getEvent()->getComposer()->getPackage()
);
if ($path)
$configs[$this->getEvent()->getComposer()->getPackage()->getName()] = $path;
}
$packages = $this->getEvent()->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages();
foreach ($packages as $package)
{
if ($this->isDependantPackage($package, false))
{
$path = $this->getConfigPackagePath(
$this->getEvent()->getComposer()->getInstallationManager()->getInstallPath($package),
$package
);
if ($path)
$configs[$package->getName()] = $path;
}
}
ksort($configs);
Cacher::getInstance()->set(
$this->getConfigsCacheName(),
$configs
);
return $configs;
} | php | protected function getConfigFilesByComposer(): array
{
$this->getLogger()->write('<info>Searching for ".apishka" files</info>');
if ($this->getEvent() === null)
throw new \LogicException('Event not exists');
$configs = array();
if ($this->isDependantPackage($this->getEvent()->getComposer()->getPackage()))
{
$path = $this->getConfigPackagePath(
rtrim($this->getRootPackagePath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
$this->getEvent()->getComposer()->getPackage()
);
if ($path)
$configs[$this->getEvent()->getComposer()->getPackage()->getName()] = $path;
}
$packages = $this->getEvent()->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages();
foreach ($packages as $package)
{
if ($this->isDependantPackage($package, false))
{
$path = $this->getConfigPackagePath(
$this->getEvent()->getComposer()->getInstallationManager()->getInstallPath($package),
$package
);
if ($path)
$configs[$package->getName()] = $path;
}
}
ksort($configs);
Cacher::getInstance()->set(
$this->getConfigsCacheName(),
$configs
);
return $configs;
} | [
"protected",
"function",
"getConfigFilesByComposer",
"(",
")",
":",
"array",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"write",
"(",
"'<info>Searching for \".apishka\" files</info>'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
"===",
"null",
")",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Event not exists'",
")",
";",
"$",
"configs",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDependantPackage",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getComposer",
"(",
")",
"->",
"getPackage",
"(",
")",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getConfigPackagePath",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"getRootPackagePath",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getComposer",
"(",
")",
"->",
"getPackage",
"(",
")",
")",
";",
"if",
"(",
"$",
"path",
")",
"$",
"configs",
"[",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getComposer",
"(",
")",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"path",
";",
"}",
"$",
"packages",
"=",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getComposer",
"(",
")",
"->",
"getRepositoryManager",
"(",
")",
"->",
"getLocalRepository",
"(",
")",
"->",
"getPackages",
"(",
")",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDependantPackage",
"(",
"$",
"package",
",",
"false",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getConfigPackagePath",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getComposer",
"(",
")",
"->",
"getInstallationManager",
"(",
")",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
",",
"$",
"package",
")",
";",
"if",
"(",
"$",
"path",
")",
"$",
"configs",
"[",
"$",
"package",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"path",
";",
"}",
"}",
"ksort",
"(",
"$",
"configs",
")",
";",
"Cacher",
"::",
"getInstance",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getConfigsCacheName",
"(",
")",
",",
"$",
"configs",
")",
";",
"return",
"$",
"configs",
";",
"}"
] | Get config files by composer
@return array | [
"Get",
"config",
"files",
"by",
"composer"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L184-L226 | train |
apishka/easy-extend | source/Builder.php | Builder.getConfigPackagePath | protected function getConfigPackagePath(string $dir, PackageInterface $package): ?string
{
$dir = preg_replace(
'#^(' . preg_quote(getcwd() . DIRECTORY_SEPARATOR, '#') . ')#',
'.' . DIRECTORY_SEPARATOR,
$dir
);
$path = $this->getConfigPath($dir);
if (file_exists($path))
{
$this->getLogger()->write(
sprintf(
' - Found in <info>%s</info>',
$package->getPrettyName()
)
);
return $path;
}
return null;
} | php | protected function getConfigPackagePath(string $dir, PackageInterface $package): ?string
{
$dir = preg_replace(
'#^(' . preg_quote(getcwd() . DIRECTORY_SEPARATOR, '#') . ')#',
'.' . DIRECTORY_SEPARATOR,
$dir
);
$path = $this->getConfigPath($dir);
if (file_exists($path))
{
$this->getLogger()->write(
sprintf(
' - Found in <info>%s</info>',
$package->getPrettyName()
)
);
return $path;
}
return null;
} | [
"protected",
"function",
"getConfigPackagePath",
"(",
"string",
"$",
"dir",
",",
"PackageInterface",
"$",
"package",
")",
":",
"?",
"string",
"{",
"$",
"dir",
"=",
"preg_replace",
"(",
"'#^('",
".",
"preg_quote",
"(",
"getcwd",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"'#'",
")",
".",
"')#'",
",",
"'.'",
".",
"DIRECTORY_SEPARATOR",
",",
"$",
"dir",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getConfigPath",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"write",
"(",
"sprintf",
"(",
"' - Found in <info>%s</info>'",
",",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
")",
")",
";",
"return",
"$",
"path",
";",
"}",
"return",
"null",
";",
"}"
] | Get config package file path
@param string $dir
@param PackageInterface $package
@return null|string | [
"Get",
"config",
"package",
"file",
"path"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L236-L258 | train |
bitrank-verified/php-client | src/BitRank/Score.php | Score.boundsCheck | protected function boundsCheck()
{
$scores = $this->bitrank->getScores();
if ($this->score > $scores->max) {
$this->score = $scores->max;
}
if ($this->score < $scores->min) {
$this->score = $scores->min;
}
} | php | protected function boundsCheck()
{
$scores = $this->bitrank->getScores();
if ($this->score > $scores->max) {
$this->score = $scores->max;
}
if ($this->score < $scores->min) {
$this->score = $scores->min;
}
} | [
"protected",
"function",
"boundsCheck",
"(",
")",
"{",
"$",
"scores",
"=",
"$",
"this",
"->",
"bitrank",
"->",
"getScores",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"score",
">",
"$",
"scores",
"->",
"max",
")",
"{",
"$",
"this",
"->",
"score",
"=",
"$",
"scores",
"->",
"max",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"score",
"<",
"$",
"scores",
"->",
"min",
")",
"{",
"$",
"this",
"->",
"score",
"=",
"$",
"scores",
"->",
"min",
";",
"}",
"}"
] | Ensure score is within bounds
@return void | [
"Ensure",
"score",
"is",
"within",
"bounds"
] | 8c1a2eb3b82e317852f70af9bb9ea75af34b715c | https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L111-L120 | train |
bitrank-verified/php-client | src/BitRank/Score.php | Score.getFlagsOfType | public function getFlagsOfType($type)
{
if ($this->flags === null) {
return [];
}
$matches = [];
foreach ($this->flags as $flag) {
if ($flag->type == $type) {
$matches []= $flag;
}
}
return $matches;
} | php | public function getFlagsOfType($type)
{
if ($this->flags === null) {
return [];
}
$matches = [];
foreach ($this->flags as $flag) {
if ($flag->type == $type) {
$matches []= $flag;
}
}
return $matches;
} | [
"public",
"function",
"getFlagsOfType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"flags",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"flags",
"as",
"$",
"flag",
")",
"{",
"if",
"(",
"$",
"flag",
"->",
"type",
"==",
"$",
"type",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"flag",
";",
"}",
"}",
"return",
"$",
"matches",
";",
"}"
] | Returns flags of the specified type associated with this address, if any.
@param $type The flag type you're looking for. Will be one of the Flag::TYPE_* constants.
@return array of Flag, or an empty array if none found. | [
"Returns",
"flags",
"of",
"the",
"specified",
"type",
"associated",
"with",
"this",
"address",
"if",
"any",
"."
] | 8c1a2eb3b82e317852f70af9bb9ea75af34b715c | https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L127-L142 | train |
bitrank-verified/php-client | src/BitRank/Score.php | Score.hasFlagsOfType | public function hasFlagsOfType($type)
{
if ($this->flags === null) {
return false;
}
foreach ($this->flags as $flag) {
if ($flag->type == $type) {
return true;
}
}
return false;
} | php | public function hasFlagsOfType($type)
{
if ($this->flags === null) {
return false;
}
foreach ($this->flags as $flag) {
if ($flag->type == $type) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFlagsOfType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"flags",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"flags",
"as",
"$",
"flag",
")",
"{",
"if",
"(",
"$",
"flag",
"->",
"type",
"==",
"$",
"type",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether or not this address has any flags of type.
@param string $type The flag type you're looking for. Will be one of the Flag::TYPE_* constants.
@return boolean | [
"Returns",
"whether",
"or",
"not",
"this",
"address",
"has",
"any",
"flags",
"of",
"type",
"."
] | 8c1a2eb3b82e317852f70af9bb9ea75af34b715c | https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L149-L162 | train |
digipolisgent/robo-digipolis-deploy | src/Traits/SymlinkFolderFileContentsTrait.php | SymlinkFolderFileContentsTrait.taskSymlinkFolderFileContents | protected function taskSymlinkFolderFileContents($source, $destination, Finder $finder = null)
{
return $this->task(SymlinkFolderFileContents::class, $source, $destination, $finder);
} | php | protected function taskSymlinkFolderFileContents($source, $destination, Finder $finder = null)
{
return $this->task(SymlinkFolderFileContents::class, $source, $destination, $finder);
} | [
"protected",
"function",
"taskSymlinkFolderFileContents",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"Finder",
"$",
"finder",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"task",
"(",
"SymlinkFolderFileContents",
"::",
"class",
",",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"finder",
")",
";",
"}"
] | Creates a SymlinkFolderFileContents task.
@param string $source
The directory containing the files to symlink.
@param string $destination
The directory where the symlinks should be placed.
@param null|\Symfony\Component\Finder\Finder $finder
The finder used to get the files from the source folder.
@return \DigipolisGent\Robo\Task\Package\Deploy\SymlinkFolderFileContents
The package project task. | [
"Creates",
"a",
"SymlinkFolderFileContents",
"task",
"."
] | fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/Traits/SymlinkFolderFileContentsTrait.php#L24-L27 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.reset | public function reset()
{
$this->oosql_limit = null;
$this->oosql_order = null;
$this->oosql_where = null;
$this->oosql_join = null;
$this->oosql_stmt = null;
$this->oosql_conValues = array();
$this->oosql_numargs = null;
$this->oosql_fromFlag = false;
$this->oosql_multiFlag = false;
$this->oosql_del_multiFlag = false;
$this->oosql_multi = array();
$this->oosql_del_numargs = null;
$this->oosql_sql = null;
$this->oosql_select = null;
$this->oosql_distinct = false;
$this->oosql_insert = false;
$this->oosql_sub = false;
$this->oosql_table_alias = null;
$this->oosql_fields = array();
$this->oosql_entity_obj = null;
$this->oosql_in = null;
$this->oosql_between = null;
$this->oosql_fetchChanged = null;
$this->oosql_group = null;
$this->oosql_prepParams = null;
return $this;
} | php | public function reset()
{
$this->oosql_limit = null;
$this->oosql_order = null;
$this->oosql_where = null;
$this->oosql_join = null;
$this->oosql_stmt = null;
$this->oosql_conValues = array();
$this->oosql_numargs = null;
$this->oosql_fromFlag = false;
$this->oosql_multiFlag = false;
$this->oosql_del_multiFlag = false;
$this->oosql_multi = array();
$this->oosql_del_numargs = null;
$this->oosql_sql = null;
$this->oosql_select = null;
$this->oosql_distinct = false;
$this->oosql_insert = false;
$this->oosql_sub = false;
$this->oosql_table_alias = null;
$this->oosql_fields = array();
$this->oosql_entity_obj = null;
$this->oosql_in = null;
$this->oosql_between = null;
$this->oosql_fetchChanged = null;
$this->oosql_group = null;
$this->oosql_prepParams = null;
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"oosql_limit",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_order",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_where",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_join",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_stmt",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_conValues",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"oosql_numargs",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_fromFlag",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_multiFlag",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_del_multiFlag",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_multi",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"oosql_del_numargs",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_sql",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_select",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_distinct",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_insert",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_sub",
"=",
"false",
";",
"$",
"this",
"->",
"oosql_table_alias",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_fields",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"oosql_entity_obj",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_in",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_between",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_fetchChanged",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_group",
"=",
"null",
";",
"$",
"this",
"->",
"oosql_prepParams",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Resets the class vars to their initial values for a new query
@return \Phiber\oosql\oosql Instance | [
"Resets",
"the",
"class",
"vars",
"to",
"their",
"initial",
"values",
"for",
"a",
"new",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L250-L304 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.sql | protected function sql($sql = null, $replace = false)
{
if (null !== $sql) {
if (!isset($this->oosql_sql[$this->oosql_table]) || $replace) {
$this->oosql_sql[$this->oosql_table] = $sql;
} else {
$this->oosql_sql[$this->oosql_table] .= $sql;
}
return;
}
return $this->oosql_sql[$this->oosql_table];
} | php | protected function sql($sql = null, $replace = false)
{
if (null !== $sql) {
if (!isset($this->oosql_sql[$this->oosql_table]) || $replace) {
$this->oosql_sql[$this->oosql_table] = $sql;
} else {
$this->oosql_sql[$this->oosql_table] .= $sql;
}
return;
}
return $this->oosql_sql[$this->oosql_table];
} | [
"protected",
"function",
"sql",
"(",
"$",
"sql",
"=",
"null",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"sql",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"oosql_sql",
"[",
"$",
"this",
"->",
"oosql_table",
"]",
")",
"||",
"$",
"replace",
")",
"{",
"$",
"this",
"->",
"oosql_sql",
"[",
"$",
"this",
"->",
"oosql_table",
"]",
"=",
"$",
"sql",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_sql",
"[",
"$",
"this",
"->",
"oosql_table",
"]",
".=",
"$",
"sql",
";",
"}",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"oosql_sql",
"[",
"$",
"this",
"->",
"oosql_table",
"]",
";",
"}"
] | Append to the query string or return the current one
@param mixed $sql SQL
@param boolean $replace Replace current query or not | [
"Append",
"to",
"the",
"query",
"string",
"or",
"return",
"the",
"current",
"one"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L347-L359 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.select | public function select()
{
self::$instance->reset();
$this->sql('SELECT ');
if ($this->oosql_distinct) {
$this->sql('DISTINCT ');
}
$numargs = func_num_args();
if ($numargs > 0) {
$arg_list = func_get_args();
$this->oosql_fields = $arg_list;
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
$this->sql($arg_list[$i]);
}
} else {
$this->oosql_fields[] = '*';
$this->sql($this->oosql_table . '.* ');
}
$this->oosql_fromFlag = true;
$this->oosql_select = $this;
$this->oosql_where = null;
return $this;
} | php | public function select()
{
self::$instance->reset();
$this->sql('SELECT ');
if ($this->oosql_distinct) {
$this->sql('DISTINCT ');
}
$numargs = func_num_args();
if ($numargs > 0) {
$arg_list = func_get_args();
$this->oosql_fields = $arg_list;
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
$this->sql($arg_list[$i]);
}
} else {
$this->oosql_fields[] = '*';
$this->sql($this->oosql_table . '.* ');
}
$this->oosql_fromFlag = true;
$this->oosql_select = $this;
$this->oosql_where = null;
return $this;
} | [
"public",
"function",
"select",
"(",
")",
"{",
"self",
"::",
"$",
"instance",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"'SELECT '",
")",
";",
"if",
"(",
"$",
"this",
"->",
"oosql_distinct",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"'DISTINCT '",
")",
";",
"}",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numargs",
">",
"0",
")",
"{",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"oosql_fields",
"=",
"$",
"arg_list",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numargs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"!=",
"0",
"&&",
"$",
"numargs",
">",
"1",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"','",
")",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"$",
"arg_list",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_fields",
"[",
"]",
"=",
"'*'",
";",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"oosql_table",
".",
"'.* '",
")",
";",
"}",
"$",
"this",
"->",
"oosql_fromFlag",
"=",
"true",
";",
"$",
"this",
"->",
"oosql_select",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"oosql_where",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Create a select statement
@variadic
@return \Phiber\oosql\oosql Instance | [
"Create",
"a",
"select",
"statement"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L366-L397 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.getFields | public function getFields($table = null)
{
if (null == $table) {
$table = $this->oosql_table;
}
$newFields = array();
foreach ($this->oosql_fields as $field) {
$newFields[] = $table . '.' . $field;
}
return $newFields;
} | php | public function getFields($table = null)
{
if (null == $table) {
$table = $this->oosql_table;
}
$newFields = array();
foreach ($this->oosql_fields as $field) {
$newFields[] = $table . '.' . $field;
}
return $newFields;
} | [
"public",
"function",
"getFields",
"(",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"oosql_table",
";",
"}",
"$",
"newFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"oosql_fields",
"as",
"$",
"field",
")",
"{",
"$",
"newFields",
"[",
"]",
"=",
"$",
"table",
".",
"'.'",
".",
"$",
"field",
";",
"}",
"return",
"$",
"newFields",
";",
"}"
] | Get an array of fields of the current or given table
@param mixed $table table name
@return array Table fields | [
"Get",
"an",
"array",
"of",
"fields",
"of",
"the",
"current",
"or",
"given",
"table"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L404-L414 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.insert | public function insert()
{
self::$instance->reset();
$this->sql('INSERT INTO ' . $this->oosql_table);
$arg_list = func_get_args();
$numargs = func_num_args();
if ($numargs > 0) {
$this->oosql_numargs = $numargs;
$this->sql(' (');
$this->sql(implode(',', $arg_list));
$this->sql(')');
}
$this->oosql_insert = true;
return $this;
} | php | public function insert()
{
self::$instance->reset();
$this->sql('INSERT INTO ' . $this->oosql_table);
$arg_list = func_get_args();
$numargs = func_num_args();
if ($numargs > 0) {
$this->oosql_numargs = $numargs;
$this->sql(' (');
$this->sql(implode(',', $arg_list));
$this->sql(')');
}
$this->oosql_insert = true;
return $this;
} | [
"public",
"function",
"insert",
"(",
")",
"{",
"self",
"::",
"$",
"instance",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"oosql_table",
")",
";",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numargs",
">",
"0",
")",
"{",
"$",
"this",
"->",
"oosql_numargs",
"=",
"$",
"numargs",
";",
"$",
"this",
"->",
"sql",
"(",
"' ('",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"implode",
"(",
"','",
",",
"$",
"arg_list",
")",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"')'",
")",
";",
"}",
"$",
"this",
"->",
"oosql_insert",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Creates an INSERT query
@return \Phiber\oosql\oosql Instance | [
"Creates",
"an",
"INSERT",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L429-L447 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.update | public function update()
{
self::$instance->reset();
$this->sql('UPDATE');
$numargs = func_num_args();
if ($numargs > 0) {
$arg_list = func_get_args();
$this->oosql_multiFlag = true;
$this->oosql_multi = $arg_list;
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > $i) {
$this->sql(',');
}
$this->sql(' ' . $arg_list[$i]);
}
} else {
$this->sql(" $this->oosql_table");
}
$this->sql(' SET ');
$this->oosql_where = null;
return $this;
} | php | public function update()
{
self::$instance->reset();
$this->sql('UPDATE');
$numargs = func_num_args();
if ($numargs > 0) {
$arg_list = func_get_args();
$this->oosql_multiFlag = true;
$this->oosql_multi = $arg_list;
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > $i) {
$this->sql(',');
}
$this->sql(' ' . $arg_list[$i]);
}
} else {
$this->sql(" $this->oosql_table");
}
$this->sql(' SET ');
$this->oosql_where = null;
return $this;
} | [
"public",
"function",
"update",
"(",
")",
"{",
"self",
"::",
"$",
"instance",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"'UPDATE'",
")",
";",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numargs",
">",
"0",
")",
"{",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"oosql_multiFlag",
"=",
"true",
";",
"$",
"this",
"->",
"oosql_multi",
"=",
"$",
"arg_list",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numargs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"!=",
"0",
"&&",
"$",
"numargs",
">",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"','",
")",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"' '",
".",
"$",
"arg_list",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"sql",
"(",
"\" $this->oosql_table\"",
")",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"' SET '",
")",
";",
"$",
"this",
"->",
"oosql_where",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Creates an UPDATE query
@return \Phiber\oosql\oosql Instance | [
"Creates",
"an",
"UPDATE",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L453-L480 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.delete | public function delete()
{
self::$instance->reset();
$this->sql('DELETE');
$this->oosql_where = null;
$numargs = func_num_args();
if ($numargs > 0) {
if ($numargs > 1) {
$this->oosql_del_multiFlag = true;
$this->oosql_del_numargs = $numargs;
}
$arg_list = func_get_args();
if (is_array($arg_list[0])) {
$this->sql(' FROM ' . $this->oosql_table);
$this->where($arg_list[0][0] . ' = ?', $arg_list[0][1]);
return $this;
}
$this->oosql_sql .= ' FROM';
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
$this->sql(' ' . $arg_list[$i]);
}
} else {
$this->oosql_fromFlag = true;
}
return $this;
} | php | public function delete()
{
self::$instance->reset();
$this->sql('DELETE');
$this->oosql_where = null;
$numargs = func_num_args();
if ($numargs > 0) {
if ($numargs > 1) {
$this->oosql_del_multiFlag = true;
$this->oosql_del_numargs = $numargs;
}
$arg_list = func_get_args();
if (is_array($arg_list[0])) {
$this->sql(' FROM ' . $this->oosql_table);
$this->where($arg_list[0][0] . ' = ?', $arg_list[0][1]);
return $this;
}
$this->oosql_sql .= ' FROM';
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
$this->sql(' ' . $arg_list[$i]);
}
} else {
$this->oosql_fromFlag = true;
}
return $this;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"self",
"::",
"$",
"instance",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"'DELETE'",
")",
";",
"$",
"this",
"->",
"oosql_where",
"=",
"null",
";",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numargs",
">",
"0",
")",
"{",
"if",
"(",
"$",
"numargs",
">",
"1",
")",
"{",
"$",
"this",
"->",
"oosql_del_multiFlag",
"=",
"true",
";",
"$",
"this",
"->",
"oosql_del_numargs",
"=",
"$",
"numargs",
";",
"}",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"arg_list",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"' FROM '",
".",
"$",
"this",
"->",
"oosql_table",
")",
";",
"$",
"this",
"->",
"where",
"(",
"$",
"arg_list",
"[",
"0",
"]",
"[",
"0",
"]",
".",
"' = ?'",
",",
"$",
"arg_list",
"[",
"0",
"]",
"[",
"1",
"]",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"oosql_sql",
".=",
"' FROM'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numargs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"!=",
"0",
"&&",
"$",
"numargs",
">",
"1",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"','",
")",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"' '",
".",
"$",
"arg_list",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_fromFlag",
"=",
"true",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Creates a DELETE query
@return \Phiber\oosql\oosql Instance | [
"Creates",
"a",
"DELETE",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L486-L518 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.deleteRecord | public function deleteRecord($oosql = null, array $criteria)
{
if (null == $oosql) {
$oosql = $this;
}
$oosql->delete()->createWhere($criteria)->exe();
return $this;
} | php | public function deleteRecord($oosql = null, array $criteria)
{
if (null == $oosql) {
$oosql = $this;
}
$oosql->delete()->createWhere($criteria)->exe();
return $this;
} | [
"public",
"function",
"deleteRecord",
"(",
"$",
"oosql",
"=",
"null",
",",
"array",
"$",
"criteria",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"oosql",
")",
"{",
"$",
"oosql",
"=",
"$",
"this",
";",
"}",
"$",
"oosql",
"->",
"delete",
"(",
")",
"->",
"createWhere",
"(",
"$",
"criteria",
")",
"->",
"exe",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Delete a record or more from a table
@param mixed $oosql Optional oosql\oosql instance to run query on
@param array $criteria Criteria of current opperation
@return \Phiber\oosql\oosql Instance | [
"Delete",
"a",
"record",
"or",
"more",
"from",
"a",
"table"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L526-L533 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.set | public function set(array $data)
{
$sql = '';
foreach ($data as $field => $value) {
$sql .= $field . ' = ?,';
$this->oosql_conValues[] = $value;
}
$this->sql(rtrim($sql, ','));
return $this;
} | php | public function set(array $data)
{
$sql = '';
foreach ($data as $field => $value) {
$sql .= $field . ' = ?,';
$this->oosql_conValues[] = $value;
}
$this->sql(rtrim($sql, ','));
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"sql",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"sql",
".=",
"$",
"field",
".",
"' = ?,'",
";",
"$",
"this",
"->",
"oosql_conValues",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"rtrim",
"(",
"$",
"sql",
",",
"','",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the column, value pairs in update queries
@param array $data An array of the fields with their corresponding values in a key => value format
@return \Phiber\oosql\oosql Instance | [
"Sets",
"the",
"column",
"value",
"pairs",
"in",
"update",
"queries"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L540-L552 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.values | public function values()
{
$arg_list = func_get_args();
$numargs = func_num_args();
if (($this->oosql_numargs !== 0 && $numargs !== $this->oosql_numargs) || $numargs === 0) {
$msg = 'Insert numargs: ' . $this->oosql_numargs . ' | values numargs = ' . $numargs . ', Columns and passed data do not match! ' . $this->sql();
throw new \Exception($msg, 9809, null);
}
$this->sql(' VALUES (');
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
if (is_array($arg_list[$i])) {
$this->sql(rtrim(str_repeat('?,', count($arg_list[$i])), ','));
$this->oosql_conValues += $arg_list[$i];
} else {
$this->oosql_conValues[] = $arg_list[$i];
$this->sql(' ?');
}
}
$this->sql(')');
$this->oosql_fromFlag = false;
return $this;
} | php | public function values()
{
$arg_list = func_get_args();
$numargs = func_num_args();
if (($this->oosql_numargs !== 0 && $numargs !== $this->oosql_numargs) || $numargs === 0) {
$msg = 'Insert numargs: ' . $this->oosql_numargs . ' | values numargs = ' . $numargs . ', Columns and passed data do not match! ' . $this->sql();
throw new \Exception($msg, 9809, null);
}
$this->sql(' VALUES (');
for ($i = 0; $i < $numargs; $i++) {
if ($i != 0 && $numargs > 1) {
$this->sql(',');
}
if (is_array($arg_list[$i])) {
$this->sql(rtrim(str_repeat('?,', count($arg_list[$i])), ','));
$this->oosql_conValues += $arg_list[$i];
} else {
$this->oosql_conValues[] = $arg_list[$i];
$this->sql(' ?');
}
}
$this->sql(')');
$this->oosql_fromFlag = false;
return $this;
} | [
"public",
"function",
"values",
"(",
")",
"{",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"oosql_numargs",
"!==",
"0",
"&&",
"$",
"numargs",
"!==",
"$",
"this",
"->",
"oosql_numargs",
")",
"||",
"$",
"numargs",
"===",
"0",
")",
"{",
"$",
"msg",
"=",
"'Insert numargs: '",
".",
"$",
"this",
"->",
"oosql_numargs",
".",
"' | values numargs = '",
".",
"$",
"numargs",
".",
"', Columns and passed data do not match! '",
".",
"$",
"this",
"->",
"sql",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9809",
",",
"null",
")",
";",
"}",
"$",
"this",
"->",
"sql",
"(",
"' VALUES ('",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numargs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"!=",
"0",
"&&",
"$",
"numargs",
">",
"1",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"','",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"arg_list",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"rtrim",
"(",
"str_repeat",
"(",
"'?,'",
",",
"count",
"(",
"$",
"arg_list",
"[",
"$",
"i",
"]",
")",
")",
",",
"','",
")",
")",
";",
"$",
"this",
"->",
"oosql_conValues",
"+=",
"$",
"arg_list",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_conValues",
"[",
"]",
"=",
"$",
"arg_list",
"[",
"$",
"i",
"]",
";",
"$",
"this",
"->",
"sql",
"(",
"' ?'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"sql",
"(",
"')'",
")",
";",
"$",
"this",
"->",
"oosql_fromFlag",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Assembles values part of an insert
@throws \Exception
@return \Phiber\oosql\oosql Instance | [
"Assembles",
"values",
"part",
"of",
"an",
"insert"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L682-L715 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.from | public function from()
{
$from = '';
$numargs = func_num_args();
if ($this->oosql_del_multiFlag) {
if ($numargs < $this->oosql_del_numargs) {
$msg = 'Columns and passed data do not match! ' . $this->sql();
throw new \Exception($msg, 9810, null);
}
}
$from .= ' FROM ';
$from .= $this->oosql_table;
if ($numargs > 0) {
$from .= ', ';
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
if ($i !== 0 && $numargs > $i) {
$from .= ', ';
}
if ($arg_list[$i] instanceof oosql) {
$arg_list[$i]->alias();
$fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias());
$this->sql(',' . implode(', ', $fields));
$from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias();
} else {
$from .= $arg_list[$i];
}
}
}
$this->sql($from);
$this->oosql_fromFlag = false;
return $this;
} | php | public function from()
{
$from = '';
$numargs = func_num_args();
if ($this->oosql_del_multiFlag) {
if ($numargs < $this->oosql_del_numargs) {
$msg = 'Columns and passed data do not match! ' . $this->sql();
throw new \Exception($msg, 9810, null);
}
}
$from .= ' FROM ';
$from .= $this->oosql_table;
if ($numargs > 0) {
$from .= ', ';
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
if ($i !== 0 && $numargs > $i) {
$from .= ', ';
}
if ($arg_list[$i] instanceof oosql) {
$arg_list[$i]->alias();
$fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias());
$this->sql(',' . implode(', ', $fields));
$from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias();
} else {
$from .= $arg_list[$i];
}
}
}
$this->sql($from);
$this->oosql_fromFlag = false;
return $this;
} | [
"public",
"function",
"from",
"(",
")",
"{",
"$",
"from",
"=",
"''",
";",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"oosql_del_multiFlag",
")",
"{",
"if",
"(",
"$",
"numargs",
"<",
"$",
"this",
"->",
"oosql_del_numargs",
")",
"{",
"$",
"msg",
"=",
"'Columns and passed data do not match! '",
".",
"$",
"this",
"->",
"sql",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9810",
",",
"null",
")",
";",
"}",
"}",
"$",
"from",
".=",
"' FROM '",
";",
"$",
"from",
".=",
"$",
"this",
"->",
"oosql_table",
";",
"if",
"(",
"$",
"numargs",
">",
"0",
")",
"{",
"$",
"from",
".=",
"', '",
";",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numargs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"!==",
"0",
"&&",
"$",
"numargs",
">",
"$",
"i",
")",
"{",
"$",
"from",
".=",
"', '",
";",
"}",
"if",
"(",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"instanceof",
"oosql",
")",
"{",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"->",
"alias",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"->",
"getFields",
"(",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"->",
"getTableAlias",
"(",
")",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"','",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
")",
";",
"$",
"from",
".=",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"->",
"getSql",
"(",
")",
".",
"' AS '",
".",
"$",
"arg_list",
"[",
"$",
"i",
"]",
"->",
"getTableAlias",
"(",
")",
";",
"}",
"else",
"{",
"$",
"from",
".=",
"$",
"arg_list",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"sql",
"(",
"$",
"from",
")",
";",
"$",
"this",
"->",
"oosql_fromFlag",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Assembles the FROM part of the query
@throws \Exception
@return \Phiber\oosql\oosql Instance | [
"Assembles",
"the",
"FROM",
"part",
"of",
"the",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L722-L771 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.where | public function where($condition, $value = null, $type = null)
{
switch ($type) {
case null:
$clause = 'WHERE';
break;
case 'or':
$clause = 'OR';
break;
case 'and':
$clause = 'AND';
break;
default:
$clause = 'WHERE';
}
$this->oosql_where .= " $clause $condition";
if ($value instanceof oosql) {
$this->oosql_where .= $value->getSql();
} elseif (null !== $value) {
$this->oosql_conValues[] = $value;
}
return $this;
} | php | public function where($condition, $value = null, $type = null)
{
switch ($type) {
case null:
$clause = 'WHERE';
break;
case 'or':
$clause = 'OR';
break;
case 'and':
$clause = 'AND';
break;
default:
$clause = 'WHERE';
}
$this->oosql_where .= " $clause $condition";
if ($value instanceof oosql) {
$this->oosql_where .= $value->getSql();
} elseif (null !== $value) {
$this->oosql_conValues[] = $value;
}
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"condition",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"null",
":",
"$",
"clause",
"=",
"'WHERE'",
";",
"break",
";",
"case",
"'or'",
":",
"$",
"clause",
"=",
"'OR'",
";",
"break",
";",
"case",
"'and'",
":",
"$",
"clause",
"=",
"'AND'",
";",
"break",
";",
"default",
":",
"$",
"clause",
"=",
"'WHERE'",
";",
"}",
"$",
"this",
"->",
"oosql_where",
".=",
"\" $clause $condition\"",
";",
"if",
"(",
"$",
"value",
"instanceof",
"oosql",
")",
"{",
"$",
"this",
"->",
"oosql_where",
".=",
"$",
"value",
"->",
"getSql",
"(",
")",
";",
"}",
"elseif",
"(",
"null",
"!==",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"oosql_conValues",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Assembles a WHERE clause
@param string $condition
@param string $value
@param string $type
@return \Phiber\oosql\oosql | [
"Assembles",
"a",
"WHERE",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L829-L857 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.sub | public function sub()
{
$this->oosql_sub = true;
$this->exe();
$this->sql('(' . $this->getSql() . ')', true);
return $this;
} | php | public function sub()
{
$this->oosql_sub = true;
$this->exe();
$this->sql('(' . $this->getSql() . ')', true);
return $this;
} | [
"public",
"function",
"sub",
"(",
")",
"{",
"$",
"this",
"->",
"oosql_sub",
"=",
"true",
";",
"$",
"this",
"->",
"exe",
"(",
")",
";",
"$",
"this",
"->",
"sql",
"(",
"'('",
".",
"$",
"this",
"->",
"getSql",
"(",
")",
".",
"')'",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Declares current query as a sub-query
@return \Phiber\oosql\oosql | [
"Declares",
"current",
"query",
"as",
"a",
"sub",
"-",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L863-L870 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.prep | public function prep($values = null)
{
$hash = $this->queryHash();
$prepOnly = true;
if (is_array($values)) {
$prepOnly = false;
}
if ($this->oosql_prepParams) {
$this->oosql_stmt = $this->prepare(trim($this->sql()), $this->oosql_prepParams);
} else {
$this->oosql_stmt = $this->prepare(trim($this->sql()));
}
if ($prepOnly) {
return $this->oosql_stmt;
}
return $this->execBound($this->oosql_stmt, $values);
} | php | public function prep($values = null)
{
$hash = $this->queryHash();
$prepOnly = true;
if (is_array($values)) {
$prepOnly = false;
}
if ($this->oosql_prepParams) {
$this->oosql_stmt = $this->prepare(trim($this->sql()), $this->oosql_prepParams);
} else {
$this->oosql_stmt = $this->prepare(trim($this->sql()));
}
if ($prepOnly) {
return $this->oosql_stmt;
}
return $this->execBound($this->oosql_stmt, $values);
} | [
"public",
"function",
"prep",
"(",
"$",
"values",
"=",
"null",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"queryHash",
"(",
")",
";",
"$",
"prepOnly",
"=",
"true",
";",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"prepOnly",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"oosql_prepParams",
")",
"{",
"$",
"this",
"->",
"oosql_stmt",
"=",
"$",
"this",
"->",
"prepare",
"(",
"trim",
"(",
"$",
"this",
"->",
"sql",
"(",
")",
")",
",",
"$",
"this",
"->",
"oosql_prepParams",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_stmt",
"=",
"$",
"this",
"->",
"prepare",
"(",
"trim",
"(",
"$",
"this",
"->",
"sql",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"prepOnly",
")",
"{",
"return",
"$",
"this",
"->",
"oosql_stmt",
";",
"}",
"return",
"$",
"this",
"->",
"execBound",
"(",
"$",
"this",
"->",
"oosql_stmt",
",",
"$",
"values",
")",
";",
"}"
] | Prepare a query statement
@param array $values Bound values if any
@return mixed A \PDOStatement object or the boolean return of PDOStatement::execute | [
"Prepare",
"a",
"query",
"statement"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L901-L928 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.execBound | public function execBound(\PDOStatement $stmt, array $values)
{
$ord = 1;
foreach ($values as $val) {
if (is_bool($val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_BOOL);
} elseif (is_resource($val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_LOB);
} elseif ((string)$val === ((string)(int)$val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_INT);
} else {
$stmt->bindValue($ord, $val, \PDO::PARAM_STR);
}
$ord++;
}
return $stmt->execute();
} | php | public function execBound(\PDOStatement $stmt, array $values)
{
$ord = 1;
foreach ($values as $val) {
if (is_bool($val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_BOOL);
} elseif (is_resource($val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_LOB);
} elseif ((string)$val === ((string)(int)$val)) {
$stmt->bindValue($ord, $val, \PDO::PARAM_INT);
} else {
$stmt->bindValue($ord, $val, \PDO::PARAM_STR);
}
$ord++;
}
return $stmt->execute();
} | [
"public",
"function",
"execBound",
"(",
"\\",
"PDOStatement",
"$",
"stmt",
",",
"array",
"$",
"values",
")",
"{",
"$",
"ord",
"=",
"1",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"val",
")",
")",
"{",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"ord",
",",
"$",
"val",
",",
"\\",
"PDO",
"::",
"PARAM_BOOL",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"val",
")",
")",
"{",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"ord",
",",
"$",
"val",
",",
"\\",
"PDO",
"::",
"PARAM_LOB",
")",
";",
"}",
"elseif",
"(",
"(",
"string",
")",
"$",
"val",
"===",
"(",
"(",
"string",
")",
"(",
"int",
")",
"$",
"val",
")",
")",
"{",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"ord",
",",
"$",
"val",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
";",
"}",
"else",
"{",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"ord",
",",
"$",
"val",
",",
"\\",
"PDO",
"::",
"PARAM_STR",
")",
";",
"}",
"$",
"ord",
"++",
";",
"}",
"return",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}"
] | Executes a prepared statement with parameterized values
@param \PDOStatement $stmt
@param array $values
@return boolean True on success | [
"Executes",
"a",
"prepared",
"statement",
"with",
"parameterized",
"values"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L936-L961 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.exe | public function exe()
{
if ($this->oosql_fromFlag) {
$this->from();
}
if (null != $this->oosql_join) {
$this->sql($this->oosql_join);
}
if (null != $this->oosql_where) {
$this->sql($this->oosql_where);
}
if (null != $this->oosql_in) {
$this->sql($this->oosql_in);
}
if (null != $this->oosql_between) {
$this->sql($this->oosql_between);
}
if (null != $this->oosql_limit) {
$this->sql(' ' . $this->oosql_limit);
}
if (null != $this->oosql_group) {
$this->sql(' ' . $this->oosql_group);
}
if (null != $this->oosql_order) {
$this->sql(' ' . $this->oosql_order);
}
if (count($this->oosql_conValues) !== 0) {
$return = $this->prep($this->oosql_conValues);
$this->oosql_conValues = array();
if ($return === false) {
$msg = 'Execution failed! ' . $this->sql();
throw new \Exception($msg, 9811, null);
}
} else {
$this->oosql_stmt = $this->query($this->sql());
}
if ($this->oosql_insert) {
$identity = $this->getEntityObject()->identity();
if ($identity !== false) {
if ($this->oosql_driver == 'pgsql') {
$identity = $this->oosql_table . '_' . $identity . '_seq';
}
$lastID = $this->lastInsertId($identity);
return $lastID;
}
}
return $this->oosql_stmt;
} | php | public function exe()
{
if ($this->oosql_fromFlag) {
$this->from();
}
if (null != $this->oosql_join) {
$this->sql($this->oosql_join);
}
if (null != $this->oosql_where) {
$this->sql($this->oosql_where);
}
if (null != $this->oosql_in) {
$this->sql($this->oosql_in);
}
if (null != $this->oosql_between) {
$this->sql($this->oosql_between);
}
if (null != $this->oosql_limit) {
$this->sql(' ' . $this->oosql_limit);
}
if (null != $this->oosql_group) {
$this->sql(' ' . $this->oosql_group);
}
if (null != $this->oosql_order) {
$this->sql(' ' . $this->oosql_order);
}
if (count($this->oosql_conValues) !== 0) {
$return = $this->prep($this->oosql_conValues);
$this->oosql_conValues = array();
if ($return === false) {
$msg = 'Execution failed! ' . $this->sql();
throw new \Exception($msg, 9811, null);
}
} else {
$this->oosql_stmt = $this->query($this->sql());
}
if ($this->oosql_insert) {
$identity = $this->getEntityObject()->identity();
if ($identity !== false) {
if ($this->oosql_driver == 'pgsql') {
$identity = $this->oosql_table . '_' . $identity . '_seq';
}
$lastID = $this->lastInsertId($identity);
return $lastID;
}
}
return $this->oosql_stmt;
} | [
"public",
"function",
"exe",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"oosql_fromFlag",
")",
"{",
"$",
"this",
"->",
"from",
"(",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_join",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"oosql_join",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_where",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"oosql_where",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_in",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"oosql_in",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_between",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"oosql_between",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_limit",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"' '",
".",
"$",
"this",
"->",
"oosql_limit",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_group",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"' '",
".",
"$",
"this",
"->",
"oosql_group",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"oosql_order",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"' '",
".",
"$",
"this",
"->",
"oosql_order",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"oosql_conValues",
")",
"!==",
"0",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"prep",
"(",
"$",
"this",
"->",
"oosql_conValues",
")",
";",
"$",
"this",
"->",
"oosql_conValues",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"return",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"'Execution failed! '",
".",
"$",
"this",
"->",
"sql",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9811",
",",
"null",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"oosql_stmt",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"this",
"->",
"sql",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"oosql_insert",
")",
"{",
"$",
"identity",
"=",
"$",
"this",
"->",
"getEntityObject",
"(",
")",
"->",
"identity",
"(",
")",
";",
"if",
"(",
"$",
"identity",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"oosql_driver",
"==",
"'pgsql'",
")",
"{",
"$",
"identity",
"=",
"$",
"this",
"->",
"oosql_table",
".",
"'_'",
".",
"$",
"identity",
".",
"'_seq'",
";",
"}",
"$",
"lastID",
"=",
"$",
"this",
"->",
"lastInsertId",
"(",
"$",
"identity",
")",
";",
"return",
"$",
"lastID",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"oosql_stmt",
";",
"}"
] | Checks flags and clauses then assembles and executes the query
@throws \Exception
@return string|object
@throws \Exception | [
"Checks",
"flags",
"and",
"clauses",
"then",
"assembles",
"and",
"executes",
"the",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L969-L1029 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.prepFetch | protected function prepFetch()
{
if ($this->oosql_sub) {
return $this;
}
if (!$this->oosql_select instanceof oosql) {
$this->select();
}
$this->oosql_select->exe();
if (!$this->oosql_stmt) {
$msg = 'Query returned no results! ' . $this->sql();
throw new \Exception($msg, 9814, null);
}
if (!is_array($this->oosql_fetchChanged)) {
$this->oosql_stmt->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->oosql_class);
} else {
call_user_func_array(array($this->oosql_stmt, 'setFetchMode'), $this->oosql_fetchChanged);
}
} | php | protected function prepFetch()
{
if ($this->oosql_sub) {
return $this;
}
if (!$this->oosql_select instanceof oosql) {
$this->select();
}
$this->oosql_select->exe();
if (!$this->oosql_stmt) {
$msg = 'Query returned no results! ' . $this->sql();
throw new \Exception($msg, 9814, null);
}
if (!is_array($this->oosql_fetchChanged)) {
$this->oosql_stmt->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->oosql_class);
} else {
call_user_func_array(array($this->oosql_stmt, 'setFetchMode'), $this->oosql_fetchChanged);
}
} | [
"protected",
"function",
"prepFetch",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"oosql_sub",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"oosql_select",
"instanceof",
"oosql",
")",
"{",
"$",
"this",
"->",
"select",
"(",
")",
";",
"}",
"$",
"this",
"->",
"oosql_select",
"->",
"exe",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"oosql_stmt",
")",
"{",
"$",
"msg",
"=",
"'Query returned no results! '",
".",
"$",
"this",
"->",
"sql",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9814",
",",
"null",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"oosql_fetchChanged",
")",
")",
"{",
"$",
"this",
"->",
"oosql_stmt",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
"|",
"\\",
"PDO",
"::",
"FETCH_PROPS_LATE",
",",
"$",
"this",
"->",
"oosql_class",
")",
";",
"}",
"else",
"{",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
"->",
"oosql_stmt",
",",
"'setFetchMode'",
")",
",",
"$",
"this",
"->",
"oosql_fetchChanged",
")",
";",
"}",
"}"
] | Returns the results of a SELECT if any
@throws \InvalidArgumentException
@throws \Exception
@return \Phiber\oosql\oosql|\Phiber\oosql\collection | [
"Returns",
"the",
"results",
"of",
"a",
"SELECT",
"if",
"any"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1037-L1058 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.with | public function with(array $related)
{
$relations = $this->getEntityObject()->getRelations();
foreach ($relations as $fk => $target) {
$table = strstr($target, '.', true);
if (in_array($table, $related)) {
$this->sql(" ,$table.*");
$this->join($table, "$this->oosql_table.$fk = $target");
} elseif (isset($related[$table])) {
foreach ($related[$table] as $field) {
$this->sql(" ,$table.$field");
}
$this->join($table, "$this->oosql_table.$fk = $target");
}
}
return $this;
} | php | public function with(array $related)
{
$relations = $this->getEntityObject()->getRelations();
foreach ($relations as $fk => $target) {
$table = strstr($target, '.', true);
if (in_array($table, $related)) {
$this->sql(" ,$table.*");
$this->join($table, "$this->oosql_table.$fk = $target");
} elseif (isset($related[$table])) {
foreach ($related[$table] as $field) {
$this->sql(" ,$table.$field");
}
$this->join($table, "$this->oosql_table.$fk = $target");
}
}
return $this;
} | [
"public",
"function",
"with",
"(",
"array",
"$",
"related",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"getEntityObject",
"(",
")",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"fk",
"=>",
"$",
"target",
")",
"{",
"$",
"table",
"=",
"strstr",
"(",
"$",
"target",
",",
"'.'",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"table",
",",
"$",
"related",
")",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"\" ,$table.*\"",
")",
";",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"\"$this->oosql_table.$fk = $target\"",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"related",
"[",
"$",
"table",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"related",
"[",
"$",
"table",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"sql",
"(",
"\" ,$table.$field\"",
")",
";",
"}",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"\"$this->oosql_table.$fk = $target\"",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Creates a join automatically based on the relationships of current entity
@param array $related
@return \Phiber\oosql\oosql | [
"Creates",
"a",
"join",
"automatically",
"based",
"on",
"the",
"relationships",
"of",
"current",
"entity"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1144-L1164 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.limit | public function limit($from, $size)
{
if (!$this->oosql_multiFlag) {
$this->oosql_limit = ' LIMIT ' . $from . ', ' . $size;
}
return $this;
} | php | public function limit($from, $size)
{
if (!$this->oosql_multiFlag) {
$this->oosql_limit = ' LIMIT ' . $from . ', ' . $size;
}
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"from",
",",
"$",
"size",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"oosql_multiFlag",
")",
"{",
"$",
"this",
"->",
"oosql_limit",
"=",
"' LIMIT '",
".",
"$",
"from",
".",
"', '",
".",
"$",
"size",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Creates a limit clause for MySQL
@param integer $from Offset tostart from
@param integer $size Chunk size
@return \Phiber\oosql\oosql | [
"Creates",
"a",
"limit",
"clause",
"for",
"MySQL"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1172-L1178 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.orderBy | public function orderBy($field, $dir = 'ASC')
{
if (!$this->oosql_multiFlag) {
$this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir;
}
return $this;
} | php | public function orderBy($field, $dir = 'ASC')
{
if (!$this->oosql_multiFlag) {
$this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir;
}
return $this;
} | [
"public",
"function",
"orderBy",
"(",
"$",
"field",
",",
"$",
"dir",
"=",
"'ASC'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"oosql_multiFlag",
")",
"{",
"$",
"this",
"->",
"oosql_order",
"=",
"' ORDER BY '",
".",
"$",
"field",
".",
"' '",
".",
"$",
"dir",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Creates an ORDER BY clause
@param string $field Field name
@param string DESC|ASC
@return \Phiber\oosql\oosql | [
"Creates",
"an",
"ORDER",
"BY",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1186-L1192 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.findOne | public function findOne($arg = null, $operator = '=', $fields = array('*'))
{
return $this->find($arg, $operator, $fields)->limit(0, 1);
} | php | public function findOne($arg = null, $operator = '=', $fields = array('*'))
{
return $this->find($arg, $operator, $fields)->limit(0, 1);
} | [
"public",
"function",
"findOne",
"(",
"$",
"arg",
"=",
"null",
",",
"$",
"operator",
"=",
"'='",
",",
"$",
"fields",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"arg",
",",
"$",
"operator",
",",
"$",
"fields",
")",
"->",
"limit",
"(",
"0",
",",
"1",
")",
";",
"}"
] | Find first random value returned by the query
@param string $arg
@param string $operator
@param array $fields
@return \Phiber\oosql\oosql | [
"Find",
"first",
"random",
"value",
"returned",
"by",
"the",
"query"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1201-L1204 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.findLimited | public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*'))
{
return $this->find($arg, $operator, $fields)->limit($from, $to);
} | php | public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*'))
{
return $this->find($arg, $operator, $fields)->limit($from, $to);
} | [
"public",
"function",
"findLimited",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"arg",
"=",
"null",
",",
"$",
"operator",
"=",
"'='",
",",
"$",
"fields",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"arg",
",",
"$",
"operator",
",",
"$",
"fields",
")",
"->",
"limit",
"(",
"$",
"from",
",",
"$",
"to",
")",
";",
"}"
] | Find with limit
@param string $arg
@param integer $from
@param integer $to
@param string $operator
@param array $fields
@return \Phiber\oosql\oosql | [
"Find",
"with",
"limit"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1215-L1218 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.find | public function find($arg = null, $operator = '=', $fields = array('*'))
{
if ($fields[0] == '*') {
$this->select();
} else {
$select_args = '';
foreach ($fields as $key => $field) {
if (is_array($field) && is_string($key)) {
foreach ($field as $part) {
$select_args .= $key . '.' . $part . ', ';
}
} else {
$select_args .= $this->oosql_table . '.' . $field . ', ';
}
}
$this->select(rtrim($select_args, ','));
}
if (!is_array($arg)) {
$obj = $this->getEntityObject();
$pri = $obj->getPrimary();
if (null !== $arg) {
$arg = array($pri[0] => $arg);
}
}
$i = 0;
$flag = '';
if (is_array($arg)) {
foreach ($arg as $col => $val) {
if ($i > 0) {
$flag = 'and';
}
$this->where("$this->oosql_table.$col $operator ?", $val, $flag);
$i++;
}
}
return $this;
} | php | public function find($arg = null, $operator = '=', $fields = array('*'))
{
if ($fields[0] == '*') {
$this->select();
} else {
$select_args = '';
foreach ($fields as $key => $field) {
if (is_array($field) && is_string($key)) {
foreach ($field as $part) {
$select_args .= $key . '.' . $part . ', ';
}
} else {
$select_args .= $this->oosql_table . '.' . $field . ', ';
}
}
$this->select(rtrim($select_args, ','));
}
if (!is_array($arg)) {
$obj = $this->getEntityObject();
$pri = $obj->getPrimary();
if (null !== $arg) {
$arg = array($pri[0] => $arg);
}
}
$i = 0;
$flag = '';
if (is_array($arg)) {
foreach ($arg as $col => $val) {
if ($i > 0) {
$flag = 'and';
}
$this->where("$this->oosql_table.$col $operator ?", $val, $flag);
$i++;
}
}
return $this;
} | [
"public",
"function",
"find",
"(",
"$",
"arg",
"=",
"null",
",",
"$",
"operator",
"=",
"'='",
",",
"$",
"fields",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"if",
"(",
"$",
"fields",
"[",
"0",
"]",
"==",
"'*'",
")",
"{",
"$",
"this",
"->",
"select",
"(",
")",
";",
"}",
"else",
"{",
"$",
"select_args",
"=",
"''",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"field",
")",
"&&",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"foreach",
"(",
"$",
"field",
"as",
"$",
"part",
")",
"{",
"$",
"select_args",
".=",
"$",
"key",
".",
"'.'",
".",
"$",
"part",
".",
"', '",
";",
"}",
"}",
"else",
"{",
"$",
"select_args",
".=",
"$",
"this",
"->",
"oosql_table",
".",
"'.'",
".",
"$",
"field",
".",
"', '",
";",
"}",
"}",
"$",
"this",
"->",
"select",
"(",
"rtrim",
"(",
"$",
"select_args",
",",
"','",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getEntityObject",
"(",
")",
";",
"$",
"pri",
"=",
"$",
"obj",
"->",
"getPrimary",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"arg",
")",
"{",
"$",
"arg",
"=",
"array",
"(",
"$",
"pri",
"[",
"0",
"]",
"=>",
"$",
"arg",
")",
";",
"}",
"}",
"$",
"i",
"=",
"0",
";",
"$",
"flag",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"arg",
")",
")",
"{",
"foreach",
"(",
"$",
"arg",
"as",
"$",
"col",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"i",
">",
"0",
")",
"{",
"$",
"flag",
"=",
"'and'",
";",
"}",
"$",
"this",
"->",
"where",
"(",
"\"$this->oosql_table.$col $operator ?\"",
",",
"$",
"val",
",",
"$",
"flag",
")",
";",
"$",
"i",
"++",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Find records with a filtering condition
@param string $arg
@param string $operator
@param array $fields
@return \Phiber\oosql\oosql | [
"Find",
"records",
"with",
"a",
"filtering",
"condition"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1227-L1267 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.alias | public function alias($alias = null)
{
if (null === $alias) {
$alias = $this->getTableAlias();
}
$this->oosql_table_alias = $alias;
return $this;
} | php | public function alias($alias = null)
{
if (null === $alias) {
$alias = $this->getTableAlias();
}
$this->oosql_table_alias = $alias;
return $this;
} | [
"public",
"function",
"alias",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"alias",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"getTableAlias",
"(",
")",
";",
"}",
"$",
"this",
"->",
"oosql_table_alias",
"=",
"$",
"alias",
";",
"return",
"$",
"this",
";",
"}"
] | Creates or bind provided alias with the current loaded table class
@param string $alias
@return \Phiber\oosql\oosql | [
"Creates",
"or",
"bind",
"provided",
"alias",
"with",
"the",
"current",
"loaded",
"table",
"class"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1274-L1281 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.notIn | public function notIn($item, array $list, $cond = null, $not = true)
{
return $this->in($item, $list, $cond, $not);
} | php | public function notIn($item, array $list, $cond = null, $not = true)
{
return $this->in($item, $list, $cond, $not);
} | [
"public",
"function",
"notIn",
"(",
"$",
"item",
",",
"array",
"$",
"list",
",",
"$",
"cond",
"=",
"null",
",",
"$",
"not",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"in",
"(",
"$",
"item",
",",
"$",
"list",
",",
"$",
"cond",
",",
"$",
"not",
")",
";",
"}"
] | Creates a NOT IN clause
@param mixed $item Subject of comparison
@param array $list A list of values
@param string $cond OR|AND
@param boolean $not | [
"Creates",
"a",
"NOT",
"IN",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1332-L1335 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.orIn | public function orIn($item, array $list, $cond = 'or', $not = false)
{
return $this->in($item, $list, $cond, $not);
} | php | public function orIn($item, array $list, $cond = 'or', $not = false)
{
return $this->in($item, $list, $cond, $not);
} | [
"public",
"function",
"orIn",
"(",
"$",
"item",
",",
"array",
"$",
"list",
",",
"$",
"cond",
"=",
"'or'",
",",
"$",
"not",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"in",
"(",
"$",
"item",
",",
"$",
"list",
",",
"$",
"cond",
",",
"$",
"not",
")",
";",
"}"
] | Creates a OR IN clause
@param mixed $item Subject of comparison
@param array $list A list of values
@param string $cond OR|AND
@param boolean $not | [
"Creates",
"a",
"OR",
"IN",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1344-L1347 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.orNotIn | public function orNotIn($item, array $list, $cond = 'or', $not = true)
{
return $this->in($item, $list, $cond, $not);
} | php | public function orNotIn($item, array $list, $cond = 'or', $not = true)
{
return $this->in($item, $list, $cond, $not);
} | [
"public",
"function",
"orNotIn",
"(",
"$",
"item",
",",
"array",
"$",
"list",
",",
"$",
"cond",
"=",
"'or'",
",",
"$",
"not",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"in",
"(",
"$",
"item",
",",
"$",
"list",
",",
"$",
"cond",
",",
"$",
"not",
")",
";",
"}"
] | Creates an OR NOT IN clause
@param mixed $item Subject of comparison
@param array $list A list of values
@param string $cond OR|AND
@param boolean $not | [
"Creates",
"an",
"OR",
"NOT",
"IN",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1356-L1359 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.in | public function in($item, array $list, $cond = null, $not = false)
{
$inClause = '';
if (null == $this->oosql_where && null == $this->oosql_in && null == $this->oosql_between) {
$inClause .= ' WHERE ';
} else {
$cnd = ' AND ';
if (null != $cond) {
if (strtolower($cond) == 'or') {
$cnd = ' OR ';
}
}
$inClause .= $cnd;
}
if ($not) {
$item = $item . ' NOT ';
}
$inClause .= $item . ' IN ';
$obj = $this;
$list = array_map(function ($data) use ($obj) {
return (!$obj->validInt($data)) ? $obj->quote($data) : $data;
}, $list);
$inClause .= '(' . implode(',', $list) . ')';
$this->oosql_in = $inClause;
return $this;
} | php | public function in($item, array $list, $cond = null, $not = false)
{
$inClause = '';
if (null == $this->oosql_where && null == $this->oosql_in && null == $this->oosql_between) {
$inClause .= ' WHERE ';
} else {
$cnd = ' AND ';
if (null != $cond) {
if (strtolower($cond) == 'or') {
$cnd = ' OR ';
}
}
$inClause .= $cnd;
}
if ($not) {
$item = $item . ' NOT ';
}
$inClause .= $item . ' IN ';
$obj = $this;
$list = array_map(function ($data) use ($obj) {
return (!$obj->validInt($data)) ? $obj->quote($data) : $data;
}, $list);
$inClause .= '(' . implode(',', $list) . ')';
$this->oosql_in = $inClause;
return $this;
} | [
"public",
"function",
"in",
"(",
"$",
"item",
",",
"array",
"$",
"list",
",",
"$",
"cond",
"=",
"null",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"inClause",
"=",
"''",
";",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"oosql_where",
"&&",
"null",
"==",
"$",
"this",
"->",
"oosql_in",
"&&",
"null",
"==",
"$",
"this",
"->",
"oosql_between",
")",
"{",
"$",
"inClause",
".=",
"' WHERE '",
";",
"}",
"else",
"{",
"$",
"cnd",
"=",
"' AND '",
";",
"if",
"(",
"null",
"!=",
"$",
"cond",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"cond",
")",
"==",
"'or'",
")",
"{",
"$",
"cnd",
"=",
"' OR '",
";",
"}",
"}",
"$",
"inClause",
".=",
"$",
"cnd",
";",
"}",
"if",
"(",
"$",
"not",
")",
"{",
"$",
"item",
"=",
"$",
"item",
".",
"' NOT '",
";",
"}",
"$",
"inClause",
".=",
"$",
"item",
".",
"' IN '",
";",
"$",
"obj",
"=",
"$",
"this",
";",
"$",
"list",
"=",
"array_map",
"(",
"function",
"(",
"$",
"data",
")",
"use",
"(",
"$",
"obj",
")",
"{",
"return",
"(",
"!",
"$",
"obj",
"->",
"validInt",
"(",
"$",
"data",
")",
")",
"?",
"$",
"obj",
"->",
"quote",
"(",
"$",
"data",
")",
":",
"$",
"data",
";",
"}",
",",
"$",
"list",
")",
";",
"$",
"inClause",
".=",
"'('",
".",
"implode",
"(",
"','",
",",
"$",
"list",
")",
".",
"')'",
";",
"$",
"this",
"->",
"oosql_in",
"=",
"$",
"inClause",
";",
"return",
"$",
"this",
";",
"}"
] | Creates an IN clause
@param mixed $item Subject of comparison
@param array $list A list of values
@param string $cond OR|AND
@param boolean $not | [
"Creates",
"an",
"IN",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1368-L1402 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.between | public function between($item, $low, $up, $cond = null, $not = false)
{
$bClause = '';
if (null == $this->oosql_where && null == $this->oosql_between && null == $this->oosql_in) {
$bClause .= ' WHERE ';
} else {
$cnd = ' AND ';
if (null != $cond) {
if (strtolower($cond) == 'or') {
$cnd = ' OR ';
}
}
$bClause .= $cnd;
}
if ($not) {
$item = $item . ' NOT ';
}
$bClause .= $item . ' BETWEEN ' . $low . ' AND ' . $up;
$this->oosql_between = $bClause;
return $this;
} | php | public function between($item, $low, $up, $cond = null, $not = false)
{
$bClause = '';
if (null == $this->oosql_where && null == $this->oosql_between && null == $this->oosql_in) {
$bClause .= ' WHERE ';
} else {
$cnd = ' AND ';
if (null != $cond) {
if (strtolower($cond) == 'or') {
$cnd = ' OR ';
}
}
$bClause .= $cnd;
}
if ($not) {
$item = $item . ' NOT ';
}
$bClause .= $item . ' BETWEEN ' . $low . ' AND ' . $up;
$this->oosql_between = $bClause;
return $this;
} | [
"public",
"function",
"between",
"(",
"$",
"item",
",",
"$",
"low",
",",
"$",
"up",
",",
"$",
"cond",
"=",
"null",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"bClause",
"=",
"''",
";",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"oosql_where",
"&&",
"null",
"==",
"$",
"this",
"->",
"oosql_between",
"&&",
"null",
"==",
"$",
"this",
"->",
"oosql_in",
")",
"{",
"$",
"bClause",
".=",
"' WHERE '",
";",
"}",
"else",
"{",
"$",
"cnd",
"=",
"' AND '",
";",
"if",
"(",
"null",
"!=",
"$",
"cond",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"cond",
")",
"==",
"'or'",
")",
"{",
"$",
"cnd",
"=",
"' OR '",
";",
"}",
"}",
"$",
"bClause",
".=",
"$",
"cnd",
";",
"}",
"if",
"(",
"$",
"not",
")",
"{",
"$",
"item",
"=",
"$",
"item",
".",
"' NOT '",
";",
"}",
"$",
"bClause",
".=",
"$",
"item",
".",
"' BETWEEN '",
".",
"$",
"low",
".",
"' AND '",
".",
"$",
"up",
";",
"$",
"this",
"->",
"oosql_between",
"=",
"$",
"bClause",
";",
"return",
"$",
"this",
";",
"}"
] | Creates a BETWEEN clause
@param mixed $item
@param mixed $low
@param mixed $up
@param string $cond OR|AND
@param boolean $not
@return \Phiber\oosql\oosql | [
"Creates",
"a",
"BETWEEN",
"clause"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1413-L1440 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.transactional | public static function transactional($fn)
{
$oosql = self::getInstance('oosql', 'void');
if (!$oosql->beginTransaction()) {
$msg = 'Could not start this transaction. BeginTransaction failed!';
throw new \Exception($msg, 9815, null);
}
if (is_callable($fn)) {
$ret = $fn($oosql);
return $ret;
}
$msg = 'Please pass a Lamda function as a parameter to this method!';
throw new \Exception($msg, 9816, null);
} | php | public static function transactional($fn)
{
$oosql = self::getInstance('oosql', 'void');
if (!$oosql->beginTransaction()) {
$msg = 'Could not start this transaction. BeginTransaction failed!';
throw new \Exception($msg, 9815, null);
}
if (is_callable($fn)) {
$ret = $fn($oosql);
return $ret;
}
$msg = 'Please pass a Lamda function as a parameter to this method!';
throw new \Exception($msg, 9816, null);
} | [
"public",
"static",
"function",
"transactional",
"(",
"$",
"fn",
")",
"{",
"$",
"oosql",
"=",
"self",
"::",
"getInstance",
"(",
"'oosql'",
",",
"'void'",
")",
";",
"if",
"(",
"!",
"$",
"oosql",
"->",
"beginTransaction",
"(",
")",
")",
"{",
"$",
"msg",
"=",
"'Could not start this transaction. BeginTransaction failed!'",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9815",
",",
"null",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"fn",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"fn",
"(",
"$",
"oosql",
")",
";",
"return",
"$",
"ret",
";",
"}",
"$",
"msg",
"=",
"'Please pass a Lamda function as a parameter to this method!'",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
",",
"9816",
",",
"null",
")",
";",
"}"
] | Starts a transaction if current driver supports it
@param callable $fn A Closure
@throws \Exception
@return mixed Whatever the Closure returns is passed to the higher scope variable if any | [
"Starts",
"a",
"transaction",
"if",
"current",
"driver",
"supports",
"it"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1474-L1487 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.getNamedLock | public function getNamedLock($name, $timeout = 15)
{
$stmt = $this->query('SELECT GET_LOCK("' . $name . '", '.$timeout .')');
return $stmt->fetch(self::FETCH_COLUMN);
} | php | public function getNamedLock($name, $timeout = 15)
{
$stmt = $this->query('SELECT GET_LOCK("' . $name . '", '.$timeout .')');
return $stmt->fetch(self::FETCH_COLUMN);
} | [
"public",
"function",
"getNamedLock",
"(",
"$",
"name",
",",
"$",
"timeout",
"=",
"15",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"query",
"(",
"'SELECT GET_LOCK(\"'",
".",
"$",
"name",
".",
"'\", '",
".",
"$",
"timeout",
".",
"')'",
")",
";",
"return",
"$",
"stmt",
"->",
"fetch",
"(",
"self",
"::",
"FETCH_COLUMN",
")",
";",
"}"
] | Try to obtain a named lock
@author Housseyn Guettaf
@param string $name - Lock name
@param int $timeout - Timeout
@return mixed | [
"Try",
"to",
"obtain",
"a",
"named",
"lock"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1499-L1504 | train |
ghousseyn/phiber | library/oosql/oosql.php | oosql.releaseNamedLock | public function releaseNamedLock($name)
{
$stmt = $this->query('SELECT RELEASE_LOCK("' . $name . '")');
return $stmt->fetch(self::FETCH_COLUMN);
} | php | public function releaseNamedLock($name)
{
$stmt = $this->query('SELECT RELEASE_LOCK("' . $name . '")');
return $stmt->fetch(self::FETCH_COLUMN);
} | [
"public",
"function",
"releaseNamedLock",
"(",
"$",
"name",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"query",
"(",
"'SELECT RELEASE_LOCK(\"'",
".",
"$",
"name",
".",
"'\")'",
")",
";",
"return",
"$",
"stmt",
"->",
"fetch",
"(",
"self",
"::",
"FETCH_COLUMN",
")",
";",
"}"
] | releases a named lock
@author Housseyn Guettaf
@param string $name - Lock name
@return mixed | [
"releases",
"a",
"named",
"lock"
] | 2574249d49b6930a0123a310a32073a105cdd486 | https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1514-L1519 | train |
zbox/UnifiedPush | src/Zbox/UnifiedPush/Notification/PayloadHandler/APNS.php | APNS.packPayload | public function packPayload($payload)
{
$payload = JsonEncoder::jsonEncode($payload);
/** @var APNSMessage $message */
$message = $this->message;
$recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier();
$messageRecipientId = $this->notificationId . '_' . $recipientId;
$packedPayload =
pack('C', 1). // Command push
pack('N', $messageRecipientId).
pack('N', $message->getExpirationTime()->format('U')).
pack('n', 32). // Token binary length
pack('H*', $recipientId);
pack('n', strlen($payload));
$packedPayload .= $payload;
return $packedPayload;
} | php | public function packPayload($payload)
{
$payload = JsonEncoder::jsonEncode($payload);
/** @var APNSMessage $message */
$message = $this->message;
$recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier();
$messageRecipientId = $this->notificationId . '_' . $recipientId;
$packedPayload =
pack('C', 1). // Command push
pack('N', $messageRecipientId).
pack('N', $message->getExpirationTime()->format('U')).
pack('n', 32). // Token binary length
pack('H*', $recipientId);
pack('n', strlen($payload));
$packedPayload .= $payload;
return $packedPayload;
} | [
"public",
"function",
"packPayload",
"(",
"$",
"payload",
")",
"{",
"$",
"payload",
"=",
"JsonEncoder",
"::",
"jsonEncode",
"(",
"$",
"payload",
")",
";",
"/** @var APNSMessage $message */",
"$",
"message",
"=",
"$",
"this",
"->",
"message",
";",
"$",
"recipientId",
"=",
"$",
"message",
"->",
"getRecipientDeviceCollection",
"(",
")",
"->",
"current",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"messageRecipientId",
"=",
"$",
"this",
"->",
"notificationId",
".",
"'_'",
".",
"$",
"recipientId",
";",
"$",
"packedPayload",
"=",
"pack",
"(",
"'C'",
",",
"1",
")",
".",
"// Command push",
"pack",
"(",
"'N'",
",",
"$",
"messageRecipientId",
")",
".",
"pack",
"(",
"'N'",
",",
"$",
"message",
"->",
"getExpirationTime",
"(",
")",
"->",
"format",
"(",
"'U'",
")",
")",
".",
"pack",
"(",
"'n'",
",",
"32",
")",
".",
"// Token binary length",
"pack",
"(",
"'H*'",
",",
"$",
"recipientId",
")",
";",
"pack",
"(",
"'n'",
",",
"strlen",
"(",
"$",
"payload",
")",
")",
";",
"$",
"packedPayload",
".=",
"$",
"payload",
";",
"return",
"$",
"packedPayload",
";",
"}"
] | Pack message body into binary string
@param array $payload
@return string | [
"Pack",
"message",
"body",
"into",
"binary",
"string"
] | 47da2d0577b18ac709cd947c68541014001e1866 | https://github.com/zbox/UnifiedPush/blob/47da2d0577b18ac709cd947c68541014001e1866/src/Zbox/UnifiedPush/Notification/PayloadHandler/APNS.php#L77-L99 | train |
newestindustry/ginger-rest | src/Ginger/Routes.php | Routes.set | public static function set($uri, $path = false)
{
$route = new \Ginger\Route($uri, $path);
self::$routes[$route->route] = $route;
} | php | public static function set($uri, $path = false)
{
$route = new \Ginger\Route($uri, $path);
self::$routes[$route->route] = $route;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"uri",
",",
"$",
"path",
"=",
"false",
")",
"{",
"$",
"route",
"=",
"new",
"\\",
"Ginger",
"\\",
"Route",
"(",
"$",
"uri",
",",
"$",
"path",
")",
";",
"self",
"::",
"$",
"routes",
"[",
"$",
"route",
"->",
"route",
"]",
"=",
"$",
"route",
";",
"}"
] | set function.
@access public
@static
@param mixed $uri
@param bool $path (default: false)
@return void | [
"set",
"function",
"."
] | 482b77dc122a60ab0bf143a3c4a1e67168985c83 | https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/Routes.php#L48-L52 | train |
newestindustry/ginger-rest | src/Ginger/Routes.php | Routes.detect | public static function detect($uri)
{
$routes = self::get();
$found = false;
foreach($routes as $key => $route) {
$currentLength = strlen($route->route);
if(substr($uri, 0, $currentLength) == $route->route) {
$found = $route;
break;
}
}
return $found;
} | php | public static function detect($uri)
{
$routes = self::get();
$found = false;
foreach($routes as $key => $route) {
$currentLength = strlen($route->route);
if(substr($uri, 0, $currentLength) == $route->route) {
$found = $route;
break;
}
}
return $found;
} | [
"public",
"static",
"function",
"detect",
"(",
"$",
"uri",
")",
"{",
"$",
"routes",
"=",
"self",
"::",
"get",
"(",
")",
";",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"key",
"=>",
"$",
"route",
")",
"{",
"$",
"currentLength",
"=",
"strlen",
"(",
"$",
"route",
"->",
"route",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"uri",
",",
"0",
",",
"$",
"currentLength",
")",
"==",
"$",
"route",
"->",
"route",
")",
"{",
"$",
"found",
"=",
"$",
"route",
";",
"break",
";",
"}",
"}",
"return",
"$",
"found",
";",
"}"
] | detect function.
@access public
@static
@param string $uri
@return false|\Ginger\Route | [
"detect",
"function",
"."
] | 482b77dc122a60ab0bf143a3c4a1e67168985c83 | https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/Routes.php#L74-L87 | train |
schpill/thin | src/Html/Qwerly.php | Qwerly._lookUpBy | private function _lookUpBy($service, $data)
{
$batch = false;
$urlFormat = self::$URLS[$service];
if (is_array($data)) {
$data = implode(',', $data);
$batch = true;
}
$url = self::BASE_URL . sprintf($urlFormat, urlencode($data)) . sprintf(self::API_KEY, $this->_apiKey);
$this->_client->setUri($url);
$request = $this->_client->request();
$data = json_decode($request->getBody(), true);
if ($request->getStatus() == self::TRY_AGAIN_LATER_CODE || $request->getStatus() == self::NOT_FOUND_CODE) {
throw new \Thin\Exception(
$data['message'], $data['status']
);
} else if ($request->getStatus() == 400) {
throw new \Thin\Exception(
$data['message'], $data['status']
);
} else if (!$request->isSuccessful()) {
throw new \Thin\Exception($request->getBody());
}
if ($batch) {
return new \Thin\Html\Qwerly\Batch($data);
} else {
return new \Thin\Html\Qwerly\User($data);
}
} | php | private function _lookUpBy($service, $data)
{
$batch = false;
$urlFormat = self::$URLS[$service];
if (is_array($data)) {
$data = implode(',', $data);
$batch = true;
}
$url = self::BASE_URL . sprintf($urlFormat, urlencode($data)) . sprintf(self::API_KEY, $this->_apiKey);
$this->_client->setUri($url);
$request = $this->_client->request();
$data = json_decode($request->getBody(), true);
if ($request->getStatus() == self::TRY_AGAIN_LATER_CODE || $request->getStatus() == self::NOT_FOUND_CODE) {
throw new \Thin\Exception(
$data['message'], $data['status']
);
} else if ($request->getStatus() == 400) {
throw new \Thin\Exception(
$data['message'], $data['status']
);
} else if (!$request->isSuccessful()) {
throw new \Thin\Exception($request->getBody());
}
if ($batch) {
return new \Thin\Html\Qwerly\Batch($data);
} else {
return new \Thin\Html\Qwerly\User($data);
}
} | [
"private",
"function",
"_lookUpBy",
"(",
"$",
"service",
",",
"$",
"data",
")",
"{",
"$",
"batch",
"=",
"false",
";",
"$",
"urlFormat",
"=",
"self",
"::",
"$",
"URLS",
"[",
"$",
"service",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"implode",
"(",
"','",
",",
"$",
"data",
")",
";",
"$",
"batch",
"=",
"true",
";",
"}",
"$",
"url",
"=",
"self",
"::",
"BASE_URL",
".",
"sprintf",
"(",
"$",
"urlFormat",
",",
"urlencode",
"(",
"$",
"data",
")",
")",
".",
"sprintf",
"(",
"self",
"::",
"API_KEY",
",",
"$",
"this",
"->",
"_apiKey",
")",
";",
"$",
"this",
"->",
"_client",
"->",
"setUri",
"(",
"$",
"url",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"_client",
"->",
"request",
"(",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getStatus",
"(",
")",
"==",
"self",
"::",
"TRY_AGAIN_LATER_CODE",
"||",
"$",
"request",
"->",
"getStatus",
"(",
")",
"==",
"self",
"::",
"NOT_FOUND_CODE",
")",
"{",
"throw",
"new",
"\\",
"Thin",
"\\",
"Exception",
"(",
"$",
"data",
"[",
"'message'",
"]",
",",
"$",
"data",
"[",
"'status'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"request",
"->",
"getStatus",
"(",
")",
"==",
"400",
")",
"{",
"throw",
"new",
"\\",
"Thin",
"\\",
"Exception",
"(",
"$",
"data",
"[",
"'message'",
"]",
",",
"$",
"data",
"[",
"'status'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"request",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Thin",
"\\",
"Exception",
"(",
"$",
"request",
"->",
"getBody",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"batch",
")",
"{",
"return",
"new",
"\\",
"Thin",
"\\",
"Html",
"\\",
"Qwerly",
"\\",
"Batch",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"return",
"new",
"\\",
"Thin",
"\\",
"Html",
"\\",
"Qwerly",
"\\",
"User",
"(",
"$",
"data",
")",
";",
"}",
"}"
] | Looks up an user using the given service data.
@param string $service Service to look up with.
@param mixed $data Data relevant to the service.
@return Qwerly_API_Response|null
@throws Qwerly_API_ErrorException
@throws Qwerly_API_NotFoundException | [
"Looks",
"up",
"an",
"user",
"using",
"the",
"given",
"service",
"data",
"."
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Qwerly.php#L120-L154 | train |
chilimatic/chilimatic-framework | lib/database/sql/mysql/Collection.php | Collection._checkdatabase | private function _checkdatabase($database)
{
if (count($this->_collection) == 0) {
$this->_collection[$database] = new $database();
return $this->_collection[$database];
}
$new = false;
foreach ($this->_collection as $db) {
if ($db === $database) continue;
$new = true;
}
if ($new === true) {
$this->_collection[$database] = new $database();
}
return false;
} | php | private function _checkdatabase($database)
{
if (count($this->_collection) == 0) {
$this->_collection[$database] = new $database();
return $this->_collection[$database];
}
$new = false;
foreach ($this->_collection as $db) {
if ($db === $database) continue;
$new = true;
}
if ($new === true) {
$this->_collection[$database] = new $database();
}
return false;
} | [
"private",
"function",
"_checkdatabase",
"(",
"$",
"database",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_collection",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"_collection",
"[",
"$",
"database",
"]",
"=",
"new",
"$",
"database",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_collection",
"[",
"$",
"database",
"]",
";",
"}",
"$",
"new",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"_collection",
"as",
"$",
"db",
")",
"{",
"if",
"(",
"$",
"db",
"===",
"$",
"database",
")",
"continue",
";",
"$",
"new",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"new",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"_collection",
"[",
"$",
"database",
"]",
"=",
"new",
"$",
"database",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | checks if a database already exists
@param $database
@return $this | [
"checks",
"if",
"a",
"database",
"already",
"exists"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Collection.php#L79-L99 | train |
acacha/forge-publish | src/Console/Commands/Traits/PossibleEmails.php | PossibleEmails.getPossibleEmails | protected function getPossibleEmails()
{
$this->checkGit();
$github_email = null;
$github_email = str_replace(array("\r", "\n"), '', shell_exec('git config user.email'));
if (filter_var($github_email, FILTER_VALIDATE_EMAIL)) {
return [ $github_email ];
} else {
return [];
}
} | php | protected function getPossibleEmails()
{
$this->checkGit();
$github_email = null;
$github_email = str_replace(array("\r", "\n"), '', shell_exec('git config user.email'));
if (filter_var($github_email, FILTER_VALIDATE_EMAIL)) {
return [ $github_email ];
} else {
return [];
}
} | [
"protected",
"function",
"getPossibleEmails",
"(",
")",
"{",
"$",
"this",
"->",
"checkGit",
"(",
")",
";",
"$",
"github_email",
"=",
"null",
";",
"$",
"github_email",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\"",
",",
"\"\\n\"",
")",
",",
"''",
",",
"shell_exec",
"(",
"'git config user.email'",
")",
")",
";",
"if",
"(",
"filter_var",
"(",
"$",
"github_email",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"{",
"return",
"[",
"$",
"github_email",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] | Get possible emails
@return array | [
"Get",
"possible",
"emails"
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/PossibleEmails.php#L20-L31 | train |
acacha/forge-publish | src/Console/Commands/PublishMySQLUsers.php | PublishMySQLUsers.createMySQLUser | protected function createMySQLUser()
{
$this->checkParameters();
$this->url = $this->obtainAPIURLEndpoint();
$this->http->post($this->url, [
'form_params' => $this->getData(),
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
]
]
);
} | php | protected function createMySQLUser()
{
$this->checkParameters();
$this->url = $this->obtainAPIURLEndpoint();
$this->http->post($this->url, [
'form_params' => $this->getData(),
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
]
]
);
} | [
"protected",
"function",
"createMySQLUser",
"(",
")",
"{",
"$",
"this",
"->",
"checkParameters",
"(",
")",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"this",
"->",
"obtainAPIURLEndpoint",
"(",
")",
";",
"$",
"this",
"->",
"http",
"->",
"post",
"(",
"$",
"this",
"->",
"url",
",",
"[",
"'form_params'",
"=>",
"$",
"this",
"->",
"getData",
"(",
")",
",",
"'headers'",
"=>",
"[",
"'X-Requested-With'",
"=>",
"'XMLHttpRequest'",
",",
"'Authorization'",
"=>",
"'Bearer '",
".",
"fp_env",
"(",
"'ACACHA_FORGE_ACCESS_TOKEN'",
")",
"]",
"]",
")",
";",
"}"
] | Create MySQL user. | [
"Create",
"MySQL",
"user",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishMySQLUsers.php#L75-L87 | train |
acacha/forge-publish | src/Console/Commands/PublishMySQLUsers.php | PublishMySQLUsers.listMySQLUsers | protected function listMySQLUsers()
{
$this->url = $this->obtainAPIURLEndpointForList();
$response = $this->http->get($this->url, [
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
]
]
);
$users = json_decode($response->getBody(), true) ;
if ($this->option('dump')) {
dump($users);
}
if (empty($users)) {
$this->error('No users found.');
die();
}
$headers = ['Id', 'Server Id','Name','Status','Created at'];
$rows = [];
foreach ($users as $user) {
$rows[] = [
$user['id'],
$user['serverId'],
$user['name'],
$user['status'],
$user['createdAt']
];
}
$this->table($headers, $rows);
} | php | protected function listMySQLUsers()
{
$this->url = $this->obtainAPIURLEndpointForList();
$response = $this->http->get($this->url, [
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
]
]
);
$users = json_decode($response->getBody(), true) ;
if ($this->option('dump')) {
dump($users);
}
if (empty($users)) {
$this->error('No users found.');
die();
}
$headers = ['Id', 'Server Id','Name','Status','Created at'];
$rows = [];
foreach ($users as $user) {
$rows[] = [
$user['id'],
$user['serverId'],
$user['name'],
$user['status'],
$user['createdAt']
];
}
$this->table($headers, $rows);
} | [
"protected",
"function",
"listMySQLUsers",
"(",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"this",
"->",
"obtainAPIURLEndpointForList",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"http",
"->",
"get",
"(",
"$",
"this",
"->",
"url",
",",
"[",
"'headers'",
"=>",
"[",
"'X-Requested-With'",
"=>",
"'XMLHttpRequest'",
",",
"'Authorization'",
"=>",
"'Bearer '",
".",
"fp_env",
"(",
"'ACACHA_FORGE_ACCESS_TOKEN'",
")",
"]",
"]",
")",
";",
"$",
"users",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'dump'",
")",
")",
"{",
"dump",
"(",
"$",
"users",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"users",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'No users found.'",
")",
";",
"die",
"(",
")",
";",
"}",
"$",
"headers",
"=",
"[",
"'Id'",
",",
"'Server Id'",
",",
"'Name'",
",",
"'Status'",
",",
"'Created at'",
"]",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"rows",
"[",
"]",
"=",
"[",
"$",
"user",
"[",
"'id'",
"]",
",",
"$",
"user",
"[",
"'serverId'",
"]",
",",
"$",
"user",
"[",
"'name'",
"]",
",",
"$",
"user",
"[",
"'status'",
"]",
",",
"$",
"user",
"[",
"'createdAt'",
"]",
"]",
";",
"}",
"$",
"this",
"->",
"table",
"(",
"$",
"headers",
",",
"$",
"rows",
")",
";",
"}"
] | List MySQL users. | [
"List",
"MySQL",
"users",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishMySQLUsers.php#L92-L129 | train |
acacha/forge-publish | src/Console/Commands/Traits/InteractsWithEnvironment.php | InteractsWithEnvironment.addValueToEnv | protected function addValueToEnv($key, $value)
{
$env_path = base_path('.env');
$sed_command = "/bin/sed -i '/^$key=/d' " . $env_path;
passthru($sed_command);
File::append($env_path, "\n$key=$value\n");
} | php | protected function addValueToEnv($key, $value)
{
$env_path = base_path('.env');
$sed_command = "/bin/sed -i '/^$key=/d' " . $env_path;
passthru($sed_command);
File::append($env_path, "\n$key=$value\n");
} | [
"protected",
"function",
"addValueToEnv",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"env_path",
"=",
"base_path",
"(",
"'.env'",
")",
";",
"$",
"sed_command",
"=",
"\"/bin/sed -i '/^$key=/d' \"",
".",
"$",
"env_path",
";",
"passthru",
"(",
"$",
"sed_command",
")",
";",
"File",
"::",
"append",
"(",
"$",
"env_path",
",",
"\"\\n$key=$value\\n\"",
")",
";",
"}"
] | Add value to env.
@param $key
@param $value | [
"Add",
"value",
"to",
"env",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/InteractsWithEnvironment.php#L20-L26 | train |
PlatoCreative/silverstripe-sections | code/models/Section.php | Section.Anchor | public function Anchor(){
if ($this->MenuTitle && $this->ShowInMenus) {
return strtolower(trim(preg_replace('/[^a-zA-Z0-9]+/', '-',$this->MenuTitle), '-'));
}
return false;
} | php | public function Anchor(){
if ($this->MenuTitle && $this->ShowInMenus) {
return strtolower(trim(preg_replace('/[^a-zA-Z0-9]+/', '-',$this->MenuTitle), '-'));
}
return false;
} | [
"public",
"function",
"Anchor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"MenuTitle",
"&&",
"$",
"this",
"->",
"ShowInMenus",
")",
"{",
"return",
"strtolower",
"(",
"trim",
"(",
"preg_replace",
"(",
"'/[^a-zA-Z0-9]+/'",
",",
"'-'",
",",
"$",
"this",
"->",
"MenuTitle",
")",
",",
"'-'",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Applies anchor to section in template.
@return string $classes | [
"Applies",
"anchor",
"to",
"section",
"in",
"template",
"."
] | 54c96146ea8cc625b00ee009753539658f10d01a | https://github.com/PlatoCreative/silverstripe-sections/blob/54c96146ea8cc625b00ee009753539658f10d01a/code/models/Section.php#L245-L250 | train |
PlatoCreative/silverstripe-sections | code/models/Section.php | Section.Classes | public function Classes(){
$classes = array($this->config()->get('base_class'));
if ($this->Style) {
$classes[] = strtolower($this->Style).'-'.strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
}else{
$classes[] = strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
}
return implode(' ',$classes);
} | php | public function Classes(){
$classes = array($this->config()->get('base_class'));
if ($this->Style) {
$classes[] = strtolower($this->Style).'-'.strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
}else{
$classes[] = strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
}
return implode(' ',$classes);
} | [
"public",
"function",
"Classes",
"(",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'base_class'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Style",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"Style",
")",
".",
"'-'",
".",
"strtolower",
"(",
"preg_replace",
"(",
"'/([a-z]+)([A-Z0-9])/'",
",",
"'$1-$2'",
",",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"classes",
"[",
"]",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/([a-z]+)([A-Z0-9])/'",
",",
"'$1-$2'",
",",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}"
] | Applies classes to section in template.
@return string $classes | [
"Applies",
"classes",
"to",
"section",
"in",
"template",
"."
] | 54c96146ea8cc625b00ee009753539658f10d01a | https://github.com/PlatoCreative/silverstripe-sections/blob/54c96146ea8cc625b00ee009753539658f10d01a/code/models/Section.php#L269-L277 | train |
smalldb/libSmalldb | class/Utils/Utils.php | Utils.write_json_file | static function write_json_file($filename, $json_array, array $whitelist = null, $json_options = null)
{
$stop_snippet = "<?php printf('_%c%c}%c',34,10,10);__halt_compiler();?>";
if ($whitelist === null) {
// Put stop snippet on begin.
$result = array_merge(array('_' => null), $json_array);
} else {
// Whitelisted keys first (if they exist in $json_array), then stop snippet, then rest.
$header = array_intersect_key(array_flip($whitelist), $json_array);
$header['_'] = null;
$result = array_merge($header, $json_array);
// Replace '<?' with '<_?' in all whitelisted values, so injected PHP will not execute.
foreach ($whitelist as $k) {
if (array_key_exists($k, $result) && is_string($result[$k])) {
$result[$k] = str_replace('<?', '<_?', $result[$k]);
}
}
}
// Put stop snipped at marked position (it is here to prevent
// overwriting from $json_array).
$result['_'] = $stop_snippet;
$json_str = json_encode($result, $json_options === null
? (defined('JSON_PRETTY_PRINT')
? JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
: JSON_NUMERIC_CHECK)
: $json_options & ~(JSON_HEX_TAG | JSON_HEX_APOS));
if ($filename === null) {
return $json_str;
} else {
return file_put_contents($filename, $json_str);
}
} | php | static function write_json_file($filename, $json_array, array $whitelist = null, $json_options = null)
{
$stop_snippet = "<?php printf('_%c%c}%c',34,10,10);__halt_compiler();?>";
if ($whitelist === null) {
// Put stop snippet on begin.
$result = array_merge(array('_' => null), $json_array);
} else {
// Whitelisted keys first (if they exist in $json_array), then stop snippet, then rest.
$header = array_intersect_key(array_flip($whitelist), $json_array);
$header['_'] = null;
$result = array_merge($header, $json_array);
// Replace '<?' with '<_?' in all whitelisted values, so injected PHP will not execute.
foreach ($whitelist as $k) {
if (array_key_exists($k, $result) && is_string($result[$k])) {
$result[$k] = str_replace('<?', '<_?', $result[$k]);
}
}
}
// Put stop snipped at marked position (it is here to prevent
// overwriting from $json_array).
$result['_'] = $stop_snippet;
$json_str = json_encode($result, $json_options === null
? (defined('JSON_PRETTY_PRINT')
? JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
: JSON_NUMERIC_CHECK)
: $json_options & ~(JSON_HEX_TAG | JSON_HEX_APOS));
if ($filename === null) {
return $json_str;
} else {
return file_put_contents($filename, $json_str);
}
} | [
"static",
"function",
"write_json_file",
"(",
"$",
"filename",
",",
"$",
"json_array",
",",
"array",
"$",
"whitelist",
"=",
"null",
",",
"$",
"json_options",
"=",
"null",
")",
"{",
"$",
"stop_snippet",
"=",
"\"<?php printf('_%c%c}%c',34,10,10);__halt_compiler();?>\"",
";",
"if",
"(",
"$",
"whitelist",
"===",
"null",
")",
"{",
"// Put stop snippet on begin.",
"$",
"result",
"=",
"array_merge",
"(",
"array",
"(",
"'_'",
"=>",
"null",
")",
",",
"$",
"json_array",
")",
";",
"}",
"else",
"{",
"// Whitelisted keys first (if they exist in $json_array), then stop snippet, then rest.",
"$",
"header",
"=",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"whitelist",
")",
",",
"$",
"json_array",
")",
";",
"$",
"header",
"[",
"'_'",
"]",
"=",
"null",
";",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"header",
",",
"$",
"json_array",
")",
";",
"// Replace '<?' with '<_?' in all whitelisted values, so injected PHP will not execute.",
"foreach",
"(",
"$",
"whitelist",
"as",
"$",
"k",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"k",
",",
"$",
"result",
")",
"&&",
"is_string",
"(",
"$",
"result",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"str_replace",
"(",
"'<?'",
",",
"'<_?'",
",",
"$",
"result",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}",
"// Put stop snipped at marked position (it is here to prevent ",
"// overwriting from $json_array).",
"$",
"result",
"[",
"'_'",
"]",
"=",
"$",
"stop_snippet",
";",
"$",
"json_str",
"=",
"json_encode",
"(",
"$",
"result",
",",
"$",
"json_options",
"===",
"null",
"?",
"(",
"defined",
"(",
"'JSON_PRETTY_PRINT'",
")",
"?",
"JSON_NUMERIC_CHECK",
"|",
"JSON_PRETTY_PRINT",
"|",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_UNESCAPED_UNICODE",
":",
"JSON_NUMERIC_CHECK",
")",
":",
"$",
"json_options",
"&",
"~",
"(",
"JSON_HEX_TAG",
"|",
"JSON_HEX_APOS",
")",
")",
";",
"if",
"(",
"$",
"filename",
"===",
"null",
")",
"{",
"return",
"$",
"json_str",
";",
"}",
"else",
"{",
"return",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"json_str",
")",
";",
"}",
"}"
] | Encode array to JSON using json_encode, but insert PHP snippet to protect
sensitive data.
If $filename is set, JSON will be written to given file. Otherwise you are
expected to store returned string into *.json.php file.
Stop snippet: When JSON file is evaluated as PHP, stop snippet will
interrupt evaluation without breaking JSON syntax, only underscore
key is appended (and overwritten if exists).
To make sure that whitelisted keys does not contain PHP tags, all
occurrences of '<?' are replaced with '<_?' in whitelisted values.
Default $json_options are:
- PHP >= 5.4: JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
- PHP < 5.4: JSON_NUMERIC_CHECK
Options JSON_HEX_TAG and JSON_HEX_APOS are disabled, becouse they break
PHP snippet. | [
"Encode",
"array",
"to",
"JSON",
"using",
"json_encode",
"but",
"insert",
"PHP",
"snippet",
"to",
"protect",
"sensitive",
"data",
"."
] | b94d22af5014e8060d0530fc7043768cdc57b01a | https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/Utils/Utils.php#L262-L297 | train |
SpoonX/SxBootstrap | src/SxBootstrap/Service/BootstrapFilter.php | BootstrapFilter.filterLoad | public function filterLoad(AssetInterface $asset)
{
$assetRoot = $asset->getSourceRoot();
$assetPath = $asset->getSourcePath();
$assetImportDir = dirname($assetRoot . '/' . $assetPath);
$importDir = $this->config->getBootstrapPath() . '/less';
$this->setupLoadPaths($assetImportDir);
// Make sure we _always_ have the bootstrap import dir.
if ($importDir !== $assetImportDir) {
$this->lessFilter->addLoadPath($importDir);
}
$variables = array_merge(
$this->extractVariables($importDir . '/variables.less'),
$this->config->getVariables()
);
$variablesString = '';
foreach ($variables as $key => $value) {
$variablesString .= "@$key:$value;" . PHP_EOL;
}
if ('bootstrap.less' === $assetPath) {
$imports = $this->filterImportFiles(array_unique(array_merge(
$this->extractImports($importDir . '/bootstrap.less'),
$this->extractImports($importDir . '/responsive.less'),
$this->config->getCustomComponents()
)));
$assetContent = $variablesString . $imports;
$asset->setContent($assetContent);
} else {
$asset->setContent($variablesString . $asset->getContent());
}
$this->lessFilter->filterLoad($asset);
} | php | public function filterLoad(AssetInterface $asset)
{
$assetRoot = $asset->getSourceRoot();
$assetPath = $asset->getSourcePath();
$assetImportDir = dirname($assetRoot . '/' . $assetPath);
$importDir = $this->config->getBootstrapPath() . '/less';
$this->setupLoadPaths($assetImportDir);
// Make sure we _always_ have the bootstrap import dir.
if ($importDir !== $assetImportDir) {
$this->lessFilter->addLoadPath($importDir);
}
$variables = array_merge(
$this->extractVariables($importDir . '/variables.less'),
$this->config->getVariables()
);
$variablesString = '';
foreach ($variables as $key => $value) {
$variablesString .= "@$key:$value;" . PHP_EOL;
}
if ('bootstrap.less' === $assetPath) {
$imports = $this->filterImportFiles(array_unique(array_merge(
$this->extractImports($importDir . '/bootstrap.less'),
$this->extractImports($importDir . '/responsive.less'),
$this->config->getCustomComponents()
)));
$assetContent = $variablesString . $imports;
$asset->setContent($assetContent);
} else {
$asset->setContent($variablesString . $asset->getContent());
}
$this->lessFilter->filterLoad($asset);
} | [
"public",
"function",
"filterLoad",
"(",
"AssetInterface",
"$",
"asset",
")",
"{",
"$",
"assetRoot",
"=",
"$",
"asset",
"->",
"getSourceRoot",
"(",
")",
";",
"$",
"assetPath",
"=",
"$",
"asset",
"->",
"getSourcePath",
"(",
")",
";",
"$",
"assetImportDir",
"=",
"dirname",
"(",
"$",
"assetRoot",
".",
"'/'",
".",
"$",
"assetPath",
")",
";",
"$",
"importDir",
"=",
"$",
"this",
"->",
"config",
"->",
"getBootstrapPath",
"(",
")",
".",
"'/less'",
";",
"$",
"this",
"->",
"setupLoadPaths",
"(",
"$",
"assetImportDir",
")",
";",
"// Make sure we _always_ have the bootstrap import dir.",
"if",
"(",
"$",
"importDir",
"!==",
"$",
"assetImportDir",
")",
"{",
"$",
"this",
"->",
"lessFilter",
"->",
"addLoadPath",
"(",
"$",
"importDir",
")",
";",
"}",
"$",
"variables",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"extractVariables",
"(",
"$",
"importDir",
".",
"'/variables.less'",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getVariables",
"(",
")",
")",
";",
"$",
"variablesString",
"=",
"''",
";",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"variablesString",
".=",
"\"@$key:$value;\"",
".",
"PHP_EOL",
";",
"}",
"if",
"(",
"'bootstrap.less'",
"===",
"$",
"assetPath",
")",
"{",
"$",
"imports",
"=",
"$",
"this",
"->",
"filterImportFiles",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"extractImports",
"(",
"$",
"importDir",
".",
"'/bootstrap.less'",
")",
",",
"$",
"this",
"->",
"extractImports",
"(",
"$",
"importDir",
".",
"'/responsive.less'",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getCustomComponents",
"(",
")",
")",
")",
")",
";",
"$",
"assetContent",
"=",
"$",
"variablesString",
".",
"$",
"imports",
";",
"$",
"asset",
"->",
"setContent",
"(",
"$",
"assetContent",
")",
";",
"}",
"else",
"{",
"$",
"asset",
"->",
"setContent",
"(",
"$",
"variablesString",
".",
"$",
"asset",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"lessFilter",
"->",
"filterLoad",
"(",
"$",
"asset",
")",
";",
"}"
] | Sets the by-config generated imports on the asset.
{@inheritDoc} | [
"Sets",
"the",
"by",
"-",
"config",
"generated",
"imports",
"on",
"the",
"asset",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/Service/BootstrapFilter.php#L86-L127 | train |
SpoonX/SxBootstrap | src/SxBootstrap/Service/BootstrapFilter.php | BootstrapFilter.extractImports | protected function extractImports($importsFile)
{
$str = file_get_contents($importsFile);
preg_match_all('/@import "(?!variables)(?<imports>[\w-_\.]+)";/', $str, $matches);
return array_map('trim', $matches['imports']);
} | php | protected function extractImports($importsFile)
{
$str = file_get_contents($importsFile);
preg_match_all('/@import "(?!variables)(?<imports>[\w-_\.]+)";/', $str, $matches);
return array_map('trim', $matches['imports']);
} | [
"protected",
"function",
"extractImports",
"(",
"$",
"importsFile",
")",
"{",
"$",
"str",
"=",
"file_get_contents",
"(",
"$",
"importsFile",
")",
";",
"preg_match_all",
"(",
"'/@import \"(?!variables)(?<imports>[\\w-_\\.]+)\";/'",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"return",
"array_map",
"(",
"'trim'",
",",
"$",
"matches",
"[",
"'imports'",
"]",
")",
";",
"}"
] | Extract the imports from the import file.
@param string $importsFile
@return array The extracted imports | [
"Extract",
"the",
"imports",
"from",
"the",
"import",
"file",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/Service/BootstrapFilter.php#L136-L143 | train |
SpoonX/SxBootstrap | src/SxBootstrap/Service/BootstrapFilter.php | BootstrapFilter.extractVariables | protected function extractVariables($variablesFile)
{
$str = file_get_contents($variablesFile);
$parts = explode(';', preg_replace('/(\/\/.*?\n|\s\n|\s{2,})/', '', $str));
$vars = array();
foreach ($parts as $part) {
$varMeta = explode(':', $part);
if (empty($varMeta[0]) || empty($varMeta[1])) {
continue;
}
$vars[substr(trim($varMeta[0]), 1)] = trim($varMeta[1]);
}
return $vars;
} | php | protected function extractVariables($variablesFile)
{
$str = file_get_contents($variablesFile);
$parts = explode(';', preg_replace('/(\/\/.*?\n|\s\n|\s{2,})/', '', $str));
$vars = array();
foreach ($parts as $part) {
$varMeta = explode(':', $part);
if (empty($varMeta[0]) || empty($varMeta[1])) {
continue;
}
$vars[substr(trim($varMeta[0]), 1)] = trim($varMeta[1]);
}
return $vars;
} | [
"protected",
"function",
"extractVariables",
"(",
"$",
"variablesFile",
")",
"{",
"$",
"str",
"=",
"file_get_contents",
"(",
"$",
"variablesFile",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"';'",
",",
"preg_replace",
"(",
"'/(\\/\\/.*?\\n|\\s\\n|\\s{2,})/'",
",",
"''",
",",
"$",
"str",
")",
")",
";",
"$",
"vars",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"varMeta",
"=",
"explode",
"(",
"':'",
",",
"$",
"part",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"varMeta",
"[",
"0",
"]",
")",
"||",
"empty",
"(",
"$",
"varMeta",
"[",
"1",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"vars",
"[",
"substr",
"(",
"trim",
"(",
"$",
"varMeta",
"[",
"0",
"]",
")",
",",
"1",
")",
"]",
"=",
"trim",
"(",
"$",
"varMeta",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"vars",
";",
"}"
] | Extract the variables from the less file.
@param string $variablesFile The path to the less file
@return array The extracted variables | [
"Extract",
"the",
"variables",
"from",
"the",
"less",
"file",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/Service/BootstrapFilter.php#L152-L167 | train |
SpoonX/SxBootstrap | src/SxBootstrap/Service/BootstrapFilter.php | BootstrapFilter.filterImportFiles | protected function filterImportFiles(array $imports)
{
$config = $this->config;
$excludedComponents = $config->getExcludedComponents();
$includedComponents = $config->getIncludedComponents();
if (!empty($excludedComponents) && !empty($includedComponents)) {
throw new Exception\RuntimeException(
'You may not set both excluded and included components.'
);
}
if (!empty($excludedComponents)) {
$imports = $this->removeImportFiles($imports, $excludedComponents);
} elseif (!empty($includedComponents)) {
$imports = $this->addImportFiles($imports, $includedComponents);
}
$imports = $this->setupFontAwesome($imports);
array_walk($imports, function (&$val) {
$val = "@import \"$val\";";
});
return implode(PHP_EOL, $imports);
} | php | protected function filterImportFiles(array $imports)
{
$config = $this->config;
$excludedComponents = $config->getExcludedComponents();
$includedComponents = $config->getIncludedComponents();
if (!empty($excludedComponents) && !empty($includedComponents)) {
throw new Exception\RuntimeException(
'You may not set both excluded and included components.'
);
}
if (!empty($excludedComponents)) {
$imports = $this->removeImportFiles($imports, $excludedComponents);
} elseif (!empty($includedComponents)) {
$imports = $this->addImportFiles($imports, $includedComponents);
}
$imports = $this->setupFontAwesome($imports);
array_walk($imports, function (&$val) {
$val = "@import \"$val\";";
});
return implode(PHP_EOL, $imports);
} | [
"protected",
"function",
"filterImportFiles",
"(",
"array",
"$",
"imports",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"excludedComponents",
"=",
"$",
"config",
"->",
"getExcludedComponents",
"(",
")",
";",
"$",
"includedComponents",
"=",
"$",
"config",
"->",
"getIncludedComponents",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedComponents",
")",
"&&",
"!",
"empty",
"(",
"$",
"includedComponents",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'You may not set both excluded and included components.'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedComponents",
")",
")",
"{",
"$",
"imports",
"=",
"$",
"this",
"->",
"removeImportFiles",
"(",
"$",
"imports",
",",
"$",
"excludedComponents",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"includedComponents",
")",
")",
"{",
"$",
"imports",
"=",
"$",
"this",
"->",
"addImportFiles",
"(",
"$",
"imports",
",",
"$",
"includedComponents",
")",
";",
"}",
"$",
"imports",
"=",
"$",
"this",
"->",
"setupFontAwesome",
"(",
"$",
"imports",
")",
";",
"array_walk",
"(",
"$",
"imports",
",",
"function",
"(",
"&",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"\"@import \\\"$val\\\";\"",
";",
"}",
")",
";",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"imports",
")",
";",
"}"
] | Filter the import files needed.
@param array $imports
@throws \SxBootstrap\Exception\RuntimeException
@return array | [
"Filter",
"the",
"import",
"files",
"needed",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/Service/BootstrapFilter.php#L177-L202 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.