repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.collectClassData | protected function collectClassData($item, array $data, \ReflectionClass $reflector): array
{
foreach ($this->getClassVariants($reflector, $item) as $name)
{
$key = $this->getItemKey($name);
if (!array_key_exists($key, $data['data']) || $this->isItemGreedy($data['data'][$key], $reflector, $item))
$data = $this->addClassData($data, $key, $reflector, $item, $name);
}
return $data;
} | php | protected function collectClassData($item, array $data, \ReflectionClass $reflector): array
{
foreach ($this->getClassVariants($reflector, $item) as $name)
{
$key = $this->getItemKey($name);
if (!array_key_exists($key, $data['data']) || $this->isItemGreedy($data['data'][$key], $reflector, $item))
$data = $this->addClassData($data, $key, $reflector, $item, $name);
}
return $data;
} | [
"protected",
"function",
"collectClassData",
"(",
"$",
"item",
",",
"array",
"$",
"data",
",",
"\\",
"ReflectionClass",
"$",
"reflector",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getClassVariants",
"(",
"$",
"reflector",
",",
"$",
"item",
")",
"as",
"$",
"name",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getItemKey",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"data",
"[",
"'data'",
"]",
")",
"||",
"$",
"this",
"->",
"isItemGreedy",
"(",
"$",
"data",
"[",
"'data'",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"reflector",
",",
"$",
"item",
")",
")",
"$",
"data",
"=",
"$",
"this",
"->",
"addClassData",
"(",
"$",
"data",
",",
"$",
"key",
",",
"$",
"reflector",
",",
"$",
"item",
",",
"$",
"name",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Collect class data
@param object $item
@param array $data
@param \ReflectionClass $reflector
@return array | [
"Collect",
"class",
"data"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L91-L102 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.addClassData | protected function addClassData(array $data, string $key, \ReflectionClass $reflector, $item, $variant): array
{
$data['data'][$key] = $this->getClassData($reflector, $item, $variant);
return $data;
} | php | protected function addClassData(array $data, string $key, \ReflectionClass $reflector, $item, $variant): array
{
$data['data'][$key] = $this->getClassData($reflector, $item, $variant);
return $data;
} | [
"protected",
"function",
"addClassData",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"key",
",",
"\\",
"ReflectionClass",
"$",
"reflector",
",",
"$",
"item",
",",
"$",
"variant",
")",
":",
"array",
"{",
"$",
"data",
"[",
"'data'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"getClassData",
"(",
"$",
"reflector",
",",
"$",
"item",
",",
"$",
"variant",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Add class data
@param array $data
@param string $key
@param \ReflectionClass $reflector
@param object $item
@param mixed $variant
@return array | [
"Add",
"class",
"data"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L115-L120 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.isItemGreedy | protected function isItemGreedy(array $info, \ReflectionClass $reflector, $item): bool
{
$base = new \ReflectionClass($info['class']);
if ($reflector->isSubclassOf($base->getName()))
return true;
if (!$base->isSubclassOf($reflector->getName()))
throw new \LogicException('Class ' . var_export($reflector->getName(), true) . ' has no direct relation with class ' . var_export($base->getName(), true) . '. Use @easy-extend-base to create new branch.');
return false;
} | php | protected function isItemGreedy(array $info, \ReflectionClass $reflector, $item): bool
{
$base = new \ReflectionClass($info['class']);
if ($reflector->isSubclassOf($base->getName()))
return true;
if (!$base->isSubclassOf($reflector->getName()))
throw new \LogicException('Class ' . var_export($reflector->getName(), true) . ' has no direct relation with class ' . var_export($base->getName(), true) . '. Use @easy-extend-base to create new branch.');
return false;
} | [
"protected",
"function",
"isItemGreedy",
"(",
"array",
"$",
"info",
",",
"\\",
"ReflectionClass",
"$",
"reflector",
",",
"$",
"item",
")",
":",
"bool",
"{",
"$",
"base",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"info",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"$",
"reflector",
"->",
"isSubclassOf",
"(",
"$",
"base",
"->",
"getName",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"!",
"$",
"base",
"->",
"isSubclassOf",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
")",
")",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Class '",
".",
"var_export",
"(",
"$",
"reflector",
"->",
"getName",
"(",
")",
",",
"true",
")",
".",
"' has no direct relation with class '",
".",
"var_export",
"(",
"$",
"base",
"->",
"getName",
"(",
")",
",",
"true",
")",
".",
"'. Use @easy-extend-base to create new branch.'",
")",
";",
"return",
"false",
";",
"}"
] | Returns true if item is greedy
@param array $info
@param \ReflectionClass $reflector
@param object $item
@return bool | [
"Returns",
"true",
"if",
"item",
"is",
"greedy"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L162-L173 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.getClassBaseNames | protected function getClassBaseNames($item): array
{
$basenames = array();
$reflector = new \ReflectionClass($item);
do
{
if (!$reflector->isAbstract())
{
$docComment = $reflector->getDocComment();
if ($docComment && strpos($docComment, '@easy-extend-base') !== false)
{
$basenames[] = $reflector->getName();
return $basenames;
}
$basenames[] = $reflector->getName();
}
$parent = $reflector->getParentClass();
if (!$parent)
break;
$reflector = new \ReflectionClass($parent->getName());
}
while (true);
return $basenames;
} | php | protected function getClassBaseNames($item): array
{
$basenames = array();
$reflector = new \ReflectionClass($item);
do
{
if (!$reflector->isAbstract())
{
$docComment = $reflector->getDocComment();
if ($docComment && strpos($docComment, '@easy-extend-base') !== false)
{
$basenames[] = $reflector->getName();
return $basenames;
}
$basenames[] = $reflector->getName();
}
$parent = $reflector->getParentClass();
if (!$parent)
break;
$reflector = new \ReflectionClass($parent->getName());
}
while (true);
return $basenames;
} | [
"protected",
"function",
"getClassBaseNames",
"(",
"$",
"item",
")",
":",
"array",
"{",
"$",
"basenames",
"=",
"array",
"(",
")",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"item",
")",
";",
"do",
"{",
"if",
"(",
"!",
"$",
"reflector",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"docComment",
"=",
"$",
"reflector",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"$",
"docComment",
"&&",
"strpos",
"(",
"$",
"docComment",
",",
"'@easy-extend-base'",
")",
"!==",
"false",
")",
"{",
"$",
"basenames",
"[",
"]",
"=",
"$",
"reflector",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"basenames",
";",
"}",
"$",
"basenames",
"[",
"]",
"=",
"$",
"reflector",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"reflector",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parent",
")",
"break",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"parent",
"->",
"getName",
"(",
")",
")",
";",
"}",
"while",
"(",
"true",
")",
";",
"return",
"$",
"basenames",
";",
"}"
] | Get class base names
@param object $item
@return array | [
"Get",
"class",
"base",
"names"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L196-L226 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.getClassTraits | protected function getClassTraits(\ReflectionClass $reflector): array
{
$class = $reflector->getName();
$traits = array();
do
{
$traits = array_merge(class_uses($class), $traits);
}
while ($class = get_parent_class($class));
foreach ($traits as $trait)
$traits = array_merge(class_uses($trait), $traits);
return array_keys(array_unique($traits));
} | php | protected function getClassTraits(\ReflectionClass $reflector): array
{
$class = $reflector->getName();
$traits = array();
do
{
$traits = array_merge(class_uses($class), $traits);
}
while ($class = get_parent_class($class));
foreach ($traits as $trait)
$traits = array_merge(class_uses($trait), $traits);
return array_keys(array_unique($traits));
} | [
"protected",
"function",
"getClassTraits",
"(",
"\\",
"ReflectionClass",
"$",
"reflector",
")",
":",
"array",
"{",
"$",
"class",
"=",
"$",
"reflector",
"->",
"getName",
"(",
")",
";",
"$",
"traits",
"=",
"array",
"(",
")",
";",
"do",
"{",
"$",
"traits",
"=",
"array_merge",
"(",
"class_uses",
"(",
"$",
"class",
")",
",",
"$",
"traits",
")",
";",
"}",
"while",
"(",
"$",
"class",
"=",
"get_parent_class",
"(",
"$",
"class",
")",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"$",
"traits",
"=",
"array_merge",
"(",
"class_uses",
"(",
"$",
"trait",
")",
",",
"$",
"traits",
")",
";",
"return",
"array_keys",
"(",
"array_unique",
"(",
"$",
"traits",
")",
")",
";",
"}"
] | Get class traits
@param \ReflectionClass $reflector
@return array | [
"Get",
"class",
"traits"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L269-L285 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.getItemData | public function getItemData($name): array
{
if (func_num_args() > 1)
$name = func_get_args();
if (!$this->hasItemData($name))
return $this->getItemDataNotFound($name);
return $this->getData()[$this->getItemKey($name)];
} | php | public function getItemData($name): array
{
if (func_num_args() > 1)
$name = func_get_args();
if (!$this->hasItemData($name))
return $this->getItemDataNotFound($name);
return $this->getData()[$this->getItemKey($name)];
} | [
"public",
"function",
"getItemData",
"(",
"$",
"name",
")",
":",
"array",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"$",
"name",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasItemData",
"(",
"$",
"name",
")",
")",
"return",
"$",
"this",
"->",
"getItemDataNotFound",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"getData",
"(",
")",
"[",
"$",
"this",
"->",
"getItemKey",
"(",
"$",
"name",
")",
"]",
";",
"}"
] | Get item data
@param string|array $name
@return array | [
"Get",
"item",
"data"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L383-L392 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.hasItemData | public function hasItemData($name): bool
{
if (func_num_args() > 1)
$name = func_get_args();
return array_key_exists($this->getItemKey($name), $this->getData());
} | php | public function hasItemData($name): bool
{
if (func_num_args() > 1)
$name = func_get_args();
return array_key_exists($this->getItemKey($name), $this->getData());
} | [
"public",
"function",
"hasItemData",
"(",
"$",
"name",
")",
":",
"bool",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"$",
"name",
"=",
"func_get_args",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"getItemKey",
"(",
"$",
"name",
")",
",",
"$",
"this",
"->",
"getData",
"(",
")",
")",
";",
"}"
] | Has item data
@param string|array $name
@return bool | [
"Has",
"item",
"data"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L401-L407 | train |
apishka/easy-extend | source/RouterAbstract.php | RouterAbstract.getItemKey | public function getItemKey($name): string
{
if (func_num_args() > 1)
$name = func_get_args();
if (is_array($name))
return implode('|', $name);
return (string) $name;
} | php | public function getItemKey($name): string
{
if (func_num_args() > 1)
$name = func_get_args();
if (is_array($name))
return implode('|', $name);
return (string) $name;
} | [
"public",
"function",
"getItemKey",
"(",
"$",
"name",
")",
":",
"string",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"$",
"name",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"return",
"implode",
"(",
"'|'",
",",
"$",
"name",
")",
";",
"return",
"(",
"string",
")",
"$",
"name",
";",
"}"
] | Returns item key
@param string|array $name
@return string | [
"Returns",
"item",
"key"
] | 5e5c63c2509377abc3db6956e353623683703e09 | https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/RouterAbstract.php#L416-L425 | train |
slickframework/form | src/Input/ValidationAwareMethods.php | ValidationAwareMethods.isValid | public function isValid()
{
$valid = $this->valid;
if ($this->isMultiple()) {
$valid = $this->isMultipleValid();
}
return $valid;
} | php | public function isValid()
{
$valid = $this->valid;
if ($this->isMultiple()) {
$valid = $this->isMultipleValid();
}
return $valid;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"valid",
"=",
"$",
"this",
"->",
"valid",
";",
"if",
"(",
"$",
"this",
"->",
"isMultiple",
"(",
")",
")",
"{",
"$",
"valid",
"=",
"$",
"this",
"->",
"isMultipleValid",
"(",
")",
";",
"}",
"return",
"$",
"valid",
";",
"}"
] | Check if the value is valid
The value should pass through all validators in the validation chain
@return boolean True if is valid, false otherwise | [
"Check",
"if",
"the",
"value",
"is",
"valid"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Input/ValidationAwareMethods.php#L64-L71 | train |
slickframework/form | src/Input/ValidationAwareMethods.php | ValidationAwareMethods.isMultipleValid | protected function isMultipleValid()
{
if (!$this->isRendering()) {
return empty($this->invalidInstances);
}
return ! in_array($this->getInstance(), $this->invalidInstances);
} | php | protected function isMultipleValid()
{
if (!$this->isRendering()) {
return empty($this->invalidInstances);
}
return ! in_array($this->getInstance(), $this->invalidInstances);
} | [
"protected",
"function",
"isMultipleValid",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRendering",
"(",
")",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"invalidInstances",
")",
";",
"}",
"return",
"!",
"in_array",
"(",
"$",
"this",
"->",
"getInstance",
"(",
")",
",",
"$",
"this",
"->",
"invalidInstances",
")",
";",
"}"
] | Validates when input is set to be multiple
@return bool | [
"Validates",
"when",
"input",
"is",
"set",
"to",
"be",
"multiple"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Input/ValidationAwareMethods.php#L78-L85 | train |
slickframework/form | src/Input/ValidationAwareMethods.php | ValidationAwareMethods.validateArray | protected function validateArray(array $values, $context)
{
foreach ($values as $key => $value) {
$valid = $this->getValidationChain()
->validates($value, $context);
if (!$valid) {
$this->setInvalid($key);
}
}
} | php | protected function validateArray(array $values, $context)
{
foreach ($values as $key => $value) {
$valid = $this->getValidationChain()
->validates($value, $context);
if (!$valid) {
$this->setInvalid($key);
}
}
} | [
"protected",
"function",
"validateArray",
"(",
"array",
"$",
"values",
",",
"$",
"context",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"valid",
"=",
"$",
"this",
"->",
"getValidationChain",
"(",
")",
"->",
"validates",
"(",
"$",
"value",
",",
"$",
"context",
")",
";",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"$",
"this",
"->",
"setInvalid",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}"
] | Validates input when is set to be multiple
@param array $values
@param array $context | [
"Validates",
"input",
"when",
"is",
"set",
"to",
"be",
"multiple"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Input/ValidationAwareMethods.php#L112-L121 | train |
slickframework/form | src/Input/ValidationAwareMethods.php | ValidationAwareMethods.addValidator | public function addValidator($validator, $message = null)
{
try {
$msg = $message;
if (is_array($message)) {
$msg = array_shift($message);
$this->context = $message;
}
$validator = StaticValidator::create($validator, $msg);
$this->getValidationChain()
->add($validator);
if ($validator instanceof NotEmpty) {
$this->setRequired(true);
}
} catch (ValidatorException $caught) {
throw new InvalidArgumentException(
$caught->getMessage(),
0,
$caught
);
}
return $this;
} | php | public function addValidator($validator, $message = null)
{
try {
$msg = $message;
if (is_array($message)) {
$msg = array_shift($message);
$this->context = $message;
}
$validator = StaticValidator::create($validator, $msg);
$this->getValidationChain()
->add($validator);
if ($validator instanceof NotEmpty) {
$this->setRequired(true);
}
} catch (ValidatorException $caught) {
throw new InvalidArgumentException(
$caught->getMessage(),
0,
$caught
);
}
return $this;
} | [
"public",
"function",
"addValidator",
"(",
"$",
"validator",
",",
"$",
"message",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"msg",
"=",
"$",
"message",
";",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"$",
"msg",
"=",
"array_shift",
"(",
"$",
"message",
")",
";",
"$",
"this",
"->",
"context",
"=",
"$",
"message",
";",
"}",
"$",
"validator",
"=",
"StaticValidator",
"::",
"create",
"(",
"$",
"validator",
",",
"$",
"msg",
")",
";",
"$",
"this",
"->",
"getValidationChain",
"(",
")",
"->",
"add",
"(",
"$",
"validator",
")",
";",
"if",
"(",
"$",
"validator",
"instanceof",
"NotEmpty",
")",
"{",
"$",
"this",
"->",
"setRequired",
"(",
"true",
")",
";",
"}",
"}",
"catch",
"(",
"ValidatorException",
"$",
"caught",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"caught",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"caught",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a validator to the validation chain
The validator param could be a known validator alias, a FQ
ValidatorInterface class name or an object implementing
ValidatorInterface.
@param string|ValidatorInterface $validator
@param string|array $message Error message and possible contexts
variables.
@return self|$this|ValidationAwareInterface|ElementInterface
@throws InvalidArgumentException If the provided validator is an unknown
validator alias or not a valid class name or the object passed
does not implement the ValidatorInterface interface. | [
"Adds",
"a",
"validator",
"to",
"the",
"validation",
"chain"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Input/ValidationAwareMethods.php#L179-L201 | train |
air-php/http | src/Request/Request.php | Request.getReferer | public function getReferer()
{
$referer = null;
if (array_key_exists(self::REFERER_KEY, $this->serverData)) {
$referer = $this->serverData[self::REFERER_KEY];
}
return $referer;
} | php | public function getReferer()
{
$referer = null;
if (array_key_exists(self::REFERER_KEY, $this->serverData)) {
$referer = $this->serverData[self::REFERER_KEY];
}
return $referer;
} | [
"public",
"function",
"getReferer",
"(",
")",
"{",
"$",
"referer",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"REFERER_KEY",
",",
"$",
"this",
"->",
"serverData",
")",
")",
"{",
"$",
"referer",
"=",
"$",
"this",
"->",
"serverData",
"[",
"self",
"::",
"REFERER_KEY",
"]",
";",
"}",
"return",
"$",
"referer",
";",
"}"
] | Get the HTTP REFERER from the server data.
@return string|null The referer or null if not found. | [
"Get",
"the",
"HTTP",
"REFERER",
"from",
"the",
"server",
"data",
"."
] | 213c02e537cea3d949cc8dbb1218c60c070fce8a | https://github.com/air-php/http/blob/213c02e537cea3d949cc8dbb1218c60c070fce8a/src/Request/Request.php#L176-L185 | train |
hummer2k/ConLayout | src/Zdt/Collector/LayoutCollector.php | LayoutCollector.collect | public function collect(MvcEvent $mvcEvent)
{
$layout = $mvcEvent->getViewModel();
$blocks = [];
foreach ($this->layout->getBlocks() as $blockId => $block) {
if ($parentBlock = $block->getOption('parent')) {
$captureTo = $parentBlock . '::' . $block->captureTo();
} else {
$captureTo = $block->captureTo();
}
$blocks[$blockId] = [
'instance' => $block,
'template' => $this->resolveTemplate($block->getTemplate()),
'capture_to' => $captureTo,
'class' => get_class($block)
];
}
$data = [
'handles' => $this->updater->getHandles(true),
'layout_structure' => $this->updater->getLayoutStructure()->toArray(),
'blocks' => $blocks,
'layout_template' => $layout->getTemplate(),
'current_area' => $this->updater->getArea()
];
$this->data = $data;
return $this;
} | php | public function collect(MvcEvent $mvcEvent)
{
$layout = $mvcEvent->getViewModel();
$blocks = [];
foreach ($this->layout->getBlocks() as $blockId => $block) {
if ($parentBlock = $block->getOption('parent')) {
$captureTo = $parentBlock . '::' . $block->captureTo();
} else {
$captureTo = $block->captureTo();
}
$blocks[$blockId] = [
'instance' => $block,
'template' => $this->resolveTemplate($block->getTemplate()),
'capture_to' => $captureTo,
'class' => get_class($block)
];
}
$data = [
'handles' => $this->updater->getHandles(true),
'layout_structure' => $this->updater->getLayoutStructure()->toArray(),
'blocks' => $blocks,
'layout_template' => $layout->getTemplate(),
'current_area' => $this->updater->getArea()
];
$this->data = $data;
return $this;
} | [
"public",
"function",
"collect",
"(",
"MvcEvent",
"$",
"mvcEvent",
")",
"{",
"$",
"layout",
"=",
"$",
"mvcEvent",
"->",
"getViewModel",
"(",
")",
";",
"$",
"blocks",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"layout",
"->",
"getBlocks",
"(",
")",
"as",
"$",
"blockId",
"=>",
"$",
"block",
")",
"{",
"if",
"(",
"$",
"parentBlock",
"=",
"$",
"block",
"->",
"getOption",
"(",
"'parent'",
")",
")",
"{",
"$",
"captureTo",
"=",
"$",
"parentBlock",
".",
"'::'",
".",
"$",
"block",
"->",
"captureTo",
"(",
")",
";",
"}",
"else",
"{",
"$",
"captureTo",
"=",
"$",
"block",
"->",
"captureTo",
"(",
")",
";",
"}",
"$",
"blocks",
"[",
"$",
"blockId",
"]",
"=",
"[",
"'instance'",
"=>",
"$",
"block",
",",
"'template'",
"=>",
"$",
"this",
"->",
"resolveTemplate",
"(",
"$",
"block",
"->",
"getTemplate",
"(",
")",
")",
",",
"'capture_to'",
"=>",
"$",
"captureTo",
",",
"'class'",
"=>",
"get_class",
"(",
"$",
"block",
")",
"]",
";",
"}",
"$",
"data",
"=",
"[",
"'handles'",
"=>",
"$",
"this",
"->",
"updater",
"->",
"getHandles",
"(",
"true",
")",
",",
"'layout_structure'",
"=>",
"$",
"this",
"->",
"updater",
"->",
"getLayoutStructure",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"'blocks'",
"=>",
"$",
"blocks",
",",
"'layout_template'",
"=>",
"$",
"layout",
"->",
"getTemplate",
"(",
")",
",",
"'current_area'",
"=>",
"$",
"this",
"->",
"updater",
"->",
"getArea",
"(",
")",
"]",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] | collect data for zdt
@param MvcEvent $mvcEvent
@return LayoutCollector | [
"collect",
"data",
"for",
"zdt"
] | 15e472eaabc9b23ec6a5547524874e30d95e8d3e | https://github.com/hummer2k/ConLayout/blob/15e472eaabc9b23ec6a5547524874e30d95e8d3e/src/Zdt/Collector/LayoutCollector.php#L77-L104 | train |
hummer2k/ConLayout | src/Zdt/Collector/LayoutCollector.php | LayoutCollector.resolveTemplate | private function resolveTemplate($template)
{
$template = str_replace(
getcwd(),
'',
$this->viewResolver->resolve($template)
);
return $template;
} | php | private function resolveTemplate($template)
{
$template = str_replace(
getcwd(),
'',
$this->viewResolver->resolve($template)
);
return $template;
} | [
"private",
"function",
"resolveTemplate",
"(",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"str_replace",
"(",
"getcwd",
"(",
")",
",",
"''",
",",
"$",
"this",
"->",
"viewResolver",
"->",
"resolve",
"(",
"$",
"template",
")",
")",
";",
"return",
"$",
"template",
";",
"}"
] | retrieve resolved template path
@param string $template
@return string | [
"retrieve",
"resolved",
"template",
"path"
] | 15e472eaabc9b23ec6a5547524874e30d95e8d3e | https://github.com/hummer2k/ConLayout/blob/15e472eaabc9b23ec6a5547524874e30d95e8d3e/src/Zdt/Collector/LayoutCollector.php#L112-L120 | train |
phPoirot/Stream | ResourceStream.php | ResourceStream.meta | function meta()
{
if (!$this->_rMetaInfo)
$this->_rMetaInfo = new MetaReaderOfPhpResource($this->getRHandler());
return $this->_rMetaInfo;
} | php | function meta()
{
if (!$this->_rMetaInfo)
$this->_rMetaInfo = new MetaReaderOfPhpResource($this->getRHandler());
return $this->_rMetaInfo;
} | [
"function",
"meta",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_rMetaInfo",
")",
"$",
"this",
"->",
"_rMetaInfo",
"=",
"new",
"MetaReaderOfPhpResource",
"(",
"$",
"this",
"->",
"getRHandler",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"_rMetaInfo",
";",
"}"
] | Meta Data About Handler
@return MetaReaderOfPhpResource|iMetaReaderOfPhpResource | [
"Meta",
"Data",
"About",
"Handler"
] | db448ee0528c2a5b07c594b8a30e2543fbc15f57 | https://github.com/phPoirot/Stream/blob/db448ee0528c2a5b07c594b8a30e2543fbc15f57/ResourceStream.php#L90-L96 | train |
phPoirot/Stream | ResourceStream.php | ResourceStream.removeFilter | function removeFilter(iFilterStream $filter)
{
$filterName = $filter->getLabel();
if (isset($this->attachedFilters[$filterName])) {
$filterRes = $this->attachedFilters[$filterName];
stream_filter_remove($filterRes);
unset($this->attachedFilters[$filterName]); // filter was removed
}
return $this;
} | php | function removeFilter(iFilterStream $filter)
{
$filterName = $filter->getLabel();
if (isset($this->attachedFilters[$filterName])) {
$filterRes = $this->attachedFilters[$filterName];
stream_filter_remove($filterRes);
unset($this->attachedFilters[$filterName]); // filter was removed
}
return $this;
} | [
"function",
"removeFilter",
"(",
"iFilterStream",
"$",
"filter",
")",
"{",
"$",
"filterName",
"=",
"$",
"filter",
"->",
"getLabel",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attachedFilters",
"[",
"$",
"filterName",
"]",
")",
")",
"{",
"$",
"filterRes",
"=",
"$",
"this",
"->",
"attachedFilters",
"[",
"$",
"filterName",
"]",
";",
"stream_filter_remove",
"(",
"$",
"filterRes",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"attachedFilters",
"[",
"$",
"filterName",
"]",
")",
";",
"// filter was removed",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove Given Filter From Resource
@param iFilterStream $filter
@return $this | [
"Remove",
"Given",
"Filter",
"From",
"Resource"
] | db448ee0528c2a5b07c594b8a30e2543fbc15f57 | https://github.com/phPoirot/Stream/blob/db448ee0528c2a5b07c594b8a30e2543fbc15f57/ResourceStream.php#L143-L154 | train |
austinkregel/formmodel | src/FormModel/Frameworks/Materialize.php | Materialize.select | public function select(array $configs, $options)
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainSelect(array_merge([
'id' => $this->genId($label),
], $configs), $options).(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$label.'">'.$this->inputToRead($label).'</label>').'
</div>
';
} | php | public function select(array $configs, $options)
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainSelect(array_merge([
'id' => $this->genId($label),
], $configs), $options).(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$label.'">'.$this->inputToRead($label).'</label>').'
</div>
';
} | [
"public",
"function",
"select",
"(",
"array",
"$",
"configs",
",",
"$",
"options",
")",
"{",
"$",
"label",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
"?",
"ucwords",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
":",
"''",
")",
";",
"return",
"'\n <div class=\"input-field\">\n '",
".",
"parent",
"::",
"plainSelect",
"(",
"array_merge",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"genId",
"(",
"$",
"label",
")",
",",
"]",
",",
"$",
"configs",
")",
",",
"$",
"options",
")",
".",
"(",
"empty",
"(",
"$",
"label",
")",
"|",
"(",
"substr",
"(",
"$",
"label",
",",
"0",
",",
"1",
")",
"==",
"'_'",
")",
"?",
"''",
":",
"'<label for=\"'",
".",
"$",
"label",
".",
"'\">'",
".",
"$",
"this",
"->",
"inputToRead",
"(",
"$",
"label",
")",
".",
"'</label>'",
")",
".",
"'\n </div>\n '",
";",
"}"
] | Generate a select.
@param array $configs
@param mixed $options
@return string | [
"Generate",
"a",
"select",
"."
] | 49943a8f563d2e9028f6bc992708e104f9be22e3 | https://github.com/austinkregel/formmodel/blob/49943a8f563d2e9028f6bc992708e104f9be22e3/src/FormModel/Frameworks/Materialize.php#L57-L69 | train |
austinkregel/formmodel | src/FormModel/Frameworks/Materialize.php | Materialize.textarea | public function textarea(array $options, $text = '')
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainTextarea(array_merge([
'class' => 'materialize-textarea',
'id' => $this->genId($label),
], $options), $text).'
'.(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$this->genId($label).'">'.$this->inputToRead($label).'</label>').'
</div>';
} | php | public function textarea(array $options, $text = '')
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainTextarea(array_merge([
'class' => 'materialize-textarea',
'id' => $this->genId($label),
], $options), $text).'
'.(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$this->genId($label).'">'.$this->inputToRead($label).'</label>').'
</div>';
} | [
"public",
"function",
"textarea",
"(",
"array",
"$",
"options",
",",
"$",
"text",
"=",
"''",
")",
"{",
"$",
"label",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
"?",
"ucwords",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
":",
"''",
")",
";",
"return",
"'\n <div class=\"input-field\">\n '",
".",
"parent",
"::",
"plainTextarea",
"(",
"array_merge",
"(",
"[",
"'class'",
"=>",
"'materialize-textarea'",
",",
"'id'",
"=>",
"$",
"this",
"->",
"genId",
"(",
"$",
"label",
")",
",",
"]",
",",
"$",
"options",
")",
",",
"$",
"text",
")",
".",
"'\n '",
".",
"(",
"empty",
"(",
"$",
"label",
")",
"|",
"(",
"substr",
"(",
"$",
"label",
",",
"0",
",",
"1",
")",
"==",
"'_'",
")",
"?",
"''",
":",
"'<label for=\"'",
".",
"$",
"this",
"->",
"genId",
"(",
"$",
"label",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"inputToRead",
"(",
"$",
"label",
")",
".",
"'</label>'",
")",
".",
"'\n </div>'",
";",
"}"
] | Generate a textarea.
@param array $options
@param string $text
@return string | [
"Generate",
"a",
"textarea",
"."
] | 49943a8f563d2e9028f6bc992708e104f9be22e3 | https://github.com/austinkregel/formmodel/blob/49943a8f563d2e9028f6bc992708e104f9be22e3/src/FormModel/Frameworks/Materialize.php#L79-L92 | train |
austinkregel/formmodel | src/FormModel/Frameworks/Materialize.php | Materialize.input | public function input(array $options)
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainInput(array_merge([
'class' => 'validate',
'id' => $this->genId($label),
], $options)).(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$this->genId($label).'">'.$this->inputToRead($label).'</label>').'
</div>
';
} | php | public function input(array $options)
{
$label = (!empty($options['name']) ? ucwords($options['name']) : '');
return '
<div class="input-field">
'.parent::plainInput(array_merge([
'class' => 'validate',
'id' => $this->genId($label),
], $options)).(empty($label) | (substr($label, 0,
1) == '_') ? '' : '<label for="'.$this->genId($label).'">'.$this->inputToRead($label).'</label>').'
</div>
';
} | [
"public",
"function",
"input",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"label",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
"?",
"ucwords",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
":",
"''",
")",
";",
"return",
"'\n <div class=\"input-field\">\n '",
".",
"parent",
"::",
"plainInput",
"(",
"array_merge",
"(",
"[",
"'class'",
"=>",
"'validate'",
",",
"'id'",
"=>",
"$",
"this",
"->",
"genId",
"(",
"$",
"label",
")",
",",
"]",
",",
"$",
"options",
")",
")",
".",
"(",
"empty",
"(",
"$",
"label",
")",
"|",
"(",
"substr",
"(",
"$",
"label",
",",
"0",
",",
"1",
")",
"==",
"'_'",
")",
"?",
"''",
":",
"'<label for=\"'",
".",
"$",
"this",
"->",
"genId",
"(",
"$",
"label",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"inputToRead",
"(",
"$",
"label",
")",
".",
"'</label>'",
")",
".",
"'\n </div>\n '",
";",
"}"
] | Generate an input area.
@param array $options
@return string | [
"Generate",
"an",
"input",
"area",
"."
] | 49943a8f563d2e9028f6bc992708e104f9be22e3 | https://github.com/austinkregel/formmodel/blob/49943a8f563d2e9028f6bc992708e104f9be22e3/src/FormModel/Frameworks/Materialize.php#L101-L114 | train |
PhoxPHP/Glider | src/Model/Model.php | Model.addPropertyIf | final public function addPropertyIf(Bool $condition=null, String $property, $value=null)
{
if ($condition == true) {
$this->softProperties[$property] = $value;
}
} | php | final public function addPropertyIf(Bool $condition=null, String $property, $value=null)
{
if ($condition == true) {
$this->softProperties[$property] = $value;
}
} | [
"final",
"public",
"function",
"addPropertyIf",
"(",
"Bool",
"$",
"condition",
"=",
"null",
",",
"String",
"$",
"property",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"condition",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"softProperties",
"[",
"$",
"property",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Adds a property to list of soft properties if condition is true.
@param $condition <Boolean>
@param $property <String>
@param $value <Mixed>
@access public
@return <void> | [
"Adds",
"a",
"property",
"to",
"list",
"of",
"soft",
"properties",
"if",
"condition",
"is",
"true",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Model/Model.php#L193-L198 | train |
PhoxPHP/Glider | src/Model/Model.php | Model.addPropertyIfNot | final public function addPropertyIfNot(Bool $condition=null, String $property, $value=null)
{
if ($condition == false) {
$this->softProperties[$property] = $value;
}
} | php | final public function addPropertyIfNot(Bool $condition=null, String $property, $value=null)
{
if ($condition == false) {
$this->softProperties[$property] = $value;
}
} | [
"final",
"public",
"function",
"addPropertyIfNot",
"(",
"Bool",
"$",
"condition",
"=",
"null",
",",
"String",
"$",
"property",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"condition",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"softProperties",
"[",
"$",
"property",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Adds a property to list of soft properties if condition is false.
@param $condition <Boolean>
@param $property <String>
@param $value <Mixed>
@access public
@return <void> | [
"Adds",
"a",
"property",
"to",
"list",
"of",
"soft",
"properties",
"if",
"condition",
"is",
"false",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Model/Model.php#L209-L214 | train |
PhoxPHP/Glider | src/Model/Model.php | Model.hasRelation | public function hasRelation(String $label) : Bool
{
if (isset($this->relations[$label])) {
return true;
}
return false;
} | php | public function hasRelation(String $label) : Bool
{
if (isset($this->relations[$label])) {
return true;
}
return false;
} | [
"public",
"function",
"hasRelation",
"(",
"String",
"$",
"label",
")",
":",
"Bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"relations",
"[",
"$",
"label",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if model is related to another model.
@param $label <String>
@access public
@return <Boolean> | [
"Checks",
"if",
"model",
"is",
"related",
"to",
"another",
"model",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Model/Model.php#L490-L497 | train |
PhoxPHP/Glider | src/Model/Model.php | Model.toSql | protected function toSql($fields=null) : QueryBuilder
{
$queryBuilder = $this->queryBuilder()
->select($fields)
->from($this->table);
$orderBy = [];
if (isset(Model::$findOptions['asc'])) {
$orderBy[] = Model::$findOptions['asc'] . ' ASC';
}
if (isset(Model::$findOptions['desc'])) {
$orderBy[] = Model::$findOptions['desc'] . ' DESC';
}
if (!empty($orderBy)) {
$queryBuilder->orderBy($orderBy);
}
if (isset(Model::$findOptions['limit'])) {
$limit = Model::$findOptions['limit'];
if (is_array($limit) && count($limit) > 1) {
$queryBuilder->limit($limit[0], $limit[1]);
}else{
$queryBuilder->limit($limit);
}
}
return $queryBuilder;
} | php | protected function toSql($fields=null) : QueryBuilder
{
$queryBuilder = $this->queryBuilder()
->select($fields)
->from($this->table);
$orderBy = [];
if (isset(Model::$findOptions['asc'])) {
$orderBy[] = Model::$findOptions['asc'] . ' ASC';
}
if (isset(Model::$findOptions['desc'])) {
$orderBy[] = Model::$findOptions['desc'] . ' DESC';
}
if (!empty($orderBy)) {
$queryBuilder->orderBy($orderBy);
}
if (isset(Model::$findOptions['limit'])) {
$limit = Model::$findOptions['limit'];
if (is_array($limit) && count($limit) > 1) {
$queryBuilder->limit($limit[0], $limit[1]);
}else{
$queryBuilder->limit($limit);
}
}
return $queryBuilder;
} | [
"protected",
"function",
"toSql",
"(",
"$",
"fields",
"=",
"null",
")",
":",
"QueryBuilder",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"queryBuilder",
"(",
")",
"->",
"select",
"(",
"$",
"fields",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"table",
")",
";",
"$",
"orderBy",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"Model",
"::",
"$",
"findOptions",
"[",
"'asc'",
"]",
")",
")",
"{",
"$",
"orderBy",
"[",
"]",
"=",
"Model",
"::",
"$",
"findOptions",
"[",
"'asc'",
"]",
".",
"' ASC'",
";",
"}",
"if",
"(",
"isset",
"(",
"Model",
"::",
"$",
"findOptions",
"[",
"'desc'",
"]",
")",
")",
"{",
"$",
"orderBy",
"[",
"]",
"=",
"Model",
"::",
"$",
"findOptions",
"[",
"'desc'",
"]",
".",
"' DESC'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"orderBy",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"orderBy",
"(",
"$",
"orderBy",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"Model",
"::",
"$",
"findOptions",
"[",
"'limit'",
"]",
")",
")",
"{",
"$",
"limit",
"=",
"Model",
"::",
"$",
"findOptions",
"[",
"'limit'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"limit",
")",
"&&",
"count",
"(",
"$",
"limit",
")",
">",
"1",
")",
"{",
"$",
"queryBuilder",
"->",
"limit",
"(",
"$",
"limit",
"[",
"0",
"]",
",",
"$",
"limit",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"queryBuilder",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
] | Returns a prepared query that will be used by other find methods.
@param $fields <Mixed>
@access protected
@static
@return <Object> <Kit\Glider\Query\Builder\QueryBuilder> | [
"Returns",
"a",
"prepared",
"query",
"that",
"will",
"be",
"used",
"by",
"other",
"find",
"methods",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Model/Model.php#L507-L538 | train |
PhoxPHP/Glider | src/Model/Model.php | Model.isAccessible | protected function isAccessible(String $property) : Bool
{
if (in_array($property, $this->accessibleProperties())) {
return true;
}
return false;
} | php | protected function isAccessible(String $property) : Bool
{
if (in_array($property, $this->accessibleProperties())) {
return true;
}
return false;
} | [
"protected",
"function",
"isAccessible",
"(",
"String",
"$",
"property",
")",
":",
"Bool",
"{",
"if",
"(",
"in_array",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"accessibleProperties",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if a property can be accessed.
@param $property <String>
@access protected
@return <Boolean> | [
"Checks",
"if",
"a",
"property",
"can",
"be",
"accessed",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Model/Model.php#L576-L583 | train |
alxmsl/Cli | source/CommandPosix.php | CommandPosix.getPostfix | private static function getPostfix(Option $Option) {
$postfix = '';
if ($Option->getType() == Option::TYPE_STRING) {
$postfix .= ':';
if (!$Option->isRequired()) {
$postfix .= ':';
}
}
return $postfix;
} | php | private static function getPostfix(Option $Option) {
$postfix = '';
if ($Option->getType() == Option::TYPE_STRING) {
$postfix .= ':';
if (!$Option->isRequired()) {
$postfix .= ':';
}
}
return $postfix;
} | [
"private",
"static",
"function",
"getPostfix",
"(",
"Option",
"$",
"Option",
")",
"{",
"$",
"postfix",
"=",
"''",
";",
"if",
"(",
"$",
"Option",
"->",
"getType",
"(",
")",
"==",
"Option",
"::",
"TYPE_STRING",
")",
"{",
"$",
"postfix",
".=",
"':'",
";",
"if",
"(",
"!",
"$",
"Option",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"postfix",
".=",
"':'",
";",
"}",
"}",
"return",
"$",
"postfix",
";",
"}"
] | Method to build getopt parameter postfix for option
@param Option $Option instance of option
@return string getopt parameter postfix for option | [
"Method",
"to",
"build",
"getopt",
"parameter",
"postfix",
"for",
"option"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/CommandPosix.php#L39-L48 | train |
alxmsl/Cli | source/CommandPosix.php | CommandPosix.getOptionsSearchStrings | private function getOptionsSearchStrings() {
if (empty($this->searchStringsCache)) {
$this->searchStringsCache = array(
0 => '',
1 => array(),
);
foreach ($this->parameters as $Option) {
$postfix = self::getPostfix($Option);
/** @var $Option Option */
$this->searchStringsCache[0] .= $Option->getShort() . $postfix;
$this->searchStringsCache[1][] = $Option->getLong() . $postfix;
}
}
return $this->searchStringsCache;
} | php | private function getOptionsSearchStrings() {
if (empty($this->searchStringsCache)) {
$this->searchStringsCache = array(
0 => '',
1 => array(),
);
foreach ($this->parameters as $Option) {
$postfix = self::getPostfix($Option);
/** @var $Option Option */
$this->searchStringsCache[0] .= $Option->getShort() . $postfix;
$this->searchStringsCache[1][] = $Option->getLong() . $postfix;
}
}
return $this->searchStringsCache;
} | [
"private",
"function",
"getOptionsSearchStrings",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"searchStringsCache",
")",
")",
"{",
"$",
"this",
"->",
"searchStringsCache",
"=",
"array",
"(",
"0",
"=>",
"''",
",",
"1",
"=>",
"array",
"(",
")",
",",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"Option",
")",
"{",
"$",
"postfix",
"=",
"self",
"::",
"getPostfix",
"(",
"$",
"Option",
")",
";",
"/** @var $Option Option */",
"$",
"this",
"->",
"searchStringsCache",
"[",
"0",
"]",
".=",
"$",
"Option",
"->",
"getShort",
"(",
")",
".",
"$",
"postfix",
";",
"$",
"this",
"->",
"searchStringsCache",
"[",
"1",
"]",
"[",
"]",
"=",
"$",
"Option",
"->",
"getLong",
"(",
")",
".",
"$",
"postfix",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"searchStringsCache",
";",
"}"
] | Method to get getopt parameters for command line parsing
@return array getopt parameters | [
"Method",
"to",
"get",
"getopt",
"parameters",
"for",
"command",
"line",
"parsing"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/CommandPosix.php#L54-L68 | train |
alxmsl/Cli | source/CommandPosix.php | CommandPosix.parse | public function parse($panic = false) {
list($shorts, $longs) = $this->getOptionsSearchStrings();
$options = getopt($shorts, $longs);
$Exception = null;
foreach ($this->parameters as $Option) {
/** @var $Option Option */
$short = $Option->getShort();
$long = $Option->getLong();
switch (true) {
case isset($options[$short]) && isset($options[$long]):
throw new DuplicateOptionException();
case isset($options[$short]):
$this->setOptionValue($Option, $this->getPreparedValue($options[$short]));
break;
case isset($options[$long]):
$this->setOptionValue($Option, $this->getPreparedValue($options[$long]));
break;
case $Option->isRequired():
$Exception = new RequiredOptionException($long);
}
}
if ($panic && !is_null($Exception)) {
throw $Exception;
}
} | php | public function parse($panic = false) {
list($shorts, $longs) = $this->getOptionsSearchStrings();
$options = getopt($shorts, $longs);
$Exception = null;
foreach ($this->parameters as $Option) {
/** @var $Option Option */
$short = $Option->getShort();
$long = $Option->getLong();
switch (true) {
case isset($options[$short]) && isset($options[$long]):
throw new DuplicateOptionException();
case isset($options[$short]):
$this->setOptionValue($Option, $this->getPreparedValue($options[$short]));
break;
case isset($options[$long]):
$this->setOptionValue($Option, $this->getPreparedValue($options[$long]));
break;
case $Option->isRequired():
$Exception = new RequiredOptionException($long);
}
}
if ($panic && !is_null($Exception)) {
throw $Exception;
}
} | [
"public",
"function",
"parse",
"(",
"$",
"panic",
"=",
"false",
")",
"{",
"list",
"(",
"$",
"shorts",
",",
"$",
"longs",
")",
"=",
"$",
"this",
"->",
"getOptionsSearchStrings",
"(",
")",
";",
"$",
"options",
"=",
"getopt",
"(",
"$",
"shorts",
",",
"$",
"longs",
")",
";",
"$",
"Exception",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"Option",
")",
"{",
"/** @var $Option Option */",
"$",
"short",
"=",
"$",
"Option",
"->",
"getShort",
"(",
")",
";",
"$",
"long",
"=",
"$",
"Option",
"->",
"getLong",
"(",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"isset",
"(",
"$",
"options",
"[",
"$",
"short",
"]",
")",
"&&",
"isset",
"(",
"$",
"options",
"[",
"$",
"long",
"]",
")",
":",
"throw",
"new",
"DuplicateOptionException",
"(",
")",
";",
"case",
"isset",
"(",
"$",
"options",
"[",
"$",
"short",
"]",
")",
":",
"$",
"this",
"->",
"setOptionValue",
"(",
"$",
"Option",
",",
"$",
"this",
"->",
"getPreparedValue",
"(",
"$",
"options",
"[",
"$",
"short",
"]",
")",
")",
";",
"break",
";",
"case",
"isset",
"(",
"$",
"options",
"[",
"$",
"long",
"]",
")",
":",
"$",
"this",
"->",
"setOptionValue",
"(",
"$",
"Option",
",",
"$",
"this",
"->",
"getPreparedValue",
"(",
"$",
"options",
"[",
"$",
"long",
"]",
")",
")",
";",
"break",
";",
"case",
"$",
"Option",
"->",
"isRequired",
"(",
")",
":",
"$",
"Exception",
"=",
"new",
"RequiredOptionException",
"(",
"$",
"long",
")",
";",
"}",
"}",
"if",
"(",
"$",
"panic",
"&&",
"!",
"is_null",
"(",
"$",
"Exception",
")",
")",
"{",
"throw",
"$",
"Exception",
";",
"}",
"}"
] | POSIX parse command line method
@param bool $panic throw exception about required option absence
@throws DuplicateOptionException when option value duplicated
@throws RequiredOptionException when required options is not set | [
"POSIX",
"parse",
"command",
"line",
"method"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/CommandPosix.php#L92-L117 | train |
alxmsl/Cli | source/CommandPosix.php | CommandPosix.displayHelp | public function displayHelp() {
$string = 'Using: ' . $this->script . ' ' . $this->command . ' ';
$where = array();
foreach ($this->parameters as $Option) {
/** @var $Option Option */
$short = $Option->getShort();
$long = $Option->getLong();
$temp = '-' . $short . '|--' . $long;
if (!$Option->isRequired()) {
$string .= '[' . $temp . '] ';
} else {
$string .= $temp . ' ';
}
$where[] = '-' . $short . ', --' . $long . ' - ' . $Option->getDescription();
}
$string .= "\n";
$string .= implode("\n", $where) . "\n";
echo $string;
exit(0);
} | php | public function displayHelp() {
$string = 'Using: ' . $this->script . ' ' . $this->command . ' ';
$where = array();
foreach ($this->parameters as $Option) {
/** @var $Option Option */
$short = $Option->getShort();
$long = $Option->getLong();
$temp = '-' . $short . '|--' . $long;
if (!$Option->isRequired()) {
$string .= '[' . $temp . '] ';
} else {
$string .= $temp . ' ';
}
$where[] = '-' . $short . ', --' . $long . ' - ' . $Option->getDescription();
}
$string .= "\n";
$string .= implode("\n", $where) . "\n";
echo $string;
exit(0);
} | [
"public",
"function",
"displayHelp",
"(",
")",
"{",
"$",
"string",
"=",
"'Using: '",
".",
"$",
"this",
"->",
"script",
".",
"' '",
".",
"$",
"this",
"->",
"command",
".",
"' '",
";",
"$",
"where",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"Option",
")",
"{",
"/** @var $Option Option */",
"$",
"short",
"=",
"$",
"Option",
"->",
"getShort",
"(",
")",
";",
"$",
"long",
"=",
"$",
"Option",
"->",
"getLong",
"(",
")",
";",
"$",
"temp",
"=",
"'-'",
".",
"$",
"short",
".",
"'|--'",
".",
"$",
"long",
";",
"if",
"(",
"!",
"$",
"Option",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"string",
".=",
"'['",
".",
"$",
"temp",
".",
"'] '",
";",
"}",
"else",
"{",
"$",
"string",
".=",
"$",
"temp",
".",
"' '",
";",
"}",
"$",
"where",
"[",
"]",
"=",
"'-'",
".",
"$",
"short",
".",
"', --'",
".",
"$",
"long",
".",
"' - '",
".",
"$",
"Option",
"->",
"getDescription",
"(",
")",
";",
"}",
"$",
"string",
".=",
"\"\\n\"",
";",
"$",
"string",
".=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"where",
")",
".",
"\"\\n\"",
";",
"echo",
"$",
"string",
";",
"exit",
"(",
"0",
")",
";",
"}"
] | Display command help | [
"Display",
"command",
"help"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/CommandPosix.php#L122-L142 | train |
alxmsl/Cli | source/CommandPosix.php | CommandPosix.setOptionValue | private function setOptionValue(Option $Option, $value) {
$Option->setValue($value);
$long = $Option->getLong();
if (isset($this->events[$long])) {
$Handler = $this->events[$long];
$Handler($long, $value);
}
} | php | private function setOptionValue(Option $Option, $value) {
$Option->setValue($value);
$long = $Option->getLong();
if (isset($this->events[$long])) {
$Handler = $this->events[$long];
$Handler($long, $value);
}
} | [
"private",
"function",
"setOptionValue",
"(",
"Option",
"$",
"Option",
",",
"$",
"value",
")",
"{",
"$",
"Option",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"long",
"=",
"$",
"Option",
"->",
"getLong",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"long",
"]",
")",
")",
"{",
"$",
"Handler",
"=",
"$",
"this",
"->",
"events",
"[",
"$",
"long",
"]",
";",
"$",
"Handler",
"(",
"$",
"long",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Method to set option value and call event handler if needed
@param Option $Option instance of option
@param bool|string $value option value | [
"Method",
"to",
"set",
"option",
"value",
"and",
"call",
"event",
"handler",
"if",
"needed"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/CommandPosix.php#L149-L156 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.setAdapterAction | public function setAdapterAction($action)
{
if (true===$this->isInited) {
$this->resetOutput();
}
$this->__adapter_action = $action;
return $this;
} | php | public function setAdapterAction($action)
{
if (true===$this->isInited) {
$this->resetOutput();
}
$this->__adapter_action = $action;
return $this;
} | [
"public",
"function",
"setAdapterAction",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isInited",
")",
"{",
"$",
"this",
"->",
"resetOutput",
"(",
")",
";",
"}",
"$",
"this",
"->",
"__adapter_action",
"=",
"$",
"action",
";",
"return",
"$",
"this",
";",
"}"
] | Set the adapter action to process and reset the output
@param string $action The action name
@return self | [
"Set",
"the",
"adapter",
"action",
"to",
"process",
"and",
"reset",
"the",
"output"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L239-L246 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.addContent | public function addContent($str, $index = null)
{
if (!is_null($index)) {
$this->contents[$index] = $str;
} else {
$this->contents[] = $str;
}
return $this;
} | php | public function addContent($str, $index = null)
{
if (!is_null($index)) {
$this->contents[$index] = $str;
} else {
$this->contents[] = $str;
}
return $this;
} | [
"public",
"function",
"addContent",
"(",
"$",
"str",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"$",
"this",
"->",
"contents",
"[",
"$",
"index",
"]",
"=",
"$",
"str",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contents",
"[",
"]",
"=",
"$",
"str",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a raw content to treat
@param string $str the content to add
@param null/string $index the content index
@return self | [
"Add",
"a",
"raw",
"content",
"to",
"treat"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L279-L287 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.setDestinationFile | public function setDestinationFile($destination_file)
{
if (is_string($destination_file)) {
$this->destination_file = $destination_file;
} else {
if (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination file name must be a string (got "%s")!', gettype($destination_file))
);
}
}
return $this;
} | php | public function setDestinationFile($destination_file)
{
if (is_string($destination_file)) {
$this->destination_file = $destination_file;
} else {
if (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination file name must be a string (got "%s")!', gettype($destination_file))
);
}
}
return $this;
} | [
"public",
"function",
"setDestinationFile",
"(",
"$",
"destination_file",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"destination_file",
")",
")",
"{",
"$",
"this",
"->",
"destination_file",
"=",
"$",
"destination_file",
";",
"}",
"else",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'[Compressor] Destination file name must be a string (got \"%s\")!'",
",",
"gettype",
"(",
"$",
"destination_file",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the destination file to write the result in
@param string $destination_file The file path or name to create and write in
@return self
@throws \InvalidArgumentException if the file name is not a string (and if $silent==false) | [
"Set",
"the",
"destination",
"file",
"to",
"write",
"the",
"result",
"in"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L351-L363 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.guessDestinationFilename | public function guessDestinationFilename()
{
if (!empty($this->files_stack)) {
$this->_cleanFilesStack();
$this->init();
$_fs = array();
foreach ($this->files_stack as $_file) {
$_fs[] = $_file->getFilename();
}
if (!empty($_fs)) {
sort($_fs);
$this->setDestinationFile(
md5(join('', $_fs))
.'_'.$this->__adapter_action
.'.'.$this->__adapter->file_extension
);
return $this->getDestinationFile();
}
}
if (false===$this->silent) {
throw new \RuntimeException(
'[Compressor] Destination filename can\'t be guessed because files stack is empty!'
);
}
return null;
} | php | public function guessDestinationFilename()
{
if (!empty($this->files_stack)) {
$this->_cleanFilesStack();
$this->init();
$_fs = array();
foreach ($this->files_stack as $_file) {
$_fs[] = $_file->getFilename();
}
if (!empty($_fs)) {
sort($_fs);
$this->setDestinationFile(
md5(join('', $_fs))
.'_'.$this->__adapter_action
.'.'.$this->__adapter->file_extension
);
return $this->getDestinationFile();
}
}
if (false===$this->silent) {
throw new \RuntimeException(
'[Compressor] Destination filename can\'t be guessed because files stack is empty!'
);
}
return null;
} | [
"public",
"function",
"guessDestinationFilename",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"files_stack",
")",
")",
"{",
"$",
"this",
"->",
"_cleanFilesStack",
"(",
")",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"$",
"_fs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"files_stack",
"as",
"$",
"_file",
")",
"{",
"$",
"_fs",
"[",
"]",
"=",
"$",
"_file",
"->",
"getFilename",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_fs",
")",
")",
"{",
"sort",
"(",
"$",
"_fs",
")",
";",
"$",
"this",
"->",
"setDestinationFile",
"(",
"md5",
"(",
"join",
"(",
"''",
",",
"$",
"_fs",
")",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"__adapter_action",
".",
"'.'",
".",
"$",
"this",
"->",
"__adapter",
"->",
"file_extension",
")",
";",
"return",
"$",
"this",
"->",
"getDestinationFile",
"(",
")",
";",
"}",
"}",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'[Compressor] Destination filename can\\'t be guessed because files stack is empty!'",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Build a destination filename based on the files stack names
@return string The file name built
@throws \RuntimeException if the files stack is empty (filename can not be guessed) | [
"Build",
"a",
"destination",
"filename",
"based",
"on",
"the",
"files",
"stack",
"names"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L381-L407 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.setDestinationDir | public function setDestinationDir($destination_dir)
{
if (is_string($destination_dir)) {
$destination_dir = realpath($destination_dir);
if (@file_exists($destination_dir) && @is_dir($destination_dir)) {
$this->destination_dir = rtrim($destination_dir, '/').'/';
} elseif (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination directory "%s" must exist!', $destination_dir)
);
}
} else {
if (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination directory must be a string (got "%s")!', gettype($destination_dir))
);
}
}
return $this;
} | php | public function setDestinationDir($destination_dir)
{
if (is_string($destination_dir)) {
$destination_dir = realpath($destination_dir);
if (@file_exists($destination_dir) && @is_dir($destination_dir)) {
$this->destination_dir = rtrim($destination_dir, '/').'/';
} elseif (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination directory "%s" must exist!', $destination_dir)
);
}
} else {
if (false===$this->silent) {
throw new \InvalidArgumentException(
sprintf('[Compressor] Destination directory must be a string (got "%s")!', gettype($destination_dir))
);
}
}
return $this;
} | [
"public",
"function",
"setDestinationDir",
"(",
"$",
"destination_dir",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"destination_dir",
")",
")",
"{",
"$",
"destination_dir",
"=",
"realpath",
"(",
"$",
"destination_dir",
")",
";",
"if",
"(",
"@",
"file_exists",
"(",
"$",
"destination_dir",
")",
"&&",
"@",
"is_dir",
"(",
"$",
"destination_dir",
")",
")",
"{",
"$",
"this",
"->",
"destination_dir",
"=",
"rtrim",
"(",
"$",
"destination_dir",
",",
"'/'",
")",
".",
"'/'",
";",
"}",
"elseif",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'[Compressor] Destination directory \"%s\" must exist!'",
",",
"$",
"destination_dir",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'[Compressor] Destination directory must be a string (got \"%s\")!'",
",",
"gettype",
"(",
"$",
"destination_dir",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the destination directory to write the destination file in
@param string $destination_dir The directory path to create the file in
@return self
@throws \InvalidArgumentException if the directory name is not a string (and if $silent==false) | [
"Set",
"the",
"destination",
"directory",
"to",
"write",
"the",
"destination",
"file",
"in"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L416-L435 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.getDestinationWebPath | public function getDestinationWebPath()
{
if (!empty($this->web_root_path)) {
return str_replace($this->web_root_path, '', $this->getDestinationRealPath());
} elseif (false===$this->silent) {
throw new \LogicException(
'[Compressor] Can\'t create web path because "web_root_path" is not defined!'
);
}
return null;
} | php | public function getDestinationWebPath()
{
if (!empty($this->web_root_path)) {
return str_replace($this->web_root_path, '', $this->getDestinationRealPath());
} elseif (false===$this->silent) {
throw new \LogicException(
'[Compressor] Can\'t create web path because "web_root_path" is not defined!'
);
}
return null;
} | [
"public",
"function",
"getDestinationWebPath",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"web_root_path",
")",
")",
"{",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"web_root_path",
",",
"''",
",",
"$",
"this",
"->",
"getDestinationRealPath",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'[Compressor] Can\\'t create web path because \"web_root_path\" is not defined!'",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the destination file path ready for web inclusion
@return string The file path to write in
@throws \LogicException if the web root path has not been set (and silent==false) | [
"Get",
"the",
"destination",
"file",
"path",
"ready",
"for",
"web",
"inclusion"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L491-L501 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.mustRefresh | public function mustRefresh()
{
if ($this->fileExists()) {
$this->_cleanFilesStack();
$_dest = new \SplFileInfo($this->getDestinationRealPath());
if (!empty($this->files_stack)) {
foreach ($this->files_stack as $_file) {
if ($_file->getMTime() > $_dest->getMTime()) {
return true;
}
}
return false;
}
}
return true;
} | php | public function mustRefresh()
{
if ($this->fileExists()) {
$this->_cleanFilesStack();
$_dest = new \SplFileInfo($this->getDestinationRealPath());
if (!empty($this->files_stack)) {
foreach ($this->files_stack as $_file) {
if ($_file->getMTime() > $_dest->getMTime()) {
return true;
}
}
return false;
}
}
return true;
} | [
"public",
"function",
"mustRefresh",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fileExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_cleanFilesStack",
"(",
")",
";",
"$",
"_dest",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"this",
"->",
"getDestinationRealPath",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"files_stack",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"files_stack",
"as",
"$",
"_file",
")",
"{",
"if",
"(",
"$",
"_file",
"->",
"getMTime",
"(",
")",
">",
"$",
"_dest",
"->",
"getMTime",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if a destination file already exist for the current object and if it is fresher than sources
@return bool True if the sources had been modified after minified file creation | [
"Check",
"if",
"a",
"destination",
"file",
"already",
"exist",
"for",
"the",
"current",
"object",
"and",
"if",
"it",
"is",
"fresher",
"than",
"sources"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L531-L546 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor.process | public function process()
{
$this->_cleanFilesStack();
$this->init();
if (empty($this->destination_file) && false===$this->direct_output) {
$this->guessDestinationFilename();
}
if (!method_exists($this->__adapter, $this->__adapter_action)) {
throw new \RuntimeException(
sprintf('[Compressor] Action "%s" doesn\'t exist in "%s" adapter!', $this->__adapter_action, get_class($this->__adapter))
);
}
if (false===$this->direct_output) {
if (!$this->mustRefresh()) {
$this->output = file_get_contents($this->getDestinationRealPath());
return $this;
}
}
$this->prepare();
$stack = $this->getContents();
$contents = array();
foreach ($stack as $_name=>$_content) {
$contents[] = '';
$contents[] = $this->__adapter->buildComment($_name);
$contents[] = $this->__adapter->{$this->__adapter_action}($_content);
}
if (!empty($this->raw_header)) {
$this->output = $this->raw_header."\n";
}
$this->output .= implode("\n", $contents);
if (!empty($this->output) && false===$this->direct_output) {
$this->_writeDestinationFile();
}
return strlen($this->output);
} | php | public function process()
{
$this->_cleanFilesStack();
$this->init();
if (empty($this->destination_file) && false===$this->direct_output) {
$this->guessDestinationFilename();
}
if (!method_exists($this->__adapter, $this->__adapter_action)) {
throw new \RuntimeException(
sprintf('[Compressor] Action "%s" doesn\'t exist in "%s" adapter!', $this->__adapter_action, get_class($this->__adapter))
);
}
if (false===$this->direct_output) {
if (!$this->mustRefresh()) {
$this->output = file_get_contents($this->getDestinationRealPath());
return $this;
}
}
$this->prepare();
$stack = $this->getContents();
$contents = array();
foreach ($stack as $_name=>$_content) {
$contents[] = '';
$contents[] = $this->__adapter->buildComment($_name);
$contents[] = $this->__adapter->{$this->__adapter_action}($_content);
}
if (!empty($this->raw_header)) {
$this->output = $this->raw_header."\n";
}
$this->output .= implode("\n", $contents);
if (!empty($this->output) && false===$this->direct_output) {
$this->_writeDestinationFile();
}
return strlen($this->output);
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"this",
"->",
"_cleanFilesStack",
"(",
")",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"destination_file",
")",
"&&",
"false",
"===",
"$",
"this",
"->",
"direct_output",
")",
"{",
"$",
"this",
"->",
"guessDestinationFilename",
"(",
")",
";",
"}",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"__adapter",
",",
"$",
"this",
"->",
"__adapter_action",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'[Compressor] Action \"%s\" doesn\\'t exist in \"%s\" adapter!'",
",",
"$",
"this",
"->",
"__adapter_action",
",",
"get_class",
"(",
"$",
"this",
"->",
"__adapter",
")",
")",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"direct_output",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mustRefresh",
"(",
")",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"getDestinationRealPath",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}",
"}",
"$",
"this",
"->",
"prepare",
"(",
")",
";",
"$",
"stack",
"=",
"$",
"this",
"->",
"getContents",
"(",
")",
";",
"$",
"contents",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"stack",
"as",
"$",
"_name",
"=>",
"$",
"_content",
")",
"{",
"$",
"contents",
"[",
"]",
"=",
"''",
";",
"$",
"contents",
"[",
"]",
"=",
"$",
"this",
"->",
"__adapter",
"->",
"buildComment",
"(",
"$",
"_name",
")",
";",
"$",
"contents",
"[",
"]",
"=",
"$",
"this",
"->",
"__adapter",
"->",
"{",
"$",
"this",
"->",
"__adapter_action",
"}",
"(",
"$",
"_content",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"raw_header",
")",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"raw_header",
".",
"\"\\n\"",
";",
"}",
"$",
"this",
"->",
"output",
".=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"contents",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"output",
")",
"&&",
"false",
"===",
"$",
"this",
"->",
"direct_output",
")",
"{",
"$",
"this",
"->",
"_writeDestinationFile",
"(",
")",
";",
"}",
"return",
"strlen",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}"
] | Process the current files stack
@return self
@throws \RuntimeException | [
"Process",
"the",
"current",
"files",
"stack"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L576-L615 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor._cleanFilesStack | protected function _cleanFilesStack()
{
if (true===$this->isCleaned_files_stack) {
return;
}
$new_stack = array();
foreach ($this->files_stack as $_file) {
if (is_object($_file) && ($_file instanceof \SplFileInfo)) {
$new_stack[] = $_file;
} elseif (is_string($_file) && @file_exists($_file)) {
$new_stack[] = new \SplFileInfo($_file);
} elseif (false===$this->silent) {
throw new \RuntimeException(
sprintf('[Compressor] Source to process "%s" not found!', $_file)
);
}
}
$this->files_stack = $new_stack;
$this->isCleaned_files_stack = true;
} | php | protected function _cleanFilesStack()
{
if (true===$this->isCleaned_files_stack) {
return;
}
$new_stack = array();
foreach ($this->files_stack as $_file) {
if (is_object($_file) && ($_file instanceof \SplFileInfo)) {
$new_stack[] = $_file;
} elseif (is_string($_file) && @file_exists($_file)) {
$new_stack[] = new \SplFileInfo($_file);
} elseif (false===$this->silent) {
throw new \RuntimeException(
sprintf('[Compressor] Source to process "%s" not found!', $_file)
);
}
}
$this->files_stack = $new_stack;
$this->isCleaned_files_stack = true;
} | [
"protected",
"function",
"_cleanFilesStack",
"(",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isCleaned_files_stack",
")",
"{",
"return",
";",
"}",
"$",
"new_stack",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"files_stack",
"as",
"$",
"_file",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"_file",
")",
"&&",
"(",
"$",
"_file",
"instanceof",
"\\",
"SplFileInfo",
")",
")",
"{",
"$",
"new_stack",
"[",
"]",
"=",
"$",
"_file",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"_file",
")",
"&&",
"@",
"file_exists",
"(",
"$",
"_file",
")",
")",
"{",
"$",
"new_stack",
"[",
"]",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"_file",
")",
";",
"}",
"elseif",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'[Compressor] Source to process \"%s\" not found!'",
",",
"$",
"_file",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"files_stack",
"=",
"$",
"new_stack",
";",
"$",
"this",
"->",
"isCleaned_files_stack",
"=",
"true",
";",
"}"
] | Rebuild the current files stack as an array of File objects
@return void
@throws \RuntimeException if one of the files stack doesn't exist (and if $silent==false) | [
"Rebuild",
"the",
"current",
"files",
"stack",
"as",
"an",
"array",
"of",
"File",
"objects"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L659-L679 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor._guessAdapterType | protected function _guessAdapterType()
{
$this->_cleanFilesStack();
if (!empty($this->files_stack)) {
$_fs = $this->files_stack;
$_file = array_shift($_fs);
$this->setAdapterType($_file->getExtension());
return true;
} elseif (false===$this->silent) {
throw new \RuntimeException(
'[Compressor] Trying to guess adapter from an empty files stack!'
);
}
return false;
} | php | protected function _guessAdapterType()
{
$this->_cleanFilesStack();
if (!empty($this->files_stack)) {
$_fs = $this->files_stack;
$_file = array_shift($_fs);
$this->setAdapterType($_file->getExtension());
return true;
} elseif (false===$this->silent) {
throw new \RuntimeException(
'[Compressor] Trying to guess adapter from an empty files stack!'
);
}
return false;
} | [
"protected",
"function",
"_guessAdapterType",
"(",
")",
"{",
"$",
"this",
"->",
"_cleanFilesStack",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"files_stack",
")",
")",
"{",
"$",
"_fs",
"=",
"$",
"this",
"->",
"files_stack",
";",
"$",
"_file",
"=",
"array_shift",
"(",
"$",
"_fs",
")",
";",
"$",
"this",
"->",
"setAdapterType",
"(",
"$",
"_file",
"->",
"getExtension",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"elseif",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'[Compressor] Trying to guess adapter from an empty files stack!'",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Guess the adapter type based on extension of the first file in stack
@return bool True if the adapter type had been guessed
@throws \RuntimeException if no file was found in the stack | [
"Guess",
"the",
"adapter",
"type",
"based",
"on",
"extension",
"of",
"the",
"first",
"file",
"in",
"stack"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L687-L701 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor._writeDestinationFile | protected function _writeDestinationFile()
{
if (empty($this->destination_file)) {
$this->guessDestinationFilename();
}
$content = $this->_getHeaderComment()."\n".$this->output;
$dest_file = $this->getDestinationRealPath();
if (false!==file_put_contents($dest_file, $content)) {
return true;
} else {
if (false===$this->silent) {
throw new \RuntimeException(
sprintf('[Compressor] Destination compressed file "%s" can\'t be written on disk!', $dest_file)
);
}
return false;
}
} | php | protected function _writeDestinationFile()
{
if (empty($this->destination_file)) {
$this->guessDestinationFilename();
}
$content = $this->_getHeaderComment()."\n".$this->output;
$dest_file = $this->getDestinationRealPath();
if (false!==file_put_contents($dest_file, $content)) {
return true;
} else {
if (false===$this->silent) {
throw new \RuntimeException(
sprintf('[Compressor] Destination compressed file "%s" can\'t be written on disk!', $dest_file)
);
}
return false;
}
} | [
"protected",
"function",
"_writeDestinationFile",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"destination_file",
")",
")",
"{",
"$",
"this",
"->",
"guessDestinationFilename",
"(",
")",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"_getHeaderComment",
"(",
")",
".",
"\"\\n\"",
".",
"$",
"this",
"->",
"output",
";",
"$",
"dest_file",
"=",
"$",
"this",
"->",
"getDestinationRealPath",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"file_put_contents",
"(",
"$",
"dest_file",
",",
"$",
"content",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"silent",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'[Compressor] Destination compressed file \"%s\" can\\'t be written on disk!'",
",",
"$",
"dest_file",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"}"
] | Writes the compressed content in the destination file
@return bool|string The filename if it has been created, false otherwise
@throws \RuntimeException if the file can't be written | [
"Writes",
"the",
"compressed",
"content",
"in",
"the",
"destination",
"file"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L713-L731 | train |
atelierspierrot/templatengine | src/Assets/Compressor.php | Compressor._getHeaderComment | protected function _getHeaderComment()
{
$this->init();
return $this->__adapter->buildComment(
sprintf('Generated by %s class on %s at %s', __CLASS__, date('Y-m-d'), date('H:i'))
);
} | php | protected function _getHeaderComment()
{
$this->init();
return $this->__adapter->buildComment(
sprintf('Generated by %s class on %s at %s', __CLASS__, date('Y-m-d'), date('H:i'))
);
} | [
"protected",
"function",
"_getHeaderComment",
"(",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"return",
"$",
"this",
"->",
"__adapter",
"->",
"buildComment",
"(",
"sprintf",
"(",
"'Generated by %s class on %s at %s'",
",",
"__CLASS__",
",",
"date",
"(",
"'Y-m-d'",
")",
",",
"date",
"(",
"'H:i'",
")",
")",
")",
";",
"}"
] | Build the compressed content header comment information
@return string A comment string to write in top of the content | [
"Build",
"the",
"compressed",
"content",
"header",
"comment",
"information"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Compressor.php#L738-L744 | train |
acacha/forge-publish | src/Console/Commands/Traits/InteractsWithLocalGithub.php | InteractsWithLocalGithub.getRepoFromGithubConfig | protected function getRepoFromGithubConfig()
{
$remote = `git remote get-url origin 2> /dev/null`;
if (! starts_with($remote, ['git@github.com:','https://github.com/'])) {
return '';
}
if (starts_with($remote, 'git@github.com:')) {
// git@github.com:acacha/forge-publish.git
return explode('.', explode(":", $remote)[1])[0];
}
if (starts_with($remote, 'https://github.com/')) {
// https://github.com/acacha/llum.git
return explode('.', str_replace('https://github.com/', '', $remote))[0];
}
} | php | protected function getRepoFromGithubConfig()
{
$remote = `git remote get-url origin 2> /dev/null`;
if (! starts_with($remote, ['git@github.com:','https://github.com/'])) {
return '';
}
if (starts_with($remote, 'git@github.com:')) {
// git@github.com:acacha/forge-publish.git
return explode('.', explode(":", $remote)[1])[0];
}
if (starts_with($remote, 'https://github.com/')) {
// https://github.com/acacha/llum.git
return explode('.', str_replace('https://github.com/', '', $remote))[0];
}
} | [
"protected",
"function",
"getRepoFromGithubConfig",
"(",
")",
"{",
"$",
"remote",
"=",
"`git remote get-url origin 2> /dev/null`",
";",
"if",
"(",
"!",
"starts_with",
"(",
"$",
"remote",
",",
"[",
"'git@github.com:'",
",",
"'https://github.com/'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"starts_with",
"(",
"$",
"remote",
",",
"'git@github.com:'",
")",
")",
"{",
"// git@github.com:acacha/forge-publish.git",
"return",
"explode",
"(",
"'.'",
",",
"explode",
"(",
"\":\"",
",",
"$",
"remote",
")",
"[",
"1",
"]",
")",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"starts_with",
"(",
"$",
"remote",
",",
"'https://github.com/'",
")",
")",
"{",
"// https://github.com/acacha/llum.git",
"return",
"explode",
"(",
"'.'",
",",
"str_replace",
"(",
"'https://github.com/'",
",",
"''",
",",
"$",
"remote",
")",
")",
"[",
"0",
"]",
";",
"}",
"}"
] | Get github repo from github.
@return string | [
"Get",
"github",
"repo",
"from",
"github",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/InteractsWithLocalGithub.php#L17-L32 | train |
pmdevelopment/tool-bundle | Framework/Utilities/CryptUtility.php | CryptUtility.encrypt | public static function encrypt($sValue, $sSecretKey, $migration = false)
{
if (empty($sValue)) {
return "";
}
if (true === $migration) {
$sSecretKey = substr($sSecretKey, 0, 30) . "\0\0";
} else {
$sSecretKey = substr($sSecretKey, 0, 32);
}
return rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, $sValue, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))), "\0");
} | php | public static function encrypt($sValue, $sSecretKey, $migration = false)
{
if (empty($sValue)) {
return "";
}
if (true === $migration) {
$sSecretKey = substr($sSecretKey, 0, 30) . "\0\0";
} else {
$sSecretKey = substr($sSecretKey, 0, 32);
}
return rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, $sValue, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))), "\0");
} | [
"public",
"static",
"function",
"encrypt",
"(",
"$",
"sValue",
",",
"$",
"sSecretKey",
",",
"$",
"migration",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sValue",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"migration",
")",
"{",
"$",
"sSecretKey",
"=",
"substr",
"(",
"$",
"sSecretKey",
",",
"0",
",",
"30",
")",
".",
"\"\\0\\0\"",
";",
"}",
"else",
"{",
"$",
"sSecretKey",
"=",
"substr",
"(",
"$",
"sSecretKey",
",",
"0",
",",
"32",
")",
";",
"}",
"return",
"rtrim",
"(",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"$",
"sSecretKey",
",",
"$",
"sValue",
",",
"MCRYPT_MODE_ECB",
",",
"mcrypt_create_iv",
"(",
"mcrypt_get_iv_size",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"MCRYPT_MODE_ECB",
")",
",",
"MCRYPT_RAND",
")",
")",
")",
",",
"\"\\0\"",
")",
";",
"}"
] | Encrypt Value by Key
@param string $sValue
@param string $sSecretKey
@param bool $migration Use old buggy key or not
@return string | [
"Encrypt",
"Value",
"by",
"Key"
] | 2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129 | https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/Utilities/CryptUtility.php#L27-L41 | train |
pmdevelopment/tool-bundle | Framework/Utilities/CryptUtility.php | CryptUtility.decrypt | public static function decrypt($sValue, $sSecretKey, $migration = false)
{
if (empty($sValue)) {
return "";
}
if (true === $migration) {
$sSecretKey = substr($sSecretKey, 0, 30) . "\0\0";
} else {
$sSecretKey = substr($sSecretKey, 0, 32);
}
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sValue), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)), "\0");
} | php | public static function decrypt($sValue, $sSecretKey, $migration = false)
{
if (empty($sValue)) {
return "";
}
if (true === $migration) {
$sSecretKey = substr($sSecretKey, 0, 30) . "\0\0";
} else {
$sSecretKey = substr($sSecretKey, 0, 32);
}
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sValue), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)), "\0");
} | [
"public",
"static",
"function",
"decrypt",
"(",
"$",
"sValue",
",",
"$",
"sSecretKey",
",",
"$",
"migration",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sValue",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"migration",
")",
"{",
"$",
"sSecretKey",
"=",
"substr",
"(",
"$",
"sSecretKey",
",",
"0",
",",
"30",
")",
".",
"\"\\0\\0\"",
";",
"}",
"else",
"{",
"$",
"sSecretKey",
"=",
"substr",
"(",
"$",
"sSecretKey",
",",
"0",
",",
"32",
")",
";",
"}",
"return",
"rtrim",
"(",
"mcrypt_decrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"$",
"sSecretKey",
",",
"base64_decode",
"(",
"$",
"sValue",
")",
",",
"MCRYPT_MODE_ECB",
",",
"mcrypt_create_iv",
"(",
"mcrypt_get_iv_size",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"MCRYPT_MODE_ECB",
")",
",",
"MCRYPT_RAND",
")",
")",
",",
"\"\\0\"",
")",
";",
"}"
] | Decrypt value by key
@param string $sValue
@param string $sSecretKey
@param bool $migration Use old buggy key or not
@return string | [
"Decrypt",
"value",
"by",
"key"
] | 2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129 | https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/Utilities/CryptUtility.php#L52-L65 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getContent | public function getContent()
{
$content = $this->getRawContent();
$content = apply_filters('the_content', $content);
$content = str_replace( ']]>', ']]>', $content);
return $content;
} | php | public function getContent()
{
$content = $this->getRawContent();
$content = apply_filters('the_content', $content);
$content = str_replace( ']]>', ']]>', $content);
return $content;
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getRawContent",
"(",
")",
";",
"$",
"content",
"=",
"apply_filters",
"(",
"'the_content'",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
"']]>'",
",",
"']]>'",
",",
"$",
"content",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Get the post content, formatted as HTML.
@return string | [
"Get",
"the",
"post",
"content",
"formatted",
"as",
"HTML",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L207-L214 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getExcerpt | public function getExcerpt($content = null)
{
$raw = $exc = $this->base->post_excerpt;
if (!strlen($exc)) {
$exc = $content === null ? $this->getRawContent() : $content;
$exc = strip_shortcodes($exc);
$exc = apply_filters('the_content', $exc);
$exc = str_replace(']]>', ']]>', $exc);
$exc = wp_trim_words(
$exc,
apply_filters('excerpt_length', 55),
apply_filters('excerpt_more', ' ' . '[…]')
);
}
return apply_filters('wp_trim_excerpt', $exc, $raw);
} | php | public function getExcerpt($content = null)
{
$raw = $exc = $this->base->post_excerpt;
if (!strlen($exc)) {
$exc = $content === null ? $this->getRawContent() : $content;
$exc = strip_shortcodes($exc);
$exc = apply_filters('the_content', $exc);
$exc = str_replace(']]>', ']]>', $exc);
$exc = wp_trim_words(
$exc,
apply_filters('excerpt_length', 55),
apply_filters('excerpt_more', ' ' . '[…]')
);
}
return apply_filters('wp_trim_excerpt', $exc, $raw);
} | [
"public",
"function",
"getExcerpt",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"$",
"raw",
"=",
"$",
"exc",
"=",
"$",
"this",
"->",
"base",
"->",
"post_excerpt",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"exc",
")",
")",
"{",
"$",
"exc",
"=",
"$",
"content",
"===",
"null",
"?",
"$",
"this",
"->",
"getRawContent",
"(",
")",
":",
"$",
"content",
";",
"$",
"exc",
"=",
"strip_shortcodes",
"(",
"$",
"exc",
")",
";",
"$",
"exc",
"=",
"apply_filters",
"(",
"'the_content'",
",",
"$",
"exc",
")",
";",
"$",
"exc",
"=",
"str_replace",
"(",
"']]>'",
",",
"']]>'",
",",
"$",
"exc",
")",
";",
"$",
"exc",
"=",
"wp_trim_words",
"(",
"$",
"exc",
",",
"apply_filters",
"(",
"'excerpt_length'",
",",
"55",
")",
",",
"apply_filters",
"(",
"'excerpt_more'",
",",
"' '",
".",
"'[…]'",
")",
")",
";",
"}",
"return",
"apply_filters",
"(",
"'wp_trim_excerpt'",
",",
"$",
"exc",
",",
"$",
"raw",
")",
";",
"}"
] | Get the post excerpt.
Adapted from wp_trim_excerpt() in wp-includes/formatting.php.
@param string|null $content Optional. Base content to use for excerpt
if post excerpt isn't defined. Defaults to
post content
@return string | [
"Get",
"the",
"post",
"excerpt",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L246-L263 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getFeaturedImage | public function getFeaturedImage()
{
if ($this->featuredImage === null) {
if ($imgId = get_post_thumbnail_id((int) $this->getId())) {
$this->featuredImage = $this->postFactory->create(get_post($imgId));
} else {
$this->featuredImage = false;
}
}
return $this->featuredImage;
} | php | public function getFeaturedImage()
{
if ($this->featuredImage === null) {
if ($imgId = get_post_thumbnail_id((int) $this->getId())) {
$this->featuredImage = $this->postFactory->create(get_post($imgId));
} else {
$this->featuredImage = false;
}
}
return $this->featuredImage;
} | [
"public",
"function",
"getFeaturedImage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"featuredImage",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"imgId",
"=",
"get_post_thumbnail_id",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"getId",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"featuredImage",
"=",
"$",
"this",
"->",
"postFactory",
"->",
"create",
"(",
"get_post",
"(",
"$",
"imgId",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"featuredImage",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"featuredImage",
";",
"}"
] | Get this Post's featured image.
@return \Tev\Post\Model\Attachment|false Featured image object, or false if not
set | [
"Get",
"this",
"Post",
"s",
"featured",
"image",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L282-L293 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getAuthor | public function getAuthor()
{
if ($this->author === null) {
$this->author = $this->authorFactory->create($this->getAuthorId());
}
return $this->author;
} | php | public function getAuthor()
{
if ($this->author === null) {
$this->author = $this->authorFactory->create($this->getAuthorId());
}
return $this->author;
} | [
"public",
"function",
"getAuthor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"author",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"author",
"=",
"$",
"this",
"->",
"authorFactory",
"->",
"create",
"(",
"$",
"this",
"->",
"getAuthorId",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"author",
";",
"}"
] | Get post author.
@return \Tev\Author\Model\Author | [
"Get",
"post",
"author",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L331-L338 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getParent | public function getParent()
{
if ($this->parent === null) {
if (($parentId = $this->getParentPostId()) !== null) {
$this->parent = $this->postFactory->create(get_post($parentId));
} else {
$this->parent = false;
}
}
return $this->parent ?: null;
} | php | public function getParent()
{
if ($this->parent === null) {
if (($parentId = $this->getParentPostId()) !== null) {
$this->parent = $this->postFactory->create(get_post($parentId));
} else {
$this->parent = false;
}
}
return $this->parent ?: null;
} | [
"public",
"function",
"getParent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"===",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"parentId",
"=",
"$",
"this",
"->",
"getParentPostId",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"$",
"this",
"->",
"postFactory",
"->",
"create",
"(",
"get_post",
"(",
"$",
"parentId",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"parent",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"parent",
"?",
":",
"null",
";",
"}"
] | Get the parent post, if set.
@return \Tev\Post\Model\AbstractPost|null | [
"Get",
"the",
"parent",
"post",
"if",
"set",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L355-L366 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getTermsFor | public function getTermsFor($taxonomy)
{
if (!($taxonomy instanceof Taxonomy)) {
$taxonomy = $this->taxonomyFactory->create($taxonomy);
}
return $taxonomy->getTermsForPost($this);
} | php | public function getTermsFor($taxonomy)
{
if (!($taxonomy instanceof Taxonomy)) {
$taxonomy = $this->taxonomyFactory->create($taxonomy);
}
return $taxonomy->getTermsForPost($this);
} | [
"public",
"function",
"getTermsFor",
"(",
"$",
"taxonomy",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"taxonomy",
"instanceof",
"Taxonomy",
")",
")",
"{",
"$",
"taxonomy",
"=",
"$",
"this",
"->",
"taxonomyFactory",
"->",
"create",
"(",
"$",
"taxonomy",
")",
";",
"}",
"return",
"$",
"taxonomy",
"->",
"getTermsForPost",
"(",
"$",
"this",
")",
";",
"}"
] | Get all terms for this post in the given taxonomy.
@param mixed|\Tev\Taxonomy\Model\Taxonomy $taxonomy Taxonomy name or object
@return \Tev\Term\Model\Term[] Array of terms | [
"Get",
"all",
"terms",
"for",
"this",
"post",
"in",
"the",
"given",
"taxonomy",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L442-L449 | train |
3ev/wordpress-core | src/Tev/Post/Model/AbstractPost.php | AbstractPost.getPostTypeObject | protected function getPostTypeObject()
{
if ($this->postTypeObj === null) {
$this->postTypeObj = get_post_type_object($this->getType());
}
return $this->postTypeObj;
} | php | protected function getPostTypeObject()
{
if ($this->postTypeObj === null) {
$this->postTypeObj = get_post_type_object($this->getType());
}
return $this->postTypeObj;
} | [
"protected",
"function",
"getPostTypeObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"postTypeObj",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"postTypeObj",
"=",
"get_post_type_object",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"postTypeObj",
";",
"}"
] | Get the post type object for this post.
Contains information about the post type of this post.
@return \stdClass | [
"Get",
"the",
"post",
"type",
"object",
"for",
"this",
"post",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Post/Model/AbstractPost.php#L494-L501 | train |
atelierspierrot/patterns | src/Patterns/Abstracts/AbstractView.php | AbstractView.getParams | public function getParams($alone = false)
{
if ($alone) {
return $this->params;
} else {
return array_merge($this->getDefaultViewParams(), $this->params);
}
} | php | public function getParams($alone = false)
{
if ($alone) {
return $this->params;
} else {
return array_merge($this->getDefaultViewParams(), $this->params);
}
} | [
"public",
"function",
"getParams",
"(",
"$",
"alone",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"alone",
")",
"{",
"return",
"$",
"this",
"->",
"params",
";",
"}",
"else",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getDefaultViewParams",
"(",
")",
",",
"$",
"this",
"->",
"params",
")",
";",
"}",
"}"
] | Get the parameters for the current view
@param bool $alone Get the stack of parameters without the default params (default is `false`)
@return array The array of parameters | [
"Get",
"the",
"parameters",
"for",
"the",
"current",
"view"
] | b7a8313e98bbfb6525e1672d0a726a1ead6f156e | https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Abstracts/AbstractView.php#L168-L175 | train |
YiMAproject/yimaAdminor | src/yimaAdminor/Mvc/OffCanvasAdminThemeResolver.php | OffCanvasAdminThemeResolver.getName | public function getName()
{
$name = false;
// - we are on admin
$sm = $this->themeLocator->getServiceLocator();
// get registered PermissionsManager service and retrieve plugin
$permissionsManager = $sm->get('yimaAuthorize.AuthServiceManager');
/** @var $permission \yimaAdminor\Auth\AuthService */
$permission = $permissionsManager->get('yima_adminor');
if (!$permission->identity()->hasAuthenticated())
// user not authorized to adminor
return false;
$config = $sm->get('config');
if (isset($config['yima_adminor']) && is_array($config['yima_adminor'])) {
$name = (isset($config['yima_adminor']['default_theme']))
? $config['yima_adminor']['default_theme']
: false;
}
return $name;
} | php | public function getName()
{
$name = false;
// - we are on admin
$sm = $this->themeLocator->getServiceLocator();
// get registered PermissionsManager service and retrieve plugin
$permissionsManager = $sm->get('yimaAuthorize.AuthServiceManager');
/** @var $permission \yimaAdminor\Auth\AuthService */
$permission = $permissionsManager->get('yima_adminor');
if (!$permission->identity()->hasAuthenticated())
// user not authorized to adminor
return false;
$config = $sm->get('config');
if (isset($config['yima_adminor']) && is_array($config['yima_adminor'])) {
$name = (isset($config['yima_adminor']['default_theme']))
? $config['yima_adminor']['default_theme']
: false;
}
return $name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"false",
";",
"// - we are on admin",
"$",
"sm",
"=",
"$",
"this",
"->",
"themeLocator",
"->",
"getServiceLocator",
"(",
")",
";",
"// get registered PermissionsManager service and retrieve plugin",
"$",
"permissionsManager",
"=",
"$",
"sm",
"->",
"get",
"(",
"'yimaAuthorize.AuthServiceManager'",
")",
";",
"/** @var $permission \\yimaAdminor\\Auth\\AuthService */",
"$",
"permission",
"=",
"$",
"permissionsManager",
"->",
"get",
"(",
"'yima_adminor'",
")",
";",
"if",
"(",
"!",
"$",
"permission",
"->",
"identity",
"(",
")",
"->",
"hasAuthenticated",
"(",
")",
")",
"// user not authorized to adminor",
"return",
"false",
";",
"$",
"config",
"=",
"$",
"sm",
"->",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'yima_adminor'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'yima_adminor'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"(",
"isset",
"(",
"$",
"config",
"[",
"'yima_adminor'",
"]",
"[",
"'default_theme'",
"]",
")",
")",
"?",
"$",
"config",
"[",
"'yima_adminor'",
"]",
"[",
"'default_theme'",
"]",
":",
"false",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Get default admin template name from merged config
@return bool | [
"Get",
"default",
"admin",
"template",
"name",
"from",
"merged",
"config"
] | 7a6c66e05aedaef8061c8998dfa44ac1ce9cc319 | https://github.com/YiMAproject/yimaAdminor/blob/7a6c66e05aedaef8061c8998dfa44ac1ce9cc319/src/yimaAdminor/Mvc/OffCanvasAdminThemeResolver.php#L25-L50 | train |
eloquent/endec | src/Base32/Base32DecodeTransform.php | Base32DecodeTransform.mapByte | protected function mapByte($data, $index)
{
$byte = ord($data[$index]);
if ($byte > 49) {
if ($byte < 56) {
return $byte - 24;
}
if ($byte > 64 && $byte < 91) {
return $byte - 65;
}
}
throw new InvalidEncodedDataException($this->key(), $data);
} | php | protected function mapByte($data, $index)
{
$byte = ord($data[$index]);
if ($byte > 49) {
if ($byte < 56) {
return $byte - 24;
}
if ($byte > 64 && $byte < 91) {
return $byte - 65;
}
}
throw new InvalidEncodedDataException($this->key(), $data);
} | [
"protected",
"function",
"mapByte",
"(",
"$",
"data",
",",
"$",
"index",
")",
"{",
"$",
"byte",
"=",
"ord",
"(",
"$",
"data",
"[",
"$",
"index",
"]",
")",
";",
"if",
"(",
"$",
"byte",
">",
"49",
")",
"{",
"if",
"(",
"$",
"byte",
"<",
"56",
")",
"{",
"return",
"$",
"byte",
"-",
"24",
";",
"}",
"if",
"(",
"$",
"byte",
">",
"64",
"&&",
"$",
"byte",
"<",
"91",
")",
"{",
"return",
"$",
"byte",
"-",
"65",
";",
"}",
"}",
"throw",
"new",
"InvalidEncodedDataException",
"(",
"$",
"this",
"->",
"key",
"(",
")",
",",
"$",
"data",
")",
";",
"}"
] | Map a byte to its relevant alphabet entry.
@param string $data The data to be decoded.
@param integer $index The index into the data at which the relevant byte is located.
@return integer The relevant alphabet entry.
@throws EncodingExceptionInterface If there is no relevant alphabet entry. | [
"Map",
"a",
"byte",
"to",
"its",
"relevant",
"alphabet",
"entry",
"."
] | 90043a26439739d6bac631cc57dab3ecf5cafdc3 | https://github.com/eloquent/endec/blob/90043a26439739d6bac631cc57dab3ecf5cafdc3/src/Base32/Base32DecodeTransform.php#L48-L61 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.removeTranslation | public function removeTranslation($locale = null) {
$translation = $this->translate($locale);
if(! is_null($translation))
$translation->delete();
return $this;
} | php | public function removeTranslation($locale = null) {
$translation = $this->translate($locale);
if(! is_null($translation))
$translation->delete();
return $this;
} | [
"public",
"function",
"removeTranslation",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"translation",
")",
")",
"$",
"translation",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove translation by locale .
@param null $locale
@return $this
@throws TranslatableException | [
"Remove",
"translation",
"by",
"locale",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L21-L28 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.translate | public function translate($locale = null) {
$locale = isset($locale) ? $locale : Locale\get_active_locale();
if( in_array( $locale, Locale\get_locales() ) )
throw new TranslatableException(
_('Invalid locale')
);
$language = $this->getByLocale($locale);
return $this->translations()
->where('language_id', $language->id)
->first();
} | php | public function translate($locale = null) {
$locale = isset($locale) ? $locale : Locale\get_active_locale();
if( in_array( $locale, Locale\get_locales() ) )
throw new TranslatableException(
_('Invalid locale')
);
$language = $this->getByLocale($locale);
return $this->translations()
->where('language_id', $language->id)
->first();
} | [
"public",
"function",
"translate",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"isset",
"(",
"$",
"locale",
")",
"?",
"$",
"locale",
":",
"Locale",
"\\",
"get_active_locale",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"locale",
",",
"Locale",
"\\",
"get_locales",
"(",
")",
")",
")",
"throw",
"new",
"TranslatableException",
"(",
"_",
"(",
"'Invalid locale'",
")",
")",
";",
"$",
"language",
"=",
"$",
"this",
"->",
"getByLocale",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"this",
"->",
"translations",
"(",
")",
"->",
"where",
"(",
"'language_id'",
",",
"$",
"language",
"->",
"id",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Translate attribute by locale .
@param null $locale
@return mixed
@throws TranslatableException | [
"Translate",
"attribute",
"by",
"locale",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L48-L61 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.save | public function save(array $options = []) {
$saved = parent::save($options);
array_walk($this->translations, function($translation, $locale) {
if(! array_filter($translation))
return false;
$this->newTranslation($locale, $translation)
->save();
});
return $saved;
} | php | public function save(array $options = []) {
$saved = parent::save($options);
array_walk($this->translations, function($translation, $locale) {
if(! array_filter($translation))
return false;
$this->newTranslation($locale, $translation)
->save();
});
return $saved;
} | [
"public",
"function",
"save",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"saved",
"=",
"parent",
"::",
"save",
"(",
"$",
"options",
")",
";",
"array_walk",
"(",
"$",
"this",
"->",
"translations",
",",
"function",
"(",
"$",
"translation",
",",
"$",
"locale",
")",
"{",
"if",
"(",
"!",
"array_filter",
"(",
"$",
"translation",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"newTranslation",
"(",
"$",
"locale",
",",
"$",
"translation",
")",
"->",
"save",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"saved",
";",
"}"
] | Save eloquent model .
@param array $options
@return mixed | [
"Save",
"eloquent",
"model",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L70-L82 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.fill | public function fill(array $attributes) {
$locales = Locale\get_locales();
foreach($locales as $locale => $options)
if( in_array($locale, array_keys($attributes)) )
$this->translations[$locale] = array_pull($attributes, $locale);
return parent::fill($attributes);
} | php | public function fill(array $attributes) {
$locales = Locale\get_locales();
foreach($locales as $locale => $options)
if( in_array($locale, array_keys($attributes)) )
$this->translations[$locale] = array_pull($attributes, $locale);
return parent::fill($attributes);
} | [
"public",
"function",
"fill",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"locales",
"=",
"Locale",
"\\",
"get_locales",
"(",
")",
";",
"foreach",
"(",
"$",
"locales",
"as",
"$",
"locale",
"=>",
"$",
"options",
")",
"if",
"(",
"in_array",
"(",
"$",
"locale",
",",
"array_keys",
"(",
"$",
"attributes",
")",
")",
")",
"$",
"this",
"->",
"translations",
"[",
"$",
"locale",
"]",
"=",
"array_pull",
"(",
"$",
"attributes",
",",
"$",
"locale",
")",
";",
"return",
"parent",
"::",
"fill",
"(",
"$",
"attributes",
")",
";",
"}"
] | Fill attributes and save locales if exists .
@param array $attributes
@return mixed | [
"Fill",
"attributes",
"and",
"save",
"locales",
"if",
"exists",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L90-L98 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.newTranslation | protected function newTranslation($locale = null, array $attributes) {
$locale = isset($locale) ? $locale : Locale\get_active_locale();
$language = $this->getByLocale($locale);
$class = $this->classTranslation();
$update = [
'language_id' => $language->id,
isset($this->translation_id) ? $this->translation_id : str_singular($this->getModel()->getTable()) . '_id' => $this->id,
];
$attributes = array_merge($update, $attributes);
return $class::updateOrCreate($update, $attributes);
} | php | protected function newTranslation($locale = null, array $attributes) {
$locale = isset($locale) ? $locale : Locale\get_active_locale();
$language = $this->getByLocale($locale);
$class = $this->classTranslation();
$update = [
'language_id' => $language->id,
isset($this->translation_id) ? $this->translation_id : str_singular($this->getModel()->getTable()) . '_id' => $this->id,
];
$attributes = array_merge($update, $attributes);
return $class::updateOrCreate($update, $attributes);
} | [
"protected",
"function",
"newTranslation",
"(",
"$",
"locale",
"=",
"null",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"locale",
"=",
"isset",
"(",
"$",
"locale",
")",
"?",
"$",
"locale",
":",
"Locale",
"\\",
"get_active_locale",
"(",
")",
";",
"$",
"language",
"=",
"$",
"this",
"->",
"getByLocale",
"(",
"$",
"locale",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"classTranslation",
"(",
")",
";",
"$",
"update",
"=",
"[",
"'language_id'",
"=>",
"$",
"language",
"->",
"id",
",",
"isset",
"(",
"$",
"this",
"->",
"translation_id",
")",
"?",
"$",
"this",
"->",
"translation_id",
":",
"str_singular",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getTable",
"(",
")",
")",
".",
"'_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"]",
";",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"update",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"class",
"::",
"updateOrCreate",
"(",
"$",
"update",
",",
"$",
"attributes",
")",
";",
"}"
] | Get new translation instance .
@param null $locale
@param array $attributes
@return mixed | [
"Get",
"new",
"translation",
"instance",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L108-L123 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.classTranslation | protected function classTranslation() {
if(! $classTranslation = $this['translationClass'])
$classTranslation = sprintf('App\\%s%s', ucfirst(str_singular($this->getModel()->getTable())), 'Translations');
return $classTranslation;
} | php | protected function classTranslation() {
if(! $classTranslation = $this['translationClass'])
$classTranslation = sprintf('App\\%s%s', ucfirst(str_singular($this->getModel()->getTable())), 'Translations');
return $classTranslation;
} | [
"protected",
"function",
"classTranslation",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"classTranslation",
"=",
"$",
"this",
"[",
"'translationClass'",
"]",
")",
"$",
"classTranslation",
"=",
"sprintf",
"(",
"'App\\\\%s%s'",
",",
"ucfirst",
"(",
"str_singular",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getTable",
"(",
")",
")",
")",
",",
"'Translations'",
")",
";",
"return",
"$",
"classTranslation",
";",
"}"
] | Get Class Translations .
@return string | [
"Get",
"Class",
"Translations",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L142-L147 | train |
parfumix/eloquent-translatable | src/TranslatableTrait.php | TranslatableTrait.translatedAttributes | public function translatedAttributes() {
if(! $attributes = isset($this['translatedAttributes']) ? $this['translatedAttributes'] : null) {
$class = $this->classTranslation();
$attributes = (new $class)
->getFillable();
$attributes = array_except(array_flip($attributes), [
'language_id' ,
str_singular($this->getModel()->getTable()) . '_id'
]);
$attributes = array_flip($attributes);
}
return $attributes;
} | php | public function translatedAttributes() {
if(! $attributes = isset($this['translatedAttributes']) ? $this['translatedAttributes'] : null) {
$class = $this->classTranslation();
$attributes = (new $class)
->getFillable();
$attributes = array_except(array_flip($attributes), [
'language_id' ,
str_singular($this->getModel()->getTable()) . '_id'
]);
$attributes = array_flip($attributes);
}
return $attributes;
} | [
"public",
"function",
"translatedAttributes",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"attributes",
"=",
"isset",
"(",
"$",
"this",
"[",
"'translatedAttributes'",
"]",
")",
"?",
"$",
"this",
"[",
"'translatedAttributes'",
"]",
":",
"null",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"classTranslation",
"(",
")",
";",
"$",
"attributes",
"=",
"(",
"new",
"$",
"class",
")",
"->",
"getFillable",
"(",
")",
";",
"$",
"attributes",
"=",
"array_except",
"(",
"array_flip",
"(",
"$",
"attributes",
")",
",",
"[",
"'language_id'",
",",
"str_singular",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getTable",
"(",
")",
")",
".",
"'_id'",
"]",
")",
";",
"$",
"attributes",
"=",
"array_flip",
"(",
"$",
"attributes",
")",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] | Get translatedAttributes .
@return mixed | [
"Get",
"translatedAttributes",
"."
] | 53a4d5c7288219a035d8c512892efbe670029a79 | https://github.com/parfumix/eloquent-translatable/blob/53a4d5c7288219a035d8c512892efbe670029a79/src/TranslatableTrait.php#L167-L183 | train |
rkeet/zf-doctrine-mvc | src/Controller/AbstractDoctrineActionController.php | AbstractDoctrineActionController.isEntity | function isEntity(string $classFQCN) : bool
{
if ( ! class_exists($classFQCN)) {
throw new ClassNotFoundException(sprintf('Given class FQCN "%s" does not exist.', $classFQCN));
}
if ( ! is_object($classFQCN)) {
throw new EntityNotFoundException(sprintf('Given class "%s" is not a Doctrine Entity.', $classFQCN));
}
return ! $this->getObjectManager()
->getMetadataFactory()
->isTransient(ClassUtils::getClass($classFQCN));
} | php | function isEntity(string $classFQCN) : bool
{
if ( ! class_exists($classFQCN)) {
throw new ClassNotFoundException(sprintf('Given class FQCN "%s" does not exist.', $classFQCN));
}
if ( ! is_object($classFQCN)) {
throw new EntityNotFoundException(sprintf('Given class "%s" is not a Doctrine Entity.', $classFQCN));
}
return ! $this->getObjectManager()
->getMetadataFactory()
->isTransient(ClassUtils::getClass($classFQCN));
} | [
"function",
"isEntity",
"(",
"string",
"$",
"classFQCN",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classFQCN",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"sprintf",
"(",
"'Given class FQCN \"%s\" does not exist.'",
",",
"$",
"classFQCN",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"classFQCN",
")",
")",
"{",
"throw",
"new",
"EntityNotFoundException",
"(",
"sprintf",
"(",
"'Given class \"%s\" is not a Doctrine Entity.'",
",",
"$",
"classFQCN",
")",
")",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
"->",
"getMetadataFactory",
"(",
")",
"->",
"isTransient",
"(",
"ClassUtils",
"::",
"getClass",
"(",
"$",
"classFQCN",
")",
")",
";",
"}"
] | Tests if a received class name is in fact a Doctrine Entity
Based on @link https://stackoverflow.com/a/27121978/1155833
@param string $classFQCN
@return boolean
@throws EntityNotFoundException | [
"Tests",
"if",
"a",
"received",
"class",
"name",
"is",
"in",
"fact",
"a",
"Doctrine",
"Entity"
] | ec5fb19e453824383b39570d15bd77b85cec3ca1 | https://github.com/rkeet/zf-doctrine-mvc/blob/ec5fb19e453824383b39570d15bd77b85cec3ca1/src/Controller/AbstractDoctrineActionController.php#L39-L54 | train |
borobudur-php/borobudur | src/Borobudur/Component/Http/Request.php | Request.getBodyData | private function getBodyData(string $key, $default = null)
{
$body = $this->getParsedBody();
if (is_array($body)) {
return array_key_exists($key, $body) ? $body[$key] : $default;
}
if (is_object($body)) {
return property_exists($body, $key) ? $body->{$key} : $default;
}
return $default;
} | php | private function getBodyData(string $key, $default = null)
{
$body = $this->getParsedBody();
if (is_array($body)) {
return array_key_exists($key, $body) ? $body[$key] : $default;
}
if (is_object($body)) {
return property_exists($body, $key) ? $body->{$key} : $default;
}
return $default;
} | [
"private",
"function",
"getBodyData",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"getParsedBody",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"body",
")",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"body",
")",
"?",
"$",
"body",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"body",
")",
")",
"{",
"return",
"property_exists",
"(",
"$",
"body",
",",
"$",
"key",
")",
"?",
"$",
"body",
"->",
"{",
"$",
"key",
"}",
":",
"$",
"default",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Gets parsed body data with specified key.
@param string $key
@param mixed $default
@return mixed | [
"Gets",
"parsed",
"body",
"data",
"with",
"specified",
"key",
"."
] | 6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44 | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Http/Request.php#L101-L114 | train |
fxpio/fxp-doctrine-console | Command/Base.php | Base.showMessage | protected function showMessage(OutputInterface $output, $instance, $message)
{
$methodGet = $this->adapter->getDisplayNameMethod();
$output->writeln([
'',
sprintf($message, strtolower($this->adapter->getShortName()), $instance->$methodGet()),
]);
} | php | protected function showMessage(OutputInterface $output, $instance, $message)
{
$methodGet = $this->adapter->getDisplayNameMethod();
$output->writeln([
'',
sprintf($message, strtolower($this->adapter->getShortName()), $instance->$methodGet()),
]);
} | [
"protected",
"function",
"showMessage",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"instance",
",",
"$",
"message",
")",
"{",
"$",
"methodGet",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getDisplayNameMethod",
"(",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"[",
"''",
",",
"sprintf",
"(",
"$",
"message",
",",
"strtolower",
"(",
"$",
"this",
"->",
"adapter",
"->",
"getShortName",
"(",
")",
")",
",",
"$",
"instance",
"->",
"$",
"methodGet",
"(",
")",
")",
",",
"]",
")",
";",
"}"
] | Show the message in the console output.
@param OutputInterface $output The console output
@param object $instance The object instance
@param string $message The displayed message | [
"Show",
"the",
"message",
"in",
"the",
"console",
"output",
"."
] | 2fc16d7a4eb0f247075c50de225ec2670ca5479a | https://github.com/fxpio/fxp-doctrine-console/blob/2fc16d7a4eb0f247075c50de225ec2670ca5479a/Command/Base.php#L123-L131 | train |
hal-platform/hal-core | src/Repository/TargetRepository.php | TargetRepository.getGroupedTargets | public function getGroupedTargets(?Application $application = null): array
{
$environments = $this->getEntityManager()
->getRepository(Environment::class)
->findAll();
if ($application) {
$findBy = ['application' => $application];
} else {
$findBy = [];
}
$targets = $this->findBy($findBy);
usort($environments, $this->environmentSorter());
usort($targets, $this->targetSorter());
$sorted = [];
foreach ($environments as $environment) {
$sorted[$environment->id()] = [
'environment' => $environment,
'targets' => [],
];
}
foreach ($targets as $target) {
$id = $target->environment()->id();
$sorted[$id]['targets'][] = $target;
}
return array_filter($sorted, function ($e) {
return count($e['targets']) !== 0;
});
} | php | public function getGroupedTargets(?Application $application = null): array
{
$environments = $this->getEntityManager()
->getRepository(Environment::class)
->findAll();
if ($application) {
$findBy = ['application' => $application];
} else {
$findBy = [];
}
$targets = $this->findBy($findBy);
usort($environments, $this->environmentSorter());
usort($targets, $this->targetSorter());
$sorted = [];
foreach ($environments as $environment) {
$sorted[$environment->id()] = [
'environment' => $environment,
'targets' => [],
];
}
foreach ($targets as $target) {
$id = $target->environment()->id();
$sorted[$id]['targets'][] = $target;
}
return array_filter($sorted, function ($e) {
return count($e['targets']) !== 0;
});
} | [
"public",
"function",
"getGroupedTargets",
"(",
"?",
"Application",
"$",
"application",
"=",
"null",
")",
":",
"array",
"{",
"$",
"environments",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"Environment",
"::",
"class",
")",
"->",
"findAll",
"(",
")",
";",
"if",
"(",
"$",
"application",
")",
"{",
"$",
"findBy",
"=",
"[",
"'application'",
"=>",
"$",
"application",
"]",
";",
"}",
"else",
"{",
"$",
"findBy",
"=",
"[",
"]",
";",
"}",
"$",
"targets",
"=",
"$",
"this",
"->",
"findBy",
"(",
"$",
"findBy",
")",
";",
"usort",
"(",
"$",
"environments",
",",
"$",
"this",
"->",
"environmentSorter",
"(",
")",
")",
";",
"usort",
"(",
"$",
"targets",
",",
"$",
"this",
"->",
"targetSorter",
"(",
")",
")",
";",
"$",
"sorted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"environments",
"as",
"$",
"environment",
")",
"{",
"$",
"sorted",
"[",
"$",
"environment",
"->",
"id",
"(",
")",
"]",
"=",
"[",
"'environment'",
"=>",
"$",
"environment",
",",
"'targets'",
"=>",
"[",
"]",
",",
"]",
";",
"}",
"foreach",
"(",
"$",
"targets",
"as",
"$",
"target",
")",
"{",
"$",
"id",
"=",
"$",
"target",
"->",
"environment",
"(",
")",
"->",
"id",
"(",
")",
";",
"$",
"sorted",
"[",
"$",
"id",
"]",
"[",
"'targets'",
"]",
"[",
"]",
"=",
"$",
"target",
";",
"}",
"return",
"array_filter",
"(",
"$",
"sorted",
",",
"function",
"(",
"$",
"e",
")",
"{",
"return",
"count",
"(",
"$",
"e",
"[",
"'targets'",
"]",
")",
"!==",
"0",
";",
"}",
")",
";",
"}"
] | Get all targets sorted into environments.
@param Application|null $application
@return array | [
"Get",
"all",
"targets",
"sorted",
"into",
"environments",
"."
] | 30d456f8392fc873301ad4217d2ae90436c67090 | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Repository/TargetRepository.php#L50-L83 | train |
ajaxtown/eaglehorn_framework | src/Eaglehorn/Template.php | Template._applyInjections | private function _applyInjections()
{
foreach ($this->injections as $head)
{
$tags = $this->_getInjectionString($head);
}
$this->template_markup = str_replace('</head>', $tags, $this->template_markup);
} | php | private function _applyInjections()
{
foreach ($this->injections as $head)
{
$tags = $this->_getInjectionString($head);
}
$this->template_markup = str_replace('</head>', $tags, $this->template_markup);
} | [
"private",
"function",
"_applyInjections",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"injections",
"as",
"$",
"head",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"_getInjectionString",
"(",
"$",
"head",
")",
";",
"}",
"$",
"this",
"->",
"template_markup",
"=",
"str_replace",
"(",
"'</head>'",
",",
"$",
"tags",
",",
"$",
"this",
"->",
"template_markup",
")",
";",
"}"
] | Insert the stored CSS links, JS, files and Meta into the HEAD | [
"Insert",
"the",
"stored",
"CSS",
"links",
"JS",
"files",
"and",
"Meta",
"into",
"the",
"HEAD"
] | 5e2a1456ff6c65b3925f1219f115d8a919930f52 | https://github.com/ajaxtown/eaglehorn_framework/blob/5e2a1456ff6c65b3925f1219f115d8a919930f52/src/Eaglehorn/Template.php#L137-L146 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.addClass | public function addClass(string $value) : self
{
$class = trim($this->attributes['class']);
$this->attributes['class'] = trim($class . ' ' . trim($value));
return $this;
} | php | public function addClass(string $value) : self
{
$class = trim($this->attributes['class']);
$this->attributes['class'] = trim($class . ' ' . trim($value));
return $this;
} | [
"public",
"function",
"addClass",
"(",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"class",
"=",
"trim",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"trim",
"(",
"$",
"class",
".",
"' '",
".",
"trim",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add the specified class to the class attribute for the form field.
@param string $value A class to add
@return self | [
"Add",
"the",
"specified",
"class",
"to",
"the",
"class",
"attribute",
"for",
"the",
"form",
"field",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L161-L166 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.setValidator | public function setValidator(string $validator_class_name, array $constraints = []) : self
{
$this->validator = $validator_class_name;
$this->constraints = $constraints;
return $this;
} | php | public function setValidator(string $validator_class_name, array $constraints = []) : self
{
$this->validator = $validator_class_name;
$this->constraints = $constraints;
return $this;
} | [
"public",
"function",
"setValidator",
"(",
"string",
"$",
"validator_class_name",
",",
"array",
"$",
"constraints",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"this",
"->",
"validator",
"=",
"$",
"validator_class_name",
";",
"$",
"this",
"->",
"constraints",
"=",
"$",
"constraints",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a validator for the field
@param string $validator_class_name The name of the validation class
@param array $constraints Optional constraints
@return self | [
"Sets",
"a",
"validator",
"for",
"the",
"field"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L189-L194 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.setRequired | public function setRequired(bool $required) : self
{
$required = (bool)$required;
$this->required = $required;
return $this;
} | php | public function setRequired(bool $required) : self
{
$required = (bool)$required;
$this->required = $required;
return $this;
} | [
"public",
"function",
"setRequired",
"(",
"bool",
"$",
"required",
")",
":",
"self",
"{",
"$",
"required",
"=",
"(",
"bool",
")",
"$",
"required",
";",
"$",
"this",
"->",
"required",
"=",
"$",
"required",
";",
"return",
"$",
"this",
";",
"}"
] | Set if the field is required.
@param bool $required True if this field is required.
@return self | [
"Set",
"if",
"the",
"field",
"is",
"required",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L203-L208 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.setDefaultValue | public function setDefaultValue($value) : self
{
$this->default_value = $value;
// If valid input was entered already, check if this value is different.
if ($this->is_valid) {
$this->is_changed = ($this->default_value == $this->user_value);
}
return $this;
} | php | public function setDefaultValue($value) : self
{
$this->default_value = $value;
// If valid input was entered already, check if this value is different.
if ($this->is_valid) {
$this->is_changed = ($this->default_value == $this->user_value);
}
return $this;
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"default_value",
"=",
"$",
"value",
";",
"// If valid input was entered already, check if this value is different.",
"if",
"(",
"$",
"this",
"->",
"is_valid",
")",
"{",
"$",
"this",
"->",
"is_changed",
"=",
"(",
"$",
"this",
"->",
"default_value",
"==",
"$",
"this",
"->",
"user_value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the default or database value for the
@param mixed $value The value of the form field.
@return self | [
"Sets",
"the",
"default",
"or",
"database",
"value",
"for",
"the"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L277-L285 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.getSelectName | public function getSelectName() : ?string
{
if (null !== $this->select_name) {
return $this->select_name . ' as ' . $this->getDBName();
}
if (null !== $this->db_name) {
return $this->db_name;
}
return $this->attributes['name'];
} | php | public function getSelectName() : ?string
{
if (null !== $this->select_name) {
return $this->select_name . ' as ' . $this->getDBName();
}
if (null !== $this->db_name) {
return $this->db_name;
}
return $this->attributes['name'];
} | [
"public",
"function",
"getSelectName",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"select_name",
")",
"{",
"return",
"$",
"this",
"->",
"select_name",
".",
"' as '",
".",
"$",
"this",
"->",
"getDBName",
"(",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"db_name",
")",
"{",
"return",
"$",
"this",
"->",
"db_name",
";",
"}",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'name'",
"]",
";",
"}"
] | Returns the db select name of the field. If none is set, returns the db_name of the field, if that is not set,
returns the base name of the field.
@return null|string | [
"Returns",
"the",
"db",
"select",
"name",
"of",
"the",
"field",
".",
"If",
"none",
"is",
"set",
"returns",
"the",
"db_name",
"of",
"the",
"field",
"if",
"that",
"is",
"not",
"set",
"returns",
"the",
"base",
"name",
"of",
"the",
"field",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L335-L344 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.setUserValue | public function setUserValue(string $value) : self
{
$this->user_value = $value;
$this->is_valid = null;
return $this;
} | php | public function setUserValue(string $value) : self
{
$this->user_value = $value;
$this->is_valid = null;
return $this;
} | [
"public",
"function",
"setUserValue",
"(",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"user_value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"is_valid",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a user value to be validated
@param mixed $value
@return self | [
"Sets",
"a",
"user",
"value",
"to",
"be",
"validated"
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L363-L368 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.getValue | public function getValue()
{
if (null == $this->is_valid && null != $this->user_value) {
$this->validate();
}
if (null !== $this->user_value && $this->is_valid) {
if ('' === $this->user_value && true === $this->null_on_empty) {
return null;
}
return $this->user_value;
} else {
if ('' === $this->default_value && true === $this->null_on_empty) {
return null;
}
return $this->default_value;
}
} | php | public function getValue()
{
if (null == $this->is_valid && null != $this->user_value) {
$this->validate();
}
if (null !== $this->user_value && $this->is_valid) {
if ('' === $this->user_value && true === $this->null_on_empty) {
return null;
}
return $this->user_value;
} else {
if ('' === $this->default_value && true === $this->null_on_empty) {
return null;
}
return $this->default_value;
}
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"is_valid",
"&&",
"null",
"!=",
"$",
"this",
"->",
"user_value",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"user_value",
"&&",
"$",
"this",
"->",
"is_valid",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"user_value",
"&&",
"true",
"===",
"$",
"this",
"->",
"null_on_empty",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"user_value",
";",
"}",
"else",
"{",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"default_value",
"&&",
"true",
"===",
"$",
"this",
"->",
"null_on_empty",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"default_value",
";",
"}",
"}"
] | Gets the value of the field, either the user set value if valid and set, or the object value.
@return mixed | [
"Gets",
"the",
"value",
"of",
"the",
"field",
"either",
"the",
"user",
"set",
"value",
"if",
"valid",
"and",
"set",
"or",
"the",
"object",
"value",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L375-L391 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.getUserValue | public function getUserValue()
{
if (null == $this->is_valid) {
$this->validate();
}
if (null !== $this->user_value && $this->is_valid) {
if ('' === $this->user_value && true === $this->null_on_empty) {
return null;
}
return $this->user_value;
} else {
return '';
}
} | php | public function getUserValue()
{
if (null == $this->is_valid) {
$this->validate();
}
if (null !== $this->user_value && $this->is_valid) {
if ('' === $this->user_value && true === $this->null_on_empty) {
return null;
}
return $this->user_value;
} else {
return '';
}
} | [
"public",
"function",
"getUserValue",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"is_valid",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"user_value",
"&&",
"$",
"this",
"->",
"is_valid",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"user_value",
"&&",
"true",
"===",
"$",
"this",
"->",
"null_on_empty",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"user_value",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | Get the user set value, if valid.
@return mixed | [
"Get",
"the",
"user",
"set",
"value",
"if",
"valid",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L408-L421 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.setError | public function setError(?string $message = null) : void
{
$this->is_valid = false;
$this->error = (null === $message) ? $this->default_error : $message;
} | php | public function setError(?string $message = null) : void
{
$this->is_valid = false;
$this->error = (null === $message) ? $this->default_error : $message;
} | [
"public",
"function",
"setError",
"(",
"?",
"string",
"$",
"message",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"is_valid",
"=",
"false",
";",
"$",
"this",
"->",
"error",
"=",
"(",
"null",
"===",
"$",
"message",
")",
"?",
"$",
"this",
"->",
"default_error",
":",
"$",
"message",
";",
"}"
] | Allows other systems such as the form's validator, to set this element as invalid. If no error message is
specified, the default error message will be set.
@param string|null $message | [
"Allows",
"other",
"systems",
"such",
"as",
"the",
"form",
"s",
"validator",
"to",
"set",
"this",
"element",
"as",
"invalid",
".",
"If",
"no",
"error",
"message",
"is",
"specified",
"the",
"default",
"error",
"message",
"will",
"be",
"set",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L527-L531 | train |
wigedev/farm | src/FormBuilder/FormElement.php | FormElement.commit | public function commit() : void
{
if (null === $this->is_valid) {
$this->validate();
}
if ($this->is_valid && $this->user_value != null) {
$this->default_value = $this->user_value;
}
$this->user_value = null;
$this->is_valid = null;
$this->is_changed = false;
} | php | public function commit() : void
{
if (null === $this->is_valid) {
$this->validate();
}
if ($this->is_valid && $this->user_value != null) {
$this->default_value = $this->user_value;
}
$this->user_value = null;
$this->is_valid = null;
$this->is_changed = false;
} | [
"public",
"function",
"commit",
"(",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"is_valid",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"is_valid",
"&&",
"$",
"this",
"->",
"user_value",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"default_value",
"=",
"$",
"this",
"->",
"user_value",
";",
"}",
"$",
"this",
"->",
"user_value",
"=",
"null",
";",
"$",
"this",
"->",
"is_valid",
"=",
"null",
";",
"$",
"this",
"->",
"is_changed",
"=",
"false",
";",
"}"
] | After the form is saved, use commit to "save" the input values. This replaces the default value with the input
value, and resets isValid to null and isChanged to false. | [
"After",
"the",
"form",
"is",
"saved",
"use",
"commit",
"to",
"save",
"the",
"input",
"values",
".",
"This",
"replaces",
"the",
"default",
"value",
"with",
"the",
"input",
"value",
"and",
"resets",
"isValid",
"to",
"null",
"and",
"isChanged",
"to",
"false",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement.php#L537-L548 | train |
stackpr/quipxml | src/Xml/QuipXmlElement.php | QuipXmlElement.before | public function before($content) {
if (FALSE === (bool) $this) {
return $this;
}
$me = $this->dom();
$parent = $this->xparent()->dom();
$new = $this->_contentToDom($content);
$parent->insertBefore($new, $me);
return $this;
} | php | public function before($content) {
if (FALSE === (bool) $this) {
return $this;
}
$me = $this->dom();
$parent = $this->xparent()->dom();
$new = $this->_contentToDom($content);
$parent->insertBefore($new, $me);
return $this;
} | [
"public",
"function",
"before",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"FALSE",
"===",
"(",
"bool",
")",
"$",
"this",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"me",
"=",
"$",
"this",
"->",
"dom",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"xparent",
"(",
")",
"->",
"dom",
"(",
")",
";",
"$",
"new",
"=",
"$",
"this",
"->",
"_contentToDom",
"(",
"$",
"content",
")",
";",
"$",
"parent",
"->",
"insertBefore",
"(",
"$",
"new",
",",
"$",
"me",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add the content before this node.
@param mixed $content
@return \QuipXml\Xml\QuipXmlElement | [
"Add",
"the",
"content",
"before",
"this",
"node",
"."
] | 472e0d98a90aa0a283aac933158d830311480ff8 | https://github.com/stackpr/quipxml/blob/472e0d98a90aa0a283aac933158d830311480ff8/src/Xml/QuipXmlElement.php#L63-L72 | train |
stackpr/quipxml | src/Xml/QuipXmlElement.php | QuipXmlElement.after | public function after($content) {
if (FALSE === (bool) $this) {
return $this;
}
$me = $this->dom();
$parent = $this->xparent()->dom();
$new = $this->_contentToDom($content);
if (isset($me->nextSibling)) {
$parent->insertBefore($new, $me->nextSibling);
}
else {
$parent->appendChild($new);
}
return $this;
} | php | public function after($content) {
if (FALSE === (bool) $this) {
return $this;
}
$me = $this->dom();
$parent = $this->xparent()->dom();
$new = $this->_contentToDom($content);
if (isset($me->nextSibling)) {
$parent->insertBefore($new, $me->nextSibling);
}
else {
$parent->appendChild($new);
}
return $this;
} | [
"public",
"function",
"after",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"FALSE",
"===",
"(",
"bool",
")",
"$",
"this",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"me",
"=",
"$",
"this",
"->",
"dom",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"xparent",
"(",
")",
"->",
"dom",
"(",
")",
";",
"$",
"new",
"=",
"$",
"this",
"->",
"_contentToDom",
"(",
"$",
"content",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"me",
"->",
"nextSibling",
")",
")",
"{",
"$",
"parent",
"->",
"insertBefore",
"(",
"$",
"new",
",",
"$",
"me",
"->",
"nextSibling",
")",
";",
"}",
"else",
"{",
"$",
"parent",
"->",
"appendChild",
"(",
"$",
"new",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add the content after this node.
@param mixed $content
@return \QuipXml\Xml\QuipXmlElement | [
"Add",
"the",
"content",
"after",
"this",
"node",
"."
] | 472e0d98a90aa0a283aac933158d830311480ff8 | https://github.com/stackpr/quipxml/blob/472e0d98a90aa0a283aac933158d830311480ff8/src/Xml/QuipXmlElement.php#L79-L93 | train |
stackpr/quipxml | src/Xml/QuipXmlElement.php | QuipXmlElement.xpath | public function xpath($path) {
$results = parent::xpath($path);
if (empty($results)) {
return $this->_getEmptyElement();
}
return new QuipXmlElementIterator(new \ArrayIterator($results));
} | php | public function xpath($path) {
$results = parent::xpath($path);
if (empty($results)) {
return $this->_getEmptyElement();
}
return new QuipXmlElementIterator(new \ArrayIterator($results));
} | [
"public",
"function",
"xpath",
"(",
"$",
"path",
")",
"{",
"$",
"results",
"=",
"parent",
"::",
"xpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"results",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getEmptyElement",
"(",
")",
";",
"}",
"return",
"new",
"QuipXmlElementIterator",
"(",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"results",
")",
")",
";",
"}"
] | Wrap the xpath results in a Quip iterator.
@see SimpleXMLElement::xpath()
@return \QuipXml\Xml\QuipXmlElementIterator | [
"Wrap",
"the",
"xpath",
"results",
"in",
"a",
"Quip",
"iterator",
"."
] | 472e0d98a90aa0a283aac933158d830311480ff8 | https://github.com/stackpr/quipxml/blob/472e0d98a90aa0a283aac933158d830311480ff8/src/Xml/QuipXmlElement.php#L325-L331 | train |
jelix/castor | lib/Castor/CastorCore.php | CastorCore.append | public function append($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $key => $val) {
if (isset($this->_vars[$key])) {
$this->_vars[$key] .= $val;
} else {
$this->_vars[$key] = $val;
}
}
} else {
if (isset($this->_vars[$name])) {
$this->_vars[$name] .= $value;
} else {
$this->_vars[$name] = $value;
}
}
} | php | public function append($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $key => $val) {
if (isset($this->_vars[$key])) {
$this->_vars[$key] .= $val;
} else {
$this->_vars[$key] = $val;
}
}
} else {
if (isset($this->_vars[$name])) {
$this->_vars[$name] .= $value;
} else {
$this->_vars[$name] = $value;
}
}
} | [
"public",
"function",
"append",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_vars",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_vars",
"[",
"$",
"key",
"]",
".=",
"$",
"val",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_vars",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_vars",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_vars",
"[",
"$",
"name",
"]",
".=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_vars",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] | concat a value in with a value of an existing template variable.
@param string|array $name the variable name, or an associative array 'name'=>'value'
@param mixed $value the value (or null if $name is an array) | [
"concat",
"a",
"value",
"in",
"with",
"a",
"value",
"of",
"an",
"existing",
"template",
"variable",
"."
] | 113aacc4c65766816bb11e263e44da12ec645d6e | https://github.com/jelix/castor/blob/113aacc4c65766816bb11e263e44da12ec645d6e/lib/Castor/CastorCore.php#L86-L103 | train |
jelix/castor | lib/Castor/CastorCore.php | CastorCore.meta | public function meta($tpl, $outputtype = '', $trusted = true)
{
if (in_array($tpl, $this->processedMeta)) {
// we want to process meta only one time, when a template is included
// several time in an other template, or, more important, when a template
// is included in a recursive manner (in this case, it did cause infinite loop, see #1396).
return $this->_meta;
}
$this->processedMeta[] = $tpl;
$md = $this->getTemplate($tpl, $outputtype, $trusted);
$fct = 'template_meta_'.$md;
$fct($this);
return $this->_meta;
} | php | public function meta($tpl, $outputtype = '', $trusted = true)
{
if (in_array($tpl, $this->processedMeta)) {
// we want to process meta only one time, when a template is included
// several time in an other template, or, more important, when a template
// is included in a recursive manner (in this case, it did cause infinite loop, see #1396).
return $this->_meta;
}
$this->processedMeta[] = $tpl;
$md = $this->getTemplate($tpl, $outputtype, $trusted);
$fct = 'template_meta_'.$md;
$fct($this);
return $this->_meta;
} | [
"public",
"function",
"meta",
"(",
"$",
"tpl",
",",
"$",
"outputtype",
"=",
"''",
",",
"$",
"trusted",
"=",
"true",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"tpl",
",",
"$",
"this",
"->",
"processedMeta",
")",
")",
"{",
"// we want to process meta only one time, when a template is included",
"// several time in an other template, or, more important, when a template",
"// is included in a recursive manner (in this case, it did cause infinite loop, see #1396).",
"return",
"$",
"this",
"->",
"_meta",
";",
"}",
"$",
"this",
"->",
"processedMeta",
"[",
"]",
"=",
"$",
"tpl",
";",
"$",
"md",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"tpl",
",",
"$",
"outputtype",
",",
"$",
"trusted",
")",
";",
"$",
"fct",
"=",
"'template_meta_'",
".",
"$",
"md",
";",
"$",
"fct",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"_meta",
";",
"}"
] | process all meta instruction of a template.
@param string $tpl template selector
@param string $outputtype the type of output (html, text etc..)
@param bool $trusted says if the template file is trusted or not | [
"process",
"all",
"meta",
"instruction",
"of",
"a",
"template",
"."
] | 113aacc4c65766816bb11e263e44da12ec645d6e | https://github.com/jelix/castor/blob/113aacc4c65766816bb11e263e44da12ec645d6e/lib/Castor/CastorCore.php#L173-L188 | train |
jelix/castor | lib/Castor/CastorCore.php | CastorCore.display | public function display($tpl, $outputtype = '', $trusted = true)
{
$previousTpl = $this->_templateName;
$this->_templateName = $tpl;
$this->recursiveTpl[] = $tpl;
$md = $this->getTemplate($tpl, $outputtype, $trusted);
$fct = 'template_'.$md;
$fct($this);
array_pop($this->recursiveTpl);
$this->_templateName = $previousTpl;
} | php | public function display($tpl, $outputtype = '', $trusted = true)
{
$previousTpl = $this->_templateName;
$this->_templateName = $tpl;
$this->recursiveTpl[] = $tpl;
$md = $this->getTemplate($tpl, $outputtype, $trusted);
$fct = 'template_'.$md;
$fct($this);
array_pop($this->recursiveTpl);
$this->_templateName = $previousTpl;
} | [
"public",
"function",
"display",
"(",
"$",
"tpl",
",",
"$",
"outputtype",
"=",
"''",
",",
"$",
"trusted",
"=",
"true",
")",
"{",
"$",
"previousTpl",
"=",
"$",
"this",
"->",
"_templateName",
";",
"$",
"this",
"->",
"_templateName",
"=",
"$",
"tpl",
";",
"$",
"this",
"->",
"recursiveTpl",
"[",
"]",
"=",
"$",
"tpl",
";",
"$",
"md",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"tpl",
",",
"$",
"outputtype",
",",
"$",
"trusted",
")",
";",
"$",
"fct",
"=",
"'template_'",
".",
"$",
"md",
";",
"$",
"fct",
"(",
"$",
"this",
")",
";",
"array_pop",
"(",
"$",
"this",
"->",
"recursiveTpl",
")",
";",
"$",
"this",
"->",
"_templateName",
"=",
"$",
"previousTpl",
";",
"}"
] | display the generated content from the given template.
@param string $tpl template selector
@param string $outputtype the type of output (html, text etc..)
@param bool $trusted says if the template file is trusted or not | [
"display",
"the",
"generated",
"content",
"from",
"the",
"given",
"template",
"."
] | 113aacc4c65766816bb11e263e44da12ec645d6e | https://github.com/jelix/castor/blob/113aacc4c65766816bb11e263e44da12ec645d6e/lib/Castor/CastorCore.php#L197-L208 | train |
3ev/wordpress-core | src/Tev/Field/Model/RepeaterField.php | RepeaterField.current | public function current()
{
return new FieldGroup(
$this->base['sub_fields'],
$this->base['value'][$this->position],
$this,
$this->fieldFactory
);
} | php | public function current()
{
return new FieldGroup(
$this->base['sub_fields'],
$this->base['value'][$this->position],
$this,
$this->fieldFactory
);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"return",
"new",
"FieldGroup",
"(",
"$",
"this",
"->",
"base",
"[",
"'sub_fields'",
"]",
",",
"$",
"this",
"->",
"base",
"[",
"'value'",
"]",
"[",
"$",
"this",
"->",
"position",
"]",
",",
"$",
"this",
",",
"$",
"this",
"->",
"fieldFactory",
")",
";",
"}"
] | Get the current repeater item.
@return \Tev\Field\Util\FieldGroup | [
"Get",
"the",
"current",
"repeater",
"item",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Field/Model/RepeaterField.php#L74-L82 | train |
3ev/wordpress-core | src/Tev/Field/Model/RepeaterField.php | RepeaterField.valid | public function valid()
{
return isset($this->base['value'][$this->position]) && is_array($this->base['value'][$this->position]);
} | php | public function valid()
{
return isset($this->base['value'][$this->position]) && is_array($this->base['value'][$this->position]);
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"base",
"[",
"'value'",
"]",
"[",
"$",
"this",
"->",
"position",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"base",
"[",
"'value'",
"]",
"[",
"$",
"this",
"->",
"position",
"]",
")",
";",
"}"
] | Check if current position is valid.
@return boolean | [
"Check",
"if",
"current",
"position",
"is",
"valid",
"."
] | da674fbec5bf3d5bd2a2141680a4c141113eb6b0 | https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Field/Model/RepeaterField.php#L119-L122 | train |
asaritech/ukey1-php-sdk | src/Ukey1/Endpoints/Authentication/User.php | User.jwt | private function jwt()
{
if (!$this->jwt) {
if (!$this->accessToken) {
throw new EndpointException("No access token was provided");
}
$this->jwt = (new Parser())->parse($this->accessToken);
$this->checkSignature();
}
} | php | private function jwt()
{
if (!$this->jwt) {
if (!$this->accessToken) {
throw new EndpointException("No access token was provided");
}
$this->jwt = (new Parser())->parse($this->accessToken);
$this->checkSignature();
}
} | [
"private",
"function",
"jwt",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jwt",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"accessToken",
")",
"{",
"throw",
"new",
"EndpointException",
"(",
"\"No access token was provided\"",
")",
";",
"}",
"$",
"this",
"->",
"jwt",
"=",
"(",
"new",
"Parser",
"(",
")",
")",
"->",
"parse",
"(",
"$",
"this",
"->",
"accessToken",
")",
";",
"$",
"this",
"->",
"checkSignature",
"(",
")",
";",
"}",
"}"
] | Create JWT object from access token string
@throws EndpointException | [
"Create",
"JWT",
"object",
"from",
"access",
"token",
"string"
] | a4a306b9c71db8644dfd85e0e231f2b2b21bdd3a | https://github.com/asaritech/ukey1-php-sdk/blob/a4a306b9c71db8644dfd85e0e231f2b2b21bdd3a/src/Ukey1/Endpoints/Authentication/User.php#L148-L158 | train |
asaritech/ukey1-php-sdk | src/Ukey1/Endpoints/Authentication/User.php | User.valid | public function valid()
{
$this->jwt();
$data = new ValidationData();
if ($this->leeway != 0) {
$data->setCurrentTime(time() + $this->leeway);
}
return $this->jwt->validate($data);
} | php | public function valid()
{
$this->jwt();
$data = new ValidationData();
if ($this->leeway != 0) {
$data->setCurrentTime(time() + $this->leeway);
}
return $this->jwt->validate($data);
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"$",
"this",
"->",
"jwt",
"(",
")",
";",
"$",
"data",
"=",
"new",
"ValidationData",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"leeway",
"!=",
"0",
")",
"{",
"$",
"data",
"->",
"setCurrentTime",
"(",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"leeway",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jwt",
"->",
"validate",
"(",
"$",
"data",
")",
";",
"}"
] | Return if access token is valid
@return bool | [
"Return",
"if",
"access",
"token",
"is",
"valid"
] | a4a306b9c71db8644dfd85e0e231f2b2b21bdd3a | https://github.com/asaritech/ukey1-php-sdk/blob/a4a306b9c71db8644dfd85e0e231f2b2b21bdd3a/src/Ukey1/Endpoints/Authentication/User.php#L238-L249 | train |
DimNS/SimpleCSRF | src/SimpleCSRF.php | SimpleCSRF.getToken | public function getToken()
{
if (isset($_SESSION[$this->session_name])) {
return $_SESSION[$this->session_name];
} else {
$token = uniqid($this->randomString());
$_SESSION[$this->session_name] = $token;
return $token;
}
} | php | public function getToken()
{
if (isset($_SESSION[$this->session_name])) {
return $_SESSION[$this->session_name];
} else {
$token = uniqid($this->randomString());
$_SESSION[$this->session_name] = $token;
return $token;
}
} | [
"public",
"function",
"getToken",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"session_name",
"]",
")",
")",
"{",
"return",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"session_name",
"]",
";",
"}",
"else",
"{",
"$",
"token",
"=",
"uniqid",
"(",
"$",
"this",
"->",
"randomString",
"(",
")",
")",
";",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"session_name",
"]",
"=",
"$",
"token",
";",
"return",
"$",
"token",
";",
"}",
"}"
] | Getting a token
@return string Return result
@version v2.0.0
@author Dmitrii Shcherbakov <atomcms@ya.ru> | [
"Getting",
"a",
"token"
] | 8bd8fe2e9fe8aa90334b88f8fa398fcf3817ba45 | https://github.com/DimNS/SimpleCSRF/blob/8bd8fe2e9fe8aa90334b88f8fa398fcf3817ba45/src/SimpleCSRF.php#L49-L58 | train |
DimNS/SimpleCSRF | src/SimpleCSRF.php | SimpleCSRF.validateToken | public function validateToken($token)
{
if (isset($_SESSION[$this->session_name])) {
if ($_SESSION[$this->session_name] === $token) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function validateToken($token)
{
if (isset($_SESSION[$this->session_name])) {
if ($_SESSION[$this->session_name] === $token) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"validateToken",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"session_name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"session_name",
"]",
"===",
"$",
"token",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Checking the token
@param string $token The token to check
@return boolean Return result
@version v2.0.0
@author Dmitrii Shcherbakov <atomcms@ya.ru> | [
"Checking",
"the",
"token"
] | 8bd8fe2e9fe8aa90334b88f8fa398fcf3817ba45 | https://github.com/DimNS/SimpleCSRF/blob/8bd8fe2e9fe8aa90334b88f8fa398fcf3817ba45/src/SimpleCSRF.php#L70-L81 | train |
emeric0101/PHPEntityManagerRest.Server | src/Service/Auth.php | Auth.createTable | private function createTable($rights) {
$table = [];
foreach ($rights as $flag => $right) {
$table[$flag] = new RightGroup($flag);
}
foreach ($rights as $flag => $right) {
$this->parseRightGroup($right, $flag, $table);
}
return $table;
} | php | private function createTable($rights) {
$table = [];
foreach ($rights as $flag => $right) {
$table[$flag] = new RightGroup($flag);
}
foreach ($rights as $flag => $right) {
$this->parseRightGroup($right, $flag, $table);
}
return $table;
} | [
"private",
"function",
"createTable",
"(",
"$",
"rights",
")",
"{",
"$",
"table",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rights",
"as",
"$",
"flag",
"=>",
"$",
"right",
")",
"{",
"$",
"table",
"[",
"$",
"flag",
"]",
"=",
"new",
"RightGroup",
"(",
"$",
"flag",
")",
";",
"}",
"foreach",
"(",
"$",
"rights",
"as",
"$",
"flag",
"=>",
"$",
"right",
")",
"{",
"$",
"this",
"->",
"parseRightGroup",
"(",
"$",
"right",
",",
"$",
"flag",
",",
"$",
"table",
")",
";",
"}",
"return",
"$",
"table",
";",
"}"
] | Create the right table from the Config | [
"Create",
"the",
"right",
"table",
"from",
"the",
"Config"
] | 532db4f89c99b5775cbc1bcf7e0fd02c7a1c1bd5 | https://github.com/emeric0101/PHPEntityManagerRest.Server/blob/532db4f89c99b5775cbc1bcf7e0fd02c7a1c1bd5/src/Service/Auth.php#L67-L77 | train |
davin-bao/php-git | src/Controllers/AssetController.php | AssetController.js | public function js($name){
$content = $this->dumpAssetsToString('js', $name);
$response = new Response(
$content, 200, array(
'Content-Type' => 'text/javascript',
)
);
return $this->cacheResponse($response);
} | php | public function js($name){
$content = $this->dumpAssetsToString('js', $name);
$response = new Response(
$content, 200, array(
'Content-Type' => 'text/javascript',
)
);
return $this->cacheResponse($response);
} | [
"public",
"function",
"js",
"(",
"$",
"name",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"dumpAssetsToString",
"(",
"'js'",
",",
"$",
"name",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"content",
",",
"200",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'text/javascript'",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"cacheResponse",
"(",
"$",
"response",
")",
";",
"}"
] | Return the javascript for the PhpGit
@return \Symfony\Component\HttpFoundation\Response | [
"Return",
"the",
"javascript",
"for",
"the",
"PhpGit"
] | 9ae1997dc07978a3e647d44cba433d6638474c5c | https://github.com/davin-bao/php-git/blob/9ae1997dc07978a3e647d44cba433d6638474c5c/src/Controllers/AssetController.php#L19-L30 | train |
davin-bao/php-git | src/Controllers/AssetController.php | AssetController.css | public function css($name) {
$content = $this->dumpAssetsToString('css', $name);
$response = new Response(
$content, 200, array(
'Content-Type' => 'text/css',
)
);
return $this->cacheResponse($response);
} | php | public function css($name) {
$content = $this->dumpAssetsToString('css', $name);
$response = new Response(
$content, 200, array(
'Content-Type' => 'text/css',
)
);
return $this->cacheResponse($response);
} | [
"public",
"function",
"css",
"(",
"$",
"name",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"dumpAssetsToString",
"(",
"'css'",
",",
"$",
"name",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"content",
",",
"200",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'text/css'",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"cacheResponse",
"(",
"$",
"response",
")",
";",
"}"
] | Return the stylesheets for the PhpGit
@return \Symfony\Component\HttpFoundation\Response | [
"Return",
"the",
"stylesheets",
"for",
"the",
"PhpGit"
] | 9ae1997dc07978a3e647d44cba433d6638474c5c | https://github.com/davin-bao/php-git/blob/9ae1997dc07978a3e647d44cba433d6638474c5c/src/Controllers/AssetController.php#L37-L48 | train |
slickframework/form | src/Renderer/AbstractRenderer.php | AbstractRenderer.getEngine | public function getEngine()
{
if (null === $this->engine) {
$this->setEngine(TemplateFactory::getEngine());
}
return $this->engine;
} | php | public function getEngine()
{
if (null === $this->engine) {
$this->setEngine(TemplateFactory::getEngine());
}
return $this->engine;
} | [
"public",
"function",
"getEngine",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"engine",
")",
"{",
"$",
"this",
"->",
"setEngine",
"(",
"TemplateFactory",
"::",
"getEngine",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"engine",
";",
"}"
] | Returns the current template engine
If no template is provided a new one is created with default settings.
@return EngineInterface | [
"Returns",
"the",
"current",
"template",
"engine"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Renderer/AbstractRenderer.php#L74-L80 | train |
slickframework/form | src/Renderer/AbstractRenderer.php | AbstractRenderer.getAttributes | public function getAttributes()
{
$result = [];
foreach ($this->element->getAttributes() as $attribute => $value) {
if (null === $value) {
$result[] = $attribute;
continue;
}
$result[] = "{$attribute}=\"{$value}\"";
}
return implode(' ', $result);
} | php | public function getAttributes()
{
$result = [];
foreach ($this->element->getAttributes() as $attribute => $value) {
if (null === $value) {
$result[] = $attribute;
continue;
}
$result[] = "{$attribute}=\"{$value}\"";
}
return implode(' ', $result);
} | [
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"element",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"attribute",
";",
"continue",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"\"{$attribute}=\\\"{$value}\\\"\"",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"result",
")",
";",
"}"
] | Returns the elements's attributes as a string
@return string | [
"Returns",
"the",
"elements",
"s",
"attributes",
"as",
"a",
"string"
] | e7d536b3bad49194e246ff93587da2589e31a003 | https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Renderer/AbstractRenderer.php#L100-L112 | train |
borobudur-php/borobudur | src/Borobudur/Component/Ddd/ModelMapperTrait.php | ModelMapperTrait.fill | protected function fill(Model $model, object $data): Model
{
$mapper = new ObjectMapper();
return $mapper->map($model)->fill($data);
} | php | protected function fill(Model $model, object $data): Model
{
$mapper = new ObjectMapper();
return $mapper->map($model)->fill($data);
} | [
"protected",
"function",
"fill",
"(",
"Model",
"$",
"model",
",",
"object",
"$",
"data",
")",
":",
"Model",
"{",
"$",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"return",
"$",
"mapper",
"->",
"map",
"(",
"$",
"model",
")",
"->",
"fill",
"(",
"$",
"data",
")",
";",
"}"
] | Fill the model with given data.
@param Model $model
@param object $data
@return Model|mixed | [
"Fill",
"the",
"model",
"with",
"given",
"data",
"."
] | 6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44 | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Ddd/ModelMapperTrait.php#L32-L37 | train |
borobudur-php/borobudur | src/Borobudur/Component/Ddd/ModelMapperTrait.php | ModelMapperTrait.setId | protected function setId(Identifier $id, Model $model): void
{
$prop = new ReflectionProperty(get_class($model), 'id');
$prop->setAccessible(true);
$prop->setValue($model, $id);
} | php | protected function setId(Identifier $id, Model $model): void
{
$prop = new ReflectionProperty(get_class($model), 'id');
$prop->setAccessible(true);
$prop->setValue($model, $id);
} | [
"protected",
"function",
"setId",
"(",
"Identifier",
"$",
"id",
",",
"Model",
"$",
"model",
")",
":",
"void",
"{",
"$",
"prop",
"=",
"new",
"ReflectionProperty",
"(",
"get_class",
"(",
"$",
"model",
")",
",",
"'id'",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"prop",
"->",
"setValue",
"(",
"$",
"model",
",",
"$",
"id",
")",
";",
"}"
] | Set the protected id value.
@param Identifier $id
@param Model $model | [
"Set",
"the",
"protected",
"id",
"value",
"."
] | 6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44 | https://github.com/borobudur-php/borobudur/blob/6ab0d97e1819ba0b96dc4c3bca3a7c9b1217bd44/src/Borobudur/Component/Ddd/ModelMapperTrait.php#L45-L50 | train |
IftekherSunny/Planet-Framework | src/Sun/Console/Application.php | Application.bootCommand | protected function bootCommand()
{
foreach ($this->commands as $command) {
$this->add($this->app->make($command));
}
} | php | protected function bootCommand()
{
foreach ($this->commands as $command) {
$this->add($this->app->make($command));
}
} | [
"protected",
"function",
"bootCommand",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"command",
")",
")",
";",
"}",
"}"
] | Resolve all dependencies | [
"Resolve",
"all",
"dependencies"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Console/Application.php#L48-L53 | train |
IftekherSunny/Planet-Framework | src/Sun/Console/Application.php | Application.getPhpMigCommands | protected function getPhpMigCommands()
{
return [
new Command\CheckCommand(),
new Command\DownCommand(),
new Command\GenerateCommand(),
new Command\MigrateCommand(),
new Command\RedoCommand(),
new Command\RollbackCommand(),
new Command\StatusCommand(),
new Command\UpCommand(),
];
} | php | protected function getPhpMigCommands()
{
return [
new Command\CheckCommand(),
new Command\DownCommand(),
new Command\GenerateCommand(),
new Command\MigrateCommand(),
new Command\RedoCommand(),
new Command\RollbackCommand(),
new Command\StatusCommand(),
new Command\UpCommand(),
];
} | [
"protected",
"function",
"getPhpMigCommands",
"(",
")",
"{",
"return",
"[",
"new",
"Command",
"\\",
"CheckCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"DownCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"GenerateCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"MigrateCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"RedoCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"RollbackCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"StatusCommand",
"(",
")",
",",
"new",
"Command",
"\\",
"UpCommand",
"(",
")",
",",
"]",
";",
"}"
] | Get PHP Mig console commands
@return array | [
"Get",
"PHP",
"Mig",
"console",
"commands"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Console/Application.php#L71-L83 | train |
spiral/views | src/ViewCache.php | ViewCache.resetPath | public function resetPath(string $path)
{
foreach ($this->cache as &$cache) {
unset($cache[$path], $cache);
}
} | php | public function resetPath(string $path)
{
foreach ($this->cache as &$cache) {
unset($cache[$path], $cache);
}
} | [
"public",
"function",
"resetPath",
"(",
"string",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"cache",
"as",
"&",
"$",
"cache",
")",
"{",
"unset",
"(",
"$",
"cache",
"[",
"$",
"path",
"]",
",",
"$",
"cache",
")",
";",
"}",
"}"
] | Reset view cache from all the contexts.
@param string $path | [
"Reset",
"view",
"cache",
"from",
"all",
"the",
"contexts",
"."
] | 0e35697204dfffabf71546d20e89f14b50414a9a | https://github.com/spiral/views/blob/0e35697204dfffabf71546d20e89f14b50414a9a/src/ViewCache.php#L37-L42 | train |
m6w6/pq-gateway | lib/pq/Gateway/Rowset.php | Rowset.create | function create($txn = true) {
if ($txn && !($txn instanceof pq\Transaction)) {
$txn = $this->table->getConnection()->startTransaction();
}
try {
foreach ($this->rows as $row) {
$row->create();
}
} catch (\Exception $e) {
if ($txn) {
$txn->rollback();
}
throw $e;
}
if ($txn) {
$txn->commit();
}
return $this;
} | php | function create($txn = true) {
if ($txn && !($txn instanceof pq\Transaction)) {
$txn = $this->table->getConnection()->startTransaction();
}
try {
foreach ($this->rows as $row) {
$row->create();
}
} catch (\Exception $e) {
if ($txn) {
$txn->rollback();
}
throw $e;
}
if ($txn) {
$txn->commit();
}
return $this;
} | [
"function",
"create",
"(",
"$",
"txn",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"txn",
"&&",
"!",
"(",
"$",
"txn",
"instanceof",
"pq",
"\\",
"Transaction",
")",
")",
"{",
"$",
"txn",
"=",
"$",
"this",
"->",
"table",
"->",
"getConnection",
"(",
")",
"->",
"startTransaction",
"(",
")",
";",
"}",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"row",
"->",
"create",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"txn",
")",
"{",
"$",
"txn",
"->",
"rollback",
"(",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"$",
"txn",
")",
"{",
"$",
"txn",
"->",
"commit",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Create all rows of this rowset
@param mixed $txn
@return \pq\Gateway\Rowset
@throws Exception | [
"Create",
"all",
"rows",
"of",
"this",
"rowset"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Rowset.php#L106-L124 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.