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
jasny/controller
src/Controller/RouteAction.php
RouteAction.getFunctionArgs
protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl) { $args = []; $params = $refl->getParameters(); foreach ($params as $param) { $key = $param->name; if (property_exists($route, $key)) { $value = $route->$key; } else { if (!$param->isOptional()) { $fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name; throw new \RuntimeException("Missing argument '$key' for {$fn}()"); } $value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null; } $args[$key] = $value; } return $args; }
php
protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl) { $args = []; $params = $refl->getParameters(); foreach ($params as $param) { $key = $param->name; if (property_exists($route, $key)) { $value = $route->$key; } else { if (!$param->isOptional()) { $fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name; throw new \RuntimeException("Missing argument '$key' for {$fn}()"); } $value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null; } $args[$key] = $value; } return $args; }
[ "protected", "function", "getFunctionArgs", "(", "\\", "stdClass", "$", "route", ",", "\\", "ReflectionFunctionAbstract", "$", "refl", ")", "{", "$", "args", "=", "[", "]", ";", "$", "params", "=", "$", "refl", "->", "getParameters", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "key", "=", "$", "param", "->", "name", ";", "if", "(", "property_exists", "(", "$", "route", ",", "$", "key", ")", ")", "{", "$", "value", "=", "$", "route", "->", "$", "key", ";", "}", "else", "{", "if", "(", "!", "$", "param", "->", "isOptional", "(", ")", ")", "{", "$", "fn", "=", "$", "refl", "instanceof", "\\", "ReflectionMethod", "?", "$", "refl", "->", "class", ".", "'::'", ".", "$", "refl", "->", "name", ":", "$", "refl", "->", "name", ";", "throw", "new", "\\", "RuntimeException", "(", "\"Missing argument '$key' for {$fn}()\"", ")", ";", "}", "$", "value", "=", "$", "param", "->", "isDefaultValueAvailable", "(", ")", "?", "$", "param", "->", "getDefaultValue", "(", ")", ":", "null", ";", "}", "$", "args", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "args", ";", "}" ]
Get the arguments for a function from a route using reflection @param \stdClass $route @param \ReflectionFunctionAbstract $refl @return array
[ "Get", "the", "arguments", "for", "a", "function", "from", "a", "route", "using", "reflection" ]
train
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/RouteAction.php#L161-L184
42mate/towel
src/Towel/Model/User.php
User.validateLogin
public function validateLogin($email, $password) { $password = md5($password); $result = $this->fetchOne( "SELECT * FROM {$this->table} WHERE email = ? AND password = ?", array($email, $password) ); if (!empty($result)) { return true; } return false; }
php
public function validateLogin($email, $password) { $password = md5($password); $result = $this->fetchOne( "SELECT * FROM {$this->table} WHERE email = ? AND password = ?", array($email, $password) ); if (!empty($result)) { return true; } return false; }
[ "public", "function", "validateLogin", "(", "$", "email", ",", "$", "password", ")", "{", "$", "password", "=", "md5", "(", "$", "password", ")", ";", "$", "result", "=", "$", "this", "->", "fetchOne", "(", "\"SELECT * FROM {$this->table} WHERE email = ? AND password = ?\"", ",", "array", "(", "$", "email", ",", "$", "password", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "result", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Validates username and password against the DB. If success sets the user info in the object and return true. If fails returns false. @param String $email @param String $password @return Boolean
[ "Validates", "username", "and", "password", "against", "the", "DB", ".", "If", "success", "sets", "the", "user", "info", "in", "the", "object", "and", "return", "true", ".", "If", "fails", "returns", "false", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/User.php#L19-L33
42mate/towel
src/Towel/Model/User.php
User.regeneratePassword
public function regeneratePassword() { $clean_password = generatePassword(6, 4); $password = md5($clean_password); $this->db()->executeUpdate( "UPDATE {$this->table} SET password = ? WHERE ID = ?", array($password, $this->getId()) ); return $clean_password; }
php
public function regeneratePassword() { $clean_password = generatePassword(6, 4); $password = md5($clean_password); $this->db()->executeUpdate( "UPDATE {$this->table} SET password = ? WHERE ID = ?", array($password, $this->getId()) ); return $clean_password; }
[ "public", "function", "regeneratePassword", "(", ")", "{", "$", "clean_password", "=", "generatePassword", "(", "6", ",", "4", ")", ";", "$", "password", "=", "md5", "(", "$", "clean_password", ")", ";", "$", "this", "->", "db", "(", ")", "->", "executeUpdate", "(", "\"UPDATE {$this->table} SET password = ? WHERE ID = ?\"", ",", "array", "(", "$", "password", ",", "$", "this", "->", "getId", "(", ")", ")", ")", ";", "return", "$", "clean_password", ";", "}" ]
Regenerates and sets the new password for a User. @return String password : The new Password.
[ "Regenerates", "and", "sets", "the", "new", "password", "for", "a", "User", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/User.php#L70-L80
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.login
public function login($login, $password) { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before trying to login. Please use session_start()."); } } // Let's regenerate the session ID to avoid session fixation attacks. if ($this->sessionManager) { $this->sessionManager->regenerateId(); } // First, if we are logged, let's unlog the user. if ($this->isLogged()) { $this->logoff(); } $user = $this->userDao->getUserByCredentials($login, $password); if ($user != null) { if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs in.", array('login'=>$user->getLogin())); } else { $this->log->trace("User '".$user->getLogin()."' logs in."); } $_SESSION[$this->sessionPrefix.'MoufUserId'] = $user->getId(); $_SESSION[$this->sessionPrefix.'MoufUserLogin'] = $user->getLogin(); if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->afterLogIn($this); } } return true; } else { if ($this->log instanceof LoggerInterface) { $this->log->debug("Identication failed for login '{login}'", array('login'=>$login)); } else { $this->log->trace("Identication failed for login '".$login."'"); } return false; } }
php
public function login($login, $password) { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before trying to login. Please use session_start()."); } } // Let's regenerate the session ID to avoid session fixation attacks. if ($this->sessionManager) { $this->sessionManager->regenerateId(); } // First, if we are logged, let's unlog the user. if ($this->isLogged()) { $this->logoff(); } $user = $this->userDao->getUserByCredentials($login, $password); if ($user != null) { if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs in.", array('login'=>$user->getLogin())); } else { $this->log->trace("User '".$user->getLogin()."' logs in."); } $_SESSION[$this->sessionPrefix.'MoufUserId'] = $user->getId(); $_SESSION[$this->sessionPrefix.'MoufUserLogin'] = $user->getLogin(); if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->afterLogIn($this); } } return true; } else { if ($this->log instanceof LoggerInterface) { $this->log->debug("Identication failed for login '{login}'", array('login'=>$login)); } else { $this->log->trace("Identication failed for login '".$login."'"); } return false; } }
[ "public", "function", "login", "(", "$", "login", ",", "$", "password", ")", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before trying to login. Please use session_start().\"", ")", ";", "}", "}", "// Let's regenerate the session ID to avoid session fixation attacks.", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "regenerateId", "(", ")", ";", "}", "// First, if we are logged, let's unlog the user.", "if", "(", "$", "this", "->", "isLogged", "(", ")", ")", "{", "$", "this", "->", "logoff", "(", ")", ";", "}", "$", "user", "=", "$", "this", "->", "userDao", "->", "getUserByCredentials", "(", "$", "login", ",", "$", "password", ")", ";", "if", "(", "$", "user", "!=", "null", ")", "{", "if", "(", "$", "this", "->", "log", "instanceof", "LoggerInterface", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "\"User '{login}' logs in.\"", ",", "array", "(", "'login'", "=>", "$", "user", "->", "getLogin", "(", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "log", "->", "trace", "(", "\"User '\"", ".", "$", "user", "->", "getLogin", "(", ")", ".", "\"' logs in.\"", ")", ";", "}", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", "=", "$", "user", "->", "getLogin", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "authenticationListeners", ")", ")", "{", "foreach", "(", "$", "this", "->", "authenticationListeners", "as", "$", "listener", ")", "{", "$", "listener", "->", "afterLogIn", "(", "$", "this", ")", ";", "}", "}", "return", "true", ";", "}", "else", "{", "if", "(", "$", "this", "->", "log", "instanceof", "LoggerInterface", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "\"Identication failed for login '{login}'\"", ",", "array", "(", "'login'", "=>", "$", "login", ")", ")", ";", "}", "else", "{", "$", "this", "->", "log", "->", "trace", "(", "\"Identication failed for login '\"", ".", "$", "login", ".", "\"'\"", ")", ";", "}", "return", "false", ";", "}", "}" ]
Logs the user using the provided login and password. Returns true on success, false if the user or password is incorrect. A Mouf Exception is thrown if no session is initialized. Require the mouf/load.php file in Mouf to start a session. @param string $login @param string $password @return boolean.
[ "Logs", "the", "user", "using", "the", "provided", "login", "and", "password", ".", "Returns", "true", "on", "success", "false", "if", "the", "user", "or", "password", "is", "incorrect", ".", "A", "Mouf", "Exception", "is", "thrown", "if", "no", "session", "is", "initialized", ".", "Require", "the", "mouf", "/", "load", ".", "php", "file", "in", "Mouf", "to", "start", "a", "session", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L113-L158
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.loginWithoutPassword
public function loginWithoutPassword($login) { // First, if we are logged, let's unlog the user. if (!$this->byPassIsLogged && $this->isLogged()) { $this->logoff(); } $user = $this->userDao->getUserByLogin($login); if ($user == null) { throw new UserServiceException("Unable to find user whose login is ".$login); } if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs in, without providing a password.", array('login'=>$user->getLogin())); } else { $this->log->trace("User '".$user->getLogin()."' logs in, without providing a password."); } $_SESSION[$this->sessionPrefix.'MoufUserId'] = $user->getId(); $_SESSION[$this->sessionPrefix.'MoufUserLogin'] = $user->getLogin(); if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->afterLogIn($this); } } }
php
public function loginWithoutPassword($login) { // First, if we are logged, let's unlog the user. if (!$this->byPassIsLogged && $this->isLogged()) { $this->logoff(); } $user = $this->userDao->getUserByLogin($login); if ($user == null) { throw new UserServiceException("Unable to find user whose login is ".$login); } if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs in, without providing a password.", array('login'=>$user->getLogin())); } else { $this->log->trace("User '".$user->getLogin()."' logs in, without providing a password."); } $_SESSION[$this->sessionPrefix.'MoufUserId'] = $user->getId(); $_SESSION[$this->sessionPrefix.'MoufUserLogin'] = $user->getLogin(); if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->afterLogIn($this); } } }
[ "public", "function", "loginWithoutPassword", "(", "$", "login", ")", "{", "// First, if we are logged, let's unlog the user.", "if", "(", "!", "$", "this", "->", "byPassIsLogged", "&&", "$", "this", "->", "isLogged", "(", ")", ")", "{", "$", "this", "->", "logoff", "(", ")", ";", "}", "$", "user", "=", "$", "this", "->", "userDao", "->", "getUserByLogin", "(", "$", "login", ")", ";", "if", "(", "$", "user", "==", "null", ")", "{", "throw", "new", "UserServiceException", "(", "\"Unable to find user whose login is \"", ".", "$", "login", ")", ";", "}", "if", "(", "$", "this", "->", "log", "instanceof", "LoggerInterface", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "\"User '{login}' logs in, without providing a password.\"", ",", "array", "(", "'login'", "=>", "$", "user", "->", "getLogin", "(", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "log", "->", "trace", "(", "\"User '\"", ".", "$", "user", "->", "getLogin", "(", ")", ".", "\"' logs in, without providing a password.\"", ")", ";", "}", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", "=", "$", "user", "->", "getLogin", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "authenticationListeners", ")", ")", "{", "foreach", "(", "$", "this", "->", "authenticationListeners", "as", "$", "listener", ")", "{", "$", "listener", "->", "afterLogIn", "(", "$", "this", ")", ";", "}", "}", "}" ]
Logs the user using the provided login. The password is not needed if you use this function. Of course, you should use this functions sparingly. For instance, it can be useful if you want an administrator to "become" another user without requiring the administrator to provide the password. @param string $login
[ "Logs", "the", "user", "using", "the", "provided", "login", ".", "The", "password", "is", "not", "needed", "if", "you", "use", "this", "function", ".", "Of", "course", "you", "should", "use", "this", "functions", "sparingly", ".", "For", "instance", "it", "can", "be", "useful", "if", "you", "want", "an", "administrator", "to", "become", "another", "user", "without", "requiring", "the", "administrator", "to", "provide", "the", "password", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L169-L194
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.loginViaToken
public function loginViaToken($token) { $user = $this->userDao->getUserByToken($token); if ($user) { $this->loginWithoutPassword($user->getLogin()); return true; } else { return false; } }
php
public function loginViaToken($token) { $user = $this->userDao->getUserByToken($token); if ($user) { $this->loginWithoutPassword($user->getLogin()); return true; } else { return false; } }
[ "public", "function", "loginViaToken", "(", "$", "token", ")", "{", "$", "user", "=", "$", "this", "->", "userDao", "->", "getUserByToken", "(", "$", "token", ")", ";", "if", "(", "$", "user", ")", "{", "$", "this", "->", "loginWithoutPassword", "(", "$", "user", "->", "getLogin", "(", ")", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Logs a user using a token. The token should be discarded as soon as it was used. Returns false if the token is not valid, else true. @param string $token @return UserInterface
[ "Logs", "a", "user", "using", "a", "token", ".", "The", "token", "should", "be", "discarded", "as", "soon", "as", "it", "was", "used", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L206-L215
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.isLogged
public function isLogged() { $this->byPassIsLogged = true; try { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return true; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ if ($provider->isLogged($this)) { return true; } } } } catch (\Exception $e) { $this->byPassIsLogged = false; throw $e; } $this->byPassIsLogged = false; return false; }
php
public function isLogged() { $this->byPassIsLogged = true; try { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return true; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ if ($provider->isLogged($this)) { return true; } } } } catch (\Exception $e) { $this->byPassIsLogged = false; throw $e; } $this->byPassIsLogged = false; return false; }
[ "public", "function", "isLogged", "(", ")", "{", "$", "this", "->", "byPassIsLogged", "=", "true", ";", "try", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before checking if the user is logged. Please use session_start().\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ")", ")", "{", "return", "true", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "authProviders", "as", "$", "provider", ")", "{", "/* @var $provider AuthenticationProviderInterface */", "if", "(", "$", "provider", "->", "isLogged", "(", "$", "this", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "byPassIsLogged", "=", "false", ";", "throw", "$", "e", ";", "}", "$", "this", "->", "byPassIsLogged", "=", "false", ";", "return", "false", ";", "}" ]
Returns "true" if the user is logged, "false" otherwise. @return boolean
[ "Returns", "true", "if", "the", "user", "is", "logged", "false", "otherwise", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L222-L251
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.redirectNotLogged
public function redirectNotLogged() { // TODO: only if GET request! http_response_code(403); header("Location:".ROOT_URL.$this->loginPageUrl."?".$this->redirectParameter."=".urlencode($_SERVER['REQUEST_URI'])); exit; }
php
public function redirectNotLogged() { // TODO: only if GET request! http_response_code(403); header("Location:".ROOT_URL.$this->loginPageUrl."?".$this->redirectParameter."=".urlencode($_SERVER['REQUEST_URI'])); exit; }
[ "public", "function", "redirectNotLogged", "(", ")", "{", "// TODO: only if GET request!", "http_response_code", "(", "403", ")", ";", "header", "(", "\"Location:\"", ".", "ROOT_URL", ".", "$", "this", "->", "loginPageUrl", ".", "\"?\"", ".", "$", "this", "->", "redirectParameter", ".", "\"=\"", ".", "urlencode", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", ";", "exit", ";", "}" ]
Redirects the user to the login page if he is not logged. The URL will be added a "redirect" GET parameter that can be used to return to the current page. The function will exit the program, so do not expect any return value :)
[ "Redirects", "the", "user", "to", "the", "login", "page", "if", "he", "is", "not", "logged", ".", "The", "URL", "will", "be", "added", "a", "redirect", "GET", "parameter", "that", "can", "be", "used", "to", "return", "to", "the", "current", "page", ".", "The", "function", "will", "exit", "the", "program", "so", "do", "not", "expect", "any", "return", "value", ":", ")" ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L258-L264
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.logoff
public function logoff() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before trying to login. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) { $login = $_SESSION[$this->sessionPrefix.'MoufUserLogin']; if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->beforeLogOut($this); } } if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs out.", array('login' => $login)); } else { $this->log->trace("User '".$login."' logs out."); } unset($_SESSION[$this->sessionPrefix.'MoufUserId']); unset($_SESSION[$this->sessionPrefix.'MoufUserLogin']); } }
php
public function logoff() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before trying to login. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) { $login = $_SESSION[$this->sessionPrefix.'MoufUserLogin']; if (is_array($this->authenticationListeners)) { foreach ($this->authenticationListeners as $listener) { $listener->beforeLogOut($this); } } if ($this->log instanceof LoggerInterface) { $this->log->debug("User '{login}' logs out.", array('login' => $login)); } else { $this->log->trace("User '".$login."' logs out."); } unset($_SESSION[$this->sessionPrefix.'MoufUserId']); unset($_SESSION[$this->sessionPrefix.'MoufUserLogin']); } }
[ "public", "function", "logoff", "(", ")", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before trying to login. Please use session_start().\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", ")", ")", "{", "$", "login", "=", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", ";", "if", "(", "is_array", "(", "$", "this", "->", "authenticationListeners", ")", ")", "{", "foreach", "(", "$", "this", "->", "authenticationListeners", "as", "$", "listener", ")", "{", "$", "listener", "->", "beforeLogOut", "(", "$", "this", ")", ";", "}", "}", "if", "(", "$", "this", "->", "log", "instanceof", "LoggerInterface", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "\"User '{login}' logs out.\"", ",", "array", "(", "'login'", "=>", "$", "login", ")", ")", ";", "}", "else", "{", "$", "this", "->", "log", "->", "trace", "(", "\"User '\"", ".", "$", "login", ".", "\"' logs out.\"", ")", ";", "}", "unset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ")", ";", "unset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", ")", ";", "}", "}" ]
Logs the user off.
[ "Logs", "the", "user", "off", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L270-L296
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.getUserId
public function getUserId() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return $_SESSION[$this->sessionPrefix.'MoufUserId']; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $userId = $provider->getUserId($this); if ($userId) { return $userId; } } } return null; }
php
public function getUserId() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return $_SESSION[$this->sessionPrefix.'MoufUserId']; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $userId = $provider->getUserId($this); if ($userId) { return $userId; } } } return null; }
[ "public", "function", "getUserId", "(", ")", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before checking if the user is logged. Please use session_start().\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ")", ")", "{", "return", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "authProviders", "as", "$", "provider", ")", "{", "/* @var $provider AuthenticationProviderInterface */", "$", "userId", "=", "$", "provider", "->", "getUserId", "(", "$", "this", ")", ";", "if", "(", "$", "userId", ")", "{", "return", "$", "userId", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the current user ID. @return string
[ "Returns", "the", "current", "user", "ID", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L303-L326
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.getUserLogin
public function getUserLogin() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) { return $_SESSION[$this->sessionPrefix.'MoufUserLogin']; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $login = $provider->getUserLogin($this); if ($login) { return $login; } } } return null; }
php
public function getUserLogin() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) { return $_SESSION[$this->sessionPrefix.'MoufUserLogin']; } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $login = $provider->getUserLogin($this); if ($login) { return $login; } } } return null; }
[ "public", "function", "getUserLogin", "(", ")", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before checking if the user is logged. Please use session_start().\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", ")", ")", "{", "return", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserLogin'", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "authProviders", "as", "$", "provider", ")", "{", "/* @var $provider AuthenticationProviderInterface */", "$", "login", "=", "$", "provider", "->", "getUserLogin", "(", "$", "this", ")", ";", "if", "(", "$", "login", ")", "{", "return", "$", "login", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the current user login. @return string
[ "Returns", "the", "current", "user", "login", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L333-L356
thecodingmachine/security.userservice
src/Mouf/Security/UserService/UserService.php
UserService.getLoggedUser
public function getLoggedUser() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return $this->userDao->getUserById($_SESSION[$this->sessionPrefix.'MoufUserId']); } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $user = $provider->getLoggedUser($this); if ($user) { return $user; } } } return null; }
php
public function getLoggedUser() { // Is a session mechanism available? if (!session_id()) { if ($this->sessionManager) { $this->sessionManager->start(); } else { throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start()."); } } if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) { return $this->userDao->getUserById($_SESSION[$this->sessionPrefix.'MoufUserId']); } else { foreach ($this->authProviders as $provider) { /* @var $provider AuthenticationProviderInterface */ $user = $provider->getLoggedUser($this); if ($user) { return $user; } } } return null; }
[ "public", "function", "getLoggedUser", "(", ")", "{", "// Is a session mechanism available?", "if", "(", "!", "session_id", "(", ")", ")", "{", "if", "(", "$", "this", "->", "sessionManager", ")", "{", "$", "this", "->", "sessionManager", "->", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "MoufException", "(", "\"The session must be initialized before checking if the user is logged. Please use session_start().\"", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ")", ")", "{", "return", "$", "this", "->", "userDao", "->", "getUserById", "(", "$", "_SESSION", "[", "$", "this", "->", "sessionPrefix", ".", "'MoufUserId'", "]", ")", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "authProviders", "as", "$", "provider", ")", "{", "/* @var $provider AuthenticationProviderInterface */", "$", "user", "=", "$", "provider", "->", "getLoggedUser", "(", "$", "this", ")", ";", "if", "(", "$", "user", ")", "{", "return", "$", "user", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the user that is logged (or null if no user is logged). return UserInterface
[ "Returns", "the", "user", "that", "is", "logged", "(", "or", "null", "if", "no", "user", "is", "logged", ")", "." ]
train
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L363-L386
zhouyl/mellivora
Mellivora/Console/Commands/ViewClearCommand.php
ViewClearCommand.fire
public function fire() { $path = $this->container['config']['view.compiled']; if (!$path) { throw new RuntimeException('View path not found.'); } foreach (glob("{$path}/*") as $view) { unlink($view); } $this->info('Compiled views cleared!'); }
php
public function fire() { $path = $this->container['config']['view.compiled']; if (!$path) { throw new RuntimeException('View path not found.'); } foreach (glob("{$path}/*") as $view) { unlink($view); } $this->info('Compiled views cleared!'); }
[ "public", "function", "fire", "(", ")", "{", "$", "path", "=", "$", "this", "->", "container", "[", "'config'", "]", "[", "'view.compiled'", "]", ";", "if", "(", "!", "$", "path", ")", "{", "throw", "new", "RuntimeException", "(", "'View path not found.'", ")", ";", "}", "foreach", "(", "glob", "(", "\"{$path}/*\"", ")", "as", "$", "view", ")", "{", "unlink", "(", "$", "view", ")", ";", "}", "$", "this", "->", "info", "(", "'Compiled views cleared!'", ")", ";", "}" ]
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/Commands/ViewClearCommand.php#L29-L42
antaresproject/notifications
src/Http/Filter/DateRangeNotificationLogsFilter.php
DateRangeNotificationLogsFilter.apply
public function apply($builder) { if (!empty($values = $this->getValues())) { $range = json_decode($values, true); if (!isset($range['start']) or ! isset($range['end'])) { return $builder; } $start = $range['start'] . ' 00:00:00'; $end = $range['end'] . ' 23:59:59'; $builder->whereBetween('tbl_notifications_stack.created_at', [$start, $end]); } }
php
public function apply($builder) { if (!empty($values = $this->getValues())) { $range = json_decode($values, true); if (!isset($range['start']) or ! isset($range['end'])) { return $builder; } $start = $range['start'] . ' 00:00:00'; $end = $range['end'] . ' 23:59:59'; $builder->whereBetween('tbl_notifications_stack.created_at', [$start, $end]); } }
[ "public", "function", "apply", "(", "$", "builder", ")", "{", "if", "(", "!", "empty", "(", "$", "values", "=", "$", "this", "->", "getValues", "(", ")", ")", ")", "{", "$", "range", "=", "json_decode", "(", "$", "values", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "range", "[", "'start'", "]", ")", "or", "!", "isset", "(", "$", "range", "[", "'end'", "]", ")", ")", "{", "return", "$", "builder", ";", "}", "$", "start", "=", "$", "range", "[", "'start'", "]", ".", "' 00:00:00'", ";", "$", "end", "=", "$", "range", "[", "'end'", "]", ".", "' 23:59:59'", ";", "$", "builder", "->", "whereBetween", "(", "'tbl_notifications_stack.created_at'", ",", "[", "$", "start", ",", "$", "end", "]", ")", ";", "}", "}" ]
Filters data by parameters from memory @param mixed $builder
[ "Filters", "data", "by", "parameters", "from", "memory" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Filter/DateRangeNotificationLogsFilter.php#L57-L68
everest-php/framework
src/Storage/DBWrapper.php
DBWrapper.first
public function first(){ $this->execute(); if(count($this->results) > 0){ return current($this->results); } else { return null; } }
php
public function first(){ $this->execute(); if(count($this->results) > 0){ return current($this->results); } else { return null; } }
[ "public", "function", "first", "(", ")", "{", "$", "this", "->", "execute", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "results", ")", ">", "0", ")", "{", "return", "current", "(", "$", "this", "->", "results", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
/* +--------------------------------------------------------------------+ + + + Following methods are helpers for select statements: + + + +--------------------------------------------------------------------+
[ "/", "*", "+", "--------------------------------------------------------------------", "+", "+", "+", "+", "Following", "methods", "are", "helpers", "for", "select", "statements", ":", "+", "+", "+", "+", "--------------------------------------------------------------------", "+" ]
train
https://github.com/everest-php/framework/blob/f5c402dd7dbd7622074d2aa4835bcee133f398a7/src/Storage/DBWrapper.php#L100-L107
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php
ezcDbSchemaMysqlWriter.applyDiffToDb
public function applyDiffToDb( ezcDbHandler $db, ezcDbSchemaDiff $dbSchemaDiff ) { $db->beginTransaction(); foreach ( $this->convertDiffToDDL( $dbSchemaDiff ) as $query ) { $db->exec( $query ); } $db->commit(); }
php
public function applyDiffToDb( ezcDbHandler $db, ezcDbSchemaDiff $dbSchemaDiff ) { $db->beginTransaction(); foreach ( $this->convertDiffToDDL( $dbSchemaDiff ) as $query ) { $db->exec( $query ); } $db->commit(); }
[ "public", "function", "applyDiffToDb", "(", "ezcDbHandler", "$", "db", ",", "ezcDbSchemaDiff", "$", "dbSchemaDiff", ")", "{", "$", "db", "->", "beginTransaction", "(", ")", ";", "foreach", "(", "$", "this", "->", "convertDiffToDDL", "(", "$", "dbSchemaDiff", ")", "as", "$", "query", ")", "{", "$", "db", "->", "exec", "(", "$", "query", ")", ";", "}", "$", "db", "->", "commit", "(", ")", ";", "}" ]
Applies the differences defined in $dbSchemaDiff to the database referenced by $db. This method uses {@link convertDiffToDDL} to create SQL for the differences and then executes the returned SQL statements on the database handler $db. @todo check for failed transaction @param ezcDbHandler $db @param ezcDbSchemaDiff $dbSchemaDiff
[ "Applies", "the", "differences", "defined", "in", "$dbSchemaDiff", "to", "the", "database", "referenced", "by", "$db", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php#L72-L80
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php
ezcDbSchemaMysqlWriter.convertDiffToDDL
public function convertDiffToDDL( ezcDbSchemaDiff $dbSchemaDiff ) { $this->diffSchema = $dbSchemaDiff; // reset queries $this->queries = array(); $this->context = array(); $this->generateDiffSchemaAsSql(); return $this->queries; }
php
public function convertDiffToDDL( ezcDbSchemaDiff $dbSchemaDiff ) { $this->diffSchema = $dbSchemaDiff; // reset queries $this->queries = array(); $this->context = array(); $this->generateDiffSchemaAsSql(); return $this->queries; }
[ "public", "function", "convertDiffToDDL", "(", "ezcDbSchemaDiff", "$", "dbSchemaDiff", ")", "{", "$", "this", "->", "diffSchema", "=", "$", "dbSchemaDiff", ";", "// reset queries", "$", "this", "->", "queries", "=", "array", "(", ")", ";", "$", "this", "->", "context", "=", "array", "(", ")", ";", "$", "this", "->", "generateDiffSchemaAsSql", "(", ")", ";", "return", "$", "this", "->", "queries", ";", "}" ]
Returns the differences definition in $dbSchema as database specific SQL DDL queries. @param ezcDbSchemaDiff $dbSchemaDiff @return array(string)
[ "Returns", "the", "differences", "definition", "in", "$dbSchema", "as", "database", "specific", "SQL", "DDL", "queries", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php#L89-L99
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php
ezcDbSchemaMysqlWriter.generateCreateTableSql
protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition ) { $this->context['skip_primary'] = false; parent::generateCreateTableSql( $tableName, $tableDefinition ); }
php
protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition ) { $this->context['skip_primary'] = false; parent::generateCreateTableSql( $tableName, $tableDefinition ); }
[ "protected", "function", "generateCreateTableSql", "(", "$", "tableName", ",", "ezcDbSchemaTable", "$", "tableDefinition", ")", "{", "$", "this", "->", "context", "[", "'skip_primary'", "]", "=", "false", ";", "parent", "::", "generateCreateTableSql", "(", "$", "tableName", ",", "$", "tableDefinition", ")", ";", "}" ]
Adds a "create table" query for the table $tableName with definition $tableDefinition to the internal list of queries. @param string $tableName @param ezcDbSchemaTable $tableDefinition
[ "Adds", "a", "create", "table", "query", "for", "the", "table", "$tableName", "with", "definition", "$tableDefinition", "to", "the", "internal", "list", "of", "queries", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php#L158-L162
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php
ezcDbSchemaMysqlWriter.generateDiffSchemaTableAsSql
protected function generateDiffSchemaTableAsSql( $tableName, ezcDbSchemaTableDiff $tableDiff ) { $this->context['skip_primary'] = false; parent::generateDiffSchemaTableAsSql( $tableName, $tableDiff ); }
php
protected function generateDiffSchemaTableAsSql( $tableName, ezcDbSchemaTableDiff $tableDiff ) { $this->context['skip_primary'] = false; parent::generateDiffSchemaTableAsSql( $tableName, $tableDiff ); }
[ "protected", "function", "generateDiffSchemaTableAsSql", "(", "$", "tableName", ",", "ezcDbSchemaTableDiff", "$", "tableDiff", ")", "{", "$", "this", "->", "context", "[", "'skip_primary'", "]", "=", "false", ";", "parent", "::", "generateDiffSchemaTableAsSql", "(", "$", "tableName", ",", "$", "tableDiff", ")", ";", "}" ]
Generates queries to upgrade a the table $tableName with the differences in $tableDiff. This method generates queries to migrate a table to a new version with the changes that are stored in the $tableDiff property. It will call different subfunctions for the different types of changes, and those functions will add queries to the internal list of queries that is stored in $this->queries. @param string $tableName @param ezcDbSchemaTableDiff $tableDiff
[ "Generates", "queries", "to", "upgrade", "a", "the", "table", "$tableName", "with", "the", "differences", "in", "$tableDiff", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php#L176-L180
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php
ezcDbSchemaMysqlWriter.generateAddIndexSql
protected function generateAddIndexSql( $tableName, $indexName, ezcDbSchemaIndex $indexDefinition ) { $sql = "ALTER TABLE `$tableName` ADD "; if ( $indexDefinition->primary ) { if ( $this->context['skip_primary'] ) { return; } $sql .= 'PRIMARY KEY'; } else if ( $indexDefinition->unique ) { $sql .= "UNIQUE `$indexName`"; } else { $sql .= "INDEX `$indexName`"; } $sql .= " ( "; $indexFieldSql = array(); foreach ( $indexDefinition->indexFields as $indexFieldName => $dummy ) { if ( isset( $this->schema[$tableName] ) && isset( $this->schema[$tableName]->fields[$indexFieldName] ) && isset( $this->schema[$tableName]->fields[$indexFieldName]->type ) && in_array( $this->schema[$tableName]->fields[$indexFieldName]->type, array( 'blob', 'clob' ) ) ) { $indexFieldSql[] = "`{$indexFieldName}`(250)"; } else { $indexFieldSql[] = "`$indexFieldName`"; } } $sql .= join( ', ', $indexFieldSql ) . " )"; $this->queries[] = $sql; }
php
protected function generateAddIndexSql( $tableName, $indexName, ezcDbSchemaIndex $indexDefinition ) { $sql = "ALTER TABLE `$tableName` ADD "; if ( $indexDefinition->primary ) { if ( $this->context['skip_primary'] ) { return; } $sql .= 'PRIMARY KEY'; } else if ( $indexDefinition->unique ) { $sql .= "UNIQUE `$indexName`"; } else { $sql .= "INDEX `$indexName`"; } $sql .= " ( "; $indexFieldSql = array(); foreach ( $indexDefinition->indexFields as $indexFieldName => $dummy ) { if ( isset( $this->schema[$tableName] ) && isset( $this->schema[$tableName]->fields[$indexFieldName] ) && isset( $this->schema[$tableName]->fields[$indexFieldName]->type ) && in_array( $this->schema[$tableName]->fields[$indexFieldName]->type, array( 'blob', 'clob' ) ) ) { $indexFieldSql[] = "`{$indexFieldName}`(250)"; } else { $indexFieldSql[] = "`$indexFieldName`"; } } $sql .= join( ', ', $indexFieldSql ) . " )"; $this->queries[] = $sql; }
[ "protected", "function", "generateAddIndexSql", "(", "$", "tableName", ",", "$", "indexName", ",", "ezcDbSchemaIndex", "$", "indexDefinition", ")", "{", "$", "sql", "=", "\"ALTER TABLE `$tableName` ADD \"", ";", "if", "(", "$", "indexDefinition", "->", "primary", ")", "{", "if", "(", "$", "this", "->", "context", "[", "'skip_primary'", "]", ")", "{", "return", ";", "}", "$", "sql", ".=", "'PRIMARY KEY'", ";", "}", "else", "if", "(", "$", "indexDefinition", "->", "unique", ")", "{", "$", "sql", ".=", "\"UNIQUE `$indexName`\"", ";", "}", "else", "{", "$", "sql", ".=", "\"INDEX `$indexName`\"", ";", "}", "$", "sql", ".=", "\" ( \"", ";", "$", "indexFieldSql", "=", "array", "(", ")", ";", "foreach", "(", "$", "indexDefinition", "->", "indexFields", "as", "$", "indexFieldName", "=>", "$", "dummy", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "schema", "[", "$", "tableName", "]", ")", "&&", "isset", "(", "$", "this", "->", "schema", "[", "$", "tableName", "]", "->", "fields", "[", "$", "indexFieldName", "]", ")", "&&", "isset", "(", "$", "this", "->", "schema", "[", "$", "tableName", "]", "->", "fields", "[", "$", "indexFieldName", "]", "->", "type", ")", "&&", "in_array", "(", "$", "this", "->", "schema", "[", "$", "tableName", "]", "->", "fields", "[", "$", "indexFieldName", "]", "->", "type", ",", "array", "(", "'blob'", ",", "'clob'", ")", ")", ")", "{", "$", "indexFieldSql", "[", "]", "=", "\"`{$indexFieldName}`(250)\"", ";", "}", "else", "{", "$", "indexFieldSql", "[", "]", "=", "\"`$indexFieldName`\"", ";", "}", "}", "$", "sql", ".=", "join", "(", "', '", ",", "$", "indexFieldSql", ")", ".", "\" )\"", ";", "$", "this", "->", "queries", "[", "]", "=", "$", "sql", ";", "}" ]
Adds a "alter table" query to add the index $indexName to the table $tableName with definition $indexDefinition to the internal list of queries @param string $tableName @param string $indexName @param ezcDbSchemaIndex $indexDefinition
[ "Adds", "a", "alter", "table", "query", "to", "add", "the", "index", "$indexName", "to", "the", "table", "$tableName", "with", "definition", "$indexDefinition", "to", "the", "internal", "list", "of", "queries" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/mysql/writer.php#L262-L303
gedex/php-janrain-api
lib/Janrain/Api/Engage/Sharing.php
Sharing.broadcast
public function broadcast(array $params) { if (!isset($params['identifier']) && !isset($params['device_token'])) { throw new MissingArgumentException('identifier or device_token'); } if (!isset($params['message'])) { throw new MissingArgumentException('message'); } return $this->post('sharing/broadcast', $params); }
php
public function broadcast(array $params) { if (!isset($params['identifier']) && !isset($params['device_token'])) { throw new MissingArgumentException('identifier or device_token'); } if (!isset($params['message'])) { throw new MissingArgumentException('message'); } return $this->post('sharing/broadcast', $params); }
[ "public", "function", "broadcast", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'identifier'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'device_token'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier or device_token'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'message'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'message'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'sharing/broadcast'", ",", "$", "params", ")", ";", "}" ]
Shares activity information directly with a provider. The information provided in the parameters is passed to a provider to publish on their network. The `broadcast` call shares with one provider at a time, determined by the `identifier` or `device_token` that you use. @param array $params @link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/broadcast/
[ "Shares", "activity", "information", "directly", "with", "a", "provider", ".", "The", "information", "provided", "in", "the", "parameters", "is", "passed", "to", "a", "provider", "to", "publish", "on", "their", "network", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L23-L34
gedex/php-janrain-api
lib/Janrain/Api/Engage/Sharing.php
Sharing.direct
public function direct(array $params) { if (!isset($params['identifier']) && !isset($params['device_token'])) { throw new MissingArgumentException('identifier or device_token'); } if (!isset($params['recipients'])) { throw new MissingArgumentException('recipients'); } else if (!is_array($params['recipients'])) { throw new InvalidArgumentException('Invalid Argument: recipients must be passed as array'); } else { $params['recipients'] = json_encode(array_values($params['recipients'])); } if (!isset($params['message'])) { throw new MissingArgumentException('message'); } return $this->post('sharing/direct', $params); }
php
public function direct(array $params) { if (!isset($params['identifier']) && !isset($params['device_token'])) { throw new MissingArgumentException('identifier or device_token'); } if (!isset($params['recipients'])) { throw new MissingArgumentException('recipients'); } else if (!is_array($params['recipients'])) { throw new InvalidArgumentException('Invalid Argument: recipients must be passed as array'); } else { $params['recipients'] = json_encode(array_values($params['recipients'])); } if (!isset($params['message'])) { throw new MissingArgumentException('message'); } return $this->post('sharing/direct', $params); }
[ "public", "function", "direct", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'identifier'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'device_token'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier or device_token'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'recipients'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'recipients'", ")", ";", "}", "else", "if", "(", "!", "is_array", "(", "$", "params", "[", "'recipients'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid Argument: recipients must be passed as array'", ")", ";", "}", "else", "{", "$", "params", "[", "'recipients'", "]", "=", "json_encode", "(", "array_values", "(", "$", "params", "[", "'recipients'", "]", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'message'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'message'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'sharing/direct'", ",", "$", "params", ")", ";", "}" ]
Shares activity information directly with the specified recipents on a provider's network, instead of publishing it to everyone on the network. The `direct` call shares with one provider at a time, determined by the `identifier` or `device_token` you enter. @param array $params @link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/direct/
[ "Shares", "activity", "information", "directly", "with", "the", "specified", "recipents", "on", "a", "provider", "s", "network", "instead", "of", "publishing", "it", "to", "everyone", "on", "the", "network", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L47-L66
gedex/php-janrain-api
lib/Janrain/Api/Engage/Sharing.php
Sharing.getShareProviders
public function getShareProviders($format = 'json', $callback = '') { $params = compact('format'); if (!empty($callback)) { $params['callback'] = $callback; } return $this->post('get_share_providers', $params); }
php
public function getShareProviders($format = 'json', $callback = '') { $params = compact('format'); if (!empty($callback)) { $params['callback'] = $callback; } return $this->post('get_share_providers', $params); }
[ "public", "function", "getShareProviders", "(", "$", "format", "=", "'json'", ",", "$", "callback", "=", "''", ")", "{", "$", "params", "=", "compact", "(", "'format'", ")", ";", "if", "(", "!", "empty", "(", "$", "callback", ")", ")", "{", "$", "params", "[", "'callback'", "]", "=", "$", "callback", ";", "}", "return", "$", "this", "->", "post", "(", "'get_share_providers'", ",", "$", "params", ")", ";", "}" ]
Returns a list of email and sharing providers configured for the widget. This call has no required parameters; it identifies the proper application by the realm prefacing the URL path. @param string $format Either 'json' or 'xml' @param string $callback Specifies the return of a JSONP-formatted response @link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/get_share_providers/
[ "Returns", "a", "list", "of", "email", "and", "sharing", "providers", "configured", "for", "the", "widget", ".", "This", "call", "has", "no", "required", "parameters", ";", "it", "identifies", "the", "proper", "application", "by", "the", "realm", "prefacing", "the", "URL", "path", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L92-L100
Isset/pushnotification
src/PushNotification/Core/Connection/ConnectionHandlerImpl.php
ConnectionHandlerImpl.getConnection
public function getConnection(string $type = null): Connection { if ($type === null) { return $this->getDefaultConnection(); } if (!$this->hasConnectionType($type)) { throw new ConnectionHandlerExceptionImpl('Connection not found for type: ' . $type); } return $this->connections[$type]; }
php
public function getConnection(string $type = null): Connection { if ($type === null) { return $this->getDefaultConnection(); } if (!$this->hasConnectionType($type)) { throw new ConnectionHandlerExceptionImpl('Connection not found for type: ' . $type); } return $this->connections[$type]; }
[ "public", "function", "getConnection", "(", "string", "$", "type", "=", "null", ")", ":", "Connection", "{", "if", "(", "$", "type", "===", "null", ")", "{", "return", "$", "this", "->", "getDefaultConnection", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasConnectionType", "(", "$", "type", ")", ")", "{", "throw", "new", "ConnectionHandlerExceptionImpl", "(", "'Connection not found for type: '", ".", "$", "type", ")", ";", "}", "return", "$", "this", "->", "connections", "[", "$", "type", "]", ";", "}" ]
@param string $type @throws ConnectionHandlerExceptionImpl @return Connection
[ "@param", "string", "$type" ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Core/Connection/ConnectionHandlerImpl.php#L36-L46
Isset/pushnotification
src/PushNotification/Core/Connection/ConnectionHandlerImpl.php
ConnectionHandlerImpl.setLogger
public function setLogger(LoggerInterface $logger) { $this->traitSetLogger($logger); foreach ($this->connections as $connection) { $connection->setLogger($logger); } }
php
public function setLogger(LoggerInterface $logger) { $this->traitSetLogger($logger); foreach ($this->connections as $connection) { $connection->setLogger($logger); } }
[ "public", "function", "setLogger", "(", "LoggerInterface", "$", "logger", ")", "{", "$", "this", "->", "traitSetLogger", "(", "$", "logger", ")", ";", "foreach", "(", "$", "this", "->", "connections", "as", "$", "connection", ")", "{", "$", "connection", "->", "setLogger", "(", "$", "logger", ")", ";", "}", "}" ]
Sets a logger instance on the object. @param LoggerInterface $logger
[ "Sets", "a", "logger", "instance", "on", "the", "object", "." ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Core/Connection/ConnectionHandlerImpl.php#L77-L83
Isset/pushnotification
src/PushNotification/Core/Connection/ConnectionHandlerImpl.php
ConnectionHandlerImpl.addConnection
public function addConnection(Connection $connection, bool $useLogger = true) { if ($useLogger) { $connection->setLogger($this->getLogger()); } $this->connections[$connection->getType()] = $connection; if ($connection->isDefault()) { $this->setDefaultConnectionByType($connection->getType()); } }
php
public function addConnection(Connection $connection, bool $useLogger = true) { if ($useLogger) { $connection->setLogger($this->getLogger()); } $this->connections[$connection->getType()] = $connection; if ($connection->isDefault()) { $this->setDefaultConnectionByType($connection->getType()); } }
[ "public", "function", "addConnection", "(", "Connection", "$", "connection", ",", "bool", "$", "useLogger", "=", "true", ")", "{", "if", "(", "$", "useLogger", ")", "{", "$", "connection", "->", "setLogger", "(", "$", "this", "->", "getLogger", "(", ")", ")", ";", "}", "$", "this", "->", "connections", "[", "$", "connection", "->", "getType", "(", ")", "]", "=", "$", "connection", ";", "if", "(", "$", "connection", "->", "isDefault", "(", ")", ")", "{", "$", "this", "->", "setDefaultConnectionByType", "(", "$", "connection", "->", "getType", "(", ")", ")", ";", "}", "}" ]
@param Connection $connection @param bool $useLogger @throws ConnectionHandlerExceptionImpl
[ "@param", "Connection", "$connection", "@param", "bool", "$useLogger" ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Core/Connection/ConnectionHandlerImpl.php#L91-L100
mekras/Types
src/DateTime/Traits/DateComingChecks.php
DateComingChecks.isDateWillComeIn
public function isDateWillComeIn($interval) { if (!($interval instanceof \DateInterval)) { $interval = new \DateInterval((string) $interval); } $now = new \DateTime('now'); return 0 === $this->diff($now->add($interval))->invert; }
php
public function isDateWillComeIn($interval) { if (!($interval instanceof \DateInterval)) { $interval = new \DateInterval((string) $interval); } $now = new \DateTime('now'); return 0 === $this->diff($now->add($interval))->invert; }
[ "public", "function", "isDateWillComeIn", "(", "$", "interval", ")", "{", "if", "(", "!", "(", "$", "interval", "instanceof", "\\", "DateInterval", ")", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "(", "string", ")", "$", "interval", ")", ";", "}", "$", "now", "=", "new", "\\", "DateTime", "(", "'now'", ")", ";", "return", "0", "===", "$", "this", "->", "diff", "(", "$", "now", "->", "add", "(", "$", "interval", ")", ")", "->", "invert", ";", "}" ]
Return TRUE if this date will come in a given interval @param \DateInterval|string $interval DateInterval or string interval specification @return bool @link http://php.net/DateInterval @since 1.1
[ "Return", "TRUE", "if", "this", "date", "will", "come", "in", "a", "given", "interval" ]
train
https://github.com/mekras/Types/blob/a168809097d41f3dacec658b6ecd2fd0f10b30e1/src/DateTime/Traits/DateComingChecks.php#L43-L50
Eresus/EresusCMS
src/core/Admin/ContentProvider/Plugin.php
Eresus_Admin_ContentProvider_Plugin.adminRender
public function adminRender(Eresus_CMS_Request $request) { $this->linkAdminResources(); $html = parent::adminRender($request); return $html; }
php
public function adminRender(Eresus_CMS_Request $request) { $this->linkAdminResources(); $html = parent::adminRender($request); return $html; }
[ "public", "function", "adminRender", "(", "Eresus_CMS_Request", "$", "request", ")", "{", "$", "this", "->", "linkAdminResources", "(", ")", ";", "$", "html", "=", "parent", "::", "adminRender", "(", "$", "request", ")", ";", "return", "$", "html", ";", "}" ]
Отрисовывает интерфейс модуля @param Eresus_CMS_Request $request @throws LogicException @throws RuntimeException @return string HTML @since 3.01
[ "Отрисовывает", "интерфейс", "модуля" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/ContentProvider/Plugin.php#L61-L66
Eresus/EresusCMS
src/core/Admin/ContentProvider/Plugin.php
Eresus_Admin_ContentProvider_Plugin.adminRenderContent
public function adminRenderContent(Eresus_CMS_Request $request) { $this->linkAdminResources(); $html = parent::adminRenderContent($request); return $html; }
php
public function adminRenderContent(Eresus_CMS_Request $request) { $this->linkAdminResources(); $html = parent::adminRenderContent($request); return $html; }
[ "public", "function", "adminRenderContent", "(", "Eresus_CMS_Request", "$", "request", ")", "{", "$", "this", "->", "linkAdminResources", "(", ")", ";", "$", "html", "=", "parent", "::", "adminRenderContent", "(", "$", "request", ")", ";", "return", "$", "html", ";", "}" ]
Отрисовывает область контента раздела @param Eresus_CMS_Request $request @return string HTML @throws LogicException @throws RuntimeException @since 3.01
[ "Отрисовывает", "область", "контента", "раздела" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/ContentProvider/Plugin.php#L80-L85
Eresus/EresusCMS
src/core/Admin/ContentProvider/Plugin.php
Eresus_Admin_ContentProvider_Plugin.getSettingsController
public function getSettingsController() { /** @var Eresus_Plugin $plugin */ $plugin = $this->getModule(); if (!method_exists($plugin, 'settings')) { return false; } $this->linkAdminResources(); $controller = new Eresus_Plugin_Controller_Admin_LegacySettings($plugin); return $controller; }
php
public function getSettingsController() { /** @var Eresus_Plugin $plugin */ $plugin = $this->getModule(); if (!method_exists($plugin, 'settings')) { return false; } $this->linkAdminResources(); $controller = new Eresus_Plugin_Controller_Admin_LegacySettings($plugin); return $controller; }
[ "public", "function", "getSettingsController", "(", ")", "{", "/** @var Eresus_Plugin $plugin */", "$", "plugin", "=", "$", "this", "->", "getModule", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "plugin", ",", "'settings'", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "linkAdminResources", "(", ")", ";", "$", "controller", "=", "new", "Eresus_Plugin_Controller_Admin_LegacySettings", "(", "$", "plugin", ")", ";", "return", "$", "controller", ";", "}" ]
Возвращает контроллер диалога настроек или false, если настроек у модуля нет @return bool|Eresus_Admin_Controller_Content_Interface @since 3.01
[ "Возвращает", "контроллер", "диалога", "настроек", "или", "false", "если", "настроек", "у", "модуля", "нет" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/ContentProvider/Plugin.php#L108-L119
Eresus/EresusCMS
src/core/Admin/ContentProvider/Plugin.php
Eresus_Admin_ContentProvider_Plugin.linkAdminResources
private function linkAdminResources() { $page = Eresus_Kernel::app()->getPage(); /** @var Eresus_Plugin $plugin */ $plugin = $this->getModule(); $resource = 'admin/default.css'; // В будущем «default» можно заменить именем темы if (file_exists($plugin->getCodeDir() . '/' . $resource)) { $page->linkStyles($plugin->getCodeUrl() . $resource); } $resource = 'admin/scripts.js'; if (file_exists($plugin->getCodeDir() . '/' . $resource)) { $page->linkScripts($plugin->getCodeUrl() . $resource); } }
php
private function linkAdminResources() { $page = Eresus_Kernel::app()->getPage(); /** @var Eresus_Plugin $plugin */ $plugin = $this->getModule(); $resource = 'admin/default.css'; // В будущем «default» можно заменить именем темы if (file_exists($plugin->getCodeDir() . '/' . $resource)) { $page->linkStyles($plugin->getCodeUrl() . $resource); } $resource = 'admin/scripts.js'; if (file_exists($plugin->getCodeDir() . '/' . $resource)) { $page->linkScripts($plugin->getCodeUrl() . $resource); } }
[ "private", "function", "linkAdminResources", "(", ")", "{", "$", "page", "=", "Eresus_Kernel", "::", "app", "(", ")", "->", "getPage", "(", ")", ";", "/** @var Eresus_Plugin $plugin */", "$", "plugin", "=", "$", "this", "->", "getModule", "(", ")", ";", "$", "resource", "=", "'admin/default.css'", ";", "// В будущем «default» можно заменить именем темы", "if", "(", "file_exists", "(", "$", "plugin", "->", "getCodeDir", "(", ")", ".", "'/'", ".", "$", "resource", ")", ")", "{", "$", "page", "->", "linkStyles", "(", "$", "plugin", "->", "getCodeUrl", "(", ")", ".", "$", "resource", ")", ";", "}", "$", "resource", "=", "'admin/scripts.js'", ";", "if", "(", "file_exists", "(", "$", "plugin", "->", "getCodeDir", "(", ")", ".", "'/'", ".", "$", "resource", ")", ")", "{", "$", "page", "->", "linkScripts", "(", "$", "plugin", "->", "getCodeUrl", "(", ")", ".", "$", "resource", ")", ";", "}", "}" ]
Подключает стили и скрипты АИ @since 3.01
[ "Подключает", "стили", "и", "скрипты", "АИ" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/ContentProvider/Plugin.php#L126-L143
frdl/webfan
.ApplicationComposer/lib/webfan/Install.php
Install.form_app_webdof
protected function form_app_webdof($click = false){ $args = func_get_args(); if(isset($args[0]))$click = $args[0]; $div = 'APP_WEBDOF'; $title = 'Webfan PragmaMx Module Setup'; $homepage = 'http://www.webfan.de/Downloads-lid-webdof-php-library-63.html'; $appKey = 'apps_webdof'; $html = ''; $html.= '<a name="'.$appKey.'"></a>'; $html.= '<div class="webfanWikiBoxouter" style="background-size: contain; background-attachment: hidden; background: url(\'http://static.webfan.de/logos/bg-light-1.png\') #E8F9FF;vertical-align:top;">'; $html.= $this->render_app_head_table($title, $appKey, $div, $homepage, 'http://webfan.de/bilder/domainundhomepagespeicher/produkte/kurzbeschreibung/24.247.247THP.produktbild_artikelbeschreibung.jpg', $click); $html.= '<div id="'.$div.'" style="display:none;">'; $html.= '[ <b><a title="webdof php library" href="'.$homepage.'" target="_blank" style="color:black;">Homepage</a></b> ]'; $html.= '<span class="webfan-blue" style="font-size:14px;font-weight:bold;">webdof php library</span>, '.$this->lang('__REQUIRED_BY_WEBFAN_PMX_MODULES__').'. <br />Version/update check, InstallShield, API Modul / API-D Interfaces, Cronjobverwaltung, Languagestrings-Manager, Plugin-System, Fast-Cache...<br />'; $Installer = null; $li = false; $pmx = false; if(count($this->detect[self::GROUP_APPS][self::APP_PMX]) === 0){ $html.= '<a href="#apps_pmx" style="color:red;">'.$this->e('PragmaMx required.').'</a><br />'; $pmx = false; }else{ $li = true; $pmx = true; } if(count($this->detect[self::GROUP_APPS][self::APP_WEBDOF]) > 0)$li = true; if($li === true){ $Installer = new \webfan\InstallShield\PragmaMx\WebfanModulesSetup($this); $html.= $Installer->render_form_install(); foreach($this->detect[self::GROUP_APPS][self::APP_WEBDOF] as $dir => $app){ } } $html.= $this->render_app_close_x( $div, $homepage); $html.= '</div>'; $html.= '</div>'; return $html; }
php
protected function form_app_webdof($click = false){ $args = func_get_args(); if(isset($args[0]))$click = $args[0]; $div = 'APP_WEBDOF'; $title = 'Webfan PragmaMx Module Setup'; $homepage = 'http://www.webfan.de/Downloads-lid-webdof-php-library-63.html'; $appKey = 'apps_webdof'; $html = ''; $html.= '<a name="'.$appKey.'"></a>'; $html.= '<div class="webfanWikiBoxouter" style="background-size: contain; background-attachment: hidden; background: url(\'http://static.webfan.de/logos/bg-light-1.png\') #E8F9FF;vertical-align:top;">'; $html.= $this->render_app_head_table($title, $appKey, $div, $homepage, 'http://webfan.de/bilder/domainundhomepagespeicher/produkte/kurzbeschreibung/24.247.247THP.produktbild_artikelbeschreibung.jpg', $click); $html.= '<div id="'.$div.'" style="display:none;">'; $html.= '[ <b><a title="webdof php library" href="'.$homepage.'" target="_blank" style="color:black;">Homepage</a></b> ]'; $html.= '<span class="webfan-blue" style="font-size:14px;font-weight:bold;">webdof php library</span>, '.$this->lang('__REQUIRED_BY_WEBFAN_PMX_MODULES__').'. <br />Version/update check, InstallShield, API Modul / API-D Interfaces, Cronjobverwaltung, Languagestrings-Manager, Plugin-System, Fast-Cache...<br />'; $Installer = null; $li = false; $pmx = false; if(count($this->detect[self::GROUP_APPS][self::APP_PMX]) === 0){ $html.= '<a href="#apps_pmx" style="color:red;">'.$this->e('PragmaMx required.').'</a><br />'; $pmx = false; }else{ $li = true; $pmx = true; } if(count($this->detect[self::GROUP_APPS][self::APP_WEBDOF]) > 0)$li = true; if($li === true){ $Installer = new \webfan\InstallShield\PragmaMx\WebfanModulesSetup($this); $html.= $Installer->render_form_install(); foreach($this->detect[self::GROUP_APPS][self::APP_WEBDOF] as $dir => $app){ } } $html.= $this->render_app_close_x( $div, $homepage); $html.= '</div>'; $html.= '</div>'; return $html; }
[ "protected", "function", "form_app_webdof", "(", "$", "click", "=", "false", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "isset", "(", "$", "args", "[", "0", "]", ")", ")", "$", "click", "=", "$", "args", "[", "0", "]", ";", "$", "div", "=", "'APP_WEBDOF'", ";", "$", "title", "=", "'Webfan PragmaMx Module Setup'", ";", "$", "homepage", "=", "'http://www.webfan.de/Downloads-lid-webdof-php-library-63.html'", ";", "$", "appKey", "=", "'apps_webdof'", ";", "$", "html", "=", "''", ";", "$", "html", ".=", "'<a name=\"'", ".", "$", "appKey", ".", "'\"></a>'", ";", "$", "html", ".=", "'<div class=\"webfanWikiBoxouter\" style=\"background-size: contain; background-attachment: hidden; background: url(\\'http://static.webfan.de/logos/bg-light-1.png\\') #E8F9FF;vertical-align:top;\">'", ";", "$", "html", ".=", "$", "this", "->", "render_app_head_table", "(", "$", "title", ",", "$", "appKey", ",", "$", "div", ",", "$", "homepage", ",", "'http://webfan.de/bilder/domainundhomepagespeicher/produkte/kurzbeschreibung/24.247.247THP.produktbild_artikelbeschreibung.jpg'", ",", "$", "click", ")", ";", "$", "html", ".=", "'<div id=\"'", ".", "$", "div", ".", "'\" style=\"display:none;\">'", ";", "$", "html", ".=", "'[ <b><a title=\"webdof php library\" href=\"'", ".", "$", "homepage", ".", "'\" target=\"_blank\" style=\"color:black;\">Homepage</a></b> ]'", ";", "$", "html", ".=", "'<span class=\"webfan-blue\" style=\"font-size:14px;font-weight:bold;\">webdof php library</span>, '", ".", "$", "this", "->", "lang", "(", "'__REQUIRED_BY_WEBFAN_PMX_MODULES__'", ")", ".", "'. <br />Version/update check, InstallShield, API Modul / API-D Interfaces, Cronjobverwaltung, Languagestrings-Manager, Plugin-System, Fast-Cache...<br />'", ";", "$", "Installer", "=", "null", ";", "$", "li", "=", "false", ";", "$", "pmx", "=", "false", ";", "if", "(", "count", "(", "$", "this", "->", "detect", "[", "self", "::", "GROUP_APPS", "]", "[", "self", "::", "APP_PMX", "]", ")", "===", "0", ")", "{", "$", "html", ".=", "'<a href=\"#apps_pmx\" style=\"color:red;\">'", ".", "$", "this", "->", "e", "(", "'PragmaMx required.'", ")", ".", "'</a><br />'", ";", "$", "pmx", "=", "false", ";", "}", "else", "{", "$", "li", "=", "true", ";", "$", "pmx", "=", "true", ";", "}", "if", "(", "count", "(", "$", "this", "->", "detect", "[", "self", "::", "GROUP_APPS", "]", "[", "self", "::", "APP_WEBDOF", "]", ")", ">", "0", ")", "$", "li", "=", "true", ";", "if", "(", "$", "li", "===", "true", ")", "{", "$", "Installer", "=", "new", "\\", "webfan", "\\", "InstallShield", "\\", "PragmaMx", "\\", "WebfanModulesSetup", "(", "$", "this", ")", ";", "$", "html", ".=", "$", "Installer", "->", "render_form_install", "(", ")", ";", "foreach", "(", "$", "this", "->", "detect", "[", "self", "::", "GROUP_APPS", "]", "[", "self", "::", "APP_WEBDOF", "]", "as", "$", "dir", "=>", "$", "app", ")", "{", "}", "}", "$", "html", ".=", "$", "this", "->", "render_app_close_x", "(", "$", "div", ",", "$", "homepage", ")", ";", "$", "html", ".=", "'</div>'", ";", "$", "html", ".=", "'</div>'", ";", "return", "$", "html", ";", "}" ]
http://static.webfan.de/logos/bg-light-1.png
[ "http", ":", "//", "static", ".", "webfan", ".", "de", "/", "logos", "/", "bg", "-", "light", "-", "1", ".", "png" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webfan/Install.php#L580-L639
ronaldborla/chikka
src/Borla/Chikka/Chikka.php
Chikka.send
public function send($mobile, $message, $messageId = null) { // Create message $message = $this->createMessage([ 'id' => $messageId, 'mobile' => $mobile, 'message' => $message, ]); // Return sender response return Loader::sender($this->config)->send($message); }
php
public function send($mobile, $message, $messageId = null) { // Create message $message = $this->createMessage([ 'id' => $messageId, 'mobile' => $mobile, 'message' => $message, ]); // Return sender response return Loader::sender($this->config)->send($message); }
[ "public", "function", "send", "(", "$", "mobile", ",", "$", "message", ",", "$", "messageId", "=", "null", ")", "{", "// Create message", "$", "message", "=", "$", "this", "->", "createMessage", "(", "[", "'id'", "=>", "$", "messageId", ",", "'mobile'", "=>", "$", "mobile", ",", "'message'", "=>", "$", "message", ",", "]", ")", ";", "// Return sender response", "return", "Loader", "::", "sender", "(", "$", "this", "->", "config", ")", "->", "send", "(", "$", "message", ")", ";", "}" ]
Send SMS @param string|Mobile $mobile Mobile number can be string or an instance of \Borla\Chikka\Models\Mobile @param string|Message $message Message can be string or an instance of \Borla\Chikka\Models\Message
[ "Send", "SMS" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Chikka.php#L51-L60
ronaldborla/chikka
src/Borla/Chikka/Chikka.php
Chikka.reply
public function reply($requestId, $mobile, $message, $cost = 0, $messageId = null, $adjustCost = true) { // Create message $message = $this->createMessage([ 'id' => $messageId, 'mobile' => $mobile, 'message' => $message, 'request_id'=> $requestId, 'cost' => $cost, ]); // Return sender response return Loader::sender($this->config)->reply($message, $adjustCost); }
php
public function reply($requestId, $mobile, $message, $cost = 0, $messageId = null, $adjustCost = true) { // Create message $message = $this->createMessage([ 'id' => $messageId, 'mobile' => $mobile, 'message' => $message, 'request_id'=> $requestId, 'cost' => $cost, ]); // Return sender response return Loader::sender($this->config)->reply($message, $adjustCost); }
[ "public", "function", "reply", "(", "$", "requestId", ",", "$", "mobile", ",", "$", "message", ",", "$", "cost", "=", "0", ",", "$", "messageId", "=", "null", ",", "$", "adjustCost", "=", "true", ")", "{", "// Create message", "$", "message", "=", "$", "this", "->", "createMessage", "(", "[", "'id'", "=>", "$", "messageId", ",", "'mobile'", "=>", "$", "mobile", ",", "'message'", "=>", "$", "message", ",", "'request_id'", "=>", "$", "requestId", ",", "'cost'", "=>", "$", "cost", ",", "]", ")", ";", "// Return sender response", "return", "Loader", "::", "sender", "(", "$", "this", "->", "config", ")", "->", "reply", "(", "$", "message", ",", "$", "adjustCost", ")", ";", "}" ]
Reply
[ "Reply" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Chikka.php#L73-L84
ronaldborla/chikka
src/Borla/Chikka/Chikka.php
Chikka.replyTo
public function replyTo(Message $message, $messageOrContent, $cost = 0, $messageId = null, $adjustCost = true) { // Return return $this->reply($message->id, $message->mobile, $messageOrContent, $cost, $messageId, $adjustCost); }
php
public function replyTo(Message $message, $messageOrContent, $cost = 0, $messageId = null, $adjustCost = true) { // Return return $this->reply($message->id, $message->mobile, $messageOrContent, $cost, $messageId, $adjustCost); }
[ "public", "function", "replyTo", "(", "Message", "$", "message", ",", "$", "messageOrContent", ",", "$", "cost", "=", "0", ",", "$", "messageId", "=", "null", ",", "$", "adjustCost", "=", "true", ")", "{", "// Return", "return", "$", "this", "->", "reply", "(", "$", "message", "->", "id", ",", "$", "message", "->", "mobile", ",", "$", "messageOrContent", ",", "$", "cost", ",", "$", "messageId", ",", "$", "adjustCost", ")", ";", "}" ]
Reply to a message
[ "Reply", "to", "a", "message" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Chikka.php#L89-L92
ronaldborla/chikka
src/Borla/Chikka/Chikka.php
Chikka.createMessage
protected function createMessage($message) { // If instance of message if ($message instanceof Message) { // Return immediately return $message; } // If array elseif (is_array($message)) { // If there's message instance in message if (isset($message['message']) && $message['message'] instanceof Message) { // Get message and set attributes return $message['message']->setAttributes(Utilities::arrayExcept(['message'], $message)); } } // Return return Loader::message($message); }
php
protected function createMessage($message) { // If instance of message if ($message instanceof Message) { // Return immediately return $message; } // If array elseif (is_array($message)) { // If there's message instance in message if (isset($message['message']) && $message['message'] instanceof Message) { // Get message and set attributes return $message['message']->setAttributes(Utilities::arrayExcept(['message'], $message)); } } // Return return Loader::message($message); }
[ "protected", "function", "createMessage", "(", "$", "message", ")", "{", "// If instance of message", "if", "(", "$", "message", "instanceof", "Message", ")", "{", "// Return immediately", "return", "$", "message", ";", "}", "// If array", "elseif", "(", "is_array", "(", "$", "message", ")", ")", "{", "// If there's message instance in message", "if", "(", "isset", "(", "$", "message", "[", "'message'", "]", ")", "&&", "$", "message", "[", "'message'", "]", "instanceof", "Message", ")", "{", "// Get message and set attributes", "return", "$", "message", "[", "'message'", "]", "->", "setAttributes", "(", "Utilities", "::", "arrayExcept", "(", "[", "'message'", "]", ",", "$", "message", ")", ")", ";", "}", "}", "// Return", "return", "Loader", "::", "message", "(", "$", "message", ")", ";", "}" ]
Create message
[ "Create", "message" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Chikka.php#L97-L113
ronaldborla/chikka
src/Borla/Chikka/Support/Http/Curl.php
Curl.post
public function post($url, $body, array $headers = array()) { // Create a post request return $this->request($url, [ // Use post CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true, CURLOPT_HEADER => true, CURLOPT_CAINFO => dirname(__FILE__) . '/certs/ca-bundle.crt', ]); }
php
public function post($url, $body, array $headers = array()) { // Create a post request return $this->request($url, [ // Use post CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true, CURLOPT_HEADER => true, CURLOPT_CAINFO => dirname(__FILE__) . '/certs/ca-bundle.crt', ]); }
[ "public", "function", "post", "(", "$", "url", ",", "$", "body", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "// Create a post request", "return", "$", "this", "->", "request", "(", "$", "url", ",", "[", "// Use post", "CURLOPT_POST", "=>", "true", ",", "CURLOPT_POSTFIELDS", "=>", "$", "body", ",", "CURLOPT_HTTPHEADER", "=>", "$", "headers", ",", "CURLOPT_RETURNTRANSFER", "=>", "true", ",", "CURLOPT_VERBOSE", "=>", "true", ",", "CURLOPT_HEADER", "=>", "true", ",", "CURLOPT_CAINFO", "=>", "dirname", "(", "__FILE__", ")", ".", "'/certs/ca-bundle.crt'", ",", "]", ")", ";", "}" ]
Post
[ "Post" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Support/Http/Curl.php#L15-L27
ronaldborla/chikka
src/Borla/Chikka/Support/Http/Curl.php
Curl.request
public function request($url, array $options = array()) { // Initialize a curl $curl = curl_init($url); // If there's options if ($options) { // Set options curl_setopt_array($curl, $options); } // Execute $response = curl_exec($curl); // Get header size $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); // Get body $body = substr($response, $headerSize); // Get status $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); // Parse header $headers = $this->parseHeaders(substr($response, 0, $headerSize)); // Close curl curl_close($curl); // Return response return new Response($body, $status, $headers); }
php
public function request($url, array $options = array()) { // Initialize a curl $curl = curl_init($url); // If there's options if ($options) { // Set options curl_setopt_array($curl, $options); } // Execute $response = curl_exec($curl); // Get header size $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); // Get body $body = substr($response, $headerSize); // Get status $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); // Parse header $headers = $this->parseHeaders(substr($response, 0, $headerSize)); // Close curl curl_close($curl); // Return response return new Response($body, $status, $headers); }
[ "public", "function", "request", "(", "$", "url", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Initialize a curl", "$", "curl", "=", "curl_init", "(", "$", "url", ")", ";", "// If there's options", "if", "(", "$", "options", ")", "{", "// Set options", "curl_setopt_array", "(", "$", "curl", ",", "$", "options", ")", ";", "}", "// Execute", "$", "response", "=", "curl_exec", "(", "$", "curl", ")", ";", "// Get header size", "$", "headerSize", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HEADER_SIZE", ")", ";", "// Get body", "$", "body", "=", "substr", "(", "$", "response", ",", "$", "headerSize", ")", ";", "// Get status", "$", "status", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HTTP_CODE", ")", ";", "// Parse header", "$", "headers", "=", "$", "this", "->", "parseHeaders", "(", "substr", "(", "$", "response", ",", "0", ",", "$", "headerSize", ")", ")", ";", "// Close curl", "curl_close", "(", "$", "curl", ")", ";", "// Return response", "return", "new", "Response", "(", "$", "body", ",", "$", "status", ",", "$", "headers", ")", ";", "}" ]
Create a request
[ "Create", "a", "request" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Support/Http/Curl.php#L32-L54
ronaldborla/chikka
src/Borla/Chikka/Support/Http/Curl.php
Curl.parseHeaders
protected function parseHeaders($rawHeaders) { // Set headers $headers = []; // Loop through lines foreach (explode("\n", $rawHeaders) as $line=> $header) { // If line is first or header is empty if ($line == 0 || ! trim($header)) { // Skip continue; } // Find first : $colon = strpos($header, ':'); // Name $name = trim(substr($header, 0, $colon)); // Value $value = trim(substr($header, $colon + 1)); // Set header $headers[$name] = $value; } // Return return $headers; }
php
protected function parseHeaders($rawHeaders) { // Set headers $headers = []; // Loop through lines foreach (explode("\n", $rawHeaders) as $line=> $header) { // If line is first or header is empty if ($line == 0 || ! trim($header)) { // Skip continue; } // Find first : $colon = strpos($header, ':'); // Name $name = trim(substr($header, 0, $colon)); // Value $value = trim(substr($header, $colon + 1)); // Set header $headers[$name] = $value; } // Return return $headers; }
[ "protected", "function", "parseHeaders", "(", "$", "rawHeaders", ")", "{", "// Set headers", "$", "headers", "=", "[", "]", ";", "// Loop through lines", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "rawHeaders", ")", "as", "$", "line", "=>", "$", "header", ")", "{", "// If line is first or header is empty", "if", "(", "$", "line", "==", "0", "||", "!", "trim", "(", "$", "header", ")", ")", "{", "// Skip", "continue", ";", "}", "// Find first :", "$", "colon", "=", "strpos", "(", "$", "header", ",", "':'", ")", ";", "// Name", "$", "name", "=", "trim", "(", "substr", "(", "$", "header", ",", "0", ",", "$", "colon", ")", ")", ";", "// Value", "$", "value", "=", "trim", "(", "substr", "(", "$", "header", ",", "$", "colon", "+", "1", ")", ")", ";", "// Set header", "$", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "}", "// Return", "return", "$", "headers", ";", "}" ]
Parse headers
[ "Parse", "headers" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Support/Http/Curl.php#L59-L80
snapwp/snap-blade
src/Snap_Blade.php
Snap_Blade.runChild
public function runChild($partial, $data = array()) { return parent::runChild( $partial, \array_merge( $this->variables, // Get default data for the current template. View::get_additional_data($partial, $data), // Ensure data passed into parent view is passed to this child. $data ) ); }
php
public function runChild($partial, $data = array()) { return parent::runChild( $partial, \array_merge( $this->variables, // Get default data for the current template. View::get_additional_data($partial, $data), // Ensure data passed into parent view is passed to this child. $data ) ); }
[ "public", "function", "runChild", "(", "$", "partial", ",", "$", "data", "=", "array", "(", ")", ")", "{", "return", "parent", "::", "runChild", "(", "$", "partial", ",", "\\", "array_merge", "(", "$", "this", "->", "variables", ",", "// Get default data for the current template.", "View", "::", "get_additional_data", "(", "$", "partial", ",", "$", "data", ")", ",", "// Ensure data passed into parent view is passed to this child.", "$", "data", ")", ")", ";", "}" ]
Ensures any additional data provided by View::when() is passed to BladeOne. @since 1.0.0 @param string $partial The template name to render. @param array $data The data to pass to BladeOne. @return string @throws \Exception
[ "Ensures", "any", "additional", "data", "provided", "by", "View", "::", "when", "()", "is", "passed", "to", "BladeOne", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Snap_Blade.php#L43-L55
snapwp/snap-blade
src/Snap_Blade.php
Snap_Blade.run
public function run($view, $data = array()) { return parent::run( $view, \array_merge(View::get_additional_data($view, $data), $data) ); }
php
public function run($view, $data = array()) { return parent::run( $view, \array_merge(View::get_additional_data($view, $data), $data) ); }
[ "public", "function", "run", "(", "$", "view", ",", "$", "data", "=", "array", "(", ")", ")", "{", "return", "parent", "::", "run", "(", "$", "view", ",", "\\", "array_merge", "(", "View", "::", "get_additional_data", "(", "$", "view", ",", "$", "data", ")", ",", "$", "data", ")", ")", ";", "}" ]
Run the blade engine. Is only called when rendering a view. @since 1.0.0 @param string $view The template name to render. @param array $data The data to pass to BladeOne. @return string @throws \Exception
[ "Run", "the", "blade", "engine", ".", "Is", "only", "called", "when", "rendering", "a", "view", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Snap_Blade.php#L68-L74
highday/glitter
src/Audit/Listeners/Member/LogChangePassword.php
LogChangePassword.handle
public function handle(MemberUpdated $event) { if (is_null($event->actor)) { return; } if ($event->member->isDirty($event->member->getKeyName()) || $event->member->isClean('password')) { return; } $data = [ 'ip' => request()->ip(), 'ua' => request()->header('User-Agent'), ]; $event->actor->log('member.change_password', $data); }
php
public function handle(MemberUpdated $event) { if (is_null($event->actor)) { return; } if ($event->member->isDirty($event->member->getKeyName()) || $event->member->isClean('password')) { return; } $data = [ 'ip' => request()->ip(), 'ua' => request()->header('User-Agent'), ]; $event->actor->log('member.change_password', $data); }
[ "public", "function", "handle", "(", "MemberUpdated", "$", "event", ")", "{", "if", "(", "is_null", "(", "$", "event", "->", "actor", ")", ")", "{", "return", ";", "}", "if", "(", "$", "event", "->", "member", "->", "isDirty", "(", "$", "event", "->", "member", "->", "getKeyName", "(", ")", ")", "||", "$", "event", "->", "member", "->", "isClean", "(", "'password'", ")", ")", "{", "return", ";", "}", "$", "data", "=", "[", "'ip'", "=>", "request", "(", ")", "->", "ip", "(", ")", ",", "'ua'", "=>", "request", "(", ")", "->", "header", "(", "'User-Agent'", ")", ",", "]", ";", "$", "event", "->", "actor", "->", "log", "(", "'member.change_password'", ",", "$", "data", ")", ";", "}" ]
Handle the event. @param MemberUpdated $event @return void
[ "Handle", "the", "event", "." ]
train
https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Audit/Listeners/Member/LogChangePassword.php#L26-L43
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setPhone
public function setPhone(\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone = null) { $this->phone = $phone; return $this; }
php
public function setPhone(\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone = null) { $this->phone = $phone; return $this; }
[ "public", "function", "setPhone", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "People", "\\", "Phone", "$", "phone", "=", "null", ")", "{", "$", "this", "->", "phone", "=", "$", "phone", ";", "return", "$", "this", ";", "}" ]
Set phone. @param null|\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone @return Customer
[ "Set", "phone", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L287-L292
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setAlternativePhone
public function setAlternativePhone(\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone = null) { $this->alternative_phone = $alternativePhone; return $this; }
php
public function setAlternativePhone(\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone = null) { $this->alternative_phone = $alternativePhone; return $this; }
[ "public", "function", "setAlternativePhone", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "People", "\\", "AlternativePhone", "$", "alternativePhone", "=", "null", ")", "{", "$", "this", "->", "alternative_phone", "=", "$", "alternativePhone", ";", "return", "$", "this", ";", "}" ]
Set alternativePhone. @param null|\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone @return Customer
[ "Set", "alternativePhone", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L311-L316
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setDocument
public function setDocument(\Gpupo\CommonSchema\ORM\Entity\People\Document $document = null) { $this->document = $document; return $this; }
php
public function setDocument(\Gpupo\CommonSchema\ORM\Entity\People\Document $document = null) { $this->document = $document; return $this; }
[ "public", "function", "setDocument", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "People", "\\", "Document", "$", "document", "=", "null", ")", "{", "$", "this", "->", "document", "=", "$", "document", ";", "return", "$", "this", ";", "}" ]
Set document. @param null|\Gpupo\CommonSchema\ORM\Entity\People\Document $document @return Customer
[ "Set", "document", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L335-L340
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setAddressBilling
public function setAddressBilling(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling = null) { $this->address_billing = $addressBilling; return $this; }
php
public function setAddressBilling(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling = null) { $this->address_billing = $addressBilling; return $this; }
[ "public", "function", "setAddressBilling", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Trading", "\\", "Order", "\\", "Customer", "\\", "AddressBilling", "$", "addressBilling", "=", "null", ")", "{", "$", "this", "->", "address_billing", "=", "$", "addressBilling", ";", "return", "$", "this", ";", "}" ]
Set addressBilling. @param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling @return Customer
[ "Set", "addressBilling", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L359-L364
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setAddressDelivery
public function setAddressDelivery(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery = null) { $this->address_delivery = $addressDelivery; return $this; }
php
public function setAddressDelivery(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery = null) { $this->address_delivery = $addressDelivery; return $this; }
[ "public", "function", "setAddressDelivery", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Trading", "\\", "Order", "\\", "Customer", "\\", "AddressDelivery", "$", "addressDelivery", "=", "null", ")", "{", "$", "this", "->", "address_delivery", "=", "$", "addressDelivery", ";", "return", "$", "this", ";", "}" ]
Set addressDelivery. @param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery @return Customer
[ "Set", "addressDelivery", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L383-L388
gpupo/common-schema
src/ORM/Entity/Trading/Order/Customer/Customer.php
Customer.setOrder
public function setOrder(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Order $order = null) { $this->order = $order; return $this; }
php
public function setOrder(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Order $order = null) { $this->order = $order; return $this; }
[ "public", "function", "setOrder", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Trading", "\\", "Order", "\\", "Order", "$", "order", "=", "null", ")", "{", "$", "this", "->", "order", "=", "$", "order", ";", "return", "$", "this", ";", "}" ]
Set order. @param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Order $order @return Customer
[ "Set", "order", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L407-L412
wenbinye/PhalconX
src/Db/Column.php
Column.copy
public static function copy(BaseColumn $column) { $definition = self::filterArray(get_object_vars($column)); return new self($definition['name'], $definition); }
php
public static function copy(BaseColumn $column) { $definition = self::filterArray(get_object_vars($column)); return new self($definition['name'], $definition); }
[ "public", "static", "function", "copy", "(", "BaseColumn", "$", "column", ")", "{", "$", "definition", "=", "self", "::", "filterArray", "(", "get_object_vars", "(", "$", "column", ")", ")", ";", "return", "new", "self", "(", "$", "definition", "[", "'name'", "]", ",", "$", "definition", ")", ";", "}" ]
Copy to new column
[ "Copy", "to", "new", "column" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Column.php#L24-L28
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php
ezcDbHandler.beginTransaction
public function beginTransaction() { $retval = true; if ( $this->transactionNestingLevel == 0 ) { $retval = parent::beginTransaction(); } // else NOP $this->transactionNestingLevel++; return $retval; }
php
public function beginTransaction() { $retval = true; if ( $this->transactionNestingLevel == 0 ) { $retval = parent::beginTransaction(); } // else NOP $this->transactionNestingLevel++; return $retval; }
[ "public", "function", "beginTransaction", "(", ")", "{", "$", "retval", "=", "true", ";", "if", "(", "$", "this", "->", "transactionNestingLevel", "==", "0", ")", "{", "$", "retval", "=", "parent", "::", "beginTransaction", "(", ")", ";", "}", "// else NOP", "$", "this", "->", "transactionNestingLevel", "++", ";", "return", "$", "retval", ";", "}" ]
Begins a transaction. This method executes a begin transaction query unless a transaction has already been started (transaction nesting level > 0 ) Each call to beginTransaction() must have a corresponding commit() or rollback() call. @see commit() @see rollback() @return bool
[ "Begins", "a", "transaction", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php#L164-L175
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php
ezcDbHandler.commit
public function commit() { if ( $this->transactionNestingLevel <= 0 ) { $this->transactionNestingLevel = 0; throw new ezcDbTransactionException( "commit() called before beginTransaction()." ); } $retval = true; if ( $this->transactionNestingLevel == 1 ) { if ( $this->transactionErrorFlag ) { parent::rollback(); $this->transactionErrorFlag = false; // reset error flag $retval = false; } else { parent::commit(); } } // else NOP $this->transactionNestingLevel--; return $retval; }
php
public function commit() { if ( $this->transactionNestingLevel <= 0 ) { $this->transactionNestingLevel = 0; throw new ezcDbTransactionException( "commit() called before beginTransaction()." ); } $retval = true; if ( $this->transactionNestingLevel == 1 ) { if ( $this->transactionErrorFlag ) { parent::rollback(); $this->transactionErrorFlag = false; // reset error flag $retval = false; } else { parent::commit(); } } // else NOP $this->transactionNestingLevel--; return $retval; }
[ "public", "function", "commit", "(", ")", "{", "if", "(", "$", "this", "->", "transactionNestingLevel", "<=", "0", ")", "{", "$", "this", "->", "transactionNestingLevel", "=", "0", ";", "throw", "new", "ezcDbTransactionException", "(", "\"commit() called before beginTransaction().\"", ")", ";", "}", "$", "retval", "=", "true", ";", "if", "(", "$", "this", "->", "transactionNestingLevel", "==", "1", ")", "{", "if", "(", "$", "this", "->", "transactionErrorFlag", ")", "{", "parent", "::", "rollback", "(", ")", ";", "$", "this", "->", "transactionErrorFlag", "=", "false", ";", "// reset error flag", "$", "retval", "=", "false", ";", "}", "else", "{", "parent", "::", "commit", "(", ")", ";", "}", "}", "// else NOP", "$", "this", "->", "transactionNestingLevel", "--", ";", "return", "$", "retval", ";", "}" ]
Commits a transaction. If this this call to commit corresponds to the outermost call to beginTransaction() and all queries within this transaction were successful, a commit query is executed. If one of the queries returned with an error, a rollback query is executed instead. This method returns true if the transaction was successful. If the transaction failed and rollback was called, false is returned. @see beginTransaction() @see rollback() @return bool
[ "Commits", "a", "transaction", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php#L192-L219
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php
ezcDbHandler.rollback
public function rollback() { if ( $this->transactionNestingLevel <= 0 ) { $this->transactionNestingLevel = 0; throw new ezcDbTransactionException( "rollback() called without previous beginTransaction()." ); } if ( $this->transactionNestingLevel == 1 ) { parent::rollback(); $this->transactionErrorFlag = false; // reset error flag } else { // set the error flag, so that if there is outermost commit // then ROLLBACK will be done instead of COMMIT $this->transactionErrorFlag = true; } $this->transactionNestingLevel--; return true; }
php
public function rollback() { if ( $this->transactionNestingLevel <= 0 ) { $this->transactionNestingLevel = 0; throw new ezcDbTransactionException( "rollback() called without previous beginTransaction()." ); } if ( $this->transactionNestingLevel == 1 ) { parent::rollback(); $this->transactionErrorFlag = false; // reset error flag } else { // set the error flag, so that if there is outermost commit // then ROLLBACK will be done instead of COMMIT $this->transactionErrorFlag = true; } $this->transactionNestingLevel--; return true; }
[ "public", "function", "rollback", "(", ")", "{", "if", "(", "$", "this", "->", "transactionNestingLevel", "<=", "0", ")", "{", "$", "this", "->", "transactionNestingLevel", "=", "0", ";", "throw", "new", "ezcDbTransactionException", "(", "\"rollback() called without previous beginTransaction().\"", ")", ";", "}", "if", "(", "$", "this", "->", "transactionNestingLevel", "==", "1", ")", "{", "parent", "::", "rollback", "(", ")", ";", "$", "this", "->", "transactionErrorFlag", "=", "false", ";", "// reset error flag", "}", "else", "{", "// set the error flag, so that if there is outermost commit", "// then ROLLBACK will be done instead of COMMIT", "$", "this", "->", "transactionErrorFlag", "=", "true", ";", "}", "$", "this", "->", "transactionNestingLevel", "--", ";", "return", "true", ";", "}" ]
Rollback a transaction. If this this call to rollback corresponds to the outermost call to beginTransaction(), a rollback query is executed. If this is an inner transaction (nesting level > 1) the error flag is set, leaving the rollback to the outermost transaction. This method always returns true. @see beginTransaction() @see commit() @return bool
[ "Rollback", "a", "transaction", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php#L235-L257
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php
ezcDbHandler.quoteIdentifier
public function quoteIdentifier( $identifier ) { if ( sizeof( $this->identifierQuoteChars ) === 2 ) { $identifier = $this->identifierQuoteChars["start"] . str_replace( $this->identifierQuoteChars["end"], $this->identifierQuoteChars["end"].$this->identifierQuoteChars["end"], $identifier ) . $this->identifierQuoteChars["end"]; } return $identifier; }
php
public function quoteIdentifier( $identifier ) { if ( sizeof( $this->identifierQuoteChars ) === 2 ) { $identifier = $this->identifierQuoteChars["start"] . str_replace( $this->identifierQuoteChars["end"], $this->identifierQuoteChars["end"].$this->identifierQuoteChars["end"], $identifier ) . $this->identifierQuoteChars["end"]; } return $identifier; }
[ "public", "function", "quoteIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "sizeof", "(", "$", "this", "->", "identifierQuoteChars", ")", "===", "2", ")", "{", "$", "identifier", "=", "$", "this", "->", "identifierQuoteChars", "[", "\"start\"", "]", ".", "str_replace", "(", "$", "this", "->", "identifierQuoteChars", "[", "\"end\"", "]", ",", "$", "this", "->", "identifierQuoteChars", "[", "\"end\"", "]", ".", "$", "this", "->", "identifierQuoteChars", "[", "\"end\"", "]", ",", "$", "identifier", ")", ".", "$", "this", "->", "identifierQuoteChars", "[", "\"end\"", "]", ";", "}", "return", "$", "identifier", ";", "}" ]
Returns the quoted version of an identifier to be used in an SQL query. This method takes a given identifier and quotes it, so it can safely be used in SQL queries. @param string $identifier The identifier to quote. @return string The quoted identifier.
[ "Returns", "the", "quoted", "version", "of", "an", "identifier", "to", "be", "used", "in", "an", "SQL", "query", ".", "This", "method", "takes", "a", "given", "identifier", "and", "quotes", "it", "so", "it", "can", "safely", "be", "used", "in", "SQL", "queries", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php#L327-L341
php-lug/lug
src/Component/Behat/Extension/Api/Context/Initializer/ApiContextInitializer.php
ApiContextInitializer.initializeContext
public function initializeContext(Context $context) { if (!$context instanceof ApiContextInterface) { return; } $context->setBaseUrl($this->baseUrl); $context->setClient($this->client); $context->setRequestFactory($this->messageFactory); $context->setFileLocator($this->fileLocator); }
php
public function initializeContext(Context $context) { if (!$context instanceof ApiContextInterface) { return; } $context->setBaseUrl($this->baseUrl); $context->setClient($this->client); $context->setRequestFactory($this->messageFactory); $context->setFileLocator($this->fileLocator); }
[ "public", "function", "initializeContext", "(", "Context", "$", "context", ")", "{", "if", "(", "!", "$", "context", "instanceof", "ApiContextInterface", ")", "{", "return", ";", "}", "$", "context", "->", "setBaseUrl", "(", "$", "this", "->", "baseUrl", ")", ";", "$", "context", "->", "setClient", "(", "$", "this", "->", "client", ")", ";", "$", "context", "->", "setRequestFactory", "(", "$", "this", "->", "messageFactory", ")", ";", "$", "context", "->", "setFileLocator", "(", "$", "this", "->", "fileLocator", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Extension/Api/Context/Initializer/ApiContextInitializer.php#L64-L74
Eresus/EresusCMS
src/core/framework/core/WWW/HTTP/HttpResponse.php
HttpResponse.redirect
public static function redirect($url = null, $params = null, $session = false, $status = null) { /* No headers can be sent before redirect */ if (headers_sent()) { return false; } $url = HTTP::buildURL($url); $httpMessage = HttpMessage::fromEnv(HttpMessage::TYPE_REQUEST); /* Choose HTTP status code */ switch (true) { case $status !== null: $code = $status; break; case $httpMessage->getHttpVersion() == '1.0': $code = 302; break; default: $code = 303; break; } /* Choose HTTP status message */ switch ($code) { case 302: $message = '302 Found'; break; case 303: $message = '303 See Other'; break; default: $message = ''; break; } /* Sending headers */ header('HTTP/' . $httpMessage->getHttpVersion() . ' ' . $message, true, $code); header('Location: ' . $url); /* Sending HTML page for agents which does not support Location header */ header('Content-type: text/html; charset=UTF-8'); $hUrl = htmlspecialchars($url); echo <<<PAGE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta http-equiv="Refresh" content="0; url='{$hUrl}'"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>{$message}</title> </head> <body> <script> function doRedirect() { location.replace("{$hUrl}"); } setTimeout("doRedirect()", 1000); </script> <p>Your browser does not support automatic redirection. Please follow <a href="{$hUrl}">this link</a>.</p> </body> </html> PAGE; // Stopping application exit($code); }
php
public static function redirect($url = null, $params = null, $session = false, $status = null) { /* No headers can be sent before redirect */ if (headers_sent()) { return false; } $url = HTTP::buildURL($url); $httpMessage = HttpMessage::fromEnv(HttpMessage::TYPE_REQUEST); /* Choose HTTP status code */ switch (true) { case $status !== null: $code = $status; break; case $httpMessage->getHttpVersion() == '1.0': $code = 302; break; default: $code = 303; break; } /* Choose HTTP status message */ switch ($code) { case 302: $message = '302 Found'; break; case 303: $message = '303 See Other'; break; default: $message = ''; break; } /* Sending headers */ header('HTTP/' . $httpMessage->getHttpVersion() . ' ' . $message, true, $code); header('Location: ' . $url); /* Sending HTML page for agents which does not support Location header */ header('Content-type: text/html; charset=UTF-8'); $hUrl = htmlspecialchars($url); echo <<<PAGE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta http-equiv="Refresh" content="0; url='{$hUrl}'"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>{$message}</title> </head> <body> <script> function doRedirect() { location.replace("{$hUrl}"); } setTimeout("doRedirect()", 1000); </script> <p>Your browser does not support automatic redirection. Please follow <a href="{$hUrl}">this link</a>.</p> </body> </html> PAGE; // Stopping application exit($code); }
[ "public", "static", "function", "redirect", "(", "$", "url", "=", "null", ",", "$", "params", "=", "null", ",", "$", "session", "=", "false", ",", "$", "status", "=", "null", ")", "{", "/* No headers can be sent before redirect */", "if", "(", "headers_sent", "(", ")", ")", "{", "return", "false", ";", "}", "$", "url", "=", "HTTP", "::", "buildURL", "(", "$", "url", ")", ";", "$", "httpMessage", "=", "HttpMessage", "::", "fromEnv", "(", "HttpMessage", "::", "TYPE_REQUEST", ")", ";", "/* Choose HTTP status code */", "switch", "(", "true", ")", "{", "case", "$", "status", "!==", "null", ":", "$", "code", "=", "$", "status", ";", "break", ";", "case", "$", "httpMessage", "->", "getHttpVersion", "(", ")", "==", "'1.0'", ":", "$", "code", "=", "302", ";", "break", ";", "default", ":", "$", "code", "=", "303", ";", "break", ";", "}", "/* Choose HTTP status message */", "switch", "(", "$", "code", ")", "{", "case", "302", ":", "$", "message", "=", "'302 Found'", ";", "break", ";", "case", "303", ":", "$", "message", "=", "'303 See Other'", ";", "break", ";", "default", ":", "$", "message", "=", "''", ";", "break", ";", "}", "/* Sending headers */", "header", "(", "'HTTP/'", ".", "$", "httpMessage", "->", "getHttpVersion", "(", ")", ".", "' '", ".", "$", "message", ",", "true", ",", "$", "code", ")", ";", "header", "(", "'Location: '", ".", "$", "url", ")", ";", "/* Sending HTML page for agents which does not support Location header */", "header", "(", "'Content-type: text/html; charset=UTF-8'", ")", ";", "$", "hUrl", "=", "htmlspecialchars", "(", "$", "url", ")", ";", "echo", " <<<PAGE\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<html>\n\t<head>\n\t\t<meta http-equiv=\"Refresh\" content=\"0; url='{$hUrl}'\">\n\t\t<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\t\t<title>{$message}</title>\n\t</head>\n\t<body>\n\t\t<script>\n\t\t\tfunction doRedirect()\n\t\t\t{\n\t\t\t\tlocation.replace(\"{$hUrl}\");\n\t\t\t}\n\t\t\tsetTimeout(\"doRedirect()\", 1000);\n\t\t</script>\n\t\t<p>Your browser does not support automatic redirection. Please follow <a href=\"{$hUrl}\">this link</a>.</p>\n\t</body>\n</html>\nPAGE", ";", "// Stopping application", "exit", "(", "$", "code", ")", ";", "}" ]
Перенаправляет на новый адрес @param string $url адрес для переадресации @param array $params Associative array of query parameters (not implemented yet!) @param bool $session Whether to append session information (not implemented yet!) @param int $status код HTTP @return bool FALSE or exits on success with the specified redirection status code @author based on function by w999d
[ "Перенаправляет", "на", "новый", "адрес" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/WWW/HTTP/HttpResponse.php#L68-L138
VincentChalnot/SidusDataGridBundle
Registry/DataGridRegistry.php
DataGridRegistry.getDataGrid
public function getDataGrid(string $code): DataGrid { if (!array_key_exists($code, $this->dataGrids)) { return $this->buildDataGrid($code); } return $this->dataGrids[$code]; }
php
public function getDataGrid(string $code): DataGrid { if (!array_key_exists($code, $this->dataGrids)) { return $this->buildDataGrid($code); } return $this->dataGrids[$code]; }
[ "public", "function", "getDataGrid", "(", "string", "$", "code", ")", ":", "DataGrid", "{", "if", "(", "!", "array_key_exists", "(", "$", "code", ",", "$", "this", "->", "dataGrids", ")", ")", "{", "return", "$", "this", "->", "buildDataGrid", "(", "$", "code", ")", ";", "}", "return", "$", "this", "->", "dataGrids", "[", "$", "code", "]", ";", "}" ]
@param string $code @throws \Symfony\Component\PropertyAccess\Exception\ExceptionInterface @throws \Sidus\FilterBundle\Exception\MissingQueryHandlerFactoryException @throws \Sidus\FilterBundle\Exception\MissingQueryHandlerException @throws \Sidus\FilterBundle\Exception\MissingFilterException @throws \UnexpectedValueException @return DataGrid
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Registry/DataGridRegistry.php#L69-L76
VincentChalnot/SidusDataGridBundle
Registry/DataGridRegistry.php
DataGridRegistry.hasDataGrid
public function hasDataGrid(string $code): bool { return array_key_exists($code, $this->dataGrids) || array_key_exists($code, $this->dataGridConfigurations); }
php
public function hasDataGrid(string $code): bool { return array_key_exists($code, $this->dataGrids) || array_key_exists($code, $this->dataGridConfigurations); }
[ "public", "function", "hasDataGrid", "(", "string", "$", "code", ")", ":", "bool", "{", "return", "array_key_exists", "(", "$", "code", ",", "$", "this", "->", "dataGrids", ")", "||", "array_key_exists", "(", "$", "code", ",", "$", "this", "->", "dataGridConfigurations", ")", ";", "}" ]
@param string $code @return bool
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Registry/DataGridRegistry.php#L83-L86
VincentChalnot/SidusDataGridBundle
Registry/DataGridRegistry.php
DataGridRegistry.buildDataGrid
protected function buildDataGrid(string $code): DataGrid { if (!array_key_exists($code, $this->dataGridConfigurations)) { throw new UnexpectedValueException("No data-grid with code : {$code}"); } $configuration = $this->dataGridConfigurations[$code]; $this->queryHandlerRegistry->addRawQueryHandlerConfiguration( '__sidus_datagrid.'.$code, $configuration['query_handler'] ); $configuration['query_handler'] = $this->queryHandlerRegistry->getQueryHandler('__sidus_datagrid.'.$code); $dataGrid = new DataGrid($code, $configuration); $this->addDataGrid($dataGrid); unset($this->dataGridConfigurations[$code]); return $dataGrid; }
php
protected function buildDataGrid(string $code): DataGrid { if (!array_key_exists($code, $this->dataGridConfigurations)) { throw new UnexpectedValueException("No data-grid with code : {$code}"); } $configuration = $this->dataGridConfigurations[$code]; $this->queryHandlerRegistry->addRawQueryHandlerConfiguration( '__sidus_datagrid.'.$code, $configuration['query_handler'] ); $configuration['query_handler'] = $this->queryHandlerRegistry->getQueryHandler('__sidus_datagrid.'.$code); $dataGrid = new DataGrid($code, $configuration); $this->addDataGrid($dataGrid); unset($this->dataGridConfigurations[$code]); return $dataGrid; }
[ "protected", "function", "buildDataGrid", "(", "string", "$", "code", ")", ":", "DataGrid", "{", "if", "(", "!", "array_key_exists", "(", "$", "code", ",", "$", "this", "->", "dataGridConfigurations", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"No data-grid with code : {$code}\"", ")", ";", "}", "$", "configuration", "=", "$", "this", "->", "dataGridConfigurations", "[", "$", "code", "]", ";", "$", "this", "->", "queryHandlerRegistry", "->", "addRawQueryHandlerConfiguration", "(", "'__sidus_datagrid.'", ".", "$", "code", ",", "$", "configuration", "[", "'query_handler'", "]", ")", ";", "$", "configuration", "[", "'query_handler'", "]", "=", "$", "this", "->", "queryHandlerRegistry", "->", "getQueryHandler", "(", "'__sidus_datagrid.'", ".", "$", "code", ")", ";", "$", "dataGrid", "=", "new", "DataGrid", "(", "$", "code", ",", "$", "configuration", ")", ";", "$", "this", "->", "addDataGrid", "(", "$", "dataGrid", ")", ";", "unset", "(", "$", "this", "->", "dataGridConfigurations", "[", "$", "code", "]", ")", ";", "return", "$", "dataGrid", ";", "}" ]
@param string $code @throws \Symfony\Component\PropertyAccess\Exception\ExceptionInterface @throws \Sidus\FilterBundle\Exception\MissingQueryHandlerFactoryException @throws \Sidus\FilterBundle\Exception\MissingQueryHandlerException @throws \Sidus\FilterBundle\Exception\MissingFilterException @throws \UnexpectedValueException @return DataGrid
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Registry/DataGridRegistry.php#L99-L117
wenbinye/PhalconX
src/Mvc/Controller.php
Controller.render
public function render($view = null, $vars = null, $return = false) { if (is_array($view)) { $vars = $view; $view = null; } if (isset($view)) { $parts = explode('/', $view, 2); if (count($parts) == 2) { list($controllerName, $actionName) = $parts; } else { $controllerName = $this->dispatcher->getControllerName(); $actionName = $parts[0]; } } else { $controllerName = $this->dispatcher->getControllerName(); $actionName = $this->dispatcher->getActionName(); } $view = $this->view; if (isset($vars)) { $view->setVars($vars); } $view->pick($this->pickView($controllerName, $actionName)); $view->start()->render(null, null, $vars); $view->finish(); if ($return) { return $view->getContent(); } else { $this->response->setContent($view->getContent()); } }
php
public function render($view = null, $vars = null, $return = false) { if (is_array($view)) { $vars = $view; $view = null; } if (isset($view)) { $parts = explode('/', $view, 2); if (count($parts) == 2) { list($controllerName, $actionName) = $parts; } else { $controllerName = $this->dispatcher->getControllerName(); $actionName = $parts[0]; } } else { $controllerName = $this->dispatcher->getControllerName(); $actionName = $this->dispatcher->getActionName(); } $view = $this->view; if (isset($vars)) { $view->setVars($vars); } $view->pick($this->pickView($controllerName, $actionName)); $view->start()->render(null, null, $vars); $view->finish(); if ($return) { return $view->getContent(); } else { $this->response->setContent($view->getContent()); } }
[ "public", "function", "render", "(", "$", "view", "=", "null", ",", "$", "vars", "=", "null", ",", "$", "return", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "view", ")", ")", "{", "$", "vars", "=", "$", "view", ";", "$", "view", "=", "null", ";", "}", "if", "(", "isset", "(", "$", "view", ")", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "view", ",", "2", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "2", ")", "{", "list", "(", "$", "controllerName", ",", "$", "actionName", ")", "=", "$", "parts", ";", "}", "else", "{", "$", "controllerName", "=", "$", "this", "->", "dispatcher", "->", "getControllerName", "(", ")", ";", "$", "actionName", "=", "$", "parts", "[", "0", "]", ";", "}", "}", "else", "{", "$", "controllerName", "=", "$", "this", "->", "dispatcher", "->", "getControllerName", "(", ")", ";", "$", "actionName", "=", "$", "this", "->", "dispatcher", "->", "getActionName", "(", ")", ";", "}", "$", "view", "=", "$", "this", "->", "view", ";", "if", "(", "isset", "(", "$", "vars", ")", ")", "{", "$", "view", "->", "setVars", "(", "$", "vars", ")", ";", "}", "$", "view", "->", "pick", "(", "$", "this", "->", "pickView", "(", "$", "controllerName", ",", "$", "actionName", ")", ")", ";", "$", "view", "->", "start", "(", ")", "->", "render", "(", "null", ",", "null", ",", "$", "vars", ")", ";", "$", "view", "->", "finish", "(", ")", ";", "if", "(", "$", "return", ")", "{", "return", "$", "view", "->", "getContent", "(", ")", ";", "}", "else", "{", "$", "this", "->", "response", "->", "setContent", "(", "$", "view", "->", "getContent", "(", ")", ")", ";", "}", "}" ]
渲染页面 <code> $this->render('action', $vars); $this->render('controller/action', $vars); $this->render($vars); </code> @param string $view 页面名 可以是 'controller/action' 的形式或 'action'形式 @param array $vars 页面参数 @param $return 是否返回渲染结果 @return null|string 如果 $return 为 true,返回渲染结果
[ "渲染页面" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Controller.php#L51-L81
wenbinye/PhalconX
src/Mvc/Controller.php
Controller.forward
public function forward($action) { if (is_string($action)) { $parts = explode('/', ltrim($action, '/')); if (count($parts) == 1) { array_unshift($parts, $this->dispatcher->getControllerName()); } $action = array('controller' => $parts[0], 'action' => $parts[1]); } return $this->dispatcher->forward($action); }
php
public function forward($action) { if (is_string($action)) { $parts = explode('/', ltrim($action, '/')); if (count($parts) == 1) { array_unshift($parts, $this->dispatcher->getControllerName()); } $action = array('controller' => $parts[0], 'action' => $parts[1]); } return $this->dispatcher->forward($action); }
[ "public", "function", "forward", "(", "$", "action", ")", "{", "if", "(", "is_string", "(", "$", "action", ")", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "ltrim", "(", "$", "action", ",", "'/'", ")", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "1", ")", "{", "array_unshift", "(", "$", "parts", ",", "$", "this", "->", "dispatcher", "->", "getControllerName", "(", ")", ")", ";", "}", "$", "action", "=", "array", "(", "'controller'", "=>", "$", "parts", "[", "0", "]", ",", "'action'", "=>", "$", "parts", "[", "1", "]", ")", ";", "}", "return", "$", "this", "->", "dispatcher", "->", "forward", "(", "$", "action", ")", ";", "}" ]
跳转到其它 action @param $action
[ "跳转到其它", "action" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Controller.php#L88-L98
wenbinye/PhalconX
src/Mvc/Controller.php
Controller.getParam
public function getParam($name, $filters = null, $defaultValue = null) { $value = $this->dispatcher->getParam($name); if (!isset($value)) { if (!isset($this->pathParameters)) { // 解析路径参数 $this->pathParameters = array(); $uri = $this->router->getRewriteUri(); $parts = explode('/', trim($uri, '/')); for ($i=$this->pathParamOffset, $len=count($parts); $i<$len; $i+=2) { $this->pathParameters[$parts[$i]] = isset($parts[$i+1]) ? $parts[$i+1] : null; } } $value = isset($this->pathParameters[$name]) ? $this->pathParameters[$name] : null; } if (isset($value)) { return isset($filters) ? $this->filter->sanitize($value, $filters) : $value; } else { return $defaultValue; } }
php
public function getParam($name, $filters = null, $defaultValue = null) { $value = $this->dispatcher->getParam($name); if (!isset($value)) { if (!isset($this->pathParameters)) { // 解析路径参数 $this->pathParameters = array(); $uri = $this->router->getRewriteUri(); $parts = explode('/', trim($uri, '/')); for ($i=$this->pathParamOffset, $len=count($parts); $i<$len; $i+=2) { $this->pathParameters[$parts[$i]] = isset($parts[$i+1]) ? $parts[$i+1] : null; } } $value = isset($this->pathParameters[$name]) ? $this->pathParameters[$name] : null; } if (isset($value)) { return isset($filters) ? $this->filter->sanitize($value, $filters) : $value; } else { return $defaultValue; } }
[ "public", "function", "getParam", "(", "$", "name", ",", "$", "filters", "=", "null", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "dispatcher", "->", "getParam", "(", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "pathParameters", ")", ")", "{", "// 解析路径参数", "$", "this", "->", "pathParameters", "=", "array", "(", ")", ";", "$", "uri", "=", "$", "this", "->", "router", "->", "getRewriteUri", "(", ")", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "uri", ",", "'/'", ")", ")", ";", "for", "(", "$", "i", "=", "$", "this", "->", "pathParamOffset", ",", "$", "len", "=", "count", "(", "$", "parts", ")", ";", "$", "i", "<", "$", "len", ";", "$", "i", "+=", "2", ")", "{", "$", "this", "->", "pathParameters", "[", "$", "parts", "[", "$", "i", "]", "]", "=", "isset", "(", "$", "parts", "[", "$", "i", "+", "1", "]", ")", "?", "$", "parts", "[", "$", "i", "+", "1", "]", ":", "null", ";", "}", "}", "$", "value", "=", "isset", "(", "$", "this", "->", "pathParameters", "[", "$", "name", "]", ")", "?", "$", "this", "->", "pathParameters", "[", "$", "name", "]", ":", "null", ";", "}", "if", "(", "isset", "(", "$", "value", ")", ")", "{", "return", "isset", "(", "$", "filters", ")", "?", "$", "this", "->", "filter", "->", "sanitize", "(", "$", "value", ",", "$", "filters", ")", ":", "$", "value", ";", "}", "else", "{", "return", "$", "defaultValue", ";", "}", "}" ]
读取参数信息
[ "读取参数信息" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Controller.php#L103-L123
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/unique_index_name.php
ezcDbSchemaUniqueIndexNameValidator.validate
static public function validate( ezcDbSchema $schema ) { $indexes = array(); $errors = array(); /* For each table we check all auto increment fields. */ foreach ( $schema->getSchema() as $tableName => $table ) { foreach ( $table->indexes as $indexName => $dummy ) { $indexes[$indexName][] = $tableName; } } foreach ( $indexes as $indexName => $tableList ) { if ( count( $tableList ) > 1 ) { $errors[] = "The index name '$indexName' is not unique. It exists for the tables: '" . join( "', '", $tableList ) . "'."; } } return $errors; }
php
static public function validate( ezcDbSchema $schema ) { $indexes = array(); $errors = array(); /* For each table we check all auto increment fields. */ foreach ( $schema->getSchema() as $tableName => $table ) { foreach ( $table->indexes as $indexName => $dummy ) { $indexes[$indexName][] = $tableName; } } foreach ( $indexes as $indexName => $tableList ) { if ( count( $tableList ) > 1 ) { $errors[] = "The index name '$indexName' is not unique. It exists for the tables: '" . join( "', '", $tableList ) . "'."; } } return $errors; }
[ "static", "public", "function", "validate", "(", "ezcDbSchema", "$", "schema", ")", "{", "$", "indexes", "=", "array", "(", ")", ";", "$", "errors", "=", "array", "(", ")", ";", "/* For each table we check all auto increment fields. */", "foreach", "(", "$", "schema", "->", "getSchema", "(", ")", "as", "$", "tableName", "=>", "$", "table", ")", "{", "foreach", "(", "$", "table", "->", "indexes", "as", "$", "indexName", "=>", "$", "dummy", ")", "{", "$", "indexes", "[", "$", "indexName", "]", "[", "]", "=", "$", "tableName", ";", "}", "}", "foreach", "(", "$", "indexes", "as", "$", "indexName", "=>", "$", "tableList", ")", "{", "if", "(", "count", "(", "$", "tableList", ")", ">", "1", ")", "{", "$", "errors", "[", "]", "=", "\"The index name '$indexName' is not unique. It exists for the tables: '\"", ".", "join", "(", "\"', '\"", ",", "$", "tableList", ")", ".", "\"'.\"", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Validates if all the index names used are unique accross the schema. This method loops over all the indexes in all tables and checks whether they have been used before. @param ezcDbSchema $schema @return array(string)
[ "Validates", "if", "all", "the", "index", "names", "used", "are", "unique", "accross", "the", "schema", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/unique_index_name.php#L29-L52
hametuha/wpametu
src/WPametu/API/Rest/WpApi.php
WpApi.rest_api_init
public function rest_api_init() { $register = []; foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) { $method_name = strtolower( "handle_{$method}" ); if ( ! method_exists( $this, $method_name ) ) { continue; } $register[] = [ 'methods' => $method, 'callback' => [ $this, 'invoke' ], 'args' => $this->get_arguments( $method ), 'permission_callback' => [ $this, 'permission_callback' ], ]; } if ( ! $register ) { throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 ); } else { register_rest_route( $this->namespace, $this->get_route(), $register ); } }
php
public function rest_api_init() { $register = []; foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) { $method_name = strtolower( "handle_{$method}" ); if ( ! method_exists( $this, $method_name ) ) { continue; } $register[] = [ 'methods' => $method, 'callback' => [ $this, 'invoke' ], 'args' => $this->get_arguments( $method ), 'permission_callback' => [ $this, 'permission_callback' ], ]; } if ( ! $register ) { throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 ); } else { register_rest_route( $this->namespace, $this->get_route(), $register ); } }
[ "public", "function", "rest_api_init", "(", ")", "{", "$", "register", "=", "[", "]", ";", "foreach", "(", "[", "'GET'", ",", "'POST'", ",", "'PUT'", ",", "'PATCH'", ",", "'DELETE'", ",", "'HEAD'", ",", "'OPTION'", "]", "as", "$", "method", ")", "{", "$", "method_name", "=", "strtolower", "(", "\"handle_{$method}\"", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method_name", ")", ")", "{", "continue", ";", "}", "$", "register", "[", "]", "=", "[", "'methods'", "=>", "$", "method", ",", "'callback'", "=>", "[", "$", "this", ",", "'invoke'", "]", ",", "'args'", "=>", "$", "this", "->", "get_arguments", "(", "$", "method", ")", ",", "'permission_callback'", "=>", "[", "$", "this", ",", "'permission_callback'", "]", ",", "]", ";", "}", "if", "(", "!", "$", "register", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Class %s has no handler.'", ",", "get_called_class", "(", ")", ")", ",", "500", ")", ";", "}", "else", "{", "register_rest_route", "(", "$", "this", "->", "namespace", ",", "$", "this", "->", "get_route", "(", ")", ",", "$", "register", ")", ";", "}", "}" ]
Register rest endpoints @throws \Exception If no handler is set, throws error.
[ "Register", "rest", "endpoints" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/WpApi.php#L40-L59
hametuha/wpametu
src/WPametu/API/Rest/WpApi.php
WpApi.invoke
public function invoke( $request ) { $method_name = 'handle_' . strtolower( $request->get_method() ); try { return call_user_func_array( [ $this, $method_name ], func_get_args() ); } catch ( \Exception $e ) { return new \WP_Error( $e->getCode(), $e->getMessage() ); } }
php
public function invoke( $request ) { $method_name = 'handle_' . strtolower( $request->get_method() ); try { return call_user_func_array( [ $this, $method_name ], func_get_args() ); } catch ( \Exception $e ) { return new \WP_Error( $e->getCode(), $e->getMessage() ); } }
[ "public", "function", "invoke", "(", "$", "request", ")", "{", "$", "method_name", "=", "'handle_'", ".", "strtolower", "(", "$", "request", "->", "get_method", "(", ")", ")", ";", "try", "{", "return", "call_user_func_array", "(", "[", "$", "this", ",", "$", "method_name", "]", ",", "func_get_args", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "new", "\\", "WP_Error", "(", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Invoke callback @param \WP_REST_Request $request @return \WP_Error|\WP_REST_Response
[ "Invoke", "callback" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/WpApi.php#L67-L74
interactivesolutions/honeycomb-core
src/models/HCModel.php
HCModel.getTableEnumList
public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null) { $type = DB::select( DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"') )[0]->Type; preg_match('/^enum\((.*)\)$/', $type, $matches); $values = []; foreach (explode(',', $matches[1]) as $value) { $value = trim($value, "'"); if (is_null($labelKey)) { $values[] = $value; } else { $values[] = [ 'id' => $value, $labelKey => trans($translationCode . $value), ]; } } return $values; }
php
public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null) { $type = DB::select( DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"') )[0]->Type; preg_match('/^enum\((.*)\)$/', $type, $matches); $values = []; foreach (explode(',', $matches[1]) as $value) { $value = trim($value, "'"); if (is_null($labelKey)) { $values[] = $value; } else { $values[] = [ 'id' => $value, $labelKey => trans($translationCode . $value), ]; } } return $values; }
[ "public", "static", "function", "getTableEnumList", "(", "string", "$", "field", ",", "string", "$", "labelKey", "=", "null", ",", "string", "$", "translationCode", "=", "null", ")", "{", "$", "type", "=", "DB", "::", "select", "(", "DB", "::", "raw", "(", "'SHOW COLUMNS FROM '", ".", "self", "::", "getTableName", "(", ")", ".", "' WHERE Field = \"'", ".", "$", "field", ".", "'\"'", ")", ")", "[", "0", "]", "->", "Type", ";", "preg_match", "(", "'/^enum\\((.*)\\)$/'", ",", "$", "type", ",", "$", "matches", ")", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "explode", "(", "','", ",", "$", "matches", "[", "1", "]", ")", "as", "$", "value", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ",", "\"'\"", ")", ";", "if", "(", "is_null", "(", "$", "labelKey", ")", ")", "{", "$", "values", "[", "]", "=", "$", "value", ";", "}", "else", "{", "$", "values", "[", "]", "=", "[", "'id'", "=>", "$", "value", ",", "$", "labelKey", "=>", "trans", "(", "$", "translationCode", ".", "$", "value", ")", ",", "]", ";", "}", "}", "return", "$", "values", ";", "}" ]
Get table enum field list with translations or not @param string $field @param null|string $labelKey @param string $translationCode @return array
[ "Get", "table", "enum", "field", "list", "with", "translations", "or", "not" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/HCModel.php#L55-L79
ouropencode/dachi
src/Modules.php
Modules.initialize
protected static function initialize() { if(file_exists("cache/dachi.modules.json")) { $modules = json_decode(file_get_contents("cache/dachi.modules.json")); foreach($modules as $module) self::$modules[$module->shortname] = new Module($module); } }
php
protected static function initialize() { if(file_exists("cache/dachi.modules.json")) { $modules = json_decode(file_get_contents("cache/dachi.modules.json")); foreach($modules as $module) self::$modules[$module->shortname] = new Module($module); } }
[ "protected", "static", "function", "initialize", "(", ")", "{", "if", "(", "file_exists", "(", "\"cache/dachi.modules.json\"", ")", ")", "{", "$", "modules", "=", "json_decode", "(", "file_get_contents", "(", "\"cache/dachi.modules.json\"", ")", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "self", "::", "$", "modules", "[", "$", "module", "->", "shortname", "]", "=", "new", "Module", "(", "$", "module", ")", ";", "}", "}" ]
Load the routing information object into memory. @return null
[ "Load", "the", "routing", "information", "object", "into", "memory", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Modules.php#L22-L29
ouropencode/dachi
src/Modules.php
Modules.get
public static function get($module) { if(self::$modules === array()) self::initialize(); if(!isset(self::$modules[$module])) return false; return self::$modules[$module]; }
php
public static function get($module) { if(self::$modules === array()) self::initialize(); if(!isset(self::$modules[$module])) return false; return self::$modules[$module]; }
[ "public", "static", "function", "get", "(", "$", "module", ")", "{", "if", "(", "self", "::", "$", "modules", "===", "array", "(", ")", ")", "self", "::", "initialize", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "modules", "[", "$", "module", "]", ")", ")", "return", "false", ";", "return", "self", "::", "$", "modules", "[", "$", "module", "]", ";", "}" ]
Retrieve module information. @param string $module Module shortname @return Module
[ "Retrieve", "module", "information", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Modules.php#L36-L44
geocoder-php/GeocoderServiceProvider
src/Geocoder/LoggableGeocoder.php
LoggableGeocoder.geocode
public function geocode($value) { if (null === $this->logger) { return parent::geocode($value); } $startTime = microtime(true); $result = parent::geocode($value); $duration = (microtime(true) - $startTime) * 1000; $this->logger->logRequest( sprintf("[Geocoding] %s", $value), $duration, $this->getProviderClass(), json_encode($result->toArray()) ); return $result; }
php
public function geocode($value) { if (null === $this->logger) { return parent::geocode($value); } $startTime = microtime(true); $result = parent::geocode($value); $duration = (microtime(true) - $startTime) * 1000; $this->logger->logRequest( sprintf("[Geocoding] %s", $value), $duration, $this->getProviderClass(), json_encode($result->toArray()) ); return $result; }
[ "public", "function", "geocode", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "this", "->", "logger", ")", "{", "return", "parent", "::", "geocode", "(", "$", "value", ")", ";", "}", "$", "startTime", "=", "microtime", "(", "true", ")", ";", "$", "result", "=", "parent", "::", "geocode", "(", "$", "value", ")", ";", "$", "duration", "=", "(", "microtime", "(", "true", ")", "-", "$", "startTime", ")", "*", "1000", ";", "$", "this", "->", "logger", "->", "logRequest", "(", "sprintf", "(", "\"[Geocoding] %s\"", ",", "$", "value", ")", ",", "$", "duration", ",", "$", "this", "->", "getProviderClass", "(", ")", ",", "json_encode", "(", "$", "result", "->", "toArray", "(", ")", ")", ")", ";", "return", "$", "result", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/geocoder-php/GeocoderServiceProvider/blob/9bb850f5ac881b4d317d569c87e0573faa69e4bb/src/Geocoder/LoggableGeocoder.php#L34-L52
geocoder-php/GeocoderServiceProvider
src/Geocoder/LoggableGeocoder.php
LoggableGeocoder.reverse
public function reverse($latitude, $longitude) { if (null === $this->logger) { return parent::reverse($latitude, $longitude); } $startTime = microtime(true); $result = parent::reverse($latitude, $longitude); $duration = (microtime(true) - $startTime) * 1000; $value = sprintf("[Reverse geocoding] latitude: %s, longitude: %s", $latitude, $longitude); $this->logger->logRequest( $value, $duration, $this->getProviderClass(), json_encode($result->toArray()) ); return $result; }
php
public function reverse($latitude, $longitude) { if (null === $this->logger) { return parent::reverse($latitude, $longitude); } $startTime = microtime(true); $result = parent::reverse($latitude, $longitude); $duration = (microtime(true) - $startTime) * 1000; $value = sprintf("[Reverse geocoding] latitude: %s, longitude: %s", $latitude, $longitude); $this->logger->logRequest( $value, $duration, $this->getProviderClass(), json_encode($result->toArray()) ); return $result; }
[ "public", "function", "reverse", "(", "$", "latitude", ",", "$", "longitude", ")", "{", "if", "(", "null", "===", "$", "this", "->", "logger", ")", "{", "return", "parent", "::", "reverse", "(", "$", "latitude", ",", "$", "longitude", ")", ";", "}", "$", "startTime", "=", "microtime", "(", "true", ")", ";", "$", "result", "=", "parent", "::", "reverse", "(", "$", "latitude", ",", "$", "longitude", ")", ";", "$", "duration", "=", "(", "microtime", "(", "true", ")", "-", "$", "startTime", ")", "*", "1000", ";", "$", "value", "=", "sprintf", "(", "\"[Reverse geocoding] latitude: %s, longitude: %s\"", ",", "$", "latitude", ",", "$", "longitude", ")", ";", "$", "this", "->", "logger", "->", "logRequest", "(", "$", "value", ",", "$", "duration", ",", "$", "this", "->", "getProviderClass", "(", ")", ",", "json_encode", "(", "$", "result", "->", "toArray", "(", ")", ")", ")", ";", "return", "$", "result", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/geocoder-php/GeocoderServiceProvider/blob/9bb850f5ac881b4d317d569c87e0573faa69e4bb/src/Geocoder/LoggableGeocoder.php#L57-L77
LIN3S/Distribution
src/Php/Composer/Wordpress.php
Wordpress.installRequiredFiles
public static function installRequiredFiles() { $htaccess = __DIR__ . '/../../../../../../.htaccess'; $robots = __DIR__ . '/../../../../../../robots.txt'; $wpConfig = __DIR__ . '/../../../../../../wp-config-custom'; $fileSystem = new Filesystem(); try { if (false === $fileSystem->exists($htaccess)) { $fileSystem->copy($htaccess . '.dist', $htaccess); } if (false === $fileSystem->exists($robots)) { $fileSystem->copy($robots . '.dist', $robots); } if (false === $fileSystem->exists($wpConfig . '.php')) { $fileSystem->copy($wpConfig . '-sample.php', $wpConfig . '.php'); } } catch (\Exception $exception) { echo sprintf("Something wrong happens during process: \n%s\n", $exception->getMessage()); } }
php
public static function installRequiredFiles() { $htaccess = __DIR__ . '/../../../../../../.htaccess'; $robots = __DIR__ . '/../../../../../../robots.txt'; $wpConfig = __DIR__ . '/../../../../../../wp-config-custom'; $fileSystem = new Filesystem(); try { if (false === $fileSystem->exists($htaccess)) { $fileSystem->copy($htaccess . '.dist', $htaccess); } if (false === $fileSystem->exists($robots)) { $fileSystem->copy($robots . '.dist', $robots); } if (false === $fileSystem->exists($wpConfig . '.php')) { $fileSystem->copy($wpConfig . '-sample.php', $wpConfig . '.php'); } } catch (\Exception $exception) { echo sprintf("Something wrong happens during process: \n%s\n", $exception->getMessage()); } }
[ "public", "static", "function", "installRequiredFiles", "(", ")", "{", "$", "htaccess", "=", "__DIR__", ".", "'/../../../../../../.htaccess'", ";", "$", "robots", "=", "__DIR__", ".", "'/../../../../../../robots.txt'", ";", "$", "wpConfig", "=", "__DIR__", ".", "'/../../../../../../wp-config-custom'", ";", "$", "fileSystem", "=", "new", "Filesystem", "(", ")", ";", "try", "{", "if", "(", "false", "===", "$", "fileSystem", "->", "exists", "(", "$", "htaccess", ")", ")", "{", "$", "fileSystem", "->", "copy", "(", "$", "htaccess", ".", "'.dist'", ",", "$", "htaccess", ")", ";", "}", "if", "(", "false", "===", "$", "fileSystem", "->", "exists", "(", "$", "robots", ")", ")", "{", "$", "fileSystem", "->", "copy", "(", "$", "robots", ".", "'.dist'", ",", "$", "robots", ")", ";", "}", "if", "(", "false", "===", "$", "fileSystem", "->", "exists", "(", "$", "wpConfig", ".", "'.php'", ")", ")", "{", "$", "fileSystem", "->", "copy", "(", "$", "wpConfig", ".", "'-sample.php'", ",", "$", "wpConfig", ".", "'.php'", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "echo", "sprintf", "(", "\"Something wrong happens during process: \\n%s\\n\"", ",", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Static method that creates .htaccess, robots.txt and wp-config-custom.php files if they do not exist.
[ "Static", "method", "that", "creates", ".", "htaccess", "robots", ".", "txt", "and", "wp", "-", "config", "-", "custom", ".", "php", "files", "if", "they", "do", "not", "exist", "." ]
train
https://github.com/LIN3S/Distribution/blob/294cda1c2128fa967b3b316f01f202e4e46d2e5b/src/Php/Composer/Wordpress.php#L26-L46
glynnforrest/active-doctrine
src/ActiveDoctrine/Entity/EntitySelector.php
EntitySelector.with
public function with($relation, \Closure $callback = null) { if ($callback === null) { $callback = function () {}; } $this->with[$relation] = $callback; return $this; }
php
public function with($relation, \Closure $callback = null) { if ($callback === null) { $callback = function () {}; } $this->with[$relation] = $callback; return $this; }
[ "public", "function", "with", "(", "$", "relation", ",", "\\", "Closure", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", ")", "{", "$", "callback", "=", "function", "(", ")", "{", "}", ";", "}", "$", "this", "->", "with", "[", "$", "relation", "]", "=", "$", "callback", ";", "return", "$", "this", ";", "}" ]
Eagerly load related entities with this query. A new EntitySelector instance will be created which can be configured with a supplied callback (including loading relations of those entities). @param string $relation The name of the relation @param Closure|null $callback An optional callback for the resulting EntitySelector
[ "Eagerly", "load", "related", "entities", "with", "this", "query", ".", "A", "new", "EntitySelector", "instance", "will", "be", "created", "which", "can", "be", "configured", "with", "a", "supplied", "callback", "(", "including", "loading", "relations", "of", "those", "entities", ")", "." ]
train
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntitySelector.php#L93-L102
glynnforrest/active-doctrine
src/ActiveDoctrine/Entity/EntitySelector.php
EntitySelector.decorateWhere
protected function decorateWhere($method, &$args) { $column = $args[0]; $expression = isset($args[1]) ? $args[1] : null; $value = isset($args[2]) ? $args[2] : null; if (!$expression instanceof Entity && !$value instanceof Entity) { return; } $entity_class = $this->entity_class; $relation = $entity_class::getRelationDefinition($column); $column = $relation[3]; $relation_column = $relation[2]; if ($expression instanceof Entity) { $expression = $expression->getRaw($relation_column); } else { $value = $value->getRaw($relation_column); } $args = [$column, $expression, $value]; }
php
protected function decorateWhere($method, &$args) { $column = $args[0]; $expression = isset($args[1]) ? $args[1] : null; $value = isset($args[2]) ? $args[2] : null; if (!$expression instanceof Entity && !$value instanceof Entity) { return; } $entity_class = $this->entity_class; $relation = $entity_class::getRelationDefinition($column); $column = $relation[3]; $relation_column = $relation[2]; if ($expression instanceof Entity) { $expression = $expression->getRaw($relation_column); } else { $value = $value->getRaw($relation_column); } $args = [$column, $expression, $value]; }
[ "protected", "function", "decorateWhere", "(", "$", "method", ",", "&", "$", "args", ")", "{", "$", "column", "=", "$", "args", "[", "0", "]", ";", "$", "expression", "=", "isset", "(", "$", "args", "[", "1", "]", ")", "?", "$", "args", "[", "1", "]", ":", "null", ";", "$", "value", "=", "isset", "(", "$", "args", "[", "2", "]", ")", "?", "$", "args", "[", "2", "]", ":", "null", ";", "if", "(", "!", "$", "expression", "instanceof", "Entity", "&&", "!", "$", "value", "instanceof", "Entity", ")", "{", "return", ";", "}", "$", "entity_class", "=", "$", "this", "->", "entity_class", ";", "$", "relation", "=", "$", "entity_class", "::", "getRelationDefinition", "(", "$", "column", ")", ";", "$", "column", "=", "$", "relation", "[", "3", "]", ";", "$", "relation_column", "=", "$", "relation", "[", "2", "]", ";", "if", "(", "$", "expression", "instanceof", "Entity", ")", "{", "$", "expression", "=", "$", "expression", "->", "getRaw", "(", "$", "relation_column", ")", ";", "}", "else", "{", "$", "value", "=", "$", "value", "->", "getRaw", "(", "$", "relation_column", ")", ";", "}", "$", "args", "=", "[", "$", "column", ",", "$", "expression", ",", "$", "value", "]", ";", "}" ]
Modify the arguments of a where method to account for selecting by entity objects. @param $method The where method being called @param $args The arguments
[ "Modify", "the", "arguments", "of", "a", "where", "method", "to", "account", "for", "selecting", "by", "entity", "objects", "." ]
train
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntitySelector.php#L111-L132
glynnforrest/active-doctrine
src/ActiveDoctrine/Entity/EntitySelector.php
EntitySelector.execute
public function execute() { if ($this->counting) { return $this->executeCount(); } if ($this->single) { return $this->executeSingle($this->entity_class); } return $this->executeCollection($this->entity_class); }
php
public function execute() { if ($this->counting) { return $this->executeCount(); } if ($this->single) { return $this->executeSingle($this->entity_class); } return $this->executeCollection($this->entity_class); }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "$", "this", "->", "counting", ")", "{", "return", "$", "this", "->", "executeCount", "(", ")", ";", "}", "if", "(", "$", "this", "->", "single", ")", "{", "return", "$", "this", "->", "executeSingle", "(", "$", "this", "->", "entity_class", ")", ";", "}", "return", "$", "this", "->", "executeCollection", "(", "$", "this", "->", "entity_class", ")", ";", "}" ]
Execute the query and return the result. @return mixed An EntityCollection, Entity or integer.
[ "Execute", "the", "query", "and", "return", "the", "result", "." ]
train
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntitySelector.php#L139-L150
phpnfe/tools
src/Certificado/Asn.php
Asn.getCNPJCert
public static function getCNPJCert($certPem) { $certDer = self::pem2Der((string) $certPem); $data = self::getOIDdata((string) $certDer, '2.16.76.1.3.3'); return (string) $data[0][1][1][0][1]; }
php
public static function getCNPJCert($certPem) { $certDer = self::pem2Der((string) $certPem); $data = self::getOIDdata((string) $certDer, '2.16.76.1.3.3'); return (string) $data[0][1][1][0][1]; }
[ "public", "static", "function", "getCNPJCert", "(", "$", "certPem", ")", "{", "$", "certDer", "=", "self", "::", "pem2Der", "(", "(", "string", ")", "$", "certPem", ")", ";", "$", "data", "=", "self", "::", "getOIDdata", "(", "(", "string", ")", "$", "certDer", ",", "'2.16.76.1.3.3'", ")", ";", "return", "(", "string", ")", "$", "data", "[", "0", "]", "[", "1", "]", "[", "1", "]", "[", "0", "]", "[", "1", "]", ";", "}" ]
getCNPJCert. Obtêm o numero de CNPJ da chave publica do Certificado (A1) @param string $certpem conteúdo do certificado @return string CNPJ
[ "getCNPJCert", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L20-L26
phpnfe/tools
src/Certificado/Asn.php
Asn.getOIDdata
protected static function getOIDdata($certDer, $oidNumber) { //converte onumero OTD de texto para hexadecimal $oidHexa = self::oidtoHex((string) $oidNumber); //Divide o certificado usando a OID como marcador,uma antes do OID e outra contendo o OID. //Normalmente o certificado será dividido em duas partes, pois em geral existe //apenas um OID de cada tipo no certificado, mas podem haver mais. $partes = explode($oidHexa, $certDer); $ret = []; //se count($partes) > 1 então o OID foi localizado no certificado $tot = count($partes); if ($tot > 1) { //O inicio da sequencia que nos interessa pode estar a 3 ou 2 digitos //antes do inicio da OID, isso depende do numero de bytes usados para //identificar o tamanho da sequencia for ($i = 1; $i < $tot; $i++) { //recupera da primeira parte os 4 últimos digitos na parte sem o OID $xcv4 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 4, 4); //recupera da primeira parte os 3 ultimos digitos na parte sem o OID $xcv3 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 3, 3); //recupera da primeira parte os 2 ultimos digitos na parte em o OID $xcv2 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 2, 2); //verifica se o primeiro digito é Hex 030 if ($xcv4[0] == chr(0x30)) { //se for, então tamanho é definido por esses 4 bytes $xcv = $xcv4; } else { //se for, então tamanho é definido por esses 3 bytes if ($xcv3[0] == chr(0x30)) { $xcv = $xcv3; } else { //então tamanho é definido por esses 2 bytes $xcv = $xcv2; } } //reconstroi a sequencia, marca do tamanho do campo, OID e //a parte do certificado com o OID $data = $xcv . $oidHexa . $partes[$i]; //converte para decimal, o segundo digito da sequencia $len = (int) ord($data[1]); $bytes = 0; // obtem tamanho da parte de dados da oid self::getLength($len, $bytes, (string) $data); // Obtem o conjunto de bytes pertencentes a oid $oidData = substr($data, 2 + $bytes, $len); //parse dos dados da oid $ret[] = self::parseASN((string) $oidData); } } return $ret; }
php
protected static function getOIDdata($certDer, $oidNumber) { //converte onumero OTD de texto para hexadecimal $oidHexa = self::oidtoHex((string) $oidNumber); //Divide o certificado usando a OID como marcador,uma antes do OID e outra contendo o OID. //Normalmente o certificado será dividido em duas partes, pois em geral existe //apenas um OID de cada tipo no certificado, mas podem haver mais. $partes = explode($oidHexa, $certDer); $ret = []; //se count($partes) > 1 então o OID foi localizado no certificado $tot = count($partes); if ($tot > 1) { //O inicio da sequencia que nos interessa pode estar a 3 ou 2 digitos //antes do inicio da OID, isso depende do numero de bytes usados para //identificar o tamanho da sequencia for ($i = 1; $i < $tot; $i++) { //recupera da primeira parte os 4 últimos digitos na parte sem o OID $xcv4 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 4, 4); //recupera da primeira parte os 3 ultimos digitos na parte sem o OID $xcv3 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 3, 3); //recupera da primeira parte os 2 ultimos digitos na parte em o OID $xcv2 = substr($partes[$i - 1], strlen($partes[$i - 1]) - 2, 2); //verifica se o primeiro digito é Hex 030 if ($xcv4[0] == chr(0x30)) { //se for, então tamanho é definido por esses 4 bytes $xcv = $xcv4; } else { //se for, então tamanho é definido por esses 3 bytes if ($xcv3[0] == chr(0x30)) { $xcv = $xcv3; } else { //então tamanho é definido por esses 2 bytes $xcv = $xcv2; } } //reconstroi a sequencia, marca do tamanho do campo, OID e //a parte do certificado com o OID $data = $xcv . $oidHexa . $partes[$i]; //converte para decimal, o segundo digito da sequencia $len = (int) ord($data[1]); $bytes = 0; // obtem tamanho da parte de dados da oid self::getLength($len, $bytes, (string) $data); // Obtem o conjunto de bytes pertencentes a oid $oidData = substr($data, 2 + $bytes, $len); //parse dos dados da oid $ret[] = self::parseASN((string) $oidData); } } return $ret; }
[ "protected", "static", "function", "getOIDdata", "(", "$", "certDer", ",", "$", "oidNumber", ")", "{", "//converte onumero OTD de texto para hexadecimal", "$", "oidHexa", "=", "self", "::", "oidtoHex", "(", "(", "string", ")", "$", "oidNumber", ")", ";", "//Divide o certificado usando a OID como marcador,uma antes do OID e outra contendo o OID.", "//Normalmente o certificado será dividido em duas partes, pois em geral existe", "//apenas um OID de cada tipo no certificado, mas podem haver mais.", "$", "partes", "=", "explode", "(", "$", "oidHexa", ",", "$", "certDer", ")", ";", "$", "ret", "=", "[", "]", ";", "//se count($partes) > 1 então o OID foi localizado no certificado", "$", "tot", "=", "count", "(", "$", "partes", ")", ";", "if", "(", "$", "tot", ">", "1", ")", "{", "//O inicio da sequencia que nos interessa pode estar a 3 ou 2 digitos", "//antes do inicio da OID, isso depende do numero de bytes usados para", "//identificar o tamanho da sequencia", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "tot", ";", "$", "i", "++", ")", "{", "//recupera da primeira parte os 4 últimos digitos na parte sem o OID", "$", "xcv4", "=", "substr", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ",", "strlen", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ")", "-", "4", ",", "4", ")", ";", "//recupera da primeira parte os 3 ultimos digitos na parte sem o OID", "$", "xcv3", "=", "substr", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ",", "strlen", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ")", "-", "3", ",", "3", ")", ";", "//recupera da primeira parte os 2 ultimos digitos na parte em o OID", "$", "xcv2", "=", "substr", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ",", "strlen", "(", "$", "partes", "[", "$", "i", "-", "1", "]", ")", "-", "2", ",", "2", ")", ";", "//verifica se o primeiro digito é Hex 030", "if", "(", "$", "xcv4", "[", "0", "]", "==", "chr", "(", "0x30", ")", ")", "{", "//se for, então tamanho é definido por esses 4 bytes", "$", "xcv", "=", "$", "xcv4", ";", "}", "else", "{", "//se for, então tamanho é definido por esses 3 bytes", "if", "(", "$", "xcv3", "[", "0", "]", "==", "chr", "(", "0x30", ")", ")", "{", "$", "xcv", "=", "$", "xcv3", ";", "}", "else", "{", "//então tamanho é definido por esses 2 bytes", "$", "xcv", "=", "$", "xcv2", ";", "}", "}", "//reconstroi a sequencia, marca do tamanho do campo, OID e", "//a parte do certificado com o OID", "$", "data", "=", "$", "xcv", ".", "$", "oidHexa", ".", "$", "partes", "[", "$", "i", "]", ";", "//converte para decimal, o segundo digito da sequencia", "$", "len", "=", "(", "int", ")", "ord", "(", "$", "data", "[", "1", "]", ")", ";", "$", "bytes", "=", "0", ";", "// obtem tamanho da parte de dados da oid", "self", "::", "getLength", "(", "$", "len", ",", "$", "bytes", ",", "(", "string", ")", "$", "data", ")", ";", "// Obtem o conjunto de bytes pertencentes a oid", "$", "oidData", "=", "substr", "(", "$", "data", ",", "2", "+", "$", "bytes", ",", "$", "len", ")", ";", "//parse dos dados da oid", "$", "ret", "[", "]", "=", "self", "::", "parseASN", "(", "(", "string", ")", "$", "oidData", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
getOIDdata Recupera a informação referente ao OID contido no certificado Este método assume que a OID está inserida dentro de uma estrutura do tipo "sequencia", como primeiro elemento da estrutura. @param string $certDer @param string $oidNumber @return array
[ "getOIDdata", "Recupera", "a", "informação", "referente", "ao", "OID", "contido", "no", "certificado", "Este", "método", "assume", "que", "a", "OID", "está", "inserida", "dentro", "de", "uma", "estrutura", "do", "tipo", "sequencia", "como", "primeiro", "elemento", "da", "estrutura", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L37-L88
phpnfe/tools
src/Certificado/Asn.php
Asn.parseASN
protected static function parseASN($data, $contextEspecific = false) { $result = []; while (strlen($data) > 1) { $class = ord($data[0]); switch ($class) { case 0x30: // Sequence self::parseSequence($data, $result); break; case 0x31: self::parseSetOf($data, $result); break; case 0x01: // Boolean type self::parseBooleanType($data, $result); break; case 0x02: // Integer type self::parseIntegerType($data, $result); break; case 0x03: self::parseBitString($data, $result); break; case 0x04: self::parseOctetSting($data, $result, $contextEspecific); break; case 0x0C: self::parseUtf8String($data, $result, $contextEspecific); break; case 0x05: // Null type $data = substr($data, 2); $result[] = ['null', null]; break; case 0x06: self::parseOIDtype($data, $result); break; case 0x16: self::parseIA5String($data, $result); break; case 0x12: case 0x14: case 0x15: case 0x81: self::parseString($data, $result); break; case 0x80: // Character string type self::parseCharString($data, $result); break; case 0x13: case 0x86: // Printable string type self::parsePrintableString($data, $result); break; case 0x17: // Time types self::parseTimesType($data, $result); break; case 0x82: // X509v3 extensions? self::parseExtensions($data, $result, 'extension : X509v3 extensions'); break; case 0xa0: // Extensions Context Especific self::parseExtensions($data, $result, 'Context Especific'); break; case 0xa3: // Extensions self::parseExtensions($data, $result, 'extension (0xA3)'); break; case 0xe6: // Hex Extensions extension (0xE6) self::parseHexExtensions($data, $result, 'extension (0xE6)'); break; case 0xa1: // Hex Extensions extension (0xA1) self::parseHexExtensions($data, $result, 'extension (0xA1)'); break; default: // Unknown $result[] = 'UNKNOWN' . $data; $data = ''; break; } } if (count($result) > 1) { return $result; } else { return array_pop($result); } }
php
protected static function parseASN($data, $contextEspecific = false) { $result = []; while (strlen($data) > 1) { $class = ord($data[0]); switch ($class) { case 0x30: // Sequence self::parseSequence($data, $result); break; case 0x31: self::parseSetOf($data, $result); break; case 0x01: // Boolean type self::parseBooleanType($data, $result); break; case 0x02: // Integer type self::parseIntegerType($data, $result); break; case 0x03: self::parseBitString($data, $result); break; case 0x04: self::parseOctetSting($data, $result, $contextEspecific); break; case 0x0C: self::parseUtf8String($data, $result, $contextEspecific); break; case 0x05: // Null type $data = substr($data, 2); $result[] = ['null', null]; break; case 0x06: self::parseOIDtype($data, $result); break; case 0x16: self::parseIA5String($data, $result); break; case 0x12: case 0x14: case 0x15: case 0x81: self::parseString($data, $result); break; case 0x80: // Character string type self::parseCharString($data, $result); break; case 0x13: case 0x86: // Printable string type self::parsePrintableString($data, $result); break; case 0x17: // Time types self::parseTimesType($data, $result); break; case 0x82: // X509v3 extensions? self::parseExtensions($data, $result, 'extension : X509v3 extensions'); break; case 0xa0: // Extensions Context Especific self::parseExtensions($data, $result, 'Context Especific'); break; case 0xa3: // Extensions self::parseExtensions($data, $result, 'extension (0xA3)'); break; case 0xe6: // Hex Extensions extension (0xE6) self::parseHexExtensions($data, $result, 'extension (0xE6)'); break; case 0xa1: // Hex Extensions extension (0xA1) self::parseHexExtensions($data, $result, 'extension (0xA1)'); break; default: // Unknown $result[] = 'UNKNOWN' . $data; $data = ''; break; } } if (count($result) > 1) { return $result; } else { return array_pop($result); } }
[ "protected", "static", "function", "parseASN", "(", "$", "data", ",", "$", "contextEspecific", "=", "false", ")", "{", "$", "result", "=", "[", "]", ";", "while", "(", "strlen", "(", "$", "data", ")", ">", "1", ")", "{", "$", "class", "=", "ord", "(", "$", "data", "[", "0", "]", ")", ";", "switch", "(", "$", "class", ")", "{", "case", "0x30", ":", "// Sequence", "self", "::", "parseSequence", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x31", ":", "self", "::", "parseSetOf", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x01", ":", "// Boolean type", "self", "::", "parseBooleanType", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x02", ":", "// Integer type", "self", "::", "parseIntegerType", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x03", ":", "self", "::", "parseBitString", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x04", ":", "self", "::", "parseOctetSting", "(", "$", "data", ",", "$", "result", ",", "$", "contextEspecific", ")", ";", "break", ";", "case", "0x0C", ":", "self", "::", "parseUtf8String", "(", "$", "data", ",", "$", "result", ",", "$", "contextEspecific", ")", ";", "break", ";", "case", "0x05", ":", "// Null type", "$", "data", "=", "substr", "(", "$", "data", ",", "2", ")", ";", "$", "result", "[", "]", "=", "[", "'null'", ",", "null", "]", ";", "break", ";", "case", "0x06", ":", "self", "::", "parseOIDtype", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x16", ":", "self", "::", "parseIA5String", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x12", ":", "case", "0x14", ":", "case", "0x15", ":", "case", "0x81", ":", "self", "::", "parseString", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x80", ":", "// Character string type", "self", "::", "parseCharString", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x13", ":", "case", "0x86", ":", "// Printable string type", "self", "::", "parsePrintableString", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x17", ":", "// Time types", "self", "::", "parseTimesType", "(", "$", "data", ",", "$", "result", ")", ";", "break", ";", "case", "0x82", ":", "// X509v3 extensions?", "self", "::", "parseExtensions", "(", "$", "data", ",", "$", "result", ",", "'extension : X509v3 extensions'", ")", ";", "break", ";", "case", "0xa0", ":", "// Extensions Context Especific", "self", "::", "parseExtensions", "(", "$", "data", ",", "$", "result", ",", "'Context Especific'", ")", ";", "break", ";", "case", "0xa3", ":", "// Extensions", "self", "::", "parseExtensions", "(", "$", "data", ",", "$", "result", ",", "'extension (0xA3)'", ")", ";", "break", ";", "case", "0xe6", ":", "// Hex Extensions extension (0xE6)", "self", "::", "parseHexExtensions", "(", "$", "data", ",", "$", "result", ",", "'extension (0xE6)'", ")", ";", "break", ";", "case", "0xa1", ":", "// Hex Extensions extension (0xA1)", "self", "::", "parseHexExtensions", "(", "$", "data", ",", "$", "result", ",", "'extension (0xA1)'", ")", ";", "break", ";", "default", ":", "// Unknown", "$", "result", "[", "]", "=", "'UNKNOWN'", ".", "$", "data", ";", "$", "data", "=", "''", ";", "break", ";", "}", "}", "if", "(", "count", "(", "$", "result", ")", ">", "1", ")", "{", "return", "$", "result", ";", "}", "else", "{", "return", "array_pop", "(", "$", "result", ")", ";", "}", "}" ]
parseASN Retorna a informação requerida do certificado. @param string $data bloco de dados do certificado a ser traduzido @param bool $contextEspecific @return array com o dado do certificado já traduzido
[ "parseASN", "Retorna", "a", "informação", "requerida", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L97-L189
phpnfe/tools
src/Certificado/Asn.php
Asn.parseCommon
protected static function parseCommon($data, &$result) { self::$len = (int) ord($data[1]); $bytes = 0; self::getLength(self::$len, $bytes, (string) $data); $result = substr($data, 2 + $bytes, self::$len); return substr($data, 2 + $bytes + self::$len); }
php
protected static function parseCommon($data, &$result) { self::$len = (int) ord($data[1]); $bytes = 0; self::getLength(self::$len, $bytes, (string) $data); $result = substr($data, 2 + $bytes, self::$len); return substr($data, 2 + $bytes + self::$len); }
[ "protected", "static", "function", "parseCommon", "(", "$", "data", ",", "&", "$", "result", ")", "{", "self", "::", "$", "len", "=", "(", "int", ")", "ord", "(", "$", "data", "[", "1", "]", ")", ";", "$", "bytes", "=", "0", ";", "self", "::", "getLength", "(", "self", "::", "$", "len", ",", "$", "bytes", ",", "(", "string", ")", "$", "data", ")", ";", "$", "result", "=", "substr", "(", "$", "data", ",", "2", "+", "$", "bytes", ",", "self", "::", "$", "len", ")", ";", "return", "substr", "(", "$", "data", ",", "2", "+", "$", "bytes", "+", "self", "::", "$", "len", ")", ";", "}" ]
parseCommon. @param string $data @param string $result @return string
[ "parseCommon", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L197-L205
phpnfe/tools
src/Certificado/Asn.php
Asn.parseBooleanType
protected static function parseBooleanType(&$data, &$result) { // Boolean type $booleanValue = (bool) (ord($data[2]) == 0xff); $dataI = substr($data, 3); $result[] = [ 'boolean (1)', $booleanValue, ]; $data = $dataI; }
php
protected static function parseBooleanType(&$data, &$result) { // Boolean type $booleanValue = (bool) (ord($data[2]) == 0xff); $dataI = substr($data, 3); $result[] = [ 'boolean (1)', $booleanValue, ]; $data = $dataI; }
[ "protected", "static", "function", "parseBooleanType", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Boolean type", "$", "booleanValue", "=", "(", "bool", ")", "(", "ord", "(", "$", "data", "[", "2", "]", ")", "==", "0xff", ")", ";", "$", "dataI", "=", "substr", "(", "$", "data", ",", "3", ")", ";", "$", "result", "[", "]", "=", "[", "'boolean (1)'", ",", "$", "booleanValue", ",", "]", ";", "$", "data", "=", "$", "dataI", ";", "}" ]
parseBooleanType. @param string $data @param array $result @return void
[ "parseBooleanType", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L213-L222
phpnfe/tools
src/Certificado/Asn.php
Asn.parseIntegerType
protected static function parseIntegerType(&$data, &$result) { $dataI = self::parseCommon($data, $integerData); if (self::$len == 16) { $result[] = [ 'integer(' . self::$len . ')', $integerData, ]; } else { $value = 0; if (self::$len <= 4) { // metodo funciona bem para inteiros pequenos for ($i = 0; $i < strlen($integerData); $i++) { $value = ($value << 8) | ord($integerData[$i]); } } else { // metodo trabalha com inteiros arbritrários if (extension_loaded('bcmath')) { for ($i = 0; $i < strlen($integerData); $i++) { $value = bcadd(bcmul($value, 256), ord($integerData[$i])); } } else { $value = -1; } } $result[] = ['integer(' . self::$len . ')', $value]; } $data = $dataI; }
php
protected static function parseIntegerType(&$data, &$result) { $dataI = self::parseCommon($data, $integerData); if (self::$len == 16) { $result[] = [ 'integer(' . self::$len . ')', $integerData, ]; } else { $value = 0; if (self::$len <= 4) { // metodo funciona bem para inteiros pequenos for ($i = 0; $i < strlen($integerData); $i++) { $value = ($value << 8) | ord($integerData[$i]); } } else { // metodo trabalha com inteiros arbritrários if (extension_loaded('bcmath')) { for ($i = 0; $i < strlen($integerData); $i++) { $value = bcadd(bcmul($value, 256), ord($integerData[$i])); } } else { $value = -1; } } $result[] = ['integer(' . self::$len . ')', $value]; } $data = $dataI; }
[ "protected", "static", "function", "parseIntegerType", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "$", "dataI", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "integerData", ")", ";", "if", "(", "self", "::", "$", "len", "==", "16", ")", "{", "$", "result", "[", "]", "=", "[", "'integer('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "integerData", ",", "]", ";", "}", "else", "{", "$", "value", "=", "0", ";", "if", "(", "self", "::", "$", "len", "<=", "4", ")", "{", "// metodo funciona bem para inteiros pequenos", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "integerData", ")", ";", "$", "i", "++", ")", "{", "$", "value", "=", "(", "$", "value", "<<", "8", ")", "|", "ord", "(", "$", "integerData", "[", "$", "i", "]", ")", ";", "}", "}", "else", "{", "// metodo trabalha com inteiros arbritrários", "if", "(", "extension_loaded", "(", "'bcmath'", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "integerData", ")", ";", "$", "i", "++", ")", "{", "$", "value", "=", "bcadd", "(", "bcmul", "(", "$", "value", ",", "256", ")", ",", "ord", "(", "$", "integerData", "[", "$", "i", "]", ")", ")", ";", "}", "}", "else", "{", "$", "value", "=", "-", "1", ";", "}", "}", "$", "result", "[", "]", "=", "[", "'integer('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "value", "]", ";", "}", "$", "data", "=", "$", "dataI", ";", "}" ]
parseIntegerType. @param string $data @param array $result @return void
[ "parseIntegerType", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L230-L257
phpnfe/tools
src/Certificado/Asn.php
Asn.parseHexExtensions
protected static function parseHexExtensions(&$data, &$result, $text) { $extensionData = substr($data, 0, 1); $dataI = substr($data, 1); $result[] = [ $text . ' (' . self::$len . ')', dechex($extensionData), ]; $data = $dataI; }
php
protected static function parseHexExtensions(&$data, &$result, $text) { $extensionData = substr($data, 0, 1); $dataI = substr($data, 1); $result[] = [ $text . ' (' . self::$len . ')', dechex($extensionData), ]; $data = $dataI; }
[ "protected", "static", "function", "parseHexExtensions", "(", "&", "$", "data", ",", "&", "$", "result", ",", "$", "text", ")", "{", "$", "extensionData", "=", "substr", "(", "$", "data", ",", "0", ",", "1", ")", ";", "$", "dataI", "=", "substr", "(", "$", "data", ",", "1", ")", ";", "$", "result", "[", "]", "=", "[", "$", "text", ".", "' ('", ".", "self", "::", "$", "len", ".", "')'", ",", "dechex", "(", "$", "extensionData", ")", ",", "]", ";", "$", "data", "=", "$", "dataI", ";", "}" ]
parseHexExtensions. @param string $data @param array $result @param string $text @return void
[ "parseHexExtensions", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L266-L274
phpnfe/tools
src/Certificado/Asn.php
Asn.parseTimesType
protected static function parseTimesType(&$data, &$result) { // Time types $dataI = self::parseCommon($data, $timeData); $result[] = [ 'utctime (' . self::$len . ')', $timeData, ]; $data = $dataI; }
php
protected static function parseTimesType(&$data, &$result) { // Time types $dataI = self::parseCommon($data, $timeData); $result[] = [ 'utctime (' . self::$len . ')', $timeData, ]; $data = $dataI; }
[ "protected", "static", "function", "parseTimesType", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Time types", "$", "dataI", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "timeData", ")", ";", "$", "result", "[", "]", "=", "[", "'utctime ('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "timeData", ",", "]", ";", "$", "data", "=", "$", "dataI", ";", "}" ]
parseTimesType. @param string $data @param array $result @return void
[ "parseTimesType", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L282-L290
phpnfe/tools
src/Certificado/Asn.php
Asn.parsePrintableString
protected static function parsePrintableString(&$data, &$result) { // Printable string type $data = self::parseCommon($data, $stringData); $result[] = [ 'Printable String (' . self::$len . ')', $stringData, ]; }
php
protected static function parsePrintableString(&$data, &$result) { // Printable string type $data = self::parseCommon($data, $stringData); $result[] = [ 'Printable String (' . self::$len . ')', $stringData, ]; }
[ "protected", "static", "function", "parsePrintableString", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Printable string type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "stringData", ")", ";", "$", "result", "[", "]", "=", "[", "'Printable String ('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "stringData", ",", "]", ";", "}" ]
parsePrintableString. @param string $data @param array $result @return void
[ "parsePrintableString", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L298-L305
phpnfe/tools
src/Certificado/Asn.php
Asn.parseCharString
protected static function parseCharString(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'string (' . self::$len . ')', self::printHex((string) $stringData), ]; }
php
protected static function parseCharString(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'string (' . self::$len . ')', self::printHex((string) $stringData), ]; }
[ "protected", "static", "function", "parseCharString", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Character string type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "stringData", ")", ";", "$", "result", "[", "]", "=", "[", "'string ('", ".", "self", "::", "$", "len", ".", "')'", ",", "self", "::", "printHex", "(", "(", "string", ")", "$", "stringData", ")", ",", "]", ";", "}" ]
parseCharString. @param string $data @param array $result @return void
[ "parseCharString", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L313-L320
phpnfe/tools
src/Certificado/Asn.php
Asn.parseExtensions
protected static function parseExtensions(&$data, &$result, $text) { // Extensions $data = self::parseCommon($data, $extensionData); $result[] = [ "$text (" . self::$len . ')', [self::parseASN((string) $extensionData, true)], ]; }
php
protected static function parseExtensions(&$data, &$result, $text) { // Extensions $data = self::parseCommon($data, $extensionData); $result[] = [ "$text (" . self::$len . ')', [self::parseASN((string) $extensionData, true)], ]; }
[ "protected", "static", "function", "parseExtensions", "(", "&", "$", "data", ",", "&", "$", "result", ",", "$", "text", ")", "{", "// Extensions", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "extensionData", ")", ";", "$", "result", "[", "]", "=", "[", "\"$text (\"", ".", "self", "::", "$", "len", ".", "')'", ",", "[", "self", "::", "parseASN", "(", "(", "string", ")", "$", "extensionData", ",", "true", ")", "]", ",", "]", ";", "}" ]
parseExtensions. @param string $data @param array $result @param string $text @return void
[ "parseExtensions", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L329-L336
phpnfe/tools
src/Certificado/Asn.php
Asn.parseSequence
protected static function parseSequence(&$data, &$result) { // Sequence $data = self::parseCommon($data, $sequenceData); $values = self::parseASN((string) $sequenceData); if (! is_array($values) || is_string($values[0])) { $values = [$values]; } $result[] = [ 'sequence (' . self::$len . ')', $values, ]; }
php
protected static function parseSequence(&$data, &$result) { // Sequence $data = self::parseCommon($data, $sequenceData); $values = self::parseASN((string) $sequenceData); if (! is_array($values) || is_string($values[0])) { $values = [$values]; } $result[] = [ 'sequence (' . self::$len . ')', $values, ]; }
[ "protected", "static", "function", "parseSequence", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Sequence", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "sequenceData", ")", ";", "$", "values", "=", "self", "::", "parseASN", "(", "(", "string", ")", "$", "sequenceData", ")", ";", "if", "(", "!", "is_array", "(", "$", "values", ")", "||", "is_string", "(", "$", "values", "[", "0", "]", ")", ")", "{", "$", "values", "=", "[", "$", "values", "]", ";", "}", "$", "result", "[", "]", "=", "[", "'sequence ('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "values", ",", "]", ";", "}" ]
parseSequence. @param string $data @param array $result @return void
[ "parseSequence", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L344-L355
phpnfe/tools
src/Certificado/Asn.php
Asn.parseOIDtype
protected static function parseOIDtype(&$data, &$result) { // Object identifier type $data = self::parseCommon($data, $oidData); // Unpack the OID $plain = floor(ord($oidData[0]) / 40); $plain .= '.' . ord($oidData[0]) % 40; $value = 0; $iCount = 1; while ($iCount < strlen($oidData)) { $value = $value << 7; $value = $value | (ord($oidData[$iCount]) & 0x7f); if (! (ord($oidData[$iCount]) & 0x80)) { $plain .= '.' . $value; $value = 0; } $iCount++; } $oidResp = Oids::getOid($plain); if ($oidResp) { $result[] = [ 'oid(' . self::$len . '): ' . $plain, $oidResp, ]; } else { $result[] = [ 'oid(' . self::$len . '): ' . $plain, $plain, ]; } }
php
protected static function parseOIDtype(&$data, &$result) { // Object identifier type $data = self::parseCommon($data, $oidData); // Unpack the OID $plain = floor(ord($oidData[0]) / 40); $plain .= '.' . ord($oidData[0]) % 40; $value = 0; $iCount = 1; while ($iCount < strlen($oidData)) { $value = $value << 7; $value = $value | (ord($oidData[$iCount]) & 0x7f); if (! (ord($oidData[$iCount]) & 0x80)) { $plain .= '.' . $value; $value = 0; } $iCount++; } $oidResp = Oids::getOid($plain); if ($oidResp) { $result[] = [ 'oid(' . self::$len . '): ' . $plain, $oidResp, ]; } else { $result[] = [ 'oid(' . self::$len . '): ' . $plain, $plain, ]; } }
[ "protected", "static", "function", "parseOIDtype", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Object identifier type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "oidData", ")", ";", "// Unpack the OID", "$", "plain", "=", "floor", "(", "ord", "(", "$", "oidData", "[", "0", "]", ")", "/", "40", ")", ";", "$", "plain", ".=", "'.'", ".", "ord", "(", "$", "oidData", "[", "0", "]", ")", "%", "40", ";", "$", "value", "=", "0", ";", "$", "iCount", "=", "1", ";", "while", "(", "$", "iCount", "<", "strlen", "(", "$", "oidData", ")", ")", "{", "$", "value", "=", "$", "value", "<<", "7", ";", "$", "value", "=", "$", "value", "|", "(", "ord", "(", "$", "oidData", "[", "$", "iCount", "]", ")", "&", "0x7f", ")", ";", "if", "(", "!", "(", "ord", "(", "$", "oidData", "[", "$", "iCount", "]", ")", "&", "0x80", ")", ")", "{", "$", "plain", ".=", "'.'", ".", "$", "value", ";", "$", "value", "=", "0", ";", "}", "$", "iCount", "++", ";", "}", "$", "oidResp", "=", "Oids", "::", "getOid", "(", "$", "plain", ")", ";", "if", "(", "$", "oidResp", ")", "{", "$", "result", "[", "]", "=", "[", "'oid('", ".", "self", "::", "$", "len", ".", "'): '", ".", "$", "plain", ",", "$", "oidResp", ",", "]", ";", "}", "else", "{", "$", "result", "[", "]", "=", "[", "'oid('", ".", "self", "::", "$", "len", ".", "'): '", ".", "$", "plain", ",", "$", "plain", ",", "]", ";", "}", "}" ]
parseOIDtype. @param string $data @param array $result @return void
[ "parseOIDtype", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L363-L391
phpnfe/tools
src/Certificado/Asn.php
Asn.parseSetOf
protected static function parseSetOf(&$data, &$result) { $data = self::parseCommon($data, $sequenceData); $result[] = [ 'set (' . self::$len . ')', self::parseASN((string) $sequenceData), ]; }
php
protected static function parseSetOf(&$data, &$result) { $data = self::parseCommon($data, $sequenceData); $result[] = [ 'set (' . self::$len . ')', self::parseASN((string) $sequenceData), ]; }
[ "protected", "static", "function", "parseSetOf", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "sequenceData", ")", ";", "$", "result", "[", "]", "=", "[", "'set ('", ".", "self", "::", "$", "len", ".", "')'", ",", "self", "::", "parseASN", "(", "(", "string", ")", "$", "sequenceData", ")", ",", "]", ";", "}" ]
parseSetOf. @param string $data @param array $result @return void
[ "parseSetOf", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L399-L405
phpnfe/tools
src/Certificado/Asn.php
Asn.parseOctetSting
protected static function parseOctetSting(&$data, &$result, $contextEspecific) { // Octetstring type $data = self::parseCommon($data, $octectstringData); if ($contextEspecific) { $result[] = [ 'octet string(' . self::$len . ')', $octectstringData, ]; } else { $result[] = [ 'octet string (' . self::$len . ')', self::parseASN((string) $octectstringData), ]; } }
php
protected static function parseOctetSting(&$data, &$result, $contextEspecific) { // Octetstring type $data = self::parseCommon($data, $octectstringData); if ($contextEspecific) { $result[] = [ 'octet string(' . self::$len . ')', $octectstringData, ]; } else { $result[] = [ 'octet string (' . self::$len . ')', self::parseASN((string) $octectstringData), ]; } }
[ "protected", "static", "function", "parseOctetSting", "(", "&", "$", "data", ",", "&", "$", "result", ",", "$", "contextEspecific", ")", "{", "// Octetstring type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "octectstringData", ")", ";", "if", "(", "$", "contextEspecific", ")", "{", "$", "result", "[", "]", "=", "[", "'octet string('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "octectstringData", ",", "]", ";", "}", "else", "{", "$", "result", "[", "]", "=", "[", "'octet string ('", ".", "self", "::", "$", "len", ".", "')'", ",", "self", "::", "parseASN", "(", "(", "string", ")", "$", "octectstringData", ")", ",", "]", ";", "}", "}" ]
parseOctetSting. @param string $data @param array $result @param bool $contextEspecific @return void
[ "parseOctetSting", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L414-L427
phpnfe/tools
src/Certificado/Asn.php
Asn.parseIA5String
protected static function parseIA5String(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'IA5 String (' . self::$len . ')', $stringData, ]; }
php
protected static function parseIA5String(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'IA5 String (' . self::$len . ')', $stringData, ]; }
[ "protected", "static", "function", "parseIA5String", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Character string type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "stringData", ")", ";", "$", "result", "[", "]", "=", "[", "'IA5 String ('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "stringData", ",", "]", ";", "}" ]
parseIA5String. @param string $data @param array $result @return void
[ "parseIA5String", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L457-L464
phpnfe/tools
src/Certificado/Asn.php
Asn.parseString
protected static function parseString(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'string (' . self::$len . ')', $stringData, ]; }
php
protected static function parseString(&$data, &$result) { // Character string type $data = self::parseCommon($data, $stringData); $result[] = [ 'string (' . self::$len . ')', $stringData, ]; }
[ "protected", "static", "function", "parseString", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Character string type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "stringData", ")", ";", "$", "result", "[", "]", "=", "[", "'string ('", ".", "self", "::", "$", "len", ".", "')'", ",", "$", "stringData", ",", "]", ";", "}" ]
parseString. @param string $data @param array $result @return void
[ "parseString", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L472-L479
phpnfe/tools
src/Certificado/Asn.php
Asn.parseBitString
protected static function parseBitString(&$data, &$result) { // Bitstring type $data = self::parseCommon($data, $bitstringData); $result[] = [ 'bit string (' . self::$len . ')', 'UnsedBits:' . ord($bitstringData[0]) . ':' . ord($bitstringData[1]), ]; }
php
protected static function parseBitString(&$data, &$result) { // Bitstring type $data = self::parseCommon($data, $bitstringData); $result[] = [ 'bit string (' . self::$len . ')', 'UnsedBits:' . ord($bitstringData[0]) . ':' . ord($bitstringData[1]), ]; }
[ "protected", "static", "function", "parseBitString", "(", "&", "$", "data", ",", "&", "$", "result", ")", "{", "// Bitstring type", "$", "data", "=", "self", "::", "parseCommon", "(", "$", "data", ",", "$", "bitstringData", ")", ";", "$", "result", "[", "]", "=", "[", "'bit string ('", ".", "self", "::", "$", "len", ".", "')'", ",", "'UnsedBits:'", ".", "ord", "(", "$", "bitstringData", "[", "0", "]", ")", ".", "':'", ".", "ord", "(", "$", "bitstringData", "[", "1", "]", ")", ",", "]", ";", "}" ]
parseBitString. @param string $data @param array $result @return void
[ "parseBitString", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Asn.php#L487-L494
surebert/surebert-framework
src/sb/XMPP/Message.php
Message.setBody
public function setBody($body) { $node = $this->getBody(false); if(!$node){ $node = $this->createElement('body'); $this->doc->appendChild($node); } $node->nodeValue = htmlspecialchars($body); }
php
public function setBody($body) { $node = $this->getBody(false); if(!$node){ $node = $this->createElement('body'); $this->doc->appendChild($node); } $node->nodeValue = htmlspecialchars($body); }
[ "public", "function", "setBody", "(", "$", "body", ")", "{", "$", "node", "=", "$", "this", "->", "getBody", "(", "false", ")", ";", "if", "(", "!", "$", "node", ")", "{", "$", "node", "=", "$", "this", "->", "createElement", "(", "'body'", ")", ";", "$", "this", "->", "doc", "->", "appendChild", "(", "$", "node", ")", ";", "}", "$", "node", "->", "nodeValue", "=", "htmlspecialchars", "(", "$", "body", ")", ";", "}" ]
Sets the body of the message to be send @param string $body
[ "Sets", "the", "body", "of", "the", "message", "to", "be", "send" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L104-L112
surebert/surebert-framework
src/sb/XMPP/Message.php
Message.setSubject
public function setSubject($subject) { $node = $this->getSubject(false); if(!$node){ $node = $this->createElement('subject'); $this->doc->appendChild($node); } $node->nodeValue = htmlspecialchars($subject); }
php
public function setSubject($subject) { $node = $this->getSubject(false); if(!$node){ $node = $this->createElement('subject'); $this->doc->appendChild($node); } $node->nodeValue = htmlspecialchars($subject); }
[ "public", "function", "setSubject", "(", "$", "subject", ")", "{", "$", "node", "=", "$", "this", "->", "getSubject", "(", "false", ")", ";", "if", "(", "!", "$", "node", ")", "{", "$", "node", "=", "$", "this", "->", "createElement", "(", "'subject'", ")", ";", "$", "this", "->", "doc", "->", "appendChild", "(", "$", "node", ")", ";", "}", "$", "node", "->", "nodeValue", "=", "htmlspecialchars", "(", "$", "subject", ")", ";", "}" ]
Set the subject of the message @param string $subject
[ "Set", "the", "subject", "of", "the", "message" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L118-L126
surebert/surebert-framework
src/sb/XMPP/Message.php
Message.setHTML
public function setHTML($html) { $node = $this->createDocumentFragment(); $node->appendXML('<html xmlns="http://www.w3.org/1999/xhtml">'.$html.'</html>'); $this->doc->appendChild($node); }
php
public function setHTML($html) { $node = $this->createDocumentFragment(); $node->appendXML('<html xmlns="http://www.w3.org/1999/xhtml">'.$html.'</html>'); $this->doc->appendChild($node); }
[ "public", "function", "setHTML", "(", "$", "html", ")", "{", "$", "node", "=", "$", "this", "->", "createDocumentFragment", "(", ")", ";", "$", "node", "->", "appendXML", "(", "'<html xmlns=\"http://www.w3.org/1999/xhtml\">'", ".", "$", "html", ".", "'</html>'", ")", ";", "$", "this", "->", "doc", "->", "appendChild", "(", "$", "node", ")", ";", "}" ]
Sets the html node of the message, expiremental @param string $html
[ "Sets", "the", "html", "node", "of", "the", "message", "expiremental" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L132-L137
surebert/surebert-framework
src/sb/XMPP/Message.php
Message.reply
public function reply($str) { $message = new \sb\XMPP\Message(); $message->setTo($this->getFrom()); $message->setFrom($this->getTo()); $message->setBody($str); $this->client->sendMessage($message); }
php
public function reply($str) { $message = new \sb\XMPP\Message(); $message->setTo($this->getFrom()); $message->setFrom($this->getTo()); $message->setBody($str); $this->client->sendMessage($message); }
[ "public", "function", "reply", "(", "$", "str", ")", "{", "$", "message", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Message", "(", ")", ";", "$", "message", "->", "setTo", "(", "$", "this", "->", "getFrom", "(", ")", ")", ";", "$", "message", "->", "setFrom", "(", "$", "this", "->", "getTo", "(", ")", ")", ";", "$", "message", "->", "setBody", "(", "$", "str", ")", ";", "$", "this", "->", "client", "->", "sendMessage", "(", "$", "message", ")", ";", "}" ]
Creates a reply message and sends it to the user that sent the original message. This can be used only on \sb\XMPP\Message instances that came over the socket and were passed to the onMessage method. @param string $str
[ "Creates", "a", "reply", "message", "and", "sends", "it", "to", "the", "user", "that", "sent", "the", "original", "message", ".", "This", "can", "be", "used", "only", "on", "\\", "sb", "\\", "XMPP", "\\", "Message", "instances", "that", "came", "over", "the", "socket", "and", "were", "passed", "to", "the", "onMessage", "method", "." ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L145-L152
ekuiter/feature-php
FeaturePhp/Helper/Logic.php
Logic.is
public static function is($feature) { return function ($features) use ($feature) { return fphp\Model\Feature::has($features, $feature); }; }
php
public static function is($feature) { return function ($features) use ($feature) { return fphp\Model\Feature::has($features, $feature); }; }
[ "public", "static", "function", "is", "(", "$", "feature", ")", "{", "return", "function", "(", "$", "features", ")", "use", "(", "$", "feature", ")", "{", "return", "fphp", "\\", "Model", "\\", "Feature", "::", "has", "(", "$", "features", ",", "$", "feature", ")", ";", "}", ";", "}" ]
Returns a formula that tests for the presence of a feature. @param Feature $feature @return callable
[ "Returns", "a", "formula", "that", "tests", "for", "the", "presence", "of", "a", "feature", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L27-L31
ekuiter/feature-php
FeaturePhp/Helper/Logic.php
Logic._and
public static function _and(/* ... */) { $args = func_get_args(); return function ($features) use ($args) { $acc = true; foreach ($args as $arg) $acc = $acc && $arg($features); return $acc; }; }
php
public static function _and(/* ... */) { $args = func_get_args(); return function ($features) use ($args) { $acc = true; foreach ($args as $arg) $acc = $acc && $arg($features); return $acc; }; }
[ "public", "static", "function", "_and", "(", "/* ... */", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "function", "(", "$", "features", ")", "use", "(", "$", "args", ")", "{", "$", "acc", "=", "true", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "$", "acc", "=", "$", "acc", "&&", "$", "arg", "(", "$", "features", ")", ";", "return", "$", "acc", ";", "}", ";", "}" ]
Returns a formula that is the conjunction of other formulas. Formulas can be supplied variadically. @return callable
[ "Returns", "a", "formula", "that", "is", "the", "conjunction", "of", "other", "formulas", ".", "Formulas", "can", "be", "supplied", "variadically", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L49-L57
ekuiter/feature-php
FeaturePhp/Helper/Logic.php
Logic._or
public static function _or(/* ... */) { $args = func_get_args(); return function ($features) use ($args) { $acc = false; foreach ($args as $arg) $acc = $acc || $arg($features); return $acc; }; }
php
public static function _or(/* ... */) { $args = func_get_args(); return function ($features) use ($args) { $acc = false; foreach ($args as $arg) $acc = $acc || $arg($features); return $acc; }; }
[ "public", "static", "function", "_or", "(", "/* ... */", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "function", "(", "$", "features", ")", "use", "(", "$", "args", ")", "{", "$", "acc", "=", "false", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "$", "acc", "=", "$", "acc", "||", "$", "arg", "(", "$", "features", ")", ";", "return", "$", "acc", ";", "}", ";", "}" ]
Returns a formula that is the disjunction of other formulas. Formulas can be supplied variadically. @return callable
[ "Returns", "a", "formula", "that", "is", "the", "disjunction", "of", "other", "formulas", ".", "Formulas", "can", "be", "supplied", "variadically", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L64-L72
ekuiter/feature-php
FeaturePhp/Helper/Logic.php
Logic.equiv
public static function equiv($constraintA, $constraintB) { return function ($features) use ($constraintA, $constraintB) { return $constraintA($features) === $constraintB($features); }; }
php
public static function equiv($constraintA, $constraintB) { return function ($features) use ($constraintA, $constraintB) { return $constraintA($features) === $constraintB($features); }; }
[ "public", "static", "function", "equiv", "(", "$", "constraintA", ",", "$", "constraintB", ")", "{", "return", "function", "(", "$", "features", ")", "use", "(", "$", "constraintA", ",", "$", "constraintB", ")", "{", "return", "$", "constraintA", "(", "$", "features", ")", "===", "$", "constraintB", "(", "$", "features", ")", ";", "}", ";", "}" ]
Returns a formula that is the biconditional of two formulas. @param callable $constraintA @param callable $constraintB @return callable
[ "Returns", "a", "formula", "that", "is", "the", "biconditional", "of", "two", "formulas", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L80-L84
ekuiter/feature-php
FeaturePhp/Helper/Logic.php
Logic.implies
public static function implies($constraintA, $constraintB) { return function ($features) use ($constraintA, $constraintB) { return !$constraintA($features) || $constraintB($features); }; }
php
public static function implies($constraintA, $constraintB) { return function ($features) use ($constraintA, $constraintB) { return !$constraintA($features) || $constraintB($features); }; }
[ "public", "static", "function", "implies", "(", "$", "constraintA", ",", "$", "constraintB", ")", "{", "return", "function", "(", "$", "features", ")", "use", "(", "$", "constraintA", ",", "$", "constraintB", ")", "{", "return", "!", "$", "constraintA", "(", "$", "features", ")", "||", "$", "constraintB", "(", "$", "features", ")", ";", "}", ";", "}" ]
Returns a formula that is the material conditional of two formulas. @param callable $constraintA @param callable $constraintB @return callable
[ "Returns", "a", "formula", "that", "is", "the", "material", "conditional", "of", "two", "formulas", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L92-L96