id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
238,300
tadcka/Tree
Validator/NodeValidator.php
NodeValidator.validateByParent
public function validateByParent($nodeType, NodeInterface $parent = null) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ((null !== $parent) && $parent->getType()) { return in_array($parent->getType(), $config->getParentTypes()); } return false; }
php
public function validateByParent($nodeType, NodeInterface $parent = null) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ((null !== $parent) && $parent->getType()) { return in_array($parent->getType(), $config->getParentTypes()); } return false; }
[ "public", "function", "validateByParent", "(", "$", "nodeType", ",", "NodeInterface", "$", "parent", "=", "null", ")", "{", "if", "(", "!", "$", "nodeType", ")", "{", "return", "true", ";", "}", "$", "config", "=", "$", "this", "->", "getNodeTypeConfig", "(", "$", "nodeType", ")", ";", "if", "(", "null", "===", "$", "config", ")", "{", "return", "false", ";", "}", "if", "(", "(", "null", "!==", "$", "parent", ")", "&&", "$", "parent", "->", "getType", "(", ")", ")", "{", "return", "in_array", "(", "$", "parent", "->", "getType", "(", ")", ",", "$", "config", "->", "getParentTypes", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Validate by parent. @param string $nodeType @param NodeInterface $parent @return bool
[ "Validate", "by", "parent", "." ]
b45038283225508b09a05f99651ecd5127a08f20
https://github.com/tadcka/Tree/blob/b45038283225508b09a05f99651ecd5127a08f20/Validator/NodeValidator.php#L84-L100
238,301
CableFramework/Annotations
src/Cable/Annotation/Parser.php
Parser.filterEmptyLines
public function filterEmptyLines(array $lines) { return array_filter($lines, function ($line) { $line = trim($line); return $line !== '*' ? $line : false; }); }
php
public function filterEmptyLines(array $lines) { return array_filter($lines, function ($line) { $line = trim($line); return $line !== '*' ? $line : false; }); }
[ "public", "function", "filterEmptyLines", "(", "array", "$", "lines", ")", "{", "return", "array_filter", "(", "$", "lines", ",", "function", "(", "$", "line", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "return", "$", "line", "!==", "'*'", "?", "$", "line", ":", "false", ";", "}", ")", ";", "}" ]
filter lines if they empty @param array $lines @return array
[ "filter", "lines", "if", "they", "empty" ]
2fcac6f4e7b1d27655ce87dd82dfb485dcade28e
https://github.com/CableFramework/Annotations/blob/2fcac6f4e7b1d27655ce87dd82dfb485dcade28e/src/Cable/Annotation/Parser.php#L182-L189
238,302
cundd/test-flight
src/DefinitionProvider/DefinitionProvider.php
DefinitionProvider.createForClasses
public function createForClasses(array $classNameToFiles): array { $definitionCollection = []; foreach ($classNameToFiles as $className => $file) { $definitionCollection[$className] = $this->collectDefinitionsForClass($className, $file); } return $definitionCollection; }
php
public function createForClasses(array $classNameToFiles): array { $definitionCollection = []; foreach ($classNameToFiles as $className => $file) { $definitionCollection[$className] = $this->collectDefinitionsForClass($className, $file); } return $definitionCollection; }
[ "public", "function", "createForClasses", "(", "array", "$", "classNameToFiles", ")", ":", "array", "{", "$", "definitionCollection", "=", "[", "]", ";", "foreach", "(", "$", "classNameToFiles", "as", "$", "className", "=>", "$", "file", ")", "{", "$", "definitionCollection", "[", "$", "className", "]", "=", "$", "this", "->", "collectDefinitionsForClass", "(", "$", "className", ",", "$", "file", ")", ";", "}", "return", "$", "definitionCollection", ";", "}" ]
Create the test definitions for the given classes @param array $classNameToFiles @return DefinitionInterface[][]
[ "Create", "the", "test", "definitions", "for", "the", "given", "classes" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/DefinitionProvider/DefinitionProvider.php#L75-L83
238,303
cundd/test-flight
src/DefinitionProvider/DefinitionProvider.php
DefinitionProvider.createForDocumentation
public function createForDocumentation(array $files): array { if (in_array(Constants::TEST_TYPE_DOCUMENTATION, $this->types)) { $definitions = []; foreach ($files as $file) { $key = $this->getTestGroupNameForDocumentationFile($file); $definitions[$key] = $this->collectDefinitionsForFile($file); } return $definitions; } return []; }
php
public function createForDocumentation(array $files): array { if (in_array(Constants::TEST_TYPE_DOCUMENTATION, $this->types)) { $definitions = []; foreach ($files as $file) { $key = $this->getTestGroupNameForDocumentationFile($file); $definitions[$key] = $this->collectDefinitionsForFile($file); } return $definitions; } return []; }
[ "public", "function", "createForDocumentation", "(", "array", "$", "files", ")", ":", "array", "{", "if", "(", "in_array", "(", "Constants", "::", "TEST_TYPE_DOCUMENTATION", ",", "$", "this", "->", "types", ")", ")", "{", "$", "definitions", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "key", "=", "$", "this", "->", "getTestGroupNameForDocumentationFile", "(", "$", "file", ")", ";", "$", "definitions", "[", "$", "key", "]", "=", "$", "this", "->", "collectDefinitionsForFile", "(", "$", "file", ")", ";", "}", "return", "$", "definitions", ";", "}", "return", "[", "]", ";", "}" ]
Create the test definitions for the given documentation files @param FileInterface[] $files @return DefinitionInterface[][]
[ "Create", "the", "test", "definitions", "for", "the", "given", "documentation", "files" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/DefinitionProvider/DefinitionProvider.php#L91-L104
238,304
Koudela/eArc-tree
src/Node.php
Node.nodeToString
protected function nodeToString(string $indent = ''): string { $str = $indent . "--{$this->getName()}--\n"; foreach ($this->getChildren() as $child) { $str .= $child->nodeToString($indent . ' '); } return $str; }
php
protected function nodeToString(string $indent = ''): string { $str = $indent . "--{$this->getName()}--\n"; foreach ($this->getChildren() as $child) { $str .= $child->nodeToString($indent . ' '); } return $str; }
[ "protected", "function", "nodeToString", "(", "string", "$", "indent", "=", "''", ")", ":", "string", "{", "$", "str", "=", "$", "indent", ".", "\"--{$this->getName()}--\\n\"", ";", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "str", ".=", "$", "child", "->", "nodeToString", "(", "$", "indent", ".", "' '", ")", ";", "}", "return", "$", "str", ";", "}" ]
Transforms the instance and its children into a string representation. @param string $indent @return string
[ "Transforms", "the", "instance", "and", "its", "children", "into", "a", "string", "representation", "." ]
811c4341e0eda6e85ae535a87af87f3ed461a7f2
https://github.com/Koudela/eArc-tree/blob/811c4341e0eda6e85ae535a87af87f3ed461a7f2/src/Node.php#L53-L63
238,305
20steps/autotables-bundle
Twig/AutoTablesExtension.php
AutoTablesExtension.renderTable
public function renderTable(\Twig_Environment $env, $args = array()) { $array = array(); $config = $this->fillModel($array); $array['deleteUrl'] = $this->fetchUrl($args, 'delete', $config->getDeleteRoute()); $array['tableId'] = $config->getId(); $array['transScope'] = $config->getTransScope(); $array['views'] = $config->getViews(); $array['frontendFramework'] = $config->getFrontendFramework(); $array['frontendFrameworkName'] = FrontendFramework::toString($config->getFrontendFramework()); return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTable.html.twig', $array); }
php
public function renderTable(\Twig_Environment $env, $args = array()) { $array = array(); $config = $this->fillModel($array); $array['deleteUrl'] = $this->fetchUrl($args, 'delete', $config->getDeleteRoute()); $array['tableId'] = $config->getId(); $array['transScope'] = $config->getTransScope(); $array['views'] = $config->getViews(); $array['frontendFramework'] = $config->getFrontendFramework(); $array['frontendFrameworkName'] = FrontendFramework::toString($config->getFrontendFramework()); return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTable.html.twig', $array); }
[ "public", "function", "renderTable", "(", "\\", "Twig_Environment", "$", "env", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "array", "=", "array", "(", ")", ";", "$", "config", "=", "$", "this", "->", "fillModel", "(", "$", "array", ")", ";", "$", "array", "[", "'deleteUrl'", "]", "=", "$", "this", "->", "fetchUrl", "(", "$", "args", ",", "'delete'", ",", "$", "config", "->", "getDeleteRoute", "(", ")", ")", ";", "$", "array", "[", "'tableId'", "]", "=", "$", "config", "->", "getId", "(", ")", ";", "$", "array", "[", "'transScope'", "]", "=", "$", "config", "->", "getTransScope", "(", ")", ";", "$", "array", "[", "'views'", "]", "=", "$", "config", "->", "getViews", "(", ")", ";", "$", "array", "[", "'frontendFramework'", "]", "=", "$", "config", "->", "getFrontendFramework", "(", ")", ";", "$", "array", "[", "'frontendFrameworkName'", "]", "=", "FrontendFramework", "::", "toString", "(", "$", "config", "->", "getFrontendFramework", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "$", "env", ",", "'twentystepsAutoTablesBundle:AutoTablesExtension:autoTable.html.twig'", ",", "$", "array", ")", ";", "}" ]
Prints a table with the given entities.
[ "Prints", "a", "table", "with", "the", "given", "entities", "." ]
12c52f485079766154d0ac784df4b421ce2e1b85
https://github.com/20steps/autotables-bundle/blob/12c52f485079766154d0ac784df4b421ce2e1b85/Twig/AutoTablesExtension.php#L63-L73
238,306
20steps/autotables-bundle
Twig/AutoTablesExtension.php
AutoTablesExtension.renderTableJs
public function renderTableJs(\Twig_Environment $env, $args = array()) { $array = array(); $config = $this->fillModel($array); $array['updateUrl'] = $this->fetchUrl($args, 'update', $config->getUpdateRoute()); $array['deleteUrl'] = $this->fetchUrl($args, 'delete', $config->getDeleteRoute()); $array['addUrl'] = $this->fetchUrl($args, 'add', $config->getAddRoute()); $array['dtDefaultOpts'] = $this->container->getParameter('twentysteps_auto_tables.default_datatables_options'); $array['dtOpts'] = $config->getDataTablesOptions(); $array['dtTagOpts'] = $this->getParameter($args, 'dtOptions', array()); $array['tableId'] = $config->getId(); $array['transScope'] = $config->getTransScope(); $array['reloadAfterAdd'] = $this->getParameter($args, 'reloadAfterAdd', true); $array['reloadAfterUpdate'] = $this->getParameter($args, 'reloadAfterUpdate', false); $array['includeJavascript'] = $this->checkIncludeJavascript(); $array['includeBootstrap3'] = $this->getParameter($args, 'includeBootstrap3', false); $array['includeJquery'] = $this->getParameter($args, 'includeJquery', FALSE); $array['includeJqueryUi'] = $this->getParameter($args, 'includeJqueryUi', $config->getFrontendFramework() == FrontendFramework::JQUERY_UI); $array['includeJqueryEditable'] = $this->getParameter($args, 'includeJqueryEditable', TRUE); $array['includeJqueryEditableDatePicker'] = $this->getParameter($args, 'includeJqueryEditableDatePicker', $config->getFrontendFramework() == FrontendFramework::JQUERY_UI); $array['includeJqueryEditableBootstrapDatePicker'] = $this->getParameter($args, 'includeJqueryEditableBootstrapDatePicker', $config->getFrontendFramework() == FrontendFramework::BOOTSTRAP3); $array['includeJqueryDataTables'] = $this->getParameter($args, 'includeJqueryDataTables', TRUE); $array['includeJqueryValidate'] = $this->getParameter($args, 'includeJqueryValidate', TRUE); $array['useJqueryUi'] = $config->getFrontendFramework() == FrontendFramework::JQUERY_UI; $array['useBootstrap'] = $config->getFrontendFramework() == FrontendFramework::BOOTSTRAP3; return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableJs.html.twig', $array); }
php
public function renderTableJs(\Twig_Environment $env, $args = array()) { $array = array(); $config = $this->fillModel($array); $array['updateUrl'] = $this->fetchUrl($args, 'update', $config->getUpdateRoute()); $array['deleteUrl'] = $this->fetchUrl($args, 'delete', $config->getDeleteRoute()); $array['addUrl'] = $this->fetchUrl($args, 'add', $config->getAddRoute()); $array['dtDefaultOpts'] = $this->container->getParameter('twentysteps_auto_tables.default_datatables_options'); $array['dtOpts'] = $config->getDataTablesOptions(); $array['dtTagOpts'] = $this->getParameter($args, 'dtOptions', array()); $array['tableId'] = $config->getId(); $array['transScope'] = $config->getTransScope(); $array['reloadAfterAdd'] = $this->getParameter($args, 'reloadAfterAdd', true); $array['reloadAfterUpdate'] = $this->getParameter($args, 'reloadAfterUpdate', false); $array['includeJavascript'] = $this->checkIncludeJavascript(); $array['includeBootstrap3'] = $this->getParameter($args, 'includeBootstrap3', false); $array['includeJquery'] = $this->getParameter($args, 'includeJquery', FALSE); $array['includeJqueryUi'] = $this->getParameter($args, 'includeJqueryUi', $config->getFrontendFramework() == FrontendFramework::JQUERY_UI); $array['includeJqueryEditable'] = $this->getParameter($args, 'includeJqueryEditable', TRUE); $array['includeJqueryEditableDatePicker'] = $this->getParameter($args, 'includeJqueryEditableDatePicker', $config->getFrontendFramework() == FrontendFramework::JQUERY_UI); $array['includeJqueryEditableBootstrapDatePicker'] = $this->getParameter($args, 'includeJqueryEditableBootstrapDatePicker', $config->getFrontendFramework() == FrontendFramework::BOOTSTRAP3); $array['includeJqueryDataTables'] = $this->getParameter($args, 'includeJqueryDataTables', TRUE); $array['includeJqueryValidate'] = $this->getParameter($args, 'includeJqueryValidate', TRUE); $array['useJqueryUi'] = $config->getFrontendFramework() == FrontendFramework::JQUERY_UI; $array['useBootstrap'] = $config->getFrontendFramework() == FrontendFramework::BOOTSTRAP3; return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableJs.html.twig', $array); }
[ "public", "function", "renderTableJs", "(", "\\", "Twig_Environment", "$", "env", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "array", "=", "array", "(", ")", ";", "$", "config", "=", "$", "this", "->", "fillModel", "(", "$", "array", ")", ";", "$", "array", "[", "'updateUrl'", "]", "=", "$", "this", "->", "fetchUrl", "(", "$", "args", ",", "'update'", ",", "$", "config", "->", "getUpdateRoute", "(", ")", ")", ";", "$", "array", "[", "'deleteUrl'", "]", "=", "$", "this", "->", "fetchUrl", "(", "$", "args", ",", "'delete'", ",", "$", "config", "->", "getDeleteRoute", "(", ")", ")", ";", "$", "array", "[", "'addUrl'", "]", "=", "$", "this", "->", "fetchUrl", "(", "$", "args", ",", "'add'", ",", "$", "config", "->", "getAddRoute", "(", ")", ")", ";", "$", "array", "[", "'dtDefaultOpts'", "]", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'twentysteps_auto_tables.default_datatables_options'", ")", ";", "$", "array", "[", "'dtOpts'", "]", "=", "$", "config", "->", "getDataTablesOptions", "(", ")", ";", "$", "array", "[", "'dtTagOpts'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'dtOptions'", ",", "array", "(", ")", ")", ";", "$", "array", "[", "'tableId'", "]", "=", "$", "config", "->", "getId", "(", ")", ";", "$", "array", "[", "'transScope'", "]", "=", "$", "config", "->", "getTransScope", "(", ")", ";", "$", "array", "[", "'reloadAfterAdd'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'reloadAfterAdd'", ",", "true", ")", ";", "$", "array", "[", "'reloadAfterUpdate'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'reloadAfterUpdate'", ",", "false", ")", ";", "$", "array", "[", "'includeJavascript'", "]", "=", "$", "this", "->", "checkIncludeJavascript", "(", ")", ";", "$", "array", "[", "'includeBootstrap3'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeBootstrap3'", ",", "false", ")", ";", "$", "array", "[", "'includeJquery'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJquery'", ",", "FALSE", ")", ";", "$", "array", "[", "'includeJqueryUi'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryUi'", ",", "$", "config", "->", "getFrontendFramework", "(", ")", "==", "FrontendFramework", "::", "JQUERY_UI", ")", ";", "$", "array", "[", "'includeJqueryEditable'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryEditable'", ",", "TRUE", ")", ";", "$", "array", "[", "'includeJqueryEditableDatePicker'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryEditableDatePicker'", ",", "$", "config", "->", "getFrontendFramework", "(", ")", "==", "FrontendFramework", "::", "JQUERY_UI", ")", ";", "$", "array", "[", "'includeJqueryEditableBootstrapDatePicker'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryEditableBootstrapDatePicker'", ",", "$", "config", "->", "getFrontendFramework", "(", ")", "==", "FrontendFramework", "::", "BOOTSTRAP3", ")", ";", "$", "array", "[", "'includeJqueryDataTables'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryDataTables'", ",", "TRUE", ")", ";", "$", "array", "[", "'includeJqueryValidate'", "]", "=", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryValidate'", ",", "TRUE", ")", ";", "$", "array", "[", "'useJqueryUi'", "]", "=", "$", "config", "->", "getFrontendFramework", "(", ")", "==", "FrontendFramework", "::", "JQUERY_UI", ";", "$", "array", "[", "'useBootstrap'", "]", "=", "$", "config", "->", "getFrontendFramework", "(", ")", "==", "FrontendFramework", "::", "BOOTSTRAP3", ";", "return", "$", "this", "->", "render", "(", "$", "env", ",", "'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableJs.html.twig'", ",", "$", "array", ")", ";", "}" ]
Prints the JavaScript code needed for the datatables of the given entities.
[ "Prints", "the", "JavaScript", "code", "needed", "for", "the", "datatables", "of", "the", "given", "entities", "." ]
12c52f485079766154d0ac784df4b421ce2e1b85
https://github.com/20steps/autotables-bundle/blob/12c52f485079766154d0ac784df4b421ce2e1b85/Twig/AutoTablesExtension.php#L78-L103
238,307
20steps/autotables-bundle
Twig/AutoTablesExtension.php
AutoTablesExtension.renderStylesheets
public function renderStylesheets(\Twig_Environment $env, $args = array()) { $frontendFramework = $this->fetchAutoTablesGlobalConfiguration()->getFrontendFramework(); return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableStylesheets.html.twig', array( 'includeJqueryUi' => $this->getParameter($args, 'includeJqueryUi', $frontendFramework == FrontendFramework::JQUERY_UI), 'includeBootstrap3' => $this->getParameter($args, 'includeBootstrap3', false) ) ); }
php
public function renderStylesheets(\Twig_Environment $env, $args = array()) { $frontendFramework = $this->fetchAutoTablesGlobalConfiguration()->getFrontendFramework(); return $this->render($env, 'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableStylesheets.html.twig', array( 'includeJqueryUi' => $this->getParameter($args, 'includeJqueryUi', $frontendFramework == FrontendFramework::JQUERY_UI), 'includeBootstrap3' => $this->getParameter($args, 'includeBootstrap3', false) ) ); }
[ "public", "function", "renderStylesheets", "(", "\\", "Twig_Environment", "$", "env", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "frontendFramework", "=", "$", "this", "->", "fetchAutoTablesGlobalConfiguration", "(", ")", "->", "getFrontendFramework", "(", ")", ";", "return", "$", "this", "->", "render", "(", "$", "env", ",", "'twentystepsAutoTablesBundle:AutoTablesExtension:autoTableStylesheets.html.twig'", ",", "array", "(", "'includeJqueryUi'", "=>", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeJqueryUi'", ",", "$", "frontendFramework", "==", "FrontendFramework", "::", "JQUERY_UI", ")", ",", "'includeBootstrap3'", "=>", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'includeBootstrap3'", ",", "false", ")", ")", ")", ";", "}" ]
Renders the needed JavaScript and stylesheet includes.
[ "Renders", "the", "needed", "JavaScript", "and", "stylesheet", "includes", "." ]
12c52f485079766154d0ac784df4b421ce2e1b85
https://github.com/20steps/autotables-bundle/blob/12c52f485079766154d0ac784df4b421ce2e1b85/Twig/AutoTablesExtension.php#L108-L116
238,308
20steps/autotables-bundle
Twig/AutoTablesExtension.php
AutoTablesExtension.defineOptions
public function defineOptions(\Twig_Environment $env, $args) { $request = $this->requestStack->getCurrentRequest(); if ($request) { $config = $this->fetchAutoTablesConfiguration($args); $entities = $this->entityInspectionService->parseEntities($this->getParameter($args, 'entities', array()), $config); $request->attributes->set('tsAutoTablesConfig', $config); $request->attributes->set('tsAutoTablesEntities', $entities); $request->attributes->set('tsAutoTablesEntityDescriptor', $this->entityInspectionService->fetchEntityDescriptor($config)); } return ''; }
php
public function defineOptions(\Twig_Environment $env, $args) { $request = $this->requestStack->getCurrentRequest(); if ($request) { $config = $this->fetchAutoTablesConfiguration($args); $entities = $this->entityInspectionService->parseEntities($this->getParameter($args, 'entities', array()), $config); $request->attributes->set('tsAutoTablesConfig', $config); $request->attributes->set('tsAutoTablesEntities', $entities); $request->attributes->set('tsAutoTablesEntityDescriptor', $this->entityInspectionService->fetchEntityDescriptor($config)); } return ''; }
[ "public", "function", "defineOptions", "(", "\\", "Twig_Environment", "$", "env", ",", "$", "args", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "if", "(", "$", "request", ")", "{", "$", "config", "=", "$", "this", "->", "fetchAutoTablesConfiguration", "(", "$", "args", ")", ";", "$", "entities", "=", "$", "this", "->", "entityInspectionService", "->", "parseEntities", "(", "$", "this", "->", "getParameter", "(", "$", "args", ",", "'entities'", ",", "array", "(", ")", ")", ",", "$", "config", ")", ";", "$", "request", "->", "attributes", "->", "set", "(", "'tsAutoTablesConfig'", ",", "$", "config", ")", ";", "$", "request", "->", "attributes", "->", "set", "(", "'tsAutoTablesEntities'", ",", "$", "entities", ")", ";", "$", "request", "->", "attributes", "->", "set", "(", "'tsAutoTablesEntityDescriptor'", ",", "$", "this", "->", "entityInspectionService", "->", "fetchEntityDescriptor", "(", "$", "config", ")", ")", ";", "}", "return", "''", ";", "}" ]
Define options to be used for "ts_auto_table" and "ts_auto_table_js".
[ "Define", "options", "to", "be", "used", "for", "ts_auto_table", "and", "ts_auto_table_js", "." ]
12c52f485079766154d0ac784df4b421ce2e1b85
https://github.com/20steps/autotables-bundle/blob/12c52f485079766154d0ac784df4b421ce2e1b85/Twig/AutoTablesExtension.php#L121-L131
238,309
20steps/autotables-bundle
Twig/AutoTablesExtension.php
AutoTablesExtension.checkIncludeJavascript
private function checkIncludeJavascript() { $request = $this->requestStack->getCurrentRequest(); $rtn = !$request->attributes->has($this::JS_INCLUDE_KEY); if (!$rtn) { $request->attributes->set($this::JS_INCLUDE_KEY, true); } return $rtn; }
php
private function checkIncludeJavascript() { $request = $this->requestStack->getCurrentRequest(); $rtn = !$request->attributes->has($this::JS_INCLUDE_KEY); if (!$rtn) { $request->attributes->set($this::JS_INCLUDE_KEY, true); } return $rtn; }
[ "private", "function", "checkIncludeJavascript", "(", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "$", "rtn", "=", "!", "$", "request", "->", "attributes", "->", "has", "(", "$", "this", "::", "JS_INCLUDE_KEY", ")", ";", "if", "(", "!", "$", "rtn", ")", "{", "$", "request", "->", "attributes", "->", "set", "(", "$", "this", "::", "JS_INCLUDE_KEY", ",", "true", ")", ";", "}", "return", "$", "rtn", ";", "}" ]
Determines whether we have to include the javascript files.
[ "Determines", "whether", "we", "have", "to", "include", "the", "javascript", "files", "." ]
12c52f485079766154d0ac784df4b421ce2e1b85
https://github.com/20steps/autotables-bundle/blob/12c52f485079766154d0ac784df4b421ce2e1b85/Twig/AutoTablesExtension.php#L165-L172
238,310
netcore/module-category
Repositories/CategoryRepository.php
CategoryRepository.getCategoriesPlain
public function getCategoriesPlain() : Collection { static $categories; if ($categories) { return $categories; } $categories = []; $languages = TransHelper::getAllLanguages(); foreach (Category::all() as $category) { $categoryData = [ 'id' => $category->id, 'parent_id' => $category->parent_id, 'slugs' => [], ]; foreach ($languages as $language) { $translation = $category->translations->where('locale', $language->iso_code)->first(); $slug = object_get($translation, 'slug'); $categoryData['slugs'][$language->iso_code] = $slug; } $categories[] = $categoryData; } $categories = collect($categories); return $categories; }
php
public function getCategoriesPlain() : Collection { static $categories; if ($categories) { return $categories; } $categories = []; $languages = TransHelper::getAllLanguages(); foreach (Category::all() as $category) { $categoryData = [ 'id' => $category->id, 'parent_id' => $category->parent_id, 'slugs' => [], ]; foreach ($languages as $language) { $translation = $category->translations->where('locale', $language->iso_code)->first(); $slug = object_get($translation, 'slug'); $categoryData['slugs'][$language->iso_code] = $slug; } $categories[] = $categoryData; } $categories = collect($categories); return $categories; }
[ "public", "function", "getCategoriesPlain", "(", ")", ":", "Collection", "{", "static", "$", "categories", ";", "if", "(", "$", "categories", ")", "{", "return", "$", "categories", ";", "}", "$", "categories", "=", "[", "]", ";", "$", "languages", "=", "TransHelper", "::", "getAllLanguages", "(", ")", ";", "foreach", "(", "Category", "::", "all", "(", ")", "as", "$", "category", ")", "{", "$", "categoryData", "=", "[", "'id'", "=>", "$", "category", "->", "id", ",", "'parent_id'", "=>", "$", "category", "->", "parent_id", ",", "'slugs'", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "languages", "as", "$", "language", ")", "{", "$", "translation", "=", "$", "category", "->", "translations", "->", "where", "(", "'locale'", ",", "$", "language", "->", "iso_code", ")", "->", "first", "(", ")", ";", "$", "slug", "=", "object_get", "(", "$", "translation", ",", "'slug'", ")", ";", "$", "categoryData", "[", "'slugs'", "]", "[", "$", "language", "->", "iso_code", "]", "=", "$", "slug", ";", "}", "$", "categories", "[", "]", "=", "$", "categoryData", ";", "}", "$", "categories", "=", "collect", "(", "$", "categories", ")", ";", "return", "$", "categories", ";", "}" ]
Get plain categories Used to build full slugs without querying the database @return array|\Illuminate\Support\Collection
[ "Get", "plain", "categories", "Used", "to", "build", "full", "slugs", "without", "querying", "the", "database" ]
61a4fc2525774f8ddea730ad9f6f06644552adf7
https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Repositories/CategoryRepository.php#L17-L48
238,311
patternseek/componentview
lib/ExecHelper.php
ExecHelper.replaceElementUsingLink
public function replaceElementUsingLink( $execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ] ) { $url = $this->url( $execMethod, $args, true ); $attrs = [ ]; foreach ($anchorAttrs as $k => $v) { $attrs[ ] = "{$k}='{$v}'"; } $attrsStr = implode( ' ', $attrs ); return <<<EOS <script type="application/javascript"> if( typeof(execLink) != "function" ){ var execLink = function( url, targetDiv ){ // Send the data using post var posting = $.get( url, $( form ).serialize() ); // Put the results in a div posting.done(function( data ) { $( "#"+targetDiv ).replaceWith( data ); $("body").css("cursor", "default"); }); // Show optional progress $("body").css("cursor", "progress"); } } </script> <a href="#" onclick="execLink( '{$url}', '{$targetDiv}' ); return false;" {$attrsStr}>{$linkText}</a> EOS; }
php
public function replaceElementUsingLink( $execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ] ) { $url = $this->url( $execMethod, $args, true ); $attrs = [ ]; foreach ($anchorAttrs as $k => $v) { $attrs[ ] = "{$k}='{$v}'"; } $attrsStr = implode( ' ', $attrs ); return <<<EOS <script type="application/javascript"> if( typeof(execLink) != "function" ){ var execLink = function( url, targetDiv ){ // Send the data using post var posting = $.get( url, $( form ).serialize() ); // Put the results in a div posting.done(function( data ) { $( "#"+targetDiv ).replaceWith( data ); $("body").css("cursor", "default"); }); // Show optional progress $("body").css("cursor", "progress"); } } </script> <a href="#" onclick="execLink( '{$url}', '{$targetDiv}' ); return false;" {$attrsStr}>{$linkText}</a> EOS; }
[ "public", "function", "replaceElementUsingLink", "(", "$", "execMethod", ",", "$", "args", "=", "[", "]", ",", "$", "targetDiv", ",", "$", "linkText", ",", "$", "anchorAttrs", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "url", "(", "$", "execMethod", ",", "$", "args", ",", "true", ")", ";", "$", "attrs", "=", "[", "]", ";", "foreach", "(", "$", "anchorAttrs", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "attrs", "[", "]", "=", "\"{$k}='{$v}'\"", ";", "}", "$", "attrsStr", "=", "implode", "(", "' '", ",", "$", "attrs", ")", ";", "return", " <<<EOS\n <script type=\"application/javascript\">\n if( typeof(execLink) != \"function\" ){\n var execLink = function( url, targetDiv ){\n // Send the data using post\n var posting = $.get( url, $( form ).serialize() );\n \n // Put the results in a div\n posting.done(function( data ) {\n $( \"#\"+targetDiv ).replaceWith( data );\n $(\"body\").css(\"cursor\", \"default\");\n });\n \n // Show optional progress\n $(\"body\").css(\"cursor\", \"progress\");\n }\n }\n </script>\n <a href=\"#\" onclick=\"execLink( '{$url}', '{$targetDiv}' ); return false;\" {$attrsStr}>{$linkText}</a>\nEOS", ";", "}" ]
Generate a link which replaces the content of a DOM element with the output of an exec method @param $execMethod @param array $args @param $targetDiv @param $linkText @param array $anchorAttrs @return string
[ "Generate", "a", "link", "which", "replaces", "the", "content", "of", "a", "DOM", "element", "with", "the", "output", "of", "an", "exec", "method" ]
b3f2a81f69e32ee8abe4c3ec2613ad129fa2ad8d
https://github.com/patternseek/componentview/blob/b3f2a81f69e32ee8abe4c3ec2613ad129fa2ad8d/lib/ExecHelper.php#L101-L129
238,312
bhavitk/micro-struct
src/Library/Mailer.php
Mailer.send
public function send($to) { $message = Swift_Message::newInstance($this->subject) ->setFrom(array(MAIL_USERNAME => 'View Tuber')) ->setTo($to) ->setBody($this->body); if ($this->mailer->send($message)) { echo 'Sent'; } else { echo 'Failed'; } }
php
public function send($to) { $message = Swift_Message::newInstance($this->subject) ->setFrom(array(MAIL_USERNAME => 'View Tuber')) ->setTo($to) ->setBody($this->body); if ($this->mailer->send($message)) { echo 'Sent'; } else { echo 'Failed'; } }
[ "public", "function", "send", "(", "$", "to", ")", "{", "$", "message", "=", "Swift_Message", "::", "newInstance", "(", "$", "this", "->", "subject", ")", "->", "setFrom", "(", "array", "(", "MAIL_USERNAME", "=>", "'View Tuber'", ")", ")", "->", "setTo", "(", "$", "to", ")", "->", "setBody", "(", "$", "this", "->", "body", ")", ";", "if", "(", "$", "this", "->", "mailer", "->", "send", "(", "$", "message", ")", ")", "{", "echo", "'Sent'", ";", "}", "else", "{", "echo", "'Failed'", ";", "}", "}" ]
Sends mail. @param type $to
[ "Sends", "mail", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Library/Mailer.php#L76-L90
238,313
HouseOfAgile/dacorp-extra-bundle
Services/YmlFileManager.php
YmlFileManager.loadYmlFile
public function loadYmlFile($fileName, $path) { $configDirectories = array(($path!=null)?$path:$this->rootDir); $locator = new FileLocator($configDirectories); $ymlFile = $locator->locate($fileName, null, true); $ymlDatas = Yaml::parse($ymlFile); $dataArray = array(); foreach ($ymlDatas as $key => $data) { $dataArray[$key] = array_merge( $data); } return $dataArray; }
php
public function loadYmlFile($fileName, $path) { $configDirectories = array(($path!=null)?$path:$this->rootDir); $locator = new FileLocator($configDirectories); $ymlFile = $locator->locate($fileName, null, true); $ymlDatas = Yaml::parse($ymlFile); $dataArray = array(); foreach ($ymlDatas as $key => $data) { $dataArray[$key] = array_merge( $data); } return $dataArray; }
[ "public", "function", "loadYmlFile", "(", "$", "fileName", ",", "$", "path", ")", "{", "$", "configDirectories", "=", "array", "(", "(", "$", "path", "!=", "null", ")", "?", "$", "path", ":", "$", "this", "->", "rootDir", ")", ";", "$", "locator", "=", "new", "FileLocator", "(", "$", "configDirectories", ")", ";", "$", "ymlFile", "=", "$", "locator", "->", "locate", "(", "$", "fileName", ",", "null", ",", "true", ")", ";", "$", "ymlDatas", "=", "Yaml", "::", "parse", "(", "$", "ymlFile", ")", ";", "$", "dataArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "ymlDatas", "as", "$", "key", "=>", "$", "data", ")", "{", "$", "dataArray", "[", "$", "key", "]", "=", "array_merge", "(", "$", "data", ")", ";", "}", "return", "$", "dataArray", ";", "}" ]
Load a yml file and return an array of the data ordered by keys @param string $fileName @param string $path (full path to search in) @return array
[ "Load", "a", "yml", "file", "and", "return", "an", "array", "of", "the", "data", "ordered", "by", "keys" ]
99fe024791e7833058908a2e5544bde948031524
https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Services/YmlFileManager.php#L51-L66
238,314
slickframework/orm
src/Mapper/Relation/BelongsTo.php
BelongsTo.beforeSelect
public function beforeSelect(Select $event) { if ($this->isLazyLoaded()) { return; } $fields = $this->getFieldsPrefixed(); $table = $this->entityDescriptor->getTableName(); $relateTable = $this->getParentTableName(); $pmk = $this->getParentPrimaryKey(); $onClause = "{$table}.{$this->getForeignKey()} = ". "{$relateTable}.{$pmk}"; $query = $event->getQuery(); $query->join($relateTable, $onClause, $fields, $relateTable); }
php
public function beforeSelect(Select $event) { if ($this->isLazyLoaded()) { return; } $fields = $this->getFieldsPrefixed(); $table = $this->entityDescriptor->getTableName(); $relateTable = $this->getParentTableName(); $pmk = $this->getParentPrimaryKey(); $onClause = "{$table}.{$this->getForeignKey()} = ". "{$relateTable}.{$pmk}"; $query = $event->getQuery(); $query->join($relateTable, $onClause, $fields, $relateTable); }
[ "public", "function", "beforeSelect", "(", "Select", "$", "event", ")", "{", "if", "(", "$", "this", "->", "isLazyLoaded", "(", ")", ")", "{", "return", ";", "}", "$", "fields", "=", "$", "this", "->", "getFieldsPrefixed", "(", ")", ";", "$", "table", "=", "$", "this", "->", "entityDescriptor", "->", "getTableName", "(", ")", ";", "$", "relateTable", "=", "$", "this", "->", "getParentTableName", "(", ")", ";", "$", "pmk", "=", "$", "this", "->", "getParentPrimaryKey", "(", ")", ";", "$", "onClause", "=", "\"{$table}.{$this->getForeignKey()} = \"", ".", "\"{$relateTable}.{$pmk}\"", ";", "$", "query", "=", "$", "event", "->", "getQuery", "(", ")", ";", "$", "query", "->", "join", "(", "$", "relateTable", ",", "$", "onClause", ",", "$", "fields", ",", "$", "relateTable", ")", ";", "}" ]
Handles the before select callback @param Select $event
[ "Handles", "the", "before", "select", "callback" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/BelongsTo.php#L63-L79
238,315
slickframework/orm
src/Mapper/Relation/BelongsTo.php
BelongsTo.afterSelect
public function afterSelect(Select $event) { if ($this->isLazyLoaded()) { return; } foreach ($event->getEntityCollection() as $index => $entity) { $row = $event->getData()[$index]; $entity->{$this->propertyName} = $this->getFromMap($row); } }
php
public function afterSelect(Select $event) { if ($this->isLazyLoaded()) { return; } foreach ($event->getEntityCollection() as $index => $entity) { $row = $event->getData()[$index]; $entity->{$this->propertyName} = $this->getFromMap($row); } }
[ "public", "function", "afterSelect", "(", "Select", "$", "event", ")", "{", "if", "(", "$", "this", "->", "isLazyLoaded", "(", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "event", "->", "getEntityCollection", "(", ")", "as", "$", "index", "=>", "$", "entity", ")", "{", "$", "row", "=", "$", "event", "->", "getData", "(", ")", "[", "$", "index", "]", ";", "$", "entity", "->", "{", "$", "this", "->", "propertyName", "}", "=", "$", "this", "->", "getFromMap", "(", "$", "row", ")", ";", "}", "}" ]
Handles the after select callback @param Select $event
[ "Handles", "the", "after", "select", "callback" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/BelongsTo.php#L86-L95
238,316
slickframework/orm
src/Mapper/Relation/BelongsTo.php
BelongsTo.getFieldsPrefixed
protected function getFieldsPrefixed() { $table = $this->getParentTableName(); $data = []; foreach ($this->getParentFields() as $field) { $data[] = "{$field->getField()} AS ". "{$table}_{$field->getField()}"; } return $data; }
php
protected function getFieldsPrefixed() { $table = $this->getParentTableName(); $data = []; foreach ($this->getParentFields() as $field) { $data[] = "{$field->getField()} AS ". "{$table}_{$field->getField()}"; } return $data; }
[ "protected", "function", "getFieldsPrefixed", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getParentTableName", "(", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getParentFields", "(", ")", "as", "$", "field", ")", "{", "$", "data", "[", "]", "=", "\"{$field->getField()} AS \"", ".", "\"{$table}_{$field->getField()}\"", ";", "}", "return", "$", "data", ";", "}" ]
Prefixed fields for join @return array
[ "Prefixed", "fields", "for", "join" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/BelongsTo.php#L144-L154
238,317
slickframework/orm
src/Mapper/Relation/BelongsTo.php
BelongsTo.map
protected function map($dataRow) { $data = $this->getData($dataRow); $pmk = $this->getParentPrimaryKey(); $entity = (isset($data[$pmk]) && $data[$pmk]) ? $this->getParentEntityMapper()->createFrom($data) : null; return null == $entity ? null : $this->registerEntity($entity); }
php
protected function map($dataRow) { $data = $this->getData($dataRow); $pmk = $this->getParentPrimaryKey(); $entity = (isset($data[$pmk]) && $data[$pmk]) ? $this->getParentEntityMapper()->createFrom($data) : null; return null == $entity ? null : $this->registerEntity($entity); }
[ "protected", "function", "map", "(", "$", "dataRow", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", "$", "dataRow", ")", ";", "$", "pmk", "=", "$", "this", "->", "getParentPrimaryKey", "(", ")", ";", "$", "entity", "=", "(", "isset", "(", "$", "data", "[", "$", "pmk", "]", ")", "&&", "$", "data", "[", "$", "pmk", "]", ")", "?", "$", "this", "->", "getParentEntityMapper", "(", ")", "->", "createFrom", "(", "$", "data", ")", ":", "null", ";", "return", "null", "==", "$", "entity", "?", "null", ":", "$", "this", "->", "registerEntity", "(", "$", "entity", ")", ";", "}" ]
Creates and maps related entity @param array $dataRow @return null|EntityCollection|EntityInterface|EntityInterface[]
[ "Creates", "and", "maps", "related", "entity" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/BelongsTo.php#L184-L192
238,318
slickframework/orm
src/Mapper/Relation/BelongsTo.php
BelongsTo.getData
protected function getData($dataRow) { $data = []; $relateTable = $this->getParentTableName(); $regexp = "/{$relateTable}_(?P<name>.+)/i"; foreach ($dataRow as $field => $value) { if (preg_match($regexp, $field, $matched)) { $data[$matched['name']] = $value; } } return $data; }
php
protected function getData($dataRow) { $data = []; $relateTable = $this->getParentTableName(); $regexp = "/{$relateTable}_(?P<name>.+)/i"; foreach ($dataRow as $field => $value) { if (preg_match($regexp, $field, $matched)) { $data[$matched['name']] = $value; } } return $data; }
[ "protected", "function", "getData", "(", "$", "dataRow", ")", "{", "$", "data", "=", "[", "]", ";", "$", "relateTable", "=", "$", "this", "->", "getParentTableName", "(", ")", ";", "$", "regexp", "=", "\"/{$relateTable}_(?P<name>.+)/i\"", ";", "foreach", "(", "$", "dataRow", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "preg_match", "(", "$", "regexp", ",", "$", "field", ",", "$", "matched", ")", ")", "{", "$", "data", "[", "$", "matched", "[", "'name'", "]", "]", "=", "$", "value", ";", "}", "}", "return", "$", "data", ";", "}" ]
Gets a data array with fields and values for parent entity creation @param array $dataRow @return array
[ "Gets", "a", "data", "array", "with", "fields", "and", "values", "for", "parent", "entity", "creation" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Mapper/Relation/BelongsTo.php#L201-L212
238,319
ehough/curly
src/main/php/ehough/curly/Url.php
ehough_curly_Url.setUser
public function setUser($user) { $regex = '`^' . self::$_regexUser . '$`i'; if (preg_match_all($regex, $user, $matches) !== 1) { throw new InvalidArgumentException('User must match ' . $regex); } $this->_user = $user; }
php
public function setUser($user) { $regex = '`^' . self::$_regexUser . '$`i'; if (preg_match_all($regex, $user, $matches) !== 1) { throw new InvalidArgumentException('User must match ' . $regex); } $this->_user = $user; }
[ "public", "function", "setUser", "(", "$", "user", ")", "{", "$", "regex", "=", "'`^'", ".", "self", "::", "$", "_regexUser", ".", "'$`i'", ";", "if", "(", "preg_match_all", "(", "$", "regex", ",", "$", "user", ",", "$", "matches", ")", "!==", "1", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'User must match '", ".", "$", "regex", ")", ";", "}", "$", "this", "->", "_user", "=", "$", "user", ";", "}" ]
Set the user for this URL. @param string $user The user name to send. @throws InvalidArgumentException If the supplied username is in invalid syntax. @return void
[ "Set", "the", "user", "for", "this", "URL", "." ]
b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347
https://github.com/ehough/curly/blob/b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347/src/main/php/ehough/curly/Url.php#L188-L198
238,320
ehough/curly
src/main/php/ehough/curly/Url.php
ehough_curly_Url.setHost
public function setHost($host) { if (! (self::_isHostname($host) || self::_isIpAddress($host))) { throw new InvalidArgumentException("Invalid host ($host)"); } $this->_host = strtolower(trim($host)); }
php
public function setHost($host) { if (! (self::_isHostname($host) || self::_isIpAddress($host))) { throw new InvalidArgumentException("Invalid host ($host)"); } $this->_host = strtolower(trim($host)); }
[ "public", "function", "setHost", "(", "$", "host", ")", "{", "if", "(", "!", "(", "self", "::", "_isHostname", "(", "$", "host", ")", "||", "self", "::", "_isIpAddress", "(", "$", "host", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Invalid host ($host)\"", ")", ";", "}", "$", "this", "->", "_host", "=", "strtolower", "(", "trim", "(", "$", "host", ")", ")", ";", "}" ]
Sets the host for this URL. @param string $host The hostname or IP address for this URL. @throws InvalidArgumentException If the given host is not an IP address or hostname. @return void
[ "Sets", "the", "host", "for", "this", "URL", "." ]
b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347
https://github.com/ehough/curly/blob/b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347/src/main/php/ehough/curly/Url.php#L209-L217
238,321
ehough/curly
src/main/php/ehough/curly/Url.php
ehough_curly_Url.setQueryVariables
public function setQueryVariables($array) { if (! is_array($array)) { throw new InvalidArgumentException('Must pass an array to setQueryVariables()'); } $parts = array(); foreach ($array as $name => $value) { $name = urlencode($name); if (! is_null($value)) { $parts[] = $name . '=' . urlencode($value); } else { $parts[] = $name; } } $this->setQuery(implode('&', $parts)); }
php
public function setQueryVariables($array) { if (! is_array($array)) { throw new InvalidArgumentException('Must pass an array to setQueryVariables()'); } $parts = array(); foreach ($array as $name => $value) { $name = urlencode($name); if (! is_null($value)) { $parts[] = $name . '=' . urlencode($value); } else { $parts[] = $name; } } $this->setQuery(implode('&', $parts)); }
[ "public", "function", "setQueryVariables", "(", "$", "array", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Must pass an array to setQueryVariables()'", ")", ";", "}", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "name", "=", "urlencode", "(", "$", "name", ")", ";", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "parts", "[", "]", "=", "$", "name", ".", "'='", ".", "urlencode", "(", "$", "value", ")", ";", "}", "else", "{", "$", "parts", "[", "]", "=", "$", "name", ";", "}", "}", "$", "this", "->", "setQuery", "(", "implode", "(", "'&'", ",", "$", "parts", ")", ")", ";", "}" ]
Sets the query string to the specified variable in the query stsring. @param array $array (name => value) array @return void
[ "Sets", "the", "query", "string", "to", "the", "specified", "variable", "in", "the", "query", "stsring", "." ]
b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347
https://github.com/ehough/curly/blob/b9bed86c8681adafe19ba7ca1b7ca98dbd0a8347/src/main/php/ehough/curly/Url.php#L380-L404
238,322
bluetree-service/container
src/ContainerObject.php
ContainerObject._compareData
protected function _compareData($dataToCheck, $key, $originalData, $comparator) { if (is_callable($dataToCheck)) { return call_user_func_array($dataToCheck, [$key, $originalData, $this]); } return $this->_comparator($originalData, $dataToCheck, $comparator); }
php
protected function _compareData($dataToCheck, $key, $originalData, $comparator) { if (is_callable($dataToCheck)) { return call_user_func_array($dataToCheck, [$key, $originalData, $this]); } return $this->_comparator($originalData, $dataToCheck, $comparator); }
[ "protected", "function", "_compareData", "(", "$", "dataToCheck", ",", "$", "key", ",", "$", "originalData", ",", "$", "comparator", ")", "{", "if", "(", "is_callable", "(", "$", "dataToCheck", ")", ")", "{", "return", "call_user_func_array", "(", "$", "dataToCheck", ",", "[", "$", "key", ",", "$", "originalData", ",", "$", "this", "]", ")", ";", "}", "return", "$", "this", "->", "_comparator", "(", "$", "originalData", ",", "$", "dataToCheck", ",", "$", "comparator", ")", ";", "}" ]
compare given data with possibility to use callable functions to check data @param mixed $dataToCheck @param string $key @param mixed $originalData @param string $comparator @return bool
[ "compare", "given", "data", "with", "possibility", "to", "use", "callable", "functions", "to", "check", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L376-L383
238,323
bluetree-service/container
src/ContainerObject.php
ContainerObject.removeObjectError
public function removeObjectError($key = null) { $this->_genericDestroy($key, 'error_list'); $this->_hasErrors = false; return $this; }
php
public function removeObjectError($key = null) { $this->_genericDestroy($key, 'error_list'); $this->_hasErrors = false; return $this; }
[ "public", "function", "removeObjectError", "(", "$", "key", "=", "null", ")", "{", "$", "this", "->", "_genericDestroy", "(", "$", "key", ",", "'error_list'", ")", ";", "$", "this", "->", "_hasErrors", "=", "false", ";", "return", "$", "this", ";", "}" ]
remove single error, or all object errors @param string|null $key @return Object
[ "remove", "single", "error", "or", "all", "object", "errors" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L423-L428
238,324
bluetree-service/container
src/ContainerObject.php
ContainerObject.serialize
public function serialize($skipObjects = false) { $this->_prepareData(); $temporaryData = $this->toArray(); $data = ''; if ($skipObjects) { $temporaryData = $this->traveler( 'self::_skipObject', null, $temporaryData, true ); } try { $data = Serializer::serialize($temporaryData); } catch (ExceptionInterface $exception) { $this->_addException($exception); } return $data; }
php
public function serialize($skipObjects = false) { $this->_prepareData(); $temporaryData = $this->toArray(); $data = ''; if ($skipObjects) { $temporaryData = $this->traveler( 'self::_skipObject', null, $temporaryData, true ); } try { $data = Serializer::serialize($temporaryData); } catch (ExceptionInterface $exception) { $this->_addException($exception); } return $data; }
[ "public", "function", "serialize", "(", "$", "skipObjects", "=", "false", ")", "{", "$", "this", "->", "_prepareData", "(", ")", ";", "$", "temporaryData", "=", "$", "this", "->", "toArray", "(", ")", ";", "$", "data", "=", "''", ";", "if", "(", "$", "skipObjects", ")", "{", "$", "temporaryData", "=", "$", "this", "->", "traveler", "(", "'self::_skipObject'", ",", "null", ",", "$", "temporaryData", ",", "true", ")", ";", "}", "try", "{", "$", "data", "=", "Serializer", "::", "serialize", "(", "$", "temporaryData", ")", ";", "}", "catch", "(", "ExceptionInterface", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "return", "$", "data", ";", "}" ]
return serialized object data @param boolean $skipObjects @return string
[ "return", "serialized", "object", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L436-L458
238,325
bluetree-service/container
src/ContainerObject.php
ContainerObject.get
public function get($key = null) { $this->_prepareData($key); $data = null; if (is_null($key)) { $data = $this->_DATA; } elseif (array_key_exists($key, $this->_DATA)) { $data = $this->_DATA[$key]; } if ($this->_getPreparationOn) { return $this->_dataPreparation($key, $data, $this->_dataRetrieveCallbacks); } return $data; }
php
public function get($key = null) { $this->_prepareData($key); $data = null; if (is_null($key)) { $data = $this->_DATA; } elseif (array_key_exists($key, $this->_DATA)) { $data = $this->_DATA[$key]; } if ($this->_getPreparationOn) { return $this->_dataPreparation($key, $data, $this->_dataRetrieveCallbacks); } return $data; }
[ "public", "function", "get", "(", "$", "key", "=", "null", ")", "{", "$", "this", "->", "_prepareData", "(", "$", "key", ")", ";", "$", "data", "=", "null", ";", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "$", "data", "=", "$", "this", "->", "_DATA", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_DATA", ")", ")", "{", "$", "data", "=", "$", "this", "->", "_DATA", "[", "$", "key", "]", ";", "}", "if", "(", "$", "this", "->", "_getPreparationOn", ")", "{", "return", "$", "this", "->", "_dataPreparation", "(", "$", "key", ",", "$", "data", ",", "$", "this", "->", "_dataRetrieveCallbacks", ")", ";", "}", "return", "$", "data", ";", "}" ]
return data for given key if exist in object or null if key was not found @param string|null $key @return mixed
[ "return", "data", "for", "given", "key", "if", "exist", "in", "object", "or", "null", "if", "key", "was", "not", "found" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L490-L505
238,326
bluetree-service/container
src/ContainerObject.php
ContainerObject.set
public function set($key, $data = null) { if (is_array($key)) { $this->appendArray($key); } else { $this->appendData($key, $data); } return $this; }
php
public function set($key, $data = null) { if (is_array($key)) { $this->appendArray($key); } else { $this->appendData($key, $data); } return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "data", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "appendArray", "(", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "appendData", "(", "$", "key", ",", "$", "data", ")", ";", "}", "return", "$", "this", ";", "}" ]
set some data in object can give pair key=>value or array of keys @param string|array $key @param mixed $data @return $this
[ "set", "some", "data", "in", "object", "can", "give", "pair", "key", "=", ">", "value", "or", "array", "of", "keys" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L529-L538
238,327
bluetree-service/container
src/ContainerObject.php
ContainerObject.returnOriginalData
public function returnOriginalData($key = null) { $this->_prepareData($key); $mergedData = array_merge($this->_DATA, $this->_originalDATA); $data = $this->_removeNewKeys($mergedData); if (array_key_exists($key, $data)) { return $data[$key]; } return null; }
php
public function returnOriginalData($key = null) { $this->_prepareData($key); $mergedData = array_merge($this->_DATA, $this->_originalDATA); $data = $this->_removeNewKeys($mergedData); if (array_key_exists($key, $data)) { return $data[$key]; } return null; }
[ "public", "function", "returnOriginalData", "(", "$", "key", "=", "null", ")", "{", "$", "this", "->", "_prepareData", "(", "$", "key", ")", ";", "$", "mergedData", "=", "array_merge", "(", "$", "this", "->", "_DATA", ",", "$", "this", "->", "_originalDATA", ")", ";", "$", "data", "=", "$", "this", "->", "_removeNewKeys", "(", "$", "mergedData", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "return", "$", "data", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
return original data for key, before it was changed that method don't handle return data preparation @param null|string $key @return mixed
[ "return", "original", "data", "for", "key", "before", "it", "was", "changed", "that", "method", "don", "t", "handle", "return", "data", "preparation" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L547-L559
238,328
bluetree-service/container
src/ContainerObject.php
ContainerObject._comparator
protected function _comparator($dataOrigin, $dataCheck, $operator) { switch ($operator) { case '===': return $dataOrigin === $dataCheck; // no break, always will return boolean value case '!==': return $dataOrigin !== $dataCheck; // no break, always will return boolean value case '==': return $dataOrigin == $dataCheck; // no break, always will return boolean value case '!=': case '<>': return $dataOrigin != $dataCheck; // no break, always will return boolean value case '<': return $dataOrigin < $dataCheck; // no break, always will return boolean value case '>': return $dataOrigin > $dataCheck; // no break, always will return boolean value case '<=': return $dataOrigin <= $dataCheck; // no break, always will return boolean value case '>=': return $dataOrigin >= $dataCheck; // no break, always will return boolean value default: return null; // no break, always will return boolean value } }
php
protected function _comparator($dataOrigin, $dataCheck, $operator) { switch ($operator) { case '===': return $dataOrigin === $dataCheck; // no break, always will return boolean value case '!==': return $dataOrigin !== $dataCheck; // no break, always will return boolean value case '==': return $dataOrigin == $dataCheck; // no break, always will return boolean value case '!=': case '<>': return $dataOrigin != $dataCheck; // no break, always will return boolean value case '<': return $dataOrigin < $dataCheck; // no break, always will return boolean value case '>': return $dataOrigin > $dataCheck; // no break, always will return boolean value case '<=': return $dataOrigin <= $dataCheck; // no break, always will return boolean value case '>=': return $dataOrigin >= $dataCheck; // no break, always will return boolean value default: return null; // no break, always will return boolean value } }
[ "protected", "function", "_comparator", "(", "$", "dataOrigin", ",", "$", "dataCheck", ",", "$", "operator", ")", "{", "switch", "(", "$", "operator", ")", "{", "case", "'==='", ":", "return", "$", "dataOrigin", "===", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'!=='", ":", "return", "$", "dataOrigin", "!==", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'=='", ":", "return", "$", "dataOrigin", "==", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'!='", ":", "case", "'<>'", ":", "return", "$", "dataOrigin", "!=", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'<'", ":", "return", "$", "dataOrigin", "<", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'>'", ":", "return", "$", "dataOrigin", ">", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'<='", ":", "return", "$", "dataOrigin", "<=", "$", "dataCheck", ";", "// no break, always will return boolean value", "case", "'>='", ":", "return", "$", "dataOrigin", ">=", "$", "dataCheck", ";", "// no break, always will return boolean value", "default", ":", "return", "null", ";", "// no break, always will return boolean value", "}", "}" ]
allow to compare data with given operator @param mixed $dataOrigin @param mixed $dataCheck @param string $operator @return bool|null
[ "allow", "to", "compare", "data", "with", "given", "operator" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L643-L683
238,329
bluetree-service/container
src/ContainerObject.php
ContainerObject.destroy
public function destroy($key = null) { if (is_null($key)) { $this->_dataChanged = true; $mergedData = array_merge($this->_DATA, $this->_originalDATA); $this->_originalDATA = $this->_removeNewKeys($mergedData); $this->_DATA = []; } elseif (array_key_exists($key, $this->_DATA)) { $this->_dataChanged = true; if (!array_key_exists($key, $this->_originalDATA) && !array_key_exists($key, $this->_newKeys) ) { $this->_originalDATA[$key] = $this->_DATA[$key]; } unset ($this->_DATA[$key]); } return $this; }
php
public function destroy($key = null) { if (is_null($key)) { $this->_dataChanged = true; $mergedData = array_merge($this->_DATA, $this->_originalDATA); $this->_originalDATA = $this->_removeNewKeys($mergedData); $this->_DATA = []; } elseif (array_key_exists($key, $this->_DATA)) { $this->_dataChanged = true; if (!array_key_exists($key, $this->_originalDATA) && !array_key_exists($key, $this->_newKeys) ) { $this->_originalDATA[$key] = $this->_DATA[$key]; } unset ($this->_DATA[$key]); } return $this; }
[ "public", "function", "destroy", "(", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "$", "this", "->", "_dataChanged", "=", "true", ";", "$", "mergedData", "=", "array_merge", "(", "$", "this", "->", "_DATA", ",", "$", "this", "->", "_originalDATA", ")", ";", "$", "this", "->", "_originalDATA", "=", "$", "this", "->", "_removeNewKeys", "(", "$", "mergedData", ")", ";", "$", "this", "->", "_DATA", "=", "[", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_DATA", ")", ")", "{", "$", "this", "->", "_dataChanged", "=", "true", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_originalDATA", ")", "&&", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_newKeys", ")", ")", "{", "$", "this", "->", "_originalDATA", "[", "$", "key", "]", "=", "$", "this", "->", "_DATA", "[", "$", "key", "]", ";", "}", "unset", "(", "$", "this", "->", "_DATA", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
destroy key entry in object data, or whole keys automatically set data to original array @param string|null $key @return $this
[ "destroy", "key", "entry", "in", "object", "data", "or", "whole", "keys", "automatically", "set", "data", "to", "original", "array" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L705-L726
238,330
bluetree-service/container
src/ContainerObject.php
ContainerObject.restore
public function restore($key = null) { if (is_null($key)) { $mergedData = array_merge($this->_DATA, $this->_originalDATA); $this->_DATA = $this->_removeNewKeys($mergedData); $this->_dataChanged = false; $this->_newKeys = []; } else { if (array_key_exists($key, $this->_originalDATA)) { $this->_DATA[$key] = $this->_originalDATA[$key]; } } return $this; }
php
public function restore($key = null) { if (is_null($key)) { $mergedData = array_merge($this->_DATA, $this->_originalDATA); $this->_DATA = $this->_removeNewKeys($mergedData); $this->_dataChanged = false; $this->_newKeys = []; } else { if (array_key_exists($key, $this->_originalDATA)) { $this->_DATA[$key] = $this->_originalDATA[$key]; } } return $this; }
[ "public", "function", "restore", "(", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "$", "mergedData", "=", "array_merge", "(", "$", "this", "->", "_DATA", ",", "$", "this", "->", "_originalDATA", ")", ";", "$", "this", "->", "_DATA", "=", "$", "this", "->", "_removeNewKeys", "(", "$", "mergedData", ")", ";", "$", "this", "->", "_dataChanged", "=", "false", ";", "$", "this", "->", "_newKeys", "=", "[", "]", ";", "}", "else", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_originalDATA", ")", ")", "{", "$", "this", "->", "_DATA", "[", "$", "key", "]", "=", "$", "this", "->", "_originalDATA", "[", "$", "key", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
replace changed data by original data set data changed to false only if restore whole data @param string|null $key @return $this
[ "replace", "changed", "data", "by", "original", "data", "set", "data", "changed", "to", "false", "only", "if", "restore", "whole", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L772-L786
238,331
bluetree-service/container
src/ContainerObject.php
ContainerObject.toString
public function toString($separator = null) { if (!is_null($separator)) { $this->_separator = $separator; } $this->_prepareData(); return $this->__toString(); }
php
public function toString($separator = null) { if (!is_null($separator)) { $this->_separator = $separator; } $this->_prepareData(); return $this->__toString(); }
[ "public", "function", "toString", "(", "$", "separator", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "separator", ")", ")", "{", "$", "this", "->", "_separator", "=", "$", "separator", ";", "}", "$", "this", "->", "_prepareData", "(", ")", ";", "return", "$", "this", "->", "__toString", "(", ")", ";", "}" ]
return object as string each data value separated by coma @param string $separator @return string
[ "return", "object", "as", "string", "each", "data", "value", "separated", "by", "coma" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L808-L816
238,332
bluetree-service/container
src/ContainerObject.php
ContainerObject.toXml
public function toXml($addCdata = true, $dtd = false, $version = '1.0') { $this->_prepareData(); $xml = new Xml(['version' => $version]); $root = $xml->createElement('root'); $xml = $this->_arrayToXml($this->toArray(), $xml, $addCdata, $root); $xml->appendChild($root); if ($dtd) { $dtd = "<!DOCTYPE root SYSTEM '$dtd'>"; } $xml->formatOutput = true; $xmlData = $xml->saveXmlFile(false, true); if ($xml->hasErrors()) { $this->_hasErrors = true; $this->_errorsList[] = $xml->getError(); return false; } return $dtd . $xmlData; }
php
public function toXml($addCdata = true, $dtd = false, $version = '1.0') { $this->_prepareData(); $xml = new Xml(['version' => $version]); $root = $xml->createElement('root'); $xml = $this->_arrayToXml($this->toArray(), $xml, $addCdata, $root); $xml->appendChild($root); if ($dtd) { $dtd = "<!DOCTYPE root SYSTEM '$dtd'>"; } $xml->formatOutput = true; $xmlData = $xml->saveXmlFile(false, true); if ($xml->hasErrors()) { $this->_hasErrors = true; $this->_errorsList[] = $xml->getError(); return false; } return $dtd . $xmlData; }
[ "public", "function", "toXml", "(", "$", "addCdata", "=", "true", ",", "$", "dtd", "=", "false", ",", "$", "version", "=", "'1.0'", ")", "{", "$", "this", "->", "_prepareData", "(", ")", ";", "$", "xml", "=", "new", "Xml", "(", "[", "'version'", "=>", "$", "version", "]", ")", ";", "$", "root", "=", "$", "xml", "->", "createElement", "(", "'root'", ")", ";", "$", "xml", "=", "$", "this", "->", "_arrayToXml", "(", "$", "this", "->", "toArray", "(", ")", ",", "$", "xml", ",", "$", "addCdata", ",", "$", "root", ")", ";", "$", "xml", "->", "appendChild", "(", "$", "root", ")", ";", "if", "(", "$", "dtd", ")", "{", "$", "dtd", "=", "\"<!DOCTYPE root SYSTEM '$dtd'>\"", ";", "}", "$", "xml", "->", "formatOutput", "=", "true", ";", "$", "xmlData", "=", "$", "xml", "->", "saveXmlFile", "(", "false", ",", "true", ")", ";", "if", "(", "$", "xml", "->", "hasErrors", "(", ")", ")", "{", "$", "this", "->", "_hasErrors", "=", "true", ";", "$", "this", "->", "_errorsList", "[", "]", "=", "$", "xml", "->", "getError", "(", ")", ";", "return", "false", ";", "}", "return", "$", "dtd", ".", "$", "xmlData", ";", "}" ]
return object data as xml representation @param bool $addCdata @param string|boolean $dtd @param string $version @return string
[ "return", "object", "data", "as", "xml", "representation" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L859-L883
238,333
bluetree-service/container
src/ContainerObject.php
ContainerObject.toStdClass
public function toStdClass() { $this->_prepareData(); $data = new stdClass(); foreach ($this->toArray() as $key => $val) { $data->$key = $val; } return $data; }
php
public function toStdClass() { $this->_prepareData(); $data = new stdClass(); foreach ($this->toArray() as $key => $val) { $data->$key = $val; } return $data; }
[ "public", "function", "toStdClass", "(", ")", "{", "$", "this", "->", "_prepareData", "(", ")", ";", "$", "data", "=", "new", "stdClass", "(", ")", ";", "foreach", "(", "$", "this", "->", "toArray", "(", ")", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "data", "->", "$", "key", "=", "$", "val", ";", "}", "return", "$", "data", ";", "}" ]
return object as stdClass @return stdClass
[ "return", "object", "as", "stdClass" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L890-L900
238,334
bluetree-service/container
src/ContainerObject.php
ContainerObject.keyDataChanged
public function keyDataChanged($key) { $data = $this->toArray($key); $originalData = $this->returnOriginalData($key); return $data !== $originalData; }
php
public function keyDataChanged($key) { $data = $this->toArray($key); $originalData = $this->returnOriginalData($key); return $data !== $originalData; }
[ "public", "function", "keyDataChanged", "(", "$", "key", ")", "{", "$", "data", "=", "$", "this", "->", "toArray", "(", "$", "key", ")", ";", "$", "originalData", "=", "$", "this", "->", "returnOriginalData", "(", "$", "key", ")", ";", "return", "$", "data", "!==", "$", "originalData", ";", "}" ]
check that data for given key was changed @param string $key @return bool
[ "check", "that", "data", "for", "given", "key", "was", "changed" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L929-L935
238,335
bluetree-service/container
src/ContainerObject.php
ContainerObject.traveler
public function traveler( $function, $methodAttributes = null, $data = null, $recursive = false ) { if (!$data) { $data =& $this->_DATA; } foreach ($data as $key => $value) { $isRecursive = is_array($value) && $recursive; if ($isRecursive) { $data[$key] = $this->_recursiveTraveler($function, $methodAttributes, $value); } else { $data[$key] = $this->_callUserFunction($function, $key, $value, $methodAttributes); } } return $data; }
php
public function traveler( $function, $methodAttributes = null, $data = null, $recursive = false ) { if (!$data) { $data =& $this->_DATA; } foreach ($data as $key => $value) { $isRecursive = is_array($value) && $recursive; if ($isRecursive) { $data[$key] = $this->_recursiveTraveler($function, $methodAttributes, $value); } else { $data[$key] = $this->_callUserFunction($function, $key, $value, $methodAttributes); } } return $data; }
[ "public", "function", "traveler", "(", "$", "function", ",", "$", "methodAttributes", "=", "null", ",", "$", "data", "=", "null", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "!", "$", "data", ")", "{", "$", "data", "=", "&", "$", "this", "->", "_DATA", ";", "}", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "isRecursive", "=", "is_array", "(", "$", "value", ")", "&&", "$", "recursive", ";", "if", "(", "$", "isRecursive", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_recursiveTraveler", "(", "$", "function", ",", "$", "methodAttributes", ",", "$", "value", ")", ";", "}", "else", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_callUserFunction", "(", "$", "function", ",", "$", "key", ",", "$", "value", ",", "$", "methodAttributes", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
allow to use given method or function for all data inside of object @param array|string|\Closure $function @param mixed $methodAttributes @param mixed $data @param bool $recursive @return array|null
[ "allow", "to", "use", "given", "method", "or", "function", "for", "all", "data", "inside", "of", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L946-L967
238,336
bluetree-service/container
src/ContainerObject.php
ContainerObject._recursiveTraveler
protected function _recursiveTraveler($function, $methodAttributes, $data) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->_recursiveTraveler($function, $methodAttributes, $value); } else { $data[$key] = $this->_callUserFunction($function, $key, $value, $methodAttributes); } } return $data; }
php
protected function _recursiveTraveler($function, $methodAttributes, $data) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->_recursiveTraveler($function, $methodAttributes, $value); } else { $data[$key] = $this->_callUserFunction($function, $key, $value, $methodAttributes); } } return $data; }
[ "protected", "function", "_recursiveTraveler", "(", "$", "function", ",", "$", "methodAttributes", ",", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_recursiveTraveler", "(", "$", "function", ",", "$", "methodAttributes", ",", "$", "value", ")", ";", "}", "else", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_callUserFunction", "(", "$", "function", ",", "$", "key", ",", "$", "value", ",", "$", "methodAttributes", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
allow to change some data in multi level arrays @param mixed $methodAttributes @param mixed $data @param array|string|\Closure $function @return mixed
[ "allow", "to", "change", "some", "data", "in", "multi", "level", "arrays" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L977-L988
238,337
bluetree-service/container
src/ContainerObject.php
ContainerObject._callUserFunction
protected function _callUserFunction($function, $key, $value, $attributes) { if (is_callable($function)) { return call_user_func_array($function, [$key, $value, $this, $attributes]); } return $value; }
php
protected function _callUserFunction($function, $key, $value, $attributes) { if (is_callable($function)) { return call_user_func_array($function, [$key, $value, $this, $attributes]); } return $value; }
[ "protected", "function", "_callUserFunction", "(", "$", "function", ",", "$", "key", ",", "$", "value", ",", "$", "attributes", ")", "{", "if", "(", "is_callable", "(", "$", "function", ")", ")", "{", "return", "call_user_func_array", "(", "$", "function", ",", "[", "$", "key", ",", "$", "value", ",", "$", "this", ",", "$", "attributes", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
run given function, method or closure on given data @param array|string|\Closure $function @param string $key @param mixed $value @param mixed $attributes @return mixed
[ "run", "given", "function", "method", "or", "closure", "on", "given", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L999-L1006
238,338
bluetree-service/container
src/ContainerObject.php
ContainerObject.mergeBlueObject
public function mergeBlueObject(Container $object) { $newData = $object->toArray(); foreach ($newData as $key => $value) { $this->appendData($key, $value); } $this->_dataChanged = true; return $this; }
php
public function mergeBlueObject(Container $object) { $newData = $object->toArray(); foreach ($newData as $key => $value) { $this->appendData($key, $value); } $this->_dataChanged = true; return $this; }
[ "public", "function", "mergeBlueObject", "(", "Container", "$", "object", ")", "{", "$", "newData", "=", "$", "object", "->", "toArray", "(", ")", ";", "foreach", "(", "$", "newData", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "appendData", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "this", "->", "_dataChanged", "=", "true", ";", "return", "$", "this", ";", "}" ]
allow to join two blue objects into one @param \BlueContainer\Container $object @return $this
[ "allow", "to", "join", "two", "blue", "objects", "into", "one" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1014-L1024
238,339
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendJson
public function appendJson($data) { $jsonData = json_decode($data, true); if (is_null($jsonData)) { $this->_errorsList['json_decode'] = 'Json cannot be decoded.'; $this->_hasErrors = true; return $this; } $this->appendArray($jsonData); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendJson($data) { $jsonData = json_decode($data, true); if (is_null($jsonData)) { $this->_errorsList['json_decode'] = 'Json cannot be decoded.'; $this->_hasErrors = true; return $this; } $this->appendArray($jsonData); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendJson", "(", "$", "data", ")", "{", "$", "jsonData", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "jsonData", ")", ")", "{", "$", "this", "->", "_errorsList", "[", "'json_decode'", "]", "=", "'Json cannot be decoded.'", ";", "$", "this", "->", "_hasErrors", "=", "true", ";", "return", "$", "this", ";", "}", "$", "this", "->", "appendArray", "(", "$", "jsonData", ")", ";", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
apply given json data as object data @param string $data @return $this
[ "apply", "given", "json", "data", "as", "object", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1059-L1075
238,340
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendSimpleXml
public function appendSimpleXml($data) { $loadedXml = simplexml_load_string($data); $jsonXml = json_encode($loadedXml); $jsonData = json_decode($jsonXml, true); $this->appendArray($jsonData); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendSimpleXml($data) { $loadedXml = simplexml_load_string($data); $jsonXml = json_encode($loadedXml); $jsonData = json_decode($jsonXml, true); $this->appendArray($jsonData); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendSimpleXml", "(", "$", "data", ")", "{", "$", "loadedXml", "=", "simplexml_load_string", "(", "$", "data", ")", ";", "$", "jsonXml", "=", "json_encode", "(", "$", "loadedXml", ")", ";", "$", "jsonData", "=", "json_decode", "(", "$", "jsonXml", ",", "true", ")", ";", "$", "this", "->", "appendArray", "(", "$", "jsonData", ")", ";", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
apply given xml data as object data @param $data string @return $this
[ "apply", "given", "xml", "data", "as", "object", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1083-L1095
238,341
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendXml
public function appendXml($data) { $xml = new Xml(); $xml->preserveWhiteSpace = false; $bool = @$xml->loadXML($data); if (!$bool) { $this->_errorsList['xml_load_error'] = $data; $this->_hasErrors = true; return $this; } try { $temp = $this->_xmlToArray($xml->documentElement); $this->appendArray($temp); } catch (DOMException $exception) { $this->_addException($exception); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendXml($data) { $xml = new Xml(); $xml->preserveWhiteSpace = false; $bool = @$xml->loadXML($data); if (!$bool) { $this->_errorsList['xml_load_error'] = $data; $this->_hasErrors = true; return $this; } try { $temp = $this->_xmlToArray($xml->documentElement); $this->appendArray($temp); } catch (DOMException $exception) { $this->_addException($exception); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendXml", "(", "$", "data", ")", "{", "$", "xml", "=", "new", "Xml", "(", ")", ";", "$", "xml", "->", "preserveWhiteSpace", "=", "false", ";", "$", "bool", "=", "@", "$", "xml", "->", "loadXML", "(", "$", "data", ")", ";", "if", "(", "!", "$", "bool", ")", "{", "$", "this", "->", "_errorsList", "[", "'xml_load_error'", "]", "=", "$", "data", ";", "$", "this", "->", "_hasErrors", "=", "true", ";", "return", "$", "this", ";", "}", "try", "{", "$", "temp", "=", "$", "this", "->", "_xmlToArray", "(", "$", "xml", "->", "documentElement", ")", ";", "$", "this", "->", "appendArray", "(", "$", "temp", ")", ";", "}", "catch", "(", "DOMException", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
apply given xml data as object data also handling attributes @param $data string @return $this
[ "apply", "given", "xml", "data", "as", "object", "data", "also", "handling", "attributes" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1104-L1127
238,342
bluetree-service/container
src/ContainerObject.php
ContainerObject._xmlToArray
protected function _xmlToArray(DOMElement $data) { $temporaryData = []; /** @var $node DOMElement */ foreach ($data->childNodes as $node) { $nodeName = $this->_stringToIntegerKey($node->nodeName); $nodeData = []; $unSerializedData = []; if ($node->hasAttributes() && $node->getAttribute('serialized_object')) { try { $unSerializedData = Serializer::unserialize($node->nodeValue); } catch (ExceptionInterface $exception) { $this->_addException($exception); } $temporaryData[$nodeName] = $unSerializedData; continue; } if ($node->hasAttributes()) { foreach ($node->attributes as $key => $value) { $nodeData['@attributes'][$key] = $value->nodeValue; } } if ($node->hasChildNodes()) { $childNodesData = []; /** @var $childNode DOMElement */ foreach ($node->childNodes as $childNode) { if ($childNode->nodeType === 1) { $childNodesData = $this->_xmlToArray($node); } } if (!empty($childNodesData)) { $temporaryData[$nodeName] = $childNodesData; continue; } } if (!empty($nodeData)) { $temporaryData[$nodeName] = array_merge( [$node->nodeValue], $nodeData ); } else { $temporaryData[$nodeName] = $node->nodeValue; } } return $temporaryData; }
php
protected function _xmlToArray(DOMElement $data) { $temporaryData = []; /** @var $node DOMElement */ foreach ($data->childNodes as $node) { $nodeName = $this->_stringToIntegerKey($node->nodeName); $nodeData = []; $unSerializedData = []; if ($node->hasAttributes() && $node->getAttribute('serialized_object')) { try { $unSerializedData = Serializer::unserialize($node->nodeValue); } catch (ExceptionInterface $exception) { $this->_addException($exception); } $temporaryData[$nodeName] = $unSerializedData; continue; } if ($node->hasAttributes()) { foreach ($node->attributes as $key => $value) { $nodeData['@attributes'][$key] = $value->nodeValue; } } if ($node->hasChildNodes()) { $childNodesData = []; /** @var $childNode DOMElement */ foreach ($node->childNodes as $childNode) { if ($childNode->nodeType === 1) { $childNodesData = $this->_xmlToArray($node); } } if (!empty($childNodesData)) { $temporaryData[$nodeName] = $childNodesData; continue; } } if (!empty($nodeData)) { $temporaryData[$nodeName] = array_merge( [$node->nodeValue], $nodeData ); } else { $temporaryData[$nodeName] = $node->nodeValue; } } return $temporaryData; }
[ "protected", "function", "_xmlToArray", "(", "DOMElement", "$", "data", ")", "{", "$", "temporaryData", "=", "[", "]", ";", "/** @var $node DOMElement */", "foreach", "(", "$", "data", "->", "childNodes", "as", "$", "node", ")", "{", "$", "nodeName", "=", "$", "this", "->", "_stringToIntegerKey", "(", "$", "node", "->", "nodeName", ")", ";", "$", "nodeData", "=", "[", "]", ";", "$", "unSerializedData", "=", "[", "]", ";", "if", "(", "$", "node", "->", "hasAttributes", "(", ")", "&&", "$", "node", "->", "getAttribute", "(", "'serialized_object'", ")", ")", "{", "try", "{", "$", "unSerializedData", "=", "Serializer", "::", "unserialize", "(", "$", "node", "->", "nodeValue", ")", ";", "}", "catch", "(", "ExceptionInterface", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "$", "temporaryData", "[", "$", "nodeName", "]", "=", "$", "unSerializedData", ";", "continue", ";", "}", "if", "(", "$", "node", "->", "hasAttributes", "(", ")", ")", "{", "foreach", "(", "$", "node", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "nodeData", "[", "'@attributes'", "]", "[", "$", "key", "]", "=", "$", "value", "->", "nodeValue", ";", "}", "}", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "$", "childNodesData", "=", "[", "]", ";", "/** @var $childNode DOMElement */", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "childNode", ")", "{", "if", "(", "$", "childNode", "->", "nodeType", "===", "1", ")", "{", "$", "childNodesData", "=", "$", "this", "->", "_xmlToArray", "(", "$", "node", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "childNodesData", ")", ")", "{", "$", "temporaryData", "[", "$", "nodeName", "]", "=", "$", "childNodesData", ";", "continue", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "nodeData", ")", ")", "{", "$", "temporaryData", "[", "$", "nodeName", "]", "=", "array_merge", "(", "[", "$", "node", "->", "nodeValue", "]", ",", "$", "nodeData", ")", ";", "}", "else", "{", "$", "temporaryData", "[", "$", "nodeName", "]", "=", "$", "node", "->", "nodeValue", ";", "}", "}", "return", "$", "temporaryData", ";", "}" ]
recurrent function to travel on xml nodes and set their data as object data @param DOMElement $data @return array
[ "recurrent", "function", "to", "travel", "on", "xml", "nodes", "and", "set", "their", "data", "as", "object", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1135-L1189
238,343
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendArray
public function appendArray(array $arrayData) { foreach ($arrayData as $dataKey => $data) { $this->_putData($dataKey, $data); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendArray(array $arrayData) { foreach ($arrayData as $dataKey => $data) { $this->_putData($dataKey, $data); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendArray", "(", "array", "$", "arrayData", ")", "{", "foreach", "(", "$", "arrayData", "as", "$", "dataKey", "=>", "$", "data", ")", "{", "$", "this", "->", "_putData", "(", "$", "dataKey", ",", "$", "data", ")", ";", "}", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
allow to set array in object or some other value @param array $arrayData @return $this
[ "allow", "to", "set", "array", "in", "object", "or", "some", "other", "value" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1218-L1228
238,344
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendData
public function appendData($key, $data) { $this->_putData($key, $data); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendData($key, $data) { $this->_putData($key, $data); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendData", "(", "$", "key", ",", "$", "data", ")", "{", "$", "this", "->", "_putData", "(", "$", "key", ",", "$", "data", ")", ";", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
allow to set some mixed data type as given key @param array|string $key @param mixed $data @return $this
[ "allow", "to", "set", "some", "mixed", "data", "type", "as", "given", "key" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1237-L1245
238,345
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendStdClass
public function appendStdClass(stdClass $class) { $this->appendArray(get_object_vars($class)); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendStdClass(stdClass $class) { $this->appendArray(get_object_vars($class)); if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendStdClass", "(", "stdClass", "$", "class", ")", "{", "$", "this", "->", "appendArray", "(", "get_object_vars", "(", "$", "class", ")", ")", ";", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
get class variables and set them as data @param stdClass $class @return $this
[ "get", "class", "variables", "and", "set", "them", "as", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1253-L1261
238,346
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendSerialized
public function appendSerialized($data) { try { $data = Serializer::unserialize($data); } catch (ExceptionInterface $exception) { $this->_addException($exception); } if (is_object($data)) { $name = $this->_convertKeyNames(get_class($data)); $this->appendData($name, $data); } elseif (is_array($data)) { $this->appendArray($data); } else { $this->appendData($this->_defaultDataName, $data); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendSerialized($data) { try { $data = Serializer::unserialize($data); } catch (ExceptionInterface $exception) { $this->_addException($exception); } if (is_object($data)) { $name = $this->_convertKeyNames(get_class($data)); $this->appendData($name, $data); } elseif (is_array($data)) { $this->appendArray($data); } else { $this->appendData($this->_defaultDataName, $data); } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendSerialized", "(", "$", "data", ")", "{", "try", "{", "$", "data", "=", "Serializer", "::", "unserialize", "(", "$", "data", ")", ";", "}", "catch", "(", "ExceptionInterface", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "$", "name", "=", "$", "this", "->", "_convertKeyNames", "(", "get_class", "(", "$", "data", ")", ")", ";", "$", "this", "->", "appendData", "(", "$", "name", ",", "$", "data", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "appendArray", "(", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "appendData", "(", "$", "this", "->", "_defaultDataName", ",", "$", "data", ")", ";", "}", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
set data from serialized string as object data if data is an object set one variable where key is an object class name @param mixed $data @return $this
[ "set", "data", "from", "serialized", "string", "as", "object", "data", "if", "data", "is", "an", "object", "set", "one", "variable", "where", "key", "is", "an", "object", "class", "name" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1270-L1291
238,347
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendIni
public function appendIni($data) { $array = parse_ini_string($data, $this->_processIniSection, INI_SCANNER_RAW); if ($array === false) { $this->_hasErrors = true; $this->_errorsList[] = 'parse_ini_string'; return $this; } $this->appendArray($array); return $this; }
php
public function appendIni($data) { $array = parse_ini_string($data, $this->_processIniSection, INI_SCANNER_RAW); if ($array === false) { $this->_hasErrors = true; $this->_errorsList[] = 'parse_ini_string'; return $this; } $this->appendArray($array); return $this; }
[ "public", "function", "appendIni", "(", "$", "data", ")", "{", "$", "array", "=", "parse_ini_string", "(", "$", "data", ",", "$", "this", "->", "_processIniSection", ",", "INI_SCANNER_RAW", ")", ";", "if", "(", "$", "array", "===", "false", ")", "{", "$", "this", "->", "_hasErrors", "=", "true", ";", "$", "this", "->", "_errorsList", "[", "]", "=", "'parse_ini_string'", ";", "return", "$", "this", ";", "}", "$", "this", "->", "appendArray", "(", "$", "array", ")", ";", "return", "$", "this", ";", "}" ]
allow to set ini data into object @param string $data @return $this
[ "allow", "to", "set", "ini", "data", "into", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1299-L1311
238,348
bluetree-service/container
src/ContainerObject.php
ContainerObject.toIni
public function toIni() { $ini = ''; foreach ($this->toArray() as $key => $iniRow) { $this->_appendIniData($ini, $key, $iniRow); } return $ini; }
php
public function toIni() { $ini = ''; foreach ($this->toArray() as $key => $iniRow) { $this->_appendIniData($ini, $key, $iniRow); } return $ini; }
[ "public", "function", "toIni", "(", ")", "{", "$", "ini", "=", "''", ";", "foreach", "(", "$", "this", "->", "toArray", "(", ")", "as", "$", "key", "=>", "$", "iniRow", ")", "{", "$", "this", "->", "_appendIniData", "(", "$", "ini", ",", "$", "key", ",", "$", "iniRow", ")", ";", "}", "return", "$", "ini", ";", "}" ]
export object as ini string @return string
[ "export", "object", "as", "ini", "string" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1340-L1349
238,349
bluetree-service/container
src/ContainerObject.php
ContainerObject._appendIniData
protected function _appendIniData(&$ini, $key, $iniRow) { if ($this->_processIniSection && is_array($iniRow)) { $ini .= '[' . $key . ']' . "\n"; foreach ($iniRow as $rowKey => $rowData) { $ini .= $rowKey . ' = ' . $rowData . "\n"; } } else { $ini .= $key . ' = ' . $iniRow . "\n"; } }
php
protected function _appendIniData(&$ini, $key, $iniRow) { if ($this->_processIniSection && is_array($iniRow)) { $ini .= '[' . $key . ']' . "\n"; foreach ($iniRow as $rowKey => $rowData) { $ini .= $rowKey . ' = ' . $rowData . "\n"; } } else { $ini .= $key . ' = ' . $iniRow . "\n"; } }
[ "protected", "function", "_appendIniData", "(", "&", "$", "ini", ",", "$", "key", ",", "$", "iniRow", ")", "{", "if", "(", "$", "this", "->", "_processIniSection", "&&", "is_array", "(", "$", "iniRow", ")", ")", "{", "$", "ini", ".=", "'['", ".", "$", "key", ".", "']'", ".", "\"\\n\"", ";", "foreach", "(", "$", "iniRow", "as", "$", "rowKey", "=>", "$", "rowData", ")", "{", "$", "ini", ".=", "$", "rowKey", ".", "' = '", ".", "$", "rowData", ".", "\"\\n\"", ";", "}", "}", "else", "{", "$", "ini", ".=", "$", "key", ".", "' = '", ".", "$", "iniRow", ".", "\"\\n\"", ";", "}", "}" ]
append ini data to string @param string $ini @param string $key @param mixed $iniRow
[ "append", "ini", "data", "to", "string" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1358-L1368
238,350
bluetree-service/container
src/ContainerObject.php
ContainerObject.appendCsv
public function appendCsv($data) { $counter = 0; $rows = str_getcsv($data, $this->_csvLineDelimiter); foreach ($rows as $row) { $rowData = str_getcsv( $row, $this->_csvDelimiter, $this->_csvEnclosure, $this->_csvEscape ); $this->_putData($this->_integerKeyPrefix . $counter, $rowData); $counter++; } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
php
public function appendCsv($data) { $counter = 0; $rows = str_getcsv($data, $this->_csvLineDelimiter); foreach ($rows as $row) { $rowData = str_getcsv( $row, $this->_csvDelimiter, $this->_csvEnclosure, $this->_csvEscape ); $this->_putData($this->_integerKeyPrefix . $counter, $rowData); $counter++; } if ($this->_objectCreation) { return $this->_afterAppendDataToNewObject(); } return $this; }
[ "public", "function", "appendCsv", "(", "$", "data", ")", "{", "$", "counter", "=", "0", ";", "$", "rows", "=", "str_getcsv", "(", "$", "data", ",", "$", "this", "->", "_csvLineDelimiter", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "rowData", "=", "str_getcsv", "(", "$", "row", ",", "$", "this", "->", "_csvDelimiter", ",", "$", "this", "->", "_csvEnclosure", ",", "$", "this", "->", "_csvEscape", ")", ";", "$", "this", "->", "_putData", "(", "$", "this", "->", "_integerKeyPrefix", ".", "$", "counter", ",", "$", "rowData", ")", ";", "$", "counter", "++", ";", "}", "if", "(", "$", "this", "->", "_objectCreation", ")", "{", "return", "$", "this", "->", "_afterAppendDataToNewObject", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
allow to set csv data into object @param string $data @return $this
[ "allow", "to", "set", "csv", "data", "into", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1376-L1399
238,351
bluetree-service/container
src/ContainerObject.php
ContainerObject.toCsv
public function toCsv() { $csv = ''; foreach ($this->toArray() as $csvRow) { if (is_array($csvRow)) { $data = implode($this->_csvDelimiter, $csvRow); } else { $data = $csvRow; } $csv .= $data . $this->_csvLineDelimiter; } return rtrim($csv, $this->_csvLineDelimiter); }
php
public function toCsv() { $csv = ''; foreach ($this->toArray() as $csvRow) { if (is_array($csvRow)) { $data = implode($this->_csvDelimiter, $csvRow); } else { $data = $csvRow; } $csv .= $data . $this->_csvLineDelimiter; } return rtrim($csv, $this->_csvLineDelimiter); }
[ "public", "function", "toCsv", "(", ")", "{", "$", "csv", "=", "''", ";", "foreach", "(", "$", "this", "->", "toArray", "(", ")", "as", "$", "csvRow", ")", "{", "if", "(", "is_array", "(", "$", "csvRow", ")", ")", "{", "$", "data", "=", "implode", "(", "$", "this", "->", "_csvDelimiter", ",", "$", "csvRow", ")", ";", "}", "else", "{", "$", "data", "=", "$", "csvRow", ";", "}", "$", "csv", ".=", "$", "data", ".", "$", "this", "->", "_csvLineDelimiter", ";", "}", "return", "rtrim", "(", "$", "csv", ",", "$", "this", "->", "_csvLineDelimiter", ")", ";", "}" ]
export object as csv data @return string
[ "export", "object", "as", "csv", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1486-L1501
238,352
bluetree-service/container
src/ContainerObject.php
ContainerObject._putData
protected function _putData($key, $data) { $bool = $this->_validateDataKey($key, $data); if (!$bool) { return $this; } $hasData = $this->has($key); if ($this->_setPreparationOn) { $data = $this->_dataPreparation( $key, $data, $this->_dataPreparationCallbacks ); } if (!$hasData || ($hasData && $this->_comparator($this->_DATA[$key], $data, '!==')) ) { $this->_changeData($key, $data, $hasData); } return $this; }
php
protected function _putData($key, $data) { $bool = $this->_validateDataKey($key, $data); if (!$bool) { return $this; } $hasData = $this->has($key); if ($this->_setPreparationOn) { $data = $this->_dataPreparation( $key, $data, $this->_dataPreparationCallbacks ); } if (!$hasData || ($hasData && $this->_comparator($this->_DATA[$key], $data, '!==')) ) { $this->_changeData($key, $data, $hasData); } return $this; }
[ "protected", "function", "_putData", "(", "$", "key", ",", "$", "data", ")", "{", "$", "bool", "=", "$", "this", "->", "_validateDataKey", "(", "$", "key", ",", "$", "data", ")", ";", "if", "(", "!", "$", "bool", ")", "{", "return", "$", "this", ";", "}", "$", "hasData", "=", "$", "this", "->", "has", "(", "$", "key", ")", ";", "if", "(", "$", "this", "->", "_setPreparationOn", ")", "{", "$", "data", "=", "$", "this", "->", "_dataPreparation", "(", "$", "key", ",", "$", "data", ",", "$", "this", "->", "_dataPreparationCallbacks", ")", ";", "}", "if", "(", "!", "$", "hasData", "||", "(", "$", "hasData", "&&", "$", "this", "->", "_comparator", "(", "$", "this", "->", "_DATA", "[", "$", "key", "]", ",", "$", "data", ",", "'!=='", ")", ")", ")", "{", "$", "this", "->", "_changeData", "(", "$", "key", ",", "$", "data", ",", "$", "hasData", ")", ";", "}", "return", "$", "this", ";", "}" ]
check that given data for key is valid and set in object if don't exist or is different @param string $key @param mixed $data @return $this
[ "check", "that", "given", "data", "for", "key", "is", "valid", "and", "set", "in", "object", "if", "don", "t", "exist", "or", "is", "different" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1510-L1533
238,353
bluetree-service/container
src/ContainerObject.php
ContainerObject._validateDataKey
protected function _validateDataKey($key, $data) { $dataOkFlag = true; if (!$this->_validationOn) { return $dataOkFlag; } foreach ($this->_validationRules as $ruleKey => $ruleValue) { if (!preg_match($ruleKey, $key)) { continue; } $bool = $this->_validateData($ruleValue, $key, $data); if (!$bool) { $dataOkFlag = false; } } return $dataOkFlag; }
php
protected function _validateDataKey($key, $data) { $dataOkFlag = true; if (!$this->_validationOn) { return $dataOkFlag; } foreach ($this->_validationRules as $ruleKey => $ruleValue) { if (!preg_match($ruleKey, $key)) { continue; } $bool = $this->_validateData($ruleValue, $key, $data); if (!$bool) { $dataOkFlag = false; } } return $dataOkFlag; }
[ "protected", "function", "_validateDataKey", "(", "$", "key", ",", "$", "data", ")", "{", "$", "dataOkFlag", "=", "true", ";", "if", "(", "!", "$", "this", "->", "_validationOn", ")", "{", "return", "$", "dataOkFlag", ";", "}", "foreach", "(", "$", "this", "->", "_validationRules", "as", "$", "ruleKey", "=>", "$", "ruleValue", ")", "{", "if", "(", "!", "preg_match", "(", "$", "ruleKey", ",", "$", "key", ")", ")", "{", "continue", ";", "}", "$", "bool", "=", "$", "this", "->", "_validateData", "(", "$", "ruleValue", ",", "$", "key", ",", "$", "data", ")", ";", "if", "(", "!", "$", "bool", ")", "{", "$", "dataOkFlag", "=", "false", ";", "}", "}", "return", "$", "dataOkFlag", ";", "}" ]
search validation rule for given key and check data @param string $key @param mixed $data @return bool
[ "search", "validation", "rule", "for", "given", "key", "and", "check", "data" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1569-L1589
238,354
bluetree-service/container
src/ContainerObject.php
ContainerObject._arrayToXml
protected function _arrayToXml($data, Xml $xml, $addCdata, $parent) { foreach ($data as $key => $value) { $key = str_replace(' ', '_', $key); $attributes = []; $data = ''; if (is_object($value)) { try { $data = Serializer::serialize($value); } catch (ExceptionInterface $exception) { $this->_addException($exception); } $value = [ '@attributes' => ['serialized_object' => true], $data ]; } try { $isArray = is_array($value); if ($isArray && array_key_exists('@attributes', $value)) { $attributes = $value['@attributes']; unset ($value['@attributes']); } if ($isArray) { $parent = $this->_convertArrayDataToXml( $value, $addCdata, $xml, $key, $parent, $attributes ); continue; } $element = $this->_appendDataToNode($addCdata, $xml, $key, $value); $parent->appendChild($element); } catch (DOMException $exception) { $this->_addException($exception); } } return $xml; }
php
protected function _arrayToXml($data, Xml $xml, $addCdata, $parent) { foreach ($data as $key => $value) { $key = str_replace(' ', '_', $key); $attributes = []; $data = ''; if (is_object($value)) { try { $data = Serializer::serialize($value); } catch (ExceptionInterface $exception) { $this->_addException($exception); } $value = [ '@attributes' => ['serialized_object' => true], $data ]; } try { $isArray = is_array($value); if ($isArray && array_key_exists('@attributes', $value)) { $attributes = $value['@attributes']; unset ($value['@attributes']); } if ($isArray) { $parent = $this->_convertArrayDataToXml( $value, $addCdata, $xml, $key, $parent, $attributes ); continue; } $element = $this->_appendDataToNode($addCdata, $xml, $key, $value); $parent->appendChild($element); } catch (DOMException $exception) { $this->_addException($exception); } } return $xml; }
[ "protected", "function", "_arrayToXml", "(", "$", "data", ",", "Xml", "$", "xml", ",", "$", "addCdata", ",", "$", "parent", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "str_replace", "(", "' '", ",", "'_'", ",", "$", "key", ")", ";", "$", "attributes", "=", "[", "]", ";", "$", "data", "=", "''", ";", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "try", "{", "$", "data", "=", "Serializer", "::", "serialize", "(", "$", "value", ")", ";", "}", "catch", "(", "ExceptionInterface", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "$", "value", "=", "[", "'@attributes'", "=>", "[", "'serialized_object'", "=>", "true", "]", ",", "$", "data", "]", ";", "}", "try", "{", "$", "isArray", "=", "is_array", "(", "$", "value", ")", ";", "if", "(", "$", "isArray", "&&", "array_key_exists", "(", "'@attributes'", ",", "$", "value", ")", ")", "{", "$", "attributes", "=", "$", "value", "[", "'@attributes'", "]", ";", "unset", "(", "$", "value", "[", "'@attributes'", "]", ")", ";", "}", "if", "(", "$", "isArray", ")", "{", "$", "parent", "=", "$", "this", "->", "_convertArrayDataToXml", "(", "$", "value", ",", "$", "addCdata", ",", "$", "xml", ",", "$", "key", ",", "$", "parent", ",", "$", "attributes", ")", ";", "continue", ";", "}", "$", "element", "=", "$", "this", "->", "_appendDataToNode", "(", "$", "addCdata", ",", "$", "xml", ",", "$", "key", ",", "$", "value", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "element", ")", ";", "}", "catch", "(", "DOMException", "$", "exception", ")", "{", "$", "this", "->", "_addException", "(", "$", "exception", ")", ";", "}", "}", "return", "$", "xml", ";", "}" ]
recursive method to create structure xml structure of object DATA @param $data @param Xml $xml @param boolean $addCdata @param Xml|DOMElement $parent @return Xml
[ "recursive", "method", "to", "create", "structure", "xml", "structure", "of", "object", "DATA" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1654-L1703
238,355
bluetree-service/container
src/ContainerObject.php
ContainerObject._convertArrayDataToXml
protected function _convertArrayDataToXml( $value, $addCdata, Xml $xml, $key, $parent, array $attributes ) { $count = count($value) === 1; $isNotEmpty = !empty($attributes); $exist = array_key_exists(0, $value); if ($count && $isNotEmpty && $exist) { $children = $this->_appendDataToNode( $addCdata, $xml, $key, $value[0] ); } else { $children = $xml->createElement( $this->_integerToStringKey($key) ); $this->_arrayToXml($value, $xml, $addCdata, $children); } $parent->appendChild($children); foreach ($attributes as $attributeKey => $attributeValue) { $children->setAttribute($attributeKey, $attributeValue); } return $parent; }
php
protected function _convertArrayDataToXml( $value, $addCdata, Xml $xml, $key, $parent, array $attributes ) { $count = count($value) === 1; $isNotEmpty = !empty($attributes); $exist = array_key_exists(0, $value); if ($count && $isNotEmpty && $exist) { $children = $this->_appendDataToNode( $addCdata, $xml, $key, $value[0] ); } else { $children = $xml->createElement( $this->_integerToStringKey($key) ); $this->_arrayToXml($value, $xml, $addCdata, $children); } $parent->appendChild($children); foreach ($attributes as $attributeKey => $attributeValue) { $children->setAttribute($attributeKey, $attributeValue); } return $parent; }
[ "protected", "function", "_convertArrayDataToXml", "(", "$", "value", ",", "$", "addCdata", ",", "Xml", "$", "xml", ",", "$", "key", ",", "$", "parent", ",", "array", "$", "attributes", ")", "{", "$", "count", "=", "count", "(", "$", "value", ")", "===", "1", ";", "$", "isNotEmpty", "=", "!", "empty", "(", "$", "attributes", ")", ";", "$", "exist", "=", "array_key_exists", "(", "0", ",", "$", "value", ")", ";", "if", "(", "$", "count", "&&", "$", "isNotEmpty", "&&", "$", "exist", ")", "{", "$", "children", "=", "$", "this", "->", "_appendDataToNode", "(", "$", "addCdata", ",", "$", "xml", ",", "$", "key", ",", "$", "value", "[", "0", "]", ")", ";", "}", "else", "{", "$", "children", "=", "$", "xml", "->", "createElement", "(", "$", "this", "->", "_integerToStringKey", "(", "$", "key", ")", ")", ";", "$", "this", "->", "_arrayToXml", "(", "$", "value", ",", "$", "xml", ",", "$", "addCdata", ",", "$", "children", ")", ";", "}", "$", "parent", "->", "appendChild", "(", "$", "children", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attributeKey", "=>", "$", "attributeValue", ")", "{", "$", "children", "->", "setAttribute", "(", "$", "attributeKey", ",", "$", "attributeValue", ")", ";", "}", "return", "$", "parent", ";", "}" ]
convert array DATA value to xml format and return as xml object @param array|string $value @param string $addCdata @param Xml $xml @param string|integer $key @param DOMElement $parent @param array $attributes @return DOMElement
[ "convert", "array", "DATA", "value", "to", "xml", "format", "and", "return", "as", "xml", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1716-L1748
238,356
bluetree-service/container
src/ContainerObject.php
ContainerObject._appendDataToNode
protected function _appendDataToNode($addCdata, Xml $xml, $key, $value) { if ($addCdata) { $cdata = $xml->createCDATASection($value); $element = $xml->createElement( $this->_integerToStringKey($key) ); $element->appendChild($cdata); } else { $element = $xml->createElement( $this->_integerToStringKey($key), $value ); } return $element; }
php
protected function _appendDataToNode($addCdata, Xml $xml, $key, $value) { if ($addCdata) { $cdata = $xml->createCDATASection($value); $element = $xml->createElement( $this->_integerToStringKey($key) ); $element->appendChild($cdata); } else { $element = $xml->createElement( $this->_integerToStringKey($key), $value ); } return $element; }
[ "protected", "function", "_appendDataToNode", "(", "$", "addCdata", ",", "Xml", "$", "xml", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "addCdata", ")", "{", "$", "cdata", "=", "$", "xml", "->", "createCDATASection", "(", "$", "value", ")", ";", "$", "element", "=", "$", "xml", "->", "createElement", "(", "$", "this", "->", "_integerToStringKey", "(", "$", "key", ")", ")", ";", "$", "element", "->", "appendChild", "(", "$", "cdata", ")", ";", "}", "else", "{", "$", "element", "=", "$", "xml", "->", "createElement", "(", "$", "this", "->", "_integerToStringKey", "(", "$", "key", ")", ",", "$", "value", ")", ";", "}", "return", "$", "element", ";", "}" ]
append data to node @param string $addCdata @param Xml $xml @param string|integer $key @param string $value @return DOMElement
[ "append", "data", "to", "node" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1758-L1774
238,357
bluetree-service/container
src/ContainerObject.php
ContainerObject._genericPut
protected function _genericPut($key, $value, $type) { $listName = $this->_getCorrectList($type); if (is_array($key)) { $this->$listName = array_merge($this->$listName, $key); } else { $list = &$this->$listName; $list[$key] = $value; } return $this; }
php
protected function _genericPut($key, $value, $type) { $listName = $this->_getCorrectList($type); if (is_array($key)) { $this->$listName = array_merge($this->$listName, $key); } else { $list = &$this->$listName; $list[$key] = $value; } return $this; }
[ "protected", "function", "_genericPut", "(", "$", "key", ",", "$", "value", ",", "$", "type", ")", "{", "$", "listName", "=", "$", "this", "->", "_getCorrectList", "(", "$", "type", ")", ";", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "$", "listName", "=", "array_merge", "(", "$", "this", "->", "$", "listName", ",", "$", "key", ")", ";", "}", "else", "{", "$", "list", "=", "&", "$", "this", "->", "$", "listName", ";", "$", "list", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
common put data method for class data lists @param string|array $key @param mixed $value @param string $type @return $this
[ "common", "put", "data", "method", "for", "class", "data", "lists" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1849-L1861
238,358
bluetree-service/container
src/ContainerObject.php
ContainerObject._genericDestroy
protected function _genericDestroy($key, $type) { $listName = $this->_getCorrectList($type); if ($key) { $list = &$this->$listName; unset ($list[$key]); } $this->$listName = []; return $this; }
php
protected function _genericDestroy($key, $type) { $listName = $this->_getCorrectList($type); if ($key) { $list = &$this->$listName; unset ($list[$key]); } $this->$listName = []; return $this; }
[ "protected", "function", "_genericDestroy", "(", "$", "key", ",", "$", "type", ")", "{", "$", "listName", "=", "$", "this", "->", "_getCorrectList", "(", "$", "type", ")", ";", "if", "(", "$", "key", ")", "{", "$", "list", "=", "&", "$", "this", "->", "$", "listName", ";", "unset", "(", "$", "list", "[", "$", "key", "]", ")", ";", "}", "$", "this", "->", "$", "listName", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
common destroy data method for class data lists @param string $key @param string $type @return $this
[ "common", "destroy", "data", "method", "for", "class", "data", "lists" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1870-L1881
238,359
bluetree-service/container
src/ContainerObject.php
ContainerObject._genericReturn
protected function _genericReturn($key, $type) { $listName = $this->_getCorrectList($type); switch (true) { case !$key: return $this->$listName; case array_key_exists($key, $this->$listName): $list = &$this->$listName; return $list[$key]; default: return null; } }
php
protected function _genericReturn($key, $type) { $listName = $this->_getCorrectList($type); switch (true) { case !$key: return $this->$listName; case array_key_exists($key, $this->$listName): $list = &$this->$listName; return $list[$key]; default: return null; } }
[ "protected", "function", "_genericReturn", "(", "$", "key", ",", "$", "type", ")", "{", "$", "listName", "=", "$", "this", "->", "_getCorrectList", "(", "$", "type", ")", ";", "switch", "(", "true", ")", "{", "case", "!", "$", "key", ":", "return", "$", "this", "->", "$", "listName", ";", "case", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "$", "listName", ")", ":", "$", "list", "=", "&", "$", "this", "->", "$", "listName", ";", "return", "$", "list", "[", "$", "key", "]", ";", "default", ":", "return", "null", ";", "}", "}" ]
common return data method for class data lists @param string $key @param string $type @return mixed|null
[ "common", "return", "data", "method", "for", "class", "data", "lists" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1890-L1905
238,360
bluetree-service/container
src/ContainerObject.php
ContainerObject._dataPreparation
protected function _dataPreparation($key, $data, array $rulesList) { foreach ($rulesList as $ruleKey => $function) { switch (true) { case is_null($key): $data = $this->_prepareWholeData($ruleKey, $data, $function); break; case preg_match($ruleKey, $key) && !is_null($key): $data = $this->_callUserFunction($function, $key, $data, null); break; default: break; } } return $data; }
php
protected function _dataPreparation($key, $data, array $rulesList) { foreach ($rulesList as $ruleKey => $function) { switch (true) { case is_null($key): $data = $this->_prepareWholeData($ruleKey, $data, $function); break; case preg_match($ruleKey, $key) && !is_null($key): $data = $this->_callUserFunction($function, $key, $data, null); break; default: break; } } return $data; }
[ "protected", "function", "_dataPreparation", "(", "$", "key", ",", "$", "data", ",", "array", "$", "rulesList", ")", "{", "foreach", "(", "$", "rulesList", "as", "$", "ruleKey", "=>", "$", "function", ")", "{", "switch", "(", "true", ")", "{", "case", "is_null", "(", "$", "key", ")", ":", "$", "data", "=", "$", "this", "->", "_prepareWholeData", "(", "$", "ruleKey", ",", "$", "data", ",", "$", "function", ")", ";", "break", ";", "case", "preg_match", "(", "$", "ruleKey", ",", "$", "key", ")", "&&", "!", "is_null", "(", "$", "key", ")", ":", "$", "data", "=", "$", "this", "->", "_callUserFunction", "(", "$", "function", ",", "$", "key", ",", "$", "data", ",", "null", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "return", "$", "data", ";", "}" ]
return data formatted by given function @param string $key @param mixed $data @param array $rulesList @return mixed
[ "return", "data", "formatted", "by", "given", "function" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1944-L1963
238,361
bluetree-service/container
src/ContainerObject.php
ContainerObject._prepareWholeData
protected function _prepareWholeData($ruleKey, array $data, $function) { foreach ($data as $key => $value) { if (preg_match($ruleKey, $key)) { $data[$key] = $this->_callUserFunction($function, $key, $value, null); } } return $data; }
php
protected function _prepareWholeData($ruleKey, array $data, $function) { foreach ($data as $key => $value) { if (preg_match($ruleKey, $key)) { $data[$key] = $this->_callUserFunction($function, $key, $value, null); } } return $data; }
[ "protected", "function", "_prepareWholeData", "(", "$", "ruleKey", ",", "array", "$", "data", ",", "$", "function", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "preg_match", "(", "$", "ruleKey", ",", "$", "key", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_callUserFunction", "(", "$", "function", ",", "$", "key", ",", "$", "value", ",", "null", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
allow to use return preparation on all data in object @param string $ruleKey @param array $data @param array|string|\Closure $function @return array
[ "allow", "to", "use", "return", "preparation", "on", "all", "data", "in", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L1973-L1982
238,362
bluetree-service/container
src/ContainerObject.php
ContainerObject.offsetSet
public function offsetSet($offset, $value) { if (is_null($offset)) { $offset = $this->_integerToStringKey($this->_integerKeysCounter++); } $this->_putData($offset, $value); return $this; }
php
public function offsetSet($offset, $value) { if (is_null($offset)) { $offset = $this->_integerToStringKey($this->_integerKeysCounter++); } $this->_putData($offset, $value); return $this; }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "offset", ")", ")", "{", "$", "offset", "=", "$", "this", "->", "_integerToStringKey", "(", "$", "this", "->", "_integerKeysCounter", "++", ")", ";", "}", "$", "this", "->", "_putData", "(", "$", "offset", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
set data for given key @param string|null $offset @param mixed $value @return $this
[ "set", "data", "for", "given", "key" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L2081-L2089
238,363
bluetree-service/container
src/ContainerObject.php
ContainerObject._addException
protected function _addException(Exception $exception) { $this->_hasErrors = true; $this->_errorsList[$exception->getCode()] = [ 'message' => $exception->getMessage(), 'line' => $exception->getLine(), 'file' => $exception->getFile(), 'trace' => $exception->getTraceAsString(), ]; return $this; }
php
protected function _addException(Exception $exception) { $this->_hasErrors = true; $this->_errorsList[$exception->getCode()] = [ 'message' => $exception->getMessage(), 'line' => $exception->getLine(), 'file' => $exception->getFile(), 'trace' => $exception->getTraceAsString(), ]; return $this; }
[ "protected", "function", "_addException", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "_hasErrors", "=", "true", ";", "$", "this", "->", "_errorsList", "[", "$", "exception", "->", "getCode", "(", ")", "]", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'trace'", "=>", "$", "exception", "->", "getTraceAsString", "(", ")", ",", "]", ";", "return", "$", "this", ";", "}" ]
create exception message and set it in object @param Exception $exception @return $this
[ "create", "exception", "message", "and", "set", "it", "in", "object" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L2229-L2240
238,364
allinora/allinora-simple-framework
src/Controller.php
Controller.setTemplateFile
function setTemplateFile($file){ $this->_template->setTemplateFile(ROOT . DS . 'application' . DS . 'views' . DS . $file); }
php
function setTemplateFile($file){ $this->_template->setTemplateFile(ROOT . DS . 'application' . DS . 'views' . DS . $file); }
[ "function", "setTemplateFile", "(", "$", "file", ")", "{", "$", "this", "->", "_template", "->", "setTemplateFile", "(", "ROOT", ".", "DS", ".", "'application'", ".", "DS", ".", "'views'", ".", "DS", ".", "$", "file", ")", ";", "}" ]
Override the default template
[ "Override", "the", "default", "template" ]
005b41766e64412f1420b27e1d6ccb07aa722a6a
https://github.com/allinora/allinora-simple-framework/blob/005b41766e64412f1420b27e1d6ccb07aa722a6a/src/Controller.php#L144-L147
238,365
uthando-cms/uthando-common
src/UthandoCommon/View/ConfigTrait.php
ConfigTrait.getConfig
protected function getConfig($key = null) { if ($this->config === null) { $this->setConfig(); } if (null === $key) { return $this->config; } if (!array_key_exists($key, $this->config)) { throw new InvalidArgumentException("key: '" . $key . "' is not set in configuration options."); } return $this->config[$key]; }
php
protected function getConfig($key = null) { if ($this->config === null) { $this->setConfig(); } if (null === $key) { return $this->config; } if (!array_key_exists($key, $this->config)) { throw new InvalidArgumentException("key: '" . $key . "' is not set in configuration options."); } return $this->config[$key]; }
[ "protected", "function", "getConfig", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "this", "->", "config", "===", "null", ")", "{", "$", "this", "->", "setConfig", "(", ")", ";", "}", "if", "(", "null", "===", "$", "key", ")", "{", "return", "$", "this", "->", "config", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "config", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"key: '\"", ".", "$", "key", ".", "\"' is not set in configuration options.\"", ")", ";", "}", "return", "$", "this", "->", "config", "[", "$", "key", "]", ";", "}" ]
Gets the config options as an array, if a key is supplied then that keys options is returned. @param string $key @return array|null @throws array|InvalidArgumentException
[ "Gets", "the", "config", "options", "as", "an", "array", "if", "a", "key", "is", "supplied", "then", "that", "keys", "options", "is", "returned", "." ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/View/ConfigTrait.php#L40-L55
238,366
marando/phpSOFA
src/Marando/IAU/iauAper13.php
iauAper13.Aper13
public static function Aper13($ut11, $ut12, iauASTROM &$astrom) { IAU::Aper(IAU::Era00($ut11, $ut12), $astrom); /* Finished. */ }
php
public static function Aper13($ut11, $ut12, iauASTROM &$astrom) { IAU::Aper(IAU::Era00($ut11, $ut12), $astrom); /* Finished. */ }
[ "public", "static", "function", "Aper13", "(", "$", "ut11", ",", "$", "ut12", ",", "iauASTROM", "&", "$", "astrom", ")", "{", "IAU", "::", "Aper", "(", "IAU", "::", "Era00", "(", "$", "ut11", ",", "$", "ut12", ")", ",", "$", "astrom", ")", ";", "/* Finished. */", "}" ]
- - - - - - - - - - i a u A p e r 1 3 - - - - - - - - - - In the star-independent astrometry parameters, update only the Earth rotation angle. The caller provides UT1, (n.b. not UTC). This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: ut11 double UT1 as a 2-part... ut12 double ...Julian Date (Note 1) astrom iauASTROM* star-independent astrometry parameters: pmt double not used eb double[3] not used eh double[3] not used em double not used v double[3] not used bm1 double not used bpn double[3][3] not used along double longitude + s' (radians) xpl double not used ypl double not used sphi double not used cphi double not used diurab double not used eral double not used refa double not used refb double not used Returned: astrom iauASTROM* star-independent astrometry parameters: pmt double unchanged eb double[3] unchanged eh double[3] unchanged em double unchanged v double[3] unchanged bm1 double unchanged bpn double[3][3] unchanged along double unchanged xpl double unchanged ypl double unchanged sphi double unchanged cphi double unchanged diurab double unchanged eral double "local" Earth rotation angle (radians) refa double unchanged refb double unchanged Notes: 1) The UT1 date (n.b. not UTC) ut11+ut12 is a Julian Date, apportioned in any convenient way between the arguments ut11 and ut12. For example, JD(UT1)=2450123.7 could be expressed in any of these ways, among others: ut11 ut12 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 and MJD methods are good compromises between resolution and convenience. The date & time method is best matched to the algorithm used: maximum precision is delivered when the ut11 argument is for 0hrs UT1 on the day in question and the ut12 argument lies in the range 0 to 1, or vice versa. 2) If the caller wishes to provide the Earth rotation angle itself, the function iauAper can be used instead. One use of this technique is to substitute Greenwich apparent sidereal time and thereby to support equinox based transformations directly. 3) This is one of several functions that inserts into the astrom structure star-independent parameters needed for the chain of astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed. The various functions support different classes of observer and portions of the transformation chain: functions observer transformation iauApcg iauApcg13 geocentric ICRS <-> GCRS iauApci iauApci13 terrestrial ICRS <-> CIRS iauApco iauApco13 terrestrial ICRS <-> observed iauApcs iauApcs13 space ICRS <-> GCRS iauAper iauAper13 terrestrial update Earth rotation iauApio iauApio13 terrestrial CIRS <-> observed Those with names ending in "13" use contemporary SOFA models to compute the various ephemerides. The others accept ephemerides supplied by the caller. The transformation from ICRS to GCRS covers space motion, parallax, light deflection, and aberration. From GCRS to CIRS comprises frame bias and precession-nutation. From CIRS to observed takes account of Earth rotation, polar motion, diurnal aberration and parallax (unless subsumed into the ICRS <-> GCRS transformation), and atmospheric refraction. Called: iauAper astrometry parameters: update ERA iauEra00 Earth rotation angle, IAU 2000 This revision: 2013 September 25 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "p", "e", "r", "1", "3", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAper13.php#L125-L129
238,367
FuturaSoft/Pabana
src/Routing/Router.php
Router.autoResolve
private static function autoResolve($arsUrlValueList) { $sController = 'Index'; $sAction = 'index'; $arsParamList = array(); foreach ($arsUrlValueList as $nIndexValue => $sUrlValue) { if ($nIndexValue == 0) { $sController = $sUrlValue; } elseif ($nIndexValue == 1) { $sAction = $sUrlValue; } else { if (isset($arsUrlValueList[$nIndexValue]) && $nIndexValue % 2 == 0) { $sParamName = $arsUrlValueList[$nIndexValue]; $sParamValue = null; if (isset($arsUrlValueList[$nIndexValue + 1])) { $sParamValue = $arsUrlValueList[$nIndexValue + 1]; } $arsParamList[$sParamName] = $sParamValue; } } } // Set controller self::setController($sController); // Set action to route action self::setAction($sAction); // Set param list self::setParameter($arsParamList); }
php
private static function autoResolve($arsUrlValueList) { $sController = 'Index'; $sAction = 'index'; $arsParamList = array(); foreach ($arsUrlValueList as $nIndexValue => $sUrlValue) { if ($nIndexValue == 0) { $sController = $sUrlValue; } elseif ($nIndexValue == 1) { $sAction = $sUrlValue; } else { if (isset($arsUrlValueList[$nIndexValue]) && $nIndexValue % 2 == 0) { $sParamName = $arsUrlValueList[$nIndexValue]; $sParamValue = null; if (isset($arsUrlValueList[$nIndexValue + 1])) { $sParamValue = $arsUrlValueList[$nIndexValue + 1]; } $arsParamList[$sParamName] = $sParamValue; } } } // Set controller self::setController($sController); // Set action to route action self::setAction($sAction); // Set param list self::setParameter($arsParamList); }
[ "private", "static", "function", "autoResolve", "(", "$", "arsUrlValueList", ")", "{", "$", "sController", "=", "'Index'", ";", "$", "sAction", "=", "'index'", ";", "$", "arsParamList", "=", "array", "(", ")", ";", "foreach", "(", "$", "arsUrlValueList", "as", "$", "nIndexValue", "=>", "$", "sUrlValue", ")", "{", "if", "(", "$", "nIndexValue", "==", "0", ")", "{", "$", "sController", "=", "$", "sUrlValue", ";", "}", "elseif", "(", "$", "nIndexValue", "==", "1", ")", "{", "$", "sAction", "=", "$", "sUrlValue", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "arsUrlValueList", "[", "$", "nIndexValue", "]", ")", "&&", "$", "nIndexValue", "%", "2", "==", "0", ")", "{", "$", "sParamName", "=", "$", "arsUrlValueList", "[", "$", "nIndexValue", "]", ";", "$", "sParamValue", "=", "null", ";", "if", "(", "isset", "(", "$", "arsUrlValueList", "[", "$", "nIndexValue", "+", "1", "]", ")", ")", "{", "$", "sParamValue", "=", "$", "arsUrlValueList", "[", "$", "nIndexValue", "+", "1", "]", ";", "}", "$", "arsParamList", "[", "$", "sParamName", "]", "=", "$", "sParamValue", ";", "}", "}", "}", "// Set controller", "self", "::", "setController", "(", "$", "sController", ")", ";", "// Set action to route action", "self", "::", "setAction", "(", "$", "sAction", ")", ";", "// Set param list", "self", "::", "setParameter", "(", "$", "arsParamList", ")", ";", "}" ]
Auto resolve a Route from URL by separator @since 1.0 @param string $arsUrlValueList Liste of url part. @return void
[ "Auto", "resolve", "a", "Route", "from", "URL", "by", "separator" ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L54-L81
238,368
FuturaSoft/Pabana
src/Routing/Router.php
Router.checkRoute
private static function checkRoute($arcUrlSeparator, $arsUrlValue) { $aroRouteList = RouteCollection::getAll(); if (empty($aroRouteList)) { return false; } foreach ($aroRouteList as $oRoute) { // Get route $sRoute = $oRoute->getRoute(); // Remove last char of route if it's a separator $sRoute = self::removeLastSeparator($sRoute); // Get list of separator for this route $arcRouteSeparator = self::listSeparator($sRoute); // If URL and route have same number of separator in same position if ($arcUrlSeparator == $arcRouteSeparator) { // Get list of value of this route $arsRouteValueList = self::listValue($sRoute); // Valid boolean $bGoodRoute = true; // Array to store param $arsParamList = array(); // Check each value of url to compare with route foreach ($arsRouteValueList as $nParamIndex => $sRouteValue) { if (isset($arsUrlValue[$nParamIndex])) { // Get first char of $cFirstCharValue = substr($sRouteValue, 0, 1); if ($cFirstCharValue == ':') { $arsParamList[substr($sRouteValue, 1)] = $arsUrlValue[$nParamIndex]; } elseif ($sRouteValue != $arsUrlValue[$nParamIndex] && $cFirstCharValue != '*') { $bGoodRoute = false; } } else { $bGoodRoute = false; } } // If valid boolean is true if ($bGoodRoute) { // Set controller to route controller self::setController($oRoute->getController()); // Set action to route action self::setAction($oRoute->getAction()); // Add route param to param list if (is_array($oRoute->getParamList())) { $arsParamList = $arsParamList + $oRoute->getParamList(); } // Set param list self::setParameter($arsParamList); // End of check route return true; } } } // No route is found return false; }
php
private static function checkRoute($arcUrlSeparator, $arsUrlValue) { $aroRouteList = RouteCollection::getAll(); if (empty($aroRouteList)) { return false; } foreach ($aroRouteList as $oRoute) { // Get route $sRoute = $oRoute->getRoute(); // Remove last char of route if it's a separator $sRoute = self::removeLastSeparator($sRoute); // Get list of separator for this route $arcRouteSeparator = self::listSeparator($sRoute); // If URL and route have same number of separator in same position if ($arcUrlSeparator == $arcRouteSeparator) { // Get list of value of this route $arsRouteValueList = self::listValue($sRoute); // Valid boolean $bGoodRoute = true; // Array to store param $arsParamList = array(); // Check each value of url to compare with route foreach ($arsRouteValueList as $nParamIndex => $sRouteValue) { if (isset($arsUrlValue[$nParamIndex])) { // Get first char of $cFirstCharValue = substr($sRouteValue, 0, 1); if ($cFirstCharValue == ':') { $arsParamList[substr($sRouteValue, 1)] = $arsUrlValue[$nParamIndex]; } elseif ($sRouteValue != $arsUrlValue[$nParamIndex] && $cFirstCharValue != '*') { $bGoodRoute = false; } } else { $bGoodRoute = false; } } // If valid boolean is true if ($bGoodRoute) { // Set controller to route controller self::setController($oRoute->getController()); // Set action to route action self::setAction($oRoute->getAction()); // Add route param to param list if (is_array($oRoute->getParamList())) { $arsParamList = $arsParamList + $oRoute->getParamList(); } // Set param list self::setParameter($arsParamList); // End of check route return true; } } } // No route is found return false; }
[ "private", "static", "function", "checkRoute", "(", "$", "arcUrlSeparator", ",", "$", "arsUrlValue", ")", "{", "$", "aroRouteList", "=", "RouteCollection", "::", "getAll", "(", ")", ";", "if", "(", "empty", "(", "$", "aroRouteList", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "aroRouteList", "as", "$", "oRoute", ")", "{", "// Get route", "$", "sRoute", "=", "$", "oRoute", "->", "getRoute", "(", ")", ";", "// Remove last char of route if it's a separator", "$", "sRoute", "=", "self", "::", "removeLastSeparator", "(", "$", "sRoute", ")", ";", "// Get list of separator for this route", "$", "arcRouteSeparator", "=", "self", "::", "listSeparator", "(", "$", "sRoute", ")", ";", "// If URL and route have same number of separator in same position", "if", "(", "$", "arcUrlSeparator", "==", "$", "arcRouteSeparator", ")", "{", "// Get list of value of this route", "$", "arsRouteValueList", "=", "self", "::", "listValue", "(", "$", "sRoute", ")", ";", "// Valid boolean", "$", "bGoodRoute", "=", "true", ";", "// Array to store param", "$", "arsParamList", "=", "array", "(", ")", ";", "// Check each value of url to compare with route", "foreach", "(", "$", "arsRouteValueList", "as", "$", "nParamIndex", "=>", "$", "sRouteValue", ")", "{", "if", "(", "isset", "(", "$", "arsUrlValue", "[", "$", "nParamIndex", "]", ")", ")", "{", "// Get first char of", "$", "cFirstCharValue", "=", "substr", "(", "$", "sRouteValue", ",", "0", ",", "1", ")", ";", "if", "(", "$", "cFirstCharValue", "==", "':'", ")", "{", "$", "arsParamList", "[", "substr", "(", "$", "sRouteValue", ",", "1", ")", "]", "=", "$", "arsUrlValue", "[", "$", "nParamIndex", "]", ";", "}", "elseif", "(", "$", "sRouteValue", "!=", "$", "arsUrlValue", "[", "$", "nParamIndex", "]", "&&", "$", "cFirstCharValue", "!=", "'*'", ")", "{", "$", "bGoodRoute", "=", "false", ";", "}", "}", "else", "{", "$", "bGoodRoute", "=", "false", ";", "}", "}", "// If valid boolean is true", "if", "(", "$", "bGoodRoute", ")", "{", "// Set controller to route controller", "self", "::", "setController", "(", "$", "oRoute", "->", "getController", "(", ")", ")", ";", "// Set action to route action", "self", "::", "setAction", "(", "$", "oRoute", "->", "getAction", "(", ")", ")", ";", "// Add route param to param list", "if", "(", "is_array", "(", "$", "oRoute", "->", "getParamList", "(", ")", ")", ")", "{", "$", "arsParamList", "=", "$", "arsParamList", "+", "$", "oRoute", "->", "getParamList", "(", ")", ";", "}", "// Set param list", "self", "::", "setParameter", "(", "$", "arsParamList", ")", ";", "// End of check route", "return", "true", ";", "}", "}", "}", "// No route is found", "return", "false", ";", "}" ]
Check if Route exist in RouterCollection who can match to current url @since 1.0 @param array $arcUrlSeparator List of separator of URL. @param array $arsUrlValue List of part of URL. @return bool True if Route match, else false
[ "Check", "if", "Route", "exist", "in", "RouterCollection", "who", "can", "match", "to", "current", "url" ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L91-L145
238,369
FuturaSoft/Pabana
src/Routing/Router.php
Router.checkController
private static function checkController() { $bSetFallback = false; $sControllerNamespace = Configuration::read('application.namespace') . '\Controller\\' . self::getController(); if (class_exists($sControllerNamespace) === false) { $bSetFallback = true; } if (method_exists($sControllerNamespace, self::getAction()) === false) { $bSetFallback = true; } if ($bSetFallback === true) { // Set controller $sFallbackController = RouteCollection::getFallbackController(); self::setController($sFallbackController); // Set action to route action $sFallbackAction = RouteCollection::getFallbackAction(); self::setAction($sFallbackAction); // Set action to route action $arsFallbackParameter = array('code' => 404); self::setParameter($arsFallbackParameter); } }
php
private static function checkController() { $bSetFallback = false; $sControllerNamespace = Configuration::read('application.namespace') . '\Controller\\' . self::getController(); if (class_exists($sControllerNamespace) === false) { $bSetFallback = true; } if (method_exists($sControllerNamespace, self::getAction()) === false) { $bSetFallback = true; } if ($bSetFallback === true) { // Set controller $sFallbackController = RouteCollection::getFallbackController(); self::setController($sFallbackController); // Set action to route action $sFallbackAction = RouteCollection::getFallbackAction(); self::setAction($sFallbackAction); // Set action to route action $arsFallbackParameter = array('code' => 404); self::setParameter($arsFallbackParameter); } }
[ "private", "static", "function", "checkController", "(", ")", "{", "$", "bSetFallback", "=", "false", ";", "$", "sControllerNamespace", "=", "Configuration", "::", "read", "(", "'application.namespace'", ")", ".", "'\\Controller\\\\'", ".", "self", "::", "getController", "(", ")", ";", "if", "(", "class_exists", "(", "$", "sControllerNamespace", ")", "===", "false", ")", "{", "$", "bSetFallback", "=", "true", ";", "}", "if", "(", "method_exists", "(", "$", "sControllerNamespace", ",", "self", "::", "getAction", "(", ")", ")", "===", "false", ")", "{", "$", "bSetFallback", "=", "true", ";", "}", "if", "(", "$", "bSetFallback", "===", "true", ")", "{", "// Set controller", "$", "sFallbackController", "=", "RouteCollection", "::", "getFallbackController", "(", ")", ";", "self", "::", "setController", "(", "$", "sFallbackController", ")", ";", "// Set action to route action", "$", "sFallbackAction", "=", "RouteCollection", "::", "getFallbackAction", "(", ")", ";", "self", "::", "setAction", "(", "$", "sFallbackAction", ")", ";", "// Set action to route action", "$", "arsFallbackParameter", "=", "array", "(", "'code'", "=>", "404", ")", ";", "self", "::", "setParameter", "(", "$", "arsFallbackParameter", ")", ";", "}", "}" ]
Check if controller and action exist, else change to fallback controller and action @since 1.0 @return void
[ "Check", "if", "controller", "and", "action", "exist", "else", "change", "to", "fallback", "controller", "and", "action" ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L153-L174
238,370
FuturaSoft/Pabana
src/Routing/Router.php
Router.listSeparator
private static function listSeparator($sUrl) { $armSeparatorPosition = array(); foreach (RouteCollection::getSeparator() as $cSeparator) { $sUrlSearch = $sUrl; while ($nSeparatorPosition = strrpos($sUrlSearch, $cSeparator)) { $armSeparatorPosition[$nSeparatorPosition] = $cSeparator; $sUrlSearch = substr($sUrlSearch, 0, $nSeparatorPosition); } } ksort($armSeparatorPosition); return array_values($armSeparatorPosition); }
php
private static function listSeparator($sUrl) { $armSeparatorPosition = array(); foreach (RouteCollection::getSeparator() as $cSeparator) { $sUrlSearch = $sUrl; while ($nSeparatorPosition = strrpos($sUrlSearch, $cSeparator)) { $armSeparatorPosition[$nSeparatorPosition] = $cSeparator; $sUrlSearch = substr($sUrlSearch, 0, $nSeparatorPosition); } } ksort($armSeparatorPosition); return array_values($armSeparatorPosition); }
[ "private", "static", "function", "listSeparator", "(", "$", "sUrl", ")", "{", "$", "armSeparatorPosition", "=", "array", "(", ")", ";", "foreach", "(", "RouteCollection", "::", "getSeparator", "(", ")", "as", "$", "cSeparator", ")", "{", "$", "sUrlSearch", "=", "$", "sUrl", ";", "while", "(", "$", "nSeparatorPosition", "=", "strrpos", "(", "$", "sUrlSearch", ",", "$", "cSeparator", ")", ")", "{", "$", "armSeparatorPosition", "[", "$", "nSeparatorPosition", "]", "=", "$", "cSeparator", ";", "$", "sUrlSearch", "=", "substr", "(", "$", "sUrlSearch", ",", "0", ",", "$", "nSeparatorPosition", ")", ";", "}", "}", "ksort", "(", "$", "armSeparatorPosition", ")", ";", "return", "array_values", "(", "$", "armSeparatorPosition", ")", ";", "}" ]
List of separator defined in URL. @since 1.0 @param string $sUrl Current URL. @return array List of separator defined in URL.
[ "List", "of", "separator", "defined", "in", "URL", "." ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L216-L228
238,371
FuturaSoft/Pabana
src/Routing/Router.php
Router.listValue
private static function listValue($sUrl) { $sRegexSeparator = implode('', RouteCollection::getSeparator()); $sRegexSeparator = preg_quote($sRegexSeparator); $arsListValue = preg_split("{[" . $sRegexSeparator . "]}", $sUrl); array_shift($arsListValue); return $arsListValue; }
php
private static function listValue($sUrl) { $sRegexSeparator = implode('', RouteCollection::getSeparator()); $sRegexSeparator = preg_quote($sRegexSeparator); $arsListValue = preg_split("{[" . $sRegexSeparator . "]}", $sUrl); array_shift($arsListValue); return $arsListValue; }
[ "private", "static", "function", "listValue", "(", "$", "sUrl", ")", "{", "$", "sRegexSeparator", "=", "implode", "(", "''", ",", "RouteCollection", "::", "getSeparator", "(", ")", ")", ";", "$", "sRegexSeparator", "=", "preg_quote", "(", "$", "sRegexSeparator", ")", ";", "$", "arsListValue", "=", "preg_split", "(", "\"{[\"", ".", "$", "sRegexSeparator", ".", "\"]}\"", ",", "$", "sUrl", ")", ";", "array_shift", "(", "$", "arsListValue", ")", ";", "return", "$", "arsListValue", ";", "}" ]
List of value defined in URL. @since 1.0 @param string $sUrl Current URL. @return array List of value defined in URL.
[ "List", "of", "value", "defined", "in", "URL", "." ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L237-L244
238,372
FuturaSoft/Pabana
src/Routing/Router.php
Router.removeLastSeparator
private static function removeLastSeparator($sUrl) { $cLastChar = substr($sUrl, -1); if (in_array($cLastChar, RouteCollection::getSeparator())) { $sUrl = substr($sUrl, 0, -1); } return $sUrl; }
php
private static function removeLastSeparator($sUrl) { $cLastChar = substr($sUrl, -1); if (in_array($cLastChar, RouteCollection::getSeparator())) { $sUrl = substr($sUrl, 0, -1); } return $sUrl; }
[ "private", "static", "function", "removeLastSeparator", "(", "$", "sUrl", ")", "{", "$", "cLastChar", "=", "substr", "(", "$", "sUrl", ",", "-", "1", ")", ";", "if", "(", "in_array", "(", "$", "cLastChar", ",", "RouteCollection", "::", "getSeparator", "(", ")", ")", ")", "{", "$", "sUrl", "=", "substr", "(", "$", "sUrl", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "sUrl", ";", "}" ]
Remove last separtor in URL. @since 1.0 @param string $sUrl Current URL. @return string $Url without last separator.
[ "Remove", "last", "separtor", "in", "URL", "." ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L253-L260
238,373
FuturaSoft/Pabana
src/Routing/Router.php
Router.resolve
public static function resolve() { // Get current URL $oRequest = new Request(); $sUrl = $oRequest->url(); // Set default separator if (Configuration::check('routing.default_separator') === true) { $cDefaultSeparator = Configuration::read('routing.default_separator'); RouteCollection::setDefaultSeparator($cDefaultSeparator); } // Remove last char of URL if it's a separator $sUrl = self::removeLastSeparator($sUrl); // Get list of separator for this URL $arcUrlSeparator = self::listSeparator($sUrl); // Get list of value of this URL $arsUrlValue = self::listValue($sUrl); // Check route $bCheckResult = self::checkRoute($arcUrlSeparator, $arsUrlValue); if ($bCheckResult === false && Configuration::read('routing.auto') === true) { self::autoResolve($arsUrlValue); } self::checkController(); self::setParameterInGlobal(); }
php
public static function resolve() { // Get current URL $oRequest = new Request(); $sUrl = $oRequest->url(); // Set default separator if (Configuration::check('routing.default_separator') === true) { $cDefaultSeparator = Configuration::read('routing.default_separator'); RouteCollection::setDefaultSeparator($cDefaultSeparator); } // Remove last char of URL if it's a separator $sUrl = self::removeLastSeparator($sUrl); // Get list of separator for this URL $arcUrlSeparator = self::listSeparator($sUrl); // Get list of value of this URL $arsUrlValue = self::listValue($sUrl); // Check route $bCheckResult = self::checkRoute($arcUrlSeparator, $arsUrlValue); if ($bCheckResult === false && Configuration::read('routing.auto') === true) { self::autoResolve($arsUrlValue); } self::checkController(); self::setParameterInGlobal(); }
[ "public", "static", "function", "resolve", "(", ")", "{", "// Get current URL", "$", "oRequest", "=", "new", "Request", "(", ")", ";", "$", "sUrl", "=", "$", "oRequest", "->", "url", "(", ")", ";", "// Set default separator", "if", "(", "Configuration", "::", "check", "(", "'routing.default_separator'", ")", "===", "true", ")", "{", "$", "cDefaultSeparator", "=", "Configuration", "::", "read", "(", "'routing.default_separator'", ")", ";", "RouteCollection", "::", "setDefaultSeparator", "(", "$", "cDefaultSeparator", ")", ";", "}", "// Remove last char of URL if it's a separator", "$", "sUrl", "=", "self", "::", "removeLastSeparator", "(", "$", "sUrl", ")", ";", "// Get list of separator for this URL", "$", "arcUrlSeparator", "=", "self", "::", "listSeparator", "(", "$", "sUrl", ")", ";", "// Get list of value of this URL", "$", "arsUrlValue", "=", "self", "::", "listValue", "(", "$", "sUrl", ")", ";", "// Check route", "$", "bCheckResult", "=", "self", "::", "checkRoute", "(", "$", "arcUrlSeparator", ",", "$", "arsUrlValue", ")", ";", "if", "(", "$", "bCheckResult", "===", "false", "&&", "Configuration", "::", "read", "(", "'routing.auto'", ")", "===", "true", ")", "{", "self", "::", "autoResolve", "(", "$", "arsUrlValue", ")", ";", "}", "self", "::", "checkController", "(", ")", ";", "self", "::", "setParameterInGlobal", "(", ")", ";", "}" ]
Call differnant action in Router to resolve road from URL. @since 1.0 @return void
[ "Call", "differnant", "action", "in", "Router", "to", "resolve", "road", "from", "URL", "." ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Routing/Router.php#L268-L291
238,374
asbsoft/yii2-common_2_170212
web/RoutesInfo.php
RoutesInfo.showRoutes
public static function showRoutes($moduleUid = '', $app = null, $echo = false) { if (empty($app)) { $app = Yii::$app; } $urlMan = $app->urlManager; $result = ''; foreach ($urlMan->rules as $rule) { if (empty($moduleUid)) { $result .= static::showRoute($rule); } else { switch ($rule::className()) { case GroupUrlRule::className(): foreach ($rule->rules as $singleRule) { if (0 === strpos($singleRule->route, $moduleUid)) { $result .= static::showRoute($rule); // will show all rules from group break; } } break; case RestUrlRule::className(): if (is_array($rule->controller)) { $urlPrefix = array_keys($rule->controller)[0]; $controller = $rule->controller[$urlPrefix]; } else { $controller = $rule->controller; } if (0 === strpos($controller, $moduleUid)) { $result .= static::showRoute($rule); } break; default: if (0 === strpos($rule->route, $moduleUid)) { $result .= static::showRoute($rule); } break; } } } if ($echo) { echo $result; } else { return $result; } }
php
public static function showRoutes($moduleUid = '', $app = null, $echo = false) { if (empty($app)) { $app = Yii::$app; } $urlMan = $app->urlManager; $result = ''; foreach ($urlMan->rules as $rule) { if (empty($moduleUid)) { $result .= static::showRoute($rule); } else { switch ($rule::className()) { case GroupUrlRule::className(): foreach ($rule->rules as $singleRule) { if (0 === strpos($singleRule->route, $moduleUid)) { $result .= static::showRoute($rule); // will show all rules from group break; } } break; case RestUrlRule::className(): if (is_array($rule->controller)) { $urlPrefix = array_keys($rule->controller)[0]; $controller = $rule->controller[$urlPrefix]; } else { $controller = $rule->controller; } if (0 === strpos($controller, $moduleUid)) { $result .= static::showRoute($rule); } break; default: if (0 === strpos($rule->route, $moduleUid)) { $result .= static::showRoute($rule); } break; } } } if ($echo) { echo $result; } else { return $result; } }
[ "public", "static", "function", "showRoutes", "(", "$", "moduleUid", "=", "''", ",", "$", "app", "=", "null", ",", "$", "echo", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "app", ")", ")", "{", "$", "app", "=", "Yii", "::", "$", "app", ";", "}", "$", "urlMan", "=", "$", "app", "->", "urlManager", ";", "$", "result", "=", "''", ";", "foreach", "(", "$", "urlMan", "->", "rules", "as", "$", "rule", ")", "{", "if", "(", "empty", "(", "$", "moduleUid", ")", ")", "{", "$", "result", ".=", "static", "::", "showRoute", "(", "$", "rule", ")", ";", "}", "else", "{", "switch", "(", "$", "rule", "::", "className", "(", ")", ")", "{", "case", "GroupUrlRule", "::", "className", "(", ")", ":", "foreach", "(", "$", "rule", "->", "rules", "as", "$", "singleRule", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "singleRule", "->", "route", ",", "$", "moduleUid", ")", ")", "{", "$", "result", ".=", "static", "::", "showRoute", "(", "$", "rule", ")", ";", "// will show all rules from group", "break", ";", "}", "}", "break", ";", "case", "RestUrlRule", "::", "className", "(", ")", ":", "if", "(", "is_array", "(", "$", "rule", "->", "controller", ")", ")", "{", "$", "urlPrefix", "=", "array_keys", "(", "$", "rule", "->", "controller", ")", "[", "0", "]", ";", "$", "controller", "=", "$", "rule", "->", "controller", "[", "$", "urlPrefix", "]", ";", "}", "else", "{", "$", "controller", "=", "$", "rule", "->", "controller", ";", "}", "if", "(", "0", "===", "strpos", "(", "$", "controller", ",", "$", "moduleUid", ")", ")", "{", "$", "result", ".=", "static", "::", "showRoute", "(", "$", "rule", ")", ";", "}", "break", ";", "default", ":", "if", "(", "0", "===", "strpos", "(", "$", "rule", "->", "route", ",", "$", "moduleUid", ")", ")", "{", "$", "result", ".=", "static", "::", "showRoute", "(", "$", "rule", ")", ";", "}", "break", ";", "}", "}", "}", "if", "(", "$", "echo", ")", "{", "echo", "$", "result", ";", "}", "else", "{", "return", "$", "result", ";", "}", "}" ]
Show all application routes. @param string $moduleUid module uniqueId @param Application $app @param boolean $echo if true print resule otherwise return result in string @return string|null
[ "Show", "all", "application", "routes", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/RoutesInfo.php#L24-L68
238,375
asbsoft/yii2-common_2_170212
web/RoutesInfo.php
RoutesInfo.showRoute
public static function showRoute($rule, $echo = false, $showPattern = false) { $result = ''; switch ($rule::className()) { case WebUrlRule::className(): $result .= '' . "'" . htmlspecialchars($rule->name) . "'" . ($showPattern ? " (" . htmlspecialchars($rule->pattern) . ")" : '') . " => '" . htmlspecialchars($rule->route) . "'" . " ({$rule::className()})" . "\n" ; break; case GroupUrlRule::className(): $result .= "'{$rule->prefix}/...' ({$rule::className()}): <br>"; foreach ($rule->rules as $singleRule) { $result .= static::$ruleShift . "'" . htmlspecialchars($singleRule->name) . "'" . ($showPattern ? " (" . htmlspecialchars($singleRule->pattern) . ")" : '') . ' => ' . "'" . htmlspecialchars($singleRule->route) . "'" . "\n" ; } break; case RestUrlRule::className(): if (is_array($rule->controller)) { //foreach ($rule->controller as $urlPrefix => $controller) break; $urlPrefix = array_keys($rule->controller)[0]; $controller = $rule->controller[$urlPrefix]; } else { $controller = $rule->controller; $urlPrefix = ''; } $result .= "'{$rule->prefix}/{$urlPrefix}/...' ({$rule::className()}): <br>"; foreach ($rule->patterns as $template => $action) { $result .= static::$ruleShift . "'" . $rule->prefix . '/' . $urlPrefix . '/' . htmlspecialchars($template) . htmlspecialchars($rule->suffix) . "'" . " => '" . $controller . '/' . htmlspecialchars($action) . "'" . "\n" ; } break; default: $result .= "{$rule::className()}:<br>"; if (method_exists($rule, 'showRouteInfo')) { $info = $rule->showRouteInfo($showPattern); $strings = explode("\n", trim($info)); foreach ($strings as $str) $result .= static::$ruleShift . trim($str) . "\n"; } else { ob_start(); ob_implicit_flush(false); var_dump($rule); $result .= ob_get_clean(); } break; } if ($echo) { echo $result; } else { return $result; } }
php
public static function showRoute($rule, $echo = false, $showPattern = false) { $result = ''; switch ($rule::className()) { case WebUrlRule::className(): $result .= '' . "'" . htmlspecialchars($rule->name) . "'" . ($showPattern ? " (" . htmlspecialchars($rule->pattern) . ")" : '') . " => '" . htmlspecialchars($rule->route) . "'" . " ({$rule::className()})" . "\n" ; break; case GroupUrlRule::className(): $result .= "'{$rule->prefix}/...' ({$rule::className()}): <br>"; foreach ($rule->rules as $singleRule) { $result .= static::$ruleShift . "'" . htmlspecialchars($singleRule->name) . "'" . ($showPattern ? " (" . htmlspecialchars($singleRule->pattern) . ")" : '') . ' => ' . "'" . htmlspecialchars($singleRule->route) . "'" . "\n" ; } break; case RestUrlRule::className(): if (is_array($rule->controller)) { //foreach ($rule->controller as $urlPrefix => $controller) break; $urlPrefix = array_keys($rule->controller)[0]; $controller = $rule->controller[$urlPrefix]; } else { $controller = $rule->controller; $urlPrefix = ''; } $result .= "'{$rule->prefix}/{$urlPrefix}/...' ({$rule::className()}): <br>"; foreach ($rule->patterns as $template => $action) { $result .= static::$ruleShift . "'" . $rule->prefix . '/' . $urlPrefix . '/' . htmlspecialchars($template) . htmlspecialchars($rule->suffix) . "'" . " => '" . $controller . '/' . htmlspecialchars($action) . "'" . "\n" ; } break; default: $result .= "{$rule::className()}:<br>"; if (method_exists($rule, 'showRouteInfo')) { $info = $rule->showRouteInfo($showPattern); $strings = explode("\n", trim($info)); foreach ($strings as $str) $result .= static::$ruleShift . trim($str) . "\n"; } else { ob_start(); ob_implicit_flush(false); var_dump($rule); $result .= ob_get_clean(); } break; } if ($echo) { echo $result; } else { return $result; } }
[ "public", "static", "function", "showRoute", "(", "$", "rule", ",", "$", "echo", "=", "false", ",", "$", "showPattern", "=", "false", ")", "{", "$", "result", "=", "''", ";", "switch", "(", "$", "rule", "::", "className", "(", ")", ")", "{", "case", "WebUrlRule", "::", "className", "(", ")", ":", "$", "result", ".=", "''", ".", "\"'\"", ".", "htmlspecialchars", "(", "$", "rule", "->", "name", ")", ".", "\"'\"", ".", "(", "$", "showPattern", "?", "\" (\"", ".", "htmlspecialchars", "(", "$", "rule", "->", "pattern", ")", ".", "\")\"", ":", "''", ")", ".", "\" => '\"", ".", "htmlspecialchars", "(", "$", "rule", "->", "route", ")", ".", "\"'\"", ".", "\" ({$rule::className()})\"", ".", "\"\\n\"", ";", "break", ";", "case", "GroupUrlRule", "::", "className", "(", ")", ":", "$", "result", ".=", "\"'{$rule->prefix}/...' ({$rule::className()}): <br>\"", ";", "foreach", "(", "$", "rule", "->", "rules", "as", "$", "singleRule", ")", "{", "$", "result", ".=", "static", "::", "$", "ruleShift", ".", "\"'\"", ".", "htmlspecialchars", "(", "$", "singleRule", "->", "name", ")", ".", "\"'\"", ".", "(", "$", "showPattern", "?", "\" (\"", ".", "htmlspecialchars", "(", "$", "singleRule", "->", "pattern", ")", ".", "\")\"", ":", "''", ")", ".", "' => '", ".", "\"'\"", ".", "htmlspecialchars", "(", "$", "singleRule", "->", "route", ")", ".", "\"'\"", ".", "\"\\n\"", ";", "}", "break", ";", "case", "RestUrlRule", "::", "className", "(", ")", ":", "if", "(", "is_array", "(", "$", "rule", "->", "controller", ")", ")", "{", "//foreach ($rule->controller as $urlPrefix => $controller) break;", "$", "urlPrefix", "=", "array_keys", "(", "$", "rule", "->", "controller", ")", "[", "0", "]", ";", "$", "controller", "=", "$", "rule", "->", "controller", "[", "$", "urlPrefix", "]", ";", "}", "else", "{", "$", "controller", "=", "$", "rule", "->", "controller", ";", "$", "urlPrefix", "=", "''", ";", "}", "$", "result", ".=", "\"'{$rule->prefix}/{$urlPrefix}/...' ({$rule::className()}): <br>\"", ";", "foreach", "(", "$", "rule", "->", "patterns", "as", "$", "template", "=>", "$", "action", ")", "{", "$", "result", ".=", "static", "::", "$", "ruleShift", ".", "\"'\"", ".", "$", "rule", "->", "prefix", ".", "'/'", ".", "$", "urlPrefix", ".", "'/'", ".", "htmlspecialchars", "(", "$", "template", ")", ".", "htmlspecialchars", "(", "$", "rule", "->", "suffix", ")", ".", "\"'\"", ".", "\" => '\"", ".", "$", "controller", ".", "'/'", ".", "htmlspecialchars", "(", "$", "action", ")", ".", "\"'\"", ".", "\"\\n\"", ";", "}", "break", ";", "default", ":", "$", "result", ".=", "\"{$rule::className()}:<br>\"", ";", "if", "(", "method_exists", "(", "$", "rule", ",", "'showRouteInfo'", ")", ")", "{", "$", "info", "=", "$", "rule", "->", "showRouteInfo", "(", "$", "showPattern", ")", ";", "$", "strings", "=", "explode", "(", "\"\\n\"", ",", "trim", "(", "$", "info", ")", ")", ";", "foreach", "(", "$", "strings", "as", "$", "str", ")", "$", "result", ".=", "static", "::", "$", "ruleShift", ".", "trim", "(", "$", "str", ")", ".", "\"\\n\"", ";", "}", "else", "{", "ob_start", "(", ")", ";", "ob_implicit_flush", "(", "false", ")", ";", "var_dump", "(", "$", "rule", ")", ";", "$", "result", ".=", "ob_get_clean", "(", ")", ";", "}", "break", ";", "}", "if", "(", "$", "echo", ")", "{", "echo", "$", "result", ";", "}", "else", "{", "return", "$", "result", ";", "}", "}" ]
Show route. @param yii\web\UrlRule $rule @param boolean $echo if true print resule otherwise return result in string @param boolean $showPattern @return string|null
[ "Show", "route", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/RoutesInfo.php#L78-L142
238,376
sebastianmonzel/webfiles-framework-php
source/core/datasystem/file/format/MWebfile.php
MWebfile.marshall
public function marshall($usePreamble = true) { $out = ""; $attributes = $this->getAttributes(); if ($usePreamble) { $out .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; } $out .= "<object classname=\"" . static::$m__sClassName . "\">\n"; foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); if (MWebfile::isSimpleDatatype($attributeName)) { $attribute->setAccessible(true); $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $out .= "\t<" . $attributeFieldName . "><![CDATA[" . $attribute->getValue($this) . "]]></" . $attributeFieldName . ">\n"; } } $out .= "</object>"; return $out; }
php
public function marshall($usePreamble = true) { $out = ""; $attributes = $this->getAttributes(); if ($usePreamble) { $out .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; } $out .= "<object classname=\"" . static::$m__sClassName . "\">\n"; foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); if (MWebfile::isSimpleDatatype($attributeName)) { $attribute->setAccessible(true); $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $out .= "\t<" . $attributeFieldName . "><![CDATA[" . $attribute->getValue($this) . "]]></" . $attributeFieldName . ">\n"; } } $out .= "</object>"; return $out; }
[ "public", "function", "marshall", "(", "$", "usePreamble", "=", "true", ")", "{", "$", "out", "=", "\"\"", ";", "$", "attributes", "=", "$", "this", "->", "getAttributes", "(", ")", ";", "if", "(", "$", "usePreamble", ")", "{", "$", "out", ".=", "\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"", ";", "}", "$", "out", ".=", "\"<object classname=\\\"\"", ".", "static", "::", "$", "m__sClassName", ".", "\"\\\">\\n\"", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "$", "attributeName", "=", "$", "attribute", "->", "getName", "(", ")", ";", "if", "(", "MWebfile", "::", "isSimpleDatatype", "(", "$", "attributeName", ")", ")", "{", "$", "attribute", "->", "setAccessible", "(", "true", ")", ";", "$", "attributeFieldName", "=", "static", "::", "getSimplifiedAttributeName", "(", "$", "attributeName", ")", ";", "$", "out", ".=", "\"\\t<\"", ".", "$", "attributeFieldName", ".", "\"><![CDATA[\"", ".", "$", "attribute", "->", "getValue", "(", "$", "this", ")", ".", "\"]]></\"", ".", "$", "attributeFieldName", ".", "\">\\n\"", ";", "}", "}", "$", "out", ".=", "\"</object>\"", ";", "return", "$", "out", ";", "}" ]
Converts the current webfile into its xml representation. @param boolean $usePreamble sets the option of using a preamble in xml - usually used for setting the version of xml an the encoding. @return string returns the webfile as a marshalled String.
[ "Converts", "the", "current", "webfile", "into", "its", "xml", "representation", "." ]
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/format/MWebfile.php#L38-L59
238,377
sebastianmonzel/webfiles-framework-php
source/core/datasystem/file/format/MWebfile.php
MWebfile.getAttributes
public static function getAttributes($onlyAttributesOfSimpleDatatypes = false) { $oSelfReflection = new \ReflectionClass(static::$m__sClassName); $oPropertyArray = $oSelfReflection->getProperties( \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE); $count = 0; while ($count < count($oPropertyArray)) { $sAttributeName = $oPropertyArray[$count]->getName(); if ( // TODO generalize attribute prefix (sample "m_-s-", (start 2, length 1) ) substr($sAttributeName, 1, 1) != "_" || substr($sAttributeName, 2, 1) == "_" || ($onlyAttributesOfSimpleDatatypes && substr($sAttributeName, 2, 1) == "o") ) { unset($oPropertyArray[$count]); } $count++; } return $oPropertyArray; }
php
public static function getAttributes($onlyAttributesOfSimpleDatatypes = false) { $oSelfReflection = new \ReflectionClass(static::$m__sClassName); $oPropertyArray = $oSelfReflection->getProperties( \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE); $count = 0; while ($count < count($oPropertyArray)) { $sAttributeName = $oPropertyArray[$count]->getName(); if ( // TODO generalize attribute prefix (sample "m_-s-", (start 2, length 1) ) substr($sAttributeName, 1, 1) != "_" || substr($sAttributeName, 2, 1) == "_" || ($onlyAttributesOfSimpleDatatypes && substr($sAttributeName, 2, 1) == "o") ) { unset($oPropertyArray[$count]); } $count++; } return $oPropertyArray; }
[ "public", "static", "function", "getAttributes", "(", "$", "onlyAttributesOfSimpleDatatypes", "=", "false", ")", "{", "$", "oSelfReflection", "=", "new", "\\", "ReflectionClass", "(", "static", "::", "$", "m__sClassName", ")", ";", "$", "oPropertyArray", "=", "$", "oSelfReflection", "->", "getProperties", "(", "\\", "ReflectionProperty", "::", "IS_PUBLIC", "|", "\\", "ReflectionProperty", "::", "IS_PROTECTED", "|", "\\", "ReflectionProperty", "::", "IS_PRIVATE", ")", ";", "$", "count", "=", "0", ";", "while", "(", "$", "count", "<", "count", "(", "$", "oPropertyArray", ")", ")", "{", "$", "sAttributeName", "=", "$", "oPropertyArray", "[", "$", "count", "]", "->", "getName", "(", ")", ";", "if", "(", "// TODO generalize attribute prefix (sample \"m_-s-\", (start 2, length 1) )\r", "substr", "(", "$", "sAttributeName", ",", "1", ",", "1", ")", "!=", "\"_\"", "||", "substr", "(", "$", "sAttributeName", ",", "2", ",", "1", ")", "==", "\"_\"", "||", "(", "$", "onlyAttributesOfSimpleDatatypes", "&&", "substr", "(", "$", "sAttributeName", ",", "2", ",", "1", ")", "==", "\"o\"", ")", ")", "{", "unset", "(", "$", "oPropertyArray", "[", "$", "count", "]", ")", ";", "}", "$", "count", "++", ";", "}", "return", "$", "oPropertyArray", ";", "}" ]
Returns the attributes of the actual class which are relevant for the webfile definition. @param bool $onlyAttributesOfSimpleDatatypes @return array array with attributes
[ "Returns", "the", "attributes", "of", "the", "actual", "class", "which", "are", "relevant", "for", "the", "webfile", "definition", "." ]
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/format/MWebfile.php#L212-L234
238,378
sebastianmonzel/webfiles-framework-php
source/core/datasystem/file/format/MWebfile.php
MWebfile.getClassInformation
public static function getClassInformation() { $returnValue = "<classinformation>\n"; $returnValue .= "\t<author>simpleserv.de</author>\n"; $returnValue .= "\t<classname>" . static::$m__sClassName . "</classname>\n"; $returnValue .= "\t<attributes>\n"; $attributes = static::getAttributes(); foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); if (MWebfile::isSimpleDatatype($attributeName)) { $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $attributeFieldType = MWebfile::getDatatypeFromAttributeName($attributeName); $returnValue .= "\t\t<attribute name=\"" . $attributeFieldName . "\" type=\"" . $attributeFieldType . "\" />\n"; } } $returnValue .= "\t</attributes>\n"; $returnValue .= "</classinformation>"; return $returnValue; }
php
public static function getClassInformation() { $returnValue = "<classinformation>\n"; $returnValue .= "\t<author>simpleserv.de</author>\n"; $returnValue .= "\t<classname>" . static::$m__sClassName . "</classname>\n"; $returnValue .= "\t<attributes>\n"; $attributes = static::getAttributes(); foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); if (MWebfile::isSimpleDatatype($attributeName)) { $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $attributeFieldType = MWebfile::getDatatypeFromAttributeName($attributeName); $returnValue .= "\t\t<attribute name=\"" . $attributeFieldName . "\" type=\"" . $attributeFieldType . "\" />\n"; } } $returnValue .= "\t</attributes>\n"; $returnValue .= "</classinformation>"; return $returnValue; }
[ "public", "static", "function", "getClassInformation", "(", ")", "{", "$", "returnValue", "=", "\"<classinformation>\\n\"", ";", "$", "returnValue", ".=", "\"\\t<author>simpleserv.de</author>\\n\"", ";", "$", "returnValue", ".=", "\"\\t<classname>\"", ".", "static", "::", "$", "m__sClassName", ".", "\"</classname>\\n\"", ";", "$", "returnValue", ".=", "\"\\t<attributes>\\n\"", ";", "$", "attributes", "=", "static", "::", "getAttributes", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "$", "attributeName", "=", "$", "attribute", "->", "getName", "(", ")", ";", "if", "(", "MWebfile", "::", "isSimpleDatatype", "(", "$", "attributeName", ")", ")", "{", "$", "attributeFieldName", "=", "static", "::", "getSimplifiedAttributeName", "(", "$", "attributeName", ")", ";", "$", "attributeFieldType", "=", "MWebfile", "::", "getDatatypeFromAttributeName", "(", "$", "attributeName", ")", ";", "$", "returnValue", ".=", "\"\\t\\t<attribute name=\\\"\"", ".", "$", "attributeFieldName", ".", "\"\\\" type=\\\"\"", ".", "$", "attributeFieldType", ".", "\"\\\" />\\n\"", ";", "}", "}", "$", "returnValue", ".=", "\"\\t</attributes>\\n\"", ";", "$", "returnValue", ".=", "\"</classinformation>\"", ";", "return", "$", "returnValue", ";", "}" ]
Returns a xml defined class information. It contains the classname and the given attributes. @return string xml with information about the class
[ "Returns", "a", "xml", "defined", "class", "information", ".", "It", "contains", "the", "classname", "and", "the", "given", "attributes", "." ]
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/format/MWebfile.php#L242-L268
238,379
sebastianmonzel/webfiles-framework-php
source/core/datasystem/file/format/MWebfile.php
MWebfile.getDataset
public function getDataset() { $dataset = array(); $attributes = $this->getAttributes(); foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); $attribute->setAccessible(true); $attributeValue = $attribute->getValue($this); if (MWebfile::isSimpleDatatype($attributeName)) { $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $dataset[$attributeFieldName] = $attributeValue; } } return $dataset; }
php
public function getDataset() { $dataset = array(); $attributes = $this->getAttributes(); foreach ($attributes as $attribute) { $attributeName = $attribute->getName(); $attribute->setAccessible(true); $attributeValue = $attribute->getValue($this); if (MWebfile::isSimpleDatatype($attributeName)) { $attributeFieldName = static::getSimplifiedAttributeName($attributeName); $dataset[$attributeFieldName] = $attributeValue; } } return $dataset; }
[ "public", "function", "getDataset", "(", ")", "{", "$", "dataset", "=", "array", "(", ")", ";", "$", "attributes", "=", "$", "this", "->", "getAttributes", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "$", "attributeName", "=", "$", "attribute", "->", "getName", "(", ")", ";", "$", "attribute", "->", "setAccessible", "(", "true", ")", ";", "$", "attributeValue", "=", "$", "attribute", "->", "getValue", "(", "$", "this", ")", ";", "if", "(", "MWebfile", "::", "isSimpleDatatype", "(", "$", "attributeName", ")", ")", "{", "$", "attributeFieldName", "=", "static", "::", "getSimplifiedAttributeName", "(", "$", "attributeName", ")", ";", "$", "dataset", "[", "$", "attributeFieldName", "]", "=", "$", "attributeValue", ";", "}", "}", "return", "$", "dataset", ";", "}" ]
Transforms the actual webfile into an dataset. A dataset is represented by a key value array. The key is the attributes name. The value is the attributes value. @return array
[ "Transforms", "the", "actual", "webfile", "into", "an", "dataset", ".", "A", "dataset", "is", "represented", "by", "a", "key", "value", "array", ".", "The", "key", "is", "the", "attributes", "name", ".", "The", "value", "is", "the", "attributes", "value", "." ]
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/format/MWebfile.php#L306-L324
238,380
mszewcz/php-light-framework
src/Variables/Specific/Session.php
Session.set
public function set(string $variableName = null, $variableValue = null): Session { if ($variableName === null) { throw new BadMethodCallException('Variable name must be specified'); } if ($variableName === '_MFREG_') { throw new InvalidArgumentException('_MFREG_ variable name is not allowed'); } $_SESSION[$variableName] = \base64_encode(\serialize($variableValue)); $this->variables[$variableName] = \base64_encode(\serialize($variableValue)); return static::$instance; }
php
public function set(string $variableName = null, $variableValue = null): Session { if ($variableName === null) { throw new BadMethodCallException('Variable name must be specified'); } if ($variableName === '_MFREG_') { throw new InvalidArgumentException('_MFREG_ variable name is not allowed'); } $_SESSION[$variableName] = \base64_encode(\serialize($variableValue)); $this->variables[$variableName] = \base64_encode(\serialize($variableValue)); return static::$instance; }
[ "public", "function", "set", "(", "string", "$", "variableName", "=", "null", ",", "$", "variableValue", "=", "null", ")", ":", "Session", "{", "if", "(", "$", "variableName", "===", "null", ")", "{", "throw", "new", "BadMethodCallException", "(", "'Variable name must be specified'", ")", ";", "}", "if", "(", "$", "variableName", "===", "'_MFREG_'", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'_MFREG_ variable name is not allowed'", ")", ";", "}", "$", "_SESSION", "[", "$", "variableName", "]", "=", "\\", "base64_encode", "(", "\\", "serialize", "(", "$", "variableValue", ")", ")", ";", "$", "this", "->", "variables", "[", "$", "variableName", "]", "=", "\\", "base64_encode", "(", "\\", "serialize", "(", "$", "variableValue", ")", ")", ";", "return", "static", "::", "$", "instance", ";", "}" ]
Sets SESSION variable. @param string|null $variableName @param null $variableValue @return Session
[ "Sets", "SESSION", "variable", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/Session.php#L95-L107
238,381
sgoendoer/sonic
src/Config/Configuration.php
Configuration.setConfiguration
public static function setConfiguration($config) { if(!is_array($config)) throw new ConfigurationException('Configuration needs to be an array'); if(array_key_exists('primaryGSLSNode')) self::$primaryGSLSNode = $config['primaryGSLSNode']; if(array_key_exists('secondaryGSLSNode')) self::$secondaryGSLSNode = $config['secondaryGSLSNode']; if(array_key_exists('apiPath')) self::$apiPath = $config['apiPath']; if(array_key_exists('timezone')) self::$timezone = $config['timezone']; if(array_key_exists('verbose')) self::$verbose = $config['verbose']; if(array_key_exists('curlVerbose')) self::$curlVerbose = $config['curlVerbose']; if(array_key_exists('requestTimeout')) self::$requestTimeout = $config['requestTimeout']; if(array_key_exists('gslsTimeout')) self::$gslsTimeout = $config['gslsTimeout']; if(array_key_exists('logfile')) self::$logfile = $config['logfile']; }
php
public static function setConfiguration($config) { if(!is_array($config)) throw new ConfigurationException('Configuration needs to be an array'); if(array_key_exists('primaryGSLSNode')) self::$primaryGSLSNode = $config['primaryGSLSNode']; if(array_key_exists('secondaryGSLSNode')) self::$secondaryGSLSNode = $config['secondaryGSLSNode']; if(array_key_exists('apiPath')) self::$apiPath = $config['apiPath']; if(array_key_exists('timezone')) self::$timezone = $config['timezone']; if(array_key_exists('verbose')) self::$verbose = $config['verbose']; if(array_key_exists('curlVerbose')) self::$curlVerbose = $config['curlVerbose']; if(array_key_exists('requestTimeout')) self::$requestTimeout = $config['requestTimeout']; if(array_key_exists('gslsTimeout')) self::$gslsTimeout = $config['gslsTimeout']; if(array_key_exists('logfile')) self::$logfile = $config['logfile']; }
[ "public", "static", "function", "setConfiguration", "(", "$", "config", ")", "{", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "throw", "new", "ConfigurationException", "(", "'Configuration needs to be an array'", ")", ";", "if", "(", "array_key_exists", "(", "'primaryGSLSNode'", ")", ")", "self", "::", "$", "primaryGSLSNode", "=", "$", "config", "[", "'primaryGSLSNode'", "]", ";", "if", "(", "array_key_exists", "(", "'secondaryGSLSNode'", ")", ")", "self", "::", "$", "secondaryGSLSNode", "=", "$", "config", "[", "'secondaryGSLSNode'", "]", ";", "if", "(", "array_key_exists", "(", "'apiPath'", ")", ")", "self", "::", "$", "apiPath", "=", "$", "config", "[", "'apiPath'", "]", ";", "if", "(", "array_key_exists", "(", "'timezone'", ")", ")", "self", "::", "$", "timezone", "=", "$", "config", "[", "'timezone'", "]", ";", "if", "(", "array_key_exists", "(", "'verbose'", ")", ")", "self", "::", "$", "verbose", "=", "$", "config", "[", "'verbose'", "]", ";", "if", "(", "array_key_exists", "(", "'curlVerbose'", ")", ")", "self", "::", "$", "curlVerbose", "=", "$", "config", "[", "'curlVerbose'", "]", ";", "if", "(", "array_key_exists", "(", "'requestTimeout'", ")", ")", "self", "::", "$", "requestTimeout", "=", "$", "config", "[", "'requestTimeout'", "]", ";", "if", "(", "array_key_exists", "(", "'gslsTimeout'", ")", ")", "self", "::", "$", "gslsTimeout", "=", "$", "config", "[", "'gslsTimeout'", "]", ";", "if", "(", "array_key_exists", "(", "'logfile'", ")", ")", "self", "::", "$", "logfile", "=", "$", "config", "[", "'logfile'", "]", ";", "}" ]
Sets configuration values @param $config Array The configuration value
[ "Sets", "configuration", "values" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Config/Configuration.php#L30-L45
238,382
Puzzlout/FrameworkMvcLegacy
src/Helpers/ArrayExtractionHelper.php
ArrayExtractionHelper.ExtractDistinctValues
public function ExtractDistinctValues($array) { foreach ($array as $key => $value) { $valueIsArray = is_array($value); $valueIsAlreadyExtracted = in_array($value, $this->List); $keyIsExtracted = in_array($key, $this->List); if (!$valueIsArray && !$valueIsAlreadyExtracted && !RegexHelper::Init($value)->StringContainsWhiteSpace()) { array_push($this->List, $value); } if (!$keyIsExtracted && is_string($key) && !RegexHelper::Init($key)->StringContainsWhiteSpace()) { array_push($this->List, $key); } if ($valueIsArray) { $this->ExtractDistinctValues($value); } } return $this; }
php
public function ExtractDistinctValues($array) { foreach ($array as $key => $value) { $valueIsArray = is_array($value); $valueIsAlreadyExtracted = in_array($value, $this->List); $keyIsExtracted = in_array($key, $this->List); if (!$valueIsArray && !$valueIsAlreadyExtracted && !RegexHelper::Init($value)->StringContainsWhiteSpace()) { array_push($this->List, $value); } if (!$keyIsExtracted && is_string($key) && !RegexHelper::Init($key)->StringContainsWhiteSpace()) { array_push($this->List, $key); } if ($valueIsArray) { $this->ExtractDistinctValues($value); } } return $this; }
[ "public", "function", "ExtractDistinctValues", "(", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "valueIsArray", "=", "is_array", "(", "$", "value", ")", ";", "$", "valueIsAlreadyExtracted", "=", "in_array", "(", "$", "value", ",", "$", "this", "->", "List", ")", ";", "$", "keyIsExtracted", "=", "in_array", "(", "$", "key", ",", "$", "this", "->", "List", ")", ";", "if", "(", "!", "$", "valueIsArray", "&&", "!", "$", "valueIsAlreadyExtracted", "&&", "!", "RegexHelper", "::", "Init", "(", "$", "value", ")", "->", "StringContainsWhiteSpace", "(", ")", ")", "{", "array_push", "(", "$", "this", "->", "List", ",", "$", "value", ")", ";", "}", "if", "(", "!", "$", "keyIsExtracted", "&&", "is_string", "(", "$", "key", ")", "&&", "!", "RegexHelper", "::", "Init", "(", "$", "key", ")", "->", "StringContainsWhiteSpace", "(", ")", ")", "{", "array_push", "(", "$", "this", "->", "List", ",", "$", "key", ")", ";", "}", "if", "(", "$", "valueIsArray", ")", "{", "$", "this", "->", "ExtractDistinctValues", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Extracts distinct values from the array that don't contain whitespace. @param array $array The array to extract the values from @return \Puzzlout\Framework\Helpers\ArrayExtractionHelper The extrator instance.
[ "Extracts", "distinct", "values", "from", "the", "array", "that", "don", "t", "contain", "whitespace", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/ArrayExtractionHelper.php#L35-L51
238,383
echo511/TreeTraversal
src/Operations/Base.php
Base.run
public function run() { $config = $this->config; try { $this->getFluent()->getPdo()->beginTransaction(); $this->tree->getFluent()->getPdo()->exec("LOCK TABLES $config[table] WRITE;"); $return = $this->doRun(); $this->getFluent()->getPdo()->commit(); $this->tree->getFluent()->getPdo()->query("UNLOCK TABLES;"); return $return; } catch (Exception $ex) { $this->getFluent()->getPdo()->rollBack(); $this->tree->getFluent()->getPdo()->query("UNLOCK TABLES;"); throw $ex; } }
php
public function run() { $config = $this->config; try { $this->getFluent()->getPdo()->beginTransaction(); $this->tree->getFluent()->getPdo()->exec("LOCK TABLES $config[table] WRITE;"); $return = $this->doRun(); $this->getFluent()->getPdo()->commit(); $this->tree->getFluent()->getPdo()->query("UNLOCK TABLES;"); return $return; } catch (Exception $ex) { $this->getFluent()->getPdo()->rollBack(); $this->tree->getFluent()->getPdo()->query("UNLOCK TABLES;"); throw $ex; } }
[ "public", "function", "run", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "try", "{", "$", "this", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "beginTransaction", "(", ")", ";", "$", "this", "->", "tree", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "exec", "(", "\"LOCK TABLES $config[table] WRITE;\"", ")", ";", "$", "return", "=", "$", "this", "->", "doRun", "(", ")", ";", "$", "this", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "commit", "(", ")", ";", "$", "this", "->", "tree", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "query", "(", "\"UNLOCK TABLES;\"", ")", ";", "return", "$", "return", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "$", "this", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "rollBack", "(", ")", ";", "$", "this", "->", "tree", "->", "getFluent", "(", ")", "->", "getPdo", "(", ")", "->", "query", "(", "\"UNLOCK TABLES;\"", ")", ";", "throw", "$", "ex", ";", "}", "}" ]
Run the operation in transaction.
[ "Run", "the", "operation", "in", "transaction", "." ]
7d748c90df4a1941e7c1ad4578f892bc1414c189
https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L46-L61
238,384
echo511/TreeTraversal
src/Operations/Base.php
Base.getNodesBetween
protected function getNodesBetween($min, $max) { $config = $this->config; $query = $this->tree->table() ->select(NULL)// fetch only id ->select("$config[id] AS id") ->where("($config[lft] >= :min AND $config[lft] <= :max) OR ($config[rgt] >= :min AND $config[rgt] <= :max)", [ ':min' => $min, ':max' => $max, ]) ->fetchAll(); $ids = array_map(function ($key) { return $key['id']; }, $query); return $ids; }
php
protected function getNodesBetween($min, $max) { $config = $this->config; $query = $this->tree->table() ->select(NULL)// fetch only id ->select("$config[id] AS id") ->where("($config[lft] >= :min AND $config[lft] <= :max) OR ($config[rgt] >= :min AND $config[rgt] <= :max)", [ ':min' => $min, ':max' => $max, ]) ->fetchAll(); $ids = array_map(function ($key) { return $key['id']; }, $query); return $ids; }
[ "protected", "function", "getNodesBetween", "(", "$", "min", ",", "$", "max", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "$", "query", "=", "$", "this", "->", "tree", "->", "table", "(", ")", "->", "select", "(", "NULL", ")", "// fetch only id", "->", "select", "(", "\"$config[id] AS id\"", ")", "->", "where", "(", "\"($config[lft] >= :min AND $config[lft] <= :max) OR ($config[rgt] >= :min AND $config[rgt] <= :max)\"", ",", "[", "':min'", "=>", "$", "min", ",", "':max'", "=>", "$", "max", ",", "]", ")", "->", "fetchAll", "(", ")", ";", "$", "ids", "=", "array_map", "(", "function", "(", "$", "key", ")", "{", "return", "$", "key", "[", "'id'", "]", ";", "}", ",", "$", "query", ")", ";", "return", "$", "ids", ";", "}" ]
Get IDs of nodes between indexes including parent. @param $min @param $max @return array
[ "Get", "IDs", "of", "nodes", "between", "indexes", "including", "parent", "." ]
7d748c90df4a1941e7c1ad4578f892bc1414c189
https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L91-L106
238,385
echo511/TreeTraversal
src/Operations/Base.php
Base.updateDepths
protected function updateDepths($nodes, $value) { $config = $this->config; $this->getFluent() ->update($config['table']) ->set($config['dpt'], new FluentLiteral("$config[dpt] + $value")) ->where($config['id'], $nodes) ->execute(); }
php
protected function updateDepths($nodes, $value) { $config = $this->config; $this->getFluent() ->update($config['table']) ->set($config['dpt'], new FluentLiteral("$config[dpt] + $value")) ->where($config['id'], $nodes) ->execute(); }
[ "protected", "function", "updateDepths", "(", "$", "nodes", ",", "$", "value", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "$", "this", "->", "getFluent", "(", ")", "->", "update", "(", "$", "config", "[", "'table'", "]", ")", "->", "set", "(", "$", "config", "[", "'dpt'", "]", ",", "new", "FluentLiteral", "(", "\"$config[dpt] + $value\"", ")", ")", "->", "where", "(", "$", "config", "[", "'id'", "]", ",", "$", "nodes", ")", "->", "execute", "(", ")", ";", "}" ]
Update nodes depths. @param $nodes @param $value
[ "Update", "nodes", "depths", "." ]
7d748c90df4a1941e7c1ad4578f892bc1414c189
https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L143-L151
238,386
echo511/TreeTraversal
src/Operations/Base.php
Base.updateNodeParent
protected function updateNodeParent($nodeId, $parent) { $config = $this->config; $this->getFluent() ->update($config['table']) ->set($config['prt'], $parent) ->where($config['id'], $nodeId) ->execute(); }
php
protected function updateNodeParent($nodeId, $parent) { $config = $this->config; $this->getFluent() ->update($config['table']) ->set($config['prt'], $parent) ->where($config['id'], $nodeId) ->execute(); }
[ "protected", "function", "updateNodeParent", "(", "$", "nodeId", ",", "$", "parent", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "$", "this", "->", "getFluent", "(", ")", "->", "update", "(", "$", "config", "[", "'table'", "]", ")", "->", "set", "(", "$", "config", "[", "'prt'", "]", ",", "$", "parent", ")", "->", "where", "(", "$", "config", "[", "'id'", "]", ",", "$", "nodeId", ")", "->", "execute", "(", ")", ";", "}" ]
Set node the new parent. @param mixed $nodeId @param mixed $parent
[ "Set", "node", "the", "new", "parent", "." ]
7d748c90df4a1941e7c1ad4578f892bc1414c189
https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L158-L166
238,387
AdamB7586/pagination
src/Pagination.php
Pagination.paging
public function paging($records, $pageURL, $start = 0, $maxshown = 50, $numpagesshown = 11, $arrows = true, $additional = array()) { self::$pageURL = $pageURL; $this->queryString = $additional; if ($records > $maxshown) { self::$current = $start >= 1 ? intval($start) : 1; self::$totalPages = ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)); self::$lastpage = self::$totalPages; $this->getPage($records, $maxshown, $numpagesshown); $paging = '<ul class="'.$this->getPaginationClass().'">'.$this->preLinks($arrows); while (self::$page <= self::$lastpage) { $paging .= $this->buildLink(self::$page, self::$page, (self::$current == self::$page)); self::$page = (self::$page + 1); } return $paging.$this->postLinks($arrows).'</ul>'; } return false; }
php
public function paging($records, $pageURL, $start = 0, $maxshown = 50, $numpagesshown = 11, $arrows = true, $additional = array()) { self::$pageURL = $pageURL; $this->queryString = $additional; if ($records > $maxshown) { self::$current = $start >= 1 ? intval($start) : 1; self::$totalPages = ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)); self::$lastpage = self::$totalPages; $this->getPage($records, $maxshown, $numpagesshown); $paging = '<ul class="'.$this->getPaginationClass().'">'.$this->preLinks($arrows); while (self::$page <= self::$lastpage) { $paging .= $this->buildLink(self::$page, self::$page, (self::$current == self::$page)); self::$page = (self::$page + 1); } return $paging.$this->postLinks($arrows).'</ul>'; } return false; }
[ "public", "function", "paging", "(", "$", "records", ",", "$", "pageURL", ",", "$", "start", "=", "0", ",", "$", "maxshown", "=", "50", ",", "$", "numpagesshown", "=", "11", ",", "$", "arrows", "=", "true", ",", "$", "additional", "=", "array", "(", ")", ")", "{", "self", "::", "$", "pageURL", "=", "$", "pageURL", ";", "$", "this", "->", "queryString", "=", "$", "additional", ";", "if", "(", "$", "records", ">", "$", "maxshown", ")", "{", "self", "::", "$", "current", "=", "$", "start", ">=", "1", "?", "intval", "(", "$", "start", ")", ":", "1", ";", "self", "::", "$", "totalPages", "=", "ceil", "(", "intval", "(", "$", "records", ")", "/", "(", "$", "maxshown", ">=", "1", "?", "intval", "(", "$", "maxshown", ")", ":", "1", ")", ")", ";", "self", "::", "$", "lastpage", "=", "self", "::", "$", "totalPages", ";", "$", "this", "->", "getPage", "(", "$", "records", ",", "$", "maxshown", ",", "$", "numpagesshown", ")", ";", "$", "paging", "=", "'<ul class=\"'", ".", "$", "this", "->", "getPaginationClass", "(", ")", ".", "'\">'", ".", "$", "this", "->", "preLinks", "(", "$", "arrows", ")", ";", "while", "(", "self", "::", "$", "page", "<=", "self", "::", "$", "lastpage", ")", "{", "$", "paging", ".=", "$", "this", "->", "buildLink", "(", "self", "::", "$", "page", ",", "self", "::", "$", "page", ",", "(", "self", "::", "$", "current", "==", "self", "::", "$", "page", ")", ")", ";", "self", "::", "$", "page", "=", "(", "self", "::", "$", "page", "+", "1", ")", ";", "}", "return", "$", "paging", ".", "$", "this", "->", "postLinks", "(", "$", "arrows", ")", ".", "'</ul>'", ";", "}", "return", "false", ";", "}" ]
Returns paging buttons for the number of records @param int $records The total number of records @param string $pageURL The URL of the page you are creating the paging for @param int $start The start number for the results @param int $maxshown The number of records that are shown on each page @param int $numpagesshown The number of pagination buttons to display @param boolean $arrows If you want arrows to display before and after for next and previous set to true (default) else set to false @param array $additional Any additional get values to include in the URL @return string|false Returns the pagination menu if required else will return false
[ "Returns", "paging", "buttons", "for", "the", "number", "of", "records" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L123-L140
238,388
AdamB7586/pagination
src/Pagination.php
Pagination.buildLink
protected function buildLink($link, $page, $current = false) { return '<li'.(!empty($this->getLiClass()) || ($current === true && !empty($this->getLiActiveClass())) ? ' class="'.trim($this->getLiClass().(($current === true && !empty($this->getLiActiveClass())) ? ' '.$this->getLiActiveClass() : '').'"') : '').'><a href="'.self::$pageURL.(!empty($this->buildQueryString($link)) ? '?'.$this->buildQueryString($link) : '').'" title="Page '.$page.'"'.(!empty($this->getAClass()) || ($current === true && !empty($this->getAActiveClass())) ? ' class="'.trim($this->getAClass().(($current === true && !empty($this->getAActiveClass())) ? ' '.$this->getAActiveClass() : '')).'"' : '').'>'.$page.'</a></li>'; }
php
protected function buildLink($link, $page, $current = false) { return '<li'.(!empty($this->getLiClass()) || ($current === true && !empty($this->getLiActiveClass())) ? ' class="'.trim($this->getLiClass().(($current === true && !empty($this->getLiActiveClass())) ? ' '.$this->getLiActiveClass() : '').'"') : '').'><a href="'.self::$pageURL.(!empty($this->buildQueryString($link)) ? '?'.$this->buildQueryString($link) : '').'" title="Page '.$page.'"'.(!empty($this->getAClass()) || ($current === true && !empty($this->getAActiveClass())) ? ' class="'.trim($this->getAClass().(($current === true && !empty($this->getAActiveClass())) ? ' '.$this->getAActiveClass() : '')).'"' : '').'>'.$page.'</a></li>'; }
[ "protected", "function", "buildLink", "(", "$", "link", ",", "$", "page", ",", "$", "current", "=", "false", ")", "{", "return", "'<li'", ".", "(", "!", "empty", "(", "$", "this", "->", "getLiClass", "(", ")", ")", "||", "(", "$", "current", "===", "true", "&&", "!", "empty", "(", "$", "this", "->", "getLiActiveClass", "(", ")", ")", ")", "?", "' class=\"'", ".", "trim", "(", "$", "this", "->", "getLiClass", "(", ")", ".", "(", "(", "$", "current", "===", "true", "&&", "!", "empty", "(", "$", "this", "->", "getLiActiveClass", "(", ")", ")", ")", "?", "' '", ".", "$", "this", "->", "getLiActiveClass", "(", ")", ":", "''", ")", ".", "'\"'", ")", ":", "''", ")", ".", "'><a href=\"'", ".", "self", "::", "$", "pageURL", ".", "(", "!", "empty", "(", "$", "this", "->", "buildQueryString", "(", "$", "link", ")", ")", "?", "'?'", ".", "$", "this", "->", "buildQueryString", "(", "$", "link", ")", ":", "''", ")", ".", "'\" title=\"Page '", ".", "$", "page", ".", "'\"'", ".", "(", "!", "empty", "(", "$", "this", "->", "getAClass", "(", ")", ")", "||", "(", "$", "current", "===", "true", "&&", "!", "empty", "(", "$", "this", "->", "getAActiveClass", "(", ")", ")", ")", "?", "' class=\"'", ".", "trim", "(", "$", "this", "->", "getAClass", "(", ")", ".", "(", "(", "$", "current", "===", "true", "&&", "!", "empty", "(", "$", "this", "->", "getAActiveClass", "(", ")", ")", ")", "?", "' '", ".", "$", "this", "->", "getAActiveClass", "(", ")", ":", "''", ")", ")", ".", "'\"'", ":", "''", ")", ".", "'>'", ".", "$", "page", ".", "'</a></li>'", ";", "}" ]
Build a link item with the given values @param string $link This should be any additional items to be included as part of the link @param mixed $page This should be the link test on the link normally set as numbers but may be anything like arrows or dots etc @param boolean $current If this is the current link item set this as true so the class is added to the link item @return string This will return the paging item as a string
[ "Build", "a", "link", "item", "with", "the", "given", "values" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L149-L151
238,389
AdamB7586/pagination
src/Pagination.php
Pagination.buildQueryString
protected function buildQueryString($page) { $pageInfo = is_numeric($page) ? ['page' => $page] : []; return http_build_query(array_filter(array_merge($pageInfo, $this->queryString)), '', '&amp;'); }
php
protected function buildQueryString($page) { $pageInfo = is_numeric($page) ? ['page' => $page] : []; return http_build_query(array_filter(array_merge($pageInfo, $this->queryString)), '', '&amp;'); }
[ "protected", "function", "buildQueryString", "(", "$", "page", ")", "{", "$", "pageInfo", "=", "is_numeric", "(", "$", "page", ")", "?", "[", "'page'", "=>", "$", "page", "]", ":", "[", "]", ";", "return", "http_build_query", "(", "array_filter", "(", "array_merge", "(", "$", "pageInfo", ",", "$", "this", "->", "queryString", ")", ")", ",", "''", ",", "'&amp;'", ")", ";", "}" ]
Builds the query string to add to the URL @param mixed $page If the page variable is set to a number will add the page number to the query string else will not add any additional items @return string The complete string will be returned to add to the link item
[ "Builds", "the", "query", "string", "to", "add", "to", "the", "URL" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L158-L161
238,390
AdamB7586/pagination
src/Pagination.php
Pagination.getPage
protected function getPage($records, $maxshown, $numpages) { $show = floor($numpages / 2); if (self::$lastpage > $numpages) { self::$page = (self::$current > $show ? (self::$current - $show) : 1); if (self::$current < (self::$lastpage - $show)) { self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show)); } else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); } } else { self::$page = 1; } }
php
protected function getPage($records, $maxshown, $numpages) { $show = floor($numpages / 2); if (self::$lastpage > $numpages) { self::$page = (self::$current > $show ? (self::$current - $show) : 1); if (self::$current < (self::$lastpage - $show)) { self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show)); } else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); } } else { self::$page = 1; } }
[ "protected", "function", "getPage", "(", "$", "records", ",", "$", "maxshown", ",", "$", "numpages", ")", "{", "$", "show", "=", "floor", "(", "$", "numpages", "/", "2", ")", ";", "if", "(", "self", "::", "$", "lastpage", ">", "$", "numpages", ")", "{", "self", "::", "$", "page", "=", "(", "self", "::", "$", "current", ">", "$", "show", "?", "(", "self", "::", "$", "current", "-", "$", "show", ")", ":", "1", ")", ";", "if", "(", "self", "::", "$", "current", "<", "(", "self", "::", "$", "lastpage", "-", "$", "show", ")", ")", "{", "self", "::", "$", "lastpage", "=", "(", "(", "self", "::", "$", "current", "<=", "$", "show", ")", "?", "(", "self", "::", "$", "current", "+", "(", "$", "numpages", "-", "self", "::", "$", "current", ")", ")", ":", "(", "self", "::", "$", "current", "+", "$", "show", ")", ")", ";", "}", "else", "{", "self", "::", "$", "page", "=", "self", "::", "$", "current", "-", "(", "$", "numpages", "-", "(", "(", "ceil", "(", "intval", "(", "$", "records", ")", "/", "(", "$", "maxshown", ">=", "1", "?", "intval", "(", "$", "maxshown", ")", ":", "1", ")", ")", "-", "self", "::", "$", "current", ")", ")", "-", "1", ")", ";", "}", "}", "else", "{", "self", "::", "$", "page", "=", "1", ";", "}", "}" ]
Gets the current page @param int $records The total number of records @param int $maxshown The number of records that are shown on each page @param int $numpages The number of pagination buttons to display return void Nothing is returned
[ "Gets", "the", "current", "page" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L170-L180
238,391
AdamB7586/pagination
src/Pagination.php
Pagination.preLinks
protected function preLinks($arrows = true) { $paging = ''; if (self::$current != 1 && $arrows) { if (self::$current != 2) { $paging .= $this->buildLink('', '&laquo;'); } $paging .= $this->buildLink((self::$current - 1), '&lt;'); } return $paging; }
php
protected function preLinks($arrows = true) { $paging = ''; if (self::$current != 1 && $arrows) { if (self::$current != 2) { $paging .= $this->buildLink('', '&laquo;'); } $paging .= $this->buildLink((self::$current - 1), '&lt;'); } return $paging; }
[ "protected", "function", "preLinks", "(", "$", "arrows", "=", "true", ")", "{", "$", "paging", "=", "''", ";", "if", "(", "self", "::", "$", "current", "!=", "1", "&&", "$", "arrows", ")", "{", "if", "(", "self", "::", "$", "current", "!=", "2", ")", "{", "$", "paging", ".=", "$", "this", "->", "buildLink", "(", "''", ",", "'&laquo;'", ")", ";", "}", "$", "paging", ".=", "$", "this", "->", "buildLink", "(", "(", "self", "::", "$", "current", "-", "1", ")", ",", "'&lt;'", ")", ";", "}", "return", "$", "paging", ";", "}" ]
Returns the previous arrows as long as arrows is set to true and the page is not the first page @param boolean $arrows If you want to display previous arrows set to true else set to false @return string Any previous link arrows will be returned as a string
[ "Returns", "the", "previous", "arrows", "as", "long", "as", "arrows", "is", "set", "to", "true", "and", "the", "page", "is", "not", "the", "first", "page" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L187-L194
238,392
AdamB7586/pagination
src/Pagination.php
Pagination.postLinks
protected function postLinks($arrows = true) { $paging = ''; if (self::$current != self::$totalPages && $arrows) { $paging .= $this->buildLink((self::$current + 1), '&gt;'); if (self::$current != (self::$totalPages - 1)) { $paging .= $this->buildLink(self::$totalPages, '&raquo;'); } } return $paging; }
php
protected function postLinks($arrows = true) { $paging = ''; if (self::$current != self::$totalPages && $arrows) { $paging .= $this->buildLink((self::$current + 1), '&gt;'); if (self::$current != (self::$totalPages - 1)) { $paging .= $this->buildLink(self::$totalPages, '&raquo;'); } } return $paging; }
[ "protected", "function", "postLinks", "(", "$", "arrows", "=", "true", ")", "{", "$", "paging", "=", "''", ";", "if", "(", "self", "::", "$", "current", "!=", "self", "::", "$", "totalPages", "&&", "$", "arrows", ")", "{", "$", "paging", ".=", "$", "this", "->", "buildLink", "(", "(", "self", "::", "$", "current", "+", "1", ")", ",", "'&gt;'", ")", ";", "if", "(", "self", "::", "$", "current", "!=", "(", "self", "::", "$", "totalPages", "-", "1", ")", ")", "{", "$", "paging", ".=", "$", "this", "->", "buildLink", "(", "self", "::", "$", "totalPages", ",", "'&raquo;'", ")", ";", "}", "}", "return", "$", "paging", ";", "}" ]
Returns the next arrows as long as arrows is set to true and the page is not the last page @param boolean $arrows If you want to display next arrows set to true else set to false @return string Any next link arrows will be returned as a string
[ "Returns", "the", "next", "arrows", "as", "long", "as", "arrows", "is", "set", "to", "true", "and", "the", "page", "is", "not", "the", "last", "page" ]
d49182423ea2235c6821fa27fde1d7fbeae85cbb
https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L201-L208
238,393
CampusUnion/Sked
src/SkeDate.php
SkeDate.events
public function events(int $iMemberId = null, bool $bPublicEvents = false) { $aReturn = []; $this->oModel->forMember($iMemberId)->public($bPublicEvents); foreach ($this->oModel->fetch($this->strDate) as $aEvent) $aReturn[] = new SkeVent($aEvent); return $aReturn; }
php
public function events(int $iMemberId = null, bool $bPublicEvents = false) { $aReturn = []; $this->oModel->forMember($iMemberId)->public($bPublicEvents); foreach ($this->oModel->fetch($this->strDate) as $aEvent) $aReturn[] = new SkeVent($aEvent); return $aReturn; }
[ "public", "function", "events", "(", "int", "$", "iMemberId", "=", "null", ",", "bool", "$", "bPublicEvents", "=", "false", ")", "{", "$", "aReturn", "=", "[", "]", ";", "$", "this", "->", "oModel", "->", "forMember", "(", "$", "iMemberId", ")", "->", "public", "(", "$", "bPublicEvents", ")", ";", "foreach", "(", "$", "this", "->", "oModel", "->", "fetch", "(", "$", "this", "->", "strDate", ")", "as", "$", "aEvent", ")", "$", "aReturn", "[", "]", "=", "new", "SkeVent", "(", "$", "aEvent", ")", ";", "return", "$", "aReturn", ";", "}" ]
Get today's events. @param int $iMemberId Unique ID of the event participant. @param bool $bPublicEvents Retrieve only public events? (those without an owner) @return array
[ "Get", "today", "s", "events", "." ]
5b51afdb56c0f607e54364635c4725627b19ecc6
https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeDate.php#L35-L42
238,394
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/config/file.php
Config_File.find_file
protected function find_file($cache = true) { if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file)) { $paths = array($this->file); } else { $paths = array_merge( \Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache), \Finder::search('config', $this->file, $this->ext, true, $cache) ); } if (empty($paths)) { throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file)); } return array_reverse($paths); }
php
protected function find_file($cache = true) { if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file)) { $paths = array($this->file); } else { $paths = array_merge( \Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache), \Finder::search('config', $this->file, $this->ext, true, $cache) ); } if (empty($paths)) { throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file)); } return array_reverse($paths); }
[ "protected", "function", "find_file", "(", "$", "cache", "=", "true", ")", "{", "if", "(", "(", "$", "this", "->", "file", "[", "0", "]", "===", "'/'", "or", "(", "isset", "(", "$", "this", "->", "file", "[", "1", "]", ")", "and", "$", "this", "->", "file", "[", "1", "]", "===", "':'", ")", ")", "and", "is_file", "(", "$", "this", "->", "file", ")", ")", "{", "$", "paths", "=", "array", "(", "$", "this", "->", "file", ")", ";", "}", "else", "{", "$", "paths", "=", "array_merge", "(", "\\", "Finder", "::", "search", "(", "'config/'", ".", "\\", "Fuel", "::", "$", "env", ",", "$", "this", "->", "file", ",", "$", "this", "->", "ext", ",", "true", ",", "$", "cache", ")", ",", "\\", "Finder", "::", "search", "(", "'config'", ",", "$", "this", "->", "file", ",", "$", "this", "->", "ext", ",", "true", ",", "$", "cache", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "paths", ")", ")", "{", "throw", "new", "\\", "ConfigException", "(", "sprintf", "(", "'File \"%s\" does not exist.'", ",", "$", "this", "->", "file", ")", ")", ";", "}", "return", "array_reverse", "(", "$", "paths", ")", ";", "}" ]
Finds the given config files @param bool $multiple Whether to load multiple files or not @return array
[ "Finds", "the", "given", "config", "files" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/config/file.php#L118-L138
238,395
easy-system/es-controller-plugins
src/Plugin/Redirect.php
Redirect.toRoute
public function toRoute($name, array $params = []) { $url = $this->getUrl()->fromRoute($name, $params); return $this->toUrl($url); }
php
public function toRoute($name, array $params = []) { $url = $this->getUrl()->fromRoute($name, $params); return $this->toUrl($url); }
[ "public", "function", "toRoute", "(", "$", "name", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "getUrl", "(", ")", "->", "fromRoute", "(", "$", "name", ",", "$", "params", ")", ";", "return", "$", "this", "->", "toUrl", "(", "$", "url", ")", ";", "}" ]
Generates redirection by given route. @param string $name The route name @param array $params Optional; The route parameters @return \Es\Http\Psr\ResponseInterface The response
[ "Generates", "redirection", "by", "given", "route", "." ]
b1f58b0e62bb24d936aac15d34002826af7ee9b6
https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Redirect.php#L54-L59
238,396
easy-system/es-controller-plugins
src/Plugin/Redirect.php
Redirect.toUrl
public function toUrl($url, $statusCode = 302) { $server = $this->getServer(); $response = $server->getResponse(false) ->withHeader('Location', $url) ->withStatus($statusCode); return $response; }
php
public function toUrl($url, $statusCode = 302) { $server = $this->getServer(); $response = $server->getResponse(false) ->withHeader('Location', $url) ->withStatus($statusCode); return $response; }
[ "public", "function", "toUrl", "(", "$", "url", ",", "$", "statusCode", "=", "302", ")", "{", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "response", "=", "$", "server", "->", "getResponse", "(", "false", ")", "->", "withHeader", "(", "'Location'", ",", "$", "url", ")", "->", "withStatus", "(", "$", "statusCode", ")", ";", "return", "$", "response", ";", "}" ]
Generates redirection by given url. @param string $url The url @param int $statusCode Optional; by default 302. The status code @return \Es\Http\Psr\ResponseInterface The response
[ "Generates", "redirection", "by", "given", "url", "." ]
b1f58b0e62bb24d936aac15d34002826af7ee9b6
https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Redirect.php#L69-L78
238,397
delboy1978uk/bone
src/Mvc/Dispatcher.php
Dispatcher.checkNavigator
public function checkNavigator() { // can we find th' darned controller? if (!$this->checkControllerExists()) { $this->setNotFound(); return; } // merge the feckin params if (array_key_exists('params', $this->config) && is_array($this->config['params']) ) { $merged = array_merge($this->config['params'], $this->request->getQueryParams()); $this->request = $this->request->withQueryParams($merged); } // create the controller $this->controller = new $this->config['controller_name']($this->request); $this->controller->setServerEnvironment($this->getEnv()); // where's the bloody action? if (!$this->checkActionExists()) { $this->setNotFound(); } return null; }
php
public function checkNavigator() { // can we find th' darned controller? if (!$this->checkControllerExists()) { $this->setNotFound(); return; } // merge the feckin params if (array_key_exists('params', $this->config) && is_array($this->config['params']) ) { $merged = array_merge($this->config['params'], $this->request->getQueryParams()); $this->request = $this->request->withQueryParams($merged); } // create the controller $this->controller = new $this->config['controller_name']($this->request); $this->controller->setServerEnvironment($this->getEnv()); // where's the bloody action? if (!$this->checkActionExists()) { $this->setNotFound(); } return null; }
[ "public", "function", "checkNavigator", "(", ")", "{", "// can we find th' darned controller?", "if", "(", "!", "$", "this", "->", "checkControllerExists", "(", ")", ")", "{", "$", "this", "->", "setNotFound", "(", ")", ";", "return", ";", "}", "// merge the feckin params", "if", "(", "array_key_exists", "(", "'params'", ",", "$", "this", "->", "config", ")", "&&", "is_array", "(", "$", "this", "->", "config", "[", "'params'", "]", ")", ")", "{", "$", "merged", "=", "array_merge", "(", "$", "this", "->", "config", "[", "'params'", "]", ",", "$", "this", "->", "request", "->", "getQueryParams", "(", ")", ")", ";", "$", "this", "->", "request", "=", "$", "this", "->", "request", "->", "withQueryParams", "(", "$", "merged", ")", ";", "}", "// create the controller", "$", "this", "->", "controller", "=", "new", "$", "this", "->", "config", "[", "'controller_name'", "]", "(", "$", "this", "->", "request", ")", ";", "$", "this", "->", "controller", "->", "setServerEnvironment", "(", "$", "this", "->", "getEnv", "(", ")", ")", ";", "// where's the bloody action?", "if", "(", "!", "$", "this", "->", "checkActionExists", "(", ")", ")", "{", "$", "this", "->", "setNotFound", "(", ")", ";", "}", "return", "null", ";", "}" ]
Gaaarrr! Check the Navigator be readin' the map! @return null|void
[ "Gaaarrr!", "Check", "the", "Navigator", "be", "readin", "the", "map!" ]
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Dispatcher.php#L66-L89
238,398
delboy1978uk/bone
src/Mvc/Dispatcher.php
Dispatcher.setNotFound
private function setNotFound() { $this->config['controller_name'] = class_exists('\App\Controller\ErrorController') ? '\App\Controller\ErrorController' : '\Bone\Mvc\Controller'; $this->config['action_name'] = 'notFoundAction'; $this->config['controller'] = 'error'; $this->config['action'] = 'not-found'; $this->controller = new $this->config['controller_name']($this->request); $this->controller->setServerEnvironment($this->getEnv()); $this->response = $this->response->withStatus(404); }
php
private function setNotFound() { $this->config['controller_name'] = class_exists('\App\Controller\ErrorController') ? '\App\Controller\ErrorController' : '\Bone\Mvc\Controller'; $this->config['action_name'] = 'notFoundAction'; $this->config['controller'] = 'error'; $this->config['action'] = 'not-found'; $this->controller = new $this->config['controller_name']($this->request); $this->controller->setServerEnvironment($this->getEnv()); $this->response = $this->response->withStatus(404); }
[ "private", "function", "setNotFound", "(", ")", "{", "$", "this", "->", "config", "[", "'controller_name'", "]", "=", "class_exists", "(", "'\\App\\Controller\\ErrorController'", ")", "?", "'\\App\\Controller\\ErrorController'", ":", "'\\Bone\\Mvc\\Controller'", ";", "$", "this", "->", "config", "[", "'action_name'", "]", "=", "'notFoundAction'", ";", "$", "this", "->", "config", "[", "'controller'", "]", "=", "'error'", ";", "$", "this", "->", "config", "[", "'action'", "]", "=", "'not-found'", ";", "$", "this", "->", "controller", "=", "new", "$", "this", "->", "config", "[", "'controller_name'", "]", "(", "$", "this", "->", "request", ")", ";", "$", "this", "->", "controller", "->", "setServerEnvironment", "(", "$", "this", "->", "getEnv", "(", ")", ")", ";", "$", "this", "->", "response", "=", "$", "this", "->", "response", "->", "withStatus", "(", "404", ")", ";", "}" ]
Sets controller to error and action to not found @return void
[ "Sets", "controller", "to", "error", "and", "action", "to", "not", "found" ]
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Dispatcher.php#L282-L291
238,399
arvici/framework
src/Arvici/Heart/Collections/DataCollection.php
DataCollection.get
public function get($key, $default = null) { if (isset($this->contents[$key])) { return $this->contents[$key]; } return $default; }
php
public function get($key, $default = null) { if (isset($this->contents[$key])) { return $this->contents[$key]; } return $default; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "contents", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "contents", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get value for key @param string $key @param mixed $default Default value returned when key doesn't exists. @return mixed
[ "Get", "value", "for", "key" ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Collections/DataCollection.php#L104-L110