repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.oneOf | public function oneOf($allowed, $message = null)
{
if (is_string($allowed)) {
$allowed = explode(',', $allowed);
}
$this->setRule(__FUNCTION__, function($val, $args)
{
return in_array($val, $args[0]);
}, $message, array($allowed));
return $this;
} | php | public function oneOf($allowed, $message = null)
{
if (is_string($allowed)) {
$allowed = explode(',', $allowed);
}
$this->setRule(__FUNCTION__, function($val, $args)
{
return in_array($val, $args[0]);
}, $message, array($allowed));
return $this;
} | [
"public",
"function",
"oneOf",
"(",
"$",
"allowed",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"allowed",
")",
")",
"{",
"$",
"allowed",
"=",
"explode",
"(",
"','",
",",
"$",
"allowed",
")",
";",
"}",
"$",
"this... | Field has to be one of the allowed ones.
@param string|array $allowed Allowed values.
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"one",
"of",
"the",
"allowed",
"ones",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L604-L615 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator._applyFilter | protected function _applyFilter(&$val)
{
if (is_array($val)) {
foreach($val as $key => &$item) {
$this->_applyFilter($item);
}
} else {
foreach($this->filters as $filter) {
$val = $filter($val);
}
}
} | php | protected function _applyFilter(&$val)
{
if (is_array($val)) {
foreach($val as $key => &$item) {
$this->_applyFilter($item);
}
} else {
foreach($this->filters as $filter) {
$val = $filter($val);
}
}
} | [
"protected",
"function",
"_applyFilter",
"(",
"&",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"foreach",
"(",
"$",
"val",
"as",
"$",
"key",
"=>",
"&",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"_applyFilter",
"("... | recursively apply filters to a value
@access protected
@param mixed $val reference
@return void | [
"recursively",
"apply",
"filters",
"to",
"a",
"value"
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L686-L697 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator._validate | protected function _validate($key, $val)
{
// try each rule function
foreach ($this->rules as $rule => $is_true) {
if ($is_true) {
$function = $this->functions[$rule];
$args = $this->arguments[$rule]; // Arguments of rule
$valid = true;
if(is_array($val)) {
foreach($val as $v) {
$valid = $valid && (empty($args)) ? $function($v) : $function($v, $args);
}
} else {
$valid = (empty($args)) ? $function($val) : $function($val, $args);
}
if ($valid === FALSE) {
$this->registerError($rule, $key);
$this->rules = array(); // reset rules
$this->filters = array();
return FALSE;
}
}
}
$this->validData[$key] = $val;
return TRUE;
} | php | protected function _validate($key, $val)
{
// try each rule function
foreach ($this->rules as $rule => $is_true) {
if ($is_true) {
$function = $this->functions[$rule];
$args = $this->arguments[$rule]; // Arguments of rule
$valid = true;
if(is_array($val)) {
foreach($val as $v) {
$valid = $valid && (empty($args)) ? $function($v) : $function($v, $args);
}
} else {
$valid = (empty($args)) ? $function($val) : $function($val, $args);
}
if ($valid === FALSE) {
$this->registerError($rule, $key);
$this->rules = array(); // reset rules
$this->filters = array();
return FALSE;
}
}
}
$this->validData[$key] = $val;
return TRUE;
} | [
"protected",
"function",
"_validate",
"(",
"$",
"key",
",",
"$",
"val",
")",
"{",
"// try each rule function",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
"=>",
"$",
"is_true",
")",
"{",
"if",
"(",
"$",
"is_true",
")",
"{",
"$",
"f... | recursively validates a value
@access protected
@param string $key
@param mixed $val
@return bool | [
"recursively",
"validates",
"a",
"value"
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L732-L761 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.getAllErrors | public function getAllErrors($keys = true)
{
return ($keys == true) ? $this->errors : array_values($this->errors);
} | php | public function getAllErrors($keys = true)
{
return ($keys == true) ? $this->errors : array_values($this->errors);
} | [
"public",
"function",
"getAllErrors",
"(",
"$",
"keys",
"=",
"true",
")",
"{",
"return",
"(",
"$",
"keys",
"==",
"true",
")",
"?",
"$",
"this",
"->",
"errors",
":",
"array_values",
"(",
"$",
"this",
"->",
"errors",
")",
";",
"}"
] | Get all errors.
@return array | [
"Get",
"all",
"errors",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L788-L791 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.registerError | protected function registerError($rule, $key, $message = null)
{
if (empty($message)) {
$message = $this->messages[$rule];
}
$this->errors[$key] = sprintf($message, $this->fields[$key]);
} | php | protected function registerError($rule, $key, $message = null)
{
if (empty($message)) {
$message = $this->messages[$rule];
}
$this->errors[$key] = sprintf($message, $this->fields[$key]);
} | [
"protected",
"function",
"registerError",
"(",
"$",
"rule",
",",
"$",
"key",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"messages",
"[",
"$",
"rule",
... | Register error.
@param string $rule
@param string $key
@param string $message | [
"Register",
"error",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L853-L860 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.setRule | public function setRule($rule, $function, $message = '', $args = array())
{
if (!array_key_exists($rule, $this->rules)) {
$this->rules[$rule] = TRUE;
if (!array_key_exists($rule, $this->functions)) {
if (!is_callable($function)) {
die('Invalid function for rule: ' . $rule);
}
$this->functions[$rule] = $function;
}
$this->arguments[$rule] = $args; // Specific arguments for rule
$this->messages[$rule] = (empty($message)) ? $this->_getDefaultMessage($rule, $args) : $message;
}
} | php | public function setRule($rule, $function, $message = '', $args = array())
{
if (!array_key_exists($rule, $this->rules)) {
$this->rules[$rule] = TRUE;
if (!array_key_exists($rule, $this->functions)) {
if (!is_callable($function)) {
die('Invalid function for rule: ' . $rule);
}
$this->functions[$rule] = $function;
}
$this->arguments[$rule] = $args; // Specific arguments for rule
$this->messages[$rule] = (empty($message)) ? $this->_getDefaultMessage($rule, $args) : $message;
}
} | [
"public",
"function",
"setRule",
"(",
"$",
"rule",
",",
"$",
"function",
",",
"$",
"message",
"=",
"''",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"rule",
",",
"$",
"this",
"->",
"rules",
")... | Set rule.
@param string $rule
@param closure $function
@param string $message
@param array $args | [
"Set",
"rule",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L870-L884 | train |
datto/core-enumerator | src/Core/Enumerator.php | Enumerator.getClasses | public static function getClasses($namespace, $conditions = [])
{
self::_setupRoot();
$namespace = explode('\\', trim($namespace, '\\'));
$composerNamespaces = self::getComposerNamespaces();
$searchPaths = [];
// for each Composer namespace, assess whether it may contain the namespace $namespace.
foreach ( $composerNamespaces as $ns => $paths )
{
$nsTrimmed = explode('\\', trim($ns, '\\'));
for ( $i = min(count($nsTrimmed), count($namespace)); $i > 0; $i-- ) {
if ( array_slice($nsTrimmed, 0, $i) === array_slice($namespace, 0, $i) ) {
$searchPaths[] = [
'prefix' => $nsTrimmed
, 'paths' => $paths
];
continue;
}
}
}
// $searchPaths now contains a list of PSR-4 namespaces we must search for
// classes under the namespace $namespace.
// FIXME crawling everything under the sun is potentially very time-consuming. It would make a lot of
// sense to be able to generate a cache classes specifying what interfaces each class implements, etc.
$result = [];
foreach ( $searchPaths as $pathspec ) {
foreach ( $pathspec['paths'] as $path ) {
// Determine the path under which the namespace we are searching for will exist for this pathspace
$path = $path
. DIRECTORY_SEPARATOR
. implode(DIRECTORY_SEPARATOR, array_slice($namespace, count($pathspec['prefix'])));
$prefix = count($pathspec['prefix']) > count($namespace) ? implode('\\', $pathspec['prefix']) : implode('\\', $namespace);
// if that path exists, go ahead and search it for class files and append them to the result.
if ( is_dir($path) ) {
$result = array_merge($result, self::searchPath($prefix, rtrim($path, DIRECTORY_SEPARATOR), $conditions));
}
}
}
return $result;
} | php | public static function getClasses($namespace, $conditions = [])
{
self::_setupRoot();
$namespace = explode('\\', trim($namespace, '\\'));
$composerNamespaces = self::getComposerNamespaces();
$searchPaths = [];
// for each Composer namespace, assess whether it may contain the namespace $namespace.
foreach ( $composerNamespaces as $ns => $paths )
{
$nsTrimmed = explode('\\', trim($ns, '\\'));
for ( $i = min(count($nsTrimmed), count($namespace)); $i > 0; $i-- ) {
if ( array_slice($nsTrimmed, 0, $i) === array_slice($namespace, 0, $i) ) {
$searchPaths[] = [
'prefix' => $nsTrimmed
, 'paths' => $paths
];
continue;
}
}
}
// $searchPaths now contains a list of PSR-4 namespaces we must search for
// classes under the namespace $namespace.
// FIXME crawling everything under the sun is potentially very time-consuming. It would make a lot of
// sense to be able to generate a cache classes specifying what interfaces each class implements, etc.
$result = [];
foreach ( $searchPaths as $pathspec ) {
foreach ( $pathspec['paths'] as $path ) {
// Determine the path under which the namespace we are searching for will exist for this pathspace
$path = $path
. DIRECTORY_SEPARATOR
. implode(DIRECTORY_SEPARATOR, array_slice($namespace, count($pathspec['prefix'])));
$prefix = count($pathspec['prefix']) > count($namespace) ? implode('\\', $pathspec['prefix']) : implode('\\', $namespace);
// if that path exists, go ahead and search it for class files and append them to the result.
if ( is_dir($path) ) {
$result = array_merge($result, self::searchPath($prefix, rtrim($path, DIRECTORY_SEPARATOR), $conditions));
}
}
}
return $result;
} | [
"public",
"static",
"function",
"getClasses",
"(",
"$",
"namespace",
",",
"$",
"conditions",
"=",
"[",
"]",
")",
"{",
"self",
"::",
"_setupRoot",
"(",
")",
";",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"trim",
"(",
"$",
"namespace",
",",
... | Return a list of classes under a given namespace. It is an error to enumerate the root namespace.
@param string Namespace name. Trailing backslash may be omitted.
@param Limiting rules. An array of constraints on the returned results. Currently
the only supported constraints are "implements" (string - class name) and "abstract"
(boolean).
Use it: [ ['implements' => 'Some\Interface', 'abstract' => false] ]
@return array
@static | [
"Return",
"a",
"list",
"of",
"classes",
"under",
"a",
"given",
"namespace",
".",
"It",
"is",
"an",
"error",
"to",
"enumerate",
"the",
"root",
"namespace",
"."
] | 90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39 | https://github.com/datto/core-enumerator/blob/90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39/src/Core/Enumerator.php#L53-L102 | train |
datto/core-enumerator | src/Core/Enumerator.php | Enumerator.getComposerModule | public static function getComposerModule($className)
{
global $Composer;
if ( $result = $Composer->findFile($className) ) {
$result = substr($result, strlen(self::$root));
if ( preg_match('#^vendor/([a-z0-9_-]+/[a-z0-9_-]+)/#', $result, $match) ) {
return $match[1];
}
}
return null;
} | php | public static function getComposerModule($className)
{
global $Composer;
if ( $result = $Composer->findFile($className) ) {
$result = substr($result, strlen(self::$root));
if ( preg_match('#^vendor/([a-z0-9_-]+/[a-z0-9_-]+)/#', $result, $match) ) {
return $match[1];
}
}
return null;
} | [
"public",
"static",
"function",
"getComposerModule",
"(",
"$",
"className",
")",
"{",
"global",
"$",
"Composer",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"Composer",
"->",
"findFile",
"(",
"$",
"className",
")",
")",
"{",
"$",
"result",
"=",
"substr",
... | Return the name of the composer module where a given class lives.
@param string Class name
@return mixed String if it lives in a module, or null if the root | [
"Return",
"the",
"name",
"of",
"the",
"composer",
"module",
"where",
"a",
"given",
"class",
"lives",
"."
] | 90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39 | https://github.com/datto/core-enumerator/blob/90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39/src/Core/Enumerator.php#L110-L123 | train |
datto/core-enumerator | src/Core/Enumerator.php | Enumerator.getComposerNamespaces | private static function getComposerNamespaces()
{
static $result = null;
if ( !is_array($result) ) {
$result = require self::$root . 'vendor/composer/autoload_namespaces.php';
foreach ( $result as $ns => &$paths ) {
$subpath = trim(str_replace('\\', DIRECTORY_SEPARATOR, $ns), DIRECTORY_SEPARATOR);
foreach ( $paths as &$path ) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
if ( is_dir("$path/$subpath") ) {
$path = "$path/$subpath";
}
}
unset($path);
}
unset($paths);
$psr4 = require self::$root . 'vendor/composer/autoload_psr4.php';
foreach ( $psr4 as $ns => $paths )
{
if ( isset($result[$ns]) ) {
$result[$ns] = array_merge($result[$ns], $paths);
}
else {
$result[$ns] = $paths;
}
}
}
return $result;
} | php | private static function getComposerNamespaces()
{
static $result = null;
if ( !is_array($result) ) {
$result = require self::$root . 'vendor/composer/autoload_namespaces.php';
foreach ( $result as $ns => &$paths ) {
$subpath = trim(str_replace('\\', DIRECTORY_SEPARATOR, $ns), DIRECTORY_SEPARATOR);
foreach ( $paths as &$path ) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
if ( is_dir("$path/$subpath") ) {
$path = "$path/$subpath";
}
}
unset($path);
}
unset($paths);
$psr4 = require self::$root . 'vendor/composer/autoload_psr4.php';
foreach ( $psr4 as $ns => $paths )
{
if ( isset($result[$ns]) ) {
$result[$ns] = array_merge($result[$ns], $paths);
}
else {
$result[$ns] = $paths;
}
}
}
return $result;
} | [
"private",
"static",
"function",
"getComposerNamespaces",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"require",
"self",
"::",
"$",
"root",
".",
"'vendor/c... | Get Composer's namespace list.
@return array
@access private
@static | [
"Get",
"Composer",
"s",
"namespace",
"list",
"."
] | 90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39 | https://github.com/datto/core-enumerator/blob/90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39/src/Core/Enumerator.php#L132-L165 | train |
datto/core-enumerator | src/Core/Enumerator.php | Enumerator.searchPath | private static function searchPath($prefix, $path, $conditions)
{
$result = [];
$dir = new DirectoryIterator($path);
foreach ( $dir as $entry ) {
if ( $entry->isDot() ) {
continue;
}
$de = $entry->getFilename();
if ( $entry->isDir() && preg_match('/^[A-Za-z_]+$/', $de) ) {
// it's a subdirectory, search it
$result = array_merge($result, self::searchPath("$prefix\\$de", $path . DIRECTORY_SEPARATOR . $de, $conditions));
}
else if ( preg_match('/\.php$/', $de) ) {
// FIXME I'm using a regex test here because that in theory is quicker than having
// PHP parse the file. Also, this is deliberately designed to exclude abstract classes,
// which will cause class_exists() to return (bool)true.
$foundNamespace = $foundClass = false;
$className = preg_replace('/\.php$/', '', $de);
if ( $fp = @fopen($filePath = "$path/$de", 'r') ) {
while ( !feof($fp) && ($line = fgets($fp)) ) {
// FIXME PHP leaves pretty little room for error in the namespace declaration
// line. This is still a little needlessly picky - if someone has a space between
// the namespace name and the semicolon this test will fail, as well as dumber
// stuff like the word "namespace" being mixed case/uppercase.
if ( trim($line) === "namespace $prefix;" ) {
$foundNamespace = true;
}
// This fairly complicated regexp covers "implements" with multiple inheritance,
// "extends" and a fair amount of syntactical deviation.
else if ( preg_match('/^\s*class ([A-Za-z0-9_]+)(?:\s+(?:extends|implements) [A-Za-z0-9_\\\\]+(?:\s*,\s*[A-Za-z0-9_]+)*)*\s*[\{,]?$/', trim($line), $match)
&& ($match[1] === "\\$prefix\\$className" || $match[1] === $className) ) {
$foundClass = true;
}
// if we have found the namespace declaration and the class declaration,
// we no longer need any more information from this file, so break and
// close the handle.
if ( $foundNamespace && $foundClass ) {
break;
}
}
fclose($fp);
}
// if we found the namespace declaration and the class declaration, append
// the discovered class to the result list.
if ( $foundNamespace && $foundClass )
{
// fully qualified class name
$fqcn = "$prefix\\$className";
// conditions are an OR between each, AND within an individual condition
$condCount = 0;
// ReflectionClass instance - created only if necessary
$rfl = null;
foreach ( $conditions as $cond ) {
$condResult = true;
foreach ( $cond as $test => $value ) {
switch($test) {
case 'implements':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( !$rfl->implementsInterface($value) ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
case 'extends':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( $rfl->getParentClass()->getName() !== $value ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
case 'abstract':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( $rfl->isAbstract() !== $value ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
}
}
if ( $condResult ) {
$condCount++;
}
}
if ( $condCount || count($conditions) === 0 ) {
$result[] = $fqcn;
}
}
}
}
return $result;
} | php | private static function searchPath($prefix, $path, $conditions)
{
$result = [];
$dir = new DirectoryIterator($path);
foreach ( $dir as $entry ) {
if ( $entry->isDot() ) {
continue;
}
$de = $entry->getFilename();
if ( $entry->isDir() && preg_match('/^[A-Za-z_]+$/', $de) ) {
// it's a subdirectory, search it
$result = array_merge($result, self::searchPath("$prefix\\$de", $path . DIRECTORY_SEPARATOR . $de, $conditions));
}
else if ( preg_match('/\.php$/', $de) ) {
// FIXME I'm using a regex test here because that in theory is quicker than having
// PHP parse the file. Also, this is deliberately designed to exclude abstract classes,
// which will cause class_exists() to return (bool)true.
$foundNamespace = $foundClass = false;
$className = preg_replace('/\.php$/', '', $de);
if ( $fp = @fopen($filePath = "$path/$de", 'r') ) {
while ( !feof($fp) && ($line = fgets($fp)) ) {
// FIXME PHP leaves pretty little room for error in the namespace declaration
// line. This is still a little needlessly picky - if someone has a space between
// the namespace name and the semicolon this test will fail, as well as dumber
// stuff like the word "namespace" being mixed case/uppercase.
if ( trim($line) === "namespace $prefix;" ) {
$foundNamespace = true;
}
// This fairly complicated regexp covers "implements" with multiple inheritance,
// "extends" and a fair amount of syntactical deviation.
else if ( preg_match('/^\s*class ([A-Za-z0-9_]+)(?:\s+(?:extends|implements) [A-Za-z0-9_\\\\]+(?:\s*,\s*[A-Za-z0-9_]+)*)*\s*[\{,]?$/', trim($line), $match)
&& ($match[1] === "\\$prefix\\$className" || $match[1] === $className) ) {
$foundClass = true;
}
// if we have found the namespace declaration and the class declaration,
// we no longer need any more information from this file, so break and
// close the handle.
if ( $foundNamespace && $foundClass ) {
break;
}
}
fclose($fp);
}
// if we found the namespace declaration and the class declaration, append
// the discovered class to the result list.
if ( $foundNamespace && $foundClass )
{
// fully qualified class name
$fqcn = "$prefix\\$className";
// conditions are an OR between each, AND within an individual condition
$condCount = 0;
// ReflectionClass instance - created only if necessary
$rfl = null;
foreach ( $conditions as $cond ) {
$condResult = true;
foreach ( $cond as $test => $value ) {
switch($test) {
case 'implements':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( !$rfl->implementsInterface($value) ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
case 'extends':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( $rfl->getParentClass()->getName() !== $value ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
case 'abstract':
if ( empty($rfl) ) {
$rfl = new \ReflectionClass($fqcn);
}
if ( $rfl->isAbstract() !== $value ) {
$condResult = false;
break 2; // lazy evaluation
}
break;
}
}
if ( $condResult ) {
$condCount++;
}
}
if ( $condCount || count($conditions) === 0 ) {
$result[] = $fqcn;
}
}
}
}
return $result;
} | [
"private",
"static",
"function",
"searchPath",
"(",
"$",
"prefix",
",",
"$",
"path",
",",
"$",
"conditions",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"dir",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
... | Search one directory recursively for classes belonging to a given namespace.
@param string Namespace to search for
@param string Directory to search
@param array Search conditions
@return array
@access private
@static | [
"Search",
"one",
"directory",
"recursively",
"for",
"classes",
"belonging",
"to",
"a",
"given",
"namespace",
"."
] | 90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39 | https://github.com/datto/core-enumerator/blob/90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39/src/Core/Enumerator.php#L177-L287 | train |
datto/core-enumerator | src/Core/Enumerator.php | Enumerator._setupRoot | private static function _setupRoot()
{
if ( !empty(self::$root) ) {
// avoid duplicating efforts... only set root if it's not already set
return;
}
if ( defined('ROOT') ) {
self::$root = rtrim(ROOT, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
else if ( !empty($GLOBALS['baseDir']) ) {
self::$root = rtrim($GLOBALS['baseDir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
else if ( strpos(__FILE__, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR) !== false ) {
// fall back to guessing the project root from the path...
// we're in /vendor/datto/core-enumerator/src/Core
$path = __FILE__;
// up 5 levels
while (!file_exists("$path/autoload.php")) {
$path = dirname($path);
}
$path = dirname($path);
self::$root = $path . DIRECTORY_SEPARATOR;
}
else if ( class_exists("Composer\\Autoload\\ClassLoader") ) {
// go up until we find vendor/autoload.php - last resort
$path = dirname(__FILE__);
while ( $path && !file_exists($path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php') ) {
$path = dirname($path);
}
if ( !empty($path) ) {
var_dump($path);
self::$root = $path . DIRECTORY_SEPARATOR;
}
}
if ( empty(self::$root) ) {
throw new \Exception("Unable to determine project base directory");
}
} | php | private static function _setupRoot()
{
if ( !empty(self::$root) ) {
// avoid duplicating efforts... only set root if it's not already set
return;
}
if ( defined('ROOT') ) {
self::$root = rtrim(ROOT, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
else if ( !empty($GLOBALS['baseDir']) ) {
self::$root = rtrim($GLOBALS['baseDir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
else if ( strpos(__FILE__, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR) !== false ) {
// fall back to guessing the project root from the path...
// we're in /vendor/datto/core-enumerator/src/Core
$path = __FILE__;
// up 5 levels
while (!file_exists("$path/autoload.php")) {
$path = dirname($path);
}
$path = dirname($path);
self::$root = $path . DIRECTORY_SEPARATOR;
}
else if ( class_exists("Composer\\Autoload\\ClassLoader") ) {
// go up until we find vendor/autoload.php - last resort
$path = dirname(__FILE__);
while ( $path && !file_exists($path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php') ) {
$path = dirname($path);
}
if ( !empty($path) ) {
var_dump($path);
self::$root = $path . DIRECTORY_SEPARATOR;
}
}
if ( empty(self::$root) ) {
throw new \Exception("Unable to determine project base directory");
}
} | [
"private",
"static",
"function",
"_setupRoot",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"root",
")",
")",
"{",
"// avoid duplicating efforts... only set root if it's not already set ",
"return",
";",
"}",
"if",
"(",
"defined",
"(",
"'ROOT'... | Determine the project root directory. | [
"Determine",
"the",
"project",
"root",
"directory",
"."
] | 90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39 | https://github.com/datto/core-enumerator/blob/90cdcc90cc0453c35e7b2d2e941d23abd6e9cf39/src/Core/Enumerator.php#L292-L335 | train |
phramework/phramework | src/URIStrategy/URITemplate.php | URITemplate.URI | public static function URI()
{
$REDIRECT_QUERY_STRING =
isset($_SERVER['QUERY_STRING'])
? $_SERVER['QUERY_STRING']
: '';
$REDIRECT_URL = '';
if (isset($_SERVER['REQUEST_URI'])) {
$url_parts = parse_url($_SERVER['REQUEST_URI']);
$REDIRECT_URL = $url_parts['path'];
}
$URI = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
if (substr($REDIRECT_URL, 0, strlen($URI)) == $URI) {
$URI = substr($REDIRECT_URL, strlen($URI));
}
$URI = urldecode($URI) . '/';
$URI = trim($URI, '/');
$parameters = [];
//Extract parameters from QUERY string
parse_str($REDIRECT_QUERY_STRING, $parameters);
return [$URI, $parameters];
} | php | public static function URI()
{
$REDIRECT_QUERY_STRING =
isset($_SERVER['QUERY_STRING'])
? $_SERVER['QUERY_STRING']
: '';
$REDIRECT_URL = '';
if (isset($_SERVER['REQUEST_URI'])) {
$url_parts = parse_url($_SERVER['REQUEST_URI']);
$REDIRECT_URL = $url_parts['path'];
}
$URI = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
if (substr($REDIRECT_URL, 0, strlen($URI)) == $URI) {
$URI = substr($REDIRECT_URL, strlen($URI));
}
$URI = urldecode($URI) . '/';
$URI = trim($URI, '/');
$parameters = [];
//Extract parameters from QUERY string
parse_str($REDIRECT_QUERY_STRING, $parameters);
return [$URI, $parameters];
} | [
"public",
"static",
"function",
"URI",
"(",
")",
"{",
"$",
"REDIRECT_QUERY_STRING",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
":",
"''",
";",
"$",
"REDIRECT_URL",
"=",
"''",
";",
... | Get current URI and GET parameters from the requested URI
@return string[2] Returns an array with current URI and GET parameters | [
"Get",
"current",
"URI",
"and",
"GET",
"parameters",
"from",
"the",
"requested",
"URI"
] | 40041d1ef23b1f8cdbd26fb112448d6a3dbef012 | https://github.com/phramework/phramework/blob/40041d1ef23b1f8cdbd26fb112448d6a3dbef012/src/URIStrategy/URITemplate.php#L120-L150 | train |
ThomasMarinissen/FileDownloader | src/FileDownloader/Exceptions/DownloadException.php | DownloadException.codeToMessage | private function codeToMessage($code) {
// get the error message belong to the given code
switch ($code) {
case \Th\FileDownloader::FILE_WRONG_MIME:
$message = "File is of the wrong MIME type";
break;
case \Th\FileDownloader::FILE_WRONG_EXTENSION:
$message = "File is of the wrong extension";
break;
case \Th\FileDownloader::INVALID_DOWNLOAD_DIR:
$message = "User set download directory does not exist";
break;
default:
$message = "Unknown download error";
break;
}
// done, return the error message
return $message;
} | php | private function codeToMessage($code) {
// get the error message belong to the given code
switch ($code) {
case \Th\FileDownloader::FILE_WRONG_MIME:
$message = "File is of the wrong MIME type";
break;
case \Th\FileDownloader::FILE_WRONG_EXTENSION:
$message = "File is of the wrong extension";
break;
case \Th\FileDownloader::INVALID_DOWNLOAD_DIR:
$message = "User set download directory does not exist";
break;
default:
$message = "Unknown download error";
break;
}
// done, return the error message
return $message;
} | [
"private",
"function",
"codeToMessage",
"(",
"$",
"code",
")",
"{",
"// get the error message belong to the given code",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"\\",
"Th",
"\\",
"FileDownloader",
"::",
"FILE_WRONG_MIME",
":",
"$",
"message",
"=",
"\"File is... | Method that switches the error code constants till it finds the messages
that belongs to the error code and then returns the message.
@param int The error code
@return string The error message | [
"Method",
"that",
"switches",
"the",
"error",
"code",
"constants",
"till",
"it",
"finds",
"the",
"messages",
"that",
"belongs",
"to",
"the",
"error",
"code",
"and",
"then",
"returns",
"the",
"message",
"."
] | a69a1c88674038597bcd2e8f0777abf39f58c215 | https://github.com/ThomasMarinissen/FileDownloader/blob/a69a1c88674038597bcd2e8f0777abf39f58c215/src/FileDownloader/Exceptions/DownloadException.php#L33-L52 | train |
hal-platform/hal-core | src/Entity/Target.php | Target.isAWS | public function isAWS()
{
return in_array($this->type(), [TargetEnum::TYPE_CD, TargetEnum::TYPE_EB, TargetEnum::TYPE_S3]);
} | php | public function isAWS()
{
return in_array($this->type(), [TargetEnum::TYPE_CD, TargetEnum::TYPE_EB, TargetEnum::TYPE_S3]);
} | [
"public",
"function",
"isAWS",
"(",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"type",
"(",
")",
",",
"[",
"TargetEnum",
"::",
"TYPE_CD",
",",
"TargetEnum",
"::",
"TYPE_EB",
",",
"TargetEnum",
"::",
"TYPE_S3",
"]",
")",
";",
"}"
] | Is this group for AWS?
@return bool | [
"Is",
"this",
"group",
"for",
"AWS?"
] | 30d456f8392fc873301ad4217d2ae90436c67090 | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Entity/Target.php#L253-L256 | train |
hal-platform/hal-core | src/Entity/Target.php | Target.formatParameters | public function formatParameters()
{
switch ($this->type()) {
case TargetEnum::TYPE_CD:
return $this->parameter('group') ?: '???';
case TargetEnum::TYPE_EB:
return $this->parameter('environment') ?: '???';
case TargetEnum::TYPE_S3:
$bucket = $this->parameter('bucket') ?: '???';
if ($path = $this->parameter('path')) {
$bucket = sprintf('%s/%s', $bucket, $path);
if ($source = $this->parameter('source')) {
$bucket = sprintf('%s:%s', $source, $bucket);
}
}
return $bucket;
case TargetEnum::TYPE_SCRIPT:
return $this->parameter('context') ?: '???';
case TargetEnum::TYPE_RSYNC:
return $this->parameter('path') ?: '???';
default:
return 'Unknown';
}
} | php | public function formatParameters()
{
switch ($this->type()) {
case TargetEnum::TYPE_CD:
return $this->parameter('group') ?: '???';
case TargetEnum::TYPE_EB:
return $this->parameter('environment') ?: '???';
case TargetEnum::TYPE_S3:
$bucket = $this->parameter('bucket') ?: '???';
if ($path = $this->parameter('path')) {
$bucket = sprintf('%s/%s', $bucket, $path);
if ($source = $this->parameter('source')) {
$bucket = sprintf('%s:%s', $source, $bucket);
}
}
return $bucket;
case TargetEnum::TYPE_SCRIPT:
return $this->parameter('context') ?: '???';
case TargetEnum::TYPE_RSYNC:
return $this->parameter('path') ?: '???';
default:
return 'Unknown';
}
} | [
"public",
"function",
"formatParameters",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
"(",
")",
")",
"{",
"case",
"TargetEnum",
"::",
"TYPE_CD",
":",
"return",
"$",
"this",
"->",
"parameter",
"(",
"'group'",
")",
"?",
":",
"'???'",
";",
... | Format parameters into something readable.
@return string | [
"Format",
"parameters",
"into",
"something",
"readable",
"."
] | 30d456f8392fc873301ad4217d2ae90436c67090 | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Entity/Target.php#L263-L293 | train |
ncou/Chiron-Pipeline | src/Pipeline.php | Pipeline.handle | public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->index >= count($this->middlewares)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response ?');
}
$middleware = $this->middlewares[$this->index++];
return $middleware->process($request, $this);
} | php | public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->index >= count($this->middlewares)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response ?');
}
$middleware = $this->middlewares[$this->index++];
return $middleware->process($request, $this);
} | [
"public",
"function",
"handle",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"ResponseInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"index",
">=",
"count",
"(",
"$",
"this",
"->",
"middlewares",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsExcepti... | Execute the middleware stack.
@param ServerRequestInterface $request
@return ResponseInterface | [
"Execute",
"the",
"middleware",
"stack",
"."
] | dda743d797bc85c24a947dc332f3cfb41f6bf05a | https://github.com/ncou/Chiron-Pipeline/blob/dda743d797bc85c24a947dc332f3cfb41f6bf05a/src/Pipeline.php#L149-L158 | train |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseXml | private static function parseXml(\Gettext\Translations $translations, $realPath, $shownPath)
{
if (@filesize($realPath) !== 0) {
$xml = new \DOMDocument();
if ($xml->load($realPath) === false) {
global $php_errormsg;
if (isset($php_errormsg) && $php_errormsg) {
throw new \Exception("Error loading '$realPath': $php_errormsg");
} else {
throw new \Exception("Error loading '$realPath'");
}
}
switch ($xml->documentElement->tagName) {
case 'concrete5-cif':
case 'styles':
static::parseXmlNode($translations, $shownPath, $xml->documentElement, '');
break;
}
}
} | php | private static function parseXml(\Gettext\Translations $translations, $realPath, $shownPath)
{
if (@filesize($realPath) !== 0) {
$xml = new \DOMDocument();
if ($xml->load($realPath) === false) {
global $php_errormsg;
if (isset($php_errormsg) && $php_errormsg) {
throw new \Exception("Error loading '$realPath': $php_errormsg");
} else {
throw new \Exception("Error loading '$realPath'");
}
}
switch ($xml->documentElement->tagName) {
case 'concrete5-cif':
case 'styles':
static::parseXmlNode($translations, $shownPath, $xml->documentElement, '');
break;
}
}
} | [
"private",
"static",
"function",
"parseXml",
"(",
"\\",
"Gettext",
"\\",
"Translations",
"$",
"translations",
",",
"$",
"realPath",
",",
"$",
"shownPath",
")",
"{",
"if",
"(",
"@",
"filesize",
"(",
"$",
"realPath",
")",
"!==",
"0",
")",
"{",
"$",
"xml"... | Parses an XML CIF file and extracts translatable strings.
@param \Gettext\Translations $translations
@param string $realPath
@param string $shownPath
@throws \Exception | [
"Parses",
"an",
"XML",
"CIF",
"file",
"and",
"extracts",
"translatable",
"strings",
"."
] | 26f806c8c1ecb6ce63115a4058ab396303622e00 | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L65-L84 | train |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.readXmlNodeAttribute | private static function readXmlNodeAttribute(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $attributeName, $context = '')
{
$value = (string) $node->getAttribute($attributeName);
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | php | private static function readXmlNodeAttribute(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $attributeName, $context = '')
{
$value = (string) $node->getAttribute($attributeName);
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | [
"private",
"static",
"function",
"readXmlNodeAttribute",
"(",
"\\",
"Gettext",
"\\",
"Translations",
"$",
"translations",
",",
"$",
"filenameRel",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"attributeName",
",",
"$",
"context",
"=",
"''",
")",
"{",
"$",
... | Parse a node attribute and create a POEntry item if it has a value.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $attributeName The name of the attribute
@param string $context='' The translation context | [
"Parse",
"a",
"node",
"attribute",
"and",
"create",
"a",
"POEntry",
"item",
"if",
"it",
"has",
"a",
"value",
"."
] | 26f806c8c1ecb6ce63115a4058ab396303622e00 | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L409-L416 | train |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.readXmlPageKeywords | private static function readXmlPageKeywords(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $pageUrl)
{
$keywords = (string) $node->nodeValue;
if ($keywords !== '') {
$translation = $translations->insert('', $keywords);
$translation->addReference($filenameRel, $node->getLineNo());
$pageUrl = (string) $pageUrl;
if ($pageUrl !== '') {
$translation->addExtractedComment("Keywords for page $pageUrl");
}
}
} | php | private static function readXmlPageKeywords(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $pageUrl)
{
$keywords = (string) $node->nodeValue;
if ($keywords !== '') {
$translation = $translations->insert('', $keywords);
$translation->addReference($filenameRel, $node->getLineNo());
$pageUrl = (string) $pageUrl;
if ($pageUrl !== '') {
$translation->addExtractedComment("Keywords for page $pageUrl");
}
}
} | [
"private",
"static",
"function",
"readXmlPageKeywords",
"(",
"\\",
"Gettext",
"\\",
"Translations",
"$",
"translations",
",",
"$",
"filenameRel",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"pageUrl",
")",
"{",
"$",
"keywords",
"=",
"(",
"string",
")",
"$... | Parse a node attribute which contains the keywords for a page.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $pageUrl The url of the page for which the keywords are for | [
"Parse",
"a",
"node",
"attribute",
"which",
"contains",
"the",
"keywords",
"for",
"a",
"page",
"."
] | 26f806c8c1ecb6ce63115a4058ab396303622e00 | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L424-L435 | train |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseXmlNodeValue | private static function parseXmlNodeValue(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $context = '')
{
$value = (string) $node->nodeValue;
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | php | private static function parseXmlNodeValue(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $context = '')
{
$value = (string) $node->nodeValue;
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | [
"private",
"static",
"function",
"parseXmlNodeValue",
"(",
"\\",
"Gettext",
"\\",
"Translations",
"$",
"translations",
",",
"$",
"filenameRel",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"context",
"=",
"''",
")",
"{",
"$",
"value",
"=",
"(",
"string",
... | Parse a node value and create a POEntry item if it has a value.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $context='' The translation context | [
"Parse",
"a",
"node",
"value",
"and",
"create",
"a",
"POEntry",
"item",
"if",
"it",
"has",
"a",
"value",
"."
] | 26f806c8c1ecb6ce63115a4058ab396303622e00 | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L445-L452 | train |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.dirs | public function dirs(array $dirs)
{
foreach ($dirs as $k => $v) {
if (is_numeric($v)) {
$this->dir($k, $v);
continue;
}
$this->dir($v);
}
return $this;
} | php | public function dirs(array $dirs)
{
foreach ($dirs as $k => $v) {
if (is_numeric($v)) {
$this->dir($k, $v);
continue;
}
$this->dir($v);
}
return $this;
} | [
"public",
"function",
"dirs",
"(",
"array",
"$",
"dirs",
")",
"{",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"dir",
"(",
"$",
"k",
",",
"... | Add directories to clean.
@param array $dirs
Either an array of directories or an array keyed by directory with the
number of items to keep within this directory as value.
@return $this | [
"Add",
"directories",
"to",
"clean",
"."
] | fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L138-L149 | train |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.cleanDir | protected function cleanDir($dir, $keep)
{
$finder = clone $this->finder;
$finder->in($dir);
$finder->depth(0);
$this->doSort($finder);
$items = iterator_to_array($finder->getIterator());
if ($keep) {
array_splice($items, -$keep);
}
while ($items) {
$item = reset($items);
try {
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work and the exception contains a path, try
// to remove anyway.
$path = $e->getPath();
if ($path && realpath($path) !== realpath($item)) {
$this->fs->remove($path);
continue;
}
}
$this->fs->remove($item);
array_shift($items);
}
} | php | protected function cleanDir($dir, $keep)
{
$finder = clone $this->finder;
$finder->in($dir);
$finder->depth(0);
$this->doSort($finder);
$items = iterator_to_array($finder->getIterator());
if ($keep) {
array_splice($items, -$keep);
}
while ($items) {
$item = reset($items);
try {
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work and the exception contains a path, try
// to remove anyway.
$path = $e->getPath();
if ($path && realpath($path) !== realpath($item)) {
$this->fs->remove($path);
continue;
}
}
$this->fs->remove($item);
array_shift($items);
}
} | [
"protected",
"function",
"cleanDir",
"(",
"$",
"dir",
",",
"$",
"keep",
")",
"{",
"$",
"finder",
"=",
"clone",
"$",
"this",
"->",
"finder",
";",
"$",
"finder",
"->",
"in",
"(",
"$",
"dir",
")",
";",
"$",
"finder",
"->",
"depth",
"(",
"0",
")",
... | Clean a directory.
@param string $dir
The directory to clean.
@param int $keep
The number of items to keep. | [
"Clean",
"a",
"directory",
"."
] | fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L221-L247 | train |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.doSort | protected function doSort(Finder $finder)
{
switch ($this->sort) {
case static::SORT_NAME:
$finder->sortByName();
break;
case static::SORT_TYPE:
$finder->sortByType();
break;
case static::SORT_ACCESS_TIME:
$finder->sortByAccessedTime();
break;
case static::SORT_MODIFIED_TIME:
$finder->sortByModifiedTime();
break;
case static::SORT_CHANGED_TIME:
$finder->sortByType();
break;
case $this->sort instanceof \Closure:
$finder->sort($this->sort);
break;
}
} | php | protected function doSort(Finder $finder)
{
switch ($this->sort) {
case static::SORT_NAME:
$finder->sortByName();
break;
case static::SORT_TYPE:
$finder->sortByType();
break;
case static::SORT_ACCESS_TIME:
$finder->sortByAccessedTime();
break;
case static::SORT_MODIFIED_TIME:
$finder->sortByModifiedTime();
break;
case static::SORT_CHANGED_TIME:
$finder->sortByType();
break;
case $this->sort instanceof \Closure:
$finder->sort($this->sort);
break;
}
} | [
"protected",
"function",
"doSort",
"(",
"Finder",
"$",
"finder",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"sort",
")",
"{",
"case",
"static",
"::",
"SORT_NAME",
":",
"$",
"finder",
"->",
"sortByName",
"(",
")",
";",
"break",
";",
"case",
"static",
... | Sort the finder.
@param Finder $finder
The finder to sort. | [
"Sort",
"the",
"finder",
"."
] | fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L255-L282 | train |
bennybi/yii2-cza-base | behaviors/CmsMediaBehavior.php | CmsMediaBehavior.setup | protected function setup() {
if (!$this->_isSetup) {
$defaultConfig = array(
'srcBasePath' => Yii::getAlias('@webroot'),
'dstBasePath' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(true),
'dstUrlBase' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(),
'underOwnerEntityPath' => true,
'createMode' => 0775,
'cachingPath' => '',
);
$this->config = \yii\helpers\ArrayHelper::merge($defaultConfig, $this->config);
$defaultOptions = array(
'isTranslation' => false,
'handleFiles' => true,
'handleImages' => true,
);
$this->options = \yii\helpers\ArrayHelper::merge($defaultOptions, $this->options);
$this->_isSetup = true;
}
} | php | protected function setup() {
if (!$this->_isSetup) {
$defaultConfig = array(
'srcBasePath' => Yii::getAlias('@webroot'),
'dstBasePath' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(true),
'dstUrlBase' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(),
'underOwnerEntityPath' => true,
'createMode' => 0775,
'cachingPath' => '',
);
$this->config = \yii\helpers\ArrayHelper::merge($defaultConfig, $this->config);
$defaultOptions = array(
'isTranslation' => false,
'handleFiles' => true,
'handleImages' => true,
);
$this->options = \yii\helpers\ArrayHelper::merge($defaultOptions, $this->options);
$this->_isSetup = true;
}
} | [
"protected",
"function",
"setup",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isSetup",
")",
"{",
"$",
"defaultConfig",
"=",
"array",
"(",
"'srcBasePath'",
"=>",
"Yii",
"::",
"getAlias",
"(",
"'@webroot'",
")",
",",
"'dstBasePath'",
"=>",
"Yii",
... | setup config on flying | [
"setup",
"config",
"on",
"flying"
] | 8257db8034bd948712fa469062921f210f0ba8da | https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/behaviors/CmsMediaBehavior.php#L82-L103 | train |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.giveIdentity | function giveIdentity(iIdentity $identity)
{
if ($this->identity)
throw new \Exception('Identity is immutable.');
$defIdentity = $this->_newDefaultIdentity();
$defIdentity->import($identity);
if (!$defIdentity->isFulfilled())
throw new \InvalidArgumentException(sprintf(
'Identity (%s) not fulfillment (%s).'
, \Poirot\Std\flatten($identity)
, \Poirot\Std\flatten($defIdentity)
));
$this->identity = $defIdentity;
return $this;
} | php | function giveIdentity(iIdentity $identity)
{
if ($this->identity)
throw new \Exception('Identity is immutable.');
$defIdentity = $this->_newDefaultIdentity();
$defIdentity->import($identity);
if (!$defIdentity->isFulfilled())
throw new \InvalidArgumentException(sprintf(
'Identity (%s) not fulfillment (%s).'
, \Poirot\Std\flatten($identity)
, \Poirot\Std\flatten($defIdentity)
));
$this->identity = $defIdentity;
return $this;
} | [
"function",
"giveIdentity",
"(",
"iIdentity",
"$",
"identity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"identity",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Identity is immutable.'",
")",
";",
"$",
"defIdentity",
"=",
"$",
"this",
"->",
"_newDefaultIden... | Set Immutable Identity
@param iIdentity $identity
@return $this
@throws \Exception immutable error; identity not met requirement | [
"Set",
"Immutable",
"Identity"
] | bb8d02f72a7c2686d7d453021143361fa704a5a6 | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L95-L111 | train |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.issueException | final function issueException(exAuthentication $exception = null)
{
$callable = ($this->issuer_exception)
? $this->issuer_exception
: $this->doIssueExceptionDefault();
return call_user_func($callable, $exception);
} | php | final function issueException(exAuthentication $exception = null)
{
$callable = ($this->issuer_exception)
? $this->issuer_exception
: $this->doIssueExceptionDefault();
return call_user_func($callable, $exception);
} | [
"final",
"function",
"issueException",
"(",
"exAuthentication",
"$",
"exception",
"=",
"null",
")",
"{",
"$",
"callable",
"=",
"(",
"$",
"this",
"->",
"issuer_exception",
")",
"?",
"$",
"this",
"->",
"issuer_exception",
":",
"$",
"this",
"->",
"doIssueExcept... | Issue To Handle Authentication Exception
usually called when authentication exception rise
to challenge client to login form or something.
@param exAuthentication $exception Maybe support for specific error
@return mixed Result Handle in Dispatch Listener Events | [
"Issue",
"To",
"Handle",
"Authentication",
"Exception"
] | bb8d02f72a7c2686d7d453021143361fa704a5a6 | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L150-L157 | train |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.setIssuerException | function setIssuerException(/*callable*/ $callable)
{
if (!is_callable($callable))
throw new \InvalidArgumentException(sprintf(
'Issuer must be callable; given: (%s).'
, \Poirot\Std\flatten($callable)
));
$this->issuer_exception = $callable;
return $this;
} | php | function setIssuerException(/*callable*/ $callable)
{
if (!is_callable($callable))
throw new \InvalidArgumentException(sprintf(
'Issuer must be callable; given: (%s).'
, \Poirot\Std\flatten($callable)
));
$this->issuer_exception = $callable;
return $this;
} | [
"function",
"setIssuerException",
"(",
"/*callable*/",
"$",
"callable",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Issuer must be callable; given: (%s).'",
",",
... | Set Exception Issuer
callable:
function(exAuthentication $e)
@param callable $callable
@return $this | [
"Set",
"Exception",
"Issuer"
] | bb8d02f72a7c2686d7d453021143361fa704a5a6 | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L213-L223 | train |
jlaso/slim-routing-manager | JLaso/SlimRoutingManager/RoutingCacheManager.php | RoutingCacheManager.writeCache | protected function writeCache($class, $content)
{
$date = date("Y-m-d h:i:s");
$content = <<<EOD
<?php
/**
* Generated with RoutingCacheManager
*
* on {$date}
*/
\$app = Slim\Slim::getInstance();
{$content}
EOD;
$fileName = $this->cacheFile($class);
file_put_contents($fileName, $content);
return $fileName;
} | php | protected function writeCache($class, $content)
{
$date = date("Y-m-d h:i:s");
$content = <<<EOD
<?php
/**
* Generated with RoutingCacheManager
*
* on {$date}
*/
\$app = Slim\Slim::getInstance();
{$content}
EOD;
$fileName = $this->cacheFile($class);
file_put_contents($fileName, $content);
return $fileName;
} | [
"protected",
"function",
"writeCache",
"(",
"$",
"class",
",",
"$",
"content",
")",
"{",
"$",
"date",
"=",
"date",
"(",
"\"Y-m-d h:i:s\"",
")",
";",
"$",
"content",
"=",
" <<<EOD\n<?php\n\n\n/**\n * Generated with RoutingCacheManager\n *\n * on {$date}\n */\n\n\\$app = Sl... | This method writes the cache content into cache file
@param $class
@param $content
@return string | [
"This",
"method",
"writes",
"the",
"cache",
"content",
"into",
"cache",
"file"
] | a9fb697e03377b1694add048418a484ef62eae08 | https://github.com/jlaso/slim-routing-manager/blob/a9fb697e03377b1694add048418a484ef62eae08/JLaso/SlimRoutingManager/RoutingCacheManager.php#L68-L90 | train |
php-kit/power-primitives | src/PowerString.php | PowerString.indexOfPattern | function indexOfPattern ($pattern)
{
self::toUnicodeRegex ($pattern);
if (!preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) return false;
return $m[0][1];
} | php | function indexOfPattern ($pattern)
{
self::toUnicodeRegex ($pattern);
if (!preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) return false;
return $m[0][1];
} | [
"function",
"indexOfPattern",
"(",
"$",
"pattern",
")",
"{",
"self",
"::",
"toUnicodeRegex",
"(",
"$",
"pattern",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"S",
",",
"$",
"m",
",",
"PREG_OFFSET_CAPTURE",
")",
... | Searches for a pattern on a string and returns the index of the matched substring.
><p>This is a simpler version of {@see search}.
@param string $pattern A regular expression pattern.
@return int The index of the matched substring. | [
"Searches",
"for",
"a",
"pattern",
"on",
"a",
"string",
"and",
"returns",
"the",
"index",
"of",
"the",
"matched",
"substring",
"."
] | 98450f8c1c34abe86ef293a4764c62c51852632b | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L195-L200 | train |
php-kit/power-primitives | src/PowerString.php | PowerString.search | function search ($pattern, $from = 0, &$match = null)
{
self::toUnicodeRegex ($pattern);
if (preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) {
list ($match, $ofs) = $m[0];
return $ofs;
}
return false;
} | php | function search ($pattern, $from = 0, &$match = null)
{
self::toUnicodeRegex ($pattern);
if (preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) {
list ($match, $ofs) = $m[0];
return $ofs;
}
return false;
} | [
"function",
"search",
"(",
"$",
"pattern",
",",
"$",
"from",
"=",
"0",
",",
"&",
"$",
"match",
"=",
"null",
")",
"{",
"self",
"::",
"toUnicodeRegex",
"(",
"$",
"pattern",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"this",
"... | Finds the position of the first occurrence of a pattern in the current string.
><p>This is an extended version of {@see indexOfPattern}.
@param string $pattern A regular expression.
@param int $from The position where the search begins, counted from the beginning of the current string.
@param string $match [optional] If a variable is specified, it will be set to the matched substring.
@return int|bool false if no match was found. | [
"Finds",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"a",
"pattern",
"in",
"the",
"current",
"string",
"."
] | 98450f8c1c34abe86ef293a4764c62c51852632b | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L289-L297 | train |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.addError | public function addError(OperationError $ex, bool $stopPropagation = false) {
$this->lastError = $ex;
if ($stopPropagation) {
$this->stopPropagation();
}
} | php | public function addError(OperationError $ex, bool $stopPropagation = false) {
$this->lastError = $ex;
if ($stopPropagation) {
$this->stopPropagation();
}
} | [
"public",
"function",
"addError",
"(",
"OperationError",
"$",
"ex",
",",
"bool",
"$",
"stopPropagation",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"lastError",
"=",
"$",
"ex",
";",
"if",
"(",
"$",
"stopPropagation",
")",
"{",
"$",
"this",
"->",
"stopP... | Adds an OperationError to the operation events error list.
If the argument <code>$stopPropagation</code> is true than this operation
will stop propagating once complete.
@param \Nasumilu\Geometry\Operation\OperationError $ex
@param bool $stopPropagation | [
"Adds",
"an",
"OperationError",
"to",
"the",
"operation",
"events",
"error",
"list",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L111-L116 | train |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.setResults | public function setResults($results = null, bool $stopPropagation = false) {
$this->result = $results;
if ($stopPropagation) {
$this->stopPropagation();
}
} | php | public function setResults($results = null, bool $stopPropagation = false) {
$this->result = $results;
if ($stopPropagation) {
$this->stopPropagation();
}
} | [
"public",
"function",
"setResults",
"(",
"$",
"results",
"=",
"null",
",",
"bool",
"$",
"stopPropagation",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"result",
"=",
"$",
"results",
";",
"if",
"(",
"$",
"stopPropagation",
")",
"{",
"$",
"this",
"->",
... | Sets the operations result.
To stop the operations propagation set <code>$stopPropagation</code> to
true.
@param mixed $results
@param bool $stopPropagation | [
"Sets",
"the",
"operations",
"result",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L232-L237 | train |
schpill/thin | src/Vertica.php | Vertica.query | public function query($query, $params = null, $fetchResult = false)
{
$this->checkConnection(true);
$this->log('Query: ' . $query);
if(!empty($params)) {
$this->log('Params: ' . print_r($params, true));
}
$start = microtime(true);
if(empty($params)) {
$res = $this->executeQuery($query);
} else {
$res = $this->executePreparedStatement($query, $params);
}
$end = microtime(true);
$this->log("Execution time: " . ($end - $start) . " seconds");
if($fetchResult) {
$this->log('Num Rows: '.odbc_num_rows($res));
$resutlSet = $this->getRows($res);
odbc_free_result($res);
$res = $resutlSet;
$resultSet = null;
$fetch = microtime(true);
$this->log("Fetch time: " . ($fetch - $end) . " seconds");
}
return $res;
} | php | public function query($query, $params = null, $fetchResult = false)
{
$this->checkConnection(true);
$this->log('Query: ' . $query);
if(!empty($params)) {
$this->log('Params: ' . print_r($params, true));
}
$start = microtime(true);
if(empty($params)) {
$res = $this->executeQuery($query);
} else {
$res = $this->executePreparedStatement($query, $params);
}
$end = microtime(true);
$this->log("Execution time: " . ($end - $start) . " seconds");
if($fetchResult) {
$this->log('Num Rows: '.odbc_num_rows($res));
$resutlSet = $this->getRows($res);
odbc_free_result($res);
$res = $resutlSet;
$resultSet = null;
$fetch = microtime(true);
$this->log("Fetch time: " . ($fetch - $end) . " seconds");
}
return $res;
} | [
"public",
"function",
"query",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"null",
",",
"$",
"fetchResult",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"checkConnection",
"(",
"true",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Query: '",
".",
"$",
"... | Execute a query and return the results
@param string $query
@param array $params
@param bool $fetchResult Return a ressource or a an array
@return resource|array
@throws Exception | [
"Execute",
"a",
"query",
"and",
"return",
"the",
"results"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L36-L66 | train |
schpill/thin | src/Vertica.php | Vertica.executeQuery | protected function executeQuery($query)
{
$res = @odbc_exec($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Query failed: '.$error);
throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | php | protected function executeQuery($query)
{
$res = @odbc_exec($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Query failed: '.$error);
throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | [
"protected",
"function",
"executeQuery",
"(",
"$",
"query",
")",
"{",
"$",
"res",
"=",
"@",
"odbc_exec",
"(",
"$",
"this",
"->",
"_lnk",
",",
"$",
"query",
")",
";",
"if",
"(",
"!",
"$",
"res",
")",
"{",
"$",
"error",
"=",
"odbc_errormsg",
"(",
"... | Execute a query and returns an ODBC result identifier
@param string $query
@return resource
@throws Exception | [
"Execute",
"a",
"query",
"and",
"returns",
"an",
"ODBC",
"result",
"identifier"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L74-L83 | train |
schpill/thin | src/Vertica.php | Vertica.executePreparedStatement | protected function executePreparedStatement($query, $params)
{
$res = odbc_prepare($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepare failed: ' . $error);
throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
}
$res = odbc_execute($res, $params);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepared query execution failed: ' . $error);
throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | php | protected function executePreparedStatement($query, $params)
{
$res = odbc_prepare($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepare failed: ' . $error);
throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
}
$res = odbc_execute($res, $params);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepared query execution failed: ' . $error);
throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | [
"protected",
"function",
"executePreparedStatement",
"(",
"$",
"query",
",",
"$",
"params",
")",
"{",
"$",
"res",
"=",
"odbc_prepare",
"(",
"$",
"this",
"->",
"_lnk",
",",
"$",
"query",
")",
";",
"if",
"(",
"!",
"$",
"res",
")",
"{",
"$",
"error",
... | Prepare a query, execute it and return an ODBC result identifier
@param string $query
@param array $params
@return bool|resource
@throws Exception | [
"Prepare",
"a",
"query",
"execute",
"it",
"and",
"return",
"an",
"ODBC",
"result",
"identifier"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L92-L107 | train |
schpill/thin | src/Vertica.php | Vertica.checkConnection | protected function checkConnection($reconnect = false)
{
if(empty($this->_lnk)) {
$this->log('CheckConnection: link is not valid');
if($reconnect) {
$this->log('CheckConnection: try to reconnect');
$this->_lnk = @odbc_connect('Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SERVER . ';Database='.VERTICA_DATABASE, VERTICA_USER_ETL, VERTICA_PASS_ETL);
if(!$this->_lnk) {
$this->log('CheckConnection: reconnect failed');
throw new Exception('Connection failed or gone away and can\'t reconnect - '.odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
$this->log('CheckConnection: reconnected!');
return;
}
throw new Exception('Connection failed or gone away - ' . odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
} | php | protected function checkConnection($reconnect = false)
{
if(empty($this->_lnk)) {
$this->log('CheckConnection: link is not valid');
if($reconnect) {
$this->log('CheckConnection: try to reconnect');
$this->_lnk = @odbc_connect('Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SERVER . ';Database='.VERTICA_DATABASE, VERTICA_USER_ETL, VERTICA_PASS_ETL);
if(!$this->_lnk) {
$this->log('CheckConnection: reconnect failed');
throw new Exception('Connection failed or gone away and can\'t reconnect - '.odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
$this->log('CheckConnection: reconnected!');
return;
}
throw new Exception('Connection failed or gone away - ' . odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
} | [
"protected",
"function",
"checkConnection",
"(",
"$",
"reconnect",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_lnk",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'CheckConnection: link is not valid'",
")",
";",
"if",
"(",
"$",... | Check if the connection failed and try to reconnect if asked
@param bool $reconnect
@throws Exception | [
"Check",
"if",
"the",
"connection",
"failed",
"and",
"try",
"to",
"reconnect",
"if",
"asked"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L128-L144 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.decode | public static function decode($cookie)
{
$params = (array) json_decode(base64_decode($cookie), true);
return new self((string) array_value($params, 'user_email'),
(string) array_value($params, 'agent'),
(string) array_value($params, 'series'),
(string) array_value($params, 'token'));
} | php | public static function decode($cookie)
{
$params = (array) json_decode(base64_decode($cookie), true);
return new self((string) array_value($params, 'user_email'),
(string) array_value($params, 'agent'),
(string) array_value($params, 'series'),
(string) array_value($params, 'token'));
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"cookie",
")",
"{",
"$",
"params",
"=",
"(",
"array",
")",
"json_decode",
"(",
"base64_decode",
"(",
"$",
"cookie",
")",
",",
"true",
")",
";",
"return",
"new",
"self",
"(",
"(",
"string",
")",
"arr... | Decodes an encoded remember me cookie string.
@param string $cookie
@return self | [
"Decodes",
"an",
"encoded",
"remember",
"me",
"cookie",
"string",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L130-L138 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.encode | public function encode()
{
$json = json_encode([
'user_email' => $this->email,
'agent' => $this->userAgent,
'series' => $this->series,
'token' => $this->token,
]);
return base64_encode($json);
} | php | public function encode()
{
$json = json_encode([
'user_email' => $this->email,
'agent' => $this->userAgent,
'series' => $this->series,
'token' => $this->token,
]);
return base64_encode($json);
} | [
"public",
"function",
"encode",
"(",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"[",
"'user_email'",
"=>",
"$",
"this",
"->",
"email",
",",
"'agent'",
"=>",
"$",
"this",
"->",
"userAgent",
",",
"'series'",
"=>",
"$",
"this",
"->",
"series",
",",
... | Encodes a remember me cookie.
@return string | [
"Encodes",
"a",
"remember",
"me",
"cookie",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L145-L155 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.isValid | public function isValid()
{
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
return false;
}
if (empty($this->userAgent)) {
return false;
}
if (empty($this->series)) {
return false;
}
if (empty($this->token)) {
return false;
}
return true;
} | php | public function isValid()
{
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
return false;
}
if (empty($this->userAgent)) {
return false;
}
if (empty($this->series)) {
return false;
}
if (empty($this->token)) {
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"this",
"->",
"email",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"userAgent",
")",
")"... | Checks if the cookie contains valid values.
@return bool | [
"Checks",
"if",
"the",
"cookie",
"contains",
"valid",
"values",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L162-L181 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.verify | public function verify(Request $req, AuthManager $auth)
{
if (!$this->isValid()) {
return false;
}
// verify the user agent matches the one in the request
if ($this->userAgent != $req->agent()) {
return false;
}
// look up the user with a matching email address
try {
$userClass = $auth->getUserClass();
$user = $userClass::where('email', $this->email)
->first();
} catch (ModelException $e) {
// fail open when unable to look up the user
return false;
}
if (!$user) {
return false;
}
// hash series for matching with the db
$seriesHash = $this->hash($this->series);
// First, make sure all of the parameters match, except the token.
// We match the token separately to detect if an older session is
// being used, in which case we cowardly run away.
$expiration = time() - $this->getExpires();
$db = $auth->getApp()['database']->getDefault();
$query = $db->select('token,two_factor_verified')
->from('PersistentSessions')
->where('email', $this->email)
->where('created_at', U::unixToDb($expiration), '>')
->where('series', $seriesHash);
$persistentSession = $query->one();
if ($query->rowCount() !== 1) {
return false;
}
// if there is a match, sign the user in
$tokenHash = $this->hash($this->token);
// Same series, but different token, meaning the user is trying
// to use an older token. It's most likely an attack, so flush
// all sessions.
if (!hash_equals($persistentSession['token'], $tokenHash)) {
$db->delete('PersistentSessions')
->where('email', $this->email)
->execute();
return false;
}
// remove the token once used
$db->delete('PersistentSessions')
->where('email', $this->email)
->where('series', $seriesHash)
->where('token', $tokenHash)
->execute();
// mark the user as 2fa verified
if ($persistentSession['two_factor_verified']) {
$user->markTwoFactorVerified();
}
return $user;
} | php | public function verify(Request $req, AuthManager $auth)
{
if (!$this->isValid()) {
return false;
}
// verify the user agent matches the one in the request
if ($this->userAgent != $req->agent()) {
return false;
}
// look up the user with a matching email address
try {
$userClass = $auth->getUserClass();
$user = $userClass::where('email', $this->email)
->first();
} catch (ModelException $e) {
// fail open when unable to look up the user
return false;
}
if (!$user) {
return false;
}
// hash series for matching with the db
$seriesHash = $this->hash($this->series);
// First, make sure all of the parameters match, except the token.
// We match the token separately to detect if an older session is
// being used, in which case we cowardly run away.
$expiration = time() - $this->getExpires();
$db = $auth->getApp()['database']->getDefault();
$query = $db->select('token,two_factor_verified')
->from('PersistentSessions')
->where('email', $this->email)
->where('created_at', U::unixToDb($expiration), '>')
->where('series', $seriesHash);
$persistentSession = $query->one();
if ($query->rowCount() !== 1) {
return false;
}
// if there is a match, sign the user in
$tokenHash = $this->hash($this->token);
// Same series, but different token, meaning the user is trying
// to use an older token. It's most likely an attack, so flush
// all sessions.
if (!hash_equals($persistentSession['token'], $tokenHash)) {
$db->delete('PersistentSessions')
->where('email', $this->email)
->execute();
return false;
}
// remove the token once used
$db->delete('PersistentSessions')
->where('email', $this->email)
->where('series', $seriesHash)
->where('token', $tokenHash)
->execute();
// mark the user as 2fa verified
if ($persistentSession['two_factor_verified']) {
$user->markTwoFactorVerified();
}
return $user;
} | [
"public",
"function",
"verify",
"(",
"Request",
"$",
"req",
",",
"AuthManager",
"$",
"auth",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// verify the user agent matches the one in the request",
"... | Looks for a remembered user using this cookie
from an incoming request.
@param Request $req
@param AuthManager $auth
@return UserInterface|false remembered user | [
"Looks",
"for",
"a",
"remembered",
"user",
"using",
"this",
"cookie",
"from",
"an",
"incoming",
"request",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L192-L264 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.persist | public function persist(UserInterface $user)
{
$session = new PersistentSession();
$session->email = $this->email;
$session->series = $this->hash($this->series);
$session->token = $this->hash($this->token);
$session->user_id = $user->id();
$session->two_factor_verified = $user->isTwoFactorVerified();
try {
$session->save();
} catch (\Exception $e) {
throw new \Exception("Unable to save persistent session for user # {$user->id()}: ".$e->getMessage());
}
return $session;
} | php | public function persist(UserInterface $user)
{
$session = new PersistentSession();
$session->email = $this->email;
$session->series = $this->hash($this->series);
$session->token = $this->hash($this->token);
$session->user_id = $user->id();
$session->two_factor_verified = $user->isTwoFactorVerified();
try {
$session->save();
} catch (\Exception $e) {
throw new \Exception("Unable to save persistent session for user # {$user->id()}: ".$e->getMessage());
}
return $session;
} | [
"public",
"function",
"persist",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"session",
"=",
"new",
"PersistentSession",
"(",
")",
";",
"$",
"session",
"->",
"email",
"=",
"$",
"this",
"->",
"email",
";",
"$",
"session",
"->",
"series",
"=",
"$",... | Persists this cookie to the database.
@param UserInterface $user
@throws \Exception when the model cannot be saved.
@return PersistentSession | [
"Persists",
"this",
"cookie",
"to",
"the",
"database",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L275-L291 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.destroy | function destroy()
{
$seriesHash = $this->hash($this->series);
PersistentSession::where('email', $this->email)
->where('series', $seriesHash)
->delete();
} | php | function destroy()
{
$seriesHash = $this->hash($this->series);
PersistentSession::where('email', $this->email)
->where('series', $seriesHash)
->delete();
} | [
"function",
"destroy",
"(",
")",
"{",
"$",
"seriesHash",
"=",
"$",
"this",
"->",
"hash",
"(",
"$",
"this",
"->",
"series",
")",
";",
"PersistentSession",
"::",
"where",
"(",
"'email'",
",",
"$",
"this",
"->",
"email",
")",
"->",
"where",
"(",
"'serie... | Destroys the persisted cookie in the data store. | [
"Destroys",
"the",
"persisted",
"cookie",
"in",
"the",
"data",
"store",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L296-L302 | train |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.hash | private function hash($token)
{
$app = Application::getDefault();
$salt = $app['config']->get('app.salt');
return hash_hmac('sha512', $token, $salt);
} | php | private function hash($token)
{
$app = Application::getDefault();
$salt = $app['config']->get('app.salt');
return hash_hmac('sha512', $token, $salt);
} | [
"private",
"function",
"hash",
"(",
"$",
"token",
")",
"{",
"$",
"app",
"=",
"Application",
"::",
"getDefault",
"(",
")",
";",
"$",
"salt",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'app.salt'",
")",
";",
"return",
"hash_hmac",
"(",
... | Hashes a token.
@param string $token
@return string hashed token | [
"Hashes",
"a",
"token",
"."
] | 720280b4b2635572f331afe8d082e3e88cf54eb7 | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L323-L329 | train |
gplcart/file_manager | handlers/commands/Listing.php | Listing.getFilesListing | protected function getFilesListing($path, array $params)
{
$files = $this->getFiles($path, $params);
return $this->prepareFiles($files);
} | php | protected function getFilesListing($path, array $params)
{
$files = $this->getFiles($path, $params);
return $this->prepareFiles($files);
} | [
"protected",
"function",
"getFilesListing",
"(",
"$",
"path",
",",
"array",
"$",
"params",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"path",
",",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"prepareFiles",
"(",
"... | Returns an array of scanned and prepared files
@param string $path
@param array $params
@return array | [
"Returns",
"an",
"array",
"of",
"scanned",
"and",
"prepared",
"files"
] | 45424e93eafea75d31af6410ac9cf110f08e500a | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L91-L95 | train |
gplcart/file_manager | handlers/commands/Listing.php | Listing.prepareFiles | protected function prepareFiles(array $files)
{
$prepared = array();
foreach ($files as $file) {
$type = $file->getType();
$path = $file->getRealPath();
$relative_path = gplcart_file_relative($path);
$item = array(
'info' => $file,
'type' => $type,
'path' => $relative_path,
'owner' => fileowner($path),
'extension' => $file->getExtension(),
'size' => gplcart_file_size($file->getSize()),
'command' => $type === 'dir' ? 'list' : 'read',
'commands' => $this->command->getAllowed($file),
'permissions' => gplcart_file_perms($file->getPerms())
);
$prepared[$relative_path] = $item;
$prepared[$relative_path]['icon'] = $this->renderIcon($item);
}
return $prepared;
} | php | protected function prepareFiles(array $files)
{
$prepared = array();
foreach ($files as $file) {
$type = $file->getType();
$path = $file->getRealPath();
$relative_path = gplcart_file_relative($path);
$item = array(
'info' => $file,
'type' => $type,
'path' => $relative_path,
'owner' => fileowner($path),
'extension' => $file->getExtension(),
'size' => gplcart_file_size($file->getSize()),
'command' => $type === 'dir' ? 'list' : 'read',
'commands' => $this->command->getAllowed($file),
'permissions' => gplcart_file_perms($file->getPerms())
);
$prepared[$relative_path] = $item;
$prepared[$relative_path]['icon'] = $this->renderIcon($item);
}
return $prepared;
} | [
"protected",
"function",
"prepareFiles",
"(",
"array",
"$",
"files",
")",
"{",
"$",
"prepared",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"type",
"=",
"$",
"file",
"->",
"getType",
"(",
")",
";",
... | Prepares an array of scanned files
@param array $files
@return array | [
"Prepares",
"an",
"array",
"of",
"scanned",
"files"
] | 45424e93eafea75d31af6410ac9cf110f08e500a | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L102-L128 | train |
gplcart/file_manager | handlers/commands/Listing.php | Listing.renderIcon | protected function renderIcon(array $item)
{
static $rendered = array();
if (isset($rendered[$item['extension']])) {
return $rendered[$item['extension']];
}
$template = "file_manager|icons/ext/{$item['extension']}";
if ($item['type'] === 'dir') {
$template = 'file_manager|icons/dir';
}
$data = array('item' => $item);
$default = $this->controller->render('file_manager|icons/file', $data);
$rendered[$item['extension']] = $this->controller->render($template, $data, true, $default);
return $rendered[$item['extension']];
} | php | protected function renderIcon(array $item)
{
static $rendered = array();
if (isset($rendered[$item['extension']])) {
return $rendered[$item['extension']];
}
$template = "file_manager|icons/ext/{$item['extension']}";
if ($item['type'] === 'dir') {
$template = 'file_manager|icons/dir';
}
$data = array('item' => $item);
$default = $this->controller->render('file_manager|icons/file', $data);
$rendered[$item['extension']] = $this->controller->render($template, $data, true, $default);
return $rendered[$item['extension']];
} | [
"protected",
"function",
"renderIcon",
"(",
"array",
"$",
"item",
")",
"{",
"static",
"$",
"rendered",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"rendered",
"[",
"$",
"item",
"[",
"'extension'",
"]",
"]",
")",
")",
"{",
"return",
"... | Returns a rendered icon for the given file extension and type
@param array $item
@return string | [
"Returns",
"a",
"rendered",
"icon",
"for",
"the",
"given",
"file",
"extension",
"and",
"type"
] | 45424e93eafea75d31af6410ac9cf110f08e500a | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L135-L154 | train |
AbuseIO/collector-common | src/Collector.php | Collector.isKnownFeed | protected function isKnownFeed()
{
if (empty(config("{$this->configBase}.feeds.{$this->feedName}"))) {
$this->warningCount++;
Log::warning(
"The feed referred as '{$this->feedName}' is not configured in the collector " .
config("{$this->configBase}.collector.name") .
' therefore skipping processing of this e-mail'
);
return false;
} else {
return true;
}
} | php | protected function isKnownFeed()
{
if (empty(config("{$this->configBase}.feeds.{$this->feedName}"))) {
$this->warningCount++;
Log::warning(
"The feed referred as '{$this->feedName}' is not configured in the collector " .
config("{$this->configBase}.collector.name") .
' therefore skipping processing of this e-mail'
);
return false;
} else {
return true;
}
} | [
"protected",
"function",
"isKnownFeed",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"config",
"(",
"\"{$this->configBase}.feeds.{$this->feedName}\"",
")",
")",
")",
"{",
"$",
"this",
"->",
"warningCount",
"++",
";",
"Log",
"::",
"warning",
"(",
"\"The feed referred ... | Check if the feed specified is known in the collector config.
@return Boolean Returns true or false | [
"Check",
"if",
"the",
"feed",
"specified",
"is",
"known",
"in",
"the",
"collector",
"config",
"."
] | fe887083371ac50c9112f313b2441b9852dfd263 | https://github.com/AbuseIO/collector-common/blob/fe887083371ac50c9112f313b2441b9852dfd263/src/Collector.php#L170-L183 | train |
temp/media-converter | src/Transmuter.php | Transmuter.transmute | public function transmute($inFilename, Specification $targetFormat, $outFilename)
{
$extractedFile = $this->extractor->extract($inFilename, $targetFormat);
if (!$extractedFile) {
return null;
}
$this->converter->convert($extractedFile, $targetFormat, $outFilename);
return $outFilename;
} | php | public function transmute($inFilename, Specification $targetFormat, $outFilename)
{
$extractedFile = $this->extractor->extract($inFilename, $targetFormat);
if (!$extractedFile) {
return null;
}
$this->converter->convert($extractedFile, $targetFormat, $outFilename);
return $outFilename;
} | [
"public",
"function",
"transmute",
"(",
"$",
"inFilename",
",",
"Specification",
"$",
"targetFormat",
",",
"$",
"outFilename",
")",
"{",
"$",
"extractedFile",
"=",
"$",
"this",
"->",
"extractor",
"->",
"extract",
"(",
"$",
"inFilename",
",",
"$",
"targetForm... | Transmute file to target format
@param string $inFilename
@param Specification $targetFormat
@param string $outFilename
@return string|null | [
"Transmute",
"file",
"to",
"target",
"format"
] | a6e8768c583aa461be568f13e592ae49294e5e33 | https://github.com/temp/media-converter/blob/a6e8768c583aa461be568f13e592ae49294e5e33/src/Transmuter.php#L54-L65 | train |
schpill/thin | src/Html/Attributes.php | Attributes.add | public function add($attribute, $value = array())
{
if(is_array($attribute)) {
foreach($attribute as $k => $v) {
$this->add($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->add($attribute->getArray());
} else {
$attribute = strval($attribute);
if(!\Thin\Arrays::exists($attribute, $this->attributes)) {
$this->attributes[$attribute] = array();
}
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
foreach($value as $v) {
$this->attributes[$attribute][] = $v;
}
$this->attributes[$attribute] = array_unique($this->attributes[$attribute]);
}
}
return $this;
} | php | public function add($attribute, $value = array())
{
if(is_array($attribute)) {
foreach($attribute as $k => $v) {
$this->add($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->add($attribute->getArray());
} else {
$attribute = strval($attribute);
if(!\Thin\Arrays::exists($attribute, $this->attributes)) {
$this->attributes[$attribute] = array();
}
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
foreach($value as $v) {
$this->attributes[$attribute][] = $v;
}
$this->attributes[$attribute] = array_unique($this->attributes[$attribute]);
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"attribute",
",",
"$",
"value",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attribute",
")",
")",
"{",
"foreach",
"(",
"$",
"attribute",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$... | Add an attribute or an array thereof. If the attribute already exists, the specified values will be added to it, without overwriting the previous ones. Duplicate values are removed.
@param string|array|\Thin\Html\Attributes $attribute The name of the attribute to add, a name-value array of attributes or an attributes object
@param string|array $value In case the first parametre is a string, value or array of values for the added attribute
@return \Thin\Html\Attributes Provides a fluent interface | [
"Add",
"an",
"attribute",
"or",
"an",
"array",
"thereof",
".",
"If",
"the",
"attribute",
"already",
"exists",
"the",
"specified",
"values",
"will",
"be",
"added",
"to",
"it",
"without",
"overwriting",
"the",
"previous",
"ones",
".",
"Duplicate",
"values",
"a... | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L19-L54 | train |
schpill/thin | src/Html/Attributes.php | Attributes.set | public function set($attribute, $value = array())
{
if(is_array($attribute)) {
$this->attributes = array();
foreach($attribute as $k => $v) {
$this->set($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->attributes = $attribute->getArray();
} else {
$attribute = strval($attribute);
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
$this->attributes[$attribute] = array_unique($value);
}
}
return $this;
} | php | public function set($attribute, $value = array())
{
if(is_array($attribute)) {
$this->attributes = array();
foreach($attribute as $k => $v) {
$this->set($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->attributes = $attribute->getArray();
} else {
$attribute = strval($attribute);
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
$this->attributes[$attribute] = array_unique($value);
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"attribute",
",",
"$",
"value",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attribute",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$... | Set the value or values of an attribute or an array thereof. Already existent attributes are overwritten.
@param string|array|\Thin\Html\Attributes $attribute The name of the attribute to set, a name-value array of attributes or an attributes object
@param string|array $value In case the first parametre is a string, value or array of values for the set attribute
@return \Thin\Html\Attributes Provides a fluent interface | [
"Set",
"the",
"value",
"or",
"values",
"of",
"an",
"attribute",
"or",
"an",
"array",
"thereof",
".",
"Already",
"existent",
"attributes",
"are",
"overwritten",
"."
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L64-L93 | train |
schpill/thin | src/Html/Attributes.php | Attributes.remove | public function remove($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value) {
unset($this->attributes[$attribute]);
} else {
$value = strval($value);
foreach($this->attributes[$attribute] as $k => $v) {
if($v == $value) {
unset($this->attributes[$attribute][$k]);
}
}
}
}
return $this;
} | php | public function remove($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value) {
unset($this->attributes[$attribute]);
} else {
$value = strval($value);
foreach($this->attributes[$attribute] as $k => $v) {
if($v == $value) {
unset($this->attributes[$attribute][$k]);
}
}
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"attribute",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"attribute",
"=",
"strval",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"\\",
"Thin",
"\\",
"Arrays",
"::",
"exists",
"(",
"$",
"attribute",
",",
... | Remove an attribute or a value
@param string $attribute The attribute name to remove(or to remove a value from)
@param string $value The value to remove from the attribute. Omit the parametre to remove the entire attribute.
@return \Thin\Html\Attributes Provides a fluent interface | [
"Remove",
"an",
"attribute",
"or",
"a",
"value"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L103-L121 | train |
schpill/thin | src/Html/Attributes.php | Attributes.getArray | public function getArray($attribute = null)
{
if(null === $attribute) {
return $this->attributes;
} else {
$attribute = strval($attribute);
if(ake($attribute, $this->attributes)) {
return $this->attributes[$attribute];
}
}
return null;
} | php | public function getArray($attribute = null)
{
if(null === $attribute) {
return $this->attributes;
} else {
$attribute = strval($attribute);
if(ake($attribute, $this->attributes)) {
return $this->attributes[$attribute];
}
}
return null;
} | [
"public",
"function",
"getArray",
"(",
"$",
"attribute",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"attribute",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
";",
"}",
"else",
"{",
"$",
"attribute",
"=",
"strval",
"(",
"$",
"attrib... | Get the entire attributes array or the array of values for a single attribute.
@param string $attribute The attribute whose values are to be retrieved. Omit the parametre to fetch the entire array of attributes.
@return array|null The attribute or attributes or null in case a nonexistent attribute is requested | [
"Get",
"the",
"entire",
"attributes",
"array",
"or",
"the",
"array",
"of",
"values",
"for",
"a",
"single",
"attribute",
"."
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L130-L142 | train |
schpill/thin | src/Html/Attributes.php | Attributes.getHtml | public function getHtml($attribute = null)
{
if(null !== $attribute) {
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
return $attribute . '="' . implode(' ', $this->attributes[$attribute]) . '"';
}
} else {
$return = array();
foreach(array_keys($this->attributes) as $attrib) {
$return[] = $this->getHtml($attrib);
}
return implode(' ', $return);
}
return '';
} | php | public function getHtml($attribute = null)
{
if(null !== $attribute) {
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
return $attribute . '="' . implode(' ', $this->attributes[$attribute]) . '"';
}
} else {
$return = array();
foreach(array_keys($this->attributes) as $attrib) {
$return[] = $this->getHtml($attrib);
}
return implode(' ', $return);
}
return '';
} | [
"public",
"function",
"getHtml",
"(",
"$",
"attribute",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"attribute",
")",
"{",
"$",
"attribute",
"=",
"strval",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"\\",
"Thin",
"\\",
"Arrays",
"::",
"e... | Generate the HTML code for the attributes
@param string $attribute The attribute for which HTML code is to be generated. Omit the parametre to generate HTML code for all attributes.
@return string HTML code | [
"Generate",
"the",
"HTML",
"code",
"for",
"the",
"attributes"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L151-L167 | train |
schpill/thin | src/Html/Attributes.php | Attributes.exists | public function exists($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value || in_array(strval($value), $this->attributes[$attribute])) {
return true;
}
}
return false;
} | php | public function exists($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value || in_array(strval($value), $this->attributes[$attribute])) {
return true;
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"$",
"attribute",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"attribute",
"=",
"strval",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"\\",
"Thin",
"\\",
"Arrays",
"::",
"exists",
"(",
"$",
"attribute",
",",
... | Check whether a given attribute or attribute value exists
@param string $attribute Attribute name whose existence is to be checked
@param string $value The attribute's value to be checked. Omit the parametre to check the existence of the attribute.
@return boolean | [
"Check",
"whether",
"a",
"given",
"attribute",
"or",
"attribute",
"value",
"exists"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L187-L198 | train |
PhoxPHP/Glider | src/Query/Builder/Type.php | Type.getStatementType | public static function getStatementType(String $query) : Int
{
$type = 0;
if (preg_match("/^SELECT|select|Select([^ ]+)/", $query)) {
$type = 1;
}
if (preg_match("/^INSERT([^ ]+)/", $query)) {
$type = 2;
}
if (preg_match("/^UPDATE([^ ]+)/", $query)) {
$type = 3;
}
if (preg_match("/^DELETE([^ ]+)/", $query)) {
$type = 4;
}
return $type;
} | php | public static function getStatementType(String $query) : Int
{
$type = 0;
if (preg_match("/^SELECT|select|Select([^ ]+)/", $query)) {
$type = 1;
}
if (preg_match("/^INSERT([^ ]+)/", $query)) {
$type = 2;
}
if (preg_match("/^UPDATE([^ ]+)/", $query)) {
$type = 3;
}
if (preg_match("/^DELETE([^ ]+)/", $query)) {
$type = 4;
}
return $type;
} | [
"public",
"static",
"function",
"getStatementType",
"(",
"String",
"$",
"query",
")",
":",
"Int",
"{",
"$",
"type",
"=",
"0",
";",
"if",
"(",
"preg_match",
"(",
"\"/^SELECT|select|Select([^ ]+)/\"",
",",
"$",
"query",
")",
")",
"{",
"$",
"type",
"=",
"1"... | This method gets and returns the statement type.
@param $query <String>
@access public
@return <Integer> | [
"This",
"method",
"gets",
"and",
"returns",
"the",
"statement",
"type",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Query/Builder/Type.php#L35-L55 | train |
skeeks-cms/cms-search | src/console/controllers/ClearController.php | ClearController.actionPhrase | public function actionPhrase()
{
$this->stdout('phraseLiveTime: ' . \Yii::$app->cmsSearch->phraseLiveTime . "\n");
if (\Yii::$app->cmsSearch->phraseLiveTime) {
$deleted = CmsSearchPhrase::deleteAll([
'<=',
'created_at',
\Yii::$app->formatter->asTimestamp(time()) - (int)\Yii::$app->cmsSearch->phraseLiveTime
]);
$message = \Yii::t('skeeks/search', 'Removing searches') . " :" . $deleted;
\Yii::info($message, 'skeeks/search');
$this->stdout("\t" . $message . "\n");
}
} | php | public function actionPhrase()
{
$this->stdout('phraseLiveTime: ' . \Yii::$app->cmsSearch->phraseLiveTime . "\n");
if (\Yii::$app->cmsSearch->phraseLiveTime) {
$deleted = CmsSearchPhrase::deleteAll([
'<=',
'created_at',
\Yii::$app->formatter->asTimestamp(time()) - (int)\Yii::$app->cmsSearch->phraseLiveTime
]);
$message = \Yii::t('skeeks/search', 'Removing searches') . " :" . $deleted;
\Yii::info($message, 'skeeks/search');
$this->stdout("\t" . $message . "\n");
}
} | [
"public",
"function",
"actionPhrase",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"'phraseLiveTime: '",
".",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"cmsSearch",
"->",
"phraseLiveTime",
".",
"\"\\n\"",
")",
";",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"ap... | Remove old searches | [
"Remove",
"old",
"searches"
] | 2fcd8c6343f46938c5cc5829bbb4c9a83593092d | https://github.com/skeeks-cms/cms-search/blob/2fcd8c6343f46938c5cc5829bbb4c9a83593092d/src/console/controllers/ClearController.php#L26-L41 | train |
diasbruno/stc | lib/stc/DataWriter.php | DataWriter.write_to | private function write_to($file, $data)
{
$handler = fopen($file, "w");
fwrite($handler, $data);
fclose($handler);
} | php | private function write_to($file, $data)
{
$handler = fopen($file, "w");
fwrite($handler, $data);
fclose($handler);
} | [
"private",
"function",
"write_to",
"(",
"$",
"file",
",",
"$",
"data",
")",
"{",
"$",
"handler",
"=",
"fopen",
"(",
"$",
"file",
",",
"\"w\"",
")",
";",
"fwrite",
"(",
"$",
"handler",
",",
"$",
"data",
")",
";",
"fclose",
"(",
"$",
"handler",
")"... | Creates the handler and writes the files.
@param $file string | The filename.
@return string | [
"Creates",
"the",
"handler",
"and",
"writes",
"the",
"files",
"."
] | 43f62c3b28167bff76274f954e235413a9e9c707 | https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataWriter.php#L21-L26 | train |
diasbruno/stc | lib/stc/DataWriter.php | DataWriter.write | public function write($path = '', $file = '', $content = '')
{
$the_path = Application::config()->public_folder() . '/' . $path;
@mkdir($the_path, 0755, true);
$this->write_to($the_path . '/'. $file, $content);
} | php | public function write($path = '', $file = '', $content = '')
{
$the_path = Application::config()->public_folder() . '/' . $path;
@mkdir($the_path, 0755, true);
$this->write_to($the_path . '/'. $file, $content);
} | [
"public",
"function",
"write",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"file",
"=",
"''",
",",
"$",
"content",
"=",
"''",
")",
"{",
"$",
"the_path",
"=",
"Application",
"::",
"config",
"(",
")",
"->",
"public_folder",
"(",
")",
".",
"'/'",
".",
"$... | Write the file.
@param $path string | The path where the file is located.
@param $file string | The filename.
@param $content string | The file content.
@return string | [
"Write",
"the",
"file",
"."
] | 43f62c3b28167bff76274f954e235413a9e9c707 | https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataWriter.php#L35-L41 | train |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._deserializeResponse | protected function _deserializeResponse($responseData)
{
try {
$this->getResponseBody()->deserialize($responseData);
} catch (Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $e) {
$logMessage = sprintf('[%s] Error Payload Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::WARN);
}
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::DEBUG);
}
return $this;
} | php | protected function _deserializeResponse($responseData)
{
try {
$this->getResponseBody()->deserialize($responseData);
} catch (Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $e) {
$logMessage = sprintf('[%s] Error Payload Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::WARN);
}
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::DEBUG);
}
return $this;
} | [
"protected",
"function",
"_deserializeResponse",
"(",
"$",
"responseData",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getResponseBody",
"(",
")",
"->",
"deserialize",
"(",
"$",
"responseData",
")",
";",
"}",
"catch",
"(",
"Radial_RiskService_Sdk_Exception_Invalid_P... | Deserialized the response xml into response payload if an exception is thrown catch it
and set the error payload and deserialized the response xml into it.
@param string
@return self | [
"Deserialized",
"the",
"response",
"xml",
"into",
"response",
"payload",
"if",
"an",
"exception",
"is",
"thrown",
"catch",
"it",
"and",
"set",
"the",
"error",
"payload",
"and",
"deserialized",
"the",
"response",
"xml",
"into",
"it",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L94-L107 | train |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._sendRequest | protected function _sendRequest()
{
// clear the old response
$this->_lastRequestsResponse = null;
$httpMethod = strtolower($this->_config->getHttpMethod());
if (!method_exists($this, $httpMethod)) {
throw Mage::exception(
'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action',
sprintf('HTTP action %s not supported.', strtoupper($httpMethod))
);
}
return $this->$httpMethod();
} | php | protected function _sendRequest()
{
// clear the old response
$this->_lastRequestsResponse = null;
$httpMethod = strtolower($this->_config->getHttpMethod());
if (!method_exists($this, $httpMethod)) {
throw Mage::exception(
'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action',
sprintf('HTTP action %s not supported.', strtoupper($httpMethod))
);
}
return $this->$httpMethod();
} | [
"protected",
"function",
"_sendRequest",
"(",
")",
"{",
"// clear the old response",
"$",
"this",
"->",
"_lastRequestsResponse",
"=",
"null",
";",
"$",
"httpMethod",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"_config",
"->",
"getHttpMethod",
"(",
")",
")",
";... | Send get or post CURL request to the API URI.
@return boolean
@throws Radial_RiskService_Sdk_Exception_Unsupported_Http_Action_Exception | [
"Send",
"get",
"or",
"post",
"CURL",
"request",
"to",
"the",
"API",
"URI",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L175-L188 | train |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._post | protected function _post()
{
$requestXml = $this->getRequestBody()->serialize();
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Request Body: %s', __CLASS__, $this->cleanAuthXml($requestXml));
Mage::log($logMessage, Zend_Log::DEBUG);
}
$xml = simplexml_load_string($requestXml);
if( strcmp($xml->getName(), "RiskAssessmentRequest") === 0)
{
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/assess.xml";
} elseif ( strcmp($xml->getName(), "RiskOrderConfirmationRequest") === 0 ) {
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/orderConfirmation.xml";
} else {
throw Mage::exception('Radial_RiskService_Sdk_Exception_Network_Error', "Unsupported Payload - ". $xml->getName());
}
$options = array();
if( $this->_config->getResponseTimeout() )
{
$seconds = (float)$this->_config->getResponseTimeout() / 1000.0;
$options = array( 'timeout' => $seconds );
}
$this->_lastRequestsResponse = Requests::post(
$hostname,
$this->_buildHeader(),
$requestXml,
$options
);
return $this->_lastRequestsResponse->success;
} | php | protected function _post()
{
$requestXml = $this->getRequestBody()->serialize();
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Request Body: %s', __CLASS__, $this->cleanAuthXml($requestXml));
Mage::log($logMessage, Zend_Log::DEBUG);
}
$xml = simplexml_load_string($requestXml);
if( strcmp($xml->getName(), "RiskAssessmentRequest") === 0)
{
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/assess.xml";
} elseif ( strcmp($xml->getName(), "RiskOrderConfirmationRequest") === 0 ) {
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/orderConfirmation.xml";
} else {
throw Mage::exception('Radial_RiskService_Sdk_Exception_Network_Error', "Unsupported Payload - ". $xml->getName());
}
$options = array();
if( $this->_config->getResponseTimeout() )
{
$seconds = (float)$this->_config->getResponseTimeout() / 1000.0;
$options = array( 'timeout' => $seconds );
}
$this->_lastRequestsResponse = Requests::post(
$hostname,
$this->_buildHeader(),
$requestXml,
$options
);
return $this->_lastRequestsResponse->success;
} | [
"protected",
"function",
"_post",
"(",
")",
"{",
"$",
"requestXml",
"=",
"$",
"this",
"->",
"getRequestBody",
"(",
")",
"->",
"serialize",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_helperConfig",
"->",
"isDebugMode",
"(",
")",
")",
"{",
"$",
"lo... | Send post CURL request.
@return Requests_Response
@throws Requests_Exception | [
"Send",
"post",
"CURL",
"request",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L196-L231 | train |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._get | protected function _get()
{
$this->_lastRequestsResponse = Requests::post(
$this->_config->getEndpoint(),
$this->_buildHeader()
);
return $this->_lastRequestsResponse->success;
} | php | protected function _get()
{
$this->_lastRequestsResponse = Requests::post(
$this->_config->getEndpoint(),
$this->_buildHeader()
);
return $this->_lastRequestsResponse->success;
} | [
"protected",
"function",
"_get",
"(",
")",
"{",
"$",
"this",
"->",
"_lastRequestsResponse",
"=",
"Requests",
"::",
"post",
"(",
"$",
"this",
"->",
"_config",
"->",
"getEndpoint",
"(",
")",
",",
"$",
"this",
"->",
"_buildHeader",
"(",
")",
")",
";",
"re... | Send get CURL request.
@return Requests_Response
@throws Requests_Exception | [
"Send",
"get",
"CURL",
"request",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L252-L259 | train |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api.cleanAuthXml | public function cleanAuthXml($xml)
{
$xml = preg_replace('#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?AccountID.*?\>).*(\</(?:Encrypted)?AccountID\>)#', '$1***$2', $xml);
return $xml;
} | php | public function cleanAuthXml($xml)
{
$xml = preg_replace('#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?AccountID.*?\>).*(\</(?:Encrypted)?AccountID\>)#', '$1***$2', $xml);
return $xml;
} | [
"public",
"function",
"cleanAuthXml",
"(",
"$",
"xml",
")",
"{",
"$",
"xml",
"=",
"preg_replace",
"(",
"'#(\\<(?:Encrypted)?CardSecurityCode\\>).*(\\</(?:Encrypted)?CardSecurityCode\\>)#'",
",",
"'$1***$2'",
",",
"$",
"xml",
")",
";",
"$",
"xml",
"=",
"preg_replace",
... | Scrub the auth request XML message of any sensitive data - CVV, CC number.
@param string $xml
@return string | [
"Scrub",
"the",
"auth",
"request",
"XML",
"message",
"of",
"any",
"sensitive",
"data",
"-",
"CVV",
"CC",
"number",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L266-L272 | train |
drmvc/router | src/Router/Router.php | Router.set | public function set(array $methods, array $args): RouterInterface
{
list($pattern, $callable) = $args;
$route = new Route($methods, $pattern, $callable);
$this->setRoute($route);
return $this;
} | php | public function set(array $methods, array $args): RouterInterface
{
list($pattern, $callable) = $args;
$route = new Route($methods, $pattern, $callable);
$this->setRoute($route);
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"methods",
",",
"array",
"$",
"args",
")",
":",
"RouterInterface",
"{",
"list",
"(",
"$",
"pattern",
",",
"$",
"callable",
")",
"=",
"$",
"args",
";",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"met... | Abstraction of setter
@param array $methods
@param array $args
@return RouterInterface | [
"Abstraction",
"of",
"setter"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L80-L86 | train |
drmvc/router | src/Router/Router.php | Router.checkMethods | public function checkMethods(array $methods): array
{
return array_map(
function($method) {
$method = strtolower($method);
if (!\in_array($method, self::METHODS, false)) {
throw new Exception("Method \"$method\" is not in allowed list [" . implode(',',
self::METHODS) . ']');
}
return $method;
},
$methods
);
} | php | public function checkMethods(array $methods): array
{
return array_map(
function($method) {
$method = strtolower($method);
if (!\in_array($method, self::METHODS, false)) {
throw new Exception("Method \"$method\" is not in allowed list [" . implode(',',
self::METHODS) . ']');
}
return $method;
},
$methods
);
} | [
"public",
"function",
"checkMethods",
"(",
"array",
"$",
"methods",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"method",
")",
"{",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"if",
"(",
"!",
"\\",
"i... | Check if passed methods in allowed list
@param array $methods list of methods for check
@throws Exception
@return array | [
"Check",
"if",
"passed",
"methods",
"in",
"allowed",
"list"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L95-L108 | train |
drmvc/router | src/Router/Router.php | Router.map | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
// Check if method in allowed list
$methods = $this->checkMethods($methods);
// Set new route with parameters
$this->set($methods, [$pattern, $callable]);
return $this;
} | php | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
// Check if method in allowed list
$methods = $this->checkMethods($methods);
// Set new route with parameters
$this->set($methods, [$pattern, $callable]);
return $this;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"methods",
",",
"string",
"$",
"pattern",
",",
"$",
"callable",
")",
":",
"MethodsInterface",
"{",
"// Check if method in allowed list",
"$",
"methods",
"=",
"$",
"this",
"->",
"checkMethods",
"(",
"$",
"methods"... | Callable must be only selected methods
@param array $methods
@param string $pattern
@param callable|string $callable
@throws Exception
@return MethodsInterface | [
"Callable",
"must",
"be",
"only",
"selected",
"methods"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L119-L128 | train |
drmvc/router | src/Router/Router.php | Router.any | public function any(string $pattern, $callable): MethodsInterface
{
// Set new route with all methods
$this->set(self::METHODS, [$pattern, $callable]);
return $this;
} | php | public function any(string $pattern, $callable): MethodsInterface
{
// Set new route with all methods
$this->set(self::METHODS, [$pattern, $callable]);
return $this;
} | [
"public",
"function",
"any",
"(",
"string",
"$",
"pattern",
",",
"$",
"callable",
")",
":",
"MethodsInterface",
"{",
"// Set new route with all methods",
"$",
"this",
"->",
"set",
"(",
"self",
"::",
"METHODS",
",",
"[",
"$",
"pattern",
",",
"$",
"callable",
... | Any method should be callable
@param string $pattern
@param callable|string $callable
@return MethodsInterface | [
"Any",
"method",
"should",
"be",
"callable"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L137-L143 | train |
drmvc/router | src/Router/Router.php | Router.setRoute | public function setRoute(RouteInterface $route): RouterInterface
{
$regexp = $route->getRegexp();
$this->_routes[$regexp] = $route;
return $this;
} | php | public function setRoute(RouteInterface $route): RouterInterface
{
$regexp = $route->getRegexp();
$this->_routes[$regexp] = $route;
return $this;
} | [
"public",
"function",
"setRoute",
"(",
"RouteInterface",
"$",
"route",
")",
":",
"RouterInterface",
"{",
"$",
"regexp",
"=",
"$",
"route",
"->",
"getRegexp",
"(",
")",
";",
"$",
"this",
"->",
"_routes",
"[",
"$",
"regexp",
"]",
"=",
"$",
"route",
";",
... | Add route into the array of routes
@param RouteInterface $route
@return RouterInterface | [
"Add",
"route",
"into",
"the",
"array",
"of",
"routes"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L225-L230 | train |
drmvc/router | src/Router/Router.php | Router.checkMatches | private function checkMatches(string $uri, string $method): array
{
return array_map(
function($regexp, $route) use ($uri, $method) {
$match = preg_match_all($regexp, $uri, $matches);
// If something found and method is correct
if ($match && $route->checkMethod($method)) {
// Set array of variables
$route->setVariables($matches);
return $route;
}
return null;
},
// Array with keys
$this->getRoutes(true),
// Array with values
$this->getRoutes()
);
} | php | private function checkMatches(string $uri, string $method): array
{
return array_map(
function($regexp, $route) use ($uri, $method) {
$match = preg_match_all($regexp, $uri, $matches);
// If something found and method is correct
if ($match && $route->checkMethod($method)) {
// Set array of variables
$route->setVariables($matches);
return $route;
}
return null;
},
// Array with keys
$this->getRoutes(true),
// Array with values
$this->getRoutes()
);
} | [
"private",
"function",
"checkMatches",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"method",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"regexp",
",",
"$",
"route",
")",
"use",
"(",
"$",
"uri",
",",
"$",
"method",
")... | Find route object by URL nad method
@param string $uri
@param string $method
@return array | [
"Find",
"route",
"object",
"by",
"URL",
"nad",
"method"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L239-L258 | train |
drmvc/router | src/Router/Router.php | Router.getMatches | private function getMatches(): array
{
// Extract URI of current query
$uri = $this->getRequest()->getUri()->getPath();
// Extract method of current request
$method = $this->getRequest()->getMethod();
$method = strtolower($method);
// Foreach emulation
return $this->checkMatches($uri, $method);
} | php | private function getMatches(): array
{
// Extract URI of current query
$uri = $this->getRequest()->getUri()->getPath();
// Extract method of current request
$method = $this->getRequest()->getMethod();
$method = strtolower($method);
// Foreach emulation
return $this->checkMatches($uri, $method);
} | [
"private",
"function",
"getMatches",
"(",
")",
":",
"array",
"{",
"// Extract URI of current query",
"$",
"uri",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"// Extract method of current request",
"... | Find optimal route from array of routes by regexp and uri
@return array | [
"Find",
"optimal",
"route",
"from",
"array",
"of",
"routes",
"by",
"regexp",
"and",
"uri"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L265-L276 | train |
drmvc/router | src/Router/Router.php | Router.getRoute | public function getRoute(): RouteInterface
{
// Find route by regexp and URI
$matches = $this->getMatches();
// Cleanup the array of matches, then reindex array
$matches = array_values(array_filter($matches));
// If we have some classes in result of regexp
$result = !empty($matches)
// Take first from matches
? $matches[0] // Here the Route() object
// Create new object with error inside
: $this->getError();
return $result;
} | php | public function getRoute(): RouteInterface
{
// Find route by regexp and URI
$matches = $this->getMatches();
// Cleanup the array of matches, then reindex array
$matches = array_values(array_filter($matches));
// If we have some classes in result of regexp
$result = !empty($matches)
// Take first from matches
? $matches[0] // Here the Route() object
// Create new object with error inside
: $this->getError();
return $result;
} | [
"public",
"function",
"getRoute",
"(",
")",
":",
"RouteInterface",
"{",
"// Find route by regexp and URI",
"$",
"matches",
"=",
"$",
"this",
"->",
"getMatches",
"(",
")",
";",
"// Cleanup the array of matches, then reindex array",
"$",
"matches",
"=",
"array_values",
... | Parse URI by Regexp from routes and return single route
@return RouteInterface | [
"Parse",
"URI",
"by",
"Regexp",
"from",
"routes",
"and",
"return",
"single",
"route"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L283-L299 | train |
drmvc/router | src/Router/Router.php | Router.getRoutes | public function getRoutes(bool $keys = false): array
{
return $keys
? array_keys($this->_routes)
: $this->_routes;
} | php | public function getRoutes(bool $keys = false): array
{
return $keys
? array_keys($this->_routes)
: $this->_routes;
} | [
"public",
"function",
"getRoutes",
"(",
"bool",
"$",
"keys",
"=",
"false",
")",
":",
"array",
"{",
"return",
"$",
"keys",
"?",
"array_keys",
"(",
"$",
"this",
"->",
"_routes",
")",
":",
"$",
"this",
"->",
"_routes",
";",
"}"
] | Get all available routes
@param bool $keys - Return only keys
@return array | [
"Get",
"all",
"available",
"routes"
] | ecbf5f4380a060af83af23334b9f81054bc6c64c | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L307-L312 | train |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.get | public function get(string $index) : string
{
if (!$this->isValid($index)) {
throw new \InvalidArgumentException('The specified value does not exist');
}
return $this->map[$index];
} | php | public function get(string $index) : string
{
if (!$this->isValid($index)) {
throw new \InvalidArgumentException('The specified value does not exist');
}
return $this->map[$index];
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"index",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The specified value does not exist'",
... | Retrieve a value
@param string $index
@return string | [
"Retrieve",
"a",
"value"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L22-L28 | train |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.addValue | public function addValue(string $key, string $value) : void
{
$this->map[$key] = $value;
} | php | public function addValue(string $key, string $value) : void
{
$this->map[$key] = $value;
} | [
"public",
"function",
"addValue",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Add a new value to the map
@param string $key
@param string $value | [
"Add",
"a",
"new",
"value",
"to",
"the",
"map"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L47-L50 | train |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.deleteValue | public function deleteValue(string $key) : void
{
if (isset($this->map[$key])) {
unset($this->map[$key]);
}
} | php | public function deleteValue(string $key) : void
{
if (isset($this->map[$key])) {
unset($this->map[$key]);
}
} | [
"public",
"function",
"deleteValue",
"(",
"string",
"$",
"key",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
")",
... | Delete a value from the map based on the key
@param string $key | [
"Delete",
"a",
"value",
"from",
"the",
"map",
"based",
"on",
"the",
"key"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L56-L61 | train |
valu-digital/valuso | src/ValuSo/Broker/ServiceBrokerFactory.php | ServiceBrokerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$evm = $serviceLocator->get('EventManager');
$config = $serviceLocator->get('Config');
$config = empty($config['valu_so']) ? [] : $config['valu_so'];
$cacheConfig = isset($config['cache']) ? $config['cache'] : null;
/**
* Configure loader
*/
$loaderOptions = array(
'locator' => $serviceLocator->createScopedServiceManager()
);
if (!empty($config['services'])) {
$loaderOptions['services'] = $config['services'];
}
unset($config['services']);
if (isset($config['use_main_locator']) && $config['use_main_locator']) {
$peeringManager = $serviceLocator;
} else {
$peeringManager = null;
}
unset($config['use_main_locator']);
// Pass other configurations as service plugin manager configuration
if (!empty($config)) {
if (isset($cacheConfig['enabled']) && !$cacheConfig['enabled']) {
unset($config['cache']);
} elseif (!isset($cacheConfig['adapter']) && isset($cacheConfig['service'])) {
$cache = $serviceLocator->get($cacheConfig['service']);
if ($cache instanceof StorageInterface) {
$config['cache'] = $cache;
}
}
$smConfig = new ServicePluginManagerConfig($config);
$loaderOptions['service_manager'] = $smConfig;
}
// Initialize loader
$loader = new ServiceLoader(
$loaderOptions
);
if ($peeringManager) {
$loader->addPeeringServiceManager($peeringManager);
}
$broker = new ServiceBroker();
$broker->setLoader($loader);
$this->configureQueue($serviceLocator, $config, $broker);
// Attach configured event listeners
if (!empty($config['listeners'])) {
EventManagerConfigurator::configure(
$broker->getEventManager(),
$serviceLocator,
$config['listeners']);
}
$evm->trigger('valu_so.servicebroker.init', $broker);
return $broker;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$evm = $serviceLocator->get('EventManager');
$config = $serviceLocator->get('Config');
$config = empty($config['valu_so']) ? [] : $config['valu_so'];
$cacheConfig = isset($config['cache']) ? $config['cache'] : null;
/**
* Configure loader
*/
$loaderOptions = array(
'locator' => $serviceLocator->createScopedServiceManager()
);
if (!empty($config['services'])) {
$loaderOptions['services'] = $config['services'];
}
unset($config['services']);
if (isset($config['use_main_locator']) && $config['use_main_locator']) {
$peeringManager = $serviceLocator;
} else {
$peeringManager = null;
}
unset($config['use_main_locator']);
// Pass other configurations as service plugin manager configuration
if (!empty($config)) {
if (isset($cacheConfig['enabled']) && !$cacheConfig['enabled']) {
unset($config['cache']);
} elseif (!isset($cacheConfig['adapter']) && isset($cacheConfig['service'])) {
$cache = $serviceLocator->get($cacheConfig['service']);
if ($cache instanceof StorageInterface) {
$config['cache'] = $cache;
}
}
$smConfig = new ServicePluginManagerConfig($config);
$loaderOptions['service_manager'] = $smConfig;
}
// Initialize loader
$loader = new ServiceLoader(
$loaderOptions
);
if ($peeringManager) {
$loader->addPeeringServiceManager($peeringManager);
}
$broker = new ServiceBroker();
$broker->setLoader($loader);
$this->configureQueue($serviceLocator, $config, $broker);
// Attach configured event listeners
if (!empty($config['listeners'])) {
EventManagerConfigurator::configure(
$broker->getEventManager(),
$serviceLocator,
$config['listeners']);
}
$evm->trigger('valu_so.servicebroker.init', $broker);
return $broker;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"evm",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'EventManager'",
")",
";",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'... | Create a ServiceBroker
{@see ValuSo\Broker\ServiceBroker} uses {@see Zend\ServiceManager\ServiceManager} internally to initialize service
instances. {@see Zend\Mvc\Service\ServiceManagerConfig} for how to configure service manager.
This factory uses following configuration scheme:
<code>
[
'valu_so' => [
// See Zend\Mvc\Service\ServiceManagerConfig
'initializers' => [...],
// Set true to add main service locator as a peering service manager
'use_main_locator' => <true>|<false>,
// See Zend\Mvc\Service\ServiceManagerConfig
'factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'invokables' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'abstract_factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'shared' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'aliases' => [...],
'cache' => [
'enabled' => true|false,
'adapter' => '<ZendCacheAdapter>',
'service' => '<ServiceNameReturningCacheAdapter',
<adapterConfig> => <value>...
],
'services' => [
'<id>' => [
// Name of the service
'name' => '<ServiceName>',
// [optional] Options passed to service
// when initialized
'options' => [...],
// [optional] Service class (same as
// defining it in 'invokables')
'class' => '<Class>',
// [optional] Factory class (same as
// defining it in 'factories')
'factory' => '<Class>',
// [optional] Service object/closure
'service' => <Object|Closure>,
// [optinal] Priority number,
// defaults to 1, highest
// number is executed first
'priority' => <Priority>
]
]
]
]
</code>
@see \Zend\ServiceManager\FactoryInterface::createService()
@return ServiceBroker | [
"Create",
"a",
"ServiceBroker"
] | c96bed0f6bd21551822334fe6cfe913a7436dd17 | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBrokerFactory.php#L76-L144 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.create | public function create($filename, $content)
{
$filename = str::path($filename);
$this->createDirectory(dirname($filename));
return file_put_contents($filename, $content);
} | php | public function create($filename, $content)
{
$filename = str::path($filename);
$this->createDirectory(dirname($filename));
return file_put_contents($filename, $content);
} | [
"public",
"function",
"create",
"(",
"$",
"filename",
",",
"$",
"content",
")",
"{",
"$",
"filename",
"=",
"str",
"::",
"path",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"dirname",
"(",
"$",
"filename",
")",
")",
";",... | To create file
@param string $filename
@param string $content
@return int | [
"To",
"create",
"file"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L20-L27 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.delete | public function delete($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return @unlink($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function delete($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return @unlink($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | [
"public",
"function",
"delete",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"filename",
")",
"&&",
"$",
"this",
"->",
"isFile",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"@",
"unlink",
"(",
"$",
"filename"... | To delete file
@param string $filename
@return bool
@throws FileNotFoundException | [
"To",
"delete",
"file"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L37-L44 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.update | public function update($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return $this->create($filename, $content);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function update($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return $this->create($filename, $content);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | [
"public",
"function",
"update",
"(",
"$",
"filename",
",",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"filename",
")",
"&&",
"$",
"this",
"->",
"isFile",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"$",
"this",
... | To update file
@param string $filename
@param string $content
@return int
@throws FileNotFoundException | [
"To",
"update",
"file"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L71-L78 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.get | public function get($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_get_contents($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function get($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_get_contents($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | [
"public",
"function",
"get",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"filename",
")",
"&&",
"$",
"this",
"->",
"isFile",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"file_get_contents",
"(",
"$",
"filename... | To get file content
@param string $filename
@return string
@throws FileNotFoundException | [
"To",
"get",
"file",
"content"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L88-L95 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.append | public function append($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_put_contents($filename, $content, FILE_APPEND);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function append($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_put_contents($filename, $content, FILE_APPEND);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | [
"public",
"function",
"append",
"(",
"$",
"filename",
",",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"filename",
")",
"&&",
"$",
"this",
"->",
"isFile",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"file_put_conten... | To append file
@param string $filename
@param string $content
@return int
@throws FileNotFoundException | [
"To",
"append",
"file"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L106-L113 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.size | public function size($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return filesize($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function size($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return filesize($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | [
"public",
"function",
"size",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"filename",
")",
"&&",
"$",
"this",
"->",
"isFile",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"filesize",
"(",
"$",
"filename",
")"... | To get a filesize in byte
@param string $filename
@return int
@throws FileNotFoundException | [
"To",
"get",
"a",
"filesize",
"in",
"byte"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L149-L155 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.files | public function files($directoryName)
{
if (!$this->isDir($directoryName)) {
throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directoryName,
RecursiveDirectoryIterator::SKIP_DOTS
)
);
return array_filter(iterator_to_array($files), 'is_file');
} | php | public function files($directoryName)
{
if (!$this->isDir($directoryName)) {
throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directoryName,
RecursiveDirectoryIterator::SKIP_DOTS
)
);
return array_filter(iterator_to_array($files), 'is_file');
} | [
"public",
"function",
"files",
"(",
"$",
"directoryName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isDir",
"(",
"$",
"directoryName",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"'Directory not found in the path [ '",
".",
"$",
"directory... | To get all files in a directory
@param string $directoryName
@return array
@throws FileNotFoundException | [
"To",
"get",
"all",
"files",
"in",
"a",
"directory"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L165-L178 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.directories | public function directories($directoryName)
{
if (!$this->isDir($directoryName)) {
throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directoryName,
RecursiveDirectoryIterator::CURRENT_AS_FILEINFO)
);
$directories = [];
foreach($iterator as $file) {
if($file->isDir()) {
if( !(substr($file,-2) === '..')) {
$directories[] = trim($file,'.');
}
}
}
array_shift($directories);
return $directories;
} | php | public function directories($directoryName)
{
if (!$this->isDir($directoryName)) {
throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directoryName,
RecursiveDirectoryIterator::CURRENT_AS_FILEINFO)
);
$directories = [];
foreach($iterator as $file) {
if($file->isDir()) {
if( !(substr($file,-2) === '..')) {
$directories[] = trim($file,'.');
}
}
}
array_shift($directories);
return $directories;
} | [
"public",
"function",
"directories",
"(",
"$",
"directoryName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isDir",
"(",
"$",
"directoryName",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"'Directory not found in the path [ '",
".",
"$",
"dir... | To get all directories in a directory
@param string $directoryName
@return array
@throws FileNotFoundException | [
"To",
"get",
"all",
"directories",
"in",
"a",
"directory"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L188-L212 | train |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.cleanDirectory | public function cleanDirectory($directoryName, $deleteRootDirectory = false)
{
if(is_dir($directoryName)){
$files = glob( $directoryName . '/*', GLOB_NOSORT );
foreach( $files as $file )
{
$this->cleanDirectory( $file, true );
}
if(file_exists($directoryName) && ($deleteRootDirectory == true)) {
@rmdir( $directoryName );
}
} elseif(is_file($directoryName)) {
@unlink( $directoryName );
}
if(file_exists($directoryName)) {
return true;
}
return false;
} | php | public function cleanDirectory($directoryName, $deleteRootDirectory = false)
{
if(is_dir($directoryName)){
$files = glob( $directoryName . '/*', GLOB_NOSORT );
foreach( $files as $file )
{
$this->cleanDirectory( $file, true );
}
if(file_exists($directoryName) && ($deleteRootDirectory == true)) {
@rmdir( $directoryName );
}
} elseif(is_file($directoryName)) {
@unlink( $directoryName );
}
if(file_exists($directoryName)) {
return true;
}
return false;
} | [
"public",
"function",
"cleanDirectory",
"(",
"$",
"directoryName",
",",
"$",
"deleteRootDirectory",
"=",
"false",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directoryName",
")",
")",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"directoryName",
".",
"'/*'",
... | To clean a directory
@param string $directoryName
@param bool $deleteRootDirectory
@return bool | [
"To",
"clean",
"a",
"directory"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L250-L272 | train |
ARCANEDEV/Markup | src/Entities/Tag.php | Tag.addElement | public function addElement($tag, array $attributes = [])
{
if ($tag instanceof self) {
$htmlTag = $tag;
$htmlTag->top = $this->top;
$htmlTag->attrs($attributes);
$this->elements->add($htmlTag);
return $htmlTag;
}
return self::make(
$tag,
$attributes,
$this->hasParent() ? $this->parent : $this
);
} | php | public function addElement($tag, array $attributes = [])
{
if ($tag instanceof self) {
$htmlTag = $tag;
$htmlTag->top = $this->top;
$htmlTag->attrs($attributes);
$this->elements->add($htmlTag);
return $htmlTag;
}
return self::make(
$tag,
$attributes,
$this->hasParent() ? $this->parent : $this
);
} | [
"public",
"function",
"addElement",
"(",
"$",
"tag",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"tag",
"instanceof",
"self",
")",
"{",
"$",
"htmlTag",
"=",
"$",
"tag",
";",
"$",
"htmlTag",
"->",
"top",
"=",
"$",
"th... | Add element at an existing Markup
@param Tag|string $tag
@param array $attributes
@return Tag | [
"Add",
"element",
"at",
"an",
"existing",
"Markup"
] | 881331df74b27614d025c365daacbae6aa865612 | https://github.com/ARCANEDEV/Markup/blob/881331df74b27614d025c365daacbae6aa865612/src/Entities/Tag.php#L187-L203 | train |
ARCANEDEV/Markup | src/Entities/Tag.php | Tag.getFirst | public function getFirst()
{
$element = null;
if (
$this->hasParent() and
$this->parent->hasElements()
) {
$element = $this->parent->elements[0];
}
return $element;
} | php | public function getFirst()
{
$element = null;
if (
$this->hasParent() and
$this->parent->hasElements()
) {
$element = $this->parent->elements[0];
}
return $element;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"$",
"element",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasParent",
"(",
")",
"and",
"$",
"this",
"->",
"parent",
"->",
"hasElements",
"(",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
... | Return first child of parent of current object
@return Tag|null | [
"Return",
"first",
"child",
"of",
"parent",
"of",
"current",
"object"
] | 881331df74b27614d025c365daacbae6aa865612 | https://github.com/ARCANEDEV/Markup/blob/881331df74b27614d025c365daacbae6aa865612/src/Entities/Tag.php#L220-L232 | train |
phossa2/storage | src/Storage/Traits/MountableTrait.php | MountableTrait.getMountPoint | protected function getMountPoint(/*# string */ $path)/*# : string */
{
while ($path !== '') {
if (isset($this->filesystems[$path])) {
return $path;
}
$path = substr($path, 0, strrpos($path, '/'));
}
return '/';
} | php | protected function getMountPoint(/*# string */ $path)/*# : string */
{
while ($path !== '') {
if (isset($this->filesystems[$path])) {
return $path;
}
$path = substr($path, 0, strrpos($path, '/'));
}
return '/';
} | [
"protected",
"function",
"getMountPoint",
"(",
"/*# string */",
"$",
"path",
")",
"/*# : string */",
"{",
"while",
"(",
"$",
"path",
"!==",
"''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filesystems",
"[",
"$",
"path",
"]",
")",
")",
"{",... | Find mount point of the path
@param string $path
@return string
@access protected | [
"Find",
"mount",
"point",
"of",
"the",
"path"
] | 777f174559359deb56e63101c4962750eb15cfde | https://github.com/phossa2/storage/blob/777f174559359deb56e63101c4962750eb15cfde/src/Storage/Traits/MountableTrait.php#L119-L128 | train |
schpill/thin | src/Hash.php | Hash.make | public static function make($value, $rounds = 8)
{
$work = str_pad($rounds, 2, '0', STR_PAD_LEFT);
// Bcrypt expects the salt to be 22 base64 encoded characters including
// dots and slashes. We will get rid of the plus signs included in the
// base64 data and replace them with dots.
if (function_exists('openssl_random_pseudo_bytes')) {
$salt = openssl_random_pseudo_bytes(16);
} else {
$salt = Inflector::random(40);
}
$salt = substr(strtr(base64_encode($salt), '+', '.'), 0 , 22);
return crypt($value, '$2a$' . $work . '$' . $salt);
} | php | public static function make($value, $rounds = 8)
{
$work = str_pad($rounds, 2, '0', STR_PAD_LEFT);
// Bcrypt expects the salt to be 22 base64 encoded characters including
// dots and slashes. We will get rid of the plus signs included in the
// base64 data and replace them with dots.
if (function_exists('openssl_random_pseudo_bytes')) {
$salt = openssl_random_pseudo_bytes(16);
} else {
$salt = Inflector::random(40);
}
$salt = substr(strtr(base64_encode($salt), '+', '.'), 0 , 22);
return crypt($value, '$2a$' . $work . '$' . $salt);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"value",
",",
"$",
"rounds",
"=",
"8",
")",
"{",
"$",
"work",
"=",
"str_pad",
"(",
"$",
"rounds",
",",
"2",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"// Bcrypt expects the salt to be 22 base64 encoded chara... | Hash a password using the Bcrypt hashing scheme.
<code>
// Create a Bcrypt hash of a value
$hash = Hash::make('secret');
// Use a specified number of iterations when creating the hash
$hash = Hash::make('secret', 12);
</code>
@param string $value
@param int $rounds
@return string | [
"Hash",
"a",
"password",
"using",
"the",
"Bcrypt",
"hashing",
"scheme",
"."
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Hash.php#L25-L41 | train |
CandleLight-Project/Framework | src/Error.php | Error.registerSystemErrors | public static function registerSystemErrors(Slim $app): void{
/** @var Container $c */
$c = $app->getContainer();
// Exception Handler
$c['errorHandler'] = function ($c){
/**
* Custom exception cather for the slim-framework
* @param Request $request Request Object
* @param Response $response Response Object
* @param \Exception $exception Thrown Exception
* @return Response Object
*/
return function (Request $request, Response $response, \Exception $exception) use ($c): Response{
/** @var Response $response */
$response = $c['response'];
return $response
->withStatus(500)
->withJson(new self($exception->getMessage()));
};
};
// 404 Handler
$c['notFoundHandler'] = function ($c){
/**
* Custom 404 handler for the slim-framework
* @param Request $request Request Object
* @param Response $response Response Object
* @return Response Object
*/
return function (Request $request, Response $response) use ($c){
return $c['response']
->withStatus(404)
->withJson(new self('Route not defined'));
};
};
// Method not supported Handler
$c['notAllowedHandler'] = function ($c){
return function ($request, $response, $methods) use ($c){
return $c['response']
->withStatus(405)
->withJson(new self('Method needs to be ' . implode($methods, ', ') . ' for this route.'));
};
};
} | php | public static function registerSystemErrors(Slim $app): void{
/** @var Container $c */
$c = $app->getContainer();
// Exception Handler
$c['errorHandler'] = function ($c){
/**
* Custom exception cather for the slim-framework
* @param Request $request Request Object
* @param Response $response Response Object
* @param \Exception $exception Thrown Exception
* @return Response Object
*/
return function (Request $request, Response $response, \Exception $exception) use ($c): Response{
/** @var Response $response */
$response = $c['response'];
return $response
->withStatus(500)
->withJson(new self($exception->getMessage()));
};
};
// 404 Handler
$c['notFoundHandler'] = function ($c){
/**
* Custom 404 handler for the slim-framework
* @param Request $request Request Object
* @param Response $response Response Object
* @return Response Object
*/
return function (Request $request, Response $response) use ($c){
return $c['response']
->withStatus(404)
->withJson(new self('Route not defined'));
};
};
// Method not supported Handler
$c['notAllowedHandler'] = function ($c){
return function ($request, $response, $methods) use ($c){
return $c['response']
->withStatus(405)
->withJson(new self('Method needs to be ' . implode($methods, ', ') . ' for this route.'));
};
};
} | [
"public",
"static",
"function",
"registerSystemErrors",
"(",
"Slim",
"$",
"app",
")",
":",
"void",
"{",
"/** @var Container $c */",
"$",
"c",
"=",
"$",
"app",
"->",
"getContainer",
"(",
")",
";",
"// Exception Handler",
"$",
"c",
"[",
"'errorHandler'",
"]",
... | Injects a custom error handling into the Slim-framework
@param Slim $app Slim Framework instance | [
"Injects",
"a",
"custom",
"error",
"handling",
"into",
"the",
"Slim",
"-",
"framework"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Error.php#L32-L74 | train |
ARCANEDEV/Markup | src/Support/Builder.php | Builder.make | public static function make(TagInterface $tag)
{
if (
$tag->getType() === '' and
$tag->getText() !== ''
) {
return $tag->getText();
}
return self::isAutoClosed($tag->getType())
? self::open($tag, true)
: self::open($tag) . $tag->getText() . $tag->renderElements() . self::close($tag);
} | php | public static function make(TagInterface $tag)
{
if (
$tag->getType() === '' and
$tag->getText() !== ''
) {
return $tag->getText();
}
return self::isAutoClosed($tag->getType())
? self::open($tag, true)
: self::open($tag) . $tag->getText() . $tag->renderElements() . self::close($tag);
} | [
"public",
"static",
"function",
"make",
"(",
"TagInterface",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"tag",
"->",
"getType",
"(",
")",
"===",
"''",
"and",
"$",
"tag",
"->",
"getText",
"(",
")",
"!==",
"''",
")",
"{",
"return",
"$",
"tag",
"->",
"ge... | Render a Tag and its elements
@param TagInterface $tag
@return string | [
"Render",
"a",
"Tag",
"and",
"its",
"elements"
] | 881331df74b27614d025c365daacbae6aa865612 | https://github.com/ARCANEDEV/Markup/blob/881331df74b27614d025c365daacbae6aa865612/src/Support/Builder.php#L28-L40 | train |
ARCANEDEV/Markup | src/Support/Builder.php | Builder.open | private static function open(TagInterface $tag, $autoClosed = false)
{
$output = '<' . $tag->getType();
if ($tag->hasAttributes()) {
$output .= ' ' . $tag->renderAttributes();
}
$output .= ($autoClosed ? '/>' : '>');
return $output;
} | php | private static function open(TagInterface $tag, $autoClosed = false)
{
$output = '<' . $tag->getType();
if ($tag->hasAttributes()) {
$output .= ' ' . $tag->renderAttributes();
}
$output .= ($autoClosed ? '/>' : '>');
return $output;
} | [
"private",
"static",
"function",
"open",
"(",
"TagInterface",
"$",
"tag",
",",
"$",
"autoClosed",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"'<'",
".",
"$",
"tag",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"$",
"tag",
"->",
"hasAttributes",
"(",
... | Render open Tag
@param TagInterface $tag
@param bool $autoClosed
@return string | [
"Render",
"open",
"Tag"
] | 881331df74b27614d025c365daacbae6aa865612 | https://github.com/ARCANEDEV/Markup/blob/881331df74b27614d025c365daacbae6aa865612/src/Support/Builder.php#L50-L61 | train |
chilimatic/chilimatic-framework | lib/database/sql/mysql/Statement.php | Statement.bindParam | public function bindParam($placeholder, &$var, $type = null)
{
$this->param_list[$placeholder] = &$var;
if (!empty($type) && in_array($type, $this->_type_list)) {
$this->type_list[$placeholder] = &$type;
}
return true;
} | php | public function bindParam($placeholder, &$var, $type = null)
{
$this->param_list[$placeholder] = &$var;
if (!empty($type) && in_array($type, $this->_type_list)) {
$this->type_list[$placeholder] = &$type;
}
return true;
} | [
"public",
"function",
"bindParam",
"(",
"$",
"placeholder",
",",
"&",
"$",
"var",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"param_list",
"[",
"$",
"placeholder",
"]",
"=",
"&",
"$",
"var",
";",
"if",
"(",
"!",
"empty",
"(",
"$"... | binds a parameter
@param string $placeholder
@param mixed $var
@param null $type
@return bool | [
"binds",
"a",
"parameter"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Statement.php#L142-L152 | train |
chilimatic/chilimatic-framework | lib/database/sql/mysql/Statement.php | Statement.fetchAll | public function fetchAll($type = null)
{
try {
if ($this->res === false) {
throw new DatabaseException(__METHOD__ . " No ressource has been given", MySQL::NO_RESSOURCE, MySQL::SEVERITY_DEBUG, __FILE__, __LINE__);
}
switch ($type) {
case MySQL::FETCH_ASSOC:
return $this->_db->fetch_assoc_list($this->res);
break;
case MySQL::FETCH_NUM:
return $this->_db->fetch_num_list($this->res);
break;
case MySQL::FETCH_OBJ:
default:
return $this->_db->fetch_object_list($this->res);
break;
}
} catch (DatabaseException $e) {
throw $e;
}
} | php | public function fetchAll($type = null)
{
try {
if ($this->res === false) {
throw new DatabaseException(__METHOD__ . " No ressource has been given", MySQL::NO_RESSOURCE, MySQL::SEVERITY_DEBUG, __FILE__, __LINE__);
}
switch ($type) {
case MySQL::FETCH_ASSOC:
return $this->_db->fetch_assoc_list($this->res);
break;
case MySQL::FETCH_NUM:
return $this->_db->fetch_num_list($this->res);
break;
case MySQL::FETCH_OBJ:
default:
return $this->_db->fetch_object_list($this->res);
break;
}
} catch (DatabaseException $e) {
throw $e;
}
} | [
"public",
"function",
"fetchAll",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"res",
"===",
"false",
")",
"{",
"throw",
"new",
"DatabaseException",
"(",
"__METHOD__",
".",
"\" No ressource has been given\"",
",",
"MyS... | fetch all option
@param null $type
@return array
@throws DatabaseException
@throws \Exception | [
"fetch",
"all",
"option"
] | 8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12 | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Statement.php#L225-L249 | train |
andyburton/Sonic-Framework | src/Model/Tools/Comment.php | Comment.hasTag | public function hasTag ($tag)
{
foreach ($this->lines as $line)
{
if (strpos ($line, '@' . $tag) === 0)
{
return TRUE;
}
}
return FALSE;
} | php | public function hasTag ($tag)
{
foreach ($this->lines as $line)
{
if (strpos ($line, '@' . $tag) === 0)
{
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"hasTag",
"(",
"$",
"tag",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'@'",
".",
"$",
"tag",
")",
"===",
"0",
")",
"{",
"return",
"TRUE",... | Check if a tag is set in the comment
@param string $tag Tag to check for e.g. ignore = @ignore
@return boolean | [
"Check",
"if",
"a",
"tag",
"is",
"set",
"in",
"the",
"comment"
] | a5999448a0abab4d542413002a780ede391e7374 | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Model/Tools/Comment.php#L36-L49 | train |
andyburton/Sonic-Framework | src/Model/Tools/Comment.php | Comment.getTags | public function getTags ($tag)
{
$tags = array ();
foreach ($this->lines as $line)
{
if (strpos ($line, '@' . $tag) === 0)
{
$tags[] = trim (substr ($line, strlen ('@' . $tag)));
}
}
return $tags;
} | php | public function getTags ($tag)
{
$tags = array ();
foreach ($this->lines as $line)
{
if (strpos ($line, '@' . $tag) === 0)
{
$tags[] = trim (substr ($line, strlen ('@' . $tag)));
}
}
return $tags;
} | [
"public",
"function",
"getTags",
"(",
"$",
"tag",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'@'",
".",
"$",
"tag",
... | Return array of matching tags
@param string $tag Tags to return
@return array | [
"Return",
"array",
"of",
"matching",
"tags"
] | a5999448a0abab4d542413002a780ede391e7374 | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Model/Tools/Comment.php#L57-L72 | train |
andyburton/Sonic-Framework | src/Model/Tools/Comment.php | Comment.getLongDescription | public function getLongDescription ()
{
$comment = '';
foreach ($this->lines as $key => $line)
{
if ($key == 0 || ($line && $line[0] == '@'))
{
continue;
}
if ($comment)
{
$comment .= "\n";
}
$comment .= $line;
}
return $comment;
} | php | public function getLongDescription ()
{
$comment = '';
foreach ($this->lines as $key => $line)
{
if ($key == 0 || ($line && $line[0] == '@'))
{
continue;
}
if ($comment)
{
$comment .= "\n";
}
$comment .= $line;
}
return $comment;
} | [
"public",
"function",
"getLongDescription",
"(",
")",
"{",
"$",
"comment",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"key",
"=>",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"0",
"||",
"(",
"$",
"line",
"&&",
... | Return long description
This is every other line of a comment besides the first line and any tags
@return string | [
"Return",
"long",
"description",
"This",
"is",
"every",
"other",
"line",
"of",
"a",
"comment",
"besides",
"the",
"first",
"line",
"and",
"any",
"tags"
] | a5999448a0abab4d542413002a780ede391e7374 | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Model/Tools/Comment.php#L93-L117 | train |
andyburton/Sonic-Framework | src/Model/Tools/Comment.php | Comment.starComment | public static function starComment ($strComment, $intTabs = 0)
{
// Set return
$strReturn = '';
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Find the position of the first /
$intFirstSlash = strpos ($arrComment[0], '/');
// Set prefix
$strPrefix = ($intFirstSlash)? substr ($arrComment[0], 0, $intFirstSlash) : NULL;
// Clean comment
$strComment = self::cleanComment ($strComment);
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Set the high count
$intHigh = 0;
// For each line
foreach ($arrComment as $strLine)
{
// If the length is above the high count
if (strlen ($strLine) > $intHigh)
{
// Set length as high count
$intHigh = strlen ($strLine);
}
}
// For each line
foreach ($arrComment as &$strLine)
{
// Count chars
$strCountChars = count_chars ($strLine, 3);
// If the comment consists of only -'s
if ($strCountChars == '-')
{
// Set the line to be -'s
$strLine = str_repeat ('-', $intHigh);
}
}
// Unset reference
unset ($strLine);
// Set tabs
$strTabs = str_repeat ("\t", $intTabs);
// Add the first lines
$strReturn .= $strTabs . $strPrefix . '/****' . str_repeat ('*', $intHigh) . '*****' . "\n" .
$strTabs . $strPrefix . '* ' . str_repeat (' ', $intHigh) . ' *' . "\n";
// For each line
foreach ($arrComment as $strLine)
{
// Add to return
$strReturn .= $strTabs . $strPrefix . '* ' . str_pad ($strLine, $intHigh) . ' *' . "\n";
}
// Add the last lines
$strReturn .= $strTabs . $strPrefix . '* ' . str_repeat (' ', $intHigh) . ' *' . "\n" .
$strTabs . $strPrefix . '*****' . str_repeat ('*', $intHigh) . '****/';
// Return
return $strReturn;
} | php | public static function starComment ($strComment, $intTabs = 0)
{
// Set return
$strReturn = '';
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Find the position of the first /
$intFirstSlash = strpos ($arrComment[0], '/');
// Set prefix
$strPrefix = ($intFirstSlash)? substr ($arrComment[0], 0, $intFirstSlash) : NULL;
// Clean comment
$strComment = self::cleanComment ($strComment);
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Set the high count
$intHigh = 0;
// For each line
foreach ($arrComment as $strLine)
{
// If the length is above the high count
if (strlen ($strLine) > $intHigh)
{
// Set length as high count
$intHigh = strlen ($strLine);
}
}
// For each line
foreach ($arrComment as &$strLine)
{
// Count chars
$strCountChars = count_chars ($strLine, 3);
// If the comment consists of only -'s
if ($strCountChars == '-')
{
// Set the line to be -'s
$strLine = str_repeat ('-', $intHigh);
}
}
// Unset reference
unset ($strLine);
// Set tabs
$strTabs = str_repeat ("\t", $intTabs);
// Add the first lines
$strReturn .= $strTabs . $strPrefix . '/****' . str_repeat ('*', $intHigh) . '*****' . "\n" .
$strTabs . $strPrefix . '* ' . str_repeat (' ', $intHigh) . ' *' . "\n";
// For each line
foreach ($arrComment as $strLine)
{
// Add to return
$strReturn .= $strTabs . $strPrefix . '* ' . str_pad ($strLine, $intHigh) . ' *' . "\n";
}
// Add the last lines
$strReturn .= $strTabs . $strPrefix . '* ' . str_repeat (' ', $intHigh) . ' *' . "\n" .
$strTabs . $strPrefix . '*****' . str_repeat ('*', $intHigh) . '****/';
// Return
return $strReturn;
} | [
"public",
"static",
"function",
"starComment",
"(",
"$",
"strComment",
",",
"$",
"intTabs",
"=",
"0",
")",
"{",
"// Set return",
"$",
"strReturn",
"=",
"''",
";",
"// Split comment into lines",
"$",
"arrComment",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"st... | Return a stared comment
@param string $strComment Comment
@param integer $intTabs Tabs before line
@return string | [
"Return",
"a",
"stared",
"comment"
] | a5999448a0abab4d542413002a780ede391e7374 | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Model/Tools/Comment.php#L127-L231 | train |
andyburton/Sonic-Framework | src/Model/Tools/Comment.php | Comment.lineComment | public static function lineComment ($strComment, $intTabs = 0)
{
// Set return
$strReturn = '';
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Find the position of the first /
$intFirstSlash = strpos ($arrComment[0], '/');
// Set prefix
$strPrefix = ($intFirstSlash)? substr ($arrComment[0], 0, $intFirstSlash) : NULL;
// Clean comment
$strComment = self::cleanComment ($strComment);
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Set tabs
$strTabs = str_repeat ("\t", $intTabs);
// For each line
foreach ($arrComment as $strLine)
{
// Add line
$strReturn .= $strTabs . $strPrefix . '// ' . $strLine . "\n";
}
// Remove last \n
if (substr ($strReturn, -1) == "\n")
{
$strReturn = substr ($strReturn, 0, -1);
}
// Return
return $strReturn;
} | php | public static function lineComment ($strComment, $intTabs = 0)
{
// Set return
$strReturn = '';
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Find the position of the first /
$intFirstSlash = strpos ($arrComment[0], '/');
// Set prefix
$strPrefix = ($intFirstSlash)? substr ($arrComment[0], 0, $intFirstSlash) : NULL;
// Clean comment
$strComment = self::cleanComment ($strComment);
// Split comment into lines
$arrComment = explode ("\n", $strComment);
// Set tabs
$strTabs = str_repeat ("\t", $intTabs);
// For each line
foreach ($arrComment as $strLine)
{
// Add line
$strReturn .= $strTabs . $strPrefix . '// ' . $strLine . "\n";
}
// Remove last \n
if (substr ($strReturn, -1) == "\n")
{
$strReturn = substr ($strReturn, 0, -1);
}
// Return
return $strReturn;
} | [
"public",
"static",
"function",
"lineComment",
"(",
"$",
"strComment",
",",
"$",
"intTabs",
"=",
"0",
")",
"{",
"// Set return",
"$",
"strReturn",
"=",
"''",
";",
"// Split comment into lines",
"$",
"arrComment",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"st... | Return a lined comment
@param type $strComment Comment
@param type $intTabs Tabs before line
@return string | [
"Return",
"a",
"lined",
"comment"
] | a5999448a0abab4d542413002a780ede391e7374 | https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Model/Tools/Comment.php#L241-L296 | train |
pascalchevrel/vcs | src/VCS/Git.php | Git.getCommits | public function getCommits()
{
$log = $this->execute(
"git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' "
. $this->repository_path
);
$this->repository_type = 'git';
return $this->parseLog($log);
} | php | public function getCommits()
{
$log = $this->execute(
"git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' "
. $this->repository_path
);
$this->repository_type = 'git';
return $this->parseLog($log);
} | [
"public",
"function",
"getCommits",
"(",
")",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"execute",
"(",
"\"git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' \"",
".",
"$",
"this",
"->",
"repository_path",
")",
";",
"$",
"this",
"->... | Get the list of Git commits for the repository as a structured array
@return array List of commits | [
"Get",
"the",
"list",
"of",
"Git",
"commits",
"for",
"the",
"repository",
"as",
"a",
"structured",
"array"
] | 23d4827d5f8f44f20cd9a59fdf71ee7dfc895bfa | https://github.com/pascalchevrel/vcs/blob/23d4827d5f8f44f20cd9a59fdf71ee7dfc895bfa/src/VCS/Git.php#L11-L20 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.