repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
samsonos/social_network
Network.php
Network.init
public function init(array $params = array()) { // Try to load token from session if (isset($_SESSION[self::SESSION_PREFIX.'_'.$this->id])) { $this->token = $_SESSION[self::SESSION_PREFIX.'_'.$this->id]; } parent::init($params); }
php
public function init(array $params = array()) { // Try to load token from session if (isset($_SESSION[self::SESSION_PREFIX.'_'.$this->id])) { $this->token = $_SESSION[self::SESSION_PREFIX.'_'.$this->id]; } parent::init($params); }
[ "public", "function", "init", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "// Try to load token from session", "if", "(", "isset", "(", "$", "_SESSION", "[", "self", "::", "SESSION_PREFIX", ".", "'_'", ".", "$", "this", "->", "id", "]"...
Social network initialization
[ "Social", "network", "initialization" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L102-L110
train
samsonos/social_network
Network.php
Network.setUser
protected function setUser(array $userData, & $user = null) { // Generic birthdate parsing $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday)); // If no external user is passed set as current user if (isset($user)) { $this->user = & $user; } }
php
protected function setUser(array $userData, & $user = null) { // Generic birthdate parsing $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday)); // If no external user is passed set as current user if (isset($user)) { $this->user = & $user; } }
[ "protected", "function", "setUser", "(", "array", "$", "userData", ",", "&", "$", "user", "=", "null", ")", "{", "// Generic birthdate parsing", "$", "user", "->", "birthday", "=", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "user", "->", "bi...
Fill object User @param array $userData Answer of social network @param mixed $user Pointer to user object for filling
[ "Fill", "object", "User" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L118-L127
train
samsonos/social_network
Network.php
Network.&
protected function & storeUserData(&$user = null) { // If no user is passed - create it if (!isset($user)) { $user = new $this->dbTable(false); } // Store social data for user $user[$this->dbIdField] = $this->user->socialID; $user[$this->dbNameField] = strlen($this->user->name) ? $this->user->name : $user[$this->dbNameField]; $user[$this->dbSurnameField] = strlen($this->user->surname) ? $this->user->surname : $user[$this->dbSurnameField] ; $user[$this->dbGenderField] = strlen($this->user->gender) ? $this->user->gender : $user[$this->dbGenderField] ; $user[$this->dbBirthdayField] = max($user[$this->dbBirthdayField],$this->user->birthday); $user[$this->dbPhotoField] = strlen($this->user->photo) ? $this->user->photo : $user[$this->dbPhotoField]; // If no email is passed - set hashed socialID as email if (!strlen($this->user->email)) { if (!strlen($user->email)) { $user[$this->dbEmailField] = md5($this->user->socialID); } } else { $user[$this->dbEmailField] = $this->user->email; } $user->save(); return $user; }
php
protected function & storeUserData(&$user = null) { // If no user is passed - create it if (!isset($user)) { $user = new $this->dbTable(false); } // Store social data for user $user[$this->dbIdField] = $this->user->socialID; $user[$this->dbNameField] = strlen($this->user->name) ? $this->user->name : $user[$this->dbNameField]; $user[$this->dbSurnameField] = strlen($this->user->surname) ? $this->user->surname : $user[$this->dbSurnameField] ; $user[$this->dbGenderField] = strlen($this->user->gender) ? $this->user->gender : $user[$this->dbGenderField] ; $user[$this->dbBirthdayField] = max($user[$this->dbBirthdayField],$this->user->birthday); $user[$this->dbPhotoField] = strlen($this->user->photo) ? $this->user->photo : $user[$this->dbPhotoField]; // If no email is passed - set hashed socialID as email if (!strlen($this->user->email)) { if (!strlen($user->email)) { $user[$this->dbEmailField] = md5($this->user->socialID); } } else { $user[$this->dbEmailField] = $this->user->email; } $user->save(); return $user; }
[ "protected", "function", "&", "storeUserData", "(", "&", "$", "user", "=", "null", ")", "{", "// If no user is passed - create it", "if", "(", "!", "isset", "(", "$", "user", ")", ")", "{", "$", "user", "=", "new", "$", "this", "->", "dbTable", "(", "f...
Store current social user data in database @param \samson\activerecord\dbRecord $user @return \samson\activerecord\dbRecord Stored user database record
[ "Store", "current", "social", "user", "data", "in", "database" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L184-L211
train
samsonos/social_network
Network.php
Network.&
public function & friends($count = null, $offset = null) { $result = array(); // If we have authorized via one of social modules if (isset($this->active)) { // Call friends method on active social module $result = & $this->active->friends($count, $offset); } return $result; }
php
public function & friends($count = null, $offset = null) { $result = array(); // If we have authorized via one of social modules if (isset($this->active)) { // Call friends method on active social module $result = & $this->active->friends($count, $offset); } return $result; }
[ "public", "function", "&", "friends", "(", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// If we have authorized via one of social modules", "if", "(", "isset", "(", "$", "this", "->", ...
Get user fiends list @param integer $count Friends count @param integer $offset Friends offset @return User[] Collection of user friends objects
[ "Get", "user", "fiends", "list" ]
3700cf526fa58692d89247141e3f0f04bb5ec759
https://github.com/samsonos/social_network/blob/3700cf526fa58692d89247141e3f0f04bb5ec759/Network.php#L265-L276
train
bishopb/vanilla
applications/dashboard/models/class.spammodel.php
SpamModel.IsSpam
public static function IsSpam($RecordType, $Data, $Options = array()) { if (self::$Disabled) return FALSE; // Set some information about the user in the data. if ($RecordType == 'Registration') { TouchValue('Username', $Data, $Data['Name']); } else { TouchValue('InsertUserID', $Data, Gdn::Session()->UserID); $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY); if ($User) { if (GetValue('Verified', $User)) { // The user has been verified and isn't a spammer. return FALSE; } TouchValue('Username', $Data, $User['Name']); TouchValue('Email', $Data, $User['Email']); TouchValue('IPAddress', $Data, $User['LastIPAddress']); } } if (!isset($Data['Body']) && isset($Data['Story'])) { $Data['Body'] = $Data['Story']; } TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress()); $Sp = self::_Instance(); $Sp->EventArguments['RecordType'] = $RecordType; $Sp->EventArguments['Data'] =& $Data; $Sp->EventArguments['Options'] =& $Options; $Sp->EventArguments['IsSpam'] = FALSE; $Sp->FireEvent('CheckSpam'); $Spam = $Sp->EventArguments['IsSpam']; // Log the spam entry. if ($Spam && GetValue('Log', $Options, TRUE)) { $LogOptions = array(); switch ($RecordType) { case 'Registration': $LogOptions['GroupBy'] = array('RecordIPAddress'); break; case 'Comment': case 'Discussion': case 'Activity': case 'ActivityComment': $LogOptions['GroupBy'] = array('RecordID'); break; } LogModel::Insert('Spam', $RecordType, $Data, $LogOptions); } return $Spam; }
php
public static function IsSpam($RecordType, $Data, $Options = array()) { if (self::$Disabled) return FALSE; // Set some information about the user in the data. if ($RecordType == 'Registration') { TouchValue('Username', $Data, $Data['Name']); } else { TouchValue('InsertUserID', $Data, Gdn::Session()->UserID); $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY); if ($User) { if (GetValue('Verified', $User)) { // The user has been verified and isn't a spammer. return FALSE; } TouchValue('Username', $Data, $User['Name']); TouchValue('Email', $Data, $User['Email']); TouchValue('IPAddress', $Data, $User['LastIPAddress']); } } if (!isset($Data['Body']) && isset($Data['Story'])) { $Data['Body'] = $Data['Story']; } TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress()); $Sp = self::_Instance(); $Sp->EventArguments['RecordType'] = $RecordType; $Sp->EventArguments['Data'] =& $Data; $Sp->EventArguments['Options'] =& $Options; $Sp->EventArguments['IsSpam'] = FALSE; $Sp->FireEvent('CheckSpam'); $Spam = $Sp->EventArguments['IsSpam']; // Log the spam entry. if ($Spam && GetValue('Log', $Options, TRUE)) { $LogOptions = array(); switch ($RecordType) { case 'Registration': $LogOptions['GroupBy'] = array('RecordIPAddress'); break; case 'Comment': case 'Discussion': case 'Activity': case 'ActivityComment': $LogOptions['GroupBy'] = array('RecordID'); break; } LogModel::Insert('Spam', $RecordType, $Data, $LogOptions); } return $Spam; }
[ "public", "static", "function", "IsSpam", "(", "$", "RecordType", ",", "$", "Data", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "if", "(", "self", "::", "$", "Disabled", ")", "return", "FALSE", ";", "// Set some information about the user in the d...
Check whether or not the record is spam. @param string $RecordType By default, this should be one of the following: - Comment: A comment. - Discussion: A discussion. - User: A user registration. @param array $Data The record data. @param array $Options Options for fine-tuning this method call. - Log: Log the record if it is found to be spam.
[ "Check", "whether", "or", "not", "the", "record", "is", "spam", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.spammodel.php#L33-L91
train
gourmet/common
Lib/Navigation.php
Navigation.clear
public static function clear($path = null) { if (empty($path)) { self::$_items = array(); return; } if (Hash::check(self::$_items, $path)) { self::$_items = Hash::insert(self::$_items, $path, array()); } }
php
public static function clear($path = null) { if (empty($path)) { self::$_items = array(); return; } if (Hash::check(self::$_items, $path)) { self::$_items = Hash::insert(self::$_items, $path, array()); } }
[ "public", "static", "function", "clear", "(", "$", "path", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "self", "::", "$", "_items", "=", "array", "(", ")", ";", "return", ";", "}", "if", "(", "Hash", "::", "check...
Clear all menus. @return void
[ "Clear", "all", "menus", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Lib/Navigation.php#L94-L103
train
gourmet/common
Lib/Navigation.php
Navigation.order
public static function order($items) { if (empty($items)) { return array(); } $_items = array_combine(array_keys($items), Hash::extract($items, '{s}.weight')); asort($_items); foreach (array_keys($_items) as $key) { $_items[$key] = $items[$key]; } return $items; }
php
public static function order($items) { if (empty($items)) { return array(); } $_items = array_combine(array_keys($items), Hash::extract($items, '{s}.weight')); asort($_items); foreach (array_keys($_items) as $key) { $_items[$key] = $items[$key]; } return $items; }
[ "public", "static", "function", "order", "(", "$", "items", ")", "{", "if", "(", "empty", "(", "$", "items", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "_items", "=", "array_combine", "(", "array_keys", "(", "$", "items", ")", ",", ...
Orders items by weight. @param array $items @return array
[ "Orders", "items", "by", "weight", "." ]
53ad4e919c51606dc81f2c716267d01ee768ade5
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Lib/Navigation.php#L142-L155
train
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.findMultiple
public function findMultiple($classes = [], $interfaces = [], $traits = []) { $this->init(); $classes = $this->normalizeArray($classes); $interfaces = $this->normalizeArray($interfaces); $traits = $this->normalizeArray($traits); $foundClasses = []; if ($classes !== false) { foreach ($classes as $class) { $foundClasses = array_merge($foundClasses, $this->findExtends($class)); } } if ($interfaces !== false) { foreach ($interfaces as $interface) { $foundClasses = array_merge($foundClasses, $this->findImplements($interface)); } } if ($traits !== false) { foreach ($traits as $trait) { $foundClasses = array_merge($foundClasses, $this->findTraitUse($trait)); } } return $this->arrayUniqueObject($foundClasses); }
php
public function findMultiple($classes = [], $interfaces = [], $traits = []) { $this->init(); $classes = $this->normalizeArray($classes); $interfaces = $this->normalizeArray($interfaces); $traits = $this->normalizeArray($traits); $foundClasses = []; if ($classes !== false) { foreach ($classes as $class) { $foundClasses = array_merge($foundClasses, $this->findExtends($class)); } } if ($interfaces !== false) { foreach ($interfaces as $interface) { $foundClasses = array_merge($foundClasses, $this->findImplements($interface)); } } if ($traits !== false) { foreach ($traits as $trait) { $foundClasses = array_merge($foundClasses, $this->findTraitUse($trait)); } } return $this->arrayUniqueObject($foundClasses); }
[ "public", "function", "findMultiple", "(", "$", "classes", "=", "[", "]", ",", "$", "interfaces", "=", "[", "]", ",", "$", "traits", "=", "[", "]", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "classes", "=", "$", "this", "->", "nor...
Can find multiple classes at once. @param array $classes @param array $interfaces @param array $traits @return PhpClass[]
[ "Can", "find", "multiple", "classes", "at", "once", "." ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L126-L154
train
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.findImplementsOrTraitUse
protected function findImplementsOrTraitUse($fullQualifiedNamespace, $type) { $fullQualifiedNamespace = $this->trimNamespace($fullQualifiedNamespace); $phpClasses = []; $method = 'get' . ucfirst($type); foreach ($this->localCache as $phpClass) { $implementsOrTrait = $phpClass->$method(); if (is_array($implementsOrTrait) && in_array($fullQualifiedNamespace, $implementsOrTrait)) { $phpClasses[] = $phpClass; $phpClasses = array_merge($phpClasses, $this->findExtends($phpClass->getFullQualifiedNamespace())); } } return $this->arrayUniqueObject($phpClasses); }
php
protected function findImplementsOrTraitUse($fullQualifiedNamespace, $type) { $fullQualifiedNamespace = $this->trimNamespace($fullQualifiedNamespace); $phpClasses = []; $method = 'get' . ucfirst($type); foreach ($this->localCache as $phpClass) { $implementsOrTrait = $phpClass->$method(); if (is_array($implementsOrTrait) && in_array($fullQualifiedNamespace, $implementsOrTrait)) { $phpClasses[] = $phpClass; $phpClasses = array_merge($phpClasses, $this->findExtends($phpClass->getFullQualifiedNamespace())); } } return $this->arrayUniqueObject($phpClasses); }
[ "protected", "function", "findImplementsOrTraitUse", "(", "$", "fullQualifiedNamespace", ",", "$", "type", ")", "{", "$", "fullQualifiedNamespace", "=", "$", "this", "->", "trimNamespace", "(", "$", "fullQualifiedNamespace", ")", ";", "$", "phpClasses", "=", "[", ...
Can find implements or detect trait use @param $fullQualifiedNamespace @param $type @return PhpClass[]
[ "Can", "find", "implements", "or", "detect", "trait", "use" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L163-L179
train
synga-nl/inheritance-finder
src/InheritanceFinder.php
InheritanceFinder.arrayUniqueObject
protected function arrayUniqueObject($phpClasses) { $hashes = []; foreach ($phpClasses as $key => $phpClass) { $hashes[$key] = spl_object_hash($phpClass); } $hashes = array_unique($hashes); $uniqueArray = []; foreach ($hashes as $key => $hash) { $uniqueArray[$key] = $phpClasses[$key]; } return $uniqueArray; }
php
protected function arrayUniqueObject($phpClasses) { $hashes = []; foreach ($phpClasses as $key => $phpClass) { $hashes[$key] = spl_object_hash($phpClass); } $hashes = array_unique($hashes); $uniqueArray = []; foreach ($hashes as $key => $hash) { $uniqueArray[$key] = $phpClasses[$key]; } return $uniqueArray; }
[ "protected", "function", "arrayUniqueObject", "(", "$", "phpClasses", ")", "{", "$", "hashes", "=", "[", "]", ";", "foreach", "(", "$", "phpClasses", "as", "$", "key", "=>", "$", "phpClass", ")", "{", "$", "hashes", "[", "$", "key", "]", "=", "spl_ob...
Makes an array of object unique using the spl_object_hash function @param $phpClasses @return array
[ "Makes", "an", "array", "of", "object", "unique", "using", "the", "spl_object_hash", "function" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/InheritanceFinder.php#L187-L203
train
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/AbstractArray.php
AbstractArray.getValue
public function getValue($key) { if (isset ( $this->a [$key] )) { return $this->a [$key]; } else { return NULL; } }
php
public function getValue($key) { if (isset ( $this->a [$key] )) { return $this->a [$key]; } else { return NULL; } }
[ "public", "function", "getValue", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "a", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "a", "[", "$", "key", "]", ";", "}", "else", "{", "return", "NULL"...
Getter method for a specific value referenced by the given key. @param string $key
[ "Getter", "method", "for", "a", "specific", "value", "referenced", "by", "the", "given", "key", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/AbstractArray.php#L67-L73
train
SocietyCMS/Core
Utilities/Localization/Generators/LangJsGenerator.php
LangJsGenerator.getMessagesFromSourcePath
protected function getMessagesFromSourcePath($path, $namespace) { $messages = []; if (! $this->file->exists($path)) { throw new \Exception("${path} doesn't exists!"); } foreach ($this->file->allFiles($path) as $file) { $pathName = $file->getRelativePathName(); if ($this->file->extension($pathName) !== 'php') { continue; } $key = substr($pathName, 0, -4); $key = str_replace('\\', '.', $key); $key = str_replace('/', '.', $key); $array = explode('.', $key, 2); $keyWithNamespace = $array[0].'.'.$namespace.'::'.$array[1]; $messages[$keyWithNamespace] = include "${path}/${pathName}"; } return $messages; }
php
protected function getMessagesFromSourcePath($path, $namespace) { $messages = []; if (! $this->file->exists($path)) { throw new \Exception("${path} doesn't exists!"); } foreach ($this->file->allFiles($path) as $file) { $pathName = $file->getRelativePathName(); if ($this->file->extension($pathName) !== 'php') { continue; } $key = substr($pathName, 0, -4); $key = str_replace('\\', '.', $key); $key = str_replace('/', '.', $key); $array = explode('.', $key, 2); $keyWithNamespace = $array[0].'.'.$namespace.'::'.$array[1]; $messages[$keyWithNamespace] = include "${path}/${pathName}"; } return $messages; }
[ "protected", "function", "getMessagesFromSourcePath", "(", "$", "path", ",", "$", "namespace", ")", "{", "$", "messages", "=", "[", "]", ";", "if", "(", "!", "$", "this", "->", "file", "->", "exists", "(", "$", "path", ")", ")", "{", "throw", "new", ...
Return language messages for a path. @param $path @return array @throws \Exception
[ "Return", "language", "messages", "for", "a", "path", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/Localization/Generators/LangJsGenerator.php#L88-L109
train
SocietyCMS/Core
Utilities/Localization/Generators/LangJsGenerator.php
LangJsGenerator.prepareTarget
protected function prepareTarget($target) { $dirname = dirname($target); if (! $this->file->exists($dirname)) { $this->file->makeDirectory($dirname); } }
php
protected function prepareTarget($target) { $dirname = dirname($target); if (! $this->file->exists($dirname)) { $this->file->makeDirectory($dirname); } }
[ "protected", "function", "prepareTarget", "(", "$", "target", ")", "{", "$", "dirname", "=", "dirname", "(", "$", "target", ")", ";", "if", "(", "!", "$", "this", "->", "file", "->", "exists", "(", "$", "dirname", ")", ")", "{", "$", "this", "->", ...
Prepare the target directoy. @param string $target The target directory.
[ "Prepare", "the", "target", "directoy", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/Localization/Generators/LangJsGenerator.php#L116-L122
train
apioo/psx-oauth2
src/Authorization/AuthorizationCode.php
AuthorizationCode.redirect
public static function redirect(Url $url, $clientId, $redirectUri = null, $scope = null, $state = null) { $parameters = $url->getParameters(); $parameters['response_type'] = 'code'; $parameters['client_id'] = $clientId; if (isset($redirectUri)) { $parameters['redirect_uri'] = $redirectUri; } if (isset($scope)) { $parameters['scope'] = $scope; } if (isset($state)) { $parameters['state'] = $state; } throw new StatusCode\TemporaryRedirectException($url->withScheme('https')->withParameters($parameters)->toString()); }
php
public static function redirect(Url $url, $clientId, $redirectUri = null, $scope = null, $state = null) { $parameters = $url->getParameters(); $parameters['response_type'] = 'code'; $parameters['client_id'] = $clientId; if (isset($redirectUri)) { $parameters['redirect_uri'] = $redirectUri; } if (isset($scope)) { $parameters['scope'] = $scope; } if (isset($state)) { $parameters['state'] = $state; } throw new StatusCode\TemporaryRedirectException($url->withScheme('https')->withParameters($parameters)->toString()); }
[ "public", "static", "function", "redirect", "(", "Url", "$", "url", ",", "$", "clientId", ",", "$", "redirectUri", "=", "null", ",", "$", "scope", "=", "null", ",", "$", "state", "=", "null", ")", "{", "$", "parameters", "=", "$", "url", "->", "get...
Helper method to start the flow by redirecting the user to the authentication server. The getAccessToken method must be used when the server redirects the user back to the redirect uri @param \PSX\Uri\Url $url @param string $clientId @param string $redirectUri @param string $scope @param string $state
[ "Helper", "method", "to", "start", "the", "flow", "by", "redirecting", "the", "user", "to", "the", "authentication", "server", ".", "The", "getAccessToken", "method", "must", "be", "used", "when", "the", "server", "redirects", "the", "user", "back", "to", "t...
60c6eb824393bfc49f9f60ae06b56543c8eab548
https://github.com/apioo/psx-oauth2/blob/60c6eb824393bfc49f9f60ae06b56543c8eab548/src/Authorization/AuthorizationCode.php#L83-L102
train
mszewcz/php-light-framework
src/Text/CharCount.php
CharCount.count
public static function count(string $text = '', bool $includeSpaces = false): int { if (\trim($text) === '') { return 0; } $text = StripTags::strip($text); $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5); $text = \preg_replace('/\s+/', $includeSpaces ? ' ' : '', $text); $text = \trim($text); return \mb_strlen($text, 'UTF-8'); }
php
public static function count(string $text = '', bool $includeSpaces = false): int { if (\trim($text) === '') { return 0; } $text = StripTags::strip($text); $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5); $text = \preg_replace('/\s+/', $includeSpaces ? ' ' : '', $text); $text = \trim($text); return \mb_strlen($text, 'UTF-8'); }
[ "public", "static", "function", "count", "(", "string", "$", "text", "=", "''", ",", "bool", "$", "includeSpaces", "=", "false", ")", ":", "int", "{", "if", "(", "\\", "trim", "(", "$", "text", ")", "===", "''", ")", "{", "return", "0", ";", "}",...
Counts characters. Strips HTML tags. Treats multiple spaces as one. @param string $text @param bool $includeSpaces @return int
[ "Counts", "characters", ".", "Strips", "HTML", "tags", ".", "Treats", "multiple", "spaces", "as", "one", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Text/CharCount.php#L28-L39
train
mvccore/ext-view-helper-internationalized
src/MvcCore/Ext/Views/Helpers/InternationalizedHelper.php
InternationalizedHelper.&
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); return $this->SetLangAndLocale($this->request->GetLang(), $this->request->GetLocale()); }
php
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); return $this->SetLangAndLocale($this->request->GetLang(), $this->request->GetLocale()); }
[ "public", "function", "&", "SetView", "(", "\\", "MvcCore", "\\", "IView", "&", "$", "view", ")", "{", "parent", "::", "SetView", "(", "$", "view", ")", ";", "return", "$", "this", "->", "SetLangAndLocale", "(", "$", "this", "->", "request", "->", "G...
Set up view properties and language and locale by request object in every view rendering change. @param \MvcCore\View|\MvcCore\IView $view @return \MvcCore\Ext\Views\Helpers\InternationalizedHelper
[ "Set", "up", "view", "properties", "and", "language", "and", "locale", "by", "request", "object", "in", "every", "view", "rendering", "change", "." ]
f7013decea5c1343a66adf45f664e275772ac703
https://github.com/mvccore/ext-view-helper-internationalized/blob/f7013decea5c1343a66adf45f664e275772ac703/src/MvcCore/Ext/Views/Helpers/InternationalizedHelper.php#L182-L185
train
marando/phpSOFA
src/Marando/IAU/iauAtciq.php
iauAtciq.Atciq
public static function Atciq($rc, $dc, $pr, $pd, $px, $rv, iauASTROM $astrom, &$ri, &$di) { $pco = []; $pnat = []; $ppr = []; $pi = []; $w; /* Proper motion and parallax, giving BCRS coordinate direction. */ IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco); /* Light deflection by the Sun, giving BCRS natural direction. */ IAU::Ldsun($pco, $astrom->eh, $astrom->em, $pnat); /* Aberration, giving GCRS proper direction. */ IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ IAU::Rxp($astrom->bpn, $ppr, $pi); /* CIRS RA,Dec. */ IAU::C2s($pi, $w, $di); $ri = IAU::Anp($w); /* Finished. */ }
php
public static function Atciq($rc, $dc, $pr, $pd, $px, $rv, iauASTROM $astrom, &$ri, &$di) { $pco = []; $pnat = []; $ppr = []; $pi = []; $w; /* Proper motion and parallax, giving BCRS coordinate direction. */ IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco); /* Light deflection by the Sun, giving BCRS natural direction. */ IAU::Ldsun($pco, $astrom->eh, $astrom->em, $pnat); /* Aberration, giving GCRS proper direction. */ IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr); /* Bias-precession-nutation, giving CIRS proper direction. */ IAU::Rxp($astrom->bpn, $ppr, $pi); /* CIRS RA,Dec. */ IAU::C2s($pi, $w, $di); $ri = IAU::Anp($w); /* Finished. */ }
[ "public", "static", "function", "Atciq", "(", "$", "rc", ",", "$", "dc", ",", "$", "pr", ",", "$", "pd", ",", "$", "px", ",", "$", "rv", ",", "iauASTROM", "$", "astrom", ",", "&", "$", "ri", ",", "&", "$", "di", ")", "{", "$", "pco", "=", ...
- - - - - - - - - i a u A t c i q - - - - - - - - - Quick ICRS, epoch J2000.0, to CIRS transformation, given precomputed star-independent astrometry parameters. Use of this function is appropriate when efficiency is important and where many star positions are to be transformed for one date. The star-independent parameters can be obtained by calling one of the functions iauApci[13], iauApcg[13], iauApco[13] or iauApcs[13]. If the parallax and proper motions are zero the iauAtciqz function can be used instead. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: rc,dc double ICRS RA,Dec at J2000.0 (radians) pr double RA proper motion (radians/year; Note 3) pd double Dec proper motion (radians/year) px double parallax (arcsec) rv double radial velocity (km/s, +ve if receding) astrom iauASTROM* star-independent astrometry parameters: pmt double PM time interval (SSB, Julian years) eb double[3] SSB to observer (vector, au) eh double[3] Sun to observer (unit vector) em double distance from Sun to observer (au) v double[3] barycentric observer velocity (vector, c) bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor bpn double[3][3] bias-precession-nutation matrix along double longitude + s' (radians) xpl double polar motion xp wrt local meridian (radians) ypl double polar motion yp wrt local meridian (radians) sphi double sine of geodetic latitude cphi double cosine of geodetic latitude diurab double magnitude of diurnal aberration vector eral double "local" Earth rotation angle (radians) refa double refraction constant A (radians) refb double refraction constant B (radians) Returned: ri,di double CIRS RA,Dec (radians) Notes: 1) All the vectors are with respect to BCRS axes. 2) Star data for an epoch other than J2000.0 (for example from the Hipparcos catalog, which has an epoch of J1991.25) will require a preliminary call to iauPmsafe before use. 3) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt. Called: iauPmpx proper motion and parallax iauLdsun light deflection by the Sun iauAb stellar aberration iauRxp product of r-matrix and pv-vector iauC2s p-vector to spherical iauAnp normalize angle into range 0 to 2pi This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "t", "c", "i", "q", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAtciq.php#L79-L105
train
jaimeeee/laravelpanel
src/LaravelPanel/models/HTML.php
HTML.tag
public static function tag($tag, $attr = [], $html = '') { // Build attributes $attributes = []; foreach ($attr as $name => $value) { $attributes[] = $name.'="'.$value.'"'; } if (in_array($tag, self::$voidElements)) { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'; } else { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>'; } }
php
public static function tag($tag, $attr = [], $html = '') { // Build attributes $attributes = []; foreach ($attr as $name => $value) { $attributes[] = $name.'="'.$value.'"'; } if (in_array($tag, self::$voidElements)) { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'; } else { return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>'; } }
[ "public", "static", "function", "tag", "(", "$", "tag", ",", "$", "attr", "=", "[", "]", ",", "$", "html", "=", "''", ")", "{", "// Build attributes", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "attr", "as", "$", "name", "=>", "$...
Generate the HTML code for an element. @param string $tag <tag> @param array $attr The tag attributes @param string $html The tag HTML content @return string HTML code of the tag
[ "Generate", "the", "HTML", "code", "for", "an", "element", "." ]
211599ba0be7dc5ea11af292a75d4104c41512ca
https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTML.php#L21-L34
train
jfortunato/fortune
src/Security/Bouncer/ParentBouncer.php
ParentBouncer.routeContainsParent
protected function routeContainsParent() { // get just the base url $route = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // lets split it into pieces $parts = explode('/', $route); // if a resource has a parent, it should be in the form /dogs/1/puppies // so the parent resource should be 2 spots before the child resource $resourcePosition = array_search($this->config->getResource(), $parts); return isset($parts[$resourcePosition - 2]); }
php
protected function routeContainsParent() { // get just the base url $route = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // lets split it into pieces $parts = explode('/', $route); // if a resource has a parent, it should be in the form /dogs/1/puppies // so the parent resource should be 2 spots before the child resource $resourcePosition = array_search($this->config->getResource(), $parts); return isset($parts[$resourcePosition - 2]); }
[ "protected", "function", "routeContainsParent", "(", ")", "{", "// get just the base url", "$", "route", "=", "parse_url", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "PHP_URL_PATH", ")", ";", "// lets split it into pieces", "$", "parts", "=", "explode", ...
Checks if the current route contains the parents id. @return boolean
[ "Checks", "if", "the", "current", "route", "contains", "the", "parents", "id", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Security/Bouncer/ParentBouncer.php#L28-L41
train
SIBPHP/Redis
Redis.php
Redis._connection
protected function _connection(array $config) { $redis = new \Redis; $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host']; $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port']; $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout']; $connect = empty($config['persistent']) ? 'connect' : 'pconnect'; $redis->$connect($host, $port, $timeout); return $redis; }
php
protected function _connection(array $config) { $redis = new \Redis; $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host']; $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port']; $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout']; $connect = empty($config['persistent']) ? 'connect' : 'pconnect'; $redis->$connect($host, $port, $timeout); return $redis; }
[ "protected", "function", "_connection", "(", "array", "$", "config", ")", "{", "$", "redis", "=", "new", "\\", "Redis", ";", "$", "host", "=", "empty", "(", "$", "config", "[", "'host'", "]", ")", "?", "self", "::", "DEFAULT_HOST", ":", "$", "config"...
Redis connect and return the redis instance @param array $config The config @return \Redis
[ "Redis", "connect", "and", "return", "the", "redis", "instance" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L96-L105
train
SIBPHP/Redis
Redis.php
Redis._master
protected function _master() { if (null === $this->_master) { $this->_master = $this->_connection($this->_config_master); } return $this->_master; }
php
protected function _master() { if (null === $this->_master) { $this->_master = $this->_connection($this->_config_master); } return $this->_master; }
[ "protected", "function", "_master", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_master", ")", "{", "$", "this", "->", "_master", "=", "$", "this", "->", "_connection", "(", "$", "this", "->", "_config_master", ")", ";", "}", "return...
Get the master connection @return \Redis
[ "Get", "the", "master", "connection" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L113-L119
train
SIBPHP/Redis
Redis.php
Redis._slave
protected function _slave() { if (empty($this->_config_slaves)) { return $this->_master(); } if (null === $this->_slave) { $count = count($this->_config_slaves); $index = mt_rand(0, $count-1); $config = $this->_config_slaves[$index]; $this->_slave = $this->_connection($config); } return $this->_slave; }
php
protected function _slave() { if (empty($this->_config_slaves)) { return $this->_master(); } if (null === $this->_slave) { $count = count($this->_config_slaves); $index = mt_rand(0, $count-1); $config = $this->_config_slaves[$index]; $this->_slave = $this->_connection($config); } return $this->_slave; }
[ "protected", "function", "_slave", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_config_slaves", ")", ")", "{", "return", "$", "this", "->", "_master", "(", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "_slave", ")", ...
Get the slave connection @return \Redis
[ "Get", "the", "slave", "connection" ]
c4293528ae55c930b4cb4f75870447ed928f6b02
https://github.com/SIBPHP/Redis/blob/c4293528ae55c930b4cb4f75870447ed928f6b02/Redis.php#L126-L138
train
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/Adapter.php
Adapter.run
public function run() { $this->init(); // Loop forever, except when a maximum number of requests is configured $requestsHandled = 0; while ($this->maxRequests === null || $requestsHandled < $this->maxRequests) { $this->doStep(); $requestsHandled++; } }
php
public function run() { $this->init(); // Loop forever, except when a maximum number of requests is configured $requestsHandled = 0; while ($this->maxRequests === null || $requestsHandled < $this->maxRequests) { $this->doStep(); $requestsHandled++; } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "init", "(", ")", ";", "// Loop forever, except when a maximum number of requests is configured", "$", "requestsHandled", "=", "0", ";", "while", "(", "$", "this", "->", "maxRequests", "===", "null", ...
Starts the adapter and keeps handling requests in a loop. This method never returns and will typically be the last call in an adapter implementation script.
[ "Starts", "the", "adapter", "and", "keeps", "handling", "requests", "in", "a", "loop", ".", "This", "method", "never", "returns", "and", "will", "typically", "be", "the", "last", "call", "in", "an", "adapter", "implementation", "script", "." ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/Adapter.php#L98-L108
train
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/Adapter.php
Adapter.init
private function init() { if ($this->encoder === null) { // Send the adapter config as JSON payload to the host $config = new AdapterConfig( $this->codec->getName(), $this->getAdapterType(), $this->getExtraConfig() ); Codecs::json()->newEncoder($this->output)->useNewlines(false)->encode($config); // Set up encoder / decoder for further communication $this->decoder = $this->codec->newDecoder($this->input); $this->encoder = $this->codec->newEncoder($this->output); } }
php
private function init() { if ($this->encoder === null) { // Send the adapter config as JSON payload to the host $config = new AdapterConfig( $this->codec->getName(), $this->getAdapterType(), $this->getExtraConfig() ); Codecs::json()->newEncoder($this->output)->useNewlines(false)->encode($config); // Set up encoder / decoder for further communication $this->decoder = $this->codec->newDecoder($this->input); $this->encoder = $this->codec->newEncoder($this->output); } }
[ "private", "function", "init", "(", ")", "{", "if", "(", "$", "this", "->", "encoder", "===", "null", ")", "{", "// Send the adapter config as JSON payload to the host", "$", "config", "=", "new", "AdapterConfig", "(", "$", "this", "->", "codec", "->", "getNam...
Prepare this adapter for communication. Will send the adapter configuration to the nervus host and set up an encoder and decoder for further communication.
[ "Prepare", "this", "adapter", "for", "communication", ".", "Will", "send", "the", "adapter", "configuration", "to", "the", "nervus", "host", "and", "set", "up", "an", "encoder", "and", "decoder", "for", "further", "communication", "." ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/Adapter.php#L129-L144
train
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.generateTraitMethods
protected function generateTraitMethods() { if (empty($this->_traitMethodsAliases)) { return; } $this->addProperty( '___classMocker_traitMethods', $this->_traitMethodsAliases, PropertyGenerator::FLAG_PRIVATE | PropertyGenerator::FLAG_STATIC ); foreach (array_keys($this->_traitMethodsAliases) as $methodName) { if (!$this->canGenerateMethod($methodName)) { continue; } if (!$this->isValidTraitMethod($methodName)) { throw new \RuntimeException( sprintf( "Trait magic method %s::%s() is not valid, use %s() instead", $this->getName(), $methodName, '_' . $methodName ) ); } $this->generateMethod($methodName); } }
php
protected function generateTraitMethods() { if (empty($this->_traitMethodsAliases)) { return; } $this->addProperty( '___classMocker_traitMethods', $this->_traitMethodsAliases, PropertyGenerator::FLAG_PRIVATE | PropertyGenerator::FLAG_STATIC ); foreach (array_keys($this->_traitMethodsAliases) as $methodName) { if (!$this->canGenerateMethod($methodName)) { continue; } if (!$this->isValidTraitMethod($methodName)) { throw new \RuntimeException( sprintf( "Trait magic method %s::%s() is not valid, use %s() instead", $this->getName(), $methodName, '_' . $methodName ) ); } $this->generateMethod($methodName); } }
[ "protected", "function", "generateTraitMethods", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_traitMethodsAliases", ")", ")", "{", "return", ";", "}", "$", "this", "->", "addProperty", "(", "'___classMocker_traitMethods'", ",", "$", "this", "...
Generate foot print of all methods specified by all traits registered to this mock class Register all trait methods to the private static property ___classMocker_traitMethods which is accessible to the base mock object and used to call all trait methods in order @see \JSiefer\ClassMocker\Mock\BaseMock::mergeTraitMethods() @return void
[ "Generate", "foot", "print", "of", "all", "methods", "specified", "by", "all", "traits", "registered", "to", "this", "mock", "class" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L71-L102
train
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.canGenerateMethod
public function canGenerateMethod($methodName) { /** * any special methods only called by the base mock class * and therefor should not be made accessible * * @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods() */ switch ($methodName) { case BaseMock::CALL: case BaseMock::CONSTRUCTOR: case BaseMock::GETTER: case BaseMock::SETTER: case BaseMock::INIT: return false; } return true; }
php
public function canGenerateMethod($methodName) { /** * any special methods only called by the base mock class * and therefor should not be made accessible * * @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods() */ switch ($methodName) { case BaseMock::CALL: case BaseMock::CONSTRUCTOR: case BaseMock::GETTER: case BaseMock::SETTER: case BaseMock::INIT: return false; } return true; }
[ "public", "function", "canGenerateMethod", "(", "$", "methodName", ")", "{", "/**\n * any special methods only called by the base mock class\n * and therefor should not be made accessible\n *\n * @see \\JSiefer\\ClassMocker\\Mock\\BaseMock::__callTraitMethods()\n ...
Check if method can be generated @param string $methodName @return bool
[ "Check", "if", "method", "can", "be", "generated" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L111-L128
train
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.useTrait
public function useTrait(\ReflectionClass $trait) { $alias = 'trait' . ($this->_traitsIdx++); $alias .= '_' . str_replace('\\', '__', $trait->getName()); $alias = 'Trait_' . substr(md5($alias), 0, 10) . '_' .$trait->getShortName(); $this->addUse($trait->getName(), $alias); $this->addTrait($alias); foreach ($trait->getMethods() as $method) { if ($method->isAbstract()) { continue; } $this->registerTraitMethod($alias, $method); } return $this; }
php
public function useTrait(\ReflectionClass $trait) { $alias = 'trait' . ($this->_traitsIdx++); $alias .= '_' . str_replace('\\', '__', $trait->getName()); $alias = 'Trait_' . substr(md5($alias), 0, 10) . '_' .$trait->getShortName(); $this->addUse($trait->getName(), $alias); $this->addTrait($alias); foreach ($trait->getMethods() as $method) { if ($method->isAbstract()) { continue; } $this->registerTraitMethod($alias, $method); } return $this; }
[ "public", "function", "useTrait", "(", "\\", "ReflectionClass", "$", "trait", ")", "{", "$", "alias", "=", "'trait'", ".", "(", "$", "this", "->", "_traitsIdx", "++", ")", ";", "$", "alias", ".=", "'_'", ".", "str_replace", "(", "'\\\\'", ",", "'__'", ...
Use a trait and save all methods so in case a second trait will overwrite any @param \ReflectionClass $trait @return $this
[ "Use", "a", "trait", "and", "save", "all", "methods", "so", "in", "case", "a", "second", "trait", "will", "overwrite", "any" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L235-L253
train
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.registerTraitMethod
protected function registerTraitMethod($trait, \ReflectionMethod $method) { $name = $method->getName(); $this->_method[$name] = $method; $alias = '__' . lcfirst($trait) . ucfirst($name); $this->addTraitAlias($trait . '::' . $name, $alias); $this->addTraitMethod($trait, $name); if (!isset($this->_traitMethodsAliases[$name])) { $this->_traitMethodsAliases[$name] = []; } $this->_traitMethodsAliases[$name][] = $alias; }
php
protected function registerTraitMethod($trait, \ReflectionMethod $method) { $name = $method->getName(); $this->_method[$name] = $method; $alias = '__' . lcfirst($trait) . ucfirst($name); $this->addTraitAlias($trait . '::' . $name, $alias); $this->addTraitMethod($trait, $name); if (!isset($this->_traitMethodsAliases[$name])) { $this->_traitMethodsAliases[$name] = []; } $this->_traitMethodsAliases[$name][] = $alias; }
[ "protected", "function", "registerTraitMethod", "(", "$", "trait", ",", "\\", "ReflectionMethod", "$", "method", ")", "{", "$", "name", "=", "$", "method", "->", "getName", "(", ")", ";", "$", "this", "->", "_method", "[", "$", "name", "]", "=", "$", ...
Register magic method alias @param string $trait @param \ReflectionMethod $method @return void
[ "Register", "magic", "method", "alias" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L263-L276
train
jsiefer/class-mocker
src/Generator/ClassGenerator.php
ClassGenerator.addTraitMethod
protected function addTraitMethod($trait, $method) { if (!isset($this->_traitMethods[$method])) { $this->_traitMethods[$method] = []; } else { foreach ($this->_traitMethods[$method] as $prefTrait) { $this->removeTraitOverride($prefTrait . '::' . $method); } $traits = implode(', ', $this->_traitMethods[$method]); $this->addTraitOverride($trait . '::' . $method, $traits); } $this->_traitMethods[$method][] = $trait; }
php
protected function addTraitMethod($trait, $method) { if (!isset($this->_traitMethods[$method])) { $this->_traitMethods[$method] = []; } else { foreach ($this->_traitMethods[$method] as $prefTrait) { $this->removeTraitOverride($prefTrait . '::' . $method); } $traits = implode(', ', $this->_traitMethods[$method]); $this->addTraitOverride($trait . '::' . $method, $traits); } $this->_traitMethods[$method][] = $trait; }
[ "protected", "function", "addTraitMethod", "(", "$", "trait", ",", "$", "method", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_traitMethods", "[", "$", "method", "]", ")", ")", "{", "$", "this", "->", "_traitMethods", "[", "$", "metho...
Register trait method this will overwrite all previously registered methods @param string $trait @param string $method @return void
[ "Register", "trait", "method", "this", "will", "overwrite", "all", "previously", "registered", "methods" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Generator/ClassGenerator.php#L287-L299
train
oaugustus/direct-silex-provider
src/Direct/Router/Response.php
Response.encode
public function encode($result) { if ('form' == $this->type) { array_walk_recursive($result[0], array($this, 'utf8')); $response = new SfResponse("<html><body><textarea>".json_encode($result[0])."</textarea></body></html>"); $response->headers->set('Content-Type', 'text/html'); return $response; } else { if ($this->responseEncode){ // @todo: check utf8 config option from bundle array_walk_recursive($result, array($this, 'utf8')); } $response = new SfResponse(json_encode($result)); $response->headers->set('Content-Type', 'application/json'); return $response; } }
php
public function encode($result) { if ('form' == $this->type) { array_walk_recursive($result[0], array($this, 'utf8')); $response = new SfResponse("<html><body><textarea>".json_encode($result[0])."</textarea></body></html>"); $response->headers->set('Content-Type', 'text/html'); return $response; } else { if ($this->responseEncode){ // @todo: check utf8 config option from bundle array_walk_recursive($result, array($this, 'utf8')); } $response = new SfResponse(json_encode($result)); $response->headers->set('Content-Type', 'application/json'); return $response; } }
[ "public", "function", "encode", "(", "$", "result", ")", "{", "if", "(", "'form'", "==", "$", "this", "->", "type", ")", "{", "array_walk_recursive", "(", "$", "result", "[", "0", "]", ",", "array", "(", "$", "this", ",", "'utf8'", ")", ")", ";", ...
Encode the response into a valid json ExtDirect result. @param array $result @return string
[ "Encode", "the", "response", "into", "a", "valid", "json", "ExtDirect", "result", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Response.php#L38-L58
train
oaugustus/direct-silex-provider
src/Direct/Router/Response.php
Response.utf8
private function utf8(&$value, &$key) { if (is_string($value)) { $value = utf8_encode($value); } if (is_array($value)) { array_walk_recursive($value, array($this, 'utf8')); } }
php
private function utf8(&$value, &$key) { if (is_string($value)) { $value = utf8_encode($value); } if (is_array($value)) { array_walk_recursive($value, array($this, 'utf8')); } }
[ "private", "function", "utf8", "(", "&", "$", "value", ",", "&", "$", "key", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "utf8_encode", "(", "$", "value", ")", ";", "}", "if", "(", "is_array", "(", "$"...
Encode the result recursivily as utf8. @param mixed $value @param string $key
[ "Encode", "the", "result", "recursivily", "as", "utf8", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Response.php#L66-L75
train
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.setCompilerRoot
public function setCompilerRoot($path) { $path = realpath($path); if (is_dir($path)) { $this->root = $path; } }
php
public function setCompilerRoot($path) { $path = realpath($path); if (is_dir($path)) { $this->root = $path; } }
[ "public", "function", "setCompilerRoot", "(", "$", "path", ")", "{", "$", "path", "=", "realpath", "(", "$", "path", ")", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "this", "->", "root", "=", "$", "path", ";", "}", "}" ]
Set compiler root @param string $path Path @return null
[ "Set", "compiler", "root" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L71-L77
train
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.addWatcher
public function addWatcher(Watcher\WatcherInterface $watcher) { $type = $watcher->getType(); $this->watchers[$type] = $watcher; }
php
public function addWatcher(Watcher\WatcherInterface $watcher) { $type = $watcher->getType(); $this->watchers[$type] = $watcher; }
[ "public", "function", "addWatcher", "(", "Watcher", "\\", "WatcherInterface", "$", "watcher", ")", "{", "$", "type", "=", "$", "watcher", "->", "getType", "(", ")", ";", "$", "this", "->", "watchers", "[", "$", "type", "]", "=", "$", "watcher", ";", ...
Add named watcher instance @param Watcher\WatcherInterface $watcher Watcher instance @return null
[ "Add", "named", "watcher", "instance" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L110-L115
train
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.addConfig
public function addConfig($config, $watcher) { if (!$this->root) { return; } $config = realpath($config); $filesystem = new Filesystem(); $relativePath = $filesystem->makePathRelative($config, $this->root); if (substr($relativePath, 0, 2) == "..") { return; } if (!isset($this->configs[$watcher])) { $this->configs[$watcher] = array(); } $this->configs[$watcher][] = $config; }
php
public function addConfig($config, $watcher) { if (!$this->root) { return; } $config = realpath($config); $filesystem = new Filesystem(); $relativePath = $filesystem->makePathRelative($config, $this->root); if (substr($relativePath, 0, 2) == "..") { return; } if (!isset($this->configs[$watcher])) { $this->configs[$watcher] = array(); } $this->configs[$watcher][] = $config; }
[ "public", "function", "addConfig", "(", "$", "config", ",", "$", "watcher", ")", "{", "if", "(", "!", "$", "this", "->", "root", ")", "{", "return", ";", "}", "$", "config", "=", "realpath", "(", "$", "config", ")", ";", "$", "filesystem", "=", "...
Add config path to watch @param string $config Path to config file @param string $watcher Watcher name @return null
[ "Add", "config", "path", "to", "watch" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L125-L142
train
apnet/AsseticImporterBundle
src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php
SourceCodeWatcher.compile
public function compile() { if (!$this->enabled || $this->env !== "dev") { return; } foreach ($this->watchers as $name => $watcher) { if (isset($this->configs[$name])) { foreach ($this->configs[$name] as $configPath) { $files = $watcher->getChildren($configPath); if ($this->cache->isFresh($configPath, $files)) { $watcher->compile($configPath); $this->cache->write($configPath, $files); } } } } }
php
public function compile() { if (!$this->enabled || $this->env !== "dev") { return; } foreach ($this->watchers as $name => $watcher) { if (isset($this->configs[$name])) { foreach ($this->configs[$name] as $configPath) { $files = $watcher->getChildren($configPath); if ($this->cache->isFresh($configPath, $files)) { $watcher->compile($configPath); $this->cache->write($configPath, $files); } } } } }
[ "public", "function", "compile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", "||", "$", "this", "->", "env", "!==", "\"dev\"", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "watchers", "as", "$", "name", "=>", ...
Compile watchers' files @return null
[ "Compile", "watchers", "files" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticWatcherBundle/Factory/SourceCodeWatcher.php#L149-L165
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.getInstaller
protected function getInstaller(): BaseInstaller { return Installer::create($this->io, $this->composer, $this->input); }
php
protected function getInstaller(): BaseInstaller { return Installer::create($this->io, $this->composer, $this->input); }
[ "protected", "function", "getInstaller", "(", ")", ":", "BaseInstaller", "{", "return", "Installer", "::", "create", "(", "$", "this", "->", "io", ",", "$", "this", "->", "composer", ",", "$", "this", "->", "input", ")", ";", "}" ]
Get configured installer instance. @codeCoverageIgnore @return \Composer\Installer
[ "Get", "configured", "installer", "instance", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L145-L148
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.findBestVersionForPackage
protected function findBestVersionForPackage(string $name): string { // find the latest version allowed in this pool $package = $this->versionSelector->findBestCandidate($name, null, null, 'stable'); if ($package === false) { throw new InvalidArgumentException(\sprintf( 'Could not find package %s at any version for your minimum-stability (%s).' . ' Check the package spelling or your minimum-stability.', $name, $this->stability )); } return $this->versionSelector->findRecommendedRequireVersion($package); }
php
protected function findBestVersionForPackage(string $name): string { // find the latest version allowed in this pool $package = $this->versionSelector->findBestCandidate($name, null, null, 'stable'); if ($package === false) { throw new InvalidArgumentException(\sprintf( 'Could not find package %s at any version for your minimum-stability (%s).' . ' Check the package spelling or your minimum-stability.', $name, $this->stability )); } return $this->versionSelector->findRecommendedRequireVersion($package); }
[ "protected", "function", "findBestVersionForPackage", "(", "string", "$", "name", ")", ":", "string", "{", "// find the latest version allowed in this pool", "$", "package", "=", "$", "this", "->", "versionSelector", "->", "findBestCandidate", "(", "$", "name", ",", ...
Try to find the best version fot the package. @param string $name @throws \Narrowspark\Automatic\Common\Contract\Exception\InvalidArgumentException @return string
[ "Try", "to", "find", "the", "best", "version", "fot", "the", "package", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L159-L174
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootComposerJson
protected function updateRootComposerJson(array $requires, array $devRequires, int $type): RootPackageInterface { $this->io->writeError('Updating root package'); $this->updateRootPackageRequire($requires, $type); $this->updateRootPackageDevRequire($devRequires, $type); return $this->rootPackage; }
php
protected function updateRootComposerJson(array $requires, array $devRequires, int $type): RootPackageInterface { $this->io->writeError('Updating root package'); $this->updateRootPackageRequire($requires, $type); $this->updateRootPackageDevRequire($devRequires, $type); return $this->rootPackage; }
[ "protected", "function", "updateRootComposerJson", "(", "array", "$", "requires", ",", "array", "$", "devRequires", ",", "int", "$", "type", ")", ":", "RootPackageInterface", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Updating root package'", ")", ...
Update the root package require and dev-require. @param array $requires @param array $devRequires @param int $type @return \Composer\Package\RootPackageInterface
[ "Update", "the", "root", "package", "require", "and", "dev", "-", "require", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L185-L193
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateComposerJson
protected function updateComposerJson(array $requires, array $devRequires, int $type): void { $this->io->writeError('Updating composer.json'); if ($type === self::ADD) { $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath())); $sortPackages = $this->composer->getConfig()->get('sort-packages') ?? false; foreach ($requires as $name => $version) { $jsonManipulator->addLink('require', $name, $version, $sortPackages); } foreach ($devRequires as $name => $version) { $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages); } \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents()); } elseif ($type === self::REMOVE) { $jsonFileContent = $this->jsonFile->read(); foreach ($requires as $packageName => $version) { unset($jsonFileContent['require'][$packageName]); } foreach ($devRequires as $packageName => $version) { unset($jsonFileContent['require-dev'][$packageName]); } $this->jsonFile->write($jsonFileContent); } }
php
protected function updateComposerJson(array $requires, array $devRequires, int $type): void { $this->io->writeError('Updating composer.json'); if ($type === self::ADD) { $jsonManipulator = new JsonManipulator(\file_get_contents($this->jsonFile->getPath())); $sortPackages = $this->composer->getConfig()->get('sort-packages') ?? false; foreach ($requires as $name => $version) { $jsonManipulator->addLink('require', $name, $version, $sortPackages); } foreach ($devRequires as $name => $version) { $jsonManipulator->addLink('require-dev', $name, $version, $sortPackages); } \file_put_contents($this->jsonFile->getPath(), $jsonManipulator->getContents()); } elseif ($type === self::REMOVE) { $jsonFileContent = $this->jsonFile->read(); foreach ($requires as $packageName => $version) { unset($jsonFileContent['require'][$packageName]); } foreach ($devRequires as $packageName => $version) { unset($jsonFileContent['require-dev'][$packageName]); } $this->jsonFile->write($jsonFileContent); } }
[ "protected", "function", "updateComposerJson", "(", "array", "$", "requires", ",", "array", "$", "devRequires", ",", "int", "$", "type", ")", ":", "void", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Updating composer.json'", ")", ";", "if", "(...
Manipulate root composer.json with the new packages and dump it. @param array $requires @param array $devRequires @param int $type @throws \Exception happens in the JsonFile class @return void
[ "Manipulate", "root", "composer", ".", "json", "with", "the", "new", "packages", "and", "dump", "it", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L206-L236
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.runInstaller
protected function runInstaller(RootPackageInterface $rootPackage, array $whitelistPackages): int { $this->io->writeError('Running an update to install dependent packages'); $this->composer->setPackage($rootPackage); $installer = $this->getInstaller(); $installer->setUpdateWhitelist($whitelistPackages); return $installer->run(); }
php
protected function runInstaller(RootPackageInterface $rootPackage, array $whitelistPackages): int { $this->io->writeError('Running an update to install dependent packages'); $this->composer->setPackage($rootPackage); $installer = $this->getInstaller(); $installer->setUpdateWhitelist($whitelistPackages); return $installer->run(); }
[ "protected", "function", "runInstaller", "(", "RootPackageInterface", "$", "rootPackage", ",", "array", "$", "whitelistPackages", ")", ":", "int", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Running an update to install dependent packages'", ")", ";", "...
Install selected packages. @param \Composer\Package\RootPackageInterface $rootPackage @param array $whitelistPackages @throws \Exception @return int
[ "Install", "selected", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L248-L258
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootPackageRequire
protected function updateRootPackageRequire(array $packages, int $type): void { $requires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getRequires() ); $this->rootPackage->setRequires($requires); }
php
protected function updateRootPackageRequire(array $packages, int $type): void { $requires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getRequires() ); $this->rootPackage->setRequires($requires); }
[ "protected", "function", "updateRootPackageRequire", "(", "array", "$", "packages", ",", "int", "$", "type", ")", ":", "void", "{", "$", "requires", "=", "$", "this", "->", "manipulateRootPackage", "(", "$", "packages", ",", "$", "type", ",", "$", "this", ...
Update the root required packages. @param array $packages @param int $type @return void
[ "Update", "the", "root", "required", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L278-L287
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.updateRootPackageDevRequire
protected function updateRootPackageDevRequire(array $packages, int $type): void { $devRequires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getDevRequires() ); $this->rootPackage->setDevRequires($devRequires); }
php
protected function updateRootPackageDevRequire(array $packages, int $type): void { $devRequires = $this->manipulateRootPackage( $packages, $type, $this->rootPackage->getDevRequires() ); $this->rootPackage->setDevRequires($devRequires); }
[ "protected", "function", "updateRootPackageDevRequire", "(", "array", "$", "packages", ",", "int", "$", "type", ")", ":", "void", "{", "$", "devRequires", "=", "$", "this", "->", "manipulateRootPackage", "(", "$", "packages", ",", "$", "type", ",", "$", "t...
Update the root dev-required packages. @param array $packages @param int $type @return void
[ "Update", "the", "root", "dev", "-", "required", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L297-L306
train
narrowspark/automatic-common
Installer/AbstractInstallationManager.php
AbstractInstallationManager.manipulateRootPackage
protected function manipulateRootPackage(array $packages, int $type, array $requires): array { if ($type === self::ADD) { foreach ($packages as $packageName => $version) { $requires[$packageName] = new Link( '__root__', $packageName, (new VersionParser())->parseConstraints($version), 'relates to', $version ); } } elseif ($type === self::REMOVE) { foreach ($packages as $packageName => $version) { unset($requires[$packageName]); } } return $requires; }
php
protected function manipulateRootPackage(array $packages, int $type, array $requires): array { if ($type === self::ADD) { foreach ($packages as $packageName => $version) { $requires[$packageName] = new Link( '__root__', $packageName, (new VersionParser())->parseConstraints($version), 'relates to', $version ); } } elseif ($type === self::REMOVE) { foreach ($packages as $packageName => $version) { unset($requires[$packageName]); } } return $requires; }
[ "protected", "function", "manipulateRootPackage", "(", "array", "$", "packages", ",", "int", "$", "type", ",", "array", "$", "requires", ")", ":", "array", "{", "if", "(", "$", "type", "===", "self", "::", "ADD", ")", "{", "foreach", "(", "$", "package...
Manipulates the given requires with the new added packages. @param array $packages @param int $type @param array $requires @return array
[ "Manipulates", "the", "given", "requires", "with", "the", "new", "added", "packages", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Installer/AbstractInstallationManager.php#L317-L336
train
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionIndex
public function actionIndex() { $searchModel = new UserSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $statusArray = User::getStatusArray(); $roleArray = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'statusArray' => $statusArray, 'roleArray' => $roleArray ]); }
php
public function actionIndex() { $searchModel = new UserSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $statusArray = User::getStatusArray(); $roleArray = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'statusArray' => $statusArray, 'roleArray' => $roleArray ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "UserSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", ...
Users list page.
[ "Users", "list", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L71-L85
train
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionUpdate
public function actionUpdate($id) { $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id)); $user = $this->findUser($id); //return $this->render('view', [ // 'user' => $user, // 'roles' => $roles, // 'user_permit' => $user_permit, // 'moduleName' => Yii::$app->controller->module->id //]); return $this->render('update', [ 'user' => $user, 'roles' => $roles, 'user_permit' => $user_permit, 'moduleName' => Yii::$app->controller->module->id ]); /* $user = $this->findUser($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } //роли Yii::$app->authManager->revokeAll($user->getId()); if(Yii::$app->request->post('roles')){ foreach(Yii::$app->request->post('roles') as $role) { $new_role = Yii::$app->authManager->getRole($role); Yii::$app->authManager->assign($new_role, $user->getId()); } } return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/ }
php
public function actionUpdate($id) { $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'); $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id)); $user = $this->findUser($id); //return $this->render('view', [ // 'user' => $user, // 'roles' => $roles, // 'user_permit' => $user_permit, // 'moduleName' => Yii::$app->controller->module->id //]); return $this->render('update', [ 'user' => $user, 'roles' => $roles, 'user_permit' => $user_permit, 'moduleName' => Yii::$app->controller->module->id ]); /* $user = $this->findUser($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } //роли Yii::$app->authManager->revokeAll($user->getId()); if(Yii::$app->request->post('roles')){ foreach(Yii::$app->request->post('roles') as $role) { $new_role = Yii::$app->authManager->getRole($role); Yii::$app->authManager->assign($new_role, $user->getId()); } } return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/ }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "roles", "=", "ArrayHelper", "::", "map", "(", "Yii", "::", "$", "app", "->", "authManager", "->", "getRoles", "(", ")", ",", "'name'", ",", "'description'", ")", ";", "$", "user_perm...
Updates an existing Users model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Users", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L140-L181
train
cubiclab/users-cube
controllers/backend/UserController.php
UserController.actionMassDelete
public function actionMassDelete() { if (($ids = Yii::$app->request->post('ids')) !== null) { $models = $this->findUser($ids); foreach ($models as $model) { $model->delete($model); } return $this->redirect(['index']); } else { throw new HttpException(400); } }
php
public function actionMassDelete() { if (($ids = Yii::$app->request->post('ids')) !== null) { $models = $this->findUser($ids); foreach ($models as $model) { $model->delete($model); } return $this->redirect(['index']); } else { throw new HttpException(400); } }
[ "public", "function", "actionMassDelete", "(", ")", "{", "if", "(", "(", "$", "ids", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'ids'", ")", ")", "!==", "null", ")", "{", "$", "models", "=", "$", "this", "->", "findUser", ...
Delete multiple users page.
[ "Delete", "multiple", "users", "page", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L195-L206
train
cubiclab/users-cube
controllers/backend/UserController.php
UserController.findUser
private function findUser($id) { if (is_array($id)) { /** @var User $user */ $model = User::findIdentities($id); } else { /** @var User $user */ $model = User::findIdentity($id); } if ($model !== null) { return $model; } else { throw new NotFoundHttpException('User not found'); } }
php
private function findUser($id) { if (is_array($id)) { /** @var User $user */ $model = User::findIdentities($id); } else { /** @var User $user */ $model = User::findIdentity($id); } if ($model !== null) { return $model; } else { throw new NotFoundHttpException('User not found'); } }
[ "private", "function", "findUser", "(", "$", "id", ")", "{", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "/** @var User $user */", "$", "model", "=", "User", "::", "findIdentities", "(", "$", "id", ")", ";", "}", "else", "{", "/** @var User $...
Find User model by ID @param integer|array $id User ID @return \cubiclab\users\models\User User @throws NotFoundHttpException User not found
[ "Find", "User", "model", "by", "ID" ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/controllers/backend/UserController.php#L216-L230
train
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.getBackLink
public function getBackLink($fallback = '') { $url = ''; if ($this->owner->Request) { if ($this->owner->Request->requestVar('BackURL')) { $url = $this->owner->Request->requestVar('BackURL'); } else { if ($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) { $url = $this->owner->Request->getHeader('X-Backurl'); } else { if ($this->owner->Request->getHeader('Referer')) { $url = $this->owner->Request->getHeader('Referer'); } } } } if (!$url) { $url = $fallback ? $fallback : singleton('director')->baseURL(); } return $url; }
php
public function getBackLink($fallback = '') { $url = ''; if ($this->owner->Request) { if ($this->owner->Request->requestVar('BackURL')) { $url = $this->owner->Request->requestVar('BackURL'); } else { if ($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) { $url = $this->owner->Request->getHeader('X-Backurl'); } else { if ($this->owner->Request->getHeader('Referer')) { $url = $this->owner->Request->getHeader('Referer'); } } } } if (!$url) { $url = $fallback ? $fallback : singleton('director')->baseURL(); } return $url; }
[ "public", "function", "getBackLink", "(", "$", "fallback", "=", "''", ")", "{", "$", "url", "=", "''", ";", "if", "(", "$", "this", "->", "owner", "->", "Request", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "Request", "->", "requestVar"...
Find a back link for current controller @param string $fallback @return string
[ "Find", "a", "back", "link", "for", "current", "controller" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L20-L43
train
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.displayNiceView
public function displayNiceView($controller = null, $url = '', $action = '') { if (!$controller) { $controller = $this->owner; } return singleton('director')->create_view($controller, $url, $action); }
php
public function displayNiceView($controller = null, $url = '', $action = '') { if (!$controller) { $controller = $this->owner; } return singleton('director')->create_view($controller, $url, $action); }
[ "public", "function", "displayNiceView", "(", "$", "controller", "=", "null", ",", "$", "url", "=", "''", ",", "$", "action", "=", "''", ")", "{", "if", "(", "!", "$", "controller", ")", "{", "$", "controller", "=", "$", "this", "->", "owner", ";",...
Display a controller using a Page view @param null $controller @param string $url @param string $action @return @Controller
[ "Display", "a", "controller", "using", "a", "Page", "view" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L53-L60
train
milkyway-multimedia/ss-mwm-core
code/Core/Extensions/Controller.php
Controller.respondToFormAppropriately
public function respondToFormAppropriately(array $params, $form = null, $redirect = '') { if ($redirect && !isset($params['redirect'])) { $params['redirect'] = $redirect; } if ($this->owner->Request->isAjax()) { if (!isset($params['code'])) { $params['code'] = 200; } if (!isset($params['code'])) { $params['status'] = 'success'; } return singleton('director')->ajax_response($params, $params['code'], $params['status']); } else { if (isset($params['redirect'])) { $this->owner->redirect($params['redirect']); } if ($form && isset($params['message'])) { $form->sessionMessage($params['message'], 'good'); } if (!$this->owner->redirectedTo()) { $this->owner->redirectBack(); } } }
php
public function respondToFormAppropriately(array $params, $form = null, $redirect = '') { if ($redirect && !isset($params['redirect'])) { $params['redirect'] = $redirect; } if ($this->owner->Request->isAjax()) { if (!isset($params['code'])) { $params['code'] = 200; } if (!isset($params['code'])) { $params['status'] = 'success'; } return singleton('director')->ajax_response($params, $params['code'], $params['status']); } else { if (isset($params['redirect'])) { $this->owner->redirect($params['redirect']); } if ($form && isset($params['message'])) { $form->sessionMessage($params['message'], 'good'); } if (!$this->owner->redirectedTo()) { $this->owner->redirectBack(); } } }
[ "public", "function", "respondToFormAppropriately", "(", "array", "$", "params", ",", "$", "form", "=", "null", ",", "$", "redirect", "=", "''", ")", "{", "if", "(", "$", "redirect", "&&", "!", "isset", "(", "$", "params", "[", "'redirect'", "]", ")", ...
Respond to a form view ajax or redirect @param array $params @param \Form $form @param string $redirect @return \SS_HTTPResponse|null
[ "Respond", "to", "a", "form", "view", "ajax", "or", "redirect" ]
e7216653b7100ead5a7d56736a124bee1c76fcd5
https://github.com/milkyway-multimedia/ss-mwm-core/blob/e7216653b7100ead5a7d56736a124bee1c76fcd5/code/Core/Extensions/Controller.php#L69-L97
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeIsset
protected function _invokeIsset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); return !empty($property); }
php
protected function _invokeIsset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); return !empty($property); }
[ "protected", "function", "_invokeIsset", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name",...
Internal magic checker Magic method called when `issetProp()`, `isset($this->prop)` or `empty($this->prop)` are invoked. @param string $name The name of the property to get @return bool This will return `true` if the property exists, `false` otherwise
[ "Internal", "magic", "checker" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L238-L246
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeReset
protected function _invokeReset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { return $this->_invokeUnset($name); } else { $classname = get_class($this); $reflection = new ReflectionClass($classname); $properties = $reflection->getDefaultProperties(); if (!empty($properties) && array_key_exists($property, $properties)) { $this->{$property} = $properties[$property]; } } } return $this; }
php
protected function _invokeReset($name) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { return $this->_invokeUnset($name); } else { $classname = get_class($this); $reflection = new ReflectionClass($classname); $properties = $reflection->getDefaultProperties(); if (!empty($properties) && array_key_exists($property, $properties)) { $this->{$property} = $properties[$property]; } } } return $this; }
[ "protected", "function", "_invokeReset", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", "(", "$", "name",...
Internal magic re-setter Magic method called when `resetProp(arg, value)` is invoked. As this can not work on statics, in this case it is an alias of `unset`. @param string $name The name of the property to get @return self Returns `$this` for method chaining
[ "Internal", "magic", "re", "-", "setter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L282-L302
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeGet
protected function _invokeGet($name, $default = null) { if (!self::__isInvokable($name)) { return null; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { return $is_static ? @$this::${$property} : @$this->{$property}; } return $default; }
php
protected function _invokeGet($name, $default = null) { if (!self::__isInvokable($name)) { return null; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { return $is_static ? @$this::${$property} : @$this->{$property}; } return $default; }
[ "protected", "function", "_invokeGet", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "$", "is_static", "=", "self", "::", "_...
Internal magic getter Magic method called when `getProp(arg, default)` or `$this->prop` are invoked. @param string $name The name of the property to get @param mixed $default The default value to return if the property doesn't exist @return mixed This will return the result of a magic method, or nothing if nothing can be done
[ "Internal", "magic", "getter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L313-L324
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable._invokeSet
protected function _invokeSet($name, $value) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { $this::${$property} = $value; } else { $this->{$property} = $value; } } return $this; }
php
protected function _invokeSet($name, $value) { if (!self::__isInvokable($name)) { return $this; } $is_static = self::__isStatic($name); $property = $this->findPropertyName($name); if (!empty($property)) { if ($is_static) { $this::${$property} = $value; } else { $this->{$property} = $value; } } return $this; }
[ "protected", "function", "_invokeSet", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "self", "::", "__isInvokable", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "is_static", "=", "self", "::", "__isStatic", ...
Internal magic setter Magic method called when `setProp(arg, value)` or `$this->arg = value` are invoked. @param string $name The name of the property to get @param mixed $value The value to set for the property @return self Returns `$this` for method chaining
[ "Internal", "magic", "setter" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L335-L350
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isInvokable
private function __isInvokable($name) { if (!$this->__isCalled) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isPublic(); } } return true; }
php
private function __isInvokable($name) { if (!$this->__isCalled) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isPublic(); } } return true; }
[ "private", "function", "__isInvokable", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "__isCalled", ")", "{", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$...
Check if a property is invokable in the final object Returns `false` if property access was direct and its scope is not public. @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "invokable", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L360-L370
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isStatic
private function __isStatic($name) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isStatic(); } return true; }
php
private function __isStatic($name) { $property = $this->findPropertyName($name); if (!empty($property)) { $reflection = new ReflectionProperty(get_class($this), $property); return $reflection->isStatic(); } return true; }
[ "private", "function", "__isStatic", "(", "$", "name", ")", "{", "$", "property", "=", "$", "this", "->", "findPropertyName", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "property", ")", ")", "{", "$", "reflection", "=", "new", "...
Check if a property is static in the final object @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "static", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L378-L386
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.__isInvokableStatic
private static function __isInvokableStatic($name) { $classname = get_called_class(); $reflection_class = new ReflectionClass($classname); $properties = $reflection_class->getStaticProperties(); $property = self::findPropertyNameStatic($name, $classname); if (!empty($property)) { $reflection = new ReflectionProperty($classname, $property); return (bool) !($reflection->isPrivate()); } return true; }
php
private static function __isInvokableStatic($name) { $classname = get_called_class(); $reflection_class = new ReflectionClass($classname); $properties = $reflection_class->getStaticProperties(); $property = self::findPropertyNameStatic($name, $classname); if (!empty($property)) { $reflection = new ReflectionProperty($classname, $property); return (bool) !($reflection->isPrivate()); } return true; }
[ "private", "static", "function", "__isInvokableStatic", "(", "$", "name", ")", "{", "$", "classname", "=", "get_called_class", "(", ")", ";", "$", "reflection_class", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "$", "properties", "=", "$"...
Check if a property is statically invokable in the final object Returns `false` if property access was direct and its scope is not static & public. @param string $name The property name @return bool
[ "Check", "if", "a", "property", "is", "statically", "invokable", "in", "the", "final", "object" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L396-L407
train
atelierspierrot/library
src/Library/Object/AbstractInvokable.php
AbstractInvokable.findPropertyNameStatic
public static function findPropertyNameStatic($name, $object) { $property = null; if (property_exists($object, $name)) { $property = $name; } else { // _name $underscore_name = '_'.$name; if (property_exists($object, $underscore_name)) { $property = $underscore_name; } else { // __name $doubleunderscore_name = '__'.$name; if (property_exists($object, $doubleunderscore_name)) { $property = $doubleunderscore_name; } } } return $property; }
php
public static function findPropertyNameStatic($name, $object) { $property = null; if (property_exists($object, $name)) { $property = $name; } else { // _name $underscore_name = '_'.$name; if (property_exists($object, $underscore_name)) { $property = $underscore_name; } else { // __name $doubleunderscore_name = '__'.$name; if (property_exists($object, $doubleunderscore_name)) { $property = $doubleunderscore_name; } } } return $property; }
[ "public", "static", "function", "findPropertyNameStatic", "(", "$", "name", ",", "$", "object", ")", "{", "$", "property", "=", "null", ";", "if", "(", "property_exists", "(", "$", "object", ",", "$", "name", ")", ")", "{", "$", "property", "=", "$", ...
Search a property name in the current object with one or tow leading underscores @param string $name The property name to transform @param string|object $object The object or a class name to work on @return string The transformed property name
[ "Search", "a", "property", "name", "in", "the", "current", "object", "with", "one", "or", "tow", "leading", "underscores" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Object/AbstractInvokable.php#L427-L446
train
serlo/athene2-common
src/Common/src/Common/Validator/NotIdentical.php
NotIdentical.isValid
public function isValid($value, array $context = null) { $this->setValue($value); $token = $this->getToken(); if (!$this->getLiteral() && $context !== null) { if (is_array($token)) { while (is_array($token)) { $key = key($token); if (!isset($context[$key])) { break; } $context = $context[$key]; $token = $token[$key]; } } // if $token is an array it means the above loop didn't went all the way down to the leaf, // so the $token structure doesn't match the $context structure if (is_array($token) || !isset($context[$token])) { $token = $this->getToken(); } else { $token = $context[$token]; } } if ($token === null) { $this->error(self::MISSING_TOKEN); return false; } $strict = $this->getStrict(); if (!($strict && ($value !== $token)) || (!$strict && ($value != $token))) { $this->error(self::SAME); return false; } return true; }
php
public function isValid($value, array $context = null) { $this->setValue($value); $token = $this->getToken(); if (!$this->getLiteral() && $context !== null) { if (is_array($token)) { while (is_array($token)) { $key = key($token); if (!isset($context[$key])) { break; } $context = $context[$key]; $token = $token[$key]; } } // if $token is an array it means the above loop didn't went all the way down to the leaf, // so the $token structure doesn't match the $context structure if (is_array($token) || !isset($context[$token])) { $token = $this->getToken(); } else { $token = $context[$token]; } } if ($token === null) { $this->error(self::MISSING_TOKEN); return false; } $strict = $this->getStrict(); if (!($strict && ($value !== $token)) || (!$strict && ($value != $token))) { $this->error(self::SAME); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ",", "array", "$", "context", "=", "null", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "$", "token", "=", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", ...
Returns true if and only if a token has been set and the provided value matches that token. @param mixed $value @param array $context @return bool @throws Exception\RuntimeException if the token doesn't exist in the context array
[ "Returns", "true", "if", "and", "only", "if", "a", "token", "has", "been", "set", "and", "the", "provided", "value", "matches", "that", "token", "." ]
b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c
https://github.com/serlo/athene2-common/blob/b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c/src/Common/src/Common/Validator/NotIdentical.php#L37-L76
train
slickframework/mvc
src/Service/Entity/AbstractEntityService.php
AbstractEntityService.setEntityClass
public function setEntityClass($className) { if ( !class_exists($className) || !is_subclass_of($className, EntityInterface::class) ) { throw new InvalidEntityClassException( "Class '{$className}' does not implements the " . "Slick\Orm\EntityInterface interface." ); } $this->entityClass = $className; return $this; }
php
public function setEntityClass($className) { if ( !class_exists($className) || !is_subclass_of($className, EntityInterface::class) ) { throw new InvalidEntityClassException( "Class '{$className}' does not implements the " . "Slick\Orm\EntityInterface interface." ); } $this->entityClass = $className; return $this; }
[ "public", "function", "setEntityClass", "(", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", "||", "!", "is_subclass_of", "(", "$", "className", ",", "EntityInterface", "::", "class", ")", ")", "{", "throw", "new", ...
Set FQ entity class name @param string $className @throws InvalidEntityClassException If the provided class name does not implements the Slick\Orm\EntityInterface interface. @return $this|self|AbstractEntityService
[ "Set", "FQ", "entity", "class", "name" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Service/Entity/AbstractEntityService.php#L46-L60
train
slickframework/mvc
src/Service/Entity/AbstractEntityService.php
AbstractEntityService.getEntityClassName
public function getEntityClassName() { if (null == $this->entityClass) { $this->setEntityClass(get_class($this->getEntity())); } return $this->entityClass; }
php
public function getEntityClassName() { if (null == $this->entityClass) { $this->setEntityClass(get_class($this->getEntity())); } return $this->entityClass; }
[ "public", "function", "getEntityClassName", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "entityClass", ")", "{", "$", "this", "->", "setEntityClass", "(", "get_class", "(", "$", "this", "->", "getEntity", "(", ")", ")", ")", ";", "}", ...
Get the entity FQ class name @return string
[ "Get", "the", "entity", "FQ", "class", "name" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Service/Entity/AbstractEntityService.php#L80-L86
train
etcinit/tutum-php
src/Chromabits/TutumClient/ClientFactory.php
ClientFactory.makeFromEnvironment
public function makeFromEnvironment() { $env = new EnvUtils(); // Check that we have all variables we need if (!$env->hasBearerKey()) { throw new Exception( 'TUTUM_AUTH is not set. Unable to create from environment' ); } $client = new Client('', ''); $client->setBearerKey($env->getBearerKey()); return $client; }
php
public function makeFromEnvironment() { $env = new EnvUtils(); // Check that we have all variables we need if (!$env->hasBearerKey()) { throw new Exception( 'TUTUM_AUTH is not set. Unable to create from environment' ); } $client = new Client('', ''); $client->setBearerKey($env->getBearerKey()); return $client; }
[ "public", "function", "makeFromEnvironment", "(", ")", "{", "$", "env", "=", "new", "EnvUtils", "(", ")", ";", "// Check that we have all variables we need", "if", "(", "!", "$", "env", "->", "hasBearerKey", "(", ")", ")", "{", "throw", "new", "Exception", "...
Build a client using configuration from the environment @return Client @throws Exception
[ "Build", "a", "client", "using", "configuration", "from", "the", "environment" ]
39fb3375e0d47109a5da70a0e441efb8fd4f4008
https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/ClientFactory.php#L24-L39
train
belgattitude/openstore-akilia
src/OpenstoreAkilia/Db/DbExecuter.php
DbExecuter.executeSQL
public function executeSQL($key, $query, $disable_foreign_key_checks = true, $entity=null) { if ($entity !== null && $entity != $this->last_entity) { $this->log("------------------------------------------------------"); $this->log("Entity: '$entity'"); $this->log("------------------------------------------------------"); $this->last_entity = $entity; } $this->log(" * Sync::executeSQL '$key'..."); $total_time_start = microtime(true); if ($disable_foreign_key_checks) { $this->adapter->query('set foreign_key_checks=0'); $this->log(" * FK : Foreign key check disabled"); } try { $time_start = microtime(true); $result = $this->adapter->query($query, ZendDb::QUERY_MODE_EXECUTE); $affected_rows = $result->getAffectedRows(); // Log stuffs $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $formatted_query = preg_replace('/(\n)|(\r)|(\t)/', ' ', $query); $formatted_query = preg_replace('/(\ )+/', ' ', $formatted_query); $this->log(" * SQL: " . substr(trim($formatted_query), 0, 70) . '...') ; $this->log(" * SQL: Query time $time sec(s))"); } catch (\Exception $e) { $err = $e->getMessage(); $msg = "Error running query ({$err}) : \n--------------------\n$query\n------------------\n"; $this->log("[+] $msg\n"); if ($disable_foreign_key_checks) { $this->log("[Error] Error restoring foreign key checks"); $this->adapter->query('set foreign_key_checks=1'); } throw new \Exception($msg); } if ($disable_foreign_key_checks) { $time_start = microtime(true); $this->adapter->query('set foreign_key_checks=1'); $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $this->log(" * FK : Foreign keys restored"); } $time_stop = microtime(true); $time = number_format(($time_stop - $total_time_start), 2); $this->log(" * Time: $time secs, affected rows $affected_rows."); }
php
public function executeSQL($key, $query, $disable_foreign_key_checks = true, $entity=null) { if ($entity !== null && $entity != $this->last_entity) { $this->log("------------------------------------------------------"); $this->log("Entity: '$entity'"); $this->log("------------------------------------------------------"); $this->last_entity = $entity; } $this->log(" * Sync::executeSQL '$key'..."); $total_time_start = microtime(true); if ($disable_foreign_key_checks) { $this->adapter->query('set foreign_key_checks=0'); $this->log(" * FK : Foreign key check disabled"); } try { $time_start = microtime(true); $result = $this->adapter->query($query, ZendDb::QUERY_MODE_EXECUTE); $affected_rows = $result->getAffectedRows(); // Log stuffs $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $formatted_query = preg_replace('/(\n)|(\r)|(\t)/', ' ', $query); $formatted_query = preg_replace('/(\ )+/', ' ', $formatted_query); $this->log(" * SQL: " . substr(trim($formatted_query), 0, 70) . '...') ; $this->log(" * SQL: Query time $time sec(s))"); } catch (\Exception $e) { $err = $e->getMessage(); $msg = "Error running query ({$err}) : \n--------------------\n$query\n------------------\n"; $this->log("[+] $msg\n"); if ($disable_foreign_key_checks) { $this->log("[Error] Error restoring foreign key checks"); $this->adapter->query('set foreign_key_checks=1'); } throw new \Exception($msg); } if ($disable_foreign_key_checks) { $time_start = microtime(true); $this->adapter->query('set foreign_key_checks=1'); $time_stop = microtime(true); $time = number_format(($time_stop - $time_start), 2); $this->log(" * FK : Foreign keys restored"); } $time_stop = microtime(true); $time = number_format(($time_stop - $total_time_start), 2); $this->log(" * Time: $time secs, affected rows $affected_rows."); }
[ "public", "function", "executeSQL", "(", "$", "key", ",", "$", "query", ",", "$", "disable_foreign_key_checks", "=", "true", ",", "$", "entity", "=", "null", ")", "{", "if", "(", "$", "entity", "!==", "null", "&&", "$", "entity", "!=", "$", "this", "...
Execute a query on the database and logs it @throws Exception @param string $key name of the query @param string $query @param boolean $disable_foreign_key_checks @param string $entity @return void
[ "Execute", "a", "query", "on", "the", "database", "and", "logs", "it" ]
149b9abca971d20620d5003342cb50592a05d1fa
https://github.com/belgattitude/openstore-akilia/blob/149b9abca971d20620d5003342cb50592a05d1fa/src/OpenstoreAkilia/Db/DbExecuter.php#L51-L102
train
vpg/titon.common
src/Titon/Common/Traits/Configurable.php
Configurable.applyConfig
public function applyConfig(array $config = []) { $parent = $this; $defaults = isset($this->_config) ? $this->_config : []; // Inherit config from parents while ($parent = get_parent_class($parent)) { $props = get_class_vars($parent); if (isset($props['_config'])) { $defaults = Hash::merge($props['_config'], $defaults); } } $this->__config = new ConfigAugment($config, $defaults); return $this; }
php
public function applyConfig(array $config = []) { $parent = $this; $defaults = isset($this->_config) ? $this->_config : []; // Inherit config from parents while ($parent = get_parent_class($parent)) { $props = get_class_vars($parent); if (isset($props['_config'])) { $defaults = Hash::merge($props['_config'], $defaults); } } $this->__config = new ConfigAugment($config, $defaults); return $this; }
[ "public", "function", "applyConfig", "(", "array", "$", "config", "=", "[", "]", ")", "{", "$", "parent", "=", "$", "this", ";", "$", "defaults", "=", "isset", "(", "$", "this", "->", "_config", ")", "?", "$", "this", "->", "_config", ":", "[", "...
Merge the custom configuration with the defaults and inherit from parent classes. @uses Titon\Utility\Hash @param array $config @return $this
[ "Merge", "the", "custom", "configuration", "with", "the", "defaults", "and", "inherit", "from", "parent", "classes", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Configurable.php#L56-L72
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setEmail
public function setEmail($email) { $email = (string) $email; if ($this->exists() && $this->email !== $email) { $this->updated['email'] = true; } $this->email = $email; return $this; }
php
public function setEmail($email) { $email = (string) $email; if ($this->exists() && $this->email !== $email) { $this->updated['email'] = true; } $this->email = $email; return $this; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "$", "email", "=", "(", "string", ")", "$", "email", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "email", "!==", "$", "email", ")", "{", "$", "th...
Set value for field "user_email" @param string $email @return $this
[ "Set", "value", "for", "field", "user_email" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L248-L259
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setPassword
public function setPassword($password) { $password = (string) $password; if ($this->exists() && $this->password !== $password) { $this->updated['password'] = true; } $this->password = $password; return $this; }
php
public function setPassword($password) { $password = (string) $password; if ($this->exists() && $this->password !== $password) { $this->updated['password'] = true; } $this->password = $password; return $this; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "$", "password", "=", "(", "string", ")", "$", "password", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "password", "!==", "$", "password", ")", ...
Set value for field "user_password" @param string $password @return $this
[ "Set", "value", "for", "field", "user_password" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L267-L278
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setPseudo
public function setPseudo($pseudo) { $pseudo = (string) $pseudo; if ($this->exists() && $this->pseudo !== $pseudo) { $this->updated['pseudo'] = true; } $this->pseudo = $pseudo; return $this; }
php
public function setPseudo($pseudo) { $pseudo = (string) $pseudo; if ($this->exists() && $this->pseudo !== $pseudo) { $this->updated['pseudo'] = true; } $this->pseudo = $pseudo; return $this; }
[ "public", "function", "setPseudo", "(", "$", "pseudo", ")", "{", "$", "pseudo", "=", "(", "string", ")", "$", "pseudo", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "pseudo", "!==", "$", "pseudo", ")", "{", "$",...
Set value for field "user_pseudo" @param string $pseudo @return $this
[ "Set", "value", "for", "field", "user_pseudo" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L286-L297
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setFirstname
public function setFirstname($firstname) { $firstname = ($firstname === null ? $firstname : (string) $firstname); if ($this->exists() && $this->firstname !== $firstname) { $this->updated['firstname'] = true; } $this->firstname = $firstname; return $this; }
php
public function setFirstname($firstname) { $firstname = ($firstname === null ? $firstname : (string) $firstname); if ($this->exists() && $this->firstname !== $firstname) { $this->updated['firstname'] = true; } $this->firstname = $firstname; return $this; }
[ "public", "function", "setFirstname", "(", "$", "firstname", ")", "{", "$", "firstname", "=", "(", "$", "firstname", "===", "null", "?", "$", "firstname", ":", "(", "string", ")", "$", "firstname", ")", ";", "if", "(", "$", "this", "->", "exists", "(...
Set value for field "user_firstname" @param string $firstname @return $this
[ "Set", "value", "for", "field", "user_firstname" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L305-L316
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setLastname
public function setLastname($lastname) { $lastname = ($lastname === null ? $lastname : (string) $lastname); if ($this->exists() && $this->lastname !== $lastname) { $this->updated['lastname'] = true; } $this->lastname = $lastname; return $this; }
php
public function setLastname($lastname) { $lastname = ($lastname === null ? $lastname : (string) $lastname); if ($this->exists() && $this->lastname !== $lastname) { $this->updated['lastname'] = true; } $this->lastname = $lastname; return $this; }
[ "public", "function", "setLastname", "(", "$", "lastname", ")", "{", "$", "lastname", "=", "(", "$", "lastname", "===", "null", "?", "$", "lastname", ":", "(", "string", ")", "$", "lastname", ")", ";", "if", "(", "$", "this", "->", "exists", "(", "...
Set value for field "user_lastname" @param string $lastname @return $this
[ "Set", "value", "for", "field", "user_lastname" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L324-L335
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setDateRegister
public function setDateRegister($dateRegister) { $dateRegister = ($dateRegister === null ? $dateRegister : (string) $dateRegister); if ($this->exists() && $this->dateRegister !== $dateRegister) { $this->updated['dateRegister'] = true; } $this->dateRegister = $dateRegister; return $this; }
php
public function setDateRegister($dateRegister) { $dateRegister = ($dateRegister === null ? $dateRegister : (string) $dateRegister); if ($this->exists() && $this->dateRegister !== $dateRegister) { $this->updated['dateRegister'] = true; } $this->dateRegister = $dateRegister; return $this; }
[ "public", "function", "setDateRegister", "(", "$", "dateRegister", ")", "{", "$", "dateRegister", "=", "(", "$", "dateRegister", "===", "null", "?", "$", "dateRegister", ":", "(", "string", ")", "$", "dateRegister", ")", ";", "if", "(", "$", "this", "->"...
Set value for field "user_date_register" @param string $dateRegister @return $this
[ "Set", "value", "for", "field", "user_date_register" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L343-L354
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setIsActivated
public function setIsActivated($isActivated) { $isActivated = (int) $isActivated; if ($this->exists() && $this->isActivated !== $isActivated) { $this->updated['isActivated'] = true; } $this->isActivated = $isActivated; return $this; }
php
public function setIsActivated($isActivated) { $isActivated = (int) $isActivated; if ($this->exists() && $this->isActivated !== $isActivated) { $this->updated['isActivated'] = true; } $this->isActivated = $isActivated; return $this; }
[ "public", "function", "setIsActivated", "(", "$", "isActivated", ")", "{", "$", "isActivated", "=", "(", "int", ")", "$", "isActivated", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "isActivated", "!==", "$", "isActiv...
Set value for field "user_is_activated" @param int $isActivated @return $this
[ "Set", "value", "for", "field", "user_is_activated" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L362-L373
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setDateActivation
public function setDateActivation($dateActivation) { $dateActivation = ($dateActivation === null ? $dateActivation : (string) $dateActivation); if ($this->exists() && $this->dateActivation !== $dateActivation) { $this->updated['dateActivation'] = true; } $this->dateActivation = $dateActivation; return $this; }
php
public function setDateActivation($dateActivation) { $dateActivation = ($dateActivation === null ? $dateActivation : (string) $dateActivation); if ($this->exists() && $this->dateActivation !== $dateActivation) { $this->updated['dateActivation'] = true; } $this->dateActivation = $dateActivation; return $this; }
[ "public", "function", "setDateActivation", "(", "$", "dateActivation", ")", "{", "$", "dateActivation", "=", "(", "$", "dateActivation", "===", "null", "?", "$", "dateActivation", ":", "(", "string", ")", "$", "dateActivation", ")", ";", "if", "(", "$", "t...
Set value for field "user_date_activation" @param string $dateActivation @return $this
[ "Set", "value", "for", "field", "user_date_activation" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L381-L392
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setCodeActivation
public function setCodeActivation($codeActivation) { $codeActivation = ($codeActivation === null ? $codeActivation : (string) $codeActivation); if ($this->exists() && $this->codeActivation !== $codeActivation) { $this->updated['codeActivation'] = true; } $this->codeActivation = $codeActivation; return $this; }
php
public function setCodeActivation($codeActivation) { $codeActivation = ($codeActivation === null ? $codeActivation : (string) $codeActivation); if ($this->exists() && $this->codeActivation !== $codeActivation) { $this->updated['codeActivation'] = true; } $this->codeActivation = $codeActivation; return $this; }
[ "public", "function", "setCodeActivation", "(", "$", "codeActivation", ")", "{", "$", "codeActivation", "=", "(", "$", "codeActivation", "===", "null", "?", "$", "codeActivation", ":", "(", "string", ")", "$", "codeActivation", ")", ";", "if", "(", "$", "t...
Set value for field "user_code_activation" @param string $codeActivation @return $this
[ "Set", "value", "for", "field", "user_code_activation" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L400-L411
train
velkuns/eureka-package-user
src/User/DataMapper/Data/User/Abstracts/UserAbstract.php
UserAbstract.setAvatar
public function setAvatar($avatar) { $avatar = (string) $avatar; if ($this->exists() && $this->avatar !== $avatar) { $this->updated['avatar'] = true; } $this->avatar = $avatar; return $this; }
php
public function setAvatar($avatar) { $avatar = (string) $avatar; if ($this->exists() && $this->avatar !== $avatar) { $this->updated['avatar'] = true; } $this->avatar = $avatar; return $this; }
[ "public", "function", "setAvatar", "(", "$", "avatar", ")", "{", "$", "avatar", "=", "(", "string", ")", "$", "avatar", ";", "if", "(", "$", "this", "->", "exists", "(", ")", "&&", "$", "this", "->", "avatar", "!==", "$", "avatar", ")", "{", "$",...
Set value for field "user_avatar" @param string $avatar @return $this
[ "Set", "value", "for", "field", "user_avatar" ]
b5a60b5a234162558b390ee3d452e4254c790f2b
https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Data/User/Abstracts/UserAbstract.php#L419-L430
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowById
public function getShowById($showId) { $response = $this->request('/GetShowById/' . $showId); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
php
public function getShowById($showId) { $response = $this->request('/GetShowById/' . $showId); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
[ "public", "function", "getShowById", "(", "$", "showId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowById/'", ".", "$", "showId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'false'", ...
Get a show by Bierdopje showId @param $showId @return \SimpleXMLElement[]|\stdClass @throws \Exception
[ "Get", "a", "show", "by", "Bierdopje", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L45-L55
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.findShowByName
public function findShowByName($showName) { $response = $this->request('/FindShowByName/' . $showName); if ( $response->response->status == 'false' ) return null; $shows = $response->response->results->result; if ( count($shows) <= 0 ) return null; $show = $shows[0]; $show = $this->formatShow($show); return $show; }
php
public function findShowByName($showName) { $response = $this->request('/FindShowByName/' . $showName); if ( $response->response->status == 'false' ) return null; $shows = $response->response->results->result; if ( count($shows) <= 0 ) return null; $show = $shows[0]; $show = $this->formatShow($show); return $show; }
[ "public", "function", "findShowByName", "(", "$", "showName", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/FindShowByName/'", ".", "$", "showName", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'f...
Search a show by name @param $showName @return null|\stdClass @throws \Exception
[ "Search", "a", "show", "by", "name" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L65-L79
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowByName
public function getShowByName($showName, $isLinkName = false) { $response = $this->request('/GetShowByName/' . $showName . '/' . $isLinkName); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
php
public function getShowByName($showName, $isLinkName = false) { $response = $this->request('/GetShowByName/' . $showName . '/' . $isLinkName); if ( $response->response->status == 'false' ) return null; $show = $response->response; $show = $this->formatShow($show); return $show; }
[ "public", "function", "getShowByName", "(", "$", "showName", ",", "$", "isLinkName", "=", "false", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowByName/'", ".", "$", "showName", ".", "'/'", ".", "$", "isLinkName", ")", ";",...
Get a show by exact name. @param string $showName @param bool $isLinkName @return null|\stdClass @throws \Exception
[ "Get", "a", "show", "by", "exact", "name", "." ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L90-L100
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getShowByTvdbId
public function getShowByTvdbId($tvdbId) { $response = $this->request('/GetShowByTVDBID/' . $tvdbId); if ( $response->response->status == 'false' ) return null; $show = $this->formatShow($response->response); return $show; }
php
public function getShowByTvdbId($tvdbId) { $response = $this->request('/GetShowByTVDBID/' . $tvdbId); if ( $response->response->status == 'false' ) return null; $show = $this->formatShow($response->response); return $show; }
[ "public", "function", "getShowByTvdbId", "(", "$", "tvdbId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetShowByTVDBID/'", ".", "$", "tvdbId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "'fal...
Search a show by a TVDB showId @param $tvdbId @return \stdClass @throws \Exception
[ "Search", "a", "show", "by", "a", "TVDB", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L110-L118
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getEpisodesOfSeason
public function getEpisodesOfSeason($showId, $season) { $response = $this->request('/GetEpisodesForSeason/' . $showId . '/' . $season); if ( $response->response->status == 'false' ) return null; $episodes = $response->response->results->result; if ( count($episodes) <= 0 ) return null; $episodeList = []; foreach ( $episodes as $episode ) $episodeList[] = $this->formatEpisode($episode); return $episodeList; }
php
public function getEpisodesOfSeason($showId, $season) { $response = $this->request('/GetEpisodesForSeason/' . $showId . '/' . $season); if ( $response->response->status == 'false' ) return null; $episodes = $response->response->results->result; if ( count($episodes) <= 0 ) return null; $episodeList = []; foreach ( $episodes as $episode ) $episodeList[] = $this->formatEpisode($episode); return $episodeList; }
[ "public", "function", "getEpisodesOfSeason", "(", "$", "showId", ",", "$", "season", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetEpisodesForSeason/'", ".", "$", "showId", ".", "'/'", ".", "$", "season", ")", ";", "if", "(", ...
Search episodes by season and Bierdopje showId @param $showId @param $season @return array|null @throws \Exception
[ "Search", "episodes", "by", "season", "and", "Bierdopje", "showId" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L129-L144
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.getEpisodeById
public function getEpisodeById($episodeId) { $response = $this->request('/GetEpisodeById/' . $episodeId); if ( $response->response->status == 'false' ) return null; if ($response->response->cached == 'false') { $episode = $response->response; } else { $episode = $response->response->results; } $episode = $this->formatEpisode($episode); return $episode; }
php
public function getEpisodeById($episodeId) { $response = $this->request('/GetEpisodeById/' . $episodeId); if ( $response->response->status == 'false' ) return null; if ($response->response->cached == 'false') { $episode = $response->response; } else { $episode = $response->response->results; } $episode = $this->formatEpisode($episode); return $episode; }
[ "public", "function", "getEpisodeById", "(", "$", "episodeId", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'/GetEpisodeById/'", ".", "$", "episodeId", ")", ";", "if", "(", "$", "response", "->", "response", "->", "status", "==", "...
Search an episode by its Bierdopje Id @param $episodeId @return \stdClass @throws \Exception
[ "Search", "an", "episode", "by", "its", "Bierdopje", "Id" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L179-L192
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.formatEpisode
private function formatEpisode($original) { $show = new \stdClass(); $show->id = (int) $original->episodeid; $show->tvdbId = (int) $original->tvdbid; $show->title = (string) $original->title; $show->showlink = (string) $original->showlink; $show->episodelink = (string) $original->episodelink; $show->airDate = strlen($original->airdate) ? Carbon::createFromFormat("d-m-Y", (string) $original->airdate) : null; $show->season = (int) $original->season; $show->episode = (int) $original->episode; $show->epNumber = (int) $original->epnumber; $show->score = (float) str_replace(',', '.', $original->score); $show->votes = (int) $original->votes; $show->formatted = (string) $original->formatted; $show->is_special = ((string) $original->is_special) === "true"; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); return $show; }
php
private function formatEpisode($original) { $show = new \stdClass(); $show->id = (int) $original->episodeid; $show->tvdbId = (int) $original->tvdbid; $show->title = (string) $original->title; $show->showlink = (string) $original->showlink; $show->episodelink = (string) $original->episodelink; $show->airDate = strlen($original->airdate) ? Carbon::createFromFormat("d-m-Y", (string) $original->airdate) : null; $show->season = (int) $original->season; $show->episode = (int) $original->episode; $show->epNumber = (int) $original->epnumber; $show->score = (float) str_replace(',', '.', $original->score); $show->votes = (int) $original->votes; $show->formatted = (string) $original->formatted; $show->is_special = ((string) $original->is_special) === "true"; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); return $show; }
[ "private", "function", "formatEpisode", "(", "$", "original", ")", "{", "$", "show", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "show", "->", "id", "=", "(", "int", ")", "$", "original", "->", "episodeid", ";", "$", "show", "->", "tvdbId", "...
Format an Episode response @param $original @return \stdClass
[ "Format", "an", "Episode", "response" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L201-L224
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.formatShow
private function formatShow($original) { $show = new \stdClass(); $show->id = (int) $original->showid; $show->tvdbId = (int) $original->tvdbid; $show->name = (string) $original->showname; $show->link = (string) $original->showlink; $show->firstAired = strlen($original->firstaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->firstaired) : null; $show->lastAired = strlen($original->lastaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->lastaired) : null; $show->nextEpisode = strlen($original->nextepisode) ? Carbon::createFromFormat('Y-m-d', (string) $original->nextepisode) : null; $show->seasons = (int) $original->seasons; $show->episodes = (int) $original->episodes; $show->genres = $original->genres->result; $show->score = (float) str_replace(',', '.', $original->score); $show->runtime = (float) str_replace(',', '.', $original->runtime); $show->favorites = (int) $original->favorites; $show->showstatus = (string) $original->showstatus; $show->airtime = (string) $original->airtime; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); $genres = []; foreach ( $show->genres as $key => $genre ) { $genre = (string) $genre; $genre = ucfirst($genre); $genres[] = $genre; } $show->genres = $genres; return $show; }
php
private function formatShow($original) { $show = new \stdClass(); $show->id = (int) $original->showid; $show->tvdbId = (int) $original->tvdbid; $show->name = (string) $original->showname; $show->link = (string) $original->showlink; $show->firstAired = strlen($original->firstaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->firstaired) : null; $show->lastAired = strlen($original->lastaired) ? Carbon::createFromFormat('Y-m-d', (string) $original->lastaired) : null; $show->nextEpisode = strlen($original->nextepisode) ? Carbon::createFromFormat('Y-m-d', (string) $original->nextepisode) : null; $show->seasons = (int) $original->seasons; $show->episodes = (int) $original->episodes; $show->genres = $original->genres->result; $show->score = (float) str_replace(',', '.', $original->score); $show->runtime = (float) str_replace(',', '.', $original->runtime); $show->favorites = (int) $original->favorites; $show->showstatus = (string) $original->showstatus; $show->airtime = (string) $original->airtime; $show->summary = (string) $original->summary; $show->updated = Carbon::createFromTimestamp((int) $original->updated); $genres = []; foreach ( $show->genres as $key => $genre ) { $genre = (string) $genre; $genre = ucfirst($genre); $genres[] = $genre; } $show->genres = $genres; return $show; }
[ "private", "function", "formatShow", "(", "$", "original", ")", "{", "$", "show", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "show", "->", "id", "=", "(", "int", ")", "$", "original", "->", "showid", ";", "$", "show", "->", "tvdbId", "=", ...
Format a Show response @param $original @return \stdClass
[ "Format", "a", "Show", "response" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L233-L269
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.request
protected function request($path) { $response = $this->client->get($this->url . $path); if ( $response->getStatusCode() != 200 ) throw new \Exception('Bierdopje.com not available'); $response = $this->xmlToObj($response->getBody()); return $response; }
php
protected function request($path) { $response = $this->client->get($this->url . $path); if ( $response->getStatusCode() != 200 ) throw new \Exception('Bierdopje.com not available'); $response = $this->xmlToObj($response->getBody()); return $response; }
[ "protected", "function", "request", "(", "$", "path", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "url", ".", "$", "path", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", ...
Make an HTTP request and format the XML resposne @param $path @return \SimpleXMLElement @throws \Exception
[ "Make", "an", "HTTP", "request", "and", "format", "the", "XML", "resposne" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L279-L289
train
mattiasdelang/Bierdopje-PHP
src/Bierdopje.php
Bierdopje.xmlToObj
private function xmlToObj($fileContents) { $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); $fileContents = trim(str_replace('"', "'", $fileContents)); $simpleXml = simplexml_load_string($fileContents, null, LIBXML_NOCDATA); return $simpleXml; }
php
private function xmlToObj($fileContents) { $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); $fileContents = trim(str_replace('"', "'", $fileContents)); $simpleXml = simplexml_load_string($fileContents, null, LIBXML_NOCDATA); return $simpleXml; }
[ "private", "function", "xmlToObj", "(", "$", "fileContents", ")", "{", "$", "fileContents", "=", "str_replace", "(", "array", "(", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\t\"", ")", ",", "''", ",", "$", "fileContents", ")", ";", "$", "fileContents", "=", "t...
Convert XML string to object @param $fileContents @return \SimpleXMLElement
[ "Convert", "XML", "string", "to", "object" ]
24ee72857c750da97546d92a16778840bf294e69
https://github.com/mattiasdelang/Bierdopje-PHP/blob/24ee72857c750da97546d92a16778840bf294e69/src/Bierdopje.php#L298-L305
train
jivoo/core
src/Binary.php
Binary.slice
public static function slice($string, $start, $length = null) { if (function_exists('mb_substr')) { return mb_substr($string, $start, $length, '8bit'); } return substr($string, $start, $length); }
php
public static function slice($string, $start, $length = null) { if (function_exists('mb_substr')) { return mb_substr($string, $start, $length, '8bit'); } return substr($string, $start, $length); }
[ "public", "static", "function", "slice", "(", "$", "string", ",", "$", "start", ",", "$", "length", "=", "null", ")", "{", "if", "(", "function_exists", "(", "'mb_substr'", ")", ")", "{", "return", "mb_substr", "(", "$", "string", ",", "$", "start", ...
Returns the portion of byte string specified by the start and length parameters. @param string $string String. @param int $start Offset to start at. @param int $length Optional length of slice. @return string Slice.
[ "Returns", "the", "portion", "of", "byte", "string", "specified", "by", "the", "start", "and", "length", "parameters", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L48-L54
train
jivoo/core
src/Binary.php
Binary.base64Encode
public static function base64Encode($data, $url = false) { if ($url) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } else { return base64_encode($data); } }
php
public static function base64Encode($data, $url = false) { if ($url) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } else { return base64_encode($data); } }
[ "public", "static", "function", "base64Encode", "(", "$", "data", ",", "$", "url", "=", "false", ")", "{", "if", "(", "$", "url", ")", "{", "return", "rtrim", "(", "strtr", "(", "base64_encode", "(", "$", "data", ")", ",", "'+/'", ",", "'-_'", ")",...
Encode binary data using base64. @param string $data String. @param bool $url 'base64url' standard. Removes padding and replaces '+' and '/' with '-' and '_'. @return string Base64 encoded string.
[ "Encode", "binary", "data", "using", "base64", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L66-L73
train
jivoo/core
src/Binary.php
Binary.base64Decode
public static function base64Decode($data, $url = true) { if ($url) { return base64_decode(strtr($data, '-_', '+/')); } else { return base64_decode($data); } }
php
public static function base64Decode($data, $url = true) { if ($url) { return base64_decode(strtr($data, '-_', '+/')); } else { return base64_decode($data); } }
[ "public", "static", "function", "base64Decode", "(", "$", "data", ",", "$", "url", "=", "true", ")", "{", "if", "(", "$", "url", ")", "{", "return", "base64_decode", "(", "strtr", "(", "$", "data", ",", "'-_'", ",", "'+/'", ")", ")", ";", "}", "e...
Decode base64 encoded string. @param string $data Base64 encoded string.. @param bool $url Whether to replace '-' and '_' with '+' and '/'. @return string Original string.
[ "Decode", "base64", "encoded", "string", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Binary.php#L84-L91
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.generateCode
public function generateCode($secret, $counter, $algorithm = 'sha512') { $key = $this->base32->decode($secret); if (empty($counter)) { return ''; } $hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true); return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT); }
php
public function generateCode($secret, $counter, $algorithm = 'sha512') { $key = $this->base32->decode($secret); if (empty($counter)) { return ''; } $hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true); return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT); }
[ "public", "function", "generateCode", "(", "$", "secret", ",", "$", "counter", ",", "$", "algorithm", "=", "'sha512'", ")", "{", "$", "key", "=", "$", "this", "->", "base32", "->", "decode", "(", "$", "secret", ")", ";", "if", "(", "empty", "(", "$...
Generates code based on timestamp and secret @param string $secret Secret shared with user @param int $counter Counter for code generation @param string $algorithm Algorithm to use for HMAC hash. Defaults to sha512. The following hash types are allowed: TOTP: sha1, sha256, sha512 HOTP: sha1 @return string Generated OTP code
[ "Generates", "code", "based", "on", "timestamp", "and", "secret" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L56-L68
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.checkTOTP
public function checkTOTP($secret, $code, $hash_type = 'sha512') { $time = $this->getTimestampCounter(time()); for ($i = -1; $i <= 1; $i++) { if ($this->stringCompare($code, $this->generateCode($secret, $time + $i, $hash_type)) === true) { return true; } } return false; }
php
public function checkTOTP($secret, $code, $hash_type = 'sha512') { $time = $this->getTimestampCounter(time()); for ($i = -1; $i <= 1; $i++) { if ($this->stringCompare($code, $this->generateCode($secret, $time + $i, $hash_type)) === true) { return true; } } return false; }
[ "public", "function", "checkTOTP", "(", "$", "secret", ",", "$", "code", ",", "$", "hash_type", "=", "'sha512'", ")", "{", "$", "time", "=", "$", "this", "->", "getTimestampCounter", "(", "time", "(", ")", ")", ";", "for", "(", "$", "i", "=", "-", ...
Check if supplied TOTP code is valid @param string $secret Secret to use for comparison @param int $code Supplied TOTP code @param string $hash_type Hash type @return bool True if code is valid, false if not
[ "Check", "if", "supplied", "TOTP", "code", "is", "valid" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L79-L92
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.checkHOTP
public function checkHOTP($secret, $counter, $code, $hash_type = 'sha512') { return $this->stringCompare($code, $this->generateCode($secret, $counter, $hash_type)); }
php
public function checkHOTP($secret, $counter, $code, $hash_type = 'sha512') { return $this->stringCompare($code, $this->generateCode($secret, $counter, $hash_type)); }
[ "public", "function", "checkHOTP", "(", "$", "secret", ",", "$", "counter", ",", "$", "code", ",", "$", "hash_type", "=", "'sha512'", ")", "{", "return", "$", "this", "->", "stringCompare", "(", "$", "code", ",", "$", "this", "->", "generateCode", "(",...
Check if supplied HOTP code is valid @param string $secret Secret to use for comparison @param int $counter Current counter @param int $code Supplied HOTP code @param string $hash_type Hash type @return bool True if code is valid, false if not
[ "Check", "if", "supplied", "HOTP", "code", "is", "valid" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L104-L107
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.truncate
protected function truncate($hash) { $truncated_hash = 0; $offset = ord(substr($hash, -1)) & 0xF; // Truncate hash using supplied sha1 hash for ($i = 0; $i < 4; ++$i) { $truncated_hash <<= 8; $truncated_hash |= ord($hash[$offset + $i]); } // Truncate to a smaller number of digits. $truncated_hash &= 0x7FFFFFFF; $truncated_hash %= self::VERIFICATION_CODE_MODULUS; return $truncated_hash; }
php
protected function truncate($hash) { $truncated_hash = 0; $offset = ord(substr($hash, -1)) & 0xF; // Truncate hash using supplied sha1 hash for ($i = 0; $i < 4; ++$i) { $truncated_hash <<= 8; $truncated_hash |= ord($hash[$offset + $i]); } // Truncate to a smaller number of digits. $truncated_hash &= 0x7FFFFFFF; $truncated_hash %= self::VERIFICATION_CODE_MODULUS; return $truncated_hash; }
[ "protected", "function", "truncate", "(", "$", "hash", ")", "{", "$", "truncated_hash", "=", "0", ";", "$", "offset", "=", "ord", "(", "substr", "(", "$", "hash", ",", "-", "1", ")", ")", "&", "0xF", ";", "// Truncate hash using supplied sha1 hash", "for...
Truncate HMAC hash to binary for generating a TOTP code @param string $hash HMAC hash @return int Truncated binary hash
[ "Truncate", "HMAC", "hash", "to", "binary", "for", "generating", "a", "TOTP", "code" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L116-L133
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.stringCompare
public function stringCompare($string_a, $string_b) { $diff = strlen($string_a) ^ strlen($string_b); for ($i = 0; $i < strlen($string_a) && $i < strlen($string_b); $i++) { $diff |= ord($string_a[$i]) ^ ord($string_b[$i]); } return $diff === 0; }
php
public function stringCompare($string_a, $string_b) { $diff = strlen($string_a) ^ strlen($string_b); for ($i = 0; $i < strlen($string_a) && $i < strlen($string_b); $i++) { $diff |= ord($string_a[$i]) ^ ord($string_b[$i]); } return $diff === 0; }
[ "public", "function", "stringCompare", "(", "$", "string_a", ",", "$", "string_b", ")", "{", "$", "diff", "=", "strlen", "(", "$", "string_a", ")", "^", "strlen", "(", "$", "string_b", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<",...
Compare two strings in constant time to prevent timing attacks. @param string $string_a Initial string @param string $string_b String to compare initial string to @return bool True if strings are the same, false if not
[ "Compare", "two", "strings", "in", "constant", "time", "to", "prevent", "timing", "attacks", "." ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L167-L177
train
marc1706/otp-authenticate
lib/OTPAuthenticate.php
OTPAuthenticate.generateSecret
public function generateSecret($length = 10) { $strong_secret = false; // Try to get $crypto_strong to evaluate to true. Give it 5 tries. for ($i = 0; $i < 5; $i++) { $secret = openssl_random_pseudo_bytes($length, $strong_secret); if ($strong_secret === true) { return $this->base32->encode($secret); } } return ''; }
php
public function generateSecret($length = 10) { $strong_secret = false; // Try to get $crypto_strong to evaluate to true. Give it 5 tries. for ($i = 0; $i < 5; $i++) { $secret = openssl_random_pseudo_bytes($length, $strong_secret); if ($strong_secret === true) { return $this->base32->encode($secret); } } return ''; }
[ "public", "function", "generateSecret", "(", "$", "length", "=", "10", ")", "{", "$", "strong_secret", "=", "false", ";", "// Try to get $crypto_strong to evaluate to true. Give it 5 tries.", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "5", ";", "$", ...
Generate secret with specified length @param int $length @return string
[ "Generate", "secret", "with", "specified", "length" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPAuthenticate.php#L186-L202
train
dlabas/DlcDiagramm
src/DlcDiagramm/Diagramm/Dependency.php
Dependency.getIdentifier
public function getIdentifier() { $identifier = $this->getFromNode()->getIdentifier() . '-' . $this->getType() . '-' . $this->getToNode()->getIdentifier(); return $identifier; }
php
public function getIdentifier() { $identifier = $this->getFromNode()->getIdentifier() . '-' . $this->getType() . '-' . $this->getToNode()->getIdentifier(); return $identifier; }
[ "public", "function", "getIdentifier", "(", ")", "{", "$", "identifier", "=", "$", "this", "->", "getFromNode", "(", ")", "->", "getIdentifier", "(", ")", ".", "'-'", ".", "$", "this", "->", "getType", "(", ")", ".", "'-'", ".", "$", "this", "->", ...
Returns the unique identifier of this node @return string
[ "Returns", "the", "unique", "identifier", "of", "this", "node" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Diagramm/Dependency.php#L78-L87
train
Niirrty/Niirrty.Translation
src/Translator.php
Translator.addSource
public function addSource( string $sourceName, ISource $source ) : Translator { $source->setLocale( $this->_locale ); $this->_sources[ $sourceName ] = $source; return $this; }
php
public function addSource( string $sourceName, ISource $source ) : Translator { $source->setLocale( $this->_locale ); $this->_sources[ $sourceName ] = $source; return $this; }
[ "public", "function", "addSource", "(", "string", "$", "sourceName", ",", "ISource", "$", "source", ")", ":", "Translator", "{", "$", "source", "->", "setLocale", "(", "$", "this", "->", "_locale", ")", ";", "$", "this", "->", "_sources", "[", "$", "so...
Adds a source with an associated name. @param string $sourceName The unique source name @param \Niirrty\Translation\Sources\ISource $source @return \Niirrty\Translation\Translator
[ "Adds", "a", "source", "with", "an", "associated", "name", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L120-L129
train
Niirrty/Niirrty.Translation
src/Translator.php
Translator.read
public function read( $identifier, ?string $sourceName = null, $defaultTranslation = false ) { if ( null !== $sourceName && isset( $this->_sources[ $sourceName ] ) ) { // read from specific source return $this->_sources[ $sourceName ]->read( $identifier, $defaultTranslation ); } foreach ( $this->_sources as $source ) { $result = $source->read( $identifier, static::USS ); if ( static::USS !== $result ) { return $result; } } return $defaultTranslation; }
php
public function read( $identifier, ?string $sourceName = null, $defaultTranslation = false ) { if ( null !== $sourceName && isset( $this->_sources[ $sourceName ] ) ) { // read from specific source return $this->_sources[ $sourceName ]->read( $identifier, $defaultTranslation ); } foreach ( $this->_sources as $source ) { $result = $source->read( $identifier, static::USS ); if ( static::USS !== $result ) { return $result; } } return $defaultTranslation; }
[ "public", "function", "read", "(", "$", "identifier", ",", "?", "string", "$", "sourceName", "=", "null", ",", "$", "defaultTranslation", "=", "false", ")", "{", "if", "(", "null", "!==", "$", "sourceName", "&&", "isset", "(", "$", "this", "->", "_sour...
Reads the translation and return it. The returned translation can be of each known type, depending to the requirements. If a valid source index is defined, only this source is used. @param string|int $identifier The translation identifier @param string|null $sourceName The name of the source or NULL for search all sources @param mixed $defaultTranslation Is returned if the translation was not found @return mixed
[ "Reads", "the", "translation", "and", "return", "it", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L172-L192
train
Niirrty/Niirrty.Translation
src/Translator.php
Translator.GetInstance
public static function GetInstance() : Translator { if ( null === self::$_instance ) { self::$_instance = new Translator(); } return self::$_instance; }
php
public static function GetInstance() : Translator { if ( null === self::$_instance ) { self::$_instance = new Translator(); } return self::$_instance; }
[ "public", "static", "function", "GetInstance", "(", ")", ":", "Translator", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "self", "::", "$", "_instance", "=", "new", "Translator", "(", ")", ";", "}", "return", "self", "::", ...
Gets the global Translator instance. If none is define a empty one is created. @return \Niirrty\Translation\Translator @throws TranslationException
[ "Gets", "the", "global", "Translator", "instance", ".", "If", "none", "is", "define", "a", "empty", "one", "is", "created", "." ]
5b1ad27fb87c14435edd2dc03e9af46dd5062de8
https://github.com/Niirrty/Niirrty.Translation/blob/5b1ad27fb87c14435edd2dc03e9af46dd5062de8/src/Translator.php#L303-L313
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.emptyConstruct
private function emptyConstruct() { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); $this->_state = CRUD::CREATE_STAT; }
php
private function emptyConstruct() { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); $this->_state = CRUD::CREATE_STAT; }
[ "private", "function", "emptyConstruct", "(", ")", "{", "$", "this", "->", "getModel", "(", ")", ";", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "columns", "(", ")", ";", "$", "this", "->", "key", "(", ")", ";", "$", "this",...
the empty constructor.
[ "the", "empty", "constructor", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L183-L190
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.mainConstruct
private function mainConstruct($key = null, $fail = false) { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); if (!is_null($key)) { $this->struct($key, $fail); $this->_state = CRUD::UPDATE_STAT; } else { $this->_state = CRUD::CREATE_STAT; } }
php
private function mainConstruct($key = null, $fail = false) { $this->getModel(); $this->getTable(); $this->columns(); $this->key(); if (!is_null($key)) { $this->struct($key, $fail); $this->_state = CRUD::UPDATE_STAT; } else { $this->_state = CRUD::CREATE_STAT; } }
[ "private", "function", "mainConstruct", "(", "$", "key", "=", "null", ",", "$", "fail", "=", "false", ")", "{", "$", "this", "->", "getModel", "(", ")", ";", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "columns", "(", ")", ";...
the main constructor to search that from database. @param int $key @param bool $fail
[ "the", "main", "constructor", "to", "search", "that", "from", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L198-L210
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.secondConstruct
private function secondConstruct($data) { $this->getModel($data); $this->getTable($data); $this->columns($data); $this->key($data); $this->fill($data); $this->_state = CRUD::UPDATE_STAT; }
php
private function secondConstruct($data) { $this->getModel($data); $this->getTable($data); $this->columns($data); $this->key($data); $this->fill($data); $this->_state = CRUD::UPDATE_STAT; }
[ "private", "function", "secondConstruct", "(", "$", "data", ")", "{", "$", "this", "->", "getModel", "(", "$", "data", ")", ";", "$", "this", "->", "getTable", "(", "$", "data", ")", ";", "$", "this", "->", "columns", "(", "$", "data", ")", ";", ...
the second Construct to fil data from array. @param array $data
[ "the", "second", "Construct", "to", "fil", "data", "from", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L217-L225
train