repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.getSection
public function getSection($section, $default = -1) { // Return if section is defined. if (isset($this->config[$section])) { return $this->config[$section]; } if ($default !== -1) { return $default; } // Find the default value (in default configuration definitions). $defaultClass = new \ReflectionClass(DefaultConfiguration::class); return $defaultClass->getStaticPropertyValue($section, null); }
php
public function getSection($section, $default = -1) { // Return if section is defined. if (isset($this->config[$section])) { return $this->config[$section]; } if ($default !== -1) { return $default; } // Find the default value (in default configuration definitions). $defaultClass = new \ReflectionClass(DefaultConfiguration::class); return $defaultClass->getStaticPropertyValue($section, null); }
[ "public", "function", "getSection", "(", "$", "section", ",", "$", "default", "=", "-", "1", ")", "{", "// Return if section is defined.", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", ")", "{", "return", "$", "th...
Get the whole set of the configuration section. @param string $section section name. @param mixed $default default value when undefined. Leave undefined to use the build-in defined defaults for the section. @return mixed @codeCoverageIgnore ignore due to a coverage bug.
[ "Get", "the", "whole", "set", "of", "the", "configuration", "section", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L133-L147
train
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.add
public function add($section, $config = array()) { if (! isset($this->config[$section])) { $this->config[$section] = array(); } $this->config[$section] = array_merge($this->config[$section], $config); }
php
public function add($section, $config = array()) { if (! isset($this->config[$section])) { $this->config[$section] = array(); } $this->config[$section] = array_merge($this->config[$section], $config); }
[ "public", "function", "add", "(", "$", "section", ",", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", ")", "{", "$", "this", "->", "config", "[", "$", ...
Add section data to the configuration. @param string $section @param array $config
[ "Add", "section", "data", "to", "the", "configuration", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L155-L162
train
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.doGetSection
private function doGetSection($section) { return isset($this->config[$section]) ? $this->config[$section] : null; }
php
private function doGetSection($section) { return isset($this->config[$section]) ? $this->config[$section] : null; }
[ "private", "function", "doGetSection", "(", "$", "section", ")", "{", "return", "isset", "(", "$", "this", "->", "config", "[", "$", "section", "]", ")", "?", "$", "this", "->", "config", "[", "$", "section", "]", ":", "null", ";", "}" ]
Get section configuration data. @deprecated Since 1.2.0. Will be removed in 2.0.0. @param string $section @return array|null @codeCoverageIgnore
[ "Get", "section", "configuration", "data", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L184-L187
train
mvccore/ext-router-extended
src/MvcCore/Ext/Routers/Extendeds/Preparing.php
Preparing.prepare
protected function prepare () { $request = & $this->request; // store original path value for later use $request->SetOriginalPath($request->GetPath(TRUE)); // switching media site version and targeting localized version // will be only by GET method, other methods are not very useful // to localize or target for media site version. It adds only another // not much useful route records to route processing: $this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET; // look into request params if there is any switching // parameter for session strict mode $this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET` // Set up session object to look inside for something from previous requests. // This command starts the session if not started yet. $this->setUpSession(); // Try to recognize administration request by `admin` param in query string // and by any authenticated user. The boolean flag `$this->adminRequest` // is used only to not process strict session mode redirections and to serve // requested documents directly, so there is not necessary to check if user // has any privileges or not, because this is only router. if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) { $authClass = static::$baseAuthClass; if (class_exists($authClass)) { $user = $authClass::GetInstance()->GetUser(); if ($user !== NULL) $this->adminRequest = TRUE; } } }
php
protected function prepare () { $request = & $this->request; // store original path value for later use $request->SetOriginalPath($request->GetPath(TRUE)); // switching media site version and targeting localized version // will be only by GET method, other methods are not very useful // to localize or target for media site version. It adds only another // not much useful route records to route processing: $this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET; // look into request params if there is any switching // parameter for session strict mode $this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET` // Set up session object to look inside for something from previous requests. // This command starts the session if not started yet. $this->setUpSession(); // Try to recognize administration request by `admin` param in query string // and by any authenticated user. The boolean flag `$this->adminRequest` // is used only to not process strict session mode redirections and to serve // requested documents directly, so there is not necessary to check if user // has any privileges or not, because this is only router. if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) { $authClass = static::$baseAuthClass; if (class_exists($authClass)) { $user = $authClass::GetInstance()->GetUser(); if ($user !== NULL) $this->adminRequest = TRUE; } } }
[ "protected", "function", "prepare", "(", ")", "{", "$", "request", "=", "&", "$", "this", "->", "request", ";", "// store original path value for later use", "$", "request", "->", "SetOriginalPath", "(", "$", "request", "->", "GetPath", "(", "TRUE", ")", ")", ...
Prepare extended router media site version or localization processing. @return void
[ "Prepare", "extended", "router", "media", "site", "version", "or", "localization", "processing", "." ]
39f95c1242509edae3b973db70364d7cdc61f2f5
https://github.com/mvccore/ext-router-extended/blob/39f95c1242509edae3b973db70364d7cdc61f2f5/src/MvcCore/Ext/Routers/Extendeds/Preparing.php#L31-L64
train
mvccore/ext-router-extended
src/MvcCore/Ext/Routers/Extendeds/Preparing.php
Preparing.setUpSession
protected function setUpSession () { if ($this->session === NULL) { $sessionClass = $this->application->GetSessionClass(); $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; $this->session = $sessionClass::GetNamespace($selfClass); $this->session->SetExpirationSeconds($this->sessionExpirationSeconds); } }
php
protected function setUpSession () { if ($this->session === NULL) { $sessionClass = $this->application->GetSessionClass(); $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; $this->session = $sessionClass::GetNamespace($selfClass); $this->session->SetExpirationSeconds($this->sessionExpirationSeconds); } }
[ "protected", "function", "setUpSession", "(", ")", "{", "if", "(", "$", "this", "->", "session", "===", "NULL", ")", "{", "$", "sessionClass", "=", "$", "this", "->", "application", "->", "GetSessionClass", "(", ")", ";", "$", "selfClass", "=", "version_...
If session namespace by this class is not initialized, initialize session namespace under this class name and move expiration to configured value. @return void
[ "If", "session", "namespace", "by", "this", "class", "is", "not", "initialized", "initialize", "session", "namespace", "under", "this", "class", "name", "and", "move", "expiration", "to", "configured", "value", "." ]
39f95c1242509edae3b973db70364d7cdc61f2f5
https://github.com/mvccore/ext-router-extended/blob/39f95c1242509edae3b973db70364d7cdc61f2f5/src/MvcCore/Ext/Routers/Extendeds/Preparing.php#L72-L79
train
Innmind/neo4j-onm
src/RepositoryFactory.php
RepositoryFactory.register
private function register( Entity $meta, Repository $repository ): self { $this->repositories = $this->repositories->put( $meta, $repository ); return $this; }
php
private function register( Entity $meta, Repository $repository ): self { $this->repositories = $this->repositories->put( $meta, $repository ); return $this; }
[ "private", "function", "register", "(", "Entity", "$", "meta", ",", "Repository", "$", "repository", ")", ":", "self", "{", "$", "this", "->", "repositories", "=", "$", "this", "->", "repositories", "->", "put", "(", "$", "meta", ",", "$", "repository", ...
Register a new repository instance To be used in case the repository can't be instanciated automatically
[ "Register", "a", "new", "repository", "instance" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/RepositoryFactory.php#L74-L84
train
popy-dev/popy-calendar
src/Parser/SymbolParser/Chain.php
Chain.addParser
public function addParser(SymbolParserInterface $parser) { if ($parser instanceof self) { // Reducing recursivity $this->addParsers($parser->parsers); } else { $this->parsers[] = $parser; } return $this; }
php
public function addParser(SymbolParserInterface $parser) { if ($parser instanceof self) { // Reducing recursivity $this->addParsers($parser->parsers); } else { $this->parsers[] = $parser; } return $this; }
[ "public", "function", "addParser", "(", "SymbolParserInterface", "$", "parser", ")", "{", "if", "(", "$", "parser", "instanceof", "self", ")", "{", "// Reducing recursivity", "$", "this", "->", "addParsers", "(", "$", "parser", "->", "parsers", ")", ";", "}"...
Adds a Parser to the chain. @param SymbolParserInterface $parser
[ "Adds", "a", "Parser", "to", "the", "chain", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/SymbolParser/Chain.php#L40-L50
train
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session.set
public static function set($var, $value) { // var_dump($var." ".$value); Session::init(true); if (!Session::check_checksum()) return false; $_SESSION[$var] = $value; $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return $value; }
php
public static function set($var, $value) { // var_dump($var." ".$value); Session::init(true); if (!Session::check_checksum()) return false; $_SESSION[$var] = $value; $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return $value; }
[ "public", "static", "function", "set", "(", "$", "var", ",", "$", "value", ")", "{", "// \tvar_dump($var.\" \".$value);", "Session", "::", "init", "(", "true", ")", ";", "if", "(", "!", "Session", "::", "check_checksum", "(", ")", ")", "return", "false", ...
Nastavi session premennu @param string $var @param string $value
[ "Nastavi", "session", "premennu" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L191-L198
train
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session._unset
public static function _unset($var) { Session::init(true); if (!Session::check_checksum()) return false; unset($_SESSION[$var]); $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return true; }
php
public static function _unset($var) { Session::init(true); if (!Session::check_checksum()) return false; unset($_SESSION[$var]); $_SESSION[__SESSION_checksum_var] = Session::make_checksum(); return true; }
[ "public", "static", "function", "_unset", "(", "$", "var", ")", "{", "Session", "::", "init", "(", "true", ")", ";", "if", "(", "!", "Session", "::", "check_checksum", "(", ")", ")", "return", "false", ";", "unset", "(", "$", "_SESSION", "[", "$", ...
Odstrani session premennu @param unknown_type $var @return unknown
[ "Odstrani", "session", "premennu" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L205-L211
train
scholtz/AsyncWeb
src/AsyncWeb/Storage/Session.php
Session.make_checksum
private static function make_checksum() { $ret = ""; $_SESSION[__SESSION_time_var] = \AsyncWeb\Date\Time::get(); if (isset($_SESSION) && is_array($_SESSION)) foreach ($_SESSION as $s => $v) { if ($s != __SESSION_checksum_var) { $ret = md5($ret . $s); } } Session::$checksum = $ret; return $ret; }
php
private static function make_checksum() { $ret = ""; $_SESSION[__SESSION_time_var] = \AsyncWeb\Date\Time::get(); if (isset($_SESSION) && is_array($_SESSION)) foreach ($_SESSION as $s => $v) { if ($s != __SESSION_checksum_var) { $ret = md5($ret . $s); } } Session::$checksum = $ret; return $ret; }
[ "private", "static", "function", "make_checksum", "(", ")", "{", "$", "ret", "=", "\"\"", ";", "$", "_SESSION", "[", "__SESSION_time_var", "]", "=", "\\", "AsyncWeb", "\\", "Date", "\\", "Time", "::", "get", "(", ")", ";", "if", "(", "isset", "(", "$...
Vytvori md5 session checksum @return string32 session checksum
[ "Vytvori", "md5", "session", "checksum" ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Storage/Session.php#L251-L261
train
mszewcz/php-light-framework
src/Validator/Specific/Isbn.php
Isbn.validateIsbn10
private function validateIsbn10(): bool { $value = \str_replace(['-', ' '], '', $this->value); if (!\preg_match($this->patterns['isbn10-basic'], $value)) { $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; } $sum = 0; for ($i = 0; $i < 9; $i++) { $sum += (10 - $i) * $value{$i}; } $checksum = 11 - ($sum % 11); if ($checksum == 11) { $checksum = '0'; } elseif ($checksum == 10) { $checksum = 'X'; } $isValid = \substr($value, -1) == $checksum ? true : false; if (!$isValid) { $this->setError(self::VALIDATOR_ERROR_ISBN_INVALID_NUMBER); } return $isValid; }
php
private function validateIsbn10(): bool { $value = \str_replace(['-', ' '], '', $this->value); if (!\preg_match($this->patterns['isbn10-basic'], $value)) { $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; } $sum = 0; for ($i = 0; $i < 9; $i++) { $sum += (10 - $i) * $value{$i}; } $checksum = 11 - ($sum % 11); if ($checksum == 11) { $checksum = '0'; } elseif ($checksum == 10) { $checksum = 'X'; } $isValid = \substr($value, -1) == $checksum ? true : false; if (!$isValid) { $this->setError(self::VALIDATOR_ERROR_ISBN_INVALID_NUMBER); } return $isValid; }
[ "private", "function", "validateIsbn10", "(", ")", ":", "bool", "{", "$", "value", "=", "\\", "str_replace", "(", "[", "'-'", ",", "' '", "]", ",", "''", ",", "$", "this", "->", "value", ")", ";", "if", "(", "!", "\\", "preg_match", "(", "$", "th...
Validates ISBN-10 number @return bool
[ "Validates", "ISBN", "-", "10", "number" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Isbn.php#L49-L73
train
mszewcz/php-light-framework
src/Validator/Specific/Isbn.php
Isbn.validateAuto
private function validateAuto(): bool { if (\preg_match($this->patterns['isbn13-basic'], $this->value)) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn13-separated'], $this->value) && \strlen($this->value) == 17) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn10-basic'], $this->value)) { return $this->validateIsbn10(); } if (\preg_match($this->patterns['isbn10-separated'], $this->value) && \strlen($this->value) == 13) { return $this->validateIsbn10(); } $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; }
php
private function validateAuto(): bool { if (\preg_match($this->patterns['isbn13-basic'], $this->value)) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn13-separated'], $this->value) && \strlen($this->value) == 17) { return $this->validateIsbn13(); } if (\preg_match($this->patterns['isbn10-basic'], $this->value)) { return $this->validateIsbn10(); } if (\preg_match($this->patterns['isbn10-separated'], $this->value) && \strlen($this->value) == 13) { return $this->validateIsbn10(); } $this->setError(self::VALIDATOR_ERROR_ISBN_INCORRECT_FORMAT); return false; }
[ "private", "function", "validateAuto", "(", ")", ":", "bool", "{", "if", "(", "\\", "preg_match", "(", "$", "this", "->", "patterns", "[", "'isbn13-basic'", "]", ",", "$", "this", "->", "value", ")", ")", "{", "return", "$", "this", "->", "validateIsbn...
Validates ISBN number with auto format detection @return bool
[ "Validates", "ISBN", "number", "with", "auto", "format", "detection" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Isbn.php#L106-L123
train
jaeger-app/exceptions
src/Exception.php
Exception.logException
public function logException(\Exception $e) { $error = $e->getMessage() . $e->getTraceAsString(); return $this->logEmergency($error); }
php
public function logException(\Exception $e) { $error = $e->getMessage() . $e->getTraceAsString(); return $this->logEmergency($error); }
[ "public", "function", "logException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "$", "e", "->", "getMessage", "(", ")", ".", "$", "e", "->", "getTraceAsString", "(", ")", ";", "return", "$", "this", "->", "logEmergency", "(", "$"...
Logs an exeption @param \Exception $e @return bool
[ "Logs", "an", "exeption" ]
38ae3f1db547a311ccb306bb2c1ffc43d33890bf
https://github.com/jaeger-app/exceptions/blob/38ae3f1db547a311ccb306bb2c1ffc43d33890bf/src/Exception.php#L33-L37
train
marando/phpSOFA
src/Marando/IAU/iauUtcut1.php
iauUtcut1.Utcut1
public static function Utcut1($utc1, $utc2, $dut1, &$ut11, &$ut12) { $iy; $im; $id; $js; $jw; $w; $dat; $dta; $tai1; $tai2; /* Look up TAI-UTC. */ if (IAU::Jd2cal($utc1, $utc2, $iy, $im, $id, $w)) return -1; $js = IAU::Dat($iy, $im, $id, 0.0, $dat); if ($js < 0) return -1; /* Form UT1-TAI. */ $dta = $dut1 - $dat; /* UTC to TAI to UT1. */ $jw = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($jw < 0) { return -1; } else if ($jw > 0) { $js = $jw; } if (IAU::Taiut1($tai1, $tai2, $dta, $ut11, $ut12)) return -1; /* Status. */ return $js; }
php
public static function Utcut1($utc1, $utc2, $dut1, &$ut11, &$ut12) { $iy; $im; $id; $js; $jw; $w; $dat; $dta; $tai1; $tai2; /* Look up TAI-UTC. */ if (IAU::Jd2cal($utc1, $utc2, $iy, $im, $id, $w)) return -1; $js = IAU::Dat($iy, $im, $id, 0.0, $dat); if ($js < 0) return -1; /* Form UT1-TAI. */ $dta = $dut1 - $dat; /* UTC to TAI to UT1. */ $jw = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($jw < 0) { return -1; } else if ($jw > 0) { $js = $jw; } if (IAU::Taiut1($tai1, $tai2, $dta, $ut11, $ut12)) return -1; /* Status. */ return $js; }
[ "public", "static", "function", "Utcut1", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "dut1", ",", "&", "$", "ut11", ",", "&", "$", "ut12", ")", "{", "$", "iy", ";", "$", "im", ";", "$", "id", ";", "$", "js", ";", "$", "jw", ";", "$", "...
- - - - - - - - - - i a u U t c u t 1 - - - - - - - - - - Time scale transformation: Coordinated Universal Time, UTC, to Universal Time, UT1. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical. Given: utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4) dut1 double Delta UT1 = UT1-UTC in seconds (Note 5) Returned: ut11,ut12 double UT1 as a 2-part Julian Date (Note 6) Returned (function value): int status: +1 = dubious year (Note 3) 0 = OK -1 = unacceptable date Notes: 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any convenient way between the two arguments, for example where utc1 is the Julian Day Number and utc2 is the fraction of a day. 2) JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds. 3) The warning status "dubious year" flags UTCs that predate the introduction of the time scale or that are too far in the future to be trusted. See iauDat for further details. 4) The function iauDtf2d converts from calendar date and time of day into 2-part Julian Date, and in the case of UTC implements the leap-second-ambiguity convention described above. 5) Delta UT1 can be obtained from tabulations provided by the International Earth Rotation and Reference Systems Service. It is the caller's responsibility to supply a dut1 argument containing the UT1-UTC value that matches the given UTC. 6) The returned ut11,ut12 are such that their sum is the UT1 Julian Date. References: McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed), University Science Books (1992) Called: iauJd2cal JD to Gregorian calendar iauDat delta(AT) = TAI-UTC iauUtctai UTC to TAI iauTaiut1 TAI to UT1 This revision: 2013 August 12 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "U", "t", "c", "u", "t", "1", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUtcut1.php#L79-L114
train
tadcka/Tree
Validator/NodeValidator.php
NodeValidator.validateByOnlyOne
public function validateByOnlyOne($nodeType, TreeInterface $tree) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ($config->isOnlyOne()) { return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree)); } return true; }
php
public function validateByOnlyOne($nodeType, TreeInterface $tree) { if (!$nodeType) { return true; } $config = $this->getNodeTypeConfig($nodeType); if (null === $config) { return false; } if ($config->isOnlyOne()) { return !in_array($nodeType, $this->nodeManager->findExistingNodeTypes($tree)); } return true; }
[ "public", "function", "validateByOnlyOne", "(", "$", "nodeType", ",", "TreeInterface", "$", "tree", ")", "{", "if", "(", "!", "$", "nodeType", ")", "{", "return", "true", ";", "}", "$", "config", "=", "$", "this", "->", "getNodeTypeConfig", "(", "$", "...
Validate by only one. @param string $nodeType @param TreeInterface $tree @return bool
[ "Validate", "by", "only", "one", "." ]
b45038283225508b09a05f99651ecd5127a08f20
https://github.com/tadcka/Tree/blob/b45038283225508b09a05f99651ecd5127a08f20/Validator/NodeValidator.php#L58-L74
train
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",...
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
train
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", "!=...
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
train
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", ")", "{", "$", "de...
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
train
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", "=", "[", "]",...
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
train
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", "$", "...
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
train
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", ")...
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
train
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", ...
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
train
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", "(", ")", "->", "getFrontendFramewor...
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
train
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", ")", "{", "$", "c...
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
train
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", "::...
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
train
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", "=", ...
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
train
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", "(", ...
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
train
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",...
Sends mail. @param type $to
[ "Sends", "mail", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Library/Mailer.php#L76-L90
train
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", ...
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
train
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"...
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
train
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", ...
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
train
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",...
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
train
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"...
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
train
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", "...
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
train
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",...
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
train
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", ...
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
train
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", "...
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
train
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", "(", "$", "da...
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
train
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
train
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", "(", "$...
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
train
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", "=", "$", "th...
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
train
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", "->", "a...
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
train
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", "->", "_original...
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
train
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, ...
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
train
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", "->", "_DAT...
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
train
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", ")", ";"...
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
train
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 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
train
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'", ...
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
train
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", "...
return object as stdClass @return stdClass
[ "return", "object", "as", "stdClass" ]
9827b98a9b12043ae94ae5dc60fdd971eba5d741
https://github.com/bluetree-service/container/blob/9827b98a9b12043ae94ae5dc60fdd971eba5d741/src/ContainerObject.php#L890-L900
train
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", "$",...
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
train
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", "=", "&", "$", "t...
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
train
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", ")", ...
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
train
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",...
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
train
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", "->",...
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
train
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_dec...
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
train
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", "(", ...
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
train
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", ")", ";"...
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
train
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", "=", ...
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
train
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", ")", ";", "}", ...
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
train
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", "->", "...
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
train
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",...
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
train
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", "->", "...
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
train
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", ")", "{", "...
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
train
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", ",", "$", "...
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
train
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", ".=", "'['", ".", "...
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
train
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", ")...
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
train
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", "=", "implod...
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
train
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", ...
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
train
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", "(", "$", "...
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
train
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", "(", ...
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
train
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", ")", "=...
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
train
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", "(", "$", "valu...
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
train
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", ")", ")", "{", ...
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
train
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", ...
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
train
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", ...
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
train
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", ...
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
train
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", "...
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
train
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", "+...
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
train
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'", "=>...
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
train
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
train
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", ")", "{", "...
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
train
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", ")", ";", ...
- - - - - - - - - - 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
train
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", "...
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
train
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"...
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
train
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", "::", "getContr...
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
train
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", ...
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
train
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", "(", "$", "sRegexSeparat...
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
train
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", "(...
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
train
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", ":...
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
train
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"...
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
train
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"...
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
train
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", ".=", "\...
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
train
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", "=", "$...
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
train
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", "::...
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
train
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", ")", "{", "$", "attr...
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
train
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", "(", "'Variab...
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
train
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_exi...
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
train
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", "...
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
train
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", ...
Run the operation in transaction.
[ "Run", "the", "operation", "in", "transaction", "." ]
7d748c90df4a1941e7c1ad4578f892bc1414c189
https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L46-L61
train
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", ")", ...
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
train