id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
241,000
mvccore/ext-view-helper-internationalized
src/MvcCore/Ext/Views/Helpers/InternationalizedHelper.php
InternationalizedHelper.&
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); return $this->SetLangAndLocale($this->request->GetLang(), $this->request->GetLocale()); }
php
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); return $this->SetLangAndLocale($this->request->GetLang(), $this->request->GetLocale()); }
[ "public", "function", "&", "SetView", "(", "\\", "MvcCore", "\\", "IView", "&", "$", "view", ")", "{", "parent", "::", "SetView", "(", "$", "view", ")", ";", "return", "$", "this", "->", "SetLangAndLocale", "(", "$", "this", "->", "request", "->", "GetLang", "(", ")", ",", "$", "this", "->", "request", "->", "GetLocale", "(", ")", ")", ";", "}" ]
Set up view properties and language and locale by request object in every view rendering change. @param \MvcCore\View|\MvcCore\IView $view @return \MvcCore\Ext\Views\Helpers\InternationalizedHelper
[ "Set", "up", "view", "properties", "and", "language", "and", "locale", "by", "request", "object", "in", "every", "view", "rendering", "change", "." ]
f7013decea5c1343a66adf45f664e275772ac703
https://github.com/mvccore/ext-view-helper-internationalized/blob/f7013decea5c1343a66adf45f664e275772ac703/src/MvcCore/Ext/Views/Helpers/InternationalizedHelper.php#L182-L185
241,001
marando/phpSOFA
src/Marando/IAU/iauAtciq.php
iauAtciq.Atciq
public static function Atciq($rc, $dc, $pr, $pd, $px, $rv, iauASTROM $astrom, &$ri, &$di) { $pco = []; $pnat = []; $ppr = []; $pi = []; $w; /* Proper motion and parallax, giving BCRS coordinate direction. */ IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco); /* Light deflection by the Sun, giving BCRS natural direction. */ IAU::Ldsun($pco, $astrom->eh, $astrom->em, $pnat); /* Aberration, giving GCRS proper direction. */ IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ IAU::Rxp($astrom->bpn, $ppr, $pi); /* CIRS RA,Dec. */ IAU::C2s($pi, $w, $di); $ri = IAU::Anp($w); /* Finished. */ }
php
public static function Atciq($rc, $dc, $pr, $pd, $px, $rv, iauASTROM $astrom, &$ri, &$di) { $pco = []; $pnat = []; $ppr = []; $pi = []; $w; /* Proper motion and parallax, giving BCRS coordinate direction. */ IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco); /* Light deflection by the Sun, giving BCRS natural direction. */ IAU::Ldsun($pco, $astrom->eh, $astrom->em, $pnat); /* Aberration, giving GCRS proper direction. */ IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ IAU::Rxp($astrom->bpn, $ppr, $pi); /* CIRS RA,Dec. */ IAU::C2s($pi, $w, $di); $ri = IAU::Anp($w); /* Finished. */ }
[ "public", "static", "function", "Atciq", "(", "$", "rc", ",", "$", "dc", ",", "$", "pr", ",", "$", "pd", ",", "$", "px", ",", "$", "rv", ",", "iauASTROM", "$", "astrom", ",", "&", "$", "ri", ",", "&", "$", "di", ")", "{", "$", "pco", "=", "[", "]", ";", "$", "pnat", "=", "[", "]", ";", "$", "ppr", "=", "[", "]", ";", "$", "pi", "=", "[", "]", ";", "$", "w", ";", "/* Proper motion and parallax, giving BCRS coordinate direction. */", "IAU", "::", "Pmpx", "(", "$", "rc", ",", "$", "dc", ",", "$", "pr", ",", "$", "pd", ",", "$", "px", ",", "$", "rv", ",", "$", "astrom", "->", "pmt", ",", "$", "astrom", "->", "eb", ",", "$", "pco", ")", ";", "/* Light deflection by the Sun, giving BCRS natural direction. */", "IAU", "::", "Ldsun", "(", "$", "pco", ",", "$", "astrom", "->", "eh", ",", "$", "astrom", "->", "em", ",", "$", "pnat", ")", ";", "/* Aberration, giving GCRS proper direction. */", "IAU", "::", "Ab", "(", "$", "pnat", ",", "$", "astrom", "->", "v", ",", "$", "astrom", "->", "em", ",", "$", "astrom", "->", "bm1", ",", "$", "ppr", ")", ";", "/* Bias-precession-nutation, giving CIRS proper direction. */", "IAU", "::", "Rxp", "(", "$", "astrom", "->", "bpn", ",", "$", "ppr", ",", "$", "pi", ")", ";", "/* CIRS RA,Dec. */", "IAU", "::", "C2s", "(", "$", "pi", ",", "$", "w", ",", "$", "di", ")", ";", "$", "ri", "=", "IAU", "::", "Anp", "(", "$", "w", ")", ";", "/* Finished. */", "}" ]
- - - - - - - - - i a u A t c i q - - - - - - - - - Quick ICRS, epoch J2000.0, to CIRS transformation, given precomputed star-independent astrometry parameters. Use of this function is appropriate when efficiency is important and where many star positions are to be transformed for one date. The star-independent parameters can be obtained by calling one of the functions iauApci[13], iauApcg[13], iauApco[13] or iauApcs[13]. If the parallax and proper motions are zero the iauAtciqz function can be used instead. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: rc,dc double ICRS RA,Dec at J2000.0 (radians) pr double RA proper motion (radians/year; Note 3) pd double Dec proper motion (radians/year) px double parallax (arcsec) rv double radial velocity (km/s, +ve if receding) astrom iauASTROM* star-independent astrometry parameters: pmt double PM time interval (SSB, Julian years) eb double[3] SSB to observer (vector, au) eh double[3] Sun to observer (unit vector) em double distance from Sun to observer (au) v double[3] barycentric observer velocity (vector, c) bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor bpn double[3][3] bias-precession-nutation matrix along double longitude + s' (radians) xpl double polar motion xp wrt local meridian (radians) ypl double polar motion yp wrt local meridian (radians) sphi double sine of geodetic latitude cphi double cosine of geodetic latitude diurab double magnitude of diurnal aberration vector eral double "local" Earth rotation angle (radians) refa double refraction constant A (radians) refb double refraction constant B (radians) Returned: ri,di double CIRS RA,Dec (radians) Notes: 1) All the vectors are with respect to BCRS axes. 2) Star data for an epoch other than J2000.0 (for example from the Hipparcos catalog, which has an epoch of J1991.25) will require a preliminary call to iauPmsafe before use. 3) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt. Called: iauPmpx proper motion and parallax iauLdsun light deflection by the Sun iauAb stellar aberration iauRxp product of r-matrix and pv-vector iauC2s p-vector to spherical iauAnp normalize angle into range 0 to 2pi This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "t", "c", "i", "q", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAtciq.php#L79-L105
241,002
jaimeeee/laravelpanel
src/LaravelPanel/models/HTML.php
HTML.tag
public static function tag($tag, $attr = [], $html = '') { // Build attributes $attributes = []; foreach ($attr as $name => $value) { $attributes[] = $name.'="'.$value.'"'; } if (in_array($tag, self::$voidElements)) { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'; } else { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>'; } }
php
public static function tag($tag, $attr = [], $html = '') { // Build attributes $attributes = []; foreach ($attr as $name => $value) { $attributes[] = $name.'="'.$value.'"'; } if (in_array($tag, self::$voidElements)) { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'; } else { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>'; } }
[ "public", "static", "function", "tag", "(", "$", "tag", ",", "$", "attr", "=", "[", "]", ",", "$", "html", "=", "''", ")", "{", "// Build attributes", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "attr", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "attributes", "[", "]", "=", "$", "name", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "if", "(", "in_array", "(", "$", "tag", ",", "self", "::", "$", "voidElements", ")", ")", "{", "return", "'<'", ".", "$", "tag", ".", "(", "!", "empty", "(", "$", "attributes", ")", "?", "' '", ".", "implode", "(", "' '", ",", "$", "attributes", ")", ":", "''", ")", ".", "'>'", ";", "}", "else", "{", "return", "'<'", ".", "$", "tag", ".", "(", "!", "empty", "(", "$", "attributes", ")", "?", "' '", ".", "implode", "(", "' '", ",", "$", "attributes", ")", ":", "''", ")", ".", "'>'", ".", "$", "html", ".", "'</'", ".", "$", "tag", ".", "'>'", ";", "}", "}" ]
Generate the HTML code for an element. @param string $tag <tag> @param array $attr The tag attributes @param string $html The tag HTML content @return string HTML code of the tag
[ "Generate", "the", "HTML", "code", "for", "an", "element", "." ]
211599ba0be7dc5ea11af292a75d4104c41512ca
https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTML.php#L21-L34
241,003
jfortunato/fortune
src/Security/Bouncer/ParentBouncer.php
ParentBouncer.routeContainsParent
protected function routeContainsParent() { // get just the base url $route = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // lets split it into pieces $parts = explode('/', $route); // if a resource has a parent, it should be in the form /dogs/1/puppies // so the parent resource should be 2 spots before the child resource $resourcePosition = array_search($this->config->getResource(), $parts); return isset($parts[$resourcePosition - 2]); }
php
protected function routeContainsParent() { // get just the base url $route = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // lets split it into pieces $parts = explode('/', $route); // if a resource has a parent, it should be in the form /dogs/1/puppies // so the parent resource should be 2 spots before the child resource $resourcePosition = array_search($this->config->getResource(), $parts); return isset($parts[$resourcePosition - 2]); }
[ "protected", "function", "routeContainsParent", "(", ")", "{", "// get just the base url", "$", "route", "=", "parse_url", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "PHP_URL_PATH", ")", ";", "// lets split it into pieces", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "route", ")", ";", "// if a resource has a parent, it should be in the form /dogs/1/puppies", "// so the parent resource should be 2 spots before the child resource", "$", "resourcePosition", "=", "array_search", "(", "$", "this", "->", "config", "->", "getResource", "(", ")", ",", "$", "parts", ")", ";", "return", "isset", "(", "$", "parts", "[", "$", "resourcePosition", "-", "2", "]", ")", ";", "}" ]
Checks if the current route contains the parents id. @return boolean
[ "Checks", "if", "the", "current", "route", "contains", "the", "parents", "id", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Security/Bouncer/ParentBouncer.php#L28-L41
241,004
SIBPHP/Redis
Redis.php
Redis._connection
protected function _connection(array $config) { $redis = new \Redis; $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host']; $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port']; $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout']; $connect = empty($config['persistent']) ? 'connect' : 'pconnect'; $redis->$connect($host, $port, $timeout); return $redis; }
php
protected function _connection(array $config) { $redis = new \Redis; $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host']; $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port']; $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout']; $connect = empty($config['persistent']) ? 'connect' : 'pconnect'; $redis->$connect($host, $port, $timeout); return $redis; }
[ "protected", "function", "_connection", "(", "array", "$", "config", ")", "{", "$", "redis", "=", "new", "\\", "Redis", ";", "$", "host", "=", "empty", "(", "$", "config", "[", "'host'", "]", ")", "?", "self", "::", "DEFAULT_HOST", ":", "$", "config", "[", "'host'", "]", ";", "$", "port", "=", "empty", "(", "$", "config", "[", "'port'", "]", ")", "?", "self", "::", "DEFAULT_PORT", ":", "$", "config", "[", "'port'", "]", ";", "$", "timeout", "=", "empty", "(", "$", "config", "[", "'timeout'", "]", ")", "?", "self", "::", "DEFAULT_TIMEOUT", ":", "$", "config", "[", "'timeout'", "]", ";", "$", "connect", "=", "empty", "(", "$", "config", "[", "'persistent'", "]", ")", "?", "'connect'", ":", "'pconnect'", ";", "$", "redis", "->", "$", "connect", "(", "$", "host", ",", "$", "port", ",", "$", "timeout", ")", ";", "return", "$", "redis", ";", "}" ]
Redis connect and return the redis instance @param array $config The config @return \Redis
[ "Redis", "connect", "and", "return", "the", "redis", "instance" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L96-L105
241,005
SIBPHP/Redis
Redis.php
Redis._master
protected function _master() { if (null === $this->_master) { $this->_master = $this->_connection($this->_config_master); } return $this->_master; }
php
protected function _master() { if (null === $this->_master) { $this->_master = $this->_connection($this->_config_master); } return $this->_master; }
[ "protected", "function", "_master", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_master", ")", "{", "$", "this", "->", "_master", "=", "$", "this", "->", "_connection", "(", "$", "this", "->", "_config_master", ")", ";", "}", "return", "$", "this", "->", "_master", ";", "}" ]
Get the master connection @return \Redis
[ "Get", "the", "master", "connection" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L113-L119
241,006
SIBPHP/Redis
Redis.php
Redis._slave
protected function _slave() { if (empty($this->_config_slaves)) { return $this->_master(); } if (null === $this->_slave) { $count = count($this->_config_slaves); $index = mt_rand(0, $count-1); $config = $this->_config_slaves[$index]; $this->_slave = $this->_connection($config); } return $this->_slave; }
php
protected function _slave() { if (empty($this->_config_slaves)) { return $this->_master(); } if (null === $this->_slave) { $count = count($this->_config_slaves); $index = mt_rand(0, $count-1); $config = $this->_config_slaves[$index]; $this->_slave = $this->_connection($config); } return $this->_slave; }
[ "protected", "function", "_slave", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_config_slaves", ")", ")", "{", "return", "$", "this", "->", "_master", "(", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "_slave", ")", "{", "$", "count", "=", "count", "(", "$", "this", "->", "_config_slaves", ")", ";", "$", "index", "=", "mt_rand", "(", "0", ",", "$", "count", "-", "1", ")", ";", "$", "config", "=", "$", "this", "->", "_config_slaves", "[", "$", "index", "]", ";", "$", "this", "->", "_slave", "=", "$", "this", "->", "_connection", "(", "$", "config", ")", ";", "}", "return", "$", "this", "->", "_slave", ";", "}" ]
Get the slave connection @return \Redis
[ "Get", "the", "slave", "connection" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L126-L138
241,007
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/Adapter.php
Adapter.run
public function run() { $this->init(); // Loop forever, except when a maximum number of requests is configured $requestsHandled = 0; while ($this->maxRequests === null || $requestsHandled < $this->maxRequests) { $this->doStep(); $requestsHandled++; } }
php
public function run() { $this->init(); // Loop forever, except when a maximum number of requests is configured $requestsHandled = 0; while ($this->maxRequests === null || $requestsHandled < $this->maxRequests) { $this->doStep(); $requestsHandled++; } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "init", "(", ")", ";", "// Loop forever, except when a maximum number of requests is configured", "$", "requestsHandled", "=", "0", ";", "while", "(", "$", "this", "->", "maxRequests", "===", "null", "||", "$", "requestsHandled", "<", "$", "this", "->", "maxRequests", ")", "{", "$", "this", "->", "doStep", "(", ")", ";", "$", "requestsHandled", "++", ";", "}", "}" ]
Starts the adapter and keeps handling requests in a loop. This method never returns and will typically be the last call in an adapter implementation script.
[ "Starts", "the", "adapter", "and", "keeps", "handling", "requests", "in", "a", "loop", ".", "This", "method", "never", "returns", "and", "will", "typically", "be", "the", "last", "call", "in", "an", "adapter", "implementation", "script", "." ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/Adapter.php#L98-L108
241,008
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/Adapter.php
Adapter.init
private function init() { if ($this->encoder === null) { // Send the adapter config as JSON payload to the host $config = new AdapterConfig( $this->codec->getName(), $this->getAdapterType(), $this->getExtraConfig() ); Codecs::json()->newEncoder($this->output)->useNewlines(false)->encode($config); // Set up encoder / decoder for further communication $this->decoder = $this->codec->newDecoder($this->input); $this->encoder = $this->codec->newEncoder($this->output); } }
php
private function init() { if ($this->encoder === null) { // Send the adapter config as JSON payload to the host $config = new AdapterConfig( $this->codec->getName(), $this->getAdapterType(), $this->getExtraConfig() ); Codecs::json()->newEncoder($this->output)->useNewlines(false)->encode($config); // Set up encoder / decoder for further communication $this->decoder = $this->codec->newDecoder($this->input); $this->encoder = $this->codec->newEncoder($this->output); } }
[ "private", "function", "init", "(", ")", "{", "if", "(", "$", "this", "->", "encoder", "===", "null", ")", "{", "// Send the adapter config as JSON payload to the host", "$", "config", "=", "new", "AdapterConfig", "(", "$", "this", "->", "codec", "->", "getName", "(", ")", ",", "$", "this", "->", "getAdapterType", "(", ")", ",", "$", "this", "->", "getExtraConfig", "(", ")", ")", ";", "Codecs", "::", "json", "(", ")", "->", "newEncoder", "(", "$", "this", "->", "output", ")", "->", "useNewlines", "(", "false", ")", "->", "encode", "(", "$", "config", ")", ";", "// Set up encoder / decoder for further communication", "$", "this", "->", "decoder", "=", "$", "this", "->", "codec", "->", "newDecoder", "(", "$", "this", "->", "input", ")", ";", "$", "this", "->", "encoder", "=", "$", "this", "->", "codec", "->", "newEncoder", "(", "$", "this", "->", "output", ")", ";", "}", "}" ]
Prepare this adapter for communication. Will send the adapter configuration to the nervus host and set up an encoder and decoder for further communication.
[ "Prepare", "this", "adapter", "for", "communication", ".", "Will", "send", "the", "adapter", "configuration", "to", "the", "nervus", "host", "and", "set", "up", "an", "encoder", "and", "decoder", "for", "further", "communication", "." ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/Adapter.php#L129-L144
241,009
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.generateTraitMethods
protected function generateTraitMethods() { if (empty($this->_traitMethodsAliases)) { return; } $this->addProperty( '___classMocker_traitMethods', $this->_traitMethodsAliases, PropertyGenerator::FLAG_PRIVATE | PropertyGenerator::FLAG_STATIC ); foreach (array_keys($this->_traitMethodsAliases) as $methodName) { if (!$this->canGenerateMethod($methodName)) { continue; } if (!$this->isValidTraitMethod($methodName)) { throw new \RuntimeException( sprintf( "Trait magic method %s::%s() is not valid, use %s() instead", $this->getName(), $methodName, '_' . $methodName ) ); } $this->generateMethod($methodName); } }
php
protected function generateTraitMethods() { if (empty($this->_traitMethodsAliases)) { return; } $this->addProperty( '___classMocker_traitMethods', $this->_traitMethodsAliases, PropertyGenerator::FLAG_PRIVATE | PropertyGenerator::FLAG_STATIC ); foreach (array_keys($this->_traitMethodsAliases) as $methodName) { if (!$this->canGenerateMethod($methodName)) { continue; } if (!$this->isValidTraitMethod($methodName)) { throw new \RuntimeException( sprintf( "Trait magic method %s::%s() is not valid, use %s() instead", $this->getName(), $methodName, '_' . $methodName ) ); } $this->generateMethod($methodName); } }
[ "protected", "function", "generateTraitMethods", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_traitMethodsAliases", ")", ")", "{", "return", ";", "}", "$", "this", "->", "addProperty", "(", "'___classMocker_traitMethods'", ",", "$", "this", "->", "_traitMethodsAliases", ",", "PropertyGenerator", "::", "FLAG_PRIVATE", "|", "PropertyGenerator", "::", "FLAG_STATIC", ")", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "_traitMethodsAliases", ")", "as", "$", "methodName", ")", "{", "if", "(", "!", "$", "this", "->", "canGenerateMethod", "(", "$", "methodName", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "isValidTraitMethod", "(", "$", "methodName", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Trait magic method %s::%s() is not valid, use %s() instead\"", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "methodName", ",", "'_'", ".", "$", "methodName", ")", ")", ";", "}", "$", "this", "->", "generateMethod", "(", "$", "methodName", ")", ";", "}", "}" ]
Generate foot print of all methods specified by all traits registered to this mock class Register all trait methods to the private static property ___classMocker_traitMethods which is accessible to the base mock object and used to call all trait methods in order @see \JSiefer\ClassMocker\Mock\BaseMock::mergeTraitMethods() @return void
[ "Generate", "foot", "print", "of", "all", "methods", "specified", "by", "all", "traits", "registered", "to", "this", "mock", "class" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L71-L102
241,010
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.canGenerateMethod
public function canGenerateMethod($methodName) { /** * any special methods only called by the base mock class * and therefor should not be made accessible * * @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods() */ switch ($methodName) { case BaseMock::CALL: case BaseMock::CONSTRUCTOR: case BaseMock::GETTER: case BaseMock::SETTER: case BaseMock::INIT: return false; } return true; }
php
public function canGenerateMethod($methodName) { /** * any special methods only called by the base mock class * and therefor should not be made accessible * * @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods() */ switch ($methodName) { case BaseMock::CALL: case BaseMock::CONSTRUCTOR: case BaseMock::GETTER: case BaseMock::SETTER: case BaseMock::INIT: return false; } return true; }
[ "public", "function", "canGenerateMethod", "(", "$", "methodName", ")", "{", "/**\n * any special methods only called by the base mock class\n * and therefor should not be made accessible\n *\n * @see \\JSiefer\\ClassMocker\\Mock\\BaseMock::__callTraitMethods()\n */", "switch", "(", "$", "methodName", ")", "{", "case", "BaseMock", "::", "CALL", ":", "case", "BaseMock", "::", "CONSTRUCTOR", ":", "case", "BaseMock", "::", "GETTER", ":", "case", "BaseMock", "::", "SETTER", ":", "case", "BaseMock", "::", "INIT", ":", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if method can be generated @param string $methodName @return bool
[ "Check", "if", "method", "can", "be", "generated" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L111-L128
241,011
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.useTrait
public function useTrait(\ReflectionClass $trait) { $alias = 'trait' . ($this->_traitsIdx++); $alias .= '_' . str_replace('\\', '__', $trait->getName()); $alias = 'Trait_' . substr(md5($alias), 0, 10) . '_' .$trait->getShortName(); $this->addUse($trait->getName(), $alias); $this->addTrait($alias); foreach ($trait->getMethods() as $method) { if ($method->isAbstract()) { continue; } $this->registerTraitMethod($alias, $method); } return $this; }
php
public function useTrait(\ReflectionClass $trait) { $alias = 'trait' . ($this->_traitsIdx++); $alias .= '_' . str_replace('\\', '__', $trait->getName()); $alias = 'Trait_' . substr(md5($alias), 0, 10) . '_' .$trait->getShortName(); $this->addUse($trait->getName(), $alias); $this->addTrait($alias); foreach ($trait->getMethods() as $method) { if ($method->isAbstract()) { continue; } $this->registerTraitMethod($alias, $method); } return $this; }
[ "public", "function", "useTrait", "(", "\\", "ReflectionClass", "$", "trait", ")", "{", "$", "alias", "=", "'trait'", ".", "(", "$", "this", "->", "_traitsIdx", "++", ")", ";", "$", "alias", ".=", "'_'", ".", "str_replace", "(", "'\\\\'", ",", "'__'", ",", "$", "trait", "->", "getName", "(", ")", ")", ";", "$", "alias", "=", "'Trait_'", ".", "substr", "(", "md5", "(", "$", "alias", ")", ",", "0", ",", "10", ")", ".", "'_'", ".", "$", "trait", "->", "getShortName", "(", ")", ";", "$", "this", "->", "addUse", "(", "$", "trait", "->", "getName", "(", ")", ",", "$", "alias", ")", ";", "$", "this", "->", "addTrait", "(", "$", "alias", ")", ";", "foreach", "(", "$", "trait", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "$", "method", "->", "isAbstract", "(", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "registerTraitMethod", "(", "$", "alias", ",", "$", "method", ")", ";", "}", "return", "$", "this", ";", "}" ]
Use a trait and save all methods so in case a second trait will overwrite any @param \ReflectionClass $trait @return $this
[ "Use", "a", "trait", "and", "save", "all", "methods", "so", "in", "case", "a", "second", "trait", "will", "overwrite", "any" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L235-L253
241,012
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.registerTraitMethod
protected function registerTraitMethod($trait, \ReflectionMethod $method) { $name = $method->getName(); $this->_method[$name] = $method; $alias = '__' . lcfirst($trait) . ucfirst($name); $this->addTraitAlias($trait . '::' . $name, $alias); $this->addTraitMethod($trait, $name); if (!isset($this->_traitMethodsAliases[$name])) { $this->_traitMethodsAliases[$name] = []; } $this->_traitMethodsAliases[$name][] = $alias; }
php
protected function registerTraitMethod($trait, \ReflectionMethod $method) { $name = $method->getName(); $this->_method[$name] = $method; $alias = '__' . lcfirst($trait) . ucfirst($name); $this->addTraitAlias($trait . '::' . $name, $alias); $this->addTraitMethod($trait, $name); if (!isset($this->_traitMethodsAliases[$name])) { $this->_traitMethodsAliases[$name] = []; } $this->_traitMethodsAliases[$name][] = $alias; }
[ "protected", "function", "registerTraitMethod", "(", "$", "trait", ",", "\\", "ReflectionMethod", "$", "method", ")", "{", "$", "name", "=", "$", "method", "->", "getName", "(", ")", ";", "$", "this", "->", "_method", "[", "$", "name", "]", "=", "$", "method", ";", "$", "alias", "=", "'__'", ".", "lcfirst", "(", "$", "trait", ")", ".", "ucfirst", "(", "$", "name", ")", ";", "$", "this", "->", "addTraitAlias", "(", "$", "trait", ".", "'::'", ".", "$", "name", ",", "$", "alias", ")", ";", "$", "this", "->", "addTraitMethod", "(", "$", "trait", ",", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_traitMethodsAliases", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "_traitMethodsAliases", "[", "$", "name", "]", "=", "[", "]", ";", "}", "$", "this", "->", "_traitMethodsAliases", "[", "$", "name", "]", "[", "]", "=", "$", "alias", ";", "}" ]
Register magic method alias @param string $trait @param \ReflectionMethod $method @return void
[ "Register", "magic", "method", "alias" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L263-L276
241,013
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.addTraitMethod
protected function addTraitMethod($trait, $method) { if (!isset($this->_traitMethods[$method])) { $this->_traitMethods[$method] = []; } else { foreach ($this->_traitMethods[$method] as $prefTrait) { $this->removeTraitOverride($prefTrait . '::' . $method); } $traits = implode(', ', $this->_traitMethods[$method]); $this->addTraitOverride($trait . '::' . $method, $traits); } $this->_traitMethods[$method][] = $trait; }
php
protected function addTraitMethod($trait, $method) { if (!isset($this->_traitMethods[$method])) { $this->_traitMethods[$method] = []; } else { foreach ($this->_traitMethods[$method] as $prefTrait) { $this->removeTraitOverride($prefTrait . '::' . $method); } $traits = implode(', ', $this->_traitMethods[$method]); $this->addTraitOverride($trait . '::' . $method, $traits); } $this->_traitMethods[$method][] = $trait; }
[ "protected", "function", "addTraitMethod", "(", "$", "trait", ",", "$", "method", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", ")", ")", "{", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", "=", "[", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", "as", "$", "prefTrait", ")", "{", "$", "this", "->", "removeTraitOverride", "(", "$", "prefTrait", ".", "'::'", ".", "$", "method", ")", ";", "}", "$", "traits", "=", "implode", "(", "', '", ",", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", ")", ";", "$", "this", "->", "addTraitOverride", "(", "$", "trait", ".", "'::'", ".", "$", "method", ",", "$", "traits", ")", ";", "}", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", "[", "]", "=", "$", "trait", ";", "}" ]
Register trait method this will overwrite all previously registered methods @param string $trait @param string $method @return void
[ "Register", "trait", "method", "this", "will", "overwrite", "all", "previously", "registered", "methods" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L287-L299
241,014
oaugustus/direct-silex-provider
src/Direct/Router/Response.php
Response.encode
public function encode($result) { if ('form' == $this->type) { array_walk_recursive($result[0], array($this, 'utf8')); $response = new SfResponse("<html><body><textarea>".json_encode($result[0])."</textarea></body></html>"); $response->headers->set('Content-Type', 'text/html'); return $response; } else { if ($this->responseEncode){ // @todo: check utf8 config option from bundle array_walk_recursive($result, array($this, 'utf8')); } $response = new SfResponse(json_encode($result)); $response->headers->set('Content-Type', 'application/json'); return $response; } }
php
public function encode($result) { if ('form' == $this->type) { array_walk_recursive($result[0], array($this, 'utf8')); $response = new SfResponse("<html><body><textarea>".json_encode($result[0])."</textarea></body></html>"); $response->headers->set('Content-Type', 'text/html'); return $response; } else { if ($this->responseEncode){ // @todo: check utf8 config option from bundle array_walk_recursive($result, array($this, 'utf8')); } $response = new SfResponse(json_encode($result)); $response->headers->set('Content-Type', 'application/json'); return $response; } }
[ "public", "function", "encode", "(", "$", "result", ")", "{", "if", "(", "'form'", "==", "$", "this", "->", "type", ")", "{", "array_walk_recursive", "(", "$", "result", "[", "0", "]", ",", "array", "(", "$", "this", ",", "'utf8'", ")", ")", ";", "$", "response", "=", "new", "SfResponse", "(", "\"<html><body><textarea>\"", ".", "json_encode", "(", "$", "result", "[", "0", "]", ")", ".", "\"</textarea></body></html>\"", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/html'", ")", ";", "return", "$", "response", ";", "}", "else", "{", "if", "(", "$", "this", "->", "responseEncode", ")", "{", "// @todo: check utf8 config option from bundle", "array_walk_recursive", "(", "$", "result", ",", "array", "(", "$", "this", ",", "'utf8'", ")", ")", ";", "}", "$", "response", "=", "new", "SfResponse", "(", "json_encode", "(", "$", "result", ")", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}", "}" ]
Encode the response into a valid json ExtDirect result. @param array $result @return string
[ "Encode", "the", "response", "into", "a", "valid", "json", "ExtDirect", "result", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Response.php#L38-L58
241,015
oaugustus/direct-silex-provider
src/Direct/Router/Response.php
Response.utf8
private function utf8(&$value, &$key) { if (is_string($value)) { $value = utf8_encode($value); } if (is_array($value)) { array_walk_recursive($value, array($this, 'utf8')); } }
php
private function utf8(&$value, &$key) { if (is_string($value)) { $value = utf8_encode($value); } if (is_array($value)) { array_walk_recursive($value, array($this, 'utf8')); } }
[ "private", "function", "utf8", "(", "&", "$", "value", ",", "&", "$", "key", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "utf8_encode", "(", "$", "value", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "array_walk_recursive", "(", "$", "value", ",", "array", "(", "$", "this", ",", "'utf8'", ")", ")", ";", "}", "}" ]
Encode the result recursivily as utf8. @param mixed $value @param string $key
[ "Encode", "the", "result", "recursivily", "as", "utf8", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Response.php#L66-L75
241,016
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.setCompilerRoot
public function setCompilerRoot($path) { $path = realpath($path); if (is_dir($path)) { $this->root = $path; } }
php
public function setCompilerRoot($path) { $path = realpath($path); if (is_dir($path)) { $this->root = $path; } }
[ "public", "function", "setCompilerRoot", "(", "$", "path", ")", "{", "$", "path", "=", "realpath", "(", "$", "path", ")", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "this", "->", "root", "=", "$", "path", ";", "}", "}" ]
Set compiler root @param string $path Path @return null
[ "Set", "compiler", "root" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L71-L77
241,017
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.addWatcher
public function addWatcher(Watcher\WatcherInterface $watcher) { $type = $watcher->getType(); $this->watchers[$type] = $watcher; }
php
public function addWatcher(Watcher\WatcherInterface $watcher) { $type = $watcher->getType(); $this->watchers[$type] = $watcher; }
[ "public", "function", "addWatcher", "(", "Watcher", "\\", "WatcherInterface", "$", "watcher", ")", "{", "$", "type", "=", "$", "watcher", "->", "getType", "(", ")", ";", "$", "this", "->", "watchers", "[", "$", "type", "]", "=", "$", "watcher", ";", "}" ]
Add named watcher instance @param Watcher\WatcherInterface $watcher Watcher instance @return null
[ "Add", "named", "watcher", "instance" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L110-L115
241,018
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.addConfig
public function addConfig($config, $watcher) { if (!$this->root) { return; } $config = realpath($config); $filesystem = new Filesystem(); $relativePath = $filesystem->makePathRelative($config, $this->root); if (substr($relativePath, 0, 2) == "..") { return; } if (!isset($this->configs[$watcher])) { $this->configs[$watcher] = array(); } $this->configs[$watcher][] = $config; }
php
public function addConfig($config, $watcher) { if (!$this->root) { return; } $config = realpath($config); $filesystem = new Filesystem(); $relativePath = $filesystem->makePathRelative($config, $this->root); if (substr($relativePath, 0, 2) == "..") { return; } if (!isset($this->configs[$watcher])) { $this->configs[$watcher] = array(); } $this->configs[$watcher][] = $config; }
[ "public", "function", "addConfig", "(", "$", "config", ",", "$", "watcher", ")", "{", "if", "(", "!", "$", "this", "->", "root", ")", "{", "return", ";", "}", "$", "config", "=", "realpath", "(", "$", "config", ")", ";", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "$", "relativePath", "=", "$", "filesystem", "->", "makePathRelative", "(", "$", "config", ",", "$", "this", "->", "root", ")", ";", "if", "(", "substr", "(", "$", "relativePath", ",", "0", ",", "2", ")", "==", "\"..\"", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "configs", "[", "$", "watcher", "]", ")", ")", "{", "$", "this", "->", "configs", "[", "$", "watcher", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "configs", "[", "$", "watcher", "]", "[", "]", "=", "$", "config", ";", "}" ]
Add config path to watch @param string $config Path to config file @param string $watcher Watcher name @return null
[ "Add", "config", "path", "to", "watch" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L125-L142
241,019
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.compile
public function compile() { if (!$this->enabled || $this->env !== "dev") { return; } foreach ($this->watchers as $name => $watcher) { if (isset($this->configs[$name])) { foreach ($this->configs[$name] as $configPath) { $files = $watcher->getChildren($configPath); if ($this->cache->isFresh($configPath, $files)) { $watcher->compile($configPath); $this->cache->write($configPath, $files); } } } } }
php
public function compile() { if (!$this->enabled || $this->env !== "dev") { return; } foreach ($this->watchers as $name => $watcher) { if (isset($this->configs[$name])) { foreach ($this->configs[$name] as $configPath) { $files = $watcher->getChildren($configPath); if ($this->cache->isFresh($configPath, $files)) { $watcher->compile($configPath); $this->cache->write($configPath, $files); } } } } }
[ "public", "function", "compile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", "||", "$", "this", "->", "env", "!==", "\"dev\"", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "watchers", "as", "$", "name", "=>", "$", "watcher", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configs", "[", "$", "name", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "configs", "[", "$", "name", "]", "as", "$", "configPath", ")", "{", "$", "files", "=", "$", "watcher", "->", "getChildren", "(", "$", "configPath", ")", ";", "if", "(", "$", "this", "->", "cache", "->", "isFresh", "(", "$", "configPath", ",", "$", "files", ")", ")", "{", "$", "watcher", "->", "compile", "(", "$", "configPath", ")", ";", "$", "this", "->", "cache", "->", "write", "(", "$", "configPath", ",", "$", "files", ")", ";", "}", "}", "}", "}", "}" ]
Compile watchers' files @return null
[ "Compile", "watchers", "files" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L149-L165
241,020
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.getInstaller
protected function getInstaller(): BaseInstaller { return Installer::create($this->io, $this->composer, $this->input); }
php
protected function getInstaller(): BaseInstaller { return Installer::create($this->io, $this->composer, $this->input); }
[ "protected", "function", "getInstaller", "(", ")", ":", "BaseInstaller", "{", "return", "Installer", "::", "create", "(", "$", "this", "->", "io", ",", "$", "this", "->", "composer", ",", "$", "this", "->", "input", ")", ";", "}" ]
Get configured installer instance. @codeCoverageIgnore @return \Composer\Installer
[ "Get", "configured", "installer", "instance", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L145-L148
241,021
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.findBestVersionForPackage
protected function findBestVersionForPackage(string $name): string { // find the latest version allowed in this pool $package = $this->versionSelector->findBestCandidate($name, null, null, 'stable'); if ($package === false) { throw new InvalidArgumentException(\sprintf( 'Could not find package %s at any version for your minimum-stability (%s).' . ' Check the package spelling or your minimum-stability.', $name, $this->stability )); } return $this->versionSelector->findRecommendedRequireVersion($package); }
php
protected function findBestVersionForPackage(string $name): string { // find the latest version allowed in this pool $package = $this->versionSelector->findBestCandidate($name, null, null, 'stable'); if ($package === false) { throw new InvalidArgumentException(\sprintf( 'Could not find package %s at any version for your minimum-stability (%s).' . ' Check the package spelling or your minimum-stability.', $name, $this->stability )); } return $this->versionSelector->findRecommendedRequireVersion($package); }
[ "protected", "function", "findBestVersionForPackage", "(", "string", "$", "name", ")", ":", "string", "{", "// find the latest version allowed in this pool", "$", "package", "=", "$", "this", "->", "versionSelector", "->", "findBestCandidate", "(", "$", "name", ",", "null", ",", "null", ",", "'stable'", ")", ";", "if", "(", "$", "package", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\\", "sprintf", "(", "'Could not find package %s at any version for your minimum-stability (%s).'", ".", "' Check the package spelling or your minimum-stability.'", ",", "$", "name", ",", "$", "this", "->", "stability", ")", ")", ";", "}", "return", "$", "this", "->", "versionSelector", "->", "findRecommendedRequireVersion", "(", "$", "package", ")", ";", "}" ]
Try to find the best version fot the package. @param string $name @throws \Narrowspark\Automatic\Common\Contract\Exception\InvalidArgumentException @return string
[ "Try", "to", "find", "the", "best", "version", "fot", "the", "package", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L159-L174
241,022
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootComposerJson
protected function updateRootComposerJson(array $requires, array $devRequires, int $type): RootPackageInterface { $this->io->writeError('Updating root package'); $this->updateRootPackageRequire($requires, $type); $this->updateRootPackageDevRequire($devRequires, $type); return $this->rootPackage; }
php
protected function updateRootComposerJson(array $requires, array $devRequires, int $type): RootPackageInterface { $this->io->writeError('Updating root package'); $this->updateRootPackageRequire($requires, $type); $this->updateRootPackageDevRequire($devRequires, $type); return $this->rootPackage; }
[ "protected", "function", "updateRootComposerJson", "(", "array", "$", "requires", ",", "array", "$", "devRequires", ",", "int", "$", "type", ")", ":", "RootPackageInterface", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Updating root package'", ")", ";", "$", "this", "->", "updateRootPackageRequire", "(", "$", "requires", ",", "$", "type", ")", ";", "$", "this", "->", "updateRootPackageDevRequire", "(", "$", "devRequires", ",", "$", "type", ")", ";", "return", "$", "this", "->", "rootPackage", ";", "}" ]
Update the root package require and dev-require. @param array $requires @param array $devRequires @param int $type @return \Composer\Package\RootPackageInterface
[ "Update", "the", "root", "package", "require", "and", "dev", "-", "require", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L185-L193
241,023
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateComposerJson
protected function updateComposerJson(array $requires, array $devRequires, int $type): void { $this->io->writeError('Updating composer.json'); if ($type === self::ADD) { $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath())); $sortPackages = $this->composer->getConfig()->get('sort-packages') ?? false; foreach ($requires as $name => $version) { $jsonManipulator->addLink('require', $name, $version, $sortPackages); } foreach ($devRequires as $name => $version) { $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages); } \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents()); } elseif ($type === self::REMOVE) { $jsonFileContent = $this->jsonFile->read(); foreach ($requires as $packageName => $version) { unset($jsonFileContent['require'][$packageName]); } foreach ($devRequires as $packageName => $version) { unset($jsonFileContent['require-dev'][$packageName]); } $this->jsonFile->write($jsonFileContent); } }
php
protected function updateComposerJson(array $requires, array $devRequires, int $type): void { $this->io->writeError('Updating composer.json'); if ($type === self::ADD) { $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath())); $sortPackages = $this->composer->getConfig()->get('sort-packages') ?? false; foreach ($requires as $name => $version) { $jsonManipulator->addLink('require', $name, $version, $sortPackages); } foreach ($devRequires as $name => $version) { $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages); } \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents()); } elseif ($type === self::REMOVE) { $jsonFileContent = $this->jsonFile->read(); foreach ($requires as $packageName => $version) { unset($jsonFileContent['require'][$packageName]); } foreach ($devRequires as $packageName => $version) { unset($jsonFileContent['require-dev'][$packageName]); } $this->jsonFile->write($jsonFileContent); } }
[ "protected", "function", "updateComposerJson", "(", "array", "$", "requires", ",", "array", "$", "devRequires", ",", "int", "$", "type", ")", ":", "void", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Updating composer.json'", ")", ";", "if", "(", "$", "type", "===", "self", "::", "ADD", ")", "{", "$", "jsonManipulator", "=", "new", "JsonManipulator", "(", "\\", "file_get_contents", "(", "$", "this", "->", "jsonFile", "->", "getPath", "(", ")", ")", ")", ";", "$", "sortPackages", "=", "$", "this", "->", "composer", "->", "getConfig", "(", ")", "->", "get", "(", "'sort-packages'", ")", "??", "false", ";", "foreach", "(", "$", "requires", "as", "$", "name", "=>", "$", "version", ")", "{", "$", "jsonManipulator", "->", "addLink", "(", "'require'", ",", "$", "name", ",", "$", "version", ",", "$", "sortPackages", ")", ";", "}", "foreach", "(", "$", "devRequires", "as", "$", "name", "=>", "$", "version", ")", "{", "$", "jsonManipulator", "->", "addLink", "(", "'require-dev'", ",", "$", "name", ",", "$", "version", ",", "$", "sortPackages", ")", ";", "}", "\\", "file_put_contents", "(", "$", "this", "->", "jsonFile", "->", "getPath", "(", ")", ",", "$", "jsonManipulator", "->", "getContents", "(", ")", ")", ";", "}", "elseif", "(", "$", "type", "===", "self", "::", "REMOVE", ")", "{", "$", "jsonFileContent", "=", "$", "this", "->", "jsonFile", "->", "read", "(", ")", ";", "foreach", "(", "$", "requires", "as", "$", "packageName", "=>", "$", "version", ")", "{", "unset", "(", "$", "jsonFileContent", "[", "'require'", "]", "[", "$", "packageName", "]", ")", ";", "}", "foreach", "(", "$", "devRequires", "as", "$", "packageName", "=>", "$", "version", ")", "{", "unset", "(", "$", "jsonFileContent", "[", "'require-dev'", "]", "[", "$", "packageName", "]", ")", ";", "}", "$", "this", "->", "jsonFile", "->", "write", "(", "$", "jsonFileContent", ")", ";", "}", "}" ]
Manipulate root composer.json with the new packages and dump it. @param array $requires @param array $devRequires @param int $type @throws \Exception happens in the JsonFile class @return void
[ "Manipulate", "root", "composer", ".", "json", "with", "the", "new", "packages", "and", "dump", "it", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L206-L236
241,024
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.runInstaller
protected function runInstaller(RootPackageInterface $rootPackage, array $whitelistPackages): int { $this->io->writeError('Running an update to install dependent packages'); $this->composer->setPackage($rootPackage); $installer = $this->getInstaller(); $installer->setUpdateWhitelist($whitelistPackages); return $installer->run(); }
php
protected function runInstaller(RootPackageInterface $rootPackage, array $whitelistPackages): int { $this->io->writeError('Running an update to install dependent packages'); $this->composer->setPackage($rootPackage); $installer = $this->getInstaller(); $installer->setUpdateWhitelist($whitelistPackages); return $installer->run(); }
[ "protected", "function", "runInstaller", "(", "RootPackageInterface", "$", "rootPackage", ",", "array", "$", "whitelistPackages", ")", ":", "int", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Running an update to install dependent packages'", ")", ";", "$", "this", "->", "composer", "->", "setPackage", "(", "$", "rootPackage", ")", ";", "$", "installer", "=", "$", "this", "->", "getInstaller", "(", ")", ";", "$", "installer", "->", "setUpdateWhitelist", "(", "$", "whitelistPackages", ")", ";", "return", "$", "installer", "->", "run", "(", ")", ";", "}" ]
Install selected packages. @param \Composer\Package\RootPackageInterface $rootPackage @param array $whitelistPackages @throws \Exception @return int
[ "Install", "selected", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L248-L258
241,025
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootPackageRequire
protected function updateRootPackageRequire(array $packages, int $type): void { $requires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getRequires() ); $this->rootPackage->setRequires($requires); }
php
protected function updateRootPackageRequire(array $packages, int $type): void { $requires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getRequires() ); $this->rootPackage->setRequires($requires); }
[ "protected", "function", "updateRootPackageRequire", "(", "array", "$", "packages", ",", "int", "$", "type", ")", ":", "void", "{", "$", "requires", "=", "$", "this", "->", "manipulateRootPackage", "(", "$", "packages", ",", "$", "type", ",", "$", "this", "->", "rootPackage", "->", "getRequires", "(", ")", ")", ";", "$", "this", "->", "rootPackage", "->", "setRequires", "(", "$", "requires", ")", ";", "}" ]
Update the root required packages. @param array $packages @param int $type @return void
[ "Update", "the", "root", "required", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L278-L287
241,026
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootPackageDevRequire
protected function updateRootPackageDevRequire(array $packages, int $type): void { $devRequires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getDevRequires() ); $this->rootPackage->setDevRequires($devRequires); }
php
protected function updateRootPackageDevRequire(array $packages, int $type): void { $devRequires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getDevRequires() ); $this->rootPackage->setDevRequires($devRequires); }
[ "protected", "function", "updateRootPackageDevRequire", "(", "array", "$", "packages", ",", "int", "$", "type", ")", ":", "void", "{", "$", "devRequires", "=", "$", "this", "->", "manipulateRootPackage", "(", "$", "packages", ",", "$", "type", ",", "$", "this", "->", "rootPackage", "->", "getDevRequires", "(", ")", ")", ";", "$", "this", "->", "rootPackage", "->", "setDevRequires", "(", "$", "devRequires", ")", ";", "}" ]
Update the root dev-required packages. @param array $packages @param int $type @return void
[ "Update", "the", "root", "dev", "-", "required", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L297-L306
241,027
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.manipulateRootPackage
protected function manipulateRootPackage(array $packages, int $type, array $requires): array { if ($type === self::ADD) { foreach ($packages as $packageName => $version) { $requires[$packageName] = new Link( '__root__', $packageName, (new VersionParser())->parseConstraints($version), 'relates to', $version ); } } elseif ($type === self::REMOVE) { foreach ($packages as $packageName => $version) { unset($requires[$packageName]); } } return $requires; }
php
protected function manipulateRootPackage(array $packages, int $type, array $requires): array { if ($type === self::ADD) { foreach ($packages as $packageName => $version) { $requires[$packageName] = new Link( '__root__', $packageName, (new VersionParser())->parseConstraints($version), 'relates to', $version ); } } elseif ($type === self::REMOVE) { foreach ($packages as $packageName => $version) { unset($requires[$packageName]); } } return $requires; }
[ "protected", "function", "manipulateRootPackage", "(", "array", "$", "packages", ",", "int", "$", "type", ",", "array", "$", "requires", ")", ":", "array", "{", "if", "(", "$", "type", "===", "self", "::", "ADD", ")", "{", "foreach", "(", "$", "packages", "as", "$", "packageName", "=>", "$", "version", ")", "{", "$", "requires", "[", "$", "packageName", "]", "=", "new", "Link", "(", "'__root__'", ",", "$", "packageName", ",", "(", "new", "VersionParser", "(", ")", ")", "->", "parseConstraints", "(", "$", "version", ")", ",", "'relates to'", ",", "$", "version", ")", ";", "}", "}", "elseif", "(", "$", "type", "===", "self", "::", "REMOVE", ")", "{", "foreach", "(", "$", "packages", "as", "$", "packageName", "=>", "$", "version", ")", "{", "unset", "(", "$", "requires", "[", "$", "packageName", "]", ")", ";", "}", "}", "return", "$", "requires", ";", "}" ]
Manipulates the given requires with the new added packages. @param array $packages @param int $type @param array $requires @return array
[ "Manipulates", "the", "given", "requires", "with", "the", "new", "added", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L317-L336
241,028
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionIndex
public function actionIndex() { $searchModel = new UserSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $statusArray = User::getStatusArray(); $roleArray = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'statusArray' => $statusArray, 'roleArray' => $roleArray ]); }
php
public function actionIndex() { $searchModel = new UserSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $statusArray = User::getStatusArray(); $roleArray = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'statusArray' => $statusArray, 'roleArray' => $roleArray ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "UserSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", "$", "statusArray", "=", "User", "::", "getStatusArray", "(", ")", ";", "$", "roleArray", "=", "ArrayHelper", "::", "map", "(", "Yii", "::", "$", "app", "->", "authManager", "->", "getRoles", "(", ")", ",", "'name'", ",", "'description'", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "'statusArray'", "=>", "$", "statusArray", ",", "'roleArray'", "=>", "$", "roleArray", "]", ")", ";", "}" ]
Users list page.
[ "Users", "list", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L71-L85
241,029
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionUpdate
public function actionUpdate($id) { $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id)); $user = $this->findUser($id); //return $this->render('view', [ // 'user' => $user, // 'roles' => $roles, // 'user_permit' => $user_permit, // 'moduleName' => Yii::$app->controller->module->id //]); return $this->render('update', [ 'user' => $user, 'roles' => $roles, 'user_permit' => $user_permit, 'moduleName' => Yii::$app->controller->module->id ]); /* $user = $this->findUser($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } //роли Yii::$app->authManager->revokeAll($user->getId()); if(Yii::$app->request->post('roles')){ foreach(Yii::$app->request->post('roles') as $role) { $new_role = Yii::$app->authManager->getRole($role); Yii::$app->authManager->assign($new_role, $user->getId()); } } return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/ }
php
public function actionUpdate($id) { $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id)); $user = $this->findUser($id); //return $this->render('view', [ // 'user' => $user, // 'roles' => $roles, // 'user_permit' => $user_permit, // 'moduleName' => Yii::$app->controller->module->id //]); return $this->render('update', [ 'user' => $user, 'roles' => $roles, 'user_permit' => $user_permit, 'moduleName' => Yii::$app->controller->module->id ]); /* $user = $this->findUser($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } //роли Yii::$app->authManager->revokeAll($user->getId()); if(Yii::$app->request->post('roles')){ foreach(Yii::$app->request->post('roles') as $role) { $new_role = Yii::$app->authManager->getRole($role); Yii::$app->authManager->assign($new_role, $user->getId()); } } return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/ }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "roles", "=", "ArrayHelper", "::", "map", "(", "Yii", "::", "$", "app", "->", "authManager", "->", "getRoles", "(", ")", ",", "'name'", ",", "'description'", ")", ";", "$", "user_permit", "=", "array_keys", "(", "Yii", "::", "$", "app", "->", "authManager", "->", "getRolesByUser", "(", "$", "id", ")", ")", ";", "$", "user", "=", "$", "this", "->", "findUser", "(", "$", "id", ")", ";", "//return $this->render('view', [", "// 'user' => $user,", "// 'roles' => $roles,", "// 'user_permit' => $user_permit,", "// 'moduleName' => Yii::$app->controller->module->id", "//]);", "return", "$", "this", "->", "render", "(", "'update'", ",", "[", "'user'", "=>", "$", "user", ",", "'roles'", "=>", "$", "roles", ",", "'user_permit'", "=>", "$", "user_permit", ",", "'moduleName'", "=>", "Yii", "::", "$", "app", "->", "controller", "->", "module", "->", "id", "]", ")", ";", "/* $user = $this->findUser($id);\n\n if ($model->load(Yii::$app->request->post()) && $model->save()) {\n return $this->redirect(['view', 'id' => $model->id]);\n } else {\n return $this->render('update', [\n 'model' => $model,\n ]);\n }\n\n //роли\n Yii::$app->authManager->revokeAll($user->getId());\n if(Yii::$app->request->post('roles')){\n foreach(Yii::$app->request->post('roles') as $role)\n {\n $new_role = Yii::$app->authManager->getRole($role);\n Yii::$app->authManager->assign($new_role, $user->getId());\n }\n }\n return $this->redirect(Url::to([\"/\".Yii::$app->controller->module->id.\"/user/view\", 'id' => $user->getId()]));*/", "}" ]
Updates an existing Users model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Users", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L140-L181
241,030
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionMassDelete
public function actionMassDelete() { if (($ids = Yii::$app->request->post('ids')) !== null) { $models = $this->findUser($ids); foreach ($models as $model) { $model->delete($model); } return $this->redirect(['index']); } else { throw new HttpException(400); } }
php
public function actionMassDelete() { if (($ids = Yii::$app->request->post('ids')) !== null) { $models = $this->findUser($ids); foreach ($models as $model) { $model->delete($model); } return $this->redirect(['index']); } else { throw new HttpException(400); } }
[ "public", "function", "actionMassDelete", "(", ")", "{", "if", "(", "(", "$", "ids", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'ids'", ")", ")", "!==", "null", ")", "{", "$", "models", "=", "$", "this", "->", "findUser", "(", "$", "ids", ")", ";", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "$", "model", "->", "delete", "(", "$", "model", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "else", "{", "throw", "new", "HttpException", "(", "400", ")", ";", "}", "}" ]
Delete multiple users page.
[ "Delete", "multiple", "users", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L195-L206
241,031
cubiclab/users-cube
controllers/backend/UserController.php
UserController.findUser
private function findUser($id) { if (is_array($id)) { /** @var User $user */ $model = User::findIdentities($id); } else { /** @var User $user */ $model = User::findIdentity($id); } if ($model !== null) { return $model; } else { throw new NotFoundHttpException('User not found'); } }
php
private function findUser($id) { if (is_array($id)) { /** @var User $user */ $model = User::findIdentities($id); } else { /** @var User $user */ $model = User::findIdentity($id); } if ($model !== null) { return $model; } else { throw new NotFoundHttpException('User not found'); } }
[ "private", "function", "findUser", "(", "$", "id", ")", "{", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "/** @var User $user */", "$", "model", "=", "User", "::", "findIdentities", "(", "$", "id", ")", ";", "}", "else", "{", "/** @var User $user */", "$", "model", "=", "User", "::", "findIdentity", "(", "$", "id", ")", ";", "}", "if", "(", "$", "model", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "'User not found'", ")", ";", "}", "}" ]
Find User model by ID @param integer|array $id User ID @return \cubiclab\users\models\User User @throws NotFoundHttpException User not found
[ "Find", "User", "model", "by", "ID" ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L216-L230
241,032
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.getBackLink
public function getBackLink($fallback = '') { $url = ''; if ($this->owner->Request) { if ($this->owner->Request->requestVar('BackURL')) { $url = $this->owner->Request->requestVar('BackURL'); } else { if ($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) { $url = $this->owner->Request->getHeader('X-Backurl'); } else { if ($this->owner->Request->getHeader('Referer')) { $url = $this->owner->Request->getHeader('Referer'); } } } } if (!$url) { $url = $fallback ? $fallback : singleton('director')->baseURL(); } return $url; }
php
public function getBackLink($fallback = '') { $url = ''; if ($this->owner->Request) { if ($this->owner->Request->requestVar('BackURL')) { $url = $this->owner->Request->requestVar('BackURL'); } else { if ($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) { $url = $this->owner->Request->getHeader('X-Backurl'); } else { if ($this->owner->Request->getHeader('Referer')) { $url = $this->owner->Request->getHeader('Referer'); } } } } if (!$url) { $url = $fallback ? $fallback : singleton('director')->baseURL(); } return $url; }
[ "public", "function", "getBackLink", "(", "$", "fallback", "=", "''", ")", "{", "$", "url", "=", "''", ";", "if", "(", "$", "this", "->", "owner", "->", "Request", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "Request", "->", "requestVar", "(", "'BackURL'", ")", ")", "{", "$", "url", "=", "$", "this", "->", "owner", "->", "Request", "->", "requestVar", "(", "'BackURL'", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "owner", "->", "Request", "->", "isAjax", "(", ")", "&&", "$", "this", "->", "owner", "->", "Request", "->", "getHeader", "(", "'X-Backurl'", ")", ")", "{", "$", "url", "=", "$", "this", "->", "owner", "->", "Request", "->", "getHeader", "(", "'X-Backurl'", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "owner", "->", "Request", "->", "getHeader", "(", "'Referer'", ")", ")", "{", "$", "url", "=", "$", "this", "->", "owner", "->", "Request", "->", "getHeader", "(", "'Referer'", ")", ";", "}", "}", "}", "}", "if", "(", "!", "$", "url", ")", "{", "$", "url", "=", "$", "fallback", "?", "$", "fallback", ":", "singleton", "(", "'director'", ")", "->", "baseURL", "(", ")", ";", "}", "return", "$", "url", ";", "}" ]
Find a back link for current controller @param string $fallback @return string
[ "Find", "a", "back", "link", "for", "current", "controller" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L20-L43
241,033
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.displayNiceView
public function displayNiceView($controller = null, $url = '', $action = '') { if (!$controller) { $controller = $this->owner; } return singleton('director')->create_view($controller, $url, $action); }
php
public function displayNiceView($controller = null, $url = '', $action = '') { if (!$controller) { $controller = $this->owner; } return singleton('director')->create_view($controller, $url, $action); }
[ "public", "function", "displayNiceView", "(", "$", "controller", "=", "null", ",", "$", "url", "=", "''", ",", "$", "action", "=", "''", ")", "{", "if", "(", "!", "$", "controller", ")", "{", "$", "controller", "=", "$", "this", "->", "owner", ";", "}", "return", "singleton", "(", "'director'", ")", "->", "create_view", "(", "$", "controller", ",", "$", "url", ",", "$", "action", ")", ";", "}" ]
Display a controller using a Page view @param null $controller @param string $url @param string $action @return @Controller
[ "Display", "a", "controller", "using", "a", "Page", "view" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L53-L60
241,034
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.respondToFormAppropriately
public function respondToFormAppropriately(array $params, $form = null, $redirect = '') { if ($redirect && !isset($params['redirect'])) { $params['redirect'] = $redirect; } if ($this->owner->Request->isAjax()) { if (!isset($params['code'])) { $params['code'] = 200; } if (!isset($params['code'])) { $params['status'] = 'success'; } return singleton('director')->ajax_response($params, $params['code'], $params['status']); } else { if (isset($params['redirect'])) { $this->owner->redirect($params['redirect']); } if ($form && isset($params['message'])) { $form->sessionMessage($params['message'], 'good'); } if (!$this->owner->redirectedTo()) { $this->owner->redirectBack(); } } }
php
public function respondToFormAppropriately(array $params, $form = null, $redirect = '') { if ($redirect && !isset($params['redirect'])) { $params['redirect'] = $redirect; } if ($this->owner->Request->isAjax()) { if (!isset($params['code'])) { $params['code'] = 200; } if (!isset($params['code'])) { $params['status'] = 'success'; } return singleton('director')->ajax_response($params, $params['code'], $params['status']); } else { if (isset($params['redirect'])) { $this->owner->redirect($params['redirect']); } if ($form && isset($params['message'])) { $form->sessionMessage($params['message'], 'good'); } if (!$this->owner->redirectedTo()) { $this->owner->redirectBack(); } } }
[ "public", "function", "respondToFormAppropriately", "(", "array", "$", "params", ",", "$", "form", "=", "null", ",", "$", "redirect", "=", "''", ")", "{", "if", "(", "$", "redirect", "&&", "!", "isset", "(", "$", "params", "[", "'redirect'", "]", ")", ")", "{", "$", "params", "[", "'redirect'", "]", "=", "$", "redirect", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "Request", "->", "isAjax", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'code'", "]", ")", ")", "{", "$", "params", "[", "'code'", "]", "=", "200", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'code'", "]", ")", ")", "{", "$", "params", "[", "'status'", "]", "=", "'success'", ";", "}", "return", "singleton", "(", "'director'", ")", "->", "ajax_response", "(", "$", "params", ",", "$", "params", "[", "'code'", "]", ",", "$", "params", "[", "'status'", "]", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "params", "[", "'redirect'", "]", ")", ")", "{", "$", "this", "->", "owner", "->", "redirect", "(", "$", "params", "[", "'redirect'", "]", ")", ";", "}", "if", "(", "$", "form", "&&", "isset", "(", "$", "params", "[", "'message'", "]", ")", ")", "{", "$", "form", "->", "sessionMessage", "(", "$", "params", "[", "'message'", "]", ",", "'good'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "owner", "->", "redirectedTo", "(", ")", ")", "{", "$", "this", "->", "owner", "->", "redirectBack", "(", ")", ";", "}", "}", "}" ]
Respond to a form view ajax or redirect @param array $params @param \Form $form @param string $redirect @return \SS_HTTPResponse|null
[ "Respond", "to", "a", "form", "view", "ajax", "or", "redirect" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L69-L97
241,035
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeIsset
protected function _invokeIsset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); return !empty($property); }
php
protected function _invokeIsset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); return !empty($property); }
[ "protected", "function", "_invokeIsset", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name", ")", ";", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "return", "!", "empty", "(", "$", "property", ")", ";", "}" ]
Internal magic checker Magic method called when `issetProp()`, `isset($this->prop)` or `empty($this->prop)` are invoked. @param string $name The name of the property to get @return bool This will return `true` if the property exists, `false` otherwise
[ "Internal", "magic", "checker" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L238-L246
241,036
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeReset
protected function _invokeReset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { return $this->_invokeUnset($name); } else { $classname = get_class($this); $reflection = new ReflectionClass($classname); $properties = $reflection->getDefaultProperties(); if (!empty($properties) && array_key_exists($property, $properties)) { $this->{$property} = $properties[$property]; } } } return $this; }
php
protected function _invokeReset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { return $this->_invokeUnset($name); } else { $classname = get_class($this); $reflection = new ReflectionClass($classname); $properties = $reflection->getDefaultProperties(); if (!empty($properties) && array_key_exists($property, $properties)) { $this->{$property} = $properties[$property]; } } } return $this; }
[ "protected", "function", "_invokeReset", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name", ")", ";", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "if", "(", "$", "is_static", ")", "{", "return", "$", "this", "->", "_invokeUnset", "(", "$", "name", ")", ";", "}", "else", "{", "$", "classname", "=", "get_class", "(", "$", "this", ")", ";", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "$", "properties", "=", "$", "reflection", "->", "getDefaultProperties", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", "&&", "array_key_exists", "(", "$", "property", ",", "$", "properties", ")", ")", "{", "$", "this", "->", "{", "$", "property", "}", "=", "$", "properties", "[", "$", "property", "]", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Internal magic re-setter Magic method called when `resetProp(arg, value)` is invoked. As this can not work on statics, in this case it is an alias of `unset`. @param string $name The name of the property to get @return self Returns `$this` for method chaining
[ "Internal", "magic", "re", "-", "setter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L282-L302
241,037
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeGet
protected function _invokeGet($name, $default = null) { if (!self::__isInvokable($name)) { return null; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { return $is_static ? @$this::${$property} : @$this->{$property}; } return $default; }
php
protected function _invokeGet($name, $default = null) { if (!self::__isInvokable($name)) { return null; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { return $is_static ? @$this::${$property} : @$this->{$property}; } return $default; }
[ "protected", "function", "_invokeGet", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name", ")", ";", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "return", "$", "is_static", "?", "@", "$", "this", "::", "$", "{", "$", "property", "}", ":", "@", "$", "this", "->", "{", "$", "property", "}", ";", "}", "return", "$", "default", ";", "}" ]
Internal magic getter Magic method called when `getProp(arg, default)` or `$this->prop` are invoked. @param string $name The name of the property to get @param mixed $default The default value to return if the property doesn't exist @return mixed This will return the result of a magic method, or nothing if nothing can be done
[ "Internal", "magic", "getter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L313-L324
241,038
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeSet
protected function _invokeSet($name, $value) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { $this::${$property} = $value; } else { $this->{$property} = $value; } } return $this; }
php
protected function _invokeSet($name, $value) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { $this::${$property} = $value; } else { $this->{$property} = $value; } } return $this; }
[ "protected", "function", "_invokeSet", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name", ")", ";", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "if", "(", "$", "is_static", ")", "{", "$", "this", "::", "$", "{", "$", "property", "}", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "{", "$", "property", "}", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Internal magic setter Magic method called when `setProp(arg, value)` or `$this->arg = value` are invoked. @param string $name The name of the property to get @param mixed $value The value to set for the property @return self Returns `$this` for method chaining
[ "Internal", "magic", "setter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L335-L350
241,039
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isInvokable
private function __isInvokable($name) { if (!$this->__isCalled) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isPublic(); } } return true; }
php
private function __isInvokable($name) { if (!$this->__isCalled) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isPublic(); } } return true; }
[ "private", "function", "__isInvokable", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "__isCalled", ")", "{", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "$", "reflection", "=", "new", "ReflectionProperty", "(", "get_class", "(", "$", "this", ")", ",", "$", "property", ")", ";", "return", "$", "reflection", "->", "isPublic", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Check if a property is invokable in the final object Returns `false` if property access was direct and its scope is not public. @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "invokable", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L360-L370
241,040
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isStatic
private function __isStatic($name) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isStatic(); } return true; }
php
private function __isStatic($name) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isStatic(); } return true; }
[ "private", "function", "__isStatic", "(", "$", "name", ")", "{", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "$", "reflection", "=", "new", "ReflectionProperty", "(", "get_class", "(", "$", "this", ")", ",", "$", "property", ")", ";", "return", "$", "reflection", "->", "isStatic", "(", ")", ";", "}", "return", "true", ";", "}" ]
Check if a property is static in the final object @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "static", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L378-L386
241,041
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isInvokableStatic
private static function __isInvokableStatic($name) { $classname = get_called_class(); $reflection_class = new ReflectionClass($classname); $properties = $reflection_class->getStaticProperties(); $property = self::findPropertyNameStatic($name, $classname); if (!empty($property)) { $reflection = new ReflectionProperty($classname, $property); return (bool) !($reflection->isPrivate()); } return true; }
php
private static function __isInvokableStatic($name) { $classname = get_called_class(); $reflection_class = new ReflectionClass($classname); $properties = $reflection_class->getStaticProperties(); $property = self::findPropertyNameStatic($name, $classname); if (!empty($property)) { $reflection = new ReflectionProperty($classname, $property); return (bool) !($reflection->isPrivate()); } return true; }
[ "private", "static", "function", "__isInvokableStatic", "(", "$", "name", ")", "{", "$", "classname", "=", "get_called_class", "(", ")", ";", "$", "reflection_class", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "$", "properties", "=", "$", "reflection_class", "->", "getStaticProperties", "(", ")", ";", "$", "property", "=", "self", "::", "findPropertyNameStatic", "(", "$", "name", ",", "$", "classname", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "$", "reflection", "=", "new", "ReflectionProperty", "(", "$", "classname", ",", "$", "property", ")", ";", "return", "(", "bool", ")", "!", "(", "$", "reflection", "->", "isPrivate", "(", ")", ")", ";", "}", "return", "true", ";", "}" ]
Check if a property is statically invokable in the final object Returns `false` if property access was direct and its scope is not static & public. @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "statically", "invokable", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L396-L407
241,042
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.findPropertyNameStatic
public static function findPropertyNameStatic($name, $object) { $property = null; if (property_exists($object, $name)) { $property = $name; } else { // _name $underscore_name = '_'.$name; if (property_exists($object, $underscore_name)) { $property = $underscore_name; } else { // __name $doubleunderscore_name = '__'.$name; if (property_exists($object, $doubleunderscore_name)) { $property = $doubleunderscore_name; } } } return $property; }
php
public static function findPropertyNameStatic($name, $object) { $property = null; if (property_exists($object, $name)) { $property = $name; } else { // _name $underscore_name = '_'.$name; if (property_exists($object, $underscore_name)) { $property = $underscore_name; } else { // __name $doubleunderscore_name = '__'.$name; if (property_exists($object, $doubleunderscore_name)) { $property = $doubleunderscore_name; } } } return $property; }
[ "public", "static", "function", "findPropertyNameStatic", "(", "$", "name", ",", "$", "object", ")", "{", "$", "property", "=", "null", ";", "if", "(", "property_exists", "(", "$", "object", ",", "$", "name", ")", ")", "{", "$", "property", "=", "$", "name", ";", "}", "else", "{", "// _name", "$", "underscore_name", "=", "'_'", ".", "$", "name", ";", "if", "(", "property_exists", "(", "$", "object", ",", "$", "underscore_name", ")", ")", "{", "$", "property", "=", "$", "underscore_name", ";", "}", "else", "{", "// __name", "$", "doubleunderscore_name", "=", "'__'", ".", "$", "name", ";", "if", "(", "property_exists", "(", "$", "object", ",", "$", "doubleunderscore_name", ")", ")", "{", "$", "property", "=", "$", "doubleunderscore_name", ";", "}", "}", "}", "return", "$", "property", ";", "}" ]
Search a property name in the current object with one or tow leading underscores @param string $name The property name to transform @param string|object $object The object or a class name to work on @return string The transformed property name
[ "Search", "a", "property", "name", "in", "the", "current", "object", "with", "one", "or", "tow", "leading", "underscores" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L427-L446
241,043
serlo/athene2-common
src/Common/src/Common/Validator/NotIdentical.php
NotIdentical.isValid
public function isValid($value, array $context = null) { $this->setValue($value); $token = $this->getToken(); if (!$this->getLiteral() && $context !== null) { if (is_array($token)) { while (is_array($token)) { $key = key($token); if (!isset($context[$key])) { break; } $context = $context[$key]; $token = $token[$key]; } } // if $token is an array it means the above loop didn't went all the way down to the leaf, // so the $token structure doesn't match the $context structure if (is_array($token) || !isset($context[$token])) { $token = $this->getToken(); } else { $token = $context[$token]; } } if ($token === null) { $this->error(self::MISSING_TOKEN); return false; } $strict = $this->getStrict(); if (!($strict && ($value !== $token)) || (!$strict && ($value != $token))) { $this->error(self::SAME); return false; } return true; }
php
public function isValid($value, array $context = null) { $this->setValue($value); $token = $this->getToken(); if (!$this->getLiteral() && $context !== null) { if (is_array($token)) { while (is_array($token)) { $key = key($token); if (!isset($context[$key])) { break; } $context = $context[$key]; $token = $token[$key]; } } // if $token is an array it means the above loop didn't went all the way down to the leaf, // so the $token structure doesn't match the $context structure if (is_array($token) || !isset($context[$token])) { $token = $this->getToken(); } else { $token = $context[$token]; } } if ($token === null) { $this->error(self::MISSING_TOKEN); return false; } $strict = $this->getStrict(); if (!($strict && ($value !== $token)) || (!$strict && ($value != $token))) { $this->error(self::SAME); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "$", "token", "=", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "getLiteral", "(", ")", "&&", "$", "context", "!==", "null", ")", "{", "if", "(", "is_array", "(", "$", "token", ")", ")", "{", "while", "(", "is_array", "(", "$", "token", ")", ")", "{", "$", "key", "=", "key", "(", "$", "token", ")", ";", "if", "(", "!", "isset", "(", "$", "context", "[", "$", "key", "]", ")", ")", "{", "break", ";", "}", "$", "context", "=", "$", "context", "[", "$", "key", "]", ";", "$", "token", "=", "$", "token", "[", "$", "key", "]", ";", "}", "}", "// if $token is an array it means the above loop didn't went all the way down to the leaf,", "// so the $token structure doesn't match the $context structure", "if", "(", "is_array", "(", "$", "token", ")", "||", "!", "isset", "(", "$", "context", "[", "$", "token", "]", ")", ")", "{", "$", "token", "=", "$", "this", "->", "getToken", "(", ")", ";", "}", "else", "{", "$", "token", "=", "$", "context", "[", "$", "token", "]", ";", "}", "}", "if", "(", "$", "token", "===", "null", ")", "{", "$", "this", "->", "error", "(", "self", "::", "MISSING_TOKEN", ")", ";", "return", "false", ";", "}", "$", "strict", "=", "$", "this", "->", "getStrict", "(", ")", ";", "if", "(", "!", "(", "$", "strict", "&&", "(", "$", "value", "!==", "$", "token", ")", ")", "||", "(", "!", "$", "strict", "&&", "(", "$", "value", "!=", "$", "token", ")", ")", ")", "{", "$", "this", "->", "error", "(", "self", "::", "SAME", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns true if and only if a token has been set and the provided value matches that token. @param mixed $value @param array $context @return bool @throws Exception\RuntimeException if the token doesn't exist in the context array
[ "Returns", "true", "if", "and", "only", "if", "a", "token", "has", "been", "set", "and", "the", "provided", "value", "matches", "that", "token", "." ]
b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c
https://github.com/serlo/athene2-common/blob/b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c/src/Common/src/Common/Validator/NotIdentical.php#L37-L76
241,044
slickframework/mvc
src/Service/Entity/AbstractEntityService.php
AbstractEntityService.setEntityClass
public function setEntityClass($className) { if ( !class_exists($className) || !is_subclass_of($className, EntityInterface::class) ) { throw new InvalidEntityClassException( "Class '{$className}' does not implements the " . "Slick\Orm\EntityInterface interface." ); } $this->entityClass = $className; return $this; }
php
public function setEntityClass($className) { if ( !class_exists($className) || !is_subclass_of($className, EntityInterface::class) ) { throw new InvalidEntityClassException( "Class '{$className}' does not implements the " . "Slick\Orm\EntityInterface interface." ); } $this->entityClass = $className; return $this; }
[ "public", "function", "setEntityClass", "(", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", "||", "!", "is_subclass_of", "(", "$", "className", ",", "EntityInterface", "::", "class", ")", ")", "{", "throw", "new", "InvalidEntityClassException", "(", "\"Class '{$className}' does not implements the \"", ".", "\"Slick\\Orm\\EntityInterface interface.\"", ")", ";", "}", "$", "this", "->", "entityClass", "=", "$", "className", ";", "return", "$", "this", ";", "}" ]
Set FQ entity class name @param string $className @throws InvalidEntityClassException If the provided class name does not implements the Slick\Orm\EntityInterface interface. @return $this|self|AbstractEntityService
[ "Set", "FQ", "entity", "class", "name" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Service/Entity/AbstractEntityService.php#L46-L60
241,045
slickframework/mvc
src/Service/Entity/AbstractEntityService.php
AbstractEntityService.getEntityClassName
public function getEntityClassName() { if (null == $this->entityClass) { $this->setEntityClass(get_class($this->getEntity())); } return $this->entityClass; }
php
public function getEntityClassName() { if (null == $this->entityClass) { $this->setEntityClass(get_class($this->getEntity())); } return $this->entityClass; }
[ "public", "function", "getEntityClassName", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "entityClass", ")", "{", "$", "this", "->", "setEntityClass", "(", "get_class", "(", "$", "this", "->", "getEntity", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "entityClass", ";", "}" ]
Get the entity FQ class name @return string
[ "Get", "the", "entity", "FQ", "class", "name" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Service/Entity/AbstractEntityService.php#L80-L86
241,046
etcinit/tutum-php
src/Chromabits/TutumClient/ClientFactory.php
ClientFactory.makeFromEnvironment
public function makeFromEnvironment() { $env = new EnvUtils(); // Check that we have all variables we need if (!$env->hasBearerKey()) { throw new Exception( 'TUTUM_AUTH is not set. Unable to create from environment' ); } $client = new Client('', ''); $client->setBearerKey($env->getBearerKey()); return $client; }
php
public function makeFromEnvironment() { $env = new EnvUtils(); // Check that we have all variables we need if (!$env->hasBearerKey()) { throw new Exception( 'TUTUM_AUTH is not set. Unable to create from environment' ); } $client = new Client('', ''); $client->setBearerKey($env->getBearerKey()); return $client; }
[ "public", "function", "makeFromEnvironment", "(", ")", "{", "$", "env", "=", "new", "EnvUtils", "(", ")", ";", "// Check that we have all variables we need", "if", "(", "!", "$", "env", "->", "hasBearerKey", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'TUTUM_AUTH is not set. Unable to create from environment'", ")", ";", "}", "$", "client", "=", "new", "Client", "(", "''", ",", "''", ")", ";", "$", "client", "->", "setBearerKey", "(", "$", "env", "->", "getBearerKey", "(", ")", ")", ";", "return", "$", "client", ";", "}" ]
Build a client using configuration from the environment @return Client @throws Exception
[ "Build", "a", "client", "using", "configuration", "from", "the", "environment" ]
39fb3375e0d47109a5da70a0e441efb8fd4f4008
https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/ClientFactory.php#L24-L39
241,047
belgattitude/openstore-akilia
src/OpenstoreAkilia/Db/DbExecuter.php
DbExecuter.executeSQL
public function executeSQL($key, $query, $disable_foreign_key_checks = true, $entity=null) { if ($entity !== null && $entity != $this->last_entity) { $this->log("------------------------------------------------------"); $this->log("Entity: '$entity'"); $this->log("------------------------------------------------------"); $this->last_entity = $entity; } $this->log(" * Sync::executeSQL '$key'..."); $total_time_start = microtime(true); if ($disable_foreign_key_checks) { $this->adapter->query('set foreign_key_checks=0'); $this->log(" * FK : Foreign key check disabled"); } try { $time_start = microtime(true); $result = $this->adapter->query($query, ZendDb::QUERY_MODE_EXECUTE); $affected_rows = $result->getAffectedRows(); // Log stuffs $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $formatted_query = preg_replace('/(\n)|(\r)|(\t)/', ' ', $query); $formatted_query = preg_replace('/(\ )+/', ' ', $formatted_query); $this->log(" * SQL: " . substr(trim($formatted_query), 0, 70) . '...') ; $this->log(" * SQL: Query time $time sec(s))"); } catch (\Exception $e) { $err = $e->getMessage(); $msg = "Error running query ({$err}) : \n--------------------\n$query\n------------------\n"; $this->log("[+] $msg\n"); if ($disable_foreign_key_checks) { $this->log("[Error] Error restoring foreign key checks"); $this->adapter->query('set foreign_key_checks=1'); } throw new \Exception($msg); } if ($disable_foreign_key_checks) { $time_start = microtime(true); $this->adapter->query('set foreign_key_checks=1'); $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $this->log(" * FK : Foreign keys restored"); } $time_stop = microtime(true); $time = number_format(($time_stop - $total_time_start), 2); $this->log(" * Time: $time secs, affected rows $affected_rows."); }
php
public function executeSQL($key, $query, $disable_foreign_key_checks = true, $entity=null) { if ($entity !== null && $entity != $this->last_entity) { $this->log("------------------------------------------------------"); $this->log("Entity: '$entity'"); $this->log("------------------------------------------------------"); $this->last_entity = $entity; } $this->log(" * Sync::executeSQL '$key'..."); $total_time_start = microtime(true); if ($disable_foreign_key_checks) { $this->adapter->query('set foreign_key_checks=0'); $this->log(" * FK : Foreign key check disabled"); } try { $time_start = microtime(true); $result = $this->adapter->query($query, ZendDb::QUERY_MODE_EXECUTE); $affected_rows = $result->getAffectedRows(); // Log stuffs $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $formatted_query = preg_replace('/(\n)|(\r)|(\t)/', ' ', $query); $formatted_query = preg_replace('/(\ )+/', ' ', $formatted_query); $this->log(" * SQL: " . substr(trim($formatted_query), 0, 70) . '...') ; $this->log(" * SQL: Query time $time sec(s))"); } catch (\Exception $e) { $err = $e->getMessage(); $msg = "Error running query ({$err}) : \n--------------------\n$query\n------------------\n"; $this->log("[+] $msg\n"); if ($disable_foreign_key_checks) { $this->log("[Error] Error restoring foreign key checks"); $this->adapter->query('set foreign_key_checks=1'); } throw new \Exception($msg); } if ($disable_foreign_key_checks) { $time_start = microtime(true); $this->adapter->query('set foreign_key_checks=1'); $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $this->log(" * FK : Foreign keys restored"); } $time_stop = microtime(true); $time = number_format(($time_stop - $total_time_start), 2); $this->log(" * Time: $time secs, affected rows $affected_rows."); }
[ "public", "function", "executeSQL", "(", "$", "key", ",", "$", "query", ",", "$", "disable_foreign_key_checks", "=", "true", ",", "$", "entity", "=", "null", ")", "{", "if", "(", "$", "entity", "!==", "null", "&&", "$", "entity", "!=", "$", "this", "->", "last_entity", ")", "{", "$", "this", "->", "log", "(", "\"------------------------------------------------------\"", ")", ";", "$", "this", "->", "log", "(", "\"Entity: '$entity'\"", ")", ";", "$", "this", "->", "log", "(", "\"------------------------------------------------------\"", ")", ";", "$", "this", "->", "last_entity", "=", "$", "entity", ";", "}", "$", "this", "->", "log", "(", "\" * Sync::executeSQL '$key'...\"", ")", ";", "$", "total_time_start", "=", "microtime", "(", "true", ")", ";", "if", "(", "$", "disable_foreign_key_checks", ")", "{", "$", "this", "->", "adapter", "->", "query", "(", "'set foreign_key_checks=0'", ")", ";", "$", "this", "->", "log", "(", "\" * FK : Foreign key check disabled\"", ")", ";", "}", "try", "{", "$", "time_start", "=", "microtime", "(", "true", ")", ";", "$", "result", "=", "$", "this", "->", "adapter", "->", "query", "(", "$", "query", ",", "ZendDb", "::", "QUERY_MODE_EXECUTE", ")", ";", "$", "affected_rows", "=", "$", "result", "->", "getAffectedRows", "(", ")", ";", "// Log stuffs", "$", "time_stop", "=", "microtime", "(", "true", ")", ";", "$", "time", "=", "number_format", "(", "(", "$", "time_stop", "-", "$", "time_start", ")", ",", "2", ")", ";", "$", "formatted_query", "=", "preg_replace", "(", "'/(\\n)|(\\r)|(\\t)/'", ",", "' '", ",", "$", "query", ")", ";", "$", "formatted_query", "=", "preg_replace", "(", "'/(\\ )+/'", ",", "' '", ",", "$", "formatted_query", ")", ";", "$", "this", "->", "log", "(", "\" * SQL: \"", ".", "substr", "(", "trim", "(", "$", "formatted_query", ")", ",", "0", ",", "70", ")", ".", "'...'", ")", ";", "$", "this", "->", "log", "(", "\" * SQL: Query time $time sec(s))\"", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "err", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "msg", "=", "\"Error running query ({$err}) : \\n--------------------\\n$query\\n------------------\\n\"", ";", "$", "this", "->", "log", "(", "\"[+] $msg\\n\"", ")", ";", "if", "(", "$", "disable_foreign_key_checks", ")", "{", "$", "this", "->", "log", "(", "\"[Error] Error restoring foreign key checks\"", ")", ";", "$", "this", "->", "adapter", "->", "query", "(", "'set foreign_key_checks=1'", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "if", "(", "$", "disable_foreign_key_checks", ")", "{", "$", "time_start", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "adapter", "->", "query", "(", "'set foreign_key_checks=1'", ")", ";", "$", "time_stop", "=", "microtime", "(", "true", ")", ";", "$", "time", "=", "number_format", "(", "(", "$", "time_stop", "-", "$", "time_start", ")", ",", "2", ")", ";", "$", "this", "->", "log", "(", "\" * FK : Foreign keys restored\"", ")", ";", "}", "$", "time_stop", "=", "microtime", "(", "true", ")", ";", "$", "time", "=", "number_format", "(", "(", "$", "time_stop", "-", "$", "total_time_start", ")", ",", "2", ")", ";", "$", "this", "->", "log", "(", "\" * Time: $time secs, affected rows $affected_rows.\"", ")", ";", "}" ]
Execute a query on the database and logs it @throws Exception @param string $key name of the query @param string $query @param boolean $disable_foreign_key_checks @param string $entity @return void
[ "Execute", "a", "query", "on", "the", "database", "and", "logs", "it" ]
149b9abca971d20620d5003342cb50592a05d1fa
https://github.com/belgattitude/openstore-akilia/blob/149b9abca971d20620d5003342cb50592a05d1fa/src/OpenstoreAkilia/Db/DbExecuter.php#L51-L102
241,048
vpg/titon.common
src/Titon/Common/Traits/Configurable.php
Configurable.applyConfig
public function applyConfig(array $config = []) { $parent = $this; $defaults = isset($this->_config) ? $this->_config : []; // Inherit config from parents while ($parent = get_parent_class($parent)) { $props = get_class_vars($parent); if (isset($props['_config'])) { $defaults = Hash::merge($props['_config'], $defaults); } } $this->__config = new ConfigAugment($config, $defaults); return $this; }
php
public function applyConfig(array $config = []) { $parent = $this; $defaults = isset($this->_config) ? $this->_config : []; // Inherit config from parents while ($parent = get_parent_class($parent)) { $props = get_class_vars($parent); if (isset($props['_config'])) { $defaults = Hash::merge($props['_config'], $defaults); } } $this->__config = new ConfigAugment($config, $defaults); return $this; }
[ "public", "function", "applyConfig", "(", "array", "$", "config", "=", "[", "]", ")", "{", "$", "parent", "=", "$", "this", ";", "$", "defaults", "=", "isset", "(", "$", "this", "->", "_config", ")", "?", "$", "this", "->", "_config", ":", "[", "]", ";", "// Inherit config from parents", "while", "(", "$", "parent", "=", "get_parent_class", "(", "$", "parent", ")", ")", "{", "$", "props", "=", "get_class_vars", "(", "$", "parent", ")", ";", "if", "(", "isset", "(", "$", "props", "[", "'_config'", "]", ")", ")", "{", "$", "defaults", "=", "Hash", "::", "merge", "(", "$", "props", "[", "'_config'", "]", ",", "$", "defaults", ")", ";", "}", "}", "$", "this", "->", "__config", "=", "new", "ConfigAugment", "(", "$", "config", ",", "$", "defaults", ")", ";", "return", "$", "this", ";", "}" ]
Merge the custom configuration with the defaults and inherit from parent classes. @uses Titon\Utility\Hash @param array $config @return $this
[ "Merge", "the", "custom", "configuration", "with", "the", "defaults", "and", "inherit", "from", "parent", "classes", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Configurable.php#L56-L72
241,049
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setEmail
public function setEmail($email) { $email = (string) $email; if ($this->exists() && $this->email !== $email) { $this->updated['email'] = true; } $this->email = $email; return $this; }
php
public function setEmail($email) { $email = (string) $email; if ($this->exists() && $this->email !== $email) { $this->updated['email'] = true; } $this->email = $email; return $this; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "$", "email", "=", "(", "string", ")", "$", "email", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "email", "!==", "$", "email", ")", "{", "$", "this", "->", "updated", "[", "'email'", "]", "=", "true", ";", "}", "$", "this", "->", "email", "=", "$", "email", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_email" @param string $email @return $this
[ "Set", "value", "for", "field", "user_email" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L248-L259
241,050
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setPassword
public function setPassword($password) { $password = (string) $password; if ($this->exists() && $this->password !== $password) { $this->updated['password'] = true; } $this->password = $password; return $this; }
php
public function setPassword($password) { $password = (string) $password; if ($this->exists() && $this->password !== $password) { $this->updated['password'] = true; } $this->password = $password; return $this; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "$", "password", "=", "(", "string", ")", "$", "password", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "password", "!==", "$", "password", ")", "{", "$", "this", "->", "updated", "[", "'password'", "]", "=", "true", ";", "}", "$", "this", "->", "password", "=", "$", "password", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_password" @param string $password @return $this
[ "Set", "value", "for", "field", "user_password" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L267-L278
241,051
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setPseudo
public function setPseudo($pseudo) { $pseudo = (string) $pseudo; if ($this->exists() && $this->pseudo !== $pseudo) { $this->updated['pseudo'] = true; } $this->pseudo = $pseudo; return $this; }
php
public function setPseudo($pseudo) { $pseudo = (string) $pseudo; if ($this->exists() && $this->pseudo !== $pseudo) { $this->updated['pseudo'] = true; } $this->pseudo = $pseudo; return $this; }
[ "public", "function", "setPseudo", "(", "$", "pseudo", ")", "{", "$", "pseudo", "=", "(", "string", ")", "$", "pseudo", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "pseudo", "!==", "$", "pseudo", ")", "{", "$", "this", "->", "updated", "[", "'pseudo'", "]", "=", "true", ";", "}", "$", "this", "->", "pseudo", "=", "$", "pseudo", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_pseudo" @param string $pseudo @return $this
[ "Set", "value", "for", "field", "user_pseudo" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L286-L297
241,052
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setFirstname
public function setFirstname($firstname) { $firstname = ($firstname === null ? $firstname : (string) $firstname); if ($this->exists() && $this->firstname !== $firstname) { $this->updated['firstname'] = true; } $this->firstname = $firstname; return $this; }
php
public function setFirstname($firstname) { $firstname = ($firstname === null ? $firstname : (string) $firstname); if ($this->exists() && $this->firstname !== $firstname) { $this->updated['firstname'] = true; } $this->firstname = $firstname; return $this; }
[ "public", "function", "setFirstname", "(", "$", "firstname", ")", "{", "$", "firstname", "=", "(", "$", "firstname", "===", "null", "?", "$", "firstname", ":", "(", "string", ")", "$", "firstname", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "firstname", "!==", "$", "firstname", ")", "{", "$", "this", "->", "updated", "[", "'firstname'", "]", "=", "true", ";", "}", "$", "this", "->", "firstname", "=", "$", "firstname", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_firstname" @param string $firstname @return $this
[ "Set", "value", "for", "field", "user_firstname" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L305-L316
241,053
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setLastname
public function setLastname($lastname) { $lastname = ($lastname === null ? $lastname : (string) $lastname); if ($this->exists() && $this->lastname !== $lastname) { $this->updated['lastname'] = true; } $this->lastname = $lastname; return $this; }
php
public function setLastname($lastname) { $lastname = ($lastname === null ? $lastname : (string) $lastname); if ($this->exists() && $this->lastname !== $lastname) { $this->updated['lastname'] = true; } $this->lastname = $lastname; return $this; }
[ "public", "function", "setLastname", "(", "$", "lastname", ")", "{", "$", "lastname", "=", "(", "$", "lastname", "===", "null", "?", "$", "lastname", ":", "(", "string", ")", "$", "lastname", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "lastname", "!==", "$", "lastname", ")", "{", "$", "this", "->", "updated", "[", "'lastname'", "]", "=", "true", ";", "}", "$", "this", "->", "lastname", "=", "$", "lastname", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_lastname" @param string $lastname @return $this
[ "Set", "value", "for", "field", "user_lastname" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L324-L335
241,054
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setDateRegister
public function setDateRegister($dateRegister) { $dateRegister = ($dateRegister === null ? $dateRegister : (string) $dateRegister); if ($this->exists() && $this->dateRegister !== $dateRegister) { $this->updated['dateRegister'] = true; } $this->dateRegister = $dateRegister; return $this; }
php
public function setDateRegister($dateRegister) { $dateRegister = ($dateRegister === null ? $dateRegister : (string) $dateRegister); if ($this->exists() && $this->dateRegister !== $dateRegister) { $this->updated['dateRegister'] = true; } $this->dateRegister = $dateRegister; return $this; }
[ "public", "function", "setDateRegister", "(", "$", "dateRegister", ")", "{", "$", "dateRegister", "=", "(", "$", "dateRegister", "===", "null", "?", "$", "dateRegister", ":", "(", "string", ")", "$", "dateRegister", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "dateRegister", "!==", "$", "dateRegister", ")", "{", "$", "this", "->", "updated", "[", "'dateRegister'", "]", "=", "true", ";", "}", "$", "this", "->", "dateRegister", "=", "$", "dateRegister", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_date_register" @param string $dateRegister @return $this
[ "Set", "value", "for", "field", "user_date_register" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L343-L354
241,055
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setIsActivated
public function setIsActivated($isActivated) { $isActivated = (int) $isActivated; if ($this->exists() && $this->isActivated !== $isActivated) { $this->updated['isActivated'] = true; } $this->isActivated = $isActivated; return $this; }
php
public function setIsActivated($isActivated) { $isActivated = (int) $isActivated; if ($this->exists() && $this->isActivated !== $isActivated) { $this->updated['isActivated'] = true; } $this->isActivated = $isActivated; return $this; }
[ "public", "function", "setIsActivated", "(", "$", "isActivated", ")", "{", "$", "isActivated", "=", "(", "int", ")", "$", "isActivated", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "isActivated", "!==", "$", "isActivated", ")", "{", "$", "this", "->", "updated", "[", "'isActivated'", "]", "=", "true", ";", "}", "$", "this", "->", "isActivated", "=", "$", "isActivated", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_is_activated" @param int $isActivated @return $this
[ "Set", "value", "for", "field", "user_is_activated" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L362-L373
241,056
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setDateActivation
public function setDateActivation($dateActivation) { $dateActivation = ($dateActivation === null ? $dateActivation : (string) $dateActivation); if ($this->exists() && $this->dateActivation !== $dateActivation) { $this->updated['dateActivation'] = true; } $this->dateActivation = $dateActivation; return $this; }
php
public function setDateActivation($dateActivation) { $dateActivation = ($dateActivation === null ? $dateActivation : (string) $dateActivation); if ($this->exists() && $this->dateActivation !== $dateActivation) { $this->updated['dateActivation'] = true; } $this->dateActivation = $dateActivation; return $this; }
[ "public", "function", "setDateActivation", "(", "$", "dateActivation", ")", "{", "$", "dateActivation", "=", "(", "$", "dateActivation", "===", "null", "?", "$", "dateActivation", ":", "(", "string", ")", "$", "dateActivation", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "dateActivation", "!==", "$", "dateActivation", ")", "{", "$", "this", "->", "updated", "[", "'dateActivation'", "]", "=", "true", ";", "}", "$", "this", "->", "dateActivation", "=", "$", "dateActivation", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_date_activation" @param string $dateActivation @return $this
[ "Set", "value", "for", "field", "user_date_activation" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L381-L392
241,057
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setCodeActivation
public function setCodeActivation($codeActivation) { $codeActivation = ($codeActivation === null ? $codeActivation : (string) $codeActivation); if ($this->exists() && $this->codeActivation !== $codeActivation) { $this->updated['codeActivation'] = true; } $this->codeActivation = $codeActivation; return $this; }
php
public function setCodeActivation($codeActivation) { $codeActivation = ($codeActivation === null ? $codeActivation : (string) $codeActivation); if ($this->exists() && $this->codeActivation !== $codeActivation) { $this->updated['codeActivation'] = true; } $this->codeActivation = $codeActivation; return $this; }
[ "public", "function", "setCodeActivation", "(", "$", "codeActivation", ")", "{", "$", "codeActivation", "=", "(", "$", "codeActivation", "===", "null", "?", "$", "codeActivation", ":", "(", "string", ")", "$", "codeActivation", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "codeActivation", "!==", "$", "codeActivation", ")", "{", "$", "this", "->", "updated", "[", "'codeActivation'", "]", "=", "true", ";", "}", "$", "this", "->", "codeActivation", "=", "$", "codeActivation", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_code_activation" @param string $codeActivation @return $this
[ "Set", "value", "for", "field", "user_code_activation" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L400-L411
241,058
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setAvatar
public function setAvatar($avatar) { $avatar = (string) $avatar; if ($this->exists() && $this->avatar !== $avatar) { $this->updated['avatar'] = true; } $this->avatar = $avatar; return $this; }
php
public function setAvatar($avatar) { $avatar = (string) $avatar; if ($this->exists() && $this->avatar !== $avatar) { $this->updated['avatar'] = true; } $this->avatar = $avatar; return $this; }
[ "public", "function", "setAvatar", "(", "$", "avatar", ")", "{", "$", "avatar", "=", "(", "string", ")", "$", "avatar", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "avatar", "!==", "$", "avatar", ")", "{", "$", "this", "->", "updated", "[", "'avatar'", "]", "=", "true", ";", "}", "$", "this", "->", "avatar", "=", "$", "avatar", ";", "return", "$", "this", ";", "}" ]
Set value for field "user_avatar" @param string $avatar @return $this
[ "Set", "value", "for", "field", "user_avatar" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L419-L430
241,059
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowById
public function getShowById($showId) { $response = $this->request('/GetShowById/' . $showId); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
php
public function getShowById($showId) { $response = $this->request('/GetShowById/' . $showId); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
[ "public", "function", "getShowById", "(", "$", "showId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowById/'", ".", "$", "showId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "$", "show", "=", "$", "response", "->", "response", ";", "$", "show", "=", "$", "this", "->", "formatShow", "(", "$", "show", ")", ";", "return", "$", "show", ";", "}" ]
Get a show by Bierdopje showId @param $showId @return \SimpleXMLElement[]|\stdClass @throws \Exception
[ "Get", "a", "show", "by", "Bierdopje", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L45-L55
241,060
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.findShowByName
public function findShowByName($showName) { $response = $this->request('/FindShowByName/' . $showName); if ( $response->response->status == 'false' ) return null; $shows = $response->response->results->result; if ( count($shows) <= 0 ) return null; $show = $shows[0]; $show = $this->formatShow($show); return $show; }
php
public function findShowByName($showName) { $response = $this->request('/FindShowByName/' . $showName); if ( $response->response->status == 'false' ) return null; $shows = $response->response->results->result; if ( count($shows) <= 0 ) return null; $show = $shows[0]; $show = $this->formatShow($show); return $show; }
[ "public", "function", "findShowByName", "(", "$", "showName", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/FindShowByName/'", ".", "$", "showName", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "$", "shows", "=", "$", "response", "->", "response", "->", "results", "->", "result", ";", "if", "(", "count", "(", "$", "shows", ")", "<=", "0", ")", "return", "null", ";", "$", "show", "=", "$", "shows", "[", "0", "]", ";", "$", "show", "=", "$", "this", "->", "formatShow", "(", "$", "show", ")", ";", "return", "$", "show", ";", "}" ]
Search a show by name @param $showName @return null|\stdClass @throws \Exception
[ "Search", "a", "show", "by", "name" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L65-L79
241,061
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowByName
public function getShowByName($showName, $isLinkName = false) { $response = $this->request('/GetShowByName/' . $showName . '/' . $isLinkName); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
php
public function getShowByName($showName, $isLinkName = false) { $response = $this->request('/GetShowByName/' . $showName . '/' . $isLinkName); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
[ "public", "function", "getShowByName", "(", "$", "showName", ",", "$", "isLinkName", "=", "false", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowByName/'", ".", "$", "showName", ".", "'/'", ".", "$", "isLinkName", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "$", "show", "=", "$", "response", "->", "response", ";", "$", "show", "=", "$", "this", "->", "formatShow", "(", "$", "show", ")", ";", "return", "$", "show", ";", "}" ]
Get a show by exact name. @param string $showName @param bool $isLinkName @return null|\stdClass @throws \Exception
[ "Get", "a", "show", "by", "exact", "name", "." ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L90-L100
241,062
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowByTvdbId
public function getShowByTvdbId($tvdbId) { $response = $this->request('/GetShowByTVDBID/' . $tvdbId); if ( $response->response->status == 'false' ) return null; $show = $this->formatShow($response->response); return $show; }
php
public function getShowByTvdbId($tvdbId) { $response = $this->request('/GetShowByTVDBID/' . $tvdbId); if ( $response->response->status == 'false' ) return null; $show = $this->formatShow($response->response); return $show; }
[ "public", "function", "getShowByTvdbId", "(", "$", "tvdbId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowByTVDBID/'", ".", "$", "tvdbId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "$", "show", "=", "$", "this", "->", "formatShow", "(", "$", "response", "->", "response", ")", ";", "return", "$", "show", ";", "}" ]
Search a show by a TVDB showId @param $tvdbId @return \stdClass @throws \Exception
[ "Search", "a", "show", "by", "a", "TVDB", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L110-L118
241,063
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getEpisodesOfSeason
public function getEpisodesOfSeason($showId, $season) { $response = $this->request('/GetEpisodesForSeason/' . $showId . '/' . $season); if ( $response->response->status == 'false' ) return null; $episodes = $response->response->results->result; if ( count($episodes) <= 0 ) return null; $episodeList = []; foreach ( $episodes as $episode ) $episodeList[] = $this->formatEpisode($episode); return $episodeList; }
php
public function getEpisodesOfSeason($showId, $season) { $response = $this->request('/GetEpisodesForSeason/' . $showId . '/' . $season); if ( $response->response->status == 'false' ) return null; $episodes = $response->response->results->result; if ( count($episodes) <= 0 ) return null; $episodeList = []; foreach ( $episodes as $episode ) $episodeList[] = $this->formatEpisode($episode); return $episodeList; }
[ "public", "function", "getEpisodesOfSeason", "(", "$", "showId", ",", "$", "season", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetEpisodesForSeason/'", ".", "$", "showId", ".", "'/'", ".", "$", "season", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "$", "episodes", "=", "$", "response", "->", "response", "->", "results", "->", "result", ";", "if", "(", "count", "(", "$", "episodes", ")", "<=", "0", ")", "return", "null", ";", "$", "episodeList", "=", "[", "]", ";", "foreach", "(", "$", "episodes", "as", "$", "episode", ")", "$", "episodeList", "[", "]", "=", "$", "this", "->", "formatEpisode", "(", "$", "episode", ")", ";", "return", "$", "episodeList", ";", "}" ]
Search episodes by season and Bierdopje showId @param $showId @param $season @return array|null @throws \Exception
[ "Search", "episodes", "by", "season", "and", "Bierdopje", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L129-L144
241,064
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getEpisodeById
public function getEpisodeById($episodeId) { $response = $this->request('/GetEpisodeById/' . $episodeId); if ( $response->response->status == 'false' ) return null; if ($response->response->cached == 'false') { $episode = $response->response; } else { $episode = $response->response->results; } $episode = $this->formatEpisode($episode); return $episode; }
php
public function getEpisodeById($episodeId) { $response = $this->request('/GetEpisodeById/' . $episodeId); if ( $response->response->status == 'false' ) return null; if ($response->response->cached == 'false') { $episode = $response->response; } else { $episode = $response->response->results; } $episode = $this->formatEpisode($episode); return $episode; }
[ "public", "function", "getEpisodeById", "(", "$", "episodeId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetEpisodeById/'", ".", "$", "episodeId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ")", "return", "null", ";", "if", "(", "$", "response", "->", "response", "->", "cached", "==", "'false'", ")", "{", "$", "episode", "=", "$", "response", "->", "response", ";", "}", "else", "{", "$", "episode", "=", "$", "response", "->", "response", "->", "results", ";", "}", "$", "episode", "=", "$", "this", "->", "formatEpisode", "(", "$", "episode", ")", ";", "return", "$", "episode", ";", "}" ]
Search an episode by its Bierdopje Id @param $episodeId @return \stdClass @throws \Exception
[ "Search", "an", "episode", "by", "its", "Bierdopje", "Id" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L179-L192
241,065
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.formatEpisode
private function formatEpisode($original) { $show = new \stdClass(); $show->id = (int) $original->episodeid; $show->tvdbId = (int) $original->tvdbid; $show->title = (string) $original->title; $show->showlink = (string) $original->showlink; $show->episodelink = (string) $original->episodelink; $show->airDate = strlen($original->airdate) ? Carbon::createFromFormat("d-m-Y", (string) $original->airdate) : null; $show->season = (int) $original->season; $show->episode = (int) $original->episode; $show->epNumber = (int) $original->epnumber; $show->score = (float) str_replace(',', '.', $original->score); $show->votes = (int) $original->votes; $show->formatted = (string) $original->formatted; $show->is_special = ((string) $original->is_special) === "true"; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); return $show; }
php
private function formatEpisode($original) { $show = new \stdClass(); $show->id = (int) $original->episodeid; $show->tvdbId = (int) $original->tvdbid; $show->title = (string) $original->title; $show->showlink = (string) $original->showlink; $show->episodelink = (string) $original->episodelink; $show->airDate = strlen($original->airdate) ? Carbon::createFromFormat("d-m-Y", (string) $original->airdate) : null; $show->season = (int) $original->season; $show->episode = (int) $original->episode; $show->epNumber = (int) $original->epnumber; $show->score = (float) str_replace(',', '.', $original->score); $show->votes = (int) $original->votes; $show->formatted = (string) $original->formatted; $show->is_special = ((string) $original->is_special) === "true"; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); return $show; }
[ "private", "function", "formatEpisode", "(", "$", "original", ")", "{", "$", "show", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "show", "->", "id", "=", "(", "int", ")", "$", "original", "->", "episodeid", ";", "$", "show", "->", "tvdbId", "=", "(", "int", ")", "$", "original", "->", "tvdbid", ";", "$", "show", "->", "title", "=", "(", "string", ")", "$", "original", "->", "title", ";", "$", "show", "->", "showlink", "=", "(", "string", ")", "$", "original", "->", "showlink", ";", "$", "show", "->", "episodelink", "=", "(", "string", ")", "$", "original", "->", "episodelink", ";", "$", "show", "->", "airDate", "=", "strlen", "(", "$", "original", "->", "airdate", ")", "?", "Carbon", "::", "createFromFormat", "(", "\"d-m-Y\"", ",", "(", "string", ")", "$", "original", "->", "airdate", ")", ":", "null", ";", "$", "show", "->", "season", "=", "(", "int", ")", "$", "original", "->", "season", ";", "$", "show", "->", "episode", "=", "(", "int", ")", "$", "original", "->", "episode", ";", "$", "show", "->", "epNumber", "=", "(", "int", ")", "$", "original", "->", "epnumber", ";", "$", "show", "->", "score", "=", "(", "float", ")", "str_replace", "(", "','", ",", "'.'", ",", "$", "original", "->", "score", ")", ";", "$", "show", "->", "votes", "=", "(", "int", ")", "$", "original", "->", "votes", ";", "$", "show", "->", "formatted", "=", "(", "string", ")", "$", "original", "->", "formatted", ";", "$", "show", "->", "is_special", "=", "(", "(", "string", ")", "$", "original", "->", "is_special", ")", "===", "\"true\"", ";", "$", "show", "->", "summary", "=", "(", "string", ")", "$", "original", "->", "summary", ";", "$", "show", "->", "updated", "=", "Carbon", "::", "createFromTimestamp", "(", "(", "int", ")", "$", "original", "->", "updated", ")", ";", "return", "$", "show", ";", "}" ]
Format an Episode response @param $original @return \stdClass
[ "Format", "an", "Episode", "response" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L201-L224
241,066
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.formatShow
private function formatShow($original) { $show = new \stdClass(); $show->id = (int) $original->showid; $show->tvdbId = (int) $original->tvdbid; $show->name = (string) $original->showname; $show->link = (string) $original->showlink; $show->firstAired = strlen($original->firstaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->firstaired) : null; $show->lastAired = strlen($original->lastaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->lastaired) : null; $show->nextEpisode = strlen($original->nextepisode) ? Carbon::createFromFormat('Y-m-d', (string) $original->nextepisode) : null; $show->seasons = (int) $original->seasons; $show->episodes = (int) $original->episodes; $show->genres = $original->genres->result; $show->score = (float) str_replace(',', '.', $original->score); $show->runtime = (float) str_replace(',', '.', $original->runtime); $show->favorites = (int) $original->favorites; $show->showstatus = (string) $original->showstatus; $show->airtime = (string) $original->airtime; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); $genres = []; foreach ( $show->genres as $key => $genre ) { $genre = (string) $genre; $genre = ucfirst($genre); $genres[] = $genre; } $show->genres = $genres; return $show; }
php
private function formatShow($original) { $show = new \stdClass(); $show->id = (int) $original->showid; $show->tvdbId = (int) $original->tvdbid; $show->name = (string) $original->showname; $show->link = (string) $original->showlink; $show->firstAired = strlen($original->firstaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->firstaired) : null; $show->lastAired = strlen($original->lastaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->lastaired) : null; $show->nextEpisode = strlen($original->nextepisode) ? Carbon::createFromFormat('Y-m-d', (string) $original->nextepisode) : null; $show->seasons = (int) $original->seasons; $show->episodes = (int) $original->episodes; $show->genres = $original->genres->result; $show->score = (float) str_replace(',', '.', $original->score); $show->runtime = (float) str_replace(',', '.', $original->runtime); $show->favorites = (int) $original->favorites; $show->showstatus = (string) $original->showstatus; $show->airtime = (string) $original->airtime; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); $genres = []; foreach ( $show->genres as $key => $genre ) { $genre = (string) $genre; $genre = ucfirst($genre); $genres[] = $genre; } $show->genres = $genres; return $show; }
[ "private", "function", "formatShow", "(", "$", "original", ")", "{", "$", "show", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "show", "->", "id", "=", "(", "int", ")", "$", "original", "->", "showid", ";", "$", "show", "->", "tvdbId", "=", "(", "int", ")", "$", "original", "->", "tvdbid", ";", "$", "show", "->", "name", "=", "(", "string", ")", "$", "original", "->", "showname", ";", "$", "show", "->", "link", "=", "(", "string", ")", "$", "original", "->", "showlink", ";", "$", "show", "->", "firstAired", "=", "strlen", "(", "$", "original", "->", "firstaired", ")", "?", "Carbon", "::", "createFromFormat", "(", "'Y-m-d'", ",", "(", "string", ")", "$", "original", "->", "firstaired", ")", ":", "null", ";", "$", "show", "->", "lastAired", "=", "strlen", "(", "$", "original", "->", "lastaired", ")", "?", "Carbon", "::", "createFromFormat", "(", "'Y-m-d'", ",", "(", "string", ")", "$", "original", "->", "lastaired", ")", ":", "null", ";", "$", "show", "->", "nextEpisode", "=", "strlen", "(", "$", "original", "->", "nextepisode", ")", "?", "Carbon", "::", "createFromFormat", "(", "'Y-m-d'", ",", "(", "string", ")", "$", "original", "->", "nextepisode", ")", ":", "null", ";", "$", "show", "->", "seasons", "=", "(", "int", ")", "$", "original", "->", "seasons", ";", "$", "show", "->", "episodes", "=", "(", "int", ")", "$", "original", "->", "episodes", ";", "$", "show", "->", "genres", "=", "$", "original", "->", "genres", "->", "result", ";", "$", "show", "->", "score", "=", "(", "float", ")", "str_replace", "(", "','", ",", "'.'", ",", "$", "original", "->", "score", ")", ";", "$", "show", "->", "runtime", "=", "(", "float", ")", "str_replace", "(", "','", ",", "'.'", ",", "$", "original", "->", "runtime", ")", ";", "$", "show", "->", "favorites", "=", "(", "int", ")", "$", "original", "->", "favorites", ";", "$", "show", "->", "showstatus", "=", "(", "string", ")", "$", "original", "->", "showstatus", ";", "$", "show", "->", "airtime", "=", "(", "string", ")", "$", "original", "->", "airtime", ";", "$", "show", "->", "summary", "=", "(", "string", ")", "$", "original", "->", "summary", ";", "$", "show", "->", "updated", "=", "Carbon", "::", "createFromTimestamp", "(", "(", "int", ")", "$", "original", "->", "updated", ")", ";", "$", "genres", "=", "[", "]", ";", "foreach", "(", "$", "show", "->", "genres", "as", "$", "key", "=>", "$", "genre", ")", "{", "$", "genre", "=", "(", "string", ")", "$", "genre", ";", "$", "genre", "=", "ucfirst", "(", "$", "genre", ")", ";", "$", "genres", "[", "]", "=", "$", "genre", ";", "}", "$", "show", "->", "genres", "=", "$", "genres", ";", "return", "$", "show", ";", "}" ]
Format a Show response @param $original @return \stdClass
[ "Format", "a", "Show", "response" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L233-L269
241,067
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.request
protected function request($path) { $response = $this->client->get($this->url . $path); if ( $response->getStatusCode() != 200 ) throw new \Exception('Bierdopje.com not available'); $response = $this->xmlToObj($response->getBody()); return $response; }
php
protected function request($path) { $response = $this->client->get($this->url . $path); if ( $response->getStatusCode() != 200 ) throw new \Exception('Bierdopje.com not available'); $response = $this->xmlToObj($response->getBody()); return $response; }
[ "protected", "function", "request", "(", "$", "path", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "url", ".", "$", "path", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!=", "200", ")", "throw", "new", "\\", "Exception", "(", "'Bierdopje.com not available'", ")", ";", "$", "response", "=", "$", "this", "->", "xmlToObj", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "return", "$", "response", ";", "}" ]
Make an HTTP request and format the XML resposne @param $path @return \SimpleXMLElement @throws \Exception
[ "Make", "an", "HTTP", "request", "and", "format", "the", "XML", "resposne" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L279-L289
241,068
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.xmlToObj
private function xmlToObj($fileContents) { $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); $fileContents = trim(str_replace('"', "'", $fileContents)); $simpleXml = simplexml_load_string($fileContents, null, LIBXML_NOCDATA); return $simpleXml; }
php
private function xmlToObj($fileContents) { $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); $fileContents = trim(str_replace('"', "'", $fileContents)); $simpleXml = simplexml_load_string($fileContents, null, LIBXML_NOCDATA); return $simpleXml; }
[ "private", "function", "xmlToObj", "(", "$", "fileContents", ")", "{", "$", "fileContents", "=", "str_replace", "(", "array", "(", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\t\"", ")", ",", "''", ",", "$", "fileContents", ")", ";", "$", "fileContents", "=", "trim", "(", "str_replace", "(", "'\"'", ",", "\"'\"", ",", "$", "fileContents", ")", ")", ";", "$", "simpleXml", "=", "simplexml_load_string", "(", "$", "fileContents", ",", "null", ",", "LIBXML_NOCDATA", ")", ";", "return", "$", "simpleXml", ";", "}" ]
Convert XML string to object @param $fileContents @return \SimpleXMLElement
[ "Convert", "XML", "string", "to", "object" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L298-L305
241,069
jivoo/core
src/Binary.php
Binary.slice
public static function slice($string, $start, $length = null) { if (function_exists('mb_substr')) { return mb_substr($string, $start, $length, '8bit'); } return substr($string, $start, $length); }
php
public static function slice($string, $start, $length = null) { if (function_exists('mb_substr')) { return mb_substr($string, $start, $length, '8bit'); } return substr($string, $start, $length); }
[ "public", "static", "function", "slice", "(", "$", "string", ",", "$", "start", ",", "$", "length", "=", "null", ")", "{", "if", "(", "function_exists", "(", "'mb_substr'", ")", ")", "{", "return", "mb_substr", "(", "$", "string", ",", "$", "start", ",", "$", "length", ",", "'8bit'", ")", ";", "}", "return", "substr", "(", "$", "string", ",", "$", "start", ",", "$", "length", ")", ";", "}" ]
Returns the portion of byte string specified by the start and length parameters. @param string $string String. @param int $start Offset to start at. @param int $length Optional length of slice. @return string Slice.
[ "Returns", "the", "portion", "of", "byte", "string", "specified", "by", "the", "start", "and", "length", "parameters", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L48-L54
241,070
jivoo/core
src/Binary.php
Binary.base64Encode
public static function base64Encode($data, $url = false) { if ($url) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } else { return base64_encode($data); } }
php
public static function base64Encode($data, $url = false) { if ($url) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } else { return base64_encode($data); } }
[ "public", "static", "function", "base64Encode", "(", "$", "data", ",", "$", "url", "=", "false", ")", "{", "if", "(", "$", "url", ")", "{", "return", "rtrim", "(", "strtr", "(", "base64_encode", "(", "$", "data", ")", ",", "'+/'", ",", "'-_'", ")", ",", "'='", ")", ";", "}", "else", "{", "return", "base64_encode", "(", "$", "data", ")", ";", "}", "}" ]
Encode binary data using base64. @param string $data String. @param bool $url 'base64url' standard. Removes padding and replaces '+' and '/' with '-' and '_'. @return string Base64 encoded string.
[ "Encode", "binary", "data", "using", "base64", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L66-L73
241,071
jivoo/core
src/Binary.php
Binary.base64Decode
public static function base64Decode($data, $url = true) { if ($url) { return base64_decode(strtr($data, '-_', '+/')); } else { return base64_decode($data); } }
php
public static function base64Decode($data, $url = true) { if ($url) { return base64_decode(strtr($data, '-_', '+/')); } else { return base64_decode($data); } }
[ "public", "static", "function", "base64Decode", "(", "$", "data", ",", "$", "url", "=", "true", ")", "{", "if", "(", "$", "url", ")", "{", "return", "base64_decode", "(", "strtr", "(", "$", "data", ",", "'-_'", ",", "'+/'", ")", ")", ";", "}", "else", "{", "return", "base64_decode", "(", "$", "data", ")", ";", "}", "}" ]
Decode base64 encoded string. @param string $data Base64 encoded string.. @param bool $url Whether to replace '-' and '_' with '+' and '/'. @return string Original string.
[ "Decode", "base64", "encoded", "string", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L84-L91
241,072
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.generateCode
public function generateCode($secret, $counter, $algorithm = 'sha512') { $key = $this->base32->decode($secret); if (empty($counter)) { return ''; } $hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true); return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT); }
php
public function generateCode($secret, $counter, $algorithm = 'sha512') { $key = $this->base32->decode($secret); if (empty($counter)) { return ''; } $hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true); return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT); }
[ "public", "function", "generateCode", "(", "$", "secret", ",", "$", "counter", ",", "$", "algorithm", "=", "'sha512'", ")", "{", "$", "key", "=", "$", "this", "->", "base32", "->", "decode", "(", "$", "secret", ")", ";", "if", "(", "empty", "(", "$", "counter", ")", ")", "{", "return", "''", ";", "}", "$", "hash", "=", "hash_hmac", "(", "$", "algorithm", ",", "$", "this", "->", "getBinaryCounter", "(", "$", "counter", ")", ",", "$", "key", ",", "true", ")", ";", "return", "str_pad", "(", "$", "this", "->", "truncate", "(", "$", "hash", ")", ",", "$", "this", "->", "code_length", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}" ]
Generates code based on timestamp and secret @param string $secret Secret shared with user @param int $counter Counter for code generation @param string $algorithm Algorithm to use for HMAC hash. Defaults to sha512. The following hash types are allowed: TOTP: sha1, sha256, sha512 HOTP: sha1 @return string Generated OTP code
[ "Generates", "code", "based", "on", "timestamp", "and", "secret" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L56-L68
241,073
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.checkTOTP
public function checkTOTP($secret, $code, $hash_type = 'sha512') { $time = $this->getTimestampCounter(time()); for ($i = -1; $i <= 1; $i++) { if ($this->stringCompare($code, $this->generateCode($secret, $time + $i, $hash_type)) === true) { return true; } } return false; }
php
public function checkTOTP($secret, $code, $hash_type = 'sha512') { $time = $this->getTimestampCounter(time()); for ($i = -1; $i <= 1; $i++) { if ($this->stringCompare($code, $this->generateCode($secret, $time + $i, $hash_type)) === true) { return true; } } return false; }
[ "public", "function", "checkTOTP", "(", "$", "secret", ",", "$", "code", ",", "$", "hash_type", "=", "'sha512'", ")", "{", "$", "time", "=", "$", "this", "->", "getTimestampCounter", "(", "time", "(", ")", ")", ";", "for", "(", "$", "i", "=", "-", "1", ";", "$", "i", "<=", "1", ";", "$", "i", "++", ")", "{", "if", "(", "$", "this", "->", "stringCompare", "(", "$", "code", ",", "$", "this", "->", "generateCode", "(", "$", "secret", ",", "$", "time", "+", "$", "i", ",", "$", "hash_type", ")", ")", "===", "true", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if supplied TOTP code is valid @param string $secret Secret to use for comparison @param int $code Supplied TOTP code @param string $hash_type Hash type @return bool True if code is valid, false if not
[ "Check", "if", "supplied", "TOTP", "code", "is", "valid" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L79-L92
241,074
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.checkHOTP
public function checkHOTP($secret, $counter, $code, $hash_type = 'sha512') { return $this->stringCompare($code, $this->generateCode($secret, $counter, $hash_type)); }
php
public function checkHOTP($secret, $counter, $code, $hash_type = 'sha512') { return $this->stringCompare($code, $this->generateCode($secret, $counter, $hash_type)); }
[ "public", "function", "checkHOTP", "(", "$", "secret", ",", "$", "counter", ",", "$", "code", ",", "$", "hash_type", "=", "'sha512'", ")", "{", "return", "$", "this", "->", "stringCompare", "(", "$", "code", ",", "$", "this", "->", "generateCode", "(", "$", "secret", ",", "$", "counter", ",", "$", "hash_type", ")", ")", ";", "}" ]
Check if supplied HOTP code is valid @param string $secret Secret to use for comparison @param int $counter Current counter @param int $code Supplied HOTP code @param string $hash_type Hash type @return bool True if code is valid, false if not
[ "Check", "if", "supplied", "HOTP", "code", "is", "valid" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L104-L107
241,075
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.truncate
protected function truncate($hash) { $truncated_hash = 0; $offset = ord(substr($hash, -1)) & 0xF; // Truncate hash using supplied sha1 hash for ($i = 0; $i < 4; ++$i) { $truncated_hash <<= 8; $truncated_hash |= ord($hash[$offset + $i]); } // Truncate to a smaller number of digits. $truncated_hash &= 0x7FFFFFFF; $truncated_hash %= self::VERIFICATION_CODE_MODULUS; return $truncated_hash; }
php
protected function truncate($hash) { $truncated_hash = 0; $offset = ord(substr($hash, -1)) & 0xF; // Truncate hash using supplied sha1 hash for ($i = 0; $i < 4; ++$i) { $truncated_hash <<= 8; $truncated_hash |= ord($hash[$offset + $i]); } // Truncate to a smaller number of digits. $truncated_hash &= 0x7FFFFFFF; $truncated_hash %= self::VERIFICATION_CODE_MODULUS; return $truncated_hash; }
[ "protected", "function", "truncate", "(", "$", "hash", ")", "{", "$", "truncated_hash", "=", "0", ";", "$", "offset", "=", "ord", "(", "substr", "(", "$", "hash", ",", "-", "1", ")", ")", "&", "0xF", ";", "// Truncate hash using supplied sha1 hash", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "++", "$", "i", ")", "{", "$", "truncated_hash", "<<=", "8", ";", "$", "truncated_hash", "|=", "ord", "(", "$", "hash", "[", "$", "offset", "+", "$", "i", "]", ")", ";", "}", "// Truncate to a smaller number of digits.", "$", "truncated_hash", "&=", "0x7FFFFFFF", ";", "$", "truncated_hash", "%=", "self", "::", "VERIFICATION_CODE_MODULUS", ";", "return", "$", "truncated_hash", ";", "}" ]
Truncate HMAC hash to binary for generating a TOTP code @param string $hash HMAC hash @return int Truncated binary hash
[ "Truncate", "HMAC", "hash", "to", "binary", "for", "generating", "a", "TOTP", "code" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L116-L133
241,076
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.stringCompare
public function stringCompare($string_a, $string_b) { $diff = strlen($string_a) ^ strlen($string_b); for ($i = 0; $i < strlen($string_a) && $i < strlen($string_b); $i++) { $diff |= ord($string_a[$i]) ^ ord($string_b[$i]); } return $diff === 0; }
php
public function stringCompare($string_a, $string_b) { $diff = strlen($string_a) ^ strlen($string_b); for ($i = 0; $i < strlen($string_a) && $i < strlen($string_b); $i++) { $diff |= ord($string_a[$i]) ^ ord($string_b[$i]); } return $diff === 0; }
[ "public", "function", "stringCompare", "(", "$", "string_a", ",", "$", "string_b", ")", "{", "$", "diff", "=", "strlen", "(", "$", "string_a", ")", "^", "strlen", "(", "$", "string_b", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "string_a", ")", "&&", "$", "i", "<", "strlen", "(", "$", "string_b", ")", ";", "$", "i", "++", ")", "{", "$", "diff", "|=", "ord", "(", "$", "string_a", "[", "$", "i", "]", ")", "^", "ord", "(", "$", "string_b", "[", "$", "i", "]", ")", ";", "}", "return", "$", "diff", "===", "0", ";", "}" ]
Compare two strings in constant time to prevent timing attacks. @param string $string_a Initial string @param string $string_b String to compare initial string to @return bool True if strings are the same, false if not
[ "Compare", "two", "strings", "in", "constant", "time", "to", "prevent", "timing", "attacks", "." ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L167-L177
241,077
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.generateSecret
public function generateSecret($length = 10) { $strong_secret = false; // Try to get $crypto_strong to evaluate to true. Give it 5 tries. for ($i = 0; $i < 5; $i++) { $secret = openssl_random_pseudo_bytes($length, $strong_secret); if ($strong_secret === true) { return $this->base32->encode($secret); } } return ''; }
php
public function generateSecret($length = 10) { $strong_secret = false; // Try to get $crypto_strong to evaluate to true. Give it 5 tries. for ($i = 0; $i < 5; $i++) { $secret = openssl_random_pseudo_bytes($length, $strong_secret); if ($strong_secret === true) { return $this->base32->encode($secret); } } return ''; }
[ "public", "function", "generateSecret", "(", "$", "length", "=", "10", ")", "{", "$", "strong_secret", "=", "false", ";", "// Try to get $crypto_strong to evaluate to true. Give it 5 tries.", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "5", ";", "$", "i", "++", ")", "{", "$", "secret", "=", "openssl_random_pseudo_bytes", "(", "$", "length", ",", "$", "strong_secret", ")", ";", "if", "(", "$", "strong_secret", "===", "true", ")", "{", "return", "$", "this", "->", "base32", "->", "encode", "(", "$", "secret", ")", ";", "}", "}", "return", "''", ";", "}" ]
Generate secret with specified length @param int $length @return string
[ "Generate", "secret", "with", "specified", "length" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L186-L202
241,078
dlabas/DlcDiagramm
src/DlcDiagramm/Diagramm/Dependency.php
Dependency.getIdentifier
public function getIdentifier() { $identifier = $this->getFromNode()->getIdentifier() . '-' . $this->getType() . '-' . $this->getToNode()->getIdentifier(); return $identifier; }
php
public function getIdentifier() { $identifier = $this->getFromNode()->getIdentifier() . '-' . $this->getType() . '-' . $this->getToNode()->getIdentifier(); return $identifier; }
[ "public", "function", "getIdentifier", "(", ")", "{", "$", "identifier", "=", "$", "this", "->", "getFromNode", "(", ")", "->", "getIdentifier", "(", ")", ".", "'-'", ".", "$", "this", "->", "getType", "(", ")", ".", "'-'", ".", "$", "this", "->", "getToNode", "(", ")", "->", "getIdentifier", "(", ")", ";", "return", "$", "identifier", ";", "}" ]
Returns the unique identifier of this node @return string
[ "Returns", "the", "unique", "identifier", "of", "this", "node" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Diagramm/Dependency.php#L78-L87
241,079
Niirrty/Niirrty.Translation
src/Translator.php
Translator.addSource
public function addSource( string $sourceName, ISource $source ) : Translator { $source->setLocale( $this->_locale ); $this->_sources[ $sourceName ] = $source; return $this; }
php
public function addSource( string $sourceName, ISource $source ) : Translator { $source->setLocale( $this->_locale ); $this->_sources[ $sourceName ] = $source; return $this; }
[ "public", "function", "addSource", "(", "string", "$", "sourceName", ",", "ISource", "$", "source", ")", ":", "Translator", "{", "$", "source", "->", "setLocale", "(", "$", "this", "->", "_locale", ")", ";", "$", "this", "->", "_sources", "[", "$", "sourceName", "]", "=", "$", "source", ";", "return", "$", "this", ";", "}" ]
Adds a source with an associated name. @param string $sourceName The unique source name @param \Niirrty\Translation\Sources\ISource $source @return \Niirrty\Translation\Translator
[ "Adds", "a", "source", "with", "an", "associated", "name", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L120-L129
241,080
Niirrty/Niirrty.Translation
src/Translator.php
Translator.read
public function read( $identifier, ?string $sourceName = null, $defaultTranslation = false ) { if ( null !== $sourceName && isset( $this->_sources[ $sourceName ] ) ) { // read from specific source return $this->_sources[ $sourceName ]->read( $identifier, $defaultTranslation ); } foreach ( $this->_sources as $source ) { $result = $source->read( $identifier, static::USS ); if ( static::USS !== $result ) { return $result; } } return $defaultTranslation; }
php
public function read( $identifier, ?string $sourceName = null, $defaultTranslation = false ) { if ( null !== $sourceName && isset( $this->_sources[ $sourceName ] ) ) { // read from specific source return $this->_sources[ $sourceName ]->read( $identifier, $defaultTranslation ); } foreach ( $this->_sources as $source ) { $result = $source->read( $identifier, static::USS ); if ( static::USS !== $result ) { return $result; } } return $defaultTranslation; }
[ "public", "function", "read", "(", "$", "identifier", ",", "?", "string", "$", "sourceName", "=", "null", ",", "$", "defaultTranslation", "=", "false", ")", "{", "if", "(", "null", "!==", "$", "sourceName", "&&", "isset", "(", "$", "this", "->", "_sources", "[", "$", "sourceName", "]", ")", ")", "{", "// read from specific source", "return", "$", "this", "->", "_sources", "[", "$", "sourceName", "]", "->", "read", "(", "$", "identifier", ",", "$", "defaultTranslation", ")", ";", "}", "foreach", "(", "$", "this", "->", "_sources", "as", "$", "source", ")", "{", "$", "result", "=", "$", "source", "->", "read", "(", "$", "identifier", ",", "static", "::", "USS", ")", ";", "if", "(", "static", "::", "USS", "!==", "$", "result", ")", "{", "return", "$", "result", ";", "}", "}", "return", "$", "defaultTranslation", ";", "}" ]
Reads the translation and return it. The returned translation can be of each known type, depending to the requirements. If a valid source index is defined, only this source is used. @param string|int $identifier The translation identifier @param string|null $sourceName The name of the source or NULL for search all sources @param mixed $defaultTranslation Is returned if the translation was not found @return mixed
[ "Reads", "the", "translation", "and", "return", "it", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L172-L192
241,081
Niirrty/Niirrty.Translation
src/Translator.php
Translator.GetInstance
public static function GetInstance() : Translator { if ( null === self::$_instance ) { self::$_instance = new Translator(); } return self::$_instance; }
php
public static function GetInstance() : Translator { if ( null === self::$_instance ) { self::$_instance = new Translator(); } return self::$_instance; }
[ "public", "static", "function", "GetInstance", "(", ")", ":", "Translator", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "self", "::", "$", "_instance", "=", "new", "Translator", "(", ")", ";", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Gets the global Translator instance. If none is define a empty one is created. @return \Niirrty\Translation\Translator @throws TranslationException
[ "Gets", "the", "global", "Translator", "instance", ".", "If", "none", "is", "define", "a", "empty", "one", "is", "created", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L303-L313
241,082
vinala/kernel
src/MVC/Model/ORM.php
ORM.emptyConstruct
private function emptyConstruct() { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); $this->_state = CRUD::CREATE_STAT; }
php
private function emptyConstruct() { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); $this->_state = CRUD::CREATE_STAT; }
[ "private", "function", "emptyConstruct", "(", ")", "{", "$", "this", "->", "getModel", "(", ")", ";", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "columns", "(", ")", ";", "$", "this", "->", "key", "(", ")", ";", "$", "this", "->", "_state", "=", "CRUD", "::", "CREATE_STAT", ";", "}" ]
the empty constructor.
[ "the", "empty", "constructor", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L183-L190
241,083
vinala/kernel
src/MVC/Model/ORM.php
ORM.mainConstruct
private function mainConstruct($key = null, $fail = false) { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); if (!is_null($key)) { $this->struct($key, $fail); $this->_state = CRUD::UPDATE_STAT; } else { $this->_state = CRUD::CREATE_STAT; } }
php
private function mainConstruct($key = null, $fail = false) { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); if (!is_null($key)) { $this->struct($key, $fail); $this->_state = CRUD::UPDATE_STAT; } else { $this->_state = CRUD::CREATE_STAT; } }
[ "private", "function", "mainConstruct", "(", "$", "key", "=", "null", ",", "$", "fail", "=", "false", ")", "{", "$", "this", "->", "getModel", "(", ")", ";", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "columns", "(", ")", ";", "$", "this", "->", "key", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "key", ")", ")", "{", "$", "this", "->", "struct", "(", "$", "key", ",", "$", "fail", ")", ";", "$", "this", "->", "_state", "=", "CRUD", "::", "UPDATE_STAT", ";", "}", "else", "{", "$", "this", "->", "_state", "=", "CRUD", "::", "CREATE_STAT", ";", "}", "}" ]
the main constructor to search that from database. @param int $key @param bool $fail
[ "the", "main", "constructor", "to", "search", "that", "from", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L198-L210
241,084
vinala/kernel
src/MVC/Model/ORM.php
ORM.secondConstruct
private function secondConstruct($data) { $this->getModel($data); $this->getTable($data); $this->columns($data); $this->key($data); $this->fill($data); $this->_state = CRUD::UPDATE_STAT; }
php
private function secondConstruct($data) { $this->getModel($data); $this->getTable($data); $this->columns($data); $this->key($data); $this->fill($data); $this->_state = CRUD::UPDATE_STAT; }
[ "private", "function", "secondConstruct", "(", "$", "data", ")", "{", "$", "this", "->", "getModel", "(", "$", "data", ")", ";", "$", "this", "->", "getTable", "(", "$", "data", ")", ";", "$", "this", "->", "columns", "(", "$", "data", ")", ";", "$", "this", "->", "key", "(", "$", "data", ")", ";", "$", "this", "->", "fill", "(", "$", "data", ")", ";", "$", "this", "->", "_state", "=", "CRUD", "::", "UPDATE_STAT", ";", "}" ]
the second Construct to fil data from array. @param array $data
[ "the", "second", "Construct", "to", "fil", "data", "from", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L217-L225
241,085
vinala/kernel
src/MVC/Model/ORM.php
ORM.getTable
protected function getTable($data = null) { if (is_null($data)) { $this->_table = static::$table; $this->_prifixTable = (Config::get('database.prefixing') ? Config::get('database.prefixe') : '').static::$table; // if (!$this->checkTable()) { throw new TableNotFoundException(static::$table); } // return $this->_prifixTable; } else { $this->_prifixTable = $data['prifixTable']; $this->_table = static::$table; } }
php
protected function getTable($data = null) { if (is_null($data)) { $this->_table = static::$table; $this->_prifixTable = (Config::get('database.prefixing') ? Config::get('database.prefixe') : '').static::$table; // if (!$this->checkTable()) { throw new TableNotFoundException(static::$table); } // return $this->_prifixTable; } else { $this->_prifixTable = $data['prifixTable']; $this->_table = static::$table; } }
[ "protected", "function", "getTable", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_table", "=", "static", "::", "$", "table", ";", "$", "this", "->", "_prifixTable", "=", "(", "Config", "::", "get", "(", "'database.prefixing'", ")", "?", "Config", "::", "get", "(", "'database.prefixe'", ")", ":", "''", ")", ".", "static", "::", "$", "table", ";", "//", "if", "(", "!", "$", "this", "->", "checkTable", "(", ")", ")", "{", "throw", "new", "TableNotFoundException", "(", "static", "::", "$", "table", ")", ";", "}", "//", "return", "$", "this", "->", "_prifixTable", ";", "}", "else", "{", "$", "this", "->", "_prifixTable", "=", "$", "data", "[", "'prifixTable'", "]", ";", "$", "this", "->", "_table", "=", "static", "::", "$", "table", ";", "}", "}" ]
get the model table name. @param $table @return null
[ "get", "the", "model", "table", "name", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L286-L301
241,086
vinala/kernel
src/MVC/Model/ORM.php
ORM.checkTable
protected function checkTable() { $data = Query::from('information_schema.tables', false) ->select('*') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY); // return (Table::count($data) > 0) ? true : false; }
php
protected function checkTable() { $data = Query::from('information_schema.tables', false) ->select('*') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY); // return (Table::count($data) > 0) ? true : false; }
[ "protected", "function", "checkTable", "(", ")", "{", "$", "data", "=", "Query", "::", "from", "(", "'information_schema.tables'", ",", "false", ")", "->", "select", "(", "'*'", ")", "->", "where", "(", "'TABLE_SCHEMA'", ",", "'='", ",", "Config", "::", "get", "(", "'database.database'", ")", ")", "->", "andwhere", "(", "'TABLE_NAME'", ",", "'='", ",", "$", "this", "->", "_prifixTable", ")", "->", "get", "(", "Query", "::", "GET_ARRAY", ")", ";", "//", "return", "(", "Table", "::", "count", "(", "$", "data", ")", ">", "0", ")", "?", "true", ":", "false", ";", "}" ]
Check if table exists in database. @param $table string @return bool
[ "Check", "if", "table", "exists", "in", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L310-L319
241,087
vinala/kernel
src/MVC/Model/ORM.php
ORM.columns
protected function columns($data = null) { if (is_null($data)) { $this->_columns = $this->extruct( Query::from('INFORMATION_SCHEMA.COLUMNS', false) ->select('COLUMN_NAME') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY) ); // return $this->_columns; } else { $this->_columns = $data['columns']; } }
php
protected function columns($data = null) { if (is_null($data)) { $this->_columns = $this->extruct( Query::from('INFORMATION_SCHEMA.COLUMNS', false) ->select('COLUMN_NAME') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY) ); // return $this->_columns; } else { $this->_columns = $data['columns']; } }
[ "protected", "function", "columns", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_columns", "=", "$", "this", "->", "extruct", "(", "Query", "::", "from", "(", "'INFORMATION_SCHEMA.COLUMNS'", ",", "false", ")", "->", "select", "(", "'COLUMN_NAME'", ")", "->", "where", "(", "'TABLE_SCHEMA'", ",", "'='", ",", "Config", "::", "get", "(", "'database.database'", ")", ")", "->", "andwhere", "(", "'TABLE_NAME'", ",", "'='", ",", "$", "this", "->", "_prifixTable", ")", "->", "get", "(", "Query", "::", "GET_ARRAY", ")", ")", ";", "//", "return", "$", "this", "->", "_columns", ";", "}", "else", "{", "$", "this", "->", "_columns", "=", "$", "data", "[", "'columns'", "]", ";", "}", "}" ]
to get and set all columns of data table. @return array
[ "to", "get", "and", "set", "all", "columns", "of", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L326-L341
241,088
vinala/kernel
src/MVC/Model/ORM.php
ORM.key
protected function key($data = null) { if (is_null($data)) { $data = $this->getPK(); // if (Table::count($data) > 1) { throw new ManyPrimaryKeysException(); } elseif (Table::count($data) == 0) { throw new PrimaryKeyNotFoundException(static::$table); } // $this->_keyName = $data[0]['Column_name']; $this->_key['name'] = $data[0]['Column_name']; } else { $this->_keyName = $data['key']; $this->_key['name'] = $data['key']; } }
php
protected function key($data = null) { if (is_null($data)) { $data = $this->getPK(); // if (Table::count($data) > 1) { throw new ManyPrimaryKeysException(); } elseif (Table::count($data) == 0) { throw new PrimaryKeyNotFoundException(static::$table); } // $this->_keyName = $data[0]['Column_name']; $this->_key['name'] = $data[0]['Column_name']; } else { $this->_keyName = $data['key']; $this->_key['name'] = $data['key']; } }
[ "protected", "function", "key", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getPK", "(", ")", ";", "//", "if", "(", "Table", "::", "count", "(", "$", "data", ")", ">", "1", ")", "{", "throw", "new", "ManyPrimaryKeysException", "(", ")", ";", "}", "elseif", "(", "Table", "::", "count", "(", "$", "data", ")", "==", "0", ")", "{", "throw", "new", "PrimaryKeyNotFoundException", "(", "static", "::", "$", "table", ")", ";", "}", "//", "$", "this", "->", "_keyName", "=", "$", "data", "[", "0", "]", "[", "'Column_name'", "]", ";", "$", "this", "->", "_key", "[", "'name'", "]", "=", "$", "data", "[", "0", "]", "[", "'Column_name'", "]", ";", "}", "else", "{", "$", "this", "->", "_keyName", "=", "$", "data", "[", "'key'", "]", ";", "$", "this", "->", "_key", "[", "'name'", "]", "=", "$", "data", "[", "'key'", "]", ";", "}", "}" ]
set primary key the framework doesn't support more the column to be the primary key otherwise exception will be thrown. @return null
[ "set", "primary", "key", "the", "framework", "doesn", "t", "support", "more", "the", "column", "to", "be", "the", "primary", "key", "otherwise", "exception", "will", "be", "thrown", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L446-L463
241,089
vinala/kernel
src/MVC/Model/ORM.php
ORM.struct
protected function struct($key, $fail) { $data = $this->dig($key); // if (Table::count($data) == 1) { if ($this->_canKept && $this->keptAt($data)) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data)) { $this->_stashed = true; } // $this->convert($data); } elseif ($fail && Table::count($data) == 0) { throw new ModelNotFoundException($key, $this->_model); } }
php
protected function struct($key, $fail) { $data = $this->dig($key); // if (Table::count($data) == 1) { if ($this->_canKept && $this->keptAt($data)) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data)) { $this->_stashed = true; } // $this->convert($data); } elseif ($fail && Table::count($data) == 0) { throw new ModelNotFoundException($key, $this->_model); } }
[ "protected", "function", "struct", "(", "$", "key", ",", "$", "fail", ")", "{", "$", "data", "=", "$", "this", "->", "dig", "(", "$", "key", ")", ";", "//", "if", "(", "Table", "::", "count", "(", "$", "data", ")", "==", "1", ")", "{", "if", "(", "$", "this", "->", "_canKept", "&&", "$", "this", "->", "keptAt", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_kept", "=", "true", ";", "}", "if", "(", "$", "this", "->", "_canStashed", "&&", "$", "this", "->", "stashedAt", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_stashed", "=", "true", ";", "}", "//", "$", "this", "->", "convert", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "fail", "&&", "Table", "::", "count", "(", "$", "data", ")", "==", "0", ")", "{", "throw", "new", "ModelNotFoundException", "(", "$", "key", ",", "$", "this", "->", "_model", ")", ";", "}", "}" ]
get data from data table according to primary key value. @param int $key @return null
[ "get", "data", "from", "data", "table", "according", "to", "primary", "key", "value", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L472-L488
241,090
vinala/kernel
src/MVC/Model/ORM.php
ORM.fill
protected function fill($data) { if ($this->_canKept && $this->keptAt($data['values'])) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data['values'])) { $this->_stashed = true; } // $this->convert($data['values']); }
php
protected function fill($data) { if ($this->_canKept && $this->keptAt($data['values'])) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data['values'])) { $this->_stashed = true; } // $this->convert($data['values']); }
[ "protected", "function", "fill", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "_canKept", "&&", "$", "this", "->", "keptAt", "(", "$", "data", "[", "'values'", "]", ")", ")", "{", "$", "this", "->", "_kept", "=", "true", ";", "}", "if", "(", "$", "this", "->", "_canStashed", "&&", "$", "this", "->", "stashedAt", "(", "$", "data", "[", "'values'", "]", ")", ")", "{", "$", "this", "->", "_stashed", "=", "true", ";", "}", "//", "$", "this", "->", "convert", "(", "$", "data", "[", "'values'", "]", ")", ";", "}" ]
fill data from array. @param array $data @return null
[ "fill", "data", "from", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L497-L507
241,091
vinala/kernel
src/MVC/Model/ORM.php
ORM.dig
protected function dig($key) { return Query::from(static::$table) ->select('*') ->where($this->_keyName, '=', $key) ->get(Query::GET_ARRAY); }
php
protected function dig($key) { return Query::from(static::$table) ->select('*') ->where($this->_keyName, '=', $key) ->get(Query::GET_ARRAY); }
[ "protected", "function", "dig", "(", "$", "key", ")", "{", "return", "Query", "::", "from", "(", "static", "::", "$", "table", ")", "->", "select", "(", "'*'", ")", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "key", ")", "->", "get", "(", "Query", "::", "GET_ARRAY", ")", ";", "}" ]
search for data by Query Class according to primary key. @param int $key @return array
[ "search", "for", "data", "by", "Query", "Class", "according", "to", "primary", "key", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L516-L522
241,092
vinala/kernel
src/MVC/Model/ORM.php
ORM.convert
protected function convert($data) { foreach ($data[0] as $key => $value) { if (!$this->_kept && !$this->_stashed) { $this->$key = $value; $this->setKey($key, $value); } else { if ($this->_kept) { $this->_keptData[$key] = $value; } if ($this->_stashed) { $this->_stashedData[$key] = $value; } } $this->data[$key] = $value; } }
php
protected function convert($data) { foreach ($data[0] as $key => $value) { if (!$this->_kept && !$this->_stashed) { $this->$key = $value; $this->setKey($key, $value); } else { if ($this->_kept) { $this->_keptData[$key] = $value; } if ($this->_stashed) { $this->_stashedData[$key] = $value; } } $this->data[$key] = $value; } }
[ "protected", "function", "convert", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "[", "0", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "_kept", "&&", "!", "$", "this", "->", "_stashed", ")", "{", "$", "this", "->", "$", "key", "=", "$", "value", ";", "$", "this", "->", "setKey", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "_kept", ")", "{", "$", "this", "->", "_keptData", "[", "$", "key", "]", "=", "$", "value", ";", "}", "if", "(", "$", "this", "->", "_stashed", ")", "{", "$", "this", "->", "_stashedData", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
make data array colmuns as property in case of hidden data property was true data will be stored in hidden data instead ofas property. @param array $data @return null
[ "make", "data", "array", "colmuns", "as", "property", "in", "case", "of", "hidden", "data", "property", "was", "true", "data", "will", "be", "stored", "in", "hidden", "data", "instead", "ofas", "property", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L566-L583
241,093
vinala/kernel
src/MVC/Model/ORM.php
ORM.save
public function save() { if ($this->_state == CRUD::CREATE_STAT) { $this->add(); } elseif ($this->_state == CRUD::UPDATE_STAT) { $this->edit(); } }
php
public function save() { if ($this->_state == CRUD::CREATE_STAT) { $this->add(); } elseif ($this->_state == CRUD::UPDATE_STAT) { $this->edit(); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "_state", "==", "CRUD", "::", "CREATE_STAT", ")", "{", "$", "this", "->", "add", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "_state", "==", "CRUD", "::", "UPDATE_STAT", ")", "{", "$", "this", "->", "edit", "(", ")", ";", "}", "}" ]
Save the opertaion makes by user either creation or editing. @return bool
[ "Save", "the", "opertaion", "makes", "by", "user", "either", "creation", "or", "editing", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L640-L647
241,094
vinala/kernel
src/MVC/Model/ORM.php
ORM.add
private function add() { $columns = []; $values = []; // if ($this->_tracked) { $this->created_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName && isset($this->$value) && !empty($this->$value)) { $columns[] = $value; $values[] = $this->$value; } } // return $this->insert($columns, $values); }
php
private function add() { $columns = []; $values = []; // if ($this->_tracked) { $this->created_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName && isset($this->$value) && !empty($this->$value)) { $columns[] = $value; $values[] = $this->$value; } } // return $this->insert($columns, $values); }
[ "private", "function", "add", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "//", "if", "(", "$", "this", "->", "_tracked", ")", "{", "$", "this", "->", "created_at", "=", "Time", "::", "current", "(", ")", ";", "}", "//", "foreach", "(", "$", "this", "->", "_columns", "as", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "$", "this", "->", "_keyName", "&&", "isset", "(", "$", "this", "->", "$", "value", ")", "&&", "!", "empty", "(", "$", "this", "->", "$", "value", ")", ")", "{", "$", "columns", "[", "]", "=", "$", "value", ";", "$", "values", "[", "]", "=", "$", "this", "->", "$", "value", ";", "}", "}", "//", "return", "$", "this", "->", "insert", "(", "$", "columns", ",", "$", "values", ")", ";", "}" ]
function to add data in data table. @return bool
[ "function", "to", "add", "data", "in", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L654-L671
241,095
vinala/kernel
src/MVC/Model/ORM.php
ORM.insert
private function insert($columns, $values) { return Query::table(static::$table) ->column($columns) ->value($values) ->insert(); }
php
private function insert($columns, $values) { return Query::table(static::$table) ->column($columns) ->value($values) ->insert(); }
[ "private", "function", "insert", "(", "$", "columns", ",", "$", "values", ")", "{", "return", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "column", "(", "$", "columns", ")", "->", "value", "(", "$", "values", ")", "->", "insert", "(", ")", ";", "}" ]
function to exexute insert data. @param array $columns @param array $values @return bool
[ "function", "to", "exexute", "insert", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L681-L687
241,096
vinala/kernel
src/MVC/Model/ORM.php
ORM.edit
private function edit() { $columns = []; $values = []; // if ($this->_tracked) { $this->edited_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName) { $columns[] = $value; $values[] = empty($this->$value) ? null : $this->$value; } } // return $this->update($columns, $values); }
php
private function edit() { $columns = []; $values = []; // if ($this->_tracked) { $this->edited_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName) { $columns[] = $value; $values[] = empty($this->$value) ? null : $this->$value; } } // return $this->update($columns, $values); }
[ "private", "function", "edit", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "//", "if", "(", "$", "this", "->", "_tracked", ")", "{", "$", "this", "->", "edited_at", "=", "Time", "::", "current", "(", ")", ";", "}", "//", "foreach", "(", "$", "this", "->", "_columns", "as", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "$", "this", "->", "_keyName", ")", "{", "$", "columns", "[", "]", "=", "$", "value", ";", "$", "values", "[", "]", "=", "empty", "(", "$", "this", "->", "$", "value", ")", "?", "null", ":", "$", "this", "->", "$", "value", ";", "}", "}", "//", "return", "$", "this", "->", "update", "(", "$", "columns", ",", "$", "values", ")", ";", "}" ]
function to edit data in data table. @return bool
[ "function", "to", "edit", "data", "in", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L694-L711
241,097
vinala/kernel
src/MVC/Model/ORM.php
ORM.update
private function update($columns, $values) { $query = Query::table(static::$table); // for ($i = 0; $i < Table::count($columns); $i++) { $query = !empty($values[$i]) ? $query->set($columns[$i], $values[$i]) : $query->set($columns[$i], 'null', false); } // $query->where($this->_keyName, '=', $this->_keyValue) ->update(); // return $query; }
php
private function update($columns, $values) { $query = Query::table(static::$table); // for ($i = 0; $i < Table::count($columns); $i++) { $query = !empty($values[$i]) ? $query->set($columns[$i], $values[$i]) : $query->set($columns[$i], 'null', false); } // $query->where($this->_keyName, '=', $this->_keyValue) ->update(); // return $query; }
[ "private", "function", "update", "(", "$", "columns", ",", "$", "values", ")", "{", "$", "query", "=", "Query", "::", "table", "(", "static", "::", "$", "table", ")", ";", "//", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "Table", "::", "count", "(", "$", "columns", ")", ";", "$", "i", "++", ")", "{", "$", "query", "=", "!", "empty", "(", "$", "values", "[", "$", "i", "]", ")", "?", "$", "query", "->", "set", "(", "$", "columns", "[", "$", "i", "]", ",", "$", "values", "[", "$", "i", "]", ")", ":", "$", "query", "->", "set", "(", "$", "columns", "[", "$", "i", "]", ",", "'null'", ",", "false", ")", ";", "}", "//", "$", "query", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "this", "->", "_keyValue", ")", "->", "update", "(", ")", ";", "//", "return", "$", "query", ";", "}" ]
function to exexute update data. @param array $columns @param array $values @return bool
[ "function", "to", "exexute", "update", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L721-L733
241,098
vinala/kernel
src/MVC/Model/ORM.php
ORM.delete
public function delete() { if (!$this->_canKept) { $this->forceDelete(); } else { Query::table(static::$table) ->set('deleted_at', Time::current()) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
php
public function delete() { if (!$this->_canKept) { $this->forceDelete(); } else { Query::table(static::$table) ->set('deleted_at', Time::current()) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_canKept", ")", "{", "$", "this", "->", "forceDelete", "(", ")", ";", "}", "else", "{", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "set", "(", "'deleted_at'", ",", "Time", "::", "current", "(", ")", ")", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "this", "->", "_keyValue", ")", "->", "update", "(", ")", ";", "}", "}" ]
to delete the model from database in case of Kept deleted just hide it. @return bool
[ "to", "delete", "the", "model", "from", "database", "in", "case", "of", "Kept", "deleted", "just", "hide", "it", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L741-L751
241,099
vinala/kernel
src/MVC/Model/ORM.php
ORM.forceDelete
public function forceDelete() { $key = $this->_kept ? $this->_keptData[$this->_keyName] : $this->_keyValue; // Query::table(static::$table) ->where($this->_keyName, '=', $key) ->delete(); // $this->reset(); }
php
public function forceDelete() { $key = $this->_kept ? $this->_keptData[$this->_keyName] : $this->_keyValue; // Query::table(static::$table) ->where($this->_keyName, '=', $key) ->delete(); // $this->reset(); }
[ "public", "function", "forceDelete", "(", ")", "{", "$", "key", "=", "$", "this", "->", "_kept", "?", "$", "this", "->", "_keptData", "[", "$", "this", "->", "_keyName", "]", ":", "$", "this", "->", "_keyValue", ";", "//", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "key", ")", "->", "delete", "(", ")", ";", "//", "$", "this", "->", "reset", "(", ")", ";", "}" ]
to force delete the model from database even if the model is Kept deleted. @return bool
[ "to", "force", "delete", "the", "model", "from", "database", "even", "if", "the", "model", "is", "Kept", "deleted", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L758-L767