repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
KodiComponents/Support
src/Upload.php
Upload.isUploadField
public function isUploadField($key) { return array_key_exists($key, $this->uploadGetKeys) || array_key_exists($key, $this->uploadSetKeys); }
php
public function isUploadField($key) { return array_key_exists($key, $this->uploadGetKeys) || array_key_exists($key, $this->uploadSetKeys); }
[ "public", "function", "isUploadField", "(", "$", "key", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "uploadGetKeys", ")", "||", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "uploadSetKeys", ")", ";", "}" ]
Determine if a set mutator exists for an attribute. @param string $key @return bool
[ "Determine", "if", "a", "set", "mutator", "exists", "for", "an", "attribute", "." ]
train
https://github.com/KodiComponents/Support/blob/9090543605a2354c7454d707650a0abdb815b60a/src/Upload.php#L206-L209
Erdiko/core
src/Helper.php
Helper.serve
public static function serve($context = null) { if(empty($context)) $context = getenv('ERDIKO_CONTEXT'); $routes = static::getRoutes($context); Toro::serve($routes); }
php
public static function serve($context = null) { if(empty($context)) $context = getenv('ERDIKO_CONTEXT'); $routes = static::getRoutes($context); Toro::serve($routes); }
[ "public", "static", "function", "serve", "(", "$", "context", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "context", ")", ")", "$", "context", "=", "getenv", "(", "'ERDIKO_CONTEXT'", ")", ";", "$", "routes", "=", "static", "::", "getRoutes", "(", "$", "context", ")", ";", "Toro", "::", "serve", "(", "$", "routes", ")", ";", "}" ]
Serve your site Loads routes based off of context and serves up the current request @param string $context optional context defaults to getenv('ERDIKO_CONTEXT')
[ "Serve", "your", "site", "Loads", "routes", "based", "off", "of", "context", "and", "serves", "up", "the", "current", "request" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L27-L34
Erdiko/core
src/Helper.php
Helper.getView
public static function getView($viewName, $data = null, $templateRootFolder = null) { $view = new \erdiko\core\View($viewName, $data); if ($templateRootFolder !== null) { $view->setTemplateRootFolder($templateRootFolder); } return $view->toHtml(); }
php
public static function getView($viewName, $data = null, $templateRootFolder = null) { $view = new \erdiko\core\View($viewName, $data); if ($templateRootFolder !== null) { $view->setTemplateRootFolder($templateRootFolder); } return $view->toHtml(); }
[ "public", "static", "function", "getView", "(", "$", "viewName", ",", "$", "data", "=", "null", ",", "$", "templateRootFolder", "=", "null", ")", "{", "$", "view", "=", "new", "\\", "erdiko", "\\", "core", "\\", "View", "(", "$", "viewName", ",", "$", "data", ")", ";", "if", "(", "$", "templateRootFolder", "!==", "null", ")", "{", "$", "view", "->", "setTemplateRootFolder", "(", "$", "templateRootFolder", ")", ";", "}", "return", "$", "view", "->", "toHtml", "(", ")", ";", "}" ]
Load a view from the current theme with the given data @param string $viewName @param array $data
[ "Load", "a", "view", "from", "the", "current", "theme", "with", "the", "given", "data" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L42-L50
Erdiko/core
src/Helper.php
Helper.getConfigFile
public static function getConfigFile($filename) { $filename = addslashes($filename); if (is_file($filename)) { $data = str_replace("\\", "\\\\", file_get_contents($filename)); $json = json_decode($data, true); if (empty($json)) { throw new \Exception("Config file has a json parse error, $filename"); } } else { throw new \Exception("Config file not found, $filename"); } return $json; }
php
public static function getConfigFile($filename) { $filename = addslashes($filename); if (is_file($filename)) { $data = str_replace("\\", "\\\\", file_get_contents($filename)); $json = json_decode($data, true); if (empty($json)) { throw new \Exception("Config file has a json parse error, $filename"); } } else { throw new \Exception("Config file not found, $filename"); } return $json; }
[ "public", "static", "function", "getConfigFile", "(", "$", "filename", ")", "{", "$", "filename", "=", "addslashes", "(", "$", "filename", ")", ";", "if", "(", "is_file", "(", "$", "filename", ")", ")", "{", "$", "data", "=", "str_replace", "(", "\"\\\\\"", ",", "\"\\\\\\\\\"", ",", "file_get_contents", "(", "$", "filename", ")", ")", ";", "$", "json", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "json", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Config file has a json parse error, $filename\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Config file not found, $filename\"", ")", ";", "}", "return", "$", "json", ";", "}" ]
Read JSON config file and return array @param string $file @return array $config
[ "Read", "JSON", "config", "file", "and", "return", "array" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L58-L74
Erdiko/core
src/Helper.php
Helper.getConfig
public static function getConfig($name = 'application', $context = null) { if($context == null) $context = getenv('ERDIKO_CONTEXT'); $filename = ERDIKO_APP."/config/{$context}/{$name}.json"; return static::getConfigFile($filename); }
php
public static function getConfig($name = 'application', $context = null) { if($context == null) $context = getenv('ERDIKO_CONTEXT'); $filename = ERDIKO_APP."/config/{$context}/{$name}.json"; return static::getConfigFile($filename); }
[ "public", "static", "function", "getConfig", "(", "$", "name", "=", "'application'", ",", "$", "context", "=", "null", ")", "{", "if", "(", "$", "context", "==", "null", ")", "$", "context", "=", "getenv", "(", "'ERDIKO_CONTEXT'", ")", ";", "$", "filename", "=", "ERDIKO_APP", ".", "\"/config/{$context}/{$name}.json\"", ";", "return", "static", "::", "getConfigFile", "(", "$", "filename", ")", ";", "}" ]
Get configuration
[ "Get", "configuration" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L79-L86
Erdiko/core
src/Helper.php
Helper.getRoutes
public static function getRoutes($context = null) { if($context == null) $context = getenv('ERDIKO_CONTEXT'); $file = ERDIKO_APP."/config/{$context}/routes.json"; $applicationConfig = static::getConfigFile($file); return $applicationConfig['routes']; }
php
public static function getRoutes($context = null) { if($context == null) $context = getenv('ERDIKO_CONTEXT'); $file = ERDIKO_APP."/config/{$context}/routes.json"; $applicationConfig = static::getConfigFile($file); return $applicationConfig['routes']; }
[ "public", "static", "function", "getRoutes", "(", "$", "context", "=", "null", ")", "{", "if", "(", "$", "context", "==", "null", ")", "$", "context", "=", "getenv", "(", "'ERDIKO_CONTEXT'", ")", ";", "$", "file", "=", "ERDIKO_APP", ".", "\"/config/{$context}/routes.json\"", ";", "$", "applicationConfig", "=", "static", "::", "getConfigFile", "(", "$", "file", ")", ";", "return", "$", "applicationConfig", "[", "'routes'", "]", ";", "}" ]
Get the compiled application routes from the config files @todo cache the loaded/compiled routes
[ "Get", "the", "compiled", "application", "routes", "from", "the", "config", "files" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L93-L101
Erdiko/core
src/Helper.php
Helper.sendEmail
public static function sendEmail($toEmail, $subject, $body, $fromEmail) { $headers = "From: $fromEmail\r\n" . "Reply-To: $fromEmail\r\n" . "X-Mailer: PHP/" . phpversion(); return mail($toEmail, $subject, $body, $headers); }
php
public static function sendEmail($toEmail, $subject, $body, $fromEmail) { $headers = "From: $fromEmail\r\n" . "Reply-To: $fromEmail\r\n" . "X-Mailer: PHP/" . phpversion(); return mail($toEmail, $subject, $body, $headers); }
[ "public", "static", "function", "sendEmail", "(", "$", "toEmail", ",", "$", "subject", ",", "$", "body", ",", "$", "fromEmail", ")", "{", "$", "headers", "=", "\"From: $fromEmail\\r\\n\"", ".", "\"Reply-To: $fromEmail\\r\\n\"", ".", "\"X-Mailer: PHP/\"", ".", "phpversion", "(", ")", ";", "return", "mail", "(", "$", "toEmail", ",", "$", "subject", ",", "$", "body", ",", "$", "headers", ")", ";", "}" ]
Send email @todo add ways to swap out ways of sending
[ "Send", "email" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L107-L114
Erdiko/core
src/Helper.php
Helper.log
public static function log($level, $message, array $context = array()) { if(static::$_logObject==null) { $erdikoContext = getenv('ERDIKO_CONTEXT'); $config = static::getConfig("application", $erdikoContext); $logFiles = $config["logs"]["files"][0]; $logDir = $config["logs"]["path"]; static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir); } if(empty($level)) $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience return static::$_logObject->log($level, $message, $context); }
php
public static function log($level, $message, array $context = array()) { if(static::$_logObject==null) { $erdikoContext = getenv('ERDIKO_CONTEXT'); $config = static::getConfig("application", $erdikoContext); $logFiles = $config["logs"]["files"][0]; $logDir = $config["logs"]["path"]; static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir); } if(empty($level)) $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience return static::$_logObject->log($level, $message, $context); }
[ "public", "static", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "static", "::", "$", "_logObject", "==", "null", ")", "{", "$", "erdikoContext", "=", "getenv", "(", "'ERDIKO_CONTEXT'", ")", ";", "$", "config", "=", "static", "::", "getConfig", "(", "\"application\"", ",", "$", "erdikoContext", ")", ";", "$", "logFiles", "=", "$", "config", "[", "\"logs\"", "]", "[", "\"files\"", "]", "[", "0", "]", ";", "$", "logDir", "=", "$", "config", "[", "\"logs\"", "]", "[", "\"path\"", "]", ";", "static", "::", "$", "_logObject", "=", "new", "\\", "erdiko", "\\", "core", "\\", "Logger", "(", "$", "logFiles", ",", "$", "logDir", ")", ";", "}", "if", "(", "empty", "(", "$", "level", ")", ")", "$", "level", "=", "\\", "Psr", "\\", "Log", "\\", "LogLevel", "::", "DEBUG", ";", "// Default to debug for convenience", "return", "static", "::", "$", "_logObject", "->", "log", "(", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}" ]
log message to log file If you enter null for level it will default to 'debug' @usage \Erdiko::log('debug',"Message here...", array()) @param string $level @param string $message @param array $context @return bool $success @todo refactor how logging is used, eventually remove from helper
[ "log", "message", "to", "log", "file", "If", "you", "enter", "null", "for", "level", "it", "will", "default", "to", "debug" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L128-L144
Erdiko/core
src/Helper.php
Helper.getCache
public static function getCache($cacheType = "default") { $context = getenv('ERDIKO_CONTEXT'); $config = static::getConfig("application"); if (isset($config["cache"][$cacheType])) { $cacheConfig = $config["cache"][$cacheType]; $class = "erdiko\core\cache\\".$cacheConfig["type"]; return new $class; } else { return false; } }
php
public static function getCache($cacheType = "default") { $context = getenv('ERDIKO_CONTEXT'); $config = static::getConfig("application"); if (isset($config["cache"][$cacheType])) { $cacheConfig = $config["cache"][$cacheType]; $class = "erdiko\core\cache\\".$cacheConfig["type"]; return new $class; } else { return false; } }
[ "public", "static", "function", "getCache", "(", "$", "cacheType", "=", "\"default\"", ")", "{", "$", "context", "=", "getenv", "(", "'ERDIKO_CONTEXT'", ")", ";", "$", "config", "=", "static", "::", "getConfig", "(", "\"application\"", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "\"cache\"", "]", "[", "$", "cacheType", "]", ")", ")", "{", "$", "cacheConfig", "=", "$", "config", "[", "\"cache\"", "]", "[", "$", "cacheType", "]", ";", "$", "class", "=", "\"erdiko\\core\\cache\\\\\"", ".", "$", "cacheConfig", "[", "\"type\"", "]", ";", "return", "new", "$", "class", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Get the configured cache instance using name @return cache $cache returns the instance of the cache type
[ "Get", "the", "configured", "cache", "instance", "using", "name" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Helper.php#L177-L189
scherersoftware/cake-monitor
src/Error/ConsoleErrorHandler.php
ConsoleErrorHandler.handleError
public function handleError($code, $description, $file = null, $line = null, $context = null) { $exception = new ErrorException($description, 0, $code, $file, $line); $sentryHandler = new SentryHandler(); $sentryHandler->handle($exception); return parent::handleError($code, $description, $file, $line, $context); }
php
public function handleError($code, $description, $file = null, $line = null, $context = null) { $exception = new ErrorException($description, 0, $code, $file, $line); $sentryHandler = new SentryHandler(); $sentryHandler->handle($exception); return parent::handleError($code, $description, $file, $line, $context); }
[ "public", "function", "handleError", "(", "$", "code", ",", "$", "description", ",", "$", "file", "=", "null", ",", "$", "line", "=", "null", ",", "$", "context", "=", "null", ")", "{", "$", "exception", "=", "new", "ErrorException", "(", "$", "description", ",", "0", ",", "$", "code", ",", "$", "file", ",", "$", "line", ")", ";", "$", "sentryHandler", "=", "new", "SentryHandler", "(", ")", ";", "$", "sentryHandler", "->", "handle", "(", "$", "exception", ")", ";", "return", "parent", "::", "handleError", "(", "$", "code", ",", "$", "description", ",", "$", "file", ",", "$", "line", ",", "$", "context", ")", ";", "}" ]
Set as the default error handler by CakePHP. @param int $code Code of error @param string $description Error description @param string|null $file File on which error occurred @param int|null $line Line that triggered the error @param array|null $context Context @return bool True if error was handled
[ "Set", "as", "the", "default", "error", "handler", "by", "CakePHP", "." ]
train
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Error/ConsoleErrorHandler.php#L20-L26
scherersoftware/cake-monitor
src/Error/ConsoleErrorHandler.php
ConsoleErrorHandler.handleException
public function handleException(Exception $exception) { $sentryHandler = new SentryHandler(); $sentryHandler->handle($exception); return parent::handleException($exception); }
php
public function handleException(Exception $exception) { $sentryHandler = new SentryHandler(); $sentryHandler->handle($exception); return parent::handleException($exception); }
[ "public", "function", "handleException", "(", "Exception", "$", "exception", ")", "{", "$", "sentryHandler", "=", "new", "SentryHandler", "(", ")", ";", "$", "sentryHandler", "->", "handle", "(", "$", "exception", ")", ";", "return", "parent", "::", "handleException", "(", "$", "exception", ")", ";", "}" ]
Handle uncaught exceptions. @param \Exception $exception Exception instance. @return void @throws \Exception When renderer class not found @see http://php.net/manual/en/function.set-exception-handler.php
[ "Handle", "uncaught", "exceptions", "." ]
train
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Error/ConsoleErrorHandler.php#L36-L41
ouropencode/dachi
src/Database.php
Database.initialize
public static function initialize() { $paths = array_merge( array_filter(glob('src/*'), 'is_dir'), array_filter(glob('src-*/*'), 'is_dir'), array_filter(glob(__DIR__ . '/../../*/src/*/'), 'is_dir') ); $db_params = array( "url" => Configuration::get("database.uri", "sqlite:///:memory:") ); $cache = null; if(Configuration::get("database.cache", "false") == "false") $cache = new \Doctrine\Common\Cache\ArrayCache; $config = Setup::createAnnotationMetadataConfiguration($paths, Configuration::get("debug.database", "false") == "true", "cache", $cache); foreach(Modules::getAll() as $module) $config->addEntityNamespace($module->getShortName(), $module->getNamespace() . "\\Models"); self::$entity_manager = EntityManager::create($db_params, $config); }
php
public static function initialize() { $paths = array_merge( array_filter(glob('src/*'), 'is_dir'), array_filter(glob('src-*/*'), 'is_dir'), array_filter(glob(__DIR__ . '/../../*/src/*/'), 'is_dir') ); $db_params = array( "url" => Configuration::get("database.uri", "sqlite:///:memory:") ); $cache = null; if(Configuration::get("database.cache", "false") == "false") $cache = new \Doctrine\Common\Cache\ArrayCache; $config = Setup::createAnnotationMetadataConfiguration($paths, Configuration::get("debug.database", "false") == "true", "cache", $cache); foreach(Modules::getAll() as $module) $config->addEntityNamespace($module->getShortName(), $module->getNamespace() . "\\Models"); self::$entity_manager = EntityManager::create($db_params, $config); }
[ "public", "static", "function", "initialize", "(", ")", "{", "$", "paths", "=", "array_merge", "(", "array_filter", "(", "glob", "(", "'src/*'", ")", ",", "'is_dir'", ")", ",", "array_filter", "(", "glob", "(", "'src-*/*'", ")", ",", "'is_dir'", ")", ",", "array_filter", "(", "glob", "(", "__DIR__", ".", "'/../../*/src/*/'", ")", ",", "'is_dir'", ")", ")", ";", "$", "db_params", "=", "array", "(", "\"url\"", "=>", "Configuration", "::", "get", "(", "\"database.uri\"", ",", "\"sqlite:///:memory:\"", ")", ")", ";", "$", "cache", "=", "null", ";", "if", "(", "Configuration", "::", "get", "(", "\"database.cache\"", ",", "\"false\"", ")", "==", "\"false\"", ")", "$", "cache", "=", "new", "\\", "Doctrine", "\\", "Common", "\\", "Cache", "\\", "ArrayCache", ";", "$", "config", "=", "Setup", "::", "createAnnotationMetadataConfiguration", "(", "$", "paths", ",", "Configuration", "::", "get", "(", "\"debug.database\"", ",", "\"false\"", ")", "==", "\"true\"", ",", "\"cache\"", ",", "$", "cache", ")", ";", "foreach", "(", "Modules", "::", "getAll", "(", ")", "as", "$", "module", ")", "$", "config", "->", "addEntityNamespace", "(", "$", "module", "->", "getShortName", "(", ")", ",", "$", "module", "->", "getNamespace", "(", ")", ".", "\"\\\\Models\"", ")", ";", "self", "::", "$", "entity_manager", "=", "EntityManager", "::", "create", "(", "$", "db_params", ",", "$", "config", ")", ";", "}" ]
Initialize the Doctrine database engine. This will connect to the database uri specified in the configuration. If the database uri cannot be found, an in-memory sqlite instance will be used. @return null
[ "Initialize", "the", "Doctrine", "database", "engine", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L26-L47
ouropencode/dachi
src/Database.php
Database.getRepository
public static function getRepository() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "getRepository"), func_get_args()); }
php
public static function getRepository() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "getRepository"), func_get_args()); }
[ "public", "static", "function", "getRepository", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"getRepository\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 getRepository function. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return EntityRepository
[ "Wrapper", "to", "the", "Doctrine2", "getRepository", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L68-L73
ouropencode/dachi
src/Database.php
Database.find
public static function find() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "find"), func_get_args()); }
php
public static function find() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "find"), func_get_args()); }
[ "public", "static", "function", "find", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"find\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 find function. This function will call the 'find' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return mixed
[ "Wrapper", "to", "the", "Doctrine2", "find", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L83-L88
ouropencode/dachi
src/Database.php
Database.flush
public static function flush() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "flush"), func_get_args()); }
php
public static function flush() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "flush"), func_get_args()); }
[ "public", "static", "function", "flush", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"flush\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 flush function. This function will call the 'flush' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return null
[ "Wrapper", "to", "the", "Doctrine2", "flush", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L98-L103
ouropencode/dachi
src/Database.php
Database.persist
public static function persist() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "persist"), func_get_args()); }
php
public static function persist() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "persist"), func_get_args()); }
[ "public", "static", "function", "persist", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"persist\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 persist function. This function will call the 'persist' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return null
[ "Wrapper", "to", "the", "Doctrine2", "persist", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L113-L118
ouropencode/dachi
src/Database.php
Database.remove
public static function remove() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "remove"), func_get_args()); }
php
public static function remove() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "remove"), func_get_args()); }
[ "public", "static", "function", "remove", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"remove\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 remove function. This function will call the 'remove' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return null
[ "Wrapper", "to", "the", "Doctrine2", "remove", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L128-L133
ouropencode/dachi
src/Database.php
Database.createQuery
public static function createQuery() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createQuery"), func_get_args()); }
php
public static function createQuery() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createQuery"), func_get_args()); }
[ "public", "static", "function", "createQuery", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"createQuery\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 createQuery function. This function will call the 'createQuery' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return mixed
[ "Wrapper", "to", "the", "Doctrine2", "createQuery", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L143-L148
ouropencode/dachi
src/Database.php
Database.createQueryBuilder
public static function createQueryBuilder() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createQueryBuilder"), func_get_args()); }
php
public static function createQueryBuilder() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createQueryBuilder"), func_get_args()); }
[ "public", "static", "function", "createQueryBuilder", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"createQueryBuilder\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 createQueryBuilder function. This function will call the 'createQueryBuilder' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return mixed
[ "Wrapper", "to", "the", "Doctrine2", "createQueryBuilder", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L158-L163
ouropencode/dachi
src/Database.php
Database.createNativeQuery
public static function createNativeQuery() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createNativeQuery"), func_get_args()); }
php
public static function createNativeQuery() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "createNativeQuery"), func_get_args()); }
[ "public", "static", "function", "createNativeQuery", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"createNativeQuery\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 createNativeQuery function. This function will call the 'createNativeQuery' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return mixed
[ "Wrapper", "to", "the", "Doctrine2", "createNativeQuery", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L172-L177
ouropencode/dachi
src/Database.php
Database.getReference
public static function getReference() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "getReference"), func_get_args()); }
php
public static function getReference() { if(self::$entity_manager == null) self::initialize(); return call_user_func_array(array(self::$entity_manager, "getReference"), func_get_args()); }
[ "public", "static", "function", "getReference", "(", ")", "{", "if", "(", "self", "::", "$", "entity_manager", "==", "null", ")", "self", "::", "initialize", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "entity_manager", ",", "\"getReference\"", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Wrapper to the Doctrine2 getReference function. This function will call the 'getReference' function on the Doctrine2 Entity Manager. @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/index.html @return mixed
[ "Wrapper", "to", "the", "Doctrine2", "getReference", "function", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Database.php#L187-L192
nabab/bbn
src/bbn/user.php
user._login
private function _login($id){ if ( $this->check() && $id ){ $this ->_authenticate($id) ->_user_info() ->_init_dir(true) ->save_session(); } return $this; }
php
private function _login($id){ if ( $this->check() && $id ){ $this ->_authenticate($id) ->_user_info() ->_init_dir(true) ->save_session(); } return $this; }
[ "private", "function", "_login", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "$", "id", ")", "{", "$", "this", "->", "_authenticate", "(", "$", "id", ")", "->", "_user_info", "(", ")", "->", "_init_dir", "(", "true", ")", "->", "save_session", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
initialize and saves session @return $this
[ "initialize", "and", "saves", "session" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L225-L234
nabab/bbn
src/bbn/user.php
user._user_info
private function _user_info(){ if ( $this->get_id() ){ if ( !empty($this->get_session('cfg')) ){ $this->cfg = $this->get_session('cfg'); $this->id_group = $this->get_session('id_group'); } else if ( $d = $this->db->rselect( $this->class_cfg['tables']['users'], array_unique(array_values($this->fields)), x::merge_arrays( $this->class_cfg['conditions'], [$this->fields['active'] => 1], [$this->fields['id'] => $this->id])) ){ $r = []; foreach ( $d as $key => $val ){ $this->$key = $val; $r[$key] = $key === $this->fields['cfg'] ? json_decode($val, true) : $val; } $this->cfg = $r['cfg'] ?: []; // Group $this->id_group = $r['id_group']; $this->session->set($r, self::$un); $this->save_session(); } } return $this; }
php
private function _user_info(){ if ( $this->get_id() ){ if ( !empty($this->get_session('cfg')) ){ $this->cfg = $this->get_session('cfg'); $this->id_group = $this->get_session('id_group'); } else if ( $d = $this->db->rselect( $this->class_cfg['tables']['users'], array_unique(array_values($this->fields)), x::merge_arrays( $this->class_cfg['conditions'], [$this->fields['active'] => 1], [$this->fields['id'] => $this->id])) ){ $r = []; foreach ( $d as $key => $val ){ $this->$key = $val; $r[$key] = $key === $this->fields['cfg'] ? json_decode($val, true) : $val; } $this->cfg = $r['cfg'] ?: []; // Group $this->id_group = $r['id_group']; $this->session->set($r, self::$un); $this->save_session(); } } return $this; }
[ "private", "function", "_user_info", "(", ")", "{", "if", "(", "$", "this", "->", "get_id", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "get_session", "(", "'cfg'", ")", ")", ")", "{", "$", "this", "->", "cfg", "=", "$", "this", "->", "get_session", "(", "'cfg'", ")", ";", "$", "this", "->", "id_group", "=", "$", "this", "->", "get_session", "(", "'id_group'", ")", ";", "}", "else", "if", "(", "$", "d", "=", "$", "this", "->", "db", "->", "rselect", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'users'", "]", ",", "array_unique", "(", "array_values", "(", "$", "this", "->", "fields", ")", ")", ",", "x", "::", "merge_arrays", "(", "$", "this", "->", "class_cfg", "[", "'conditions'", "]", ",", "[", "$", "this", "->", "fields", "[", "'active'", "]", "=>", "1", "]", ",", "[", "$", "this", "->", "fields", "[", "'id'", "]", "=>", "$", "this", "->", "id", "]", ")", ")", ")", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "d", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "$", "key", "=", "$", "val", ";", "$", "r", "[", "$", "key", "]", "=", "$", "key", "===", "$", "this", "->", "fields", "[", "'cfg'", "]", "?", "json_decode", "(", "$", "val", ",", "true", ")", ":", "$", "val", ";", "}", "$", "this", "->", "cfg", "=", "$", "r", "[", "'cfg'", "]", "?", ":", "[", "]", ";", "// Group", "$", "this", "->", "id_group", "=", "$", "r", "[", "'id_group'", "]", ";", "$", "this", "->", "session", "->", "set", "(", "$", "r", ",", "self", "::", "$", "un", ")", ";", "$", "this", "->", "save_session", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Gathers all the information about a user and puts it in the session The user's table data can be sent as argument if it has already been fetched @param array $d The user's table data @return $this
[ "Gathers", "all", "the", "information", "about", "a", "user", "and", "puts", "it", "in", "the", "session", "The", "user", "s", "table", "data", "can", "be", "sent", "as", "argument", "if", "it", "has", "already", "been", "fetched" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L244-L271
nabab/bbn
src/bbn/user.php
user._sess_info
private function _sess_info($id_session = null){ if ( !str::is_uid($id_session) ){ $id_session = $this->get_id_session(); } else{ $cfg = $this->_get_session('cfg'); } if ( empty($cfg) && str::is_uid($id_session) && ($id = $this->get_session('id')) && ($d = $this->db->rselect( $this->class_cfg['tables']['sessions'], $this->class_cfg['arch']['sessions'], [ $this->class_cfg['arch']['sessions']['id'] => $id_session, $this->class_cfg['arch']['sessions']['id_user'] => $id, $this->class_cfg['arch']['sessions']['opened'] => 1, ])) ){ $cfg = json_decode($d['cfg'], true); } if ( \is_array($cfg) ){ $this->sess_cfg = $cfg; } else{ $this->set_error(14); } return $this; }
php
private function _sess_info($id_session = null){ if ( !str::is_uid($id_session) ){ $id_session = $this->get_id_session(); } else{ $cfg = $this->_get_session('cfg'); } if ( empty($cfg) && str::is_uid($id_session) && ($id = $this->get_session('id')) && ($d = $this->db->rselect( $this->class_cfg['tables']['sessions'], $this->class_cfg['arch']['sessions'], [ $this->class_cfg['arch']['sessions']['id'] => $id_session, $this->class_cfg['arch']['sessions']['id_user'] => $id, $this->class_cfg['arch']['sessions']['opened'] => 1, ])) ){ $cfg = json_decode($d['cfg'], true); } if ( \is_array($cfg) ){ $this->sess_cfg = $cfg; } else{ $this->set_error(14); } return $this; }
[ "private", "function", "_sess_info", "(", "$", "id_session", "=", "null", ")", "{", "if", "(", "!", "str", "::", "is_uid", "(", "$", "id_session", ")", ")", "{", "$", "id_session", "=", "$", "this", "->", "get_id_session", "(", ")", ";", "}", "else", "{", "$", "cfg", "=", "$", "this", "->", "_get_session", "(", "'cfg'", ")", ";", "}", "if", "(", "empty", "(", "$", "cfg", ")", "&&", "str", "::", "is_uid", "(", "$", "id_session", ")", "&&", "(", "$", "id", "=", "$", "this", "->", "get_session", "(", "'id'", ")", ")", "&&", "(", "$", "d", "=", "$", "this", "->", "db", "->", "rselect", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'id'", "]", "=>", "$", "id_session", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'id_user'", "]", "=>", "$", "id", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'opened'", "]", "=>", "1", ",", "]", ")", ")", ")", "{", "$", "cfg", "=", "json_decode", "(", "$", "d", "[", "'cfg'", "]", ",", "true", ")", ";", "}", "if", "(", "\\", "is_array", "(", "$", "cfg", ")", ")", "{", "$", "this", "->", "sess_cfg", "=", "$", "cfg", ";", "}", "else", "{", "$", "this", "->", "set_error", "(", "14", ")", ";", "}", "return", "$", "this", ";", "}" ]
Gathers all the information about the user's session The session's table data can be sent as argument if it has already been fetched @param mixed $d The session's table data or its ID @return $this
[ "Gathers", "all", "the", "information", "about", "the", "user", "s", "session", "The", "session", "s", "table", "data", "can", "be", "sent", "as", "argument", "if", "it", "has", "already", "been", "fetched" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L280-L309
nabab/bbn
src/bbn/user.php
user._retrieve_session
private function _retrieve_session(){ if ( !$this->id ){ // The user ID must be in the session $id_session = $this->get_id_session(); $id = $this->get_session('id'); if ( $id_session && $id ){ $this->_sess_info($id_session); if ( isset($this->sess_cfg['fingerprint']) && ($this->get_print($this->_get_session('fingerprint')) === $this->sess_cfg['fingerprint']) ){ $this ->_authenticate($id) ->_user_info() ->_init_dir() ->save_session(); } else{ $this->set_error(19); } } else{ //$this->set_error(15); } } return $this; }
php
private function _retrieve_session(){ if ( !$this->id ){ // The user ID must be in the session $id_session = $this->get_id_session(); $id = $this->get_session('id'); if ( $id_session && $id ){ $this->_sess_info($id_session); if ( isset($this->sess_cfg['fingerprint']) && ($this->get_print($this->_get_session('fingerprint')) === $this->sess_cfg['fingerprint']) ){ $this ->_authenticate($id) ->_user_info() ->_init_dir() ->save_session(); } else{ $this->set_error(19); } } else{ //$this->set_error(15); } } return $this; }
[ "private", "function", "_retrieve_session", "(", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "// The user ID must be in the session", "$", "id_session", "=", "$", "this", "->", "get_id_session", "(", ")", ";", "$", "id", "=", "$", "this", "->", "get_session", "(", "'id'", ")", ";", "if", "(", "$", "id_session", "&&", "$", "id", ")", "{", "$", "this", "->", "_sess_info", "(", "$", "id_session", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "sess_cfg", "[", "'fingerprint'", "]", ")", "&&", "(", "$", "this", "->", "get_print", "(", "$", "this", "->", "_get_session", "(", "'fingerprint'", ")", ")", "===", "$", "this", "->", "sess_cfg", "[", "'fingerprint'", "]", ")", ")", "{", "$", "this", "->", "_authenticate", "(", "$", "id", ")", "->", "_user_info", "(", ")", "->", "_init_dir", "(", ")", "->", "save_session", "(", ")", ";", "}", "else", "{", "$", "this", "->", "set_error", "(", "19", ")", ";", "}", "}", "else", "{", "//$this->set_error(15);", "}", "}", "return", "$", "this", ";", "}" ]
Retrieves all user info from its session and populates the object @return $this
[ "Retrieves", "all", "user", "info", "from", "its", "session", "and", "populates", "the", "object" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L337-L363
nabab/bbn
src/bbn/user.php
user._init_session
private function _init_session(){ // Getting or creating the session is it doesn't exist yet /** @var user\session */ $this->session = user\session::get_instance(); if ( !$this->session ){ $this->session = new user\session(); } /** @var int $id_session The ID of the session row in the DB */ if ( $id_session = $this->get_id_session() ){ $this->sess_cfg = json_decode($this->db->select_one( $this->class_cfg['tables']['sessions'], $this->class_cfg['arch']['sessions']['cfg'], [$this->class_cfg['arch']['sessions']['id'] => $id_session] ), true); } else{ /** @var string $salt */ $salt = self::make_fingerprint(); /** @var string $fingerprint */ $fingerprint = self::make_fingerprint(); /** @var array $p The fields of the sessions table */ $p =& $this->class_cfg['arch']['sessions']; $this->sess_cfg = [ 'fingerprint' => $this->get_print($fingerprint), 'last_renew' => time() ]; // Inserting the session in the database if ( $this->db->insert($this->class_cfg['tables']['sessions'], [ $p['sess_id'] => $this->session->get_id(), $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 1, $p['last_activity'] => date('Y-m-d H:i:s'), $p['creation'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ]) ){ // Setting the session with its ID $id_session = $this->db->last_id(); $this->session->set([ 'fingerprint' => $fingerprint, 'tokens' => [], 'id_session' => $id_session, 'salt' => $salt ], self::$sn); $this->save_session(); } else{ $this->set_error(16); } } return $this; }
php
private function _init_session(){ // Getting or creating the session is it doesn't exist yet /** @var user\session */ $this->session = user\session::get_instance(); if ( !$this->session ){ $this->session = new user\session(); } /** @var int $id_session The ID of the session row in the DB */ if ( $id_session = $this->get_id_session() ){ $this->sess_cfg = json_decode($this->db->select_one( $this->class_cfg['tables']['sessions'], $this->class_cfg['arch']['sessions']['cfg'], [$this->class_cfg['arch']['sessions']['id'] => $id_session] ), true); } else{ /** @var string $salt */ $salt = self::make_fingerprint(); /** @var string $fingerprint */ $fingerprint = self::make_fingerprint(); /** @var array $p The fields of the sessions table */ $p =& $this->class_cfg['arch']['sessions']; $this->sess_cfg = [ 'fingerprint' => $this->get_print($fingerprint), 'last_renew' => time() ]; // Inserting the session in the database if ( $this->db->insert($this->class_cfg['tables']['sessions'], [ $p['sess_id'] => $this->session->get_id(), $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 1, $p['last_activity'] => date('Y-m-d H:i:s'), $p['creation'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ]) ){ // Setting the session with its ID $id_session = $this->db->last_id(); $this->session->set([ 'fingerprint' => $fingerprint, 'tokens' => [], 'id_session' => $id_session, 'salt' => $salt ], self::$sn); $this->save_session(); } else{ $this->set_error(16); } } return $this; }
[ "private", "function", "_init_session", "(", ")", "{", "// Getting or creating the session is it doesn't exist yet", "/** @var user\\session */", "$", "this", "->", "session", "=", "user", "\\", "session", "::", "get_instance", "(", ")", ";", "if", "(", "!", "$", "this", "->", "session", ")", "{", "$", "this", "->", "session", "=", "new", "user", "\\", "session", "(", ")", ";", "}", "/** @var int $id_session The ID of the session row in the DB */", "if", "(", "$", "id_session", "=", "$", "this", "->", "get_id_session", "(", ")", ")", "{", "$", "this", "->", "sess_cfg", "=", "json_decode", "(", "$", "this", "->", "db", "->", "select_one", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'cfg'", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'id'", "]", "=>", "$", "id_session", "]", ")", ",", "true", ")", ";", "}", "else", "{", "/** @var string $salt */", "$", "salt", "=", "self", "::", "make_fingerprint", "(", ")", ";", "/** @var string $fingerprint */", "$", "fingerprint", "=", "self", "::", "make_fingerprint", "(", ")", ";", "/** @var array $p The fields of the sessions table */", "$", "p", "=", "&", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", ";", "$", "this", "->", "sess_cfg", "=", "[", "'fingerprint'", "=>", "$", "this", "->", "get_print", "(", "$", "fingerprint", ")", ",", "'last_renew'", "=>", "time", "(", ")", "]", ";", "// Inserting the session in the database", "if", "(", "$", "this", "->", "db", "->", "insert", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "[", "$", "p", "[", "'sess_id'", "]", "=>", "$", "this", "->", "session", "->", "get_id", "(", ")", ",", "$", "p", "[", "'ip_address'", "]", "=>", "$", "this", "->", "ip_address", ",", "$", "p", "[", "'user_agent'", "]", "=>", "$", "this", "->", "user_agent", ",", "$", "p", "[", "'opened'", "]", "=>", "1", ",", "$", "p", "[", "'last_activity'", "]", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "$", "p", "[", "'creation'", "]", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "$", "p", "[", "'cfg'", "]", "=>", "json_encode", "(", "$", "this", "->", "sess_cfg", ")", "]", ")", ")", "{", "// Setting the session with its ID", "$", "id_session", "=", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "$", "this", "->", "session", "->", "set", "(", "[", "'fingerprint'", "=>", "$", "fingerprint", ",", "'tokens'", "=>", "[", "]", ",", "'id_session'", "=>", "$", "id_session", ",", "'salt'", "=>", "$", "salt", "]", ",", "self", "::", "$", "sn", ")", ";", "$", "this", "->", "save_session", "(", ")", ";", "}", "else", "{", "$", "this", "->", "set_error", "(", "16", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sets the user's session for the first time and creates the session's DB row @return $this
[ "Sets", "the", "user", "s", "session", "for", "the", "first", "time", "and", "creates", "the", "session", "s", "DB", "row" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L369-L428
nabab/bbn
src/bbn/user.php
user._set_session
private function _set_session($attr){ if ( $this->session->has(self::$sn) ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($args[0]) ){ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->session->set($val, self::$sn, $key); } } } return $this; }
php
private function _set_session($attr){ if ( $this->session->has(self::$sn) ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($args[0]) ){ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->session->set($val, self::$sn, $key); } } } return $this; }
[ "private", "function", "_set_session", "(", "$", "attr", ")", "{", "if", "(", "$", "this", "->", "session", "->", "has", "(", "self", "::", "$", "sn", ")", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "(", "\\", "count", "(", "$", "args", ")", "===", "2", ")", "&&", "\\", "is_string", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "attr", "=", "[", "$", "args", "[", "0", "]", "=>", "$", "args", "[", "1", "]", "]", ";", "}", "foreach", "(", "$", "attr", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "\\", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "session", "->", "set", "(", "$", "val", ",", "self", "::", "$", "sn", ",", "$", "key", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Sets the "session" part of the session @param mixed $attr @return $this $this
[ "Sets", "the", "session", "part", "of", "the", "session" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L435-L448
nabab/bbn
src/bbn/user.php
user._get_session
private function _get_session($attr){ //die(\bbn\x::hdump(self::$sn, $this->session->has(self::$sn), $attr, $this->session->get(self::$sn))); if ( $this->session->has(self::$sn) ){ return $attr ? $this->session->get(self::$sn, $attr) : $this->session->get(self::$sn); } }
php
private function _get_session($attr){ //die(\bbn\x::hdump(self::$sn, $this->session->has(self::$sn), $attr, $this->session->get(self::$sn))); if ( $this->session->has(self::$sn) ){ return $attr ? $this->session->get(self::$sn, $attr) : $this->session->get(self::$sn); } }
[ "private", "function", "_get_session", "(", "$", "attr", ")", "{", "//die(\\bbn\\x::hdump(self::$sn, $this->session->has(self::$sn), $attr, $this->session->get(self::$sn)));", "if", "(", "$", "this", "->", "session", "->", "has", "(", "self", "::", "$", "sn", ")", ")", "{", "return", "$", "attr", "?", "$", "this", "->", "session", "->", "get", "(", "self", "::", "$", "sn", ",", "$", "attr", ")", ":", "$", "this", "->", "session", "->", "get", "(", "self", "::", "$", "sn", ")", ";", "}", "}" ]
Gets the "session" part of the session @param string $attr @return mixed
[ "Gets", "the", "session", "part", "of", "the", "session" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L455-L462
nabab/bbn
src/bbn/user.php
user._check_credentials
private function _check_credentials($params){ if ( $this->check() ){ /** @var array $f The form fields sent to identify the users */ $f =& $this->class_cfg['fields']; if ( !isset($params[$f['salt']]) ){ $this->set_error(11); } else{ if ( !$this->check_salt($params[$f['salt']]) ){ $this->set_error(17); } } if ( $this->check() ){ if ( isset($params[$f['user']], $params[$f['pass']]) ){ // Table structure $arch =& $this->class_cfg['arch']; $this->just_login = 1; // Database Query if ( $id = $this->db->select_one( $this->class_cfg['tables']['users'], $this->fields['id'], x::merge_arrays( $this->class_cfg['conditions'], [$arch['users']['active'] => 1], [($arch['users']['login'] ?? $arch['users']['email']) => $params[$f['user']]]) ) ){ $pass = $this->db->select_one( $this->class_cfg['tables']['passwords'], $arch['passwords']['pass'], [$arch['passwords']['id_user'] => $id], [$arch['passwords']['added'] => 'DESC']); if ( $this->_check_password($params[$f['pass']], $pass) ){ $this->_login($id); } else{ $this->record_attempt(); // Canceling authentication if num_attempts > max_attempts $this->set_error($this->check_attempts() ? 6 : 4); } } else{ $this->set_error(6); } } else{ $this->set_error(12); } } } else{ die(var_dump($this->get_error())); } return $this->auth; }
php
private function _check_credentials($params){ if ( $this->check() ){ /** @var array $f The form fields sent to identify the users */ $f =& $this->class_cfg['fields']; if ( !isset($params[$f['salt']]) ){ $this->set_error(11); } else{ if ( !$this->check_salt($params[$f['salt']]) ){ $this->set_error(17); } } if ( $this->check() ){ if ( isset($params[$f['user']], $params[$f['pass']]) ){ // Table structure $arch =& $this->class_cfg['arch']; $this->just_login = 1; // Database Query if ( $id = $this->db->select_one( $this->class_cfg['tables']['users'], $this->fields['id'], x::merge_arrays( $this->class_cfg['conditions'], [$arch['users']['active'] => 1], [($arch['users']['login'] ?? $arch['users']['email']) => $params[$f['user']]]) ) ){ $pass = $this->db->select_one( $this->class_cfg['tables']['passwords'], $arch['passwords']['pass'], [$arch['passwords']['id_user'] => $id], [$arch['passwords']['added'] => 'DESC']); if ( $this->_check_password($params[$f['pass']], $pass) ){ $this->_login($id); } else{ $this->record_attempt(); // Canceling authentication if num_attempts > max_attempts $this->set_error($this->check_attempts() ? 6 : 4); } } else{ $this->set_error(6); } } else{ $this->set_error(12); } } } else{ die(var_dump($this->get_error())); } return $this->auth; }
[ "private", "function", "_check_credentials", "(", "$", "params", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "/** @var array $f The form fields sent to identify the users */", "$", "f", "=", "&", "$", "this", "->", "class_cfg", "[", "'fields'", "]", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "$", "f", "[", "'salt'", "]", "]", ")", ")", "{", "$", "this", "->", "set_error", "(", "11", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "check_salt", "(", "$", "params", "[", "$", "f", "[", "'salt'", "]", "]", ")", ")", "{", "$", "this", "->", "set_error", "(", "17", ")", ";", "}", "}", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "$", "f", "[", "'user'", "]", "]", ",", "$", "params", "[", "$", "f", "[", "'pass'", "]", "]", ")", ")", "{", "// Table structure", "$", "arch", "=", "&", "$", "this", "->", "class_cfg", "[", "'arch'", "]", ";", "$", "this", "->", "just_login", "=", "1", ";", "// Database Query", "if", "(", "$", "id", "=", "$", "this", "->", "db", "->", "select_one", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'users'", "]", ",", "$", "this", "->", "fields", "[", "'id'", "]", ",", "x", "::", "merge_arrays", "(", "$", "this", "->", "class_cfg", "[", "'conditions'", "]", ",", "[", "$", "arch", "[", "'users'", "]", "[", "'active'", "]", "=>", "1", "]", ",", "[", "(", "$", "arch", "[", "'users'", "]", "[", "'login'", "]", "??", "$", "arch", "[", "'users'", "]", "[", "'email'", "]", ")", "=>", "$", "params", "[", "$", "f", "[", "'user'", "]", "]", "]", ")", ")", ")", "{", "$", "pass", "=", "$", "this", "->", "db", "->", "select_one", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'passwords'", "]", ",", "$", "arch", "[", "'passwords'", "]", "[", "'pass'", "]", ",", "[", "$", "arch", "[", "'passwords'", "]", "[", "'id_user'", "]", "=>", "$", "id", "]", ",", "[", "$", "arch", "[", "'passwords'", "]", "[", "'added'", "]", "=>", "'DESC'", "]", ")", ";", "if", "(", "$", "this", "->", "_check_password", "(", "$", "params", "[", "$", "f", "[", "'pass'", "]", "]", ",", "$", "pass", ")", ")", "{", "$", "this", "->", "_login", "(", "$", "id", ")", ";", "}", "else", "{", "$", "this", "->", "record_attempt", "(", ")", ";", "// Canceling authentication if num_attempts > max_attempts", "$", "this", "->", "set_error", "(", "$", "this", "->", "check_attempts", "(", ")", "?", "6", ":", "4", ")", ";", "}", "}", "else", "{", "$", "this", "->", "set_error", "(", "6", ")", ";", "}", "}", "else", "{", "$", "this", "->", "set_error", "(", "12", ")", ";", "}", "}", "}", "else", "{", "die", "(", "var_dump", "(", "$", "this", "->", "get_error", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "auth", ";", "}" ]
Checks the credentials of a user @param array $params @return mixed
[ "Checks", "the", "credentials", "of", "a", "user" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L469-L528
nabab/bbn
src/bbn/user.php
user._init_dir
private function _init_dir($create = false){ if ( \defined('BBN_DATA_PATH') && $this->get_id() ){ $this->path = BBN_DATA_PATH.'users/'.$this->get_id().'/'; if ( !\defined('BBN_USER_PATH') ){ define('BBN_USER_PATH', $this->path); } if ( $create ){ file\dir::create_path(BBN_USER_PATH.'tmp'); file\dir::delete(BBN_USER_PATH.'tmp', false); } } return $this; }
php
private function _init_dir($create = false){ if ( \defined('BBN_DATA_PATH') && $this->get_id() ){ $this->path = BBN_DATA_PATH.'users/'.$this->get_id().'/'; if ( !\defined('BBN_USER_PATH') ){ define('BBN_USER_PATH', $this->path); } if ( $create ){ file\dir::create_path(BBN_USER_PATH.'tmp'); file\dir::delete(BBN_USER_PATH.'tmp', false); } } return $this; }
[ "private", "function", "_init_dir", "(", "$", "create", "=", "false", ")", "{", "if", "(", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", "&&", "$", "this", "->", "get_id", "(", ")", ")", "{", "$", "this", "->", "path", "=", "BBN_DATA_PATH", ".", "'users/'", ".", "$", "this", "->", "get_id", "(", ")", ".", "'/'", ";", "if", "(", "!", "\\", "defined", "(", "'BBN_USER_PATH'", ")", ")", "{", "define", "(", "'BBN_USER_PATH'", ",", "$", "this", "->", "path", ")", ";", "}", "if", "(", "$", "create", ")", "{", "file", "\\", "dir", "::", "create_path", "(", "BBN_USER_PATH", ".", "'tmp'", ")", ";", "file", "\\", "dir", "::", "delete", "(", "BBN_USER_PATH", ".", "'tmp'", ",", "false", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
If BBN_DATA_PATH is defined creates a directory and removes temp files @return $this $this
[ "If", "BBN_DATA_PATH", "is", "defined", "creates", "a", "directory", "and", "removes", "temp", "files" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L534-L546
nabab/bbn
src/bbn/user.php
user._authenticate
private function _authenticate($id){ if ( $this->check() && $id ){ $this->id = $id; $this->auth = 1; $this->db->update($this->class_cfg['tables']['sessions'], [ $this->class_cfg['arch']['sessions']['id_user'] => $id ], [ $this->class_cfg['arch']['sessions']['id'] => $this->get_id_session() ]); } return $this; }
php
private function _authenticate($id){ if ( $this->check() && $id ){ $this->id = $id; $this->auth = 1; $this->db->update($this->class_cfg['tables']['sessions'], [ $this->class_cfg['arch']['sessions']['id_user'] => $id ], [ $this->class_cfg['arch']['sessions']['id'] => $this->get_id_session() ]); } return $this; }
[ "private", "function", "_authenticate", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "$", "id", ")", "{", "$", "this", "->", "id", "=", "$", "id", ";", "$", "this", "->", "auth", "=", "1", ";", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'id_user'", "]", "=>", "$", "id", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", "[", "'id'", "]", "=>", "$", "this", "->", "get_id_session", "(", ")", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a user as authenticated ($this->auth = 1) @param int $id @return $this
[ "Sets", "a", "user", "as", "authenticated", "(", "$this", "-", ">", "auth", "=", "1", ")" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L553-L564
nabab/bbn
src/bbn/user.php
user.get_error
public function get_error(){ if ( $this->error ){ return [ 'code' => $this->error, 'text' => $this->class_cfg['errors'][$this->error] ]; } return false; }
php
public function get_error(){ if ( $this->error ){ return [ 'code' => $this->error, 'text' => $this->class_cfg['errors'][$this->error] ]; } return false; }
[ "public", "function", "get_error", "(", ")", "{", "if", "(", "$", "this", "->", "error", ")", "{", "return", "[", "'code'", "=>", "$", "this", "->", "error", ",", "'text'", "=>", "$", "this", "->", "class_cfg", "[", "'errors'", "]", "[", "$", "this", "->", "error", "]", "]", ";", "}", "return", "false", ";", "}" ]
Returns the last known error and false if there was no error @return mixed
[ "Returns", "the", "last", "known", "error", "and", "false", "if", "there", "was", "no", "error" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L575-L583
nabab/bbn
src/bbn/user.php
user.get_print
protected function get_print(string $fp = null){ if ( !$fp ){ $fp = $this->_get_session('fingerprint'); } if ( $fp ){ return sha1($this->user_agent.$this->accept_lang./*$this->ip_address .*/ $fp); } return false; }
php
protected function get_print(string $fp = null){ if ( !$fp ){ $fp = $this->_get_session('fingerprint'); } if ( $fp ){ return sha1($this->user_agent.$this->accept_lang./*$this->ip_address .*/ $fp); } return false; }
[ "protected", "function", "get_print", "(", "string", "$", "fp", "=", "null", ")", "{", "if", "(", "!", "$", "fp", ")", "{", "$", "fp", "=", "$", "this", "->", "_get_session", "(", "'fingerprint'", ")", ";", "}", "if", "(", "$", "fp", ")", "{", "return", "sha1", "(", "$", "this", "->", "user_agent", ".", "$", "this", "->", "accept_lang", ".", "/*$this->ip_address .*/", "$", "fp", ")", ";", "}", "return", "false", ";", "}" ]
Returns a "print", ie an identifier based on the user agent @param false|string $fp @return string
[ "Returns", "a", "print", "ie", "an", "identifier", "based", "on", "the", "user", "agent" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L590-L598
nabab/bbn
src/bbn/user.php
user.record_attempt
protected function record_attempt(){ $this->cfg['num_attempts'] = isset($this->cfg['num_attempts']) ? $this->cfg['num_attempts']+1 : 1; $this->_set_session('num_attempts', $this->cfg['num_attempts']); $this->save_session(); return $this; }
php
protected function record_attempt(){ $this->cfg['num_attempts'] = isset($this->cfg['num_attempts']) ? $this->cfg['num_attempts']+1 : 1; $this->_set_session('num_attempts', $this->cfg['num_attempts']); $this->save_session(); return $this; }
[ "protected", "function", "record_attempt", "(", ")", "{", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", "=", "isset", "(", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", ")", "?", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", "+", "1", ":", "1", ";", "$", "this", "->", "_set_session", "(", "'num_attempts'", ",", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", ")", ";", "$", "this", "->", "save_session", "(", ")", ";", "return", "$", "this", ";", "}" ]
Increment the num_attempt variable @return $this
[ "Increment", "the", "num_attempt", "variable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L612-L618
nabab/bbn
src/bbn/user.php
user.get_cfg
public function get_cfg($attr = ''){ if ( $this->check() ){ if ( !$this->cfg ){ $this->cfg = $this->session->get('cfg'); } if ( empty($attr) ){ return $this->cfg; } if ( isset($this->cfg[$attr]) ){ return $this->cfg[$attr]; } return false; } }
php
public function get_cfg($attr = ''){ if ( $this->check() ){ if ( !$this->cfg ){ $this->cfg = $this->session->get('cfg'); } if ( empty($attr) ){ return $this->cfg; } if ( isset($this->cfg[$attr]) ){ return $this->cfg[$attr]; } return false; } }
[ "public", "function", "get_cfg", "(", "$", "attr", "=", "''", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "cfg", ")", "{", "$", "this", "->", "cfg", "=", "$", "this", "->", "session", "->", "get", "(", "'cfg'", ")", ";", "}", "if", "(", "empty", "(", "$", "attr", ")", ")", "{", "return", "$", "this", "->", "cfg", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "cfg", "[", "$", "attr", "]", ")", ")", "{", "return", "$", "this", "->", "cfg", "[", "$", "attr", "]", ";", "}", "return", "false", ";", "}", "}" ]
Returns the current user's configuration. @param string $attr @return mixed
[ "Returns", "the", "current", "user", "s", "configuration", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L698-L711
nabab/bbn
src/bbn/user.php
user.get_fields
public function get_fields(string $table = ''): ?array { if ( !empty($this->class_cfg) ){ if ( $table ){ return $this->class_cfg['arch'][$table] ?? null; } return $this->class_cfg['arch']; } return null; }
php
public function get_fields(string $table = ''): ?array { if ( !empty($this->class_cfg) ){ if ( $table ){ return $this->class_cfg['arch'][$table] ?? null; } return $this->class_cfg['arch']; } return null; }
[ "public", "function", "get_fields", "(", "string", "$", "table", "=", "''", ")", ":", "?", "array", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "class_cfg", ")", ")", "{", "if", "(", "$", "table", ")", "{", "return", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "$", "table", "]", "??", "null", ";", "}", "return", "$", "this", "->", "class_cfg", "[", "'arch'", "]", ";", "}", "return", "null", ";", "}" ]
Returns the list of fields of the given table, and if empty the list of fields for each table. @param string $table @return array|null
[ "Returns", "the", "list", "of", "fields", "of", "the", "given", "table", "and", "if", "empty", "the", "list", "of", "fields", "for", "each", "table", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L759-L768
nabab/bbn
src/bbn/user.php
user.update_info
public function update_info(array $d) { if ( $this->check_session() ){ $update = []; foreach ( $d as $key => $val ){ if ( ($key !== $this->fields['id']) && ($key !== $this->fields['cfg']) && ($key !== 'auth') && ($key !== 'pass') && \in_array($key, $this->fields) ){ $update[$key] = $val; } } if ( \count($update) > 0 ){ $r = $this->db->update( $this->class_cfg['tables']['users'], $update, [$this->fields['id'] => $this->id]); /** @todo Why did I do this?? */ $this->set_session(['cfg' => false]); $this->_user_info(); return $r; } } return false; }
php
public function update_info(array $d) { if ( $this->check_session() ){ $update = []; foreach ( $d as $key => $val ){ if ( ($key !== $this->fields['id']) && ($key !== $this->fields['cfg']) && ($key !== 'auth') && ($key !== 'pass') && \in_array($key, $this->fields) ){ $update[$key] = $val; } } if ( \count($update) > 0 ){ $r = $this->db->update( $this->class_cfg['tables']['users'], $update, [$this->fields['id'] => $this->id]); /** @todo Why did I do this?? */ $this->set_session(['cfg' => false]); $this->_user_info(); return $r; } } return false; }
[ "public", "function", "update_info", "(", "array", "$", "d", ")", "{", "if", "(", "$", "this", "->", "check_session", "(", ")", ")", "{", "$", "update", "=", "[", "]", ";", "foreach", "(", "$", "d", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "(", "$", "key", "!==", "$", "this", "->", "fields", "[", "'id'", "]", ")", "&&", "(", "$", "key", "!==", "$", "this", "->", "fields", "[", "'cfg'", "]", ")", "&&", "(", "$", "key", "!==", "'auth'", ")", "&&", "(", "$", "key", "!==", "'pass'", ")", "&&", "\\", "in_array", "(", "$", "key", ",", "$", "this", "->", "fields", ")", ")", "{", "$", "update", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "if", "(", "\\", "count", "(", "$", "update", ")", ">", "0", ")", "{", "$", "r", "=", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'users'", "]", ",", "$", "update", ",", "[", "$", "this", "->", "fields", "[", "'id'", "]", "=>", "$", "this", "->", "id", "]", ")", ";", "/** @todo Why did I do this?? */", "$", "this", "->", "set_session", "(", "[", "'cfg'", "=>", "false", "]", ")", ";", "$", "this", "->", "_user_info", "(", ")", ";", "return", "$", "r", ";", "}", "}", "return", "false", ";", "}" ]
Changes the data in the user's table. @param array $d The new data @return bool
[ "Changes", "the", "data", "in", "the", "user", "s", "table", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L777-L804
nabab/bbn
src/bbn/user.php
user.set_session
public function set_session($attr){ if ( $this->session->has(self::$un) ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($args[0]) ){ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->session->set($val, self::$un, $key); } } } return $this; }
php
public function set_session($attr){ if ( $this->session->has(self::$un) ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($args[0]) ){ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->session->set($val, self::$un, $key); } } } return $this; }
[ "public", "function", "set_session", "(", "$", "attr", ")", "{", "if", "(", "$", "this", "->", "session", "->", "has", "(", "self", "::", "$", "un", ")", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "(", "\\", "count", "(", "$", "args", ")", "===", "2", ")", "&&", "\\", "is_string", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "attr", "=", "[", "$", "args", "[", "0", "]", "=>", "$", "args", "[", "1", "]", "]", ";", "}", "foreach", "(", "$", "attr", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "\\", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "session", "->", "set", "(", "$", "val", ",", "self", "::", "$", "un", ",", "$", "key", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Sets the given attribute(s) in the user's session. @return $this
[ "Sets", "the", "given", "attribute", "(", "s", ")", "in", "the", "user", "s", "session", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L833-L846
nabab/bbn
src/bbn/user.php
user.get_session
public function get_session($attr = null){ if ( $this->session->has(self::$un) ){ return $attr ? $this->session->get(self::$un, $attr) : $this->session->get(self::$un); } }
php
public function get_session($attr = null){ if ( $this->session->has(self::$un) ){ return $attr ? $this->session->get(self::$un, $attr) : $this->session->get(self::$un); } }
[ "public", "function", "get_session", "(", "$", "attr", "=", "null", ")", "{", "if", "(", "$", "this", "->", "session", "->", "has", "(", "self", "::", "$", "un", ")", ")", "{", "return", "$", "attr", "?", "$", "this", "->", "session", "->", "get", "(", "self", "::", "$", "un", ",", "$", "attr", ")", ":", "$", "this", "->", "session", "->", "get", "(", "self", "::", "$", "un", ")", ";", "}", "}" ]
Returns session property from the session's user array. @param null|string The property to get @return mixed
[ "Returns", "session", "property", "from", "the", "session", "s", "user", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L854-L858
nabab/bbn
src/bbn/user.php
user.save_session
public function save_session(): self { $id_session = $this->get_id_session(); //die(var_dump($id_session, $this->check())); if ( $id_session && $this->check() ){ $p =& $this->class_cfg['arch']['sessions']; $this->db->update($this->class_cfg['tables']['sessions'], [ $p['id_user'] => $this->id, $p['sess_id'] => $this->session->get_id(), $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 1, $p['last_activity'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ], [ $p['id'] => $id_session ]); } else{ $this->set_error(13); } return $this; }
php
public function save_session(): self { $id_session = $this->get_id_session(); //die(var_dump($id_session, $this->check())); if ( $id_session && $this->check() ){ $p =& $this->class_cfg['arch']['sessions']; $this->db->update($this->class_cfg['tables']['sessions'], [ $p['id_user'] => $this->id, $p['sess_id'] => $this->session->get_id(), $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 1, $p['last_activity'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ], [ $p['id'] => $id_session ]); } else{ $this->set_error(13); } return $this; }
[ "public", "function", "save_session", "(", ")", ":", "self", "{", "$", "id_session", "=", "$", "this", "->", "get_id_session", "(", ")", ";", "//die(var_dump($id_session, $this->check()));", "if", "(", "$", "id_session", "&&", "$", "this", "->", "check", "(", ")", ")", "{", "$", "p", "=", "&", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", ";", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "[", "$", "p", "[", "'id_user'", "]", "=>", "$", "this", "->", "id", ",", "$", "p", "[", "'sess_id'", "]", "=>", "$", "this", "->", "session", "->", "get_id", "(", ")", ",", "$", "p", "[", "'ip_address'", "]", "=>", "$", "this", "->", "ip_address", ",", "$", "p", "[", "'user_agent'", "]", "=>", "$", "this", "->", "user_agent", ",", "$", "p", "[", "'opened'", "]", "=>", "1", ",", "$", "p", "[", "'last_activity'", "]", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "$", "p", "[", "'cfg'", "]", "=>", "json_encode", "(", "$", "this", "->", "sess_cfg", ")", "]", ",", "[", "$", "p", "[", "'id'", "]", "=>", "$", "id_session", "]", ")", ";", "}", "else", "{", "$", "this", "->", "set_error", "(", "13", ")", ";", "}", "return", "$", "this", ";", "}" ]
Saves the session config in the database. @return $this
[ "Saves", "the", "session", "config", "in", "the", "database", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L893-L915
nabab/bbn
src/bbn/user.php
user.close_session
public function close_session($with_session = false): self { $p =& $this->class_cfg['arch']['sessions']; $this->db->update($this->class_cfg['tables']['sessions'], [ $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 0, $p['last_activity'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ],[ $p['id_user'] => $this->id, $p['sess_id'] => $this->session->get_id() ]); $this->auth = false; $this->id = null; $this->sess_cfg = null; if ( $with_session ){ $this->session->set([]); } else{ $this->session->set([], self::$un); } return $this; }
php
public function close_session($with_session = false): self { $p =& $this->class_cfg['arch']['sessions']; $this->db->update($this->class_cfg['tables']['sessions'], [ $p['ip_address'] => $this->ip_address, $p['user_agent'] => $this->user_agent, $p['opened'] => 0, $p['last_activity'] => date('Y-m-d H:i:s'), $p['cfg'] => json_encode($this->sess_cfg) ],[ $p['id_user'] => $this->id, $p['sess_id'] => $this->session->get_id() ]); $this->auth = false; $this->id = null; $this->sess_cfg = null; if ( $with_session ){ $this->session->set([]); } else{ $this->session->set([], self::$un); } return $this; }
[ "public", "function", "close_session", "(", "$", "with_session", "=", "false", ")", ":", "self", "{", "$", "p", "=", "&", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'sessions'", "]", ";", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'sessions'", "]", ",", "[", "$", "p", "[", "'ip_address'", "]", "=>", "$", "this", "->", "ip_address", ",", "$", "p", "[", "'user_agent'", "]", "=>", "$", "this", "->", "user_agent", ",", "$", "p", "[", "'opened'", "]", "=>", "0", ",", "$", "p", "[", "'last_activity'", "]", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "$", "p", "[", "'cfg'", "]", "=>", "json_encode", "(", "$", "this", "->", "sess_cfg", ")", "]", ",", "[", "$", "p", "[", "'id_user'", "]", "=>", "$", "this", "->", "id", ",", "$", "p", "[", "'sess_id'", "]", "=>", "$", "this", "->", "session", "->", "get_id", "(", ")", "]", ")", ";", "$", "this", "->", "auth", "=", "false", ";", "$", "this", "->", "id", "=", "null", ";", "$", "this", "->", "sess_cfg", "=", "null", ";", "if", "(", "$", "with_session", ")", "{", "$", "this", "->", "session", "->", "set", "(", "[", "]", ")", ";", "}", "else", "{", "$", "this", "->", "session", "->", "set", "(", "[", "]", ",", "self", "::", "$", "un", ")", ";", "}", "return", "$", "this", ";", "}" ]
Closes the session in the database, and if $with_session is true, deletes also the session information. @param bool $with_session @return user
[ "Closes", "the", "session", "in", "the", "database", "and", "if", "$with_session", "is", "true", "deletes", "also", "the", "session", "information", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L923-L946
nabab/bbn
src/bbn/user.php
user.check_attempts
public function check_attempts(): bool { if ( !isset($this->cfg) ){ return false; } //die(var_dump($this->session->get('num_attempts'), $this->sess_cfg, $this->session->get('attempts'))); if ( isset($this->cfg['num_attempts']) && $this->cfg['num_attempts'] > $this->class_cfg['max_attempts'] ){ return false; } return true; }
php
public function check_attempts(): bool { if ( !isset($this->cfg) ){ return false; } //die(var_dump($this->session->get('num_attempts'), $this->sess_cfg, $this->session->get('attempts'))); if ( isset($this->cfg['num_attempts']) && $this->cfg['num_attempts'] > $this->class_cfg['max_attempts'] ){ return false; } return true; }
[ "public", "function", "check_attempts", "(", ")", ":", "bool", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cfg", ")", ")", "{", "return", "false", ";", "}", "//die(var_dump($this->session->get('num_attempts'), $this->sess_cfg, $this->session->get('attempts')));", "if", "(", "isset", "(", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", ")", "&&", "$", "this", "->", "cfg", "[", "'num_attempts'", "]", ">", "$", "this", "->", "class_cfg", "[", "'max_attempts'", "]", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns false if the max number of connections attempts has been reached @return bool
[ "Returns", "false", "if", "the", "max", "number", "of", "connections", "attempts", "has", "been", "reached" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L952-L963
nabab/bbn
src/bbn/user.php
user.save_cfg
public function save_cfg() { if ( $this->check() ){ $this->db->update( $this->class_cfg['tables']['users'], [$this->fields['cfg'] => json_encode($this->cfg)], [$this->fields['id'] => $this->id]); } return $this; }
php
public function save_cfg() { if ( $this->check() ){ $this->db->update( $this->class_cfg['tables']['users'], [$this->fields['cfg'] => json_encode($this->cfg)], [$this->fields['id'] => $this->id]); } return $this; }
[ "public", "function", "save_cfg", "(", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'users'", "]", ",", "[", "$", "this", "->", "fields", "[", "'cfg'", "]", "=>", "json_encode", "(", "$", "this", "->", "cfg", ")", "]", ",", "[", "$", "this", "->", "fields", "[", "'id'", "]", "=>", "$", "this", "->", "id", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Saves the user's config in the cfg field of the users' table return connection
[ "Saves", "the", "user", "s", "config", "in", "the", "cfg", "field", "of", "the", "users", "table", "return", "connection" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L969-L978
nabab/bbn
src/bbn/user.php
user.set_cfg
public function set_cfg($attr){ if ( null !== $this->cfg ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($attr) ){ /** @var array $attr */ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->cfg[$key] = $val; } } $this->set_session(['cfg' => $this->cfg]); } return $this; }
php
public function set_cfg($attr){ if ( null !== $this->cfg ){ $args = \func_get_args(); if ( (\count($args) === 2) && \is_string($attr) ){ /** @var array $attr */ $attr = [$args[0] => $args[1]]; } foreach ( $attr as $key => $val ){ if ( \is_string($key) ){ $this->cfg[$key] = $val; } } $this->set_session(['cfg' => $this->cfg]); } return $this; }
[ "public", "function", "set_cfg", "(", "$", "attr", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "cfg", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "(", "\\", "count", "(", "$", "args", ")", "===", "2", ")", "&&", "\\", "is_string", "(", "$", "attr", ")", ")", "{", "/** @var array $attr */", "$", "attr", "=", "[", "$", "args", "[", "0", "]", "=>", "$", "args", "[", "1", "]", "]", ";", "}", "foreach", "(", "$", "attr", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "\\", "is_string", "(", "$", "key", ")", ")", "{", "$", "this", "->", "cfg", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "$", "this", "->", "set_session", "(", "[", "'cfg'", "=>", "$", "this", "->", "cfg", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
return connection
[ "return", "connection" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L983-L998
nabab/bbn
src/bbn/user.php
user.set_password
public function set_password($old_pass, $new_pass){ if ( $this->auth ){ $pwt = $this->class_cfg['tables']['passwords']; $pwa = $this->class_cfg['arch']['passwords']; $stored_pass = $this->db->select_one($pwt, $pwa['pass'], [ $this->class_cfg['arch']['passwords']['id_user'] => $this->id ], [ $this->class_cfg['arch']['passwords']['added'] => 'DESC' ]); if ( $this->_check_password($old_pass, $stored_pass) ){ return $this->force_password($new_pass, $this->get_id()); } } return false; }
php
public function set_password($old_pass, $new_pass){ if ( $this->auth ){ $pwt = $this->class_cfg['tables']['passwords']; $pwa = $this->class_cfg['arch']['passwords']; $stored_pass = $this->db->select_one($pwt, $pwa['pass'], [ $this->class_cfg['arch']['passwords']['id_user'] => $this->id ], [ $this->class_cfg['arch']['passwords']['added'] => 'DESC' ]); if ( $this->_check_password($old_pass, $stored_pass) ){ return $this->force_password($new_pass, $this->get_id()); } } return false; }
[ "public", "function", "set_password", "(", "$", "old_pass", ",", "$", "new_pass", ")", "{", "if", "(", "$", "this", "->", "auth", ")", "{", "$", "pwt", "=", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'passwords'", "]", ";", "$", "pwa", "=", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", ";", "$", "stored_pass", "=", "$", "this", "->", "db", "->", "select_one", "(", "$", "pwt", ",", "$", "pwa", "[", "'pass'", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", "[", "'id_user'", "]", "=>", "$", "this", "->", "id", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", "[", "'added'", "]", "=>", "'DESC'", "]", ")", ";", "if", "(", "$", "this", "->", "_check_password", "(", "$", "old_pass", ",", "$", "stored_pass", ")", ")", "{", "return", "$", "this", "->", "force_password", "(", "$", "new_pass", ",", "$", "this", "->", "get_id", "(", ")", ")", ";", "}", "}", "return", "false", ";", "}" ]
Change the password in the database after checking the current one @return boolean
[ "Change", "the", "password", "in", "the", "database", "after", "checking", "the", "current", "one" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L1143-L1157
nabab/bbn
src/bbn/user.php
user.force_password
public function force_password($pass, $id){ if ( $this->check() ){ return $this->db->insert($this->class_cfg['tables']['passwords'], [ $this->class_cfg['arch']['passwords']['pass'] => $this->_crypt($pass), $this->class_cfg['arch']['passwords']['id_user'] => $id, $this->class_cfg['arch']['passwords']['added'] => date('Y-m-d H:i:s') ]); } return false; }
php
public function force_password($pass, $id){ if ( $this->check() ){ return $this->db->insert($this->class_cfg['tables']['passwords'], [ $this->class_cfg['arch']['passwords']['pass'] => $this->_crypt($pass), $this->class_cfg['arch']['passwords']['id_user'] => $id, $this->class_cfg['arch']['passwords']['added'] => date('Y-m-d H:i:s') ]); } return false; }
[ "public", "function", "force_password", "(", "$", "pass", ",", "$", "id", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "db", "->", "insert", "(", "$", "this", "->", "class_cfg", "[", "'tables'", "]", "[", "'passwords'", "]", ",", "[", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", "[", "'pass'", "]", "=>", "$", "this", "->", "_crypt", "(", "$", "pass", ")", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", "[", "'id_user'", "]", "=>", "$", "id", ",", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'passwords'", "]", "[", "'added'", "]", "=>", "date", "(", "'Y-m-d H:i:s'", ")", "]", ")", ";", "}", "return", "false", ";", "}" ]
Change the password in the database @return boolean
[ "Change", "the", "password", "in", "the", "database" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L1163-L1172
nabab/bbn
src/bbn/user.php
user.get_name
public function get_name($usr = null){ if ( $this->auth ){ if ( \is_null($usr) ){ $usr = $this->get_session(); } else if ( str::is_uid($usr) ){ $mgr = $this->get_manager(); $usr = $mgr->get_user($usr); } if ( isset($usr[$this->class_cfg['show']]) ){ return $usr[$this->class_cfg['show']]; } } return false; }
php
public function get_name($usr = null){ if ( $this->auth ){ if ( \is_null($usr) ){ $usr = $this->get_session(); } else if ( str::is_uid($usr) ){ $mgr = $this->get_manager(); $usr = $mgr->get_user($usr); } if ( isset($usr[$this->class_cfg['show']]) ){ return $usr[$this->class_cfg['show']]; } } return false; }
[ "public", "function", "get_name", "(", "$", "usr", "=", "null", ")", "{", "if", "(", "$", "this", "->", "auth", ")", "{", "if", "(", "\\", "is_null", "(", "$", "usr", ")", ")", "{", "$", "usr", "=", "$", "this", "->", "get_session", "(", ")", ";", "}", "else", "if", "(", "str", "::", "is_uid", "(", "$", "usr", ")", ")", "{", "$", "mgr", "=", "$", "this", "->", "get_manager", "(", ")", ";", "$", "usr", "=", "$", "mgr", "->", "get_user", "(", "$", "usr", ")", ";", "}", "if", "(", "isset", "(", "$", "usr", "[", "$", "this", "->", "class_cfg", "[", "'show'", "]", "]", ")", ")", "{", "return", "$", "usr", "[", "$", "this", "->", "class_cfg", "[", "'show'", "]", "]", ";", "}", "}", "return", "false", ";", "}" ]
Returns the written name of this or a user @return string|false
[ "Returns", "the", "written", "name", "of", "this", "or", "a", "user" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user.php#L1178-L1192
atoum/autoloop-extension
classes/configuration.php
configuration.unserialize
public static function unserialize(array $config) { $configuration = new static; if (false !== ($clientConfiguration = unserialize($config['watched_files']))) { $configuration->set($clientConfiguration); } return $configuration; }
php
public static function unserialize(array $config) { $configuration = new static; if (false !== ($clientConfiguration = unserialize($config['watched_files']))) { $configuration->set($clientConfiguration); } return $configuration; }
[ "public", "static", "function", "unserialize", "(", "array", "$", "config", ")", "{", "$", "configuration", "=", "new", "static", ";", "if", "(", "false", "!==", "(", "$", "clientConfiguration", "=", "unserialize", "(", "$", "config", "[", "'watched_files'", "]", ")", ")", ")", "{", "$", "configuration", "->", "set", "(", "$", "clientConfiguration", ")", ";", "}", "return", "$", "configuration", ";", "}" ]
@param array $config @return configuration
[ "@param", "array", "$config" ]
train
https://github.com/atoum/autoloop-extension/blob/0aaf1c4e01540607a5f25af9f09ddb1be8cc17b7/classes/configuration.php#L27-L36
php-lug/lug
src/Bundle/ResourceBundle/AbstractResourceBundle.php
AbstractResourceBundle.getResources
public function getResources() { if ($this->resources === null) { $this->resources = $this->createResources($this->driver); } return $this->resources; }
php
public function getResources() { if ($this->resources === null) { $this->resources = $this->createResources($this->driver); } return $this->resources; }
[ "public", "function", "getResources", "(", ")", "{", "if", "(", "$", "this", "->", "resources", "===", "null", ")", "{", "$", "this", "->", "resources", "=", "$", "this", "->", "createResources", "(", "$", "this", "->", "driver", ")", ";", "}", "return", "$", "this", "->", "resources", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/AbstractResourceBundle.php#L45-L52
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Block/Widget/Grid/Column/Renderer/Action.php
Aoe_Layout_Block_Widget_Grid_Column_Renderer_Action.render
public function render(Varien_Object $row) { $renderActions = []; $actions = $this->getColumn()->getActions(); if (is_array($actions)) { foreach ($actions as $action) { if (isset($action['checks'])) { $fail = false; $checks = array_filter(array_map('trim', explode(',', $action['checks']))); foreach ($checks as $check) { $negativeCheck = (substr($check, 0, 1) === '!'); $check = ($negativeCheck ? substr($check, 1) : $check); $value = (strpos($check, '/') === false ? $row->getDataUsingMethod($check) : $row->getData($check)); if ((bool)$value === $negativeCheck) { $fail = true; break; } } if ($fail) { continue; } } $renderActions[] = $action; } } if (empty($renderActions)) { return '&nbsp;'; } $linkLimit = ($this->getColumn()->getNoLink() ? 0 : max(intval($this->getColumn()->getLinkLimit()), 1)); $out = ''; if (count($renderActions) <= $linkLimit) { foreach ($renderActions as $action) { if (is_array($action)) { $out .= $this->_toLinkHtml($action, $row); } } } else { $out .= '<select class="action-select" onchange="varienGridAction.execute(this);">'; $out .= '<option value=""></option>'; foreach ($renderActions as $action) { if (is_array($action)) { $out .= $this->_toOptionHtml($action, $row); } } $out .= '</select>'; } return $out; }
php
public function render(Varien_Object $row) { $renderActions = []; $actions = $this->getColumn()->getActions(); if (is_array($actions)) { foreach ($actions as $action) { if (isset($action['checks'])) { $fail = false; $checks = array_filter(array_map('trim', explode(',', $action['checks']))); foreach ($checks as $check) { $negativeCheck = (substr($check, 0, 1) === '!'); $check = ($negativeCheck ? substr($check, 1) : $check); $value = (strpos($check, '/') === false ? $row->getDataUsingMethod($check) : $row->getData($check)); if ((bool)$value === $negativeCheck) { $fail = true; break; } } if ($fail) { continue; } } $renderActions[] = $action; } } if (empty($renderActions)) { return '&nbsp;'; } $linkLimit = ($this->getColumn()->getNoLink() ? 0 : max(intval($this->getColumn()->getLinkLimit()), 1)); $out = ''; if (count($renderActions) <= $linkLimit) { foreach ($renderActions as $action) { if (is_array($action)) { $out .= $this->_toLinkHtml($action, $row); } } } else { $out .= '<select class="action-select" onchange="varienGridAction.execute(this);">'; $out .= '<option value=""></option>'; foreach ($renderActions as $action) { if (is_array($action)) { $out .= $this->_toOptionHtml($action, $row); } } $out .= '</select>'; } return $out; }
[ "public", "function", "render", "(", "Varien_Object", "$", "row", ")", "{", "$", "renderActions", "=", "[", "]", ";", "$", "actions", "=", "$", "this", "->", "getColumn", "(", ")", "->", "getActions", "(", ")", ";", "if", "(", "is_array", "(", "$", "actions", ")", ")", "{", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if", "(", "isset", "(", "$", "action", "[", "'checks'", "]", ")", ")", "{", "$", "fail", "=", "false", ";", "$", "checks", "=", "array_filter", "(", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "action", "[", "'checks'", "]", ")", ")", ")", ";", "foreach", "(", "$", "checks", "as", "$", "check", ")", "{", "$", "negativeCheck", "=", "(", "substr", "(", "$", "check", ",", "0", ",", "1", ")", "===", "'!'", ")", ";", "$", "check", "=", "(", "$", "negativeCheck", "?", "substr", "(", "$", "check", ",", "1", ")", ":", "$", "check", ")", ";", "$", "value", "=", "(", "strpos", "(", "$", "check", ",", "'/'", ")", "===", "false", "?", "$", "row", "->", "getDataUsingMethod", "(", "$", "check", ")", ":", "$", "row", "->", "getData", "(", "$", "check", ")", ")", ";", "if", "(", "(", "bool", ")", "$", "value", "===", "$", "negativeCheck", ")", "{", "$", "fail", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "fail", ")", "{", "continue", ";", "}", "}", "$", "renderActions", "[", "]", "=", "$", "action", ";", "}", "}", "if", "(", "empty", "(", "$", "renderActions", ")", ")", "{", "return", "'&nbsp;'", ";", "}", "$", "linkLimit", "=", "(", "$", "this", "->", "getColumn", "(", ")", "->", "getNoLink", "(", ")", "?", "0", ":", "max", "(", "intval", "(", "$", "this", "->", "getColumn", "(", ")", "->", "getLinkLimit", "(", ")", ")", ",", "1", ")", ")", ";", "$", "out", "=", "''", ";", "if", "(", "count", "(", "$", "renderActions", ")", "<=", "$", "linkLimit", ")", "{", "foreach", "(", "$", "renderActions", "as", "$", "action", ")", "{", "if", "(", "is_array", "(", "$", "action", ")", ")", "{", "$", "out", ".=", "$", "this", "->", "_toLinkHtml", "(", "$", "action", ",", "$", "row", ")", ";", "}", "}", "}", "else", "{", "$", "out", ".=", "'<select class=\"action-select\" onchange=\"varienGridAction.execute(this);\">'", ";", "$", "out", ".=", "'<option value=\"\"></option>'", ";", "foreach", "(", "$", "renderActions", "as", "$", "action", ")", "{", "if", "(", "is_array", "(", "$", "action", ")", ")", "{", "$", "out", ".=", "$", "this", "->", "_toOptionHtml", "(", "$", "action", ",", "$", "row", ")", ";", "}", "}", "$", "out", ".=", "'</select>'", ";", "}", "return", "$", "out", ";", "}" ]
Renders column @param Varien_Object $row @return string
[ "Renders", "column" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Grid/Column/Renderer/Action.php#L12-L65
endroid/import-bundle
src/DependencyInjection/EndroidImportExtension.php
EndroidImportExtension.load
public function load(array $configs, ContainerBuilder $container) { $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(), $configs); $taggedServices = $container->findTaggedServiceIds('endroid.import.importer'); foreach ($taggedServices as $id => $tags) { $importerDefinition = $container->getDefinition($id); $importerDefinition->addMethodCall('setTimeLimit', [$config['time_limit']]); $importerDefinition->addMethodCall('setMemoryLimit', [$config['memory_limit']]); } }
php
public function load(array $configs, ContainerBuilder $container) { $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(), $configs); $taggedServices = $container->findTaggedServiceIds('endroid.import.importer'); foreach ($taggedServices as $id => $tags) { $importerDefinition = $container->getDefinition($id); $importerDefinition->addMethodCall('setTimeLimit', [$config['time_limit']]); $importerDefinition->addMethodCall('setMemoryLimit', [$config['memory_limit']]); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "config", "=", "$", "processor", "->", "processConfiguration", "(", "new", "Configuration", "(", ")", ",", "$", "configs", ")", ";", "$", "taggedServices", "=", "$", "container", "->", "findTaggedServiceIds", "(", "'endroid.import.importer'", ")", ";", "foreach", "(", "$", "taggedServices", "as", "$", "id", "=>", "$", "tags", ")", "{", "$", "importerDefinition", "=", "$", "container", "->", "getDefinition", "(", "$", "id", ")", ";", "$", "importerDefinition", "->", "addMethodCall", "(", "'setTimeLimit'", ",", "[", "$", "config", "[", "'time_limit'", "]", "]", ")", ";", "$", "importerDefinition", "->", "addMethodCall", "(", "'setMemoryLimit'", ",", "[", "$", "config", "[", "'memory_limit'", "]", "]", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/endroid/import-bundle/blob/637f29720822432192efad6993f505adc9dd4af4/src/DependencyInjection/EndroidImportExtension.php#L23-L35
mothership-ec/composer
src/Composer/Config.php
Config.merge
public function merge($config) { // override defaults with given config if (!empty($config['config']) && is_array($config['config'])) { foreach ($config['config'] as $key => $val) { if (in_array($key, array('github-oauth', 'http-basic')) && isset($this->config[$key])) { $this->config[$key] = array_merge($this->config[$key], $val); } else { $this->config[$key] = $val; } } } if (!empty($config['repositories']) && is_array($config['repositories'])) { $this->repositories = array_reverse($this->repositories, true); $newRepos = array_reverse($config['repositories'], true); foreach ($newRepos as $name => $repository) { // disable a repository by name if (false === $repository) { unset($this->repositories[$name]); continue; } // disable a repository with an anonymous {"name": false} repo if (is_array($repository) && 1 === count($repository) && false === current($repository)) { unset($this->repositories[key($repository)]); continue; } // store repo if (is_int($name)) { $this->repositories[] = $repository; } else { $this->repositories[$name] = $repository; } } $this->repositories = array_reverse($this->repositories, true); } }
php
public function merge($config) { // override defaults with given config if (!empty($config['config']) && is_array($config['config'])) { foreach ($config['config'] as $key => $val) { if (in_array($key, array('github-oauth', 'http-basic')) && isset($this->config[$key])) { $this->config[$key] = array_merge($this->config[$key], $val); } else { $this->config[$key] = $val; } } } if (!empty($config['repositories']) && is_array($config['repositories'])) { $this->repositories = array_reverse($this->repositories, true); $newRepos = array_reverse($config['repositories'], true); foreach ($newRepos as $name => $repository) { // disable a repository by name if (false === $repository) { unset($this->repositories[$name]); continue; } // disable a repository with an anonymous {"name": false} repo if (is_array($repository) && 1 === count($repository) && false === current($repository)) { unset($this->repositories[key($repository)]); continue; } // store repo if (is_int($name)) { $this->repositories[] = $repository; } else { $this->repositories[$name] = $repository; } } $this->repositories = array_reverse($this->repositories, true); } }
[ "public", "function", "merge", "(", "$", "config", ")", "{", "// override defaults with given config", "if", "(", "!", "empty", "(", "$", "config", "[", "'config'", "]", ")", "&&", "is_array", "(", "$", "config", "[", "'config'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'config'", "]", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "array", "(", "'github-oauth'", ",", "'http-basic'", ")", ")", "&&", "isset", "(", "$", "this", "->", "config", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "config", "[", "$", "key", "]", "=", "array_merge", "(", "$", "this", "->", "config", "[", "$", "key", "]", ",", "$", "val", ")", ";", "}", "else", "{", "$", "this", "->", "config", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'repositories'", "]", ")", "&&", "is_array", "(", "$", "config", "[", "'repositories'", "]", ")", ")", "{", "$", "this", "->", "repositories", "=", "array_reverse", "(", "$", "this", "->", "repositories", ",", "true", ")", ";", "$", "newRepos", "=", "array_reverse", "(", "$", "config", "[", "'repositories'", "]", ",", "true", ")", ";", "foreach", "(", "$", "newRepos", "as", "$", "name", "=>", "$", "repository", ")", "{", "// disable a repository by name", "if", "(", "false", "===", "$", "repository", ")", "{", "unset", "(", "$", "this", "->", "repositories", "[", "$", "name", "]", ")", ";", "continue", ";", "}", "// disable a repository with an anonymous {\"name\": false} repo", "if", "(", "is_array", "(", "$", "repository", ")", "&&", "1", "===", "count", "(", "$", "repository", ")", "&&", "false", "===", "current", "(", "$", "repository", ")", ")", "{", "unset", "(", "$", "this", "->", "repositories", "[", "key", "(", "$", "repository", ")", "]", ")", ";", "continue", ";", "}", "// store repo", "if", "(", "is_int", "(", "$", "name", ")", ")", "{", "$", "this", "->", "repositories", "[", "]", "=", "$", "repository", ";", "}", "else", "{", "$", "this", "->", "repositories", "[", "$", "name", "]", "=", "$", "repository", ";", "}", "}", "$", "this", "->", "repositories", "=", "array_reverse", "(", "$", "this", "->", "repositories", ",", "true", ")", ";", "}", "}" ]
Merges new config values with the existing ones (overriding) @param array $config
[ "Merges", "new", "config", "values", "with", "the", "existing", "ones", "(", "overriding", ")" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Config.php#L106-L144
mothership-ec/composer
src/Composer/Config.php
Config.get
public function get($key, $flags = 0) { switch ($key) { case 'vendor-dir': case 'bin-dir': case 'process-timeout': case 'cache-dir': case 'cache-files-dir': case 'cache-repo-dir': case 'cache-vcs-dir': // convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_')); $val = rtrim($this->process($this->getComposerEnv($env) ?: $this->config[$key], $flags), '/\\'); $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $val); if (substr($key, -4) !== '-dir') { return $val; } return ($flags & self::RELATIVE_PATHS == 1) ? $val : $this->realpath($val); case 'cache-ttl': return (int) $this->config[$key]; case 'cache-files-maxsize': if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) { throw new \RuntimeException( "Could not parse the value of 'cache-files-maxsize': {$this->config[$key]}" ); } $size = $matches[1]; if (isset($matches[2])) { switch (strtolower($matches[2])) { case 'g': $size *= 1024; // intentional fallthrough case 'm': $size *= 1024; // intentional fallthrough case 'k': $size *= 1024; break; } } return $size; case 'cache-files-ttl': if (isset($this->config[$key])) { return (int) $this->config[$key]; } return (int) $this->config['cache-ttl']; case 'home': return rtrim($this->process($this->config[$key], $flags), '/\\'); case 'discard-changes': if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) { if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) { throw new \RuntimeException( "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash" ); } if ('stash' === $env) { return 'stash'; } // convert string value to bool return $env !== 'false' && (bool) $env; } if (!in_array($this->config[$key], array(true, false, 'stash'), true)) { throw new \RuntimeException( "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash" ); } return $this->config[$key]; case 'github-protocols': if (reset($this->config['github-protocols']) === 'http') { throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"'); } return $this->config[$key]; default: if (!isset($this->config[$key])) { return null; } return $this->process($this->config[$key], $flags); } }
php
public function get($key, $flags = 0) { switch ($key) { case 'vendor-dir': case 'bin-dir': case 'process-timeout': case 'cache-dir': case 'cache-files-dir': case 'cache-repo-dir': case 'cache-vcs-dir': // convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_')); $val = rtrim($this->process($this->getComposerEnv($env) ?: $this->config[$key], $flags), '/\\'); $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $val); if (substr($key, -4) !== '-dir') { return $val; } return ($flags & self::RELATIVE_PATHS == 1) ? $val : $this->realpath($val); case 'cache-ttl': return (int) $this->config[$key]; case 'cache-files-maxsize': if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) { throw new \RuntimeException( "Could not parse the value of 'cache-files-maxsize': {$this->config[$key]}" ); } $size = $matches[1]; if (isset($matches[2])) { switch (strtolower($matches[2])) { case 'g': $size *= 1024; // intentional fallthrough case 'm': $size *= 1024; // intentional fallthrough case 'k': $size *= 1024; break; } } return $size; case 'cache-files-ttl': if (isset($this->config[$key])) { return (int) $this->config[$key]; } return (int) $this->config['cache-ttl']; case 'home': return rtrim($this->process($this->config[$key], $flags), '/\\'); case 'discard-changes': if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) { if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) { throw new \RuntimeException( "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash" ); } if ('stash' === $env) { return 'stash'; } // convert string value to bool return $env !== 'false' && (bool) $env; } if (!in_array($this->config[$key], array(true, false, 'stash'), true)) { throw new \RuntimeException( "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash" ); } return $this->config[$key]; case 'github-protocols': if (reset($this->config['github-protocols']) === 'http') { throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"'); } return $this->config[$key]; default: if (!isset($this->config[$key])) { return null; } return $this->process($this->config[$key], $flags); } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "flags", "=", "0", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'vendor-dir'", ":", "case", "'bin-dir'", ":", "case", "'process-timeout'", ":", "case", "'cache-dir'", ":", "case", "'cache-files-dir'", ":", "case", "'cache-repo-dir'", ":", "case", "'cache-vcs-dir'", ":", "// convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config", "$", "env", "=", "'COMPOSER_'", ".", "strtoupper", "(", "strtr", "(", "$", "key", ",", "'-'", ",", "'_'", ")", ")", ";", "$", "val", "=", "rtrim", "(", "$", "this", "->", "process", "(", "$", "this", "->", "getComposerEnv", "(", "$", "env", ")", "?", ":", "$", "this", "->", "config", "[", "$", "key", "]", ",", "$", "flags", ")", ",", "'/\\\\'", ")", ";", "$", "val", "=", "preg_replace", "(", "'#^(\\$HOME|~)(/|$)#'", ",", "rtrim", "(", "getenv", "(", "'HOME'", ")", "?", ":", "getenv", "(", "'USERPROFILE'", ")", ",", "'/\\\\'", ")", ".", "'/'", ",", "$", "val", ")", ";", "if", "(", "substr", "(", "$", "key", ",", "-", "4", ")", "!==", "'-dir'", ")", "{", "return", "$", "val", ";", "}", "return", "(", "$", "flags", "&", "self", "::", "RELATIVE_PATHS", "==", "1", ")", "?", "$", "val", ":", "$", "this", "->", "realpath", "(", "$", "val", ")", ";", "case", "'cache-ttl'", ":", "return", "(", "int", ")", "$", "this", "->", "config", "[", "$", "key", "]", ";", "case", "'cache-files-maxsize'", ":", "if", "(", "!", "preg_match", "(", "'/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i'", ",", "$", "this", "->", "config", "[", "$", "key", "]", ",", "$", "matches", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Could not parse the value of 'cache-files-maxsize': {$this->config[$key]}\"", ")", ";", "}", "$", "size", "=", "$", "matches", "[", "1", "]", ";", "if", "(", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "switch", "(", "strtolower", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "case", "'g'", ":", "$", "size", "*=", "1024", ";", "// intentional fallthrough", "case", "'m'", ":", "$", "size", "*=", "1024", ";", "// intentional fallthrough", "case", "'k'", ":", "$", "size", "*=", "1024", ";", "break", ";", "}", "}", "return", "$", "size", ";", "case", "'cache-files-ttl'", ":", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "key", "]", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "config", "[", "$", "key", "]", ";", "}", "return", "(", "int", ")", "$", "this", "->", "config", "[", "'cache-ttl'", "]", ";", "case", "'home'", ":", "return", "rtrim", "(", "$", "this", "->", "process", "(", "$", "this", "->", "config", "[", "$", "key", "]", ",", "$", "flags", ")", ",", "'/\\\\'", ")", ";", "case", "'discard-changes'", ":", "if", "(", "$", "env", "=", "$", "this", "->", "getComposerEnv", "(", "'COMPOSER_DISCARD_CHANGES'", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "env", ",", "array", "(", "'stash'", ",", "'true'", ",", "'false'", ",", "'1'", ",", "'0'", ")", ",", "true", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash\"", ")", ";", "}", "if", "(", "'stash'", "===", "$", "env", ")", "{", "return", "'stash'", ";", "}", "// convert string value to bool", "return", "$", "env", "!==", "'false'", "&&", "(", "bool", ")", "$", "env", ";", "}", "if", "(", "!", "in_array", "(", "$", "this", "->", "config", "[", "$", "key", "]", ",", "array", "(", "true", ",", "false", ",", "'stash'", ")", ",", "true", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash\"", ")", ";", "}", "return", "$", "this", "->", "config", "[", "$", "key", "]", ";", "case", "'github-protocols'", ":", "if", "(", "reset", "(", "$", "this", "->", "config", "[", "'github-protocols'", "]", ")", "===", "'http'", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'The http protocol for github is not available anymore, update your config\\'s github-protocols to use \"https\", \"git\" or \"ssh\"'", ")", ";", "}", "return", "$", "this", "->", "config", "[", "$", "key", "]", ";", "default", ":", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "process", "(", "$", "this", "->", "config", "[", "$", "key", "]", ",", "$", "flags", ")", ";", "}", "}" ]
Returns a setting @param string $key @param int $flags Options (see class constants) @throws \RuntimeException @return mixed
[ "Returns", "a", "setting" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Config.php#L162-L257
mothership-ec/composer
src/Composer/Config.php
Config.realpath
private function realpath($path) { if (substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':') { return $path; } return $this->baseDir . '/' . $path; }
php
private function realpath($path) { if (substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':') { return $path; } return $this->baseDir . '/' . $path; }
[ "private", "function", "realpath", "(", "$", "path", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "===", "'/'", "||", "substr", "(", "$", "path", ",", "1", ",", "1", ")", "===", "':'", ")", "{", "return", "$", "path", ";", "}", "return", "$", "this", "->", "baseDir", ".", "'/'", ".", "$", "path", ";", "}" ]
Turns relative paths in absolute paths without realpath() Since the dirs might not exist yet we can not call realpath or it will fail. @param string $path @return string
[ "Turns", "relative", "paths", "in", "absolute", "paths", "without", "realpath", "()" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Config.php#L318-L325
CalderaWP/metaplate-core
src/data.php
data.get_active_metaplates
public static function get_active_metaplates( ) { global $post; if( empty( $post ) ){ return; } // no post - return // GET METAPLATEs $metaplates = self::get_registry(); $meta_stack = array(); if ( is_array( $metaplates ) ) { foreach ( $metaplates as $metaplate_try ) { $is_plate = self::get_metaplate( $metaplate_try['id'] ); if ( ! empty( $is_plate['post_type'][ $post->post_type ] ) ) { switch ( $is_plate['page_type'] ) { case 'single': if ( is_single() || is_page() ) { $meta_stack[] = $is_plate; } break; case 'archive': if ( ( is_archive() || is_front_page() ) && ( ! is_page() || ! is_single() ) ) { $meta_stack[] = $is_plate; } break; default: $meta_stack[] = $is_plate; break; } } } } return $meta_stack; }
php
public static function get_active_metaplates( ) { global $post; if( empty( $post ) ){ return; } // no post - return // GET METAPLATEs $metaplates = self::get_registry(); $meta_stack = array(); if ( is_array( $metaplates ) ) { foreach ( $metaplates as $metaplate_try ) { $is_plate = self::get_metaplate( $metaplate_try['id'] ); if ( ! empty( $is_plate['post_type'][ $post->post_type ] ) ) { switch ( $is_plate['page_type'] ) { case 'single': if ( is_single() || is_page() ) { $meta_stack[] = $is_plate; } break; case 'archive': if ( ( is_archive() || is_front_page() ) && ( ! is_page() || ! is_single() ) ) { $meta_stack[] = $is_plate; } break; default: $meta_stack[] = $is_plate; break; } } } } return $meta_stack; }
[ "public", "static", "function", "get_active_metaplates", "(", ")", "{", "global", "$", "post", ";", "if", "(", "empty", "(", "$", "post", ")", ")", "{", "return", ";", "}", "// no post - return", "// GET METAPLATEs", "$", "metaplates", "=", "self", "::", "get_registry", "(", ")", ";", "$", "meta_stack", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "metaplates", ")", ")", "{", "foreach", "(", "$", "metaplates", "as", "$", "metaplate_try", ")", "{", "$", "is_plate", "=", "self", "::", "get_metaplate", "(", "$", "metaplate_try", "[", "'id'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "is_plate", "[", "'post_type'", "]", "[", "$", "post", "->", "post_type", "]", ")", ")", "{", "switch", "(", "$", "is_plate", "[", "'page_type'", "]", ")", "{", "case", "'single'", ":", "if", "(", "is_single", "(", ")", "||", "is_page", "(", ")", ")", "{", "$", "meta_stack", "[", "]", "=", "$", "is_plate", ";", "}", "break", ";", "case", "'archive'", ":", "if", "(", "(", "is_archive", "(", ")", "||", "is_front_page", "(", ")", ")", "&&", "(", "!", "is_page", "(", ")", "||", "!", "is_single", "(", ")", ")", ")", "{", "$", "meta_stack", "[", "]", "=", "$", "is_plate", ";", "}", "break", ";", "default", ":", "$", "meta_stack", "[", "]", "=", "$", "is_plate", ";", "break", ";", "}", "}", "}", "}", "return", "$", "meta_stack", ";", "}" ]
Get the metaplates for the post @return array active metaplates for this post type
[ "Get", "the", "metaplates", "for", "the", "post" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L31-L65
CalderaWP/metaplate-core
src/data.php
data.get_custom_field_data
public static function get_custom_field_data( $post_id ) { global $post; if ( ! is_object( $post ) ) { $post = get_post( $post_id ); } $raw_data = get_post_meta( $post_id ); if ( ! is_array( $raw_data ) ) { return; } // init the data array $template_data = array(); // add taxonomies in with a :taxonomy alias $taxonomies = get_object_taxonomies( $post ); if( !empty( $taxonomies ) ){ foreach ( $taxonomies as $taxonomy_name ) { $taxonomy = get_taxonomy( $taxonomy_name ); $template_data['taxonomy'][ $taxonomy_name ] = $template_data[ $taxonomy_name ] = wp_get_post_terms( $post->ID, $taxonomy_name, array("fields" => "all") ); } } // break to standard arrays foreach( $raw_data as $meta_key=>$meta_data ){ if( count( $meta_data ) === 1 ){ if( strlen( trim( $meta_data[0] ) ) > 0 ){ // check value is something else leave it out. $template_data[$meta_key] = trim( $meta_data[0] ); } }else{ $template_data[$meta_key] = $meta_data; } } // ACF support if( class_exists( 'acf' ) ){ $fields = get_fields( $post->ID ); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } // CFS support if( class_exists( 'Custom_Field_Suite' ) ){ $fields = CFS()->get(); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } //Pods support if ( class_exists( 'Pods' ) && false != ( $pods = pods( $post->post_type, $post->ID, true ) ) ) { $fields = $pods->export(); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } // include post values if in a post if( !empty( $post ) ){ foreach( $post as $post_key=>$post_value ){ $template_data[$post_key] = $post_value; } // author details $template_data['post_author'] = get_userdata( $template_data['post_author'] ); // add permalink $template_data['permalink'] = get_permalink( $post->ID ); // core post object $template_data['post_format'] = get_post_format( $post ); } return $template_data; }
php
public static function get_custom_field_data( $post_id ) { global $post; if ( ! is_object( $post ) ) { $post = get_post( $post_id ); } $raw_data = get_post_meta( $post_id ); if ( ! is_array( $raw_data ) ) { return; } // init the data array $template_data = array(); // add taxonomies in with a :taxonomy alias $taxonomies = get_object_taxonomies( $post ); if( !empty( $taxonomies ) ){ foreach ( $taxonomies as $taxonomy_name ) { $taxonomy = get_taxonomy( $taxonomy_name ); $template_data['taxonomy'][ $taxonomy_name ] = $template_data[ $taxonomy_name ] = wp_get_post_terms( $post->ID, $taxonomy_name, array("fields" => "all") ); } } // break to standard arrays foreach( $raw_data as $meta_key=>$meta_data ){ if( count( $meta_data ) === 1 ){ if( strlen( trim( $meta_data[0] ) ) > 0 ){ // check value is something else leave it out. $template_data[$meta_key] = trim( $meta_data[0] ); } }else{ $template_data[$meta_key] = $meta_data; } } // ACF support if( class_exists( 'acf' ) ){ $fields = get_fields( $post->ID ); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } // CFS support if( class_exists( 'Custom_Field_Suite' ) ){ $fields = CFS()->get(); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } //Pods support if ( class_exists( 'Pods' ) && false != ( $pods = pods( $post->post_type, $post->ID, true ) ) ) { $fields = $pods->export(); if ( is_array( $fields ) && ! empty( $fields ) ) { $template_data = array_merge( $template_data, $fields ); } } // include post values if in a post if( !empty( $post ) ){ foreach( $post as $post_key=>$post_value ){ $template_data[$post_key] = $post_value; } // author details $template_data['post_author'] = get_userdata( $template_data['post_author'] ); // add permalink $template_data['permalink'] = get_permalink( $post->ID ); // core post object $template_data['post_format'] = get_post_format( $post ); } return $template_data; }
[ "public", "static", "function", "get_custom_field_data", "(", "$", "post_id", ")", "{", "global", "$", "post", ";", "if", "(", "!", "is_object", "(", "$", "post", ")", ")", "{", "$", "post", "=", "get_post", "(", "$", "post_id", ")", ";", "}", "$", "raw_data", "=", "get_post_meta", "(", "$", "post_id", ")", ";", "if", "(", "!", "is_array", "(", "$", "raw_data", ")", ")", "{", "return", ";", "}", "// init the data array\t\t", "$", "template_data", "=", "array", "(", ")", ";", "// add taxonomies in with a :taxonomy alias", "$", "taxonomies", "=", "get_object_taxonomies", "(", "$", "post", ")", ";", "if", "(", "!", "empty", "(", "$", "taxonomies", ")", ")", "{", "foreach", "(", "$", "taxonomies", "as", "$", "taxonomy_name", ")", "{", "$", "taxonomy", "=", "get_taxonomy", "(", "$", "taxonomy_name", ")", ";", "$", "template_data", "[", "'taxonomy'", "]", "[", "$", "taxonomy_name", "]", "=", "$", "template_data", "[", "$", "taxonomy_name", "]", "=", "wp_get_post_terms", "(", "$", "post", "->", "ID", ",", "$", "taxonomy_name", ",", "array", "(", "\"fields\"", "=>", "\"all\"", ")", ")", ";", "}", "}", "// break to standard arrays", "foreach", "(", "$", "raw_data", "as", "$", "meta_key", "=>", "$", "meta_data", ")", "{", "if", "(", "count", "(", "$", "meta_data", ")", "===", "1", ")", "{", "if", "(", "strlen", "(", "trim", "(", "$", "meta_data", "[", "0", "]", ")", ")", ">", "0", ")", "{", "// check value is something else leave it out.", "$", "template_data", "[", "$", "meta_key", "]", "=", "trim", "(", "$", "meta_data", "[", "0", "]", ")", ";", "}", "}", "else", "{", "$", "template_data", "[", "$", "meta_key", "]", "=", "$", "meta_data", ";", "}", "}", "// ACF support", "if", "(", "class_exists", "(", "'acf'", ")", ")", "{", "$", "fields", "=", "get_fields", "(", "$", "post", "->", "ID", ")", ";", "if", "(", "is_array", "(", "$", "fields", ")", "&&", "!", "empty", "(", "$", "fields", ")", ")", "{", "$", "template_data", "=", "array_merge", "(", "$", "template_data", ",", "$", "fields", ")", ";", "}", "}", "// CFS support", "if", "(", "class_exists", "(", "'Custom_Field_Suite'", ")", ")", "{", "$", "fields", "=", "CFS", "(", ")", "->", "get", "(", ")", ";", "if", "(", "is_array", "(", "$", "fields", ")", "&&", "!", "empty", "(", "$", "fields", ")", ")", "{", "$", "template_data", "=", "array_merge", "(", "$", "template_data", ",", "$", "fields", ")", ";", "}", "}", "//Pods support", "if", "(", "class_exists", "(", "'Pods'", ")", "&&", "false", "!=", "(", "$", "pods", "=", "pods", "(", "$", "post", "->", "post_type", ",", "$", "post", "->", "ID", ",", "true", ")", ")", ")", "{", "$", "fields", "=", "$", "pods", "->", "export", "(", ")", ";", "if", "(", "is_array", "(", "$", "fields", ")", "&&", "!", "empty", "(", "$", "fields", ")", ")", "{", "$", "template_data", "=", "array_merge", "(", "$", "template_data", ",", "$", "fields", ")", ";", "}", "}", "// include post values if in a post", "if", "(", "!", "empty", "(", "$", "post", ")", ")", "{", "foreach", "(", "$", "post", "as", "$", "post_key", "=>", "$", "post_value", ")", "{", "$", "template_data", "[", "$", "post_key", "]", "=", "$", "post_value", ";", "}", "// author details", "$", "template_data", "[", "'post_author'", "]", "=", "get_userdata", "(", "$", "template_data", "[", "'post_author'", "]", ")", ";", "// add permalink", "$", "template_data", "[", "'permalink'", "]", "=", "get_permalink", "(", "$", "post", "->", "ID", ")", ";", "// core post object", "$", "template_data", "[", "'post_format'", "]", "=", "get_post_format", "(", "$", "post", ")", ";", "}", "return", "$", "template_data", ";", "}" ]
Merge in Custom field data, meta and post data @return array array with merged data
[ "Merge", "in", "Custom", "field", "data", "meta", "and", "post", "data" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L72-L154
CalderaWP/metaplate-core
src/data.php
data.get_metaplate
public static function get_metaplate( $id ) { $metaplates = self::get_registry(); if ( array_key_exists( $id, $metaplates ) ) { $metaplate = get_option( $id ); } else { $metaplate = self::get_metaplate_id_by_slug( $id ); if ( is_string( $metaplate ) ) { $metaplate = self::get_metaplate( $metaplate ); } } if ( is_string( $metaplate ) ) { $metaplate = json_decode( $metaplate, ARRAY_A ); } if ( is_object( $metaplate ) ) { $metaplate = (array) $metaplate; } $metaplate = self::code( $metaplate ); return (array) $metaplate; }
php
public static function get_metaplate( $id ) { $metaplates = self::get_registry(); if ( array_key_exists( $id, $metaplates ) ) { $metaplate = get_option( $id ); } else { $metaplate = self::get_metaplate_id_by_slug( $id ); if ( is_string( $metaplate ) ) { $metaplate = self::get_metaplate( $metaplate ); } } if ( is_string( $metaplate ) ) { $metaplate = json_decode( $metaplate, ARRAY_A ); } if ( is_object( $metaplate ) ) { $metaplate = (array) $metaplate; } $metaplate = self::code( $metaplate ); return (array) $metaplate; }
[ "public", "static", "function", "get_metaplate", "(", "$", "id", ")", "{", "$", "metaplates", "=", "self", "::", "get_registry", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "metaplates", ")", ")", "{", "$", "metaplate", "=", "get_option", "(", "$", "id", ")", ";", "}", "else", "{", "$", "metaplate", "=", "self", "::", "get_metaplate_id_by_slug", "(", "$", "id", ")", ";", "if", "(", "is_string", "(", "$", "metaplate", ")", ")", "{", "$", "metaplate", "=", "self", "::", "get_metaplate", "(", "$", "metaplate", ")", ";", "}", "}", "if", "(", "is_string", "(", "$", "metaplate", ")", ")", "{", "$", "metaplate", "=", "json_decode", "(", "$", "metaplate", ",", "ARRAY_A", ")", ";", "}", "if", "(", "is_object", "(", "$", "metaplate", ")", ")", "{", "$", "metaplate", "=", "(", "array", ")", "$", "metaplate", ";", "}", "$", "metaplate", "=", "self", "::", "code", "(", "$", "metaplate", ")", ";", "return", "(", "array", ")", "$", "metaplate", ";", "}" ]
Get a metaplate by ID or slug @param string $id @return array|bool
[ "Get", "a", "metaplate", "by", "ID", "or", "slug" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L163-L189
CalderaWP/metaplate-core
src/data.php
data.code
private static function code( $metaplate ) { foreach ( array( 'html', 'js', 'css' ) as $field ) { if ( isset( $metaplate[ $field ] ) ) { if ( is_object( $metaplate[ $field ] ) ) { $value = $metaplate[ $field ]; $value = $value->code; unset( $metaplate[ $field ] ); $metaplate[ $field ]['code' ] = $value; } } else { $metaplate[ $field ][ 'code' ] = 1; } } return $metaplate; }
php
private static function code( $metaplate ) { foreach ( array( 'html', 'js', 'css' ) as $field ) { if ( isset( $metaplate[ $field ] ) ) { if ( is_object( $metaplate[ $field ] ) ) { $value = $metaplate[ $field ]; $value = $value->code; unset( $metaplate[ $field ] ); $metaplate[ $field ]['code' ] = $value; } } else { $metaplate[ $field ][ 'code' ] = 1; } } return $metaplate; }
[ "private", "static", "function", "code", "(", "$", "metaplate", ")", "{", "foreach", "(", "array", "(", "'html'", ",", "'js'", ",", "'css'", ")", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "metaplate", "[", "$", "field", "]", ")", ")", "{", "if", "(", "is_object", "(", "$", "metaplate", "[", "$", "field", "]", ")", ")", "{", "$", "value", "=", "$", "metaplate", "[", "$", "field", "]", ";", "$", "value", "=", "$", "value", "->", "code", ";", "unset", "(", "$", "metaplate", "[", "$", "field", "]", ")", ";", "$", "metaplate", "[", "$", "field", "]", "[", "'code'", "]", "=", "$", "value", ";", "}", "}", "else", "{", "$", "metaplate", "[", "$", "field", "]", "[", "'code'", "]", "=", "1", ";", "}", "}", "return", "$", "metaplate", ";", "}" ]
Make sure the code fields are arrays not objects and are set @param array $metaplate The metaplate @return array The metaplate with the code fields as arrays
[ "Make", "sure", "the", "code", "fields", "are", "arrays", "not", "objects", "and", "are", "set" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L198-L216
CalderaWP/metaplate-core
src/data.php
data.get_metaplate_id_by_slug
public static function get_metaplate_id_by_slug( $slug, $metaplates = null ) { if ( is_null( $metaplates ) ) { $metaplates = self::get_registry(); } if ( is_array( $metaplates ) ) { $search = wp_list_pluck( $metaplates, 'slug' ); return array_search( $slug, $search ); } return false; }
php
public static function get_metaplate_id_by_slug( $slug, $metaplates = null ) { if ( is_null( $metaplates ) ) { $metaplates = self::get_registry(); } if ( is_array( $metaplates ) ) { $search = wp_list_pluck( $metaplates, 'slug' ); return array_search( $slug, $search ); } return false; }
[ "public", "static", "function", "get_metaplate_id_by_slug", "(", "$", "slug", ",", "$", "metaplates", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "metaplates", ")", ")", "{", "$", "metaplates", "=", "self", "::", "get_registry", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "metaplates", ")", ")", "{", "$", "search", "=", "wp_list_pluck", "(", "$", "metaplates", ",", "'slug'", ")", ";", "return", "array_search", "(", "$", "slug", ",", "$", "search", ")", ";", "}", "return", "false", ";", "}" ]
Get a metaplate's ID using its slug @param string $slug The metaplate's slug. @param null|array $metaplates Optional. The metaplate registry to look in. @return bool|array
[ "Get", "a", "metaplate", "s", "ID", "using", "its", "slug" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L235-L247
CalderaWP/metaplate-core
src/data.php
data.update_registry
public static function update_registry( $new_value, $id ) { $registry = self::get_registry(); $registry[ $id ] = $new_value; return update_option( self::$registry_option_name, $registry ); }
php
public static function update_registry( $new_value, $id ) { $registry = self::get_registry(); $registry[ $id ] = $new_value; return update_option( self::$registry_option_name, $registry ); }
[ "public", "static", "function", "update_registry", "(", "$", "new_value", ",", "$", "id", ")", "{", "$", "registry", "=", "self", "::", "get_registry", "(", ")", ";", "$", "registry", "[", "$", "id", "]", "=", "$", "new_value", ";", "return", "update_option", "(", "self", "::", "$", "registry_option_name", ",", "$", "registry", ")", ";", "}" ]
Update registry of metaplates Note: Does not save the metaplate itself. @param array $new_value The new item to add. @param string $id Id of new item to add. @return bool
[ "Update", "registry", "of", "metaplates" ]
train
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/data.php#L259-L265
zhouyl/mellivora
Mellivora/Support/Facades/Facade.php
Facade.resolveFacadeInstance
protected static function resolveFacadeInstance($name) { if (is_object($name)) { return $name; } if (isset(static::$resolvedInstance[$name])) { return static::$resolvedInstance[$name]; } return static::$resolvedInstance[$name] = static::$app->getContainer()->get($name); }
php
protected static function resolveFacadeInstance($name) { if (is_object($name)) { return $name; } if (isset(static::$resolvedInstance[$name])) { return static::$resolvedInstance[$name]; } return static::$resolvedInstance[$name] = static::$app->getContainer()->get($name); }
[ "protected", "static", "function", "resolveFacadeInstance", "(", "$", "name", ")", "{", "if", "(", "is_object", "(", "$", "name", ")", ")", "{", "return", "$", "name", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "resolvedInstance", "[", "$", "name", "]", ")", ")", "{", "return", "static", "::", "$", "resolvedInstance", "[", "$", "name", "]", ";", "}", "return", "static", "::", "$", "resolvedInstance", "[", "$", "name", "]", "=", "static", "::", "$", "app", "->", "getContainer", "(", ")", "->", "get", "(", "$", "name", ")", ";", "}" ]
Resolve the facade root instance from the container. @param object|string $name @return mixed
[ "Resolve", "the", "facade", "root", "instance", "from", "the", "container", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Facades/Facade.php#L55-L66
mothership-ec/composer
src/Composer/DependencyResolver/Pool.php
Pool.whatProvides
public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false) { $key = ((int) $mustMatchName).$constraint; if (isset($this->providerCache[$name][$key])) { return $this->providerCache[$name][$key]; } return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName); }
php
public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false) { $key = ((int) $mustMatchName).$constraint; if (isset($this->providerCache[$name][$key])) { return $this->providerCache[$name][$key]; } return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName); }
[ "public", "function", "whatProvides", "(", "$", "name", ",", "LinkConstraintInterface", "$", "constraint", "=", "null", ",", "$", "mustMatchName", "=", "false", ")", "{", "$", "key", "=", "(", "(", "int", ")", "$", "mustMatchName", ")", ".", "$", "constraint", ";", "if", "(", "isset", "(", "$", "this", "->", "providerCache", "[", "$", "name", "]", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "providerCache", "[", "$", "name", "]", "[", "$", "key", "]", ";", "}", "return", "$", "this", "->", "providerCache", "[", "$", "name", "]", "[", "$", "key", "]", "=", "$", "this", "->", "computeWhatProvides", "(", "$", "name", ",", "$", "constraint", ",", "$", "mustMatchName", ")", ";", "}" ]
Searches all packages providing the given package name and match the constraint @param string $name The package name to be searched for @param LinkConstraintInterface $constraint A constraint that all returned packages must match or null to return all @param bool $mustMatchName Whether the name of returned packages must match the given name @return PackageInterface[] A set of packages
[ "Searches", "all", "packages", "providing", "the", "given", "package", "name", "and", "match", "the", "constraint" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Pool.php#L173-L181
mothership-ec/composer
src/Composer/DependencyResolver/Pool.php
Pool.match
private function match($candidate, $name, LinkConstraintInterface $constraint = null) { $candidateName = $candidate->getName(); $candidateVersion = $candidate->getVersion(); $isDev = $candidate->getStability() === 'dev'; $isAlias = $candidate instanceof AliasPackage; if (!$isDev && !$isAlias && isset($this->filterRequires[$name])) { $requireFilter = $this->filterRequires[$name]; } else { $requireFilter = new EmptyConstraint; } if ($candidateName === $name) { $pkgConstraint = new VersionConstraint('==', $candidateVersion); if ($constraint === null || $constraint->matches($pkgConstraint)) { return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED; } return self::MATCH_NAME; } $provides = $candidate->getProvides(); $replaces = $candidate->getReplaces(); // aliases create multiple replaces/provides for one target so they can not use the shortcut below if (isset($replaces[0]) || isset($provides[0])) { foreach ($provides as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; } } foreach ($replaces as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; } } return self::MATCH_NONE; } if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) { return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; } if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) { return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; } return self::MATCH_NONE; }
php
private function match($candidate, $name, LinkConstraintInterface $constraint = null) { $candidateName = $candidate->getName(); $candidateVersion = $candidate->getVersion(); $isDev = $candidate->getStability() === 'dev'; $isAlias = $candidate instanceof AliasPackage; if (!$isDev && !$isAlias && isset($this->filterRequires[$name])) { $requireFilter = $this->filterRequires[$name]; } else { $requireFilter = new EmptyConstraint; } if ($candidateName === $name) { $pkgConstraint = new VersionConstraint('==', $candidateVersion); if ($constraint === null || $constraint->matches($pkgConstraint)) { return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED; } return self::MATCH_NAME; } $provides = $candidate->getProvides(); $replaces = $candidate->getReplaces(); // aliases create multiple replaces/provides for one target so they can not use the shortcut below if (isset($replaces[0]) || isset($provides[0])) { foreach ($provides as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; } } foreach ($replaces as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; } } return self::MATCH_NONE; } if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) { return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; } if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) { return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; } return self::MATCH_NONE; }
[ "private", "function", "match", "(", "$", "candidate", ",", "$", "name", ",", "LinkConstraintInterface", "$", "constraint", "=", "null", ")", "{", "$", "candidateName", "=", "$", "candidate", "->", "getName", "(", ")", ";", "$", "candidateVersion", "=", "$", "candidate", "->", "getVersion", "(", ")", ";", "$", "isDev", "=", "$", "candidate", "->", "getStability", "(", ")", "===", "'dev'", ";", "$", "isAlias", "=", "$", "candidate", "instanceof", "AliasPackage", ";", "if", "(", "!", "$", "isDev", "&&", "!", "$", "isAlias", "&&", "isset", "(", "$", "this", "->", "filterRequires", "[", "$", "name", "]", ")", ")", "{", "$", "requireFilter", "=", "$", "this", "->", "filterRequires", "[", "$", "name", "]", ";", "}", "else", "{", "$", "requireFilter", "=", "new", "EmptyConstraint", ";", "}", "if", "(", "$", "candidateName", "===", "$", "name", ")", "{", "$", "pkgConstraint", "=", "new", "VersionConstraint", "(", "'=='", ",", "$", "candidateVersion", ")", ";", "if", "(", "$", "constraint", "===", "null", "||", "$", "constraint", "->", "matches", "(", "$", "pkgConstraint", ")", ")", "{", "return", "$", "requireFilter", "->", "matches", "(", "$", "pkgConstraint", ")", "?", "self", "::", "MATCH", ":", "self", "::", "MATCH_FILTERED", ";", "}", "return", "self", "::", "MATCH_NAME", ";", "}", "$", "provides", "=", "$", "candidate", "->", "getProvides", "(", ")", ";", "$", "replaces", "=", "$", "candidate", "->", "getReplaces", "(", ")", ";", "// aliases create multiple replaces/provides for one target so they can not use the shortcut below", "if", "(", "isset", "(", "$", "replaces", "[", "0", "]", ")", "||", "isset", "(", "$", "provides", "[", "0", "]", ")", ")", "{", "foreach", "(", "$", "provides", "as", "$", "link", ")", "{", "if", "(", "$", "link", "->", "getTarget", "(", ")", "===", "$", "name", "&&", "(", "$", "constraint", "===", "null", "||", "$", "constraint", "->", "matches", "(", "$", "link", "->", "getConstraint", "(", ")", ")", ")", ")", "{", "return", "$", "requireFilter", "->", "matches", "(", "$", "link", "->", "getConstraint", "(", ")", ")", "?", "self", "::", "MATCH_PROVIDE", ":", "self", "::", "MATCH_FILTERED", ";", "}", "}", "foreach", "(", "$", "replaces", "as", "$", "link", ")", "{", "if", "(", "$", "link", "->", "getTarget", "(", ")", "===", "$", "name", "&&", "(", "$", "constraint", "===", "null", "||", "$", "constraint", "->", "matches", "(", "$", "link", "->", "getConstraint", "(", ")", ")", ")", ")", "{", "return", "$", "requireFilter", "->", "matches", "(", "$", "link", "->", "getConstraint", "(", ")", ")", "?", "self", "::", "MATCH_REPLACE", ":", "self", "::", "MATCH_FILTERED", ";", "}", "}", "return", "self", "::", "MATCH_NONE", ";", "}", "if", "(", "isset", "(", "$", "provides", "[", "$", "name", "]", ")", "&&", "(", "$", "constraint", "===", "null", "||", "$", "constraint", "->", "matches", "(", "$", "provides", "[", "$", "name", "]", "->", "getConstraint", "(", ")", ")", ")", ")", "{", "return", "$", "requireFilter", "->", "matches", "(", "$", "provides", "[", "$", "name", "]", "->", "getConstraint", "(", ")", ")", "?", "self", "::", "MATCH_PROVIDE", ":", "self", "::", "MATCH_FILTERED", ";", "}", "if", "(", "isset", "(", "$", "replaces", "[", "$", "name", "]", ")", "&&", "(", "$", "constraint", "===", "null", "||", "$", "constraint", "->", "matches", "(", "$", "replaces", "[", "$", "name", "]", "->", "getConstraint", "(", ")", ")", ")", ")", "{", "return", "$", "requireFilter", "->", "matches", "(", "$", "replaces", "[", "$", "name", "]", "->", "getConstraint", "(", ")", ")", "?", "self", "::", "MATCH_REPLACE", ":", "self", "::", "MATCH_FILTERED", ";", "}", "return", "self", "::", "MATCH_NONE", ";", "}" ]
Checks if the package matches the given constraint directly or through provided or replaced packages @param array|PackageInterface $candidate @param string $name Name of the package to be matched @param LinkConstraintInterface $constraint The constraint to verify @return int One of the MATCH* constants of this class or 0 if there is no match
[ "Checks", "if", "the", "package", "matches", "the", "given", "constraint", "directly", "or", "through", "provided", "or", "replaced", "packages" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Pool.php#L317-L369
ekuiter/feature-php
FeaturePhp/Model/Feature.php
Feature.fromNode
public static function fromNode($node, $parent) { if (is_null($node["value"])) return new Feature($node, $parent, $node->children()); else return new ValueFeature($node, $parent, $node->children()); }
php
public static function fromNode($node, $parent) { if (is_null($node["value"])) return new Feature($node, $parent, $node->children()); else return new ValueFeature($node, $parent, $node->children()); }
[ "public", "static", "function", "fromNode", "(", "$", "node", ",", "$", "parent", ")", "{", "if", "(", "is_null", "(", "$", "node", "[", "\"value\"", "]", ")", ")", "return", "new", "Feature", "(", "$", "node", ",", "$", "parent", ",", "$", "node", "->", "children", "(", ")", ")", ";", "else", "return", "new", "ValueFeature", "(", "$", "node", ",", "$", "parent", ",", "$", "node", "->", "children", "(", ")", ")", ";", "}" ]
Creates a feature from an XML node. @param \SimpleXMLElement $node @param \SimpleXMLElement $parent @return Feature
[ "Creates", "a", "feature", "from", "an", "XML", "node", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Feature.php#L94-L99
ekuiter/feature-php
FeaturePhp/Model/Feature.php
Feature.findByName
public static function findByName($features, $featureName, $permissive = false) { if ($permissive) $featureName = self::_getPermissiveName($featureName); return fphp\Helper\_Array::findByKey($features, $permissive ? "getPermissiveName" : "getName", $featureName); }
php
public static function findByName($features, $featureName, $permissive = false) { if ($permissive) $featureName = self::_getPermissiveName($featureName); return fphp\Helper\_Array::findByKey($features, $permissive ? "getPermissiveName" : "getName", $featureName); }
[ "public", "static", "function", "findByName", "(", "$", "features", ",", "$", "featureName", ",", "$", "permissive", "=", "false", ")", "{", "if", "(", "$", "permissive", ")", "$", "featureName", "=", "self", "::", "_getPermissiveName", "(", "$", "featureName", ")", ";", "return", "fphp", "\\", "Helper", "\\", "_Array", "::", "findByKey", "(", "$", "features", ",", "$", "permissive", "?", "\"getPermissiveName\"", ":", "\"getName\"", ",", "$", "featureName", ")", ";", "}" ]
Finds a feature by its name in a list of features. Permissive search ignores case and substitutes hyphens. @param Feature[] $features @param string $featureName @param bool $permissive @return Feature
[ "Finds", "a", "feature", "by", "its", "name", "in", "a", "list", "of", "features", ".", "Permissive", "search", "ignores", "case", "and", "substitutes", "hyphens", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Feature.php#L198-L202
mergado/mergado-api-client-php
src/mergadoclient/ApiClient.php
ApiClient.get
public function get() { $builtUrl = $this->urlBuilder->buildUrl(); $this->urlBuilder->resetUrl(); return $this->http->request($builtUrl, 'GET'); }
php
public function get() { $builtUrl = $this->urlBuilder->buildUrl(); $this->urlBuilder->resetUrl(); return $this->http->request($builtUrl, 'GET'); }
[ "public", "function", "get", "(", ")", "{", "$", "builtUrl", "=", "$", "this", "->", "urlBuilder", "->", "buildUrl", "(", ")", ";", "$", "this", "->", "urlBuilder", "->", "resetUrl", "(", ")", ";", "return", "$", "this", "->", "http", "->", "request", "(", "$", "builtUrl", ",", "'GET'", ")", ";", "}" ]
Get resource @return string
[ "Get", "resource" ]
train
https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/ApiClient.php#L75-L80
kinnngg/swat4query
src/Kinnngg/Swat4query/Server.php
Server.GetItemInfo
public static function GetItemInfo($itemname, $itemchunks) { $retval = "-"; for ($i=0;$i<count($itemchunks);$i++) if (strcasecmp($itemchunks[$i], $itemname) == 0) $retval = $itemchunks[$i+1]; return $retval; }
php
public static function GetItemInfo($itemname, $itemchunks) { $retval = "-"; for ($i=0;$i<count($itemchunks);$i++) if (strcasecmp($itemchunks[$i], $itemname) == 0) $retval = $itemchunks[$i+1]; return $retval; }
[ "public", "static", "function", "GetItemInfo", "(", "$", "itemname", ",", "$", "itemchunks", ")", "{", "$", "retval", "=", "\"-\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "itemchunks", ")", ";", "$", "i", "++", ")", "if", "(", "strcasecmp", "(", "$", "itemchunks", "[", "$", "i", "]", ",", "$", "itemname", ")", "==", "0", ")", "$", "retval", "=", "$", "itemchunks", "[", "$", "i", "+", "1", "]", ";", "return", "$", "retval", ";", "}" ]
A Helper Function. Returns Item Info from chunk. @param [type] $itemname [description] @param [type] $itemchunks [description]
[ "A", "Helper", "Function", ".", "Returns", "Item", "Info", "from", "chunk", "." ]
train
https://github.com/kinnngg/swat4query/blob/d01ce8595228f2e3e13f63b138611604a483a982/src/Kinnngg/Swat4query/Server.php#L145-L151
kinnngg/swat4query
src/Kinnngg/Swat4query/Server.php
Server.FontCodes
public static function FontCodes($text,$advanced=TRUE,$charset='utf-8'){ //special chars $text = htmlspecialchars($text, ENT_QUOTES,$charset); /** * This array contains the main static bbcode * @var array $basic_bbcode */ $basic_bbcode = array( '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[B]', '[/B]', '[I]', '[/I]', '[U]', '[/U]', ); /** * This array contains the main static bbcode's html * @var array $basic_html */ $basic_html = array( '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', ); /** * * Parses basic bbcode, used str_replace since seems to be the fastest */ $text = str_replace($basic_bbcode, $basic_html, $text); //advanced BBCODE if ($advanced) { /** * This array contains the advanced static bbcode * @var array $advanced_bbcode */ $advanced_bbcode = array( '/\[c=([0-9a-fA-F]{6})\](.+)(\[\\c\])?/i', ); /** * This array contains the advanced static bbcode's html * @var array $advanced_html */ $advanced_html = array( "<span style='color: #$1'>$2</span>", ); $text = htmlspecialchars(preg_replace($advanced_bbcode, $advanced_html,$text)); } return $text; }
php
public static function FontCodes($text,$advanced=TRUE,$charset='utf-8'){ //special chars $text = htmlspecialchars($text, ENT_QUOTES,$charset); /** * This array contains the main static bbcode * @var array $basic_bbcode */ $basic_bbcode = array( '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[B]', '[/B]', '[I]', '[/I]', '[U]', '[/U]', ); /** * This array contains the main static bbcode's html * @var array $basic_html */ $basic_html = array( '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', ); /** * * Parses basic bbcode, used str_replace since seems to be the fastest */ $text = str_replace($basic_bbcode, $basic_html, $text); //advanced BBCODE if ($advanced) { /** * This array contains the advanced static bbcode * @var array $advanced_bbcode */ $advanced_bbcode = array( '/\[c=([0-9a-fA-F]{6})\](.+)(\[\\c\])?/i', ); /** * This array contains the advanced static bbcode's html * @var array $advanced_html */ $advanced_html = array( "<span style='color: #$1'>$2</span>", ); $text = htmlspecialchars(preg_replace($advanced_bbcode, $advanced_html,$text)); } return $text; }
[ "public", "static", "function", "FontCodes", "(", "$", "text", ",", "$", "advanced", "=", "TRUE", ",", "$", "charset", "=", "'utf-8'", ")", "{", "//special chars", "$", "text", "=", "htmlspecialchars", "(", "$", "text", ",", "ENT_QUOTES", ",", "$", "charset", ")", ";", "/**\n * This array contains the main static bbcode\n * @var array $basic_bbcode\n */", "$", "basic_bbcode", "=", "array", "(", "'[b]'", ",", "'[/b]'", ",", "'[i]'", ",", "'[/i]'", ",", "'[u]'", ",", "'[/u]'", ",", "'[B]'", ",", "'[/B]'", ",", "'[I]'", ",", "'[/I]'", ",", "'[U]'", ",", "'[/U]'", ",", ")", ";", "/**\n * This array contains the main static bbcode's html\n * @var array $basic_html\n */", "$", "basic_html", "=", "array", "(", "'<b>'", ",", "'</b>'", ",", "'<i>'", ",", "'</i>'", ",", "'<u>'", ",", "'</u>'", ",", "'<b>'", ",", "'</b>'", ",", "'<i>'", ",", "'</i>'", ",", "'<u>'", ",", "'</u>'", ",", ")", ";", "/**\n *\n * Parses basic bbcode, used str_replace since seems to be the fastest\n */", "$", "text", "=", "str_replace", "(", "$", "basic_bbcode", ",", "$", "basic_html", ",", "$", "text", ")", ";", "//advanced BBCODE", "if", "(", "$", "advanced", ")", "{", "/**\n * This array contains the advanced static bbcode\n * @var array $advanced_bbcode\n */", "$", "advanced_bbcode", "=", "array", "(", "'/\\[c=([0-9a-fA-F]{6})\\](.+)(\\[\\\\c\\])?/i'", ",", ")", ";", "/**\n * This array contains the advanced static bbcode's html\n * @var array $advanced_html\n */", "$", "advanced_html", "=", "array", "(", "\"<span style='color: #$1'>$2</span>\"", ",", ")", ";", "$", "text", "=", "htmlspecialchars", "(", "preg_replace", "(", "$", "advanced_bbcode", ",", "$", "advanced_html", ",", "$", "text", ")", ")", ";", "}", "return", "$", "text", ";", "}" ]
Helper Function Convery SWAT4 Server font codes into html tags @param string $data @return string
[ "Helper", "Function", "Convery", "SWAT4", "Server", "font", "codes", "into", "html", "tags" ]
train
https://github.com/kinnngg/swat4query/blob/d01ce8595228f2e3e13f63b138611604a483a982/src/Kinnngg/Swat4query/Server.php#L161-L214
kinnngg/swat4query
src/Kinnngg/Swat4query/Server.php
Server.FixNickname
public static function FixNickname($nick) { $nick=str_replace('&','&amp;',$nick); $nick=str_replace('<','&lt;',$nick); $nick=str_replace('>','&gt;',$nick); return $nick; }
php
public static function FixNickname($nick) { $nick=str_replace('&','&amp;',$nick); $nick=str_replace('<','&lt;',$nick); $nick=str_replace('>','&gt;',$nick); return $nick; }
[ "public", "static", "function", "FixNickname", "(", "$", "nick", ")", "{", "$", "nick", "=", "str_replace", "(", "'&'", ",", "'&amp;'", ",", "$", "nick", ")", ";", "$", "nick", "=", "str_replace", "(", "'<'", ",", "'&lt;'", ",", "$", "nick", ")", ";", "$", "nick", "=", "str_replace", "(", "'>'", ",", "'&gt;'", ",", "$", "nick", ")", ";", "return", "$", "nick", ";", "}" ]
Helper Function Returns fixed names for html. @param string $nick @return string
[ "Helper", "Function", "Returns", "fixed", "names", "for", "html", "." ]
train
https://github.com/kinnngg/swat4query/blob/d01ce8595228f2e3e13f63b138611604a483a982/src/Kinnngg/Swat4query/Server.php#L264-L269
kinnngg/swat4query
src/Kinnngg/Swat4query/Server.php
Server.SortPlayers
public static function SortPlayers($a,$b,$co,$jak) { if($co=="name") { $a2=strtolower($a['name']); $b2=strtolower($b['name']); if($a2==$b2) return 0; if((($jak=="+")&&($a2>$b2))||(($jak=="-")&&($a2<$b2))) return 1; else return -1; } else { if($a[$co]==$b[$co]) return 0; if((($jak=="+")&&($a[$co]>$b[$co]))||(($jak=="-")&&($a[$co]<$b[$co]))) return 1; else return -1; } }
php
public static function SortPlayers($a,$b,$co,$jak) { if($co=="name") { $a2=strtolower($a['name']); $b2=strtolower($b['name']); if($a2==$b2) return 0; if((($jak=="+")&&($a2>$b2))||(($jak=="-")&&($a2<$b2))) return 1; else return -1; } else { if($a[$co]==$b[$co]) return 0; if((($jak=="+")&&($a[$co]>$b[$co]))||(($jak=="-")&&($a[$co]<$b[$co]))) return 1; else return -1; } }
[ "public", "static", "function", "SortPlayers", "(", "$", "a", ",", "$", "b", ",", "$", "co", ",", "$", "jak", ")", "{", "if", "(", "$", "co", "==", "\"name\"", ")", "{", "$", "a2", "=", "strtolower", "(", "$", "a", "[", "'name'", "]", ")", ";", "$", "b2", "=", "strtolower", "(", "$", "b", "[", "'name'", "]", ")", ";", "if", "(", "$", "a2", "==", "$", "b2", ")", "return", "0", ";", "if", "(", "(", "(", "$", "jak", "==", "\"+\"", ")", "&&", "(", "$", "a2", ">", "$", "b2", ")", ")", "||", "(", "(", "$", "jak", "==", "\"-\"", ")", "&&", "(", "$", "a2", "<", "$", "b2", ")", ")", ")", "return", "1", ";", "else", "return", "-", "1", ";", "}", "else", "{", "if", "(", "$", "a", "[", "$", "co", "]", "==", "$", "b", "[", "$", "co", "]", ")", "return", "0", ";", "if", "(", "(", "(", "$", "jak", "==", "\"+\"", ")", "&&", "(", "$", "a", "[", "$", "co", "]", ">", "$", "b", "[", "$", "co", "]", ")", ")", "||", "(", "(", "$", "jak", "==", "\"-\"", ")", "&&", "(", "$", "a", "[", "$", "co", "]", "<", "$", "b", "[", "$", "co", "]", ")", ")", ")", "return", "1", ";", "else", "return", "-", "1", ";", "}", "}" ]
A Helper Function This function will sort players. @param [type] $a [description] @param [type] $b [description] @param [type] $co [description] @param [type] $jak [description]
[ "A", "Helper", "Function", "This", "function", "will", "sort", "players", "." ]
train
https://github.com/kinnngg/swat4query/blob/d01ce8595228f2e3e13f63b138611604a483a982/src/Kinnngg/Swat4query/Server.php#L280-L290
kinnngg/swat4query
src/Kinnngg/Swat4query/Server.php
Server.LinkImageSort
function LinkImageSort($_by,$sby,$soby,$soby2,$stitle) { if($_by==$sby) return <<<EOF <a href="{$_SERVER['PHP_SELF']}?sort={$soby}&amp;by={$sby}" class="formfont" onmouseover="if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby}.gif'; }" onmouseout="if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby2}.gif'; }"><b>{$stitle}</b> <img src="./swat4query/images/server_{$soby2}.gif" width="11" height="9" border="0" alt="{$soby}" id="so{$sby}" /> EOF; else return '<a href="'.$_SERVER['PHP_SELF'].'?sort='.$soby.'&amp;by='.$sby.'" class="formfont"><b>'.$stitle.'</b>'; }
php
function LinkImageSort($_by,$sby,$soby,$soby2,$stitle) { if($_by==$sby) return <<<EOF <a href="{$_SERVER['PHP_SELF']}?sort={$soby}&amp;by={$sby}" class="formfont" onmouseover="if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby}.gif'; }" onmouseout="if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby2}.gif'; }"><b>{$stitle}</b> <img src="./swat4query/images/server_{$soby2}.gif" width="11" height="9" border="0" alt="{$soby}" id="so{$sby}" /> EOF; else return '<a href="'.$_SERVER['PHP_SELF'].'?sort='.$soby.'&amp;by='.$sby.'" class="formfont"><b>'.$stitle.'</b>'; }
[ "function", "LinkImageSort", "(", "$", "_by", ",", "$", "sby", ",", "$", "soby", ",", "$", "soby2", ",", "$", "stitle", ")", "{", "if", "(", "$", "_by", "==", "$", "sby", ")", "return", " <<<EOF\n <a href=\"{$_SERVER['PHP_SELF']}?sort={$soby}&amp;by={$sby}\" class=\"formfont\" onmouseover=\"if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby}.gif'; }\" onmouseout=\"if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby2}.gif'; }\"><b>{$stitle}</b> <img src=\"./swat4query/images/server_{$soby2}.gif\" width=\"11\" height=\"9\" border=\"0\" alt=\"{$soby}\" id=\"so{$sby}\" />\nEOF", ";", "else", "return", "'<a href=\"'", ".", "$", "_SERVER", "[", "'PHP_SELF'", "]", ".", "'?sort='", ".", "$", "soby", ".", "'&amp;by='", ".", "$", "sby", ".", "'\" class=\"formfont\"><b>'", ".", "$", "stitle", ".", "'</b>'", ";", "}" ]
Helper Function Can be used to created a link to sort data accordingly. @param [type] $_by [description] @param [type] $sby [description] @param [type] $soby [description] @param [type] $soby2 [description] @param [type] $stitle [description]
[ "Helper", "Function", "Can", "be", "used", "to", "created", "a", "link", "to", "sort", "data", "accordingly", "." ]
train
https://github.com/kinnngg/swat4query/blob/d01ce8595228f2e3e13f63b138611604a483a982/src/Kinnngg/Swat4query/Server.php#L342-L348
garf/laravel-title
src/Title.php
Title.render
public function render($delimiter = null, $no_additions = false) { $delimiter = is_null($delimiter) ? config('laravel-title.delimiter') : $delimiter; $suffix = $no_additions ? '' : config('laravel-title.suffix'); $prefix = $no_additions ? '' : config('laravel-title.prefix'); $on_empty = $no_additions ? '' : config('laravel-title.on_empty'); return $this->make($this->segments, $delimiter, $suffix, $prefix, $on_empty); }
php
public function render($delimiter = null, $no_additions = false) { $delimiter = is_null($delimiter) ? config('laravel-title.delimiter') : $delimiter; $suffix = $no_additions ? '' : config('laravel-title.suffix'); $prefix = $no_additions ? '' : config('laravel-title.prefix'); $on_empty = $no_additions ? '' : config('laravel-title.on_empty'); return $this->make($this->segments, $delimiter, $suffix, $prefix, $on_empty); }
[ "public", "function", "render", "(", "$", "delimiter", "=", "null", ",", "$", "no_additions", "=", "false", ")", "{", "$", "delimiter", "=", "is_null", "(", "$", "delimiter", ")", "?", "config", "(", "'laravel-title.delimiter'", ")", ":", "$", "delimiter", ";", "$", "suffix", "=", "$", "no_additions", "?", "''", ":", "config", "(", "'laravel-title.suffix'", ")", ";", "$", "prefix", "=", "$", "no_additions", "?", "''", ":", "config", "(", "'laravel-title.prefix'", ")", ";", "$", "on_empty", "=", "$", "no_additions", "?", "''", ":", "config", "(", "'laravel-title.on_empty'", ")", ";", "return", "$", "this", "->", "make", "(", "$", "this", "->", "segments", ",", "$", "delimiter", ",", "$", "suffix", ",", "$", "prefix", ",", "$", "on_empty", ")", ";", "}" ]
Implode all segments into one string.
[ "Implode", "all", "segments", "into", "one", "string", "." ]
train
https://github.com/garf/laravel-title/blob/54b939b67fdd48d1579c9231d3a13a505279e1cd/src/Title.php#L53-L61
garf/laravel-title
src/Title.php
Title.make
public function make(array $segments, $delimiter = ' - ', $suffix = '', $prefix = '', $on_empty = '') { $result = implode($delimiter, $segments); if ($this->has()) { return $prefix . $result . $suffix; } else { return $on_empty; } }
php
public function make(array $segments, $delimiter = ' - ', $suffix = '', $prefix = '', $on_empty = '') { $result = implode($delimiter, $segments); if ($this->has()) { return $prefix . $result . $suffix; } else { return $on_empty; } }
[ "public", "function", "make", "(", "array", "$", "segments", ",", "$", "delimiter", "=", "' - '", ",", "$", "suffix", "=", "''", ",", "$", "prefix", "=", "''", ",", "$", "on_empty", "=", "''", ")", "{", "$", "result", "=", "implode", "(", "$", "delimiter", ",", "$", "segments", ")", ";", "if", "(", "$", "this", "->", "has", "(", ")", ")", "{", "return", "$", "prefix", ".", "$", "result", ".", "$", "suffix", ";", "}", "else", "{", "return", "$", "on_empty", ";", "}", "}" ]
Check if any segments added @param array $segments - array of segment pieces @param string $delimiter - delimiter for implosion @param string $suffix - addition to the end @param string $prefix - addition to beginning @param string $on_empty - print if segments is empty @return string
[ "Check", "if", "any", "segments", "added" ]
train
https://github.com/garf/laravel-title/blob/54b939b67fdd48d1579c9231d3a13a505279e1cd/src/Title.php#L127-L138
wenbinye/PhalconX
src/Helper/FileHelper.php
FileHelper.find
public static function find($dir, array $options = null) { $options = array_merge([ 'excludeHiddenFiles' => true, ], $options); $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); foreach ($it as $file => $fileInfo) { $name = $fileInfo->getFilename(); if ($name == '.' || $name == '..') { continue; } if ($options['excludeHiddenFiles'] && $name[0] == '.') { continue; } if (isset($options['extensions']) && !in_array($fileInfo->getExtension(), $options['extensions'])) { continue; } if (isset($options['includes']) && !preg_match($options['includes'], $file)) { continue; } if (isset($options['excludes']) && preg_match($options['excludes'], $file)) { continue; } yield $file => $fileInfo; } }
php
public static function find($dir, array $options = null) { $options = array_merge([ 'excludeHiddenFiles' => true, ], $options); $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); foreach ($it as $file => $fileInfo) { $name = $fileInfo->getFilename(); if ($name == '.' || $name == '..') { continue; } if ($options['excludeHiddenFiles'] && $name[0] == '.') { continue; } if (isset($options['extensions']) && !in_array($fileInfo->getExtension(), $options['extensions'])) { continue; } if (isset($options['includes']) && !preg_match($options['includes'], $file)) { continue; } if (isset($options['excludes']) && preg_match($options['excludes'], $file)) { continue; } yield $file => $fileInfo; } }
[ "public", "static", "function", "find", "(", "$", "dir", ",", "array", "$", "options", "=", "null", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'excludeHiddenFiles'", "=>", "true", ",", "]", ",", "$", "options", ")", ";", "$", "it", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "dir", ")", ")", ";", "foreach", "(", "$", "it", "as", "$", "file", "=>", "$", "fileInfo", ")", "{", "$", "name", "=", "$", "fileInfo", "->", "getFilename", "(", ")", ";", "if", "(", "$", "name", "==", "'.'", "||", "$", "name", "==", "'..'", ")", "{", "continue", ";", "}", "if", "(", "$", "options", "[", "'excludeHiddenFiles'", "]", "&&", "$", "name", "[", "0", "]", "==", "'.'", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'extensions'", "]", ")", "&&", "!", "in_array", "(", "$", "fileInfo", "->", "getExtension", "(", ")", ",", "$", "options", "[", "'extensions'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'includes'", "]", ")", "&&", "!", "preg_match", "(", "$", "options", "[", "'includes'", "]", ",", "$", "file", ")", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'excludes'", "]", ")", "&&", "preg_match", "(", "$", "options", "[", "'excludes'", "]", ",", "$", "file", ")", ")", "{", "continue", ";", "}", "yield", "$", "file", "=>", "$", "fileInfo", ";", "}", "}" ]
Finds file
[ "Finds", "file" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/FileHelper.php#L11-L36
wenbinye/PhalconX
src/Helper/FileHelper.php
FileHelper.recursiveRemove
public static function recursiveRemove($path) { if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { if ($file != "." && $file != "..") { self::recursiveRemove("$path/$file"); } } if (!rmdir($path)) { throw new IOException("Cannot rmdir '$path'", 0, null, $path); } } elseif (file_exists($path)) { if (!unlink($path)) { throw new IOException("Cannot unlink '$path'", 0, null, $path); } } }
php
public static function recursiveRemove($path) { if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { if ($file != "." && $file != "..") { self::recursiveRemove("$path/$file"); } } if (!rmdir($path)) { throw new IOException("Cannot rmdir '$path'", 0, null, $path); } } elseif (file_exists($path)) { if (!unlink($path)) { throw new IOException("Cannot unlink '$path'", 0, null, $path); } } }
[ "public", "static", "function", "recursiveRemove", "(", "$", "path", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "files", "=", "scandir", "(", "$", "path", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "!=", "\".\"", "&&", "$", "file", "!=", "\"..\"", ")", "{", "self", "::", "recursiveRemove", "(", "\"$path/$file\"", ")", ";", "}", "}", "if", "(", "!", "rmdir", "(", "$", "path", ")", ")", "{", "throw", "new", "IOException", "(", "\"Cannot rmdir '$path'\"", ",", "0", ",", "null", ",", "$", "path", ")", ";", "}", "}", "elseif", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "unlink", "(", "$", "path", ")", ")", "{", "throw", "new", "IOException", "(", "\"Cannot unlink '$path'\"", ",", "0", ",", "null", ",", "$", "path", ")", ";", "}", "}", "}" ]
rm -r path
[ "rm", "-", "r", "path" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/FileHelper.php#L53-L70
wenbinye/PhalconX
src/Helper/FileHelper.php
FileHelper.recursiveCopy
public static function recursiveCopy($src, $dst) { if (is_dir($src)) { if (!is_dir($dst) && !mkdir($dst)) { throw new IOException("Cannot mkdir '$dst'", 0, null, $path); } $files = scandir($src); foreach ($files as $file) { if ($file != "." && $file != "..") { self::recursiveCopy("$src/$file", "$dst/$file"); } } } elseif (file_exists($src)) { if (!copy($src, $dst)) { throw new IOException("Cannot copy '$src' to '$dst'", 0, null, $src); } } }
php
public static function recursiveCopy($src, $dst) { if (is_dir($src)) { if (!is_dir($dst) && !mkdir($dst)) { throw new IOException("Cannot mkdir '$dst'", 0, null, $path); } $files = scandir($src); foreach ($files as $file) { if ($file != "." && $file != "..") { self::recursiveCopy("$src/$file", "$dst/$file"); } } } elseif (file_exists($src)) { if (!copy($src, $dst)) { throw new IOException("Cannot copy '$src' to '$dst'", 0, null, $src); } } }
[ "public", "static", "function", "recursiveCopy", "(", "$", "src", ",", "$", "dst", ")", "{", "if", "(", "is_dir", "(", "$", "src", ")", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dst", ")", "&&", "!", "mkdir", "(", "$", "dst", ")", ")", "{", "throw", "new", "IOException", "(", "\"Cannot mkdir '$dst'\"", ",", "0", ",", "null", ",", "$", "path", ")", ";", "}", "$", "files", "=", "scandir", "(", "$", "src", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "!=", "\".\"", "&&", "$", "file", "!=", "\"..\"", ")", "{", "self", "::", "recursiveCopy", "(", "\"$src/$file\"", ",", "\"$dst/$file\"", ")", ";", "}", "}", "}", "elseif", "(", "file_exists", "(", "$", "src", ")", ")", "{", "if", "(", "!", "copy", "(", "$", "src", ",", "$", "dst", ")", ")", "{", "throw", "new", "IOException", "(", "\"Cannot copy '$src' to '$dst'\"", ",", "0", ",", "null", ",", "$", "src", ")", ";", "}", "}", "}" ]
cp -r
[ "cp", "-", "r" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/FileHelper.php#L75-L92
wenbinye/PhalconX
src/Helper/FileHelper.php
FileHelper.absolutePath
public static function absolutePath($path, $relative_to = null) { if (self::isWindows()) { $is_absolute = preg_match('/^[A-Za-z]+:/', $path); } else { $is_absolute = !strncmp($path, DIRECTORY_SEPARATOR, 1); } if (!$is_absolute) { if (!$relative_to) { $relative_to = getcwd(); } $path = $relative_to.DIRECTORY_SEPARATOR.$path; } if (is_link($path)) { $parent_realpath = realpath(dirname($path)); if ($parent_realpath !== false) { return $parent_realpath.DIRECTORY_SEPARATOR.basename($path); } } $realpath = realpath($path); if ($realpath !== false) { return $realpath; } // This won't work if the file doesn't exist or is on an unreadable mount // or something crazy like that. Try to resolve a parent so we at least // cover the nonexistent file case. $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); while (end($parts) !== false) { array_pop($parts); if (self::isWindows()) { $attempt = implode(DIRECTORY_SEPARATOR, $parts); } else { $attempt = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts); } $realpath = realpath($attempt); if ($realpath !== false) { $path = $realpath.substr($path, strlen($attempt)); break; } } return $path; }
php
public static function absolutePath($path, $relative_to = null) { if (self::isWindows()) { $is_absolute = preg_match('/^[A-Za-z]+:/', $path); } else { $is_absolute = !strncmp($path, DIRECTORY_SEPARATOR, 1); } if (!$is_absolute) { if (!$relative_to) { $relative_to = getcwd(); } $path = $relative_to.DIRECTORY_SEPARATOR.$path; } if (is_link($path)) { $parent_realpath = realpath(dirname($path)); if ($parent_realpath !== false) { return $parent_realpath.DIRECTORY_SEPARATOR.basename($path); } } $realpath = realpath($path); if ($realpath !== false) { return $realpath; } // This won't work if the file doesn't exist or is on an unreadable mount // or something crazy like that. Try to resolve a parent so we at least // cover the nonexistent file case. $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); while (end($parts) !== false) { array_pop($parts); if (self::isWindows()) { $attempt = implode(DIRECTORY_SEPARATOR, $parts); } else { $attempt = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts); } $realpath = realpath($attempt); if ($realpath !== false) { $path = $realpath.substr($path, strlen($attempt)); break; } } return $path; }
[ "public", "static", "function", "absolutePath", "(", "$", "path", ",", "$", "relative_to", "=", "null", ")", "{", "if", "(", "self", "::", "isWindows", "(", ")", ")", "{", "$", "is_absolute", "=", "preg_match", "(", "'/^[A-Za-z]+:/'", ",", "$", "path", ")", ";", "}", "else", "{", "$", "is_absolute", "=", "!", "strncmp", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ",", "1", ")", ";", "}", "if", "(", "!", "$", "is_absolute", ")", "{", "if", "(", "!", "$", "relative_to", ")", "{", "$", "relative_to", "=", "getcwd", "(", ")", ";", "}", "$", "path", "=", "$", "relative_to", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ";", "}", "if", "(", "is_link", "(", "$", "path", ")", ")", "{", "$", "parent_realpath", "=", "realpath", "(", "dirname", "(", "$", "path", ")", ")", ";", "if", "(", "$", "parent_realpath", "!==", "false", ")", "{", "return", "$", "parent_realpath", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "path", ")", ";", "}", "}", "$", "realpath", "=", "realpath", "(", "$", "path", ")", ";", "if", "(", "$", "realpath", "!==", "false", ")", "{", "return", "$", "realpath", ";", "}", "// This won't work if the file doesn't exist or is on an unreadable mount", "// or something crazy like that. Try to resolve a parent so we at least", "// cover the nonexistent file case.", "$", "parts", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "trim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ")", ";", "while", "(", "end", "(", "$", "parts", ")", "!==", "false", ")", "{", "array_pop", "(", "$", "parts", ")", ";", "if", "(", "self", "::", "isWindows", "(", ")", ")", "{", "$", "attempt", "=", "implode", "(", "DIRECTORY_SEPARATOR", ",", "$", "parts", ")", ";", "}", "else", "{", "$", "attempt", "=", "DIRECTORY_SEPARATOR", ".", "implode", "(", "DIRECTORY_SEPARATOR", ",", "$", "parts", ")", ";", "}", "$", "realpath", "=", "realpath", "(", "$", "attempt", ")", ";", "if", "(", "$", "realpath", "!==", "false", ")", "{", "$", "path", "=", "$", "realpath", ".", "substr", "(", "$", "path", ",", "strlen", "(", "$", "attempt", ")", ")", ";", "break", ";", "}", "}", "return", "$", "path", ";", "}" ]
Canonicalize a path by resolving it relative to some directory (by default PWD), following parent symlinks and removing artifacts. If the path is itself a symlink it is left unresolved. @param string Path, absolute or relative to PWD. @return string Canonical, absolute path. @task path
[ "Canonicalize", "a", "path", "by", "resolving", "it", "relative", "to", "some", "directory", "(", "by", "default", "PWD", ")", "following", "parent", "symlinks", "and", "removing", "artifacts", ".", "If", "the", "path", "is", "itself", "a", "symlink", "it", "is", "left", "unresolved", "." ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/FileHelper.php#L118-L164
blast-project/BaseEntitiesBundle
src/EventListener/TimestampableListener.php
TimestampableListener.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } // return if current entity doesn't use Timestampable trait // Check if parents already have the Timestampable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « loadClassMetadata » event' ); // setting default mapping configuration for Timestampable // createdAt $metadata->mapField([ 'fieldName' => 'createdAt', 'type' => 'datetime', ]); // updatedAt $metadata->mapField([ 'fieldName' => 'updatedAt', 'type' => 'datetime', ]); $this->logger->debug( '[TimestampableListener] Added Timestampable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } // return if current entity doesn't use Timestampable trait // Check if parents already have the Timestampable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « loadClassMetadata » event' ); // setting default mapping configuration for Timestampable // createdAt $metadata->mapField([ 'fieldName' => 'createdAt', 'type' => 'datetime', ]); // updatedAt $metadata->mapField([ 'fieldName' => 'updatedAt', 'type' => 'datetime', ]); $this->logger->debug( '[TimestampableListener] Added Timestampable mapping metadata to Entity', ['class' => $metadata->getName()] ); }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "eventArgs", ")", "{", "/** @var ClassMetadata $metadata */", "$", "metadata", "=", "$", "eventArgs", "->", "getClassMetadata", "(", ")", ";", "$", "reflectionClass", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "$", "reflectionClass", "||", "!", "$", "this", "->", "hasTrait", "(", "$", "reflectionClass", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Timestampable'", ")", ")", "{", "return", ";", "}", "// return if current entity doesn't use Timestampable trait", "// Check if parents already have the Timestampable trait", "foreach", "(", "$", "metadata", "->", "parentClasses", "as", "$", "parent", ")", "{", "if", "(", "$", "this", "->", "classAnalyzer", "->", "hasTrait", "(", "$", "parent", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Timestampable'", ")", ")", "{", "return", ";", "}", "}", "$", "this", "->", "logger", "->", "debug", "(", "'[TimestampableListener] Entering TimestampableListener for « loadClassMetadata » event'", ")", ";", "// setting default mapping configuration for Timestampable", "// createdAt", "$", "metadata", "->", "mapField", "(", "[", "'fieldName'", "=>", "'createdAt'", ",", "'type'", "=>", "'datetime'", ",", "]", ")", ";", "// updatedAt", "$", "metadata", "->", "mapField", "(", "[", "'fieldName'", "=>", "'updatedAt'", ",", "'type'", "=>", "'datetime'", ",", "]", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'[TimestampableListener] Added Timestampable mapping metadata to Entity'", ",", "[", "'class'", "=>", "$", "metadata", "->", "getName", "(", ")", "]", ")", ";", "}" ]
define Timestampable mapping at runtime. @param LoadClassMetadataEventArgs $eventArgs
[ "define", "Timestampable", "mapping", "at", "runtime", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/TimestampableListener.php#L53-L93
blast-project/BaseEntitiesBundle
src/EventListener/TimestampableListener.php
TimestampableListener.prePersist
public function prePersist(LifecycleEventArgs $eventArgs) { $entity = $eventArgs->getObject(); if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « prePersist » event' ); $now = new DateTime('NOW'); $entity->setCreatedAt($now); $entity->setUpdatedAt($now); }
php
public function prePersist(LifecycleEventArgs $eventArgs) { $entity = $eventArgs->getObject(); if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « prePersist » event' ); $now = new DateTime('NOW'); $entity->setCreatedAt($now); $entity->setUpdatedAt($now); }
[ "public", "function", "prePersist", "(", "LifecycleEventArgs", "$", "eventArgs", ")", "{", "$", "entity", "=", "$", "eventArgs", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "this", "->", "hasTrait", "(", "$", "entity", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Timestampable'", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'[TimestampableListener] Entering TimestampableListener for « prePersist » event'", ")", ";", "$", "now", "=", "new", "DateTime", "(", "'NOW'", ")", ";", "$", "entity", "->", "setCreatedAt", "(", "$", "now", ")", ";", "$", "entity", "->", "setUpdatedAt", "(", "$", "now", ")", ";", "}" ]
sets Timestampable dateTime (createdAt and updatedAt) information when persisting entity. @param LifecycleEventArgs $eventArgs
[ "sets", "Timestampable", "dateTime", "(", "createdAt", "and", "updatedAt", ")", "information", "when", "persisting", "entity", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/TimestampableListener.php#L100-L115
blast-project/BaseEntitiesBundle
src/EventListener/TimestampableListener.php
TimestampableListener.preUpdate
public function preUpdate(LifecycleEventArgs $eventArgs) { $entity = $eventArgs->getObject(); if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « preUpdate » event' ); $now = new DateTime('NOW'); $entity->setUpdatedAt($now); }
php
public function preUpdate(LifecycleEventArgs $eventArgs) { $entity = $eventArgs->getObject(); if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) { return; } $this->logger->debug( '[TimestampableListener] Entering TimestampableListener for « preUpdate » event' ); $now = new DateTime('NOW'); $entity->setUpdatedAt($now); }
[ "public", "function", "preUpdate", "(", "LifecycleEventArgs", "$", "eventArgs", ")", "{", "$", "entity", "=", "$", "eventArgs", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "this", "->", "hasTrait", "(", "$", "entity", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Timestampable'", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'[TimestampableListener] Entering TimestampableListener for « preUpdate » event'", ")", ";", "$", "now", "=", "new", "DateTime", "(", "'NOW'", ")", ";", "$", "entity", "->", "setUpdatedAt", "(", "$", "now", ")", ";", "}" ]
sets Timestampable dateTime (updatedAt) information when updating entity. @param LifecycleEventArgs $eventArgs
[ "sets", "Timestampable", "dateTime", "(", "updatedAt", ")", "information", "when", "updating", "entity", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/TimestampableListener.php#L122-L136
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.disconnect
public function disconnect() { if ( $this->state != self::STATE_NOT_CONNECTED ) { $this->connection->sendData( 'QUIT' ); $this->connection->getLine(); // discard $this->state = self::STATE_UPDATE; $this->connection->close(); $this->connection = null; $this->state = self::STATE_NOT_CONNECTED; } }
php
public function disconnect() { if ( $this->state != self::STATE_NOT_CONNECTED ) { $this->connection->sendData( 'QUIT' ); $this->connection->getLine(); // discard $this->state = self::STATE_UPDATE; $this->connection->close(); $this->connection = null; $this->state = self::STATE_NOT_CONNECTED; } }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_NOT_CONNECTED", ")", "{", "$", "this", "->", "connection", "->", "sendData", "(", "'QUIT'", ")", ";", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "// discard", "$", "this", "->", "state", "=", "self", "::", "STATE_UPDATE", ";", "$", "this", "->", "connection", "->", "close", "(", ")", ";", "$", "this", "->", "connection", "=", "null", ";", "$", "this", "->", "state", "=", "self", "::", "STATE_NOT_CONNECTED", ";", "}", "}" ]
Disconnects the transport from the POP3 server.
[ "Disconnects", "the", "transport", "from", "the", "POP3", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L308-L320
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.authenticate
public function authenticate( $user, $password, $method = null ) { if ( $this->state != self::STATE_AUTHORIZATION ) { throw new ezcMailTransportException( "Tried to authenticate when there was no connection or when already authenticated." ); } if ( is_null( $method ) ) { $method = $this->options->authenticationMethod; } if ( $method == self::AUTH_PLAIN_TEXT ) // normal plain text login { // authenticate ourselves $this->connection->sendData( "USER {$user}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the username: {$response}." ); } $this->connection->sendData( "PASS {$password}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the password: {$response}." ); } } else if ( $method == self::AUTH_APOP ) // APOP login { // fetch the timestamp from the greeting $timestamp = ''; preg_match( '/.*(<.*>).*/', $this->greeting, $timestamp ); // check if there was a greeting. If not, apop is not supported if ( count( $timestamp ) < 2 ) { throw new ezcMailTransportException( "The POP3 server did not accept the APOP login: No greeting." ); } $hash = md5( $timestamp[1] . $password ); $this->connection->sendData( "APOP {$user} {$hash}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the APOP login: {$response}." ); } } else { throw new ezcMailTransportException( "Invalid authentication method provided." ); } $this->state = self::STATE_TRANSACTION; }
php
public function authenticate( $user, $password, $method = null ) { if ( $this->state != self::STATE_AUTHORIZATION ) { throw new ezcMailTransportException( "Tried to authenticate when there was no connection or when already authenticated." ); } if ( is_null( $method ) ) { $method = $this->options->authenticationMethod; } if ( $method == self::AUTH_PLAIN_TEXT ) // normal plain text login { // authenticate ourselves $this->connection->sendData( "USER {$user}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the username: {$response}." ); } $this->connection->sendData( "PASS {$password}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the password: {$response}." ); } } else if ( $method == self::AUTH_APOP ) // APOP login { // fetch the timestamp from the greeting $timestamp = ''; preg_match( '/.*(<.*>).*/', $this->greeting, $timestamp ); // check if there was a greeting. If not, apop is not supported if ( count( $timestamp ) < 2 ) { throw new ezcMailTransportException( "The POP3 server did not accept the APOP login: No greeting." ); } $hash = md5( $timestamp[1] . $password ); $this->connection->sendData( "APOP {$user} {$hash}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server did not accept the APOP login: {$response}." ); } } else { throw new ezcMailTransportException( "Invalid authentication method provided." ); } $this->state = self::STATE_TRANSACTION; }
[ "public", "function", "authenticate", "(", "$", "user", ",", "$", "password", ",", "$", "method", "=", "null", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHORIZATION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Tried to authenticate when there was no connection or when already authenticated.\"", ")", ";", "}", "if", "(", "is_null", "(", "$", "method", ")", ")", "{", "$", "method", "=", "$", "this", "->", "options", "->", "authenticationMethod", ";", "}", "if", "(", "$", "method", "==", "self", "::", "AUTH_PLAIN_TEXT", ")", "// normal plain text login", "{", "// authenticate ourselves", "$", "this", "->", "connection", "->", "sendData", "(", "\"USER {$user}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server did not accept the username: {$response}.\"", ")", ";", "}", "$", "this", "->", "connection", "->", "sendData", "(", "\"PASS {$password}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server did not accept the password: {$response}.\"", ")", ";", "}", "}", "else", "if", "(", "$", "method", "==", "self", "::", "AUTH_APOP", ")", "// APOP login", "{", "// fetch the timestamp from the greeting", "$", "timestamp", "=", "''", ";", "preg_match", "(", "'/.*(<.*>).*/'", ",", "$", "this", "->", "greeting", ",", "$", "timestamp", ")", ";", "// check if there was a greeting. If not, apop is not supported", "if", "(", "count", "(", "$", "timestamp", ")", "<", "2", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server did not accept the APOP login: No greeting.\"", ")", ";", "}", "$", "hash", "=", "md5", "(", "$", "timestamp", "[", "1", "]", ".", "$", "password", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"APOP {$user} {$hash}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server did not accept the APOP login: {$response}.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"Invalid authentication method provided.\"", ")", ";", "}", "$", "this", "->", "state", "=", "self", "::", "STATE_TRANSACTION", ";", "}" ]
Authenticates the user to the POP3 server with $user and $password. You can choose the authentication method with the $method parameter. The default is to use plaintext username and password (specified in the ezcMailPop3TransportOptions class). This method should be called directly after the construction of this object. Example: <code> // replace with your POP3 server address $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); // replace the values with your username and password for the POP3 server $pop3->authenticate( 'username', 'password' ); </code> @throws ezcMailTransportException if there is no connection to the server or if already authenticated or if the authentication method is not accepted by the server or if the provided username/password combination did not work @param string $user @param string $password @param int $method
[ "Authenticates", "the", "user", "to", "the", "POP3", "server", "with", "$user", "and", "$password", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L350-L404
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.listMessages
public function listMessages() { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call listMessages() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "LIST" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the LIST command: {$response}." ); } // fetch the data from the server and prepare it to be returned. $messages = array(); while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { list( $num, $size ) = explode( ' ', $response ); $messages[$num] = $size; } return $messages; }
php
public function listMessages() { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call listMessages() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "LIST" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the LIST command: {$response}." ); } // fetch the data from the server and prepare it to be returned. $messages = array(); while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { list( $num, $size ) = explode( ' ', $response ); $messages[$num] = $size; } return $messages; }
[ "public", "function", "listMessages", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call listMessages() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "// send the command", "$", "this", "->", "connection", "->", "sendData", "(", "\"LIST\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative response to the LIST command: {$response}.\"", ")", ";", "}", "// fetch the data from the server and prepare it to be returned.", "$", "messages", "=", "array", "(", ")", ";", "while", "(", "(", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", "true", ")", ")", "!==", "\".\"", ")", "{", "list", "(", "$", "num", ",", "$", "size", ")", "=", "explode", "(", "' '", ",", "$", "response", ")", ";", "$", "messages", "[", "$", "num", "]", "=", "$", "size", ";", "}", "return", "$", "messages", ";", "}" ]
Returns an array of the message numbers on the server and the size of the messages in bytes. The format of the returned array is: <code> array( message_id => message_size ); </code> Example: <code> array( 2 => 1700, 5 => 1450, 6 => 21043 ); </code> Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @return array(int)
[ "Returns", "an", "array", "of", "the", "message", "numbers", "on", "the", "server", "and", "the", "size", "of", "the", "messages", "in", "bytes", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L429-L452
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.listUniqueIdentifiers
public function listUniqueIdentifiers( $msgNum = null ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call ListUniqueIdentifiers() on the POP3 transport when not successfully logged in." ); } // send the command $result = array(); if ( $msgNum !== null ) { $this->connection->sendData( "UIDL {$msgNum}" ); $response = $this->connection->getLine( true ); if ( $this->isPositiveResponse( $response ) ) { // get the single response line from the server list( $dummy, $num, $id ) = explode( ' ', $response ); $result[(int)$num] = $id; } else { throw new ezcMailTransportException( "The POP3 server sent a negative response to the UIDL command: {$response}." ); } } else { $this->connection->sendData( "UIDL" ); $response = $this->connection->getLine(); if ( $this->isPositiveResponse( $response ) ) { // fetch each of the result lines and add it to the result while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { list( $num, $id ) = explode( ' ', $response ); $result[(int)$num] = $id; } } else { throw new ezcMailTransportException( "The POP3 server sent a negative response to the UIDL command: {$response}." ); } } return $result; }
php
public function listUniqueIdentifiers( $msgNum = null ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call ListUniqueIdentifiers() on the POP3 transport when not successfully logged in." ); } // send the command $result = array(); if ( $msgNum !== null ) { $this->connection->sendData( "UIDL {$msgNum}" ); $response = $this->connection->getLine( true ); if ( $this->isPositiveResponse( $response ) ) { // get the single response line from the server list( $dummy, $num, $id ) = explode( ' ', $response ); $result[(int)$num] = $id; } else { throw new ezcMailTransportException( "The POP3 server sent a negative response to the UIDL command: {$response}." ); } } else { $this->connection->sendData( "UIDL" ); $response = $this->connection->getLine(); if ( $this->isPositiveResponse( $response ) ) { // fetch each of the result lines and add it to the result while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { list( $num, $id ) = explode( ' ', $response ); $result[(int)$num] = $id; } } else { throw new ezcMailTransportException( "The POP3 server sent a negative response to the UIDL command: {$response}." ); } } return $result; }
[ "public", "function", "listUniqueIdentifiers", "(", "$", "msgNum", "=", "null", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call ListUniqueIdentifiers() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "// send the command", "$", "result", "=", "array", "(", ")", ";", "if", "(", "$", "msgNum", "!==", "null", ")", "{", "$", "this", "->", "connection", "->", "sendData", "(", "\"UIDL {$msgNum}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", "true", ")", ";", "if", "(", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "// get the single response line from the server", "list", "(", "$", "dummy", ",", "$", "num", ",", "$", "id", ")", "=", "explode", "(", "' '", ",", "$", "response", ")", ";", "$", "result", "[", "(", "int", ")", "$", "num", "]", "=", "$", "id", ";", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative response to the UIDL command: {$response}.\"", ")", ";", "}", "}", "else", "{", "$", "this", "->", "connection", "->", "sendData", "(", "\"UIDL\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "// fetch each of the result lines and add it to the result", "while", "(", "(", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", "true", ")", ")", "!==", "\".\"", ")", "{", "list", "(", "$", "num", ",", "$", "id", ")", "=", "explode", "(", "' '", ",", "$", "response", ")", ";", "$", "result", "[", "(", "int", ")", "$", "num", "]", "=", "$", "id", ";", "}", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative response to the UIDL command: {$response}.\"", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the unique identifiers for messages on the POP3 server. You can fetch the unique identifier for a specific message by providing the $msgNum parameter. The unique identifier can be used to recognize mail from servers between requests. In contrast to the message numbers the unique numbers assigned to an email usually never changes. Note: POP3 servers are not required to support this command and it may fail. The format of the returned array is: <code> array( message_num => unique_id ); </code> Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example: <code> array( 1 => '000001fc4420e93a', 2 => '000001fd4420e93a' ); </code> @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @param int $msgNum @return array(string)
[ "Returns", "the", "unique", "identifiers", "for", "messages", "on", "the", "POP3", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L486-L529
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.status
public function status( &$numMessages, &$sizeMessages ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call status() on the POP3 transport when not successfully logged in." ); } $this->connection->sendData( "STAT" ); $response = $this->connection->getLine(); if ( $this->isPositiveResponse( $response ) ) { // get the single response line from the server list( $dummy, $numMessages, $sizeMessages ) = explode( ' ', $response ); $numMessages = (int)$numMessages; $sizeMessages = (int)$sizeMessages; } else { throw new ezcMailTransportException( "The POP3 server did not respond with a status message: {$response}." ); } }
php
public function status( &$numMessages, &$sizeMessages ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call status() on the POP3 transport when not successfully logged in." ); } $this->connection->sendData( "STAT" ); $response = $this->connection->getLine(); if ( $this->isPositiveResponse( $response ) ) { // get the single response line from the server list( $dummy, $numMessages, $sizeMessages ) = explode( ' ', $response ); $numMessages = (int)$numMessages; $sizeMessages = (int)$sizeMessages; } else { throw new ezcMailTransportException( "The POP3 server did not respond with a status message: {$response}." ); } }
[ "public", "function", "status", "(", "&", "$", "numMessages", ",", "&", "$", "sizeMessages", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call status() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "$", "this", "->", "connection", "->", "sendData", "(", "\"STAT\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "// get the single response line from the server", "list", "(", "$", "dummy", ",", "$", "numMessages", ",", "$", "sizeMessages", ")", "=", "explode", "(", "' '", ",", "$", "response", ")", ";", "$", "numMessages", "=", "(", "int", ")", "$", "numMessages", ";", "$", "sizeMessages", "=", "(", "int", ")", "$", "sizeMessages", ";", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server did not respond with a status message: {$response}.\"", ")", ";", "}", "}" ]
Returns information about the messages on the server. The information returned through the parameters is: - $numMessages = number of messages - $sizeMessages = sum of the messages sizes Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example of returning the status of messages on the server: <code> $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); $pop3->authenticate( 'username', 'password' ); $pop3->status( $numMessages, $sizeMessages ); </code> After running the above code, $numMessages and $sizeMessages will be populated with values. @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @param int &$numMessages @param int &$sizeMessages
[ "Returns", "information", "about", "the", "messages", "on", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L559-L579
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.delete
public function delete( $msgNum ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call delete() on the POP3 transport when not successfully logged in." ); } $this->connection->sendData( "DELE {$msgNum}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server could not delete the message: {$response}." ); } }
php
public function delete( $msgNum ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call delete() on the POP3 transport when not successfully logged in." ); } $this->connection->sendData( "DELE {$msgNum}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server could not delete the message: {$response}." ); } }
[ "public", "function", "delete", "(", "$", "msgNum", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call delete() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "$", "this", "->", "connection", "->", "sendData", "(", "\"DELE {$msgNum}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server could not delete the message: {$response}.\"", ")", ";", "}", "}" ]
Deletes the message with the message number $msgNum from the server. The message number must be a valid identifier fetched with (example) {@link listMessages()}. Any future reference to the message-number associated with the message in a command generates an error. Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @param int $msgNum
[ "Deletes", "the", "message", "with", "the", "message", "number", "$msgNum", "from", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L599-L613
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.top
public function top( $msgNum, $numLines = 0 ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call top() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "TOP {$msgNum} {$numLines}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the TOP command: {$response}." ); } // fetch the data from the server and prepare it to be returned. $message = ""; while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { $message .= $response . "\n"; } return $message; }
php
public function top( $msgNum, $numLines = 0 ) { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call top() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "TOP {$msgNum} {$numLines}" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the TOP command: {$response}." ); } // fetch the data from the server and prepare it to be returned. $message = ""; while ( ( $response = $this->connection->getLine( true ) ) !== "." ) { $message .= $response . "\n"; } return $message; }
[ "public", "function", "top", "(", "$", "msgNum", ",", "$", "numLines", "=", "0", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call top() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "// send the command", "$", "this", "->", "connection", "->", "sendData", "(", "\"TOP {$msgNum} {$numLines}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative response to the TOP command: {$response}.\"", ")", ";", "}", "// fetch the data from the server and prepare it to be returned.", "$", "message", "=", "\"\"", ";", "while", "(", "(", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", "true", ")", ")", "!==", "\".\"", ")", "{", "$", "message", ".=", "$", "response", ".", "\"\\n\"", ";", "}", "return", "$", "message", ";", "}" ]
Returns the headers and the $numLines first lines of the body of the mail with the message number $msgNum. If the command failed or if it was not supported by the server an empty string is returned. Note: POP3 servers are not required to support this command and it may fail. Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example of listing the mail headers of all the messages from the server: <code> $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); $pop3->authenticate( 'username', 'password' ); $parser = new ezcMailParser(); $messages = $pop3->listMessages(); foreach ( $messages as $messageNr => $size ) { $set = new ezcMailVariableSet( $pop3->top( $messageNr ) ); $mail = $parser->parseMail( $set ); $mail = $mail[0]; echo "From: {$mail->from}, Subject: {$mail->subject}, Size: {$size}\n"; } </code> @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @param int $msgNum @param int $numLines @return string
[ "Returns", "the", "headers", "and", "the", "$numLines", "first", "lines", "of", "the", "body", "of", "the", "mail", "with", "the", "message", "number", "$msgNum", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L651-L673
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.fetchAll
public function fetchAll( $deleteFromServer = false ) { $messages = $this->listMessages(); return new ezcMailPop3Set( $this->connection, array_keys( $messages ), $deleteFromServer ); }
php
public function fetchAll( $deleteFromServer = false ) { $messages = $this->listMessages(); return new ezcMailPop3Set( $this->connection, array_keys( $messages ), $deleteFromServer ); }
[ "public", "function", "fetchAll", "(", "$", "deleteFromServer", "=", "false", ")", "{", "$", "messages", "=", "$", "this", "->", "listMessages", "(", ")", ";", "return", "new", "ezcMailPop3Set", "(", "$", "this", "->", "connection", ",", "array_keys", "(", "$", "messages", ")", ",", "$", "deleteFromServer", ")", ";", "}" ]
Returns an ezcMailPop3Set with all the messages on the server. If $deleteFromServer is set to true the mail will be removed from the server after retrieval. If not it will be left. Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example: <code> $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); $pop3->authenticate( 'username', 'password' ); $set = $pop3->fetchAll(); // parse $set with ezcMailParser $parser = new ezcMailParser(); $mails = $parser->parseMail( $set ); foreach ( $mails as $mail ) { // process $mail which is an ezcMail object } </code> @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @param bool $deleteFromServer @return ezcMailParserSet
[ "Returns", "an", "ezcMailPop3Set", "with", "all", "the", "messages", "on", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L707-L711
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.fetchByMessageNr
public function fetchByMessageNr( $number, $deleteFromServer = false ) { $messages = $this->listMessages(); if ( !isset( $messages[$number] ) ) { throw new ezcMailNoSuchMessageException( $number ); } return new ezcMailPop3Set( $this->connection, array( $number ), $deleteFromServer ); }
php
public function fetchByMessageNr( $number, $deleteFromServer = false ) { $messages = $this->listMessages(); if ( !isset( $messages[$number] ) ) { throw new ezcMailNoSuchMessageException( $number ); } return new ezcMailPop3Set( $this->connection, array( $number ), $deleteFromServer ); }
[ "public", "function", "fetchByMessageNr", "(", "$", "number", ",", "$", "deleteFromServer", "=", "false", ")", "{", "$", "messages", "=", "$", "this", "->", "listMessages", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "messages", "[", "$", "number", "]", ")", ")", "{", "throw", "new", "ezcMailNoSuchMessageException", "(", "$", "number", ")", ";", "}", "return", "new", "ezcMailPop3Set", "(", "$", "this", "->", "connection", ",", "array", "(", "$", "number", ")", ",", "$", "deleteFromServer", ")", ";", "}" ]
Returns an ezcMailPop3Set containing only the $number -th message from the server. If $deleteFromServer is set to true the mail will be removed from the server after retrieval. If not it will be left. Note: for POP3 the first message is 1 (so for $number = 0 the exception will be thrown). Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example: <code> $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); $pop3->authenticate( 'username', 'password' ); $set = $pop3->fetchByMessageNr( 1 ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @throws ezcMailNoSuchMessageException if the message $number is out of range @param int $number @param bool $deleteFromServer @return ezcMailPop3Set
[ "Returns", "an", "ezcMailPop3Set", "containing", "only", "the", "$number", "-", "th", "message", "from", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L746-L754
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.fetchFromOffset
public function fetchFromOffset( $offset, $count = 0, $deleteFromServer = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } $messages = array_keys( $this->listMessages() ); if ( $count == 0 ) { $range = array_slice( $messages, $offset - 1, count( $messages ), true ); } else { $range = array_slice( $messages, $offset - 1, $count, true ); } if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } return new ezcMailPop3Set( $this->connection, $range, $deleteFromServer ); }
php
public function fetchFromOffset( $offset, $count = 0, $deleteFromServer = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } $messages = array_keys( $this->listMessages() ); if ( $count == 0 ) { $range = array_slice( $messages, $offset - 1, count( $messages ), true ); } else { $range = array_slice( $messages, $offset - 1, $count, true ); } if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } return new ezcMailPop3Set( $this->connection, $range, $deleteFromServer ); }
[ "public", "function", "fetchFromOffset", "(", "$", "offset", ",", "$", "count", "=", "0", ",", "$", "deleteFromServer", "=", "false", ")", "{", "if", "(", "$", "count", "<", "0", ")", "{", "throw", "new", "ezcMailInvalidLimitException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "$", "messages", "=", "array_keys", "(", "$", "this", "->", "listMessages", "(", ")", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "$", "range", "=", "array_slice", "(", "$", "messages", ",", "$", "offset", "-", "1", ",", "count", "(", "$", "messages", ")", ",", "true", ")", ";", "}", "else", "{", "$", "range", "=", "array_slice", "(", "$", "messages", ",", "$", "offset", "-", "1", ",", "$", "count", ",", "true", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "range", "[", "$", "offset", "-", "1", "]", ")", ")", "{", "throw", "new", "ezcMailOffsetOutOfRangeException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "return", "new", "ezcMailPop3Set", "(", "$", "this", "->", "connection", ",", "$", "range", ",", "$", "deleteFromServer", ")", ";", "}" ]
Returns an ezcMailPop3Set with $count messages starting from $offset from the server. Fetches $count messages starting from the $offset and returns them as a ezcMailPop3Set. If $count is not specified or if it is 0, it fetches all messages starting from the $offset. Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. Example: <code> $pop3 = new ezcMailPop3Transport( 'pop3.example.com' ); $pop3->authenticate( 'username', 'password' ); $set = $pop3->fetchFromOffset( 1, 10 ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response @throws ezcMailInvalidLimitException if $count is negative @throws ezcMailOffsetOutOfRangeException if $offset is outside of the existing range of messages @param int $offset @param int $count @param bool $deleteFromServer @return ezcMailPop3Set
[ "Returns", "an", "ezcMailPop3Set", "with", "$count", "messages", "starting", "from", "$offset", "from", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L790-L810
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php
ezcMailPop3Transport.noop
public function noop() { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call noop() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "NOOP" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the NOOP command: {$response}." ); } }
php
public function noop() { if ( $this->state != self::STATE_TRANSACTION ) { throw new ezcMailTransportException( "Can't call noop() on the POP3 transport when not successfully logged in." ); } // send the command $this->connection->sendData( "NOOP" ); $response = $this->connection->getLine(); if ( !$this->isPositiveResponse( $response ) ) { throw new ezcMailTransportException( "The POP3 server sent a negative response to the NOOP command: {$response}." ); } }
[ "public", "function", "noop", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_TRANSACTION", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call noop() on the POP3 transport when not successfully logged in.\"", ")", ";", "}", "// send the command", "$", "this", "->", "connection", "->", "sendData", "(", "\"NOOP\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isPositiveResponse", "(", "$", "response", ")", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative response to the NOOP command: {$response}.\"", ")", ";", "}", "}" ]
Sends a NOOP command to the server, use it to keep the connection alive. Before calling this method, a connection to the POP3 server must be established and a user must be authenticated successfully. @throws ezcMailTransportException if there was no connection to the server or if not authenticated or if the server sent a negative response
[ "Sends", "a", "NOOP", "command", "to", "the", "server", "use", "it", "to", "keep", "the", "connection", "alive", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_transport.php#L823-L837
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.addAllToSet
public function addAllToSet(string $field, array $values) { $this->update()->addToSet($field, ['$each' => $values]); return $this; }
php
public function addAllToSet(string $field, array $values) { $this->update()->addToSet($field, ['$each' => $values]); return $this; }
[ "public", "function", "addAllToSet", "(", "string", "$", "field", ",", "array", "$", "values", ")", "{", "$", "this", "->", "update", "(", ")", "->", "addToSet", "(", "$", "field", ",", "[", "'$each'", "=>", "$", "values", "]", ")", ";", "return", "$", "this", ";", "}" ]
@param string $field @param array $values @return $this
[ "@param", "string", "$field", "@param", "array", "$values" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L92-L97
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.addToSet
public function addToSet(string $field, $value) { $this->update(); $this->mongoDbUpdate['$addToSet'][$field] = $value; return $this; }
php
public function addToSet(string $field, $value) { $this->update(); $this->mongoDbUpdate['$addToSet'][$field] = $value; return $this; }
[ "public", "function", "addToSet", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$addToSet'", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
@param string $field @param mixed $value @return $this
[ "@param", "string", "$field", "@param", "mixed", "$value" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L105-L111
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.pullAll
public function pullAll(string $field, array $values) { $this->update(); $this->mongoDbUpdate['$pullAll'][$field] = $values; return $this; }
php
public function pullAll(string $field, array $values) { $this->update(); $this->mongoDbUpdate['$pullAll'][$field] = $values; return $this; }
[ "public", "function", "pullAll", "(", "string", "$", "field", ",", "array", "$", "values", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$pullAll'", "]", "[", "$", "field", "]", "=", "$", "values", ";", "return", "$", "this", ";", "}" ]
@param string $field @param array $values @return $this
[ "@param", "string", "$field", "@param", "array", "$values" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L145-L151
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.pull
public function pull(string $field, $condition) { $this->update(); $this->mongoDbUpdate['$pull'][$field] = $condition; return $this; }
php
public function pull(string $field, $condition) { $this->update(); $this->mongoDbUpdate['$pull'][$field] = $condition; return $this; }
[ "public", "function", "pull", "(", "string", "$", "field", ",", "$", "condition", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$pull'", "]", "[", "$", "field", "]", "=", "$", "condition", ";", "return", "$", "this", ";", "}" ]
@param string $field @param array|mixed $condition - a condition to specify values to delete, or a value to delete @return $this
[ "@param", "string", "$field", "@param", "array|mixed", "$condition", "-", "a", "condition", "to", "specify", "values", "to", "delete", "or", "a", "value", "to", "delete" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L159-L165
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.pushAll
public function pushAll(string $field, array $values) { $this->update()->push($field, ['$each' => $values]); return $this; }
php
public function pushAll(string $field, array $values) { $this->update()->push($field, ['$each' => $values]); return $this; }
[ "public", "function", "pushAll", "(", "string", "$", "field", ",", "array", "$", "values", ")", "{", "$", "this", "->", "update", "(", ")", "->", "push", "(", "$", "field", ",", "[", "'$each'", "=>", "$", "values", "]", ")", ";", "return", "$", "this", ";", "}" ]
@param string $field @param array $values @return $this
[ "@param", "string", "$field", "@param", "array", "$values" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L183-L188
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.increment
public function increment(string $field, $value) { $this->update(); $this->mongoDbUpdate['$inc'][$field] = $value; return $this; }
php
public function increment(string $field, $value) { $this->update(); $this->mongoDbUpdate['$inc'][$field] = $value; return $this; }
[ "public", "function", "increment", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$inc'", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
@param string $field @param int|float $value @return $this
[ "@param", "string", "$field", "@param", "int|float", "$value" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L214-L220
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.multiply
public function multiply(string $field, $value) { $this->update(); $this->mongoDbUpdate['$mul'][$field] = $value; return $this; }
php
public function multiply(string $field, $value) { $this->update(); $this->mongoDbUpdate['$mul'][$field] = $value; return $this; }
[ "public", "function", "multiply", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$mul'", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
@param string $field @param int|float $value @return $this
[ "@param", "string", "$field", "@param", "int|float", "$value" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L228-L234
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.min
public function min(string $field, $value) { $this->update(); $this->mongoDbUpdate['$min'][$field] = $value; return $this; }
php
public function min(string $field, $value) { $this->update(); $this->mongoDbUpdate['$min'][$field] = $value; return $this; }
[ "public", "function", "min", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$min'", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
@param string $field @param int|float $value @return $this
[ "@param", "string", "$field", "@param", "int|float", "$value" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L242-L248
tequila/mongodb-odm
src/Proxy/Traits/RootProxyTrait.php
RootProxyTrait.max
public function max(string $field, $value) { $this->update(); $this->mongoDbUpdate['$max'][$field] = $value; return $this; }
php
public function max(string $field, $value) { $this->update(); $this->mongoDbUpdate['$max'][$field] = $value; return $this; }
[ "public", "function", "max", "(", "string", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "update", "(", ")", ";", "$", "this", "->", "mongoDbUpdate", "[", "'$max'", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
@param string $field @param int|float $value @return $this
[ "@param", "string", "$field", "@param", "int|float", "$value" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Proxy/Traits/RootProxyTrait.php#L256-L262