id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
229,200 | PrestaShop/decimal | src/Operation/Addition.php | Addition.normalizeCoefficients | private function normalizeCoefficients(DecimalNumber $a, DecimalNumber $b)
{
$exp1 = $a->getExponent();
$exp2 = $b->getExponent();
$coeff1 = $a->getCoefficient();
$coeff2 = $b->getCoefficient();
// add trailing zeroes if needed
if ($exp1 > $exp2) {
$coeff2 = str_pad($coeff2, strlen($coeff2) + $exp1 - $exp2, '0', STR_PAD_RIGHT);
} elseif ($exp1 < $exp2) {
$coeff1 = str_pad($coeff1, strlen($coeff1) + $exp2 - $exp1, '0', STR_PAD_RIGHT);
}
$len1 = strlen($coeff1);
$len2 = strlen($coeff2);
// add leading zeroes if needed
if ($len1 > $len2) {
$coeff2 = str_pad($coeff2, $len1, '0', STR_PAD_LEFT);
} elseif ($len1 < $len2) {
$coeff1 = str_pad($coeff1, $len2, '0', STR_PAD_LEFT);
}
return [$coeff1, $coeff2];
} | php | private function normalizeCoefficients(DecimalNumber $a, DecimalNumber $b)
{
$exp1 = $a->getExponent();
$exp2 = $b->getExponent();
$coeff1 = $a->getCoefficient();
$coeff2 = $b->getCoefficient();
// add trailing zeroes if needed
if ($exp1 > $exp2) {
$coeff2 = str_pad($coeff2, strlen($coeff2) + $exp1 - $exp2, '0', STR_PAD_RIGHT);
} elseif ($exp1 < $exp2) {
$coeff1 = str_pad($coeff1, strlen($coeff1) + $exp2 - $exp1, '0', STR_PAD_RIGHT);
}
$len1 = strlen($coeff1);
$len2 = strlen($coeff2);
// add leading zeroes if needed
if ($len1 > $len2) {
$coeff2 = str_pad($coeff2, $len1, '0', STR_PAD_LEFT);
} elseif ($len1 < $len2) {
$coeff1 = str_pad($coeff1, $len2, '0', STR_PAD_LEFT);
}
return [$coeff1, $coeff2];
} | [
"private",
"function",
"normalizeCoefficients",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"$",
"exp1",
"=",
"$",
"a",
"->",
"getExponent",
"(",
")",
";",
"$",
"exp2",
"=",
"$",
"b",
"->",
"getExponent",
"(",
")",
";",
... | Normalizes coefficients by adding leading or trailing zeroes as needed so that both are the same length
@param DecimalNumber $a
@param DecimalNumber $b
@return array An array containing the normalized coefficients | [
"Normalizes",
"coefficients",
"by",
"adding",
"leading",
"or",
"trailing",
"zeroes",
"as",
"needed",
"so",
"that",
"both",
"are",
"the",
"same",
"length"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Addition.php#L143-L169 |
229,201 | PrestaShop/decimal | src/Operation/Addition.php | Addition.addStrings | private function addStrings($number1, $number2, $fractional = false)
{
// optimization - numbers can be treated as integers as long as they don't overflow the max int size
if ('0' !== $number1[0]
&& '0' !== $number2[0]
&& strlen($number1) <= $this->maxSafeIntStringSize
&& strlen($number2) <= $this->maxSafeIntStringSize
) {
return (string) ((int) $number1 + (int) $number2);
}
// find out which of the strings is longest
$maxLength = max(strlen($number1), strlen($number2));
// add leading or trailing zeroes as needed
$number1 = str_pad($number1, $maxLength, '0', $fractional ? STR_PAD_RIGHT : STR_PAD_LEFT);
$number2 = str_pad($number2, $maxLength, '0', $fractional ? STR_PAD_RIGHT : STR_PAD_LEFT);
$result = '';
$carryOver = 0;
for ($i = $maxLength - 1; 0 <= $i; $i--) {
$sum = $number1[$i] + $number2[$i] + $carryOver;
$result .= $sum % 10;
$carryOver = (int) ($sum >= 10);
}
if ($carryOver > 0) {
$result .= '1';
}
return strrev($result);
} | php | private function addStrings($number1, $number2, $fractional = false)
{
// optimization - numbers can be treated as integers as long as they don't overflow the max int size
if ('0' !== $number1[0]
&& '0' !== $number2[0]
&& strlen($number1) <= $this->maxSafeIntStringSize
&& strlen($number2) <= $this->maxSafeIntStringSize
) {
return (string) ((int) $number1 + (int) $number2);
}
// find out which of the strings is longest
$maxLength = max(strlen($number1), strlen($number2));
// add leading or trailing zeroes as needed
$number1 = str_pad($number1, $maxLength, '0', $fractional ? STR_PAD_RIGHT : STR_PAD_LEFT);
$number2 = str_pad($number2, $maxLength, '0', $fractional ? STR_PAD_RIGHT : STR_PAD_LEFT);
$result = '';
$carryOver = 0;
for ($i = $maxLength - 1; 0 <= $i; $i--) {
$sum = $number1[$i] + $number2[$i] + $carryOver;
$result .= $sum % 10;
$carryOver = (int) ($sum >= 10);
}
if ($carryOver > 0) {
$result .= '1';
}
return strrev($result);
} | [
"private",
"function",
"addStrings",
"(",
"$",
"number1",
",",
"$",
"number2",
",",
"$",
"fractional",
"=",
"false",
")",
"{",
"// optimization - numbers can be treated as integers as long as they don't overflow the max int size",
"if",
"(",
"'0'",
"!==",
"$",
"number1",
... | Adds two integer numbers as strings.
@param string $number1
@param string $number2
@param bool $fractional [default=false]
If true, the numbers will be treated as the fractional part of a number (padded with trailing zeroes).
Otherwise, they will be treated as the integer part (padded with leading zeroes).
@return string | [
"Adds",
"two",
"integer",
"numbers",
"as",
"strings",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Addition.php#L183-L214 |
229,202 | slickframework/slick | src/Slick/Di/Definition/DefinitionManager.php | DefinitionManager.add | public function add(DefinitionInterface $definition)
{
$index = count($this->_names);
$this->_definitionSource[$index] = $definition;
$this->_names[$definition->getName()] = $index;
return $this;
} | php | public function add(DefinitionInterface $definition)
{
$index = count($this->_names);
$this->_definitionSource[$index] = $definition;
$this->_names[$definition->getName()] = $index;
return $this;
} | [
"public",
"function",
"add",
"(",
"DefinitionInterface",
"$",
"definition",
")",
"{",
"$",
"index",
"=",
"count",
"(",
"$",
"this",
"->",
"_names",
")",
";",
"$",
"this",
"->",
"_definitionSource",
"[",
"$",
"index",
"]",
"=",
"$",
"definition",
";",
"... | Adds a definition to the list of definitions
@param DefinitionInterface $definition
@returns DefinitionManager | [
"Adds",
"a",
"definition",
"to",
"the",
"list",
"of",
"definitions"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Definition/DefinitionManager.php#L52-L58 |
229,203 | slickframework/slick | src/Slick/Di/Definition/DefinitionManager.php | DefinitionManager.get | public function get($name)
{
$definition = null;
if ($this->has($name)) {
$definition = $this->_definitionSource[$this->_names[$name]];
}
return $definition;
} | php | public function get($name)
{
$definition = null;
if ($this->has($name)) {
$definition = $this->_definitionSource[$this->_names[$name]];
}
return $definition;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"definition",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"_definitionSource",
"[",
"$",
"this",
... | Returns the definition stored with the provided name
@param string $name
@return null|\Slick\Di\DefinitionInterface | [
"Returns",
"the",
"definition",
"stored",
"with",
"the",
"provided",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Definition/DefinitionManager.php#L79-L86 |
229,204 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard.php | Standard._getTemplate | protected function _getTemplate()
{
if (is_null($this->_template)) {
foreach ($this->_map as $method => $className) {
if ($this->_sql instanceof $className) {
$this->_template = $this->$method();
break;
}
}
}
return $this->_template;
} | php | protected function _getTemplate()
{
if (is_null($this->_template)) {
foreach ($this->_map as $method => $className) {
if ($this->_sql instanceof $className) {
$this->_template = $this->$method();
break;
}
}
}
return $this->_template;
} | [
"protected",
"function",
"_getTemplate",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_template",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_map",
"as",
"$",
"method",
"=>",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"thi... | Creates the template for current SQL Object
@return SqlTemplateInterface | [
"Creates",
"the",
"template",
"for",
"current",
"SQL",
"Object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard.php#L61-L72 |
229,205 | gbv/jskos-php | src/Set.php | Set.contains | public function contains($member): bool
{
return $member instanceof Resource && $member->uri &&
$this->findURI($member->uri) >= 0;
} | php | public function contains($member): bool
{
return $member instanceof Resource && $member->uri &&
$this->findURI($member->uri) >= 0;
} | [
"public",
"function",
"contains",
"(",
"$",
"member",
")",
":",
"bool",
"{",
"return",
"$",
"member",
"instanceof",
"Resource",
"&&",
"$",
"member",
"->",
"uri",
"&&",
"$",
"this",
"->",
"findURI",
"(",
"$",
"member",
"->",
"uri",
")",
">=",
"0",
";"... | Check whether an equal member already exists in this Set. | [
"Check",
"whether",
"an",
"equal",
"member",
"already",
"exists",
"in",
"this",
"Set",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Set.php#L19-L23 |
229,206 | gbv/jskos-php | src/Set.php | Set.findURI | public function findURI(string $uri)
{
foreach ($this->members as $offset => $member) {
if ($member->uri == $uri) {
return $offset;
}
}
return -1;
} | php | public function findURI(string $uri)
{
foreach ($this->members as $offset => $member) {
if ($member->uri == $uri) {
return $offset;
}
}
return -1;
} | [
"public",
"function",
"findURI",
"(",
"string",
"$",
"uri",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"members",
"as",
"$",
"offset",
"=>",
"$",
"member",
")",
"{",
"if",
"(",
"$",
"member",
"->",
"uri",
"==",
"$",
"uri",
")",
"{",
"return",
"... | Return the offset of a member Resource with given URI or -1. | [
"Return",
"the",
"offset",
"of",
"a",
"member",
"Resource",
"with",
"given",
"URI",
"or",
"-",
"1",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Set.php#L28-L36 |
229,207 | gbv/jskos-php | src/Set.php | Set.isValid | public function isValid(): bool
{
$uris = [];
foreach ($this->members as $member) {
$uri = $member->uri;
if ($uri) {
if (isset($uris[$uri])) {
return false;
} else {
$uris[$uri] = true;
}
}
}
return true;
} | php | public function isValid(): bool
{
$uris = [];
foreach ($this->members as $member) {
$uri = $member->uri;
if ($uri) {
if (isset($uris[$uri])) {
return false;
} else {
$uris[$uri] = true;
}
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
")",
":",
"bool",
"{",
"$",
"uris",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"members",
"as",
"$",
"member",
")",
"{",
"$",
"uri",
"=",
"$",
"member",
"->",
"uri",
";",
"if",
"(",
"$",
"uri",
... | Return whether this set does not contain same resources. | [
"Return",
"whether",
"this",
"set",
"does",
"not",
"contain",
"same",
"resources",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Set.php#L41-L55 |
229,208 | slickframework/slick | src/Slick/I18n/Translator.php | Translator.getConfiguration | public function getConfiguration()
{
if (is_null($this->_configuration)) {
$this->_configuration = Configuration::get('config');
}
return $this->_configuration;
} | php | public function getConfiguration()
{
if (is_null($this->_configuration)) {
$this->_configuration = Configuration::get('config');
}
return $this->_configuration;
} | [
"public",
"function",
"getConfiguration",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_configuration",
")",
")",
"{",
"$",
"this",
"->",
"_configuration",
"=",
"Configuration",
"::",
"get",
"(",
"'config'",
")",
";",
"}",
"return",
"$",... | Lazy loads configuration
@return DriverInterface | [
"Lazy",
"loads",
"configuration"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/I18n/Translator.php#L91-L97 |
229,209 | slickframework/slick | src/Slick/I18n/Translator.php | Translator.getTranslatorService | public function getTranslatorService()
{
if (is_null($this->_translatorService)) {
$translator = new ZendTranslator();
$translator->addTranslationFilePattern(
$this->type,
$this->basePath,
'%s/'.$this->getMessageFile(),
$this->domain
);
$this->_translatorService = $translator;
}
return $this->_translatorService;
} | php | public function getTranslatorService()
{
if (is_null($this->_translatorService)) {
$translator = new ZendTranslator();
$translator->addTranslationFilePattern(
$this->type,
$this->basePath,
'%s/'.$this->getMessageFile(),
$this->domain
);
$this->_translatorService = $translator;
}
return $this->_translatorService;
} | [
"public",
"function",
"getTranslatorService",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_translatorService",
")",
")",
"{",
"$",
"translator",
"=",
"new",
"ZendTranslator",
"(",
")",
";",
"$",
"translator",
"->",
"addTranslationFilePattern"... | Lazy loads zend translator
@return ZendTranslator | [
"Lazy",
"loads",
"zend",
"translator"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/I18n/Translator.php#L104-L117 |
229,210 | slickframework/slick | src/Slick/I18n/Translator.php | Translator.getMessageFile | public function getMessageFile()
{
$name = $this->domain;
$name .= $this->_types[$this->type];
return $name;
} | php | public function getMessageFile()
{
$name = $this->domain;
$name .= $this->_types[$this->type];
return $name;
} | [
"public",
"function",
"getMessageFile",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"domain",
";",
"$",
"name",
".=",
"$",
"this",
"->",
"_types",
"[",
"$",
"this",
"->",
"type",
"]",
";",
"return",
"$",
"name",
";",
"}"
] | Returns the messages file name based on domain
@return string | [
"Returns",
"the",
"messages",
"file",
"name",
"based",
"on",
"domain"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/I18n/Translator.php#L124-L129 |
229,211 | slickframework/slick | src/Slick/I18n/Translator.php | Translator.translate | public function translate($message)
{
$locale = $this->configuration
->get('i18n.locale', $this->fallbackLocale);
return $this->getTranslatorService()
->translate($message, $this->domain, $locale);
} | php | public function translate($message)
{
$locale = $this->configuration
->get('i18n.locale', $this->fallbackLocale);
return $this->getTranslatorService()
->translate($message, $this->domain, $locale);
} | [
"public",
"function",
"translate",
"(",
"$",
"message",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"configuration",
"->",
"get",
"(",
"'i18n.locale'",
",",
"$",
"this",
"->",
"fallbackLocale",
")",
";",
"return",
"$",
"this",
"->",
"getTranslatorServ... | Returns the translation for the provided message
@param string $message
@return string | [
"Returns",
"the",
"translation",
"for",
"the",
"provided",
"message"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/I18n/Translator.php#L138-L145 |
229,212 | slickframework/slick | src/Slick/Orm/Entity/AbstractEntity.php | AbstractEntity.getAdapter | public function getAdapter()
{
if (is_null($this->_adapter)) {
$key = "db_{$this->configName}";
$this->setAdapter($this->getContainer()->get($key));
}
return $this->_adapter;
} | php | public function getAdapter()
{
if (is_null($this->_adapter)) {
$key = "db_{$this->configName}";
$this->setAdapter($this->getContainer()->get($key));
}
return $this->_adapter;
} | [
"public",
"function",
"getAdapter",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_adapter",
")",
")",
"{",
"$",
"key",
"=",
"\"db_{$this->configName}\"",
";",
"$",
"this",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"getContainer",
"(",
... | Retrieves the current adapter
@return AdapterInterface | [
"Retrieves",
"the",
"current",
"adapter"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/AbstractEntity.php#L156-L163 |
229,213 | gbv/jskos-php | src/LanguageMap.php | LanguageMap.offsetSet | public function offsetSet($lang, $value)
{
if (DataType::isLanguageOrRange($lang)) {
if (is_null($value)) {
unset($this->members[$lang]);
} else {
$this->members[$lang] = static::checkMember($value);
}
} else {
throw new InvalidArgumentException(
'JSKOS\LanguageMap may only use language tags or ranges as index'
);
}
} | php | public function offsetSet($lang, $value)
{
if (DataType::isLanguageOrRange($lang)) {
if (is_null($value)) {
unset($this->members[$lang]);
} else {
$this->members[$lang] = static::checkMember($value);
}
} else {
throw new InvalidArgumentException(
'JSKOS\LanguageMap may only use language tags or ranges as index'
);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"lang",
",",
"$",
"value",
")",
"{",
"if",
"(",
"DataType",
"::",
"isLanguageOrRange",
"(",
"$",
"lang",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"unset",
"(",
"$",
"this",
... | Set an value at the given language or language range.
@param mixed $lang
@param mixed $value | [
"Set",
"an",
"value",
"at",
"the",
"given",
"language",
"or",
"language",
"range",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/LanguageMap.php#L38-L51 |
229,214 | slickframework/slick | src/Slick/Database/Adapter/SqliteAdapter.php | SqliteAdapter.connect | public function connect()
{
$dsn = "sqlite:{$this->_file}";
try {
$class = $this->_handlerClass;
$this->_handler = new $class($dsn);
$this->_handler->setAttribute(
PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION
);
$this->_connected = true;
} catch (\Exception $exp) {
throw new ServiceException(
"An error occurred when trying to connect to database " .
"service. Error: {$exp->getMessage()}"
);
}
return $this;
} | php | public function connect()
{
$dsn = "sqlite:{$this->_file}";
try {
$class = $this->_handlerClass;
$this->_handler = new $class($dsn);
$this->_handler->setAttribute(
PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION
);
$this->_connected = true;
} catch (\Exception $exp) {
throw new ServiceException(
"An error occurred when trying to connect to database " .
"service. Error: {$exp->getMessage()}"
);
}
return $this;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"dsn",
"=",
"\"sqlite:{$this->_file}\"",
";",
"try",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"_handlerClass",
";",
"$",
"this",
"->",
"_handler",
"=",
"new",
"$",
"class",
"(",
"$",
"dsn",
")",
... | Connects to the database service
@throws ServiceException If any error occurs while trying to
connect to the database service
@return SqliteAdapter The current adapter to chain method calls | [
"Connects",
"to",
"the",
"database",
"service"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Adapter/SqliteAdapter.php#L53-L71 |
229,215 | wolfguarder/yii2-video-gallery | controllers/AdminController.php | AdminController.actionVideos | public function actionVideos($id)
{
$video_gallery = $this->findModel($id);
$searchModel = $this->module->manager->createVideoGalleryItemSearch();
$dataProvider = $searchModel->search($_GET, $id);
return $this->render('video/index', [
'video_gallery' => $video_gallery,
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
} | php | public function actionVideos($id)
{
$video_gallery = $this->findModel($id);
$searchModel = $this->module->manager->createVideoGalleryItemSearch();
$dataProvider = $searchModel->search($_GET, $id);
return $this->render('video/index', [
'video_gallery' => $video_gallery,
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
} | [
"public",
"function",
"actionVideos",
"(",
"$",
"id",
")",
"{",
"$",
"video_gallery",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"searchModel",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createVideoGalleryItemSearch"... | Lists all VideoGallery videos models.
@param $id VideoGallery id
@return mixed | [
"Lists",
"all",
"VideoGallery",
"videos",
"models",
"."
] | e2c4a06e469a674e1b75dbc841714f2d5a9505bf | https://github.com/wolfguarder/yii2-video-gallery/blob/e2c4a06e469a674e1b75dbc841714f2d5a9505bf/controllers/AdminController.php#L146-L158 |
229,216 | wolfguarder/yii2-video-gallery | controllers/AdminController.php | AdminController.actionCreateVideo | public function actionCreateVideo($id)
{
$video_gallery = $this->findModel($id);
$model = $this->module->manager->createVideoGalleryItem(['scenario' => 'create']);
$model->loadDefaultValues();
if ($model->load(\Yii::$app->request->post())) {
$model->video_gallery_id = $video_gallery->id;
if($model->create()) {
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been created'));
return $this->redirect(['videos', 'id' => $id]);
}
}
return $this->render('video/create', [
'video_gallery' => $video_gallery,
'model' => $model
]);
} | php | public function actionCreateVideo($id)
{
$video_gallery = $this->findModel($id);
$model = $this->module->manager->createVideoGalleryItem(['scenario' => 'create']);
$model->loadDefaultValues();
if ($model->load(\Yii::$app->request->post())) {
$model->video_gallery_id = $video_gallery->id;
if($model->create()) {
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been created'));
return $this->redirect(['videos', 'id' => $id]);
}
}
return $this->render('video/create', [
'video_gallery' => $video_gallery,
'model' => $model
]);
} | [
"public",
"function",
"actionCreateVideo",
"(",
"$",
"id",
")",
"{",
"$",
"video_gallery",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createVideoGalleryItem",
"("... | Create video_gallery video
@param $id VideoGallery id
@return string
@throws NotFoundHttpException | [
"Create",
"video_gallery",
"video"
] | e2c4a06e469a674e1b75dbc841714f2d5a9505bf | https://github.com/wolfguarder/yii2-video-gallery/blob/e2c4a06e469a674e1b75dbc841714f2d5a9505bf/controllers/AdminController.php#L166-L186 |
229,217 | wolfguarder/yii2-video-gallery | controllers/AdminController.php | AdminController.actionUpdateVideo | public function actionUpdateVideo($id)
{
$model = $this->module->manager->findVideoGalleryItemById($id);
if ($model === null) {
throw new NotFoundHttpException('The requested video does not exist');
}
$model->scenario = 'update';
$video_gallery = $this->findModel($model->video_gallery_id);
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been updated'));
return $this->refresh();
}
return $this->render('video/update', [
'model' => $model,
'video_gallery' => $video_gallery
]);
} | php | public function actionUpdateVideo($id)
{
$model = $this->module->manager->findVideoGalleryItemById($id);
if ($model === null) {
throw new NotFoundHttpException('The requested video does not exist');
}
$model->scenario = 'update';
$video_gallery = $this->findModel($model->video_gallery_id);
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been updated'));
return $this->refresh();
}
return $this->render('video/update', [
'model' => $model,
'video_gallery' => $video_gallery
]);
} | [
"public",
"function",
"actionUpdateVideo",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"findVideoGalleryItemById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"throw",... | Updates an existing VideoGalleryItem model.
If update is successful, the browser will be redirected to the 'videos' page.
@param integer $id
@return mixed
@throws NotFoundHttpException | [
"Updates",
"an",
"existing",
"VideoGalleryItem",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"videos",
"page",
"."
] | e2c4a06e469a674e1b75dbc841714f2d5a9505bf | https://github.com/wolfguarder/yii2-video-gallery/blob/e2c4a06e469a674e1b75dbc841714f2d5a9505bf/controllers/AdminController.php#L196-L220 |
229,218 | wolfguarder/yii2-video-gallery | controllers/AdminController.php | AdminController.actionDeleteVideo | public function actionDeleteVideo($id)
{
$model = $this->module->manager->findVideoGalleryItemById($id);
if ($model === null) {
throw new NotFoundHttpException('The requested page does not exist');
}
$model->delete();
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been deleted'));
return $this->redirect(['videos', 'id' => $model->video_gallery_id]);
} | php | public function actionDeleteVideo($id)
{
$model = $this->module->manager->findVideoGalleryItemById($id);
if ($model === null) {
throw new NotFoundHttpException('The requested page does not exist');
}
$model->delete();
\Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been deleted'));
return $this->redirect(['videos', 'id' => $model->video_gallery_id]);
} | [
"public",
"function",
"actionDeleteVideo",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"findVideoGalleryItemById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"throw",... | Deletes an existing VideoGalleryItem model.
If deletion is successful, the browser will be redirected to the 'videos' page.
@param integer $id
@return \yii\web\Response
@throws NotFoundHttpException
@throws \Exception | [
"Deletes",
"an",
"existing",
"VideoGalleryItem",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"videos",
"page",
"."
] | e2c4a06e469a674e1b75dbc841714f2d5a9505bf | https://github.com/wolfguarder/yii2-video-gallery/blob/e2c4a06e469a674e1b75dbc841714f2d5a9505bf/controllers/AdminController.php#L231-L243 |
229,219 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.get | public function get(string $name) : JobInterface
{
if ($this->has($name)) {
return $this->getOrMake($name);
}
throw new JobException("There is no such job: '$name'");
} | php | public function get(string $name) : JobInterface
{
if ($this->has($name)) {
return $this->getOrMake($name);
}
throw new JobException("There is no such job: '$name'");
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
":",
"JobInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getOrMake",
"(",
"$",
"name",
")",
";",
"}",
"throw",
"new... | Returns the job with the given name
@param string $name The name of the job
@return JobInterface | [
"Returns",
"the",
"job",
"with",
"the",
"given",
"name"
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L119-L126 |
229,220 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.add | public function add(JobInterface $job)
{
if (! $job->getName()) {
throw new JobException('Add a name to the job.');
}
$jobs[$job->getName()] = $job;
} | php | public function add(JobInterface $job)
{
if (! $job->getName()) {
throw new JobException('Add a name to the job.');
}
$jobs[$job->getName()] = $job;
} | [
"public",
"function",
"add",
"(",
"JobInterface",
"$",
"job",
")",
"{",
"if",
"(",
"!",
"$",
"job",
"->",
"getName",
"(",
")",
")",
"{",
"throw",
"new",
"JobException",
"(",
"'Add a name to the job.'",
")",
";",
"}",
"$",
"jobs",
"[",
"$",
"job",
"->... | Adds a job to the pool
@param JobInterface $job
@return void | [
"Adds",
"a",
"job",
"to",
"the",
"pool"
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L134-L141 |
229,221 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.remove | public function remove(string $name) : bool
{
$key = $this->makeCacheKey($name);
$this->cache->forget($key);
unset($this->jobs[$name]);
} | php | public function remove(string $name) : bool
{
$key = $this->makeCacheKey($name);
$this->cache->forget($key);
unset($this->jobs[$name]);
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"makeCacheKey",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"key",
")",
";",
"unset",
"("... | Removes a job from the pool
@param string $name
@return bool | [
"Removes",
"a",
"job",
"from",
"the",
"pool"
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L174-L181 |
229,222 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.clear | public function clear()
{
foreach ($this->jobs as $name => $job) {
$key = $this->makeCacheKey($name);
$this->cache->forget($key);
}
$this->jobs = array();
} | php | public function clear()
{
foreach ($this->jobs as $name => $job) {
$key = $this->makeCacheKey($name);
$this->cache->forget($key);
}
$this->jobs = array();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"name",
"=>",
"$",
"job",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"makeCacheKey",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"cache",
... | Removes all jobs from the pool
@return void | [
"Removes",
"all",
"jobs",
"from",
"the",
"pool"
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L188-L196 |
229,223 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.all | public function all() : array
{
$jobs = array();
foreach ($this->jobs as $name => $jobBag) {
$jobs[$name] = $this->getOrMake($name);
}
return $jobs;
} | php | public function all() : array
{
$jobs = array();
foreach ($this->jobs as $name => $jobBag) {
$jobs[$name] = $this->getOrMake($name);
}
return $jobs;
} | [
"public",
"function",
"all",
"(",
")",
":",
"array",
"{",
"$",
"jobs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"name",
"=>",
"$",
"jobBag",
")",
"{",
"$",
"jobs",
"[",
"$",
"name",
"]",
"=",
"$",
"th... | Returns an array with all jobs
@return JobInterface[] | [
"Returns",
"an",
"array",
"with",
"all",
"jobs"
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L213-L222 |
229,224 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.run | public function run()
{
$now = time();
if ($this->remainingCoolDown() > 0) {
return false;
}
$this->cache->forever($this->cacheKey, $now);
$counter = 0;
foreach ($this->jobs as $name => $jobBag) {
$job = $this->getOrMake($name);
$key = $this->makeCacheKey($name);
$executed = null;
if ($this->cache->has($key)) {
$executed = $this->cache->get($key);
if ($now - $executed < $job->getInterval() * 60) {
continue;
}
}
if ($job->getActive()) {
$now = time();
$job->run($executed);
$this->cache->forever($key, $now);
$counter++;
}
}
return $counter;
} | php | public function run()
{
$now = time();
if ($this->remainingCoolDown() > 0) {
return false;
}
$this->cache->forever($this->cacheKey, $now);
$counter = 0;
foreach ($this->jobs as $name => $jobBag) {
$job = $this->getOrMake($name);
$key = $this->makeCacheKey($name);
$executed = null;
if ($this->cache->has($key)) {
$executed = $this->cache->get($key);
if ($now - $executed < $job->getInterval() * 60) {
continue;
}
}
if ($job->getActive()) {
$now = time();
$job->run($executed);
$this->cache->forever($key, $now);
$counter++;
}
}
return $counter;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"remainingCoolDown",
"(",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"forever",
"(",
... | Runs all jobs that do not have a cool down.
Returns false or the number of executed jobs.
@return boolean|int | [
"Runs",
"all",
"jobs",
"that",
"do",
"not",
"have",
"a",
"cool",
"down",
".",
"Returns",
"false",
"or",
"the",
"number",
"of",
"executed",
"jobs",
"."
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L230-L265 |
229,225 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.remainingCoolDown | public function remainingCoolDown() : int
{
$now = time();
if ($this->cache->has($this->cacheKey)) {
$executedAt = $this->cache->get($this->cacheKey);
$remainingCoolDown = $executedAt + $this->coolDown * 60 - $now;
return max($remainingCoolDown / 60, 0);
}
return 0;
} | php | public function remainingCoolDown() : int
{
$now = time();
if ($this->cache->has($this->cacheKey)) {
$executedAt = $this->cache->get($this->cacheKey);
$remainingCoolDown = $executedAt + $this->coolDown * 60 - $now;
return max($remainingCoolDown / 60, 0);
}
return 0;
} | [
"public",
"function",
"remainingCoolDown",
"(",
")",
":",
"int",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"this",
"->",
"cacheKey",
")",
")",
"{",
"$",
"executedAt",
"=",
"$",
"thi... | Returns the number of minutes the job executor still is in cool down mode.
Minimum is 0.
@return int | [
"Returns",
"the",
"number",
"of",
"minutes",
"the",
"job",
"executor",
"still",
"is",
"in",
"cool",
"down",
"mode",
".",
"Minimum",
"is",
"0",
"."
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L273-L286 |
229,226 | chriskonnertz/Jobs | src/ChrisKonnertz/Jobs/Jobs.php | Jobs.getOrMake | protected function getOrMake(string $name) : JobInterface
{
$value = $this->jobs[$name];
if ($value instanceof JobInterface) {
return $value;
}
if (is_string($value)) {
$reflectionClass = new ReflectionClass($value);
$job = $reflectionClass->newInstance(); // Create instance
} else {
/** @var Closure $value */
$job = $value(); // Execute closure
}
if (! $job instanceof JobInterface) {
throw new JobException("Object '$name' is not a job!");
}
$this->jobs[$name] = $job;
return $job;
} | php | protected function getOrMake(string $name) : JobInterface
{
$value = $this->jobs[$name];
if ($value instanceof JobInterface) {
return $value;
}
if (is_string($value)) {
$reflectionClass = new ReflectionClass($value);
$job = $reflectionClass->newInstance(); // Create instance
} else {
/** @var Closure $value */
$job = $value(); // Execute closure
}
if (! $job instanceof JobInterface) {
throw new JobException("Object '$name' is not a job!");
}
$this->jobs[$name] = $job;
return $job;
} | [
"protected",
"function",
"getOrMake",
"(",
"string",
"$",
"name",
")",
":",
"JobInterface",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"jobs",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"value",
"instanceof",
"JobInterface",
")",
"{",
"return",
"$",
... | If a job with the given name exists, this method returns the job.
If there is no such job yet, it will create, store and return it.
@param string $name
@return JobInterface | [
"If",
"a",
"job",
"with",
"the",
"given",
"name",
"exists",
"this",
"method",
"returns",
"the",
"job",
".",
"If",
"there",
"is",
"no",
"such",
"job",
"yet",
"it",
"will",
"create",
"store",
"and",
"return",
"it",
"."
] | 77230dcc04c8aebd376343686484c6520e431130 | https://github.com/chriskonnertz/Jobs/blob/77230dcc04c8aebd376343686484c6520e431130/src/ChrisKonnertz/Jobs/Jobs.php#L339-L363 |
229,227 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector.getClassAnnotations | public function getClassAnnotations()
{
if (empty($this->_annotations['class'])) {
$comment = $this->_getReflection()->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$classAnnotations = new AnnotationsList();
foreach ($data as $name => $parsedData) {
$classAnnotations->append(
$this->_createAnnotation($name, $parsedData)
);
}
$this->_annotations['class'] = $classAnnotations;
}
return $this->_annotations['class'];
} | php | public function getClassAnnotations()
{
if (empty($this->_annotations['class'])) {
$comment = $this->_getReflection()->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$classAnnotations = new AnnotationsList();
foreach ($data as $name => $parsedData) {
$classAnnotations->append(
$this->_createAnnotation($name, $parsedData)
);
}
$this->_annotations['class'] = $classAnnotations;
}
return $this->_annotations['class'];
} | [
"public",
"function",
"getClassAnnotations",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_annotations",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"comment",
"=",
"$",
"this",
"->",
"_getReflection",
"(",
")",
"->",
"getDocComment",
"(",
... | Retrieves the list of annotations from inspected class
@return AnnotationsList | [
"Retrieves",
"the",
"list",
"of",
"annotations",
"from",
"inspected",
"class"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L80-L94 |
229,228 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector.getPropertyAnnotations | public function getPropertyAnnotations($property)
{
if (!$this->hasProperty($property)) {
$name = $this->_getReflection()->getName();
throw new Exception\InvalidArgumentException(
"The class {$name} doesn't have a property called {$property}"
);
}
if (empty($this->_annotations['properties'][$property])) {
$comment = $this->_getReflection()
->getProperty($property)
->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$propertyAnnotations = new AnnotationsList();
foreach ($data as $property => $parsedData) {
$propertyAnnotations->append(
$this->_createAnnotation($property, $parsedData)
);
}
$this->_annotations['properties'][$property] = $propertyAnnotations;
}
return $this->_annotations['properties'][$property];
} | php | public function getPropertyAnnotations($property)
{
if (!$this->hasProperty($property)) {
$name = $this->_getReflection()->getName();
throw new Exception\InvalidArgumentException(
"The class {$name} doesn't have a property called {$property}"
);
}
if (empty($this->_annotations['properties'][$property])) {
$comment = $this->_getReflection()
->getProperty($property)
->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$propertyAnnotations = new AnnotationsList();
foreach ($data as $property => $parsedData) {
$propertyAnnotations->append(
$this->_createAnnotation($property, $parsedData)
);
}
$this->_annotations['properties'][$property] = $propertyAnnotations;
}
return $this->_annotations['properties'][$property];
} | [
"public",
"function",
"getPropertyAnnotations",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasProperty",
"(",
"$",
"property",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_getReflection",
"(",
")",
"->",
"getName",
"("... | Retrieves the list of annotations from provided property
@param string $property Property name
@throws Exception\InvalidArgumentException
@return AnnotationsList | [
"Retrieves",
"the",
"list",
"of",
"annotations",
"from",
"provided",
"property"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L103-L126 |
229,229 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector.getMethodAnnotations | public function getMethodAnnotations($method)
{
if (!$this->hasMethod($method)) {
$name = $this->_getReflection()->getName();
throw new Exception\InvalidArgumentException(
"The class {$name} doesn't have a property called {$method}"
);
}
if (empty($this->_annotations['methods'][$method])) {
$comment = $this->_getReflection()
->getMethod($method)
->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$methodAnnotations = new AnnotationsList();
foreach ($data as $property => $parsedData) {
$methodAnnotations->append(
$this->_createAnnotation($property, $parsedData)
);
}
$this->_annotations['methods'][$method] = $methodAnnotations;
}
return $this->_annotations['methods'][$method];
} | php | public function getMethodAnnotations($method)
{
if (!$this->hasMethod($method)) {
$name = $this->_getReflection()->getName();
throw new Exception\InvalidArgumentException(
"The class {$name} doesn't have a property called {$method}"
);
}
if (empty($this->_annotations['methods'][$method])) {
$comment = $this->_getReflection()
->getMethod($method)
->getDocComment();
$data = AnnotationParser::getAnnotations($comment);
$methodAnnotations = new AnnotationsList();
foreach ($data as $property => $parsedData) {
$methodAnnotations->append(
$this->_createAnnotation($property, $parsedData)
);
}
$this->_annotations['methods'][$method] = $methodAnnotations;
}
return $this->_annotations['methods'][$method];
} | [
"public",
"function",
"getMethodAnnotations",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMethod",
"(",
"$",
"method",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_getReflection",
"(",
")",
"->",
"getName",
"(",
")",... | Retrieves the list of annotations of provided methods
@param string $method
@return AnnotationsList
@throws Exception\InvalidArgumentException | [
"Retrieves",
"the",
"list",
"of",
"annotations",
"of",
"provided",
"methods"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L136-L159 |
229,230 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector.getClassProperties | public function getClassProperties()
{
if (empty($this->_properties)) {
$properties = $this->_getReflection()->getProperties();
foreach ($properties as $property) {
$this->_properties[] = $property->getName();
}
}
return $this->_properties;
} | php | public function getClassProperties()
{
if (empty($this->_properties)) {
$properties = $this->_getReflection()->getProperties();
foreach ($properties as $property) {
$this->_properties[] = $property->getName();
}
}
return $this->_properties;
} | [
"public",
"function",
"getClassProperties",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_properties",
")",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"_getReflection",
"(",
")",
"->",
"getProperties",
"(",
")",
";",
"foreach",
... | Retrieves the list of class properties.
@return \ArrayIterator An array with property names. | [
"Retrieves",
"the",
"list",
"of",
"class",
"properties",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L166-L175 |
229,231 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector.getClassMethods | public function getClassMethods()
{
if (empty($this->_methods)) {
$methods = $this->_getReflection()->getMethods();
foreach ($methods as $method) {
$this->_methods[] = $method->getName();
}
}
return $this->_methods;
} | php | public function getClassMethods()
{
if (empty($this->_methods)) {
$methods = $this->_getReflection()->getMethods();
foreach ($methods as $method) {
$this->_methods[] = $method->getName();
}
}
return $this->_methods;
} | [
"public",
"function",
"getClassMethods",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_methods",
")",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"_getReflection",
"(",
")",
"->",
"getMethods",
"(",
")",
";",
"foreach",
"(",
"$",... | Retrieves the list of class methods
@return array An array with method names. | [
"Retrieves",
"the",
"list",
"of",
"class",
"methods"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L182-L191 |
229,232 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector._getReflection | protected function _getReflection()
{
if (is_null($this->_reflection)) {
$this->_reflection = new \ReflectionClass($this->_class);
}
return $this->_reflection;
} | php | protected function _getReflection()
{
if (is_null($this->_reflection)) {
$this->_reflection = new \ReflectionClass($this->_class);
}
return $this->_reflection;
} | [
"protected",
"function",
"_getReflection",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_reflection",
")",
")",
"{",
"$",
"this",
"->",
"_reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"_class",
")",
";",
"}"... | Returns the reflection object for inspected class
@return \ReflectionClass The reflection of given class | [
"Returns",
"the",
"reflection",
"object",
"for",
"inspected",
"class"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L245-L251 |
229,233 | slickframework/slick | src/Slick/Common/Inspector.php | Inspector._createAnnotation | protected function _createAnnotation($name, $parsedData)
{
$class = static::$_classMap['default'];
if (isset(static::$_classMap[$name])) {
$class = static::$_classMap[$name];
}
$classReflection = new ReflectionClass($class);
return $classReflection->newInstanceArgs([$name, $parsedData]);
} | php | protected function _createAnnotation($name, $parsedData)
{
$class = static::$_classMap['default'];
if (isset(static::$_classMap[$name])) {
$class = static::$_classMap[$name];
}
$classReflection = new ReflectionClass($class);
return $classReflection->newInstanceArgs([$name, $parsedData]);
} | [
"protected",
"function",
"_createAnnotation",
"(",
"$",
"name",
",",
"$",
"parsedData",
")",
"{",
"$",
"class",
"=",
"static",
"::",
"$",
"_classMap",
"[",
"'default'",
"]",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"_classMap",
"[",
"$",
"nam... | Creates the correct annotation object
@param string $name
@param mixed $parsedData
@return AnnotationInterface | [
"Creates",
"the",
"correct",
"annotation",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector.php#L260-L269 |
229,234 | slickframework/slick | src/Slick/Database/Sql/Dialect.php | Dialect.create | public static function create($dialect, SqlInterface $sql)
{
if (array_key_exists($dialect, static::$_map)) {
return static::_createDialect(static::$_map[$dialect], $sql);
}
if (class_exists($dialect)) {
if (
in_array(static::DIALECT_INTERFACE, class_implements($dialect))
) {
return static::_createDialect($dialect, $sql);
}
$interface = static::DIALECT_INTERFACE;
throw new InvalidArgumentException(
"The class {$dialect} does not implements the " .
"{$interface} interface."
);
}
throw new InvalidArgumentException(
"Trying to create an unknown dialect. '{$dialect}' is" .
" not recognized."
);
} | php | public static function create($dialect, SqlInterface $sql)
{
if (array_key_exists($dialect, static::$_map)) {
return static::_createDialect(static::$_map[$dialect], $sql);
}
if (class_exists($dialect)) {
if (
in_array(static::DIALECT_INTERFACE, class_implements($dialect))
) {
return static::_createDialect($dialect, $sql);
}
$interface = static::DIALECT_INTERFACE;
throw new InvalidArgumentException(
"The class {$dialect} does not implements the " .
"{$interface} interface."
);
}
throw new InvalidArgumentException(
"Trying to create an unknown dialect. '{$dialect}' is" .
" not recognized."
);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"dialect",
",",
"SqlInterface",
"$",
"sql",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"dialect",
",",
"static",
"::",
"$",
"_map",
")",
")",
"{",
"return",
"static",
"::",
"_createDialect",
"("... | Creates a dialect with provided SQL object
You can use the known dialects such as {@see Dialect::MYSQL} or you can
create your custom dialect.
The custom dialect class must implement the
{@see \Slick\Database\Sql\Dialect\DialectInterface} interface or an
exception will be thrown when trying to create it.
@param string $dialect Dialect name or dialect class name.
@param SqlInterface $sql
@throws InvalidArgumentException
@return DialectInterface | [
"Creates",
"a",
"dialect",
"with",
"provided",
"SQL",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect.php#L67-L90 |
229,235 | slickframework/slick | src/Slick/Database/Sql/Dialect.php | Dialect._createDialect | private static function _createDialect($class, SqlInterface $sql)
{
$reflection = new ReflectionClass($class);
/** @var DialectInterface $dialect */
$dialect = $reflection->newInstanceArgs();
$dialect->setSql($sql);
return $dialect;
} | php | private static function _createDialect($class, SqlInterface $sql)
{
$reflection = new ReflectionClass($class);
/** @var DialectInterface $dialect */
$dialect = $reflection->newInstanceArgs();
$dialect->setSql($sql);
return $dialect;
} | [
"private",
"static",
"function",
"_createDialect",
"(",
"$",
"class",
",",
"SqlInterface",
"$",
"sql",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"/** @var DialectInterface $dialect */",
"$",
"dialect",
"=",
"$",
"... | Creates the dialect object with the given class name
@param string $class
@param SqlInterface $sql
@return DialectInterface | [
"Creates",
"the",
"dialect",
"object",
"with",
"the",
"given",
"class",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect.php#L100-L107 |
229,236 | jacobstr/matura | lib/Blocks/Block.php | Block.skip | public function skip($message = '')
{
if ($this->skipped !== true) {
$this->skipped = true;
$this->skipped_because = $message;
}
return $this;
} | php | public function skip($message = '')
{
if ($this->skipped !== true) {
$this->skipped = true;
$this->skipped_because = $message;
}
return $this;
} | [
"public",
"function",
"skip",
"(",
"$",
"message",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"skipped",
"!==",
"true",
")",
"{",
"$",
"this",
"->",
"skipped",
"=",
"true",
";",
"$",
"this",
"->",
"skipped_because",
"=",
"$",
"message",
";"... | Unless the Block has been skipped elsewhere, this marks the block as
skipped with the given message.
@param string $message An optional skip message.
@return Block $this | [
"Unless",
"the",
"Block",
"has",
"been",
"skipped",
"elsewhere",
"this",
"marks",
"the",
"block",
"as",
"skipped",
"with",
"the",
"given",
"message",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Blocks/Block.php#L59-L67 |
229,237 | jacobstr/matura | lib/Blocks/Block.php | Block.getContextChain | public function getContextChain()
{
$block_chain = array();
// This should return all of our before hooks in the order they *should*
// have been invoked.
$this->traversePost(function ($block) use (&$block_chain) {
// Ensure ordering - even if the test defininition interleaves
// before_all with before DSL invocations, we traverse the context
// according to the 'before_alls before befores' convention.
$befores = array_merge($block->beforeAlls(), $block->befores());
$block_chain = array_merge($block_chain, $befores);
});
return array_filter(
array_map(
function ($block) {
return $block->getContext();
},
$block_chain
)
);
} | php | public function getContextChain()
{
$block_chain = array();
// This should return all of our before hooks in the order they *should*
// have been invoked.
$this->traversePost(function ($block) use (&$block_chain) {
// Ensure ordering - even if the test defininition interleaves
// before_all with before DSL invocations, we traverse the context
// according to the 'before_alls before befores' convention.
$befores = array_merge($block->beforeAlls(), $block->befores());
$block_chain = array_merge($block_chain, $befores);
});
return array_filter(
array_map(
function ($block) {
return $block->getContext();
},
$block_chain
)
);
} | [
"public",
"function",
"getContextChain",
"(",
")",
"{",
"$",
"block_chain",
"=",
"array",
"(",
")",
";",
"// This should return all of our before hooks in the order they *should*",
"// have been invoked.",
"$",
"this",
"->",
"traversePost",
"(",
"function",
"(",
"$",
"b... | Returns an aray of related contexts, in their intended call order.
@see test_model.php for assertions against various scenarios in order to
grok the `official` behavior.
@return Context[] | [
"Returns",
"an",
"aray",
"of",
"related",
"contexts",
"in",
"their",
"intended",
"call",
"order",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Blocks/Block.php#L115-L137 |
229,238 | jacobstr/matura | lib/Blocks/Block.php | Block.path | public function path($offset = null, $length = null)
{
$ancestors = array_map(
function ($ancestor) {
return $ancestor->getName();
},
$this->ancestors()
);
$ancestors = array_slice(array_reverse($ancestors), $offset, $length);
$res = implode(":", $ancestors);
return $res;
} | php | public function path($offset = null, $length = null)
{
$ancestors = array_map(
function ($ancestor) {
return $ancestor->getName();
},
$this->ancestors()
);
$ancestors = array_slice(array_reverse($ancestors), $offset, $length);
$res = implode(":", $ancestors);
return $res;
} | [
"public",
"function",
"path",
"(",
"$",
"offset",
"=",
"null",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"ancestors",
"=",
"array_map",
"(",
"function",
"(",
"$",
"ancestor",
")",
"{",
"return",
"$",
"ancestor",
"->",
"getName",
"(",
")",
";",
... | With no arguments, returns the complete path to this block down from it's
root ancestor.
@param int $offset Used to arary_slice the intermediate array before implosion.
@param int $length Used to array_slice the intermediate array before implosion. | [
"With",
"no",
"arguments",
"returns",
"the",
"complete",
"path",
"to",
"this",
"block",
"down",
"from",
"it",
"s",
"root",
"ancestor",
"."
] | 393e0f3676f502454cc6823cac8ce9cef2ea7bff | https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Blocks/Block.php#L189-L203 |
229,239 | slickframework/slick | src/Slick/Utility/ArrayMethods.php | ArrayMethods.flatten | public static function flatten($array, $return = array())
{
foreach ($array as $value) {
if (is_array($value) || is_object($value)) {
$return = self::flatten($value, $return);
} else {
$return[] = $value;
}
}
return $return;
} | php | public static function flatten($array, $return = array())
{
foreach ($array as $value) {
if (is_array($value) || is_object($value)) {
$return = self::flatten($value, $return);
} else {
$return[] = $value;
}
}
return $return;
} | [
"public",
"static",
"function",
"flatten",
"(",
"$",
"array",
",",
"$",
"return",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"is_object",
"(",
... | Converts a multidimensional array into a uni-dimensional array.
@param array $array The source array to iterate.
@param array $return The return values, for recursive proposes.
@return array A unidirectional array from source array. | [
"Converts",
"a",
"multidimensional",
"array",
"into",
"a",
"uni",
"-",
"dimensional",
"array",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Utility/ArrayMethods.php#L49-L59 |
229,240 | slickframework/slick | src/Slick/Orm/Relation/AbstractSingleRelation.php | AbstractSingleRelation.afterSelect | public function afterSelect(Select $event)
{
if ($this->lazyLoad) {
return;
}
$data = $event->data;
$multiple = $data instanceof RecordList;
if ($multiple) {
$data = $event->data->getArrayCopy();
} else {
$data = [$data];
}
if (empty($data)) {
return;
}
$related = Entity\Manager::getInstance()
->get($this->getRelatedEntity());
$relatedTable = $related->getEntity()->getTableName();
$class = $related->getEntity()->getClassName();
$dataCopy = $data;
foreach ($dataCopy as $key => $row) {
$pmk = $this->getEntity()->getPrimaryKey();
if (isset($row[$pmk]) && is_array($row[$pmk])) {
$data[$key][$pmk] = reset($row[$pmk]);
}
$options = [];
if (is_array($row)) {
foreach ($row as $column => $value) {
if (preg_match('/^' . $relatedTable . '_(.*)/', $column)) {
unset($data[$key][$column]);
$name = str_replace($relatedTable . '_', '', $column);
$options[$name] = $value;
}
}
}
$data[$key][$this->getPropertyName()] = new $class($options);
}
if ($multiple) {
$event->data = new RecordList(['data' => $data]);
} else {
$event->data = reset($data);
}
} | php | public function afterSelect(Select $event)
{
if ($this->lazyLoad) {
return;
}
$data = $event->data;
$multiple = $data instanceof RecordList;
if ($multiple) {
$data = $event->data->getArrayCopy();
} else {
$data = [$data];
}
if (empty($data)) {
return;
}
$related = Entity\Manager::getInstance()
->get($this->getRelatedEntity());
$relatedTable = $related->getEntity()->getTableName();
$class = $related->getEntity()->getClassName();
$dataCopy = $data;
foreach ($dataCopy as $key => $row) {
$pmk = $this->getEntity()->getPrimaryKey();
if (isset($row[$pmk]) && is_array($row[$pmk])) {
$data[$key][$pmk] = reset($row[$pmk]);
}
$options = [];
if (is_array($row)) {
foreach ($row as $column => $value) {
if (preg_match('/^' . $relatedTable . '_(.*)/', $column)) {
unset($data[$key][$column]);
$name = str_replace($relatedTable . '_', '', $column);
$options[$name] = $value;
}
}
}
$data[$key][$this->getPropertyName()] = new $class($options);
}
if ($multiple) {
$event->data = new RecordList(['data' => $data]);
} else {
$event->data = reset($data);
}
} | [
"public",
"function",
"afterSelect",
"(",
"Select",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lazyLoad",
")",
"{",
"return",
";",
"}",
"$",
"data",
"=",
"$",
"event",
"->",
"data",
";",
"$",
"multiple",
"=",
"$",
"data",
"instanceof",
... | Fixes the data to be sent to entity creation with related entity object
@param Select $event | [
"Fixes",
"the",
"data",
"to",
"be",
"sent",
"to",
"entity",
"creation",
"with",
"related",
"entity",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/AbstractSingleRelation.php#L89-L133 |
229,241 | tooleks/php-avg-color-picker | src/ColorConverter.php | ColorConverter.assertHex | public function assertHex(string $hex)
{
// Assert HEX value length.
if (mb_strlen($hex) !== 7) {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
// Assert HEX value first character.
if (mb_substr($hex, 0, 1) !== '#') {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
for ($i = 1; $i < mb_strlen($hex); $i++) {
// Assert HEX digit value.
if (!ctype_xdigit($hex[$i])) {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
}
} | php | public function assertHex(string $hex)
{
// Assert HEX value length.
if (mb_strlen($hex) !== 7) {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
// Assert HEX value first character.
if (mb_substr($hex, 0, 1) !== '#') {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
for ($i = 1; $i < mb_strlen($hex); $i++) {
// Assert HEX digit value.
if (!ctype_xdigit($hex[$i])) {
throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
}
}
} | [
"public",
"function",
"assertHex",
"(",
"string",
"$",
"hex",
")",
"{",
"// Assert HEX value length.",
"if",
"(",
"mb_strlen",
"(",
"$",
"hex",
")",
"!==",
"7",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid HEX value %s.'",
",",
... | Assert HEX format.
Note: The method accepts only fully specified HEX values (Example: #000000).
@param string $hex
@return void
@throws RuntimeException | [
"Assert",
"HEX",
"format",
"."
] | 64e2042def3f0450e04a812dd3dcd8e7236a7fd8 | https://github.com/tooleks/php-avg-color-picker/blob/64e2042def3f0450e04a812dd3dcd8e7236a7fd8/src/ColorConverter.php#L42-L60 |
229,242 | tooleks/php-avg-color-picker | src/ColorConverter.php | ColorConverter.rgb2hex | public function rgb2hex(array $rgb): string
{
$this->assertRgb($rgb);
list($red, $green, $blue) = $rgb;
return sprintf('#%02x%02x%02x', $red, $green, $blue);
} | php | public function rgb2hex(array $rgb): string
{
$this->assertRgb($rgb);
list($red, $green, $blue) = $rgb;
return sprintf('#%02x%02x%02x', $red, $green, $blue);
} | [
"public",
"function",
"rgb2hex",
"(",
"array",
"$",
"rgb",
")",
":",
"string",
"{",
"$",
"this",
"->",
"assertRgb",
"(",
"$",
"rgb",
")",
";",
"list",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
")",
"=",
"$",
"rgb",
";",
"return",
"s... | Convert color in RGB to HEX format.
Example: RGB (array) [0, 0, 0] -> HEX (string) #000000
@param array $rgb
@return string
@throws RuntimeException | [
"Convert",
"color",
"in",
"RGB",
"to",
"HEX",
"format",
"."
] | 64e2042def3f0450e04a812dd3dcd8e7236a7fd8 | https://github.com/tooleks/php-avg-color-picker/blob/64e2042def3f0450e04a812dd3dcd8e7236a7fd8/src/ColorConverter.php#L71-L78 |
229,243 | tooleks/php-avg-color-picker | src/ColorConverter.php | ColorConverter.assertRgb | public function assertRgb(array $rgb)
{
// Assert RGB values count.
if (count($rgb) !== 3) {
throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
}
foreach ($rgb as $value) {
// Assert RGB value.
if ($value < 0 || $value > 255) {
throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
}
}
} | php | public function assertRgb(array $rgb)
{
// Assert RGB values count.
if (count($rgb) !== 3) {
throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
}
foreach ($rgb as $value) {
// Assert RGB value.
if ($value < 0 || $value > 255) {
throw new RuntimeException(sprintf('Invalid RGB value [%s].', implode(', ', $rgb)));
}
}
} | [
"public",
"function",
"assertRgb",
"(",
"array",
"$",
"rgb",
")",
"{",
"// Assert RGB values count.",
"if",
"(",
"count",
"(",
"$",
"rgb",
")",
"!==",
"3",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid RGB value [%s].'",
",",
"... | Assert RGB format.
@param array $rgb
@return void
@throws RuntimeException | [
"Assert",
"RGB",
"format",
"."
] | 64e2042def3f0450e04a812dd3dcd8e7236a7fd8 | https://github.com/tooleks/php-avg-color-picker/blob/64e2042def3f0450e04a812dd3dcd8e7236a7fd8/src/ColorConverter.php#L87-L100 |
229,244 | Danzabar/phalcon-cli | src/Input/Traits/ValidationTrait.php | ValidationTrait.required | public function required($value)
{
if (!is_null($value) && $value !== '') {
return $value;
}
throw new Exceptions\RequiredValueMissingException($this->v_type, $this->v_key);
} | php | public function required($value)
{
if (!is_null($value) && $value !== '') {
return $value;
}
throw new Exceptions\RequiredValueMissingException($this->v_type, $this->v_key);
} | [
"public",
"function",
"required",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"!==",
"''",
")",
"{",
"return",
"$",
"value",
";",
"}",
"throw",
"new",
"Exceptions",
"\\",
"RequiredValueMissingExce... | Validation for required elements
@return Mixed | [
"Validation",
"for",
"required",
"elements"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Input/Traits/ValidationTrait.php#L65-L72 |
229,245 | Danzabar/phalcon-cli | src/Input/Traits/ValidationTrait.php | ValidationTrait.valueRequired | public function valueRequired($value)
{
if (is_string($value) || is_numeric($value)) {
return $value;
}
throw new Exceptions\RequiredValueMissingException($this->v_type, $this->v_key);
} | php | public function valueRequired($value)
{
if (is_string($value) || is_numeric($value)) {
return $value;
}
throw new Exceptions\RequiredValueMissingException($this->v_type, $this->v_key);
} | [
"public",
"function",
"valueRequired",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"throw",
"new",
"Exceptions",
"\\",
"RequiredVal... | Validation for options to specify that a value is required and not just flag
@return Mixed | [
"Validation",
"for",
"options",
"to",
"specify",
"that",
"a",
"value",
"is",
"required",
"and",
"not",
"just",
"flag"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Input/Traits/ValidationTrait.php#L79-L86 |
229,246 | gbv/jskos-php | src/Container.php | Container.map | public function map(callable $callback): array
{
$result = [];
foreach ($this->members as $member) {
$result[] = $callback($member);
}
return $result;
} | php | public function map(callable $callback): array
{
$result = [];
foreach ($this->members as $member) {
$result[] = $callback($member);
}
return $result;
} | [
"public",
"function",
"map",
"(",
"callable",
"$",
"callback",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"members",
"as",
"$",
"member",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"callback",
... | Apply a function to each member of this container.
@param $callback callable | [
"Apply",
"a",
"function",
"to",
"each",
"member",
"of",
"this",
"container",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Container.php#L52-L61 |
229,247 | gbv/jskos-php | src/Container.php | Container.offsetSet | public function offsetSet($offset, $object)
{
if (is_int($offset) && $offset >= 0 && $offset < $this->count()) {
$member = static::checkMember($object);
# TODO: merge if duplicated
if (!$this->contains($member)) {
$this->members[$offset] = $member;
}
} elseif (is_null($object)) {
$this->closed = false;
} else {
$this->append($object);
}
} | php | public function offsetSet($offset, $object)
{
if (is_int($offset) && $offset >= 0 && $offset < $this->count()) {
$member = static::checkMember($object);
# TODO: merge if duplicated
if (!$this->contains($member)) {
$this->members[$offset] = $member;
}
} elseif (is_null($object)) {
$this->closed = false;
} else {
$this->append($object);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"object",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"offset",
")",
"&&",
"$",
"offset",
">=",
"0",
"&&",
"$",
"offset",
"<",
"$",
"this",
"->",
"count",
"(",
")",
")",
"{",
"$",
"m... | Set an object at the given offset.
@param mixed $offset
@param mixed $object | [
"Set",
"an",
"object",
"at",
"the",
"given",
"offset",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Container.php#L123-L136 |
229,248 | gbv/jskos-php | src/Container.php | Container.append | public function append($object)
{
$member = static::checkMember($object);
# TODO: merge if duplicated
if (!$this->contains($member)) {
$this->members[] = $member;
}
} | php | public function append($object)
{
$member = static::checkMember($object);
# TODO: merge if duplicated
if (!$this->contains($member)) {
$this->members[] = $member;
}
} | [
"public",
"function",
"append",
"(",
"$",
"object",
")",
"{",
"$",
"member",
"=",
"static",
"::",
"checkMember",
"(",
"$",
"object",
")",
";",
"# TODO: merge if duplicated",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"member",
")",
")",
"... | Append an object at the end. | [
"Append",
"an",
"object",
"at",
"the",
"end",
"."
] | b558b3bdbced9c6c0671dbeeebcdfcee2c72e405 | https://github.com/gbv/jskos-php/blob/b558b3bdbced9c6c0671dbeeebcdfcee2c72e405/src/Container.php#L141-L148 |
229,249 | AOEpeople/StackFormation | src/StackFormation/Exception/ValueResolverException.php | ValueResolverException.getExceptionMessageAppendix | protected function getExceptionMessageAppendix()
{
$tmp = [];
if ($this->sourceBlueprint) { $tmp[] = 'Blueprint: ' . $this->sourceBlueprint->getName(); }
if ($this->sourceType) { $tmp[] = 'Type:' . $this->sourceType; }
if ($this->sourceKey) { $tmp[] = 'Key:' . $this->sourceKey; }
if (count($tmp)) {
return ' (' . implode(', ', $tmp) . ')';
}
return '';
} | php | protected function getExceptionMessageAppendix()
{
$tmp = [];
if ($this->sourceBlueprint) { $tmp[] = 'Blueprint: ' . $this->sourceBlueprint->getName(); }
if ($this->sourceType) { $tmp[] = 'Type:' . $this->sourceType; }
if ($this->sourceKey) { $tmp[] = 'Key:' . $this->sourceKey; }
if (count($tmp)) {
return ' (' . implode(', ', $tmp) . ')';
}
return '';
} | [
"protected",
"function",
"getExceptionMessageAppendix",
"(",
")",
"{",
"$",
"tmp",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"sourceBlueprint",
")",
"{",
"$",
"tmp",
"[",
"]",
"=",
"'Blueprint: '",
".",
"$",
"this",
"->",
"sourceBlueprint",
"->",... | Craft exception message appendix
@return string | [
"Craft",
"exception",
"message",
"appendix"
] | 5332dbbe54653e50d610cbaf75fb865c68aa2f1e | https://github.com/AOEpeople/StackFormation/blob/5332dbbe54653e50d610cbaf75fb865c68aa2f1e/src/StackFormation/Exception/ValueResolverException.php#L33-L43 |
229,250 | lekoala/silverstripe-form-extras | code/fields/FrontendUploadField.php | FrontendUploadField.customiseFile | protected function customiseFile(File $file)
{
$customizedfile = $file->customise(array(
'UploadFieldThumbnailURL' => $this->getThumbnailURLForFile($file),
'UploadFieldDeleteLink' => $this->getItemHandler($file->ID)->DeleteLink(),
'UploadFieldEditLink' => $this->getItemHandler($file->ID)->EditLink(),
'UploadField' => $this
));
// render file buttons
return $customizedfile->customise(array(
'UploadFieldFileButtons' => (string) $file->renderWith($this->getTemplateFileButtons(), array(
'IconRemove' => $this->IconRemove(),
'IconEdit' => $this->IconEdit(),
'EditEnabled' => $this->EditEnabled(),
))
));
} | php | protected function customiseFile(File $file)
{
$customizedfile = $file->customise(array(
'UploadFieldThumbnailURL' => $this->getThumbnailURLForFile($file),
'UploadFieldDeleteLink' => $this->getItemHandler($file->ID)->DeleteLink(),
'UploadFieldEditLink' => $this->getItemHandler($file->ID)->EditLink(),
'UploadField' => $this
));
// render file buttons
return $customizedfile->customise(array(
'UploadFieldFileButtons' => (string) $file->renderWith($this->getTemplateFileButtons(), array(
'IconRemove' => $this->IconRemove(),
'IconEdit' => $this->IconEdit(),
'EditEnabled' => $this->EditEnabled(),
))
));
} | [
"protected",
"function",
"customiseFile",
"(",
"File",
"$",
"file",
")",
"{",
"$",
"customizedfile",
"=",
"$",
"file",
"->",
"customise",
"(",
"array",
"(",
"'UploadFieldThumbnailURL'",
"=>",
"$",
"this",
"->",
"getThumbnailURLForFile",
"(",
"$",
"file",
")",
... | Customises a file with additional details suitable for rendering in the
UploadField.ss template
@param File $file
@return ViewableData_Customised | [
"Customises",
"a",
"file",
"with",
"additional",
"details",
"suitable",
"for",
"rendering",
"in",
"the",
"UploadField",
".",
"ss",
"template"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/FrontendUploadField.php#L362-L379 |
229,251 | lekoala/silverstripe-form-extras | code/fields/FrontendUploadField.php | FrontendUploadField_ItemHandler.delete | public function delete(SS_HTTPRequest $request)
{
// Check form field state
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
return $this->httpError(403);
}
// Protect against CSRF on destructive action
$token = $this->parent->getForm()->getSecurityToken();
if (!$token->checkRequest($request)) {
return $this->httpError(400);
}
// Check item permissions
$item = $this->getItem();
if (!$item) {
return $this->httpError(404);
}
$memberID = Member::currentUserID();
$res = false;
try {
// Owner can always delete
if ($memberID && $item->OwnerID == $memberID) {
$res = true;
} else {
$res = $item->canDelete();
}
} catch (Exception $ex) {
}
if (!$res) {
return $this->httpError(403);
}
// Delete the file from the filesystem. The file will be removed
// from the relation on save
// @todo Investigate if references to deleted files (if unsaved) is dangerous
$item->delete();
if (Controller::has_curr()) {
return Controller::curr()->redirectBack();
}
return $this;
} | php | public function delete(SS_HTTPRequest $request)
{
// Check form field state
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
return $this->httpError(403);
}
// Protect against CSRF on destructive action
$token = $this->parent->getForm()->getSecurityToken();
if (!$token->checkRequest($request)) {
return $this->httpError(400);
}
// Check item permissions
$item = $this->getItem();
if (!$item) {
return $this->httpError(404);
}
$memberID = Member::currentUserID();
$res = false;
try {
// Owner can always delete
if ($memberID && $item->OwnerID == $memberID) {
$res = true;
} else {
$res = $item->canDelete();
}
} catch (Exception $ex) {
}
if (!$res) {
return $this->httpError(403);
}
// Delete the file from the filesystem. The file will be removed
// from the relation on save
// @todo Investigate if references to deleted files (if unsaved) is dangerous
$item->delete();
if (Controller::has_curr()) {
return Controller::curr()->redirectBack();
}
return $this;
} | [
"public",
"function",
"delete",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"// Check form field state",
"if",
"(",
"$",
"this",
"->",
"parent",
"->",
"isDisabled",
"(",
")",
"||",
"$",
"this",
"->",
"parent",
"->",
"isReadonly",
"(",
")",
")",
"{",
... | Action to handle deleting of a single file
@param SS_HTTPRequest $request
@return SS_HTTPResponse | [
"Action",
"to",
"handle",
"deleting",
"of",
"a",
"single",
"file"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/FrontendUploadField.php#L473-L519 |
229,252 | lekoala/silverstripe-form-extras | code/fields/FrontendUploadField.php | FrontendUploadField_ItemHandler.edit | public function edit(SS_HTTPRequest $request)
{
// Check form field state
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
return $this->httpError(403);
}
// Check item permissions
$item = $this->getItem();
if (!$item) {
return $this->httpError(404);
}
$memberID = Member::currentUserID();
$res = false;
try {
// Owner can always delete
if ($memberID && $item->OwnerID == $memberID) {
$res = true;
} else {
$res = $item->canEditFrontend();
}
} catch (Exception $ex) {
}
if (!$res) {
return $this->httpError(403);
}
Requirements::css(FRAMEWORK_DIR . '/css/UploadField.css');
return $this->customise(array(
'Form' => $this->EditForm()
))->renderWith($this->parent->getTemplateFileEdit());
} | php | public function edit(SS_HTTPRequest $request)
{
// Check form field state
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
return $this->httpError(403);
}
// Check item permissions
$item = $this->getItem();
if (!$item) {
return $this->httpError(404);
}
$memberID = Member::currentUserID();
$res = false;
try {
// Owner can always delete
if ($memberID && $item->OwnerID == $memberID) {
$res = true;
} else {
$res = $item->canEditFrontend();
}
} catch (Exception $ex) {
}
if (!$res) {
return $this->httpError(403);
}
Requirements::css(FRAMEWORK_DIR . '/css/UploadField.css');
return $this->customise(array(
'Form' => $this->EditForm()
))->renderWith($this->parent->getTemplateFileEdit());
} | [
"public",
"function",
"edit",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"// Check form field state",
"if",
"(",
"$",
"this",
"->",
"parent",
"->",
"isDisabled",
"(",
")",
"||",
"$",
"this",
"->",
"parent",
"->",
"isReadonly",
"(",
")",
")",
"{",
"... | Action to handle editing of a single file
@param SS_HTTPRequest $request
@return ViewableData_Customised | [
"Action",
"to",
"handle",
"editing",
"of",
"a",
"single",
"file"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/FrontendUploadField.php#L527-L563 |
229,253 | mjacobus/php-query-builder | lib/PO/QueryBuilder/Statements/Base.php | Base.getRawQuery | public function getRawQuery()
{
$sql = array();
foreach ($this->getClauses() as $clause) {
if (!$clause->isEmpty()) {
$sql[] = $clause;
}
}
return implode(' ', $sql);
} | php | public function getRawQuery()
{
$sql = array();
foreach ($this->getClauses() as $clause) {
if (!$clause->isEmpty()) {
$sql[] = $clause;
}
}
return implode(' ', $sql);
} | [
"public",
"function",
"getRawQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getClauses",
"(",
")",
"as",
"$",
"clause",
")",
"{",
"if",
"(",
"!",
"$",
"clause",
"->",
"isEmpty",
"(",
")",
")",
... | Get the sql without any replacements
@return string | [
"Get",
"the",
"sql",
"without",
"any",
"replacements"
] | eb7a90ae3bc433659306807535b39f12ce4dfd9f | https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder/Statements/Base.php#L88-L99 |
229,254 | mjacobus/php-query-builder | lib/PO/QueryBuilder/Helper.php | Helper.quote | public function quote($value)
{
if ($this->isDoubleQuoted()) {
return $this->doubleQuote($value);
} else {
return $this->singleQuote($value);
}
} | php | public function quote($value)
{
if ($this->isDoubleQuoted()) {
return $this->doubleQuote($value);
} else {
return $this->singleQuote($value);
}
} | [
"public",
"function",
"quote",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDoubleQuoted",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"doubleQuote",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
... | Quote value with either double or single quotes, depending on the
configuration
@param string $value
@return string | [
"Quote",
"value",
"with",
"either",
"double",
"or",
"single",
"quotes",
"depending",
"on",
"the",
"configuration"
] | eb7a90ae3bc433659306807535b39f12ce4dfd9f | https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder/Helper.php#L47-L54 |
229,255 | mjacobus/php-query-builder | lib/PO/QueryBuilder/Helper.php | Helper.quoteIfNecessary | public function quoteIfNecessary($value)
{
if ($this->isNumber($value) || $this->isPlaceholder($value)) {
return $value;
}
return $this->quote($value);
} | php | public function quoteIfNecessary($value)
{
if ($this->isNumber($value) || $this->isPlaceholder($value)) {
return $value;
}
return $this->quote($value);
} | [
"public",
"function",
"quoteIfNecessary",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNumber",
"(",
"$",
"value",
")",
"||",
"$",
"this",
"->",
"isPlaceholder",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"... | Quote value if it is not a number or placeholder
@param string $value
@return string | [
"Quote",
"value",
"if",
"it",
"is",
"not",
"a",
"number",
"or",
"placeholder"
] | eb7a90ae3bc433659306807535b39f12ce4dfd9f | https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder/Helper.php#L88-L95 |
229,256 | mjacobus/php-query-builder | lib/PO/QueryBuilder/Helper.php | Helper.replacePlaceholders | public function replacePlaceholders($string, $values, $quoteIfNecessary = true)
{
foreach ($values as $placeholder => $value) {
$replacement = $quoteIfNecessary ? $this->quoteIfNecessary($value) : $value;
$string = str_replace(":{$placeholder}", $replacement, $string);
}
return $string;
} | php | public function replacePlaceholders($string, $values, $quoteIfNecessary = true)
{
foreach ($values as $placeholder => $value) {
$replacement = $quoteIfNecessary ? $this->quoteIfNecessary($value) : $value;
$string = str_replace(":{$placeholder}", $replacement, $string);
}
return $string;
} | [
"public",
"function",
"replacePlaceholders",
"(",
"$",
"string",
",",
"$",
"values",
",",
"$",
"quoteIfNecessary",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"placeholder",
"=>",
"$",
"value",
")",
"{",
"$",
"replacement",
"=",
"$",... | Replace the given string with the given placeholders
@param string $string
@param array $values the key value pair of placeholders
@return string the string to be replaced | [
"Replace",
"the",
"given",
"string",
"with",
"the",
"given",
"placeholders"
] | eb7a90ae3bc433659306807535b39f12ce4dfd9f | https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder/Helper.php#L134-L142 |
229,257 | slickframework/slick | src/Slick/Mvc/Libs/Session/FlashMessages.php | FlashMessages.getSession | public function getSession()
{
if (is_null($this->_session)) {
$this->_session = $this->getContainer()->get('session');
}
return $this->_session;
} | php | public function getSession()
{
if (is_null($this->_session)) {
$this->_session = $this->getContainer()->get('session');
}
return $this->_session;
} | [
"public",
"function",
"getSession",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_session",
")",
")",
"{",
"$",
"this",
"->",
"_session",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
";",
"}... | Lazy loads session component
@return Driver|\Slick\Session\Driver\DriverInterface | [
"Lazy",
"loads",
"session",
"component"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Libs/Session/FlashMessages.php#L81-L87 |
229,258 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._getSelectFieldsAndTable | protected function _getSelectFieldsAndTable()
{
$template = "SELECT %s FROM %s";
if ($this->_sql->isDistinct()) {
$template = "SELECT DISTINCT %s FROM %s";
}
$this->_statement = sprintf(
$template,
$this->_getFieldList(),
$this->_sql->getTable()
);
return $this;
} | php | protected function _getSelectFieldsAndTable()
{
$template = "SELECT %s FROM %s";
if ($this->_sql->isDistinct()) {
$template = "SELECT DISTINCT %s FROM %s";
}
$this->_statement = sprintf(
$template,
$this->_getFieldList(),
$this->_sql->getTable()
);
return $this;
} | [
"protected",
"function",
"_getSelectFieldsAndTable",
"(",
")",
"{",
"$",
"template",
"=",
"\"SELECT %s FROM %s\"",
";",
"if",
"(",
"$",
"this",
"->",
"_sql",
"->",
"isDistinct",
"(",
")",
")",
"{",
"$",
"template",
"=",
"\"SELECT DISTINCT %s FROM %s\"",
";",
"... | Sets the fields for this select query
@return SelectSqlTemplate | [
"Sets",
"the",
"fields",
"for",
"this",
"select",
"query"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L53-L65 |
229,259 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._getFieldList | protected function _getFieldList()
{
$fields[] = $this->_getFieldsFor($this->_sql);
foreach ($this->_sql->getJoins() as $join) {
$str = $this->_getFieldsFor($join);
if (!$str) {
continue;
}
$fields[] = $str;
}
return implode(', ', $fields);
} | php | protected function _getFieldList()
{
$fields[] = $this->_getFieldsFor($this->_sql);
foreach ($this->_sql->getJoins() as $join) {
$str = $this->_getFieldsFor($join);
if (!$str) {
continue;
}
$fields[] = $str;
}
return implode(', ', $fields);
} | [
"protected",
"function",
"_getFieldList",
"(",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"this",
"->",
"_getFieldsFor",
"(",
"$",
"this",
"->",
"_sql",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_sql",
"->",
"getJoins",
"(",
")",
"as",
"$",
"... | Sets table field list
@return string | [
"Sets",
"table",
"field",
"list"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L71-L83 |
229,260 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._getFieldsFor | protected function _getFieldsFor(FieldListAwareInterface $object)
{
if (is_null($object->getFields())) {
return false;
}
if (is_string($object->getFields())) {
return $object->getFields();
}
$alias = (is_null($object->getAlias())) ?
$object->getTable() : $object->getAlias();
$fields = [];
foreach ($object->getFields() as $field) {
$fields[] = "{$alias}.{$field}";
}
return implode(', ', $fields);
} | php | protected function _getFieldsFor(FieldListAwareInterface $object)
{
if (is_null($object->getFields())) {
return false;
}
if (is_string($object->getFields())) {
return $object->getFields();
}
$alias = (is_null($object->getAlias())) ?
$object->getTable() : $object->getAlias();
$fields = [];
foreach ($object->getFields() as $field) {
$fields[] = "{$alias}.{$field}";
}
return implode(', ', $fields);
} | [
"protected",
"function",
"_getFieldsFor",
"(",
"FieldListAwareInterface",
"$",
"object",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"object",
"->",
"getFields",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"objec... | Retrieve a field list from a FieldListAwareInterface object
@param FieldListAwareInterface $object
@return bool|string|string[] | [
"Retrieve",
"a",
"field",
"list",
"from",
"a",
"FieldListAwareInterface",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L91-L107 |
229,261 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._setJoins | protected function _setJoins()
{
$joins = $this->_sql->getJoins();
foreach ($joins as $join) {
$this->_statement .= $this->_createJoinStatement($join);
}
return $this;
} | php | protected function _setJoins()
{
$joins = $this->_sql->getJoins();
foreach ($joins as $join) {
$this->_statement .= $this->_createJoinStatement($join);
}
return $this;
} | [
"protected",
"function",
"_setJoins",
"(",
")",
"{",
"$",
"joins",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getJoins",
"(",
")",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"join",
")",
"{",
"$",
"this",
"->",
"_statement",
".=",
"$",
"this",
"->",... | Sets the joins for this select statement
@return SelectSqlTemplate | [
"Sets",
"the",
"joins",
"for",
"this",
"select",
"statement"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L114-L121 |
229,262 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._setOrder | protected function _setOrder()
{
$order = $this->_sql->getOrder();
if (!(is_null($order) || empty($order))) {
$this->_statement .= " ORDER BY {$order}";
}
return $this;
} | php | protected function _setOrder()
{
$order = $this->_sql->getOrder();
if (!(is_null($order) || empty($order))) {
$this->_statement .= " ORDER BY {$order}";
}
return $this;
} | [
"protected",
"function",
"_setOrder",
"(",
")",
"{",
"$",
"order",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getOrder",
"(",
")",
";",
"if",
"(",
"!",
"(",
"is_null",
"(",
"$",
"order",
")",
"||",
"empty",
"(",
"$",
"order",
")",
")",
")",
"{",
"$... | Sets the order by clause
@return SelectSqlTemplate | [
"Sets",
"the",
"order",
"by",
"clause"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L128-L135 |
229,263 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._setLimit | protected function _setLimit()
{
if (
is_null($this->_sql->getLimit()) ||
intval($this->_sql->getLimit()) < 1
) {
return $this;
}
if ($this->_sql->getOffset() > 0) {
return $this->_setLimitWithOffset();
}
return $this->_setSimpleLimit();
} | php | protected function _setLimit()
{
if (
is_null($this->_sql->getLimit()) ||
intval($this->_sql->getLimit()) < 1
) {
return $this;
}
if ($this->_sql->getOffset() > 0) {
return $this->_setLimitWithOffset();
}
return $this->_setSimpleLimit();
} | [
"protected",
"function",
"_setLimit",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_sql",
"->",
"getLimit",
"(",
")",
")",
"||",
"intval",
"(",
"$",
"this",
"->",
"_sql",
"->",
"getLimit",
"(",
")",
")",
"<",
"1",
")",
"{",
"retu... | Set limit clause
@return SelectSqlTemplate | [
"Set",
"limit",
"clause"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L142-L155 |
229,264 | slickframework/slick | src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php | SelectSqlTemplate._createJoinStatement | protected function _createJoinStatement(Select\Join $join )
{
$template = " %s JOIN %s%s ON %s";
$alias = (is_null($join->getAlias())) ?
null : " AS {$join->getAlias()}";
return sprintf(
$template,
$join->getType(),
$join->getTable(),
$alias,
$join->getOnClause()
);
} | php | protected function _createJoinStatement(Select\Join $join )
{
$template = " %s JOIN %s%s ON %s";
$alias = (is_null($join->getAlias())) ?
null : " AS {$join->getAlias()}";
return sprintf(
$template,
$join->getType(),
$join->getTable(),
$alias,
$join->getOnClause()
);
} | [
"protected",
"function",
"_createJoinStatement",
"(",
"Select",
"\\",
"Join",
"$",
"join",
")",
"{",
"$",
"template",
"=",
"\" %s JOIN %s%s ON %s\"",
";",
"$",
"alias",
"=",
"(",
"is_null",
"(",
"$",
"join",
"->",
"getAlias",
"(",
")",
")",
")",
"?",
"nu... | Sets the proper join syntax for a provided join object
@param Select\Join $join
@return string | [
"Sets",
"the",
"proper",
"join",
"syntax",
"for",
"a",
"provided",
"join",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/SelectSqlTemplate.php#L187-L200 |
229,265 | slickframework/slick | src/Slick/Log/Log.php | Log.getLogger | public function getLogger($name = null)
{
$name = is_null($name) ? $this->defaultLogger : $name;
$name = "{$this->getPrefix()}$name";
if (!isset(static::$_loggers[$name])) {
static::$_loggers[$name] = new Logger($name);
$this->_setDefaultHandlers(static::$_loggers[$name]);
}
return static::$_loggers[$name];
} | php | public function getLogger($name = null)
{
$name = is_null($name) ? $this->defaultLogger : $name;
$name = "{$this->getPrefix()}$name";
if (!isset(static::$_loggers[$name])) {
static::$_loggers[$name] = new Logger($name);
$this->_setDefaultHandlers(static::$_loggers[$name]);
}
return static::$_loggers[$name];
} | [
"public",
"function",
"getLogger",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"is_null",
"(",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"defaultLogger",
":",
"$",
"name",
";",
"$",
"name",
"=",
"\"{$this->getPrefix()}$name\"",
";",
"if"... | Gets the logger for the channel with the provided name.
@param string $name The loggers channel name to retrieve.
@return \Monolog\Logger The logger object for the given channel name. | [
"Gets",
"the",
"logger",
"for",
"the",
"channel",
"with",
"the",
"provided",
"name",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Log/Log.php#L79-L88 |
229,266 | slickframework/slick | src/Slick/Log/Log.php | Log._setDefaultHandlers | protected function _setDefaultHandlers(Logger &$logger)
{
if (empty($this->_handlers)) {
$socketHandler = new NullHandler();
array_push($this->_handlers, $socketHandler);
}
foreach ($this->_handlers as $handler) {
$logger->pushHandler($handler);
}
} | php | protected function _setDefaultHandlers(Logger &$logger)
{
if (empty($this->_handlers)) {
$socketHandler = new NullHandler();
array_push($this->_handlers, $socketHandler);
}
foreach ($this->_handlers as $handler) {
$logger->pushHandler($handler);
}
} | [
"protected",
"function",
"_setDefaultHandlers",
"(",
"Logger",
"&",
"$",
"logger",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_handlers",
")",
")",
"{",
"$",
"socketHandler",
"=",
"new",
"NullHandler",
"(",
")",
";",
"array_push",
"(",
"$",
... | Adds the default log handlers to the provided logger.
@param Logger $logger The logger object to add the handlers. | [
"Adds",
"the",
"default",
"log",
"handlers",
"to",
"the",
"provided",
"logger",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Log/Log.php#L95-L105 |
229,267 | slickframework/slick | src/Slick/Log/Log.php | Log.getPrefix | public function getPrefix()
{
if (is_null($this->_prefix)) {
$hostName = gethostname();
try {
$this->_prefix = Configuration::get('config')
->get('logger.prefix', $hostName);
} catch(FileNotFoundException $exp) {
$this->_prefix = $hostName;
}
}
return $this->_prefix;
} | php | public function getPrefix()
{
if (is_null($this->_prefix)) {
$hostName = gethostname();
try {
$this->_prefix = Configuration::get('config')
->get('logger.prefix', $hostName);
} catch(FileNotFoundException $exp) {
$this->_prefix = $hostName;
}
}
return $this->_prefix;
} | [
"public",
"function",
"getPrefix",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_prefix",
")",
")",
"{",
"$",
"hostName",
"=",
"gethostname",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"_prefix",
"=",
"Configuration",
"::",
"get",... | Returns the logger prefix to use
@return mixed|string | [
"Returns",
"the",
"logger",
"prefix",
"to",
"use"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Log/Log.php#L112-L125 |
229,268 | slickframework/slick | src/Slick/Database/Sql/SetDataMethods.php | SetDataMethods.set | public function set(array $data)
{
foreach ($data as $field => $value) {
$this->fields[] = $field;
$this->dataParameters[":{$field}"] = $value;
}
return $this;
} | php | public function set(array $data)
{
foreach ($data as $field => $value) {
$this->fields[] = $field;
$this->dataParameters[":{$field}"] = $value;
}
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"$",
"this",
"->",
"dataParameters",
"... | Sets the data for current SQL query
@param array $data
@return Insert|Update | [
"Sets",
"the",
"data",
"for",
"current",
"SQL",
"query"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/SetDataMethods.php#L41-L48 |
229,269 | Danzabar/phalcon-cli | src/Tasks/Helpers/Confirmation.php | Confirmation.confirm | public function confirm($text = 'Do you wish to continue?')
{
$this->output->writeln($text);
return $this->convertToBool($this->input->getInput());
} | php | public function confirm($text = 'Do you wish to continue?')
{
$this->output->writeln($text);
return $this->convertToBool($this->input->getInput());
} | [
"public",
"function",
"confirm",
"(",
"$",
"text",
"=",
"'Do you wish to continue?'",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"text",
")",
";",
"return",
"$",
"this",
"->",
"convertToBool",
"(",
"$",
"this",
"->",
"input",
"->",... | Request basic confirmation returns a boolean value depending on the answer
@return Boolean | [
"Request",
"basic",
"confirmation",
"returns",
"a",
"boolean",
"value",
"depending",
"on",
"the",
"answer"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Confirmation.php#L59-L64 |
229,270 | Danzabar/phalcon-cli | src/Tasks/Helpers/Confirmation.php | Confirmation.convertToBool | public function convertToBool($answer)
{
if (!$this->caseSensitive) {
$answer = strtoupper($answer);
}
// If it equals confirm yes
if ($answer == $this->confirmYes) {
return true;
}
if ($answer == $this->confirmNo || $this->explicit === false) {
return false;
}
$this->output->writeln($this->invalidConfirmationError);
} | php | public function convertToBool($answer)
{
if (!$this->caseSensitive) {
$answer = strtoupper($answer);
}
// If it equals confirm yes
if ($answer == $this->confirmYes) {
return true;
}
if ($answer == $this->confirmNo || $this->explicit === false) {
return false;
}
$this->output->writeln($this->invalidConfirmationError);
} | [
"public",
"function",
"convertToBool",
"(",
"$",
"answer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"caseSensitive",
")",
"{",
"$",
"answer",
"=",
"strtoupper",
"(",
"$",
"answer",
")",
";",
"}",
"// If it equals confirm yes",
"if",
"(",
"$",
"answer... | Converts the input to a boolean value depending on its answer
@return Boolean | [
"Converts",
"the",
"input",
"to",
"a",
"boolean",
"value",
"depending",
"on",
"its",
"answer"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Confirmation.php#L71-L87 |
229,271 | Danzabar/phalcon-cli | src/Input/Traits/ExpectationTrait.php | ExpectationTrait.addExpected | public function addExpected($name, $requirements)
{
if (!array_key_exists($name, static::$varPosition)) {
static::$expected[$name] = $requirements;
static::$varPosition[] = $name;
}
return $this;
} | php | public function addExpected($name, $requirements)
{
if (!array_key_exists($name, static::$varPosition)) {
static::$expected[$name] = $requirements;
static::$varPosition[] = $name;
}
return $this;
} | [
"public",
"function",
"addExpected",
"(",
"$",
"name",
",",
"$",
"requirements",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"static",
"::",
"$",
"varPosition",
")",
")",
"{",
"static",
"::",
"$",
"expected",
"[",
"$",
"name",
... | Adds an expected argument to the expected array
@return InputArgument | [
"Adds",
"an",
"expected",
"argument",
"to",
"the",
"expected",
"array"
] | 0d6293d5d899158705f8e3a31886d176e595ee38 | https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Input/Traits/ExpectationTrait.php#L16-L24 |
229,272 | PrestaShop/decimal | src/Operation/Subtraction.php | Subtraction.computeWithoutBcMath | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
if ($a->isNegative()) {
if ($b->isNegative()) {
// if both minuend and subtrahend are negative
// perform the subtraction with inverted coefficients position and sign
// f(x, y) = |y| - |x|
// eg. f(-1, -2) = |-2| - |-1| = 2 - 1 = 1
// e.g. f(-2, -1) = |-1| - |-2| = 1 - 2 = -1
return $this->computeWithoutBcMath($b->toPositive(), $a->toPositive());
} else {
// if the minuend is negative and the subtrahend is positive,
// we can just add them as positive numbers and then invert the sign
// f(x, y) = -(|x| + y)
// eg. f(1, 2) = -(|-1| + 2) = -3
// eg. f(-2, 1) = -(|-2| + 1) = -3
return $a
->toPositive()
->plus($b)
->toNegative();
}
} else if ($b->isNegative()) {
// if the minuend is positive subtrahend is negative, perform an addition
// f(x, y) = x + |y|
// eg. f(2, -1) = 2 + |-1| = 2 + 1 = 3
return $a->plus($b->toPositive());
}
// optimization: 0 - x = -x
if ('0' === (string) $a) {
return (!$b->isNegative()) ? $b->toNegative() : $b;
}
// optimization: x - 0 = x
if ('0' === (string) $b) {
return $a;
}
// pad coefficients with leading/trailing zeroes
list($coeff1, $coeff2) = $this->normalizeCoefficients($a, $b);
// compute the coefficient subtraction
if ($a->isGreaterThan($b)) {
$sub = $this->subtractStrings($coeff1, $coeff2);
$sign = '';
} else {
$sub = $this->subtractStrings($coeff2, $coeff1);
$sign = '-';
}
// keep the bigger exponent
$exponent = max($a->getExponent(), $b->getExponent());
return new DecimalNumber($sign . $sub, $exponent);
} | php | public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b)
{
if ($a->isNegative()) {
if ($b->isNegative()) {
// if both minuend and subtrahend are negative
// perform the subtraction with inverted coefficients position and sign
// f(x, y) = |y| - |x|
// eg. f(-1, -2) = |-2| - |-1| = 2 - 1 = 1
// e.g. f(-2, -1) = |-1| - |-2| = 1 - 2 = -1
return $this->computeWithoutBcMath($b->toPositive(), $a->toPositive());
} else {
// if the minuend is negative and the subtrahend is positive,
// we can just add them as positive numbers and then invert the sign
// f(x, y) = -(|x| + y)
// eg. f(1, 2) = -(|-1| + 2) = -3
// eg. f(-2, 1) = -(|-2| + 1) = -3
return $a
->toPositive()
->plus($b)
->toNegative();
}
} else if ($b->isNegative()) {
// if the minuend is positive subtrahend is negative, perform an addition
// f(x, y) = x + |y|
// eg. f(2, -1) = 2 + |-1| = 2 + 1 = 3
return $a->plus($b->toPositive());
}
// optimization: 0 - x = -x
if ('0' === (string) $a) {
return (!$b->isNegative()) ? $b->toNegative() : $b;
}
// optimization: x - 0 = x
if ('0' === (string) $b) {
return $a;
}
// pad coefficients with leading/trailing zeroes
list($coeff1, $coeff2) = $this->normalizeCoefficients($a, $b);
// compute the coefficient subtraction
if ($a->isGreaterThan($b)) {
$sub = $this->subtractStrings($coeff1, $coeff2);
$sign = '';
} else {
$sub = $this->subtractStrings($coeff2, $coeff1);
$sign = '-';
}
// keep the bigger exponent
$exponent = max($a->getExponent(), $b->getExponent());
return new DecimalNumber($sign . $sub, $exponent);
} | [
"public",
"function",
"computeWithoutBcMath",
"(",
"DecimalNumber",
"$",
"a",
",",
"DecimalNumber",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"isNegative",
"(",
")",
")",
"{",
"if",
"(",
"$",
"b",
"->",
"isNegative",
"(",
")",
")",
"{",
"// if b... | Performs the subtraction without using BC Math
@param DecimalNumber $a Minuend
@param DecimalNumber $b Subtrahend
@return DecimalNumber Result of the subtraction | [
"Performs",
"the",
"subtraction",
"without",
"using",
"BC",
"Math"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Subtraction.php#L73-L127 |
229,273 | slickframework/slick | src/Slick/Form/Element.php | Element.getInput | public function getInput()
{
if (is_null($this->_input)) {
$this->_input = new Input($this->getName());
}
return $this->_input;
} | php | public function getInput()
{
if (is_null($this->_input)) {
$this->_input = new Input($this->getName());
}
return $this->_input;
} | [
"public",
"function",
"getInput",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_input",
")",
")",
"{",
"$",
"this",
"->",
"_input",
"=",
"new",
"Input",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
... | Lazy loads the input fot this object
@return Input | [
"Lazy",
"loads",
"the",
"input",
"fot",
"this",
"object"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Element.php#L59-L65 |
229,274 | slickframework/slick | src/Slick/Form/Element.php | Element.setValue | public function setValue($value)
{
$this->_value = $value;
$this->getInput()->setValue($value);
return $this;
} | php | public function setValue($value)
{
$this->_value = $value;
$this->getInput()->setValue($value);
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"getInput",
"(",
")",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets element default value
@param string $value
@return Element | [
"Sets",
"element",
"default",
"value"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Element.php#L74-L79 |
229,275 | slickframework/slick | src/Slick/Form/InputFilter/Factory.php | Factory.newInputFilter | public function newInputFilter(array $definition = array())
{
if (!empty($definition)) {
$this->_definition = $definition;
}
$this->_inputFilter = new InputFilter();
foreach ($this->_definition as $key => $item) {
if (!is_string($key)) {
$key = $item['name'];
}
$this->_addInput($item, $key);
}
return $this->_inputFilter;
} | php | public function newInputFilter(array $definition = array())
{
if (!empty($definition)) {
$this->_definition = $definition;
}
$this->_inputFilter = new InputFilter();
foreach ($this->_definition as $key => $item) {
if (!is_string($key)) {
$key = $item['name'];
}
$this->_addInput($item, $key);
}
return $this->_inputFilter;
} | [
"public",
"function",
"newInputFilter",
"(",
"array",
"$",
"definition",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"definition",
")",
")",
"{",
"$",
"this",
"->",
"_definition",
"=",
"$",
"definition",
";",
"}",
"$",
"this"... | Creates a new input filter
@param array $definition Factory meta definition
@return InputFilter | [
"Creates",
"a",
"new",
"input",
"filter"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/Factory.php#L73-L88 |
229,276 | slickframework/slick | src/Slick/Form/InputFilter/Factory.php | Factory._addInput | protected function _addInput(array $data, $name = null)
{
$this->_inputFilter->add($this->_newInput($data, $name));
} | php | protected function _addInput(array $data, $name = null)
{
$this->_inputFilter->add($this->_newInput($data, $name));
} | [
"protected",
"function",
"_addInput",
"(",
"array",
"$",
"data",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_inputFilter",
"->",
"add",
"(",
"$",
"this",
"->",
"_newInput",
"(",
"$",
"data",
",",
"$",
"name",
")",
")",
";",
"}"
] | Adds an input to the input filter
@param array $data
@param null $name | [
"Adds",
"an",
"input",
"to",
"the",
"input",
"filter"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/Factory.php#L111-L114 |
229,277 | slickframework/slick | src/Slick/Form/InputFilter/Factory.php | Factory._newInput | protected function _newInput(array $data, $name = null)
{
$options = array();
foreach (array_keys($this->_inputProperties) as $key) {
if (isset($data[$key])) {
$options[$key] = $data[$key];
}
}
$input = new Input($name, $options);
if (isset($data['filters'])) {
$this->_addFilters($input, $data['filters']);
}
if (isset($data['validation'])) {
$this->_addValidators($input, $data['validation']);
}
return $input;
} | php | protected function _newInput(array $data, $name = null)
{
$options = array();
foreach (array_keys($this->_inputProperties) as $key) {
if (isset($data[$key])) {
$options[$key] = $data[$key];
}
}
$input = new Input($name, $options);
if (isset($data['filters'])) {
$this->_addFilters($input, $data['filters']);
}
if (isset($data['validation'])) {
$this->_addValidators($input, $data['validation']);
}
return $input;
} | [
"protected",
"function",
"_newInput",
"(",
"array",
"$",
"data",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_inputProperties",
")",
"as",
"$",
"key",
")... | Creates a new input
@param array $data
@param null $name
@return Input | [
"Creates",
"a",
"new",
"input"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/Factory.php#L124-L142 |
229,278 | slickframework/slick | src/Slick/Form/InputFilter/Factory.php | Factory._addFilters | protected function _addFilters(Input &$input, array $filters)
{
foreach($filters as $filter) {
$input->getFilterChain()->add(StaticFilter::create($filter));
}
} | php | protected function _addFilters(Input &$input, array $filters)
{
foreach($filters as $filter) {
$input->getFilterChain()->add(StaticFilter::create($filter));
}
} | [
"protected",
"function",
"_addFilters",
"(",
"Input",
"&",
"$",
"input",
",",
"array",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"input",
"->",
"getFilterChain",
"(",
")",
"->",
"add",
"(",
"StaticFil... | Add filters to an input
@param Input $input
@param array $filters | [
"Add",
"filters",
"to",
"an",
"input"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/Factory.php#L150-L155 |
229,279 | slickframework/slick | src/Slick/Form/InputFilter/Factory.php | Factory._addValidators | protected function _addValidators(Input &$input, array $validators)
{
foreach($validators as $validator => $message) {
$input->getValidatorChain()
->add(StaticValidator::create($validator, $message));
}
} | php | protected function _addValidators(Input &$input, array $validators)
{
foreach($validators as $validator => $message) {
$input->getValidatorChain()
->add(StaticValidator::create($validator, $message));
}
} | [
"protected",
"function",
"_addValidators",
"(",
"Input",
"&",
"$",
"input",
",",
"array",
"$",
"validators",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"validator",
"=>",
"$",
"message",
")",
"{",
"$",
"input",
"->",
"getValidatorChain",
"(",
... | Add validators to an input
@param Input $input
@param array $validators | [
"Add",
"validators",
"to",
"an",
"input"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/InputFilter/Factory.php#L163-L169 |
229,280 | slickframework/slick | src/Slick/Filter/StaticFilter.php | StaticFilter.create | public static function create($filter)
{
if (array_key_exists($filter, static::$filters)) {
$class = static::$filters[$filter];
} else if (
is_subclass_of($filter, 'Slick\Filter\FilterInterface')
) {
$class = $filter;
} else {
throw new Exception\UnknownFilterClassException(
"The filter '{$filter}' is not defined or does not " .
"implements the Slick\\Filter\\FilterInterface interface"
);
}
return new $class();
} | php | public static function create($filter)
{
if (array_key_exists($filter, static::$filters)) {
$class = static::$filters[$filter];
} else if (
is_subclass_of($filter, 'Slick\Filter\FilterInterface')
) {
$class = $filter;
} else {
throw new Exception\UnknownFilterClassException(
"The filter '{$filter}' is not defined or does not " .
"implements the Slick\\Filter\\FilterInterface interface"
);
}
return new $class();
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"filter",
",",
"static",
"::",
"$",
"filters",
")",
")",
"{",
"$",
"class",
"=",
"static",
"::",
"$",
"filters",
"[",
"$",
"filter",
"]",... | Creates a filter
@param $filter
@throws Exception\UnknownFilterClassException
@return FilterInterface | [
"Creates",
"a",
"filter"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Filter/StaticFilter.php#L62-L78 |
229,281 | lekoala/silverstripe-form-extras | code/fields/CKEditorField.php | CKEditorField.preventHtmlParserError | protected function preventHtmlParserError($html)
{
// remove empty tags
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/m";
$html = preg_replace($pattern, '', $html);
// Run twice just in case we got nested empty tags like figure / figurecaption
$html = preg_replace($pattern, '', $html);
return $html;
} | php | protected function preventHtmlParserError($html)
{
// remove empty tags
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/m";
$html = preg_replace($pattern, '', $html);
// Run twice just in case we got nested empty tags like figure / figurecaption
$html = preg_replace($pattern, '', $html);
return $html;
} | [
"protected",
"function",
"preventHtmlParserError",
"(",
"$",
"html",
")",
"{",
"// remove empty tags",
"$",
"pattern",
"=",
"\"/<[^\\/>]*>([\\s]?)*<\\/[^>]*>/m\"",
";",
"$",
"html",
"=",
"preg_replace",
"(",
"$",
"pattern",
",",
"''",
",",
"$",
"html",
")",
";",... | Cleanup content so that we don't get "getFirst" errors
@param string $html
@return string | [
"Cleanup",
"content",
"so",
"that",
"we",
"don",
"t",
"get",
"getFirst",
"errors"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/CKEditorField.php#L78-L87 |
229,282 | lekoala/silverstripe-form-extras | code/fields/FlatpickrField.php | FlatpickrField.setRangeInput | public function setRangeInput($rangeInput)
{
if ($rangeInput instanceof FormField) {
// Prevent any further init on this field
$rangeInput->addExtraClass("flatpickr-init");
$rangeInput = $rangeInput->ID();
}
$rangeInput = '#' . trim($rangeInput, '#');
$this->rangeInput = $rangeInput;
return $this;
} | php | public function setRangeInput($rangeInput)
{
if ($rangeInput instanceof FormField) {
// Prevent any further init on this field
$rangeInput->addExtraClass("flatpickr-init");
$rangeInput = $rangeInput->ID();
}
$rangeInput = '#' . trim($rangeInput, '#');
$this->rangeInput = $rangeInput;
return $this;
} | [
"public",
"function",
"setRangeInput",
"(",
"$",
"rangeInput",
")",
"{",
"if",
"(",
"$",
"rangeInput",
"instanceof",
"FormField",
")",
"{",
"// Prevent any further init on this field",
"$",
"rangeInput",
"->",
"addExtraClass",
"(",
"\"flatpickr-init\"",
")",
";",
"$... | Set range input
Warning : currently start and end values are stored
in the same input and require extra processing
Use with caution!
@param string|FormField $rangeInput Range input
@return self | [
"Set",
"range",
"input"
] | e0c1200792af8e6cea916e1999c73cf8408c6dd2 | https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/FlatpickrField.php#L208-L219 |
229,283 | slickframework/slick | src/Slick/Common/Inspector/Annotation.php | Annotation.getParameter | public function getParameter($name)
{
if (isset($this->_parameters[$name])) {
return $this->_parameters[$name];
}
return null;
} | php | public function getParameter($name)
{
if (isset($this->_parameters[$name])) {
return $this->_parameters[$name];
}
return null;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_parameters",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_parameters",
"[",
"$",
"name",
"]",
";",
"}",
"return"... | Returns the value of a given parameter name
@param string $name
@return mixed | [
"Returns",
"the",
"value",
"of",
"a",
"given",
"parameter",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/Annotation.php#L96-L102 |
229,284 | slickframework/slick | src/Slick/Common/Inspector/Annotation.php | Annotation.allValues | public function allValues()
{
$raw = $this->_parameters['_raw'];
$values = explode(',', $raw);
$result = ArrayMethods::trim($values);
return $result;
} | php | public function allValues()
{
$raw = $this->_parameters['_raw'];
$values = explode(',', $raw);
$result = ArrayMethods::trim($values);
return $result;
} | [
"public",
"function",
"allValues",
"(",
")",
"{",
"$",
"raw",
"=",
"$",
"this",
"->",
"_parameters",
"[",
"'_raw'",
"]",
";",
"$",
"values",
"=",
"explode",
"(",
"','",
",",
"$",
"raw",
")",
";",
"$",
"result",
"=",
"ArrayMethods",
"::",
"trim",
"(... | Returns the values as an array
@return array | [
"Returns",
"the",
"values",
"as",
"an",
"array"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/Annotation.php#L119-L125 |
229,285 | slickframework/slick | src/Slick/Common/Inspector/Annotation.php | Annotation._checkCommonTags | protected function _checkCommonTags()
{
if (in_array($this->getName(), $this->_commonTags)) {
$this->_value = $this->_parameters['_raw'];
}
} | php | protected function _checkCommonTags()
{
if (in_array($this->getName(), $this->_commonTags)) {
$this->_value = $this->_parameters['_raw'];
}
} | [
"protected",
"function",
"_checkCommonTags",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"_commonTags",
")",
")",
"{",
"$",
"this",
"->",
"_value",
"=",
"$",
"this",
"->",
"_parameters",
... | Fix the parameters for string tags | [
"Fix",
"the",
"parameters",
"for",
"string",
"tags"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Inspector/Annotation.php#L130-L135 |
229,286 | slickframework/slick | src/Slick/Database/Adapter/AbstractAdapter.php | AbstractAdapter.query | public function query($sql, $parameters = [])
{
$this->_checkConnection();
$query = $sql;
if (is_object($sql)) {
if (!($sql instanceof SqlInterface)) {
throw new InvalidArgumentException(
"The SQL provided is not a string or does not " .
"implements the Slick\Database\Sql\SqlInterface interface."
);
}
$query = $sql->getQueryString();
}
try {
$statement = $this->_handler->prepare($query);
$start = microtime(true);
$statement->execute($parameters);
$end = microtime(true);
$time = $end - $start;
$result = $statement->fetchAll($this->_fetchMode);
$this->getLogger()->info(
"Query ({$this->connectionName}): Query with results",
[
'query' => $query,
'params' => $parameters,
'time' => number_format($time, 3),
'affected' => $statement->rowCount()
]
);
} catch (\PDOException $exp) {
throw new SqlQueryException(
"An error occurred when querying the database service." .
"SQL: {$query} " .
"Error: {$exp->getMessage()} " .
"Database error: {$this->getLastError()}"
);
}
return new RecordList(['data' => $result]);
} | php | public function query($sql, $parameters = [])
{
$this->_checkConnection();
$query = $sql;
if (is_object($sql)) {
if (!($sql instanceof SqlInterface)) {
throw new InvalidArgumentException(
"The SQL provided is not a string or does not " .
"implements the Slick\Database\Sql\SqlInterface interface."
);
}
$query = $sql->getQueryString();
}
try {
$statement = $this->_handler->prepare($query);
$start = microtime(true);
$statement->execute($parameters);
$end = microtime(true);
$time = $end - $start;
$result = $statement->fetchAll($this->_fetchMode);
$this->getLogger()->info(
"Query ({$this->connectionName}): Query with results",
[
'query' => $query,
'params' => $parameters,
'time' => number_format($time, 3),
'affected' => $statement->rowCount()
]
);
} catch (\PDOException $exp) {
throw new SqlQueryException(
"An error occurred when querying the database service." .
"SQL: {$query} " .
"Error: {$exp->getMessage()} " .
"Database error: {$this->getLastError()}"
);
}
return new RecordList(['data' => $result]);
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"_checkConnection",
"(",
")",
";",
"$",
"query",
"=",
"$",
"sql",
";",
"if",
"(",
"is_object",
"(",
"$",
"sql",
")",
")",
"{",
"... | Executes a SQL query and returns a record list
@param string|SqlInterface $sql A string containing the SQL query
to perform ot the equivalent SqlInterface object
@param array $parameters An array of values with as many elements
as there are bound parameters in the SQL statement being executed
@throws \Slick\Database\Exception\InvalidArgumentException if the
sql provided id not a string or does not implements the
Slick\Database\Sql\SqlInterface
@throws SqlQueryException If any error occurs while preparing or
executing the SQL query
@return RecordList The records that are queried in the SQL
statement provided. Note that this list can be empty. | [
"Executes",
"a",
"SQL",
"query",
"and",
"returns",
"a",
"record",
"list"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Adapter/AbstractAdapter.php#L145-L187 |
229,287 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.getColumns | public function getColumns()
{
if (empty($this->_columns)) {
$properties = $this->getInspector()->getClassProperties();
foreach ($properties as $property) {
$annotations = $this->getInspector()
->getPropertyAnnotations($property);
if ($annotations->hasAnnotation('column')) {
$this->_columns[$property] =
$annotations->getAnnotation('column');
$this->_columns[$property]->field = trim($property, '_');
}
}
}
return $this->_columns;
} | php | public function getColumns()
{
if (empty($this->_columns)) {
$properties = $this->getInspector()->getClassProperties();
foreach ($properties as $property) {
$annotations = $this->getInspector()
->getPropertyAnnotations($property);
if ($annotations->hasAnnotation('column')) {
$this->_columns[$property] =
$annotations->getAnnotation('column');
$this->_columns[$property]->field = trim($property, '_');
}
}
}
return $this->_columns;
} | [
"public",
"function",
"getColumns",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_columns",
")",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getInspector",
"(",
")",
"->",
"getClassProperties",
"(",
")",
";",
"foreach",
"(",
... | Returns the list of entity columns
@return Column[] | [
"Returns",
"the",
"list",
"of",
"entity",
"columns"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L71-L86 |
229,288 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.getRelations | public function getRelations()
{
if (empty($this->_relations)) {
$properties = $this->getInspector()->getClassProperties();
foreach ($properties as $property) {
$annotations = $this->getInspector()
->getPropertyAnnotations($property);
foreach (static::$_annotations as $name => $class) {
if ($annotations->hasAnnotation($name)) {
$this->_relations[$property] = call_user_func_array(
[$class, 'create'],
[
$annotations->getAnnotation($name),
$this->getEntity(),
trim($property, '_')
]
);
break;
}
}
}
}
return $this->_relations;
} | php | public function getRelations()
{
if (empty($this->_relations)) {
$properties = $this->getInspector()->getClassProperties();
foreach ($properties as $property) {
$annotations = $this->getInspector()
->getPropertyAnnotations($property);
foreach (static::$_annotations as $name => $class) {
if ($annotations->hasAnnotation($name)) {
$this->_relations[$property] = call_user_func_array(
[$class, 'create'],
[
$annotations->getAnnotation($name),
$this->getEntity(),
trim($property, '_')
]
);
break;
}
}
}
}
return $this->_relations;
} | [
"public",
"function",
"getRelations",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_relations",
")",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getInspector",
"(",
")",
"->",
"getClassProperties",
"(",
")",
";",
"foreach",
"("... | Returns the list of relations of current entity
@return RelationInterface[] | [
"Returns",
"the",
"list",
"of",
"relations",
"of",
"current",
"entity"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L93-L116 |
229,289 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.getRelation | public function getRelation($name)
{
$relation = false;
if ($this->isRelation($name)) {
$relation = $this->getRelations()[$name];
}
return $relation;
} | php | public function getRelation($name)
{
$relation = false;
if ($this->isRelation($name)) {
$relation = $this->getRelations()[$name];
}
return $relation;
} | [
"public",
"function",
"getRelation",
"(",
"$",
"name",
")",
"{",
"$",
"relation",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isRelation",
"(",
"$",
"name",
")",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"getRelations",
"(",
")",
"["... | Returns the relation defined in the provided property name, or false
if there is no relation defined with that name.
@param string $name
@return bool|RelationInterface | [
"Returns",
"the",
"relation",
"defined",
"in",
"the",
"provided",
"property",
"name",
"or",
"false",
"if",
"there",
"is",
"no",
"relation",
"defined",
"with",
"that",
"name",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L153-L160 |
229,290 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.getInspector | public function getInspector()
{
if (is_null($this->_inspector)) {
$this->_inspector = new Inspector($this->_entity);
}
return $this->_inspector;
} | php | public function getInspector()
{
if (is_null($this->_inspector)) {
$this->_inspector = new Inspector($this->_entity);
}
return $this->_inspector;
} | [
"public",
"function",
"getInspector",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_inspector",
")",
")",
"{",
"$",
"this",
"->",
"_inspector",
"=",
"new",
"Inspector",
"(",
"$",
"this",
"->",
"_entity",
")",
";",
"}",
"return",
"$",... | Returns the inspector class for current entity
@return Inspector | [
"Returns",
"the",
"inspector",
"class",
"for",
"current",
"entity"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L167-L173 |
229,291 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.getEntity | public function getEntity()
{
if (!($this->_entity instanceof Entity)) {
$class = $this->_entity;
$this->setEntity(new $class());
}
return $this->_entity;
} | php | public function getEntity()
{
if (!($this->_entity instanceof Entity)) {
$class = $this->_entity;
$this->setEntity(new $class());
}
return $this->_entity;
} | [
"public",
"function",
"getEntity",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"_entity",
"instanceof",
"Entity",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"_entity",
";",
"$",
"this",
"->",
"setEntity",
"(",
"new",
"$",
"clas... | Checks if the entity is not just the class name
@return Entity | [
"Checks",
"if",
"the",
"entity",
"is",
"not",
"just",
"the",
"class",
"name"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L180-L187 |
229,292 | slickframework/slick | src/Slick/Orm/Entity/Descriptor.php | Descriptor.addRelationClass | public static function addRelationClass($name, $class)
{
$interface = 'Slick\Orm\RelationInterface';
if (!class_exists($class)) {
throw new InvalidArgumentException(
"{$class} class does not exists"
);
}
$rflClass = new ReflectionClass($class);
if (!$rflClass->implementsInterface($interface)) {
throw new InvalidArgumentException(
"{$class} class does not implement '{$interface}' interface"
);
}
static::$_annotations[$name] = $class;
} | php | public static function addRelationClass($name, $class)
{
$interface = 'Slick\Orm\RelationInterface';
if (!class_exists($class)) {
throw new InvalidArgumentException(
"{$class} class does not exists"
);
}
$rflClass = new ReflectionClass($class);
if (!$rflClass->implementsInterface($interface)) {
throw new InvalidArgumentException(
"{$class} class does not implement '{$interface}' interface"
);
}
static::$_annotations[$name] = $class;
} | [
"public",
"static",
"function",
"addRelationClass",
"(",
"$",
"name",
",",
"$",
"class",
")",
"{",
"$",
"interface",
"=",
"'Slick\\Orm\\RelationInterface'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidArgume... | Adds a new relation class to entity descriptor
@param string $name
@param string $class
@throws \Slick\Orm\Exception\InvalidArgumentException if class does not
exists or it does not implement the Slick\Orm\RelationInterface
interface | [
"Adds",
"a",
"new",
"relation",
"class",
"to",
"entity",
"descriptor"
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Entity/Descriptor.php#L199-L216 |
229,293 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.compute | public function compute(DecimalNumber $number, $precision, $roundingMode)
{
switch ($roundingMode) {
case self::ROUND_HALF_UP:
return $this->roundHalfUp($number, $precision);
break;
case self::ROUND_CEIL:
return $this->ceil($number, $precision);
break;
case self::ROUND_FLOOR:
return $this->floor($number, $precision);
break;
case self::ROUND_HALF_DOWN:
return $this->roundHalfDown($number, $precision);
break;
case self::ROUND_TRUNCATE:
return $this->truncate($number, $precision);
break;
case self::ROUND_HALF_EVEN:
return $this->roundHalfEven($number, $precision);
break;
}
throw new \InvalidArgumentException(sprintf("Invalid rounding mode: %s", print_r($roundingMode, true)));
} | php | public function compute(DecimalNumber $number, $precision, $roundingMode)
{
switch ($roundingMode) {
case self::ROUND_HALF_UP:
return $this->roundHalfUp($number, $precision);
break;
case self::ROUND_CEIL:
return $this->ceil($number, $precision);
break;
case self::ROUND_FLOOR:
return $this->floor($number, $precision);
break;
case self::ROUND_HALF_DOWN:
return $this->roundHalfDown($number, $precision);
break;
case self::ROUND_TRUNCATE:
return $this->truncate($number, $precision);
break;
case self::ROUND_HALF_EVEN:
return $this->roundHalfEven($number, $precision);
break;
}
throw new \InvalidArgumentException(sprintf("Invalid rounding mode: %s", print_r($roundingMode, true)));
} | [
"public",
"function",
"compute",
"(",
"DecimalNumber",
"$",
"number",
",",
"$",
"precision",
",",
"$",
"roundingMode",
")",
"{",
"switch",
"(",
"$",
"roundingMode",
")",
"{",
"case",
"self",
"::",
"ROUND_HALF_UP",
":",
"return",
"$",
"this",
"->",
"roundHa... | Rounds a decimal number to a specified precision
@param DecimalNumber $number Number to round
@param int $precision Maximum number of decimals
@param string $roundingMode Rounding algorithm
@return DecimalNumber | [
"Rounds",
"a",
"decimal",
"number",
"to",
"a",
"specified",
"precision"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L34-L58 |
229,294 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.truncate | public function truncate(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if (0 === $precision) {
return new DecimalNumber($number->getSign() . $number->getIntegerPart());
}
return new DecimalNumber(
$number->getSign()
. $number->getIntegerPart()
. '.'
. substr($number->getFractionalPart(), 0, $precision)
);
} | php | public function truncate(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if (0 === $precision) {
return new DecimalNumber($number->getSign() . $number->getIntegerPart());
}
return new DecimalNumber(
$number->getSign()
. $number->getIntegerPart()
. '.'
. substr($number->getFractionalPart(), 0, $precision)
);
} | [
"public",
"function",
"truncate",
"(",
"DecimalNumber",
"$",
"number",
",",
"$",
"precision",
")",
"{",
"$",
"precision",
"=",
"$",
"this",
"->",
"sanitizePrecision",
"(",
"$",
"precision",
")",
";",
"if",
"(",
"$",
"number",
"->",
"getPrecision",
"(",
"... | Truncates a number to a target number of decimal digits.
@param DecimalNumber $number Number to round
@param int $precision Maximum number of decimals
@return DecimalNumber | [
"Truncates",
"a",
"number",
"to",
"a",
"target",
"number",
"of",
"decimal",
"digits",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L68-L86 |
229,295 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.ceil | public function ceil(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if ($number->isNegative()) {
// ceil works exactly as truncate for negative numbers
return $this->truncate($number, $precision);
}
/**
* The principle for ceil is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
*
* if D > 0, ceil(X, P) = truncate(X + 10^(-P), P)
* if D = 0, ceil(X, P) = truncate(X, P)
*/
if ($precision > 0) {
// we know that D > 0, because we have already checked that the number's precision
// is greater than the target precision
$numberToAdd = '0.' . str_pad('1', $precision, '0', STR_PAD_LEFT);
} else {
$numberToAdd = '1';
}
return $this
->truncate($number, $precision)
->plus(new DecimalNumber($numberToAdd));
} | php | public function ceil(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if ($number->isNegative()) {
// ceil works exactly as truncate for negative numbers
return $this->truncate($number, $precision);
}
/**
* The principle for ceil is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
*
* if D > 0, ceil(X, P) = truncate(X + 10^(-P), P)
* if D = 0, ceil(X, P) = truncate(X, P)
*/
if ($precision > 0) {
// we know that D > 0, because we have already checked that the number's precision
// is greater than the target precision
$numberToAdd = '0.' . str_pad('1', $precision, '0', STR_PAD_LEFT);
} else {
$numberToAdd = '1';
}
return $this
->truncate($number, $precision)
->plus(new DecimalNumber($numberToAdd));
} | [
"public",
"function",
"ceil",
"(",
"DecimalNumber",
"$",
"number",
",",
"$",
"precision",
")",
"{",
"$",
"precision",
"=",
"$",
"this",
"->",
"sanitizePrecision",
"(",
"$",
"precision",
")",
";",
"if",
"(",
"$",
"number",
"->",
"getPrecision",
"(",
")",
... | Rounds a number up if its precision is greater than the target one.
Ceil always rounds towards positive infinity.
Examples:
```
$n = new Decimal\Number('123.456');
$this->ceil($n, 0); // '124'
$this->ceil($n, 1); // '123.5'
$this->ceil($n, 2); // '123.46'
$n = new Decimal\Number('-123.456');
$this->ceil($n, 0); // '-122'
$this->ceil($n, 1); // '-123.3'
$this->ceil($n, 2); // '-123.44'
```
@param DecimalNumber $number Number to round
@param int $precision Maximum number of decimals
@return DecimalNumber | [
"Rounds",
"a",
"number",
"up",
"if",
"its",
"precision",
"is",
"greater",
"than",
"the",
"target",
"one",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L112-L147 |
229,296 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.floor | public function floor(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if ($number->isPositive()) {
// floor works exactly as truncate for positive numbers
return $this->truncate($number, $precision);
}
/**
* The principle for ceil is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
*
* if D < 0, ceil(X, P) = truncate(X - 10^(-P), P)
* if D = 0, ceil(X, P) = truncate(X, P)
*/
if ($precision > 0) {
// we know that D > 0, because we have already checked that the number's precision
// is greater than the target precision
$numberToSubtract = '0.' . str_pad('1', $precision, '0', STR_PAD_LEFT);
} else {
$numberToSubtract = '1';
}
return $this
->truncate($number, $precision)
->minus(new DecimalNumber($numberToSubtract));
} | php | public function floor(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
if ($number->isPositive()) {
// floor works exactly as truncate for positive numbers
return $this->truncate($number, $precision);
}
/**
* The principle for ceil is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
*
* if D < 0, ceil(X, P) = truncate(X - 10^(-P), P)
* if D = 0, ceil(X, P) = truncate(X, P)
*/
if ($precision > 0) {
// we know that D > 0, because we have already checked that the number's precision
// is greater than the target precision
$numberToSubtract = '0.' . str_pad('1', $precision, '0', STR_PAD_LEFT);
} else {
$numberToSubtract = '1';
}
return $this
->truncate($number, $precision)
->minus(new DecimalNumber($numberToSubtract));
} | [
"public",
"function",
"floor",
"(",
"DecimalNumber",
"$",
"number",
",",
"$",
"precision",
")",
"{",
"$",
"precision",
"=",
"$",
"this",
"->",
"sanitizePrecision",
"(",
"$",
"precision",
")",
";",
"if",
"(",
"$",
"number",
"->",
"getPrecision",
"(",
")",... | Rounds a number down if its precision is greater than the target one.
Floor always rounds towards negative infinity.
Examples:
```
$n = new Decimal\Number('123.456');
$this->floor($n, 0); // '123'
$this->floor($n, 1); // '123.4'
$this->floor($n, 2); // '123.45'
$n = new Decimal\Number('-123.456');
$this->floor($n, 0); // '-124'
$this->floor($n, 1); // '-123.5'
$this->floor($n, 2); // '-123.46'
```
@param DecimalNumber $number Number to round
@param int $precision Maximum number of decimals
@return DecimalNumber | [
"Rounds",
"a",
"number",
"down",
"if",
"its",
"precision",
"is",
"greater",
"than",
"the",
"target",
"one",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L173-L208 |
229,297 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.roundHalfEven | public function roundHalfEven(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
/**
* The principle for roundHalfEven is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
* E = digit to the left of D
*
* if D != 5, roundHalfEven(X, P) = roundHalfUp(X, P)
* if D = 5 and E is even, roundHalfEven(X, P) = truncate(X, P)
* if D = 5 and E is odd and X is positive, roundHalfUp(X, P) = ceil(X, P)
* if D = 5 and E is odd and X is negative, roundHalfUp(X, P) = floor(X, P)
*/
$fractionalPart = $number->getFractionalPart();
$digit = (int) $fractionalPart[$precision];
if ($digit !== 5) {
return $this->roundHalfUp($number, $precision);
}
// retrieve the digit to the left of it
if ($precision === 0) {
$referenceDigit = (int) substr($number->getIntegerPart(), -1);
} else {
$referenceDigit = (int) $fractionalPart[$precision - 1];
}
// truncate if even
$isEven = $referenceDigit % 2 === 0;
if ($isEven) {
return $this->truncate($number, $precision);
}
// round away from zero
$method = ($number->isPositive()) ? self::ROUND_CEIL : self::ROUND_FLOOR;
return $this->compute($number, $precision, $method);
} | php | public function roundHalfEven(DecimalNumber $number, $precision)
{
$precision = $this->sanitizePrecision($precision);
if ($number->getPrecision() <= $precision) {
return $number;
}
/**
* The principle for roundHalfEven is the following:
*
* let X = number to round
* P = number of decimal digits that we want
* D = digit from the fractional part at index P
* E = digit to the left of D
*
* if D != 5, roundHalfEven(X, P) = roundHalfUp(X, P)
* if D = 5 and E is even, roundHalfEven(X, P) = truncate(X, P)
* if D = 5 and E is odd and X is positive, roundHalfUp(X, P) = ceil(X, P)
* if D = 5 and E is odd and X is negative, roundHalfUp(X, P) = floor(X, P)
*/
$fractionalPart = $number->getFractionalPart();
$digit = (int) $fractionalPart[$precision];
if ($digit !== 5) {
return $this->roundHalfUp($number, $precision);
}
// retrieve the digit to the left of it
if ($precision === 0) {
$referenceDigit = (int) substr($number->getIntegerPart(), -1);
} else {
$referenceDigit = (int) $fractionalPart[$precision - 1];
}
// truncate if even
$isEven = $referenceDigit % 2 === 0;
if ($isEven) {
return $this->truncate($number, $precision);
}
// round away from zero
$method = ($number->isPositive()) ? self::ROUND_CEIL : self::ROUND_FLOOR;
return $this->compute($number, $precision, $method);
} | [
"public",
"function",
"roundHalfEven",
"(",
"DecimalNumber",
"$",
"number",
",",
"$",
"precision",
")",
"{",
"$",
"precision",
"=",
"$",
"this",
"->",
"sanitizePrecision",
"(",
"$",
"precision",
")",
";",
"if",
"(",
"$",
"number",
"->",
"getPrecision",
"("... | Rounds a number according to "banker's rounding".
The number is rounded according to the digit D located at precision P.
- Away from zero if D > 5
- Towards zero if D < 5
- if D = 5, then
- If the last significant digit is even, the number is rounded away from zero
- If the last significant digit is odd, the number is rounded towards zero.
Examples:
```
$n = new Decimal\Number('123.456');
$this->roundHalfUp($n, 0); // '123'
$this->roundHalfUp($n, 1); // '123.4'
$this->roundHalfUp($n, 2); // '123.46'
$n = new Decimal\Number('-123.456');
$this->roundHalfUp($n, 0); // '-123'
$this->roundHalfUp($n, 1); // '-123.4'
$this->roundHalfUp($n, 2); // '-123.46'
$n = new Decimal\Number('1.1525354556575859505');
$this->roundHalfEven($n, 0); // '1'
$this->roundHalfEven($n, 1); // '1.2'
$this->roundHalfEven($n, 2); // '1.15'
$this->roundHalfEven($n, 3); // '1.152'
$this->roundHalfEven($n, 4); // '1.1525'
$this->roundHalfEven($n, 5); // '1.15255'
$this->roundHalfEven($n, 6); // '1.152535'
$this->roundHalfEven($n, 7); // '1.1525354'
$this->roundHalfEven($n, 8); // '1.15253546'
$this->roundHalfEven($n, 9); // '1.152535456'
$this->roundHalfEven($n, 10); // '1.1525354556'
```
@param DecimalNumber $number Number to round
@param int $precision Maximum number of decimals
@return DecimalNumber | [
"Rounds",
"a",
"number",
"according",
"to",
"banker",
"s",
"rounding",
"."
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L310-L356 |
229,298 | PrestaShop/decimal | src/Operation/Rounding.php | Rounding.sanitizePrecision | private function sanitizePrecision($precision)
{
if (!is_numeric($precision) || $precision < 0) {
throw new \InvalidArgumentException(sprintf('Invalid precision: %s', print_r($precision, true)));
}
return (int) $precision;
} | php | private function sanitizePrecision($precision)
{
if (!is_numeric($precision) || $precision < 0) {
throw new \InvalidArgumentException(sprintf('Invalid precision: %s', print_r($precision, true)));
}
return (int) $precision;
} | [
"private",
"function",
"sanitizePrecision",
"(",
"$",
"precision",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"precision",
")",
"||",
"$",
"precision",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Inva... | Ensures that precision is a positive int
@param mixed $precision
@return int Precision
@throws \InvalidArgumentException if precision is not a positive integer | [
"Ensures",
"that",
"precision",
"is",
"a",
"positive",
"int"
] | 42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f | https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Operation/Rounding.php#L412-L419 |
229,299 | slickframework/slick | src/Slick/Di/Resolver/ObjectResolver.php | ObjectResolver._createInstance | protected function _createInstance(
ObjectDefinition $definition, array $parameters)
{
$classReflection = new ReflectionClass($definition->getClassName());
$args = $this->_getMethodParameters(
$definition->getConstructor(),
$classReflection->getConstructor(),
$parameters
);
return $classReflection->newInstanceArgs($args);
} | php | protected function _createInstance(
ObjectDefinition $definition, array $parameters)
{
$classReflection = new ReflectionClass($definition->getClassName());
$args = $this->_getMethodParameters(
$definition->getConstructor(),
$classReflection->getConstructor(),
$parameters
);
return $classReflection->newInstanceArgs($args);
} | [
"protected",
"function",
"_createInstance",
"(",
"ObjectDefinition",
"$",
"definition",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"classReflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"definition",
"->",
"getClassName",
"(",
")",
")",
";",
"$",
"ar... | Creates an instance of the class and injects dependencies.
@param ObjectDefinition $definition
@param array $parameters Optional parameters to use to create
the instance.
@throws NotFoundException If class in definition is not found
@return object | [
"Creates",
"an",
"instance",
"of",
"the",
"class",
"and",
"injects",
"dependencies",
"."
] | 77f56b81020ce8c10f25f7d918661ccd9a918a37 | https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Resolver/ObjectResolver.php#L97-L109 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.