id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
2,300
slickframework/validator
src/StaticValidator.php
StaticValidator.checkValidator
private static function checkValidator($validator) { if (!array_key_exists($validator, self::$validators)) { return self::checkClass($validator); } return self::$validators[$validator]; }
php
private static function checkValidator($validator) { if (!array_key_exists($validator, self::$validators)) { return self::checkClass($validator); } return self::$validators[$validator]; }
[ "private", "static", "function", "checkValidator", "(", "$", "validator", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "validator", ",", "self", "::", "$", "validators", ")", ")", "{", "return", "self", "::", "checkClass", "(", "$", "validator", ")", ";", "}", "return", "self", "::", "$", "validators", "[", "$", "validator", "]", ";", "}" ]
Check if the provided validator is a known alias or a valid validator interface class @param string $validator Alias or FQ class name of the validator @return string
[ "Check", "if", "the", "provided", "validator", "is", "a", "known", "alias", "or", "a", "valid", "validator", "interface", "class" ]
d93f91e36b1d12f8fe9559f9e038b6a9f9357d8e
https://github.com/slickframework/validator/blob/d93f91e36b1d12f8fe9559f9e038b6a9f9357d8e/src/StaticValidator.php#L144-L150
2,301
slickframework/validator
src/StaticValidator.php
StaticValidator.checkClass
private static function checkClass($validator) { if (! class_exists($validator)) { throw new InvalidArgumentException( "Class {$validator} does not exists." ); } if (! is_subclass_of($validator, ValidatorInterface::class)) { throw new Exception\UnknownValidatorClassException( "The validator '{$validator}' is not defined or does not " . "implements the Slick\\Validator\\ValidatorInterface interface" ); } return $validator; }
php
private static function checkClass($validator) { if (! class_exists($validator)) { throw new InvalidArgumentException( "Class {$validator} does not exists." ); } if (! is_subclass_of($validator, ValidatorInterface::class)) { throw new Exception\UnknownValidatorClassException( "The validator '{$validator}' is not defined or does not " . "implements the Slick\\Validator\\ValidatorInterface interface" ); } return $validator; }
[ "private", "static", "function", "checkClass", "(", "$", "validator", ")", "{", "if", "(", "!", "class_exists", "(", "$", "validator", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Class {$validator} does not exists.\"", ")", ";", "}", "if", "(", "!", "is_subclass_of", "(", "$", "validator", ",", "ValidatorInterface", "::", "class", ")", ")", "{", "throw", "new", "Exception", "\\", "UnknownValidatorClassException", "(", "\"The validator '{$validator}' is not defined or does not \"", ".", "\"implements the Slick\\\\Validator\\\\ValidatorInterface interface\"", ")", ";", "}", "return", "$", "validator", ";", "}" ]
Check if is a valid validator class @param string $validator FQ class name of validator @return string
[ "Check", "if", "is", "a", "valid", "validator", "class" ]
d93f91e36b1d12f8fe9559f9e038b6a9f9357d8e
https://github.com/slickframework/validator/blob/d93f91e36b1d12f8fe9559f9e038b6a9f9357d8e/src/StaticValidator.php#L159-L175
2,302
ilya-dev/block
src/Block/Parser.php
Parser.transformRaw
public function transformRaw($comment) { $comment = preg_replace('/[\/\*]/', '', $comment); $chunks = array_map('trim', explode(PHP_EOL, $comment)); return implode(PHP_EOL, array_filter($chunks)); }
php
public function transformRaw($comment) { $comment = preg_replace('/[\/\*]/', '', $comment); $chunks = array_map('trim', explode(PHP_EOL, $comment)); return implode(PHP_EOL, array_filter($chunks)); }
[ "public", "function", "transformRaw", "(", "$", "comment", ")", "{", "$", "comment", "=", "preg_replace", "(", "'/[\\/\\*]/'", ",", "''", ",", "$", "comment", ")", ";", "$", "chunks", "=", "array_map", "(", "'trim'", ",", "explode", "(", "PHP_EOL", ",", "$", "comment", ")", ")", ";", "return", "implode", "(", "PHP_EOL", ",", "array_filter", "(", "$", "chunks", ")", ")", ";", "}" ]
Prettify a raw comment. @param string $comment @return string
[ "Prettify", "a", "raw", "comment", "." ]
46aeff9abd1e61a4247e1cf3aed3f8c7561e2bd8
https://github.com/ilya-dev/block/blob/46aeff9abd1e61a4247e1cf3aed3f8c7561e2bd8/src/Block/Parser.php#L11-L17
2,303
monolyth-php/formulaic
src/Radio.php
Radio.id
public function id() : string { $name = $this->name(); $name = preg_replace("@\[\]$@", '', $name); if ($name) { return $name.'-'.$this->value; } return $name; }
php
public function id() : string { $name = $this->name(); $name = preg_replace("@\[\]$@", '', $name); if ($name) { return $name.'-'.$this->value; } return $name; }
[ "public", "function", "id", "(", ")", ":", "string", "{", "$", "name", "=", "$", "this", "->", "name", "(", ")", ";", "$", "name", "=", "preg_replace", "(", "\"@\\[\\]$@\"", ",", "''", ",", "$", "name", ")", ";", "if", "(", "$", "name", ")", "{", "return", "$", "name", ".", "'-'", ".", "$", "this", "->", "value", ";", "}", "return", "$", "name", ";", "}" ]
Returns the ID of the element. @return string
[ "Returns", "the", "ID", "of", "the", "element", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio.php#L16-L24
2,304
monolyth-php/formulaic
src/Radio.php
Radio.isRequired
public function isRequired() : Testable { $this->attributes['required'] = true; return $this->addTest('required', function($value) { return $this->checked(); }); }
php
public function isRequired() : Testable { $this->attributes['required'] = true; return $this->addTest('required', function($value) { return $this->checked(); }); }
[ "public", "function", "isRequired", "(", ")", ":", "Testable", "{", "$", "this", "->", "attributes", "[", "'required'", "]", "=", "true", ";", "return", "$", "this", "->", "addTest", "(", "'required'", ",", "function", "(", "$", "value", ")", "{", "return", "$", "this", "->", "checked", "(", ")", ";", "}", ")", ";", "}" ]
Mark the field as required. @return self
[ "Mark", "the", "field", "as", "required", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio.php#L55-L61
2,305
monolyth-php/formulaic
src/Radio.php
Radio.inGroup
public function inGroup(bool $status = null) : bool { if (!is_null($status)) { $this->inGroup = $status; } return $this->inGroup; }
php
public function inGroup(bool $status = null) : bool { if (!is_null($status)) { $this->inGroup = $status; } return $this->inGroup; }
[ "public", "function", "inGroup", "(", "bool", "$", "status", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "is_null", "(", "$", "status", ")", ")", "{", "$", "this", "->", "inGroup", "=", "$", "status", ";", "}", "return", "$", "this", "->", "inGroup", ";", "}" ]
Get or set whether this element is part of a group. @param bool $status @return bool
[ "Get", "or", "set", "whether", "this", "element", "is", "part", "of", "a", "group", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio.php#L69-L75
2,306
easy-system/es-view
src/Resolver.php
Resolver.registerModulePath
public function registerModulePath($moduleName, $path, $addPrefix = true) { $normalized = static::normalizePath($path) . PHP_DS; if ($addPrefix) { $normalized .= static::DEFAULT_PREFIX . PHP_DS; } $this->modulesMap[static::normalizeModule($moduleName)] = $normalized; return $this; }
php
public function registerModulePath($moduleName, $path, $addPrefix = true) { $normalized = static::normalizePath($path) . PHP_DS; if ($addPrefix) { $normalized .= static::DEFAULT_PREFIX . PHP_DS; } $this->modulesMap[static::normalizeModule($moduleName)] = $normalized; return $this; }
[ "public", "function", "registerModulePath", "(", "$", "moduleName", ",", "$", "path", ",", "$", "addPrefix", "=", "true", ")", "{", "$", "normalized", "=", "static", "::", "normalizePath", "(", "$", "path", ")", ".", "PHP_DS", ";", "if", "(", "$", "addPrefix", ")", "{", "$", "normalized", ".=", "static", "::", "DEFAULT_PREFIX", ".", "PHP_DS", ";", "}", "$", "this", "->", "modulesMap", "[", "static", "::", "normalizeModule", "(", "$", "moduleName", ")", "]", "=", "$", "normalized", ";", "return", "$", "this", ";", "}" ]
Registers module path. @param string $moduleName The module name @param string $path The path to module directory @param bool $addPrefix Optional; true by default. To add a prefix to the directory path @return self
[ "Registers", "module", "path", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L80-L89
2,307
easy-system/es-view
src/Resolver.php
Resolver.registerTemplatePath
public function registerTemplatePath($templateName, $path) { $this->templatesMap[(string) $templateName] = (string) $path; return $this; }
php
public function registerTemplatePath($templateName, $path) { $this->templatesMap[(string) $templateName] = (string) $path; return $this; }
[ "public", "function", "registerTemplatePath", "(", "$", "templateName", ",", "$", "path", ")", "{", "$", "this", "->", "templatesMap", "[", "(", "string", ")", "$", "templateName", "]", "=", "(", "string", ")", "$", "path", ";", "return", "$", "this", ";", "}" ]
Register the template path. @param string $templateName The template name @param string $path The path to template @return self
[ "Register", "the", "template", "path", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L123-L128
2,308
easy-system/es-view
src/Resolver.php
Resolver.resolveModule
protected function resolveModule($template, $module) { $fullName = $module . '::' . $template; if (isset($this->templatesMap[$fullName])) { $file = $this->normalizePath($this->templatesMap[$fullName]); if (! file_exists($file)) { throw new RuntimeException(sprintf( 'The file "%s" of template "%s" not exists.', $file, $template )); } return $file; } return $this->findFile($module, $template); }
php
protected function resolveModule($template, $module) { $fullName = $module . '::' . $template; if (isset($this->templatesMap[$fullName])) { $file = $this->normalizePath($this->templatesMap[$fullName]); if (! file_exists($file)) { throw new RuntimeException(sprintf( 'The file "%s" of template "%s" not exists.', $file, $template )); } return $file; } return $this->findFile($module, $template); }
[ "protected", "function", "resolveModule", "(", "$", "template", ",", "$", "module", ")", "{", "$", "fullName", "=", "$", "module", ".", "'::'", ".", "$", "template", ";", "if", "(", "isset", "(", "$", "this", "->", "templatesMap", "[", "$", "fullName", "]", ")", ")", "{", "$", "file", "=", "$", "this", "->", "normalizePath", "(", "$", "this", "->", "templatesMap", "[", "$", "fullName", "]", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The file \"%s\" of template \"%s\" not exists.'", ",", "$", "file", ",", "$", "template", ")", ")", ";", "}", "return", "$", "file", ";", "}", "return", "$", "this", "->", "findFile", "(", "$", "module", ",", "$", "template", ")", ";", "}" ]
Resolves the specified module. @param string $template The template @param string $module The normalized module name @throws \RuntimeException If the registered template file not exists @return string|false Returns path to file if it found or false otherwise
[ "Resolves", "the", "specified", "module", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L225-L242
2,309
easy-system/es-view
src/Resolver.php
Resolver.findFile
protected function findFile($module, $template) { if (! isset($this->modulesMap[$module])) { return false; } $tpl = str_replace('/', PHP_DS, $template); $found = glob($this->modulesMap[$module] . $tpl . '.*'); if (! $found) { return false; } $file = $found[0]; $this->templatesMap[$module . '::' . $template] = $file; return $file; }
php
protected function findFile($module, $template) { if (! isset($this->modulesMap[$module])) { return false; } $tpl = str_replace('/', PHP_DS, $template); $found = glob($this->modulesMap[$module] . $tpl . '.*'); if (! $found) { return false; } $file = $found[0]; $this->templatesMap[$module . '::' . $template] = $file; return $file; }
[ "protected", "function", "findFile", "(", "$", "module", ",", "$", "template", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "modulesMap", "[", "$", "module", "]", ")", ")", "{", "return", "false", ";", "}", "$", "tpl", "=", "str_replace", "(", "'/'", ",", "PHP_DS", ",", "$", "template", ")", ";", "$", "found", "=", "glob", "(", "$", "this", "->", "modulesMap", "[", "$", "module", "]", ".", "$", "tpl", ".", "'.*'", ")", ";", "if", "(", "!", "$", "found", ")", "{", "return", "false", ";", "}", "$", "file", "=", "$", "found", "[", "0", "]", ";", "$", "this", "->", "templatesMap", "[", "$", "module", ".", "'::'", ".", "$", "template", "]", "=", "$", "file", ";", "return", "$", "file", ";", "}" ]
Finds file. @param string $module The normalized module namespace @param string $template The template name @return string|false Returns path to file if it found or false otherwise
[ "Finds", "file", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L252-L267
2,310
easy-system/es-view
src/Resolver.php
Resolver.normalizeModule
public static function normalizeModule($module) { $module = (string) $module; if (isset(static::$moduleNames[$module])) { return static::$moduleNames[$module]; } $normalized = trim(str_replace('\\', '/', $module), '/'); $result = strtolower( preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $normalized) ); static::$moduleNames[$module] = $result; return $result; }
php
public static function normalizeModule($module) { $module = (string) $module; if (isset(static::$moduleNames[$module])) { return static::$moduleNames[$module]; } $normalized = trim(str_replace('\\', '/', $module), '/'); $result = strtolower( preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $normalized) ); static::$moduleNames[$module] = $result; return $result; }
[ "public", "static", "function", "normalizeModule", "(", "$", "module", ")", "{", "$", "module", "=", "(", "string", ")", "$", "module", ";", "if", "(", "isset", "(", "static", "::", "$", "moduleNames", "[", "$", "module", "]", ")", ")", "{", "return", "static", "::", "$", "moduleNames", "[", "$", "module", "]", ";", "}", "$", "normalized", "=", "trim", "(", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "module", ")", ",", "'/'", ")", ";", "$", "result", "=", "strtolower", "(", "preg_replace", "(", "'/([a-zA-Z])(?=[A-Z])/'", ",", "'$1-'", ",", "$", "normalized", ")", ")", ";", "static", "::", "$", "moduleNames", "[", "$", "module", "]", "=", "$", "result", ";", "return", "$", "result", ";", "}" ]
Normalizes module name. @param string $module The module namespace @return string The normalized module name
[ "Normalizes", "module", "name", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L276-L291
2,311
easy-system/es-view
src/Resolver.php
Resolver.normalizePath
protected static function normalizePath($path) { $normalized = str_replace(['\\', '/'], PHP_DS, (string) $path); return rtrim($normalized, PHP_DS); }
php
protected static function normalizePath($path) { $normalized = str_replace(['\\', '/'], PHP_DS, (string) $path); return rtrim($normalized, PHP_DS); }
[ "protected", "static", "function", "normalizePath", "(", "$", "path", ")", "{", "$", "normalized", "=", "str_replace", "(", "[", "'\\\\'", ",", "'/'", "]", ",", "PHP_DS", ",", "(", "string", ")", "$", "path", ")", ";", "return", "rtrim", "(", "$", "normalized", ",", "PHP_DS", ")", ";", "}" ]
Normalizes path. @param string $path The path @return string Returns the normalized path
[ "Normalizes", "path", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/Resolver.php#L300-L305
2,312
AlexHowansky/ork-base
src/Filter/StringToTime.php
StringToTime.filter
public function filter($value) { // If it's already a timestamp, return it as is. if (preg_match('/^-?\d+$/', $value) === 1) { if ($value < 0) { throw new \DomainException('Invalid value'); } return $value; } // Allow SQL specials. if ($this->getConfig('allowSqlSpecials') === true) { $temp = strtolower($value); if ($temp === 'now()' || $temp === 'current_timestamp') { return time(); } } // Catch invalid strings. $time = strtotime($value); if ($time === false) { throw new \DomainException('Invalid value'); } return $time; }
php
public function filter($value) { // If it's already a timestamp, return it as is. if (preg_match('/^-?\d+$/', $value) === 1) { if ($value < 0) { throw new \DomainException('Invalid value'); } return $value; } // Allow SQL specials. if ($this->getConfig('allowSqlSpecials') === true) { $temp = strtolower($value); if ($temp === 'now()' || $temp === 'current_timestamp') { return time(); } } // Catch invalid strings. $time = strtotime($value); if ($time === false) { throw new \DomainException('Invalid value'); } return $time; }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "// If it's already a timestamp, return it as is.", "if", "(", "preg_match", "(", "'/^-?\\d+$/'", ",", "$", "value", ")", "===", "1", ")", "{", "if", "(", "$", "value", "<", "0", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Invalid value'", ")", ";", "}", "return", "$", "value", ";", "}", "// Allow SQL specials.", "if", "(", "$", "this", "->", "getConfig", "(", "'allowSqlSpecials'", ")", "===", "true", ")", "{", "$", "temp", "=", "strtolower", "(", "$", "value", ")", ";", "if", "(", "$", "temp", "===", "'now()'", "||", "$", "temp", "===", "'current_timestamp'", ")", "{", "return", "time", "(", ")", ";", "}", "}", "// Catch invalid strings.", "$", "time", "=", "strtotime", "(", "$", "value", ")", ";", "if", "(", "$", "time", "===", "false", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Invalid value'", ")", ";", "}", "return", "$", "time", ";", "}" ]
Convert a string to a timestamp. @param string $value A string to convert to a timestamp. @return integer The converted timestamp.
[ "Convert", "a", "string", "to", "a", "timestamp", "." ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Filter/StringToTime.php#L41-L68
2,313
budkit/budkit-framework
src/Budkit/Validation/Sanitize.php
Sanitize.filterArray
private function filterArray(array $data, array $options) { $this->sanitized = true; return filter_var_array($data, $options, true); }
php
private function filterArray(array $data, array $options) { $this->sanitized = true; return filter_var_array($data, $options, true); }
[ "private", "function", "filterArray", "(", "array", "$", "data", ",", "array", "$", "options", ")", "{", "$", "this", "->", "sanitized", "=", "true", ";", "return", "filter_var_array", "(", "$", "data", ",", "$", "options", ",", "true", ")", ";", "}" ]
Filters an Array recursively @param type $array
[ "Filters", "an", "Array", "recursively" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Validation/Sanitize.php#L130-L135
2,314
budkit/budkit-framework
src/Budkit/Validation/Sanitize.php
Sanitize.word
public function word($data, $default = '', $options = []) { //First word in a sanitized string $sentence = $this->string($data, $default, $options, false); //@TODO validate string before breaking into words; //Requires php5.3!! return (string)strstr($sentence, ' ', true); }
php
public function word($data, $default = '', $options = []) { //First word in a sanitized string $sentence = $this->string($data, $default, $options, false); //@TODO validate string before breaking into words; //Requires php5.3!! return (string)strstr($sentence, ' ', true); }
[ "public", "function", "word", "(", "$", "data", ",", "$", "default", "=", "''", ",", "$", "options", "=", "[", "]", ")", "{", "//First word in a sanitized string", "$", "sentence", "=", "$", "this", "->", "string", "(", "$", "data", ",", "$", "default", ",", "$", "options", ",", "false", ")", ";", "//@TODO validate string before breaking into words;", "//Requires php5.3!!", "return", "(", "string", ")", "strstr", "(", "$", "sentence", ",", "' '", ",", "true", ")", ";", "}" ]
Returns the first word a sanitised string Strip tags, optionally strip or encode special characters. @param string $name @param string $verb @param array $flags
[ "Returns", "the", "first", "word", "a", "sanitised", "string", "Strip", "tags", "optionally", "strip", "or", "encode", "special", "characters", "." ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Validation/Sanitize.php#L420-L429
2,315
vinala/kernel
src/Cubes/Cube.php
Cube.setInstance
public static function setInstance($args) { $name = array_shift($args); $name = self::getAccessor($name); $reflect = new \ReflectionClass($name); return $reflect->newInstanceArgs($args); }
php
public static function setInstance($args) { $name = array_shift($args); $name = self::getAccessor($name); $reflect = new \ReflectionClass($name); return $reflect->newInstanceArgs($args); }
[ "public", "static", "function", "setInstance", "(", "$", "args", ")", "{", "$", "name", "=", "array_shift", "(", "$", "args", ")", ";", "$", "name", "=", "self", "::", "getAccessor", "(", "$", "name", ")", ";", "$", "reflect", "=", "new", "\\", "ReflectionClass", "(", "$", "name", ")", ";", "return", "$", "reflect", "->", "newInstanceArgs", "(", "$", "args", ")", ";", "}" ]
Set Instance. @param string $name @return mixed
[ "Set", "Instance", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Cubes/Cube.php#L40-L49
2,316
flowcode/AmulenPageBundle
src/Flowcode/PageBundle/Controller/AdminPageController.php
AdminPageController.createBlockAction
public function createBlockAction(Request $request, $type) { $entity = new Block(); $entity->setType($type); $form = $this->createBlockCreateForm($entity); $form->handleRequest($request); $availableLangs = $this->container->getParameter('flowcode_page.available_languages'); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $page = $entity->getPage(); foreach ($availableLangs as $key => $value) { $entityLang = new Block(); $entityLang->setName($entity->getName()); $entityLang->setLang($key); $entityLang->setContent($entity->getContent()); $entityLang->setPage($entity->getPage()); $entityLang->setType($type); $em->persist($entityLang); } $em->flush(); return $this->redirect($this->generateUrl('admin_page_show', array('id' => $page->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function createBlockAction(Request $request, $type) { $entity = new Block(); $entity->setType($type); $form = $this->createBlockCreateForm($entity); $form->handleRequest($request); $availableLangs = $this->container->getParameter('flowcode_page.available_languages'); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $page = $entity->getPage(); foreach ($availableLangs as $key => $value) { $entityLang = new Block(); $entityLang->setName($entity->getName()); $entityLang->setLang($key); $entityLang->setContent($entity->getContent()); $entityLang->setPage($entity->getPage()); $entityLang->setType($type); $em->persist($entityLang); } $em->flush(); return $this->redirect($this->generateUrl('admin_page_show', array('id' => $page->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "createBlockAction", "(", "Request", "$", "request", ",", "$", "type", ")", "{", "$", "entity", "=", "new", "Block", "(", ")", ";", "$", "entity", "->", "setType", "(", "$", "type", ")", ";", "$", "form", "=", "$", "this", "->", "createBlockCreateForm", "(", "$", "entity", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "availableLangs", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'flowcode_page.available_languages'", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "page", "=", "$", "entity", "->", "getPage", "(", ")", ";", "foreach", "(", "$", "availableLangs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "entityLang", "=", "new", "Block", "(", ")", ";", "$", "entityLang", "->", "setName", "(", "$", "entity", "->", "getName", "(", ")", ")", ";", "$", "entityLang", "->", "setLang", "(", "$", "key", ")", ";", "$", "entityLang", "->", "setContent", "(", "$", "entity", "->", "getContent", "(", ")", ")", ";", "$", "entityLang", "->", "setPage", "(", "$", "entity", "->", "getPage", "(", ")", ")", ";", "$", "entityLang", "->", "setType", "(", "$", "type", ")", ";", "$", "em", "->", "persist", "(", "$", "entityLang", ")", ";", "}", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_page_show'", ",", "array", "(", "'id'", "=>", "$", "page", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Block entity. @Route("/block/{type}", name="admin_page_block_create") @Method("POST") @Template("FlowcodePageBundle:AdminPage:new_block.html.twig")
[ "Creates", "a", "new", "Block", "entity", "." ]
41c90e1860d5f51aeda13cb42993b17cf14cf89f
https://github.com/flowcode/AmulenPageBundle/blob/41c90e1860d5f51aeda13cb42993b17cf14cf89f/src/Flowcode/PageBundle/Controller/AdminPageController.php#L326-L358
2,317
flowcode/AmulenPageBundle
src/Flowcode/PageBundle/Controller/AdminPageController.php
AdminPageController.editBlockAction
public function editBlockAction($id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('AmulenPageBundle:Block')->find($id); $availableEntityLangs = $em->getRepository('AmulenPageBundle:Block')->findBy(array('page' => $entity->getPage(), 'name' => $entity->getName())); if (!$entity) { throw $this->createNotFoundException('Unable to find Block entity.'); } $editForm = $this->createBlockEditForm($entity); $deleteForm = $this->createBlockDeleteForm($id); return array( 'entity' => $entity, 'availableEntityLangs' => $availableEntityLangs, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editBlockAction($id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('AmulenPageBundle:Block')->find($id); $availableEntityLangs = $em->getRepository('AmulenPageBundle:Block')->findBy(array('page' => $entity->getPage(), 'name' => $entity->getName())); if (!$entity) { throw $this->createNotFoundException('Unable to find Block entity.'); } $editForm = $this->createBlockEditForm($entity); $deleteForm = $this->createBlockDeleteForm($id); return array( 'entity' => $entity, 'availableEntityLangs' => $availableEntityLangs, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editBlockAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'AmulenPageBundle:Block'", ")", "->", "find", "(", "$", "id", ")", ";", "$", "availableEntityLangs", "=", "$", "em", "->", "getRepository", "(", "'AmulenPageBundle:Block'", ")", "->", "findBy", "(", "array", "(", "'page'", "=>", "$", "entity", "->", "getPage", "(", ")", ",", "'name'", "=>", "$", "entity", "->", "getName", "(", ")", ")", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Block entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createBlockEditForm", "(", "$", "entity", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createBlockDeleteForm", "(", "$", "id", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'availableEntityLangs'", "=>", "$", "availableEntityLangs", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to edit an existing Block entity. @Route("/block/{id}/edit", name="admin_page_block_edit") @Method("GET") @Template("FlowcodePageBundle:AdminPage:edit_block.html.twig")
[ "Displays", "a", "form", "to", "edit", "an", "existing", "Block", "entity", "." ]
41c90e1860d5f51aeda13cb42993b17cf14cf89f
https://github.com/flowcode/AmulenPageBundle/blob/41c90e1860d5f51aeda13cb42993b17cf14cf89f/src/Flowcode/PageBundle/Controller/AdminPageController.php#L438-L458
2,318
DevGroup-ru/yii2-admin-utils
src/Helper.php
Helper.returnUrl
public static function returnUrl() { if (self::$returnUrl === null) { $url = ['/' . ltrim(Yii::$app->requestedRoute, '/')]; foreach (Yii::$app->request->queryParams as $key => $value) { $url[$key] = $value; } self::$returnUrl = Url::to($url); } return self::$returnUrl; }
php
public static function returnUrl() { if (self::$returnUrl === null) { $url = ['/' . ltrim(Yii::$app->requestedRoute, '/')]; foreach (Yii::$app->request->queryParams as $key => $value) { $url[$key] = $value; } self::$returnUrl = Url::to($url); } return self::$returnUrl; }
[ "public", "static", "function", "returnUrl", "(", ")", "{", "if", "(", "self", "::", "$", "returnUrl", "===", "null", ")", "{", "$", "url", "=", "[", "'/'", ".", "ltrim", "(", "Yii", "::", "$", "app", "->", "requestedRoute", ",", "'/'", ")", "]", ";", "foreach", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "url", "[", "$", "key", "]", "=", "$", "value", ";", "}", "self", "::", "$", "returnUrl", "=", "Url", "::", "to", "(", "$", "url", ")", ";", "}", "return", "self", "::", "$", "returnUrl", ";", "}" ]
returnURL param value. Used for links from grids and etc. where we should return back to specified URL @return string
[ "returnURL", "param", "value", ".", "Used", "for", "links", "from", "grids", "and", "etc", ".", "where", "we", "should", "return", "back", "to", "specified", "URL" ]
15c1853a5ec264602de3ad82dbf70f85de66adff
https://github.com/DevGroup-ru/yii2-admin-utils/blob/15c1853a5ec264602de3ad82dbf70f85de66adff/src/Helper.php#L23-L34
2,319
unyx/console
input/Value.php
Value.setDefault
public function setDefault($default) : Value { if (isset($default) && !$this->mode->is(Value::OPTIONAL)) { throw new \InvalidArgumentException('Cannot set a default value for non-optional values.'); } $this->default = $default; return $this; }
php
public function setDefault($default) : Value { if (isset($default) && !$this->mode->is(Value::OPTIONAL)) { throw new \InvalidArgumentException('Cannot set a default value for non-optional values.'); } $this->default = $default; return $this; }
[ "public", "function", "setDefault", "(", "$", "default", ")", ":", "Value", "{", "if", "(", "isset", "(", "$", "default", ")", "&&", "!", "$", "this", "->", "mode", "->", "is", "(", "Value", "::", "OPTIONAL", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Cannot set a default value for non-optional values.'", ")", ";", "}", "$", "this", "->", "default", "=", "$", "default", ";", "return", "$", "this", ";", "}" ]
Sets the default value for the underlying Parameter. @param mixed $default The default value. @return $this @throws \InvalidArgumentException When an invalid default value is given.
[ "Sets", "the", "default", "value", "for", "the", "underlying", "Parameter", "." ]
b4a76e08bbb5428b0349c0ec4259a914f81a2957
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/input/Value.php#L89-L98
2,320
CupOfTea696/WordPress-Lib
src/Application.php
Application.registerContainerAliases
protected function registerContainerAliases() { $aliases = [ 'app' => ['Illuminate\Container\Container', 'Illuminate\Contracts\Container\Container'], 'config' => ['Illuminate\Config\Repository', 'Illuminate\Contracts\Config\Repository'], 'log' => ['Psr\Log\LoggerInterface'], ]; foreach ($aliases as $key => $aliases) { foreach ($aliases as $alias) { $this->alias($key, $alias); } } }
php
protected function registerContainerAliases() { $aliases = [ 'app' => ['Illuminate\Container\Container', 'Illuminate\Contracts\Container\Container'], 'config' => ['Illuminate\Config\Repository', 'Illuminate\Contracts\Config\Repository'], 'log' => ['Psr\Log\LoggerInterface'], ]; foreach ($aliases as $key => $aliases) { foreach ($aliases as $alias) { $this->alias($key, $alias); } } }
[ "protected", "function", "registerContainerAliases", "(", ")", "{", "$", "aliases", "=", "[", "'app'", "=>", "[", "'Illuminate\\Container\\Container'", ",", "'Illuminate\\Contracts\\Container\\Container'", "]", ",", "'config'", "=>", "[", "'Illuminate\\Config\\Repository'", ",", "'Illuminate\\Contracts\\Config\\Repository'", "]", ",", "'log'", "=>", "[", "'Psr\\Log\\LoggerInterface'", "]", ",", "]", ";", "foreach", "(", "$", "aliases", "as", "$", "key", "=>", "$", "aliases", ")", "{", "foreach", "(", "$", "aliases", "as", "$", "alias", ")", "{", "$", "this", "->", "alias", "(", "$", "key", ",", "$", "alias", ")", ";", "}", "}", "}" ]
Register the core container aliases. @return void
[ "Register", "the", "core", "container", "aliases", "." ]
7b31413dff6f4f70b3e2a2fc8172d0721152891d
https://github.com/CupOfTea696/WordPress-Lib/blob/7b31413dff6f4f70b3e2a2fc8172d0721152891d/src/Application.php#L182-L195
2,321
vi-kon/laravel-support
src/ViKon/Support/SupportServiceProvider.php
SupportServiceProvider.registerParameterBinder
protected function registerParameterBinder() { $this->app->singleton(RouteBinderRegister::class, function (Container $container) { return new RouteBinderRegister($container, $container->make('router')); }); }
php
protected function registerParameterBinder() { $this->app->singleton(RouteBinderRegister::class, function (Container $container) { return new RouteBinderRegister($container, $container->make('router')); }); }
[ "protected", "function", "registerParameterBinder", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "RouteBinderRegister", "::", "class", ",", "function", "(", "Container", "$", "container", ")", "{", "return", "new", "RouteBinderRegister", "(", "$", "container", ",", "$", "container", "->", "make", "(", "'router'", ")", ")", ";", "}", ")", ";", "}" ]
Register route parameter binder @return void
[ "Register", "route", "parameter", "binder" ]
b89dec01670108b92502d2c8095513f517475194
https://github.com/vi-kon/laravel-support/blob/b89dec01670108b92502d2c8095513f517475194/src/ViKon/Support/SupportServiceProvider.php#L53-L58
2,322
timersys/geotargetingwp
src/Record/AbstractRecord.php
AbstractRecord.name
public function name() { if( empty($this->data->names) ) return null; // check if we have result for locale if ( isset( $this->data->names->{$this->default_locale} ) ) return $this->data->names->{$this->default_locale}; // otherwise fallback to english if ( isset( $this->data->names->en ) ) return $this->data->names->en; // none of the above, return first result return $this->data->names[0]; }
php
public function name() { if( empty($this->data->names) ) return null; // check if we have result for locale if ( isset( $this->data->names->{$this->default_locale} ) ) return $this->data->names->{$this->default_locale}; // otherwise fallback to english if ( isset( $this->data->names->en ) ) return $this->data->names->en; // none of the above, return first result return $this->data->names[0]; }
[ "public", "function", "name", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "data", "->", "names", ")", ")", "return", "null", ";", "// check if we have result for locale", "if", "(", "isset", "(", "$", "this", "->", "data", "->", "names", "->", "{", "$", "this", "->", "default_locale", "}", ")", ")", "return", "$", "this", "->", "data", "->", "names", "->", "{", "$", "this", "->", "default_locale", "}", ";", "// otherwise fallback to english", "if", "(", "isset", "(", "$", "this", "->", "data", "->", "names", "->", "en", ")", ")", "return", "$", "this", "->", "data", "->", "names", "->", "en", ";", "// none of the above, return first result", "return", "$", "this", "->", "data", "->", "names", "[", "0", "]", ";", "}" ]
Return name in default locale @return string
[ "Return", "name", "in", "default", "locale" ]
289c1ec12bf5d0adf2eb301cc9efeeb20363c70e
https://github.com/timersys/geotargetingwp/blob/289c1ec12bf5d0adf2eb301cc9efeeb20363c70e/src/Record/AbstractRecord.php#L54-L65
2,323
loopsframework/base
src/Loops/Service/Renderer.php
Renderer.addExtraAppearance
public function addExtraAppearance($appearance, $before = FALSE) { if($before) { array_unshift($this->extra_appearances, $appearance); } else { array_push($this->extra_appearances, $appearance); } }
php
public function addExtraAppearance($appearance, $before = FALSE) { if($before) { array_unshift($this->extra_appearances, $appearance); } else { array_push($this->extra_appearances, $appearance); } }
[ "public", "function", "addExtraAppearance", "(", "$", "appearance", ",", "$", "before", "=", "FALSE", ")", "{", "if", "(", "$", "before", ")", "{", "array_unshift", "(", "$", "this", "->", "extra_appearances", ",", "$", "appearance", ")", ";", "}", "else", "{", "array_push", "(", "$", "this", "->", "extra_appearances", ",", "$", "appearance", ")", ";", "}", "}" ]
Adds an optional appearance tag that will be used for all render calls. Additional optional appearance tags can be used to pass variables that define the environment. For example 'cli' if working in a client interface environment. Having these appearance tags, it is possible to define template files that will be preferably used in these environments. @param string $appearance The name of the appearance tag @param bool $before Specifies if the passed appearance tag should be appended or prepended to the array of extra apperance tags.
[ "Adds", "an", "optional", "appearance", "tag", "that", "will", "be", "used", "for", "all", "render", "calls", "." ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/Renderer.php#L95-L102
2,324
loopsframework/base
src/Loops/Service/Renderer.php
Renderer.loadViews
private function loadViews() { if($this->views) { return; } //scan views - and store result in cache $cache = $this->getLoops()->getService("cache"); $key = "Loops-Renderer-".implode("-", $this->view_dir); if($cache->contains($key)) { $this->views = $cache->fetch($key); } else { foreach($this->view_dir as $view_dir) { $this->scanViewDir($view_dir); } $cache->save($key, $this->views); } }
php
private function loadViews() { if($this->views) { return; } //scan views - and store result in cache $cache = $this->getLoops()->getService("cache"); $key = "Loops-Renderer-".implode("-", $this->view_dir); if($cache->contains($key)) { $this->views = $cache->fetch($key); } else { foreach($this->view_dir as $view_dir) { $this->scanViewDir($view_dir); } $cache->save($key, $this->views); } }
[ "private", "function", "loadViews", "(", ")", "{", "if", "(", "$", "this", "->", "views", ")", "{", "return", ";", "}", "//scan views - and store result in cache", "$", "cache", "=", "$", "this", "->", "getLoops", "(", ")", "->", "getService", "(", "\"cache\"", ")", ";", "$", "key", "=", "\"Loops-Renderer-\"", ".", "implode", "(", "\"-\"", ",", "$", "this", "->", "view_dir", ")", ";", "if", "(", "$", "cache", "->", "contains", "(", "$", "key", ")", ")", "{", "$", "this", "->", "views", "=", "$", "cache", "->", "fetch", "(", "$", "key", ")", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "view_dir", "as", "$", "view_dir", ")", "{", "$", "this", "->", "scanViewDir", "(", "$", "view_dir", ")", ";", "}", "$", "cache", "->", "save", "(", "$", "key", ",", "$", "this", "->", "views", ")", ";", "}", "}" ]
Helper that scans the view dirs and stores the inforation in the cache
[ "Helper", "that", "scans", "the", "view", "dirs", "and", "stores", "the", "inforation", "in", "the", "cache" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/Renderer.php#L107-L124
2,325
pdenis/SnideTravinizerBundle
Reader/ComposerReader.php
ComposerReader.load
public function load($slug, $branch = 'master') { $this->data = array(); $this->httpClient->setBaseUrl($this->helper->getRawFileUrl($slug, $branch, '')); $this->data = $this->getResponse('composer.json'); }
php
public function load($slug, $branch = 'master') { $this->data = array(); $this->httpClient->setBaseUrl($this->helper->getRawFileUrl($slug, $branch, '')); $this->data = $this->getResponse('composer.json'); }
[ "public", "function", "load", "(", "$", "slug", ",", "$", "branch", "=", "'master'", ")", "{", "$", "this", "->", "data", "=", "array", "(", ")", ";", "$", "this", "->", "httpClient", "->", "setBaseUrl", "(", "$", "this", "->", "helper", "->", "getRawFileUrl", "(", "$", "slug", ",", "$", "branch", ",", "''", ")", ")", ";", "$", "this", "->", "data", "=", "$", "this", "->", "getResponse", "(", "'composer.json'", ")", ";", "}" ]
Load Composer data by reading composer.json file @param string $slug Repository slug @param string $branch Repository branch @throws \UnexpectedValueException
[ "Load", "Composer", "data", "by", "reading", "composer", ".", "json", "file" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Reader/ComposerReader.php#L65-L71
2,326
wazoomie/support
AbstractFactory.php
AbstractFactory.getAttributes
public function getAttributes($key = null) { if (!($key)) { return $this->attributes; } return $this->attributes->get($key); }
php
public function getAttributes($key = null) { if (!($key)) { return $this->attributes; } return $this->attributes->get($key); }
[ "public", "function", "getAttributes", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "attributes", ";", "}", "return", "$", "this", "->", "attributes", "->", "get", "(", "$", "key", ")", ";", "}" ]
Get the attributes. @param null $key @return \Illuminate\Support\Collection|mixed
[ "Get", "the", "attributes", "." ]
e0a853558a2dc5acd3dc20ee8071e2ebda283bb7
https://github.com/wazoomie/support/blob/e0a853558a2dc5acd3dc20ee8071e2ebda283bb7/AbstractFactory.php#L51-L58
2,327
wazoomie/support
AbstractFactory.php
AbstractFactory.process
public function process() { $this->data = array_values($this->data); if (isset($this->data[0])) { $data = $this->data; } else { $data = [$this->data]; } foreach ($data as $key => $value) { $model = $this->fill($key, collect($value)); $this->collection->push($model); } return $this->collection; }
php
public function process() { $this->data = array_values($this->data); if (isset($this->data[0])) { $data = $this->data; } else { $data = [$this->data]; } foreach ($data as $key => $value) { $model = $this->fill($key, collect($value)); $this->collection->push($model); } return $this->collection; }
[ "public", "function", "process", "(", ")", "{", "$", "this", "->", "data", "=", "array_values", "(", "$", "this", "->", "data", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "0", "]", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "else", "{", "$", "data", "=", "[", "$", "this", "->", "data", "]", ";", "}", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "model", "=", "$", "this", "->", "fill", "(", "$", "key", ",", "collect", "(", "$", "value", ")", ")", ";", "$", "this", "->", "collection", "->", "push", "(", "$", "model", ")", ";", "}", "return", "$", "this", "->", "collection", ";", "}" ]
Process the raw data and return a collection filled with populated models. @return \Illuminate\Support\Collection
[ "Process", "the", "raw", "data", "and", "return", "a", "collection", "filled", "with", "populated", "models", "." ]
e0a853558a2dc5acd3dc20ee8071e2ebda283bb7
https://github.com/wazoomie/support/blob/e0a853558a2dc5acd3dc20ee8071e2ebda283bb7/AbstractFactory.php#L108-L124
2,328
dmeikle/pesedget
src/Gossamer/Pesedget/Commands/GetCommand.php
GetCommand.execute
public function execute($params = array(), $request = array()) { //$passableParams = $this->httpRequest->getParameters(); //remove the uri // array_shift($passableParams); $this->getQueryBuilder()->where($params); $query = ''; if ($this->entity instanceof AbstractI18nEntity) { $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY, QueryBuilder::PARENT_AND_CHILD); } else { $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY); } $firstResult = $this->query($query); $entityName = get_class($this->entity); if (is_array($firstResult) && count($firstResult) > 0) { $this->loadI18nValues($firstResult, $params); $this->loadChildTableParams($firstResult, $params); $this->loadOneToOneJoinTables($firstResult); $this->loadOneToManyJoinTables($firstResult, $params); } return array($entityName => is_array($firstResult) ? current($firstResult) : array()); }
php
public function execute($params = array(), $request = array()) { //$passableParams = $this->httpRequest->getParameters(); //remove the uri // array_shift($passableParams); $this->getQueryBuilder()->where($params); $query = ''; if ($this->entity instanceof AbstractI18nEntity) { $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY, QueryBuilder::PARENT_AND_CHILD); } else { $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY); } $firstResult = $this->query($query); $entityName = get_class($this->entity); if (is_array($firstResult) && count($firstResult) > 0) { $this->loadI18nValues($firstResult, $params); $this->loadChildTableParams($firstResult, $params); $this->loadOneToOneJoinTables($firstResult); $this->loadOneToManyJoinTables($firstResult, $params); } return array($entityName => is_array($firstResult) ? current($firstResult) : array()); }
[ "public", "function", "execute", "(", "$", "params", "=", "array", "(", ")", ",", "$", "request", "=", "array", "(", ")", ")", "{", "//$passableParams = $this->httpRequest->getParameters();", "//remove the uri", "// array_shift($passableParams);", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "where", "(", "$", "params", ")", ";", "$", "query", "=", "''", ";", "if", "(", "$", "this", "->", "entity", "instanceof", "AbstractI18nEntity", ")", "{", "$", "query", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "getQuery", "(", "$", "this", "->", "entity", ",", "QueryBuilder", "::", "GET_ITEM_QUERY", ",", "QueryBuilder", "::", "PARENT_AND_CHILD", ")", ";", "}", "else", "{", "$", "query", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "getQuery", "(", "$", "this", "->", "entity", ",", "QueryBuilder", "::", "GET_ITEM_QUERY", ")", ";", "}", "$", "firstResult", "=", "$", "this", "->", "query", "(", "$", "query", ")", ";", "$", "entityName", "=", "get_class", "(", "$", "this", "->", "entity", ")", ";", "if", "(", "is_array", "(", "$", "firstResult", ")", "&&", "count", "(", "$", "firstResult", ")", ">", "0", ")", "{", "$", "this", "->", "loadI18nValues", "(", "$", "firstResult", ",", "$", "params", ")", ";", "$", "this", "->", "loadChildTableParams", "(", "$", "firstResult", ",", "$", "params", ")", ";", "$", "this", "->", "loadOneToOneJoinTables", "(", "$", "firstResult", ")", ";", "$", "this", "->", "loadOneToManyJoinTables", "(", "$", "firstResult", ",", "$", "params", ")", ";", "}", "return", "array", "(", "$", "entityName", "=>", "is_array", "(", "$", "firstResult", ")", "?", "current", "(", "$", "firstResult", ")", ":", "array", "(", ")", ")", ";", "}" ]
retrieves a single row from the database @param array URI params @param array POST params
[ "retrieves", "a", "single", "row", "from", "the", "database" ]
bcfca25569d1f47c073f08906a710ed895f77b4d
https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/GetCommand.php#L29-L59
2,329
dmeikle/pesedget
src/Gossamer/Pesedget/Commands/GetCommand.php
GetCommand.loadI18nValues
private function loadI18nValues(&$firstResult, $params) { if (!$this->entity instanceof AbstractI18nEntity) { return; } $filter = array($this->entity->getI18nIdentifier() => $firstResult[0]['id']); $localesKey = 'locales'; if (is_array($params) && array_key_exists('locale', $params)) { $filter['locale'] = $params['locale']; $localesKey = $params['locale']; } $this->getQueryBuilder()->where($filter); $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::CHILD_ONLY); $i18nResult = $this->query($query); //file_put_contents('/var/www/shoppingcart/logs/test.log', '$i18nResult: '.print_r($i18nResult,true)."\r\n", FILE_APPEND); if ($localesKey == 'locales') { $firstResult[0]['locales'] = $this->getLocaleKeys($i18nResult, $this->getI18nValuesForPadding()); } else { $firstResult[0]['locales'][$localesKey] = $i18nResult; } }
php
private function loadI18nValues(&$firstResult, $params) { if (!$this->entity instanceof AbstractI18nEntity) { return; } $filter = array($this->entity->getI18nIdentifier() => $firstResult[0]['id']); $localesKey = 'locales'; if (is_array($params) && array_key_exists('locale', $params)) { $filter['locale'] = $params['locale']; $localesKey = $params['locale']; } $this->getQueryBuilder()->where($filter); $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::CHILD_ONLY); $i18nResult = $this->query($query); //file_put_contents('/var/www/shoppingcart/logs/test.log', '$i18nResult: '.print_r($i18nResult,true)."\r\n", FILE_APPEND); if ($localesKey == 'locales') { $firstResult[0]['locales'] = $this->getLocaleKeys($i18nResult, $this->getI18nValuesForPadding()); } else { $firstResult[0]['locales'][$localesKey] = $i18nResult; } }
[ "private", "function", "loadI18nValues", "(", "&", "$", "firstResult", ",", "$", "params", ")", "{", "if", "(", "!", "$", "this", "->", "entity", "instanceof", "AbstractI18nEntity", ")", "{", "return", ";", "}", "$", "filter", "=", "array", "(", "$", "this", "->", "entity", "->", "getI18nIdentifier", "(", ")", "=>", "$", "firstResult", "[", "0", "]", "[", "'id'", "]", ")", ";", "$", "localesKey", "=", "'locales'", ";", "if", "(", "is_array", "(", "$", "params", ")", "&&", "array_key_exists", "(", "'locale'", ",", "$", "params", ")", ")", "{", "$", "filter", "[", "'locale'", "]", "=", "$", "params", "[", "'locale'", "]", ";", "$", "localesKey", "=", "$", "params", "[", "'locale'", "]", ";", "}", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "where", "(", "$", "filter", ")", ";", "$", "query", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "getQuery", "(", "$", "this", "->", "entity", ",", "QueryBuilder", "::", "GET_ALL_ITEMS_QUERY", ",", "QueryBuilder", "::", "CHILD_ONLY", ")", ";", "$", "i18nResult", "=", "$", "this", "->", "query", "(", "$", "query", ")", ";", "//file_put_contents('/var/www/shoppingcart/logs/test.log', '$i18nResult: '.print_r($i18nResult,true).\"\\r\\n\", FILE_APPEND);", "if", "(", "$", "localesKey", "==", "'locales'", ")", "{", "$", "firstResult", "[", "0", "]", "[", "'locales'", "]", "=", "$", "this", "->", "getLocaleKeys", "(", "$", "i18nResult", ",", "$", "this", "->", "getI18nValuesForPadding", "(", ")", ")", ";", "}", "else", "{", "$", "firstResult", "[", "0", "]", "[", "'locales'", "]", "[", "$", "localesKey", "]", "=", "$", "i18nResult", ";", "}", "}" ]
load child rows from I18n specific to requested entity
[ "load", "child", "rows", "from", "I18n", "specific", "to", "requested", "entity" ]
bcfca25569d1f47c073f08906a710ed895f77b4d
https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/GetCommand.php#L73-L97
2,330
tunaqui-solutions/utils
src/Http/JsonResponse.php
JsonResponse.prepareResult
public function prepareResult($success, $message, $code, $data, $errors) { $this->success = $success; $this->code = $code; $this->message = $message; if(is_null($this->data)) { $this->data = array(); } else { if(!is_array($this->data)) { $old = $this->data; $this->data = array(); array_push($this->data, $old); } } if(!is_null($data)) { if(is_array($data)) { $this->data = array_merge($this->data, $data); } else { array_push($this->data, $data); } } if(is_object($this->errors)) { $this->errors = Objects::attrToArray($this->errors); } if(is_string($this->errors) || is_numeric($this->errors)) { $err = $this->errors; $this->errors = array(); $this->errors[0] = $err; } $this->errors = !is_null($errors) ? array_merge($this->errors, $errors) : $this->errors; }
php
public function prepareResult($success, $message, $code, $data, $errors) { $this->success = $success; $this->code = $code; $this->message = $message; if(is_null($this->data)) { $this->data = array(); } else { if(!is_array($this->data)) { $old = $this->data; $this->data = array(); array_push($this->data, $old); } } if(!is_null($data)) { if(is_array($data)) { $this->data = array_merge($this->data, $data); } else { array_push($this->data, $data); } } if(is_object($this->errors)) { $this->errors = Objects::attrToArray($this->errors); } if(is_string($this->errors) || is_numeric($this->errors)) { $err = $this->errors; $this->errors = array(); $this->errors[0] = $err; } $this->errors = !is_null($errors) ? array_merge($this->errors, $errors) : $this->errors; }
[ "public", "function", "prepareResult", "(", "$", "success", ",", "$", "message", ",", "$", "code", ",", "$", "data", ",", "$", "errors", ")", "{", "$", "this", "->", "success", "=", "$", "success", ";", "$", "this", "->", "code", "=", "$", "code", ";", "$", "this", "->", "message", "=", "$", "message", ";", "if", "(", "is_null", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "array", "(", ")", ";", "}", "else", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "data", ")", ")", "{", "$", "old", "=", "$", "this", "->", "data", ";", "$", "this", "->", "data", "=", "array", "(", ")", ";", "array_push", "(", "$", "this", "->", "data", ",", "$", "old", ")", ";", "}", "}", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "}", "else", "{", "array_push", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "}", "}", "if", "(", "is_object", "(", "$", "this", "->", "errors", ")", ")", "{", "$", "this", "->", "errors", "=", "Objects", "::", "attrToArray", "(", "$", "this", "->", "errors", ")", ";", "}", "if", "(", "is_string", "(", "$", "this", "->", "errors", ")", "||", "is_numeric", "(", "$", "this", "->", "errors", ")", ")", "{", "$", "err", "=", "$", "this", "->", "errors", ";", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "$", "this", "->", "errors", "[", "0", "]", "=", "$", "err", ";", "}", "$", "this", "->", "errors", "=", "!", "is_null", "(", "$", "errors", ")", "?", "array_merge", "(", "$", "this", "->", "errors", ",", "$", "errors", ")", ":", "$", "this", "->", "errors", ";", "}" ]
Prepare an response @param bool $success @param string $message @param int $code @param mixed $data @param array $errors
[ "Prepare", "an", "response" ]
f332f606df2ca4aea17352082182a6b21e859e0f
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Http/JsonResponse.php#L59-L88
2,331
tunaqui-solutions/utils
src/Http/JsonResponse.php
JsonResponse.prepareSuccess
public function prepareSuccess($message, $data=[], $code=200) { $this->prepareResult(true, $message, $code, $data, null); }
php
public function prepareSuccess($message, $data=[], $code=200) { $this->prepareResult(true, $message, $code, $data, null); }
[ "public", "function", "prepareSuccess", "(", "$", "message", ",", "$", "data", "=", "[", "]", ",", "$", "code", "=", "200", ")", "{", "$", "this", "->", "prepareResult", "(", "true", ",", "$", "message", ",", "$", "code", ",", "$", "data", ",", "null", ")", ";", "}" ]
Produces a failed response @param string $message @param mixed $data @param int $code
[ "Produces", "a", "failed", "response" ]
f332f606df2ca4aea17352082182a6b21e859e0f
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Http/JsonResponse.php#L96-L98
2,332
tunaqui-solutions/utils
src/Http/JsonResponse.php
JsonResponse.prepareError
public function prepareError($message, $errors=[], $code=404) { $this->prepareResult(false, $message, $code, null , $errors); }
php
public function prepareError($message, $errors=[], $code=404) { $this->prepareResult(false, $message, $code, null , $errors); }
[ "public", "function", "prepareError", "(", "$", "message", ",", "$", "errors", "=", "[", "]", ",", "$", "code", "=", "404", ")", "{", "$", "this", "->", "prepareResult", "(", "false", ",", "$", "message", ",", "$", "code", ",", "null", ",", "$", "errors", ")", ";", "}" ]
Produces a successful response @param string $message @param array $errors @param int $code default 404
[ "Produces", "a", "successful", "response" ]
f332f606df2ca4aea17352082182a6b21e859e0f
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Http/JsonResponse.php#L106-L108
2,333
tunaqui-solutions/utils
src/Http/JsonResponse.php
JsonResponse.message
public function message($message=null) { if(is_null($message)) { return $this->message; } $this->message = $message; }
php
public function message($message=null) { if(is_null($message)) { return $this->message; } $this->message = $message; }
[ "public", "function", "message", "(", "$", "message", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "message", ")", ")", "{", "return", "$", "this", "->", "message", ";", "}", "$", "this", "->", "message", "=", "$", "message", ";", "}" ]
Get or Set 'message' attribute @param null $message @return string
[ "Get", "or", "Set", "message", "attribute" ]
f332f606df2ca4aea17352082182a6b21e859e0f
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Http/JsonResponse.php#L160-L165
2,334
tunaqui-solutions/utils
src/Http/JsonResponse.php
JsonResponse.errors
public function errors($errors = null) { if(is_null($errors)) { return $this->errors; } $this->errors = $errors; }
php
public function errors($errors = null) { if(is_null($errors)) { return $this->errors; } $this->errors = $errors; }
[ "public", "function", "errors", "(", "$", "errors", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "errors", ")", ")", "{", "return", "$", "this", "->", "errors", ";", "}", "$", "this", "->", "errors", "=", "$", "errors", ";", "}" ]
Get or Set 'errors' attribute @param null $errors @return array
[ "Get", "or", "Set", "errors", "attribute" ]
f332f606df2ca4aea17352082182a6b21e859e0f
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Http/JsonResponse.php#L184-L189
2,335
digipolisgent/openbib-id-api
src/Value/UserActivities/Expense.php
Expense.fromXml
public static function fromXml(\DOMElement $xml) { $static = new static(); $static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml); $expenseId = $xml->getElementsByTagName('id'); $static->expenseId = StringLiteral::fromXml($expenseId); $date = $xml->getElementsByTagName('date'); $static->date = DateTime::fromXml($date); $amount = $xml->getElementsByTagName('amount'); $static->amount = FloatLiteral::fromXml($amount); $stringLiterals = array( 'title' => $xml->getElementsByTagName('title'), 'description' => $xml->getElementsByTagName('description'), 'type' => $xml->getElementsByTagName('type'), ); foreach ($stringLiterals as $propertyName => $xmlTag) { $static->$propertyName = StringLiteral::fromXml($xmlTag); } return $static; }
php
public static function fromXml(\DOMElement $xml) { $static = new static(); $static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml); $expenseId = $xml->getElementsByTagName('id'); $static->expenseId = StringLiteral::fromXml($expenseId); $date = $xml->getElementsByTagName('date'); $static->date = DateTime::fromXml($date); $amount = $xml->getElementsByTagName('amount'); $static->amount = FloatLiteral::fromXml($amount); $stringLiterals = array( 'title' => $xml->getElementsByTagName('title'), 'description' => $xml->getElementsByTagName('description'), 'type' => $xml->getElementsByTagName('type'), ); foreach ($stringLiterals as $propertyName => $xmlTag) { $static->$propertyName = StringLiteral::fromXml($xmlTag); } return $static; }
[ "public", "static", "function", "fromXml", "(", "\\", "DOMElement", "$", "xml", ")", "{", "$", "static", "=", "new", "static", "(", ")", ";", "$", "static", "->", "libraryItemMetadata", "=", "LibraryItemMetadata", "::", "fromXml", "(", "$", "xml", ")", ";", "$", "expenseId", "=", "$", "xml", "->", "getElementsByTagName", "(", "'id'", ")", ";", "$", "static", "->", "expenseId", "=", "StringLiteral", "::", "fromXml", "(", "$", "expenseId", ")", ";", "$", "date", "=", "$", "xml", "->", "getElementsByTagName", "(", "'date'", ")", ";", "$", "static", "->", "date", "=", "DateTime", "::", "fromXml", "(", "$", "date", ")", ";", "$", "amount", "=", "$", "xml", "->", "getElementsByTagName", "(", "'amount'", ")", ";", "$", "static", "->", "amount", "=", "FloatLiteral", "::", "fromXml", "(", "$", "amount", ")", ";", "$", "stringLiterals", "=", "array", "(", "'title'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'title'", ")", ",", "'description'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'description'", ")", ",", "'type'", "=>", "$", "xml", "->", "getElementsByTagName", "(", "'type'", ")", ",", ")", ";", "foreach", "(", "$", "stringLiterals", "as", "$", "propertyName", "=>", "$", "xmlTag", ")", "{", "$", "static", "->", "$", "propertyName", "=", "StringLiteral", "::", "fromXml", "(", "$", "xmlTag", ")", ";", "}", "return", "$", "static", ";", "}" ]
Builds a Expense object from XML. @param \DOMElement $xml The xml element containing the expense. @return Expense A Expense object
[ "Builds", "a", "Expense", "object", "from", "XML", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/UserActivities/Expense.php#L77-L101
2,336
leoshtika/logger
src/Logger.php
Logger.add
public static function add($message = 'No message', $logCode = self::LEVEL_INFO) { // if file pointer doesn't exist, then open log file if (!self::$_fileHandler) { self::_openLogFile(); } // Get user IP if (!empty($_SERVER['REMOTE_ADDR'])) { $userIP = $_SERVER['REMOTE_ADDR']; } else { $userIP = '0.0.0.0'; } // define current time $time = date('j/M/Y H:i:s'); // define script name $scriptName = pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME); // write message to the log file $fwrite = fwrite(self::$_fileHandler, "$userIP [$time][$logCode] ($scriptName) --> $message\n"); if ($fwrite === false) { return false; } else { return true; } }
php
public static function add($message = 'No message', $logCode = self::LEVEL_INFO) { // if file pointer doesn't exist, then open log file if (!self::$_fileHandler) { self::_openLogFile(); } // Get user IP if (!empty($_SERVER['REMOTE_ADDR'])) { $userIP = $_SERVER['REMOTE_ADDR']; } else { $userIP = '0.0.0.0'; } // define current time $time = date('j/M/Y H:i:s'); // define script name $scriptName = pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME); // write message to the log file $fwrite = fwrite(self::$_fileHandler, "$userIP [$time][$logCode] ($scriptName) --> $message\n"); if ($fwrite === false) { return false; } else { return true; } }
[ "public", "static", "function", "add", "(", "$", "message", "=", "'No message'", ",", "$", "logCode", "=", "self", "::", "LEVEL_INFO", ")", "{", "// if file pointer doesn't exist, then open log file ", "if", "(", "!", "self", "::", "$", "_fileHandler", ")", "{", "self", "::", "_openLogFile", "(", ")", ";", "}", "// Get user IP", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", ")", "{", "$", "userIP", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "else", "{", "$", "userIP", "=", "'0.0.0.0'", ";", "}", "// define current time ", "$", "time", "=", "date", "(", "'j/M/Y H:i:s'", ")", ";", "// define script name ", "$", "scriptName", "=", "pathinfo", "(", "$", "_SERVER", "[", "'PHP_SELF'", "]", ",", "PATHINFO_BASENAME", ")", ";", "// write message to the log file", "$", "fwrite", "=", "fwrite", "(", "self", "::", "$", "_fileHandler", ",", "\"$userIP [$time][$logCode] ($scriptName) --> $message\\n\"", ")", ";", "if", "(", "$", "fwrite", "===", "false", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Write message to the log file @param string $message Optional message @param string $logCode Optional log code (example: INFO (default), ERROR, EMERGENCY)
[ "Write", "message", "to", "the", "log", "file" ]
b75b8be0886b9d62cd92b8dffd75362f4603a34b
https://github.com/leoshtika/logger/blob/b75b8be0886b9d62cd92b8dffd75362f4603a34b/src/Logger.php#L47-L75
2,337
leoshtika/logger
src/Logger.php
Logger._crateLogsFolder
private static function _crateLogsFolder() { // If folder doesn't exist attempt to create it if (!file_exists(self::LOGS_FOLDER_PATH)) { mkdir(self::LOGS_FOLDER_PATH, 0755, true); $htaccessHandler = fopen(self::LOGS_FOLDER_PATH . '.htaccess', 'w'); fwrite($htaccessHandler, 'deny from all'); fclose($htaccessHandler); } }
php
private static function _crateLogsFolder() { // If folder doesn't exist attempt to create it if (!file_exists(self::LOGS_FOLDER_PATH)) { mkdir(self::LOGS_FOLDER_PATH, 0755, true); $htaccessHandler = fopen(self::LOGS_FOLDER_PATH . '.htaccess', 'w'); fwrite($htaccessHandler, 'deny from all'); fclose($htaccessHandler); } }
[ "private", "static", "function", "_crateLogsFolder", "(", ")", "{", "// If folder doesn't exist attempt to create it", "if", "(", "!", "file_exists", "(", "self", "::", "LOGS_FOLDER_PATH", ")", ")", "{", "mkdir", "(", "self", "::", "LOGS_FOLDER_PATH", ",", "0755", ",", "true", ")", ";", "$", "htaccessHandler", "=", "fopen", "(", "self", "::", "LOGS_FOLDER_PATH", ".", "'.htaccess'", ",", "'w'", ")", ";", "fwrite", "(", "$", "htaccessHandler", ",", "'deny from all'", ")", ";", "fclose", "(", "$", "htaccessHandler", ")", ";", "}", "}" ]
Create LogsFolder if not exist This method will create a .htaccess to deny access to logfiles
[ "Create", "LogsFolder", "if", "not", "exist", "This", "method", "will", "create", "a", ".", "htaccess", "to", "deny", "access", "to", "logfiles" ]
b75b8be0886b9d62cd92b8dffd75362f4603a34b
https://github.com/leoshtika/logger/blob/b75b8be0886b9d62cd92b8dffd75362f4603a34b/src/Logger.php#L101-L110
2,338
znframework/package-security
PHP.php
PHP.encode
public static function encode(String $str) : String { return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str); }
php
public static function encode(String $str) : String { return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str); }
[ "public", "static", "function", "encode", "(", "String", "$", "str", ")", ":", "String", "{", "return", "str_replace", "(", "array_keys", "(", "self", "::", "$", "phpTagChars", ")", ",", "array_values", "(", "self", "::", "$", "phpTagChars", ")", ",", "$", "str", ")", ";", "}" ]
Encode PHP Tag @param string $str @return string
[ "Encode", "PHP", "Tag" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/PHP.php#L32-L35
2,339
znframework/package-security
PHP.php
PHP.decode
public static function decode(String $str) : String { return str_replace(array_values(self::$phpTagChars), array_keys(self::$phpTagChars), $str); }
php
public static function decode(String $str) : String { return str_replace(array_values(self::$phpTagChars), array_keys(self::$phpTagChars), $str); }
[ "public", "static", "function", "decode", "(", "String", "$", "str", ")", ":", "String", "{", "return", "str_replace", "(", "array_values", "(", "self", "::", "$", "phpTagChars", ")", ",", "array_keys", "(", "self", "::", "$", "phpTagChars", ")", ",", "$", "str", ")", ";", "}" ]
Decode PHP Tag @param string $str @return string
[ "Decode", "PHP", "Tag" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/PHP.php#L44-L47
2,340
CatLabInteractive/Mailer
src/CatLab/Mailer/Models/Mail.php
Mail.getHtmlOrText
public function getHtmlOrText() { if ($template = $this->getTemplate ()) { if (!isset ($this->isHTML)) $this->setIsHTML(true); return $template->parse (); } else if ($body = $this->getBody ()) { $this->setIsHTML(true); return $body; } else if ($text = $this->getText ()) { $this->setIsHTML(false); return $text; } $this->setIsHTML(false); return 'No body set.'; }
php
public function getHtmlOrText() { if ($template = $this->getTemplate ()) { if (!isset ($this->isHTML)) $this->setIsHTML(true); return $template->parse (); } else if ($body = $this->getBody ()) { $this->setIsHTML(true); return $body; } else if ($text = $this->getText ()) { $this->setIsHTML(false); return $text; } $this->setIsHTML(false); return 'No body set.'; }
[ "public", "function", "getHtmlOrText", "(", ")", "{", "if", "(", "$", "template", "=", "$", "this", "->", "getTemplate", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "isHTML", ")", ")", "$", "this", "->", "setIsHTML", "(", "true", ")", ";", "return", "$", "template", "->", "parse", "(", ")", ";", "}", "else", "if", "(", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ")", "{", "$", "this", "->", "setIsHTML", "(", "true", ")", ";", "return", "$", "body", ";", "}", "else", "if", "(", "$", "text", "=", "$", "this", "->", "getText", "(", ")", ")", "{", "$", "this", "->", "setIsHTML", "(", "false", ")", ";", "return", "$", "text", ";", "}", "$", "this", "->", "setIsHTML", "(", "false", ")", ";", "return", "'No body set.'", ";", "}" ]
Return the html body or the text string, and fill in the isHTML property @return string
[ "Return", "the", "html", "body", "or", "the", "text", "string", "and", "fill", "in", "the", "isHTML", "property" ]
701f09e11cfbd68d02ab18655d22a7f19124d2c1
https://github.com/CatLabInteractive/Mailer/blob/701f09e11cfbd68d02ab18655d22a7f19124d2c1/src/CatLab/Mailer/Models/Mail.php#L119-L135
2,341
psecio/validation
src/Check.php
Check.get
public function get($name = null) { if ($name !== null) { return (isset($this->addl[$name])) ? $this->addl[$name] : null; } else { return $this->addl; } }
php
public function get($name = null) { if ($name !== null) { return (isset($this->addl[$name])) ? $this->addl[$name] : null; } else { return $this->addl; } }
[ "public", "function", "get", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "!==", "null", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "addl", "[", "$", "name", "]", ")", ")", "?", "$", "this", "->", "addl", "[", "$", "name", "]", ":", "null", ";", "}", "else", "{", "return", "$", "this", "->", "addl", ";", "}", "}" ]
Get a value from the additional value set If the "name" value is given, it tries to locate the value, returns null if not found If no "name" is given, returns all values @param string $name Name of value to locate [optional] @return mixed Either all values, the value if found or null if not found
[ "Get", "a", "value", "from", "the", "additional", "value", "set", "If", "the", "name", "value", "is", "given", "it", "tries", "to", "locate", "the", "value", "returns", "null", "if", "not", "found", "If", "no", "name", "is", "given", "returns", "all", "values" ]
79497de45e872f838b1e1398489f2e0f8167fa70
https://github.com/psecio/validation/blob/79497de45e872f838b1e1398489f2e0f8167fa70/src/Check.php#L90-L97
2,342
psecio/validation
src/Check.php
Check.getMessage
public function getMessage($name = null) { if ($name === null) { return $this->message; } return str_replace(':name', $name, $this->message); }
php
public function getMessage($name = null) { if ($name === null) { return $this->message; } return str_replace(':name', $name, $this->message); }
[ "public", "function", "getMessage", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "return", "$", "this", "->", "message", ";", "}", "return", "str_replace", "(", "':name'", ",", "$", "name", ",", "$", "this", "->", "message", ")", ";", "}" ]
Get the value of the message for the check @param string $name Key name for the field @return string Formatted/default message
[ "Get", "the", "value", "of", "the", "message", "for", "the", "check" ]
79497de45e872f838b1e1398489f2e0f8167fa70
https://github.com/psecio/validation/blob/79497de45e872f838b1e1398489f2e0f8167fa70/src/Check.php#L115-L121
2,343
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/PriorityQueue.php
PriorityQueue.toArray
public function toArray($flag = self::EXTR_DATA) { switch ($flag) { case self::EXTR_BOTH: return $this->items; case self::EXTR_PRIORITY: return array_map(function ($item) { return $item['priority']; }, $this->items); case self::EXTR_DATA: default: return array_map(function ($item) { return $item['data']; }, $this->items); } }
php
public function toArray($flag = self::EXTR_DATA) { switch ($flag) { case self::EXTR_BOTH: return $this->items; case self::EXTR_PRIORITY: return array_map(function ($item) { return $item['priority']; }, $this->items); case self::EXTR_DATA: default: return array_map(function ($item) { return $item['data']; }, $this->items); } }
[ "public", "function", "toArray", "(", "$", "flag", "=", "self", "::", "EXTR_DATA", ")", "{", "switch", "(", "$", "flag", ")", "{", "case", "self", "::", "EXTR_BOTH", ":", "return", "$", "this", "->", "items", ";", "case", "self", "::", "EXTR_PRIORITY", ":", "return", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'priority'", "]", ";", "}", ",", "$", "this", "->", "items", ")", ";", "case", "self", "::", "EXTR_DATA", ":", "default", ":", "return", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'data'", "]", ";", "}", ",", "$", "this", "->", "items", ")", ";", "}", "}" ]
Serialize to an array By default, returns only the item data, and in the order registered (not sorted). You may provide one of the EXTR_* flags as an argument, allowing the ability to return priorities or both data and priority. @param int $flag @return array
[ "Serialize", "to", "an", "array" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/PriorityQueue.php#L206-L221
2,344
glendmaatita/Tolkien
src/Tolkien/CompileSite.php
CompileSite.compile
public function compile() { $this->rrmdir($this->config['dir']['site']); $this->compilePosts(); $this->compilePages(); $this->compileCategories(); $this->compileAssets(); $this->compilePaginations(); $this->compileAuthors(); }
php
public function compile() { $this->rrmdir($this->config['dir']['site']); $this->compilePosts(); $this->compilePages(); $this->compileCategories(); $this->compileAssets(); $this->compilePaginations(); $this->compileAuthors(); }
[ "public", "function", "compile", "(", ")", "{", "$", "this", "->", "rrmdir", "(", "$", "this", "->", "config", "[", "'dir'", "]", "[", "'site'", "]", ")", ";", "$", "this", "->", "compilePosts", "(", ")", ";", "$", "this", "->", "compilePages", "(", ")", ";", "$", "this", "->", "compileCategories", "(", ")", ";", "$", "this", "->", "compileAssets", "(", ")", ";", "$", "this", "->", "compilePaginations", "(", ")", ";", "$", "this", "->", "compileAuthors", "(", ")", ";", "}" ]
Main function to compile @return void
[ "Main", "function", "to", "compile" ]
e7c27a103f1a87411dfb8eef626cba381b27d233
https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/CompileSite.php#L44-L53
2,345
glendmaatita/Tolkien
src/Tolkien/CompileSite.php
CompileSite.compileCategories
public function compileCategories() { foreach ($this->site->getCategories() as $category) { $template = $this->twig->loadTemplate( 'category.html.tpl' ); $content = $template->render(array('site' => $this->site, 'category' => $category)); $this->createFile($content, $category); } }
php
public function compileCategories() { foreach ($this->site->getCategories() as $category) { $template = $this->twig->loadTemplate( 'category.html.tpl' ); $content = $template->render(array('site' => $this->site, 'category' => $category)); $this->createFile($content, $category); } }
[ "public", "function", "compileCategories", "(", ")", "{", "foreach", "(", "$", "this", "->", "site", "->", "getCategories", "(", ")", "as", "$", "category", ")", "{", "$", "template", "=", "$", "this", "->", "twig", "->", "loadTemplate", "(", "'category.html.tpl'", ")", ";", "$", "content", "=", "$", "template", "->", "render", "(", "array", "(", "'site'", "=>", "$", "this", "->", "site", ",", "'category'", "=>", "$", "category", ")", ")", ";", "$", "this", "->", "createFile", "(", "$", "content", ",", "$", "category", ")", ";", "}", "}" ]
Compile Site Categories @return void
[ "Compile", "Site", "Categories" ]
e7c27a103f1a87411dfb8eef626cba381b27d233
https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/CompileSite.php#L90-L98
2,346
glendmaatita/Tolkien
src/Tolkien/CompileSite.php
CompileSite.compileAuthors
public function compileAuthors() { foreach ($this->site->getAuthors() as $author) { $template = $this->twig->loadTemplate( 'author.html.tpl' ); $content = $template->render(array('site' => $this->site, 'author' => $author)); $this->createFile($content, $author); } }
php
public function compileAuthors() { foreach ($this->site->getAuthors() as $author) { $template = $this->twig->loadTemplate( 'author.html.tpl' ); $content = $template->render(array('site' => $this->site, 'author' => $author)); $this->createFile($content, $author); } }
[ "public", "function", "compileAuthors", "(", ")", "{", "foreach", "(", "$", "this", "->", "site", "->", "getAuthors", "(", ")", "as", "$", "author", ")", "{", "$", "template", "=", "$", "this", "->", "twig", "->", "loadTemplate", "(", "'author.html.tpl'", ")", ";", "$", "content", "=", "$", "template", "->", "render", "(", "array", "(", "'site'", "=>", "$", "this", "->", "site", ",", "'author'", "=>", "$", "author", ")", ")", ";", "$", "this", "->", "createFile", "(", "$", "content", ",", "$", "author", ")", ";", "}", "}" ]
Compile authors page @return void
[ "Compile", "authors", "page" ]
e7c27a103f1a87411dfb8eef626cba381b27d233
https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/CompileSite.php#L105-L113
2,347
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configshow
static function Configshow(PHP_ParserGenerator_Config $cfp) { $fp = fopen('php://output', 'w'); while ($cfp) { if ($cfp->dot == $cfp->rp->nrhs) { $buf = sprintf('(%d)', $cfp->rp->index); fprintf($fp, ' %5s ', $buf); } else { fwrite($fp,' '); } $cfp->ConfigPrint($fp); fwrite($fp, "\n"); if (0) { //SetPrint(fp,cfp->fws,$this); //PlinkPrint(fp,cfp->fplp,"To "); //PlinkPrint(fp,cfp->bplp,"From"); } $cfp = $cfp->next; } fwrite($fp, "\n"); fclose($fp); }
php
static function Configshow(PHP_ParserGenerator_Config $cfp) { $fp = fopen('php://output', 'w'); while ($cfp) { if ($cfp->dot == $cfp->rp->nrhs) { $buf = sprintf('(%d)', $cfp->rp->index); fprintf($fp, ' %5s ', $buf); } else { fwrite($fp,' '); } $cfp->ConfigPrint($fp); fwrite($fp, "\n"); if (0) { //SetPrint(fp,cfp->fws,$this); //PlinkPrint(fp,cfp->fplp,"To "); //PlinkPrint(fp,cfp->bplp,"From"); } $cfp = $cfp->next; } fwrite($fp, "\n"); fclose($fp); }
[ "static", "function", "Configshow", "(", "PHP_ParserGenerator_Config", "$", "cfp", ")", "{", "$", "fp", "=", "fopen", "(", "'php://output'", ",", "'w'", ")", ";", "while", "(", "$", "cfp", ")", "{", "if", "(", "$", "cfp", "->", "dot", "==", "$", "cfp", "->", "rp", "->", "nrhs", ")", "{", "$", "buf", "=", "sprintf", "(", "'(%d)'", ",", "$", "cfp", "->", "rp", "->", "index", ")", ";", "fprintf", "(", "$", "fp", ",", "' %5s '", ",", "$", "buf", ")", ";", "}", "else", "{", "fwrite", "(", "$", "fp", ",", "' '", ")", ";", "}", "$", "cfp", "->", "ConfigPrint", "(", "$", "fp", ")", ";", "fwrite", "(", "$", "fp", ",", "\"\\n\"", ")", ";", "if", "(", "0", ")", "{", "//SetPrint(fp,cfp->fws,$this);", "//PlinkPrint(fp,cfp->fplp,\"To \");", "//PlinkPrint(fp,cfp->bplp,\"From\");", "}", "$", "cfp", "=", "$", "cfp", "->", "next", ";", "}", "fwrite", "(", "$", "fp", ",", "\"\\n\"", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}" ]
Display the current configuration for the .out file @param PHP_ParserGenerator_Config $cfp @see PHP_ParserGenerator_Data::ReportOutput()
[ "Display", "the", "current", "configuration", "for", "the", ".", "out", "file" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L194-L215
2,348
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_init
static function Configlist_init() { self::$current = 0; self::$currentend = &self::$current; self::$basis = 0; self::$basisend = &self::$basis; self::$x4a = array(); }
php
static function Configlist_init() { self::$current = 0; self::$currentend = &self::$current; self::$basis = 0; self::$basisend = &self::$basis; self::$x4a = array(); }
[ "static", "function", "Configlist_init", "(", ")", "{", "self", "::", "$", "current", "=", "0", ";", "self", "::", "$", "currentend", "=", "&", "self", "::", "$", "current", ";", "self", "::", "$", "basis", "=", "0", ";", "self", "::", "$", "basisend", "=", "&", "self", "::", "$", "basis", ";", "self", "::", "$", "x4a", "=", "array", "(", ")", ";", "}" ]
Initialize the configuration list builder for a new state.
[ "Initialize", "the", "configuration", "list", "builder", "for", "a", "new", "state", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L220-L227
2,349
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configtable_reset
static function Configtable_reset($f) { self::$current = 0; self::$currentend = &self::$current; self::$basis = 0; self::$basisend = &self::$basis; self::Configtable_clear(0); }
php
static function Configtable_reset($f) { self::$current = 0; self::$currentend = &self::$current; self::$basis = 0; self::$basisend = &self::$basis; self::Configtable_clear(0); }
[ "static", "function", "Configtable_reset", "(", "$", "f", ")", "{", "self", "::", "$", "current", "=", "0", ";", "self", "::", "$", "currentend", "=", "&", "self", "::", "$", "current", ";", "self", "::", "$", "basis", "=", "0", ";", "self", "::", "$", "basisend", "=", "&", "self", "::", "$", "basis", ";", "self", "::", "Configtable_clear", "(", "0", ")", ";", "}" ]
Remove all data from the table. Pass each data to the function $f as it is removed if $f is a valid callback. @param callback|null @see Configtable_clear()
[ "Remove", "all", "data", "from", "the", "table", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L237-L244
2,350
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configtable_clear
static function Configtable_clear($f) { if (!count(self::$x4a)) { return; } if ($f) { for ($i = 0; $i < count(self::$x4a); $i++) { call_user_func($f, self::$x4a[$i]->data); } } self::$x4a = array(); }
php
static function Configtable_clear($f) { if (!count(self::$x4a)) { return; } if ($f) { for ($i = 0; $i < count(self::$x4a); $i++) { call_user_func($f, self::$x4a[$i]->data); } } self::$x4a = array(); }
[ "static", "function", "Configtable_clear", "(", "$", "f", ")", "{", "if", "(", "!", "count", "(", "self", "::", "$", "x4a", ")", ")", "{", "return", ";", "}", "if", "(", "$", "f", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "self", "::", "$", "x4a", ")", ";", "$", "i", "++", ")", "{", "call_user_func", "(", "$", "f", ",", "self", "::", "$", "x4a", "[", "$", "i", "]", "->", "data", ")", ";", "}", "}", "self", "::", "$", "x4a", "=", "array", "(", ")", ";", "}" ]
Remove all data from the associative array representation of configurations. Pass each data to the function $f as it is removed if $f is a valid callback. @param callback|null
[ "Remove", "all", "data", "from", "the", "associative", "array", "representation", "of", "configurations", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L254-L265
2,351
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_add
static function Configlist_add($rp, $dot) { $model = new PHP_ParserGenerator_Config; $model->rp = $rp; $model->dot = $dot; $cfp = self::Configtable_find($model); if ($cfp === 0) { $cfp = self::newconfig(); $cfp->rp = $rp; $cfp->dot = $dot; $cfp->fws = array(); $cfp->stp = 0; $cfp->fplp = $cfp->bplp = 0; $cfp->next = 0; $cfp->bp = 0; self::$currentend = $cfp; self::$currentend = &$cfp->next; self::Configtable_insert($cfp); } return $cfp; }
php
static function Configlist_add($rp, $dot) { $model = new PHP_ParserGenerator_Config; $model->rp = $rp; $model->dot = $dot; $cfp = self::Configtable_find($model); if ($cfp === 0) { $cfp = self::newconfig(); $cfp->rp = $rp; $cfp->dot = $dot; $cfp->fws = array(); $cfp->stp = 0; $cfp->fplp = $cfp->bplp = 0; $cfp->next = 0; $cfp->bp = 0; self::$currentend = $cfp; self::$currentend = &$cfp->next; self::Configtable_insert($cfp); } return $cfp; }
[ "static", "function", "Configlist_add", "(", "$", "rp", ",", "$", "dot", ")", "{", "$", "model", "=", "new", "PHP_ParserGenerator_Config", ";", "$", "model", "->", "rp", "=", "$", "rp", ";", "$", "model", "->", "dot", "=", "$", "dot", ";", "$", "cfp", "=", "self", "::", "Configtable_find", "(", "$", "model", ")", ";", "if", "(", "$", "cfp", "===", "0", ")", "{", "$", "cfp", "=", "self", "::", "newconfig", "(", ")", ";", "$", "cfp", "->", "rp", "=", "$", "rp", ";", "$", "cfp", "->", "dot", "=", "$", "dot", ";", "$", "cfp", "->", "fws", "=", "array", "(", ")", ";", "$", "cfp", "->", "stp", "=", "0", ";", "$", "cfp", "->", "fplp", "=", "$", "cfp", "->", "bplp", "=", "0", ";", "$", "cfp", "->", "next", "=", "0", ";", "$", "cfp", "->", "bp", "=", "0", ";", "self", "::", "$", "currentend", "=", "$", "cfp", ";", "self", "::", "$", "currentend", "=", "&", "$", "cfp", "->", "next", ";", "self", "::", "Configtable_insert", "(", "$", "cfp", ")", ";", "}", "return", "$", "cfp", ";", "}" ]
Add another configuration to the configuration list for this parser state. @param PHP_ParserGenerator_Rule the rule @param int Index into the right-hand side of the rule where the dot goes @return PHP_ParserGenerator_Config
[ "Add", "another", "configuration", "to", "the", "configuration", "list", "for", "this", "parser", "state", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L282-L302
2,352
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_closure
static function Configlist_closure(PHP_ParserGenerator_Data $lemp) { for ($cfp = self::$current; $cfp; $cfp = $cfp->next) { $rp = $cfp->rp; $dot = $cfp->dot; if ($dot >= $rp->nrhs) { continue; } $sp = $rp->rhs[$dot]; if ($sp->type == PHP_ParserGenerator_Symbol::NONTERMINAL) { if ($sp->rule === 0 && $sp !== $lemp->errsym) { PHP_ParserGenerator::ErrorMsg($lemp->filename, $rp->line, "Nonterminal \"%s\" has no rules.", $sp->name); $lemp->errorcnt++; } for ($newrp = $sp->rule; $newrp; $newrp = $newrp->nextlhs) { $newcfp = self::Configlist_add($newrp, 0); for ($i = $dot + 1; $i < $rp->nrhs; $i++) { $xsp = $rp->rhs[$i]; if ($xsp->type == PHP_ParserGenerator_Symbol::TERMINAL) { $newcfp->fws[$xsp->index] = 1; break; } elseif ($xsp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($k = 0; $k < $xsp->nsubsym; $k++) { $newcfp->fws[$xsp->subsym[$k]->index] = 1; } break; } else { $a = array_diff_key($xsp->firstset, $newcfp->fws); $newcfp->fws += $a; if ($xsp->lambda === false) { break; } } } if ($i == $rp->nrhs) { PHP_ParserGenerator_PropagationLink::Plink_add($cfp->fplp, $newcfp); } } } } }
php
static function Configlist_closure(PHP_ParserGenerator_Data $lemp) { for ($cfp = self::$current; $cfp; $cfp = $cfp->next) { $rp = $cfp->rp; $dot = $cfp->dot; if ($dot >= $rp->nrhs) { continue; } $sp = $rp->rhs[$dot]; if ($sp->type == PHP_ParserGenerator_Symbol::NONTERMINAL) { if ($sp->rule === 0 && $sp !== $lemp->errsym) { PHP_ParserGenerator::ErrorMsg($lemp->filename, $rp->line, "Nonterminal \"%s\" has no rules.", $sp->name); $lemp->errorcnt++; } for ($newrp = $sp->rule; $newrp; $newrp = $newrp->nextlhs) { $newcfp = self::Configlist_add($newrp, 0); for ($i = $dot + 1; $i < $rp->nrhs; $i++) { $xsp = $rp->rhs[$i]; if ($xsp->type == PHP_ParserGenerator_Symbol::TERMINAL) { $newcfp->fws[$xsp->index] = 1; break; } elseif ($xsp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($k = 0; $k < $xsp->nsubsym; $k++) { $newcfp->fws[$xsp->subsym[$k]->index] = 1; } break; } else { $a = array_diff_key($xsp->firstset, $newcfp->fws); $newcfp->fws += $a; if ($xsp->lambda === false) { break; } } } if ($i == $rp->nrhs) { PHP_ParserGenerator_PropagationLink::Plink_add($cfp->fplp, $newcfp); } } } } }
[ "static", "function", "Configlist_closure", "(", "PHP_ParserGenerator_Data", "$", "lemp", ")", "{", "for", "(", "$", "cfp", "=", "self", "::", "$", "current", ";", "$", "cfp", ";", "$", "cfp", "=", "$", "cfp", "->", "next", ")", "{", "$", "rp", "=", "$", "cfp", "->", "rp", ";", "$", "dot", "=", "$", "cfp", "->", "dot", ";", "if", "(", "$", "dot", ">=", "$", "rp", "->", "nrhs", ")", "{", "continue", ";", "}", "$", "sp", "=", "$", "rp", "->", "rhs", "[", "$", "dot", "]", ";", "if", "(", "$", "sp", "->", "type", "==", "PHP_ParserGenerator_Symbol", "::", "NONTERMINAL", ")", "{", "if", "(", "$", "sp", "->", "rule", "===", "0", "&&", "$", "sp", "!==", "$", "lemp", "->", "errsym", ")", "{", "PHP_ParserGenerator", "::", "ErrorMsg", "(", "$", "lemp", "->", "filename", ",", "$", "rp", "->", "line", ",", "\"Nonterminal \\\"%s\\\" has no rules.\"", ",", "$", "sp", "->", "name", ")", ";", "$", "lemp", "->", "errorcnt", "++", ";", "}", "for", "(", "$", "newrp", "=", "$", "sp", "->", "rule", ";", "$", "newrp", ";", "$", "newrp", "=", "$", "newrp", "->", "nextlhs", ")", "{", "$", "newcfp", "=", "self", "::", "Configlist_add", "(", "$", "newrp", ",", "0", ")", ";", "for", "(", "$", "i", "=", "$", "dot", "+", "1", ";", "$", "i", "<", "$", "rp", "->", "nrhs", ";", "$", "i", "++", ")", "{", "$", "xsp", "=", "$", "rp", "->", "rhs", "[", "$", "i", "]", ";", "if", "(", "$", "xsp", "->", "type", "==", "PHP_ParserGenerator_Symbol", "::", "TERMINAL", ")", "{", "$", "newcfp", "->", "fws", "[", "$", "xsp", "->", "index", "]", "=", "1", ";", "break", ";", "}", "elseif", "(", "$", "xsp", "->", "type", "==", "PHP_ParserGenerator_Symbol", "::", "MULTITERMINAL", ")", "{", "for", "(", "$", "k", "=", "0", ";", "$", "k", "<", "$", "xsp", "->", "nsubsym", ";", "$", "k", "++", ")", "{", "$", "newcfp", "->", "fws", "[", "$", "xsp", "->", "subsym", "[", "$", "k", "]", "->", "index", "]", "=", "1", ";", "}", "break", ";", "}", "else", "{", "$", "a", "=", "array_diff_key", "(", "$", "xsp", "->", "firstset", ",", "$", "newcfp", "->", "fws", ")", ";", "$", "newcfp", "->", "fws", "+=", "$", "a", ";", "if", "(", "$", "xsp", "->", "lambda", "===", "false", ")", "{", "break", ";", "}", "}", "}", "if", "(", "$", "i", "==", "$", "rp", "->", "nrhs", ")", "{", "PHP_ParserGenerator_PropagationLink", "::", "Plink_add", "(", "$", "cfp", "->", "fplp", ",", "$", "newcfp", ")", ";", "}", "}", "}", "}", "}" ]
Compute the closure of the configuration list. This calculates all of the possible continuations of each configuration, ensuring that each state accounts for every configuration that could arrive at that state.
[ "Compute", "the", "closure", "of", "the", "configuration", "list", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L345-L386
2,353
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_return
static function Configlist_return() { $old = self::$current; self::$current = 0; self::$currentend = &self::$current; return $old; }
php
static function Configlist_return() { $old = self::$current; self::$current = 0; self::$currentend = &self::$current; return $old; }
[ "static", "function", "Configlist_return", "(", ")", "{", "$", "old", "=", "self", "::", "$", "current", ";", "self", "::", "$", "current", "=", "0", ";", "self", "::", "$", "currentend", "=", "&", "self", "::", "$", "current", ";", "return", "$", "old", ";", "}" ]
Return a pointer to the head of the configuration list and reset the list @see $current @return PHP_ParserGenerator_Config
[ "Return", "a", "pointer", "to", "the", "head", "of", "the", "configuration", "list", "and", "reset", "the", "list" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L420-L426
2,354
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_basis
static function Configlist_basis() { $old = self::$basis; self::$basis = 0; self::$basisend = &self::$basis; return $old; }
php
static function Configlist_basis() { $old = self::$basis; self::$basis = 0; self::$basisend = &self::$basis; return $old; }
[ "static", "function", "Configlist_basis", "(", ")", "{", "$", "old", "=", "self", "::", "$", "basis", ";", "self", "::", "$", "basis", "=", "0", ";", "self", "::", "$", "basisend", "=", "&", "self", "::", "$", "basis", ";", "return", "$", "old", ";", "}" ]
Return a pointer to the head of the basis list and reset the list @see $basis @return PHP_ParserGenerator_Config
[ "Return", "a", "pointer", "to", "the", "head", "of", "the", "basis", "list", "and", "reset", "the", "list" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L434-L440
2,355
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configlist_eat
static function Configlist_eat($cfp) { for (; $cfp; $cfp = $nextcfp) { $nextcfp = $cfp->next; if ($cfp->fplp !=0) { throw new Exception('fplp of configuration non-zero?'); } if ($cfp->bplp !=0) { throw new Exception('bplp of configuration non-zero?'); } if ($cfp->fws) { $cfp->fws = array(); } } }
php
static function Configlist_eat($cfp) { for (; $cfp; $cfp = $nextcfp) { $nextcfp = $cfp->next; if ($cfp->fplp !=0) { throw new Exception('fplp of configuration non-zero?'); } if ($cfp->bplp !=0) { throw new Exception('bplp of configuration non-zero?'); } if ($cfp->fws) { $cfp->fws = array(); } } }
[ "static", "function", "Configlist_eat", "(", "$", "cfp", ")", "{", "for", "(", ";", "$", "cfp", ";", "$", "cfp", "=", "$", "nextcfp", ")", "{", "$", "nextcfp", "=", "$", "cfp", "->", "next", ";", "if", "(", "$", "cfp", "->", "fplp", "!=", "0", ")", "{", "throw", "new", "Exception", "(", "'fplp of configuration non-zero?'", ")", ";", "}", "if", "(", "$", "cfp", "->", "bplp", "!=", "0", ")", "{", "throw", "new", "Exception", "(", "'bplp of configuration non-zero?'", ")", ";", "}", "if", "(", "$", "cfp", "->", "fws", ")", "{", "$", "cfp", "->", "fws", "=", "array", "(", ")", ";", "}", "}", "}" ]
Free all elements of the given configuration list @param PHP_ParserGenerator_Config
[ "Free", "all", "elements", "of", "the", "given", "configuration", "list" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L446-L460
2,356
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.Configcmp
static function Configcmp($a, $b) { $x = $a->rp->index - $b->rp->index; if (!$x) { $x = $a->dot - $b->dot; } return $x; }
php
static function Configcmp($a, $b) { $x = $a->rp->index - $b->rp->index; if (!$x) { $x = $a->dot - $b->dot; } return $x; }
[ "static", "function", "Configcmp", "(", "$", "a", ",", "$", "b", ")", "{", "$", "x", "=", "$", "a", "->", "rp", "->", "index", "-", "$", "b", "->", "rp", "->", "index", ";", "if", "(", "!", "$", "x", ")", "{", "$", "x", "=", "$", "a", "->", "dot", "-", "$", "b", "->", "dot", ";", "}", "return", "$", "x", ";", "}" ]
Compare two configurations for sorting purposes. Configurations based on higher precedence rules (those earlier in the file) are chosen first. Two configurations that are the same rule are sorted by dot (see {@link $dot}), and those configurations with a dot closer to the left-hand side are chosen first. @param unknown_type $a @param unknown_type $b @return unknown
[ "Compare", "two", "configurations", "for", "sorting", "purposes", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L474-L481
2,357
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/Config.php
PHP_ParserGenerator_Config.ConfigPrint
function ConfigPrint($fp) { $rp = $this->rp; fprintf($fp, "%s ::=", $rp->lhs->name); for ($i = 0; $i <= $rp->nrhs; $i++) { if ($i === $this->dot) { fwrite($fp,' *'); } if ($i === $rp->nrhs) { break; } $sp = $rp->rhs[$i]; fprintf($fp,' %s', $sp->name); if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($j = 1; $j < $sp->nsubsym; $j++) { fprintf($fp, '|%s', $sp->subsym[$j]->name); } } } }
php
function ConfigPrint($fp) { $rp = $this->rp; fprintf($fp, "%s ::=", $rp->lhs->name); for ($i = 0; $i <= $rp->nrhs; $i++) { if ($i === $this->dot) { fwrite($fp,' *'); } if ($i === $rp->nrhs) { break; } $sp = $rp->rhs[$i]; fprintf($fp,' %s', $sp->name); if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) { for ($j = 1; $j < $sp->nsubsym; $j++) { fprintf($fp, '|%s', $sp->subsym[$j]->name); } } } }
[ "function", "ConfigPrint", "(", "$", "fp", ")", "{", "$", "rp", "=", "$", "this", "->", "rp", ";", "fprintf", "(", "$", "fp", ",", "\"%s ::=\"", ",", "$", "rp", "->", "lhs", "->", "name", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "rp", "->", "nrhs", ";", "$", "i", "++", ")", "{", "if", "(", "$", "i", "===", "$", "this", "->", "dot", ")", "{", "fwrite", "(", "$", "fp", ",", "' *'", ")", ";", "}", "if", "(", "$", "i", "===", "$", "rp", "->", "nrhs", ")", "{", "break", ";", "}", "$", "sp", "=", "$", "rp", "->", "rhs", "[", "$", "i", "]", ";", "fprintf", "(", "$", "fp", ",", "' %s'", ",", "$", "sp", "->", "name", ")", ";", "if", "(", "$", "sp", "->", "type", "==", "PHP_ParserGenerator_Symbol", "::", "MULTITERMINAL", ")", "{", "for", "(", "$", "j", "=", "1", ";", "$", "j", "<", "$", "sp", "->", "nsubsym", ";", "$", "j", "++", ")", "{", "fprintf", "(", "$", "fp", ",", "'|%s'", ",", "$", "sp", "->", "subsym", "[", "$", "j", "]", "->", "name", ")", ";", "}", "}", "}", "}" ]
Print out information on this configuration. @param resource $fp @see PHP_ParserGenerator_Data::ReportOutput()
[ "Print", "out", "information", "on", "this", "configuration", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Config.php#L489-L508
2,358
Stratadox/HydrationMapping
src/Property/Relationship/ProxyProductionFailed.php
ProxyProductionFailed.tryingToProduceFor
public static function tryingToProduceFor( MapsProperty $mapping, Throwable $exception ): Throwable { return new self( sprintf( 'Proxy production for in the `%s` property failed: %s', $mapping->name(), $exception->getMessage() ), 0, $exception ); }
php
public static function tryingToProduceFor( MapsProperty $mapping, Throwable $exception ): Throwable { return new self( sprintf( 'Proxy production for in the `%s` property failed: %s', $mapping->name(), $exception->getMessage() ), 0, $exception ); }
[ "public", "static", "function", "tryingToProduceFor", "(", "MapsProperty", "$", "mapping", ",", "Throwable", "$", "exception", ")", ":", "Throwable", "{", "return", "new", "self", "(", "sprintf", "(", "'Proxy production for in the `%s` property failed: %s'", ",", "$", "mapping", "->", "name", "(", ")", ",", "$", "exception", "->", "getMessage", "(", ")", ")", ",", "0", ",", "$", "exception", ")", ";", "}" ]
Notifies the client code when an item could not be hydrated. @param MapsProperty $mapping The proxy mapping that failed. @param Throwable $exception The exception that was encountered. @return Throwable The proxy production failure.
[ "Notifies", "the", "client", "code", "when", "an", "item", "could", "not", "be", "hydrated", "." ]
b145deaaf76ab8c8060f0cba1a8c6f73da375982
https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Relationship/ProxyProductionFailed.php#L27-L40
2,359
OWeb/OWeb-Framework
OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/AbstractElement.php
AbstractElement.validate
public function validate(){ if(empty($this->_validators)){ $this->_valid = true; return true; } $valid = false; $newValue = null; foreach ($this->_validators as $validator) { try{ $newGeneratedValue = $validator->valideteValue($this->getVal()); if(!$valid) $newValue = $newGeneratedValue; $valid = true; } catch ( \OWeb\types\UserException $ex){ $valid = $valid || false; $this->_errMessages[] = $ex->getMessage(); $this->_errDesriptions[] = $ex->getUserDescription(); } } if($valid) $this->_trueVal = $newValue; else $this->_trueVal = null; $this->_valid = $valid; return $valid; }
php
public function validate(){ if(empty($this->_validators)){ $this->_valid = true; return true; } $valid = false; $newValue = null; foreach ($this->_validators as $validator) { try{ $newGeneratedValue = $validator->valideteValue($this->getVal()); if(!$valid) $newValue = $newGeneratedValue; $valid = true; } catch ( \OWeb\types\UserException $ex){ $valid = $valid || false; $this->_errMessages[] = $ex->getMessage(); $this->_errDesriptions[] = $ex->getUserDescription(); } } if($valid) $this->_trueVal = $newValue; else $this->_trueVal = null; $this->_valid = $valid; return $valid; }
[ "public", "function", "validate", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_validators", ")", ")", "{", "$", "this", "->", "_valid", "=", "true", ";", "return", "true", ";", "}", "$", "valid", "=", "false", ";", "$", "newValue", "=", "null", ";", "foreach", "(", "$", "this", "->", "_validators", "as", "$", "validator", ")", "{", "try", "{", "$", "newGeneratedValue", "=", "$", "validator", "->", "valideteValue", "(", "$", "this", "->", "getVal", "(", ")", ")", ";", "if", "(", "!", "$", "valid", ")", "$", "newValue", "=", "$", "newGeneratedValue", ";", "$", "valid", "=", "true", ";", "}", "catch", "(", "\\", "OWeb", "\\", "types", "\\", "UserException", "$", "ex", ")", "{", "$", "valid", "=", "$", "valid", "||", "false", ";", "$", "this", "->", "_errMessages", "[", "]", "=", "$", "ex", "->", "getMessage", "(", ")", ";", "$", "this", "->", "_errDesriptions", "[", "]", "=", "$", "ex", "->", "getUserDescription", "(", ")", ";", "}", "}", "if", "(", "$", "valid", ")", "$", "this", "->", "_trueVal", "=", "$", "newValue", ";", "else", "$", "this", "->", "_trueVal", "=", "null", ";", "$", "this", "->", "_valid", "=", "$", "valid", ";", "return", "$", "valid", ";", "}" ]
Will start the validation procees. @return boolean Whatever the validation was sucessfull or not
[ "Will", "start", "the", "validation", "procees", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Elements/AbstractElement.php#L195-L225
2,360
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/DataObject.php
DataObject.firstOrMake
public function firstOrMake($filter = [], $additionalData = [], $write = true) { if (!($record = $this->owner->get()->filter($filter)->first())) { $record = $this->owner->create(array_merge($filter, $additionalData)); if ($write) { $record->write(); $record->isNew = true; } } return $record; }
php
public function firstOrMake($filter = [], $additionalData = [], $write = true) { if (!($record = $this->owner->get()->filter($filter)->first())) { $record = $this->owner->create(array_merge($filter, $additionalData)); if ($write) { $record->write(); $record->isNew = true; } } return $record; }
[ "public", "function", "firstOrMake", "(", "$", "filter", "=", "[", "]", ",", "$", "additionalData", "=", "[", "]", ",", "$", "write", "=", "true", ")", "{", "if", "(", "!", "(", "$", "record", "=", "$", "this", "->", "owner", "->", "get", "(", ")", "->", "filter", "(", "$", "filter", ")", "->", "first", "(", ")", ")", ")", "{", "$", "record", "=", "$", "this", "->", "owner", "->", "create", "(", "array_merge", "(", "$", "filter", ",", "$", "additionalData", ")", ")", ";", "if", "(", "$", "write", ")", "{", "$", "record", "->", "write", "(", ")", ";", "$", "record", "->", "isNew", "=", "true", ";", "}", "}", "return", "$", "record", ";", "}" ]
Find a record using a filter, or create it if it doesn't exist @param array $filter @param array $additionalData @param bool|true $write @return static
[ "Find", "a", "record", "using", "a", "filter", "or", "create", "it", "if", "it", "doesn", "t", "exist" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/DataObject.php#L36-L48
2,361
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/DataObject.php
DataObject.firstOrCreate
public function firstOrCreate($filter = [], $additionalData = [], $write = true) { return $this->owner->firstOrMake($filter, $additionalData, $write); }
php
public function firstOrCreate($filter = [], $additionalData = [], $write = true) { return $this->owner->firstOrMake($filter, $additionalData, $write); }
[ "public", "function", "firstOrCreate", "(", "$", "filter", "=", "[", "]", ",", "$", "additionalData", "=", "[", "]", ",", "$", "write", "=", "true", ")", "{", "return", "$", "this", "->", "owner", "->", "firstOrMake", "(", "$", "filter", ",", "$", "additionalData", ",", "$", "write", ")", ";", "}" ]
Alias of ->firstOrMake @param array $filter @param array $additionalData @param bool|true $write @return static
[ "Alias", "of", "-", ">", "firstOrMake" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/DataObject.php#L58-L61
2,362
hubkat/hubkat.event
src/Event.php
Event.isValid
public function isValid($secret) { if (!extension_loaded('hash')) { // @codeCoverageIgnoreStart throw new \Exception('Hash extension not loaded'); // @codeCoverageIgnoreEnd } list($algo, $sig) = explode("=", $this->signature); if (!in_array($algo, hash_algos(), true)) { throw new \Exception("Hash algorithm '$algo' is not supported."); } $hash = hash_hmac($algo, $this->rawBody, $secret); return (md5($sig) === md5($hash)); }
php
public function isValid($secret) { if (!extension_loaded('hash')) { // @codeCoverageIgnoreStart throw new \Exception('Hash extension not loaded'); // @codeCoverageIgnoreEnd } list($algo, $sig) = explode("=", $this->signature); if (!in_array($algo, hash_algos(), true)) { throw new \Exception("Hash algorithm '$algo' is not supported."); } $hash = hash_hmac($algo, $this->rawBody, $secret); return (md5($sig) === md5($hash)); }
[ "public", "function", "isValid", "(", "$", "secret", ")", "{", "if", "(", "!", "extension_loaded", "(", "'hash'", ")", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "Exception", "(", "'Hash extension not loaded'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "list", "(", "$", "algo", ",", "$", "sig", ")", "=", "explode", "(", "\"=\"", ",", "$", "this", "->", "signature", ")", ";", "if", "(", "!", "in_array", "(", "$", "algo", ",", "hash_algos", "(", ")", ",", "true", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Hash algorithm '$algo' is not supported.\"", ")", ";", "}", "$", "hash", "=", "hash_hmac", "(", "$", "algo", ",", "$", "this", "->", "rawBody", ",", "$", "secret", ")", ";", "return", "(", "md5", "(", "$", "sig", ")", "===", "md5", "(", "$", "hash", ")", ")", ";", "}" ]
Validate the signature @param string $secret secret string @return bool @access public
[ "Validate", "the", "signature" ]
6b752c305e81f9ee5176bd7ac26127e68637fca6
https://github.com/hubkat/hubkat.event/blob/6b752c305e81f9ee5176bd7ac26127e68637fca6/src/Event.php#L87-L104
2,363
bytic/helpers
src/Color.php
Nip_Helper_Color.lumDiff
public function lumDiff($color1, $color2) { list($R1, $G1, $B1) = is_array($color1) ? $color1 : $this->rgb($color1); list($R2, $G2, $B2) = is_array($color2) ? $color2 : $this->rgb($color2); $L1 = 0.2126 * pow($R1 / 255, 2.2) + 0.7152 * pow($G1 / 255, 2.2) + 0.0722 * pow($B1 / 255, 2.2); $L2 = 0.2126 * pow($R2 / 255, 2.2) + 0.7152 * pow($G2 / 255, 2.2) + 0.0722 * pow($B2 / 255, 2.2); if ($L1 > $L2) { return ($L1 + 0.05) / ($L2 + 0.05); } else { return ($L2 + 0.05) / ($L1 + 0.05); } }
php
public function lumDiff($color1, $color2) { list($R1, $G1, $B1) = is_array($color1) ? $color1 : $this->rgb($color1); list($R2, $G2, $B2) = is_array($color2) ? $color2 : $this->rgb($color2); $L1 = 0.2126 * pow($R1 / 255, 2.2) + 0.7152 * pow($G1 / 255, 2.2) + 0.0722 * pow($B1 / 255, 2.2); $L2 = 0.2126 * pow($R2 / 255, 2.2) + 0.7152 * pow($G2 / 255, 2.2) + 0.0722 * pow($B2 / 255, 2.2); if ($L1 > $L2) { return ($L1 + 0.05) / ($L2 + 0.05); } else { return ($L2 + 0.05) / ($L1 + 0.05); } }
[ "public", "function", "lumDiff", "(", "$", "color1", ",", "$", "color2", ")", "{", "list", "(", "$", "R1", ",", "$", "G1", ",", "$", "B1", ")", "=", "is_array", "(", "$", "color1", ")", "?", "$", "color1", ":", "$", "this", "->", "rgb", "(", "$", "color1", ")", ";", "list", "(", "$", "R2", ",", "$", "G2", ",", "$", "B2", ")", "=", "is_array", "(", "$", "color2", ")", "?", "$", "color2", ":", "$", "this", "->", "rgb", "(", "$", "color2", ")", ";", "$", "L1", "=", "0.2126", "*", "pow", "(", "$", "R1", "/", "255", ",", "2.2", ")", "+", "0.7152", "*", "pow", "(", "$", "G1", "/", "255", ",", "2.2", ")", "+", "0.0722", "*", "pow", "(", "$", "B1", "/", "255", ",", "2.2", ")", ";", "$", "L2", "=", "0.2126", "*", "pow", "(", "$", "R2", "/", "255", ",", "2.2", ")", "+", "0.7152", "*", "pow", "(", "$", "G2", "/", "255", ",", "2.2", ")", "+", "0.0722", "*", "pow", "(", "$", "B2", "/", "255", ",", "2.2", ")", ";", "if", "(", "$", "L1", ">", "$", "L2", ")", "{", "return", "(", "$", "L1", "+", "0.05", ")", "/", "(", "$", "L2", "+", "0.05", ")", ";", "}", "else", "{", "return", "(", "$", "L2", "+", "0.05", ")", "/", "(", "$", "L1", "+", "0.05", ")", ";", "}", "}" ]
Uses luminosity to calculate the difference between the given colors. The returned value should be bigger than 5 for best readability. @param string|array $color1 @param string|array $color2 @return double
[ "Uses", "luminosity", "to", "calculate", "the", "difference", "between", "the", "given", "colors", ".", "The", "returned", "value", "should", "be", "bigger", "than", "5", "for", "best", "readability", "." ]
6a4f0388ba8653d65058ce63cf7627e38b9df041
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/Color.php#L1700-L1718
2,364
fond-of/active-campaign
src/Service.php
Service.getFormParams
protected function getFormParams($parameters = array()) { $formParams = $parameters; if (!array_key_exists('api_output', $formParams)) { $formParams['api_output'] = Api::DEFAULT_OUTPUT; } if (!array_key_exists('api_key', $formParams)) { $formParams['api_key'] = $this->apiKey; } return $formParams; }
php
protected function getFormParams($parameters = array()) { $formParams = $parameters; if (!array_key_exists('api_output', $formParams)) { $formParams['api_output'] = Api::DEFAULT_OUTPUT; } if (!array_key_exists('api_key', $formParams)) { $formParams['api_key'] = $this->apiKey; } return $formParams; }
[ "protected", "function", "getFormParams", "(", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "formParams", "=", "$", "parameters", ";", "if", "(", "!", "array_key_exists", "(", "'api_output'", ",", "$", "formParams", ")", ")", "{", "$", "formParams", "[", "'api_output'", "]", "=", "Api", "::", "DEFAULT_OUTPUT", ";", "}", "if", "(", "!", "array_key_exists", "(", "'api_key'", ",", "$", "formParams", ")", ")", "{", "$", "formParams", "[", "'api_key'", "]", "=", "$", "this", "->", "apiKey", ";", "}", "return", "$", "formParams", ";", "}" ]
Get form params @param array $parameters @return array
[ "Get", "form", "params" ]
389e6c3ca4e39f2f94f92a9673fe3207a9d15807
https://github.com/fond-of/active-campaign/blob/389e6c3ca4e39f2f94f92a9673fe3207a9d15807/src/Service.php#L137-L150
2,365
fond-of/active-campaign
src/Service.php
Service.removeResultInformation
protected function removeResultInformation($json) { $object = json_decode($json, false); if (property_exists($object, 'result_code')) { unset($object->result_code); } if (property_exists($object, 'result_message')) { unset($object->result_message); } if (property_exists($object, 'result_output')) { unset($object->result_output); } return json_encode($object); }
php
protected function removeResultInformation($json) { $object = json_decode($json, false); if (property_exists($object, 'result_code')) { unset($object->result_code); } if (property_exists($object, 'result_message')) { unset($object->result_message); } if (property_exists($object, 'result_output')) { unset($object->result_output); } return json_encode($object); }
[ "protected", "function", "removeResultInformation", "(", "$", "json", ")", "{", "$", "object", "=", "json_decode", "(", "$", "json", ",", "false", ")", ";", "if", "(", "property_exists", "(", "$", "object", ",", "'result_code'", ")", ")", "{", "unset", "(", "$", "object", "->", "result_code", ")", ";", "}", "if", "(", "property_exists", "(", "$", "object", ",", "'result_message'", ")", ")", "{", "unset", "(", "$", "object", "->", "result_message", ")", ";", "}", "if", "(", "property_exists", "(", "$", "object", ",", "'result_output'", ")", ")", "{", "unset", "(", "$", "object", "->", "result_output", ")", ";", "}", "return", "json_encode", "(", "$", "object", ")", ";", "}" ]
Remove result information @param $json @return string
[ "Remove", "result", "information" ]
389e6c3ca4e39f2f94f92a9673fe3207a9d15807
https://github.com/fond-of/active-campaign/blob/389e6c3ca4e39f2f94f92a9673fe3207a9d15807/src/Service.php#L171-L187
2,366
lucidphp/signal
src/EventName.php
EventName.parseEventName
private function parseEventName() { $name = basename(strtr(get_class($this->event), ['\\' => '/'])); return strtolower(preg_replace('#[A-Z]#', '.$0', lcfirst($name))); }
php
private function parseEventName() { $name = basename(strtr(get_class($this->event), ['\\' => '/'])); return strtolower(preg_replace('#[A-Z]#', '.$0', lcfirst($name))); }
[ "private", "function", "parseEventName", "(", ")", "{", "$", "name", "=", "basename", "(", "strtr", "(", "get_class", "(", "$", "this", "->", "event", ")", ",", "[", "'\\\\'", "=>", "'/'", "]", ")", ")", ";", "return", "strtolower", "(", "preg_replace", "(", "'#[A-Z]#'", ",", "'.$0'", ",", "lcfirst", "(", "$", "name", ")", ")", ")", ";", "}" ]
Parses an event object into a readable event name. @return string
[ "Parses", "an", "event", "object", "into", "a", "readable", "event", "name", "." ]
387c545f95d077dda726469c68a464509990a1f0
https://github.com/lucidphp/signal/blob/387c545f95d077dda726469c68a464509990a1f0/src/EventName.php#L80-L85
2,367
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.processError
public function processError($exception, $type = 'exception', $logonly = false, $forcelogtrace = false) { // log information // error function is from the trait . It will log something if there is logger inited $this->countoferrors++; if ($this->countoferrors > 500) { // if there are so many errors then somethign went wrong. better to stop // as it can be some wrong loop return false; } $this->error($exception->getMessage(), // set group and exception as context for logger. Logger will decide what to write to a file array( 'group' => 'error|'.$type, 'exception' => $exception, 'forcelogtrace' => $forcelogtrace, 'extrainfo' => 'Request info: '.$this->getRequestInformation())); $this->actionOnError($exception,$type); // this condition can be used to log information about some exception but don't stop the app if ($logonly) { return true; } if (!$this->showwarningmessage && $type == 'warning') { // show nothing to a user in case of warning return true; } if (!$this->showfatalmessage && $type == 'fatal') { // show nothing to a user in case of fatal error return true; } // decide hot to show to a user based on requested format $format = $this->getViewFormat(); if ($format != 'html' && $type == 'fatal'){ // for fatal error no sense to display somethign if this is not html request return true; } // display error screen based on the format switch ($format) { case 'json' : $this->showJSON($exception); break; case 'xml': $this->showXML($exception); break; case 'http': $this->showHTTP($exception); break; default: $this->showHTML($exception); } // if error message is displayed then no sence to do somethig else. die(); }
php
public function processError($exception, $type = 'exception', $logonly = false, $forcelogtrace = false) { // log information // error function is from the trait . It will log something if there is logger inited $this->countoferrors++; if ($this->countoferrors > 500) { // if there are so many errors then somethign went wrong. better to stop // as it can be some wrong loop return false; } $this->error($exception->getMessage(), // set group and exception as context for logger. Logger will decide what to write to a file array( 'group' => 'error|'.$type, 'exception' => $exception, 'forcelogtrace' => $forcelogtrace, 'extrainfo' => 'Request info: '.$this->getRequestInformation())); $this->actionOnError($exception,$type); // this condition can be used to log information about some exception but don't stop the app if ($logonly) { return true; } if (!$this->showwarningmessage && $type == 'warning') { // show nothing to a user in case of warning return true; } if (!$this->showfatalmessage && $type == 'fatal') { // show nothing to a user in case of fatal error return true; } // decide hot to show to a user based on requested format $format = $this->getViewFormat(); if ($format != 'html' && $type == 'fatal'){ // for fatal error no sense to display somethign if this is not html request return true; } // display error screen based on the format switch ($format) { case 'json' : $this->showJSON($exception); break; case 'xml': $this->showXML($exception); break; case 'http': $this->showHTTP($exception); break; default: $this->showHTML($exception); } // if error message is displayed then no sence to do somethig else. die(); }
[ "public", "function", "processError", "(", "$", "exception", ",", "$", "type", "=", "'exception'", ",", "$", "logonly", "=", "false", ",", "$", "forcelogtrace", "=", "false", ")", "{", "// log information ", "// error function is from the trait . It will log something if there is logger inited", "$", "this", "->", "countoferrors", "++", ";", "if", "(", "$", "this", "->", "countoferrors", ">", "500", ")", "{", "// if there are so many errors then somethign went wrong. better to stop", "// as it can be some wrong loop ", "return", "false", ";", "}", "$", "this", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "// set group and exception as context for logger. Logger will decide what to write to a file", "array", "(", "'group'", "=>", "'error|'", ".", "$", "type", ",", "'exception'", "=>", "$", "exception", ",", "'forcelogtrace'", "=>", "$", "forcelogtrace", ",", "'extrainfo'", "=>", "'Request info: '", ".", "$", "this", "->", "getRequestInformation", "(", ")", ")", ")", ";", "$", "this", "->", "actionOnError", "(", "$", "exception", ",", "$", "type", ")", ";", "// this condition can be used to log information about some exception but don't stop the app", "if", "(", "$", "logonly", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "this", "->", "showwarningmessage", "&&", "$", "type", "==", "'warning'", ")", "{", "// show nothing to a user in case of warning", "return", "true", ";", "}", "if", "(", "!", "$", "this", "->", "showfatalmessage", "&&", "$", "type", "==", "'fatal'", ")", "{", "// show nothing to a user in case of fatal error", "return", "true", ";", "}", "// decide hot to show to a user based on requested format", "$", "format", "=", "$", "this", "->", "getViewFormat", "(", ")", ";", "if", "(", "$", "format", "!=", "'html'", "&&", "$", "type", "==", "'fatal'", ")", "{", "// for fatal error no sense to display somethign if this is not html request", "return", "true", ";", "}", "// display error screen based on the format", "switch", "(", "$", "format", ")", "{", "case", "'json'", ":", "$", "this", "->", "showJSON", "(", "$", "exception", ")", ";", "break", ";", "case", "'xml'", ":", "$", "this", "->", "showXML", "(", "$", "exception", ")", ";", "break", ";", "case", "'http'", ":", "$", "this", "->", "showHTTP", "(", "$", "exception", ")", ";", "break", ";", "default", ":", "$", "this", "->", "showHTML", "(", "$", "exception", ")", ";", "}", "// if error message is displayed then no sence to do somethig else.", "die", "(", ")", ";", "}" ]
The function logs an error and desides what to show to a user It can be called from outside or from internal methods in case of warning or fatal error @param Exception $exception An exception to log and display @param string $type Type of exception error. Possible values: exception, warning, fatal @return boolean
[ "The", "function", "logs", "an", "error", "and", "desides", "what", "to", "show", "to", "a", "user", "It", "can", "be", "called", "from", "outside", "or", "from", "internal", "methods", "in", "case", "of", "warning", "or", "fatal", "error" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L260-L321
2,368
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.getHTMLError
public function getHTMLError($exception) { $html = '<div style="position: absolute; top:0; right:0; width:100%; height:100%; background: #ffffff;">'."\n". '<table align="center" style="width:65%; margin-top: 30px; background: #FFCC66;" cellpadding="10" cellspacing="1" border="0">'."\n". '<tr>'."\n". '<td style="background: #FFCC99;">Unexpected error!</td>'."\n". '</tr>'."\n". '<tr>'."\n". '<td style="padding-top: 15px; padding-bottom: 35px; background: #FFFF99;">'."\n". $this->getMessageForUser($exception).'.<br><br>'."\n". 'We are notified and will solve the problem as soon as possible.<br>'."\n". '</td>'."\n". '</tr>'."\n"; if ($this->showtrace) { $html .= '<tr>'."\n". '<td style="padding-top: 15px; padding-bottom: 35px; background: #FFFF99; white-space: pre ;">'."\n". $exception->getTraceAsString()."\n". '</td>'."\n". '</tr>'."\n"; } $html .= '</table>'."\n". '</div>'; return $html; }
php
public function getHTMLError($exception) { $html = '<div style="position: absolute; top:0; right:0; width:100%; height:100%; background: #ffffff;">'."\n". '<table align="center" style="width:65%; margin-top: 30px; background: #FFCC66;" cellpadding="10" cellspacing="1" border="0">'."\n". '<tr>'."\n". '<td style="background: #FFCC99;">Unexpected error!</td>'."\n". '</tr>'."\n". '<tr>'."\n". '<td style="padding-top: 15px; padding-bottom: 35px; background: #FFFF99;">'."\n". $this->getMessageForUser($exception).'.<br><br>'."\n". 'We are notified and will solve the problem as soon as possible.<br>'."\n". '</td>'."\n". '</tr>'."\n"; if ($this->showtrace) { $html .= '<tr>'."\n". '<td style="padding-top: 15px; padding-bottom: 35px; background: #FFFF99; white-space: pre ;">'."\n". $exception->getTraceAsString()."\n". '</td>'."\n". '</tr>'."\n"; } $html .= '</table>'."\n". '</div>'; return $html; }
[ "public", "function", "getHTMLError", "(", "$", "exception", ")", "{", "$", "html", "=", "'<div style=\"position: absolute; top:0; right:0; width:100%; height:100%; background: #ffffff;\">'", ".", "\"\\n\"", ".", "'<table align=\"center\" style=\"width:65%; margin-top: 30px; background: #FFCC66;\" cellpadding=\"10\" cellspacing=\"1\" border=\"0\">'", ".", "\"\\n\"", ".", "'<tr>'", ".", "\"\\n\"", ".", "'<td style=\"background: #FFCC99;\">Unexpected error!</td>'", ".", "\"\\n\"", ".", "'</tr>'", ".", "\"\\n\"", ".", "'<tr>'", ".", "\"\\n\"", ".", "'<td style=\"padding-top: 15px; padding-bottom: 35px; background: #FFFF99;\">'", ".", "\"\\n\"", ".", "$", "this", "->", "getMessageForUser", "(", "$", "exception", ")", ".", "'.<br><br>'", ".", "\"\\n\"", ".", "'We are notified and will solve the problem as soon as possible.<br>'", ".", "\"\\n\"", ".", "'</td>'", ".", "\"\\n\"", ".", "'</tr>'", ".", "\"\\n\"", ";", "if", "(", "$", "this", "->", "showtrace", ")", "{", "$", "html", ".=", "'<tr>'", ".", "\"\\n\"", ".", "'<td style=\"padding-top: 15px; padding-bottom: 35px; background: #FFFF99; white-space: pre ;\">'", ".", "\"\\n\"", ".", "$", "exception", "->", "getTraceAsString", "(", ")", ".", "\"\\n\"", ".", "'</td>'", ".", "\"\\n\"", ".", "'</tr>'", ".", "\"\\n\"", ";", "}", "$", "html", ".=", "'</table>'", ".", "\"\\n\"", ".", "'</div>'", ";", "return", "$", "html", ";", "}" ]
Build HTML to display error @param Exception $exception Exception to show message from @return string HTML of the error screen
[ "Build", "HTML", "to", "display", "error" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L346-L370
2,369
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.showHTTP
protected function showHTTP($exception) { header("HTTP/1.1 400 Unexpected error"); $message = preg_replace('![^a-z 0-9_-]!','',$this->getMessageForUser($exception)); header("X-Error-Message: ".$message); }
php
protected function showHTTP($exception) { header("HTTP/1.1 400 Unexpected error"); $message = preg_replace('![^a-z 0-9_-]!','',$this->getMessageForUser($exception)); header("X-Error-Message: ".$message); }
[ "protected", "function", "showHTTP", "(", "$", "exception", ")", "{", "header", "(", "\"HTTP/1.1 400 Unexpected error\"", ")", ";", "$", "message", "=", "preg_replace", "(", "'![^a-z 0-9_-]!'", ",", "''", ",", "$", "this", "->", "getMessageForUser", "(", "$", "exception", ")", ")", ";", "header", "(", "\"X-Error-Message: \"", ".", "$", "message", ")", ";", "}" ]
Return to user only headers with an error as part of a header
[ "Return", "to", "user", "only", "headers", "with", "an", "error", "as", "part", "of", "a", "header" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L374-L378
2,370
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.showXML
protected function showXML($exception) { $endline = "\r\n"; $xml = '<?xml version="1.0" encoding="UTF-8"?>'.$endline. '<response>'.$endline. '<status>error</status>'.$endline. '<message>'.htmlspecialchars($this->getMessageForUser($exception)).'</message>'.$endline. '</response>'; header('Content-Type: application/xml; charset=utf-8'); echo $xml; }
php
protected function showXML($exception) { $endline = "\r\n"; $xml = '<?xml version="1.0" encoding="UTF-8"?>'.$endline. '<response>'.$endline. '<status>error</status>'.$endline. '<message>'.htmlspecialchars($this->getMessageForUser($exception)).'</message>'.$endline. '</response>'; header('Content-Type: application/xml; charset=utf-8'); echo $xml; }
[ "protected", "function", "showXML", "(", "$", "exception", ")", "{", "$", "endline", "=", "\"\\r\\n\"", ";", "$", "xml", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", ".", "$", "endline", ".", "'<response>'", ".", "$", "endline", ".", "'<status>error</status>'", ".", "$", "endline", ".", "'<message>'", ".", "htmlspecialchars", "(", "$", "this", "->", "getMessageForUser", "(", "$", "exception", ")", ")", ".", "'</message>'", ".", "$", "endline", ".", "'</response>'", ";", "header", "(", "'Content-Type: application/xml; charset=utf-8'", ")", ";", "echo", "$", "xml", ";", "}" ]
Display error in XML format @param Exception $exception Exception to show message from
[ "Display", "error", "in", "XML", "format" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L394-L404
2,371
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.warningHandler
public function warningHandler($errno, $errstr, $errfile, $errline) { if ($errno != E_WARNING && $errno != E_USER_WARNING) { return false; } $message = "WARNING! [$errno] $errstr. Line $errline in file $errfile. "; // because some more problems can happen during logging or display // better to disable this handler $this->setCatchWarnings(false); $exception = new \Exception($message); $this->processError($exception,'warning'); $this->setCatchWarnings(true); }
php
public function warningHandler($errno, $errstr, $errfile, $errline) { if ($errno != E_WARNING && $errno != E_USER_WARNING) { return false; } $message = "WARNING! [$errno] $errstr. Line $errline in file $errfile. "; // because some more problems can happen during logging or display // better to disable this handler $this->setCatchWarnings(false); $exception = new \Exception($message); $this->processError($exception,'warning'); $this->setCatchWarnings(true); }
[ "public", "function", "warningHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "if", "(", "$", "errno", "!=", "E_WARNING", "&&", "$", "errno", "!=", "E_USER_WARNING", ")", "{", "return", "false", ";", "}", "$", "message", "=", "\"WARNING! [$errno] $errstr. Line $errline in file $errfile. \"", ";", "// because some more problems can happen during logging or display", "// better to disable this handler", "$", "this", "->", "setCatchWarnings", "(", "false", ")", ";", "$", "exception", "=", "new", "\\", "Exception", "(", "$", "message", ")", ";", "$", "this", "->", "processError", "(", "$", "exception", ",", "'warning'", ")", ";", "$", "this", "->", "setCatchWarnings", "(", "true", ")", ";", "}" ]
To catch warnings. Notices are ignored in this function. This is the callback for a function set_error_handler
[ "To", "catch", "warnings", ".", "Notices", "are", "ignored", "in", "this", "function", ".", "This", "is", "the", "callback", "for", "a", "function", "set_error_handler" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L409-L425
2,372
Gelembjuk/logger
src/Gelembjuk/Logger/ErrorScreen.php
ErrorScreen.getRequestInformation
protected function getRequestInformation() { $postdata = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // build a request string $t = array(); foreach ($_POST as $k => $v) { $t[] = $k . '=' . $v; } // make a one line string $postdata = preg_replace('![\n\r]!',"",implode('&',$t)); // truncate if too long if (strlen($postdata) > 250) { $postdata = substr($postdata,0,250); } } // build a string with information about a request $requestinfo = ' '.getmypid() . "; " . basename($_SERVER['SCRIPT_FILENAME']) . "; " . $_SERVER['REMOTE_ADDR'] . "; " . $_SERVER['REQUEST_METHOD'] . "; " . $_SERVER['QUERY_STRING'] . "; " . $postdata . "; " . $_SERVER['HTTP_USER_AGENT'] . "; " . $_SERVER['HTTP_REFERER']; return $requestinfo; }
php
protected function getRequestInformation() { $postdata = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // build a request string $t = array(); foreach ($_POST as $k => $v) { $t[] = $k . '=' . $v; } // make a one line string $postdata = preg_replace('![\n\r]!',"",implode('&',$t)); // truncate if too long if (strlen($postdata) > 250) { $postdata = substr($postdata,0,250); } } // build a string with information about a request $requestinfo = ' '.getmypid() . "; " . basename($_SERVER['SCRIPT_FILENAME']) . "; " . $_SERVER['REMOTE_ADDR'] . "; " . $_SERVER['REQUEST_METHOD'] . "; " . $_SERVER['QUERY_STRING'] . "; " . $postdata . "; " . $_SERVER['HTTP_USER_AGENT'] . "; " . $_SERVER['HTTP_REFERER']; return $requestinfo; }
[ "protected", "function", "getRequestInformation", "(", ")", "{", "$", "postdata", "=", "''", ";", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "==", "'POST'", ")", "{", "// build a request string", "$", "t", "=", "array", "(", ")", ";", "foreach", "(", "$", "_POST", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "t", "[", "]", "=", "$", "k", ".", "'='", ".", "$", "v", ";", "}", "// make a one line string", "$", "postdata", "=", "preg_replace", "(", "'![\\n\\r]!'", ",", "\"\"", ",", "implode", "(", "'&'", ",", "$", "t", ")", ")", ";", "// truncate if too long", "if", "(", "strlen", "(", "$", "postdata", ")", ">", "250", ")", "{", "$", "postdata", "=", "substr", "(", "$", "postdata", ",", "0", ",", "250", ")", ";", "}", "}", "// build a string with information about a request", "$", "requestinfo", "=", "' '", ".", "getmypid", "(", ")", ".", "\"; \"", ".", "basename", "(", "$", "_SERVER", "[", "'SCRIPT_FILENAME'", "]", ")", ".", "\"; \"", ".", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ".", "\"; \"", ".", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ".", "\"; \"", ".", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ".", "\"; \"", ".", "$", "postdata", ".", "\"; \"", ".", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ".", "\"; \"", ".", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ";", "return", "$", "requestinfo", ";", "}" ]
Collect request information to log it. This can help to solve a problem later. @return string Requets information, for logging
[ "Collect", "request", "information", "to", "log", "it", ".", "This", "can", "help", "to", "solve", "a", "problem", "later", "." ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/ErrorScreen.php#L464-L494
2,373
harmony-project/modular-routing
source/Provider/SegmentProvider.php
SegmentProvider.matchRequest
protected function matchRequest(Request $request, array $parameters = []) { if (!isset($parameters['_modular_path'])) { throw new \InvalidArgumentException('The routing provider expected parameter "_modular_path" but could not find it.'); } // Grab the first segment from the remaining path $path = $parameters['_modular_path']; $position = strpos($path, '/'); return $position ? substr($path, 0, $position) : $path; }
php
protected function matchRequest(Request $request, array $parameters = []) { if (!isset($parameters['_modular_path'])) { throw new \InvalidArgumentException('The routing provider expected parameter "_modular_path" but could not find it.'); } // Grab the first segment from the remaining path $path = $parameters['_modular_path']; $position = strpos($path, '/'); return $position ? substr($path, 0, $position) : $path; }
[ "protected", "function", "matchRequest", "(", "Request", "$", "request", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "parameters", "[", "'_modular_path'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The routing provider expected parameter \"_modular_path\" but could not find it.'", ")", ";", "}", "// Grab the first segment from the remaining path", "$", "path", "=", "$", "parameters", "[", "'_modular_path'", "]", ";", "$", "position", "=", "strpos", "(", "$", "path", ",", "'/'", ")", ";", "return", "$", "position", "?", "substr", "(", "$", "path", ",", "0", ",", "$", "position", ")", ":", "$", "path", ";", "}" ]
Filters the module identity from the request path. @param Request $request The request to match @param array $parameters Parameters returned by an UrlMatcher @return string @throws \InvalidArgumentException If the "_modular_path" parameter is not set
[ "Filters", "the", "module", "identity", "from", "the", "request", "path", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/Provider/SegmentProvider.php#L114-L125
2,374
Rehyved/php-utilities
src/Rehyved/Utilities/Base64Url.php
Base64Url.encode
public static function encode($arg) { $s = base64_encode($arg); // Standard base64 encoder $s = explode('=', $s)[0]; // Remove any trailing '='s $s = str_replace('+', '-', $s); // 62nd char of encoding $s = str_replace('/', '_', $s); //63rd char of encoding return $s; }
php
public static function encode($arg) { $s = base64_encode($arg); // Standard base64 encoder $s = explode('=', $s)[0]; // Remove any trailing '='s $s = str_replace('+', '-', $s); // 62nd char of encoding $s = str_replace('/', '_', $s); //63rd char of encoding return $s; }
[ "public", "static", "function", "encode", "(", "$", "arg", ")", "{", "$", "s", "=", "base64_encode", "(", "$", "arg", ")", ";", "// Standard base64 encoder", "$", "s", "=", "explode", "(", "'='", ",", "$", "s", ")", "[", "0", "]", ";", "// Remove any trailing '='s", "$", "s", "=", "str_replace", "(", "'+'", ",", "'-'", ",", "$", "s", ")", ";", "// 62nd char of encoding", "$", "s", "=", "str_replace", "(", "'/'", ",", "'_'", ",", "$", "s", ")", ";", "//63rd char of encoding", "return", "$", "s", ";", "}" ]
Encodes the specified byte array. @param $arg @return mixed|string
[ "Encodes", "the", "specified", "byte", "array", "." ]
fae3754576eab4cf33ad99c5143aa1f972c325bd
https://github.com/Rehyved/php-utilities/blob/fae3754576eab4cf33ad99c5143aa1f972c325bd/src/Rehyved/Utilities/Base64Url.php#L13-L22
2,375
Rehyved/php-utilities
src/Rehyved/Utilities/Base64Url.php
Base64Url.decode
public static function decode(string $arg) { $s = $arg; $s = str_replace('-', '+', $s); $s = str_replace('_', '/', $s); switch (strlen($s) % 4) { case 0: break; case 2: $s .= "=="; break; case 3: $s .= "="; break; default: throw new \Exception("Illegal base64url string!"); } return base64_decode($s); }
php
public static function decode(string $arg) { $s = $arg; $s = str_replace('-', '+', $s); $s = str_replace('_', '/', $s); switch (strlen($s) % 4) { case 0: break; case 2: $s .= "=="; break; case 3: $s .= "="; break; default: throw new \Exception("Illegal base64url string!"); } return base64_decode($s); }
[ "public", "static", "function", "decode", "(", "string", "$", "arg", ")", "{", "$", "s", "=", "$", "arg", ";", "$", "s", "=", "str_replace", "(", "'-'", ",", "'+'", ",", "$", "s", ")", ";", "$", "s", "=", "str_replace", "(", "'_'", ",", "'/'", ",", "$", "s", ")", ";", "switch", "(", "strlen", "(", "$", "s", ")", "%", "4", ")", "{", "case", "0", ":", "break", ";", "case", "2", ":", "$", "s", ".=", "\"==\"", ";", "break", ";", "case", "3", ":", "$", "s", ".=", "\"=\"", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "\"Illegal base64url string!\"", ")", ";", "}", "return", "base64_decode", "(", "$", "s", ")", ";", "}" ]
Decodes the specified string. @param string $arg @return bool|string @throws \Exception Illegal base64url string
[ "Decodes", "the", "specified", "string", "." ]
fae3754576eab4cf33ad99c5143aa1f972c325bd
https://github.com/Rehyved/php-utilities/blob/fae3754576eab4cf33ad99c5143aa1f972c325bd/src/Rehyved/Utilities/Base64Url.php#L30-L50
2,376
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.setAllHeaders
public function setAllHeaders(array $headerArray) { foreach ($headerArray as $field => $value) { $this->setHeader($field, $value); } return $this; }
php
public function setAllHeaders(array $headerArray) { foreach ($headerArray as $field => $value) { $this->setHeader($field, $value); } return $this; }
[ "public", "function", "setAllHeaders", "(", "array", "$", "headerArray", ")", "{", "foreach", "(", "$", "headerArray", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "setHeader", "(", "$", "field", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set multiple headers from a key-value array Existing values matching the specified field are replaced. Header field names are NOT case-sensitive. @param array @throws \InvalidArgumentException @return Response Returns the current object instance
[ "Set", "multiple", "headers", "from", "a", "key", "-", "value", "array" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L84-L91
2,377
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.setHeader
public function setHeader($field, $value) { if (!$field = @trim($field)) { throw new HTTPException( 'Non-empty string field name required at Argument 1' ); } $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE') { $this->setCookieFromRawHeaderValue($value); return $this; } elseif (is_scalar($value) || is_null($value)) { $value = [(string) $value]; } elseif (!(is_array($value) && $this->isValidArrayHeader($value))) { throw new HTTPException( 'Invalid header; scalar or one-dimensional array of scalars required' ); } if (isset($this->ucHeaders[$ucField])) { // There's already a case-insensitive match for this field name. Reuse the // existing case mapping. $field = $this->ucHeaders[$ucField]; } $this->headers[$field] = $value; $this->ucHeaders[$ucField] = $field; return $this; }
php
public function setHeader($field, $value) { if (!$field = @trim($field)) { throw new HTTPException( 'Non-empty string field name required at Argument 1' ); } $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE') { $this->setCookieFromRawHeaderValue($value); return $this; } elseif (is_scalar($value) || is_null($value)) { $value = [(string) $value]; } elseif (!(is_array($value) && $this->isValidArrayHeader($value))) { throw new HTTPException( 'Invalid header; scalar or one-dimensional array of scalars required' ); } if (isset($this->ucHeaders[$ucField])) { // There's already a case-insensitive match for this field name. Reuse the // existing case mapping. $field = $this->ucHeaders[$ucField]; } $this->headers[$field] = $value; $this->ucHeaders[$ucField] = $field; return $this; }
[ "public", "function", "setHeader", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "!", "$", "field", "=", "@", "trim", "(", "$", "field", ")", ")", "{", "throw", "new", "HTTPException", "(", "'Non-empty string field name required at Argument 1'", ")", ";", "}", "$", "ucField", "=", "strtoupper", "(", "$", "field", ")", ";", "if", "(", "$", "ucField", "===", "'SET-COOKIE'", ")", "{", "$", "this", "->", "setCookieFromRawHeaderValue", "(", "$", "value", ")", ";", "return", "$", "this", ";", "}", "elseif", "(", "is_scalar", "(", "$", "value", ")", "||", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "(", "string", ")", "$", "value", "]", ";", "}", "elseif", "(", "!", "(", "is_array", "(", "$", "value", ")", "&&", "$", "this", "->", "isValidArrayHeader", "(", "$", "value", ")", ")", ")", "{", "throw", "new", "HTTPException", "(", "'Invalid header; scalar or one-dimensional array of scalars required'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ")", ")", "{", "// There's already a case-insensitive match for this field name. Reuse the", "// existing case mapping.", "$", "field", "=", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ";", "}", "$", "this", "->", "headers", "[", "$", "field", "]", "=", "$", "value", ";", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", "=", "$", "field", ";", "return", "$", "this", ";", "}" ]
Assign a header value Existing values matching the specified field are replaced. Header field names are NOT case-sensitive. @param string $field @param string $value @throws \InvalidArgumentException @return Response Returns the current object instance
[ "Assign", "a", "header", "value" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L104-L136
2,378
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.addHeader
public function addHeader($field, $value) { if ($this->hasHeader($field)) { $existing = $this->getHeader($field); $existing = is_array($existing) ? $existing : [$existing]; $value = is_scalar($value) ? [$value] : $value; $newHeaders = array_merge($existing, $value); $this->setHeader($field, $newHeaders); } else { $this->setHeader($field, $value); } return $this; }
php
public function addHeader($field, $value) { if ($this->hasHeader($field)) { $existing = $this->getHeader($field); $existing = is_array($existing) ? $existing : [$existing]; $value = is_scalar($value) ? [$value] : $value; $newHeaders = array_merge($existing, $value); $this->setHeader($field, $newHeaders); } else { $this->setHeader($field, $value); } return $this; }
[ "public", "function", "addHeader", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "hasHeader", "(", "$", "field", ")", ")", "{", "$", "existing", "=", "$", "this", "->", "getHeader", "(", "$", "field", ")", ";", "$", "existing", "=", "is_array", "(", "$", "existing", ")", "?", "$", "existing", ":", "[", "$", "existing", "]", ";", "$", "value", "=", "is_scalar", "(", "$", "value", ")", "?", "[", "$", "value", "]", ":", "$", "value", ";", "$", "newHeaders", "=", "array_merge", "(", "$", "existing", ",", "$", "value", ")", ";", "$", "this", "->", "setHeader", "(", "$", "field", ",", "$", "newHeaders", ")", ";", "}", "else", "{", "$", "this", "->", "setHeader", "(", "$", "field", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Append a header value The header value is appended to existing fields with the same name. Header field names are NOT case-sensitive. @param string $field @param string $value @throws \InvalidArgumentException @return Response Returns the current object instance
[ "Append", "a", "header", "value" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L296-L309
2,379
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.hasHeader
public function hasHeader($field) { $ucField = strtoupper($field); return isset($this->ucHeaders[$ucField]) || ($ucField === 'SET-COOKIE' && $this->cookies); }
php
public function hasHeader($field) { $ucField = strtoupper($field); return isset($this->ucHeaders[$ucField]) || ($ucField === 'SET-COOKIE' && $this->cookies); }
[ "public", "function", "hasHeader", "(", "$", "field", ")", "{", "$", "ucField", "=", "strtoupper", "(", "$", "field", ")", ";", "return", "isset", "(", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ")", "||", "(", "$", "ucField", "===", "'SET-COOKIE'", "&&", "$", "this", "->", "cookies", ")", ";", "}" ]
Does the response currently have a value for the specified header field? Header field names are NOT case-sensitive. @param string $field @return bool
[ "Does", "the", "response", "currently", "have", "a", "value", "for", "the", "specified", "header", "field?" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L319-L324
2,380
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.removeHeader
public function removeHeader($field) { $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE') { $this->cookies = []; } elseif (isset($this->ucHeaders[$ucField])) { $field = $this->ucHeaders[$ucField]; unset( $this->ucHeaders[$ucField], $this->headers[$field] ); } return $this; }
php
public function removeHeader($field) { $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE') { $this->cookies = []; } elseif (isset($this->ucHeaders[$ucField])) { $field = $this->ucHeaders[$ucField]; unset( $this->ucHeaders[$ucField], $this->headers[$field] ); } return $this; }
[ "public", "function", "removeHeader", "(", "$", "field", ")", "{", "$", "ucField", "=", "strtoupper", "(", "$", "field", ")", ";", "if", "(", "$", "ucField", "===", "'SET-COOKIE'", ")", "{", "$", "this", "->", "cookies", "=", "[", "]", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ")", ")", "{", "$", "field", "=", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ";", "unset", "(", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ",", "$", "this", "->", "headers", "[", "$", "field", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes assigned headers for the specified field Header field names are NOT case-sensitive. @param string $field @return Response Returns the current object instance
[ "Removes", "assigned", "headers", "for", "the", "specified", "field" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L334-L349
2,381
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.setCookie
public function setCookie($name, $value = '', array $options = []) { $value = urlencode($value); $this->assignCookieHeader($name, $value, $options); return $this; }
php
public function setCookie($name, $value = '', array $options = []) { $value = urlencode($value); $this->assignCookieHeader($name, $value, $options); return $this; }
[ "public", "function", "setCookie", "(", "$", "name", ",", "$", "value", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "value", "=", "urlencode", "(", "$", "value", ")", ";", "$", "this", "->", "assignCookieHeader", "(", "$", "name", ",", "$", "value", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Set a cookie value to be sent with the response. Cookie values will be available upon the client's next request. Extended cookie options beyond the name-value pair may be specified using individual keys in the $options array: [ 'expire' => 0, // Expiration time (unix timestamp) for this cookie 'path' => '', // The server path on which the cookie will be available 'domain' => '', // The domain on which the cookie will be available 'secure' => FALSE, // Indicates the cookie should only be sent via HTTPS 'httponly' => FALSE // When TRUE the cookie is only available via the HTTP protocol ]; @param string $name @param string $value @param array $options @return Response Returns the current object instance
[ "Set", "a", "cookie", "value", "to", "be", "sent", "with", "the", "response", "." ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L384-L390
2,382
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.getHeader
public function getHeader($field) { $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE' && $this->cookies) { $result = array_values($this->cookies); } elseif (isset($this->ucHeaders[$ucField])) { $field = $this->ucHeaders[$ucField]; $result = $this->headers[$field]; } else { throw new HTTPException( sprintf('Header field is not assigned: %s', $field) ); } return isset($result[1]) ? $result : $result[0]; }
php
public function getHeader($field) { $ucField = strtoupper($field); if ($ucField === 'SET-COOKIE' && $this->cookies) { $result = array_values($this->cookies); } elseif (isset($this->ucHeaders[$ucField])) { $field = $this->ucHeaders[$ucField]; $result = $this->headers[$field]; } else { throw new HTTPException( sprintf('Header field is not assigned: %s', $field) ); } return isset($result[1]) ? $result : $result[0]; }
[ "public", "function", "getHeader", "(", "$", "field", ")", "{", "$", "ucField", "=", "strtoupper", "(", "$", "field", ")", ";", "if", "(", "$", "ucField", "===", "'SET-COOKIE'", "&&", "$", "this", "->", "cookies", ")", "{", "$", "result", "=", "array_values", "(", "$", "this", "->", "cookies", ")", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ")", ")", "{", "$", "field", "=", "$", "this", "->", "ucHeaders", "[", "$", "ucField", "]", ";", "$", "result", "=", "$", "this", "->", "headers", "[", "$", "field", "]", ";", "}", "else", "{", "throw", "new", "HTTPException", "(", "sprintf", "(", "'Header field is not assigned: %s'", ",", "$", "field", ")", ")", ";", "}", "return", "isset", "(", "$", "result", "[", "1", "]", ")", "?", "$", "result", ":", "$", "result", "[", "0", "]", ";", "}" ]
Retrieve assigned header values for the specified field If only one value is assigned for the specified field, that scalar value is returned. If multiple values are assigned for the field an array of scalars is returned. @param string $field @throws \DomainException @return string|array
[ "Retrieve", "assigned", "header", "values", "for", "the", "specified", "field" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L488-L504
2,383
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.setBody
public function setBody(Body $body) { $this->body = $body; $this->setAllHeaders($body->getHeaders()); $this->setStatus($body->getStatusCode()); return $this; }
php
public function setBody(Body $body) { $this->body = $body; $this->setAllHeaders($body->getHeaders()); $this->setStatus($body->getStatusCode()); return $this; }
[ "public", "function", "setBody", "(", "Body", "$", "body", ")", "{", "$", "this", "->", "body", "=", "$", "body", ";", "$", "this", "->", "setAllHeaders", "(", "$", "body", "->", "getHeaders", "(", ")", ")", ";", "$", "this", "->", "setStatus", "(", "$", "body", "->", "getStatusCode", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Assign a response entity body @param null|string|callable|Body $body @throws \InvalidArgumentException @return Response Returns the current object instance
[ "Assign", "a", "response", "entity", "body" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L513-L520
2,384
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.getAllHeaders
public function getAllHeaders() { $headers = $this->headers; if ($this->cookies) { $headers['Set-Cookie'] = array_values($this->cookies); } return $headers; }
php
public function getAllHeaders() { $headers = $this->headers; if ($this->cookies) { $headers['Set-Cookie'] = array_values($this->cookies); } return $headers; }
[ "public", "function", "getAllHeaders", "(", ")", "{", "$", "headers", "=", "$", "this", "->", "headers", ";", "if", "(", "$", "this", "->", "cookies", ")", "{", "$", "headers", "[", "'Set-Cookie'", "]", "=", "array_values", "(", "$", "this", "->", "cookies", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Retrieve an array mapping header field names to their assigned values @return array
[ "Retrieve", "an", "array", "mapping", "header", "field", "names", "to", "their", "assigned", "values" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L527-L535
2,385
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.getAllHeaderLines
public function getAllHeaderLines() { $headers = []; foreach ($this->getAllHeaders() as $field => $valueArray) { foreach ($valueArray as $value) { $headers[] = "{$field}: $value"; } } return $headers; }
php
public function getAllHeaderLines() { $headers = []; foreach ($this->getAllHeaders() as $field => $valueArray) { foreach ($valueArray as $value) { $headers[] = "{$field}: $value"; } } return $headers; }
[ "public", "function", "getAllHeaderLines", "(", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getAllHeaders", "(", ")", "as", "$", "field", "=>", "$", "valueArray", ")", "{", "foreach", "(", "$", "valueArray", "as", "$", "value", ")", "{", "$", "headers", "[", "]", "=", "\"{$field}: $value\"", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Retrieve an array of header strings appropriate for output @return array
[ "Retrieve", "an", "array", "of", "header", "strings", "appropriate", "for", "output" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L542-L552
2,386
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.import
public function import(Response $response) { $this->clear(); foreach ($response->toArray() as $key => $value) { $this->offsetSet($key, $value); } return $this; }
php
public function import(Response $response) { $this->clear(); foreach ($response->toArray() as $key => $value) { $this->offsetSet($key, $value); } return $this; }
[ "public", "function", "import", "(", "Response", "$", "response", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "foreach", "(", "$", "response", "->", "toArray", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "offsetSet", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Import values from external Response instance Calling import() will clear all previously assigned values before assigning those from the new Response instance. @param \Room11\HTTP\Response $response @return Response Returns the current object instance
[ "Import", "values", "from", "external", "Response", "instance" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L583-L591
2,387
Danack/HTTP
src/Room11/HTTP/Response/Response.php
Response.clear
public function clear() { $this->status = 200; $this->reasonPhrase = ''; $this->headers = []; $this->ucHeaders = []; $this->cookies = []; $this->body = null; $this->asgiMap = []; return $this; }
php
public function clear() { $this->status = 200; $this->reasonPhrase = ''; $this->headers = []; $this->ucHeaders = []; $this->cookies = []; $this->body = null; $this->asgiMap = []; return $this; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "status", "=", "200", ";", "$", "this", "->", "reasonPhrase", "=", "''", ";", "$", "this", "->", "headers", "=", "[", "]", ";", "$", "this", "->", "ucHeaders", "=", "[", "]", ";", "$", "this", "->", "cookies", "=", "[", "]", ";", "$", "this", "->", "body", "=", "null", ";", "$", "this", "->", "asgiMap", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Remove all assigned values and reset defaults @return Response Returns the current object instance
[ "Remove", "all", "assigned", "values", "and", "reset", "defaults" ]
c4e19668b21de0c00bfaa1e0d1a18175764fd966
https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/Response/Response.php#L624-L635
2,388
Palmabit-IT/authenticator
src/Palmabit/Authentication/Presenters/GroupPresenter.php
GroupPresenter.permissions_obj
public function permissions_obj($model = null) { $model = $model ? $model : new Permission; $objs = []; $permissions = $this->resource->permissions; if (!empty($permissions)) { foreach ($permissions as $permission => $status) { $objs[] = (!$model::wherePermission($permission)->get()->isEmpty()) ? $model::wherePermission($permission)->first() : null; } } return $objs; }
php
public function permissions_obj($model = null) { $model = $model ? $model : new Permission; $objs = []; $permissions = $this->resource->permissions; if (!empty($permissions)) { foreach ($permissions as $permission => $status) { $objs[] = (!$model::wherePermission($permission)->get()->isEmpty()) ? $model::wherePermission($permission)->first() : null; } } return $objs; }
[ "public", "function", "permissions_obj", "(", "$", "model", "=", "null", ")", "{", "$", "model", "=", "$", "model", "?", "$", "model", ":", "new", "Permission", ";", "$", "objs", "=", "[", "]", ";", "$", "permissions", "=", "$", "this", "->", "resource", "->", "permissions", ";", "if", "(", "!", "empty", "(", "$", "permissions", ")", ")", "{", "foreach", "(", "$", "permissions", "as", "$", "permission", "=>", "$", "status", ")", "{", "$", "objs", "[", "]", "=", "(", "!", "$", "model", "::", "wherePermission", "(", "$", "permission", ")", "->", "get", "(", ")", "->", "isEmpty", "(", ")", ")", "?", "$", "model", "::", "wherePermission", "(", "$", "permission", ")", "->", "first", "(", ")", ":", "null", ";", "}", "}", "return", "$", "objs", ";", "}" ]
Obtains the permission obj associated to the model @param null $model @return array
[ "Obtains", "the", "permission", "obj", "associated", "to", "the", "model" ]
986cfc7e666e0e1b0312e518d586ec61b08cdb42
https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Presenters/GroupPresenter.php#L16-L26
2,389
harvestcloud/CoreBundle
Controller/Buyer/CartController.php
CartController.addProductAction
public function addProductAction(Product $product, $quantity, Request $request) { // Find OrderCollection $orderCollection = $this->getCurrentCart(); $quantity = array_key_exists('quantity', $_POST) ? (int) $_POST['quantity'] : $quantity; try { if ('-' == $request->get('remove')) { $quantity = -1 * $quantity; } // Add Product to OrderCollection $lineItem = $orderCollection->addProduct($product, $quantity); // Persisting cascades to Order and OrderCollection $em = $this->getDoctrine()->getEntityManager(); $em->persist($lineItem); $em->flush(); if ($quantity > 0) { $notice = 'Added '.$quantity.' ' .$product->getUnitForNumber($quantity).' of ' .$product->getName().' to your cart'; } else { $quantity = abs($quantity); $notice = 'Removed '.$quantity.' ' .$product->getUnitForNumber($quantity).' of ' .$product->getName().' from your cart'; } // Set flash message $this->get('session')->getFlashBag()->add('notice', $notice); // Save the OrderCollection to the session $this->getRequest()->getSession()->set('cart_id', $orderCollection->getId()); } catch (\Exception $e) { // could not add Product to cart } $last_route = $request->get('referer'); if (in_array($last_route, array('_welcome'))) { return $this->redirect($this->generateUrl($last_route)); } return $this->redirect($this->generateUrl('Profile_product_show', array( 'product_slug' => $product->getSlug(), 'slug' => $product->getSeller()->getSlug(), ))); }
php
public function addProductAction(Product $product, $quantity, Request $request) { // Find OrderCollection $orderCollection = $this->getCurrentCart(); $quantity = array_key_exists('quantity', $_POST) ? (int) $_POST['quantity'] : $quantity; try { if ('-' == $request->get('remove')) { $quantity = -1 * $quantity; } // Add Product to OrderCollection $lineItem = $orderCollection->addProduct($product, $quantity); // Persisting cascades to Order and OrderCollection $em = $this->getDoctrine()->getEntityManager(); $em->persist($lineItem); $em->flush(); if ($quantity > 0) { $notice = 'Added '.$quantity.' ' .$product->getUnitForNumber($quantity).' of ' .$product->getName().' to your cart'; } else { $quantity = abs($quantity); $notice = 'Removed '.$quantity.' ' .$product->getUnitForNumber($quantity).' of ' .$product->getName().' from your cart'; } // Set flash message $this->get('session')->getFlashBag()->add('notice', $notice); // Save the OrderCollection to the session $this->getRequest()->getSession()->set('cart_id', $orderCollection->getId()); } catch (\Exception $e) { // could not add Product to cart } $last_route = $request->get('referer'); if (in_array($last_route, array('_welcome'))) { return $this->redirect($this->generateUrl($last_route)); } return $this->redirect($this->generateUrl('Profile_product_show', array( 'product_slug' => $product->getSlug(), 'slug' => $product->getSeller()->getSlug(), ))); }
[ "public", "function", "addProductAction", "(", "Product", "$", "product", ",", "$", "quantity", ",", "Request", "$", "request", ")", "{", "// Find OrderCollection", "$", "orderCollection", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "quantity", "=", "array_key_exists", "(", "'quantity'", ",", "$", "_POST", ")", "?", "(", "int", ")", "$", "_POST", "[", "'quantity'", "]", ":", "$", "quantity", ";", "try", "{", "if", "(", "'-'", "==", "$", "request", "->", "get", "(", "'remove'", ")", ")", "{", "$", "quantity", "=", "-", "1", "*", "$", "quantity", ";", "}", "// Add Product to OrderCollection", "$", "lineItem", "=", "$", "orderCollection", "->", "addProduct", "(", "$", "product", ",", "$", "quantity", ")", ";", "// Persisting cascades to Order and OrderCollection", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getEntityManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "lineItem", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "if", "(", "$", "quantity", ">", "0", ")", "{", "$", "notice", "=", "'Added '", ".", "$", "quantity", ".", "' '", ".", "$", "product", "->", "getUnitForNumber", "(", "$", "quantity", ")", ".", "' of '", ".", "$", "product", "->", "getName", "(", ")", ".", "' to your cart'", ";", "}", "else", "{", "$", "quantity", "=", "abs", "(", "$", "quantity", ")", ";", "$", "notice", "=", "'Removed '", ".", "$", "quantity", ".", "' '", ".", "$", "product", "->", "getUnitForNumber", "(", "$", "quantity", ")", ".", "' of '", ".", "$", "product", "->", "getName", "(", ")", ".", "' from your cart'", ";", "}", "// Set flash message", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'notice'", ",", "$", "notice", ")", ";", "// Save the OrderCollection to the session", "$", "this", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", "->", "set", "(", "'cart_id'", ",", "$", "orderCollection", "->", "getId", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// could not add Product to cart", "}", "$", "last_route", "=", "$", "request", "->", "get", "(", "'referer'", ")", ";", "if", "(", "in_array", "(", "$", "last_route", ",", "array", "(", "'_welcome'", ")", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "$", "last_route", ")", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'Profile_product_show'", ",", "array", "(", "'product_slug'", "=>", "$", "product", "->", "getSlug", "(", ")", ",", "'slug'", "=>", "$", "product", "->", "getSeller", "(", ")", "->", "getSlug", "(", ")", ",", ")", ")", ")", ";", "}" ]
add Product to Cart @author Tom Haskins-Vaughan <[email protected]> @since 2012-04-09 @Route("/cart/add-product/{id}/{quantity}") @ParamConverter("product", class="HarvestCloudCoreBundle:Product") @param Product $product @param Request $request
[ "add", "Product", "to", "Cart" ]
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Controller/Buyer/CartController.php#L110-L165
2,390
budkit/budkit-framework
src/Budkit/Session/Registry.php
Registry.set
final public function set($varname, $value) { //If its lock we can't edit if ($this->lock) return false; //Continue $previous = isset($this->data[$varname]) ? $this->data[$varname] : null; $this->data[$varname] = $value; //what to do with previous? return $this; }
php
final public function set($varname, $value) { //If its lock we can't edit if ($this->lock) return false; //Continue $previous = isset($this->data[$varname]) ? $this->data[$varname] : null; $this->data[$varname] = $value; //what to do with previous? return $this; }
[ "final", "public", "function", "set", "(", "$", "varname", ",", "$", "value", ")", "{", "//If its lock we can't edit", "if", "(", "$", "this", "->", "lock", ")", "return", "false", ";", "//Continue", "$", "previous", "=", "isset", "(", "$", "this", "->", "data", "[", "$", "varname", "]", ")", "?", "$", "this", "->", "data", "[", "$", "varname", "]", ":", "null", ";", "$", "this", "->", "data", "[", "$", "varname", "]", "=", "$", "value", ";", "//what to do with previous?", "return", "$", "this", ";", "}" ]
Adds a value to the registry @param type $varname @param type $value @return Registry
[ "Adds", "a", "value", "to", "the", "registry" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Registry.php#L68-L82
2,391
budkit/budkit-framework
src/Budkit/Session/Registry.php
Registry.get
final public function get($varname) { $previous = isset($this->data[$varname]) ? $this->data[$varname] : null; return $previous; }
php
final public function get($varname) { $previous = isset($this->data[$varname]) ? $this->data[$varname] : null; return $previous; }
[ "final", "public", "function", "get", "(", "$", "varname", ")", "{", "$", "previous", "=", "isset", "(", "$", "this", "->", "data", "[", "$", "varname", "]", ")", "?", "$", "this", "->", "data", "[", "$", "varname", "]", ":", "null", ";", "return", "$", "previous", ";", "}" ]
Gets the value of an item in the registry @param type $varname @return type
[ "Gets", "the", "value", "of", "an", "item", "in", "the", "registry" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Registry.php#L100-L105
2,392
budkit/budkit-framework
src/Budkit/Session/Registry.php
Registry.lock
final public function lock() { if (!isset($this->name) || empty($this->name) || ($this->name === 'default')) { //@TODO throw exception, namespace cannot be locked; return false; } //echo $this->name." is ".$locked; $this->lock = TRUE; }
php
final public function lock() { if (!isset($this->name) || empty($this->name) || ($this->name === 'default')) { //@TODO throw exception, namespace cannot be locked; return false; } //echo $this->name." is ".$locked; $this->lock = TRUE; }
[ "final", "public", "function", "lock", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", "||", "empty", "(", "$", "this", "->", "name", ")", "||", "(", "$", "this", "->", "name", "===", "'default'", ")", ")", "{", "//@TODO throw exception, namespace cannot be locked;", "return", "false", ";", "}", "//echo $this->name.\" is \".$locked;", "$", "this", "->", "lock", "=", "TRUE", ";", "}" ]
Locks the registry @return void
[ "Locks", "the", "registry" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Registry.php#L122-L130
2,393
AyeAyeApi/Formatters
src/Reader/Xml.php
Xml.read
public function read($string) { try { $wasUsingErrors = libxml_use_internal_errors(); @$xmlObject = simplexml_load_string($string); libxml_use_internal_errors($wasUsingErrors); if ($xmlObject) { return $this->recurseToArray($xmlObject); } } catch (\Exception $e) { // Do nothing } return null; }
php
public function read($string) { try { $wasUsingErrors = libxml_use_internal_errors(); @$xmlObject = simplexml_load_string($string); libxml_use_internal_errors($wasUsingErrors); if ($xmlObject) { return $this->recurseToArray($xmlObject); } } catch (\Exception $e) { // Do nothing } return null; }
[ "public", "function", "read", "(", "$", "string", ")", "{", "try", "{", "$", "wasUsingErrors", "=", "libxml_use_internal_errors", "(", ")", ";", "@", "$", "xmlObject", "=", "simplexml_load_string", "(", "$", "string", ")", ";", "libxml_use_internal_errors", "(", "$", "wasUsingErrors", ")", ";", "if", "(", "$", "xmlObject", ")", "{", "return", "$", "this", "->", "recurseToArray", "(", "$", "xmlObject", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Do nothing", "}", "return", "null", ";", "}" ]
Attempt to read an XML document @param string $string @return array|null
[ "Attempt", "to", "read", "an", "XML", "document" ]
0141d0186e0555f7583be419f22280ac7ed24a6f
https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Reader/Xml.php#L29-L42
2,394
AyeAyeApi/Formatters
src/Reader/Xml.php
Xml.recurseToArray
protected function recurseToArray($object) { if (is_scalar($object)) { return $object; } $array = (array)$object; foreach ($array as &$value) { if (!is_scalar(($value))) { $value = $this->recurseToArray($value); continue; } } return $array; }
php
protected function recurseToArray($object) { if (is_scalar($object)) { return $object; } $array = (array)$object; foreach ($array as &$value) { if (!is_scalar(($value))) { $value = $this->recurseToArray($value); continue; } } return $array; }
[ "protected", "function", "recurseToArray", "(", "$", "object", ")", "{", "if", "(", "is_scalar", "(", "$", "object", ")", ")", "{", "return", "$", "object", ";", "}", "$", "array", "=", "(", "array", ")", "$", "object", ";", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "(", "$", "value", ")", ")", ")", "{", "$", "value", "=", "$", "this", "->", "recurseToArray", "(", "$", "value", ")", ";", "continue", ";", "}", "}", "return", "$", "array", ";", "}" ]
Recurse through non scalars turning them into arrays, just returns scalars as is. @param $object @return mixed
[ "Recurse", "through", "non", "scalars", "turning", "them", "into", "arrays", "just", "returns", "scalars", "as", "is", "." ]
0141d0186e0555f7583be419f22280ac7ed24a6f
https://github.com/AyeAyeApi/Formatters/blob/0141d0186e0555f7583be419f22280ac7ed24a6f/src/Reader/Xml.php#L49-L62
2,395
tekkla/core-security
Core/Security/User/UserHandler.php
UserHandler.loadUser
public function loadUser(User $user) { // Guests do not have a user id. So do not try to load data for guests. if ($user->isGuest()) { return; } $this->db->qb([ 'table' => $this->table, 'field' => [ 'username', 'display_name', 'state' ], 'filter' => 'id_user=:id_user', 'params' => [ ':id_user' => $user->getId() ] ]); $data = $this->db->single(); if (!empty($data)) { $user->setUsername($data['username']); // Use username as display_name when there is no display_name for this user $user->setDisplayName(empty($data['display_name']) ? $data['username'] : $data['display_name']); // Load the groups the user is in $this->db->qb([ 'table' => 'core_users_groups', 'fields' => 'id_group', 'filter' => 'id_user=:id_user', 'params' => [ ':id_user' => $user->getId() ] ]); $groups = $this->db->column(); if (!empty($groups)) { $user->groups->set($groups); // Create a prepared string and param array to use in query $prepared = $this->db->prepareArrayQuery('group', $groups); // Get and return the permissions $this->db->qb([ 'table' => 'core_groups_permissions', 'fields' => [ 'storage', 'permission' ], 'method' => 'SELECT DISTINCT', 'filter' => 'id_group IN (' . $prepared['sql'] . ')', 'params' => $prepared['values'] ]); $permissions = $this->db->all(); foreach ($permissions as $perm) { if (!array_key_exists($perm['storage'], $user->permissions)) { $user->permissions[$perm['storage']] = new UserPermissions(); } $user->permissions[$perm['storage']]->add($perm['permission']); } // Is the user an admin? if (!empty($user->permissions['Core']->allowedTo('admin'))) { $user->setAdmin(true); } } } }
php
public function loadUser(User $user) { // Guests do not have a user id. So do not try to load data for guests. if ($user->isGuest()) { return; } $this->db->qb([ 'table' => $this->table, 'field' => [ 'username', 'display_name', 'state' ], 'filter' => 'id_user=:id_user', 'params' => [ ':id_user' => $user->getId() ] ]); $data = $this->db->single(); if (!empty($data)) { $user->setUsername($data['username']); // Use username as display_name when there is no display_name for this user $user->setDisplayName(empty($data['display_name']) ? $data['username'] : $data['display_name']); // Load the groups the user is in $this->db->qb([ 'table' => 'core_users_groups', 'fields' => 'id_group', 'filter' => 'id_user=:id_user', 'params' => [ ':id_user' => $user->getId() ] ]); $groups = $this->db->column(); if (!empty($groups)) { $user->groups->set($groups); // Create a prepared string and param array to use in query $prepared = $this->db->prepareArrayQuery('group', $groups); // Get and return the permissions $this->db->qb([ 'table' => 'core_groups_permissions', 'fields' => [ 'storage', 'permission' ], 'method' => 'SELECT DISTINCT', 'filter' => 'id_group IN (' . $prepared['sql'] . ')', 'params' => $prepared['values'] ]); $permissions = $this->db->all(); foreach ($permissions as $perm) { if (!array_key_exists($perm['storage'], $user->permissions)) { $user->permissions[$perm['storage']] = new UserPermissions(); } $user->permissions[$perm['storage']]->add($perm['permission']); } // Is the user an admin? if (!empty($user->permissions['Core']->allowedTo('admin'))) { $user->setAdmin(true); } } } }
[ "public", "function", "loadUser", "(", "User", "$", "user", ")", "{", "// Guests do not have a user id. So do not try to load data for guests.", "if", "(", "$", "user", "->", "isGuest", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "db", "->", "qb", "(", "[", "'table'", "=>", "$", "this", "->", "table", ",", "'field'", "=>", "[", "'username'", ",", "'display_name'", ",", "'state'", "]", ",", "'filter'", "=>", "'id_user=:id_user'", ",", "'params'", "=>", "[", "':id_user'", "=>", "$", "user", "->", "getId", "(", ")", "]", "]", ")", ";", "$", "data", "=", "$", "this", "->", "db", "->", "single", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "user", "->", "setUsername", "(", "$", "data", "[", "'username'", "]", ")", ";", "// Use username as display_name when there is no display_name for this user", "$", "user", "->", "setDisplayName", "(", "empty", "(", "$", "data", "[", "'display_name'", "]", ")", "?", "$", "data", "[", "'username'", "]", ":", "$", "data", "[", "'display_name'", "]", ")", ";", "// Load the groups the user is in", "$", "this", "->", "db", "->", "qb", "(", "[", "'table'", "=>", "'core_users_groups'", ",", "'fields'", "=>", "'id_group'", ",", "'filter'", "=>", "'id_user=:id_user'", ",", "'params'", "=>", "[", "':id_user'", "=>", "$", "user", "->", "getId", "(", ")", "]", "]", ")", ";", "$", "groups", "=", "$", "this", "->", "db", "->", "column", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "groups", ")", ")", "{", "$", "user", "->", "groups", "->", "set", "(", "$", "groups", ")", ";", "// Create a prepared string and param array to use in query", "$", "prepared", "=", "$", "this", "->", "db", "->", "prepareArrayQuery", "(", "'group'", ",", "$", "groups", ")", ";", "// Get and return the permissions", "$", "this", "->", "db", "->", "qb", "(", "[", "'table'", "=>", "'core_groups_permissions'", ",", "'fields'", "=>", "[", "'storage'", ",", "'permission'", "]", ",", "'method'", "=>", "'SELECT DISTINCT'", ",", "'filter'", "=>", "'id_group IN ('", ".", "$", "prepared", "[", "'sql'", "]", ".", "')'", ",", "'params'", "=>", "$", "prepared", "[", "'values'", "]", "]", ")", ";", "$", "permissions", "=", "$", "this", "->", "db", "->", "all", "(", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "perm", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "perm", "[", "'storage'", "]", ",", "$", "user", "->", "permissions", ")", ")", "{", "$", "user", "->", "permissions", "[", "$", "perm", "[", "'storage'", "]", "]", "=", "new", "UserPermissions", "(", ")", ";", "}", "$", "user", "->", "permissions", "[", "$", "perm", "[", "'storage'", "]", "]", "->", "add", "(", "$", "perm", "[", "'permission'", "]", ")", ";", "}", "// Is the user an admin?", "if", "(", "!", "empty", "(", "$", "user", "->", "permissions", "[", "'Core'", "]", "->", "allowedTo", "(", "'admin'", ")", ")", ")", "{", "$", "user", "->", "setAdmin", "(", "true", ")", ";", "}", "}", "}", "}" ]
Loads user from DB. Takes care about not to load a user more than once @param User $user
[ "Loads", "user", "from", "DB", "." ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/User/UserHandler.php#L136-L213
2,396
gourmet/common
View/Helper/TableHelper.php
TableHelper._extractAttributes
protected function _extractAttributes($str) { $str = preg_replace("/[\x{00a0}\x{200b}]+/u", ' ', $str); $attributes = array(); $patterns = array( 'name-value-quotes-dble' => '(\w+)\s*=\s*"([^"]*)"', 'name-value-quotes-sgle' => "(\w+)\s*=\s*'([^']*)'", 'name-value-quotes-none' => '(\w+)\s*=\s*([^\s\'"]+)', 'name-quotes-dble' => '"([^"]*)"', 'name-quotes-sgle' => "'([^']*)'", 'name-quotes-none' => '(\w+)' ); $pattern = '/' . implode('(?:\s|$)|', $patterns) . '(?:\s|$)/'; if (!preg_match_all($pattern, $str, $matches, PREG_SET_ORDER)) { return $attributes; } foreach ($matches as $match) { if (!empty($match[1])) { $attributes[strtolower($match[1])] = stripcslashes($match[2]); } else if (!empty($match[3])) { $attributes[$match[3]] = stripcslashes($match[4]); } else if (!empty($match[5])) { $attributes[$match[5]] = stripcslashes($match[6]); } else if (!empty($match[7]) && strlen($match[7])) { $attributes[] = stripcslashes($match[7]); } else if (!empty($match[8])) { $attributes[] = stripcslashes($match[8]); } else if (!empty($match[9])) { $attributes[] = stripcslashes($match[9]); } } return $attributes; }
php
protected function _extractAttributes($str) { $str = preg_replace("/[\x{00a0}\x{200b}]+/u", ' ', $str); $attributes = array(); $patterns = array( 'name-value-quotes-dble' => '(\w+)\s*=\s*"([^"]*)"', 'name-value-quotes-sgle' => "(\w+)\s*=\s*'([^']*)'", 'name-value-quotes-none' => '(\w+)\s*=\s*([^\s\'"]+)', 'name-quotes-dble' => '"([^"]*)"', 'name-quotes-sgle' => "'([^']*)'", 'name-quotes-none' => '(\w+)' ); $pattern = '/' . implode('(?:\s|$)|', $patterns) . '(?:\s|$)/'; if (!preg_match_all($pattern, $str, $matches, PREG_SET_ORDER)) { return $attributes; } foreach ($matches as $match) { if (!empty($match[1])) { $attributes[strtolower($match[1])] = stripcslashes($match[2]); } else if (!empty($match[3])) { $attributes[$match[3]] = stripcslashes($match[4]); } else if (!empty($match[5])) { $attributes[$match[5]] = stripcslashes($match[6]); } else if (!empty($match[7]) && strlen($match[7])) { $attributes[] = stripcslashes($match[7]); } else if (!empty($match[8])) { $attributes[] = stripcslashes($match[8]); } else if (!empty($match[9])) { $attributes[] = stripcslashes($match[9]); } } return $attributes; }
[ "protected", "function", "_extractAttributes", "(", "$", "str", ")", "{", "$", "str", "=", "preg_replace", "(", "\"/[\\x{00a0}\\x{200b}]+/u\"", ",", "' '", ",", "$", "str", ")", ";", "$", "attributes", "=", "array", "(", ")", ";", "$", "patterns", "=", "array", "(", "'name-value-quotes-dble'", "=>", "'(\\w+)\\s*=\\s*\"([^\"]*)\"'", ",", "'name-value-quotes-sgle'", "=>", "\"(\\w+)\\s*=\\s*'([^']*)'\"", ",", "'name-value-quotes-none'", "=>", "'(\\w+)\\s*=\\s*([^\\s\\'\"]+)'", ",", "'name-quotes-dble'", "=>", "'\"([^\"]*)\"'", ",", "'name-quotes-sgle'", "=>", "\"'([^']*)'\"", ",", "'name-quotes-none'", "=>", "'(\\w+)'", ")", ";", "$", "pattern", "=", "'/'", ".", "implode", "(", "'(?:\\s|$)|'", ",", "$", "patterns", ")", ".", "'(?:\\s|$)/'", ";", "if", "(", "!", "preg_match_all", "(", "$", "pattern", ",", "$", "str", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ")", "{", "return", "$", "attributes", ";", "}", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "if", "(", "!", "empty", "(", "$", "match", "[", "1", "]", ")", ")", "{", "$", "attributes", "[", "strtolower", "(", "$", "match", "[", "1", "]", ")", "]", "=", "stripcslashes", "(", "$", "match", "[", "2", "]", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "match", "[", "3", "]", ")", ")", "{", "$", "attributes", "[", "$", "match", "[", "3", "]", "]", "=", "stripcslashes", "(", "$", "match", "[", "4", "]", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "match", "[", "5", "]", ")", ")", "{", "$", "attributes", "[", "$", "match", "[", "5", "]", "]", "=", "stripcslashes", "(", "$", "match", "[", "6", "]", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "match", "[", "7", "]", ")", "&&", "strlen", "(", "$", "match", "[", "7", "]", ")", ")", "{", "$", "attributes", "[", "]", "=", "stripcslashes", "(", "$", "match", "[", "7", "]", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "match", "[", "8", "]", ")", ")", "{", "$", "attributes", "[", "]", "=", "stripcslashes", "(", "$", "match", "[", "8", "]", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "match", "[", "9", "]", ")", ")", "{", "$", "attributes", "[", "]", "=", "stripcslashes", "(", "$", "match", "[", "9", "]", ")", ";", "}", "}", "return", "$", "attributes", ";", "}" ]
Extract attributes from string. @param string $str String to parse. @return array Attributes.
[ "Extract", "attributes", "from", "string", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/View/Helper/TableHelper.php#L265-L299
2,397
gourmet/common
View/Helper/TableHelper.php
TableHelper._renderCell
protected function _renderCell($str, $data) { // The order is VERY important. $str = $this->_replaceData($str, $data); $str = $this->_replaceEval($str); $str = $this->_replaceData($str, $data); $str = $this->_replaceCurrency($str); $str = $this->_replaceTime($str); $str = $this->_replaceTranslate($str); $str = $this->_replaceUrl($str); $str = $this->_replaceImage($str); $str = $this->_replaceLink($str); $str = $this->_replaceTruncate($str); return $str; }
php
protected function _renderCell($str, $data) { // The order is VERY important. $str = $this->_replaceData($str, $data); $str = $this->_replaceEval($str); $str = $this->_replaceData($str, $data); $str = $this->_replaceCurrency($str); $str = $this->_replaceTime($str); $str = $this->_replaceTranslate($str); $str = $this->_replaceUrl($str); $str = $this->_replaceImage($str); $str = $this->_replaceLink($str); $str = $this->_replaceTruncate($str); return $str; }
[ "protected", "function", "_renderCell", "(", "$", "str", ",", "$", "data", ")", "{", "// The order is VERY important.", "$", "str", "=", "$", "this", "->", "_replaceData", "(", "$", "str", ",", "$", "data", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceEval", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceData", "(", "$", "str", ",", "$", "data", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceCurrency", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceTime", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceTranslate", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceUrl", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceImage", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceLink", "(", "$", "str", ")", ";", "$", "str", "=", "$", "this", "->", "_replaceTruncate", "(", "$", "str", ")", ";", "return", "$", "str", ";", "}" ]
Render table's cell. @param string $str Cell's content. @param array $data Cell's row data. @return Table cell's HTML.
[ "Render", "table", "s", "cell", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/View/Helper/TableHelper.php#L308-L321
2,398
gourmet/common
View/Helper/TableHelper.php
TableHelper._renderHeaders
protected function _renderHeaders($options, $tag = 'thead') { $th = array(); foreach ($options['columns'] as $name => $thOptions) { $thOptions = Hash::merge( $this->__colDefaults, array('th' => $options['th']['attrs']), $thOptions ); if (false !== $options['paginate'] && false !== $thOptions['sort']) { if (is_bool($thOptions['sort'])) { $thOptions['sort'] = $name; } if (is_string($thOptions['sort'])) { $thOptions['sort'] = array('key' => $thOptions['sort']); } $thOptions['sort'] = array_merge(array('options' => array()), $thOptions['sort']); $name = $this->Paginator->sort($thOptions['sort']['key'], $name, $thOptions['sort']['options']); } $th[] = $this->Html->useTag( 'tableheader', $this->_parseAttributes($thOptions['th']), $name ); } return sprintf( "\t<%s>\n\t\t%s\n\t</%s>", $tag, $this->Html->useTag('tablerow', null, "\n\t\t\t" . implode("\n\t\t\t", $th) . "\n\t\t"), $tag ); }
php
protected function _renderHeaders($options, $tag = 'thead') { $th = array(); foreach ($options['columns'] as $name => $thOptions) { $thOptions = Hash::merge( $this->__colDefaults, array('th' => $options['th']['attrs']), $thOptions ); if (false !== $options['paginate'] && false !== $thOptions['sort']) { if (is_bool($thOptions['sort'])) { $thOptions['sort'] = $name; } if (is_string($thOptions['sort'])) { $thOptions['sort'] = array('key' => $thOptions['sort']); } $thOptions['sort'] = array_merge(array('options' => array()), $thOptions['sort']); $name = $this->Paginator->sort($thOptions['sort']['key'], $name, $thOptions['sort']['options']); } $th[] = $this->Html->useTag( 'tableheader', $this->_parseAttributes($thOptions['th']), $name ); } return sprintf( "\t<%s>\n\t\t%s\n\t</%s>", $tag, $this->Html->useTag('tablerow', null, "\n\t\t\t" . implode("\n\t\t\t", $th) . "\n\t\t"), $tag ); }
[ "protected", "function", "_renderHeaders", "(", "$", "options", ",", "$", "tag", "=", "'thead'", ")", "{", "$", "th", "=", "array", "(", ")", ";", "foreach", "(", "$", "options", "[", "'columns'", "]", "as", "$", "name", "=>", "$", "thOptions", ")", "{", "$", "thOptions", "=", "Hash", "::", "merge", "(", "$", "this", "->", "__colDefaults", ",", "array", "(", "'th'", "=>", "$", "options", "[", "'th'", "]", "[", "'attrs'", "]", ")", ",", "$", "thOptions", ")", ";", "if", "(", "false", "!==", "$", "options", "[", "'paginate'", "]", "&&", "false", "!==", "$", "thOptions", "[", "'sort'", "]", ")", "{", "if", "(", "is_bool", "(", "$", "thOptions", "[", "'sort'", "]", ")", ")", "{", "$", "thOptions", "[", "'sort'", "]", "=", "$", "name", ";", "}", "if", "(", "is_string", "(", "$", "thOptions", "[", "'sort'", "]", ")", ")", "{", "$", "thOptions", "[", "'sort'", "]", "=", "array", "(", "'key'", "=>", "$", "thOptions", "[", "'sort'", "]", ")", ";", "}", "$", "thOptions", "[", "'sort'", "]", "=", "array_merge", "(", "array", "(", "'options'", "=>", "array", "(", ")", ")", ",", "$", "thOptions", "[", "'sort'", "]", ")", ";", "$", "name", "=", "$", "this", "->", "Paginator", "->", "sort", "(", "$", "thOptions", "[", "'sort'", "]", "[", "'key'", "]", ",", "$", "name", ",", "$", "thOptions", "[", "'sort'", "]", "[", "'options'", "]", ")", ";", "}", "$", "th", "[", "]", "=", "$", "this", "->", "Html", "->", "useTag", "(", "'tableheader'", ",", "$", "this", "->", "_parseAttributes", "(", "$", "thOptions", "[", "'th'", "]", ")", ",", "$", "name", ")", ";", "}", "return", "sprintf", "(", "\"\\t<%s>\\n\\t\\t%s\\n\\t</%s>\"", ",", "$", "tag", ",", "$", "this", "->", "Html", "->", "useTag", "(", "'tablerow'", ",", "null", ",", "\"\\n\\t\\t\\t\"", ".", "implode", "(", "\"\\n\\t\\t\\t\"", ",", "$", "th", ")", ".", "\"\\n\\t\\t\"", ")", ",", "$", "tag", ")", ";", "}" ]
Render table's headers row. @param array $options Table's options. @param string $tag Optional. Tag to group header's content. Options: 'thead' or 'tfoot'. @return string Table's header or footer HTML.
[ "Render", "table", "s", "headers", "row", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/View/Helper/TableHelper.php#L330-L363
2,399
gourmet/common
View/Helper/TableHelper.php
TableHelper._renderPagination
public function _renderPagination($options) { if ($this->Paginator->request->params['paging'][$this->Paginator->defaultModel()]['pageCount'] < 2) { return ''; } if (CakePlugin::loaded('TwitterBootstrap')) { } $out = array(); $paginate = $options['paginate']; $prev = $paginate['prev']; $next = $paginate['next']; $this->Paginator->options($paginate['attrs']); $after = false !== $paginate['divOptions'] ? "\n\t" : "\n\t\t\t"; $glue = false !== $paginate['divOptions'] ? "\n\t" : "\n\t\t\t"; $before = ''; if (CakePlugin::loaded('TwitterBootstrap')) { $glue .= "\t"; $before .= "\n"; $paginate['numbers']['separator'] = $after . "\t"; // Hack for the `BootstrapPaginatorHelper::prev()` and `BootstrapPaginatorHelper::next()` to apply the correct `class`. $prev['options']['disabled'] = $prev['disabledOptions']['class']; $next['options']['disabled'] = $next['disabledOptions']['class']; } $out[] = $this->Paginator->prev($prev['title'], $prev['options'], $prev['disabledTitle'], $prev['disabledOptions']); $out[] = $this->Paginator->numbers($paginate['numbers']); $out[] = $this->Paginator->next($next['title'], $next['options'], $next['disabledTitle'], $next['disabledOptions']); $out = $glue . implode($glue, $out); if (CakePlugin::loaded('TwitterBootstrap') || CakePlugin::loaded('BoostCake')) { if (!isset($paginate['ulOptions'])) { $paginate['ulOptions'] = array('class' => 'pagination'); } $out = $this->Html->tag('ul', $out . $after, $paginate['ulOptions']); } if (false !== $paginate['divOptions']) { return $this->Html->useTag('block', $this->_parseAttributes($paginate['divOptions']), $before . "\t" . $out . "\n"); } return "\t" . $this->Html->useTag( 'tablerow', $this->_parseAttributes($paginate['trOptions']), "\n\t\t" . $this->Html->useTag( 'tablecell', $this->_parseAttributes(array_merge($paginate['tdOptions'], array('colspan' => count($options['columns'])))), $before . "\t\t\t" . $out . "\n\t\t" ) . "\n\t" ); }
php
public function _renderPagination($options) { if ($this->Paginator->request->params['paging'][$this->Paginator->defaultModel()]['pageCount'] < 2) { return ''; } if (CakePlugin::loaded('TwitterBootstrap')) { } $out = array(); $paginate = $options['paginate']; $prev = $paginate['prev']; $next = $paginate['next']; $this->Paginator->options($paginate['attrs']); $after = false !== $paginate['divOptions'] ? "\n\t" : "\n\t\t\t"; $glue = false !== $paginate['divOptions'] ? "\n\t" : "\n\t\t\t"; $before = ''; if (CakePlugin::loaded('TwitterBootstrap')) { $glue .= "\t"; $before .= "\n"; $paginate['numbers']['separator'] = $after . "\t"; // Hack for the `BootstrapPaginatorHelper::prev()` and `BootstrapPaginatorHelper::next()` to apply the correct `class`. $prev['options']['disabled'] = $prev['disabledOptions']['class']; $next['options']['disabled'] = $next['disabledOptions']['class']; } $out[] = $this->Paginator->prev($prev['title'], $prev['options'], $prev['disabledTitle'], $prev['disabledOptions']); $out[] = $this->Paginator->numbers($paginate['numbers']); $out[] = $this->Paginator->next($next['title'], $next['options'], $next['disabledTitle'], $next['disabledOptions']); $out = $glue . implode($glue, $out); if (CakePlugin::loaded('TwitterBootstrap') || CakePlugin::loaded('BoostCake')) { if (!isset($paginate['ulOptions'])) { $paginate['ulOptions'] = array('class' => 'pagination'); } $out = $this->Html->tag('ul', $out . $after, $paginate['ulOptions']); } if (false !== $paginate['divOptions']) { return $this->Html->useTag('block', $this->_parseAttributes($paginate['divOptions']), $before . "\t" . $out . "\n"); } return "\t" . $this->Html->useTag( 'tablerow', $this->_parseAttributes($paginate['trOptions']), "\n\t\t" . $this->Html->useTag( 'tablecell', $this->_parseAttributes(array_merge($paginate['tdOptions'], array('colspan' => count($options['columns'])))), $before . "\t\t\t" . $out . "\n\t\t" ) . "\n\t" ); }
[ "public", "function", "_renderPagination", "(", "$", "options", ")", "{", "if", "(", "$", "this", "->", "Paginator", "->", "request", "->", "params", "[", "'paging'", "]", "[", "$", "this", "->", "Paginator", "->", "defaultModel", "(", ")", "]", "[", "'pageCount'", "]", "<", "2", ")", "{", "return", "''", ";", "}", "if", "(", "CakePlugin", "::", "loaded", "(", "'TwitterBootstrap'", ")", ")", "{", "}", "$", "out", "=", "array", "(", ")", ";", "$", "paginate", "=", "$", "options", "[", "'paginate'", "]", ";", "$", "prev", "=", "$", "paginate", "[", "'prev'", "]", ";", "$", "next", "=", "$", "paginate", "[", "'next'", "]", ";", "$", "this", "->", "Paginator", "->", "options", "(", "$", "paginate", "[", "'attrs'", "]", ")", ";", "$", "after", "=", "false", "!==", "$", "paginate", "[", "'divOptions'", "]", "?", "\"\\n\\t\"", ":", "\"\\n\\t\\t\\t\"", ";", "$", "glue", "=", "false", "!==", "$", "paginate", "[", "'divOptions'", "]", "?", "\"\\n\\t\"", ":", "\"\\n\\t\\t\\t\"", ";", "$", "before", "=", "''", ";", "if", "(", "CakePlugin", "::", "loaded", "(", "'TwitterBootstrap'", ")", ")", "{", "$", "glue", ".=", "\"\\t\"", ";", "$", "before", ".=", "\"\\n\"", ";", "$", "paginate", "[", "'numbers'", "]", "[", "'separator'", "]", "=", "$", "after", ".", "\"\\t\"", ";", "// Hack for the `BootstrapPaginatorHelper::prev()` and `BootstrapPaginatorHelper::next()` to apply the correct `class`.", "$", "prev", "[", "'options'", "]", "[", "'disabled'", "]", "=", "$", "prev", "[", "'disabledOptions'", "]", "[", "'class'", "]", ";", "$", "next", "[", "'options'", "]", "[", "'disabled'", "]", "=", "$", "next", "[", "'disabledOptions'", "]", "[", "'class'", "]", ";", "}", "$", "out", "[", "]", "=", "$", "this", "->", "Paginator", "->", "prev", "(", "$", "prev", "[", "'title'", "]", ",", "$", "prev", "[", "'options'", "]", ",", "$", "prev", "[", "'disabledTitle'", "]", ",", "$", "prev", "[", "'disabledOptions'", "]", ")", ";", "$", "out", "[", "]", "=", "$", "this", "->", "Paginator", "->", "numbers", "(", "$", "paginate", "[", "'numbers'", "]", ")", ";", "$", "out", "[", "]", "=", "$", "this", "->", "Paginator", "->", "next", "(", "$", "next", "[", "'title'", "]", ",", "$", "next", "[", "'options'", "]", ",", "$", "next", "[", "'disabledTitle'", "]", ",", "$", "next", "[", "'disabledOptions'", "]", ")", ";", "$", "out", "=", "$", "glue", ".", "implode", "(", "$", "glue", ",", "$", "out", ")", ";", "if", "(", "CakePlugin", "::", "loaded", "(", "'TwitterBootstrap'", ")", "||", "CakePlugin", "::", "loaded", "(", "'BoostCake'", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "paginate", "[", "'ulOptions'", "]", ")", ")", "{", "$", "paginate", "[", "'ulOptions'", "]", "=", "array", "(", "'class'", "=>", "'pagination'", ")", ";", "}", "$", "out", "=", "$", "this", "->", "Html", "->", "tag", "(", "'ul'", ",", "$", "out", ".", "$", "after", ",", "$", "paginate", "[", "'ulOptions'", "]", ")", ";", "}", "if", "(", "false", "!==", "$", "paginate", "[", "'divOptions'", "]", ")", "{", "return", "$", "this", "->", "Html", "->", "useTag", "(", "'block'", ",", "$", "this", "->", "_parseAttributes", "(", "$", "paginate", "[", "'divOptions'", "]", ")", ",", "$", "before", ".", "\"\\t\"", ".", "$", "out", ".", "\"\\n\"", ")", ";", "}", "return", "\"\\t\"", ".", "$", "this", "->", "Html", "->", "useTag", "(", "'tablerow'", ",", "$", "this", "->", "_parseAttributes", "(", "$", "paginate", "[", "'trOptions'", "]", ")", ",", "\"\\n\\t\\t\"", ".", "$", "this", "->", "Html", "->", "useTag", "(", "'tablecell'", ",", "$", "this", "->", "_parseAttributes", "(", "array_merge", "(", "$", "paginate", "[", "'tdOptions'", "]", ",", "array", "(", "'colspan'", "=>", "count", "(", "$", "options", "[", "'columns'", "]", ")", ")", ")", ")", ",", "$", "before", ".", "\"\\t\\t\\t\"", ".", "$", "out", ".", "\"\\n\\t\\t\"", ")", ".", "\"\\n\\t\"", ")", ";", "}" ]
Render table's pagination row. @param array $options Table's options. @return string Table's pagination HTML.
[ "Render", "table", "s", "pagination", "row", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/View/Helper/TableHelper.php#L371-L424