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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FuzeWorks/Core | src/FuzeWorks/Models.php | Models.loadModel | protected function loadModel($modelName, $directories): ModelAbstract
{
if (empty($directories))
{
throw new ModelException("Could not load model. No directories provided", 1);
}
// Now figure out the className and subdir
$class = trim($modelName, '/');
i... | php | protected function loadModel($modelName, $directories): ModelAbstract
{
if (empty($directories))
{
throw new ModelException("Could not load model. No directories provided", 1);
}
// Now figure out the className and subdir
$class = trim($modelName, '/');
i... | [
"protected",
"function",
"loadModel",
"(",
"$",
"modelName",
",",
"$",
"directories",
")",
":",
"ModelAbstract",
"{",
"if",
"(",
"empty",
"(",
"$",
"directories",
")",
")",
"{",
"throw",
"new",
"ModelException",
"(",
"\"Could not load model. No directories provide... | Load and return a model.
Supply the name and the model will be loaded from one of the supplied directories
@param string $modelName Name of the model
@param array $directories Directories to try and load the model from
@return ModelAbstract The Model object | [
"Load",
"and",
"return",
"a",
"model",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Models.php#L109-L161 | train |
FuzeWorks/Core | src/FuzeWorks/Models.php | Models.removeModelPath | public function removeModelPath($directory)
{
if (($key = array_search($directory, $this->modelPaths)) !== false)
{
unset($this->modelPaths[$key]);
}
} | php | public function removeModelPath($directory)
{
if (($key = array_search($directory, $this->modelPaths)) !== false)
{
unset($this->modelPaths[$key]);
}
} | [
"public",
"function",
"removeModelPath",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"directory",
",",
"$",
"this",
"->",
"modelPaths",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->... | Remove a path where models can be found
@param string $directory The directory
@return void | [
"Remove",
"a",
"path",
"where",
"models",
"can",
"be",
"found"
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Models.php#L183-L189 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.setDefaultEncoding | public static function setDefaultEncoding($encoding=null)
{
if(!is_null($encoding) && is_string($encoding) && !empty($encoding))
{
self::$defaultencoding = $encoding;
}
else
{
self::$defaultencoding = null;
}
} | php | public static function setDefaultEncoding($encoding=null)
{
if(!is_null($encoding) && is_string($encoding) && !empty($encoding))
{
self::$defaultencoding = $encoding;
}
else
{
self::$defaultencoding = null;
}
} | [
"public",
"static",
"function",
"setDefaultEncoding",
"(",
"$",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"encoding",
")",
"&&",
"is_string",
"(",
"$",
"encoding",
")",
"&&",
"!",
"empty",
"(",
"$",
"encoding",
")",
")",
... | Set global default encoding
@param string $encoding | [
"Set",
"global",
"default",
"encoding"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L17-L27 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.newInstance | public function newInstance($value = null)
{
$class = $this->getClassName();
$o = new $class($value, $this->encoding);
return $o;
} | php | public function newInstance($value = null)
{
$class = $this->getClassName();
$o = new $class($value, $this->encoding);
return $o;
} | [
"public",
"function",
"newInstance",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getClassName",
"(",
")",
";",
"$",
"o",
"=",
"new",
"$",
"class",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"encoding",
")",
";... | Creates new instance of current class type
@return \PerrysLambda\StringProperty | [
"Creates",
"new",
"instance",
"of",
"current",
"class",
"type"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L57-L62 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.getEncoding | protected function getEncoding($encoding=null)
{
if(is_null($encoding))
{
if(!is_null($this->encoding))
{
return $this->encoding;
}
return self::getDefaultEncoding();
}
return $encoding;
} | php | protected function getEncoding($encoding=null)
{
if(is_null($encoding))
{
if(!is_null($this->encoding))
{
return $this->encoding;
}
return self::getDefaultEncoding();
}
return $encoding;
} | [
"protected",
"function",
"getEncoding",
"(",
"$",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"encoding",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"encoding",
")",
")",
"{",
"return",
"$",
"this",
"->... | Helper function to set default encoding
@param string $encoding
@return string | [
"Helper",
"function",
"to",
"set",
"default",
"encoding"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L97-L108 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.substr | public function substr($start, $length=null)
{
return $this->newInstance(mb_substr($this->toString(), $start, $length, $this->getEncoding()));
} | php | public function substr($start, $length=null)
{
return $this->newInstance(mb_substr($this->toString(), $start, $length, $this->getEncoding()));
} | [
"public",
"function",
"substr",
"(",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"newInstance",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"start",
",",
"$",
"length",
",",
"$... | Return a substring of value
@param int $start
@param int $length
@return \PerrysLambda\StringProperty | [
"Return",
"a",
"substring",
"of",
"value"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L221-L224 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.split | public function split($separator)
{
$temp = explode($separator, $this->toString());
$list = ArrayList::asType($this->getClassName(), $temp);
return $list;
} | php | public function split($separator)
{
$temp = explode($separator, $this->toString());
$list = ArrayList::asType($this->getClassName(), $temp);
return $list;
} | [
"public",
"function",
"split",
"(",
"$",
"separator",
")",
"{",
"$",
"temp",
"=",
"explode",
"(",
"$",
"separator",
",",
"$",
"this",
"->",
"toString",
"(",
")",
")",
";",
"$",
"list",
"=",
"ArrayList",
"::",
"asType",
"(",
"$",
"this",
"->",
"getC... | Split string by separator
@param string $separator
@return \PerrysLambda\ArrayList | [
"Split",
"string",
"by",
"separator"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L231-L236 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.padDynamic | protected function padDynamic($padstr, $length, $type)
{
return $this->newInstance(str_pad($this->toString(), $length, $padstr, $type));
} | php | protected function padDynamic($padstr, $length, $type)
{
return $this->newInstance(str_pad($this->toString(), $length, $padstr, $type));
} | [
"protected",
"function",
"padDynamic",
"(",
"$",
"padstr",
",",
"$",
"length",
",",
"$",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"newInstance",
"(",
"str_pad",
"(",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"length",
",",
"$",
"padstr... | Helper function for string padding
@param string $padstr
@param int $length
@param int $type
@return \PerrysLambda\StringProperty | [
"Helper",
"function",
"for",
"string",
"padding"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L245-L248 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.indexOfDyamic | protected function indexOfDyamic($function, $needle, $offset)
{
$r = $function($this->toString(), $needle, $offset, $this->getEncoding());
return ($r===false ? -1 : $r);
} | php | protected function indexOfDyamic($function, $needle, $offset)
{
$r = $function($this->toString(), $needle, $offset, $this->getEncoding());
return ($r===false ? -1 : $r);
} | [
"protected",
"function",
"indexOfDyamic",
"(",
"$",
"function",
",",
"$",
"needle",
",",
"$",
"offset",
")",
"{",
"$",
"r",
"=",
"$",
"function",
"(",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"needle",
",",
"$",
"offset",
",",
"$",
"this"... | Helper function for strpos
@param string $function
@param string $needle
@param int $offset
@return int | [
"Helper",
"function",
"for",
"strpos"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L290-L294 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.lastIndexOfDynamic | protected function lastIndexOfDynamic($function, $needle, $offset=0)
{
$r = $function($this->toString(), $needle, $offset, $this->getEncoding());
return ($r===false ? -1 : $r);
} | php | protected function lastIndexOfDynamic($function, $needle, $offset=0)
{
$r = $function($this->toString(), $needle, $offset, $this->getEncoding());
return ($r===false ? -1 : $r);
} | [
"protected",
"function",
"lastIndexOfDynamic",
"(",
"$",
"function",
",",
"$",
"needle",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"r",
"=",
"$",
"function",
"(",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"needle",
",",
"$",
"offset",
"... | Helper function for strrpos
@param string $function
@param string $needle
@param int $offset
@return int | [
"Helper",
"function",
"for",
"strrpos"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L327-L331 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.endsWithDynamic | protected function endsWithDynamic($function, $needle)
{
$enc = $this->getEncoding();
$strlen = $this->length($enc);
$testlen = mb_strlen($needle, $enc);
if ($testlen <= $strlen)
{
return ($function($this->toString(), $needle, ($strlen-$testlen), $enc)!==false);
... | php | protected function endsWithDynamic($function, $needle)
{
$enc = $this->getEncoding();
$strlen = $this->length($enc);
$testlen = mb_strlen($needle, $enc);
if ($testlen <= $strlen)
{
return ($function($this->toString(), $needle, ($strlen-$testlen), $enc)!==false);
... | [
"protected",
"function",
"endsWithDynamic",
"(",
"$",
"function",
",",
"$",
"needle",
")",
"{",
"$",
"enc",
"=",
"$",
"this",
"->",
"getEncoding",
"(",
")",
";",
"$",
"strlen",
"=",
"$",
"this",
"->",
"length",
"(",
"$",
"enc",
")",
";",
"$",
"test... | Helper function for endsWith
@param string $function
@param string $needle
@return boolean | [
"Helper",
"function",
"for",
"endsWith"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L403-L414 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.match | public function match($regex)
{
$match = array();
if($this->isValidRegex($regex) && preg_match($regex, $this->toString(), $match)===1)
{
return new ObjectArray($match);
}
return null;
} | php | public function match($regex)
{
$match = array();
if($this->isValidRegex($regex) && preg_match($regex, $this->toString(), $match)===1)
{
return new ObjectArray($match);
}
return null;
} | [
"public",
"function",
"match",
"(",
"$",
"regex",
")",
"{",
"$",
"match",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isValidRegex",
"(",
"$",
"regex",
")",
"&&",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"this",
"->",
"toString",
... | Match value against regex
@param string $regex
@return \PerrysLambda\ObjectArray | [
"Match",
"value",
"against",
"regex"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L461-L469 | train |
perryflynn/PerrysLambda | src/PerrysLambda/StringProperty.php | StringProperty.matchAll | public function matchAll($regex)
{
$matches = array();
$result = preg_match_all($regex, $this->toString(), $matches, PREG_SET_ORDER);
if($this->isValidRegex($regex) && $result!==false && $result>0)
{
return ArrayList::asObjectArray($matches);
}
return null... | php | public function matchAll($regex)
{
$matches = array();
$result = preg_match_all($regex, $this->toString(), $matches, PREG_SET_ORDER);
if($this->isValidRegex($regex) && $result!==false && $result>0)
{
return ArrayList::asObjectArray($matches);
}
return null... | [
"public",
"function",
"matchAll",
"(",
"$",
"regex",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"matches",
",",
"PREG_SET_ORD... | Get all matches by regex
@param string $regex
@return \PerrysLambda\ArrayList | [
"Get",
"all",
"matches",
"by",
"regex"
] | 9f1734ae4689d73278b887f9354dfd31428e96de | https://github.com/perryflynn/PerrysLambda/blob/9f1734ae4689d73278b887f9354dfd31428e96de/src/PerrysLambda/StringProperty.php#L476-L485 | train |
lasallecms/lasallecms-l5-installedpackages-pkg | src/CreateInstalledPackagesArray.php | CreateInstalledPackagesArray.CreateArray | public function CreateArray() {
$allPackages = $this->allLaSalleSoftwarePackages();
$installedPackages = [];
foreach ($allPackages as $class) {
if ( defined("\\".$class."\\Version::VERSION") ) {
$installedPackages[] = [
'class' => $class... | php | public function CreateArray() {
$allPackages = $this->allLaSalleSoftwarePackages();
$installedPackages = [];
foreach ($allPackages as $class) {
if ( defined("\\".$class."\\Version::VERSION") ) {
$installedPackages[] = [
'class' => $class... | [
"public",
"function",
"CreateArray",
"(",
")",
"{",
"$",
"allPackages",
"=",
"$",
"this",
"->",
"allLaSalleSoftwarePackages",
"(",
")",
";",
"$",
"installedPackages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"allPackages",
"as",
"$",
"class",
")",
"{",
"... | What LaSalle Software packages are installed?
@return array | [
"What",
"LaSalle",
"Software",
"packages",
"are",
"installed?"
] | 165fb63ab424fd716aaa43057ee6efc6d8929755 | https://github.com/lasallecms/lasallecms-l5-installedpackages-pkg/blob/165fb63ab424fd716aaa43057ee6efc6d8929755/src/CreateInstalledPackagesArray.php#L45-L64 | train |
itcreator/custom-cmf | Module/View/src/Cmf/View/Helper/Style.php | Style.addStyle | public function addStyle($href, $path = null)
{
$key = $this->calculateKey($href, $path);
$this->styles[$key] = 1;
return $this;
} | php | public function addStyle($href, $path = null)
{
$key = $this->calculateKey($href, $path);
$this->styles[$key] = 1;
return $this;
} | [
"public",
"function",
"addStyle",
"(",
"$",
"href",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"calculateKey",
"(",
"$",
"href",
",",
"$",
"path",
")",
";",
"$",
"this",
"->",
"styles",
"[",
"$",
"key",
"]",
"=... | this method add css file
@param string $href
@param string $path
@return Style | [
"this",
"method",
"add",
"css",
"file"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/View/src/Cmf/View/Helper/Style.php#L35-L41 | train |
itcreator/custom-cmf | Module/View/src/Cmf/View/Helper/Style.php | Style.deleteStyle | public function deleteStyle($href, $path = null)
{
$key = $this->calculateKey($href, $path);
if (isset($this->styles[$key])) {
unset($this->styles[$key]);
}
return $this;
} | php | public function deleteStyle($href, $path = null)
{
$key = $this->calculateKey($href, $path);
if (isset($this->styles[$key])) {
unset($this->styles[$key]);
}
return $this;
} | [
"public",
"function",
"deleteStyle",
"(",
"$",
"href",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"calculateKey",
"(",
"$",
"href",
",",
"$",
"path",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"styles"... | This method remove css file from list
@param string $href
@param string $path
@return Style | [
"This",
"method",
"remove",
"css",
"file",
"from",
"list"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/View/src/Cmf/View/Helper/Style.php#L50-L58 | train |
itcreator/custom-cmf | Module/View/src/Cmf/View/Helper/Style.php | Style.buildCode | public function buildCode()
{
$res = '';
foreach ($this->styles as $href => $val) {
$res .= '<link href="' . $href . '" rel="stylesheet" type="text/css" />' . "\r\n";
}
return $res;
} | php | public function buildCode()
{
$res = '';
foreach ($this->styles as $href => $val) {
$res .= '<link href="' . $href . '" rel="stylesheet" type="text/css" />' . "\r\n";
}
return $res;
} | [
"public",
"function",
"buildCode",
"(",
")",
"{",
"$",
"res",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"styles",
"as",
"$",
"href",
"=>",
"$",
"val",
")",
"{",
"$",
"res",
".=",
"'<link href=\"'",
".",
"$",
"href",
".",
"'\" rel=\"styleshee... | This method generate code for include css files
@return string | [
"This",
"method",
"generate",
"code",
"for",
"include",
"css",
"files"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/View/src/Cmf/View/Helper/Style.php#L77-L85 | train |
bseddon/XPath20 | Value/QNameValue.php | QNameValue.fromQName | public static function fromQName( $qn )
{
$qname = new QNameValue();
$qname->LocalName = $qn->localName;
$qname->Prefix = $qn->prefix;
$qname->NamespaceUri = $qn->namespaceURI;
if ( strlen( $qn->localName ) == 0 ||
! preg_match( "/^" . NameValue::$ncName . "$/u", $qn->localName ) ||
( strle... | php | public static function fromQName( $qn )
{
$qname = new QNameValue();
$qname->LocalName = $qn->localName;
$qname->Prefix = $qn->prefix;
$qname->NamespaceUri = $qn->namespaceURI;
if ( strlen( $qn->localName ) == 0 ||
! preg_match( "/^" . NameValue::$ncName . "$/u", $qn->localName ) ||
( strle... | [
"public",
"static",
"function",
"fromQName",
"(",
"$",
"qn",
")",
"{",
"$",
"qname",
"=",
"new",
"QNameValue",
"(",
")",
";",
"$",
"qname",
"->",
"LocalName",
"=",
"$",
"qn",
"->",
"localName",
";",
"$",
"qname",
"->",
"Prefix",
"=",
"$",
"qn",
"->... | Create a QNameValue from a QName
@param QName $qn | [
"Create",
"a",
"QNameValue",
"from",
"a",
"QName"
] | 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Value/QNameValue.php#L216-L232 | train |
bseddon/XPath20 | Value/QNameValue.php | QNameValue.fromXPathNavigator | public static function fromXPathNavigator( $node )
{
return QNameValue::fromQName( new \lyquidity\xml\qname( $node->getPrefix(), $node->getNamespaceURI(), $node->getLocalName() ) );
} | php | public static function fromXPathNavigator( $node )
{
return QNameValue::fromQName( new \lyquidity\xml\qname( $node->getPrefix(), $node->getNamespaceURI(), $node->getLocalName() ) );
} | [
"public",
"static",
"function",
"fromXPathNavigator",
"(",
"$",
"node",
")",
"{",
"return",
"QNameValue",
"::",
"fromQName",
"(",
"new",
"\\",
"lyquidity",
"\\",
"xml",
"\\",
"qname",
"(",
"$",
"node",
"->",
"getPrefix",
"(",
")",
",",
"$",
"node",
"->",... | Create a QNameValue instance fron an XPathNavigator instance
@param XPathNavigator $node
@return QNameValue | [
"Create",
"a",
"QNameValue",
"instance",
"fron",
"an",
"XPathNavigator",
"instance"
] | 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Value/QNameValue.php#L239-L242 | train |
pluf/discount | src/Discount/Engine.php | Discount_Engine.isValid | public function isValid($discount, $request)
{
$code = $this->validate($discount, $request);
if ($code == Discount_Engine::VALIDATION_CODE_VALID)
return true;
return false;
} | php | public function isValid($discount, $request)
{
$code = $this->validate($discount, $request);
if ($code == Discount_Engine::VALIDATION_CODE_VALID)
return true;
return false;
} | [
"public",
"function",
"isValid",
"(",
"$",
"discount",
",",
"$",
"request",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"validate",
"(",
"$",
"discount",
",",
"$",
"request",
")",
";",
"if",
"(",
"$",
"code",
"==",
"Discount_Engine",
"::",
"VALIDA... | Check if give discount is valid or not.
@param Discount_Discount $discount
@param Pluf_HTTP_Request $request | [
"Check",
"if",
"give",
"discount",
"is",
"valid",
"or",
"not",
"."
] | b0006d6b25dd61241f51b5b098d7d546b470de26 | https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Engine.php#L109-L115 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.buildUrl | private function buildUrl($mode, $params = [])
{
$urlParams = array_merge(['mode' => $mode, 'apikey' => $this->apiKey, 'output' => 'json'], $params);
return 'http://' . $this->url . ':' . $this->port . "/api?" . http_build_query($urlParams);
} | php | private function buildUrl($mode, $params = [])
{
$urlParams = array_merge(['mode' => $mode, 'apikey' => $this->apiKey, 'output' => 'json'], $params);
return 'http://' . $this->url . ':' . $this->port . "/api?" . http_build_query($urlParams);
} | [
"private",
"function",
"buildUrl",
"(",
"$",
"mode",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"urlParams",
"=",
"array_merge",
"(",
"[",
"'mode'",
"=>",
"$",
"mode",
",",
"'apikey'",
"=>",
"$",
"this",
"->",
"apiKey",
",",
"'output'",
"=>",
... | Url builder helper
@param String $mode
@param array $params
@return string | [
"Url",
"builder",
"helper"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L52-L56 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.queue | public function queue($start = 0, $limit = 100)
{
$url = $this->buildUrl('queue', [
'start' => $start,
'limit' => $limit
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['queue'];
} | php | public function queue($start = 0, $limit = 100)
{
$url = $this->buildUrl('queue', [
'start' => $start,
'limit' => $limit
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['queue'];
} | [
"public",
"function",
"queue",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"limit",
"=",
"100",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'queue'",
",",
"[",
"'start'",
"=>",
"$",
"start",
",",
"'limit'",
"=>",
"$",
"limit",
"]",... | Returns all items currently in the queue and some additional information
@param int $start
@param int $limit
@return array | [
"Returns",
"all",
"items",
"currently",
"in",
"the",
"queue",
"and",
"some",
"additional",
"information"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L66-L75 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.history | public function history($category = '', $start = 0, $limit = 100, $failedOnly = false)
{
$url = $this->buildUrl('history', [
'start' => $start,
'limit' => $limit,
'failed_only' => $failedOnly,
'category' => $category
]);
$request... | php | public function history($category = '', $start = 0, $limit = 100, $failedOnly = false)
{
$url = $this->buildUrl('history', [
'start' => $start,
'limit' => $limit,
'failed_only' => $failedOnly,
'category' => $category
]);
$request... | [
"public",
"function",
"history",
"(",
"$",
"category",
"=",
"''",
",",
"$",
"start",
"=",
"0",
",",
"$",
"limit",
"=",
"100",
",",
"$",
"failedOnly",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'history'",
",",
"... | Returns all items in the history and some additional information
@param string $category
@param int $start
@param int $limit
@param bool $failedOnly
@return array | [
"Returns",
"all",
"items",
"in",
"the",
"history",
"and",
"some",
"additional",
"information"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L87-L98 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.deleteQueueEntries | public function deleteQueueEntries($entries)
{
$url = $this->buildUrl('queue', [
'name' => 'delete',
'value' => implode(',', $entries)
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | php | public function deleteQueueEntries($entries)
{
$url = $this->buildUrl('queue', [
'name' => 'delete',
'value' => implode(',', $entries)
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | [
"public",
"function",
"deleteQueueEntries",
"(",
"$",
"entries",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'queue'",
",",
"[",
"'name'",
"=>",
"'delete'",
",",
"'value'",
"=>",
"implode",
"(",
"','",
",",
"$",
"entries",
")",
"]",... | Deletes multiple entries with the given ids from the queue
@param array $entries
@return boolean | [
"Deletes",
"multiple",
"entries",
"with",
"the",
"given",
"ids",
"from",
"the",
"queue"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L181-L190 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.switchQueueEntries | public function switchQueueEntries($first, $second)
{
$url = $this->buildUrl('switch', [
'value' => $first,
'value2' => $second
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['result'];
} | php | public function switchQueueEntries($first, $second)
{
$url = $this->buildUrl('switch', [
'value' => $first,
'value2' => $second
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['result'];
} | [
"public",
"function",
"switchQueueEntries",
"(",
"$",
"first",
",",
"$",
"second",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'switch'",
",",
"[",
"'value'",
"=>",
"$",
"first",
",",
"'value2'",
"=>",
"$",
"second",
"]",
")",
";"... | Switches two entries in the queue
@param string $first
@param string $second
@return boolean | [
"Switches",
"two",
"entries",
"in",
"the",
"queue"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L216-L225 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.pauseQueue | public function pauseQueue()
{
$url = $this->buildUrl('set_pause');
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | php | public function pauseQueue()
{
$url = $this->buildUrl('set_pause');
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | [
"public",
"function",
"pauseQueue",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'set_pause'",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
")",
";",
"return",
"... | Pauses the whole queue
@return boolean | [
"Pauses",
"the",
"whole",
"queue"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L232-L238 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.pauseQueueTemporary | public function pauseQueueTemporary($time)
{
$url = $this->buildUrl('config', [
'name' => 'set_pause',
'value' => $time
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | php | public function pauseQueueTemporary($time)
{
$url = $this->buildUrl('config', [
'name' => 'set_pause',
'value' => $time
]);
$request = $this->guzzle->request('GET', $url);
return json_decode($request->getBody(), true)['status'];
} | [
"public",
"function",
"pauseQueueTemporary",
"(",
"$",
"time",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"'config'",
",",
"[",
"'name'",
"=>",
"'set_pause'",
",",
"'value'",
"=>",
"$",
"time",
"]",
")",
";",
"$",
"request",
"=",
... | Pauses the queue temporarely for the given amount of time.
$time is the number of minutes the queue ist paused
@param integer $time
@return boolean | [
"Pauses",
"the",
"queue",
"temporarely",
"for",
"the",
"given",
"amount",
"of",
"time",
"."
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L249-L259 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.addUrl | public function addUrl($url, $niceName = null, $priority = -100, $category = '', $postProcessing = 3, $script = '')
{
$params = [
'name' => $url,
'priority' => $priority,
'category' => $category,
'pp' => $postProcessing,
'script' => $sc... | php | public function addUrl($url, $niceName = null, $priority = -100, $category = '', $postProcessing = 3, $script = '')
{
$params = [
'name' => $url,
'priority' => $priority,
'category' => $category,
'pp' => $postProcessing,
'script' => $sc... | [
"public",
"function",
"addUrl",
"(",
"$",
"url",
",",
"$",
"niceName",
"=",
"null",
",",
"$",
"priority",
"=",
"-",
"100",
",",
"$",
"category",
"=",
"''",
",",
"$",
"postProcessing",
"=",
"3",
",",
"$",
"script",
"=",
"''",
")",
"{",
"$",
"param... | Adds a file to the queue via the given link to the file
@param string $url
@param string|null $niceName
@param int $priority
@param string $category
@param int $postProcessing
@param string $script
@return array | [
"Adds",
"a",
"file",
"to",
"the",
"queue",
"via",
"the",
"given",
"link",
"to",
"the",
"file"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L286-L303 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.deleteHistoryEntries | public function deleteHistoryEntries($ids, $withFiles = true)
{
$params = [
'name' => 'delete',
'del_files' => $withFiles,
'value' => implode(',', $ids)
];
$url = $this->buildUrl('history', $params);
$request = $this->guzzle->request('GET... | php | public function deleteHistoryEntries($ids, $withFiles = true)
{
$params = [
'name' => 'delete',
'del_files' => $withFiles,
'value' => implode(',', $ids)
];
$url = $this->buildUrl('history', $params);
$request = $this->guzzle->request('GET... | [
"public",
"function",
"deleteHistoryEntries",
"(",
"$",
"ids",
",",
"$",
"withFiles",
"=",
"true",
")",
"{",
"$",
"params",
"=",
"[",
"'name'",
"=>",
"'delete'",
",",
"'del_files'",
"=>",
"$",
"withFiles",
",",
"'value'",
"=>",
"implode",
"(",
"','",
","... | Deletes the history entry with the given id
@param string $ids
@param bool $withFiles
@return array | [
"Deletes",
"the",
"history",
"entry",
"with",
"the",
"given",
"id"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L383-L395 | train |
effem/sabnzbd-api | Sabnzbd.php | Sabnzbd.deleteAllHistoryEntries | public function deleteAllHistoryEntries($withFiles = true)
{
$params = [
'name' => 'delete',
'del_files' => $withFiles,
'value' => 'all'
];
$url = $this->buildUrl('history', $params);
$request = $this->guzzle->request('GET', $url);
... | php | public function deleteAllHistoryEntries($withFiles = true)
{
$params = [
'name' => 'delete',
'del_files' => $withFiles,
'value' => 'all'
];
$url = $this->buildUrl('history', $params);
$request = $this->guzzle->request('GET', $url);
... | [
"public",
"function",
"deleteAllHistoryEntries",
"(",
"$",
"withFiles",
"=",
"true",
")",
"{",
"$",
"params",
"=",
"[",
"'name'",
"=>",
"'delete'",
",",
"'del_files'",
"=>",
"$",
"withFiles",
",",
"'value'",
"=>",
"'all'",
"]",
";",
"$",
"url",
"=",
"$",... | Deletes all history entries
@param bool $withFiles
@return array | [
"Deletes",
"all",
"history",
"entries"
] | fb173bd6a755f0fe88df23dd20af27e8ebde9f21 | https://github.com/effem/sabnzbd-api/blob/fb173bd6a755f0fe88df23dd20af27e8ebde9f21/Sabnzbd.php#L404-L416 | train |
ARCANESOFT/Blog | src/Models/Presenters/PostPresenter.php | PostPresenter.getLocaleNativeAttribute | public function getLocaleNativeAttribute()
{
$locale = $this->getAttributeFromArray('locale');
try {
return localization()
->getSupportedLocales()
->get($locale)
->native();
}
catch (\Exception $e) {
return strt... | php | public function getLocaleNativeAttribute()
{
$locale = $this->getAttributeFromArray('locale');
try {
return localization()
->getSupportedLocales()
->get($locale)
->native();
}
catch (\Exception $e) {
return strt... | [
"public",
"function",
"getLocaleNativeAttribute",
"(",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getAttributeFromArray",
"(",
"'locale'",
")",
";",
"try",
"{",
"return",
"localization",
"(",
")",
"->",
"getSupportedLocales",
"(",
")",
"->",
"get",
"(... | Get the locale's native name.
@return string | [
"Get",
"the",
"locale",
"s",
"native",
"name",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Models/Presenters/PostPresenter.php#L29-L42 | train |
t3v/t3v_datamapper | Classes/Service/ExtensionService.php | ExtensionService.runningInStrictMode | public function runningInStrictMode(): bool {
$strictMode = true;
$settings = $this->getSettings();
if (is_array($settings) && !empty($settings)) {
$mode = $settings['mode'];
if ($mode != self::STRICT_MODE) {
$strictMode = false;
}
}
return $strictMode;
} | php | public function runningInStrictMode(): bool {
$strictMode = true;
$settings = $this->getSettings();
if (is_array($settings) && !empty($settings)) {
$mode = $settings['mode'];
if ($mode != self::STRICT_MODE) {
$strictMode = false;
}
}
return $strictMode;
} | [
"public",
"function",
"runningInStrictMode",
"(",
")",
":",
"bool",
"{",
"$",
"strictMode",
"=",
"true",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"settings",
")",
"&&",
"!",
"empty",
... | Checks if T3v DataMapper is running in `strict` mode.
@return bool If T3v DataMapper is running in `strict` mode | [
"Checks",
"if",
"T3v",
"DataMapper",
"is",
"running",
"in",
"strict",
"mode",
"."
] | bab2de90f467936fbe4270cd133cb4109d1108eb | https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Service/ExtensionService.php#L25-L38 | train |
t3v/t3v_datamapper | Classes/Service/ExtensionService.php | ExtensionService.runningInFallbackMode | public function runningInFallbackMode(): bool {
$fallbackMode = false;
$settings = $this->getSettings();
if (is_array($settings) && !empty($settings)) {
$mode = $settings['mode'];
if ($mode === self::FALLBACK_MODE) {
$fallbackMode = true;
}
}
return $fallbackMode;
... | php | public function runningInFallbackMode(): bool {
$fallbackMode = false;
$settings = $this->getSettings();
if (is_array($settings) && !empty($settings)) {
$mode = $settings['mode'];
if ($mode === self::FALLBACK_MODE) {
$fallbackMode = true;
}
}
return $fallbackMode;
... | [
"public",
"function",
"runningInFallbackMode",
"(",
")",
":",
"bool",
"{",
"$",
"fallbackMode",
"=",
"false",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"settings",
")",
"&&",
"!",
"empt... | Checks if T3v DataMapper is running in `fallback` mode.
@return bool If T3v DataMapper is running in `fallback` mode | [
"Checks",
"if",
"T3v",
"DataMapper",
"is",
"running",
"in",
"fallback",
"mode",
"."
] | bab2de90f467936fbe4270cd133cb4109d1108eb | https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Service/ExtensionService.php#L45-L58 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.__initInputValidate | protected function __initInputValidate( array &$data )
{
// $data must be a array
if( !is_array( $data ) ) {
throw \Exception( "Entity\Base expects a array for it's first argument" );
}
// check to see if any keys exist in $this->data that don't in $data
switch(... | php | protected function __initInputValidate( array &$data )
{
// $data must be a array
if( !is_array( $data ) ) {
throw \Exception( "Entity\Base expects a array for it's first argument" );
}
// check to see if any keys exist in $this->data that don't in $data
switch(... | [
"protected",
"function",
"__initInputValidate",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"// $data must be a array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"\\",
"Exception",
"(",
"\"Entity\\Base expects a array for it's first argumen... | Constructor input validation.
External to the constructor so that the constructor may itself be overloaded more easily.
Does base input validation for the constructor.
Checks, that $data is a array.
Performs input validation as per the entity constructs in static::$inputValidate
@return bool Success | [
"Constructor",
"input",
"validation",
".",
"External",
"to",
"the",
"constructor",
"so",
"that",
"the",
"constructor",
"may",
"itself",
"be",
"overloaded",
"more",
"easily",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L217-L251 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.copy | public function copy( $deep = false )
{
$data = $this->data;
foreach( static::$keyProperties as $key ) {
$data[$key] = null;
}
foreach( $data as $key => $value ) {
if( is_object( $value ) and !( $value instanceof self ) ) {
$data[$key] = clone... | php | public function copy( $deep = false )
{
$data = $this->data;
foreach( static::$keyProperties as $key ) {
$data[$key] = null;
}
foreach( $data as $key => $value ) {
if( is_object( $value ) and !( $value instanceof self ) ) {
$data[$key] = clone... | [
"public",
"function",
"copy",
"(",
"$",
"deep",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"static",
"::",
"$",
"keyProperties",
"as",
"$",
"key",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
... | Make a shallow copy of a object clearing it's key fields
@param bool # TODO. Pete/ This should probably be Bond\Schema property
@return Base | [
"Make",
"a",
"shallow",
"copy",
"of",
"a",
"object",
"clearing",
"it",
"s",
"key",
"fields"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L258-L284 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.markDeleted | public function markDeleted()
{
try {
if( $repository = $this->r() ) {
$repository->detach( $this );
}
} catch ( EntityMissingEntityManagerException $e ) {
}
$this->checksum = null;
return $this;
} | php | public function markDeleted()
{
try {
if( $repository = $this->r() ) {
$repository->detach( $this );
}
} catch ( EntityMissingEntityManagerException $e ) {
}
$this->checksum = null;
return $this;
} | [
"public",
"function",
"markDeleted",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"repository",
"=",
"$",
"this",
"->",
"r",
"(",
")",
")",
"{",
"$",
"repository",
"->",
"detach",
"(",
"$",
"this",
")",
";",
"}",
"}",
"catch",
"(",
"EntityMissingEnti... | Mark a entity as deleted
@return void | [
"Mark",
"a",
"entity",
"as",
"deleted"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L411-L421 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.markPersisted | public function markPersisted()
{
try {
if( $repository = $this->r() ) {
$repository->isNew( $this, false );
}
} catch ( EntityMissingEntityManagerException $e ) {
}
$this->checksumReset();
$this->clearDataInitialStore();
return... | php | public function markPersisted()
{
try {
if( $repository = $this->r() ) {
$repository->isNew( $this, false );
}
} catch ( EntityMissingEntityManagerException $e ) {
}
$this->checksumReset();
$this->clearDataInitialStore();
return... | [
"public",
"function",
"markPersisted",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"repository",
"=",
"$",
"this",
"->",
"r",
"(",
")",
")",
"{",
"$",
"repository",
"->",
"isNew",
"(",
"$",
"this",
",",
"false",
")",
";",
"}",
"}",
"catch",
"(",
... | Mark a entity as persisted
@return void | [
"Mark",
"a",
"entity",
"as",
"persisted"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L427-L438 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.uidGet | public function uidGet()
{
// got uid
if( isset( $this->uid ) ) {
return $this->uid->key;
// got key
} elseif( $key = $this->keyGet( $this ) ) {
return $key;
}
$this->uid = new Uid( $this );
return $this->uid->key;
} | php | public function uidGet()
{
// got uid
if( isset( $this->uid ) ) {
return $this->uid->key;
// got key
} elseif( $key = $this->keyGet( $this ) ) {
return $key;
}
$this->uid = new Uid( $this );
return $this->uid->key;
} | [
"public",
"function",
"uidGet",
"(",
")",
"{",
"// got uid",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uid",
")",
")",
"{",
"return",
"$",
"this",
"->",
"uid",
"->",
"key",
";",
"// got key",
"}",
"elseif",
"(",
"$",
"key",
"=",
"$",
"this",
"... | Get a uid for a object. This uid has the following properties.
1. Two different objects won't share the same uid simultaneously
2. In normal script usage a object's uid won't change in the script lifecycle.
To fiddle this you'd need to diddling hard with setDirect and the only thing that should be doing that is the re... | [
"Get",
"a",
"uid",
"for",
"a",
"object",
".",
"This",
"uid",
"has",
"the",
"following",
"properties",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L501-L519 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.readOnlySafetyCheck | protected function readOnlySafetyCheck()
{
switch( static::$isReadOnly ) {
case self::FULL_ACCESS:
return false;
case self::READONLY_DISABLE:
return true;
case self::READONLY_EXCEPTION:
throw new ReadonlyException( "Entity... | php | protected function readOnlySafetyCheck()
{
switch( static::$isReadOnly ) {
case self::FULL_ACCESS:
return false;
case self::READONLY_DISABLE:
return true;
case self::READONLY_EXCEPTION:
throw new ReadonlyException( "Entity... | [
"protected",
"function",
"readOnlySafetyCheck",
"(",
")",
"{",
"switch",
"(",
"static",
"::",
"$",
"isReadOnly",
")",
"{",
"case",
"self",
"::",
"FULL_ACCESS",
":",
"return",
"false",
";",
"case",
"self",
"::",
"READONLY_DISABLE",
":",
"return",
"true",
";",... | Is this object readonly?
@return int|booly | [
"Is",
"this",
"object",
"readonly?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L652-L674 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.initalPropertySet | public function initalPropertySet( $key, $value)
{
// Is this one of our initialProperties
// Is it different. Should we store it?
if( is_array( $this->dataInitial ) and $repository = $this->r() and in_array( $key, $repository->initialProperties ) ) {
$initialValue = $this->get... | php | public function initalPropertySet( $key, $value)
{
// Is this one of our initialProperties
// Is it different. Should we store it?
if( is_array( $this->dataInitial ) and $repository = $this->r() and in_array( $key, $repository->initialProperties ) ) {
$initialValue = $this->get... | [
"public",
"function",
"initalPropertySet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// Is this one of our initialProperties",
"// Is it different. Should we store it?",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"dataInitial",
")",
"and",
"$",
"repository",
... | InitialPropertiesSet helper method | [
"InitialPropertiesSet",
"helper",
"method"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L769-L788 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.keyGet | public static function keyGet( $data )
{
// Is a Entity object ?
$class = get_called_class();
if( $data instanceof $class ) {
$keys = array();
foreach( static::$keyProperties as $property ) {
$value = $data->get($property);
// resol... | php | public static function keyGet( $data )
{
// Is a Entity object ?
$class = get_called_class();
if( $data instanceof $class ) {
$keys = array();
foreach( static::$keyProperties as $property ) {
$value = $data->get($property);
// resol... | [
"public",
"static",
"function",
"keyGet",
"(",
"$",
"data",
")",
"{",
"// Is a Entity object ?",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"$",
"data",
"instanceof",
"$",
"class",
")",
"{",
"$",
"keys",
"=",
"array",
"(",
")",
";... | Key entity `key`
@param array|Entity\Base $data
@return array | [
"Key",
"entity",
"key"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L929-L973 | train |
squareproton/Bond | src/Bond/Entity/Base.php | Base.canValidateProperty | public function canValidateProperty( $key )
{
return isset( $this->data[$key] ) and is_object( $this->data[$key] ) and $this->data[$key] instanceof Base;
} | php | public function canValidateProperty( $key )
{
return isset( $this->data[$key] ) and is_object( $this->data[$key] ) and $this->data[$key] instanceof Base;
} | [
"public",
"function",
"canValidateProperty",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
"and",
"is_object",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
"and",
"$",
"this",... | Has validation property? | [
"Has",
"validation",
"property?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Base.php#L993-L996 | train |
jenskooij/cloudcontrol | src/search/CharacterFilter.php | CharacterFilter.filterSpecialCharacters | private function filterSpecialCharacters($string)
{
$string = str_replace('<', ' <',
$string); // This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething
$string = strip_tags($string);
$string = trim($string);
$string = iconv('... | php | private function filterSpecialCharacters($string)
{
$string = str_replace('<', ' <',
$string); // This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething
$string = strip_tags($string);
$string = trim($string);
$string = iconv('... | [
"private",
"function",
"filterSpecialCharacters",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"'<'",
",",
"' <'",
",",
"$",
"string",
")",
";",
"// This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething... | Filter out all special characters, like punctuation and characters with accents
@param $string
@return mixed|string | [
"Filter",
"out",
"all",
"special",
"characters",
"like",
"punctuation",
"and",
"characters",
"with",
"accents"
] | 76e5d9ac8f9c50d06d39a995d13cc03742536548 | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/search/CharacterFilter.php#L48-L63 | train |
zfegg/zfegg-admin | src/V1/Rest/UserRoles/UserRolesResource.php | UserRolesResource.fetchAll | public function fetchAll($params = [])
{
return $this->table->select(
function (Select $select) {
$select->columns([]);
$select->join(
$this->roleTableName,
sprintf('%s.role_id=%s.role_id', $this->roleTableName, $this->table... | php | public function fetchAll($params = [])
{
return $this->table->select(
function (Select $select) {
$select->columns([]);
$select->join(
$this->roleTableName,
sprintf('%s.role_id=%s.role_id', $this->roleTableName, $this->table... | [
"public",
"function",
"fetchAll",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"table",
"->",
"select",
"(",
"function",
"(",
"Select",
"$",
"select",
")",
"{",
"$",
"select",
"->",
"columns",
"(",
"[",
"]",
")",
";",
... | Fetch all or a subset of resources
@param array $params
@return \Zend\Db\ResultSet\ResultSet | [
"Fetch",
"all",
"or",
"a",
"subset",
"of",
"resources"
] | 4e8363eac54f090f84cf511be351f0cc46902b63 | https://github.com/zfegg/zfegg-admin/blob/4e8363eac54f090f84cf511be351f0cc46902b63/src/V1/Rest/UserRoles/UserRolesResource.php#L45-L60 | train |
rollerworks/search-core | Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php | MoneyToLocalizedStringTransformer.addCurrencySymbol | private function addCurrencySymbol(string $value, ?string $currency = null): string
{
$currency = $currency ?? $this->defaultCurrency;
$locale = \Locale::getDefault();
if (!isset(self::$patterns[$locale])) {
self::$patterns[$locale] = [];
}
if (!isset(self::$pat... | php | private function addCurrencySymbol(string $value, ?string $currency = null): string
{
$currency = $currency ?? $this->defaultCurrency;
$locale = \Locale::getDefault();
if (!isset(self::$patterns[$locale])) {
self::$patterns[$locale] = [];
}
if (!isset(self::$pat... | [
"private",
"function",
"addCurrencySymbol",
"(",
"string",
"$",
"value",
",",
"?",
"string",
"$",
"currency",
"=",
"null",
")",
":",
"string",
"{",
"$",
"currency",
"=",
"$",
"currency",
"??",
"$",
"this",
"->",
"defaultCurrency",
";",
"$",
"locale",
"="... | Adds the currency symbol when missing.
ICU cannot parse() without a currency,
and decimal doesn't include scale when 0. | [
"Adds",
"the",
"currency",
"symbol",
"when",
"missing",
"."
] | 6b5671b8c4d6298906ded768261b0a59845140fb | https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php#L149-L182 | train |
rollerworks/search-core | Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php | MoneyToLocalizedStringTransformer.removeCurrencySymbol | private function removeCurrencySymbol(string $value, string $currency): string
{
$locale = \Locale::getDefault();
if (!isset(self::$patterns[$locale][$currency])) {
// Initialize the cache, ignore return.
$this->addCurrencySymbol('123', $currency);
}
return ... | php | private function removeCurrencySymbol(string $value, string $currency): string
{
$locale = \Locale::getDefault();
if (!isset(self::$patterns[$locale][$currency])) {
// Initialize the cache, ignore return.
$this->addCurrencySymbol('123', $currency);
}
return ... | [
"private",
"function",
"removeCurrencySymbol",
"(",
"string",
"$",
"value",
",",
"string",
"$",
"currency",
")",
":",
"string",
"{",
"$",
"locale",
"=",
"\\",
"Locale",
"::",
"getDefault",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",... | Removes the currency symbol.
ICU cannot format() with currency, as this
produces a number with the `¤` symbol.
And, decimal doesn't include scale when 0. | [
"Removes",
"the",
"currency",
"symbol",
"."
] | 6b5671b8c4d6298906ded768261b0a59845140fb | https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php#L191-L201 | train |
judus/minimal-database | src/QueryBuilder.php | QueryBuilder.getFirst | public function getFirst($sql = null)
{
if ($sql) {
$this->setLastQuery($sql);
try {
$result = $this->db->query($sql);
} catch (\PDOException $e) {
throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
... | php | public function getFirst($sql = null)
{
if ($sql) {
$this->setLastQuery($sql);
try {
$result = $this->db->query($sql);
} catch (\PDOException $e) {
throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
... | [
"public",
"function",
"getFirst",
"(",
"$",
"sql",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"sql",
")",
"{",
"$",
"this",
"->",
"setLastQuery",
"(",
"$",
"sql",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"("... | Return the first the matching row
@param null $sql Optional query string
@return array|null
@throws DatabaseException | [
"Return",
"the",
"first",
"the",
"matching",
"row"
] | e6f8cb46eab41c3f1b6cabe0da5ccd0926727279 | https://github.com/judus/minimal-database/blob/e6f8cb46eab41c3f1b6cabe0da5ccd0926727279/src/QueryBuilder.php#L740-L761 | train |
judus/minimal-database | src/QueryBuilder.php | QueryBuilder.getById | public function getById($id)
{
$sql = "SELECT * FROM " . $this->getTable() . " WHERE " . $this->getPrimaryKey() . " = " . intval($id) . ";";
try {
$result = $this->db->query($sql);
} catch (\PDOException $e) {
throw new DatabaseException($e->getMessage() . '<br>' . $... | php | public function getById($id)
{
$sql = "SELECT * FROM " . $this->getTable() . " WHERE " . $this->getPrimaryKey() . " = " . intval($id) . ";";
try {
$result = $this->db->query($sql);
} catch (\PDOException $e) {
throw new DatabaseException($e->getMessage() . '<br>' . $... | [
"public",
"function",
"getById",
"(",
"$",
"id",
")",
"{",
"$",
"sql",
"=",
"\"SELECT * FROM \"",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"\" WHERE \"",
".",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
".",
"\" = \"",
".",
"intval",
"(",
... | Select a row by id from this table
@param $id
@return array|null
@throws DatabaseException | [
"Select",
"a",
"row",
"by",
"id",
"from",
"this",
"table"
] | e6f8cb46eab41c3f1b6cabe0da5ccd0926727279 | https://github.com/judus/minimal-database/blob/e6f8cb46eab41c3f1b6cabe0da5ccd0926727279/src/QueryBuilder.php#L771-L782 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.setConnectionInfo | public function setConnectionInfo(array $connections)
{
foreach($connections as $connectionInfo)
{
if (empty($connectionInfo['hostname']))
$connectionInfo['hostname'] = 'localhost';
if (empty($connectionInfo['port']))
$connectionInfo['port'] ... | php | public function setConnectionInfo(array $connections)
{
foreach($connections as $connectionInfo)
{
if (empty($connectionInfo['hostname']))
$connectionInfo['hostname'] = 'localhost';
if (empty($connectionInfo['port']))
$connectionInfo['port'] ... | [
"public",
"function",
"setConnectionInfo",
"(",
"array",
"$",
"connections",
")",
"{",
"foreach",
"(",
"$",
"connections",
"as",
"$",
"connectionInfo",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"connectionInfo",
"[",
"'hostname'",
"]",
")",
")",
"$",
"connec... | Validates required values are present for a database connection.
@param array $connectionInfo Connection info. See {@link __construct(...)} for details on keys and values.
@return void
@throws Exception If the required parameters aren't passed | [
"Validates",
"required",
"values",
"are",
"present",
"for",
"a",
"database",
"connection",
"."
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L68-L94 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.getConnection | public function getConnection()
{
if (empty($this->connection)) {
if (empty($this->connectionConfig) || !is_array($this->connectionConfig))
throw new DatabaseException("Connection config is empty or not an array.");
$connCount = count($this->connectionConfig);
... | php | public function getConnection()
{
if (empty($this->connection)) {
if (empty($this->connectionConfig) || !is_array($this->connectionConfig))
throw new DatabaseException("Connection config is empty or not an array.");
$connCount = count($this->connectionConfig);
... | [
"public",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"connectionConfig",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"connec... | Gets the current PDO connection object
@return PDO MySQL PDO Connection | [
"Gets",
"the",
"current",
"PDO",
"connection",
"object"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L101-L167 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.readField | public function readField($sql)
{
$result = $this->read($sql);
$result->setFetchMode(PDO::FETCH_COLUMN, 0);
$row = $result->fetch();
//$this->convertDatesInRows($result, $row);
unset($result);
return $row;
} | php | public function readField($sql)
{
$result = $this->read($sql);
$result->setFetchMode(PDO::FETCH_COLUMN, 0);
$row = $result->fetch();
//$this->convertDatesInRows($result, $row);
unset($result);
return $row;
} | [
"public",
"function",
"readField",
"(",
"$",
"sql",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"sql",
")",
";",
"$",
"result",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_COLUMN",
",",
"0",
")",
";",
"$",
"row",
"=",
"$... | Returns the first column of the first row of the result set
NOTE: It is expected that all DATETIME or TIMESTAMP or other native
date column types should automatically be converted to StorageDate.
@param string $sql SELECT statement
@return string|StorageDate | [
"Returns",
"the",
"first",
"column",
"of",
"the",
"first",
"row",
"of",
"the",
"result",
"set"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L309-L317 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.readCol | public function readCol($sql)
{
$result = $this->read($sql);
$row = $result->fetchAll(PDO::FETCH_COLUMN, 0);
//$this->convertDatesInRows($result, $row);
unset($result);
return $row;
} | php | public function readCol($sql)
{
$result = $this->read($sql);
$row = $result->fetchAll(PDO::FETCH_COLUMN, 0);
//$this->convertDatesInRows($result, $row);
unset($result);
return $row;
} | [
"public",
"function",
"readCol",
"(",
"$",
"sql",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"sql",
")",
";",
"$",
"row",
"=",
"$",
"result",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_COLUMN",
",",
"0",
")",
";",
"//$this... | Returns an array of values for the first column of the result set
<code>
$result = $this->readCol('SELECT col FROM table');
...
array(
0 => 'value1',
1 => 'value2',
2 => 'value3'
)
</code>
@param string $sql SELECT statement
@return array Single dimension array of values for the column | [
"Returns",
"an",
"array",
"of",
"values",
"for",
"the",
"first",
"column",
"of",
"the",
"result",
"set"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L338-L345 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.readOne | public function readOne($sql)
{
$result = $this->readAll($sql, false);
if (count($result) > 0) {
return $result[0];
}
} | php | public function readOne($sql)
{
$result = $this->readAll($sql, false);
if (count($result) > 0) {
return $result[0];
}
} | [
"public",
"function",
"readOne",
"(",
"$",
"sql",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"readAll",
"(",
"$",
"sql",
",",
"false",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
">",
"0",
")",
"{",
"return",
"$",
"result",
"["... | Returns the first row of the result set as an associative array, regardless
of the overall number of rows
<code>
$result = $this->readOne('SELECT col1, col2 FROM table');
...
array(
'col1' => 'value of col1',
'col2' => 'value of col2'
)
</code>
@param string $sql SELECT statement
@return array Single dimension ar... | [
"Returns",
"the",
"first",
"row",
"of",
"the",
"result",
"set",
"as",
"an",
"associative",
"array",
"regardless",
"of",
"the",
"overall",
"number",
"of",
"rows"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L368-L374 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.readAll | public function readAll($sql, $calcFoundRows = false)
{
$result = $this->read($calcFoundRows ? $this->insertPagingFlag($sql) : $sql);
$rows = $result->fetchAll(PDO::FETCH_ASSOC);
//$this->convertDatesInRows($result, $rows);
unset($result);
unset($sql);
return $rows;
... | php | public function readAll($sql, $calcFoundRows = false)
{
$result = $this->read($calcFoundRows ? $this->insertPagingFlag($sql) : $sql);
$rows = $result->fetchAll(PDO::FETCH_ASSOC);
//$this->convertDatesInRows($result, $rows);
unset($result);
unset($sql);
return $rows;
... | [
"public",
"function",
"readAll",
"(",
"$",
"sql",
",",
"$",
"calcFoundRows",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"calcFoundRows",
"?",
"$",
"this",
"->",
"insertPagingFlag",
"(",
"$",
"sql",
")",
":",
"$",... | Returns an associative array of rows and columns
<code>
$result = $this->readAll('SELECT id, col1 FROM table');
...
array(
0 => array( 'id' => '1', 'col1' => 'value'),
1 => array( 'id' => '2', 'col1' => 'value'),
...
)
</code>
@param string $sql SELECT statement
@param boolean $calcFoundRows Flag to indi... | [
"Returns",
"an",
"associative",
"array",
"of",
"rows",
"and",
"columns"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L399-L407 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.bulkInsertRecords | public function bulkInsertRecords($tablename, $parameters, $limit = 25)
{
if(empty($parameters))
throw new DatabaseException('bulkInsertRecords: no parameters.');
$count = 0;
$tcount = 0;
$totalcount = count($parameters);
foreach ($parameters as $value)... | php | public function bulkInsertRecords($tablename, $parameters, $limit = 25)
{
if(empty($parameters))
throw new DatabaseException('bulkInsertRecords: no parameters.');
$count = 0;
$tcount = 0;
$totalcount = count($parameters);
foreach ($parameters as $value)... | [
"public",
"function",
"bulkInsertRecords",
"(",
"$",
"tablename",
",",
"$",
"parameters",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parameters",
")",
")",
"throw",
"new",
"DatabaseException",
"(",
"'bulkInsertRecords: no parameters... | Inserts multiple records utilizing less INSERT statements.
This function will execute as many statements as necessary to insert
all the data supplied by the array {@link $parameters} inserting {@link $limit}
records per statement. {@link $limit} is useful for preventing max
query size errors.
@param string $tablenam... | [
"Inserts",
"multiple",
"records",
"utilizing",
"less",
"INSERT",
"statements",
"."
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L518-L549 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.insertRecord | public function insertRecord($tablename, $parameters, $ignore = false)
{
if (empty($parameters))
throw new DatabaseException('insertRecord: no parameters.');
$insert_fields = array();
$insert_values = array();
foreach ($parameters as $name => $value) {
$inse... | php | public function insertRecord($tablename, $parameters, $ignore = false)
{
if (empty($parameters))
throw new DatabaseException('insertRecord: no parameters.');
$insert_fields = array();
$insert_values = array();
foreach ($parameters as $name => $value) {
$inse... | [
"public",
"function",
"insertRecord",
"(",
"$",
"tablename",
",",
"$",
"parameters",
",",
"$",
"ignore",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parameters",
")",
")",
"throw",
"new",
"DatabaseException",
"(",
"'insertRecord: no parameters.'",
... | Provides a convenience method for inserting an single row of columns
and values into a database table
@param string $tablename Table to insert record
@param array $parameters Associative array of columns and values, ex.
<code>
array(
'col1' => 'value of col1',
'col2' => 'value of col2'
)
</code>
@param boolean $ig... | [
"Provides",
"a",
"convenience",
"method",
"for",
"inserting",
"an",
"single",
"row",
"of",
"columns",
"and",
"values",
"into",
"a",
"database",
"table"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L568-L587 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.updateRecord | public function updateRecord($tablename, $parameters, $where)
{
$update = array();
foreach ($parameters as $name => $value) {
$update[] = "$name = " . $this->quote($value) . "";
}
$sql = "UPDATE ". $tablename ." SET ". implode(",", $update) . " WHERE " . $where;
... | php | public function updateRecord($tablename, $parameters, $where)
{
$update = array();
foreach ($parameters as $name => $value) {
$update[] = "$name = " . $this->quote($value) . "";
}
$sql = "UPDATE ". $tablename ." SET ". implode(",", $update) . " WHERE " . $where;
... | [
"public",
"function",
"updateRecord",
"(",
"$",
"tablename",
",",
"$",
"parameters",
",",
"$",
"where",
")",
"{",
"$",
"update",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"... | Provides convenience method for updating columns on a table for 1 or
many records matching a WHERE clause
@param string $tablename Table to update
@param array $parameters Associative array of columns and values, ex.
<code>
array(
'col1' => 'value of col1',
'col2' => 'value of col2'
)
</code>
@param string $where ... | [
"Provides",
"convenience",
"method",
"for",
"updating",
"columns",
"on",
"a",
"table",
"for",
"1",
"or",
"many",
"records",
"matching",
"a",
"WHERE",
"clause"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L607-L618 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.deleteRecord | public function deleteRecord($tablename, $where)
{
if (!empty($tablename) && !empty($where)) {
$sql = "DELETE FROM ".$tablename." WHERE ".$where;
return $this->write($sql, DatabaseInterface::AFFECTED_ROWS);
}
} | php | public function deleteRecord($tablename, $where)
{
if (!empty($tablename) && !empty($where)) {
$sql = "DELETE FROM ".$tablename." WHERE ".$where;
return $this->write($sql, DatabaseInterface::AFFECTED_ROWS);
}
} | [
"public",
"function",
"deleteRecord",
"(",
"$",
"tablename",
",",
"$",
"where",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tablename",
")",
"&&",
"!",
"empty",
"(",
"$",
"where",
")",
")",
"{",
"$",
"sql",
"=",
"\"DELETE FROM \"",
".",
"$",
"tab... | Provides convenience method for deleting records matching a WHERE clause
@param string $tablename Table to delete from
@param string $where Where clause used to find the records to delete,
ex. "id = '2'", "title LIKE '%example%' AND status = '2'"
@return int Number of affected rows
@throws DatabaseException if ta... | [
"Provides",
"convenience",
"method",
"for",
"deleting",
"records",
"matching",
"a",
"WHERE",
"clause"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L630-L636 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.quote | public function quote($var)
{
if(is_null($var) || strtoupper($var) == 'NULL')
return 'NULL';
if ($var instanceof Date)
$var = $this->DateFactory->toStorageDate($var)->toMySQLDate();
return $this->getConnection()->quote($var);
} | php | public function quote($var)
{
if(is_null($var) || strtoupper($var) == 'NULL')
return 'NULL';
if ($var instanceof Date)
$var = $this->DateFactory->toStorageDate($var)->toMySQLDate();
return $this->getConnection()->quote($var);
} | [
"public",
"function",
"quote",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"var",
")",
"||",
"strtoupper",
"(",
"$",
"var",
")",
"==",
"'NULL'",
")",
"return",
"'NULL'",
";",
"if",
"(",
"$",
"var",
"instanceof",
"Date",
")",
"$",
"... | Returns escaped value automatically wrapped in single quotes
NOTE: Will convert Date types into strings for database entry
@param mixed $var Value to escape and quote
@return string Escaped and quoted string value ready for a SQL statement | [
"Returns",
"escaped",
"value",
"automatically",
"wrapped",
"in",
"single",
"quotes"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L647-L656 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.read | public function read($sql)
{
$sql = (string)$sql;
$conn = $this->getConnection();
$this->Benchmark->start('sql-query');
try {
// if(!substr($sql, 0, 4) == 'SHOW') {
//
// $explain = $conn->query("EXPLAIN ".$sql);
//
// $explainresults = $ex... | php | public function read($sql)
{
$sql = (string)$sql;
$conn = $this->getConnection();
$this->Benchmark->start('sql-query');
try {
// if(!substr($sql, 0, 4) == 'SHOW') {
//
// $explain = $conn->query("EXPLAIN ".$sql);
//
// $explainresults = $ex... | [
"public",
"function",
"read",
"(",
"$",
"sql",
")",
"{",
"$",
"sql",
"=",
"(",
"string",
")",
"$",
"sql",
";",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"this",
"->",
"Benchmark",
"->",
"start",
"(",
"'sql-query'",
... | Runs the SQL query in read-only mode from the database
@param string $sql The SQL query to run
@return PDOStatement The query result
@see http://us.php.net/manual/en/pdo.query.php | [
"Runs",
"the",
"SQL",
"query",
"in",
"read",
"-",
"only",
"mode",
"from",
"the",
"database"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L722-L807 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase.import | public function import($filename)
{
// TODO: Wrap this in a transaction!
if (!file_exists($filename)) {
throw new Exception("File not found: $filename");
}
$sql_queries = file_get_contents($filename);
$sql_queries = $this->_removeRemarks($sql_queries);
$s... | php | public function import($filename)
{
// TODO: Wrap this in a transaction!
if (!file_exists($filename)) {
throw new Exception("File not found: $filename");
}
$sql_queries = file_get_contents($filename);
$sql_queries = $this->_removeRemarks($sql_queries);
$s... | [
"public",
"function",
"import",
"(",
"$",
"filename",
")",
"{",
"// TODO: Wrap this in a transaction!",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"File not found: $filename\"",
")",
";",
"}",
"$",
"... | Imports and runs sql contained in the specified file.
The file must contain only valid sql.
@param string $filename The filename to load
@return void | [
"Imports",
"and",
"runs",
"sql",
"contained",
"in",
"the",
"specified",
"file",
".",
"The",
"file",
"must",
"contain",
"only",
"valid",
"sql",
"."
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L867-L884 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/database/MySQLDatabase.php | MySQLDatabase._removeRemarks | private function _removeRemarks($sql)
{
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^[-].*$/m', "\n", $sql));
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
return $sql;
} | php | private function _removeRemarks($sql)
{
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^[-].*$/m', "\n", $sql));
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
return $sql;
} | [
"private",
"function",
"_removeRemarks",
"(",
"$",
"sql",
")",
"{",
"$",
"sql",
"=",
"preg_replace",
"(",
"'/\\n{2,}/'",
",",
"\"\\n\"",
",",
"preg_replace",
"(",
"'/^[-].*$/m'",
",",
"\"\\n\"",
",",
"$",
"sql",
")",
")",
";",
"$",
"sql",
"=",
"preg_repl... | remove_remarks will strip the sql comment lines out of an uploaded sql file
@param string $sql The sql to process
@return string the SQL with the remarks removed | [
"remove_remarks",
"will",
"strip",
"the",
"sql",
"comment",
"lines",
"out",
"of",
"an",
"uploaded",
"sql",
"file"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/MySQLDatabase.php#L893-L898 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.identifyEntity | public function identifyEntity(ModelInterface $model, &$entity, $identifier)
{
$primaryKeys = $model->primaryFields();
if (count($primaryKeys) !== 1) {
return;
}
$field = reset($primaryKeys)->name();
$this->setPropertyValue($entity, $field, $identifier);
} | php | public function identifyEntity(ModelInterface $model, &$entity, $identifier)
{
$primaryKeys = $model->primaryFields();
if (count($primaryKeys) !== 1) {
return;
}
$field = reset($primaryKeys)->name();
$this->setPropertyValue($entity, $field, $identifier);
} | [
"public",
"function",
"identifyEntity",
"(",
"ModelInterface",
"$",
"model",
",",
"&",
"$",
"entity",
",",
"$",
"identifier",
")",
"{",
"$",
"primaryKeys",
"=",
"$",
"model",
"->",
"primaryFields",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"primaryKey... | Assigns passed identifier to primary key
Possible only when entity has one primary key
@param ModelInterface $model
@param mixed $entity
@param int|string $identifier
@return void | [
"Assigns",
"passed",
"identifier",
"to",
"primary",
"key",
"Possible",
"only",
"when",
"entity",
"has",
"one",
"primary",
"key"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L36-L46 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.getPropertyValue | public function getPropertyValue($entity, $field, $default = null)
{
$this->assertEntity($entity);
if (is_array($entity) || $entity instanceof \ArrayAccess) {
return isset($entity[$field]) ? $entity[$field] : $default;
}
$ref = $this->getReflection($entity);
if ... | php | public function getPropertyValue($entity, $field, $default = null)
{
$this->assertEntity($entity);
if (is_array($entity) || $entity instanceof \ArrayAccess) {
return isset($entity[$field]) ? $entity[$field] : $default;
}
$ref = $this->getReflection($entity);
if ... | [
"public",
"function",
"getPropertyValue",
"(",
"$",
"entity",
",",
"$",
"field",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"assertEntity",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"entity",
")",
"||",
"$",
... | Returns property value
@param array|object $entity
@param string $field
@param mixed $default
@return mixed
@throws AccessorException | [
"Returns",
"property",
"value"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L58-L72 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.setPropertyValue | public function setPropertyValue(&$entity, $field, $value)
{
$this->assertEntity($entity);
if (is_array($entity) || $entity instanceof \ArrayAccess) {
$entity[$field] = $value;
return;
}
$ref = $this->getReflection($entity);
if (!$ref->hasProperty($... | php | public function setPropertyValue(&$entity, $field, $value)
{
$this->assertEntity($entity);
if (is_array($entity) || $entity instanceof \ArrayAccess) {
$entity[$field] = $value;
return;
}
$ref = $this->getReflection($entity);
if (!$ref->hasProperty($... | [
"public",
"function",
"setPropertyValue",
"(",
"&",
"$",
"entity",
",",
"$",
"field",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertEntity",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"entity",
")",
"||",
"$",
"entity",
... | Sets property value
@param array|object $entity
@param string $field
@param mixed $value
@throws AccessorException | [
"Sets",
"property",
"value"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L83-L101 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.getReflection | private function getReflection($object)
{
$key = get_class($object);
if (!array_key_exists($key, $this->buffer)) {
$this->buffer[$key] = new \ReflectionClass($object);
}
return $this->buffer[$key];
} | php | private function getReflection($object)
{
$key = get_class($object);
if (!array_key_exists($key, $this->buffer)) {
$this->buffer[$key] = new \ReflectionClass($object);
}
return $this->buffer[$key];
} | [
"private",
"function",
"getReflection",
"(",
"$",
"object",
")",
"{",
"$",
"key",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"buffer",
")",
")",
"{",
"$",
"this",
"->... | Returns object reflection instance
@param object $object
@return \ReflectionClass | [
"Returns",
"object",
"reflection",
"instance"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L124-L133 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.getProperty | private function getProperty(\ReflectionClass $ref, $property)
{
$prop = $ref->getProperty($property);
$prop->setAccessible(true);
return $prop;
} | php | private function getProperty(\ReflectionClass $ref, $property)
{
$prop = $ref->getProperty($property);
$prop->setAccessible(true);
return $prop;
} | [
"private",
"function",
"getProperty",
"(",
"\\",
"ReflectionClass",
"$",
"ref",
",",
"$",
"property",
")",
"{",
"$",
"prop",
"=",
"$",
"ref",
"->",
"getProperty",
"(",
"$",
"property",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";"... | Returns object property instance
@param \ReflectionClass $ref
@param string $property
@return \ReflectionProperty | [
"Returns",
"object",
"property",
"instance"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L143-L149 | train |
mossphp/moss-storage | Moss/Storage/Query/Accessor/Accessor.php | Accessor.addPropertyValue | public function addPropertyValue(&$entity, $field, $value)
{
$container = $this->getPropertyValue($entity, $field, $entity);
if (!is_array($container)) {
$container = empty($container) ? [] : [$container];
}
$container[] = $value;
$this->setPropertyValue($entity... | php | public function addPropertyValue(&$entity, $field, $value)
{
$container = $this->getPropertyValue($entity, $field, $entity);
if (!is_array($container)) {
$container = empty($container) ? [] : [$container];
}
$container[] = $value;
$this->setPropertyValue($entity... | [
"public",
"function",
"addPropertyValue",
"(",
"&",
"$",
"entity",
",",
"$",
"field",
",",
"$",
"value",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getPropertyValue",
"(",
"$",
"entity",
",",
"$",
"field",
",",
"$",
"entity",
")",
";",
"if"... | Adds value to array property
If property is not an array - will be converted into one preserving existing value as first element
@param mixed $entity
@param string $field
@param mixed $value
@throws AccessorException | [
"Adds",
"value",
"to",
"array",
"property",
"If",
"property",
"is",
"not",
"an",
"array",
"-",
"will",
"be",
"converted",
"into",
"one",
"preserving",
"existing",
"value",
"as",
"first",
"element"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Accessor/Accessor.php#L161-L171 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getTableAlias | public function getTableAlias($table_name = null)
{
if (!$table_name) {
$table_name = $this->getTableName();
}
$bits = explode("_", $table_name);
$alias = '';
foreach ($bits as $bit) {
$alias .= strtolower(substr($bit, 0, 1));
}
return ... | php | public function getTableAlias($table_name = null)
{
if (!$table_name) {
$table_name = $this->getTableName();
}
$bits = explode("_", $table_name);
$alias = '';
foreach ($bits as $bit) {
$alias .= strtolower(substr($bit, 0, 1));
}
return ... | [
"public",
"function",
"getTableAlias",
"(",
"$",
"table_name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"table_name",
")",
"{",
"$",
"table_name",
"=",
"$",
"this",
"->",
"getTableName",
"(",
")",
";",
"}",
"$",
"bits",
"=",
"explode",
"(",
"\"_\"... | Get the short alias name of a table.
@param string $table_name Optional table name
@return string Table alias | [
"Get",
"the",
"short",
"alias",
"name",
"of",
"a",
"table",
"."
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L97-L108 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getTablePrimaryKey | public function getTablePrimaryKey()
{
trigger_error('getTablePrimaryKey() is deprecated. Use getIDField() instead.', E_USER_DEPRECATED);
$keys = $this->getPrimaryKeyIndex();
return isset($keys[0])?$keys[0]:false;
} | php | public function getTablePrimaryKey()
{
trigger_error('getTablePrimaryKey() is deprecated. Use getIDField() instead.', E_USER_DEPRECATED);
$keys = $this->getPrimaryKeyIndex();
return isset($keys[0])?$keys[0]:false;
} | [
"public",
"function",
"getTablePrimaryKey",
"(",
")",
"{",
"trigger_error",
"(",
"'getTablePrimaryKey() is deprecated. Use getIDField() instead.'",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"getPrimaryKeyIndex",
"(",
")",
";",
"return",
... | Get table primary key column name
@deprecated
@return string|false | [
"Get",
"table",
"primary",
"key",
"column",
"name"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L126-L132 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getPrimaryKeyIndex | public function getPrimaryKeyIndex()
{
$database = DatabaseLayer::getInstance();
$columns = array();
if ($this instanceof VersionedActiveRecord) {
$schema = $this->getClassSchema();
$firstColumn = reset($schema)['name'];
$columns = [$firstColumn => $firs... | php | public function getPrimaryKeyIndex()
{
$database = DatabaseLayer::getInstance();
$columns = array();
if ($this instanceof VersionedActiveRecord) {
$schema = $this->getClassSchema();
$firstColumn = reset($schema)['name'];
$columns = [$firstColumn => $firs... | [
"public",
"function",
"getPrimaryKeyIndex",
"(",
")",
"{",
"$",
"database",
"=",
"DatabaseLayer",
"::",
"getInstance",
"(",
")",
";",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"instanceof",
"VersionedActiveRecord",
")",
"{",
"$",... | Get a unique key to use as an index
@return string[] | [
"Get",
"a",
"unique",
"key",
"to",
"use",
"as",
"an",
"index"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L139-L156 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getId | public function getId()
{
$col = $this->getIDField();
if (property_exists($this, $col)) {
$id = $this->$col;
if ($id > 0) {
return $id;
}
}
return false;
} | php | public function getId()
{
$col = $this->getIDField();
if (property_exists($this, $col)) {
$id = $this->$col;
if ($id > 0) {
return $id;
}
}
return false;
} | [
"public",
"function",
"getId",
"(",
")",
"{",
"$",
"col",
"=",
"$",
"this",
"->",
"getIDField",
"(",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"col",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"$",
"col",
";",
... | Get object ID
@return integer | [
"Get",
"object",
"ID"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L162-L173 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getLabel | public function getLabel()
{
if (property_exists($this, '_label_column')) {
if (property_exists($this, $this->_label_column)) {
$label_column = $this->_label_column;
return $this->$label_column;
}
}
if (property_exists($this, 'name')) {... | php | public function getLabel()
{
if (property_exists($this, '_label_column')) {
if (property_exists($this, $this->_label_column)) {
$label_column = $this->_label_column;
return $this->$label_column;
}
}
if (property_exists($this, 'name')) {... | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'_label_column'",
")",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_label_column",
")",
")",
"{",
"$",
"label_... | Get a label for the object. Perhaps a Name or Description field.
@return string | [
"Get",
"a",
"label",
"for",
"the",
"object",
".",
"Perhaps",
"a",
"Name",
"or",
"Description",
"field",
"."
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L179-L194 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.__calculateSaveDownRows | public function __calculateSaveDownRows()
{
if (!$this->_columns) {
foreach (get_object_vars($this) as $potential_column => $discard) {
switch ($potential_column) {
case 'table':
case substr($potential_column, 0, 1) == "_":
... | php | public function __calculateSaveDownRows()
{
if (!$this->_columns) {
foreach (get_object_vars($this) as $potential_column => $discard) {
switch ($potential_column) {
case 'table':
case substr($potential_column, 0, 1) == "_":
... | [
"public",
"function",
"__calculateSaveDownRows",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_columns",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"potential_column",
"=>",
"$",
"discard",
")",
"{",
"switch",
"(... | Work out which columns should be saved down. | [
"Work",
"out",
"which",
"columns",
"should",
"be",
"saved",
"down",
"."
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L199-L233 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.save | public function save($automatic_reload = true)
{
// Run Pre-saver.
$this->preSave();
// Run Field Fixer.
$this->__fieldFix();
// Calculate row to save_down
$this->__calculateSaveDownRows();
$primary_key_column = $this->getIDField();
// Make an array... | php | public function save($automatic_reload = true)
{
// Run Pre-saver.
$this->preSave();
// Run Field Fixer.
$this->__fieldFix();
// Calculate row to save_down
$this->__calculateSaveDownRows();
$primary_key_column = $this->getIDField();
// Make an array... | [
"public",
"function",
"save",
"(",
"$",
"automatic_reload",
"=",
"true",
")",
"{",
"// Run Pre-saver.",
"$",
"this",
"->",
"preSave",
"(",
")",
";",
"// Run Field Fixer.",
"$",
"this",
"->",
"__fieldFix",
"(",
")",
";",
"// Calculate row to save_down",
"$",
"t... | Save the selected record.
This will do an INSERT or UPDATE as appropriate
@param boolean $automatic_reload Whether or not to automatically reload
@return ActiveRecord | [
"Save",
"the",
"selected",
"record",
".",
"This",
"will",
"do",
"an",
"INSERT",
"or",
"UPDATE",
"as",
"appropriate"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L283-L349 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.reload | public function reload()
{
$item = $this->getById($this->getId());
if ($item !== false) {
$this->loadFromRow($item);
return $this;
} else {
return false;
}
} | php | public function reload()
{
$item = $this->getById($this->getId());
if ($item !== false) {
$this->loadFromRow($item);
return $this;
} else {
return false;
}
} | [
"public",
"function",
"reload",
"(",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"if",
"(",
"$",
"item",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"loadFromRow",
"(",
"$",
"i... | Reload the selected record
@return ActiveRecord|false | [
"Reload",
"the",
"selected",
"record"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L355-L364 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.delete | public function delete()
{
$database = DatabaseLayer::getInstance();
$delete = $database->delete($this->getTableName(), $this->getTableAlias());
$delete->setModel($this);
$delete->condition($this->getIDField(), $this->getId());
$delete->execute($this->getClass());
/... | php | public function delete()
{
$database = DatabaseLayer::getInstance();
$delete = $database->delete($this->getTableName(), $this->getTableAlias());
$delete->setModel($this);
$delete->condition($this->getIDField(), $this->getId());
$delete->execute($this->getClass());
/... | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"database",
"=",
"DatabaseLayer",
"::",
"getInstance",
"(",
")",
";",
"$",
"delete",
"=",
"$",
"database",
"->",
"delete",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
",",
"$",
"this",
"->",
"... | Delete the selected record
@return boolean | [
"Delete",
"the",
"selected",
"record"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L369-L382 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.getBySlug | public static function getBySlug($slug)
{
$slug_parts = explode("-", $slug, 2);
$class = get_called_class();
$temp_this = new $class();
$primary_key = $temp_this->getIDField();
return self::search()->where($primary_key, $slug_parts[0])->execOne();
} | php | public static function getBySlug($slug)
{
$slug_parts = explode("-", $slug, 2);
$class = get_called_class();
$temp_this = new $class();
$primary_key = $temp_this->getIDField();
return self::search()->where($primary_key, $slug_parts[0])->execOne();
} | [
"public",
"static",
"function",
"getBySlug",
"(",
"$",
"slug",
")",
"{",
"$",
"slug_parts",
"=",
"explode",
"(",
"\"-\"",
",",
"$",
"slug",
",",
"2",
")",
";",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"$",
"temp_this",
"=",
"new",
"$",
... | Pull a database record by the slug we're given.
@param $slug string Slug
@return mixed | [
"Pull",
"a",
"database",
"record",
"by",
"the",
"slug",
"we",
"re",
"given",
"."
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L430-L437 | train |
Thruio/ActiveRecord | src/ActiveRecord.php | ActiveRecord.__fieldFix | public function __fieldFix()
{
$schema = $this->getClassSchema();
foreach ($this->__calculateSaveDownRows() as $column) {
if (!isset($schema[$column]['type'])) {
throw new Exception("No type hinting/docblock found for '{$column}' in '" . get_called_class() . "'.", E_USER_... | php | public function __fieldFix()
{
$schema = $this->getClassSchema();
foreach ($this->__calculateSaveDownRows() as $column) {
if (!isset($schema[$column]['type'])) {
throw new Exception("No type hinting/docblock found for '{$column}' in '" . get_called_class() . "'.", E_USER_... | [
"public",
"function",
"__fieldFix",
"(",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"getClassSchema",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"__calculateSaveDownRows",
"(",
")",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"isset",
... | Fix types of fields to match definition | [
"Fix",
"types",
"of",
"fields",
"to",
"match",
"definition"
] | 90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461 | https://github.com/Thruio/ActiveRecord/blob/90b0f838cd0e0fb7f3b56a0c38632ff08b3c3461/src/ActiveRecord.php#L500-L514 | train |
ingro/Rest | src/Ingruz/Rest/Controllers/RestDingoController.php | RestDingoController.respondNotFound | protected function respondNotFound($message = '')
{
if (empty($message))
{
$message = ucfirst($this->baseClass).' does not exist';
}
return $this->respondWithError($message, 404);
} | php | protected function respondNotFound($message = '')
{
if (empty($message))
{
$message = ucfirst($this->baseClass).' does not exist';
}
return $this->respondWithError($message, 404);
} | [
"protected",
"function",
"respondNotFound",
"(",
"$",
"message",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"baseClass",
")",
".",
"' does not exist'",
";",
"}",
... | Respond with an error in case the resource request is not found
@param string $message
@return Response | [
"Respond",
"with",
"an",
"error",
"in",
"case",
"the",
"resource",
"request",
"is",
"not",
"found"
] | 922bed071b8ea41feb067d97a3e283f944a86cb8 | https://github.com/ingro/Rest/blob/922bed071b8ea41feb067d97a3e283f944a86cb8/src/Ingruz/Rest/Controllers/RestDingoController.php#L165-L173 | train |
phossa/phossa-shared | src/Phossa/Shared/Message/Loader/LanguageLoader.php | LanguageLoader.loadMessages | public function loadMessages(/*# string */ $className)/*# : array */
{
$map = [];
// reflect
if (class_exists($className)) {
$class = new \ReflectionClass($className);
$file = $class->getFileName();
// language file 'Message.php' -> 'Message.zh_CN.php'
... | php | public function loadMessages(/*# string */ $className)/*# : array */
{
$map = [];
// reflect
if (class_exists($className)) {
$class = new \ReflectionClass($className);
$file = $class->getFileName();
// language file 'Message.php' -> 'Message.zh_CN.php'
... | [
"public",
"function",
"loadMessages",
"(",
"/*# string */",
"$",
"className",
")",
"/*# : array */",
"{",
"$",
"map",
"=",
"[",
"]",
";",
"// reflect",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"Refl... | Load language file from the same directory of message class.
language file name is something like 'Message.zh_CN.php'
{@inheritDoc} | [
"Load",
"language",
"file",
"from",
"the",
"same",
"directory",
"of",
"message",
"class",
"."
] | fcf140c09e94c3a441ee4e285de0b4c18cb6504b | https://github.com/phossa/phossa-shared/blob/fcf140c09e94c3a441ee4e285de0b4c18cb6504b/src/Phossa/Shared/Message/Loader/LanguageLoader.php#L85-L104 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Event/PreUpdateEventArgs.php | PreUpdateEventArgs.setNewValue | public function setNewValue($attribute, $value)
{
$this->assertValidAttribute($attribute);
$this->documentChangeSet[$attribute][1] = $value;
$this->getDocumentManager()->getUnitOfWork()->setDocumentChangeSet($this->getDocument(), $this->documentChangeSet);
} | php | public function setNewValue($attribute, $value)
{
$this->assertValidAttribute($attribute);
$this->documentChangeSet[$attribute][1] = $value;
$this->getDocumentManager()->getUnitOfWork()->setDocumentChangeSet($this->getDocument(), $this->documentChangeSet);
} | [
"public",
"function",
"setNewValue",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertValidAttribute",
"(",
"$",
"attribute",
")",
";",
"$",
"this",
"->",
"documentChangeSet",
"[",
"$",
"attribute",
"]",
"[",
"1",
"]",
"=",
... | Sets the new value of this attribute.
@param string $attribute
@param mixed $value | [
"Sets",
"the",
"new",
"value",
"of",
"this",
"attribute",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Event/PreUpdateEventArgs.php#L84-L90 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Event/PreUpdateEventArgs.php | PreUpdateEventArgs.assertValidAttribute | private function assertValidAttribute($attribute)
{
if ( ! isset($this->documentChangeSet[$attribute])) {
throw new \InvalidArgumentException(sprintf(
'Attribute "%s" is not a valid attribute of the document "%s" in PreUpdateEventArgs.',
$attribute,
... | php | private function assertValidAttribute($attribute)
{
if ( ! isset($this->documentChangeSet[$attribute])) {
throw new \InvalidArgumentException(sprintf(
'Attribute "%s" is not a valid attribute of the document "%s" in PreUpdateEventArgs.',
$attribute,
... | [
"private",
"function",
"assertValidAttribute",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"documentChangeSet",
"[",
"$",
"attribute",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",... | Asserts the attribute exists in changeset.
@param string $attribute
@throws \InvalidArgumentException if the attribute has no changeset | [
"Asserts",
"the",
"attribute",
"exists",
"in",
"changeset",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Event/PreUpdateEventArgs.php#L98-L107 | train |
shgysk8zer0/core_api | traits/path_info.php | Path_Info.getPathInfo | final public function getPathInfo($path, $use_include_path = false)
{
if ($use_include_path) {
$path = stream_resolve_include_path($path);
} else {
$path = realpath($path);
}
if (is_string($path)) {
list(
$this->dirname,
$this->basename,
$this->extension,
$this->filename
) = array_... | php | final public function getPathInfo($path, $use_include_path = false)
{
if ($use_include_path) {
$path = stream_resolve_include_path($path);
} else {
$path = realpath($path);
}
if (is_string($path)) {
list(
$this->dirname,
$this->basename,
$this->extension,
$this->filename
) = array_... | [
"final",
"public",
"function",
"getPathInfo",
"(",
"$",
"path",
",",
"$",
"use_include_path",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"use_include_path",
")",
"{",
"$",
"path",
"=",
"stream_resolve_include_path",
"(",
"$",
"path",
")",
";",
"}",
"else",
... | Retrieves information about path components
@param string $path The path to work with
@param bool $use_include_path Whether or not to search inclde_path
@return void | [
"Retrieves",
"information",
"about",
"path",
"components"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/path_info.php#L79-L97 | train |
fxpio/fxp-doctrine-extensions | Filter/Listener/AbstractFilterSubscriber.php | AbstractFilterSubscriber.onEvent | public function onEvent(Event $event): void
{
if (!$event instanceof GetResponseEvent || !$this->injected) {
if (null !== ($filter = $this->getFilter())) {
$this->injectParameters($filter);
}
}
} | php | public function onEvent(Event $event): void
{
if (!$event instanceof GetResponseEvent || !$this->injected) {
if (null !== ($filter = $this->getFilter())) {
$this->injectParameters($filter);
}
}
} | [
"public",
"function",
"onEvent",
"(",
"Event",
"$",
"event",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"GetResponseEvent",
"||",
"!",
"$",
"this",
"->",
"injected",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"filter",
"=",... | Action on the event.
@param Event $event The event | [
"Action",
"on",
"the",
"event",
"."
] | 82942f51d47cdd79a20a5725ee1b3ecfc69e9d77 | https://github.com/fxpio/fxp-doctrine-extensions/blob/82942f51d47cdd79a20a5725ee1b3ecfc69e9d77/Filter/Listener/AbstractFilterSubscriber.php#L65-L72 | train |
fxpio/fxp-doctrine-extensions | Filter/Listener/AbstractFilterSubscriber.php | AbstractFilterSubscriber.getFilter | protected function getFilter()
{
$supports = $this->supports();
$filters = $this->entityManager->getFilters()->getEnabledFilters();
$fFilter = null;
foreach ($filters as $name => $filter) {
if ($filter instanceof $supports) {
$fFilter = $filter;
... | php | protected function getFilter()
{
$supports = $this->supports();
$filters = $this->entityManager->getFilters()->getEnabledFilters();
$fFilter = null;
foreach ($filters as $name => $filter) {
if ($filter instanceof $supports) {
$fFilter = $filter;
... | [
"protected",
"function",
"getFilter",
"(",
")",
"{",
"$",
"supports",
"=",
"$",
"this",
"->",
"supports",
"(",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getFilters",
"(",
")",
"->",
"getEnabledFilters",
"(",
")",
";",
"$... | Get the supported filter.
@return null|SQLFilter | [
"Get",
"the",
"supported",
"filter",
"."
] | 82942f51d47cdd79a20a5725ee1b3ecfc69e9d77 | https://github.com/fxpio/fxp-doctrine-extensions/blob/82942f51d47cdd79a20a5725ee1b3ecfc69e9d77/Filter/Listener/AbstractFilterSubscriber.php#L79-L94 | train |
Bistro/Router | lib/Bistro/Router/Route.php | Route.isMatch | public function isMatch($method, $url)
{
$match = false;
if (\in_array($method, $this->responds_to))
{
\preg_match($this->compile(), $url, $matches);
if ( ! empty($matches))
{
$this->matched_params = \array_merge(
$this->defaults,
$this->method_defaults[$method],
$this->cleanMatches... | php | public function isMatch($method, $url)
{
$match = false;
if (\in_array($method, $this->responds_to))
{
\preg_match($this->compile(), $url, $matches);
if ( ! empty($matches))
{
$this->matched_params = \array_merge(
$this->defaults,
$this->method_defaults[$method],
$this->cleanMatches... | [
"public",
"function",
"isMatch",
"(",
"$",
"method",
",",
"$",
"url",
")",
"{",
"$",
"match",
"=",
"false",
";",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"responds_to",
")",
")",
"{",
"\\",
"preg_match",
"(",
"$",
... | Check to see if this route is a match.
@param string $method The request method
@param string $url The accessed url
@return boolean [description] | [
"Check",
"to",
"see",
"if",
"this",
"route",
"is",
"a",
"match",
"."
] | ab5c3fff119c0e6c43c05300122b236afabfff41 | https://github.com/Bistro/Router/blob/ab5c3fff119c0e6c43c05300122b236afabfff41/lib/Bistro/Router/Route.php#L66-L87 | train |
Bistro/Router | lib/Bistro/Router/Route.php | Route.url | public function url($params = array())
{
if ($this->isStatic())
{
return $this->pattern;
}
$url = $this->pattern;
foreach ($this->getSegments($url) as $segment)
{
$func = $segment['optional'] === true ? 'replaceOptional' : 'replaceRequired';
$url = $this->{$func}($url, $segment['name'], $segment... | php | public function url($params = array())
{
if ($this->isStatic())
{
return $this->pattern;
}
$url = $this->pattern;
foreach ($this->getSegments($url) as $segment)
{
$func = $segment['optional'] === true ? 'replaceOptional' : 'replaceRequired';
$url = $this->{$func}($url, $segment['name'], $segment... | [
"public",
"function",
"url",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isStatic",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pattern",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"pattern",
";... | A reverse routing helper.
@throws \UnexpectedValueException
@param array $params Parameters to set named options to
@return string | [
"A",
"reverse",
"routing",
"helper",
"."
] | ab5c3fff119c0e6c43c05300122b236afabfff41 | https://github.com/Bistro/Router/blob/ab5c3fff119c0e6c43c05300122b236afabfff41/lib/Bistro/Router/Route.php#L145-L161 | train |
Bistro/Router | lib/Bistro/Router/Route.php | Route.compile | protected function compile()
{
if ($this->compiled !== false)
{
return $this->compiled;
}
if ($this->isStatic())
{
$this->compiled = '~^'.$this->pattern.'$~';
return $this->compiled;
}
$compiled = $this->pattern;
foreach ($this->getSegments($compiled) as $segment)
{
$compiled = \str_rep... | php | protected function compile()
{
if ($this->compiled !== false)
{
return $this->compiled;
}
if ($this->isStatic())
{
$this->compiled = '~^'.$this->pattern.'$~';
return $this->compiled;
}
$compiled = $this->pattern;
foreach ($this->getSegments($compiled) as $segment)
{
$compiled = \str_rep... | [
"protected",
"function",
"compile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compiled",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"compiled",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isStatic",
"(",
")",
")",
"{",
"$",
"this",
"... | Compiles the pattern into one suitable for regex.
@return string The regex pattern | [
"Compiles",
"the",
"pattern",
"into",
"one",
"suitable",
"for",
"regex",
"."
] | ab5c3fff119c0e6c43c05300122b236afabfff41 | https://github.com/Bistro/Router/blob/ab5c3fff119c0e6c43c05300122b236afabfff41/lib/Bistro/Router/Route.php#L168-L189 | train |
Bistro/Router | lib/Bistro/Router/Route.php | Route.getSegments | protected function getSegments($pattern)
{
$segments = array();
$parts = \explode("/", ltrim($pattern, "/"));
foreach ($parts as $segment)
{
if (\strpos($segment, ":") !== false)
{
$segments[] = $this->parseSegment($segment);
}
}
return $segments;
} | php | protected function getSegments($pattern)
{
$segments = array();
$parts = \explode("/", ltrim($pattern, "/"));
foreach ($parts as $segment)
{
if (\strpos($segment, ":") !== false)
{
$segments[] = $this->parseSegment($segment);
}
}
return $segments;
} | [
"protected",
"function",
"getSegments",
"(",
"$",
"pattern",
")",
"{",
"$",
"segments",
"=",
"array",
"(",
")",
";",
"$",
"parts",
"=",
"\\",
"explode",
"(",
"\"/\"",
",",
"ltrim",
"(",
"$",
"pattern",
",",
"\"/\"",
")",
")",
";",
"foreach",
"(",
"... | Gets an array of url segments
@param string $pattern The route pattern
@return array An array containing url segments | [
"Gets",
"an",
"array",
"of",
"url",
"segments"
] | ab5c3fff119c0e6c43c05300122b236afabfff41 | https://github.com/Bistro/Router/blob/ab5c3fff119c0e6c43c05300122b236afabfff41/lib/Bistro/Router/Route.php#L197-L211 | train |
Bistro/Router | lib/Bistro/Router/Route.php | Route.parseSegment | protected function parseSegment($segment)
{
$optional = false;
list($regex, $name) = \explode(":", $segment);
if (\substr($name, -1) === "?")
{
$name = \substr($name, 0, -1);
$optional = true;
}
if ($regex === "")
{
$regex = "[^\/]+";
}
$regex = "/(?P<{$name}>{$regex})";
if ($optional... | php | protected function parseSegment($segment)
{
$optional = false;
list($regex, $name) = \explode(":", $segment);
if (\substr($name, -1) === "?")
{
$name = \substr($name, 0, -1);
$optional = true;
}
if ($regex === "")
{
$regex = "[^\/]+";
}
$regex = "/(?P<{$name}>{$regex})";
if ($optional... | [
"protected",
"function",
"parseSegment",
"(",
"$",
"segment",
")",
"{",
"$",
"optional",
"=",
"false",
";",
"list",
"(",
"$",
"regex",
",",
"$",
"name",
")",
"=",
"\\",
"explode",
"(",
"\":\"",
",",
"$",
"segment",
")",
";",
"if",
"(",
"\\",
"subst... | Pulls out relevent information on a given segment.
@param string $segment The segment
@return array ['segment' => (string), name' => (string), 'regex' => (string), 'optional' => (boolean)] | [
"Pulls",
"out",
"relevent",
"information",
"on",
"a",
"given",
"segment",
"."
] | ab5c3fff119c0e6c43c05300122b236afabfff41 | https://github.com/Bistro/Router/blob/ab5c3fff119c0e6c43c05300122b236afabfff41/lib/Bistro/Router/Route.php#L219-L250 | train |
Mandarin-Medien/MMCmfRoutingBundle | Controller/NodeRouteController.php | NodeRouteController.nodeRouteAction | public function nodeRouteAction(NodeRoute $nodeRoute)
{
if($node = $this->get('mm_cmf_routing.node_resolver')->resolve($nodeRoute)) {
if ($nodeRoute instanceof RedirectNodeRoute) {
return $this->redirectAction($nodeRoute);
} else {
if ($nodeRoute->g... | php | public function nodeRouteAction(NodeRoute $nodeRoute)
{
if($node = $this->get('mm_cmf_routing.node_resolver')->resolve($nodeRoute)) {
if ($nodeRoute instanceof RedirectNodeRoute) {
return $this->redirectAction($nodeRoute);
} else {
if ($nodeRoute->g... | [
"public",
"function",
"nodeRouteAction",
"(",
"NodeRoute",
"$",
"nodeRoute",
")",
"{",
"if",
"(",
"$",
"node",
"=",
"$",
"this",
"->",
"get",
"(",
"'mm_cmf_routing.node_resolver'",
")",
"->",
"resolve",
"(",
"$",
"nodeRoute",
")",
")",
"{",
"if",
"(",
"$... | process the the node route call
@param NodeRoute $nodeRoute
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@throws NotFoundHttpException | [
"process",
"the",
"the",
"node",
"route",
"call"
] | 7db1b03f5e120bd473486c0be6ab76c6146cd2d0 | https://github.com/Mandarin-Medien/MMCmfRoutingBundle/blob/7db1b03f5e120bd473486c0be6ab76c6146cd2d0/Controller/NodeRouteController.php#L28-L65 | train |
pdyn/base | Utils.php | Utils.genRandomStr | public static function genRandomStr($l) {
$p = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$s = '';
for ($i = 0; $i < $l; $i++) {
$s .= $p[mt_rand(0, (mb_strlen($p) - 1))];
}
return $s;
} | php | public static function genRandomStr($l) {
$p = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$s = '';
for ($i = 0; $i < $l; $i++) {
$s .= $p[mt_rand(0, (mb_strlen($p) - 1))];
}
return $s;
} | [
"public",
"static",
"function",
"genRandomStr",
"(",
"$",
"l",
")",
"{",
"$",
"p",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"$",
"s",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"l",
";",
... | Generate a random string of letters and numbers of a specific length.
@param int $l The desired length of the string.
@return string The generated string. | [
"Generate",
"a",
"random",
"string",
"of",
"letters",
"and",
"numbers",
"of",
"a",
"specific",
"length",
"."
] | 0b93961693954a6b4e1c6df7e345e5cdf07f26ff | https://github.com/pdyn/base/blob/0b93961693954a6b4e1c6df7e345e5cdf07f26ff/Utils.php#L41-L48 | train |
pdyn/base | Utils.php | Utils.uniqid | public static function uniqid($length = false) {
if ($length <= 13) {
return uniqid();
}
$uniq = strrev(str_replace('.', '', uniqid('', true)));
$uniqlen = mb_strlen($uniq);
if ($length === false || $length === $uniqlen) {
return $uniq;
} elseif ($length < $uniqlen) {
return mb_substr($uniq, 0, $le... | php | public static function uniqid($length = false) {
if ($length <= 13) {
return uniqid();
}
$uniq = strrev(str_replace('.', '', uniqid('', true)));
$uniqlen = mb_strlen($uniq);
if ($length === false || $length === $uniqlen) {
return $uniq;
} elseif ($length < $uniqlen) {
return mb_substr($uniq, 0, $le... | [
"public",
"static",
"function",
"uniqid",
"(",
"$",
"length",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"length",
"<=",
"13",
")",
"{",
"return",
"uniqid",
"(",
")",
";",
"}",
"$",
"uniq",
"=",
"strrev",
"(",
"str_replace",
"(",
"'.'",
",",
"''",
"... | Generate a guaranteed unique value of a specified length.
@param int|bool $length A desired length, or false to use uniqid length.
@return string The unique string. | [
"Generate",
"a",
"guaranteed",
"unique",
"value",
"of",
"a",
"specified",
"length",
"."
] | 0b93961693954a6b4e1c6df7e345e5cdf07f26ff | https://github.com/pdyn/base/blob/0b93961693954a6b4e1c6df7e345e5cdf07f26ff/Utils.php#L55-L68 | train |
Vectrex/vxPHP | src/Autoload/Psr4.php | Psr4.addPrefix | public function addPrefix($prefix, $baseDirs, $prepend = FALSE) {
$baseDirs = (array) $baseDirs;
// normalize the namespace prefix
$prefix = trim($prefix, '\\') . '\\';
// initialize the namespace prefix array if needed
if (! isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = [];
}
... | php | public function addPrefix($prefix, $baseDirs, $prepend = FALSE) {
$baseDirs = (array) $baseDirs;
// normalize the namespace prefix
$prefix = trim($prefix, '\\') . '\\';
// initialize the namespace prefix array if needed
if (! isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = [];
}
... | [
"public",
"function",
"addPrefix",
"(",
"$",
"prefix",
",",
"$",
"baseDirs",
",",
"$",
"prepend",
"=",
"FALSE",
")",
"{",
"$",
"baseDirs",
"=",
"(",
"array",
")",
"$",
"baseDirs",
";",
"// normalize the namespace prefix",
"$",
"prefix",
"=",
"trim",
"(",
... | add a base directory for a namespace prefix
@param string $prefix
@param string|array $baseDirs: one or more base directories for the namespace prefix
@param bool $prepend: if true, prepend base directories to prefix instead of appending them;
this causes them to be searched first rather than last.
@return void | [
"add",
"a",
"base",
"directory",
"for",
"a",
"namespace",
"prefix"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Autoload/Psr4.php#L100-L124 | train |
Vectrex/vxPHP | src/Autoload/Psr4.php | Psr4.setPrefixes | public function setPrefixes(array $prefixes) {
$this->prefixes = [];
foreach ($prefixes as $prefix => $baseDir) {
$this->addPrefix($prefix, $baseDir);
}
} | php | public function setPrefixes(array $prefixes) {
$this->prefixes = [];
foreach ($prefixes as $prefix => $baseDir) {
$this->addPrefix($prefix, $baseDir);
}
} | [
"public",
"function",
"setPrefixes",
"(",
"array",
"$",
"prefixes",
")",
"{",
"$",
"this",
"->",
"prefixes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"prefixes",
"as",
"$",
"prefix",
"=>",
"$",
"baseDir",
")",
"{",
"$",
"this",
"->",
"addPrefix",
"("... | set all namespace prefixes and their base directories; overwrites
existing prefixes
@param array $prefixes: associative array of namespace prefixes and their base directories
@return void | [
"set",
"all",
"namespace",
"prefixes",
"and",
"their",
"base",
"directories",
";",
"overwrites",
"existing",
"prefixes"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Autoload/Psr4.php#L134-L139 | train |
Vectrex/vxPHP | src/Autoload/Psr4.php | Psr4.loadFile | protected function loadFile($prefix, $relativeClass) {
// any base directories for this namespace prefix?
if (!isset($this->prefixes[$prefix])) {
$this->debug[] = $prefix . ': no base dirs';
return FALSE;
}
// search base directories for this namespace prefix
foreach($this->prefixes[$prefix] as $bas... | php | protected function loadFile($prefix, $relativeClass) {
// any base directories for this namespace prefix?
if (!isset($this->prefixes[$prefix])) {
$this->debug[] = $prefix . ': no base dirs';
return FALSE;
}
// search base directories for this namespace prefix
foreach($this->prefixes[$prefix] as $bas... | [
"protected",
"function",
"loadFile",
"(",
"$",
"prefix",
",",
"$",
"relativeClass",
")",
"{",
"// any base directories for this namespace prefix?",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"prefixes",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"$",
"thi... | loads mapped file for a namespace prefix and relative class
@param string $prefix
@param string $relativeClass
@return mixed name of mapped file that was loaded or FALSE if file could not be loaded | [
"loads",
"mapped",
"file",
"for",
"a",
"namespace",
"prefix",
"and",
"relative",
"class"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Autoload/Psr4.php#L278-L316 | train |
Ydle/HubBundle | Controller/NodesController.php | NodesController.nodesFormAction | public function nodesFormAction(Request $request)
{
$node = new Node();
// Manage edition mode
$this->currentNode = $request->get('node');
if ($this->currentNode) {
$node = $this->get("ydle.node.manager")->find($request->get('node'));
}
$action = $this->ge... | php | public function nodesFormAction(Request $request)
{
$node = new Node();
// Manage edition mode
$this->currentNode = $request->get('node');
if ($this->currentNode) {
$node = $this->get("ydle.node.manager")->find($request->get('node'));
}
$action = $this->ge... | [
"public",
"function",
"nodesFormAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"node",
"=",
"new",
"Node",
"(",
")",
";",
"// Manage edition mode",
"$",
"this",
"->",
"currentNode",
"=",
"$",
"request",
"->",
"get",
"(",
"'node'",
")",
";",
"if"... | Display a form to create or edit a node.
@param Request $request | [
"Display",
"a",
"form",
"to",
"create",
"or",
"edit",
"a",
"node",
"."
] | 7fa423241246bcfd115f2ed3ad3997b4b63adb01 | https://github.com/Ydle/HubBundle/blob/7fa423241246bcfd115f2ed3ad3997b4b63adb01/Controller/NodesController.php#L40-L58 | train |
squareproton/Bond | src/Bond/RecordManager/Task.php | Task.setObject | public function setObject( $object, $throwExceptionOnFailure = true )
{
// tasks only work on objects
if( !is_object($object) ) {
throw new BadTaskException("A task must be object");
return false;
}
$error = null;
if( $isCompatible = static::isCompa... | php | public function setObject( $object, $throwExceptionOnFailure = true )
{
// tasks only work on objects
if( !is_object($object) ) {
throw new BadTaskException("A task must be object");
return false;
}
$error = null;
if( $isCompatible = static::isCompa... | [
"public",
"function",
"setObject",
"(",
"$",
"object",
",",
"$",
"throwExceptionOnFailure",
"=",
"true",
")",
"{",
"// tasks only work on objects",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"BadTaskException",
"(",
"\"A ta... | Set a task's object property
@param object $object
@param booly Throw exception if the even we can't set the object
@return Were we able to set this property | [
"Set",
"a",
"task",
"s",
"object",
"property"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager/Task.php#L75-L96 | train |
ezra-obiwale/dSCore | src/Core/AInjector.php | AInjector.getConfigInject | protected function getConfigInject($type) {
switch (strtolower($type)) {
case 'all':
case 'a':
return engineGet('inject', 'all');
case 'controllers':
case 'controller':
case 'c':
return array_merge(engineGet('inject', 'a... | php | protected function getConfigInject($type) {
switch (strtolower($type)) {
case 'all':
case 'a':
return engineGet('inject', 'all');
case 'controllers':
case 'controller':
case 'c':
return array_merge(engineGet('inject', 'a... | [
"protected",
"function",
"getConfigInject",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'all'",
":",
"case",
"'a'",
":",
"return",
"engineGet",
"(",
"'inject'",
",",
"'all'",
")",
";",
"case",
"'co... | Fetches classes to inject from the config file. If given type is not "all",
the required is merged with the "all"
@param string $type all, controllers|controller|c,services|service|s, views|view|v
@return array | [
"Fetches",
"classes",
"to",
"inject",
"from",
"the",
"config",
"file",
".",
"If",
"given",
"type",
"is",
"not",
"all",
"the",
"required",
"is",
"merged",
"with",
"the",
"all"
] | dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d | https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/AInjector.php#L45-L63 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.