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
GrupaZero/core
src/Gzero/Core/Query/QueryBuilder.php
QueryBuilder.getArrayAndKeyName
protected function getArrayAndKeyName(string $fieldName, string $key): array { if (!in_array($key, ['filters', 'sorts'], true)) { throw new InvalidArgumentException('Key must be one of [filters, sorts]'); } if (str_contains($fieldName, '.')) { $path = explode('.', $fieldName); $name = array_pop($path); $relationPath = implode('.', $path); $array = array_get($this->relations, "$relationPath.$key", []); } else { $name = $fieldName; $array = ($key === 'filters') ? $this->filters : $this->sorts; } return [$name, $array]; }
php
protected function getArrayAndKeyName(string $fieldName, string $key): array { if (!in_array($key, ['filters', 'sorts'], true)) { throw new InvalidArgumentException('Key must be one of [filters, sorts]'); } if (str_contains($fieldName, '.')) { $path = explode('.', $fieldName); $name = array_pop($path); $relationPath = implode('.', $path); $array = array_get($this->relations, "$relationPath.$key", []); } else { $name = $fieldName; $array = ($key === 'filters') ? $this->filters : $this->sorts; } return [$name, $array]; }
[ "protected", "function", "getArrayAndKeyName", "(", "string", "$", "fieldName", ",", "string", "$", "key", ")", ":", "array", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "[", "'filters'", ",", "'sorts'", "]", ",", "true", ")", ")", "{", "t...
Helper function to figure out which array to use @param string $fieldName Field name @param string $key filters or sorts @throws InvalidArgumentException @return array
[ "Helper", "function", "to", "figure", "out", "which", "array", "to", "use" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/QueryBuilder.php#L346-L361
train
tokenly/platform-admin
src/Console/Kernel/PlatformAdminConsoleApplication.php
PlatformAdminConsoleApplication.getResolvedArtisanCommand
public function getResolvedArtisanCommand(InputInterface $input = null) { $name = $this->getCommandName($input); try { $command = $this->find($name); } catch (Exception $e) { EventLog::logError('command.notFound', $e, ['name' => $name]); return null; } return $command; }
php
public function getResolvedArtisanCommand(InputInterface $input = null) { $name = $this->getCommandName($input); try { $command = $this->find($name); } catch (Exception $e) { EventLog::logError('command.notFound', $e, ['name' => $name]); return null; } return $command; }
[ "public", "function", "getResolvedArtisanCommand", "(", "InputInterface", "$", "input", "=", "null", ")", "{", "$", "name", "=", "$", "this", "->", "getCommandName", "(", "$", "input", ")", ";", "try", "{", "$", "command", "=", "$", "this", "->", "find",...
resolve the artisan command
[ "resolve", "the", "artisan", "command" ]
0b2f5d57552d493026df94edaa250b475407d588
https://github.com/tokenly/platform-admin/blob/0b2f5d57552d493026df94edaa250b475407d588/src/Console/Kernel/PlatformAdminConsoleApplication.php#L15-L24
train
tasoftch/config
src/Config.php
Config.toArray
public function toArray($recursive = true) { $array = []; $data = $this->data; /** @var self $value */ foreach ($data as $key => $value) { if ($recursive && $value instanceof self) { $array[$key] = $value->toArray(); } else { $array[$key] = $value; } } return $array; }
php
public function toArray($recursive = true) { $array = []; $data = $this->data; /** @var self $value */ foreach ($data as $key => $value) { if ($recursive && $value instanceof self) { $array[$key] = $value->toArray(); } else { $array[$key] = $value; } } return $array; }
[ "public", "function", "toArray", "(", "$", "recursive", "=", "true", ")", "{", "$", "array", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "data", ";", "/** @var self $value */", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", ...
Converts the instance to an array @param bool $recursive Converts containing configurations recursive as well. @return array
[ "Converts", "the", "instance", "to", "an", "array" ]
4937668bd7d56150edf3a77de5d529db6f6a4a80
https://github.com/tasoftch/config/blob/4937668bd7d56150edf3a77de5d529db6f6a4a80/src/Config.php#L157-L172
train
tasoftch/config
src/Config.php
Config._convertedValue
private function _convertedValue($value, $key, $prefix) { if($this->getTransformsToConfig()) { if(is_iterable($value)) $value = new static($value, $prefix ? "$prefix.$key" : $key, true); } return $value; }
php
private function _convertedValue($value, $key, $prefix) { if($this->getTransformsToConfig()) { if(is_iterable($value)) $value = new static($value, $prefix ? "$prefix.$key" : $key, true); } return $value; }
[ "private", "function", "_convertedValue", "(", "$", "value", ",", "$", "key", ",", "$", "prefix", ")", "{", "if", "(", "$", "this", "->", "getTransformsToConfig", "(", ")", ")", "{", "if", "(", "is_iterable", "(", "$", "value", ")", ")", "$", "value"...
Internal method to convert any value to a new configuration object if required. @internal @param $value @param $key @param $prefix @return Config
[ "Internal", "method", "to", "convert", "any", "value", "to", "a", "new", "configuration", "object", "if", "required", "." ]
4937668bd7d56150edf3a77de5d529db6f6a4a80
https://github.com/tasoftch/config/blob/4937668bd7d56150edf3a77de5d529db6f6a4a80/src/Config.php#L320-L326
train
zicht/goggle
src/Zicht/ConfigTool/Writer/Factory.php
Factory.createWriter
public static function createWriter($type) { switch ($type) { case self::JSON: return new Impl\Json(); case self::YAML: return new Impl\Yaml(); case self::INI: return new Impl\Ini(); case self::COLUMNS: return new Impl\Columns(); case self::TABLE: return new Impl\ConsoleTable(); case self::MARKDOWN: return new Impl\MarkdownTable(); case self::DUMP: return new Impl\Dump(); } throw new UnknownWriterTypeException("Sorry, writer type {$type} is not something I do"); }
php
public static function createWriter($type) { switch ($type) { case self::JSON: return new Impl\Json(); case self::YAML: return new Impl\Yaml(); case self::INI: return new Impl\Ini(); case self::COLUMNS: return new Impl\Columns(); case self::TABLE: return new Impl\ConsoleTable(); case self::MARKDOWN: return new Impl\MarkdownTable(); case self::DUMP: return new Impl\Dump(); } throw new UnknownWriterTypeException("Sorry, writer type {$type} is not something I do"); }
[ "public", "static", "function", "createWriter", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "JSON", ":", "return", "new", "Impl", "\\", "Json", "(", ")", ";", "case", "self", "::", "YAML", ":", "return", ...
Create a writer for the specified type. @param string $type @return WriterInterface
[ "Create", "a", "writer", "for", "the", "specified", "type", "." ]
f3b42bda9d3821ef2d387aef1091cba8afe2cff2
https://github.com/zicht/goggle/blob/f3b42bda9d3821ef2d387aef1091cba8afe2cff2/src/Zicht/ConfigTool/Writer/Factory.php#L40-L60
train
zicht/goggle
src/Zicht/ConfigTool/Writer/Factory.php
Factory.supportedTypes
public static function supportedTypes() { return [ self::YAML, self::JSON, self::INI, self::COLUMNS, self::TABLE, self::MARKDOWN, self::DUMP ]; }
php
public static function supportedTypes() { return [ self::YAML, self::JSON, self::INI, self::COLUMNS, self::TABLE, self::MARKDOWN, self::DUMP ]; }
[ "public", "static", "function", "supportedTypes", "(", ")", "{", "return", "[", "self", "::", "YAML", ",", "self", "::", "JSON", ",", "self", "::", "INI", ",", "self", "::", "COLUMNS", ",", "self", "::", "TABLE", ",", "self", "::", "MARKDOWN", ",", "...
Returns an array of supported output formats @return array
[ "Returns", "an", "array", "of", "supported", "output", "formats" ]
f3b42bda9d3821ef2d387aef1091cba8afe2cff2
https://github.com/zicht/goggle/blob/f3b42bda9d3821ef2d387aef1091cba8afe2cff2/src/Zicht/ConfigTool/Writer/Factory.php#L67-L78
train
remote-office/libx
src/External/SimplePay/Account/IncassoAccount.php
IncassoAccount.setHolder
public function setHolder($holder) { if(!is_string($holder) || strlen(trim($holder)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid holder, must be a non empty string'); $this->holder = $holder; }
php
public function setHolder($holder) { if(!is_string($holder) || strlen(trim($holder)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid holder, must be a non empty string'); $this->holder = $holder; }
[ "public", "function", "setHolder", "(", "$", "holder", ")", "{", "if", "(", "!", "is_string", "(", "$", "holder", ")", "||", "strlen", "(", "trim", "(", "$", "holder", ")", ")", "==", "0", ")", "throw", "new", "InvalidArgumentException", "(", "__METHOD...
Set the holder of this IncassoAccount @param string $holder @return void
[ "Set", "the", "holder", "of", "this", "IncassoAccount" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Account/IncassoAccount.php#L53-L59
train
remote-office/libx
src/External/SimplePay/Account/IncassoAccount.php
IncassoAccount.setNumber
public function setNumber($number) { if(!is_string($number) || strlen(trim($number)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid number, must be a non empty string'); $this->number = $number; }
php
public function setNumber($number) { if(!is_string($number) || strlen(trim($number)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid number, must be a non empty string'); $this->number = $number; }
[ "public", "function", "setNumber", "(", "$", "number", ")", "{", "if", "(", "!", "is_string", "(", "$", "number", ")", "||", "strlen", "(", "trim", "(", "$", "number", ")", ")", "==", "0", ")", "throw", "new", "InvalidArgumentException", "(", "__METHOD...
Set the number of this IncassoAccount @param string $number @return void
[ "Set", "the", "number", "of", "this", "IncassoAccount" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Account/IncassoAccount.php#L78-L84
train
remote-office/libx
src/External/SimplePay/Account/IncassoAccount.php
IncassoAccount.setCity
public function setCity($city) { if(!is_string($city) || strlen(trim($city)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid city, must be a non empty string'); $this->city = $city; }
php
public function setCity($city) { if(!is_string($city) || strlen(trim($city)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid city, must be a non empty string'); $this->city = $city; }
[ "public", "function", "setCity", "(", "$", "city", ")", "{", "if", "(", "!", "is_string", "(", "$", "city", ")", "||", "strlen", "(", "trim", "(", "$", "city", ")", ")", "==", "0", ")", "throw", "new", "InvalidArgumentException", "(", "__METHOD__", "...
Set the city of this IncassoAccount @param string $city @return void
[ "Set", "the", "city", "of", "this", "IncassoAccount" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Account/IncassoAccount.php#L103-L109
train
harmony-project/modular-routing
source/ModularRouter.php
ModularRouter.getRouteCollectionForType
public function getRouteCollectionForType($type) { if (isset($this->collections[$type])) { return $this->collections[$type]; } if (!$this->metadataFactory->hasMetadataFor($type)) { throw new ResourceNotFoundException(sprintf('No metadata found for module type "%s".', $type)); } $metadata = $this->metadataFactory->getMetadataFor($type); $routes = $metadata->getRoutes(); // Add modular prefix to the collection $this->provider->addModularPrefix($routes); // Add route prefix to the collection $routes->addPrefix( $this->routePrefix['path'], $this->routePrefix['defaults'], $this->routePrefix['requirements'] ); return $this->collections[$type] = $routes; }
php
public function getRouteCollectionForType($type) { if (isset($this->collections[$type])) { return $this->collections[$type]; } if (!$this->metadataFactory->hasMetadataFor($type)) { throw new ResourceNotFoundException(sprintf('No metadata found for module type "%s".', $type)); } $metadata = $this->metadataFactory->getMetadataFor($type); $routes = $metadata->getRoutes(); // Add modular prefix to the collection $this->provider->addModularPrefix($routes); // Add route prefix to the collection $routes->addPrefix( $this->routePrefix['path'], $this->routePrefix['defaults'], $this->routePrefix['requirements'] ); return $this->collections[$type] = $routes; }
[ "public", "function", "getRouteCollectionForType", "(", "$", "type", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "collections", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "collections", "[", "$", "type", "]", ";", "}...
Returns the route collection for a module type. @param string $type @return RouteCollection
[ "Returns", "the", "route", "collection", "for", "a", "module", "type", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/ModularRouter.php#L278-L302
train
harmony-project/modular-routing
source/ModularRouter.php
ModularRouter.getGeneratorForModule
public function getGeneratorForModule(ModuleInterface $module) { $type = $module->getModularType(); $collection = $this->getRouteCollectionForType($type); if (array_key_exists($type, $this->generators)) { return $this->generators[$type]; } if (null === $this->options['cache_dir']) { return $this->generators[$type] = new $this->options['generator_class']($collection, $this->context, $this->logger); } $cacheClass = sprintf('%s_UrlGenerator', $type); $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'] . '/' . $cacheClass .'.php', function (ConfigCacheInterface $cache) use ($cacheClass, $collection) { /** @var GeneratorDumperInterface $dumper */ $dumper = new $this->options['generator_dumper_class']($collection); $options = [ 'class' => $cacheClass, 'base_class' => $this->options['generator_base_class'], ]; $cache->write($dumper->dump($options), $collection->getResources()); } ); require_once $cache->getPath(); return $this->generators[$type] = new $cacheClass($this->context, $this->logger); }
php
public function getGeneratorForModule(ModuleInterface $module) { $type = $module->getModularType(); $collection = $this->getRouteCollectionForType($type); if (array_key_exists($type, $this->generators)) { return $this->generators[$type]; } if (null === $this->options['cache_dir']) { return $this->generators[$type] = new $this->options['generator_class']($collection, $this->context, $this->logger); } $cacheClass = sprintf('%s_UrlGenerator', $type); $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'] . '/' . $cacheClass .'.php', function (ConfigCacheInterface $cache) use ($cacheClass, $collection) { /** @var GeneratorDumperInterface $dumper */ $dumper = new $this->options['generator_dumper_class']($collection); $options = [ 'class' => $cacheClass, 'base_class' => $this->options['generator_base_class'], ]; $cache->write($dumper->dump($options), $collection->getResources()); } ); require_once $cache->getPath(); return $this->generators[$type] = new $cacheClass($this->context, $this->logger); }
[ "public", "function", "getGeneratorForModule", "(", "ModuleInterface", "$", "module", ")", "{", "$", "type", "=", "$", "module", "->", "getModularType", "(", ")", ";", "$", "collection", "=", "$", "this", "->", "getRouteCollectionForType", "(", "$", "type", ...
Returns a generator for a module. @param ModuleInterface $module @return UrlGeneratorInterface
[ "Returns", "a", "generator", "for", "a", "module", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/ModularRouter.php#L327-L359
train
harmony-project/modular-routing
source/ModularRouter.php
ModularRouter.getModuleByRequest
public function getModuleByRequest(Request $request) { $parameters = $this->getInitialMatcher()->matchRequest($request); // Since a matcher throws an exception on failure, this will only be reached // if the match was successful. return $this->provider->loadModuleByRequest($request, $parameters); }
php
public function getModuleByRequest(Request $request) { $parameters = $this->getInitialMatcher()->matchRequest($request); // Since a matcher throws an exception on failure, this will only be reached // if the match was successful. return $this->provider->loadModuleByRequest($request, $parameters); }
[ "public", "function", "getModuleByRequest", "(", "Request", "$", "request", ")", "{", "$", "parameters", "=", "$", "this", "->", "getInitialMatcher", "(", ")", "->", "matchRequest", "(", "$", "request", ")", ";", "// Since a matcher throws an exception on failure, t...
Returns a module by matching the request. @param Request $request The request to match @return ModuleInterface @throws ResourceNotFoundException If no matching resource or module could be found @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed
[ "Returns", "a", "module", "by", "matching", "the", "request", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/ModularRouter.php#L411-L419
train
harmony-project/modular-routing
source/ModularRouter.php
ModularRouter.getInitialMatcher
public function getInitialMatcher() { if (null !== $this->initialMatcher) { return $this->initialMatcher; } $route = sprintf('%s/{_modular_path}', $this->routePrefix['path']); $collection = new RouteCollection; $collection->add('modular', new Route( $route, $this->routePrefix['defaults'], array_merge( $this->routePrefix['requirements'], ['_modular_path' => '.+'] ) )); return $this->initialMatcher = new UrlMatcher($collection, $this->context); }
php
public function getInitialMatcher() { if (null !== $this->initialMatcher) { return $this->initialMatcher; } $route = sprintf('%s/{_modular_path}', $this->routePrefix['path']); $collection = new RouteCollection; $collection->add('modular', new Route( $route, $this->routePrefix['defaults'], array_merge( $this->routePrefix['requirements'], ['_modular_path' => '.+'] ) )); return $this->initialMatcher = new UrlMatcher($collection, $this->context); }
[ "public", "function", "getInitialMatcher", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "initialMatcher", ")", "{", "return", "$", "this", "->", "initialMatcher", ";", "}", "$", "route", "=", "sprintf", "(", "'%s/{_modular_path}'", ",", "$",...
Returns a matcher that matches a Request to the route prefix. @return UrlMatcher
[ "Returns", "a", "matcher", "that", "matches", "a", "Request", "to", "the", "route", "prefix", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/ModularRouter.php#L426-L445
train
calgamo/logger
src/Logger/FileLogger.php
FileLogger.getLogFileName
private function getLogFileName() : string { $file_name = $this->file_name; if ($this->filename_processor){ $file_name = $this->filename_processor->process($file_name); } $file_name = self::escapeFileName($file_name); return $file_name; }
php
private function getLogFileName() : string { $file_name = $this->file_name; if ($this->filename_processor){ $file_name = $this->filename_processor->process($file_name); } $file_name = self::escapeFileName($file_name); return $file_name; }
[ "private", "function", "getLogFileName", "(", ")", ":", "string", "{", "$", "file_name", "=", "$", "this", "->", "file_name", ";", "if", "(", "$", "this", "->", "filename_processor", ")", "{", "$", "file_name", "=", "$", "this", "->", "filename_processor",...
Get log file name @return string
[ "Get", "log", "file", "name" ]
58aab9ddfe3f383337c61cad1f4742ce5afb9591
https://github.com/calgamo/logger/blob/58aab9ddfe3f383337c61cad1f4742ce5afb9591/src/Logger/FileLogger.php#L173-L181
train
Rockbeat-Sky/framework
src/core/Router.php
Router._initialize
protected function _initialize(){ // Fetch the complete URI string $this->uri->_fetch_uri_string(); // Do we need to remove the URL suffix? $this->uri->_remove_url_suffix(); // Compile the segments into an array $this->uri->_explode_segments(); // Set Segments $this->segments = $this->uri->segments; // Parse any custom routing that may exist $this->_parseRoutes(); // Re-index the segment array so that it starts with 1 rather than 0 $this->uri->_reindex_segments(); }
php
protected function _initialize(){ // Fetch the complete URI string $this->uri->_fetch_uri_string(); // Do we need to remove the URL suffix? $this->uri->_remove_url_suffix(); // Compile the segments into an array $this->uri->_explode_segments(); // Set Segments $this->segments = $this->uri->segments; // Parse any custom routing that may exist $this->_parseRoutes(); // Re-index the segment array so that it starts with 1 rather than 0 $this->uri->_reindex_segments(); }
[ "protected", "function", "_initialize", "(", ")", "{", "// Fetch the complete URI string", "$", "this", "->", "uri", "->", "_fetch_uri_string", "(", ")", ";", "// Do we need to remove the URL suffix?", "$", "this", "->", "uri", "->", "_remove_url_suffix", "(", ")", ...
Set the route mapping This function determines what should be served based on the URI request, as well as any "routes" that have been set in the routing config file. @access private @return void
[ "Set", "the", "route", "mapping" ]
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Router.php#L100-L121
train
Rockbeat-Sky/framework
src/core/Router.php
Router._setRequest
protected function _setRequest($segments = array()){ $segments = $this->_validateRequest($segments); if (count($segments) == 0){ return $this->uri->_reindex_segments(); } $this->setClass($segments[0]); if (isset($segments[1])) { // A standard method request $this->method = $segments[1]; } else { // This lets the "routed" segment array identify that the default // index method is being used. $segments[1] = 'index'; } // Update our "routed" segment array to contain the segments. // Note: If there is no custom routing, this array will be // identical to $this->uri->segments $this->uri->rsegments = $segments; }
php
protected function _setRequest($segments = array()){ $segments = $this->_validateRequest($segments); if (count($segments) == 0){ return $this->uri->_reindex_segments(); } $this->setClass($segments[0]); if (isset($segments[1])) { // A standard method request $this->method = $segments[1]; } else { // This lets the "routed" segment array identify that the default // index method is being used. $segments[1] = 'index'; } // Update our "routed" segment array to contain the segments. // Note: If there is no custom routing, this array will be // identical to $this->uri->segments $this->uri->rsegments = $segments; }
[ "protected", "function", "_setRequest", "(", "$", "segments", "=", "array", "(", ")", ")", "{", "$", "segments", "=", "$", "this", "->", "_validateRequest", "(", "$", "segments", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "==", "0", ")"...
Set the Route This function takes an array of URI segments as input, and sets the current class/method @access private @param array @param bool @return void
[ "Set", "the", "Route" ]
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Router.php#L137-L161
train
ojhaujjwal/UserRbac
src/Mapper/UserRoleLinkerMapper.php
UserRoleLinkerMapper.findByRoleId
public function findByRoleId($roleId) { $select = $this->getSelect($this->getUserTableName()); $select->where(array($this->getTableName() . '.role_id' => $roleId)); $select->join( $this->getTableName(), $this->getTableName(). '.user_id = ' . $this->getUserTableName(). '.user_id', array(), Select::JOIN_INNER ); $select->group($this->getUserTableName(). '.user_id'); $entityPrototype = $this->getZfcUserOptions()->getUserEntityClass(); return $this->select($select, new $entityPrototype, $this->getZfcUserHydrator()); }
php
public function findByRoleId($roleId) { $select = $this->getSelect($this->getUserTableName()); $select->where(array($this->getTableName() . '.role_id' => $roleId)); $select->join( $this->getTableName(), $this->getTableName(). '.user_id = ' . $this->getUserTableName(). '.user_id', array(), Select::JOIN_INNER ); $select->group($this->getUserTableName(). '.user_id'); $entityPrototype = $this->getZfcUserOptions()->getUserEntityClass(); return $this->select($select, new $entityPrototype, $this->getZfcUserHydrator()); }
[ "public", "function", "findByRoleId", "(", "$", "roleId", ")", "{", "$", "select", "=", "$", "this", "->", "getSelect", "(", "$", "this", "->", "getUserTableName", "(", ")", ")", ";", "$", "select", "->", "where", "(", "array", "(", "$", "this", "->"...
Finds users with a specific role @param string $roleId @return Zend\Db\ResultSet\HydratingResultSet
[ "Finds", "users", "with", "a", "specific", "role" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Mapper/UserRoleLinkerMapper.php#L60-L75
train
ojhaujjwal/UserRbac
src/Mapper/UserRoleLinkerMapper.php
UserRoleLinkerMapper.insert
public function insert($userRoleLinker, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($userRoleLinker); return parent::insert($userRoleLinker); }
php
public function insert($userRoleLinker, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($userRoleLinker); return parent::insert($userRoleLinker); }
[ "public", "function", "insert", "(", "$", "userRoleLinker", ",", "$", "tableName", "=", "null", ",", "HydratorInterface", "$", "hydrator", "=", "null", ")", "{", "$", "this", "->", "checkEntity", "(", "$", "userRoleLinker", ")", ";", "return", "parent", ":...
Add a new role of a user @param UserRbac\Entity\UserRoleLinkerInterface $userRoleLinker @return mixed
[ "Add", "a", "new", "role", "of", "a", "user" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Mapper/UserRoleLinkerMapper.php#L83-L88
train
ojhaujjwal/UserRbac
src/Mapper/UserRoleLinkerMapper.php
UserRoleLinkerMapper.delete
public function delete($userRoleLinker, $tableName = null) { $this->checkEntity($userRoleLinker); return parent::delete(array('user_id' => $userRoleLinker->getUserId(), 'role_id' => $userRoleLinker->getRoleId())); }
php
public function delete($userRoleLinker, $tableName = null) { $this->checkEntity($userRoleLinker); return parent::delete(array('user_id' => $userRoleLinker->getUserId(), 'role_id' => $userRoleLinker->getRoleId())); }
[ "public", "function", "delete", "(", "$", "userRoleLinker", ",", "$", "tableName", "=", "null", ")", "{", "$", "this", "->", "checkEntity", "(", "$", "userRoleLinker", ")", ";", "return", "parent", "::", "delete", "(", "array", "(", "'user_id'", "=>", "$...
Deletes a role of a user @param UserRoleLinkerInterface $userRoleLinker @return mixed
[ "Deletes", "a", "role", "of", "a", "user" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Mapper/UserRoleLinkerMapper.php#L96-L101
train
unyx/utils
str/Cases.php
Cases.delimit
public static function delimit(string $str, string $delimiter, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Keep track of the internal encoding as we'll change it temporarily and then revert back to it. $internalEncoding = mb_regex_encoding(); // Swap out the internal encoding for what we want... mb_regex_encoding($encoding); // ... trim the input string, convert it to lowercase, insert the delimiter. $str = mb_ereg_replace('\B([A-Z])', '-\1', mb_ereg_replace("^[[:space:]]+|[[:space:]]+\$", '', $str)); $str = mb_strtolower($str, $encoding); $str = mb_ereg_replace('[-_\s]+', $delimiter, $str); // Restore the initial internal encoding. mb_regex_encoding($internalEncoding); return $str; }
php
public static function delimit(string $str, string $delimiter, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Keep track of the internal encoding as we'll change it temporarily and then revert back to it. $internalEncoding = mb_regex_encoding(); // Swap out the internal encoding for what we want... mb_regex_encoding($encoding); // ... trim the input string, convert it to lowercase, insert the delimiter. $str = mb_ereg_replace('\B([A-Z])', '-\1', mb_ereg_replace("^[[:space:]]+|[[:space:]]+\$", '', $str)); $str = mb_strtolower($str, $encoding); $str = mb_ereg_replace('[-_\s]+', $delimiter, $str); // Restore the initial internal encoding. mb_regex_encoding($internalEncoding); return $str; }
[ "public", "static", "function", "delimit", "(", "string", "$", "str", ",", "string", "$", "delimiter", ",", "string", "$", "encoding", "=", "null", ")", ":", "string", "{", "$", "encoding", "=", "$", "encoding", "?", ":", "utils", "\\", "Str", "::", ...
Delimits the given string on spaces, underscores and dashes and before uppercase characters using the given delimiter string. The resulting string will also be trimmed and lower-cased. @param string $str The string to delimit. @param string $delimiter The delimiter to use. Can be a sequence of multiple characters. @param string|null $encoding The encoding to use. @return string The resulting string. @todo Decide whether to keep the trimming and case change in here (too much responsibility).
[ "Delimits", "the", "given", "string", "on", "spaces", "underscores", "and", "dashes", "and", "before", "uppercase", "characters", "using", "the", "given", "delimiter", "string", ".", "The", "resulting", "string", "will", "also", "be", "trimmed", "and", "lower", ...
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/str/Cases.php#L61-L80
train
unyx/utils
str/Cases.php
Cases.lower
public static function lower(string $str, string $encoding = null) : string { return mb_strtolower($str, $encoding ?: utils\Str::encoding($str)); }
php
public static function lower(string $str, string $encoding = null) : string { return mb_strtolower($str, $encoding ?: utils\Str::encoding($str)); }
[ "public", "static", "function", "lower", "(", "string", "$", "str", ",", "string", "$", "encoding", "=", "null", ")", ":", "string", "{", "return", "mb_strtolower", "(", "$", "str", ",", "$", "encoding", "?", ":", "utils", "\\", "Str", "::", "encoding"...
Converts all characters in the given string to lowercase. @param string $str The string to convert. @param string|null $encoding The encoding to use. @return string The converted string.
[ "Converts", "all", "characters", "in", "the", "given", "string", "to", "lowercase", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/str/Cases.php#L89-L92
train
unyx/utils
str/Cases.php
Cases.lowerFirst
public static function lowerFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Lowercase the first character and append the remainder. return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding); }
php
public static function lowerFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Lowercase the first character and append the remainder. return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding); }
[ "public", "static", "function", "lowerFirst", "(", "string", "$", "str", ",", "string", "$", "encoding", "=", "null", ")", ":", "string", "{", "$", "encoding", "=", "$", "encoding", "?", ":", "utils", "\\", "Str", "::", "encoding", "(", "$", "str", "...
Converts the first character in the given string to lowercase. @param string $str The string to convert. @param string|null $encoding The encoding to use. @return string The converted string.
[ "Converts", "the", "first", "character", "in", "the", "given", "string", "to", "lowercase", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/str/Cases.php#L101-L107
train
unyx/utils
str/Cases.php
Cases.upper
public static function upper(string $str, string $encoding = null) : string { return mb_strtoupper($str, $encoding ?: utils\Str::encoding($str)); }
php
public static function upper(string $str, string $encoding = null) : string { return mb_strtoupper($str, $encoding ?: utils\Str::encoding($str)); }
[ "public", "static", "function", "upper", "(", "string", "$", "str", ",", "string", "$", "encoding", "=", "null", ")", ":", "string", "{", "return", "mb_strtoupper", "(", "$", "str", ",", "$", "encoding", "?", ":", "utils", "\\", "Str", "::", "encoding"...
Converts all characters in the given string to uppercase. @param string $str The string to convert. @param string|null $encoding The encoding to use. @return string The converted string.
[ "Converts", "all", "characters", "in", "the", "given", "string", "to", "uppercase", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/str/Cases.php#L166-L169
train
unyx/utils
str/Cases.php
Cases.upperFirst
public static function upperFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Uppercase the first character and append the remainder. return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding); }
php
public static function upperFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Uppercase the first character and append the remainder. return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding); }
[ "public", "static", "function", "upperFirst", "(", "string", "$", "str", ",", "string", "$", "encoding", "=", "null", ")", ":", "string", "{", "$", "encoding", "=", "$", "encoding", "?", ":", "utils", "\\", "Str", "::", "encoding", "(", "$", "str", "...
Converts the first character in the given string to uppercase. @param string $str The string to convert. @param string|null $encoding The encoding to use. @return string The converted string.
[ "Converts", "the", "first", "character", "in", "the", "given", "string", "to", "uppercase", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/str/Cases.php#L178-L184
train
nirix/radium
src/Database/Model/Validatable.php
Validatable.validates
public function validates($data = null) { $this->errors = array(); // Get data if it wasn't passed if ($data === null) { $data = $this->data(); } foreach (static::$_validates as $field => $validations) { Validations::run($this, $field, $validations); } return count($this->errors) == 0; }
php
public function validates($data = null) { $this->errors = array(); // Get data if it wasn't passed if ($data === null) { $data = $this->data(); } foreach (static::$_validates as $field => $validations) { Validations::run($this, $field, $validations); } return count($this->errors) == 0; }
[ "public", "function", "validates", "(", "$", "data", "=", "null", ")", "{", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "// Get data if it wasn't passed", "if", "(", "$", "data", "===", "null", ")", "{", "$", "data", "=", "$", "this", "...
Validates the model data. @param array $data @return boolean
[ "Validates", "the", "model", "data", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Validatable.php#L40-L54
train
jeronimos/php-adjutants
src/Objects/DataInit/ConfigResolver.php
ConfigResolver.resolveConfigHandler
public static function resolveConfigHandler($fileName) { $configHandler = NULL; preg_match("/(\.)([a-z]{3,})/", $fileName, $matches); $fileExtension = $matches[2]; if (!in_array($fileExtension, ConfigConsts::getExtensions())) { throw new ConfigException("Not correct config file extension."); } switch ($fileExtension) { case(ConfigConsts::INI): $configHandler = new ConfigIniHandler(); break; default: throw new ConfigException("Config handler wasn't set."); } return $configHandler; }
php
public static function resolveConfigHandler($fileName) { $configHandler = NULL; preg_match("/(\.)([a-z]{3,})/", $fileName, $matches); $fileExtension = $matches[2]; if (!in_array($fileExtension, ConfigConsts::getExtensions())) { throw new ConfigException("Not correct config file extension."); } switch ($fileExtension) { case(ConfigConsts::INI): $configHandler = new ConfigIniHandler(); break; default: throw new ConfigException("Config handler wasn't set."); } return $configHandler; }
[ "public", "static", "function", "resolveConfigHandler", "(", "$", "fileName", ")", "{", "$", "configHandler", "=", "NULL", ";", "preg_match", "(", "\"/(\\.)([a-z]{3,})/\"", ",", "$", "fileName", ",", "$", "matches", ")", ";", "$", "fileExtension", "=", "$", ...
Resolve config handler by file extension. @param $fileName @return ConfigIniHandler|null @throws ConfigException
[ "Resolve", "config", "handler", "by", "file", "extension", "." ]
78b428ed05a9d6029a29a86ac47906adeb9fd41d
https://github.com/jeronimos/php-adjutants/blob/78b428ed05a9d6029a29a86ac47906adeb9fd41d/src/Objects/DataInit/ConfigResolver.php#L22-L43
train
axypro/env
Factory.php
Factory.create
public static function create($config = null) { if ($config === null) { return self::getStandard(); } if (is_array($config) || ($config instanceof Config)) { return new Env($config); } if ($config instanceof Env) { return $config; } $message = 'Factory accepts Env, Config, array or NULL'; throw new InvalidConfig('Env', $message, 0, null, __NAMESPACE__); }
php
public static function create($config = null) { if ($config === null) { return self::getStandard(); } if (is_array($config) || ($config instanceof Config)) { return new Env($config); } if ($config instanceof Env) { return $config; } $message = 'Factory accepts Env, Config, array or NULL'; throw new InvalidConfig('Env', $message, 0, null, __NAMESPACE__); }
[ "public", "static", "function", "create", "(", "$", "config", "=", "null", ")", "{", "if", "(", "$", "config", "===", "null", ")", "{", "return", "self", "::", "getStandard", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "config", ")", "||",...
Creates an environment wrapper @param \axy\env\Env|\axy\env\Config|array $config @return \axy\env\Env @throws \axy\errors\InvalidConfig
[ "Creates", "an", "environment", "wrapper" ]
0cc3539682d6f021ac6645ff8dfa0a6829c33616
https://github.com/axypro/env/blob/0cc3539682d6f021ac6645ff8dfa0a6829c33616/Factory.php#L36-L49
train
pletfix/core
src/Services/Delegate.php
Delegate.getPluginMiddleware
private function getPluginMiddleware($class) { if ($this->pluginMiddleware === null) { /** @noinspection PhpIncludeInspection */ $this->pluginMiddleware = file_exists($this->pluginManifestOfMiddleware) ? include $this->pluginManifestOfMiddleware : []; } return isset($this->pluginMiddleware[$class]) && count($this->pluginMiddleware[$class]) == 1 ? $this->pluginMiddleware[$class][0] : null; }
php
private function getPluginMiddleware($class) { if ($this->pluginMiddleware === null) { /** @noinspection PhpIncludeInspection */ $this->pluginMiddleware = file_exists($this->pluginManifestOfMiddleware) ? include $this->pluginManifestOfMiddleware : []; } return isset($this->pluginMiddleware[$class]) && count($this->pluginMiddleware[$class]) == 1 ? $this->pluginMiddleware[$class][0] : null; }
[ "private", "function", "getPluginMiddleware", "(", "$", "class", ")", "{", "if", "(", "$", "this", "->", "pluginMiddleware", "===", "null", ")", "{", "/** @noinspection PhpIncludeInspection */", "$", "this", "->", "pluginMiddleware", "=", "file_exists", "(", "$", ...
Get the full qualified class name of the plugin's middleware. @param string $class @return null|string
[ "Get", "the", "full", "qualified", "class", "name", "of", "the", "plugin", "s", "middleware", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Delegate.php#L142-L150
train
phpservicebus/core
src/Persistence/InMemory/Outbox/InMemoryOutboxStorage.php
InMemoryOutboxStorage.get
public function get($messageId) { if (!isset($this->messages[$messageId])) { return null; } return new OutboxMessage($messageId, $this->messages[$messageId]->getTransportOperations()); }
php
public function get($messageId) { if (!isset($this->messages[$messageId])) { return null; } return new OutboxMessage($messageId, $this->messages[$messageId]->getTransportOperations()); }
[ "public", "function", "get", "(", "$", "messageId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "messages", "[", "$", "messageId", "]", ")", ")", "{", "return", "null", ";", "}", "return", "new", "OutboxMessage", "(", "$", "messageId",...
Fetches the given message from the storage. It returns null if no message is found. @param string $messageId @return OutboxMessage|null
[ "Fetches", "the", "given", "message", "from", "the", "storage", ".", "It", "returns", "null", "if", "no", "message", "is", "found", "." ]
adbcf94be1e022120ede0c5aafa8a4f7900b0a6c
https://github.com/phpservicebus/core/blob/adbcf94be1e022120ede0c5aafa8a4f7900b0a6c/src/Persistence/InMemory/Outbox/InMemoryOutboxStorage.php#L28-L35
train
phpservicebus/core
src/Persistence/InMemory/Outbox/InMemoryOutboxStorage.php
InMemoryOutboxStorage.store
public function store(OutboxMessage $message) { $messageId = $message->getMessageId(); if (isset($this->messages[$messageId])) { throw new InvalidArgumentException("Outbox message with ID '$messageId' already exists in storage."); } $this->messages[$messageId] = new InMemoryStoredMessage($messageId, $message->getTransportOperations()); $this->lastMessageId = $messageId; }
php
public function store(OutboxMessage $message) { $messageId = $message->getMessageId(); if (isset($this->messages[$messageId])) { throw new InvalidArgumentException("Outbox message with ID '$messageId' already exists in storage."); } $this->messages[$messageId] = new InMemoryStoredMessage($messageId, $message->getTransportOperations()); $this->lastMessageId = $messageId; }
[ "public", "function", "store", "(", "OutboxMessage", "$", "message", ")", "{", "$", "messageId", "=", "$", "message", "->", "getMessageId", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "messages", "[", "$", "messageId", "]", ")", ")", "...
Stores the message to enable deduplication and re-dispatching of transport operations. Throws an exception if a message with the same ID already exists. @param OutboxMessage $message @return void
[ "Stores", "the", "message", "to", "enable", "deduplication", "and", "re", "-", "dispatching", "of", "transport", "operations", ".", "Throws", "an", "exception", "if", "a", "message", "with", "the", "same", "ID", "already", "exists", "." ]
adbcf94be1e022120ede0c5aafa8a4f7900b0a6c
https://github.com/phpservicebus/core/blob/adbcf94be1e022120ede0c5aafa8a4f7900b0a6c/src/Persistence/InMemory/Outbox/InMemoryOutboxStorage.php#L45-L54
train
crysalead/jit
src/Interceptor.php
Interceptor.patch
public static function patch($options = []) { if (static::$_interceptor) { throw new JitException("An interceptor is already attached."); } $defaults = ['loader' => null]; $options += $defaults; $loader = $options['originalLoader'] = $options['loader'] ?: static::composer(); if (!$loader) { throw new JitException("The loader option need to be a valid autoloader."); } unset($options['loader']); class_exists('Lead\Jit\JitException'); class_exists('Lead\Jit\Node\NodeDef'); class_exists('Lead\Jit\Node\FunctionDef'); class_exists('Lead\Jit\Node\BlockDef'); class_exists('Lead\Jit\TokenStream'); class_exists('Lead\Jit\Parser'); $interceptor = new static($options); spl_autoload_unregister($loader); return static::load($interceptor) ? $interceptor : false; }
php
public static function patch($options = []) { if (static::$_interceptor) { throw new JitException("An interceptor is already attached."); } $defaults = ['loader' => null]; $options += $defaults; $loader = $options['originalLoader'] = $options['loader'] ?: static::composer(); if (!$loader) { throw new JitException("The loader option need to be a valid autoloader."); } unset($options['loader']); class_exists('Lead\Jit\JitException'); class_exists('Lead\Jit\Node\NodeDef'); class_exists('Lead\Jit\Node\FunctionDef'); class_exists('Lead\Jit\Node\BlockDef'); class_exists('Lead\Jit\TokenStream'); class_exists('Lead\Jit\Parser'); $interceptor = new static($options); spl_autoload_unregister($loader); return static::load($interceptor) ? $interceptor : false; }
[ "public", "static", "function", "patch", "(", "$", "options", "=", "[", "]", ")", "{", "if", "(", "static", "::", "$", "_interceptor", ")", "{", "throw", "new", "JitException", "(", "\"An interceptor is already attached.\"", ")", ";", "}", "$", "defaults", ...
Patch the autoloader to be intercepted by the current autoloader. @param array $options Options for the interceptor autoloader. @throws JitException
[ "Patch", "the", "autoloader", "to", "be", "intercepted", "by", "the", "current", "autoloader", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Interceptor.php#L161-L184
train
crysalead/jit
src/Interceptor.php
Interceptor.composer
public static function composer() { $loaders = spl_autoload_functions(); foreach ($loaders as $key => $loader) { if (is_array($loader) && ($loader[0] instanceof ClassLoader)) { return $loader; } } }
php
public static function composer() { $loaders = spl_autoload_functions(); foreach ($loaders as $key => $loader) { if (is_array($loader) && ($loader[0] instanceof ClassLoader)) { return $loader; } } }
[ "public", "static", "function", "composer", "(", ")", "{", "$", "loaders", "=", "spl_autoload_functions", "(", ")", ";", "foreach", "(", "$", "loaders", "as", "$", "key", "=>", "$", "loader", ")", "{", "if", "(", "is_array", "(", "$", "loader", ")", ...
Look for the composer autoloader. @param array $options Options for the interceptor autoloader. @return mixed The founded composer autolaoder or `null` if not found.
[ "Look", "for", "the", "composer", "autoloader", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Interceptor.php#L192-L201
train
crysalead/jit
src/Interceptor.php
Interceptor.load
public static function load($interceptor = null) { if (static::$_interceptor) { static::unpatch(); } $original = $interceptor->originalLoader(); $success = spl_autoload_register($interceptor->loader(), true, true); spl_autoload_unregister($original); static::$_interceptor = $interceptor; return $success; }
php
public static function load($interceptor = null) { if (static::$_interceptor) { static::unpatch(); } $original = $interceptor->originalLoader(); $success = spl_autoload_register($interceptor->loader(), true, true); spl_autoload_unregister($original); static::$_interceptor = $interceptor; return $success; }
[ "public", "static", "function", "load", "(", "$", "interceptor", "=", "null", ")", "{", "if", "(", "static", "::", "$", "_interceptor", ")", "{", "static", "::", "unpatch", "(", ")", ";", "}", "$", "original", "=", "$", "interceptor", "->", "originalLo...
Loads an interceptor autoloader. @param array $loader The autoloader to use. @return boolean Returns `true` on success, `false` otherwise.
[ "Loads", "an", "interceptor", "autoloader", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Interceptor.php#L219-L231
train
crysalead/jit
src/Interceptor.php
Interceptor.loadFiles
public function loadFiles($files) { $files = (array) $files; $success = true; foreach ($files as $file) { $this->loadFile($file); } return true; }
php
public function loadFiles($files) { $files = (array) $files; $success = true; foreach ($files as $file) { $this->loadFile($file); } return true; }
[ "public", "function", "loadFiles", "(", "$", "files", ")", "{", "$", "files", "=", "(", "array", ")", "$", "files", ";", "$", "success", "=", "true", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "this", "->", "loadFile", "...
Manualy load files. @param array An array of files to load.
[ "Manualy", "load", "files", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Interceptor.php#L435-L445
train
crysalead/jit
src/Interceptor.php
Interceptor.cache
public function cache($file, $content, $timestamp = null) { if (!$cachePath = $this->cachePath()) { throw new JitException('Error, any cache path has been defined.'); } $path = $cachePath . DS . ltrim(preg_replace('~:~', '', $file), DS); if (!@file_exists(dirname($path))) { mkdir(dirname($path), 0755, true); } if (file_put_contents($path, $content) === false) { throw new JitException("Unable to create a cached file at `'{$file}'`."); } if ($timestamp) { touch($path, $timestamp); } return $path; }
php
public function cache($file, $content, $timestamp = null) { if (!$cachePath = $this->cachePath()) { throw new JitException('Error, any cache path has been defined.'); } $path = $cachePath . DS . ltrim(preg_replace('~:~', '', $file), DS); if (!@file_exists(dirname($path))) { mkdir(dirname($path), 0755, true); } if (file_put_contents($path, $content) === false) { throw new JitException("Unable to create a cached file at `'{$file}'`."); } if ($timestamp) { touch($path, $timestamp); } return $path; }
[ "public", "function", "cache", "(", "$", "file", ",", "$", "content", ",", "$", "timestamp", "=", "null", ")", "{", "if", "(", "!", "$", "cachePath", "=", "$", "this", "->", "cachePath", "(", ")", ")", "{", "throw", "new", "JitException", "(", "'Er...
Cache helper. @param string $file The source file path. @param string $content The patched content to cache. @return string The patched file path or the cache path if called with no params.
[ "Cache", "helper", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Interceptor.php#L454-L472
train
vinala/kernel
src/Lumos/Commands/ExecSeedCommand.php
ExecSeedCommand.backup
protected function backup($process) { if ($process) { $this->line(''); // $ok = $this->confirm('Wanna make backup for database ? [yes/no]', false); // if ($ok) { if (Database::export()) { $this->info('The database saved'); } else { $this->error("The database wasn't saved"); } } } }
php
protected function backup($process) { if ($process) { $this->line(''); // $ok = $this->confirm('Wanna make backup for database ? [yes/no]', false); // if ($ok) { if (Database::export()) { $this->info('The database saved'); } else { $this->error("The database wasn't saved"); } } } }
[ "protected", "function", "backup", "(", "$", "process", ")", "{", "if", "(", "$", "process", ")", "{", "$", "this", "->", "line", "(", "''", ")", ";", "//", "$", "ok", "=", "$", "this", "->", "confirm", "(", "'Wanna make backup for database ? [yes/no]'",...
Make backup for database.
[ "Make", "backup", "for", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands/ExecSeedCommand.php#L85-L100
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.checkClassForCompability
protected function checkClassForCompability( $className ) { $result = $className; if( isset( DeferredExceptionsGlobal::$defExcClasses [$className])){ if( ! DeferredExceptionsGlobal::$defExcClasses [$className] ){ $result = null; } } else { if( ! class_exists( $className ) || ! is_subclass_of( $className, 'Exception')) { DeferredExceptionsGlobal::$defExcClasses [$className] = false; $result = null; } else { DeferredExceptionsGlobal::$defExcClasses [$className] = true; } } return $result; }
php
protected function checkClassForCompability( $className ) { $result = $className; if( isset( DeferredExceptionsGlobal::$defExcClasses [$className])){ if( ! DeferredExceptionsGlobal::$defExcClasses [$className] ){ $result = null; } } else { if( ! class_exists( $className ) || ! is_subclass_of( $className, 'Exception')) { DeferredExceptionsGlobal::$defExcClasses [$className] = false; $result = null; } else { DeferredExceptionsGlobal::$defExcClasses [$className] = true; } } return $result; }
[ "protected", "function", "checkClassForCompability", "(", "$", "className", ")", "{", "$", "result", "=", "$", "className", ";", "if", "(", "isset", "(", "DeferredExceptionsGlobal", "::", "$", "defExcClasses", "[", "$", "className", "]", ")", ")", "{", "if",...
Check the class for existance and inheritance from the \Exception class @param string $className Class name to check @return mixed Class name or NULL
[ "Check", "the", "class", "for", "existance", "and", "inheritance", "from", "the", "\\", "Exception", "class" ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L113-L128
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.getCompatibleClass
protected function getCompatibleClass( $className ) { if( ! $className || ! is_string( $className )){ $className = get_class( $this ); } $class = $className; if( ! $this->checkClassForCompability( $class )){ $class = $this->checkClassForCompability( $class .'Exception' ); } if( ! $class ) { if( $parent = get_parent_class( $className ) ) { $class = $this->getCompatibleClass( $parent ); } else { $class = __NAMESPACE__ .'\DeferredExceptionsException'; } } return $class; }
php
protected function getCompatibleClass( $className ) { if( ! $className || ! is_string( $className )){ $className = get_class( $this ); } $class = $className; if( ! $this->checkClassForCompability( $class )){ $class = $this->checkClassForCompability( $class .'Exception' ); } if( ! $class ) { if( $parent = get_parent_class( $className ) ) { $class = $this->getCompatibleClass( $parent ); } else { $class = __NAMESPACE__ .'\DeferredExceptionsException'; } } return $class; }
[ "protected", "function", "getCompatibleClass", "(", "$", "className", ")", "{", "if", "(", "!", "$", "className", "||", "!", "is_string", "(", "$", "className", ")", ")", "{", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "}", "$", ...
Returns the class to throw exception @param string $className The desired class to use @return string
[ "Returns", "the", "class", "to", "throw", "exception" ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L136-L156
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.exception
public function exception( $message, $code = 0, $prevException = null, $className = null) { $class = $this->getCompatibleClass( $className ); $this->defExcLastErrorMessage = $message; $this->defExcLastError = $code; $exception = [ 'time' => microtime( true ), 'class' => $class, 'code' => $code, 'message' => $message, ]; $this->defExcErrors [] = $exception; DeferredExceptionsGlobal::$defExcErrorsGlobal [] = $exception; if( $this->useExceptions() ){ throw new $class( $message, $code, $prevException); } }
php
public function exception( $message, $code = 0, $prevException = null, $className = null) { $class = $this->getCompatibleClass( $className ); $this->defExcLastErrorMessage = $message; $this->defExcLastError = $code; $exception = [ 'time' => microtime( true ), 'class' => $class, 'code' => $code, 'message' => $message, ]; $this->defExcErrors [] = $exception; DeferredExceptionsGlobal::$defExcErrorsGlobal [] = $exception; if( $this->useExceptions() ){ throw new $class( $message, $code, $prevException); } }
[ "public", "function", "exception", "(", "$", "message", ",", "$", "code", "=", "0", ",", "$", "prevException", "=", "null", ",", "$", "className", "=", "null", ")", "{", "$", "class", "=", "$", "this", "->", "getCompatibleClass", "(", "$", "className",...
Throws the Exception or save last error @param string $message Exception error message. @param int $code Exception error code. Default 0. @param \Exception $prevException Previous exception. Default NULL. @param string $className Name of exception source class. Default NULL. @throws mixed
[ "Throws", "the", "Exception", "or", "save", "last", "error" ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L168-L187
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.__formatMessage
protected static function __formatMessage( array $error, $template = null ) { static $patterns = [ '~\:\:time~us', '~\:\:microtime~us', '~\:\:class~us', '~\:\:code~us', '~\:\:message~us', ]; if( empty( $error ['time'] )) $error ['time'] = microtime( true ); if( empty( $error ['class'] )) $error ['class'] = __NAMESPACE__ .'\DeferredExceptionsException'; if( empty( $error ['code'] )) $error ['code'] = 0; if( empty( $error ['message'] )) $error ['message'] = ''; $time= []; preg_match('~(\d*)(\.(\d{0,6}))?~', $error ['time'], $time); $sec = (int) $time [1]; $usec = sprintf( '%0-6s', isset( $time [3]) ? (int) $time [3] : 0); $replaces = [ date('Y-m-d H:i:s', $sec), date('Y-m-d H:i:s', $sec) . ':' . $usec, $error ['class'], $error ['code'], $error ['message'], ]; return preg_replace( $patterns, $replaces, ! empty( $template ) && is_string( $template ) ? $template : DeferredExceptionsGlobal::$defExcDefaultErrorListTemplate ); }
php
protected static function __formatMessage( array $error, $template = null ) { static $patterns = [ '~\:\:time~us', '~\:\:microtime~us', '~\:\:class~us', '~\:\:code~us', '~\:\:message~us', ]; if( empty( $error ['time'] )) $error ['time'] = microtime( true ); if( empty( $error ['class'] )) $error ['class'] = __NAMESPACE__ .'\DeferredExceptionsException'; if( empty( $error ['code'] )) $error ['code'] = 0; if( empty( $error ['message'] )) $error ['message'] = ''; $time= []; preg_match('~(\d*)(\.(\d{0,6}))?~', $error ['time'], $time); $sec = (int) $time [1]; $usec = sprintf( '%0-6s', isset( $time [3]) ? (int) $time [3] : 0); $replaces = [ date('Y-m-d H:i:s', $sec), date('Y-m-d H:i:s', $sec) . ':' . $usec, $error ['class'], $error ['code'], $error ['message'], ]; return preg_replace( $patterns, $replaces, ! empty( $template ) && is_string( $template ) ? $template : DeferredExceptionsGlobal::$defExcDefaultErrorListTemplate ); }
[ "protected", "static", "function", "__formatMessage", "(", "array", "$", "error", ",", "$", "template", "=", "null", ")", "{", "static", "$", "patterns", "=", "[", "'~\\:\\:time~us'", ",", "'~\\:\\:microtime~us'", ",", "'~\\:\\:class~us'", ",", "'~\\:\\:code~us'",...
Format message string for output. @staticvar array $patterns @param array $error Source error @param string $template Template @return string
[ "Format", "message", "string", "for", "output", "." ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L198-L230
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.throwAll
public function throwAll( $releaseOnThrow = true, $template = null) { return $this->__throw( false, $releaseOnThrow, $template); }
php
public function throwAll( $releaseOnThrow = true, $template = null) { return $this->__throw( false, $releaseOnThrow, $template); }
[ "public", "function", "throwAll", "(", "$", "releaseOnThrow", "=", "true", ",", "$", "template", "=", "null", ")", "{", "return", "$", "this", "->", "__throw", "(", "false", ",", "$", "releaseOnThrow", ",", "$", "template", ")", ";", "}" ]
Throws exception with a list of all deferred exceptions of a class instance. @param boolean $releaseOnThrow Release a thrown exceptions. Default TRUE. @param string $template <pre>Template for error list item with fields: ::time - time of exception ::microtime - time of exception with microseconds ::class - Class of exception ::code - exception code ::message - error message </pre> <b>Example</b> "::microtime Exception: `::class`, code: #::code, message: ::message" @return boolean The stack of an exceptions is not empty @throws Seotils\Traits\DeferredExceptionsException @throws mixed Other deferred exceptions classes
[ "Throws", "exception", "with", "a", "list", "of", "all", "deferred", "exceptions", "of", "a", "class", "instance", "." ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L284-L286
train
seotils/deferred-exceptions
src/DeferredExceptions.php
DeferredExceptions.throwGlobal
public static function throwGlobal( $releaseOnThrow = false, $template = null ) { if( ! empty( DeferredExceptionsGlobal::$defExcErrorsGlobal )) { $message = "There are the following exceptions:\n"; foreach( DeferredExceptionsGlobal::$defExcErrorsGlobal as $error) { $message .= self::__formatMessage( $error, $template ) . "\n"; } if( $releaseOnThrow ){ DeferredExceptionsGlobal::$defExcErrorsGlobal = []; } $result = count( DeferredExceptionsGlobal::$defExcErrorsGlobal ); throw new DeferredExceptionsException( $message ); } return false; }
php
public static function throwGlobal( $releaseOnThrow = false, $template = null ) { if( ! empty( DeferredExceptionsGlobal::$defExcErrorsGlobal )) { $message = "There are the following exceptions:\n"; foreach( DeferredExceptionsGlobal::$defExcErrorsGlobal as $error) { $message .= self::__formatMessage( $error, $template ) . "\n"; } if( $releaseOnThrow ){ DeferredExceptionsGlobal::$defExcErrorsGlobal = []; } $result = count( DeferredExceptionsGlobal::$defExcErrorsGlobal ); throw new DeferredExceptionsException( $message ); } return false; }
[ "public", "static", "function", "throwGlobal", "(", "$", "releaseOnThrow", "=", "false", ",", "$", "template", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "DeferredExceptionsGlobal", "::", "$", "defExcErrorsGlobal", ")", ")", "{", "$", "message", ...
Throws all deferred exceptions of all derived classes. @param boolean $releaseOnThrow Release a thrown exceptions. Default FALSE. @param string $template <pre>Template for error list item with fields: ::time - time of exception ::microtime - time of exception with microseconds ::class - Class of exception ::code - exception code ::message - error message </pre> <b>Example</b> "::microtime Exception: `::class`, code: #::code, message: ::message" @return boolean The global stack of an exceptions is not empty @throws Seotils\Traits\DeferredExceptionsException
[ "Throws", "all", "deferred", "exceptions", "of", "all", "derived", "classes", "." ]
305c1f037743361f06b03570a2e4b2842079c5a3
https://github.com/seotils/deferred-exceptions/blob/305c1f037743361f06b03570a2e4b2842079c5a3/src/DeferredExceptions.php#L396-L409
train
fabsgc/framework
Core/Lang/Lang.php
Lang.lang
public function lang($name, $vars = [], $template = self::USE_NOT_TPL) { $request = Request::instance(); $config = $this->resolve(RESOLVE_LANG, $name); $name = $config[1]; $config = $config[0]; if (isset($config[$request->lang][$name])) { if ($template == self::USE_NOT_TPL) { if (count($vars) == 0) { return $config[$request->lang][$name]; } else { $content = $config[$request->lang][$name]; foreach ($vars as $key => $value) { $content = preg_replace('#\{' . $key . '\}#isU', $value, $content); } return $content; } } else { $tpl = new Template($config[$request->lang][$name], $name, 0, Template::TPL_STRING); $tpl->assign($vars); return $tpl->show(Template::TPL_COMPILE_TO_STRING, Template::TPL_COMPILE_LANG); } } else { $this->addError('sentence ' . $name . '/' . $request->lang . ' not found', __FILE__, __LINE__, ERROR_WARNING); return 'sentence not found (' . $name . ',' . $request->lang . ')'; } }
php
public function lang($name, $vars = [], $template = self::USE_NOT_TPL) { $request = Request::instance(); $config = $this->resolve(RESOLVE_LANG, $name); $name = $config[1]; $config = $config[0]; if (isset($config[$request->lang][$name])) { if ($template == self::USE_NOT_TPL) { if (count($vars) == 0) { return $config[$request->lang][$name]; } else { $content = $config[$request->lang][$name]; foreach ($vars as $key => $value) { $content = preg_replace('#\{' . $key . '\}#isU', $value, $content); } return $content; } } else { $tpl = new Template($config[$request->lang][$name], $name, 0, Template::TPL_STRING); $tpl->assign($vars); return $tpl->show(Template::TPL_COMPILE_TO_STRING, Template::TPL_COMPILE_LANG); } } else { $this->addError('sentence ' . $name . '/' . $request->lang . ' not found', __FILE__, __LINE__, ERROR_WARNING); return 'sentence not found (' . $name . ',' . $request->lang . ')'; } }
[ "public", "function", "lang", "(", "$", "name", ",", "$", "vars", "=", "[", "]", ",", "$", "template", "=", "self", "::", "USE_NOT_TPL", ")", "{", "$", "request", "=", "Request", "::", "instance", "(", ")", ";", "$", "config", "=", "$", "this", "...
load a sentence from config instance @access public @param $name string : name of the sentence @param $vars array : vars @param $template bool|int : use template syntax or not @return string @since 3.0 @package Gcs\Framework\Core\Lang
[ "load", "a", "sentence", "from", "config", "instance" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Lang/Lang.php#L65-L98
train
alxmsl/Network
source/Http/Request.php
Request.send
public function send() { if (is_null($this->Transport)) { throw new TransportException(); } $this->Transport->setRequest($this); return $this->Transport->makeHttpRequest($this); }
php
public function send() { if (is_null($this->Transport)) { throw new TransportException(); } $this->Transport->setRequest($this); return $this->Transport->makeHttpRequest($this); }
[ "public", "function", "send", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "Transport", ")", ")", "{", "throw", "new", "TransportException", "(", ")", ";", "}", "$", "this", "->", "Transport", "->", "setRequest", "(", "$", "this", ")"...
Send request data method @return string request execution result @throws TransportException in case of undefined Transport
[ "Send", "request", "data", "method" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/Request.php#L104-L110
train
alxmsl/Network
source/Http/Request.php
Request.setMethod
public function setMethod($method) { $method = (int) $method; switch ($this->method) { case self::METHOD_AUTO: case self::METHOD_GET: case self::METHOD_POST: $this->method = $method; break; default: throw new InvalidArgumentException(); } }
php
public function setMethod($method) { $method = (int) $method; switch ($this->method) { case self::METHOD_AUTO: case self::METHOD_GET: case self::METHOD_POST: $this->method = $method; break; default: throw new InvalidArgumentException(); } }
[ "public", "function", "setMethod", "(", "$", "method", ")", "{", "$", "method", "=", "(", "int", ")", "$", "method", ";", "switch", "(", "$", "this", "->", "method", ")", "{", "case", "self", "::", "METHOD_AUTO", ":", "case", "self", "::", "METHOD_GE...
Setter for request method @param int $method method type code @throws InvalidArgumentException
[ "Setter", "for", "request", "method" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/Request.php#L152-L163
train
alxmsl/Network
source/Http/Request.php
Request.addPostField
public function addPostField($field, $value) { if (is_null($this->postData)) { $this->postData = array(); } if (is_array($this->postData)) { $this->postData[$field] = (string) $value; return $this; } else { throw new LogicException('cannot set field for non array'); } }
php
public function addPostField($field, $value) { if (is_null($this->postData)) { $this->postData = array(); } if (is_array($this->postData)) { $this->postData[$field] = (string) $value; return $this; } else { throw new LogicException('cannot set field for non array'); } }
[ "public", "function", "addPostField", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "postData", ")", ")", "{", "$", "this", "->", "postData", "=", "array", "(", ")", ";", "}", "if", "(", "is_array", ...
Add POST parameter @param string $field parameter name @param string $value parameter value @throw LogicException if post data is not array @return Request self
[ "Add", "POST", "parameter" ]
5c5b058572885303ff44f310bc7bedad683ca8c1
https://github.com/alxmsl/Network/blob/5c5b058572885303ff44f310bc7bedad683ca8c1/source/Http/Request.php#L221-L232
train
PaymentSuite/PaymillBundle
Controller/PaymillController.php
PaymillController.createPaymillMethod
private function createPaymillMethod(array $data) { $paymentMethod = new PaymillMethod(); $paymentMethod ->setApiToken($data['api_token']) ->setCreditCardNumber($data['credit_card_1'] . $data['credit_card_2'] . $data['credit_card_3'] . $data['credit_card_4']) ->setCreditCardOwner($data['credit_card_owner']) ->setCreditCardExpirationMonth($data['credit_card_expiration_month']) ->setCreditCardExpirationYear($data['credit_card_expiration_year']) ->setCreditCardSecurity($data['credit_card_security']); return $paymentMethod; }
php
private function createPaymillMethod(array $data) { $paymentMethod = new PaymillMethod(); $paymentMethod ->setApiToken($data['api_token']) ->setCreditCardNumber($data['credit_card_1'] . $data['credit_card_2'] . $data['credit_card_3'] . $data['credit_card_4']) ->setCreditCardOwner($data['credit_card_owner']) ->setCreditCardExpirationMonth($data['credit_card_expiration_month']) ->setCreditCardExpirationYear($data['credit_card_expiration_year']) ->setCreditCardSecurity($data['credit_card_security']); return $paymentMethod; }
[ "private", "function", "createPaymillMethod", "(", "array", "$", "data", ")", "{", "$", "paymentMethod", "=", "new", "PaymillMethod", "(", ")", ";", "$", "paymentMethod", "->", "setApiToken", "(", "$", "data", "[", "'api_token'", "]", ")", "->", "setCreditCa...
Given some data, creates a PaymillMethod object @param array $data Data @return PaymillMethod PaymillMethod instance
[ "Given", "some", "data", "creates", "a", "PaymillMethod", "object" ]
78aa85daaab8cf08e4971b10d86abd429ac7f6cd
https://github.com/PaymentSuite/PaymillBundle/blob/78aa85daaab8cf08e4971b10d86abd429ac7f6cd/Controller/PaymillController.php#L90-L102
train
vinala/kernel
src/Caches/Cache.php
Cache.driver
private static function driver() { $options = config('cache.options'); $driver = config('cache.default'); switch ($driver) { case 'file': return instance(FileDriver::class); break; case 'apc': return instance(ApcDriver::class); break; case 'database': return instance(PDODriver::class); break; default: exception(DriverNotFoundException::class); break; } }
php
private static function driver() { $options = config('cache.options'); $driver = config('cache.default'); switch ($driver) { case 'file': return instance(FileDriver::class); break; case 'apc': return instance(ApcDriver::class); break; case 'database': return instance(PDODriver::class); break; default: exception(DriverNotFoundException::class); break; } }
[ "private", "static", "function", "driver", "(", ")", "{", "$", "options", "=", "config", "(", "'cache.options'", ")", ";", "$", "driver", "=", "config", "(", "'cache.default'", ")", ";", "switch", "(", "$", "driver", ")", "{", "case", "'file'", ":", "r...
Set the cache surface driver. @return Driver
[ "Set", "the", "cache", "surface", "driver", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Cache.php#L30-L53
train
vinala/kernel
src/Caches/Cache.php
Cache.put
public static function put($name, $value, $lifetime) { return self::driver()->put($name, $value, $lifetime); }
php
public static function put($name, $value, $lifetime) { return self::driver()->put($name, $value, $lifetime); }
[ "public", "static", "function", "put", "(", "$", "name", ",", "$", "value", ",", "$", "lifetime", ")", "{", "return", "self", "::", "driver", "(", ")", "->", "put", "(", "$", "name", ",", "$", "value", ",", "$", "lifetime", ")", ";", "}" ]
Set an cache item to cache data. @param string $name @param mixed $value @param int $lifetime @return null
[ "Set", "an", "cache", "item", "to", "cache", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Caches/Cache.php#L64-L67
train
nhagemann/anycontent-client-php
src/AnyContent/Connection/AbstractConnection.php
AbstractConnection.exportRecord
protected function exportRecord(AbstractRecord $record, DataDimensions $dataDimensions) { $precalculate = $this->precalculateExportRecord($record, $dataDimensions); $allowedProperties = array_intersect_key($record->getProperties(), $precalculate['allowedProperties']); $record = clone $record; $record->setProperties($allowedProperties); return $record; }
php
protected function exportRecord(AbstractRecord $record, DataDimensions $dataDimensions) { $precalculate = $this->precalculateExportRecord($record, $dataDimensions); $allowedProperties = array_intersect_key($record->getProperties(), $precalculate['allowedProperties']); $record = clone $record; $record->setProperties($allowedProperties); return $record; }
[ "protected", "function", "exportRecord", "(", "AbstractRecord", "$", "record", ",", "DataDimensions", "$", "dataDimensions", ")", "{", "$", "precalculate", "=", "$", "this", "->", "precalculateExportRecord", "(", "$", "record", ",", "$", "dataDimensions", ")", "...
Make sure the returned record is a new instance an does only contain properties of it's current view @param AbstractRecord $record - multi view record !
[ "Make", "sure", "the", "returned", "record", "is", "a", "new", "instance", "an", "does", "only", "contain", "properties", "of", "it", "s", "current", "view" ]
7120f91197fda5a98de6d2917c5e312bd67546c0
https://github.com/nhagemann/anycontent-client-php/blob/7120f91197fda5a98de6d2917c5e312bd67546c0/src/AnyContent/Connection/AbstractConnection.php#L778-L786
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.use_view
public function use_view($view) { $views = call_user_func(array($this->model, 'views')); if ( ! array_key_exists($view, $views)) { throw new \OutOfBoundsException('Cannot use undefined database view, must be defined with Model.'); } $this->view = $views[$view]; $this->view['_name'] = $view; return $this; }
php
public function use_view($view) { $views = call_user_func(array($this->model, 'views')); if ( ! array_key_exists($view, $views)) { throw new \OutOfBoundsException('Cannot use undefined database view, must be defined with Model.'); } $this->view = $views[$view]; $this->view['_name'] = $view; return $this; }
[ "public", "function", "use_view", "(", "$", "view", ")", "{", "$", "views", "=", "call_user_func", "(", "array", "(", "$", "this", "->", "model", ",", "'views'", ")", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "view", ",", "$", "views", ...
Set a view to use instead of the table @param string $view Name of view which you want to use @throws \OutOfBoundsException Cannot use undefined database view, must be defined with Model @return Query
[ "Set", "a", "view", "to", "use", "instead", "of", "the", "table" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L325-L336
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.or_where
public function or_where() { $condition = func_get_args(); is_array(reset($condition)) and $condition = reset($condition); return $this->_where($condition, 'or_where'); }
php
public function or_where() { $condition = func_get_args(); is_array(reset($condition)) and $condition = reset($condition); return $this->_where($condition, 'or_where'); }
[ "public", "function", "or_where", "(", ")", "{", "$", "condition", "=", "func_get_args", "(", ")", ";", "is_array", "(", "reset", "(", "$", "condition", ")", ")", "and", "$", "condition", "=", "reset", "(", "$", "condition", ")", ";", "return", "$", ...
Set or_where condition @param string Property @param string Comparison type (can be omitted) @param string Comparison value @return $this
[ "Set", "or_where", "condition" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L435-L441
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query._parse_where_array
protected function _parse_where_array(array $val, $base = '', $or = false) { $or and $this->or_where_open(); foreach ($val as $k_w => $v_w) { if (is_array($v_w) and ! empty($v_w[0]) and is_string($v_w[0])) { ! $v_w[0] instanceof \Database_Expression and strpos($v_w[0], '.') === false and $v_w[0] = $base.$v_w[0]; call_fuel_func_array(array($this, ($k_w === 'or' ? 'or_' : '').'where'), $v_w); } elseif (is_int($k_w) or $k_w == 'or') { $k_w === 'or' ? $this->or_where_open() : $this->where_open(); $this->_parse_where_array($v_w, $base, $k_w === 'or'); $k_w === 'or' ? $this->or_where_close() : $this->where_close(); } else { ! $k_w instanceof \Database_Expression and strpos($k_w, '.') === false and $k_w = $base.$k_w; $this->where($k_w, $v_w); } } $or and $this->or_where_close(); }
php
protected function _parse_where_array(array $val, $base = '', $or = false) { $or and $this->or_where_open(); foreach ($val as $k_w => $v_w) { if (is_array($v_w) and ! empty($v_w[0]) and is_string($v_w[0])) { ! $v_w[0] instanceof \Database_Expression and strpos($v_w[0], '.') === false and $v_w[0] = $base.$v_w[0]; call_fuel_func_array(array($this, ($k_w === 'or' ? 'or_' : '').'where'), $v_w); } elseif (is_int($k_w) or $k_w == 'or') { $k_w === 'or' ? $this->or_where_open() : $this->where_open(); $this->_parse_where_array($v_w, $base, $k_w === 'or'); $k_w === 'or' ? $this->or_where_close() : $this->where_close(); } else { ! $k_w instanceof \Database_Expression and strpos($k_w, '.') === false and $k_w = $base.$k_w; $this->where($k_w, $v_w); } } $or and $this->or_where_close(); }
[ "protected", "function", "_parse_where_array", "(", "array", "$", "val", ",", "$", "base", "=", "''", ",", "$", "or", "=", "false", ")", "{", "$", "or", "and", "$", "this", "->", "or_where_open", "(", ")", ";", "foreach", "(", "$", "val", "as", "$"...
Parses an array of where conditions into the query @param array $val @param string $base @param bool $or
[ "Parses", "an", "array", "of", "where", "conditions", "into", "the", "query" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L566-L589
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.order_by
public function order_by($property, $direction = 'ASC') { if (is_array($property)) { foreach ($property as $p => $d) { if (is_int($p)) { is_array($d) ? $this->order_by($d[0], $d[1]) : $this->order_by($d, $direction); } else { $this->order_by($p, $d); } } return $this; } // prefix table alias when not yet prefixed and not a DB expression object if ( ! $property instanceof \Fuel\Core\Database_Expression and strpos($property, '.') === false) { $property = $this->alias.'.'.$property; } $this->order_by[] = array($property, $direction); return $this; }
php
public function order_by($property, $direction = 'ASC') { if (is_array($property)) { foreach ($property as $p => $d) { if (is_int($p)) { is_array($d) ? $this->order_by($d[0], $d[1]) : $this->order_by($d, $direction); } else { $this->order_by($p, $d); } } return $this; } // prefix table alias when not yet prefixed and not a DB expression object if ( ! $property instanceof \Fuel\Core\Database_Expression and strpos($property, '.') === false) { $property = $this->alias.'.'.$property; } $this->order_by[] = array($property, $direction); return $this; }
[ "public", "function", "order_by", "(", "$", "property", ",", "$", "direction", "=", "'ASC'", ")", "{", "if", "(", "is_array", "(", "$", "property", ")", ")", "{", "foreach", "(", "$", "property", "as", "$", "p", "=>", "$", "d", ")", "{", "if", "(...
Set the order_by @param string|array $property @param string $direction @return $this
[ "Set", "the", "order_by" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L599-L626
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.related
public function related($relation, $conditions = array()) { if (is_array($relation)) { foreach ($relation as $k_r => $v_r) { is_array($v_r) ? $this->related($k_r, $v_r) : $this->related($v_r); } return $this; } if (strpos($relation, '.')) { $rels = explode('.', $relation); $model = $this->model; foreach ($rels as $r) { $rel = call_user_func(array($model, 'relations'), $r); if (empty($rel)) { throw new \UnexpectedValueException('Relation "'.$r.'" was not found in the model "'.$model.'".'); } $model = $rel->model_to; } } else { $rel = call_user_func(array($this->model, 'relations'), $relation); if (empty($rel)) { throw new \UnexpectedValueException('Relation "'.$relation.'" was not found in the model.'); } } $this->relations[$relation] = array($rel, $conditions); if ( ! empty($conditions['related'])) { $conditions['related'] = (array) $conditions['related']; foreach ($conditions['related'] as $k_r => $v_r) { is_array($v_r) ? $this->related($relation.'.'.$k_r, $v_r) : $this->related($relation.'.'.$v_r); } unset($conditions['related']); } return $this; }
php
public function related($relation, $conditions = array()) { if (is_array($relation)) { foreach ($relation as $k_r => $v_r) { is_array($v_r) ? $this->related($k_r, $v_r) : $this->related($v_r); } return $this; } if (strpos($relation, '.')) { $rels = explode('.', $relation); $model = $this->model; foreach ($rels as $r) { $rel = call_user_func(array($model, 'relations'), $r); if (empty($rel)) { throw new \UnexpectedValueException('Relation "'.$r.'" was not found in the model "'.$model.'".'); } $model = $rel->model_to; } } else { $rel = call_user_func(array($this->model, 'relations'), $relation); if (empty($rel)) { throw new \UnexpectedValueException('Relation "'.$relation.'" was not found in the model.'); } } $this->relations[$relation] = array($rel, $conditions); if ( ! empty($conditions['related'])) { $conditions['related'] = (array) $conditions['related']; foreach ($conditions['related'] as $k_r => $v_r) { is_array($v_r) ? $this->related($relation.'.'.$k_r, $v_r) : $this->related($relation.'.'.$v_r); } unset($conditions['related']); } return $this; }
[ "public", "function", "related", "(", "$", "relation", ",", "$", "conditions", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "relation", ")", ")", "{", "foreach", "(", "$", "relation", "as", "$", "k_r", "=>", "$", "v_r", ")", ...
Set a relation to include @param string $relation @param array $conditions Optionally @throws \UnexpectedValueException Relation was not found in the model @return $this
[ "Set", "a", "relation", "to", "include" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L638-L686
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.set
public function set($property, $value = null) { if (is_array($property)) { foreach ($property as $p => $v) { $this->set($p, $v); } return $this; } $this->values[$property] = $value; return $this; }
php
public function set($property, $value = null) { if (is_array($property)) { foreach ($property as $p => $v) { $this->set($p, $v); } return $this; } $this->values[$property] = $value; return $this; }
[ "public", "function", "set", "(", "$", "property", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "property", ")", ")", "{", "foreach", "(", "$", "property", "as", "$", "p", "=>", "$", "v", ")", "{", "$", "this", "->...
Set any properties for insert or update @param string|array $property @param mixed $value Optionally @return $this
[ "Set", "any", "properties", "for", "insert", "or", "update" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L710-L724
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.get
public function get() { // Get the columns $columns = $this->select(); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); // Set from view/table $query->from(array($this->_table(), $this->alias)); // Build the query further $tmp = $this->build_query($query, $columns); $query = $tmp['query']; $models = $tmp['models']; // Make models hierarchical foreach ($models as $name => $values) { if (strpos($name, '.')) { unset($models[$name]); $rels = explode('.', $name); $ref =& $models[array_shift($rels)]; foreach ($rels as $rel) { empty($ref['models']) and $ref['models'] = array(); empty($ref['models'][$rel]) and $ref['models'][$rel] = array(); $ref =& $ref['models'][$rel]; } $ref = $values; } } $rows = $query->execute($this->connection)->as_array(); $result = array(); $model = $this->model; $select = $this->select(); $primary_key = $model::primary_key(); foreach ($rows as $id => $row) { $this->hydrate($row, $models, $result, $model, $select, $primary_key); unset($rows[$id]); } // It's all built, now lets execute and start hydration return $result; }
php
public function get() { // Get the columns $columns = $this->select(); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); // Set from view/table $query->from(array($this->_table(), $this->alias)); // Build the query further $tmp = $this->build_query($query, $columns); $query = $tmp['query']; $models = $tmp['models']; // Make models hierarchical foreach ($models as $name => $values) { if (strpos($name, '.')) { unset($models[$name]); $rels = explode('.', $name); $ref =& $models[array_shift($rels)]; foreach ($rels as $rel) { empty($ref['models']) and $ref['models'] = array(); empty($ref['models'][$rel]) and $ref['models'][$rel] = array(); $ref =& $ref['models'][$rel]; } $ref = $values; } } $rows = $query->execute($this->connection)->as_array(); $result = array(); $model = $this->model; $select = $this->select(); $primary_key = $model::primary_key(); foreach ($rows as $id => $row) { $this->hydrate($row, $models, $result, $model, $select, $primary_key); unset($rows[$id]); } // It's all built, now lets execute and start hydration return $result; }
[ "public", "function", "get", "(", ")", "{", "// Get the columns", "$", "columns", "=", "$", "this", "->", "select", "(", ")", ";", "// Start building the query", "$", "select", "=", "$", "columns", ";", "if", "(", "$", "this", "->", "use_subquery", "(", ...
Build the query and return hydrated results @return array
[ "Build", "the", "query", "and", "return", "hydrated", "results" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1184-L1241
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.get_query
public function get_query() { // Get the columns $columns = $this->select(false); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); // Set the defined connection on the query $query->set_connection($this->connection); // Set from table $query->from(array($this->_table(), $this->alias)); // Build the query further $tmp = $this->build_query($query, $columns); return $tmp['query']; }
php
public function get_query() { // Get the columns $columns = $this->select(false); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); // Set the defined connection on the query $query->set_connection($this->connection); // Set from table $query->from(array($this->_table(), $this->alias)); // Build the query further $tmp = $this->build_query($query, $columns); return $tmp['query']; }
[ "public", "function", "get_query", "(", ")", "{", "// Get the columns", "$", "columns", "=", "$", "this", "->", "select", "(", "false", ")", ";", "// Start building the query", "$", "select", "=", "$", "columns", ";", "if", "(", "$", "this", "->", "use_sub...
Get the Query as it's been build up to this point and return it as an object @return Database_Query
[ "Get", "the", "Query", "as", "it", "s", "been", "build", "up", "to", "this", "point", "and", "return", "it", "as", "an", "object" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1248-L1275
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.get_one
public function get_one() { // save the current limits $limit = $this->limit; $rows_limit = $this->rows_limit; if ($this->rows_limit !== null) { $this->limit = null; $this->rows_limit = 1; } else { $this->limit = 1; $this->rows_limit = null; } // get the result using normal find $result = $this->get(); // put back the old limits $this->limit = $limit; $this->rows_limit = $rows_limit; return $result ? reset($result) : null; }
php
public function get_one() { // save the current limits $limit = $this->limit; $rows_limit = $this->rows_limit; if ($this->rows_limit !== null) { $this->limit = null; $this->rows_limit = 1; } else { $this->limit = 1; $this->rows_limit = null; } // get the result using normal find $result = $this->get(); // put back the old limits $this->limit = $limit; $this->rows_limit = $rows_limit; return $result ? reset($result) : null; }
[ "public", "function", "get_one", "(", ")", "{", "// save the current limits", "$", "limit", "=", "$", "this", "->", "limit", ";", "$", "rows_limit", "=", "$", "this", "->", "rows_limit", ";", "if", "(", "$", "this", "->", "rows_limit", "!==", "null", ")"...
Build the query and return single object hydrated @return Model
[ "Build", "the", "query", "and", "return", "single", "object", "hydrated" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1282-L1307
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.count
public function count($column = null, $distinct = true) { $select = $column ?: \Arr::get(call_user_func($this->model.'::primary_key'), 0); $select = (strpos($select, '.') === false ? $this->alias.'.'.$select : $select); // Get the columns $columns = \DB::expr('COUNT('.($distinct ? 'DISTINCT ' : ''). \Database_Connection::instance($this->connection)->quote_identifier($select). ') AS count_result'); // Remove the current select and $query = \DB::select($columns); // Set from view or table $query->from(array($this->_table(), $this->alias)); $tmp = $this->build_query($query, $columns, 'select'); $query = $tmp['query']; $count = $query->execute($this->connection)->get('count_result'); // Database_Result::get('count_result') returns a string | null if ($count === null) { return false; } return (int) $count; }
php
public function count($column = null, $distinct = true) { $select = $column ?: \Arr::get(call_user_func($this->model.'::primary_key'), 0); $select = (strpos($select, '.') === false ? $this->alias.'.'.$select : $select); // Get the columns $columns = \DB::expr('COUNT('.($distinct ? 'DISTINCT ' : ''). \Database_Connection::instance($this->connection)->quote_identifier($select). ') AS count_result'); // Remove the current select and $query = \DB::select($columns); // Set from view or table $query->from(array($this->_table(), $this->alias)); $tmp = $this->build_query($query, $columns, 'select'); $query = $tmp['query']; $count = $query->execute($this->connection)->get('count_result'); // Database_Result::get('count_result') returns a string | null if ($count === null) { return false; } return (int) $count; }
[ "public", "function", "count", "(", "$", "column", "=", "null", ",", "$", "distinct", "=", "true", ")", "{", "$", "select", "=", "$", "column", "?", ":", "\\", "Arr", "::", "get", "(", "call_user_func", "(", "$", "this", "->", "model", ".", "'::pri...
Count the result of a query @param bool $column False for random selected column or specific column, only works for main model currently @param bool $distinct True if DISTINCT has to be aded to the query @return mixed number of rows OR false
[ "Count", "the", "result", "of", "a", "query" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1317-L1344
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.max
public function max($column) { is_array($column) and $column = array_shift($column); // Get the columns $columns = \DB::expr('MAX('. \Database_Connection::instance($this->connection)->quote_identifier($this->alias.'.'.$column). ') AS max_result'); // Remove the current select and $query = \DB::select($columns); // Set from table $query->from(array($this->_table(), $this->alias)); $tmp = $this->build_query($query, $columns, 'max'); $query = $tmp['query']; $max = $query->execute($this->connection)->get('max_result'); // Database_Result::get('max_result') returns a string | null if ($max === null) { return false; } return $max; }
php
public function max($column) { is_array($column) and $column = array_shift($column); // Get the columns $columns = \DB::expr('MAX('. \Database_Connection::instance($this->connection)->quote_identifier($this->alias.'.'.$column). ') AS max_result'); // Remove the current select and $query = \DB::select($columns); // Set from table $query->from(array($this->_table(), $this->alias)); $tmp = $this->build_query($query, $columns, 'max'); $query = $tmp['query']; $max = $query->execute($this->connection)->get('max_result'); // Database_Result::get('max_result') returns a string | null if ($max === null) { return false; } return $max; }
[ "public", "function", "max", "(", "$", "column", ")", "{", "is_array", "(", "$", "column", ")", "and", "$", "column", "=", "array_shift", "(", "$", "column", ")", ";", "// Get the columns", "$", "columns", "=", "\\", "DB", "::", "expr", "(", "'MAX('", ...
Get the maximum of a column for the current query @param string $column Column @return bool|int maximum value OR false
[ "Get", "the", "maximum", "of", "a", "column", "for", "the", "current", "query" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1352-L1378
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.insert
public function insert() { $res = \DB::insert(call_user_func($this->model.'::table'), array_keys($this->values)) ->values(array_values($this->values)) ->execute($this->write_connection); // Failed to save the new record if ($res[1] === 0) { return false; } return $res[0]; }
php
public function insert() { $res = \DB::insert(call_user_func($this->model.'::table'), array_keys($this->values)) ->values(array_values($this->values)) ->execute($this->write_connection); // Failed to save the new record if ($res[1] === 0) { return false; } return $res[0]; }
[ "public", "function", "insert", "(", ")", "{", "$", "res", "=", "\\", "DB", "::", "insert", "(", "call_user_func", "(", "$", "this", "->", "model", ".", "'::table'", ")", ",", "array_keys", "(", "$", "this", "->", "values", ")", ")", "->", "values", ...
Run INSERT with the current values @return bool|int Last inserted ID (if present) or false on failure
[ "Run", "INSERT", "with", "the", "current", "values" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1420-L1433
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.update
public function update() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::update(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'update'); $query = $tmp['query']; $res = $query->set($this->values)->execute($this->write_connection); // put back any relations settings $this->relations = $tmp_relations; // Update can affect 0 rows when input types are different but outcome stays the same return $res >= 0; }
php
public function update() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::update(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'update'); $query = $tmp['query']; $res = $query->set($this->values)->execute($this->write_connection); // put back any relations settings $this->relations = $tmp_relations; // Update can affect 0 rows when input types are different but outcome stays the same return $res >= 0; }
[ "public", "function", "update", "(", ")", "{", "// temporary disable relations", "$", "tmp_relations", "=", "$", "this", "->", "relations", ";", "$", "this", "->", "relations", "=", "array", "(", ")", ";", "// Build query and execute update", "$", "query", "=", ...
Run UPDATE with the current values @return bool success of update operation
[ "Run", "UPDATE", "with", "the", "current", "values" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1440-L1457
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/query.php
Query.delete
public function delete() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::delete(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'delete'); $query = $tmp['query']; $res = $query->execute($this->write_connection); // put back any relations settings $this->relations = $tmp_relations; return $res > 0; }
php
public function delete() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::delete(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'delete'); $query = $tmp['query']; $res = $query->execute($this->write_connection); // put back any relations settings $this->relations = $tmp_relations; return $res > 0; }
[ "public", "function", "delete", "(", ")", "{", "// temporary disable relations", "$", "tmp_relations", "=", "$", "this", "->", "relations", ";", "$", "this", "->", "relations", "=", "array", "(", ")", ";", "// Build query and execute update", "$", "query", "=", ...
Run DELETE with the current values @return bool success of delete operation
[ "Run", "DELETE", "with", "the", "current", "values" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/query.php#L1464-L1480
train
zoopcommerce/shard
lib/Zoop/Shard/Manifest.php
Manifest.createServiceManager
public static function createServiceManager(array $config = []) { $serviceManager = new ServiceManager(new Config($config)); $serviceManager->addInitializer( function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ModelManagerAwareInterface) { $instance->setModelManager($serviceLocator->get('modelmanager')); } } ); $serviceManager->addInitializer( function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceLocator); } } ); return $serviceManager; }
php
public static function createServiceManager(array $config = []) { $serviceManager = new ServiceManager(new Config($config)); $serviceManager->addInitializer( function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ModelManagerAwareInterface) { $instance->setModelManager($serviceLocator->get('modelmanager')); } } ); $serviceManager->addInitializer( function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceLocator); } } ); return $serviceManager; }
[ "public", "static", "function", "createServiceManager", "(", "array", "$", "config", "=", "[", "]", ")", "{", "$", "serviceManager", "=", "new", "ServiceManager", "(", "new", "Config", "(", "$", "config", ")", ")", ";", "$", "serviceManager", "->", "addIni...
Creates a service manager instnace @param array $config @return \Zend\ServiceManager\ServiceManager
[ "Creates", "a", "service", "manager", "instnace" ]
14dde6ff25bc3125ad35667c8ff65cb755750b27
https://github.com/zoopcommerce/shard/blob/14dde6ff25bc3125ad35667c8ff65cb755750b27/lib/Zoop/Shard/Manifest.php#L241-L262
train
koolkode/event
src/EventDispatcher.php
EventDispatcher.getListeners
public function getListeners($eventName = NULL) { if($eventName === NULL) { $listeners = []; foreach(array_keys($this->listeners) as $k) { $listeners[$k] = []; foreach(clone $this->listeners[$k] as $listener) { $listeners[$k][] = $listener; } } ksort($listeners); return $listeners; } if($eventName instanceof \ReflectionClass) { $eventName = $eventName->name; } if(empty($this->listeners[$eventName])) { return []; } $listeners = []; foreach(clone $this->listeners[$eventName] as $listener) { $listeners[] = $listener; } return $listeners; }
php
public function getListeners($eventName = NULL) { if($eventName === NULL) { $listeners = []; foreach(array_keys($this->listeners) as $k) { $listeners[$k] = []; foreach(clone $this->listeners[$k] as $listener) { $listeners[$k][] = $listener; } } ksort($listeners); return $listeners; } if($eventName instanceof \ReflectionClass) { $eventName = $eventName->name; } if(empty($this->listeners[$eventName])) { return []; } $listeners = []; foreach(clone $this->listeners[$eventName] as $listener) { $listeners[] = $listener; } return $listeners; }
[ "public", "function", "getListeners", "(", "$", "eventName", "=", "NULL", ")", "{", "if", "(", "$", "eventName", "===", "NULL", ")", "{", "$", "listeners", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "listeners", ")", "a...
Get all event listeners for the given event. @codeCoverageIgnore @param string $eventName @return array<EventListenerInterface>
[ "Get", "all", "event", "listeners", "for", "the", "given", "event", "." ]
0f823ec5aaa2df0e3e437592a4dd3a4456af7be9
https://github.com/koolkode/event/blob/0f823ec5aaa2df0e3e437592a4dd3a4456af7be9/src/EventDispatcher.php#L98-L137
train
koolkode/event
src/EventDispatcher.php
EventDispatcher.getRequiredType
protected function getRequiredType(callable $callback) { $ref = new \ReflectionFunction($callback); if($ref->getNumberOfParameters() > 0) { $params = $ref->getParameters(); if(isset($params[0]) && NULL !== ($type = $params[0]->getClass())) { return $type; } } }
php
protected function getRequiredType(callable $callback) { $ref = new \ReflectionFunction($callback); if($ref->getNumberOfParameters() > 0) { $params = $ref->getParameters(); if(isset($params[0]) && NULL !== ($type = $params[0]->getClass())) { return $type; } } }
[ "protected", "function", "getRequiredType", "(", "callable", "$", "callback", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionFunction", "(", "$", "callback", ")", ";", "if", "(", "$", "ref", "->", "getNumberOfParameters", "(", ")", ">", "0", ")", "{"...
Determines the type of the first callback argument and returns it. @param callable $callback @return string
[ "Determines", "the", "type", "of", "the", "first", "callback", "argument", "and", "returns", "it", "." ]
0f823ec5aaa2df0e3e437592a4dd3a4456af7be9
https://github.com/koolkode/event/blob/0f823ec5aaa2df0e3e437592a4dd3a4456af7be9/src/EventDispatcher.php#L365-L378
train
koolkode/event
src/EventDispatcher.php
EventDispatcher.collectListeners
protected function collectListeners($event) { $tmp = is_object($event) ? get_class($event) : (string)$event; if(isset($this->listeners[$tmp])) { $listeners = clone $this->listeners[$tmp]; } else { $listeners = new \SplPriorityQueue(); } while(false !== ($tmp = get_parent_class($tmp))) { if(isset($this->listeners[$tmp]) && !$this->listeners[$tmp]->isEmpty()) { foreach(clone $this->listeners[$tmp] as $listener) { $listeners->insert($listener, $listener->getPriority()); } } } return $listeners; }
php
protected function collectListeners($event) { $tmp = is_object($event) ? get_class($event) : (string)$event; if(isset($this->listeners[$tmp])) { $listeners = clone $this->listeners[$tmp]; } else { $listeners = new \SplPriorityQueue(); } while(false !== ($tmp = get_parent_class($tmp))) { if(isset($this->listeners[$tmp]) && !$this->listeners[$tmp]->isEmpty()) { foreach(clone $this->listeners[$tmp] as $listener) { $listeners->insert($listener, $listener->getPriority()); } } } return $listeners; }
[ "protected", "function", "collectListeners", "(", "$", "event", ")", "{", "$", "tmp", "=", "is_object", "(", "$", "event", ")", "?", "get_class", "(", "$", "event", ")", ":", "(", "string", ")", "$", "event", ";", "if", "(", "isset", "(", "$", "thi...
Collect all event listeners for the given event including inherited listeners. @param mixed $event Event object or name. @return \SplPriorityQueue
[ "Collect", "all", "event", "listeners", "for", "the", "given", "event", "including", "inherited", "listeners", "." ]
0f823ec5aaa2df0e3e437592a4dd3a4456af7be9
https://github.com/koolkode/event/blob/0f823ec5aaa2df0e3e437592a4dd3a4456af7be9/src/EventDispatcher.php#L386-L411
train
kevindierkx/elicit
src/Query/Builder.php
Builder.addNestedWhereQuery
public function addNestedWhereQuery($query) { if (count($query->wheres)) { $wheres = $this->wheres ?: []; $this->wheres = array_merge($wheres, $query->wheres); } return $this; }
php
public function addNestedWhereQuery($query) { if (count($query->wheres)) { $wheres = $this->wheres ?: []; $this->wheres = array_merge($wheres, $query->wheres); } return $this; }
[ "public", "function", "addNestedWhereQuery", "(", "$", "query", ")", "{", "if", "(", "count", "(", "$", "query", "->", "wheres", ")", ")", "{", "$", "wheres", "=", "$", "this", "->", "wheres", "?", ":", "[", "]", ";", "$", "this", "->", "wheres", ...
Merge another query builder wheres with the query builder wheres. @param \Kevindierkx\Elicit\Query\Builder|static $query @return self
[ "Merge", "another", "query", "builder", "wheres", "with", "the", "query", "builder", "wheres", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Builder.php#L214-L223
train
kevindierkx/elicit
src/Query/Builder.php
Builder.postField
public function postField($column, $value = null) { // If the column is an array, we will assume it is an array of key-value pairs // and can add them each as a post field. if (is_array($column)) { return $this->postFieldNested(function ($query) use ($column) { foreach ($column as $key => $value) { $query->postField($key, $value); } }); } $this->body[] = compact('column', 'value'); return $this; }
php
public function postField($column, $value = null) { // If the column is an array, we will assume it is an array of key-value pairs // and can add them each as a post field. if (is_array($column)) { return $this->postFieldNested(function ($query) use ($column) { foreach ($column as $key => $value) { $query->postField($key, $value); } }); } $this->body[] = compact('column', 'value'); return $this; }
[ "public", "function", "postField", "(", "$", "column", ",", "$", "value", "=", "null", ")", "{", "// If the column is an array, we will assume it is an array of key-value pairs", "// and can add them each as a post field.", "if", "(", "is_array", "(", "$", "column", ")", ...
Add a post field to the query. @param string $column @param mixed $value @return self
[ "Add", "a", "post", "field", "to", "the", "query", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Builder.php#L275-L290
train
kevindierkx/elicit
src/Query/Builder.php
Builder.postFieldNested
public function postFieldNested(Closure $callback) { // To handle nested post fields we'll actually create a brand new query instance // and pass it off to the Closure that we have. The Closure can simply do // do whatever it wants to a post field then we will store it for compiling. $query = $this->newQuery(); call_user_func($callback, $query); return $this->addNestedPostFieldQuery($query); }
php
public function postFieldNested(Closure $callback) { // To handle nested post fields we'll actually create a brand new query instance // and pass it off to the Closure that we have. The Closure can simply do // do whatever it wants to a post field then we will store it for compiling. $query = $this->newQuery(); call_user_func($callback, $query); return $this->addNestedPostFieldQuery($query); }
[ "public", "function", "postFieldNested", "(", "Closure", "$", "callback", ")", "{", "// To handle nested post fields we'll actually create a brand new query instance", "// and pass it off to the Closure that we have. The Closure can simply do", "// do whatever it wants to a post field then we ...
Add a nested post field to the query. @param \Closure $callback @return \Kevindierkx\Elicit\Query\Builder|static
[ "Add", "a", "nested", "post", "field", "to", "the", "query", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Builder.php#L298-L308
train
kevindierkx/elicit
src/Query/Builder.php
Builder.addNestedPostFieldQuery
public function addNestedPostFieldQuery($query) { if (count($query->body)) { $body = $this->body ?: []; $this->body = array_merge($body, $query->body); } return $this; }
php
public function addNestedPostFieldQuery($query) { if (count($query->body)) { $body = $this->body ?: []; $this->body = array_merge($body, $query->body); } return $this; }
[ "public", "function", "addNestedPostFieldQuery", "(", "$", "query", ")", "{", "if", "(", "count", "(", "$", "query", "->", "body", ")", ")", "{", "$", "body", "=", "$", "this", "->", "body", "?", ":", "[", "]", ";", "$", "this", "->", "body", "="...
Merge another query builder body with the query builder body. @param \Kevindierkx\Elicit\Query\Builder|static $query @return self
[ "Merge", "another", "query", "builder", "body", "with", "the", "query", "builder", "body", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Builder.php#L316-L325
train
nattreid/menu
src/Menu/Item.php
Item.setCurrent
public function setCurrent(): void { $this->current = true; $parent = $this->parent; if ($parent instanceof Item) { $parent->setCurrent(); } }
php
public function setCurrent(): void { $this->current = true; $parent = $this->parent; if ($parent instanceof Item) { $parent->setCurrent(); } }
[ "public", "function", "setCurrent", "(", ")", ":", "void", "{", "$", "this", "->", "current", "=", "true", ";", "$", "parent", "=", "$", "this", "->", "parent", ";", "if", "(", "$", "parent", "instanceof", "Item", ")", "{", "$", "parent", "->", "se...
Nastavi jako aktivni i s rodici
[ "Nastavi", "jako", "aktivni", "i", "s", "rodici" ]
bcc99c40d6d62b7792e4d40ce741548cf653c2df
https://github.com/nattreid/menu/blob/bcc99c40d6d62b7792e4d40ce741548cf653c2df/src/Menu/Item.php#L209-L216
train
las93/attila
Attila/lib/Bash.php
Bash.setDecoration
public static function setDecoration(string $sContent, string $sStyleName) : string { return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]); }
php
public static function setDecoration(string $sContent, string $sStyleName) : string { return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]); }
[ "public", "static", "function", "setDecoration", "(", "string", "$", "sContent", ",", "string", "$", "sStyleName", ")", ":", "string", "{", "return", "self", "::", "_applyCode", "(", "$", "sContent", ",", "self", "::", "$", "_aBackgroundCodes", "[", "$", "...
set a decoration of the text @access public @param string $sContent content to around by the style @param string $sStyleName the name of the style @return string
[ "set", "a", "decoration", "of", "the", "text" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/lib/Bash.php#L106-L109
train
las93/attila
Attila/lib/Bash.php
Bash.setBackground
public static function setBackground(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'black'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
php
public static function setBackground(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'black'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
[ "public", "static", "function", "setBackground", "(", "string", "$", "sContent", ",", "string", "$", "sColorName", ")", ":", "string", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_aBackgroundCodes", "[", "$", "sColorName", "]", ")", ")", "{", ...
set a color of the background @access public @param string $sContent content to around by the style @param string $sColorName the name of the color @return string
[ "set", "a", "color", "of", "the", "background" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/lib/Bash.php#L119-L124
train
las93/attila
Attila/lib/Bash.php
Bash.setColor
public static function setColor(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'white'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
php
public static function setColor(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'white'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
[ "public", "static", "function", "setColor", "(", "string", "$", "sContent", ",", "string", "$", "sColorName", ")", ":", "string", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_aBackgroundCodes", "[", "$", "sColorName", "]", ")", ")", "{", "$"...
set a color of the text @access public @param string $sContent content to around by the style @param string $sColorName the name of the color @return string
[ "set", "a", "color", "of", "the", "text" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/lib/Bash.php#L134-L139
train
bishopb/vanilla
applications/vanilla/models/class.vanillasearchmodel.php
VanillaSearchModel.DiscussionModel
public function DiscussionModel($Value = FALSE) { if($Value !== FALSE) { $this->_DiscussionModel = $Value; } if($this->_DiscussionModel === FALSE) { require_once(dirname(__FILE__).DS.'class.discussionmodel.php'); $this->_DiscussionModel = new DiscussionModel(); } return $this->_DiscussionModel; }
php
public function DiscussionModel($Value = FALSE) { if($Value !== FALSE) { $this->_DiscussionModel = $Value; } if($this->_DiscussionModel === FALSE) { require_once(dirname(__FILE__).DS.'class.discussionmodel.php'); $this->_DiscussionModel = new DiscussionModel(); } return $this->_DiscussionModel; }
[ "public", "function", "DiscussionModel", "(", "$", "Value", "=", "FALSE", ")", "{", "if", "(", "$", "Value", "!==", "FALSE", ")", "{", "$", "this", "->", "_DiscussionModel", "=", "$", "Value", ";", "}", "if", "(", "$", "this", "->", "_DiscussionModel",...
Makes a discussion model available. @since 2.0.0 @access public @param object $Value DiscussionModel. @return object DiscussionModel.
[ "Makes", "a", "discussion", "model", "available", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/models/class.vanillasearchmodel.php#L37-L46
train
bishopb/vanilla
applications/vanilla/models/class.vanillasearchmodel.php
VanillaSearchModel.DiscussionSql
public function DiscussionSql($SearchModel, $AddMatch = TRUE) { // Get permission and limit search categories if necessary. if ($AddMatch) { $Perms = CategoryModel::CategoryWatch(); if($Perms !== TRUE) { $this->SQL->WhereIn('d.CategoryID', $Perms); } // Build search part of query. $SearchModel->AddMatchSql($this->SQL, 'd.Name, d.Body', 'd.DateInserted'); } // Build base query $this->SQL ->Select('d.DiscussionID as PrimaryID, d.Name as Title, d.Body as Summary, d.Format, d.CategoryID, d.Score') ->Select('d.DiscussionID', "concat('/discussion/', %s)", 'Url') ->Select('d.DateInserted') ->Select('d.InsertUserID as UserID') ->Select("'Discussion'", '', 'RecordType') ->From('Discussion d'); if ($AddMatch) { // Execute query. $Result = $this->SQL->GetSelect(); // Unset SQL $this->SQL->Reset(); } else { $Result = $this->SQL; } return $Result; }
php
public function DiscussionSql($SearchModel, $AddMatch = TRUE) { // Get permission and limit search categories if necessary. if ($AddMatch) { $Perms = CategoryModel::CategoryWatch(); if($Perms !== TRUE) { $this->SQL->WhereIn('d.CategoryID', $Perms); } // Build search part of query. $SearchModel->AddMatchSql($this->SQL, 'd.Name, d.Body', 'd.DateInserted'); } // Build base query $this->SQL ->Select('d.DiscussionID as PrimaryID, d.Name as Title, d.Body as Summary, d.Format, d.CategoryID, d.Score') ->Select('d.DiscussionID', "concat('/discussion/', %s)", 'Url') ->Select('d.DateInserted') ->Select('d.InsertUserID as UserID') ->Select("'Discussion'", '', 'RecordType') ->From('Discussion d'); if ($AddMatch) { // Execute query. $Result = $this->SQL->GetSelect(); // Unset SQL $this->SQL->Reset(); } else { $Result = $this->SQL; } return $Result; }
[ "public", "function", "DiscussionSql", "(", "$", "SearchModel", ",", "$", "AddMatch", "=", "TRUE", ")", "{", "// Get permission and limit search categories if necessary.\r", "if", "(", "$", "AddMatch", ")", "{", "$", "Perms", "=", "CategoryModel", "::", "CategoryWat...
Execute discussion search query. @since 2.0.0 @access public @param object $SearchModel SearchModel (Dashboard) @return object SQL result.
[ "Execute", "discussion", "search", "query", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/models/class.vanillasearchmodel.php#L57-L90
train
bishopb/vanilla
applications/vanilla/models/class.vanillasearchmodel.php
VanillaSearchModel.Search
public function Search($SearchModel) { $SearchModel->AddSearch($this->DiscussionSql($SearchModel)); $SearchModel->AddSearch($this->CommentSql($SearchModel)); }
php
public function Search($SearchModel) { $SearchModel->AddSearch($this->DiscussionSql($SearchModel)); $SearchModel->AddSearch($this->CommentSql($SearchModel)); }
[ "public", "function", "Search", "(", "$", "SearchModel", ")", "{", "$", "SearchModel", "->", "AddSearch", "(", "$", "this", "->", "DiscussionSql", "(", "$", "SearchModel", ")", ")", ";", "$", "SearchModel", "->", "AddSearch", "(", "$", "this", "->", "Com...
Add the searches for Vanilla to the search model. @since 2.0.0 @access public @param object $SearchModel SearchModel (Dashboard)
[ "Add", "the", "searches", "for", "Vanilla", "to", "the", "search", "model", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/models/class.vanillasearchmodel.php#L144-L147
train
neemzy/patchwork-core
src/Model/SortableModel.php
SortableModel.move
public function move($up) { $table = $this->getTableName(); if ($up && ($this->position > 1)) { $this->position--; $this->app['redbean']->exec('UPDATE '.$table.' SET position = position + 1 WHERE position = ?', [$this->position]); } else if (!$up && ($this->position < $this->app['redbean']->count($table))) { $this->position++; $this->app['redbean']->exec('UPDATE '.$table.' SET position = position - 1 WHERE position = ?', [$this->position]); } }
php
public function move($up) { $table = $this->getTableName(); if ($up && ($this->position > 1)) { $this->position--; $this->app['redbean']->exec('UPDATE '.$table.' SET position = position + 1 WHERE position = ?', [$this->position]); } else if (!$up && ($this->position < $this->app['redbean']->count($table))) { $this->position++; $this->app['redbean']->exec('UPDATE '.$table.' SET position = position - 1 WHERE position = ?', [$this->position]); } }
[ "public", "function", "move", "(", "$", "up", ")", "{", "$", "table", "=", "$", "this", "->", "getTableName", "(", ")", ";", "if", "(", "$", "up", "&&", "(", "$", "this", "->", "position", ">", "1", ")", ")", "{", "$", "this", "->", "position",...
Moves this model up or down in position @param bool $up Move way @return void
[ "Moves", "this", "model", "up", "or", "down", "in", "position" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/SortableModel.php#L14-L25
train
neemzy/patchwork-core
src/Model/SortableModel.php
SortableModel.sortableUpdate
protected function sortableUpdate() { $table = $this->getTableName(); if (!$this->position || ($this->position && count($this->app['redbean']->find($table, 'position = ? AND id != ?', [$this->position, $this->id])))) { $position = $this->app['redbean']->getCell('SELECT position FROM '.$table.' ORDER BY position DESC LIMIT 1'); $this->position = $position + 1; } }
php
protected function sortableUpdate() { $table = $this->getTableName(); if (!$this->position || ($this->position && count($this->app['redbean']->find($table, 'position = ? AND id != ?', [$this->position, $this->id])))) { $position = $this->app['redbean']->getCell('SELECT position FROM '.$table.' ORDER BY position DESC LIMIT 1'); $this->position = $position + 1; } }
[ "protected", "function", "sortableUpdate", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getTableName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "position", "||", "(", "$", "this", "->", "position", "&&", "count", "(", "$", "this", ...
RedBean update method Automates position assigning @return void
[ "RedBean", "update", "method", "Automates", "position", "assigning" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/SortableModel.php#L35-L43
train
MINISTRYGmbH/morrow-core
src/Validator.php
Validator.add
public function add($name, $callback, $error_message) { $this->_callbacks[$name] = $callback; $this->_messages[$name] = $error_message; }
php
public function add($name, $callback, $error_message) { $this->_callbacks[$name] = $callback; $this->_messages[$name] = $error_message; }
[ "public", "function", "add", "(", "$", "name", ",", "$", "callback", ",", "$", "error_message", ")", "{", "$", "this", "->", "_callbacks", "[", "$", "name", "]", "=", "$", "callback", ";", "$", "this", "->", "_messages", "[", "$", "name", "]", "=",...
Adds a user defined validator. @param string $name The name of the validator. @param callable $callback A valid PHP callback like `['OBJECT', 'METHOD']`, `[$obj, 'METHOD']` or a n anonymous function like `function($input, $value){}`. The method gets at least two parameters passed. An array of all `$input` parameters and the `$value` to validate. Other parameters are the passed parameters. @param string $error_message The error message that get all parameters passed via `sprintf`, so you can use `%s` and other `sprintf` replacements.
[ "Adds", "a", "user", "defined", "validator", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Validator.php#L328-L331
train
MINISTRYGmbH/morrow-core
src/Validator.php
Validator.setMessages
public function setMessages($messages) { foreach ($messages as $name => $message) { $this->_messages[$name] = $message; } }
php
public function setMessages($messages) { foreach ($messages as $name => $message) { $this->_messages[$name] = $message; } }
[ "public", "function", "setMessages", "(", "$", "messages", ")", "{", "foreach", "(", "$", "messages", "as", "$", "name", "=>", "$", "message", ")", "{", "$", "this", "->", "_messages", "[", "$", "name", "]", "=", "$", "message", ";", "}", "}" ]
Adds user defined error messages. @param array $messages An associative array with the error messages (with the validators as keys). Parameters are passed via `sprintf`, so you can use `%s` and other `sprintf` replacements. It is also possible to use a key like `salutation.required` (`[fieldname].[validator]`) to get a custom message for a specific form field.
[ "Adds", "user", "defined", "error", "messages", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Validator.php#L346-L350
train
FKSE/php-utils
lib/FKSE/Utilities/DateTimeUtil.php
DateTimeUtil.getSecondsBetweenDates
public static function getSecondsBetweenDates(\DateTime $dateA, \DateTime $dateB) { $diff = $dateA->diff($dateB); $sec = $diff->s; //add minutes $sec += $diff->i * 60; //add hours $sec += $diff->h * 3600; //add days $sec += $diff->days * 86400; return $sec; }
php
public static function getSecondsBetweenDates(\DateTime $dateA, \DateTime $dateB) { $diff = $dateA->diff($dateB); $sec = $diff->s; //add minutes $sec += $diff->i * 60; //add hours $sec += $diff->h * 3600; //add days $sec += $diff->days * 86400; return $sec; }
[ "public", "static", "function", "getSecondsBetweenDates", "(", "\\", "DateTime", "$", "dateA", ",", "\\", "DateTime", "$", "dateB", ")", "{", "$", "diff", "=", "$", "dateA", "->", "diff", "(", "$", "dateB", ")", ";", "$", "sec", "=", "$", "diff", "->...
Calculates the seconds between two dates. @param \DateTime $dateA @param \DateTime $dateB @return mixed
[ "Calculates", "the", "seconds", "between", "two", "dates", "." ]
d13c5c49cf9f48658d2cabd18357257185474ff2
https://github.com/FKSE/php-utils/blob/d13c5c49cf9f48658d2cabd18357257185474ff2/lib/FKSE/Utilities/DateTimeUtil.php#L19-L32
train
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/Helpers/SharedSecretAuthentication.php
SharedSecretAuthentication.verifyCredentials
public static function verifyCredentials(ObjectRetriever $retriever, $username, $password) { // Validate input $namespaceCoid = new IRI('coid://'.$username); if (COIDParser::getType($namespaceCoid) != COIDParser::COID_ROOT) return self::RESULT_INVALID_USERNAME; if (strlen($password) != 40) return self::RESULT_INVALID_PASSWORD; // Retrieve namespace $namespace = $retriever->getObject($namespaceCoid); if (!isset($namespace)) return self::RESULT_NAMESPACE_NOT_FOUND; // Read and validate shared secret $reader = new NodeReader([ 'prefixes' => [ 'co' => 'coid://cloudobjects.io/' ] ]); $sharedSecret = $reader->getAllValuesNode($namespace, 'co:hasSharedSecret'); if (count($sharedSecret) != 1) return self::RESULT_SHARED_SECRET_NOT_RETRIEVABLE; if ($reader->getFirstValueString($sharedSecret[0], 'co:hasTokenValue') == $password) return self::RESULT_OK; else return self::RESULT_SHARED_SECRET_INCORRECT; }
php
public static function verifyCredentials(ObjectRetriever $retriever, $username, $password) { // Validate input $namespaceCoid = new IRI('coid://'.$username); if (COIDParser::getType($namespaceCoid) != COIDParser::COID_ROOT) return self::RESULT_INVALID_USERNAME; if (strlen($password) != 40) return self::RESULT_INVALID_PASSWORD; // Retrieve namespace $namespace = $retriever->getObject($namespaceCoid); if (!isset($namespace)) return self::RESULT_NAMESPACE_NOT_FOUND; // Read and validate shared secret $reader = new NodeReader([ 'prefixes' => [ 'co' => 'coid://cloudobjects.io/' ] ]); $sharedSecret = $reader->getAllValuesNode($namespace, 'co:hasSharedSecret'); if (count($sharedSecret) != 1) return self::RESULT_SHARED_SECRET_NOT_RETRIEVABLE; if ($reader->getFirstValueString($sharedSecret[0], 'co:hasTokenValue') == $password) return self::RESULT_OK; else return self::RESULT_SHARED_SECRET_INCORRECT; }
[ "public", "static", "function", "verifyCredentials", "(", "ObjectRetriever", "$", "retriever", ",", "$", "username", ",", "$", "password", ")", "{", "// Validate input", "$", "namespaceCoid", "=", "new", "IRI", "(", "'coid://'", ".", "$", "username", ")", ";",...
Verifies credentials. @param ObjectRetriever $retriever Provides access to CloudObjects. @param string $username Username; a domain. @param string $password Password; a shared secret. @return integer A result constant, RESULT_OK if successful.
[ "Verifies", "credentials", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/Helpers/SharedSecretAuthentication.php#L34-L61
train
tux-rampage/rampage-php
library/rampage/core/xml/mergerule/ChainedRule.php
ChainedRule.add
public function add(MergeRuleInterface $rule, $name = null) { if (!empty($name)) { $this->_items[$name] = $rule; } else { $this->_items[] = $rule; } return $this; }
php
public function add(MergeRuleInterface $rule, $name = null) { if (!empty($name)) { $this->_items[$name] = $rule; } else { $this->_items[] = $rule; } return $this; }
[ "public", "function", "add", "(", "MergeRuleInterface", "$", "rule", ",", "$", "name", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_items", "[", "$", "name", "]", "=", "$", "rule", ";", "...
add a rule @param xml\MergeRuleInterface $rule @param string $name
[ "add", "a", "rule" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/mergerule/ChainedRule.php#L57-L66
train
phergie/phergie-irc-plugin-react-quit
src/Plugin.php
Plugin.handleQuitCommand
public function handleQuitCommand(CommandEvent $event, EventQueueInterface $queue) { $message = sprintf($this->message, $event->getNick()); $queue->ircQuit($message); }
php
public function handleQuitCommand(CommandEvent $event, EventQueueInterface $queue) { $message = sprintf($this->message, $event->getNick()); $queue->ircQuit($message); }
[ "public", "function", "handleQuitCommand", "(", "CommandEvent", "$", "event", ",", "EventQueueInterface", "$", "queue", ")", "{", "$", "message", "=", "sprintf", "(", "$", "this", "->", "message", ",", "$", "event", "->", "getNick", "(", ")", ")", ";", "...
Terminates the connection to a server from which a quit command is received. @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Terminates", "the", "connection", "to", "a", "server", "from", "which", "a", "quit", "command", "is", "received", "." ]
810656c414a92ec2e218c8ad9d847448fa76fc14
https://github.com/phergie/phergie-irc-plugin-react-quit/blob/810656c414a92ec2e218c8ad9d847448fa76fc14/src/Plugin.php#L74-L78
train
infinity-next/eightdown
src/Traits/ParsedownMemeArrows.php
ParsedownMemeArrows.blockQuote
protected function blockQuote($Line) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { $matches = str_replace(">", "&gt;", $matches[1]); $Block = array( 'element' => array( 'name' => 'blockquote', 'handler' => 'lines', 'text' => [ "&gt;{$matches}" ], ), ); return $Block; } }
php
protected function blockQuote($Line) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { $matches = str_replace(">", "&gt;", $matches[1]); $Block = array( 'element' => array( 'name' => 'blockquote', 'handler' => 'lines', 'text' => [ "&gt;{$matches}" ], ), ); return $Block; } }
[ "protected", "function", "blockQuote", "(", "$", "Line", ")", "{", "if", "(", "!", "$", "this", "->", "config", "(", "'markup.quote.keepSigns'", ")", ")", "{", "return", "parent", "::", "blockQuote", "(", "$", "Line", ")", ";", "}", "if", "(", "mb_ereg...
Injects a greater-than sign at the start of a quote block. @param array $Line @return array
[ "Injects", "a", "greater", "-", "than", "sign", "at", "the", "start", "of", "a", "quote", "block", "." ]
e3ec0b573110a244880d09f1c92f1e932632733b
https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownMemeArrows.php#L13-L33
train
infinity-next/eightdown
src/Traits/ParsedownMemeArrows.php
ParsedownMemeArrows.blockQuoteContinue
protected function blockQuoteContinue($Line, array $Block) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { if (isset($Block['interrupted'])) { $Block['element']['text'] []= ''; unset($Block['interrupted']); } $matches = str_replace(">", "&gt;", $matches[1]); $Block['element']['text'][] = "&gt;{$matches}"; return $Block; } }
php
protected function blockQuoteContinue($Line, array $Block) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { if (isset($Block['interrupted'])) { $Block['element']['text'] []= ''; unset($Block['interrupted']); } $matches = str_replace(">", "&gt;", $matches[1]); $Block['element']['text'][] = "&gt;{$matches}"; return $Block; } }
[ "protected", "function", "blockQuoteContinue", "(", "$", "Line", ",", "array", "$", "Block", ")", "{", "if", "(", "!", "$", "this", "->", "config", "(", "'markup.quote.keepSigns'", ")", ")", "{", "return", "parent", "::", "blockQuote", "(", "$", "Line", ...
Injects a greater-than sign at the beginning of each line in a quote block. @param array $Line @return array
[ "Injects", "a", "greater", "-", "than", "sign", "at", "the", "beginning", "of", "each", "line", "in", "a", "quote", "block", "." ]
e3ec0b573110a244880d09f1c92f1e932632733b
https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownMemeArrows.php#L41-L62
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/file/handler/file.php
File_Handler_File.move
public function move($new_path) { $info = pathinfo($this->path); $new_path = $this->area->get_path($new_path); $new_path = rtrim($new_path, '\\/').DS.$info['basename']; $return = $this->area->rename($this->path, $new_path); $return and $this->path = $new_path; return $return; }
php
public function move($new_path) { $info = pathinfo($this->path); $new_path = $this->area->get_path($new_path); $new_path = rtrim($new_path, '\\/').DS.$info['basename']; $return = $this->area->rename($this->path, $new_path); $return and $this->path = $new_path; return $return; }
[ "public", "function", "move", "(", "$", "new_path", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "this", "->", "path", ")", ";", "$", "new_path", "=", "$", "this", "->", "area", "->", "get_path", "(", "$", "new_path", ")", ";", "$", "new_path"...
Move file to new directory @param string path to new directory, must be valid @return bool
[ "Move", "file", "to", "new", "directory" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/file/handler/file.php#L105-L116
train
Innmind/neo4j-onm
src/Persister/UpdatePersister.php
UpdatePersister.queryFor
private function queryFor( MapInterface $changesets, MapInterface $entities ): Query { $this->variables = new Map(Str::class, MapInterface::class); $query = $changesets->reduce( new Query\Query, function(Query $carry, Identity $identity, MapInterface $changeset) use ($entities): Query { $entity = $entities->get($identity); $meta = ($this->metadata)(\get_class($entity)); if ($meta instanceof Aggregate) { return $this->matchAggregate( $identity, $entity, $meta, $changeset, $carry ); } else if ($meta instanceof Relationship) { return $this->matchRelationship( $identity, $entity, $meta, $changeset, $carry ); } } ); $query = $this ->variables ->reduce( $query, function(Query $carry, Str $variable, MapInterface $changeset): Query { return $this->update($variable, $changeset, $carry); } ); $this->variables = null; return $query; }
php
private function queryFor( MapInterface $changesets, MapInterface $entities ): Query { $this->variables = new Map(Str::class, MapInterface::class); $query = $changesets->reduce( new Query\Query, function(Query $carry, Identity $identity, MapInterface $changeset) use ($entities): Query { $entity = $entities->get($identity); $meta = ($this->metadata)(\get_class($entity)); if ($meta instanceof Aggregate) { return $this->matchAggregate( $identity, $entity, $meta, $changeset, $carry ); } else if ($meta instanceof Relationship) { return $this->matchRelationship( $identity, $entity, $meta, $changeset, $carry ); } } ); $query = $this ->variables ->reduce( $query, function(Query $carry, Str $variable, MapInterface $changeset): Query { return $this->update($variable, $changeset, $carry); } ); $this->variables = null; return $query; }
[ "private", "function", "queryFor", "(", "MapInterface", "$", "changesets", ",", "MapInterface", "$", "entities", ")", ":", "Query", "{", "$", "this", "->", "variables", "=", "new", "Map", "(", "Str", "::", "class", ",", "MapInterface", "::", "class", ")", ...
Build the query to update all entities at once @param MapInterface<Identity, MapInterface<string, mixed>> $changesets @param MapInterface<Identity, object> $entities
[ "Build", "the", "query", "to", "update", "all", "entities", "at", "once" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/UpdatePersister.php#L111-L153
train
Innmind/neo4j-onm
src/Persister/UpdatePersister.php
UpdatePersister.matchAggregate
private function matchAggregate( Identity $identity, object $entity, Aggregate $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $query = $query ->match( (string) $name, $meta->labels()->toPrimitive() ) ->withProperty( $meta->identity()->property(), (string) $name ->prepend('{') ->append('_identity}') ) ->withParameter( (string) $name->append('_identity'), $identity->value() ); $this->variables = $this->variables->put( $name, $this->buildProperties( $changeset, $meta->properties() ) ); return $meta ->children() ->filter(static function(string $property) use ($changeset): bool { return $changeset->contains($property); }) ->reduce( $query, function(Query $carry, string $property, Child $child) use ($changeset, $name): Query { $changeset = $changeset->get($property); $childName = null; $relName = $name ->append('_') ->append($property); $this->variables = $this->variables->put( $relName, $this->buildProperties( $changeset, $child->relationship()->properties() ) ); if ($changeset->contains($child->relationship()->childProperty())) { $childName = $relName ->append('_') ->append( $child->relationship()->childProperty() ); $this->variables = $this->variables->put( $childName, $changeset->get( $child->relationship()->childProperty() ) ); } return $carry ->match((string) $name) ->linkedTo( $childName ? (string) $childName : null, $child->labels()->toPrimitive() ) ->through( (string) $child->relationship()->type(), (string) $relName ); } ); }
php
private function matchAggregate( Identity $identity, object $entity, Aggregate $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $query = $query ->match( (string) $name, $meta->labels()->toPrimitive() ) ->withProperty( $meta->identity()->property(), (string) $name ->prepend('{') ->append('_identity}') ) ->withParameter( (string) $name->append('_identity'), $identity->value() ); $this->variables = $this->variables->put( $name, $this->buildProperties( $changeset, $meta->properties() ) ); return $meta ->children() ->filter(static function(string $property) use ($changeset): bool { return $changeset->contains($property); }) ->reduce( $query, function(Query $carry, string $property, Child $child) use ($changeset, $name): Query { $changeset = $changeset->get($property); $childName = null; $relName = $name ->append('_') ->append($property); $this->variables = $this->variables->put( $relName, $this->buildProperties( $changeset, $child->relationship()->properties() ) ); if ($changeset->contains($child->relationship()->childProperty())) { $childName = $relName ->append('_') ->append( $child->relationship()->childProperty() ); $this->variables = $this->variables->put( $childName, $changeset->get( $child->relationship()->childProperty() ) ); } return $carry ->match((string) $name) ->linkedTo( $childName ? (string) $childName : null, $child->labels()->toPrimitive() ) ->through( (string) $child->relationship()->type(), (string) $relName ); } ); }
[ "private", "function", "matchAggregate", "(", "Identity", "$", "identity", ",", "object", "$", "entity", ",", "Aggregate", "$", "meta", ",", "MapInterface", "$", "changeset", ",", "Query", "$", "query", ")", ":", "Query", "{", "$", "name", "=", "$", "thi...
Add match clause to match all parts of the aggregate that needs to be updated @param MapInterface<string, mixed> $changeset
[ "Add", "match", "clause", "to", "match", "all", "parts", "of", "the", "aggregate", "that", "needs", "to", "be", "updated" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/UpdatePersister.php#L160-L238
train
Innmind/neo4j-onm
src/Persister/UpdatePersister.php
UpdatePersister.matchRelationship
private function matchRelationship( Identity $identity, object $entity, Relationship $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $this->variables = $this->variables->put( $name, $this->buildProperties( $changeset, $meta->properties() ) ); return $query ->match() ->linkedTo() ->through( (string) $meta->type(), (string) $name ) ->withProperty( $meta->identity()->property(), (string) $name ->prepend('{') ->append('_identity}') ) ->withParameter( (string) $name->append('_identity'), $identity->value() ); }
php
private function matchRelationship( Identity $identity, object $entity, Relationship $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $this->variables = $this->variables->put( $name, $this->buildProperties( $changeset, $meta->properties() ) ); return $query ->match() ->linkedTo() ->through( (string) $meta->type(), (string) $name ) ->withProperty( $meta->identity()->property(), (string) $name ->prepend('{') ->append('_identity}') ) ->withParameter( (string) $name->append('_identity'), $identity->value() ); }
[ "private", "function", "matchRelationship", "(", "Identity", "$", "identity", ",", "object", "$", "entity", ",", "Relationship", "$", "meta", ",", "MapInterface", "$", "changeset", ",", "Query", "$", "query", ")", ":", "Query", "{", "$", "name", "=", "$", ...
Add the match clause for a relationship @param MapInterface<string, mixed> $changeset
[ "Add", "the", "match", "clause", "for", "a", "relationship" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/UpdatePersister.php#L245-L278
train
Innmind/neo4j-onm
src/Persister/UpdatePersister.php
UpdatePersister.buildProperties
private function buildProperties( MapInterface $changeset, MapInterface $properties ): MapInterface { return $changeset->filter(static function(string $property) use ($properties) { return $properties->contains($property); }); }
php
private function buildProperties( MapInterface $changeset, MapInterface $properties ): MapInterface { return $changeset->filter(static function(string $property) use ($properties) { return $properties->contains($property); }); }
[ "private", "function", "buildProperties", "(", "MapInterface", "$", "changeset", ",", "MapInterface", "$", "properties", ")", ":", "MapInterface", "{", "return", "$", "changeset", "->", "filter", "(", "static", "function", "(", "string", "$", "property", ")", ...
Build a collection with only the elements that are properties @param MapInterface<string, mixed> $changeset @param MapInterface<string, Property> $properties @return MapInterface<string, mixed>
[ "Build", "a", "collection", "with", "only", "the", "elements", "that", "are", "properties" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/UpdatePersister.php#L288-L295
train
Innmind/neo4j-onm
src/Persister/UpdatePersister.php
UpdatePersister.update
private function update( Str $variable, MapInterface $changeset, Query $query ): Query { return $query ->set(sprintf( '%s += {%s_props}', $variable, $variable )) ->withParameter( (string) $variable->append('_props'), $changeset->reduce( [], static function(array $carry, string $key, $value): array { $carry[$key] = $value; return $carry; } ) ); }
php
private function update( Str $variable, MapInterface $changeset, Query $query ): Query { return $query ->set(sprintf( '%s += {%s_props}', $variable, $variable )) ->withParameter( (string) $variable->append('_props'), $changeset->reduce( [], static function(array $carry, string $key, $value): array { $carry[$key] = $value; return $carry; } ) ); }
[ "private", "function", "update", "(", "Str", "$", "variable", ",", "MapInterface", "$", "changeset", ",", "Query", "$", "query", ")", ":", "Query", "{", "return", "$", "query", "->", "set", "(", "sprintf", "(", "'%s += {%s_props}'", ",", "$", "variable", ...
Add a clause to set all properties to be updated on the wished variable @param Str $variable @param MapInterface<string, mixed> $changeset @param Query $query @return Query
[ "Add", "a", "clause", "to", "set", "all", "properties", "to", "be", "updated", "on", "the", "wished", "variable" ]
816216802a9716bb5f20cc38336313b043bf764c
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/UpdatePersister.php#L306-L328
train
ensphere/core
Ensphere/Commands/Ensphere/Back/Resource/Command.php
Command.createRoutesStub
protected function createRoutesStub() { if( ! file_exists( app_path( 'Routes' ) ) ) { mkdir( app_path( 'Routes' ), 0755 ); } if( $this->create( 'routes.stub', 'Routes', $this->getRoutesName() ) ) { $this->info( 'add ' . $this->getNamespace() . '\\Routes\\' . $this->getRoutesName() . '::routes( $router ); in your routes contract.' ); } }
php
protected function createRoutesStub() { if( ! file_exists( app_path( 'Routes' ) ) ) { mkdir( app_path( 'Routes' ), 0755 ); } if( $this->create( 'routes.stub', 'Routes', $this->getRoutesName() ) ) { $this->info( 'add ' . $this->getNamespace() . '\\Routes\\' . $this->getRoutesName() . '::routes( $router ); in your routes contract.' ); } }
[ "protected", "function", "createRoutesStub", "(", ")", "{", "if", "(", "!", "file_exists", "(", "app_path", "(", "'Routes'", ")", ")", ")", "{", "mkdir", "(", "app_path", "(", "'Routes'", ")", ",", "0755", ")", ";", "}", "if", "(", "$", "this", "->",...
Create Routes Stub @return void
[ "Create", "Routes", "Stub" ]
a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3
https://github.com/ensphere/core/blob/a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3/Ensphere/Commands/Ensphere/Back/Resource/Command.php#L159-L167
train
99designs/ergo
classes/Ergo/Application.php
Application.reset
public function reset() { unset($this->_registry); unset($this->_mixin); unset($this->_errorHandler); unset($this->_errorContext); unset($this->_middleware); return $this; }
php
public function reset() { unset($this->_registry); unset($this->_mixin); unset($this->_errorHandler); unset($this->_errorContext); unset($this->_middleware); return $this; }
[ "public", "function", "reset", "(", ")", "{", "unset", "(", "$", "this", "->", "_registry", ")", ";", "unset", "(", "$", "this", "->", "_mixin", ")", ";", "unset", "(", "$", "this", "->", "_errorHandler", ")", ";", "unset", "(", "$", "this", "->", ...
Resets all internal state
[ "Resets", "all", "internal", "state" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Application.php#L88-L96
train
99designs/ergo
classes/Ergo/Application.php
Application.loggerFactory
public function loggerFactory() { if(!isset($this->_loggerFactory)) { $this->_loggerFactory = new Logging\DefaultLoggerFactory(); } return $this->_loggerFactory; }
php
public function loggerFactory() { if(!isset($this->_loggerFactory)) { $this->_loggerFactory = new Logging\DefaultLoggerFactory(); } return $this->_loggerFactory; }
[ "public", "function", "loggerFactory", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_loggerFactory", ")", ")", "{", "$", "this", "->", "_loggerFactory", "=", "new", "Logging", "\\", "DefaultLoggerFactory", "(", ")", ";", "}", "return"...
Gets the logger factory used to create loggers
[ "Gets", "the", "logger", "factory", "used", "to", "create", "loggers" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Application.php#L131-L139
train
99designs/ergo
classes/Ergo/Application.php
Application.rand
public function rand($min = 0, $max = 0) { if (!$max) $max = getrandmax(); return $this->registry()->isRegistered(self::REGISTRY_RAND) ? $this->lookup(self::REGISTRY_RAND) : rand($min, $max); }
php
public function rand($min = 0, $max = 0) { if (!$max) $max = getrandmax(); return $this->registry()->isRegistered(self::REGISTRY_RAND) ? $this->lookup(self::REGISTRY_RAND) : rand($min, $max); }
[ "public", "function", "rand", "(", "$", "min", "=", "0", ",", "$", "max", "=", "0", ")", "{", "if", "(", "!", "$", "max", ")", "$", "max", "=", "getrandmax", "(", ")", ";", "return", "$", "this", "->", "registry", "(", ")", "->", "isRegistered"...
Returns the current random number in the registry, or generates a new one @return int
[ "Returns", "the", "current", "random", "number", "in", "the", "registry", "or", "generates", "a", "new", "one" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Application.php#L328-L336
train
99designs/ergo
classes/Ergo/Application.php
Application.run
public function run($server=null, $stream=null) { $server = $server ?: $_SERVER; $stream = $stream ?: fopen('php://output','w'); $controller = $this->controller(); // build up wrappers of middleware foreach($this->_middleware as $middleware) $controller = new $middleware($controller, $this); $requestFactory = new Http\RequestFactory($server); $response = $controller->execute($requestFactory->create()); $sender = new Http\ResponseSender($response, $stream); $sender->send(); }
php
public function run($server=null, $stream=null) { $server = $server ?: $_SERVER; $stream = $stream ?: fopen('php://output','w'); $controller = $this->controller(); // build up wrappers of middleware foreach($this->_middleware as $middleware) $controller = new $middleware($controller, $this); $requestFactory = new Http\RequestFactory($server); $response = $controller->execute($requestFactory->create()); $sender = new Http\ResponseSender($response, $stream); $sender->send(); }
[ "public", "function", "run", "(", "$", "server", "=", "null", ",", "$", "stream", "=", "null", ")", "{", "$", "server", "=", "$", "server", "?", ":", "$", "_SERVER", ";", "$", "stream", "=", "$", "stream", "?", ":", "fopen", "(", "'php://output'", ...
Processes an HTTP request, copies response to STDOUT @return void
[ "Processes", "an", "HTTP", "request", "copies", "response", "to", "STDOUT" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Application.php#L395-L409
train