repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
calgamo/getopt
src/Getopt.php
Getopt.addOptions
public function addOptions(array $options) : Getopt { if (!empty($this->options)){ $this->options = array_merge($this->options, $options); } else{ $this->options = $options; } return $this; }
php
public function addOptions(array $options) : Getopt { if (!empty($this->options)){ $this->options = array_merge($this->options, $options); } else{ $this->options = $options; } return $this; }
[ "public", "function", "addOptions", "(", "array", "$", "options", ")", ":", "Getopt", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", ")", ")", "{", "$", "this", "->", "options", "=", "array_merge", "(", "$", "this", "->", "options",...
Add short options @param array $options @return Getopt
[ "Add", "short", "options" ]
88c05513e92e5de9f6a9b481174dfc953cb57aa1
https://github.com/calgamo/getopt/blob/88c05513e92e5de9f6a9b481174dfc953cb57aa1/src/Getopt.php#L28-L37
train
bariew/yii2-user-cms-module
Module.php
Module.hasUser
public static function hasUser() { if (!(Yii::$app instanceof Application)) { return false; } if (!Yii::$app->db->getTableSchema(User::tableName())) { return false; } try { $identityClass = Yii::$app->user->identityClass; } catch (\Exception $e) { $identityClass = false; } if (!$identityClass) { return false; } return !Yii::$app->user->isGuest; }
php
public static function hasUser() { if (!(Yii::$app instanceof Application)) { return false; } if (!Yii::$app->db->getTableSchema(User::tableName())) { return false; } try { $identityClass = Yii::$app->user->identityClass; } catch (\Exception $e) { $identityClass = false; } if (!$identityClass) { return false; } return !Yii::$app->user->isGuest; }
[ "public", "static", "function", "hasUser", "(", ")", "{", "if", "(", "!", "(", "Yii", "::", "$", "app", "instanceof", "Application", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "Yii", "::", "$", "app", "->", "db", "->", "getTableSch...
We just check whether module is installed and user is logged in. @return bool
[ "We", "just", "check", "whether", "module", "is", "installed", "and", "user", "is", "logged", "in", "." ]
d9f5658cae45308c0916bc99976272a4ec906490
https://github.com/bariew/yii2-user-cms-module/blob/d9f5658cae45308c0916bc99976272a4ec906490/Module.php#L38-L58
train
neomorina/core
Str.php
Str.StartsWith
public static function StartsWith($haystack, $needle) { $length = static::Length($needle); return substr($haystack, 0, $length) === $needle; }
php
public static function StartsWith($haystack, $needle) { $length = static::Length($needle); return substr($haystack, 0, $length) === $needle; }
[ "public", "static", "function", "StartsWith", "(", "$", "haystack", ",", "$", "needle", ")", "{", "$", "length", "=", "static", "::", "Length", "(", "$", "needle", ")", ";", "return", "substr", "(", "$", "haystack", ",", "0", ",", "$", "length", ")",...
Determine if the given string starts with the given substring. @param string $haystack string @param string $needle substring @return bool
[ "Determine", "if", "the", "given", "string", "starts", "with", "the", "given", "substring", "." ]
5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a
https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L43-L48
train
neomorina/core
Str.php
Str.EndsWith
public static function EndsWith($haystack, $needle) { $length = static::Length($needle); return $length === 0 || (substr($haystack, -$length) === $needle); }
php
public static function EndsWith($haystack, $needle) { $length = static::Length($needle); return $length === 0 || (substr($haystack, -$length) === $needle); }
[ "public", "static", "function", "EndsWith", "(", "$", "haystack", ",", "$", "needle", ")", "{", "$", "length", "=", "static", "::", "Length", "(", "$", "needle", ")", ";", "return", "$", "length", "===", "0", "||", "(", "substr", "(", "$", "haystack"...
Determine if the given string ends with the given substring. @param string $haystack string @param string $needle substring @return bool
[ "Determine", "if", "the", "given", "string", "ends", "with", "the", "given", "substring", "." ]
5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a
https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L58-L63
train
neomorina/core
Str.php
Str.Ucfirst
public static function Ucfirst($str) { return function_exists('ucfirst') ? ucfirst($str) : static::Upper(substr($str, 0, 1)).substr($str, 1); }
php
public static function Ucfirst($str) { return function_exists('ucfirst') ? ucfirst($str) : static::Upper(substr($str, 0, 1)).substr($str, 1); }
[ "public", "static", "function", "Ucfirst", "(", "$", "str", ")", "{", "return", "function_exists", "(", "'ucfirst'", ")", "?", "ucfirst", "(", "$", "str", ")", ":", "static", "::", "Upper", "(", "substr", "(", "$", "str", ",", "0", ",", "1", ")", "...
Change string's first character uppercase. @param string $str @return string
[ "Change", "string", "s", "first", "character", "uppercase", "." ]
5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a
https://github.com/neomorina/core/blob/5a70e4cef64b7bd5b43674a3a9118d8b33a1f18a/Str.php#L108-L113
train
nonetallt/jinitialize-core
src/ProcedureFactory.php
ProcedureFactory.parseCommands
private function parseCommands(array $json, string $procedureName) { $factory = new CommandFactory($this->app); $errors = []; foreach($json as $commandString) { /* Get the namespace of the command */ $plugin = explode(':', $commandString, 2)[0]; /* Check that the given plugin is installed */ if(! $this->app->getContainer()->hasPlugin($plugin)) { $errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'."; continue; } $parsedCommands[] = $factory->create($plugin, $commandString); } if(! empty($errors)) { throw new PluginNotFoundException(implode(PHP_EOL, $errors)); } return $parsedCommands; }
php
private function parseCommands(array $json, string $procedureName) { $factory = new CommandFactory($this->app); $errors = []; foreach($json as $commandString) { /* Get the namespace of the command */ $plugin = explode(':', $commandString, 2)[0]; /* Check that the given plugin is installed */ if(! $this->app->getContainer()->hasPlugin($plugin)) { $errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'."; continue; } $parsedCommands[] = $factory->create($plugin, $commandString); } if(! empty($errors)) { throw new PluginNotFoundException(implode(PHP_EOL, $errors)); } return $parsedCommands; }
[ "private", "function", "parseCommands", "(", "array", "$", "json", ",", "string", "$", "procedureName", ")", "{", "$", "factory", "=", "new", "CommandFactory", "(", "$", "this", "->", "app", ")", ";", "$", "errors", "=", "[", "]", ";", "foreach", "(", ...
Create command classes from a json array
[ "Create", "command", "classes", "from", "a", "json", "array" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L60-L82
train
nonetallt/jinitialize-core
src/ProcedureFactory.php
ProcedureFactory.parseUntilFound
private function parseUntilFound(string $procedure) { /* First check if parsed content has the desired procedure */ foreach($this->parsed as $path => $json) { if($this->hasProcedure($json, $procedure)) return $json; } /* Next, check if the most likely file has the procedure */ $json = $this->findMostLikelyFile($procedure); if(! is_null($json)) return $json; /* Lastly, check rest of the files one by one */ foreach($this->unparsedPaths() as $path) { $json = $this->parsePath($path); if($this->hasProcedure($json, $procedure)) return $json; } return null; }
php
private function parseUntilFound(string $procedure) { /* First check if parsed content has the desired procedure */ foreach($this->parsed as $path => $json) { if($this->hasProcedure($json, $procedure)) return $json; } /* Next, check if the most likely file has the procedure */ $json = $this->findMostLikelyFile($procedure); if(! is_null($json)) return $json; /* Lastly, check rest of the files one by one */ foreach($this->unparsedPaths() as $path) { $json = $this->parsePath($path); if($this->hasProcedure($json, $procedure)) return $json; } return null; }
[ "private", "function", "parseUntilFound", "(", "string", "$", "procedure", ")", "{", "/* First check if parsed content has the desired procedure */", "foreach", "(", "$", "this", "->", "parsed", "as", "$", "path", "=>", "$", "json", ")", "{", "if", "(", "$", "th...
Parse paths until file containing the given procedure if found or there is nothing left to parse.
[ "Parse", "paths", "until", "file", "containing", "the", "given", "procedure", "if", "found", "or", "there", "is", "nothing", "left", "to", "parse", "." ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L89-L108
train
nonetallt/jinitialize-core
src/ProcedureFactory.php
ProcedureFactory.findMostLikelyFile
private function findMostLikelyFile(string $procedure) { foreach($this->paths as $path) { $filename = Strings::afterLast($path, '/'); $filenameWithoutExtension = Strings::untilLast($filename, '.'); if($procedure === $filenameWithoutExtension) { return $filename; } } return null; }
php
private function findMostLikelyFile(string $procedure) { foreach($this->paths as $path) { $filename = Strings::afterLast($path, '/'); $filenameWithoutExtension = Strings::untilLast($filename, '.'); if($procedure === $filenameWithoutExtension) { return $filename; } } return null; }
[ "private", "function", "findMostLikelyFile", "(", "string", "$", "procedure", ")", "{", "foreach", "(", "$", "this", "->", "paths", "as", "$", "path", ")", "{", "$", "filename", "=", "Strings", "::", "afterLast", "(", "$", "path", ",", "'/'", ")", ";",...
Find the file that is most likely to contain the given procedure. Prioritizes files with the same name as the procedure.
[ "Find", "the", "file", "that", "is", "most", "likely", "to", "contain", "the", "given", "procedure", ".", "Prioritizes", "files", "with", "the", "same", "name", "as", "the", "procedure", "." ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/ProcedureFactory.php#L115-L127
train
jpcercal/resource-manager
src/Service/DoctrineResourceManager.php
DoctrineResourceManager.getQueryBuilder
protected function getQueryBuilder($repositoryMethod) { $repository = $this ->getDriver() ->getDoctrineOrmEm() ->getRepository($this->getDriver()->getEntityFqn()) ; $repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods(); if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) { return $repository->createQueryBuilder($this->getDriver()->getEntityAlias()); } $queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}(); if (!$queryBuilder instanceof QueryBuilder) { throw new ResourceException(sprintf( 'The method "%s" of repository class must be return a %s instance', $repositoryMethods[$repositoryMethod], '\Doctrine\ORM\QueryBuilder' )); } return $queryBuilder; }
php
protected function getQueryBuilder($repositoryMethod) { $repository = $this ->getDriver() ->getDoctrineOrmEm() ->getRepository($this->getDriver()->getEntityFqn()) ; $repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods(); if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) { return $repository->createQueryBuilder($this->getDriver()->getEntityAlias()); } $queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}(); if (!$queryBuilder instanceof QueryBuilder) { throw new ResourceException(sprintf( 'The method "%s" of repository class must be return a %s instance', $repositoryMethods[$repositoryMethod], '\Doctrine\ORM\QueryBuilder' )); } return $queryBuilder; }
[ "protected", "function", "getQueryBuilder", "(", "$", "repositoryMethod", ")", "{", "$", "repository", "=", "$", "this", "->", "getDriver", "(", ")", "->", "getDoctrineOrmEm", "(", ")", "->", "getRepository", "(", "$", "this", "->", "getDriver", "(", ")", ...
Get the QueryBuilder instance. @param string $repositoryMethod @return QueryBuilder
[ "Get", "the", "QueryBuilder", "instance", "." ]
e3565eb1ce3c0f7f16188596f0a58a42a35baa64
https://github.com/jpcercal/resource-manager/blob/e3565eb1ce3c0f7f16188596f0a58a42a35baa64/src/Service/DoctrineResourceManager.php#L63-L88
train
weckx/wcx-syslog
library/Wcx/Syslog/Message/MessageAbstract.php
MessageAbstract.setTimestamp
public function setTimestamp($timestamp) { if (!$timestamp instanceof \DateTime) { $date = new \DateTime(); $date->setTimestamp($timestamp); } else { $date = $timestamp; } $this->header['TIMESTAMP'] = $date->format('M d H:i:s'); return $this; }
php
public function setTimestamp($timestamp) { if (!$timestamp instanceof \DateTime) { $date = new \DateTime(); $date->setTimestamp($timestamp); } else { $date = $timestamp; } $this->header['TIMESTAMP'] = $date->format('M d H:i:s'); return $this; }
[ "public", "function", "setTimestamp", "(", "$", "timestamp", ")", "{", "if", "(", "!", "$", "timestamp", "instanceof", "\\", "DateTime", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "date", "->", "setTimestamp", "(", "$", ...
Set the timestamp of the message generation @var int|\DateTime $timestamp UNIX Timestamp (as generated by time() or strtotime()) or a php DateTime object @return Bsd
[ "Set", "the", "timestamp", "of", "the", "message", "generation" ]
2ec40409a7b5393751ebf9051a33d829e6fc313e
https://github.com/weckx/wcx-syslog/blob/2ec40409a7b5393751ebf9051a33d829e6fc313e/library/Wcx/Syslog/Message/MessageAbstract.php#L168-L178
train
tentwofour/twig
src/Ten24/Twig/Extension/NumberExtension.php
NumberExtension.formatNumberToHumanReadable
public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common') { if ($number >= 1000000) { // Divide by 1000000 to get 1M, 1.23M, etc. $value = $number / 1000000; $extension = 'M'; } elseif ($number >= 1000 && $number < 1000000) { // Divide by 1000, to get 1K, 1.33K, etc. $value = $number / 1000; $extension = 'K'; } else { // Less than 1000, just return the number, unformatted, not rounded $value = $number; $extension = ''; } if ('common' == $method) { $value = round($value, $precision); } else { if ('ceil' != $method && 'floor' != $method) { throw new \RuntimeException('The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.'); } $value = $method($value * pow(10, $precision)) / pow(10, $precision); } return $value.$extension; }
php
public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common') { if ($number >= 1000000) { // Divide by 1000000 to get 1M, 1.23M, etc. $value = $number / 1000000; $extension = 'M'; } elseif ($number >= 1000 && $number < 1000000) { // Divide by 1000, to get 1K, 1.33K, etc. $value = $number / 1000; $extension = 'K'; } else { // Less than 1000, just return the number, unformatted, not rounded $value = $number; $extension = ''; } if ('common' == $method) { $value = round($value, $precision); } else { if ('ceil' != $method && 'floor' != $method) { throw new \RuntimeException('The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.'); } $value = $method($value * pow(10, $precision)) / pow(10, $precision); } return $value.$extension; }
[ "public", "function", "formatNumberToHumanReadable", "(", "$", "number", ",", "$", "precision", "=", "0", ",", "$", "method", "=", "'common'", ")", "{", "if", "(", "$", "number", ">=", "1000000", ")", "{", "// Divide by 1000000 to get 1M, 1.23M, etc.", "$", "v...
Format a large number into the closest million or thousand @param int|float $number The number to format @param int $precision The precision to round with @param string $method Possible values 'ceil'|'floor'|'common', default: 'common' @return float
[ "Format", "a", "large", "number", "into", "the", "closest", "million", "or", "thousand" ]
4e3dba68508a242ac0b16fa3b02239178c4151f0
https://github.com/tentwofour/twig/blob/4e3dba68508a242ac0b16fa3b02239178c4151f0/src/Ten24/Twig/Extension/NumberExtension.php#L26-L54
train
znframework/package-language
Grid.php
Grid._styleElement
protected function _styleElement() { $styleElementConfig = $this->gridConfig['styleElement'] ?? NULL; if( ! empty($styleElementConfig) ) { $attributes = NULL; $sheet = Singleton::class('ZN\Hypertext\Sheet'); $style = Singleton::class('ZN\Hypertext\Style'); foreach( $styleElementConfig as $selector => $attr ) { $attributes .= $sheet->selector($selector)->attr($attr)->create(); } return $style->open().$attributes.$style->close(); } return NULL; }
php
protected function _styleElement() { $styleElementConfig = $this->gridConfig['styleElement'] ?? NULL; if( ! empty($styleElementConfig) ) { $attributes = NULL; $sheet = Singleton::class('ZN\Hypertext\Sheet'); $style = Singleton::class('ZN\Hypertext\Style'); foreach( $styleElementConfig as $selector => $attr ) { $attributes .= $sheet->selector($selector)->attr($attr)->create(); } return $style->open().$attributes.$style->close(); } return NULL; }
[ "protected", "function", "_styleElement", "(", ")", "{", "$", "styleElementConfig", "=", "$", "this", "->", "gridConfig", "[", "'styleElement'", "]", "??", "NULL", ";", "if", "(", "!", "empty", "(", "$", "styleElementConfig", ")", ")", "{", "$", "attribute...
Protected Style Element
[ "Protected", "Style", "Element" ]
f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09
https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Grid.php#L312-L332
train
Dhii/state-machine-abstract
src/AbstractStateMachine.php
AbstractStateMachine._transition
protected function _transition($transition) { if (!$this->_canTransition($transition)) { throw $this->_createCouldNotTransitionException( $this->__('Cannot apply transition "%s"', $transition), null, null, $transition ); } return $this->_applyTransition($transition); }
php
protected function _transition($transition) { if (!$this->_canTransition($transition)) { throw $this->_createCouldNotTransitionException( $this->__('Cannot apply transition "%s"', $transition), null, null, $transition ); } return $this->_applyTransition($transition); }
[ "protected", "function", "_transition", "(", "$", "transition", ")", "{", "if", "(", "!", "$", "this", "->", "_canTransition", "(", "$", "transition", ")", ")", "{", "throw", "$", "this", "->", "_createCouldNotTransitionException", "(", "$", "this", "->", ...
Applies a transition. @since [*next-version*] @param string|Stringable $transition The transition code. @throws CouldNotTransitionExceptionInterface If the transition failed or was aborted. @throws StateMachineExceptionInterface If an error was encountered during transition. @return StateMachineInterface The state machine with the new state.
[ "Applies", "a", "transition", "." ]
cb5f706edd74d1c747f09f505b859255b13a5b27
https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/AbstractStateMachine.php#L29-L41
train
iwyg/template
AbstractPhpEngine.php
AbstractPhpEngine.loadTemplate
public function loadTemplate($template) { if (!$this->isLoaded($identity = $this->findIdentity($template))) { if (!$this->supports($identity)) { throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName())); } $this->setLoaded($identity, $this->getLoader()->load($identity)); } return $this->getLoaded($identity); }
php
public function loadTemplate($template) { if (!$this->isLoaded($identity = $this->findIdentity($template))) { if (!$this->supports($identity)) { throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName())); } $this->setLoaded($identity, $this->getLoader()->load($identity)); } return $this->getLoaded($identity); }
[ "public", "function", "loadTemplate", "(", "$", "template", ")", "{", "if", "(", "!", "$", "this", "->", "isLoaded", "(", "$", "identity", "=", "$", "this", "->", "findIdentity", "(", "$", "template", ")", ")", ")", "{", "if", "(", "!", "$", "this"...
Try to load the given template @param mixed $template @return void
[ "Try", "to", "load", "the", "given", "template" ]
ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e
https://github.com/iwyg/template/blob/ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e/AbstractPhpEngine.php#L136-L148
train
manacode/php-helpers
src/DateTime.php
DateTime.now
function now() { if (strtolower($this->timeReference) == 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); if (strlen($system_time) < 10) { $system_time = time(); } return $system_time; } else { return time(); } }
php
function now() { if (strtolower($this->timeReference) == 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); if (strlen($system_time) < 10) { $system_time = time(); } return $system_time; } else { return time(); } }
[ "function", "now", "(", ")", "{", "if", "(", "strtolower", "(", "$", "this", "->", "timeReference", ")", "==", "'gmt'", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "system_time", "=", "mktime", "(", "gmdate", "(", "\"H\"", ",", "$", "n...
Return current Unix timestamp or its GMT equivalent based on the time reference
[ "Return", "current", "Unix", "timestamp", "or", "its", "GMT", "equivalent", "based", "on", "the", "time", "reference" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L79-L90
train
manacode/php-helpers
src/DateTime.php
DateTime.mdate
function mdate($date_format = '', $time = '') { if ($date_format == '') { $date_format = $this->dateFormat; } if ($time == '') { $time = $this->now(); } return date($date_format, $time); }
php
function mdate($date_format = '', $time = '') { if ($date_format == '') { $date_format = $this->dateFormat; } if ($time == '') { $time = $this->now(); } return date($date_format, $time); }
[ "function", "mdate", "(", "$", "date_format", "=", "''", ",", "$", "time", "=", "''", ")", "{", "if", "(", "$", "date_format", "==", "''", ")", "{", "$", "date_format", "=", "$", "this", "->", "dateFormat", ";", "}", "if", "(", "$", "time", "==",...
Return date based on the date format
[ "Return", "date", "based", "on", "the", "date", "format" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L93-L101
train
manacode/php-helpers
src/DateTime.php
DateTime.mdatetime
function mdatetime($time = '', $timezone = '', $datetime_format = '') { if ($datetime_format == '') { $datetime_format = $this->dateFormat . ' ' . $this->timeFormat; } if ($time == '') { $time = 'now'; } if ($timezone == '') { $timezone = $this->timeZone; } $utc = new \DateTimeZone($timezone); $dt = new \DateTime($time, $utc); return $dt->format($datetime_format); }
php
function mdatetime($time = '', $timezone = '', $datetime_format = '') { if ($datetime_format == '') { $datetime_format = $this->dateFormat . ' ' . $this->timeFormat; } if ($time == '') { $time = 'now'; } if ($timezone == '') { $timezone = $this->timeZone; } $utc = new \DateTimeZone($timezone); $dt = new \DateTime($time, $utc); return $dt->format($datetime_format); }
[ "function", "mdatetime", "(", "$", "time", "=", "''", ",", "$", "timezone", "=", "''", ",", "$", "datetime_format", "=", "''", ")", "{", "if", "(", "$", "datetime_format", "==", "''", ")", "{", "$", "datetime_format", "=", "$", "this", "->", "dateFor...
Return date and time based on the datetime format
[ "Return", "date", "and", "time", "based", "on", "the", "datetime", "format" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L104-L117
train
manacode/php-helpers
src/DateTime.php
DateTime.get_first_date_last_month
function get_first_date_last_month($m=1) { return $this->mdate($this->dateFormat, mktime(0, 0, 0, $this->mdate("m")-$m, 1, $this->mdate("Y"))); }
php
function get_first_date_last_month($m=1) { return $this->mdate($this->dateFormat, mktime(0, 0, 0, $this->mdate("m")-$m, 1, $this->mdate("Y"))); }
[ "function", "get_first_date_last_month", "(", "$", "m", "=", "1", ")", "{", "return", "$", "this", "->", "mdate", "(", "$", "this", "->", "dateFormat", ",", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "this", "->", "mdate", "(", "\"m\"", ")",...
Return first date of last month
[ "Return", "first", "date", "of", "last", "month" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L204-L206
train
manacode/php-helpers
src/DateTime.php
DateTime.get_last_date_last_month
function get_last_date_last_month($m=1) { return $this->mdate($this->dateFormat, mktime(24, 0, 0, $this->mdate("m")-($m-1), -1, $this->mdate("Y"))); }
php
function get_last_date_last_month($m=1) { return $this->mdate($this->dateFormat, mktime(24, 0, 0, $this->mdate("m")-($m-1), -1, $this->mdate("Y"))); }
[ "function", "get_last_date_last_month", "(", "$", "m", "=", "1", ")", "{", "return", "$", "this", "->", "mdate", "(", "$", "this", "->", "dateFormat", ",", "mktime", "(", "24", ",", "0", ",", "0", ",", "$", "this", "->", "mdate", "(", "\"m\"", ")",...
Return last date of last month
[ "Return", "last", "date", "of", "last", "month" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L209-L211
train
manacode/php-helpers
src/DateTime.php
DateTime.get_first_date_last_year
function get_first_date_last_year($y=1) { return $this->mdate($this->dateFormat, mktime(0, 0, 0, 1, 1, $this->mdate("Y")-$y)); }
php
function get_first_date_last_year($y=1) { return $this->mdate($this->dateFormat, mktime(0, 0, 0, 1, 1, $this->mdate("Y")-$y)); }
[ "function", "get_first_date_last_year", "(", "$", "y", "=", "1", ")", "{", "return", "$", "this", "->", "mdate", "(", "$", "this", "->", "dateFormat", ",", "mktime", "(", "0", ",", "0", ",", "0", ",", "1", ",", "1", ",", "$", "this", "->", "mdate...
Return first date of last year
[ "Return", "first", "date", "of", "last", "year" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L228-L230
train
manacode/php-helpers
src/DateTime.php
DateTime.get_last_date_last_year
function get_last_date_last_year($y=1) { return $this->mdate($this->dateFormat, mktime(24, 0, 0, 1, -1, $this->mdate("Y")-($y-1))); }
php
function get_last_date_last_year($y=1) { return $this->mdate($this->dateFormat, mktime(24, 0, 0, 1, -1, $this->mdate("Y")-($y-1))); }
[ "function", "get_last_date_last_year", "(", "$", "y", "=", "1", ")", "{", "return", "$", "this", "->", "mdate", "(", "$", "this", "->", "dateFormat", ",", "mktime", "(", "24", ",", "0", ",", "0", ",", "1", ",", "-", "1", ",", "$", "this", "->", ...
Return last date of last year
[ "Return", "last", "date", "of", "last", "year" ]
1e408e0935298753c0803ae0a8f9b12809652d6f
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L233-L235
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Sources.php
Sources.createNew
public function createNew( string $name, array $tags ) : array { $array = [ 'name' => $name, 'tags' => $tags ]; return $this->sendPost( sprintf('/profiles/%s/sources', $this->userName), [], $array ); }
php
public function createNew( string $name, array $tags ) : array { $array = [ 'name' => $name, 'tags' => $tags ]; return $this->sendPost( sprintf('/profiles/%s/sources', $this->userName), [], $array ); }
[ "public", "function", "createNew", "(", "string", "$", "name", ",", "array", "$", "tags", ")", ":", "array", "{", "$", "array", "=", "[", "'name'", "=>", "$", "name", ",", "'tags'", "=>", "$", "tags", "]", ";", "return", "$", "this", "->", "sendPos...
Creates a new source for the given username. @param string $name @param string $ipaddr @param array $tags @return array Response
[ "Creates", "a", "new", "source", "for", "the", "given", "username", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Sources.php#L20-L34
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Sources.php
Sources.updateOne
public function updateOne(int $sourceId, array $tags, int $otpCode = null, string $ipaddr = '') : array { $array = [ 'tags' => $tags ]; if ($otpCode !== null) { $array['otpCode'] = $otpCode; } return $this->sendPatch( sprintf('/profiles/%s/sources/%s', $this->userName, $sourceId), [], $array ); }
php
public function updateOne(int $sourceId, array $tags, int $otpCode = null, string $ipaddr = '') : array { $array = [ 'tags' => $tags ]; if ($otpCode !== null) { $array['otpCode'] = $otpCode; } return $this->sendPatch( sprintf('/profiles/%s/sources/%s', $this->userName, $sourceId), [], $array ); }
[ "public", "function", "updateOne", "(", "int", "$", "sourceId", ",", "array", "$", "tags", ",", "int", "$", "otpCode", "=", "null", ",", "string", "$", "ipaddr", "=", "''", ")", ":", "array", "{", "$", "array", "=", "[", "'tags'", "=>", "$", "tags"...
Updates a source in the given profile. @param int $sourceId @param string $ipaddr @param string $tags @return array Response
[ "Updates", "a", "source", "in", "the", "given", "profile", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Sources.php#L72-L86
train
monolyth-php/formulaic
src/Datetime.php
Datetime.setMin
public function setMin(string $min) : Datetime { $min = date($this->format, strtotime($min)); $this->attributes['min'] = $min; return $this->addTest('min', function ($value) use ($min) { return $value >= $min; }); }
php
public function setMin(string $min) : Datetime { $min = date($this->format, strtotime($min)); $this->attributes['min'] = $min; return $this->addTest('min', function ($value) use ($min) { return $value >= $min; }); }
[ "public", "function", "setMin", "(", "string", "$", "min", ")", ":", "Datetime", "{", "$", "min", "=", "date", "(", "$", "this", "->", "format", ",", "strtotime", "(", "$", "min", ")", ")", ";", "$", "this", "->", "attributes", "[", "'min'", "]", ...
Set the minimum datetime. @param string $min Minimum timestamp. This can be any string parsable by PHP's `strtotime`. @return Monolyth\Formulaic\Datetime Self
[ "Set", "the", "minimum", "datetime", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Datetime.php#L77-L84
train
monolyth-php/formulaic
src/Datetime.php
Datetime.setMax
public function setMax(string $max) : Datetime { $max = date($this->format, strtotime($max)); $this->attributes['max'] = $max; return $this->addTest('max', function ($value) use ($max) { return $value <= $max; }); }
php
public function setMax(string $max) : Datetime { $max = date($this->format, strtotime($max)); $this->attributes['max'] = $max; return $this->addTest('max', function ($value) use ($max) { return $value <= $max; }); }
[ "public", "function", "setMax", "(", "string", "$", "max", ")", ":", "Datetime", "{", "$", "max", "=", "date", "(", "$", "this", "->", "format", ",", "strtotime", "(", "$", "max", ")", ")", ";", "$", "this", "->", "attributes", "[", "'max'", "]", ...
Set the maximum datetime. @param string $max Maximum timestamp. This can be any string parsable by PHP's `strtotime`. @return Monolyth\Formulaic\Datetime Self
[ "Set", "the", "maximum", "datetime", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Datetime.php#L93-L100
train
drustack/composer-generate-metadata
src/Plugin.php
Plugin.generateInfoMetadata
public function generateInfoMetadata(PackageEvent $event) { $op = $event->getOperation(); $package = $op->getJobType() == 'update' ? $op->getTargetPackage() : $op->getPackage(); $installPath = $this->installationManager->getInstallPath($package); if (preg_match('/^drupal-/', $package->getType())) { if (preg_match('/^dev-/', $package->getPrettyVersion())) { $name = $package->getName(); $project = preg_replace('/^.*\//', '', $name); $version = preg_replace('/^dev-(.*)/', $this->core.'.x-$1-dev', $package->getPrettyVersion()); $branch = preg_replace('/^([0-9]*\.x-[0-9]*).*$/', '$1', $version); $datestamp = time(); $this->io->write(' - Generating metadata for <info>'.$name.'</info>'); // Compute the rebuild version string for a project. $version = $this->computeRebuildVersion($installPath, $branch) ?: $version; if ($this->core == '7') { // Generate version information for `.info` files in ini format. $finder = new Finder(); $finder ->files() ->in($installPath) ->name('*.info') ->notContains('datestamp ='); foreach ($finder as $file) { file_put_contents( $file->getRealpath(), $this->generateInfoIniMetadata($version, $project, $datestamp), FILE_APPEND ); } } else { // Generate version information for `.info.yml` files in YAML format. $finder = new Finder(); $finder ->files() ->in($installPath) ->name('*.info.yml') ->notContains('datestamp:'); foreach ($finder as $file) { file_put_contents( $file->getRealpath(), $this->generateInfoYamlMetadata($version, $project, $datestamp), FILE_APPEND ); } } } } }
php
public function generateInfoMetadata(PackageEvent $event) { $op = $event->getOperation(); $package = $op->getJobType() == 'update' ? $op->getTargetPackage() : $op->getPackage(); $installPath = $this->installationManager->getInstallPath($package); if (preg_match('/^drupal-/', $package->getType())) { if (preg_match('/^dev-/', $package->getPrettyVersion())) { $name = $package->getName(); $project = preg_replace('/^.*\//', '', $name); $version = preg_replace('/^dev-(.*)/', $this->core.'.x-$1-dev', $package->getPrettyVersion()); $branch = preg_replace('/^([0-9]*\.x-[0-9]*).*$/', '$1', $version); $datestamp = time(); $this->io->write(' - Generating metadata for <info>'.$name.'</info>'); // Compute the rebuild version string for a project. $version = $this->computeRebuildVersion($installPath, $branch) ?: $version; if ($this->core == '7') { // Generate version information for `.info` files in ini format. $finder = new Finder(); $finder ->files() ->in($installPath) ->name('*.info') ->notContains('datestamp ='); foreach ($finder as $file) { file_put_contents( $file->getRealpath(), $this->generateInfoIniMetadata($version, $project, $datestamp), FILE_APPEND ); } } else { // Generate version information for `.info.yml` files in YAML format. $finder = new Finder(); $finder ->files() ->in($installPath) ->name('*.info.yml') ->notContains('datestamp:'); foreach ($finder as $file) { file_put_contents( $file->getRealpath(), $this->generateInfoYamlMetadata($version, $project, $datestamp), FILE_APPEND ); } } } } }
[ "public", "function", "generateInfoMetadata", "(", "PackageEvent", "$", "event", ")", "{", "$", "op", "=", "$", "event", "->", "getOperation", "(", ")", ";", "$", "package", "=", "$", "op", "->", "getJobType", "(", ")", "==", "'update'", "?", "$", "op"...
Inject metadata into all .info files for a given project. @see drush_pm_inject_info_file_metadata()
[ "Inject", "metadata", "into", "all", ".", "info", "files", "for", "a", "given", "project", "." ]
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L84-L138
train
drustack/composer-generate-metadata
src/Plugin.php
Plugin.computeRebuildVersion
protected function computeRebuildVersion($installPath, $branch) { $version = ''; $branchPreg = preg_quote($branch); $process = new Process("cd $installPath; git describe --tags"); $process->run(); if ($process->isSuccessful()) { $lastTag = strtok($process->getOutput(), "\n"); // Make sure the tag starts as Drupal formatted (for eg. // 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master) // then it's on that branch. if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) { if (isset($matches['gitextra'])) { // If we found additional git metadata (in particular, number of commits) // then use that info to build the version string. $version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev'; } else { // Otherwise, the branch tip is pointing to the same commit as the // last tag on the branch, in which case we use the prior tag and // add '+0-dev' to indicate we're still on a -dev branch. $version = $lastTag.'+0-dev'; } } } return $version; }
php
protected function computeRebuildVersion($installPath, $branch) { $version = ''; $branchPreg = preg_quote($branch); $process = new Process("cd $installPath; git describe --tags"); $process->run(); if ($process->isSuccessful()) { $lastTag = strtok($process->getOutput(), "\n"); // Make sure the tag starts as Drupal formatted (for eg. // 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master) // then it's on that branch. if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) { if (isset($matches['gitextra'])) { // If we found additional git metadata (in particular, number of commits) // then use that info to build the version string. $version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev'; } else { // Otherwise, the branch tip is pointing to the same commit as the // last tag on the branch, in which case we use the prior tag and // add '+0-dev' to indicate we're still on a -dev branch. $version = $lastTag.'+0-dev'; } } } return $version; }
[ "protected", "function", "computeRebuildVersion", "(", "$", "installPath", ",", "$", "branch", ")", "{", "$", "version", "=", "''", ";", "$", "branchPreg", "=", "preg_quote", "(", "$", "branch", ")", ";", "$", "process", "=", "new", "Process", "(", "\"cd...
Helper function to compute the rebulid version string for a project. This does some magic in Git to find the latest release tag along the branch we're packaging from, count the number of commits since then, and use that to construct this fancy alternate version string which is useful for the version-specific dependency support in Drupal 7 and higher. NOTE: A similar function lives in git_deploy and in the drupal.org packaging script (see DrupalorgProjectPackageRelease.class.php inside drupalorg/drupalorg_project/plugins/release_packager). Any changes to the actual logic in here should probably be reflected in the other places. @see drush_pm_git_drupalorg_compute_rebuild_version()
[ "Helper", "function", "to", "compute", "the", "rebulid", "version", "string", "for", "a", "project", "." ]
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L156-L183
train
drustack/composer-generate-metadata
src/Plugin.php
Plugin.generateInfoIniMetadata
protected function generateInfoIniMetadata($version, $project, $datestamp) { $core = preg_replace('/^([0-9]).*$/', '$1.x', $version); $date = date('Y-m-d', $datestamp); $info = <<<METADATA ; Information add by drustack/composer-generate-metadata on {$date} core = "{$core}" project = "{$project}" version = "{$version}" datestamp = "{$datestamp}" METADATA; return $info; }
php
protected function generateInfoIniMetadata($version, $project, $datestamp) { $core = preg_replace('/^([0-9]).*$/', '$1.x', $version); $date = date('Y-m-d', $datestamp); $info = <<<METADATA ; Information add by drustack/composer-generate-metadata on {$date} core = "{$core}" project = "{$project}" version = "{$version}" datestamp = "{$datestamp}" METADATA; return $info; }
[ "protected", "function", "generateInfoIniMetadata", "(", "$", "version", ",", "$", "project", ",", "$", "datestamp", ")", "{", "$", "core", "=", "preg_replace", "(", "'/^([0-9]).*$/'", ",", "'$1.x'", ",", "$", "version", ")", ";", "$", "date", "=", "date",...
Generate version information for `.info` files in ini format. @see _drush_pm_generate_info_ini_metadata()
[ "Generate", "version", "information", "for", ".", "info", "files", "in", "ini", "format", "." ]
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L190-L204
train
drustack/composer-generate-metadata
src/Plugin.php
Plugin.generateInfoYamlMetadata
protected function generateInfoYamlMetadata($version, $project, $datestamp) { $core = preg_replace('/^([0-9]).*$/', '$1.x', $version); $date = date('Y-m-d', $datestamp); $info = <<<METADATA # Information add by drustack/composer-generate-metadata on {$date} core: "{$core}" project: "{$project}" version: "{$version}" datestamp: "{$datestamp}" METADATA; return $info; }
php
protected function generateInfoYamlMetadata($version, $project, $datestamp) { $core = preg_replace('/^([0-9]).*$/', '$1.x', $version); $date = date('Y-m-d', $datestamp); $info = <<<METADATA # Information add by drustack/composer-generate-metadata on {$date} core: "{$core}" project: "{$project}" version: "{$version}" datestamp: "{$datestamp}" METADATA; return $info; }
[ "protected", "function", "generateInfoYamlMetadata", "(", "$", "version", ",", "$", "project", ",", "$", "datestamp", ")", "{", "$", "core", "=", "preg_replace", "(", "'/^([0-9]).*$/'", ",", "'$1.x'", ",", "$", "version", ")", ";", "$", "date", "=", "date"...
Generate version information for `.info.yml` files in YAML format. @see _drush_pm_generate_info_yaml_metadata()
[ "Generate", "version", "information", "for", ".", "info", ".", "yml", "files", "in", "YAML", "format", "." ]
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L211-L225
train
themichaelhall/datatypes
src/FilePath.php
FilePath.equals
public function equals(FilePathInterface $filePath): bool { return $this->getDrive() === $filePath->getDrive() && $this->isAbsolute() === $filePath->isAbsolute() && $this->getDirectoryParts() === $filePath->getDirectoryParts() && $this->getFilename() === $filePath->getFilename(); }
php
public function equals(FilePathInterface $filePath): bool { return $this->getDrive() === $filePath->getDrive() && $this->isAbsolute() === $filePath->isAbsolute() && $this->getDirectoryParts() === $filePath->getDirectoryParts() && $this->getFilename() === $filePath->getFilename(); }
[ "public", "function", "equals", "(", "FilePathInterface", "$", "filePath", ")", ":", "bool", "{", "return", "$", "this", "->", "getDrive", "(", ")", "===", "$", "filePath", "->", "getDrive", "(", ")", "&&", "$", "this", "->", "isAbsolute", "(", ")", "=...
Returns true if the file path equals other file path, false otherwise. @since 1.2.0 @param FilePathInterface $filePath The other file path. @return bool True if the file path equals other file path, false otherwise.
[ "Returns", "true", "if", "the", "file", "path", "equals", "other", "file", "path", "false", "otherwise", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L34-L37
train
themichaelhall/datatypes
src/FilePath.php
FilePath.getDirectory
public function getDirectory(): FilePathInterface { return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, null); }
php
public function getDirectory(): FilePathInterface { return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, null); }
[ "public", "function", "getDirectory", "(", ")", ":", "FilePathInterface", "{", "return", "new", "self", "(", "$", "this", "->", "myIsAbsolute", ",", "$", "this", "->", "myAboveBaseLevel", ",", "$", "this", "->", "myDrive", ",", "$", "this", "->", "myDirect...
Returns the directory of the file path. @since 1.0.0 @return FilePathInterface The directory of the file path.
[ "Returns", "the", "directory", "of", "the", "file", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L46-L49
train
themichaelhall/datatypes
src/FilePath.php
FilePath.getParentDirectory
public function getParentDirectory(): ?FilePathInterface { if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) { return new self($this->myIsAbsolute, $aboveBaseLevel, $this->myDrive, $directoryParts, null); } return null; }
php
public function getParentDirectory(): ?FilePathInterface { if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) { return new self($this->myIsAbsolute, $aboveBaseLevel, $this->myDrive, $directoryParts, null); } return null; }
[ "public", "function", "getParentDirectory", "(", ")", ":", "?", "FilePathInterface", "{", "if", "(", "$", "this", "->", "myParentDirectory", "(", "$", "aboveBaseLevel", ",", "$", "directoryParts", ")", ")", "{", "return", "new", "self", "(", "$", "this", "...
Returns the parent directory of the file path or null if file path does not have a parent directory. @since 1.0.0 @return FilePathInterface|null The parent directory of the file path or null if file path does not have a parent directory.
[ "Returns", "the", "parent", "directory", "of", "the", "file", "path", "or", "null", "if", "file", "path", "does", "not", "have", "a", "parent", "directory", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L70-L77
train
themichaelhall/datatypes
src/FilePath.php
FilePath.toAbsolute
public function toAbsolute(): FilePathInterface { if ($this->myAboveBaseLevel > 0) { throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.'); } return new self(true, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, $this->myFilename); }
php
public function toAbsolute(): FilePathInterface { if ($this->myAboveBaseLevel > 0) { throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.'); } return new self(true, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, $this->myFilename); }
[ "public", "function", "toAbsolute", "(", ")", ":", "FilePathInterface", "{", "if", "(", "$", "this", "->", "myAboveBaseLevel", ">", "0", ")", "{", "throw", "new", "FilePathLogicException", "(", "'File path \"'", ".", "$", "this", "->", "__toString", "(", ")"...
Returns the file path as an absolute path. @since 1.0.0 @throws FilePathLogicException if the file path could not be made absolute. @return FilePathInterface The file path as an absolute path.
[ "Returns", "the", "file", "path", "as", "an", "absolute", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L88-L95
train
themichaelhall/datatypes
src/FilePath.php
FilePath.toRelative
public function toRelative(): FilePathInterface { return new self(false, $this->myAboveBaseLevel, null, $this->myDirectoryParts, $this->myFilename); }
php
public function toRelative(): FilePathInterface { return new self(false, $this->myAboveBaseLevel, null, $this->myDirectoryParts, $this->myFilename); }
[ "public", "function", "toRelative", "(", ")", ":", "FilePathInterface", "{", "return", "new", "self", "(", "false", ",", "$", "this", "->", "myAboveBaseLevel", ",", "null", ",", "$", "this", "->", "myDirectoryParts", ",", "$", "this", "->", "myFilename", "...
Returns the file path as a relative path. @since 1.0.0 @return FilePathInterface The file path as a relative path.
[ "Returns", "the", "file", "path", "as", "a", "relative", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L104-L107
train
themichaelhall/datatypes
src/FilePath.php
FilePath.withFilePath
public function withFilePath(FilePathInterface $filePath): FilePathInterface { if (!$this->myCombine($filePath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) { throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be combined with file path "' . $filePath->__toString() . '": ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $filePath->getDrive() ?: $this->getDrive(), $directoryParts, $filename); }
php
public function withFilePath(FilePathInterface $filePath): FilePathInterface { if (!$this->myCombine($filePath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) { throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be combined with file path "' . $filePath->__toString() . '": ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $filePath->getDrive() ?: $this->getDrive(), $directoryParts, $filename); }
[ "public", "function", "withFilePath", "(", "FilePathInterface", "$", "filePath", ")", ":", "FilePathInterface", "{", "if", "(", "!", "$", "this", "->", "myCombine", "(", "$", "filePath", ",", "$", "isAbsolute", ",", "$", "aboveBaseLevel", ",", "$", "director...
Returns a copy of the file path combined with another file path. @since 1.0.0 @param FilePathInterface $filePath The other file path. @throws FilePathLogicException if the file paths could not be combined. @return FilePathInterface The combined file path.
[ "Returns", "a", "copy", "of", "the", "file", "path", "combined", "with", "another", "file", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L120-L127
train
themichaelhall/datatypes
src/FilePath.php
FilePath.isValid
public static function isValid(string $filePath): bool { return self::myFilePathParse( DIRECTORY_SEPARATOR, $filePath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }); }
php
public static function isValid(string $filePath): bool { return self::myFilePathParse( DIRECTORY_SEPARATOR, $filePath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }); }
[ "public", "static", "function", "isValid", "(", "string", "$", "filePath", ")", ":", "bool", "{", "return", "self", "::", "myFilePathParse", "(", "DIRECTORY_SEPARATOR", ",", "$", "filePath", ",", "function", "(", "$", "p", ",", "$", "d", ",", "&", "$", ...
Checks if a file path is valid. @since 1.0.0 @param string $filePath The file path. @return bool True if the $filePath parameter is a valid file path, false otherwise.
[ "Checks", "if", "a", "file", "path", "is", "valid", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L150-L158
train
themichaelhall/datatypes
src/FilePath.php
FilePath.parse
public static function parse(string $filePath): FilePathInterface { if (!self::myFilePathParse( DIRECTORY_SEPARATOR, $filePath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }, null, $isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename, $error) ) { throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename); }
php
public static function parse(string $filePath): FilePathInterface { if (!self::myFilePathParse( DIRECTORY_SEPARATOR, $filePath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }, null, $isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename, $error) ) { throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename); }
[ "public", "static", "function", "parse", "(", "string", "$", "filePath", ")", ":", "FilePathInterface", "{", "if", "(", "!", "self", "::", "myFilePathParse", "(", "DIRECTORY_SEPARATOR", ",", "$", "filePath", ",", "function", "(", "$", "p", ",", "$", "d", ...
Parses a file path. @since 1.0.0 @param string $filePath The file path. @throws FilePathInvalidArgumentException If the $filePath parameter is not a valid file path. @return FilePathInterface The file path instance.
[ "Parses", "a", "file", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L171-L191
train
themichaelhall/datatypes
src/FilePath.php
FilePath.myFilePathParse
private static function myFilePathParse(string $directorySeparator, string $path, callable $partValidator, callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?string &$drive = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool { $drive = null; // If on Window, try to parse drive. if (self::myIsWindows()) { $driveAndPath = explode(':', $path, 2); if (count($driveAndPath) === 2) { $drive = $driveAndPath[0]; if (!self::myDriveValidator($drive, $error)) { return false; } $drive = strtoupper($drive); $path = $driveAndPath[1]; } } $result = self::myParse( $directorySeparator, DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path, $partValidator, $stringDecoder, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error ); // File path containing a drive and relative path is invalid. if ($drive !== null && !$isAbsolute) { $error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".'; return false; } return $result; }
php
private static function myFilePathParse(string $directorySeparator, string $path, callable $partValidator, callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?string &$drive = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool { $drive = null; // If on Window, try to parse drive. if (self::myIsWindows()) { $driveAndPath = explode(':', $path, 2); if (count($driveAndPath) === 2) { $drive = $driveAndPath[0]; if (!self::myDriveValidator($drive, $error)) { return false; } $drive = strtoupper($drive); $path = $driveAndPath[1]; } } $result = self::myParse( $directorySeparator, DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path, $partValidator, $stringDecoder, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error ); // File path containing a drive and relative path is invalid. if ($drive !== null && !$isAbsolute) { $error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".'; return false; } return $result; }
[ "private", "static", "function", "myFilePathParse", "(", "string", "$", "directorySeparator", ",", "string", "$", "path", ",", "callable", "$", "partValidator", ",", "callable", "$", "stringDecoder", "=", "null", ",", "?", "bool", "&", "$", "isAbsolute", "=", ...
Tries to parse a file path and returns the result or error text. @param string $directorySeparator The directory separator. @param string $path The path. @param callable $partValidator The part validator. @param callable $stringDecoder The string decoding function or null if parts should not be decoded. @param bool|null $isAbsolute Whether the path is absolute or relative is parsing was successful, undefined otherwise. @param int|null $aboveBaseLevel The number of directory parts above base level if parsing was successful, undefined otherwise. @param string|null $drive The drive or null if parsing was successful, undefined otherwise @param string[]|null $directoryParts The directory parts if parsing was successful, undefined otherwise. @param string|null $filename The file or null if parsing was not successful, undefined otherwise. @param string|null $error The error text if validation was not successful, undefined otherwise. @return bool True if parsing was successful, false otherwise.
[ "Tries", "to", "parse", "a", "file", "path", "and", "returns", "the", "result", "or", "error", "text", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L259-L298
train
themichaelhall/datatypes
src/FilePath.php
FilePath.myPartValidator
private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool { if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) { $error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".'; return false; } return true; }
php
private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool { if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) { $error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".'; return false; } return true; }
[ "private", "static", "function", "myPartValidator", "(", "string", "$", "part", ",", "bool", "$", "isDirectory", ",", "?", "string", "&", "$", "error", ")", ":", "bool", "{", "if", "(", "preg_match", "(", "self", "::", "myIsWindows", "(", ")", "?", "'/...
Validates a directory part name or a file name. @param string $part The part to validate. @param bool $isDirectory If true part is a directory part name, if false part is a file name. @param string|null $error The error text if validation was not successful, undefined otherwise. @return bool True if validation was successful, false otherwise.
[ "Validates", "a", "directory", "part", "name", "or", "a", "file", "name", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L309-L318
train
themichaelhall/datatypes
src/FilePath.php
FilePath.myDriveValidator
private static function myDriveValidator(string $drive, ?string &$error): bool { if (!preg_match('/^[a-zA-Z]$/', $drive)) { $error = 'Drive "' . $drive . '" is invalid.'; return false; } return true; }
php
private static function myDriveValidator(string $drive, ?string &$error): bool { if (!preg_match('/^[a-zA-Z]$/', $drive)) { $error = 'Drive "' . $drive . '" is invalid.'; return false; } return true; }
[ "private", "static", "function", "myDriveValidator", "(", "string", "$", "drive", ",", "?", "string", "&", "$", "error", ")", ":", "bool", "{", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z]$/'", ",", "$", "drive", ")", ")", "{", "$", "error", "=", ...
Validates a drive. @param string $drive The drive to validate. @param string|null $error The error text if validation was not successful, undefined otherwise. @return bool True if validation was successful, false otherwise.
[ "Validates", "a", "drive", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L328-L337
train
joefallon/phpautoloader
src/JoeFallon/AutoLoader.php
AutoLoader.load
public function load($className) { $this->_classFilename = $className . '.php'; $this->_includePaths = explode(PATH_SEPARATOR, get_include_path()); $classFound = null; if(strpos($this->_classFilename, '\\') !== false) { $classFound = $this->searchForBackslashNamespacedClass(); } elseif(strpos($this->_classFilename, '_') !== false) { $classFound = $this->searchForUnderscoreNamespacedClass(); } else { $classFound = $this->searchForNonNamespacedClass(); } return $classFound; }
php
public function load($className) { $this->_classFilename = $className . '.php'; $this->_includePaths = explode(PATH_SEPARATOR, get_include_path()); $classFound = null; if(strpos($this->_classFilename, '\\') !== false) { $classFound = $this->searchForBackslashNamespacedClass(); } elseif(strpos($this->_classFilename, '_') !== false) { $classFound = $this->searchForUnderscoreNamespacedClass(); } else { $classFound = $this->searchForNonNamespacedClass(); } return $classFound; }
[ "public", "function", "load", "(", "$", "className", ")", "{", "$", "this", "->", "_classFilename", "=", "$", "className", ".", "'.php'", ";", "$", "this", "->", "_includePaths", "=", "explode", "(", "PATH_SEPARATOR", ",", "get_include_path", "(", ")", ")"...
This function is called by the PHP runtime to find and load a class for use. Users of this class should not call this function. @param string $className @return bool
[ "This", "function", "is", "called", "by", "the", "PHP", "runtime", "to", "find", "and", "load", "a", "class", "for", "use", ".", "Users", "of", "this", "class", "should", "not", "call", "this", "function", "." ]
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L30-L50
train
joefallon/phpautoloader
src/JoeFallon/AutoLoader.php
AutoLoader.searchForBackslashNamespacedClass
protected function searchForBackslashNamespacedClass() { $filename = $this->_classFilename; foreach($this->_includePaths as $includePath) { $className = str_replace('\\', '/', $filename); $filePath = $includePath . DIRECTORY_SEPARATOR . $className; if(file_exists($filePath) == true) { require($filePath); return true; } } return false; }
php
protected function searchForBackslashNamespacedClass() { $filename = $this->_classFilename; foreach($this->_includePaths as $includePath) { $className = str_replace('\\', '/', $filename); $filePath = $includePath . DIRECTORY_SEPARATOR . $className; if(file_exists($filePath) == true) { require($filePath); return true; } } return false; }
[ "protected", "function", "searchForBackslashNamespacedClass", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "_classFilename", ";", "foreach", "(", "$", "this", "->", "_includePaths", "as", "$", "includePath", ")", "{", "$", "className", "=", "str_rep...
This function searches for classes that are namespaced using the modern standard method of class namespacing. @example Zend\Exception @return bool Returns true if the class is found, otherwise false.
[ "This", "function", "searches", "for", "classes", "that", "are", "namespaced", "using", "the", "modern", "standard", "method", "of", "class", "namespacing", "." ]
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L64-L82
train
joefallon/phpautoloader
src/JoeFallon/AutoLoader.php
AutoLoader.searchForNonNamespacedClass
protected function searchForNonNamespacedClass() { $filename = $this->_classFilename; foreach($this->_includePaths as $includePath) { $filePath = $includePath . DIRECTORY_SEPARATOR . $filename; if(file_exists($filePath) == true) { require($filename); return true; } } return false; }
php
protected function searchForNonNamespacedClass() { $filename = $this->_classFilename; foreach($this->_includePaths as $includePath) { $filePath = $includePath . DIRECTORY_SEPARATOR . $filename; if(file_exists($filePath) == true) { require($filename); return true; } } return false; }
[ "protected", "function", "searchForNonNamespacedClass", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "_classFilename", ";", "foreach", "(", "$", "this", "->", "_includePaths", "as", "$", "includePath", ")", "{", "$", "filePath", "=", "$", "include...
This function searches for classes that are not namespaced at all. @example ZendException @return bool Returns true if the class is found, otherwise false.
[ "This", "function", "searches", "for", "classes", "that", "are", "not", "namespaced", "at", "all", "." ]
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L119-L136
train
slickframework/mvc
src/Controller/CrudCommonMethods.php
CrudCommonMethods.getEntityNamePlural
protected function getEntityNamePlural() { $name = $this->getEntityNameSingular(); $nameParts = Text::camelCaseToSeparator($name, '#'); $nameParts = explode('#', $nameParts); $lastPart = array_pop($nameParts); $lastPart = ucfirst(Text::plural(strtolower($lastPart))); array_push($nameParts, $lastPart); return lcfirst(implode('', $nameParts)); }
php
protected function getEntityNamePlural() { $name = $this->getEntityNameSingular(); $nameParts = Text::camelCaseToSeparator($name, '#'); $nameParts = explode('#', $nameParts); $lastPart = array_pop($nameParts); $lastPart = ucfirst(Text::plural(strtolower($lastPart))); array_push($nameParts, $lastPart); return lcfirst(implode('', $nameParts)); }
[ "protected", "function", "getEntityNamePlural", "(", ")", "{", "$", "name", "=", "$", "this", "->", "getEntityNameSingular", "(", ")", ";", "$", "nameParts", "=", "Text", "::", "camelCaseToSeparator", "(", "$", "name", ",", "'#'", ")", ";", "$", "nameParts...
Get the plural name of the entity @return string
[ "Get", "the", "plural", "name", "of", "the", "entity" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/CrudCommonMethods.php#L31-L40
train
slickframework/mvc
src/Controller/CrudCommonMethods.php
CrudCommonMethods.getEntityNameSingular
protected function getEntityNameSingular() { $names = explode('\\', $this->getEntityClassName()); $name = end($names); return lcfirst($name); }
php
protected function getEntityNameSingular() { $names = explode('\\', $this->getEntityClassName()); $name = end($names); return lcfirst($name); }
[ "protected", "function", "getEntityNameSingular", "(", ")", "{", "$", "names", "=", "explode", "(", "'\\\\'", ",", "$", "this", "->", "getEntityClassName", "(", ")", ")", ";", "$", "name", "=", "end", "(", "$", "names", ")", ";", "return", "lcfirst", "...
Get entity singular name used on controller actions @return string
[ "Get", "entity", "singular", "name", "used", "on", "controller", "actions" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/CrudCommonMethods.php#L47-L52
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.generateBasename
protected function generateBasename() { $filename = md5($this->image . $this->height . $this->width); if (isset(static::$config['default_extension'])) { $extension = static::$config['default_extension']; } else { $extension = pathinfo($this->image, PATHINFO_EXTENSION); } return $filename . '.' . $extension; }
php
protected function generateBasename() { $filename = md5($this->image . $this->height . $this->width); if (isset(static::$config['default_extension'])) { $extension = static::$config['default_extension']; } else { $extension = pathinfo($this->image, PATHINFO_EXTENSION); } return $filename . '.' . $extension; }
[ "protected", "function", "generateBasename", "(", ")", "{", "$", "filename", "=", "md5", "(", "$", "this", "->", "image", ".", "$", "this", "->", "height", ".", "$", "this", "->", "width", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "co...
Generate basename from the destiny file @return string
[ "Generate", "basename", "from", "the", "destiny", "file" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L142-L157
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.isCacheExpired
protected function isCacheExpired($destiny) { $cacheModified = filemtime($destiny); if ($this->expiration !== null) { return $this->expiration > $cacheModified; } return filemtime($this->image) > $cacheModified; }
php
protected function isCacheExpired($destiny) { $cacheModified = filemtime($destiny); if ($this->expiration !== null) { return $this->expiration > $cacheModified; } return filemtime($this->image) > $cacheModified; }
[ "protected", "function", "isCacheExpired", "(", "$", "destiny", ")", "{", "$", "cacheModified", "=", "filemtime", "(", "$", "destiny", ")", ";", "if", "(", "$", "this", "->", "expiration", "!==", "null", ")", "{", "return", "$", "this", "->", "expiration...
Is Expired cache of image? @param string $destiny @return boolean
[ "Is", "Expired", "cache", "of", "image?" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L164-L175
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.fromFile
public static function fromFile($filename, $width, $height = 0) { $urlizer = new Urlizer($filename); static::configureUrlizer($urlizer); // If the filename is not initialized by '/', this is a fullpath if (strpos($filename, '/') !== 0) { $filename = $urlizer->getPublicFilename(); } try { $thumb = new static($filename, $width, $height); } catch (\InvalidArgumentException $e) { if (static::$config['fallback'] === null) { throw $e; } return static::$config['fallback']; } $basename = $thumb->generateBasename(); $filename = $urlizer->buildThumbFilename($basename); $thumb->getCache($filename); return $urlizer->buildThumbUrl($basename); }
php
public static function fromFile($filename, $width, $height = 0) { $urlizer = new Urlizer($filename); static::configureUrlizer($urlizer); // If the filename is not initialized by '/', this is a fullpath if (strpos($filename, '/') !== 0) { $filename = $urlizer->getPublicFilename(); } try { $thumb = new static($filename, $width, $height); } catch (\InvalidArgumentException $e) { if (static::$config['fallback'] === null) { throw $e; } return static::$config['fallback']; } $basename = $thumb->generateBasename(); $filename = $urlizer->buildThumbFilename($basename); $thumb->getCache($filename); return $urlizer->buildThumbUrl($basename); }
[ "public", "static", "function", "fromFile", "(", "$", "filename", ",", "$", "width", ",", "$", "height", "=", "0", ")", "{", "$", "urlizer", "=", "new", "Urlizer", "(", "$", "filename", ")", ";", "static", "::", "configureUrlizer", "(", "$", "urlizer",...
Returns the url from thumb based on filename @param string $filename @param float $width @param float $height @return string
[ "Returns", "the", "url", "from", "thumb", "based", "on", "filename" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L223-L258
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.fromUrl
public static function fromUrl($url, $width, $height = 0) { $extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION); $filename = sprintf('%s/thumb_%s.%s', sys_get_temp_dir(), md5($url), $extension); if (! file_exists($filename) && ! @copy($url, $filename, static::getStreamContextOptions())) { return static::$config['fallback']; } $urlizer = new Urlizer(); static::configureUrlizer($urlizer); $thumb = new static($filename, $width, $height); $basename = $thumb->generateBasename(); $filename = $urlizer->buildThumbFilename($basename); $thumb->getCache($filename); return $urlizer->buildThumbUrl($basename); }
php
public static function fromUrl($url, $width, $height = 0) { $extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION); $filename = sprintf('%s/thumb_%s.%s', sys_get_temp_dir(), md5($url), $extension); if (! file_exists($filename) && ! @copy($url, $filename, static::getStreamContextOptions())) { return static::$config['fallback']; } $urlizer = new Urlizer(); static::configureUrlizer($urlizer); $thumb = new static($filename, $width, $height); $basename = $thumb->generateBasename(); $filename = $urlizer->buildThumbFilename($basename); $thumb->getCache($filename); return $urlizer->buildThumbUrl($basename); }
[ "public", "static", "function", "fromUrl", "(", "$", "url", ",", "$", "width", ",", "$", "height", "=", "0", ")", "{", "$", "extension", "=", "pathinfo", "(", "strtok", "(", "$", "url", ",", "'?'", ")", ",", "PATHINFO_EXTENSION", ")", ";", "$", "fi...
Get copy from external file url for make thumb @param string $url @param float $width @param float $height
[ "Get", "copy", "from", "external", "file", "url", "for", "make", "thumb" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L266-L291
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.image
public static function image($relative, array $attributes = []) { $attributes += ['alt' => null]; $height = isset($attributes['height']) ? $attributes['height'] : 0; $width = isset($attributes['width']) ? $attributes['width'] : 0; $url = static::url($relative, $width, $height); $attributes['src'] = $url; $attrs = []; foreach ($attributes as $name => $attr) { $attrs[] = "$name=\"{$attr}\""; } $attrs = implode(' ', $attrs); return "<img {$attrs} />"; }
php
public static function image($relative, array $attributes = []) { $attributes += ['alt' => null]; $height = isset($attributes['height']) ? $attributes['height'] : 0; $width = isset($attributes['width']) ? $attributes['width'] : 0; $url = static::url($relative, $width, $height); $attributes['src'] = $url; $attrs = []; foreach ($attributes as $name => $attr) { $attrs[] = "$name=\"{$attr}\""; } $attrs = implode(' ', $attrs); return "<img {$attrs} />"; }
[ "public", "static", "function", "image", "(", "$", "relative", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "attributes", "+=", "[", "'alt'", "=>", "null", "]", ";", "$", "height", "=", "isset", "(", "$", "attributes", "[", "'height...
Returns the image tag with thumb, based on attributes "height" and "width" @param string $relative @param array $attributes @return string
[ "Returns", "the", "image", "tag", "with", "thumb", "based", "on", "attributes", "height", "and", "width" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L323-L346
train
phplegends/thumb
src/Thumb/Thumb.php
Thumb.configureUrlizer
protected static function configureUrlizer(Urlizer $urlizer) { $path = isset(static::$config['public_path']) ? static::$config['public_path'] : $_SERVER['DOCUMENT_ROOT']; $urlizer->setPublicPath($path); if (isset(static::$config['base_uri'])) { $urlizer->setBaseUrl(static::$config['base_uri']); } $urlizer->setThumbFolder(static::$config['thumb_folder']); }
php
protected static function configureUrlizer(Urlizer $urlizer) { $path = isset(static::$config['public_path']) ? static::$config['public_path'] : $_SERVER['DOCUMENT_ROOT']; $urlizer->setPublicPath($path); if (isset(static::$config['base_uri'])) { $urlizer->setBaseUrl(static::$config['base_uri']); } $urlizer->setThumbFolder(static::$config['thumb_folder']); }
[ "protected", "static", "function", "configureUrlizer", "(", "Urlizer", "$", "urlizer", ")", "{", "$", "path", "=", "isset", "(", "static", "::", "$", "config", "[", "'public_path'", "]", ")", "?", "static", "::", "$", "config", "[", "'public_path'", "]", ...
Configure the \PHPLegends\Thumb\Urlizer from global config @param \PHPLegends\Thumb\Urlizer $urlizer @return void
[ "Configure", "the", "\\", "PHPLegends", "\\", "Thumb", "\\", "Urlizer", "from", "global", "config" ]
962679265f7bf34893c23a82c34d73508cb84d29
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L363-L375
train
GustavSoftware/Cache
src/ACacheManager.php
ACacheManager._createData
protected function _createData(callable $func): array { $data = \call_user_func($func); if(!\is_array($data) && !$data instanceof \Traversable) { return []; //ignore invalid results } $return = []; foreach($data as $key => $value) { $return[$key] = [ 'value' => $value, 'expires' => null ]; } return $return; }
php
protected function _createData(callable $func): array { $data = \call_user_func($func); if(!\is_array($data) && !$data instanceof \Traversable) { return []; //ignore invalid results } $return = []; foreach($data as $key => $value) { $return[$key] = [ 'value' => $value, 'expires' => null ]; } return $return; }
[ "protected", "function", "_createData", "(", "callable", "$", "func", ")", ":", "array", "{", "$", "data", "=", "\\", "call_user_func", "(", "$", "func", ")", ";", "if", "(", "!", "\\", "is_array", "(", "$", "data", ")", "&&", "!", "$", "data", "in...
Calls the creator function of the items of new cache pools and transforms it into our internal used structure. @param callable $func The creator function @return array The data
[ "Calls", "the", "creator", "function", "of", "the", "items", "of", "new", "cache", "pools", "and", "transforms", "it", "into", "our", "internal", "used", "structure", "." ]
2a70db567aa13499487c24b399f7c9d46937df0d
https://github.com/GustavSoftware/Cache/blob/2a70db567aa13499487c24b399f7c9d46937df0d/src/ACacheManager.php#L86-L100
train
GrupaZero/core
src/Gzero/Core/Http/Controllers/Api/UserController.php
UserController.index
public function index(UrlParamsProcessor $processor) { $this->authorize('readList', User::class); $processor ->addFilter(new ArrayParser('id')) ->addFilter(new StringParser('email'), 'email') ->addFilter(new StringParser('name')) ->addFilter(new StringParser('first_name')) ->addFilter(new StringParser('last_name')) ->addFilter(new DateRangeParser('created_at')) ->addFilter(new DateParser('updated_at')) ->process($this->request); $results = $this->repository->getMany($processor->buildQueryBuilder()); $results->setPath(apiUrl('users')); return new UserCollection($results); }
php
public function index(UrlParamsProcessor $processor) { $this->authorize('readList', User::class); $processor ->addFilter(new ArrayParser('id')) ->addFilter(new StringParser('email'), 'email') ->addFilter(new StringParser('name')) ->addFilter(new StringParser('first_name')) ->addFilter(new StringParser('last_name')) ->addFilter(new DateRangeParser('created_at')) ->addFilter(new DateParser('updated_at')) ->process($this->request); $results = $this->repository->getMany($processor->buildQueryBuilder()); $results->setPath(apiUrl('users')); return new UserCollection($results); }
[ "public", "function", "index", "(", "UrlParamsProcessor", "$", "processor", ")", "{", "$", "this", "->", "authorize", "(", "'readList'", ",", "User", "::", "class", ")", ";", "$", "processor", "->", "addFilter", "(", "new", "ArrayParser", "(", "'id'", ")",...
Display list of all users @SWG\Get( path="/users", tags={"user"}, summary="List of all users", description="List of all available users, <b>'admin-access'</b> policy is required.", produces={"application/json"}, security={{"AdminAccess": {}}}, @SWG\Parameter( name="in", in="query", description="Ids to filter by", required=false, type="array", minItems=1, default={"3","5"}, @SWG\Items(type="string") ), @SWG\Parameter( name="email", in="query", description="Valid email address to filter by", required=false, type="string" ), @SWG\Parameter( name="name", in="query", description="Name to filter by", required=false, type="string" ), @SWG\Parameter( name="first_name", in="query", description="First name to filter by", required=false, type="string" ), @SWG\Parameter( name="last_name", in="query", description="Last name to filter by", required=false, type="string" ), @SWG\Parameter( name="created_at", in="query", description="Date range to filter by", required=false, type="array", minItems=2, maxItems=2, default={"2017-10-01","2017-10-07"}, @SWG\Items(type="string") ), @SWG\Response( response=200, description="Successful operation", @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/User")), ), @SWG\Response( response=422, description="Validation Error", @SWG\Schema(ref="#/definitions/ValidationErrors") ) ) @param UrlParamsProcessor $processor Params processor @throws \Illuminate\Auth\Access\AuthorizationException @return UserCollection
[ "Display", "list", "of", "all", "users" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/UserController.php#L120-L138
train
GrupaZero/core
src/Gzero/Core/Http/Controllers/Api/UserController.php
UserController.update
public function update($id) { $user = $this->repository->getById($id); if (!$user) { return $this->errorNotFound(); } $this->authorize('update', $user); $input = $this->validator ->bind('name', ['user_id' => $user->id]) ->bind('email', ['user_id' => $user->id]) ->validate('update'); $user = dispatch_now(new UpdateUser($user, $input)); return new UserResource($user); }
php
public function update($id) { $user = $this->repository->getById($id); if (!$user) { return $this->errorNotFound(); } $this->authorize('update', $user); $input = $this->validator ->bind('name', ['user_id' => $user->id]) ->bind('email', ['user_id' => $user->id]) ->validate('update'); $user = dispatch_now(new UpdateUser($user, $input)); return new UserResource($user); }
[ "public", "function", "update", "(", "$", "id", ")", "{", "$", "user", "=", "$", "this", "->", "repository", "->", "getById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "$", "this", "->", "errorNotFound", "(", ")",...
Updates the specified resource. @SWG\Patch(path="/users/{id}", tags={"user"}, summary="Updated specific user", description="Updates specified user, <b>'admin-access'</b> policy is required.", produces={"application/json"}, security={{"AdminAccess": {}}}, @SWG\Parameter( name="id", in="path", description="ID of user that needs to be updated.", required=true, type="integer" ), @SWG\Parameter( in="body", name="body", description="Fields to update.", required=true, @SWG\Schema( type="object", required={"email, name"}, @SWG\Property(property="email", type="string", example="john.doe@example.com"), @SWG\Property(property="name", type="string", example="JohnDoe"), @SWG\Property(property="first_name", type="string", example="John"), @SWG\Property(property="last_name", type="string", example="Doe") ) ), @SWG\Response( response=200, description="Successful operation", @SWG\Schema(type="object", ref="#/definitions/User"), ), @SWG\Response(response=404, description="User not found"), @SWG\Response( response=422, description="Validation Error", @SWG\Schema(ref="#/definitions/ValidationErrors") ) ) @param int $id User id @throws \Illuminate\Validation\ValidationException @throws \Illuminate\Auth\Access\AuthorizationException @return UserResource
[ "Updates", "the", "specified", "resource", "." ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/UserController.php#L233-L248
train
rseyferth/activerecord
lib/Reflections.php
Reflections.get
public function get($class=null) { $class = $this->get_class($class); if (isset($this->reflections[$class])) return $this->reflections[$class]; throw new ActiveRecordException("Class not found: $class"); }
php
public function get($class=null) { $class = $this->get_class($class); if (isset($this->reflections[$class])) return $this->reflections[$class]; throw new ActiveRecordException("Class not found: $class"); }
[ "public", "function", "get", "(", "$", "class", "=", "null", ")", "{", "$", "class", "=", "$", "this", "->", "get_class", "(", "$", "class", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "reflections", "[", "$", "class", "]", ")", ")", ...
Get a cached ReflectionClass. @param string $class Optional name of a class @return mixed null or a ReflectionClass instance @throws ActiveRecordException if class was not found
[ "Get", "a", "cached", "ReflectionClass", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Reflections.php#L59-L67
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Preferences.php
Preferences.setWebHook
public function setWebHook($url) { $this->data->notification = new stdClass; $this->data->notification->webhook = new stdClass; $this->data->notification->webhook->url = $url; return $this; }
php
public function setWebHook($url) { $this->data->notification = new stdClass; $this->data->notification->webhook = new stdClass; $this->data->notification->webhook->url = $url; return $this; }
[ "public", "function", "setWebHook", "(", "$", "url", ")", "{", "$", "this", "->", "data", "->", "notification", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->", "notification", "->", "webhook", "=", "new", "stdClass", ";", "$", "this", "->...
Set Web Hook URL @param string $url @return $this
[ "Set", "Web", "Hook", "URL" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L58-L65
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Preferences.php
Preferences.enableMerchantEmail
public function enableMerchantEmail() { $this->data->email = new stdClass; $this->data->email->merchant = new stdClass; $this->data->email->merchant->enabled = true; return $this; }
php
public function enableMerchantEmail() { $this->data->email = new stdClass; $this->data->email->merchant = new stdClass; $this->data->email->merchant->enabled = true; return $this; }
[ "public", "function", "enableMerchantEmail", "(", ")", "{", "$", "this", "->", "data", "->", "email", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->", "email", "->", "merchant", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->",...
Enable merchant by email @return $this
[ "Enable", "merchant", "by", "email" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L72-L79
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Preferences.php
Preferences.disableMerchantEmail
public function disableMerchantEmail() { $this->data->email = new stdClass; $this->data->email->merchant = new stdClass; $this->data->email->merchant->enabled = false; return $this; }
php
public function disableMerchantEmail() { $this->data->email = new stdClass; $this->data->email->merchant = new stdClass; $this->data->email->merchant->enabled = false; return $this; }
[ "public", "function", "disableMerchantEmail", "(", ")", "{", "$", "this", "->", "data", "->", "email", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->", "email", "->", "merchant", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->"...
Disable merchant by email @return $this
[ "Disable", "merchant", "by", "email" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L86-L94
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Preferences.php
Preferences.enableCustomerEmail
public function enableCustomerEmail() { $this->data->email = new stdClass; $this->data->email->customer = new stdClass; $this->data->email->customer->enabled = true; return $this; }
php
public function enableCustomerEmail() { $this->data->email = new stdClass; $this->data->email->customer = new stdClass; $this->data->email->customer->enabled = true; return $this; }
[ "public", "function", "enableCustomerEmail", "(", ")", "{", "$", "this", "->", "data", "->", "email", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->", "email", "->", "customer", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->",...
Enable customer receive payments emails @return $this
[ "Enable", "customer", "receive", "payments", "emails" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L101-L109
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Preferences.php
Preferences.disableCustomerEmail
public function disableCustomerEmail() { $this->data->email = new stdClass; $this->data->email->customer = new stdClass; $this->data->email->customer->enabled = false; return $this; }
php
public function disableCustomerEmail() { $this->data->email = new stdClass; $this->data->email->customer = new stdClass; $this->data->email->customer->enabled = false; return $this; }
[ "public", "function", "disableCustomerEmail", "(", ")", "{", "$", "this", "->", "data", "->", "email", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->", "email", "->", "customer", "=", "new", "stdClass", ";", "$", "this", "->", "data", "->"...
Disable customer receive payments emails @return $this
[ "Disable", "customer", "receive", "payments", "emails" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L116-L124
train
dms-org/package.content
src/Cms/ContentPackage.php
ContentPackage.boot
public static function boot(ICms $cms) { $iocContainer = $cms->getIocContainer(); $iocContainer->bind(IIocContainer::SCOPE_SINGLETON, IContentGroupRepository::class, DbContentGroupRepository::class); $iocContainer->bind(IIocContainer::SCOPE_SINGLETON, ContentLoaderService::class, ContentLoaderService::class); $iocContainer->bindCallback( IIocContainer::SCOPE_SINGLETON, ContentConfig::class, function () use ($cms) : ContentConfig { $definition = new ContentConfigDefinition(); static::defineConfig($definition); return $definition->finalize(); } ); }
php
public static function boot(ICms $cms) { $iocContainer = $cms->getIocContainer(); $iocContainer->bind(IIocContainer::SCOPE_SINGLETON, IContentGroupRepository::class, DbContentGroupRepository::class); $iocContainer->bind(IIocContainer::SCOPE_SINGLETON, ContentLoaderService::class, ContentLoaderService::class); $iocContainer->bindCallback( IIocContainer::SCOPE_SINGLETON, ContentConfig::class, function () use ($cms) : ContentConfig { $definition = new ContentConfigDefinition(); static::defineConfig($definition); return $definition->finalize(); } ); }
[ "public", "static", "function", "boot", "(", "ICms", "$", "cms", ")", "{", "$", "iocContainer", "=", "$", "cms", "->", "getIocContainer", "(", ")", ";", "$", "iocContainer", "->", "bind", "(", "IIocContainer", "::", "SCOPE_SINGLETON", ",", "IContentGroupRepo...
Boots and configures the package resources and services. @param ICms $cms @return void
[ "Boots", "and", "configures", "the", "package", "resources", "and", "services", "." ]
6511e805c5be586c1f3740e095b49adabd621f80
https://github.com/dms-org/package.content/blob/6511e805c5be586c1f3740e095b49adabd621f80/src/Cms/ContentPackage.php#L86-L104
train
monomelodies/ornament
src/Adapter/Defaults.php
Defaults.flattenValues
protected function flattenValues(&$values) { array_walk($values, function (&$value) { if ($this->isOrnamentModel($value)) { $value = $value->getPrimaryKey(); if (is_array($value)) { $value = '('.implode(', ', $value).')'; } } }); }
php
protected function flattenValues(&$values) { array_walk($values, function (&$value) { if ($this->isOrnamentModel($value)) { $value = $value->getPrimaryKey(); if (is_array($value)) { $value = '('.implode(', ', $value).')'; } } }); }
[ "protected", "function", "flattenValues", "(", "&", "$", "values", ")", "{", "array_walk", "(", "$", "values", ",", "function", "(", "&", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isOrnamentModel", "(", "$", "value", ")", ")", "{", "$", ...
Internal helper to "flatten" all values associated with an operation. This is mainly useful for being able to store models on foreign keys and automatically "flatten" them to the associated key during saving. @param array &$values The array of values to flatten.
[ "Internal", "helper", "to", "flatten", "all", "values", "associated", "with", "an", "operation", ".", "This", "is", "mainly", "useful", "for", "being", "able", "to", "store", "models", "on", "foreign", "keys", "and", "automatically", "flatten", "them", "to", ...
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Adapter/Defaults.php#L95-L105
train
dlcrush/laravel-dbug
src/dlcrush/DBug/DBug.php
DBug.DBug
function DBug($var='',$die=false,$forceType='',$bCollapsed=false) { if ($var === '') { return; } //include js and css scripts if(!defined('BDBUGINIT')) { define("BDBUGINIT", TRUE); $this->initJSandCSS(); } $arrAccept=array("array","object","xml"); //array of variable types that can be "forced" $this->bCollapsed = $bCollapsed; if(in_array($forceType,$arrAccept)) $this->{"varIs".ucfirst($forceType)}($var); else $this->checkType($var); if ($die) { die(); } }
php
function DBug($var='',$die=false,$forceType='',$bCollapsed=false) { if ($var === '') { return; } //include js and css scripts if(!defined('BDBUGINIT')) { define("BDBUGINIT", TRUE); $this->initJSandCSS(); } $arrAccept=array("array","object","xml"); //array of variable types that can be "forced" $this->bCollapsed = $bCollapsed; if(in_array($forceType,$arrAccept)) $this->{"varIs".ucfirst($forceType)}($var); else $this->checkType($var); if ($die) { die(); } }
[ "function", "DBug", "(", "$", "var", "=", "''", ",", "$", "die", "=", "false", ",", "$", "forceType", "=", "''", ",", "$", "bCollapsed", "=", "false", ")", "{", "if", "(", "$", "var", "===", "''", ")", "{", "return", ";", "}", "//include js and c...
Dumps out variable in a nice format Dumps out variable in a nice format @param string $var the variable to dump out @param boolean $die whether or not to die after dumping @param string $forceType the type to force the variable as @param boolean $bCollapsed @return HTML the HTML output of the variable dump
[ "Dumps", "out", "variable", "in", "a", "nice", "format" ]
4a9a22beed48f670e0146950d1e646ec0b170491
https://github.com/dlcrush/laravel-dbug/blob/4a9a22beed48f670e0146950d1e646ec0b170491/src/dlcrush/DBug/DBug.php#L35-L55
train
dlcrush/laravel-dbug
src/dlcrush/DBug/DBug.php
DBug.varIsXmlResource
private function varIsXmlResource($var) { $xml_parser=xml_parser_create(); xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement")); xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData")); xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler")); $this->makeTableHeader("xml","xml document",2); $this->makeTDHeader("xml","xmlRoot"); //attempt to open xml file $bFile=(!($fp=@fopen($var,"r"))) ? false : true; //read xml file if($bFile) { while($data=str_replace("\n","",fread($fp,4096))) $this->xmlParse($xml_parser,$data,feof($fp)); } //if xml is not a file, attempt to read it as a string else { if(!is_string($var)) { echo $this->error("xml").$this->closeTDRow()."</table>\n"; return; } $data=$var; $this->xmlParse($xml_parser,$data,1); } echo $this->closeTDRow()."</table>\n"; }
php
private function varIsXmlResource($var) { $xml_parser=xml_parser_create(); xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement")); xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData")); xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler")); $this->makeTableHeader("xml","xml document",2); $this->makeTDHeader("xml","xmlRoot"); //attempt to open xml file $bFile=(!($fp=@fopen($var,"r"))) ? false : true; //read xml file if($bFile) { while($data=str_replace("\n","",fread($fp,4096))) $this->xmlParse($xml_parser,$data,feof($fp)); } //if xml is not a file, attempt to read it as a string else { if(!is_string($var)) { echo $this->error("xml").$this->closeTDRow()."</table>\n"; return; } $data=$var; $this->xmlParse($xml_parser,$data,1); } echo $this->closeTDRow()."</table>\n"; }
[ "private", "function", "varIsXmlResource", "(", "$", "var", ")", "{", "$", "xml_parser", "=", "xml_parser_create", "(", ")", ";", "xml_parser_set_option", "(", "$", "xml_parser", ",", "XML_OPTION_CASE_FOLDING", ",", "0", ")", ";", "xml_set_element_handler", "(", ...
if variable is an xml resource type
[ "if", "variable", "is", "an", "xml", "resource", "type" ]
4a9a22beed48f670e0146950d1e646ec0b170491
https://github.com/dlcrush/laravel-dbug/blob/4a9a22beed48f670e0146950d1e646ec0b170491/src/dlcrush/DBug/DBug.php#L332-L362
train
unyx/utils
math/vectors/Vector3D.php
Vector3D.scalarTripleProduct
public function scalarTripleProduct(Vector3D $second, Vector3D $third) : float { return $this->dotProduct($second->crossProduct($third)); }
php
public function scalarTripleProduct(Vector3D $second, Vector3D $third) : float { return $this->dotProduct($second->crossProduct($third)); }
[ "public", "function", "scalarTripleProduct", "(", "Vector3D", "$", "second", ",", "Vector3D", "$", "third", ")", ":", "float", "{", "return", "$", "this", "->", "dotProduct", "(", "$", "second", "->", "crossProduct", "(", "$", "third", ")", ")", ";", "}"...
Computes the scalar triple product of this and two other Vectors. @param Vector3D $second The second Vector of the triple product. @param Vector3D $third The third Vector of the triple product. @return float The scalar triple product of the three Vectors.
[ "Computes", "the", "scalar", "triple", "product", "of", "this", "and", "two", "other", "Vectors", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/vectors/Vector3D.php#L72-L75
train
unyx/utils
math/vectors/Vector3D.php
Vector3D.vectorTripleProduct
public function vectorTripleProduct(Vector3D $second, Vector3D $third) : Vector3D { return $this->crossProduct($second->crossProduct($third)); }
php
public function vectorTripleProduct(Vector3D $second, Vector3D $third) : Vector3D { return $this->crossProduct($second->crossProduct($third)); }
[ "public", "function", "vectorTripleProduct", "(", "Vector3D", "$", "second", ",", "Vector3D", "$", "third", ")", ":", "Vector3D", "{", "return", "$", "this", "->", "crossProduct", "(", "$", "second", "->", "crossProduct", "(", "$", "third", ")", ")", ";", ...
Computes the vector triple product of this and two other Vectors. @param Vector3D $second The second Vector of the triple product. @param Vector3D $third The third Vector of the triple product. @return Vector3D The vector triple product of the three Vectors as a new Vector3 instance.
[ "Computes", "the", "vector", "triple", "product", "of", "this", "and", "two", "other", "Vectors", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/vectors/Vector3D.php#L84-L87
train
bariew/phptools
FileModel.php
FileModel.readData
private function readData() { switch ($this->fileType) { case self::TYPE_JSON : $data = json_decode(file_get_contents($this->readPath), true); break; default : $data = require $this->readPath; } return $data; }
php
private function readData() { switch ($this->fileType) { case self::TYPE_JSON : $data = json_decode(file_get_contents($this->readPath), true); break; default : $data = require $this->readPath; } return $data; }
[ "private", "function", "readData", "(", ")", "{", "switch", "(", "$", "this", "->", "fileType", ")", "{", "case", "self", "::", "TYPE_JSON", ":", "$", "data", "=", "json_decode", "(", "file_get_contents", "(", "$", "this", "->", "readPath", ")", ",", "...
Reading file data. @return mixed
[ "Reading", "file", "data", "." ]
e7d3aed02be11fadd24c18915a36ad5a2be899b4
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L59-L68
train
bariew/phptools
FileModel.php
FileModel.get
public function get($key) { $key = is_array($key) ? $key : [$key]; $config = $this->data; while ($key) { $k = array_shift($key); $config = isset($config[$k]) ? $config[$k] : []; } return $config; }
php
public function get($key) { $key = is_array($key) ? $key : [$key]; $config = $this->data; while ($key) { $k = array_shift($key); $config = isset($config[$k]) ? $config[$k] : []; } return $config; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "key", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "$", "config", "=", "$", "this", "->", "data", ";", "while", "(", "$", "key", ")", "...
Gets data sub value. @see \self::set() For multidimensional @param $key @return array|mixed
[ "Gets", "data", "sub", "value", "." ]
e7d3aed02be11fadd24c18915a36ad5a2be899b4
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L108-L117
train
bariew/phptools
FileModel.php
FileModel.remove
public function remove($key) { $key = is_array($key) ? $key : [$key]; $config = $this->data; $data = &$config; while ($key) { $k = array_shift($key); if (!$key) { unset($config[$k]); break; } $config[$k] = isset($config[$k]) ? $config[$k] : []; $config = &$config[$k]; } $this->data = $data; return $this->save(); }
php
public function remove($key) { $key = is_array($key) ? $key : [$key]; $config = $this->data; $data = &$config; while ($key) { $k = array_shift($key); if (!$key) { unset($config[$k]); break; } $config[$k] = isset($config[$k]) ? $config[$k] : []; $config = &$config[$k]; } $this->data = $data; return $this->save(); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "key", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "$", "config", "=", "$", "this", "->", "data", ";", "$", "data", "=", "&", "$", "...
Removes key from data. @see \self::set() For multidimensional @param $key @return int
[ "Removes", "key", "from", "data", "." ]
e7d3aed02be11fadd24c18915a36ad5a2be899b4
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L125-L141
train
bariew/phptools
FileModel.php
FileModel.put
public function put($data) { $this->data = array_merge($this->data, $data); return $this->save(); }
php
public function put($data) { $this->data = array_merge($this->data, $data); return $this->save(); }
[ "public", "function", "put", "(", "$", "data", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "return", "$", "this", "->", "save", "(", ")", ";", "}" ]
Puts complete data into file. @param $data @return int @throws \Exception
[ "Puts", "complete", "data", "into", "file", "." ]
e7d3aed02be11fadd24c18915a36ad5a2be899b4
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L149-L153
train
bishopb/vanilla
library/core/class.proxyrequest.php
ProxyRequest.ResponseClass
public function ResponseClass($Class) { $Code = (string)$this->ResponseStatus; if (is_null($Code)) return FALSE; if (strlen($Code) != strlen($Class)) return FALSE; for ($i = 0; $i < strlen($Class); $i++) if ($Class{$i} != 'x' && $Class{$i} != $Code{$i}) return FALSE; return TRUE; }
php
public function ResponseClass($Class) { $Code = (string)$this->ResponseStatus; if (is_null($Code)) return FALSE; if (strlen($Code) != strlen($Class)) return FALSE; for ($i = 0; $i < strlen($Class); $i++) if ($Class{$i} != 'x' && $Class{$i} != $Code{$i}) return FALSE; return TRUE; }
[ "public", "function", "ResponseClass", "(", "$", "Class", ")", "{", "$", "Code", "=", "(", "string", ")", "$", "this", "->", "ResponseStatus", ";", "if", "(", "is_null", "(", "$", "Code", ")", ")", "return", "FALSE", ";", "if", "(", "strlen", "(", ...
Check if the provided response matches the provided response type Class is a string representation of the HTTP status code, with 'x' used as a wildcard. Class '2xx' = All 200-level responses Class '30x' = All 300-level responses up to 309 @param string $Class @return boolean Whether the response matches or not
[ "Check", "if", "the", "provided", "response", "matches", "the", "provided", "response", "type" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.proxyrequest.php#L511-L520
train
bishopb/vanilla
applications/vanilla/controllers/class.moderationcontroller.php
ModerationController.CheckedComments
public function CheckedComments() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); ModerationController::InformCheckedComments($this); $this->Render(); }
php
public function CheckedComments() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); ModerationController::InformCheckedComments($this); $this->Render(); }
[ "public", "function", "CheckedComments", "(", ")", "{", "$", "this", "->", "DeliveryType", "(", "DELIVERY_TYPE_BOOL", ")", ";", "$", "this", "->", "DeliveryMethod", "(", "DELIVERY_METHOD_JSON", ")", ";", "ModerationController", "::", "InformCheckedComments", "(", ...
Looks at the user's attributes and form postback to see if any comments have been checked for administration, and if so, puts an inform message on the screen to take action.
[ "Looks", "at", "the", "user", "s", "attributes", "and", "form", "postback", "to", "see", "if", "any", "comments", "have", "been", "checked", "for", "administration", "and", "if", "so", "puts", "an", "inform", "message", "on", "the", "screen", "to", "take",...
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L19-L24
train
bishopb/vanilla
applications/vanilla/controllers/class.moderationcontroller.php
ModerationController.CheckedDiscussions
public function CheckedDiscussions() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); ModerationController::InformCheckedDiscussions($this); $this->Render(); }
php
public function CheckedDiscussions() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); ModerationController::InformCheckedDiscussions($this); $this->Render(); }
[ "public", "function", "CheckedDiscussions", "(", ")", "{", "$", "this", "->", "DeliveryType", "(", "DELIVERY_TYPE_BOOL", ")", ";", "$", "this", "->", "DeliveryMethod", "(", "DELIVERY_METHOD_JSON", ")", ";", "ModerationController", "::", "InformCheckedDiscussions", "...
Looks at the user's attributes and form postback to see if any discussions have been checked for administration, and if so, puts an inform message on the screen to take action.
[ "Looks", "at", "the", "user", "s", "attributes", "and", "form", "postback", "to", "see", "if", "any", "discussions", "have", "been", "checked", "for", "administration", "and", "if", "so", "puts", "an", "inform", "message", "on", "the", "screen", "to", "tak...
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L31-L36
train
bishopb/vanilla
applications/vanilla/controllers/class.moderationcontroller.php
ModerationController.ClearCommentSelections
public function ClearCommentSelections($DiscussionID = '', $TransientKey = '') { $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) { $CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array()); unset($CheckedComments[$DiscussionID]); Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments); } Redirect(GetIncomingValue('Target', '/discussions')); }
php
public function ClearCommentSelections($DiscussionID = '', $TransientKey = '') { $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) { $CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array()); unset($CheckedComments[$DiscussionID]); Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments); } Redirect(GetIncomingValue('Target', '/discussions')); }
[ "public", "function", "ClearCommentSelections", "(", "$", "DiscussionID", "=", "''", ",", "$", "TransientKey", "=", "''", ")", "{", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "if", "(", "$", "Session", "->", "ValidateTransientKey", "(", ...
Remove all comments checked for administration from the user's attributes.
[ "Remove", "all", "comments", "checked", "for", "administration", "from", "the", "user", "s", "attributes", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L202-L211
train
bishopb/vanilla
applications/vanilla/controllers/class.moderationcontroller.php
ModerationController.ClearDiscussionSelections
public function ClearDiscussionSelections($TransientKey = '') { $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE); Redirect(GetIncomingValue('Target', '/discussions')); }
php
public function ClearDiscussionSelections($TransientKey = '') { $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE); Redirect(GetIncomingValue('Target', '/discussions')); }
[ "public", "function", "ClearDiscussionSelections", "(", "$", "TransientKey", "=", "''", ")", "{", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "if", "(", "$", "Session", "->", "ValidateTransientKey", "(", "$", "TransientKey", ")", ")", "Gdn"...
Remove all discussions checked for administration from the user's attributes.
[ "Remove", "all", "discussions", "checked", "for", "administration", "from", "the", "user", "s", "attributes", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L216-L222
train
arvici/framework
src/Arvici/Heart/Router/Route.php
Route.getCompiled
public function getCompiled() { if ($this->compiled === null) { $regexp = "/^"; // Method(s) $methodIdx = 0; foreach($this->methods as $method) { $regexp .= "(?:" . strtoupper($method) . ")"; if (($methodIdx + 1) < count($this->methods)) { $regexp .= "|"; } $methodIdx++; } // Separator $regexp .= "~"; // Url $regexp .= str_replace('/', '\/', $this->match); $regexp .= "$/"; $this->compiled = $regexp; } return $this->compiled; }
php
public function getCompiled() { if ($this->compiled === null) { $regexp = "/^"; // Method(s) $methodIdx = 0; foreach($this->methods as $method) { $regexp .= "(?:" . strtoupper($method) . ")"; if (($methodIdx + 1) < count($this->methods)) { $regexp .= "|"; } $methodIdx++; } // Separator $regexp .= "~"; // Url $regexp .= str_replace('/', '\/', $this->match); $regexp .= "$/"; $this->compiled = $regexp; } return $this->compiled; }
[ "public", "function", "getCompiled", "(", ")", "{", "if", "(", "$", "this", "->", "compiled", "===", "null", ")", "{", "$", "regexp", "=", "\"/^\"", ";", "// Method(s)", "$", "methodIdx", "=", "0", ";", "foreach", "(", "$", "this", "->", "methods", "...
Get Compiled Reg Expression key. @return string
[ "Get", "Compiled", "Reg", "Expression", "key", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Route.php#L96-L122
train
arvici/framework
src/Arvici/Heart/Router/Route.php
Route.getValue
public function getValue($key, $default = null) { if (is_array($this->kwargs) && isset($this->kwargs[$key])) { return $this->kwargs[$key]; } return $default; // @codeCoverageIgnore }
php
public function getValue($key, $default = null) { if (is_array($this->kwargs) && isset($this->kwargs[$key])) { return $this->kwargs[$key]; } return $default; // @codeCoverageIgnore }
[ "public", "function", "getValue", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "kwargs", ")", "&&", "isset", "(", "$", "this", "->", "kwargs", "[", "$", "key", "]", ")", ")", "{", "...
Get kwargs value by key, return default if not found. @param string $key Key string @param mixed $default @return mixed|null
[ "Get", "kwargs", "value", "by", "key", "return", "default", "if", "not", "found", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Route.php#L152-L158
train
bytic/helpers
src/View/Tooltips.php
Tooltips.addItem
public function addItem($id, $content, $title = false) { $this->tooltips[$id] = $this->newItem($id, $content, $title); }
php
public function addItem($id, $content, $title = false) { $this->tooltips[$id] = $this->newItem($id, $content, $title); }
[ "public", "function", "addItem", "(", "$", "id", ",", "$", "content", ",", "$", "title", "=", "false", ")", "{", "$", "this", "->", "tooltips", "[", "$", "id", "]", "=", "$", "this", "->", "newItem", "(", "$", "id", ",", "$", "content", ",", "$...
Adds a tooltip item to the queue @param string $id @param string $content @param string|bool $title
[ "Adds", "a", "tooltip", "item", "to", "the", "queue" ]
6a4f0388ba8653d65058ce63cf7627e38b9df041
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/View/Tooltips.php#L27-L30
train
remote-office/libx
src/Json/Api/JsonApiClient.php
JsonApiClient.call
protected function call(\LibX\Net\Rest\Request $request, \LibX\Net\Rest\Response $response) { // Make the call! $this->client->execute($request, $response); //print_r($request); //print_r($response); // Get info $info = $response->getInfo(); // Get JSON response $json = $response->getData(); // Decode JSON $data = json_decode($json); return $data; }
php
protected function call(\LibX\Net\Rest\Request $request, \LibX\Net\Rest\Response $response) { // Make the call! $this->client->execute($request, $response); //print_r($request); //print_r($response); // Get info $info = $response->getInfo(); // Get JSON response $json = $response->getData(); // Decode JSON $data = json_decode($json); return $data; }
[ "protected", "function", "call", "(", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "$", "request", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "$", "response", ")", "{", "// Make the call!", "$", "this", "->", "client", ...
Make a REST call @param \LibX\Net\Rest\Request $request @param \LibX\Net\Rest\Response $response @return StdClass
[ "Make", "a", "REST", "call" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Json/Api/JsonApiClient.php#L35-L53
train
joaogl/comments
src/Controllers/CommentsController.php
CommentsController.getDelete
public function getDelete($id = null) { // Get comment information $comment = Comments::getCommentsRepository()->find($id); if ($comment == null) { // Prepare the error message $error = Lang::get('comments.comment.not_found'); // Redirect to the post management page return Redirect::route('posts')->with('error', $error); } Base::Log('Comment (' . $comment->id . ') was deleted.'); // Delete the post $comment->delete(); // Prepare the success message $success = Lang::get('comments.comment.deleted'); // Redirect to the post management page return Redirect::back()->with('success', $success); }
php
public function getDelete($id = null) { // Get comment information $comment = Comments::getCommentsRepository()->find($id); if ($comment == null) { // Prepare the error message $error = Lang::get('comments.comment.not_found'); // Redirect to the post management page return Redirect::route('posts')->with('error', $error); } Base::Log('Comment (' . $comment->id . ') was deleted.'); // Delete the post $comment->delete(); // Prepare the success message $success = Lang::get('comments.comment.deleted'); // Redirect to the post management page return Redirect::back()->with('success', $success); }
[ "public", "function", "getDelete", "(", "$", "id", "=", "null", ")", "{", "// Get comment information", "$", "comment", "=", "Comments", "::", "getCommentsRepository", "(", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "$", "comment", "==", "nu...
Delete the given comment. @param int $id @return Redirect
[ "Delete", "the", "given", "comment", "." ]
66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3
https://github.com/joaogl/comments/blob/66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3/src/Controllers/CommentsController.php#L50-L74
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.temporal_property
public static function temporal_property($key, $default = null) { $class = get_called_class(); // If already determined if (!array_key_exists($class, static::$_temporal_cached)) { static::temporal_properties(); } return \Arr::get(static::$_temporal_cached[$class], $key, $default); }
php
public static function temporal_property($key, $default = null) { $class = get_called_class(); // If already determined if (!array_key_exists($class, static::$_temporal_cached)) { static::temporal_properties(); } return \Arr::get(static::$_temporal_cached[$class], $key, $default); }
[ "public", "static", "function", "temporal_property", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "// If already determined", "if", "(", "!", "array_key_exists", "(", "$", "class", ",", ...
Fetches temporal property description array, or specific data from it. Stolen from parent class. @param string property or property.key @param mixed return value when key not present @return mixed
[ "Fetches", "temporal", "property", "description", "array", "or", "specific", "data", "from", "it", ".", "Stolen", "from", "parent", "class", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L117-L128
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.find_revision
public static function find_revision($id, $timestamp = null, $relations = array()) { if ($timestamp == null) { return parent::find($id); } $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); // Select the next latest revision after the requested one then use that // to get the revision before. self::disable_primary_key_check(); $query = static::query() ->where('id', $id) ->where($timestamp_start_name, '<=', $timestamp) ->where($timestamp_end_name, '>', $timestamp); self::enable_primary_key_check(); //Make sure the temporal stuff is activated $query->set_temporal_properties($timestamp, $timestamp_end_name, $timestamp_start_name); foreach ($relations as $relation) { $query->related($relation); } $query_result = $query->get_one(); // If the query did not return a result but null, then we cannot call // set_lazy_timestamp on it without throwing errors if ( $query_result !== null ) { $query_result->set_lazy_timestamp($timestamp); } return $query_result; }
php
public static function find_revision($id, $timestamp = null, $relations = array()) { if ($timestamp == null) { return parent::find($id); } $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); // Select the next latest revision after the requested one then use that // to get the revision before. self::disable_primary_key_check(); $query = static::query() ->where('id', $id) ->where($timestamp_start_name, '<=', $timestamp) ->where($timestamp_end_name, '>', $timestamp); self::enable_primary_key_check(); //Make sure the temporal stuff is activated $query->set_temporal_properties($timestamp, $timestamp_end_name, $timestamp_start_name); foreach ($relations as $relation) { $query->related($relation); } $query_result = $query->get_one(); // If the query did not return a result but null, then we cannot call // set_lazy_timestamp on it without throwing errors if ( $query_result !== null ) { $query_result->set_lazy_timestamp($timestamp); } return $query_result; }
[ "public", "static", "function", "find_revision", "(", "$", "id", ",", "$", "timestamp", "=", "null", ",", "$", "relations", "=", "array", "(", ")", ")", "{", "if", "(", "$", "timestamp", "==", "null", ")", "{", "return", "parent", "::", "find", "(", ...
Finds a specific revision for the given ID. If a timestamp is specified the revision returned will reflect the entity's state at that given time. This will also load relations when requested. @param type $id @param int $timestamp Null to get the latest revision (Same as find($id)) @param array $relations Names of the relations to load. @return Subclass of Orm\Model_Temporal
[ "Finds", "a", "specific", "revision", "for", "the", "given", "ID", ".", "If", "a", "timestamp", "is", "specified", "the", "revision", "returned", "will", "reflect", "the", "entity", "s", "state", "at", "that", "given", "time", ".", "This", "will", "also", ...
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L140-L177
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.find_revisions_between
public static function find_revisions_between($id, $earliestTime = null, $latestTime = null) { $timestamp_start_name = static::temporal_property('start_column'); $max_timestamp = static::temporal_property('max_timestamp'); if ($earliestTime == null) { $earliestTime = 0; } if($latestTime == null) { $latestTime = $max_timestamp; } static::disable_primary_key_check(); //Select all revisions within the given range. $query = static::query() ->where('id', $id) ->where($timestamp_start_name, '>=', $earliestTime) ->where($timestamp_start_name, '<=', $latestTime); static::enable_primary_key_check(); $revisions = $query->get(); return $revisions; }
php
public static function find_revisions_between($id, $earliestTime = null, $latestTime = null) { $timestamp_start_name = static::temporal_property('start_column'); $max_timestamp = static::temporal_property('max_timestamp'); if ($earliestTime == null) { $earliestTime = 0; } if($latestTime == null) { $latestTime = $max_timestamp; } static::disable_primary_key_check(); //Select all revisions within the given range. $query = static::query() ->where('id', $id) ->where($timestamp_start_name, '>=', $earliestTime) ->where($timestamp_start_name, '<=', $latestTime); static::enable_primary_key_check(); $revisions = $query->get(); return $revisions; }
[ "public", "static", "function", "find_revisions_between", "(", "$", "id", ",", "$", "earliestTime", "=", "null", ",", "$", "latestTime", "=", "null", ")", "{", "$", "timestamp_start_name", "=", "static", "::", "temporal_property", "(", "'start_column'", ")", "...
Returns a list of revisions between the given times with the most recent first. This does not load relations. @param int|string $id @param timestamp $earliestTime @param timestamp $latestTime
[ "Returns", "a", "list", "of", "revisions", "between", "the", "given", "times", "with", "the", "most", "recent", "first", ".", "This", "does", "not", "load", "relations", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L264-L289
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.find
public static function find($id = null, array $options = array()) { $timestamp_end_name = static::temporal_property('end_column'); $max_timestamp = static::temporal_property('max_timestamp'); switch ($id) { case 'all': case 'first': case 'last': break; default: $id = (array) $id; $count = 0; foreach(static::getNonTimestampPks() as $key) { $options['where'][] = array($key, $id[$count]); $count++; } break; } $options['where'][] = array($timestamp_end_name, $max_timestamp); static::enable_id_only_primary_key(); $result = parent::find($id, $options); static::disable_id_only_primary_key(); return $result; }
php
public static function find($id = null, array $options = array()) { $timestamp_end_name = static::temporal_property('end_column'); $max_timestamp = static::temporal_property('max_timestamp'); switch ($id) { case 'all': case 'first': case 'last': break; default: $id = (array) $id; $count = 0; foreach(static::getNonTimestampPks() as $key) { $options['where'][] = array($key, $id[$count]); $count++; } break; } $options['where'][] = array($timestamp_end_name, $max_timestamp); static::enable_id_only_primary_key(); $result = parent::find($id, $options); static::disable_id_only_primary_key(); return $result; }
[ "public", "static", "function", "find", "(", "$", "id", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "timestamp_end_name", "=", "static", "::", "temporal_property", "(", "'end_column'", ")", ";", "$", "max_timestamp", ...
Overrides the default find method to allow the latest revision to be found by default. If any new options to find are added the switch statement will have to be updated too. @param type $id @param array $options @return type
[ "Overrides", "the", "default", "find", "method", "to", "allow", "the", "latest", "revision", "to", "be", "found", "by", "default", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L302-L332
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.getNonTimestampPks
public static function getNonTimestampPks() { $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $pks = array(); foreach(parent::primary_key() as $key) { if ($key != $timestamp_start_name && $key != $timestamp_end_name) { $pks[] = $key; } } return $pks; }
php
public static function getNonTimestampPks() { $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $pks = array(); foreach(parent::primary_key() as $key) { if ($key != $timestamp_start_name && $key != $timestamp_end_name) { $pks[] = $key; } } return $pks; }
[ "public", "static", "function", "getNonTimestampPks", "(", ")", "{", "$", "timestamp_start_name", "=", "static", "::", "temporal_property", "(", "'start_column'", ")", ";", "$", "timestamp_end_name", "=", "static", "::", "temporal_property", "(", "'end_column'", ")"...
Returns an array of the primary keys that are not related to temporal timestamp information.
[ "Returns", "an", "array", "of", "the", "primary", "keys", "that", "are", "not", "related", "to", "temporal", "timestamp", "information", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L338-L353
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.save
public function save($cascade = null, $use_transaction = false) { // Load temporal properties. $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $mysql_timestamp = static::temporal_property('mysql_timestamp'); $max_timestamp = static::temporal_property('max_timestamp'); $current_timestamp = $mysql_timestamp ? \Date::forge()->format('mysql') : \Date::forge()->get_timestamp(); // If this is new then just call the parent and let everything happen as normal if ($this->is_new()) { static::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; $this->{$timestamp_end_name} = $max_timestamp; static::enable_primary_key_check(); // Make sure save will populate the PK static::enable_id_only_primary_key(); $result = parent::save($cascade, $use_transaction); static::disable_id_only_primary_key(); return $result; } // If this is an update then set a new PK, save and then insert a new row else { // run the before save observers before checking the diff $this->observe('before_save'); // then disable it so it doesn't get executed by parent::save() $this->disable_event('before_save'); $diff = $this->get_diff(); if (count($diff[0]) > 0) { // Take a copy of this model $revision = clone $this; // Give that new model an end time of the current time after resetting back to the old data $revision->set($this->_original); self::disable_primary_key_check(); $revision->{$timestamp_end_name} = $current_timestamp; self::enable_primary_key_check(); // Make sure relations stay the same $revision->_original_relations = $this->_data_relations; // save that, now we have our archive self::enable_id_only_primary_key(); $revision_result = $revision->overwrite(false, $use_transaction); self::disable_id_only_primary_key(); if ( ! $revision_result) { // If the revision did not save then stop the process so the user can do something. return false; } // Now that the old data is saved update the current object so its end timestamp is now self::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; self::enable_primary_key_check(); $result = parent::save($cascade, $use_transaction); } else { // If nothing has changed call parent::save() to insure relations are saved too $result = parent::save($cascade, $use_transaction); } // make sure the before save event is enabled again $this->enable_event('before_save'); return $result; } }
php
public function save($cascade = null, $use_transaction = false) { // Load temporal properties. $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $mysql_timestamp = static::temporal_property('mysql_timestamp'); $max_timestamp = static::temporal_property('max_timestamp'); $current_timestamp = $mysql_timestamp ? \Date::forge()->format('mysql') : \Date::forge()->get_timestamp(); // If this is new then just call the parent and let everything happen as normal if ($this->is_new()) { static::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; $this->{$timestamp_end_name} = $max_timestamp; static::enable_primary_key_check(); // Make sure save will populate the PK static::enable_id_only_primary_key(); $result = parent::save($cascade, $use_transaction); static::disable_id_only_primary_key(); return $result; } // If this is an update then set a new PK, save and then insert a new row else { // run the before save observers before checking the diff $this->observe('before_save'); // then disable it so it doesn't get executed by parent::save() $this->disable_event('before_save'); $diff = $this->get_diff(); if (count($diff[0]) > 0) { // Take a copy of this model $revision = clone $this; // Give that new model an end time of the current time after resetting back to the old data $revision->set($this->_original); self::disable_primary_key_check(); $revision->{$timestamp_end_name} = $current_timestamp; self::enable_primary_key_check(); // Make sure relations stay the same $revision->_original_relations = $this->_data_relations; // save that, now we have our archive self::enable_id_only_primary_key(); $revision_result = $revision->overwrite(false, $use_transaction); self::disable_id_only_primary_key(); if ( ! $revision_result) { // If the revision did not save then stop the process so the user can do something. return false; } // Now that the old data is saved update the current object so its end timestamp is now self::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; self::enable_primary_key_check(); $result = parent::save($cascade, $use_transaction); } else { // If nothing has changed call parent::save() to insure relations are saved too $result = parent::save($cascade, $use_transaction); } // make sure the before save event is enabled again $this->enable_event('before_save'); return $result; } }
[ "public", "function", "save", "(", "$", "cascade", "=", "null", ",", "$", "use_transaction", "=", "false", ")", "{", "// Load temporal properties.", "$", "timestamp_start_name", "=", "static", "::", "temporal_property", "(", "'start_column'", ")", ";", "$", "tim...
Overrides the save method to allow temporal models to be @param boolean $cascade @param boolean $use_transaction @param boolean $skip_temporal Skips temporal filtering on initial inserts. Should not be used! @return boolean
[ "Overrides", "the", "save", "method", "to", "allow", "temporal", "models", "to", "be" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L362-L444
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.restore
public function restore() { $timestamp_end_name = static::temporal_property('end_column'); $max_timestamp = static::temporal_property('max_timestamp'); // check to see if there is a currently active row, if so then don't // restore anything. $activeRow = static::find('first', array( 'where' => array( array('id', $this->id), array($timestamp_end_name, $max_timestamp), ), )); if(is_null($activeRow)) { // No active row was found so we are ok to go and restore the this // revision $timestamp_start_name = static::temporal_property('start_column'); $mysql_timestamp = static::temporal_property('mysql_timestamp'); $max_timestamp = static::temporal_property('max_timestamp'); $current_timestamp = $mysql_timestamp ? \Date::forge()->format('mysql') : \Date::forge()->get_timestamp(); // Make sure this is saved as a new entry $this->_is_new = true; // Update timestamps static::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; $this->{$timestamp_end_name} = $max_timestamp; // Save $result = parent::save(); static::enable_primary_key_check(); return $result; } return false; }
php
public function restore() { $timestamp_end_name = static::temporal_property('end_column'); $max_timestamp = static::temporal_property('max_timestamp'); // check to see if there is a currently active row, if so then don't // restore anything. $activeRow = static::find('first', array( 'where' => array( array('id', $this->id), array($timestamp_end_name, $max_timestamp), ), )); if(is_null($activeRow)) { // No active row was found so we are ok to go and restore the this // revision $timestamp_start_name = static::temporal_property('start_column'); $mysql_timestamp = static::temporal_property('mysql_timestamp'); $max_timestamp = static::temporal_property('max_timestamp'); $current_timestamp = $mysql_timestamp ? \Date::forge()->format('mysql') : \Date::forge()->get_timestamp(); // Make sure this is saved as a new entry $this->_is_new = true; // Update timestamps static::disable_primary_key_check(); $this->{$timestamp_start_name} = $current_timestamp; $this->{$timestamp_end_name} = $max_timestamp; // Save $result = parent::save(); static::enable_primary_key_check(); return $result; } return false; }
[ "public", "function", "restore", "(", ")", "{", "$", "timestamp_end_name", "=", "static", "::", "temporal_property", "(", "'end_column'", ")", ";", "$", "max_timestamp", "=", "static", "::", "temporal_property", "(", "'max_timestamp'", ")", ";", "// check to see i...
Restores the entity to this state. @return boolean
[ "Restores", "the", "entity", "to", "this", "state", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L462-L504
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.add_primary_keys_to_where
protected function add_primary_keys_to_where($query) { $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $primary_key = array( 'id', $timestamp_start_name, $timestamp_end_name, ); foreach ($primary_key as $pk) { $query->where($pk, '=', $this->_original[$pk]); } }
php
protected function add_primary_keys_to_where($query) { $timestamp_start_name = static::temporal_property('start_column'); $timestamp_end_name = static::temporal_property('end_column'); $primary_key = array( 'id', $timestamp_start_name, $timestamp_end_name, ); foreach ($primary_key as $pk) { $query->where($pk, '=', $this->_original[$pk]); } }
[ "protected", "function", "add_primary_keys_to_where", "(", "$", "query", ")", "{", "$", "timestamp_start_name", "=", "static", "::", "temporal_property", "(", "'start_column'", ")", ";", "$", "timestamp_end_name", "=", "static", "::", "temporal_property", "(", "'end...
Allows correct PKs to be added when performing updates @param Query $query
[ "Allows", "correct", "PKs", "to", "be", "added", "when", "performing", "updates" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L535-L550
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/model/temporal.php
Model_Temporal.primary_key
public static function primary_key() { $id_only = static::get_primary_key_id_only_status(); $pk_status = static::get_primary_key_status(); if ($id_only) { return static::getNonTimestampPks(); } if ($pk_status && ! $id_only) { return static::$_primary_key; } return array(); }
php
public static function primary_key() { $id_only = static::get_primary_key_id_only_status(); $pk_status = static::get_primary_key_status(); if ($id_only) { return static::getNonTimestampPks(); } if ($pk_status && ! $id_only) { return static::$_primary_key; } return array(); }
[ "public", "static", "function", "primary_key", "(", ")", "{", "$", "id_only", "=", "static", "::", "get_primary_key_id_only_status", "(", ")", ";", "$", "pk_status", "=", "static", "::", "get_primary_key_status", "(", ")", ";", "if", "(", "$", "id_only", ")"...
Overrides the parent primary_key method to allow primaray key enforcement to be turned off when updating a temporal model.
[ "Overrides", "the", "parent", "primary_key", "method", "to", "allow", "primaray", "key", "enforcement", "to", "be", "turned", "off", "when", "updating", "a", "temporal", "model", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L556-L572
train
emilianobovetti/php-option
src/Option.php
Option.create
public static function create($value, $empty = null) { // Option is a callable class! $value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value; if (is_callable($empty)) { $option = $empty($value) ? self::$none : new Some($value); } else if ($value === $empty) { $option = self::$none; } else if ($value instanceof self) { $option = $value; } else { $option = new Some($value); } return $option; }
php
public static function create($value, $empty = null) { // Option is a callable class! $value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value; if (is_callable($empty)) { $option = $empty($value) ? self::$none : new Some($value); } else if ($value === $empty) { $option = self::$none; } else if ($value instanceof self) { $option = $value; } else { $option = new Some($value); } return $option; }
[ "public", "static", "function", "create", "(", "$", "value", ",", "$", "empty", "=", "null", ")", "{", "// Option is a callable class!", "$", "value", "=", "(", "!", "$", "value", "instanceof", "self", ")", "&&", "is_callable", "(", "$", "value", ")", "?...
Create new Option object. By default it creates a None if $value is null, Some($value) otherwise. $value can be: 1. another Option 2. a callback 3. any other PHP value $empty parameter is used to determine if $value is empty or not and it can be: 1. a callback - which is called with $value as parameter: if it returns a falsy value a None is created 2. any other PHP value - which is strictly compared to $value: if they are equals a None is created. @param mixed $value @param mixed $empty Optional. @return Option
[ "Create", "new", "Option", "object", "." ]
b4acdf5d649f06541c21880962531b542a5f614f
https://github.com/emilianobovetti/php-option/blob/b4acdf5d649f06541c21880962531b542a5f614f/src/Option.php#L72-L88
train
canis-io/yii2-canis-lib
lib/db/behaviors/PrimaryRelation.php
PrimaryRelation.getSiblings
public function getSiblings($role, $primaryOnly = false) { $primaryField = $this->getPrimaryField($role); $parentObject = $this->owner->parentObject; $childObject = $this->owner->childObject; if (empty($childObject)) { return []; } $relationFields = []; if ($primaryOnly) { $relationFields['{{%alias%}}.[[' . $primaryField . ']]'] = 1; } return $childObject->siblingRelationQuery($parentObject, ['where' => $relationFields], ['disableAccess' => true])->all(); }
php
public function getSiblings($role, $primaryOnly = false) { $primaryField = $this->getPrimaryField($role); $parentObject = $this->owner->parentObject; $childObject = $this->owner->childObject; if (empty($childObject)) { return []; } $relationFields = []; if ($primaryOnly) { $relationFields['{{%alias%}}.[[' . $primaryField . ']]'] = 1; } return $childObject->siblingRelationQuery($parentObject, ['where' => $relationFields], ['disableAccess' => true])->all(); }
[ "public", "function", "getSiblings", "(", "$", "role", ",", "$", "primaryOnly", "=", "false", ")", "{", "$", "primaryField", "=", "$", "this", "->", "getPrimaryField", "(", "$", "role", ")", ";", "$", "parentObject", "=", "$", "this", "->", "owner", "-...
Get siblings. @param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]] @param boolean $primaryOnly [[@doctodo param_description:primaryOnly]] [optional] @return [[@doctodo return_type:getSiblings]] [[@doctodo return_description:getSiblings]]
[ "Get", "siblings", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L82-L96
train
canis-io/yii2-canis-lib
lib/db/behaviors/PrimaryRelation.php
PrimaryRelation.setPrimary
public function setPrimary($role) { if (!$this->handlePrimary($role)) { return false; } $primaryField = $this->getPrimaryField($role); $primarySiblings = $this->getSiblings($role, true); foreach ($primarySiblings as $sibling) { $sibling->{$primaryField} = 0; if (!$sibling->save()) { return false; } } $this->owner->{$primaryField} = 1; return $this->owner->save(); }
php
public function setPrimary($role) { if (!$this->handlePrimary($role)) { return false; } $primaryField = $this->getPrimaryField($role); $primarySiblings = $this->getSiblings($role, true); foreach ($primarySiblings as $sibling) { $sibling->{$primaryField} = 0; if (!$sibling->save()) { return false; } } $this->owner->{$primaryField} = 1; return $this->owner->save(); }
[ "public", "function", "setPrimary", "(", "$", "role", ")", "{", "if", "(", "!", "$", "this", "->", "handlePrimary", "(", "$", "role", ")", ")", "{", "return", "false", ";", "}", "$", "primaryField", "=", "$", "this", "->", "getPrimaryField", "(", "$"...
Set primary. @param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]] @return [[@doctodo return_type:setPrimary]] [[@doctodo return_description:setPrimary]]
[ "Set", "primary", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L202-L218
train
canis-io/yii2-canis-lib
lib/db/behaviors/PrimaryRelation.php
PrimaryRelation.isPrimary
public function isPrimary($role) { if (!$this->handlePrimary($role)) { return false; } $primaryField = $this->getPrimaryField($role); return !empty($this->owner->{$primaryField}); }
php
public function isPrimary($role) { if (!$this->handlePrimary($role)) { return false; } $primaryField = $this->getPrimaryField($role); return !empty($this->owner->{$primaryField}); }
[ "public", "function", "isPrimary", "(", "$", "role", ")", "{", "if", "(", "!", "$", "this", "->", "handlePrimary", "(", "$", "role", ")", ")", "{", "return", "false", ";", "}", "$", "primaryField", "=", "$", "this", "->", "getPrimaryField", "(", "$",...
Get is primary. @param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]] @return [[@doctodo return_type:isPrimary]] [[@doctodo return_description:isPrimary]]
[ "Get", "is", "primary", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L227-L235
train
encorephp/console
src/ServiceProvider.php
ServiceProvider.register
public function register() { $container = $this->container; $console = new Console('EncorePHP', $container::VERSION); $this->container->bind('console', $console); if ($this->container->bound('error')) { $this->container['error']->setDisplayer(new ConsoleDisplayer($console)); } }
php
public function register() { $container = $this->container; $console = new Console('EncorePHP', $container::VERSION); $this->container->bind('console', $console); if ($this->container->bound('error')) { $this->container['error']->setDisplayer(new ConsoleDisplayer($console)); } }
[ "public", "function", "register", "(", ")", "{", "$", "container", "=", "$", "this", "->", "container", ";", "$", "console", "=", "new", "Console", "(", "'EncorePHP'", ",", "$", "container", "::", "VERSION", ")", ";", "$", "this", "->", "container", "-...
Register the console into the container. @return void
[ "Register", "the", "console", "into", "the", "container", "." ]
16dc0f8f6d303ec8bafef3fd388b0a0928155797
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L17-L27
train
encorephp/console
src/ServiceProvider.php
ServiceProvider.boot
public function boot() { // Loop the providers and register commands $providers = $this->container->providers(false); foreach ($providers as $provider) { if (method_exists($provider, 'commands')) { $this->registerCommands($provider->commands()); } } }
php
public function boot() { // Loop the providers and register commands $providers = $this->container->providers(false); foreach ($providers as $provider) { if (method_exists($provider, 'commands')) { $this->registerCommands($provider->commands()); } } }
[ "public", "function", "boot", "(", ")", "{", "// Loop the providers and register commands", "$", "providers", "=", "$", "this", "->", "container", "->", "providers", "(", "false", ")", ";", "foreach", "(", "$", "providers", "as", "$", "provider", ")", "{", "...
Register service provider commands on boot. @return void
[ "Register", "service", "provider", "commands", "on", "boot", "." ]
16dc0f8f6d303ec8bafef3fd388b0a0928155797
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L34-L44
train
encorephp/console
src/ServiceProvider.php
ServiceProvider.registerCommands
protected function registerCommands(array $commands) { foreach ($commands as $command) { if ( ! $command instanceof SymfonyCommand) { $command = $this->container[$command]; } $this->container['console']->add($command); } }
php
protected function registerCommands(array $commands) { foreach ($commands as $command) { if ( ! $command instanceof SymfonyCommand) { $command = $this->container[$command]; } $this->container['console']->add($command); } }
[ "protected", "function", "registerCommands", "(", "array", "$", "commands", ")", "{", "foreach", "(", "$", "commands", "as", "$", "command", ")", "{", "if", "(", "!", "$", "command", "instanceof", "SymfonyCommand", ")", "{", "$", "command", "=", "$", "th...
Register an array of commands into the console. @return void
[ "Register", "an", "array", "of", "commands", "into", "the", "console", "." ]
16dc0f8f6d303ec8bafef3fd388b0a0928155797
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L51-L60
train
vpg/titon.common
src/Titon/Common/Traits/Mutable.php
Mutable.add
public function add(array $params) { foreach ($params as $key => $value) { $this->set($key, $value); } return $this; }
php
public function add(array $params) { foreach ($params as $key => $value) { $this->set($key, $value); } return $this; }
[ "public", "function", "add", "(", "array", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this...
Add multiple parameters. @param array $params @return $this
[ "Add", "multiple", "parameters", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L74-L80
train
vpg/titon.common
src/Titon/Common/Traits/Mutable.php
Mutable.get
public function get($key, $default = null) { if (strpos($key, '.') === false) { $value = isset($this->_data[$key]) ? $this->_data[$key] : null; } else { $value = Hash::get($this->_data, $key); } if ($value === null) { return $default; } return $value; }
php
public function get($key, $default = null) { if (strpos($key, '.') === false) { $value = isset($this->_data[$key]) ? $this->_data[$key] : null; } else { $value = Hash::get($this->_data, $key); } if ($value === null) { return $default; } return $value; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "===", "false", ")", "{", "$", "value", "=", "isset", "(", "$", "this", "->", "_data", "[", "$", ...
Return a parameter by key. @uses Titon\Utility\Hash @param string $key @param mixed $default @return mixed
[ "Return", "a", "parameter", "by", "key", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L111-L123
train
vpg/titon.common
src/Titon/Common/Traits/Mutable.php
Mutable.remove
public function remove($key) { $this->_data = Hash::remove($this->_data, $key); return $this; }
php
public function remove($key) { $this->_data = Hash::remove($this->_data, $key); return $this; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "this", "->", "_data", "=", "Hash", "::", "remove", "(", "$", "this", "->", "_data", ",", "$", "key", ")", ";", "return", "$", "this", ";", "}" ]
Remove a parameter by key. @uses Titon\Utility\Hash @param string $key @return $this
[ "Remove", "a", "parameter", "by", "key", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L163-L167
train
vpg/titon.common
src/Titon/Common/Traits/Mutable.php
Mutable.set
public function set($key, $value = null) { if (strpos($key, '.') === false) { $this->_data[$key] = $value; } else { $this->_data = Hash::set($this->_data, $key, $value); } return $this; }
php
public function set($key, $value = null) { if (strpos($key, '.') === false) { $this->_data[$key] = $value; } else { $this->_data = Hash::set($this->_data, $key, $value); } return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "===", "false", ")", "{", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "$", "value", ";",...
Set a parameter value by key. @uses Titon\Utility\Hash @param string $key @param mixed $value @return $this
[ "Set", "a", "parameter", "value", "by", "key", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L178-L186
train