id
int32
0
241k
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
226,000
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/AbstractClient.php
AbstractClient.put
public function put($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); $http->setOption(CURLOPT_CUSTOMREQUEST, 'PUT'); $http->setOption(CURLOPT_URL, $uri); if ($request) { $http->setOption(CURLOPT_POSTFIELDS, $this->buildPostData($request->getQuery())); } return $http->execute(); }
php
public function put($uri, AbstractRequest $request = null) { $http = $this->getHttpClone(); $http->setOption(CURLOPT_CUSTOMREQUEST, 'PUT'); $http->setOption(CURLOPT_URL, $uri); if ($request) { $http->setOption(CURLOPT_POSTFIELDS, $this->buildPostData($request->getQuery())); } return $http->execute(); }
[ "public", "function", "put", "(", "$", "uri", ",", "AbstractRequest", "$", "request", "=", "null", ")", "{", "$", "http", "=", "$", "this", "->", "getHttpClone", "(", ")", ";", "$", "http", "->", "setOption", "(", "CURLOPT_CUSTOMREQUEST", ",", "'PUT'", ")", ";", "$", "http", "->", "setOption", "(", "CURLOPT_URL", ",", "$", "uri", ")", ";", "if", "(", "$", "request", ")", "{", "$", "http", "->", "setOption", "(", "CURLOPT_POSTFIELDS", ",", "$", "this", "->", "buildPostData", "(", "$", "request", "->", "getQuery", "(", ")", ")", ")", ";", "}", "return", "$", "http", "->", "execute", "(", ")", ";", "}" ]
Execute a PUT request against an API endpoint, optionally with a given Request object as parameters @param string $uri Endpoint URL @param AbstractRequest $request = null Request object for parameters @return string Response data
[ "Execute", "a", "PUT", "request", "against", "an", "API", "endpoint", "optionally", "with", "a", "given", "Request", "object", "as", "parameters" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/AbstractClient.php#L118-L129
226,001
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/AbstractClient.php
AbstractClient.updateCredentials
protected function updateCredentials() { if ($this->http) { $this->http->setOption(CURLOPT_USERPWD, implode(":", array( $this->getUsername(), $this->getPassword() ))); } }
php
protected function updateCredentials() { if ($this->http) { $this->http->setOption(CURLOPT_USERPWD, implode(":", array( $this->getUsername(), $this->getPassword() ))); } }
[ "protected", "function", "updateCredentials", "(", ")", "{", "if", "(", "$", "this", "->", "http", ")", "{", "$", "this", "->", "http", "->", "setOption", "(", "CURLOPT_USERPWD", ",", "implode", "(", "\":\"", ",", "array", "(", "$", "this", "->", "getUsername", "(", ")", ",", "$", "this", "->", "getPassword", "(", ")", ")", ")", ")", ";", "}", "}" ]
Rehashes the HTTP Basic Authentication on the HTTP client @return void
[ "Rehashes", "the", "HTTP", "Basic", "Authentication", "on", "the", "HTTP", "client" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/AbstractClient.php#L267-L275
226,002
infomaniac-amf/php
lib/AMF/Spec.php
Spec.isDenseArray
public static function isDenseArray($array) { $arrayLength = count($array); if(!$arrayLength) { return true; } // generate a dense array with incrementing numeric keys $keyTest = array_flip(range(0, $arrayLength - 1)); // perform a diff on the two arrays' keys - if there are any differences, // then this array is not dense. $diff = array_diff_key($keyTest, $array); return empty($diff); }
php
public static function isDenseArray($array) { $arrayLength = count($array); if(!$arrayLength) { return true; } // generate a dense array with incrementing numeric keys $keyTest = array_flip(range(0, $arrayLength - 1)); // perform a diff on the two arrays' keys - if there are any differences, // then this array is not dense. $diff = array_diff_key($keyTest, $array); return empty($diff); }
[ "public", "static", "function", "isDenseArray", "(", "$", "array", ")", "{", "$", "arrayLength", "=", "count", "(", "$", "array", ")", ";", "if", "(", "!", "$", "arrayLength", ")", "{", "return", "true", ";", "}", "// generate a dense array with incrementing numeric keys", "$", "keyTest", "=", "array_flip", "(", "range", "(", "0", ",", "$", "arrayLength", "-", "1", ")", ")", ";", "// perform a diff on the two arrays' keys - if there are any differences,", "// then this array is not dense.", "$", "diff", "=", "array_diff_key", "(", "$", "keyTest", ",", "$", "array", ")", ";", "return", "empty", "(", "$", "diff", ")", ";", "}" ]
Determine if a given array is "dense". From the AMF spec: "ordinal indices start at 0 and do not contain gaps between successive indices (that is, every index is defined from 0 for the length of the array)" @param $array @return bool
[ "Determine", "if", "a", "given", "array", "is", "dense", "." ]
1b71c125352ec562f473cd51958a03f786aa7ac9
https://github.com/infomaniac-amf/php/blob/1b71c125352ec562f473cd51958a03f786aa7ac9/lib/AMF/Spec.php#L67-L81
226,003
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.QueryContacts
public function QueryContacts(Request\QueryContacts $QueryContacts = null) { $uri = $this->getUri('/contact', array()); return $this->get($uri, $QueryContacts); }
php
public function QueryContacts(Request\QueryContacts $QueryContacts = null) { $uri = $this->getUri('/contact', array()); return $this->get($uri, $QueryContacts); }
[ "public", "function", "QueryContacts", "(", "Request", "\\", "QueryContacts", "$", "QueryContacts", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QueryContacts", ")", ";", "}" ]
Lists existing contacts Query for existing contacts using optional filters such as ContactListId, Field, etc... Returns a list of contacts and all associated info. See GetContact to return just a single contact by id. @api @param Request\QueryContacts $QueryContacts = null
[ "Lists", "existing", "contacts" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L24-L29
226,004
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.UpdateContacts
public function UpdateContacts(Request\UpdateContacts $UpdateContacts = null) { $uri = $this->getUri('/contact', array()); return $this->put($uri, $UpdateContacts); }
php
public function UpdateContacts(Request\UpdateContacts $UpdateContacts = null) { $uri = $this->getUri('/contact', array()); return $this->put($uri, $UpdateContacts); }
[ "public", "function", "UpdateContacts", "(", "Request", "\\", "UpdateContacts", "$", "UpdateContacts", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "put", "(", "$", "uri", ",", "$", "UpdateContacts", ")", ";", "}" ]
Updates existing contacts Update existing contacts. @api @param Request\UpdateContacts $UpdateContacts = null
[ "Updates", "existing", "contacts" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L39-L44
226,005
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.GetContactHistory
public function GetContactHistory($ContactId, Request\GetContactHistory $GetContactHistory) { $uri = $this->getUri('/contact/%s/history', array($ContactId)); return $this->get($uri, $GetContactHistory); }
php
public function GetContactHistory($ContactId, Request\GetContactHistory $GetContactHistory) { $uri = $this->getUri('/contact/%s/history', array($ContactId)); return $this->get($uri, $GetContactHistory); }
[ "public", "function", "GetContactHistory", "(", "$", "ContactId", ",", "Request", "\\", "GetContactHistory", "$", "GetContactHistory", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact/%s/history'", ",", "array", "(", "$", "ContactId", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "GetContactHistory", ")", ";", "}" ]
Gets a contact's history by contact ID List all calls and texts associated with a contact. @api @param int $ContactId Contact to get history @param Request\GetContactHistory $GetContactHistory
[ "Gets", "a", "contact", "s", "history", "by", "contact", "ID" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L91-L96
226,006
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.CreateContactList
public function CreateContactList(Request\CreateContactList $CreateContactList = null) { $uri = $this->getUri('/contact/list', array()); return $this->post($uri, $CreateContactList); }
php
public function CreateContactList(Request\CreateContactList $CreateContactList = null) { $uri = $this->getUri('/contact/list', array()); return $this->post($uri, $CreateContactList); }
[ "public", "function", "CreateContactList", "(", "Request", "\\", "CreateContactList", "$", "CreateContactList", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact/list'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "post", "(", "$", "uri", ",", "$", "CreateContactList", ")", ";", "}" ]
Create new contact list and add to account Add contact list to account using 1 of 4 inputs: list of contacts, numbers string, list of contactIds, or csv file containing contacts or numbers. If more then one ContactSource specified then only load from 1 source with precedence as listed above. On import contact lists go through seven system safeguards that check the accuracy of the list. For example, our system checks if a number is formatted correctly, is invalid, is duplicated in another contact list, or is on your Do Not Contact list. API calls have their default validation error resolutions set differently then the defaults set on the CallFire web site under Settings | List Validation. The API validation defaults are: LIST_COLUMNS_UNMAPPEDResolution USE_DEFAULT_COLUMNS LIST_HAS_DUPLICATE_NUMBERSResolution SCRUB LIST_HAS_DNC_CONTACTSResolution SCRUB LIST_HAS_CONTACT_CONFLICTSResolution MERGE LIST_HAS_INVALID_NUMBERSResolution SCRUB @api @param Request\CreateContactList $CreateContactList = null
[ "Create", "new", "contact", "list", "and", "add", "to", "account" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L118-L123
226,007
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.QueryContactLists
public function QueryContactLists(Request\QueryContactLists $QueryContactLists = null) { $uri = $this->getUri('/contact/list', array()); return $this->get($uri, $QueryContactLists); }
php
public function QueryContactLists(Request\QueryContactLists $QueryContactLists = null) { $uri = $this->getUri('/contact/list', array()); return $this->get($uri, $QueryContactLists); }
[ "public", "function", "QueryContactLists", "(", "Request", "\\", "QueryContactLists", "$", "QueryContactLists", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact/list'", ",", "array", "(", ")", ")", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ",", "$", "QueryContactLists", ")", ";", "}" ]
Lists existing contact lists Query for existing contact lists. Currently does no filtering and returns all contact lists. @api @param Request\QueryContactLists $QueryContactLists = null
[ "Lists", "existing", "contact", "lists" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L134-L139
226,008
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.AddContactsToList
public function AddContactsToList($ContactListId, Request\AddContactsToList $AddContactsToList) { $uri = $this->getUri('/contact/list/%s/add', array($ContactListId)); return $this->post($uri, $AddContactsToList); }
php
public function AddContactsToList($ContactListId, Request\AddContactsToList $AddContactsToList) { $uri = $this->getUri('/contact/list/%s/add', array($ContactListId)); return $this->post($uri, $AddContactsToList); }
[ "public", "function", "AddContactsToList", "(", "$", "ContactListId", ",", "Request", "\\", "AddContactsToList", "$", "AddContactsToList", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact/list/%s/add'", ",", "array", "(", "$", "ContactListId", ")", ")", ";", "return", "$", "this", "->", "post", "(", "$", "uri", ",", "$", "AddContactsToList", ")", ";", "}" ]
Adds contacts to an existing list See CreateContactList. @api @param int $ContactListId Unique ID of ContactList @param Request\AddContactsToList $AddContactsToList
[ "Adds", "contacts", "to", "an", "existing", "list" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L165-L170
226,009
CallFire/CallFire-PHP-SDK
src/CallFire/Api/Rest/Client/Contact.php
Contact.RemoveContactsFromList
public function RemoveContactsFromList($ContactListId, Request\RemoveContactsFromList $RemoveContactsFromList) { $uri = $this->getUri('/contact/list/%s/remove', array($ContactListId)); return $this->post($uri, $RemoveContactsFromList); }
php
public function RemoveContactsFromList($ContactListId, Request\RemoveContactsFromList $RemoveContactsFromList) { $uri = $this->getUri('/contact/list/%s/remove', array($ContactListId)); return $this->post($uri, $RemoveContactsFromList); }
[ "public", "function", "RemoveContactsFromList", "(", "$", "ContactListId", ",", "Request", "\\", "RemoveContactsFromList", "$", "RemoveContactsFromList", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", "'/contact/list/%s/remove'", ",", "array", "(", "$", "ContactListId", ")", ")", ";", "return", "$", "this", "->", "post", "(", "$", "uri", ",", "$", "RemoveContactsFromList", ")", ";", "}" ]
Removes contacts from a list without deleting the contacts Removes contacts from a list without deleting the contacts. @api @param int $ContactListId Unique ID of ContactList @param Request\RemoveContactsFromList $RemoveContactsFromList
[ "Removes", "contacts", "from", "a", "list", "without", "deleting", "the", "contacts" ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Api/Rest/Client/Contact.php#L197-L202
226,010
gjerokrsteski/pimf-framework
core/Pimf/Model/AsArray.php
AsArray.map
protected function map(array $properties) { $map = array(); foreach ($properties as $name => $default) { $map[$name] = (true === empty($this->$name)) ? $default : $this->$name; } return $map; }
php
protected function map(array $properties) { $map = array(); foreach ($properties as $name => $default) { $map[$name] = (true === empty($this->$name)) ? $default : $this->$name; } return $map; }
[ "protected", "function", "map", "(", "array", "$", "properties", ")", "{", "$", "map", "=", "array", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "default", ")", "{", "$", "map", "[", "$", "name", "]", "=", "(", "true", "===", "empty", "(", "$", "this", "->", "$", "name", ")", ")", "?", "$", "default", ":", "$", "this", "->", "$", "name", ";", "}", "return", "$", "map", ";", "}" ]
Maps the properties to array with actual values. For another properties-mapping, please override this method. @param array $properties @return array
[ "Maps", "the", "properties", "to", "array", "with", "actual", "values", ".", "For", "another", "properties", "-", "mapping", "please", "override", "this", "method", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Model/AsArray.php#L45-L54
226,011
infomaniac-amf/php
lib/AMF/Base.php
Base.getDataType
protected function getDataType($data) { switch (true) { case $data instanceof Undefined: return Spec::AMF3_UNDEFINED; break; case $data === null: return Spec::AMF3_NULL; break; case $data === true || $data === false: return $data ? Spec::AMF3_TRUE : Spec::AMF3_FALSE; break; case is_int($data): // AMF3 uses "Variable Length Unsigned 29-bit Integer Encoding" // ...depending on the size, we will either deserialize it as an integer or a float if ($data < Spec::MIN_INT || $data > Spec::MAX_INT) { return Spec::AMF3_DOUBLE; } return Spec::AMF3_INT; break; case is_float($data): return Spec::AMF3_DOUBLE; break; case is_string($data): return Spec::AMF3_STRING; break; case ($data instanceof DateTime): return Spec::AMF3_DATE; break; case ($data instanceof ByteArray): return Spec::AMF3_BYTE_ARRAY; break; case is_array($data): return Spec::AMF3_ARRAY; break; case is_object($data): return Spec::AMF3_OBJECT; break; default: return null; break; } }
php
protected function getDataType($data) { switch (true) { case $data instanceof Undefined: return Spec::AMF3_UNDEFINED; break; case $data === null: return Spec::AMF3_NULL; break; case $data === true || $data === false: return $data ? Spec::AMF3_TRUE : Spec::AMF3_FALSE; break; case is_int($data): // AMF3 uses "Variable Length Unsigned 29-bit Integer Encoding" // ...depending on the size, we will either deserialize it as an integer or a float if ($data < Spec::MIN_INT || $data > Spec::MAX_INT) { return Spec::AMF3_DOUBLE; } return Spec::AMF3_INT; break; case is_float($data): return Spec::AMF3_DOUBLE; break; case is_string($data): return Spec::AMF3_STRING; break; case ($data instanceof DateTime): return Spec::AMF3_DATE; break; case ($data instanceof ByteArray): return Spec::AMF3_BYTE_ARRAY; break; case is_array($data): return Spec::AMF3_ARRAY; break; case is_object($data): return Spec::AMF3_OBJECT; break; default: return null; break; } }
[ "protected", "function", "getDataType", "(", "$", "data", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "data", "instanceof", "Undefined", ":", "return", "Spec", "::", "AMF3_UNDEFINED", ";", "break", ";", "case", "$", "data", "===", "null", ":", "return", "Spec", "::", "AMF3_NULL", ";", "break", ";", "case", "$", "data", "===", "true", "||", "$", "data", "===", "false", ":", "return", "$", "data", "?", "Spec", "::", "AMF3_TRUE", ":", "Spec", "::", "AMF3_FALSE", ";", "break", ";", "case", "is_int", "(", "$", "data", ")", ":", "// AMF3 uses \"Variable Length Unsigned 29-bit Integer Encoding\"", "// ...depending on the size, we will either deserialize it as an integer or a float", "if", "(", "$", "data", "<", "Spec", "::", "MIN_INT", "||", "$", "data", ">", "Spec", "::", "MAX_INT", ")", "{", "return", "Spec", "::", "AMF3_DOUBLE", ";", "}", "return", "Spec", "::", "AMF3_INT", ";", "break", ";", "case", "is_float", "(", "$", "data", ")", ":", "return", "Spec", "::", "AMF3_DOUBLE", ";", "break", ";", "case", "is_string", "(", "$", "data", ")", ":", "return", "Spec", "::", "AMF3_STRING", ";", "break", ";", "case", "(", "$", "data", "instanceof", "DateTime", ")", ":", "return", "Spec", "::", "AMF3_DATE", ";", "break", ";", "case", "(", "$", "data", "instanceof", "ByteArray", ")", ":", "return", "Spec", "::", "AMF3_BYTE_ARRAY", ";", "break", ";", "case", "is_array", "(", "$", "data", ")", ":", "return", "Spec", "::", "AMF3_ARRAY", ";", "break", ";", "case", "is_object", "(", "$", "data", ")", ":", "return", "Spec", "::", "AMF3_OBJECT", ";", "break", ";", "default", ":", "return", "null", ";", "break", ";", "}", "}" ]
Return the AMF3 data type for given data @param $data @return int|null
[ "Return", "the", "AMF3", "data", "type", "for", "given", "data" ]
1b71c125352ec562f473cd51958a03f786aa7ac9
https://github.com/infomaniac-amf/php/blob/1b71c125352ec562f473cd51958a03f786aa7ac9/lib/AMF/Base.php#L61-L115
226,012
gamegos/php-code-sniffer
src/Gamegos/Sniffs/Strings/ConcatenationSpacingSniff.php
ConcatenationSpacingSniff.findExpected
protected function findExpected(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Find the last operator in the previous line. $prevLineOp = $phpcsFile->findPrevious( array( T_WHITESPACE, T_CONSTANT_ENCAPSED_STRING ), $stackPtr - 1, null, true ); if ($tokens[$prevLineOp]['code'] === T_EQUAL) { // Align to the assignment operator. return $tokens[$prevLineOp]['column'] - 1; } elseif ($tokens[$prevLineOp]['code'] === T_STRING_CONCAT) { // Align to the previous line. $prev2 = $phpcsFile->findPrevious(T_WHITESPACE, $prevLineOp - 1, null, true); if ($tokens[$prev2]['line'] !== $tokens[$prevLineOp]['line']) { return $tokens[$prevLineOp]['column'] - 1; } return $this->findExpected($phpcsFile, $prevLineOp); } $startOfStmt = $phpcsFile->findStartOfStatement($stackPtr); if ($tokens[$startOfStmt]['code'] == T_RETURN) { // Align to the return statement with 5 spaces. return $tokens[$startOfStmt]['column'] + 4; } // Align to the start of the statement with 4 spaces. return $tokens[$startOfStmt]['column'] + 3; }
php
protected function findExpected(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Find the last operator in the previous line. $prevLineOp = $phpcsFile->findPrevious( array( T_WHITESPACE, T_CONSTANT_ENCAPSED_STRING ), $stackPtr - 1, null, true ); if ($tokens[$prevLineOp]['code'] === T_EQUAL) { // Align to the assignment operator. return $tokens[$prevLineOp]['column'] - 1; } elseif ($tokens[$prevLineOp]['code'] === T_STRING_CONCAT) { // Align to the previous line. $prev2 = $phpcsFile->findPrevious(T_WHITESPACE, $prevLineOp - 1, null, true); if ($tokens[$prev2]['line'] !== $tokens[$prevLineOp]['line']) { return $tokens[$prevLineOp]['column'] - 1; } return $this->findExpected($phpcsFile, $prevLineOp); } $startOfStmt = $phpcsFile->findStartOfStatement($stackPtr); if ($tokens[$startOfStmt]['code'] == T_RETURN) { // Align to the return statement with 5 spaces. return $tokens[$startOfStmt]['column'] + 4; } // Align to the start of the statement with 4 spaces. return $tokens[$startOfStmt]['column'] + 3; }
[ "protected", "function", "findExpected", "(", "PHP_CodeSniffer_File", "$", "phpcsFile", ",", "$", "stackPtr", ")", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "// Find the last operator in the previous line.", "$", "prevLineOp", "=", "$", "phpcsFile", "->", "findPrevious", "(", "array", "(", "T_WHITESPACE", ",", "T_CONSTANT_ENCAPSED_STRING", ")", ",", "$", "stackPtr", "-", "1", ",", "null", ",", "true", ")", ";", "if", "(", "$", "tokens", "[", "$", "prevLineOp", "]", "[", "'code'", "]", "===", "T_EQUAL", ")", "{", "// Align to the assignment operator.", "return", "$", "tokens", "[", "$", "prevLineOp", "]", "[", "'column'", "]", "-", "1", ";", "}", "elseif", "(", "$", "tokens", "[", "$", "prevLineOp", "]", "[", "'code'", "]", "===", "T_STRING_CONCAT", ")", "{", "// Align to the previous line.", "$", "prev2", "=", "$", "phpcsFile", "->", "findPrevious", "(", "T_WHITESPACE", ",", "$", "prevLineOp", "-", "1", ",", "null", ",", "true", ")", ";", "if", "(", "$", "tokens", "[", "$", "prev2", "]", "[", "'line'", "]", "!==", "$", "tokens", "[", "$", "prevLineOp", "]", "[", "'line'", "]", ")", "{", "return", "$", "tokens", "[", "$", "prevLineOp", "]", "[", "'column'", "]", "-", "1", ";", "}", "return", "$", "this", "->", "findExpected", "(", "$", "phpcsFile", ",", "$", "prevLineOp", ")", ";", "}", "$", "startOfStmt", "=", "$", "phpcsFile", "->", "findStartOfStatement", "(", "$", "stackPtr", ")", ";", "if", "(", "$", "tokens", "[", "$", "startOfStmt", "]", "[", "'code'", "]", "==", "T_RETURN", ")", "{", "// Align to the return statement with 5 spaces.", "return", "$", "tokens", "[", "$", "startOfStmt", "]", "[", "'column'", "]", "+", "4", ";", "}", "// Align to the start of the statement with 4 spaces.", "return", "$", "tokens", "[", "$", "startOfStmt", "]", "[", "'column'", "]", "+", "3", ";", "}" ]
Find expected number of spaces to align operators. @param \PHP_CodeSniffer_File $phpcsFile @param int $stackPtr @return int
[ "Find", "expected", "number", "of", "spaces", "to", "align", "operators", "." ]
7e5939b66a55bb70eb66830b596b28e6bf3d1368
https://github.com/gamegos/php-code-sniffer/blob/7e5939b66a55bb70eb66830b596b28e6bf3d1368/src/Gamegos/Sniffs/Strings/ConcatenationSpacingSniff.php#L111-L143
226,013
infomaniac-amf/php
lib/AMF/Deserializer.php
Deserializer.createClassInstance
private function createClassInstance($className) { if (empty($className)) { return new stdClass(); } try { $refClass = new ReflectionClass($className); return $refClass->newInstance(); } catch (Exception $e) { throw new DeserializationException("Class [$className] could not be instantiated"); } }
php
private function createClassInstance($className) { if (empty($className)) { return new stdClass(); } try { $refClass = new ReflectionClass($className); return $refClass->newInstance(); } catch (Exception $e) { throw new DeserializationException("Class [$className] could not be instantiated"); } }
[ "private", "function", "createClassInstance", "(", "$", "className", ")", "{", "if", "(", "empty", "(", "$", "className", ")", ")", "{", "return", "new", "stdClass", "(", ")", ";", "}", "try", "{", "$", "refClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "return", "$", "refClass", "->", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "DeserializationException", "(", "\"Class [$className] could not be instantiated\"", ")", ";", "}", "}" ]
Create an instance of a given class Use stdClass if no class name is provided @param $className @throws \Infomaniac\Exception\DeserializationException @return object|stdClass
[ "Create", "an", "instance", "of", "a", "given", "class", "Use", "stdClass", "if", "no", "class", "name", "is", "provided" ]
1b71c125352ec562f473cd51958a03f786aa7ac9
https://github.com/infomaniac-amf/php/blob/1b71c125352ec562f473cd51958a03f786aa7ac9/lib/AMF/Deserializer.php#L239-L251
226,014
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.load
public function load($key) { if ($key !== null) { $this->session = $this->storage->load($key); } // If the session doesn't exist or is invalid. if (is_null($this->session) || static::expired($this->session)) { $this->exists = false; $this->session = $this->storage->fresh(); } // A CSRF token is stored in every session to protect // the application from cross-site request if (!$this->has(Session::CSRF)) { $this->put(Session::CSRF, Character::random(40)); } }
php
public function load($key) { if ($key !== null) { $this->session = $this->storage->load($key); } // If the session doesn't exist or is invalid. if (is_null($this->session) || static::expired($this->session)) { $this->exists = false; $this->session = $this->storage->fresh(); } // A CSRF token is stored in every session to protect // the application from cross-site request if (!$this->has(Session::CSRF)) { $this->put(Session::CSRF, Character::random(40)); } }
[ "public", "function", "load", "(", "$", "key", ")", "{", "if", "(", "$", "key", "!==", "null", ")", "{", "$", "this", "->", "session", "=", "$", "this", "->", "storage", "->", "load", "(", "$", "key", ")", ";", "}", "// If the session doesn't exist or is invalid.", "if", "(", "is_null", "(", "$", "this", "->", "session", ")", "||", "static", "::", "expired", "(", "$", "this", "->", "session", ")", ")", "{", "$", "this", "->", "exists", "=", "false", ";", "$", "this", "->", "session", "=", "$", "this", "->", "storage", "->", "fresh", "(", ")", ";", "}", "// A CSRF token is stored in every session to protect", "// the application from cross-site request", "if", "(", "!", "$", "this", "->", "has", "(", "Session", "::", "CSRF", ")", ")", "{", "$", "this", "->", "put", "(", "Session", "::", "CSRF", ",", "Character", "::", "random", "(", "40", ")", ")", ";", "}", "}" ]
Load the session for the current request. @param null|string $key
[ "Load", "the", "session", "for", "the", "current", "request", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L80-L97
226,015
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.isIn
protected function isIn($key, array $session) { if (array_key_exists($key, $session) && $session[$key] !== null) { return $session[$key]; } return null; }
php
protected function isIn($key, array $session) { if (array_key_exists($key, $session) && $session[$key] !== null) { return $session[$key]; } return null; }
[ "protected", "function", "isIn", "(", "$", "key", ",", "array", "$", "session", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "session", ")", "&&", "$", "session", "[", "$", "key", "]", "!==", "null", ")", "{", "return", "$", "session", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Checks if key is in session. @param string $key @param array $session @return mixed|null
[ "Checks", "if", "key", "is", "in", "session", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L165-L172
226,016
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.keep
public function keep($keys) { foreach ((array)$keys as $key) { $this->flash($key, $this->get($key)); } }
php
public function keep($keys) { foreach ((array)$keys as $key) { $this->flash($key, $this->get($key)); } }
[ "public", "function", "keep", "(", "$", "keys", ")", "{", "foreach", "(", "(", "array", ")", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "flash", "(", "$", "key", ",", "$", "this", "->", "get", "(", "$", "key", ")", ")", ";", "}", "}" ]
Keep a session flash item from expiring at the end of the request. @param $keys
[ "Keep", "a", "session", "flash", "item", "from", "expiring", "at", "the", "end", "of", "the", "request", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L213-L218
226,017
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.save
public function save() { $this->session['last_activity'] = time(); // age it that should expire at the end of the user's next request. $this->age(); $sessionConf = Config::get('session'); // save data into the specialized storage. $this->storage->save($this->session, $sessionConf, $this->exists); // determine the owner of the session // on the user's subsequent requests to the application. $this->cookie($sessionConf); // calculate and run garbage collection cleaning. $cleaning = $sessionConf['garbage_collection']; if (mt_rand(1, $cleaning[1]) <= $cleaning[0]) { $this->clean(); } }
php
public function save() { $this->session['last_activity'] = time(); // age it that should expire at the end of the user's next request. $this->age(); $sessionConf = Config::get('session'); // save data into the specialized storage. $this->storage->save($this->session, $sessionConf, $this->exists); // determine the owner of the session // on the user's subsequent requests to the application. $this->cookie($sessionConf); // calculate and run garbage collection cleaning. $cleaning = $sessionConf['garbage_collection']; if (mt_rand(1, $cleaning[1]) <= $cleaning[0]) { $this->clean(); } }
[ "public", "function", "save", "(", ")", "{", "$", "this", "->", "session", "[", "'last_activity'", "]", "=", "time", "(", ")", ";", "// age it that should expire at the end of the user's next request.", "$", "this", "->", "age", "(", ")", ";", "$", "sessionConf", "=", "Config", "::", "get", "(", "'session'", ")", ";", "// save data into the specialized storage.", "$", "this", "->", "storage", "->", "save", "(", "$", "this", "->", "session", ",", "$", "sessionConf", ",", "$", "this", "->", "exists", ")", ";", "// determine the owner of the session", "// on the user's subsequent requests to the application.", "$", "this", "->", "cookie", "(", "$", "sessionConf", ")", ";", "// calculate and run garbage collection cleaning.", "$", "cleaning", "=", "$", "sessionConf", "[", "'garbage_collection'", "]", ";", "if", "(", "mt_rand", "(", "1", ",", "$", "cleaning", "[", "1", "]", ")", "<=", "$", "cleaning", "[", "0", "]", ")", "{", "$", "this", "->", "clean", "(", ")", ";", "}", "}" ]
Store the session payload in storage. This method will be called automatically at the end of the request. @return void
[ "Store", "the", "session", "payload", "in", "storage", ".", "This", "method", "will", "be", "called", "automatically", "at", "the", "end", "of", "the", "request", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L273-L295
226,018
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.clean
public function clean() { if ($this->storage instanceof \Pimf\Contracts\Cleanable) { $this->storage->clean(time() - (Config::get('session.lifetime') * 60)); } }
php
public function clean() { if ($this->storage instanceof \Pimf\Contracts\Cleanable) { $this->storage->clean(time() - (Config::get('session.lifetime') * 60)); } }
[ "public", "function", "clean", "(", ")", "{", "if", "(", "$", "this", "->", "storage", "instanceof", "\\", "Pimf", "\\", "Contracts", "\\", "Cleanable", ")", "{", "$", "this", "->", "storage", "->", "clean", "(", "time", "(", ")", "-", "(", "Config", "::", "get", "(", "'session.lifetime'", ")", "*", "60", ")", ")", ";", "}", "}" ]
Clean up expired sessions. @return void
[ "Clean", "up", "expired", "sessions", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L302-L307
226,019
gjerokrsteski/pimf-framework
core/Pimf/Session/Payload.php
Payload.cookie
protected function cookie($config) { $minutes = (!$config['expire_on_close']) ? $config['lifetime'] : 0; Cookie::put($config['cookie'], $this->session['id'], $minutes, $config['path'], $config['domain'], $config['secure']); }
php
protected function cookie($config) { $minutes = (!$config['expire_on_close']) ? $config['lifetime'] : 0; Cookie::put($config['cookie'], $this->session['id'], $minutes, $config['path'], $config['domain'], $config['secure']); }
[ "protected", "function", "cookie", "(", "$", "config", ")", "{", "$", "minutes", "=", "(", "!", "$", "config", "[", "'expire_on_close'", "]", ")", "?", "$", "config", "[", "'lifetime'", "]", ":", "0", ";", "Cookie", "::", "put", "(", "$", "config", "[", "'cookie'", "]", ",", "$", "this", "->", "session", "[", "'id'", "]", ",", "$", "minutes", ",", "$", "config", "[", "'path'", "]", ",", "$", "config", "[", "'domain'", "]", ",", "$", "config", "[", "'secure'", "]", ")", ";", "}" ]
Send the session ID cookie to the browser. @param array $config @return void
[ "Send", "the", "session", "ID", "cookie", "to", "the", "browser", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session/Payload.php#L327-L333
226,020
Techworker/ssml
src/ContainerElement.php
ContainerElement.addElement
public function addElement(BaseElement $element): ContainerElement { $element->parent = $this; $this->children[] = $element; if ($element instanceof ContainerElement) { return $element; } return $this; }
php
public function addElement(BaseElement $element): ContainerElement { $element->parent = $this; $this->children[] = $element; if ($element instanceof ContainerElement) { return $element; } return $this; }
[ "public", "function", "addElement", "(", "BaseElement", "$", "element", ")", ":", "ContainerElement", "{", "$", "element", "->", "parent", "=", "$", "this", ";", "$", "this", "->", "children", "[", "]", "=", "$", "element", ";", "if", "(", "$", "element", "instanceof", "ContainerElement", ")", "{", "return", "$", "element", ";", "}", "return", "$", "this", ";", "}" ]
Adds an element instance as a child and returns either itself or the new element if its a container element. @param BaseElement $element @return ContainerElement
[ "Adds", "an", "element", "instance", "as", "a", "child", "and", "returns", "either", "itself", "or", "the", "new", "element", "if", "its", "a", "container", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/ContainerElement.php#L54-L63
226,021
Techworker/ssml
src/ContainerElement.php
ContainerElement.containerToDOM
protected function containerToDOM(\DomDocument $doc, \DomNode $node) : void { foreach ($this->children as $child) { $node->appendChild($child->toDOM($doc)); } }
php
protected function containerToDOM(\DomDocument $doc, \DomNode $node) : void { foreach ($this->children as $child) { $node->appendChild($child->toDOM($doc)); } }
[ "protected", "function", "containerToDOM", "(", "\\", "DomDocument", "$", "doc", ",", "\\", "DomNode", "$", "node", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "node", "->", "appendChild", "(", "$", "child", "->", "toDOM", "(", "$", "doc", ")", ")", ";", "}", "}" ]
Helper function that loops all children and appends them to the given \DomNode. @param \DomDocument $doc @param \DomNode $node
[ "Helper", "function", "that", "loops", "all", "children", "and", "appends", "them", "to", "the", "given", "\\", "DomNode", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/ContainerElement.php#L91-L96
226,022
Techworker/ssml
src/Traits/CustomTrait.php
CustomTrait.custom
public function custom(string $name, array $attributes): Custom { /** @var ContainerElement $this */ return $this->addElement(Custom::factory($name, $attributes)); }
php
public function custom(string $name, array $attributes): Custom { /** @var ContainerElement $this */ return $this->addElement(Custom::factory($name, $attributes)); }
[ "public", "function", "custom", "(", "string", "$", "name", ",", "array", "$", "attributes", ")", ":", "Custom", "{", "/** @var ContainerElement $this */", "return", "$", "this", "->", "addElement", "(", "Custom", "::", "factory", "(", "$", "name", ",", "$", "attributes", ")", ")", ";", "}" ]
Adds a new custom element. @param string $name @param array $attributes @return Custom
[ "Adds", "a", "new", "custom", "element", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Traits/CustomTrait.php#L30-L34
226,023
mlanin/laravel-setup-wizard
src/Commands/Setup.php
Setup.runSteps
protected function runSteps($steps = [], $pretend = false) { $return = true; $steps = empty($steps) ? array_keys($this->steps) : $steps; foreach ($steps as $step) { if ($this->runStep($step, $pretend) === false) { $return = false; } } return $return; }
php
protected function runSteps($steps = [], $pretend = false) { $return = true; $steps = empty($steps) ? array_keys($this->steps) : $steps; foreach ($steps as $step) { if ($this->runStep($step, $pretend) === false) { $return = false; } } return $return; }
[ "protected", "function", "runSteps", "(", "$", "steps", "=", "[", "]", ",", "$", "pretend", "=", "false", ")", "{", "$", "return", "=", "true", ";", "$", "steps", "=", "empty", "(", "$", "steps", ")", "?", "array_keys", "(", "$", "this", "->", "steps", ")", ":", "$", "steps", ";", "foreach", "(", "$", "steps", "as", "$", "step", ")", "{", "if", "(", "$", "this", "->", "runStep", "(", "$", "step", ",", "$", "pretend", ")", "===", "false", ")", "{", "$", "return", "=", "false", ";", "}", "}", "return", "$", "return", ";", "}" ]
Run all steps one by one. @param array $steps @param bool $pretend @return bool
[ "Run", "all", "steps", "one", "by", "one", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Setup.php#L83-L97
226,024
mlanin/laravel-setup-wizard
src/Commands/Setup.php
Setup.runStep
protected function runStep($step, $pretend = false) { try { $step = $this->createStep($step); if ($this->confirm($step->prompt(), true)) { return $step->run($pretend); } } catch (\Exception $e) { $this->error($e->getMessage()); } return false; }
php
protected function runStep($step, $pretend = false) { try { $step = $this->createStep($step); if ($this->confirm($step->prompt(), true)) { return $step->run($pretend); } } catch (\Exception $e) { $this->error($e->getMessage()); } return false; }
[ "protected", "function", "runStep", "(", "$", "step", ",", "$", "pretend", "=", "false", ")", "{", "try", "{", "$", "step", "=", "$", "this", "->", "createStep", "(", "$", "step", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "$", "step", "->", "prompt", "(", ")", ",", "true", ")", ")", "{", "return", "$", "step", "->", "run", "(", "$", "pretend", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Run installation step @param string $step @param bool $pretend @return bool
[ "Run", "installation", "step" ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Setup.php#L106-L123
226,025
mlanin/laravel-setup-wizard
src/Commands/Setup.php
Setup.createStep
protected function createStep($step) { if ( ! $this->stepExist($step)) { throw new \Exception("Step <comment>{$step}</comment> doesn't exist."); } $class = $this->steps[$step]; $step = new $class($this); if ( ! ($step instanceof AbstractStep)) { throw new \Exception("Step class <comment>{$class}</comment> should be an instance of AbstractStep."); } return $step; }
php
protected function createStep($step) { if ( ! $this->stepExist($step)) { throw new \Exception("Step <comment>{$step}</comment> doesn't exist."); } $class = $this->steps[$step]; $step = new $class($this); if ( ! ($step instanceof AbstractStep)) { throw new \Exception("Step class <comment>{$class}</comment> should be an instance of AbstractStep."); } return $step; }
[ "protected", "function", "createStep", "(", "$", "step", ")", "{", "if", "(", "!", "$", "this", "->", "stepExist", "(", "$", "step", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Step <comment>{$step}</comment> doesn't exist.\"", ")", ";", "}", "$", "class", "=", "$", "this", "->", "steps", "[", "$", "step", "]", ";", "$", "step", "=", "new", "$", "class", "(", "$", "this", ")", ";", "if", "(", "!", "(", "$", "step", "instanceof", "AbstractStep", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Step class <comment>{$class}</comment> should be an instance of AbstractStep.\"", ")", ";", "}", "return", "$", "step", ";", "}" ]
Instantiate step class. @param string $step @return AbstractStep @throws \Exception
[ "Instantiate", "step", "class", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Setup.php#L132-L148
226,026
mlanin/laravel-setup-wizard
src/Commands/Setup.php
Setup.stepExist
protected function stepExist($step) { return isset($this->steps[$step]) && class_exists($this->steps[$step]); }
php
protected function stepExist($step) { return isset($this->steps[$step]) && class_exists($this->steps[$step]); }
[ "protected", "function", "stepExist", "(", "$", "step", ")", "{", "return", "isset", "(", "$", "this", "->", "steps", "[", "$", "step", "]", ")", "&&", "class_exists", "(", "$", "this", "->", "steps", "[", "$", "step", "]", ")", ";", "}" ]
Check if step exists. @param string $step @return bool
[ "Check", "if", "step", "exists", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Setup.php#L156-L159
226,027
Daursu/postcode-lookup
src/Postcode.php
Postcode.lookup
public function lookup($postcode) { // Mutate the postcode $postcode = $this->mutatePostcode($postcode); // Sanitize the postcode: $coords = $this->getCoordinates($postcode); // If empty, we must have no results if (empty($coords)) { return []; } // A second call will now retrieve the address $address_url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . $coords['latitude'] . ',' . $coords['longitude'] . '&sensor=false'; $address_json = $this->api->fetch($address_url); // The correct result is not always the first one, so loop through results here foreach ($address_json->results as $current_address) { foreach ($current_address->address_components as $component) { // If this address_component is a postcode and matches... if(array_search('postal_code', $component->types) !== FALSE && $postcode == $this->mutatePostcode($component->long_name) ) { $address_data = $current_address->address_components; break 2; } } } // If no exact match found, use the first as a closest option if (!isset($address_data) && !empty($address_json->results) ) { $address_data = $address_json->results[0]->address_components; } // If still nothing, return empty array if (!isset($address_data)) { return []; } // Initialize all values as empty $street_number = ''; $street = ''; $sublocality = ''; $town = ''; $county = ''; $country = ''; // Process the return foreach ($address_data as $value) { if (array_search('street_number', $value->types) !== FALSE) { $street_number = $value->long_name; } elseif (array_search('route', $value->types) !== FALSE) { $street = $value->long_name; } elseif (array_search('sublocality', $value->types) !== FALSE) { $sublocality = $value->long_name; } elseif (array_search('locality', $value->types) !== FALSE) { $town = $value->long_name; } elseif (array_search('administrative_area_level_2', $value->types) !== FALSE) { $county = $value->long_name; } elseif (array_search('country', $value->types) !== FALSE) { $country = $value->long_name; } } return [ 'postcode' => $postcode, 'street_number' => $street_number, 'street' => $street, 'sublocality' => $sublocality, 'town' => $town, 'county' => $county, 'country' => $country, 'latitude' => $coords['latitude'], 'longitude' => $coords['longitude'] ]; }
php
public function lookup($postcode) { // Mutate the postcode $postcode = $this->mutatePostcode($postcode); // Sanitize the postcode: $coords = $this->getCoordinates($postcode); // If empty, we must have no results if (empty($coords)) { return []; } // A second call will now retrieve the address $address_url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . $coords['latitude'] . ',' . $coords['longitude'] . '&sensor=false'; $address_json = $this->api->fetch($address_url); // The correct result is not always the first one, so loop through results here foreach ($address_json->results as $current_address) { foreach ($current_address->address_components as $component) { // If this address_component is a postcode and matches... if(array_search('postal_code', $component->types) !== FALSE && $postcode == $this->mutatePostcode($component->long_name) ) { $address_data = $current_address->address_components; break 2; } } } // If no exact match found, use the first as a closest option if (!isset($address_data) && !empty($address_json->results) ) { $address_data = $address_json->results[0]->address_components; } // If still nothing, return empty array if (!isset($address_data)) { return []; } // Initialize all values as empty $street_number = ''; $street = ''; $sublocality = ''; $town = ''; $county = ''; $country = ''; // Process the return foreach ($address_data as $value) { if (array_search('street_number', $value->types) !== FALSE) { $street_number = $value->long_name; } elseif (array_search('route', $value->types) !== FALSE) { $street = $value->long_name; } elseif (array_search('sublocality', $value->types) !== FALSE) { $sublocality = $value->long_name; } elseif (array_search('locality', $value->types) !== FALSE) { $town = $value->long_name; } elseif (array_search('administrative_area_level_2', $value->types) !== FALSE) { $county = $value->long_name; } elseif (array_search('country', $value->types) !== FALSE) { $country = $value->long_name; } } return [ 'postcode' => $postcode, 'street_number' => $street_number, 'street' => $street, 'sublocality' => $sublocality, 'town' => $town, 'county' => $county, 'country' => $country, 'latitude' => $coords['latitude'], 'longitude' => $coords['longitude'] ]; }
[ "public", "function", "lookup", "(", "$", "postcode", ")", "{", "// Mutate the postcode", "$", "postcode", "=", "$", "this", "->", "mutatePostcode", "(", "$", "postcode", ")", ";", "// Sanitize the postcode:", "$", "coords", "=", "$", "this", "->", "getCoordinates", "(", "$", "postcode", ")", ";", "// If empty, we must have no results", "if", "(", "empty", "(", "$", "coords", ")", ")", "{", "return", "[", "]", ";", "}", "// A second call will now retrieve the address", "$", "address_url", "=", "'https://maps.googleapis.com/maps/api/geocode/json?latlng='", ".", "$", "coords", "[", "'latitude'", "]", ".", "','", ".", "$", "coords", "[", "'longitude'", "]", ".", "'&sensor=false'", ";", "$", "address_json", "=", "$", "this", "->", "api", "->", "fetch", "(", "$", "address_url", ")", ";", "// The correct result is not always the first one, so loop through results here", "foreach", "(", "$", "address_json", "->", "results", "as", "$", "current_address", ")", "{", "foreach", "(", "$", "current_address", "->", "address_components", "as", "$", "component", ")", "{", "// If this address_component is a postcode and matches...", "if", "(", "array_search", "(", "'postal_code'", ",", "$", "component", "->", "types", ")", "!==", "FALSE", "&&", "$", "postcode", "==", "$", "this", "->", "mutatePostcode", "(", "$", "component", "->", "long_name", ")", ")", "{", "$", "address_data", "=", "$", "current_address", "->", "address_components", ";", "break", "2", ";", "}", "}", "}", "// If no exact match found, use the first as a closest option", "if", "(", "!", "isset", "(", "$", "address_data", ")", "&&", "!", "empty", "(", "$", "address_json", "->", "results", ")", ")", "{", "$", "address_data", "=", "$", "address_json", "->", "results", "[", "0", "]", "->", "address_components", ";", "}", "// If still nothing, return empty array", "if", "(", "!", "isset", "(", "$", "address_data", ")", ")", "{", "return", "[", "]", ";", "}", "// Initialize all values as empty", "$", "street_number", "=", "''", ";", "$", "street", "=", "''", ";", "$", "sublocality", "=", "''", ";", "$", "town", "=", "''", ";", "$", "county", "=", "''", ";", "$", "country", "=", "''", ";", "// Process the return", "foreach", "(", "$", "address_data", "as", "$", "value", ")", "{", "if", "(", "array_search", "(", "'street_number'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "street_number", "=", "$", "value", "->", "long_name", ";", "}", "elseif", "(", "array_search", "(", "'route'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "street", "=", "$", "value", "->", "long_name", ";", "}", "elseif", "(", "array_search", "(", "'sublocality'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "sublocality", "=", "$", "value", "->", "long_name", ";", "}", "elseif", "(", "array_search", "(", "'locality'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "town", "=", "$", "value", "->", "long_name", ";", "}", "elseif", "(", "array_search", "(", "'administrative_area_level_2'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "county", "=", "$", "value", "->", "long_name", ";", "}", "elseif", "(", "array_search", "(", "'country'", ",", "$", "value", "->", "types", ")", "!==", "FALSE", ")", "{", "$", "country", "=", "$", "value", "->", "long_name", ";", "}", "}", "return", "[", "'postcode'", "=>", "$", "postcode", ",", "'street_number'", "=>", "$", "street_number", ",", "'street'", "=>", "$", "street", ",", "'sublocality'", "=>", "$", "sublocality", ",", "'town'", "=>", "$", "town", ",", "'county'", "=>", "$", "county", ",", "'country'", "=>", "$", "country", ",", "'latitude'", "=>", "$", "coords", "[", "'latitude'", "]", ",", "'longitude'", "=>", "$", "coords", "[", "'longitude'", "]", "]", ";", "}" ]
Retrieves the full address for a given postcode. @param $postcode @return array
[ "Retrieves", "the", "full", "address", "for", "a", "given", "postcode", "." ]
5afb74a3e297d06bfd3ea7681c0005a4c4088f92
https://github.com/Daursu/postcode-lookup/blob/5afb74a3e297d06bfd3ea7681c0005a4c4088f92/src/Postcode.php#L36-L115
226,028
Techworker/ssml
src/Element/SayAs.php
SayAs.factory
public static function factory(string $interpretAs, string $content, string $format = null) { $instance = new static(); $instance->interpretAs = $interpretAs; $instance->content = $content; $instance->format = $format; return $instance; }
php
public static function factory(string $interpretAs, string $content, string $format = null) { $instance = new static(); $instance->interpretAs = $interpretAs; $instance->content = $content; $instance->format = $format; return $instance; }
[ "public", "static", "function", "factory", "(", "string", "$", "interpretAs", ",", "string", "$", "content", ",", "string", "$", "format", "=", "null", ")", "{", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "instance", "->", "interpretAs", "=", "$", "interpretAs", ";", "$", "instance", "->", "content", "=", "$", "content", ";", "$", "instance", "->", "format", "=", "$", "format", ";", "return", "$", "instance", ";", "}" ]
Creates a say-as element with the given values as attributes. @param string $interpretAs @param string $content @param string|null $format @return static
[ "Creates", "a", "say", "-", "as", "element", "with", "the", "given", "values", "as", "attributes", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Element/SayAs.php#L53-L61
226,029
Daursu/postcode-lookup
src/GoogleApi.php
GoogleApi.fetch
public function fetch($url) { if ($this->apiKey) { $url .= '&key='.$this->apiKey; } try { $json = json_decode(file_get_contents($url)); } catch(\Exception $e) { throw new ServiceUnavailableException; } $this->checkApiError($json); return $json; }
php
public function fetch($url) { if ($this->apiKey) { $url .= '&key='.$this->apiKey; } try { $json = json_decode(file_get_contents($url)); } catch(\Exception $e) { throw new ServiceUnavailableException; } $this->checkApiError($json); return $json; }
[ "public", "function", "fetch", "(", "$", "url", ")", "{", "if", "(", "$", "this", "->", "apiKey", ")", "{", "$", "url", ".=", "'&key='", ".", "$", "this", "->", "apiKey", ";", "}", "try", "{", "$", "json", "=", "json_decode", "(", "file_get_contents", "(", "$", "url", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "ServiceUnavailableException", ";", "}", "$", "this", "->", "checkApiError", "(", "$", "json", ")", ";", "return", "$", "json", ";", "}" ]
Calls the Google API. @param string $url @return \stdClass @throws ServiceUnavailableException
[ "Calls", "the", "Google", "API", "." ]
5afb74a3e297d06bfd3ea7681c0005a4c4088f92
https://github.com/Daursu/postcode-lookup/blob/5afb74a3e297d06bfd3ea7681c0005a4c4088f92/src/GoogleApi.php#L43-L58
226,030
eosnewmedia/JSON-API-Common
src/Model/Resource/Extension/RelatedMetaInformationTrait.php
RelatedMetaInformationTrait.relatedMetaInformation
public function relatedMetaInformation(): KeyValueCollectionInterface { if (!$this->relatedMetaInformation instanceof KeyValueCollectionInterface) { $this->relatedMetaInformation = new KeyValueCollection(); } return $this->relatedMetaInformation; }
php
public function relatedMetaInformation(): KeyValueCollectionInterface { if (!$this->relatedMetaInformation instanceof KeyValueCollectionInterface) { $this->relatedMetaInformation = new KeyValueCollection(); } return $this->relatedMetaInformation; }
[ "public", "function", "relatedMetaInformation", "(", ")", ":", "KeyValueCollectionInterface", "{", "if", "(", "!", "$", "this", "->", "relatedMetaInformation", "instanceof", "KeyValueCollectionInterface", ")", "{", "$", "this", "->", "relatedMetaInformation", "=", "new", "KeyValueCollection", "(", ")", ";", "}", "return", "$", "this", "->", "relatedMetaInformation", ";", "}" ]
This method provides additional meta information for a resource identifier object in the context of relationship data @return KeyValueCollectionInterface
[ "This", "method", "provides", "additional", "meta", "information", "for", "a", "resource", "identifier", "object", "in", "the", "context", "of", "relationship", "data" ]
d868eb4d76bf75518f1bb72a70e5abf78fcae476
https://github.com/eosnewmedia/JSON-API-Common/blob/d868eb4d76bf75518f1bb72a70e5abf78fcae476/src/Model/Resource/Extension/RelatedMetaInformationTrait.php#L24-L31
226,031
gjerokrsteski/pimf-framework
core/Pimf/Util/Xml.php
Xml.toDOMDocument
public static function toDOMDocument($xml) { if ($xml instanceof \DOMDocument) { return $xml; } if ($xml instanceof \SimpleXMLElement) { $doc = new \DOMDocument(); $doc->loadXML('' . $xml->asXML()); return $doc; } if (is_string($xml)) { $doc = new \DOMDocument(); if (is_file($xml)) { $doc->load($xml); return $doc; } $doc->loadXML($xml); return $doc; } $type = is_object($xml) ? get_class($xml) : gettype($xml); throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument"); }
php
public static function toDOMDocument($xml) { if ($xml instanceof \DOMDocument) { return $xml; } if ($xml instanceof \SimpleXMLElement) { $doc = new \DOMDocument(); $doc->loadXML('' . $xml->asXML()); return $doc; } if (is_string($xml)) { $doc = new \DOMDocument(); if (is_file($xml)) { $doc->load($xml); return $doc; } $doc->loadXML($xml); return $doc; } $type = is_object($xml) ? get_class($xml) : gettype($xml); throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument"); }
[ "public", "static", "function", "toDOMDocument", "(", "$", "xml", ")", "{", "if", "(", "$", "xml", "instanceof", "\\", "DOMDocument", ")", "{", "return", "$", "xml", ";", "}", "if", "(", "$", "xml", "instanceof", "\\", "SimpleXMLElement", ")", "{", "$", "doc", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "doc", "->", "loadXML", "(", "''", ".", "$", "xml", "->", "asXML", "(", ")", ")", ";", "return", "$", "doc", ";", "}", "if", "(", "is_string", "(", "$", "xml", ")", ")", "{", "$", "doc", "=", "new", "\\", "DOMDocument", "(", ")", ";", "if", "(", "is_file", "(", "$", "xml", ")", ")", "{", "$", "doc", "->", "load", "(", "$", "xml", ")", ";", "return", "$", "doc", ";", "}", "$", "doc", "->", "loadXML", "(", "$", "xml", ")", ";", "return", "$", "doc", ";", "}", "$", "type", "=", "is_object", "(", "$", "xml", ")", "?", "get_class", "(", "$", "xml", ")", ":", "gettype", "(", "$", "xml", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Cannot convert instance of '$type' to DOMDocument\"", ")", ";", "}" ]
Convert anything DOMDocument|SimpleXMLElement|string to DOMDocument. @param \DOMDocument|\SimpleXMLElement|string $xml String may be filename or xml string @throws \InvalidArgumentException @return \DOMDocument
[ "Convert", "anything", "DOMDocument|SimpleXMLElement|string", "to", "DOMDocument", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Xml.php#L27-L57
226,032
gjerokrsteski/pimf-framework
core/Pimf/Util/Xml.php
Xml.toSimpleXMLElement
public static function toSimpleXMLElement($xml) { if ($xml instanceof \SimpleXMLElement) { return $xml; } if ($xml instanceof \DOMDocument) { return simplexml_import_dom($xml); } if (is_string($xml)) { if (is_file($xml)) { return simplexml_load_file($xml); } return simplexml_load_string($xml); } $type = is_object($xml) ? get_class($xml) : gettype($xml); throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument"); }
php
public static function toSimpleXMLElement($xml) { if ($xml instanceof \SimpleXMLElement) { return $xml; } if ($xml instanceof \DOMDocument) { return simplexml_import_dom($xml); } if (is_string($xml)) { if (is_file($xml)) { return simplexml_load_file($xml); } return simplexml_load_string($xml); } $type = is_object($xml) ? get_class($xml) : gettype($xml); throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument"); }
[ "public", "static", "function", "toSimpleXMLElement", "(", "$", "xml", ")", "{", "if", "(", "$", "xml", "instanceof", "\\", "SimpleXMLElement", ")", "{", "return", "$", "xml", ";", "}", "if", "(", "$", "xml", "instanceof", "\\", "DOMDocument", ")", "{", "return", "simplexml_import_dom", "(", "$", "xml", ")", ";", "}", "if", "(", "is_string", "(", "$", "xml", ")", ")", "{", "if", "(", "is_file", "(", "$", "xml", ")", ")", "{", "return", "simplexml_load_file", "(", "$", "xml", ")", ";", "}", "return", "simplexml_load_string", "(", "$", "xml", ")", ";", "}", "$", "type", "=", "is_object", "(", "$", "xml", ")", "?", "get_class", "(", "$", "xml", ")", ":", "gettype", "(", "$", "xml", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Cannot convert instance of '$type' to DOMDocument\"", ")", ";", "}" ]
Convert anything DOMDocument|SimpleXMLElement|string to SimpleXMLElement. @param \DOMDocument|\SimpleXMLElement|string $xml String may be filename or xml string @throws \InvalidArgumentException @return \SimpleXMLElement
[ "Convert", "anything", "DOMDocument|SimpleXMLElement|string", "to", "SimpleXMLElement", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Xml.php#L67-L89
226,033
gjerokrsteski/pimf-framework
core/Pimf/Util/Xml.php
Xml.toArray
public static function toArray(\SimpleXMLElement $xml, $namespace = null) { if ($namespace !== null) { $namespaces = $xml->getNamespaces(); if (false === isset($namespaces[$namespace])) { throw new \OutOfBoundsException('namespace [' . $namespace . '] not found'); } $xml = $xml->children($namespaces[$namespace]); } return Json::decode(Json::encode($xml), true); }
php
public static function toArray(\SimpleXMLElement $xml, $namespace = null) { if ($namespace !== null) { $namespaces = $xml->getNamespaces(); if (false === isset($namespaces[$namespace])) { throw new \OutOfBoundsException('namespace [' . $namespace . '] not found'); } $xml = $xml->children($namespaces[$namespace]); } return Json::decode(Json::encode($xml), true); }
[ "public", "static", "function", "toArray", "(", "\\", "SimpleXMLElement", "$", "xml", ",", "$", "namespace", "=", "null", ")", "{", "if", "(", "$", "namespace", "!==", "null", ")", "{", "$", "namespaces", "=", "$", "xml", "->", "getNamespaces", "(", ")", ";", "if", "(", "false", "===", "isset", "(", "$", "namespaces", "[", "$", "namespace", "]", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'namespace ['", ".", "$", "namespace", ".", "'] not found'", ")", ";", "}", "$", "xml", "=", "$", "xml", "->", "children", "(", "$", "namespaces", "[", "$", "namespace", "]", ")", ";", "}", "return", "Json", "::", "decode", "(", "Json", "::", "encode", "(", "$", "xml", ")", ",", "true", ")", ";", "}" ]
Convert SimpleXMLElement to multidimensional array. @param \SimpleXMLElement $xml @param string $namespace The namespace that schould be used. @throws \OutOfBoundsException If namespace not found in the xml. @return array
[ "Convert", "SimpleXMLElement", "to", "multidimensional", "array", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Xml.php#L100-L114
226,034
sop/gcm
lib/GCM/GCM.php
GCM._generateJ0
private function _generateJ0(string $IV, GHASH $ghash): string { // if len(IV) = 96 if (12 == strlen($IV)) { return $IV . "\0\0\0\1"; } $data = self::_pad128($IV) . self::ZB_64 . self::_uint64( strlen($IV) << 3); return $ghash($data); }
php
private function _generateJ0(string $IV, GHASH $ghash): string { // if len(IV) = 96 if (12 == strlen($IV)) { return $IV . "\0\0\0\1"; } $data = self::_pad128($IV) . self::ZB_64 . self::_uint64( strlen($IV) << 3); return $ghash($data); }
[ "private", "function", "_generateJ0", "(", "string", "$", "IV", ",", "GHASH", "$", "ghash", ")", ":", "string", "{", "// if len(IV) = 96", "if", "(", "12", "==", "strlen", "(", "$", "IV", ")", ")", "{", "return", "$", "IV", ".", "\"\\0\\0\\0\\1\"", ";", "}", "$", "data", "=", "self", "::", "_pad128", "(", "$", "IV", ")", ".", "self", "::", "ZB_64", ".", "self", "::", "_uint64", "(", "strlen", "(", "$", "IV", ")", "<<", "3", ")", ";", "return", "$", "ghash", "(", "$", "data", ")", ";", "}" ]
Generate pre-counter block. See NIST SP-300-38D section 7.1 step 2 for the details. @param string $IV Initialization vector @param GHASH $ghash GHASH functor @return string
[ "Generate", "pre", "-", "counter", "block", "." ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L136-L145
226,035
sop/gcm
lib/GCM/GCM.php
GCM._gctr
private function _gctr(string $ICB, string $X, string $K): string { // if data is an empty string, return an empty string if ("" == $X) { return ""; } // number of blocks $n = ceil(strlen($X) / 16); $CB = $ICB; $Y = ""; for ($i = 0; $i < $n - 1; ++$i) { // plaintext block $xi = substr($X, $i << 4, 16); // encrypt block and append to Y $Y .= $xi ^ $this->_cipher->encrypt($CB, $K); // increment counter block $CB = self::_inc32($CB); } // final block $xn = substr($X, $i << 4); // XOR against partial block $Y .= $xn ^ substr($this->_cipher->encrypt($CB, $K), 0, strlen($xn)); return $Y; }
php
private function _gctr(string $ICB, string $X, string $K): string { // if data is an empty string, return an empty string if ("" == $X) { return ""; } // number of blocks $n = ceil(strlen($X) / 16); $CB = $ICB; $Y = ""; for ($i = 0; $i < $n - 1; ++$i) { // plaintext block $xi = substr($X, $i << 4, 16); // encrypt block and append to Y $Y .= $xi ^ $this->_cipher->encrypt($CB, $K); // increment counter block $CB = self::_inc32($CB); } // final block $xn = substr($X, $i << 4); // XOR against partial block $Y .= $xn ^ substr($this->_cipher->encrypt($CB, $K), 0, strlen($xn)); return $Y; }
[ "private", "function", "_gctr", "(", "string", "$", "ICB", ",", "string", "$", "X", ",", "string", "$", "K", ")", ":", "string", "{", "// if data is an empty string, return an empty string", "if", "(", "\"\"", "==", "$", "X", ")", "{", "return", "\"\"", ";", "}", "// number of blocks", "$", "n", "=", "ceil", "(", "strlen", "(", "$", "X", ")", "/", "16", ")", ";", "$", "CB", "=", "$", "ICB", ";", "$", "Y", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "n", "-", "1", ";", "++", "$", "i", ")", "{", "// plaintext block", "$", "xi", "=", "substr", "(", "$", "X", ",", "$", "i", "<<", "4", ",", "16", ")", ";", "// encrypt block and append to Y", "$", "Y", ".=", "$", "xi", "^", "$", "this", "->", "_cipher", "->", "encrypt", "(", "$", "CB", ",", "$", "K", ")", ";", "// increment counter block", "$", "CB", "=", "self", "::", "_inc32", "(", "$", "CB", ")", ";", "}", "// final block", "$", "xn", "=", "substr", "(", "$", "X", ",", "$", "i", "<<", "4", ")", ";", "// XOR against partial block", "$", "Y", ".=", "$", "xn", "^", "substr", "(", "$", "this", "->", "_cipher", "->", "encrypt", "(", "$", "CB", ",", "$", "K", ")", ",", "0", ",", "strlen", "(", "$", "xn", ")", ")", ";", "return", "$", "Y", ";", "}" ]
Apply GCTR algorithm. See NIST SP-300-38D section 6.5 for the details. @param string $ICB Initial counter block @param string $X Input data @param string $K Encryption key @return string Output data
[ "Apply", "GCTR", "algorithm", "." ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L157-L180
226,036
sop/gcm
lib/GCM/GCM.php
GCM._computeAuthTag
private function _computeAuthTag(string $A, string $C, string $J0, string $K, GHASH $ghash): string { $data = self::_pad128($A) . self::_pad128($C) . self::_uint64(strlen($A) << 3) . self::_uint64(strlen($C) << 3); $S = $ghash($data); return substr($this->_gctr($J0, $S, $K), 0, $this->_tagLength); }
php
private function _computeAuthTag(string $A, string $C, string $J0, string $K, GHASH $ghash): string { $data = self::_pad128($A) . self::_pad128($C) . self::_uint64(strlen($A) << 3) . self::_uint64(strlen($C) << 3); $S = $ghash($data); return substr($this->_gctr($J0, $S, $K), 0, $this->_tagLength); }
[ "private", "function", "_computeAuthTag", "(", "string", "$", "A", ",", "string", "$", "C", ",", "string", "$", "J0", ",", "string", "$", "K", ",", "GHASH", "$", "ghash", ")", ":", "string", "{", "$", "data", "=", "self", "::", "_pad128", "(", "$", "A", ")", ".", "self", "::", "_pad128", "(", "$", "C", ")", ".", "self", "::", "_uint64", "(", "strlen", "(", "$", "A", ")", "<<", "3", ")", ".", "self", "::", "_uint64", "(", "strlen", "(", "$", "C", ")", "<<", "3", ")", ";", "$", "S", "=", "$", "ghash", "(", "$", "data", ")", ";", "return", "substr", "(", "$", "this", "->", "_gctr", "(", "$", "J0", ",", "$", "S", ",", "$", "K", ")", ",", "0", ",", "$", "this", "->", "_tagLength", ")", ";", "}" ]
Compute authentication tag See NIST SP-300-38D section 7.1 steps 5-6 for the details. @param string $A Additional authenticated data @param string $C Ciphertext @param string $J0 Pre-counter block @param string $K Encryption key @param GHASH $ghash GHASH functor @return string Authentication tag <code>T</code>
[ "Compute", "authentication", "tag" ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L194-L201
226,037
sop/gcm
lib/GCM/GCM.php
GCM._pad128
private static function _pad128($data) { $padlen = 16 - strlen($data) % 16; if (16 != $padlen) { $data .= str_repeat("\0", $padlen); } return $data; }
php
private static function _pad128($data) { $padlen = 16 - strlen($data) % 16; if (16 != $padlen) { $data .= str_repeat("\0", $padlen); } return $data; }
[ "private", "static", "function", "_pad128", "(", "$", "data", ")", "{", "$", "padlen", "=", "16", "-", "strlen", "(", "$", "data", ")", "%", "16", ";", "if", "(", "16", "!=", "$", "padlen", ")", "{", "$", "data", ".=", "str_repeat", "(", "\"\\0\"", ",", "$", "padlen", ")", ";", "}", "return", "$", "data", ";", "}" ]
Pad data to 128 bit block boundary. @param string $data @return string
[ "Pad", "data", "to", "128", "bit", "block", "boundary", "." ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L209-L216
226,038
sop/gcm
lib/GCM/GCM.php
GCM._inc32
private static function _inc32(string $X): string { $Y = substr($X, 0, -4); // increment counter $n = self::strToGMP(substr($X, -4)) + 1; // wrap by using only the 32 rightmost bits $Y .= substr(self::gmpToStr($n, 4), -4); return $Y; }
php
private static function _inc32(string $X): string { $Y = substr($X, 0, -4); // increment counter $n = self::strToGMP(substr($X, -4)) + 1; // wrap by using only the 32 rightmost bits $Y .= substr(self::gmpToStr($n, 4), -4); return $Y; }
[ "private", "static", "function", "_inc32", "(", "string", "$", "X", ")", ":", "string", "{", "$", "Y", "=", "substr", "(", "$", "X", ",", "0", ",", "-", "4", ")", ";", "// increment counter", "$", "n", "=", "self", "::", "strToGMP", "(", "substr", "(", "$", "X", ",", "-", "4", ")", ")", "+", "1", ";", "// wrap by using only the 32 rightmost bits", "$", "Y", ".=", "substr", "(", "self", "::", "gmpToStr", "(", "$", "n", ",", "4", ")", ",", "-", "4", ")", ";", "return", "$", "Y", ";", "}" ]
Increment 32 rightmost bits of the counter block. See NIST SP-300-38D section 6.2 for the details. @param string $X @return string
[ "Increment", "32", "rightmost", "bits", "of", "the", "counter", "block", "." ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L226-L234
226,039
sop/gcm
lib/GCM/GCM.php
GCM.gmpToStr
public static function gmpToStr(\GMP $num, int $size): string { $data = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); $len = strlen($data); if ($len < $size) { $data = str_repeat("\0", $size - $len) . $data; } return $data; }
php
public static function gmpToStr(\GMP $num, int $size): string { $data = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); $len = strlen($data); if ($len < $size) { $data = str_repeat("\0", $size - $len) . $data; } return $data; }
[ "public", "static", "function", "gmpToStr", "(", "\\", "GMP", "$", "num", ",", "int", "$", "size", ")", ":", "string", "{", "$", "data", "=", "gmp_export", "(", "$", "num", ",", "1", ",", "GMP_MSW_FIRST", "|", "GMP_BIG_ENDIAN", ")", ";", "$", "len", "=", "strlen", "(", "$", "data", ")", ";", "if", "(", "$", "len", "<", "$", "size", ")", "{", "$", "data", "=", "str_repeat", "(", "\"\\0\"", ",", "$", "size", "-", "$", "len", ")", ".", "$", "data", ";", "}", "return", "$", "data", ";", "}" ]
Convert GMP number to string. Returned string represents an unsigned integer with big endian order and the most significant byte first. @param \GMP $num GMP number @param int $size Width of the string in bytes @return string Binary data
[ "Convert", "GMP", "number", "to", "string", "." ]
ef5f63ca0fb1af4c5d2a319858746b9ffd12a216
https://github.com/sop/gcm/blob/ef5f63ca0fb1af4c5d2a319858746b9ffd12a216/lib/GCM/GCM.php#L275-L283
226,040
adamgoose/laravel-annotations
src/Adamgoose/Routing/Annotations/AnnotationSet.php
AnnotationSet.getMethodAnnotations
protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader) { $annotations = []; foreach ($class->getMethods() as $method) { $results = $reader->getMethodAnnotations($method); if (count($results) > 0) $annotations[$method->name] = $results; } return $annotations; }
php
protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader) { $annotations = []; foreach ($class->getMethods() as $method) { $results = $reader->getMethodAnnotations($method); if (count($results) > 0) $annotations[$method->name] = $results; } return $annotations; }
[ "protected", "function", "getMethodAnnotations", "(", "ReflectionClass", "$", "class", ",", "SimpleAnnotationReader", "$", "reader", ")", "{", "$", "annotations", "=", "[", "]", ";", "foreach", "(", "$", "class", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "results", "=", "$", "reader", "->", "getMethodAnnotations", "(", "$", "method", ")", ";", "if", "(", "count", "(", "$", "results", ")", ">", "0", ")", "$", "annotations", "[", "$", "method", "->", "name", "]", "=", "$", "results", ";", "}", "return", "$", "annotations", ";", "}" ]
Get the method annotations for a given class. @param \ReflectionClass $class @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader @return array
[ "Get", "the", "method", "annotations", "for", "a", "given", "class", "." ]
0a8445508d5d3aeb08e42d0bb357373b522da28e
https://github.com/adamgoose/laravel-annotations/blob/0a8445508d5d3aeb08e42d0bb357373b522da28e/src/Adamgoose/Routing/Annotations/AnnotationSet.php#L42-L55
226,041
gjerokrsteski/pimf-framework
core/Pimf/Response.php
Response.sendStream
public function sendStream($stream, $name, $exit = true) { Header::sendDownloadDialog($stream, $name, $exit); }
php
public function sendStream($stream, $name, $exit = true) { Header::sendDownloadDialog($stream, $name, $exit); }
[ "public", "function", "sendStream", "(", "$", "stream", ",", "$", "name", ",", "$", "exit", "=", "true", ")", "{", "Header", "::", "sendDownloadDialog", "(", "$", "stream", ",", "$", "name", ",", "$", "exit", ")", ";", "}" ]
Sends a download dialog to the browser. @param string $stream Can be a file-path or a string. @param string $name Name of the stream/file should be shown. @param boolean $exit Optional for testing
[ "Sends", "a", "download", "dialog", "to", "the", "browser", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Response.php#L123-L126
226,042
gjerokrsteski/pimf-framework
core/Pimf/Response.php
Response.cacheNoValidate
public function cacheNoValidate($seconds = 60) { self::preventMultipleCaching(); self::$cached = true; Header::cacheNoValidate($seconds); return $this; }
php
public function cacheNoValidate($seconds = 60) { self::preventMultipleCaching(); self::$cached = true; Header::cacheNoValidate($seconds); return $this; }
[ "public", "function", "cacheNoValidate", "(", "$", "seconds", "=", "60", ")", "{", "self", "::", "preventMultipleCaching", "(", ")", ";", "self", "::", "$", "cached", "=", "true", ";", "Header", "::", "cacheNoValidate", "(", "$", "seconds", ")", ";", "return", "$", "this", ";", "}" ]
If you want to allow a page to be cached by shared proxies for one minute. @param int $seconds Interval in seconds @return $this
[ "If", "you", "want", "to", "allow", "a", "page", "to", "be", "cached", "by", "shared", "proxies", "for", "one", "minute", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Response.php#L187-L194
226,043
gjerokrsteski/pimf-framework
core/Pimf/Environment.php
Environment.getIp
public function getIp() { if ($this->X_FORWARDED_FOR) { return $this->X_FORWARDED_FOR; } if ($this->CLIENT_IP) { return $this->CLIENT_IP; } if ($this->SERVER_NAME) { return gethostbyname($this->SERVER_NAME); } return $this->REMOTE_ADDR; }
php
public function getIp() { if ($this->X_FORWARDED_FOR) { return $this->X_FORWARDED_FOR; } if ($this->CLIENT_IP) { return $this->CLIENT_IP; } if ($this->SERVER_NAME) { return gethostbyname($this->SERVER_NAME); } return $this->REMOTE_ADDR; }
[ "public", "function", "getIp", "(", ")", "{", "if", "(", "$", "this", "->", "X_FORWARDED_FOR", ")", "{", "return", "$", "this", "->", "X_FORWARDED_FOR", ";", "}", "if", "(", "$", "this", "->", "CLIENT_IP", ")", "{", "return", "$", "this", "->", "CLIENT_IP", ";", "}", "if", "(", "$", "this", "->", "SERVER_NAME", ")", "{", "return", "gethostbyname", "(", "$", "this", "->", "SERVER_NAME", ")", ";", "}", "return", "$", "this", "->", "REMOTE_ADDR", ";", "}" ]
Get remote IP @return string
[ "Get", "remote", "IP" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Environment.php#L153-L168
226,044
gjerokrsteski/pimf-framework
core/Pimf/Environment.php
Environment.getUserAgent
public function getUserAgent() { if ($this->USER_AGENT) { return $this->USER_AGENT; } if ($this->HTTP_USER_AGENT) { return $this->HTTP_USER_AGENT; } return null; }
php
public function getUserAgent() { if ($this->USER_AGENT) { return $this->USER_AGENT; } if ($this->HTTP_USER_AGENT) { return $this->HTTP_USER_AGENT; } return null; }
[ "public", "function", "getUserAgent", "(", ")", "{", "if", "(", "$", "this", "->", "USER_AGENT", ")", "{", "return", "$", "this", "->", "USER_AGENT", ";", "}", "if", "(", "$", "this", "->", "HTTP_USER_AGENT", ")", "{", "return", "$", "this", "->", "HTTP_USER_AGENT", ";", "}", "return", "null", ";", "}" ]
Get User Agent @return string|null
[ "Get", "User", "Agent" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Environment.php#L175-L186
226,045
gjerokrsteski/pimf-framework
core/Pimf/Environment.php
Environment.getUrl
public function getUrl() { $protocol = strpos(strtolower($this->PATH_INFO), 'https') === false ? 'http' : 'https'; return $protocol . '://' . $this->getHost(); }
php
public function getUrl() { $protocol = strpos(strtolower($this->PATH_INFO), 'https') === false ? 'http' : 'https'; return $protocol . '://' . $this->getHost(); }
[ "public", "function", "getUrl", "(", ")", "{", "$", "protocol", "=", "strpos", "(", "strtolower", "(", "$", "this", "->", "PATH_INFO", ")", ",", "'https'", ")", "===", "false", "?", "'http'", ":", "'https'", ";", "return", "$", "protocol", ".", "'://'", ".", "$", "this", "->", "getHost", "(", ")", ";", "}" ]
Gives you the current page URL @return string
[ "Gives", "you", "the", "current", "page", "URL" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Environment.php#L193-L198
226,046
gjerokrsteski/pimf-framework
core/Pimf/Environment.php
Environment.getRequestHeader
public function getRequestHeader($header) { $header = str_replace('-', '_', strtoupper($header)); $value = $this->{'HTTP_' . $header}; if (!$value) { $headers = $this->getRequestHeaders(); $value = !empty($headers[$header]) ? $headers[$header] : null; } return $value; }
php
public function getRequestHeader($header) { $header = str_replace('-', '_', strtoupper($header)); $value = $this->{'HTTP_' . $header}; if (!$value) { $headers = $this->getRequestHeaders(); $value = !empty($headers[$header]) ? $headers[$header] : null; } return $value; }
[ "public", "function", "getRequestHeader", "(", "$", "header", ")", "{", "$", "header", "=", "str_replace", "(", "'-'", ",", "'_'", ",", "strtoupper", "(", "$", "header", ")", ")", ";", "$", "value", "=", "$", "this", "->", "{", "'HTTP_'", ".", "$", "header", "}", ";", "if", "(", "!", "$", "value", ")", "{", "$", "headers", "=", "$", "this", "->", "getRequestHeaders", "(", ")", ";", "$", "value", "=", "!", "empty", "(", "$", "headers", "[", "$", "header", "]", ")", "?", "$", "headers", "[", "$", "header", "]", ":", "null", ";", "}", "return", "$", "value", ";", "}" ]
Try to get a request header. @param string $header @return array
[ "Try", "to", "get", "a", "request", "header", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Environment.php#L207-L218
226,047
gjerokrsteski/pimf-framework
core/Pimf/Environment.php
Environment.getRequestHeaders
public function getRequestHeaders() { $headers = array(); foreach ($this->data->getAll() as $key => $value) { if ('HTTP_' === substr($key, 0, 5)) { $headers[substr($key, 5)] = $value; } } return $headers; }
php
public function getRequestHeaders() { $headers = array(); foreach ($this->data->getAll() as $key => $value) { if ('HTTP_' === substr($key, 0, 5)) { $headers[substr($key, 5)] = $value; } } return $headers; }
[ "public", "function", "getRequestHeaders", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "->", "getAll", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "'HTTP_'", "===", "substr", "(", "$", "key", ",", "0", ",", "5", ")", ")", "{", "$", "headers", "[", "substr", "(", "$", "key", ",", "5", ")", "]", "=", "$", "value", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Try to determine all request headers @return array
[ "Try", "to", "determine", "all", "request", "headers" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Environment.php#L225-L236
226,048
CallFire/CallFire-PHP-SDK
src/CallFire/Common/Subscription.php
Subscription.is_event_request
public static function is_event_request($requestData = null, $contentTypes = null) { if (!$requestData) { $requestData = $_SERVER; } if (!$contentTypes) { $contentTypes = static::$eventContentTypes; } switch (false) { // All of these things must be true case isset($requestData['REQUEST_METHOD']): case $requestData['REQUEST_METHOD'] == 'POST': case isset($requestData['CONTENT_TYPE']): case in_array($requestData['CONTENT_TYPE'], $contentTypes): return false; } return array_search($requestData['CONTENT_TYPE'], $contentTypes); }
php
public static function is_event_request($requestData = null, $contentTypes = null) { if (!$requestData) { $requestData = $_SERVER; } if (!$contentTypes) { $contentTypes = static::$eventContentTypes; } switch (false) { // All of these things must be true case isset($requestData['REQUEST_METHOD']): case $requestData['REQUEST_METHOD'] == 'POST': case isset($requestData['CONTENT_TYPE']): case in_array($requestData['CONTENT_TYPE'], $contentTypes): return false; } return array_search($requestData['CONTENT_TYPE'], $contentTypes); }
[ "public", "static", "function", "is_event_request", "(", "$", "requestData", "=", "null", ",", "$", "contentTypes", "=", "null", ")", "{", "if", "(", "!", "$", "requestData", ")", "{", "$", "requestData", "=", "$", "_SERVER", ";", "}", "if", "(", "!", "$", "contentTypes", ")", "{", "$", "contentTypes", "=", "static", "::", "$", "eventContentTypes", ";", "}", "switch", "(", "false", ")", "{", "// All of these things must be true", "case", "isset", "(", "$", "requestData", "[", "'REQUEST_METHOD'", "]", ")", ":", "case", "$", "requestData", "[", "'REQUEST_METHOD'", "]", "==", "'POST'", ":", "case", "isset", "(", "$", "requestData", "[", "'CONTENT_TYPE'", "]", ")", ":", "case", "in_array", "(", "$", "requestData", "[", "'CONTENT_TYPE'", "]", ",", "$", "contentTypes", ")", ":", "return", "false", ";", "}", "return", "array_search", "(", "$", "requestData", "[", "'CONTENT_TYPE'", "]", ",", "$", "contentTypes", ")", ";", "}" ]
Determines if the request is an event notification, and returns the corresponding format identifier. @static @param array $requestData = null @param array $contentTypes = null @return string
[ "Determines", "if", "the", "request", "is", "an", "event", "notification", "and", "returns", "the", "corresponding", "format", "identifier", "." ]
7d6d3e1c59d4116e4fadaf57851a2fa127a13f65
https://github.com/CallFire/CallFire-PHP-SDK/blob/7d6d3e1c59d4116e4fadaf57851a2fa127a13f65/src/CallFire/Common/Subscription.php#L48-L67
226,049
jagilpe/encryption-bundle
EventListener/UserEventsSubsbriber.php
UserEventsSubsbriber.handlePasswordChangeSuccess
public function handlePasswordChangeSuccess(FOSFormEvent $event) { $form = $event->getForm(); $user = $form->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $currentPassword = $form->get('current_password')->getData(); $this->encryptionService->handleUserPasswordChangeSuccess($user, $currentPassword); } }
php
public function handlePasswordChangeSuccess(FOSFormEvent $event) { $form = $event->getForm(); $user = $form->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $currentPassword = $form->get('current_password')->getData(); $this->encryptionService->handleUserPasswordChangeSuccess($user, $currentPassword); } }
[ "public", "function", "handlePasswordChangeSuccess", "(", "FOSFormEvent", "$", "event", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "user", "=", "$", "form", "->", "getData", "(", ")", ";", "if", "(", "$", "user", "instanceof", "PKEncryptionEnabledUserInterface", ")", "{", "$", "currentPassword", "=", "$", "form", "->", "get", "(", "'current_password'", ")", "->", "getData", "(", ")", ";", "$", "this", "->", "encryptionService", "->", "handleUserPasswordChangeSuccess", "(", "$", "user", ",", "$", "currentPassword", ")", ";", "}", "}" ]
Handles a successful password change using the FOSUserBundle forms @param \FOS\UserBundle\Event\FormEvent $event
[ "Handles", "a", "successful", "password", "change", "using", "the", "FOSUserBundle", "forms" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/EventListener/UserEventsSubsbriber.php#L47-L56
226,050
jagilpe/encryption-bundle
EventListener/UserEventsSubsbriber.php
UserEventsSubsbriber.handlePasswordResetSuccess
public function handlePasswordResetSuccess(FOSFormEvent $event) { $form = $event->getForm(); $user = $form->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPasswordResetSuccess($user); } }
php
public function handlePasswordResetSuccess(FOSFormEvent $event) { $form = $event->getForm(); $user = $form->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPasswordResetSuccess($user); } }
[ "public", "function", "handlePasswordResetSuccess", "(", "FOSFormEvent", "$", "event", ")", "{", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "user", "=", "$", "form", "->", "getData", "(", ")", ";", "if", "(", "$", "user", "instanceof", "PKEncryptionEnabledUserInterface", ")", "{", "$", "this", "->", "encryptionService", "->", "handleUserPasswordResetSuccess", "(", "$", "user", ")", ";", "}", "}" ]
Handles a successful password reset using the FOSUserBundle forms @param \FOS\UserBundle\Event\FormEvent $event
[ "Handles", "a", "successful", "password", "reset", "using", "the", "FOSUserBundle", "forms" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/EventListener/UserEventsSubsbriber.php#L63-L71
226,051
jagilpe/encryption-bundle
EventListener/UserEventsSubsbriber.php
UserEventsSubsbriber.handleUserRegistrationSuccess
public function handleUserRegistrationSuccess(FOSFormEvent $event) { $user = $event->getForm()->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPreCreation($user); } }
php
public function handleUserRegistrationSuccess(FOSFormEvent $event) { $user = $event->getForm()->getData(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPreCreation($user); } }
[ "public", "function", "handleUserRegistrationSuccess", "(", "FOSFormEvent", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getForm", "(", ")", "->", "getData", "(", ")", ";", "if", "(", "$", "user", "instanceof", "PKEncryptionEnabledUserInterface", ")", "{", "$", "this", "->", "encryptionService", "->", "handleUserPreCreation", "(", "$", "user", ")", ";", "}", "}" ]
Handles a successful user registration using the FOSUserBundle forms @param FOSFormEvent $event @throws \Exception
[ "Handles", "a", "successful", "user", "registration", "using", "the", "FOSUserBundle", "forms" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/EventListener/UserEventsSubsbriber.php#L79-L86
226,052
jagilpe/encryption-bundle
EventListener/UserEventsSubsbriber.php
UserEventsSubsbriber.handleUserRegistrationComplete
public function handleUserRegistrationComplete(FOSFilterUserResponseEvent $event) { $user = $event->getUser(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPostCreation($user); } }
php
public function handleUserRegistrationComplete(FOSFilterUserResponseEvent $event) { $user = $event->getUser(); if ($user instanceof PKEncryptionEnabledUserInterface) { $this->encryptionService->handleUserPostCreation($user); } }
[ "public", "function", "handleUserRegistrationComplete", "(", "FOSFilterUserResponseEvent", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "PKEncryptionEnabledUserInterface", ")", "{", "$", "this", "->", "encryptionService", "->", "handleUserPostCreation", "(", "$", "user", ")", ";", "}", "}" ]
Handles the completion of a user registration using the FOSUserBundle forms @param \FOS\UserBundle\Event\FilterUserResponseEvent $event
[ "Handles", "the", "completion", "of", "a", "user", "registration", "using", "the", "FOSUserBundle", "forms" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/EventListener/UserEventsSubsbriber.php#L93-L100
226,053
Techworker/ssml
src/Element/Word.php
Word.factory
public static function factory(string $role, string $text): Word { $instance = new static(); $instance->role = $role; $instance->text = $text; return $instance; }
php
public static function factory(string $role, string $text): Word { $instance = new static(); $instance->role = $role; $instance->text = $text; return $instance; }
[ "public", "static", "function", "factory", "(", "string", "$", "role", ",", "string", "$", "text", ")", ":", "Word", "{", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "instance", "->", "role", "=", "$", "role", ";", "$", "instance", "->", "text", "=", "$", "text", ";", "return", "$", "instance", ";", "}" ]
Creates a word element with the given data as attributes. @param string $role @param string $text @return Word
[ "Creates", "a", "word", "element", "with", "the", "given", "data", "as", "attributes", "." ]
cafb979b777480baf7a01b5db2bf7c2cff837805
https://github.com/Techworker/ssml/blob/cafb979b777480baf7a01b5db2bf7c2cff837805/src/Element/Word.php#L46-L53
226,054
jagilpe/encryption-bundle
Crypt/SymmetricKey.php
SymmetricKey.getSystemKey
public function getSystemKey() { return isset($this->encryptedKeys[self::SYSTEM_IDENTIFIER]) ? $this->encryptedKeys[self::SYSTEM_IDENTIFIER] : null; }
php
public function getSystemKey() { return isset($this->encryptedKeys[self::SYSTEM_IDENTIFIER]) ? $this->encryptedKeys[self::SYSTEM_IDENTIFIER] : null; }
[ "public", "function", "getSystemKey", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "encryptedKeys", "[", "self", "::", "SYSTEM_IDENTIFIER", "]", ")", "?", "$", "this", "->", "encryptedKeys", "[", "self", "::", "SYSTEM_IDENTIFIER", "]", ":", "null", ";", "}" ]
Returns the encrypted key that corresponds to the system master key @return NULL|string
[ "Returns", "the", "encrypted", "key", "that", "corresponds", "to", "the", "system", "master", "key" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/SymmetricKey.php#L39-L44
226,055
jagilpe/encryption-bundle
Crypt/SymmetricKey.php
SymmetricKey.addKey
public function addKey(PKEncryptionEnabledUserInterface $user, $encryptedKey) { $userClass = $this->getUserClass($user); $userId = $user->getId(); if (!isset($this->encryptedKeys[$userClass])) { $this->encryptedKeys[$userClass] = array(); } $this->encryptedKeys[$userClass][$userId] = $encryptedKey; }
php
public function addKey(PKEncryptionEnabledUserInterface $user, $encryptedKey) { $userClass = $this->getUserClass($user); $userId = $user->getId(); if (!isset($this->encryptedKeys[$userClass])) { $this->encryptedKeys[$userClass] = array(); } $this->encryptedKeys[$userClass][$userId] = $encryptedKey; }
[ "public", "function", "addKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ",", "$", "encryptedKey", ")", "{", "$", "userClass", "=", "$", "this", "->", "getUserClass", "(", "$", "user", ")", ";", "$", "userId", "=", "$", "user", "->", "getId", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", ")", ")", "{", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", "[", "$", "userId", "]", "=", "$", "encryptedKey", ";", "}" ]
Adds a new version of the key encrypted with the key of a new user @param \Jagilpe\EncryptionBundle\Entity\PKEncryptionEnabledUserInterface $user @param string $encryptedKey
[ "Adds", "a", "new", "version", "of", "the", "key", "encrypted", "with", "the", "key", "of", "a", "new", "user" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/SymmetricKey.php#L52-L60
226,056
jagilpe/encryption-bundle
Crypt/SymmetricKey.php
SymmetricKey.getKey
public function getKey(PKEncryptionEnabledUserInterface $user) { $userClass = $this->getUserClass($user); $userId = $user->getId(); return isset($this->encryptedKeys[$userClass]) && isset($this->encryptedKeys[$userClass][$userId]) ? $this->encryptedKeys[$userClass][$userId] : null; }
php
public function getKey(PKEncryptionEnabledUserInterface $user) { $userClass = $this->getUserClass($user); $userId = $user->getId(); return isset($this->encryptedKeys[$userClass]) && isset($this->encryptedKeys[$userClass][$userId]) ? $this->encryptedKeys[$userClass][$userId] : null; }
[ "public", "function", "getKey", "(", "PKEncryptionEnabledUserInterface", "$", "user", ")", "{", "$", "userClass", "=", "$", "this", "->", "getUserClass", "(", "$", "user", ")", ";", "$", "userId", "=", "$", "user", "->", "getId", "(", ")", ";", "return", "isset", "(", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", ")", "&&", "isset", "(", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", "[", "$", "userId", "]", ")", "?", "$", "this", "->", "encryptedKeys", "[", "$", "userClass", "]", "[", "$", "userId", "]", ":", "null", ";", "}" ]
Returns the encrypted key that corresponds to a determined user @param PKEncryptionEnabledUserInterface $user @return NULL|string
[ "Returns", "the", "encrypted", "key", "that", "corresponds", "to", "a", "determined", "user" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Crypt/SymmetricKey.php#L68-L76
226,057
gjerokrsteski/pimf-framework
core/Pimf/Session.php
Session.factory
public static function factory($storage) { switch ($storage) { case 'apc': return new Storage\Apc(Cache::storage('apc')); case 'cookie': return new Storage\Cookie(); case 'file': return new Storage\File(Config::get('session.storage_path')); case 'pdo': return new Storage\Pdo(Pdo\Factory::get(Config::get('session.database'))); case 'memcached': return new Storage\Memcached(Cache::storage('memcached')); case 'memory': return new Storage\Memory(); case 'redis': return new Storage\Redis(Cache::storage('redis')); case 'dba': return new Storage\Dba(Cache::storage('dba')); default: throw new \RuntimeException("Session storage [$storage] is not supported."); } }
php
public static function factory($storage) { switch ($storage) { case 'apc': return new Storage\Apc(Cache::storage('apc')); case 'cookie': return new Storage\Cookie(); case 'file': return new Storage\File(Config::get('session.storage_path')); case 'pdo': return new Storage\Pdo(Pdo\Factory::get(Config::get('session.database'))); case 'memcached': return new Storage\Memcached(Cache::storage('memcached')); case 'memory': return new Storage\Memory(); case 'redis': return new Storage\Redis(Cache::storage('redis')); case 'dba': return new Storage\Dba(Cache::storage('dba')); default: throw new \RuntimeException("Session storage [$storage] is not supported."); } }
[ "public", "static", "function", "factory", "(", "$", "storage", ")", "{", "switch", "(", "$", "storage", ")", "{", "case", "'apc'", ":", "return", "new", "Storage", "\\", "Apc", "(", "Cache", "::", "storage", "(", "'apc'", ")", ")", ";", "case", "'cookie'", ":", "return", "new", "Storage", "\\", "Cookie", "(", ")", ";", "case", "'file'", ":", "return", "new", "Storage", "\\", "File", "(", "Config", "::", "get", "(", "'session.storage_path'", ")", ")", ";", "case", "'pdo'", ":", "return", "new", "Storage", "\\", "Pdo", "(", "Pdo", "\\", "Factory", "::", "get", "(", "Config", "::", "get", "(", "'session.database'", ")", ")", ")", ";", "case", "'memcached'", ":", "return", "new", "Storage", "\\", "Memcached", "(", "Cache", "::", "storage", "(", "'memcached'", ")", ")", ";", "case", "'memory'", ":", "return", "new", "Storage", "\\", "Memory", "(", ")", ";", "case", "'redis'", ":", "return", "new", "Storage", "\\", "Redis", "(", "Cache", "::", "storage", "(", "'redis'", ")", ")", ";", "case", "'dba'", ":", "return", "new", "Storage", "\\", "Dba", "(", "Cache", "::", "storage", "(", "'dba'", ")", ")", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "\"Session storage [$storage] is not supported.\"", ")", ";", "}", "}" ]
Create a new session storage instance. @param string $storage @return Storage\Storage @throws \RuntimeException
[ "Create", "a", "new", "session", "storage", "instance", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Session.php#L91-L121
226,058
infomaniac-amf/php
lib/io/Input.php
Input.readDouble
public function readDouble() { $double = $this->readRawBytes(8); if (Spec::isLittleEndian()) { $double = strrev($double); } $double = unpack("d", $double); return $double[1]; }
php
public function readDouble() { $double = $this->readRawBytes(8); if (Spec::isLittleEndian()) { $double = strrev($double); } $double = unpack("d", $double); return $double[1]; }
[ "public", "function", "readDouble", "(", ")", "{", "$", "double", "=", "$", "this", "->", "readRawBytes", "(", "8", ")", ";", "if", "(", "Spec", "::", "isLittleEndian", "(", ")", ")", "{", "$", "double", "=", "strrev", "(", "$", "double", ")", ";", "}", "$", "double", "=", "unpack", "(", "\"d\"", ",", "$", "double", ")", ";", "return", "$", "double", "[", "1", "]", ";", "}" ]
Read a byte as a float @return float
[ "Read", "a", "byte", "as", "a", "float" ]
1b71c125352ec562f473cd51958a03f786aa7ac9
https://github.com/infomaniac-amf/php/blob/1b71c125352ec562f473cd51958a03f786aa7ac9/lib/io/Input.php#L49-L59
226,059
crip-laravel/filesys
src/Services/TreeService.php
TreeService.content
public function content(): array { $dirs = collect($this->storage->allDirectories($this->root)); $output = []; $dirs->filter(function ($dir) { $parts = $this->split($dir); return !in_array($parts[0], $this->exclude); })->each(function ($dir) use (&$output) { $curr = &$output; foreach ($this->split($dir) as $name) { if (!collect($curr)->contains('name', $name)) { $curr[] = [ 'path' => $this->dirToPath($dir), 'name' => $name, 'children' => [] ]; } else { foreach ($curr as $key => $item) { if ($item['name'] === $name) $curr = &$curr[$key]['children']; } } } }); return $output; }
php
public function content(): array { $dirs = collect($this->storage->allDirectories($this->root)); $output = []; $dirs->filter(function ($dir) { $parts = $this->split($dir); return !in_array($parts[0], $this->exclude); })->each(function ($dir) use (&$output) { $curr = &$output; foreach ($this->split($dir) as $name) { if (!collect($curr)->contains('name', $name)) { $curr[] = [ 'path' => $this->dirToPath($dir), 'name' => $name, 'children' => [] ]; } else { foreach ($curr as $key => $item) { if ($item['name'] === $name) $curr = &$curr[$key]['children']; } } } }); return $output; }
[ "public", "function", "content", "(", ")", ":", "array", "{", "$", "dirs", "=", "collect", "(", "$", "this", "->", "storage", "->", "allDirectories", "(", "$", "this", "->", "root", ")", ")", ";", "$", "output", "=", "[", "]", ";", "$", "dirs", "->", "filter", "(", "function", "(", "$", "dir", ")", "{", "$", "parts", "=", "$", "this", "->", "split", "(", "$", "dir", ")", ";", "return", "!", "in_array", "(", "$", "parts", "[", "0", "]", ",", "$", "this", "->", "exclude", ")", ";", "}", ")", "->", "each", "(", "function", "(", "$", "dir", ")", "use", "(", "&", "$", "output", ")", "{", "$", "curr", "=", "&", "$", "output", ";", "foreach", "(", "$", "this", "->", "split", "(", "$", "dir", ")", "as", "$", "name", ")", "{", "if", "(", "!", "collect", "(", "$", "curr", ")", "->", "contains", "(", "'name'", ",", "$", "name", ")", ")", "{", "$", "curr", "[", "]", "=", "[", "'path'", "=>", "$", "this", "->", "dirToPath", "(", "$", "dir", ")", ",", "'name'", "=>", "$", "name", ",", "'children'", "=>", "[", "]", "]", ";", "}", "else", "{", "foreach", "(", "$", "curr", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "$", "item", "[", "'name'", "]", "===", "$", "name", ")", "$", "curr", "=", "&", "$", "curr", "[", "$", "key", "]", "[", "'children'", "]", ";", "}", "}", "}", "}", ")", ";", "return", "$", "output", ";", "}" ]
Gets root folder tree content. @return array
[ "Gets", "root", "folder", "tree", "content", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/TreeService.php#L51-L78
226,060
crip-laravel/filesys
src/Services/TreeService.php
TreeService.dirToPath
private function dirToPath(string $dir): string { if ($this->root !== '') { return str_replace_first($this->root, '', $dir); } return $dir; }
php
private function dirToPath(string $dir): string { if ($this->root !== '') { return str_replace_first($this->root, '', $dir); } return $dir; }
[ "private", "function", "dirToPath", "(", "string", "$", "dir", ")", ":", "string", "{", "if", "(", "$", "this", "->", "root", "!==", "''", ")", "{", "return", "str_replace_first", "(", "$", "this", "->", "root", ",", "''", ",", "$", "dir", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Convert dir to path. @param string $dir @return string
[ "Convert", "dir", "to", "path", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/TreeService.php#L85-L92
226,061
crip-laravel/filesys
src/Services/TreeService.php
TreeService.split
private function split(string $dir): array { $path = $this->dirToPath($dir); return explode('/', Str::normalizePath($path)); }
php
private function split(string $dir): array { $path = $this->dirToPath($dir); return explode('/', Str::normalizePath($path)); }
[ "private", "function", "split", "(", "string", "$", "dir", ")", ":", "array", "{", "$", "path", "=", "$", "this", "->", "dirToPath", "(", "$", "dir", ")", ";", "return", "explode", "(", "'/'", ",", "Str", "::", "normalizePath", "(", "$", "path", ")", ")", ";", "}" ]
Normalize and split dir path. @param string $dir @return array
[ "Normalize", "and", "split", "dir", "path", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/TreeService.php#L99-L104
226,062
gjerokrsteski/pimf-framework
core/Pimf/Util/Uploaded.php
Uploaded.getMaxFilesize
public static function getMaxFilesize() { $max = trim(ini_get('upload_max_filesize')); if ('' === $max) { return PHP_INT_MAX; } $unit = strtolower(substr($max, -1)); $max = (int)substr($max, 0, -1); if (in_array($unit, array('g', 'm', 'k'), true)) { $max *= 1024; } return $max; }
php
public static function getMaxFilesize() { $max = trim(ini_get('upload_max_filesize')); if ('' === $max) { return PHP_INT_MAX; } $unit = strtolower(substr($max, -1)); $max = (int)substr($max, 0, -1); if (in_array($unit, array('g', 'm', 'k'), true)) { $max *= 1024; } return $max; }
[ "public", "static", "function", "getMaxFilesize", "(", ")", "{", "$", "max", "=", "trim", "(", "ini_get", "(", "'upload_max_filesize'", ")", ")", ";", "if", "(", "''", "===", "$", "max", ")", "{", "return", "PHP_INT_MAX", ";", "}", "$", "unit", "=", "strtolower", "(", "substr", "(", "$", "max", ",", "-", "1", ")", ")", ";", "$", "max", "=", "(", "int", ")", "substr", "(", "$", "max", ",", "0", ",", "-", "1", ")", ";", "if", "(", "in_array", "(", "$", "unit", ",", "array", "(", "'g'", ",", "'m'", ",", "'k'", ")", ",", "true", ")", ")", "{", "$", "max", "*=", "1024", ";", "}", "return", "$", "max", ";", "}" ]
Returns the maximum size of an uploaded file in bytes as configured in php.ini @return int
[ "Returns", "the", "maximum", "size", "of", "an", "uploaded", "file", "in", "bytes", "as", "configured", "in", "php", ".", "ini" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Util/Uploaded.php#L201-L217
226,063
mlanin/laravel-setup-wizard
src/Commands/Steps/CreateMysqlDatabase.php
CreateMysqlDatabase.getDatabaseConfigs
protected function getDatabaseConfigs(array &$return) { $return['localhost'] = 'localhost'; $return['host'] = $this->connection->getConfig('host'); $return['database'] = $this->connection->getConfig('database'); $return['username'] = $this->connection->getConfig('username'); $return['password'] = $this->connection->getConfig('password'); $return['connection_username'] = $return['username']; $return['connection_password'] = $return['password']; if ( ! in_array($return['host'], ['localhost', '127.0.0.1'])) { $return['localhost'] = $this->command->ask('Database is on the other server. Provide local IP/hostname.'); } }
php
protected function getDatabaseConfigs(array &$return) { $return['localhost'] = 'localhost'; $return['host'] = $this->connection->getConfig('host'); $return['database'] = $this->connection->getConfig('database'); $return['username'] = $this->connection->getConfig('username'); $return['password'] = $this->connection->getConfig('password'); $return['connection_username'] = $return['username']; $return['connection_password'] = $return['password']; if ( ! in_array($return['host'], ['localhost', '127.0.0.1'])) { $return['localhost'] = $this->command->ask('Database is on the other server. Provide local IP/hostname.'); } }
[ "protected", "function", "getDatabaseConfigs", "(", "array", "&", "$", "return", ")", "{", "$", "return", "[", "'localhost'", "]", "=", "'localhost'", ";", "$", "return", "[", "'host'", "]", "=", "$", "this", "->", "connection", "->", "getConfig", "(", "'host'", ")", ";", "$", "return", "[", "'database'", "]", "=", "$", "this", "->", "connection", "->", "getConfig", "(", "'database'", ")", ";", "$", "return", "[", "'username'", "]", "=", "$", "this", "->", "connection", "->", "getConfig", "(", "'username'", ")", ";", "$", "return", "[", "'password'", "]", "=", "$", "this", "->", "connection", "->", "getConfig", "(", "'password'", ")", ";", "$", "return", "[", "'connection_username'", "]", "=", "$", "return", "[", "'username'", "]", ";", "$", "return", "[", "'connection_password'", "]", "=", "$", "return", "[", "'password'", "]", ";", "if", "(", "!", "in_array", "(", "$", "return", "[", "'host'", "]", ",", "[", "'localhost'", ",", "'127.0.0.1'", "]", ")", ")", "{", "$", "return", "[", "'localhost'", "]", "=", "$", "this", "->", "command", "->", "ask", "(", "'Database is on the other server. Provide local IP/hostname.'", ")", ";", "}", "}" ]
Get database config. @param array $return
[ "Get", "database", "config", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/CreateMysqlDatabase.php#L61-L76
226,064
mlanin/laravel-setup-wizard
src/Commands/Steps/CreateMysqlDatabase.php
CreateMysqlDatabase.generateConsoleCommand
protected function generateConsoleCommand($results, $full = false) { return sprintf( "mysql -u\"%s\" -p\"%s\" -h\"%s\" -e\"%s\"", $results['connection_username'], $full ? $results['connection_password'] : '******', $results['host'], join(' ', $results['commands']) ); }
php
protected function generateConsoleCommand($results, $full = false) { return sprintf( "mysql -u\"%s\" -p\"%s\" -h\"%s\" -e\"%s\"", $results['connection_username'], $full ? $results['connection_password'] : '******', $results['host'], join(' ', $results['commands']) ); }
[ "protected", "function", "generateConsoleCommand", "(", "$", "results", ",", "$", "full", "=", "false", ")", "{", "return", "sprintf", "(", "\"mysql -u\\\"%s\\\" -p\\\"%s\\\" -h\\\"%s\\\" -e\\\"%s\\\"\"", ",", "$", "results", "[", "'connection_username'", "]", ",", "$", "full", "?", "$", "results", "[", "'connection_password'", "]", ":", "'******'", ",", "$", "results", "[", "'host'", "]", ",", "join", "(", "' '", ",", "$", "results", "[", "'commands'", "]", ")", ")", ";", "}" ]
Generate terminal command. @param array $results @param bool $full @return string
[ "Generate", "terminal", "command", "." ]
b2614612f92861af434e70b0fe070f6167a71e33
https://github.com/mlanin/laravel-setup-wizard/blob/b2614612f92861af434e70b0fe070f6167a71e33/src/Commands/Steps/CreateMysqlDatabase.php#L117-L126
226,065
gjerokrsteski/pimf-framework
core/Pimf/Event.php
Event.fire
public static function fire($events, $parameters = array(), $halt = false) { $responses = array(); $parameters = (array)$parameters; // If the event has listeners, iterate through them and call each listener, // passing in the parameters. foreach ((array)$events as $event) { if (static::listeners($event)) { foreach (static::$events[$event] as $callback) { $response = call_user_func_array($callback, $parameters); // If the event is set to halt, // return the first response that is not null. if ($halt && !is_null($response)) { return $response; } $responses[] = $response; } } } return $halt ? null : $responses; }
php
public static function fire($events, $parameters = array(), $halt = false) { $responses = array(); $parameters = (array)$parameters; // If the event has listeners, iterate through them and call each listener, // passing in the parameters. foreach ((array)$events as $event) { if (static::listeners($event)) { foreach (static::$events[$event] as $callback) { $response = call_user_func_array($callback, $parameters); // If the event is set to halt, // return the first response that is not null. if ($halt && !is_null($response)) { return $response; } $responses[] = $response; } } } return $halt ? null : $responses; }
[ "public", "static", "function", "fire", "(", "$", "events", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "halt", "=", "false", ")", "{", "$", "responses", "=", "array", "(", ")", ";", "$", "parameters", "=", "(", "array", ")", "$", "parameters", ";", "// If the event has listeners, iterate through them and call each listener,", "// passing in the parameters.", "foreach", "(", "(", "array", ")", "$", "events", "as", "$", "event", ")", "{", "if", "(", "static", "::", "listeners", "(", "$", "event", ")", ")", "{", "foreach", "(", "static", "::", "$", "events", "[", "$", "event", "]", "as", "$", "callback", ")", "{", "$", "response", "=", "call_user_func_array", "(", "$", "callback", ",", "$", "parameters", ")", ";", "// If the event is set to halt,", "// return the first response that is not null.", "if", "(", "$", "halt", "&&", "!", "is_null", "(", "$", "response", ")", ")", "{", "return", "$", "response", ";", "}", "$", "responses", "[", "]", "=", "$", "response", ";", "}", "}", "}", "return", "$", "halt", "?", "null", ":", "$", "responses", ";", "}" ]
Fire an event so that all listeners are called. @param string $events @param array $parameters @param bool $halt @return array|null
[ "Fire", "an", "event", "so", "that", "all", "listeners", "are", "called", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Event.php#L149-L175
226,066
kinglozzer/tinypng
src/Result.php
Result.makeDir
protected function makeDir($path) { if (! file_exists(dirname($path))) { $this->makeDir(dirname($path)); } if (! file_exists($path)) { mkdir($path); } }
php
protected function makeDir($path) { if (! file_exists(dirname($path))) { $this->makeDir(dirname($path)); } if (! file_exists($path)) { mkdir($path); } }
[ "protected", "function", "makeDir", "(", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "dirname", "(", "$", "path", ")", ")", ")", "{", "$", "this", "->", "makeDir", "(", "dirname", "(", "$", "path", ")", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "mkdir", "(", "$", "path", ")", ";", "}", "}" ]
Creates a directory, recursively iterating through, and creating, missing parent directories @param string $path
[ "Creates", "a", "directory", "recursively", "iterating", "through", "and", "creating", "missing", "parent", "directories" ]
3ae3b1ed217bd5a77c449c3a3d7ea3f0d33a4025
https://github.com/kinglozzer/tinypng/blob/3ae3b1ed217bd5a77c449c3a3d7ea3f0d33a4025/src/Result.php#L85-L94
226,067
gjerokrsteski/pimf-framework
core/Pimf/Controller/Base.php
Base.render
public function render() { if (Sapi::isCli() && Config::get('environment') == 'production') { $suffix = 'CliAction'; $action = $this->request->fromCli()->get('action', 'index'); } else { $suffix = 'Action'; if ($this->request->getMethod() != 'GET' && $this->request->getMethod() != 'POST') { $redirectUrl = new Value($this->env->REDIRECT_URL); $redirectUrl = $redirectUrl->deleteLeading('/')->deleteTrailing('/')->explode('/'); $action = isset($redirectUrl[1]) ? $redirectUrl[1] : 'index'; } else { $bag = sprintf('from%s', ucfirst(strtolower($this->request->getMethod()))); $action = $this->request->{$bag}()->get('action', 'index'); } if (Config::get('app.routeable') === true && $this->router instanceof \Pimf\Router) { $target = $this->router->find(); if ($target instanceof \Pimf\Route\Target) { $action = $target->getAction(); Request::$getData = new Param( array_merge($target->getParams(), Request::$getData->getAll()) ); } } } $action = strtolower($action) . $suffix; if (method_exists($this, 'init')) { call_user_func(array($this, 'init')); } if (!method_exists($this, $action)) { throw new Bomb("no action '{$action}' defined at controller " . get_class($this)); } return call_user_func(array($this, $action)); }
php
public function render() { if (Sapi::isCli() && Config::get('environment') == 'production') { $suffix = 'CliAction'; $action = $this->request->fromCli()->get('action', 'index'); } else { $suffix = 'Action'; if ($this->request->getMethod() != 'GET' && $this->request->getMethod() != 'POST') { $redirectUrl = new Value($this->env->REDIRECT_URL); $redirectUrl = $redirectUrl->deleteLeading('/')->deleteTrailing('/')->explode('/'); $action = isset($redirectUrl[1]) ? $redirectUrl[1] : 'index'; } else { $bag = sprintf('from%s', ucfirst(strtolower($this->request->getMethod()))); $action = $this->request->{$bag}()->get('action', 'index'); } if (Config::get('app.routeable') === true && $this->router instanceof \Pimf\Router) { $target = $this->router->find(); if ($target instanceof \Pimf\Route\Target) { $action = $target->getAction(); Request::$getData = new Param( array_merge($target->getParams(), Request::$getData->getAll()) ); } } } $action = strtolower($action) . $suffix; if (method_exists($this, 'init')) { call_user_func(array($this, 'init')); } if (!method_exists($this, $action)) { throw new Bomb("no action '{$action}' defined at controller " . get_class($this)); } return call_user_func(array($this, $action)); }
[ "public", "function", "render", "(", ")", "{", "if", "(", "Sapi", "::", "isCli", "(", ")", "&&", "Config", "::", "get", "(", "'environment'", ")", "==", "'production'", ")", "{", "$", "suffix", "=", "'CliAction'", ";", "$", "action", "=", "$", "this", "->", "request", "->", "fromCli", "(", ")", "->", "get", "(", "'action'", ",", "'index'", ")", ";", "}", "else", "{", "$", "suffix", "=", "'Action'", ";", "if", "(", "$", "this", "->", "request", "->", "getMethod", "(", ")", "!=", "'GET'", "&&", "$", "this", "->", "request", "->", "getMethod", "(", ")", "!=", "'POST'", ")", "{", "$", "redirectUrl", "=", "new", "Value", "(", "$", "this", "->", "env", "->", "REDIRECT_URL", ")", ";", "$", "redirectUrl", "=", "$", "redirectUrl", "->", "deleteLeading", "(", "'/'", ")", "->", "deleteTrailing", "(", "'/'", ")", "->", "explode", "(", "'/'", ")", ";", "$", "action", "=", "isset", "(", "$", "redirectUrl", "[", "1", "]", ")", "?", "$", "redirectUrl", "[", "1", "]", ":", "'index'", ";", "}", "else", "{", "$", "bag", "=", "sprintf", "(", "'from%s'", ",", "ucfirst", "(", "strtolower", "(", "$", "this", "->", "request", "->", "getMethod", "(", ")", ")", ")", ")", ";", "$", "action", "=", "$", "this", "->", "request", "->", "{", "$", "bag", "}", "(", ")", "->", "get", "(", "'action'", ",", "'index'", ")", ";", "}", "if", "(", "Config", "::", "get", "(", "'app.routeable'", ")", "===", "true", "&&", "$", "this", "->", "router", "instanceof", "\\", "Pimf", "\\", "Router", ")", "{", "$", "target", "=", "$", "this", "->", "router", "->", "find", "(", ")", ";", "if", "(", "$", "target", "instanceof", "\\", "Pimf", "\\", "Route", "\\", "Target", ")", "{", "$", "action", "=", "$", "target", "->", "getAction", "(", ")", ";", "Request", "::", "$", "getData", "=", "new", "Param", "(", "array_merge", "(", "$", "target", "->", "getParams", "(", ")", ",", "Request", "::", "$", "getData", "->", "getAll", "(", ")", ")", ")", ";", "}", "}", "}", "$", "action", "=", "strtolower", "(", "$", "action", ")", ".", "$", "suffix", ";", "if", "(", "method_exists", "(", "$", "this", ",", "'init'", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "'init'", ")", ")", ";", "}", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "action", ")", ")", "{", "throw", "new", "Bomb", "(", "\"no action '{$action}' defined at controller \"", ".", "get_class", "(", "$", "this", ")", ")", ";", "}", "return", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "action", ")", ")", ";", "}" ]
Method to show the content. @return mixed @throws \Exception If not supported request method or bad controller
[ "Method", "to", "show", "the", "content", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Controller/Base.php#L87-L133
226,068
gjerokrsteski/pimf-framework
core/Pimf/Controller/Base.php
Base.redirect
public function redirect($route, $permanent = false, $exit = true) { $url = Url::compute($route); ($permanent === true) ? Header::sendMovedPermanently() : Header::sendFound(); Header::toLocation($url, $exit); }
php
public function redirect($route, $permanent = false, $exit = true) { $url = Url::compute($route); ($permanent === true) ? Header::sendMovedPermanently() : Header::sendFound(); Header::toLocation($url, $exit); }
[ "public", "function", "redirect", "(", "$", "route", ",", "$", "permanent", "=", "false", ",", "$", "exit", "=", "true", ")", "{", "$", "url", "=", "Url", "::", "compute", "(", "$", "route", ")", ";", "(", "$", "permanent", "===", "true", ")", "?", "Header", "::", "sendMovedPermanently", "(", ")", ":", "Header", "::", "sendFound", "(", ")", ";", "Header", "::", "toLocation", "(", "$", "url", ",", "$", "exit", ")", ";", "}" ]
Prepares the response object to return an HTTP Redirect response to the client. @param string $route The redirect destination like controller/action @param boolean $permanent If permanent redirection or not. @param boolean $exit
[ "Prepares", "the", "response", "object", "to", "return", "an", "HTTP", "Redirect", "response", "to", "the", "client", "." ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Controller/Base.php#L142-L149
226,069
gjerokrsteski/pimf-framework
core/Pimf/Sapi.php
Sapi.isWeb
public static function isWeb() { return self::isApache() || self::isIIS() || self::isCgi() || self::isBuiltInWebServer() || self::isHHVM(); }
php
public static function isWeb() { return self::isApache() || self::isIIS() || self::isCgi() || self::isBuiltInWebServer() || self::isHHVM(); }
[ "public", "static", "function", "isWeb", "(", ")", "{", "return", "self", "::", "isApache", "(", ")", "||", "self", "::", "isIIS", "(", ")", "||", "self", "::", "isCgi", "(", ")", "||", "self", "::", "isBuiltInWebServer", "(", ")", "||", "self", "::", "isHHVM", "(", ")", ";", "}" ]
Are we in a web environment? @return boolean
[ "Are", "we", "in", "a", "web", "environment?" ]
859aa7c8bb727b556c5e32224842af3cff33f18b
https://github.com/gjerokrsteski/pimf-framework/blob/859aa7c8bb727b556c5e32224842af3cff33f18b/core/Pimf/Sapi.php#L25-L28
226,070
progsmile/request-validator
src/Rules/BaseRule.php
BaseRule.getConfig
public function getConfig($type = self::CONFIG_ALL) { if ($type == self::CONFIG_ALL) { return $this->config; } return isset($this->config[$type]) ? $this->config[$type] : []; }
php
public function getConfig($type = self::CONFIG_ALL) { if ($type == self::CONFIG_ALL) { return $this->config; } return isset($this->config[$type]) ? $this->config[$type] : []; }
[ "public", "function", "getConfig", "(", "$", "type", "=", "self", "::", "CONFIG_ALL", ")", "{", "if", "(", "$", "type", "==", "self", "::", "CONFIG_ALL", ")", "{", "return", "$", "this", "->", "config", ";", "}", "return", "isset", "(", "$", "this", "->", "config", "[", "$", "type", "]", ")", "?", "$", "this", "->", "config", "[", "$", "type", "]", ":", "[", "]", ";", "}" ]
Returns all config array, or specific one. @param string $type @return array
[ "Returns", "all", "config", "array", "or", "specific", "one", "." ]
f211abd1a8e7c67030401f8c4896d926da7dafef
https://github.com/progsmile/request-validator/blob/f211abd1a8e7c67030401f8c4896d926da7dafef/src/Rules/BaseRule.php#L36-L43
226,071
progsmile/request-validator
src/Rules/BaseRule.php
BaseRule.isNotRequiredAndEmpty
protected function isNotRequiredAndEmpty($type = 'var') { $condition = false; if ($type == 'var') { $condition = strlen($this->params[1]) == 0; } elseif ($type == 'file') { $fieldsName = $this->params[0]; //when file field is not required and empty $condition = isset($_FILES[$fieldsName]['name']) && $_FILES[$fieldsName]['name'] == ''; } return !$this->hasRule('required') && $condition; }
php
protected function isNotRequiredAndEmpty($type = 'var') { $condition = false; if ($type == 'var') { $condition = strlen($this->params[1]) == 0; } elseif ($type == 'file') { $fieldsName = $this->params[0]; //when file field is not required and empty $condition = isset($_FILES[$fieldsName]['name']) && $_FILES[$fieldsName]['name'] == ''; } return !$this->hasRule('required') && $condition; }
[ "protected", "function", "isNotRequiredAndEmpty", "(", "$", "type", "=", "'var'", ")", "{", "$", "condition", "=", "false", ";", "if", "(", "$", "type", "==", "'var'", ")", "{", "$", "condition", "=", "strlen", "(", "$", "this", "->", "params", "[", "1", "]", ")", "==", "0", ";", "}", "elseif", "(", "$", "type", "==", "'file'", ")", "{", "$", "fieldsName", "=", "$", "this", "->", "params", "[", "0", "]", ";", "//when file field is not required and empty", "$", "condition", "=", "isset", "(", "$", "_FILES", "[", "$", "fieldsName", "]", "[", "'name'", "]", ")", "&&", "$", "_FILES", "[", "$", "fieldsName", "]", "[", "'name'", "]", "==", "''", ";", "}", "return", "!", "$", "this", "->", "hasRule", "(", "'required'", ")", "&&", "$", "condition", ";", "}" ]
Check if variable is not required - to prevent error messages from another validators. @param string $type | 'var' or 'file' @return bool
[ "Check", "if", "variable", "is", "not", "required", "-", "to", "prevent", "error", "messages", "from", "another", "validators", "." ]
f211abd1a8e7c67030401f8c4896d926da7dafef
https://github.com/progsmile/request-validator/blob/f211abd1a8e7c67030401f8c4896d926da7dafef/src/Rules/BaseRule.php#L64-L78
226,072
crip-laravel/filesys
src/Services/Blob.php
Blob.setPath
public function setPath($path = '') { $userFolder = Str::normalizePath(config('cripfilesys.user_folder')); if ($userFolder !== '' && !starts_with($path, $userFolder)) { $path = empty($path) ? '' : $path; $path = $this->prefixPath($path, $userFolder); } $this->path = Str::normalizePath($path); return $this; }
php
public function setPath($path = '') { $userFolder = Str::normalizePath(config('cripfilesys.user_folder')); if ($userFolder !== '' && !starts_with($path, $userFolder)) { $path = empty($path) ? '' : $path; $path = $this->prefixPath($path, $userFolder); } $this->path = Str::normalizePath($path); return $this; }
[ "public", "function", "setPath", "(", "$", "path", "=", "''", ")", "{", "$", "userFolder", "=", "Str", "::", "normalizePath", "(", "config", "(", "'cripfilesys.user_folder'", ")", ")", ";", "if", "(", "$", "userFolder", "!==", "''", "&&", "!", "starts_with", "(", "$", "path", ",", "$", "userFolder", ")", ")", "{", "$", "path", "=", "empty", "(", "$", "path", ")", "?", "''", ":", "$", "path", ";", "$", "path", "=", "$", "this", "->", "prefixPath", "(", "$", "path", ",", "$", "userFolder", ")", ";", "}", "$", "this", "->", "path", "=", "Str", "::", "normalizePath", "(", "$", "path", ")", ";", "return", "$", "this", ";", "}" ]
Set current blob path property. @param string $path @return Blob $this
[ "Set", "current", "blob", "path", "property", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L49-L61
226,073
crip-laravel/filesys
src/Services/Blob.php
Blob.getMediaType
public function getMediaType() { $mime = $this->getMime(); if ($mime == 'file') { return $mime; } foreach ($this->package->config('mime.media') as $mediaType => $mimes) { if (in_array($mime, $mimes)) { return $mediaType; } } return 'dir'; }
php
public function getMediaType() { $mime = $this->getMime(); if ($mime == 'file') { return $mime; } foreach ($this->package->config('mime.media') as $mediaType => $mimes) { if (in_array($mime, $mimes)) { return $mediaType; } } return 'dir'; }
[ "public", "function", "getMediaType", "(", ")", "{", "$", "mime", "=", "$", "this", "->", "getMime", "(", ")", ";", "if", "(", "$", "mime", "==", "'file'", ")", "{", "return", "$", "mime", ";", "}", "foreach", "(", "$", "this", "->", "package", "->", "config", "(", "'mime.media'", ")", "as", "$", "mediaType", "=>", "$", "mimes", ")", "{", "if", "(", "in_array", "(", "$", "mime", ",", "$", "mimes", ")", ")", "{", "return", "$", "mediaType", ";", "}", "}", "return", "'dir'", ";", "}" ]
Get blob media type. @return string
[ "Get", "blob", "media", "type", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L96-L111
226,074
crip-laravel/filesys
src/Services/Blob.php
Blob.getThumbUrl
public function getThumbUrl($size = 'thumb') { $url = $this->package->config('icons.url'); $icons = $this->package->config('icons.files'); if (!$this->metadata->isFile()) { return $url . $icons['dir']; } if ($this->isImage()) { $thumbs = $this->getThumbsDetails(); if (!array_key_exists($size, $thumbs)) { return $url . $icons['img']; } return $thumbs[$size]['url']; } $mime = $this->getMime(); if (!array_key_exists($mime, $icons)) { $message = sprintf('Configuration file is missing for `%s` file type in `icons.files` array', $mime); throw new \Exception($message); } return $url . $icons[$mime]; }
php
public function getThumbUrl($size = 'thumb') { $url = $this->package->config('icons.url'); $icons = $this->package->config('icons.files'); if (!$this->metadata->isFile()) { return $url . $icons['dir']; } if ($this->isImage()) { $thumbs = $this->getThumbsDetails(); if (!array_key_exists($size, $thumbs)) { return $url . $icons['img']; } return $thumbs[$size]['url']; } $mime = $this->getMime(); if (!array_key_exists($mime, $icons)) { $message = sprintf('Configuration file is missing for `%s` file type in `icons.files` array', $mime); throw new \Exception($message); } return $url . $icons[$mime]; }
[ "public", "function", "getThumbUrl", "(", "$", "size", "=", "'thumb'", ")", "{", "$", "url", "=", "$", "this", "->", "package", "->", "config", "(", "'icons.url'", ")", ";", "$", "icons", "=", "$", "this", "->", "package", "->", "config", "(", "'icons.files'", ")", ";", "if", "(", "!", "$", "this", "->", "metadata", "->", "isFile", "(", ")", ")", "{", "return", "$", "url", ".", "$", "icons", "[", "'dir'", "]", ";", "}", "if", "(", "$", "this", "->", "isImage", "(", ")", ")", "{", "$", "thumbs", "=", "$", "this", "->", "getThumbsDetails", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "size", ",", "$", "thumbs", ")", ")", "{", "return", "$", "url", ".", "$", "icons", "[", "'img'", "]", ";", "}", "return", "$", "thumbs", "[", "$", "size", "]", "[", "'url'", "]", ";", "}", "$", "mime", "=", "$", "this", "->", "getMime", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "mime", ",", "$", "icons", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'Configuration file is missing for `%s` file type in `icons.files` array'", ",", "$", "mime", ")", ";", "throw", "new", "\\", "Exception", "(", "$", "message", ")", ";", "}", "return", "$", "url", ".", "$", "icons", "[", "$", "mime", "]", ";", "}" ]
Get 'thumb' size thumbnail url. @param string $size @return string @throws \Exception
[ "Get", "thumb", "size", "thumbnail", "url", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L119-L145
226,075
crip-laravel/filesys
src/Services/Blob.php
Blob.getUrl
public function getUrl($path = null) { $path = $path ?: $this->path; if ($this->package->config('public_storage', false)) { // If file has public access enabled, we simply can try return storage // url to file. try { $useAbsolute = $this->package->config('absolute_url', false); $absolute = $this->storage->url($path); if ($useAbsolute) return $absolute; $relative = parse_url($absolute, PHP_URL_PATH); return '/' . trim($relative, '\\/'); } catch (\Exception $ex) { // Some drivers does not support url method (like ftp), so we // simply continue and generate crip url to our controller. } } $service = new UrlService($this->package); if ($this->metadata->isFile()) { return $service->file($path); } return $service->folder($path); }
php
public function getUrl($path = null) { $path = $path ?: $this->path; if ($this->package->config('public_storage', false)) { // If file has public access enabled, we simply can try return storage // url to file. try { $useAbsolute = $this->package->config('absolute_url', false); $absolute = $this->storage->url($path); if ($useAbsolute) return $absolute; $relative = parse_url($absolute, PHP_URL_PATH); return '/' . trim($relative, '\\/'); } catch (\Exception $ex) { // Some drivers does not support url method (like ftp), so we // simply continue and generate crip url to our controller. } } $service = new UrlService($this->package); if ($this->metadata->isFile()) { return $service->file($path); } return $service->folder($path); }
[ "public", "function", "getUrl", "(", "$", "path", "=", "null", ")", "{", "$", "path", "=", "$", "path", "?", ":", "$", "this", "->", "path", ";", "if", "(", "$", "this", "->", "package", "->", "config", "(", "'public_storage'", ",", "false", ")", ")", "{", "// If file has public access enabled, we simply can try return storage", "// url to file.", "try", "{", "$", "useAbsolute", "=", "$", "this", "->", "package", "->", "config", "(", "'absolute_url'", ",", "false", ")", ";", "$", "absolute", "=", "$", "this", "->", "storage", "->", "url", "(", "$", "path", ")", ";", "if", "(", "$", "useAbsolute", ")", "return", "$", "absolute", ";", "$", "relative", "=", "parse_url", "(", "$", "absolute", ",", "PHP_URL_PATH", ")", ";", "return", "'/'", ".", "trim", "(", "$", "relative", ",", "'\\\\/'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "// Some drivers does not support url method (like ftp), so we", "// simply continue and generate crip url to our controller.", "}", "}", "$", "service", "=", "new", "UrlService", "(", "$", "this", "->", "package", ")", ";", "if", "(", "$", "this", "->", "metadata", "->", "isFile", "(", ")", ")", "{", "return", "$", "service", "->", "file", "(", "$", "path", ")", ";", "}", "return", "$", "service", "->", "folder", "(", "$", "path", ")", ";", "}" ]
Generates url to a file. @param null $path @return string
[ "Generates", "url", "to", "a", "file", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L162-L190
226,076
crip-laravel/filesys
src/Services/Blob.php
Blob.getMime
public function getMime() { if ($this->metadata->isFile()) { $mimes = $this->package->config('mime.types'); foreach ($mimes as $mime => $mimeValues) { $key = collect($mimeValues)->search(function ($mimeValue) { return preg_match($mimeValue, $this->metadata->getMimeType()); }); if ($key !== false) { return $mime; } } return 'file'; } return 'dir'; }
php
public function getMime() { if ($this->metadata->isFile()) { $mimes = $this->package->config('mime.types'); foreach ($mimes as $mime => $mimeValues) { $key = collect($mimeValues)->search(function ($mimeValue) { return preg_match($mimeValue, $this->metadata->getMimeType()); }); if ($key !== false) { return $mime; } } return 'file'; } return 'dir'; }
[ "public", "function", "getMime", "(", ")", "{", "if", "(", "$", "this", "->", "metadata", "->", "isFile", "(", ")", ")", "{", "$", "mimes", "=", "$", "this", "->", "package", "->", "config", "(", "'mime.types'", ")", ";", "foreach", "(", "$", "mimes", "as", "$", "mime", "=>", "$", "mimeValues", ")", "{", "$", "key", "=", "collect", "(", "$", "mimeValues", ")", "->", "search", "(", "function", "(", "$", "mimeValue", ")", "{", "return", "preg_match", "(", "$", "mimeValue", ",", "$", "this", "->", "metadata", "->", "getMimeType", "(", ")", ")", ";", "}", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "return", "$", "mime", ";", "}", "}", "return", "'file'", ";", "}", "return", "'dir'", ";", "}" ]
Get blob mime. @return int|string
[ "Get", "blob", "mime", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L196-L214
226,077
crip-laravel/filesys
src/Services/Blob.php
Blob.isImage
private function isImage() { if ($this->metadata->isFile() && mb_strpos($this->metadata->getMimeType(), 'image/') === 0 ) { return true; } return false; }
php
private function isImage() { if ($this->metadata->isFile() && mb_strpos($this->metadata->getMimeType(), 'image/') === 0 ) { return true; } return false; }
[ "private", "function", "isImage", "(", ")", "{", "if", "(", "$", "this", "->", "metadata", "->", "isFile", "(", ")", "&&", "mb_strpos", "(", "$", "this", "->", "metadata", "->", "getMimeType", "(", ")", ",", "'image/'", ")", "===", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determines is the current blob an image. @return bool
[ "Determines", "is", "the", "current", "blob", "an", "image", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L233-L242
226,078
crip-laravel/filesys
src/Services/Blob.php
Blob.setThumbsDetails
private function setThumbsDetails() { $this->thumbsDetails = []; if ($this->isImage()) { $service = new ThumbService($this->package); collect($service->getSizes())->each(function ($size, $key) { $this->thumbsDetails[$key] = [ 'size' => $key, 'width' => $size[0], 'height' => $size[1], 'url' => $this->getUrl($key . '/' . $this->path) ]; }); } }
php
private function setThumbsDetails() { $this->thumbsDetails = []; if ($this->isImage()) { $service = new ThumbService($this->package); collect($service->getSizes())->each(function ($size, $key) { $this->thumbsDetails[$key] = [ 'size' => $key, 'width' => $size[0], 'height' => $size[1], 'url' => $this->getUrl($key . '/' . $this->path) ]; }); } }
[ "private", "function", "setThumbsDetails", "(", ")", "{", "$", "this", "->", "thumbsDetails", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isImage", "(", ")", ")", "{", "$", "service", "=", "new", "ThumbService", "(", "$", "this", "->", "package", ")", ";", "collect", "(", "$", "service", "->", "getSizes", "(", ")", ")", "->", "each", "(", "function", "(", "$", "size", ",", "$", "key", ")", "{", "$", "this", "->", "thumbsDetails", "[", "$", "key", "]", "=", "[", "'size'", "=>", "$", "key", ",", "'width'", "=>", "$", "size", "[", "0", "]", ",", "'height'", "=>", "$", "size", "[", "1", "]", ",", "'url'", "=>", "$", "this", "->", "getUrl", "(", "$", "key", ".", "'/'", ".", "$", "this", "->", "path", ")", "]", ";", "}", ")", ";", "}", "}" ]
Set thumb sizes details for current file.
[ "Set", "thumb", "sizes", "details", "for", "current", "file", "." ]
43c66929a5a16772dbb3bae4b5188bdc10b6f9ec
https://github.com/crip-laravel/filesys/blob/43c66929a5a16772dbb3bae4b5188bdc10b6f9ec/src/Services/Blob.php#L247-L261
226,079
adamgoose/laravel-annotations
src/Adamgoose/AnnotationsServiceProvider.php
AnnotationsServiceProvider.loadAnnotatedRoutes
protected function loadAnnotatedRoutes() { if ($this->app->environment('local') && $this->scanWhenLocal) { $this->scanRoutes(); } if ( ! empty($this->scanRoutes) && $this->finder->routesAreScanned()) { $this->loadScannedRoutes(); } }
php
protected function loadAnnotatedRoutes() { if ($this->app->environment('local') && $this->scanWhenLocal) { $this->scanRoutes(); } if ( ! empty($this->scanRoutes) && $this->finder->routesAreScanned()) { $this->loadScannedRoutes(); } }
[ "protected", "function", "loadAnnotatedRoutes", "(", ")", "{", "if", "(", "$", "this", "->", "app", "->", "environment", "(", "'local'", ")", "&&", "$", "this", "->", "scanWhenLocal", ")", "{", "$", "this", "->", "scanRoutes", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "scanRoutes", ")", "&&", "$", "this", "->", "finder", "->", "routesAreScanned", "(", ")", ")", "{", "$", "this", "->", "loadScannedRoutes", "(", ")", ";", "}", "}" ]
Load the annotated routes @return void
[ "Load", "the", "annotated", "routes" ]
0a8445508d5d3aeb08e42d0bb357373b522da28e
https://github.com/adamgoose/laravel-annotations/blob/0a8445508d5d3aeb08e42d0bb357373b522da28e/src/Adamgoose/AnnotationsServiceProvider.php#L180-L191
226,080
progsmile/request-validator
src/Helpers/ValidatorFacade.php
ValidatorFacade.messages
public function messages($field = '') { if ($field) { return isset($this->errorMessages[$field]) ? $this->errorMessages[$field] : []; } $messages = []; array_walk_recursive($this->errorMessages, function ($message) use (&$messages) { $messages[] = $message; }); return $messages; }
php
public function messages($field = '') { if ($field) { return isset($this->errorMessages[$field]) ? $this->errorMessages[$field] : []; } $messages = []; array_walk_recursive($this->errorMessages, function ($message) use (&$messages) { $messages[] = $message; }); return $messages; }
[ "public", "function", "messages", "(", "$", "field", "=", "''", ")", "{", "if", "(", "$", "field", ")", "{", "return", "isset", "(", "$", "this", "->", "errorMessages", "[", "$", "field", "]", ")", "?", "$", "this", "->", "errorMessages", "[", "$", "field", "]", ":", "[", "]", ";", "}", "$", "messages", "=", "[", "]", ";", "array_walk_recursive", "(", "$", "this", "->", "errorMessages", ",", "function", "(", "$", "message", ")", "use", "(", "&", "$", "messages", ")", "{", "$", "messages", "[", "]", "=", "$", "message", ";", "}", ")", ";", "return", "$", "messages", ";", "}" ]
Get flat messages array, or all messages from field. @param string $field @return array
[ "Get", "flat", "messages", "array", "or", "all", "messages", "from", "field", "." ]
f211abd1a8e7c67030401f8c4896d926da7dafef
https://github.com/progsmile/request-validator/blob/f211abd1a8e7c67030401f8c4896d926da7dafef/src/Helpers/ValidatorFacade.php#L71-L84
226,081
progsmile/request-validator
src/Helpers/ValidatorFacade.php
ValidatorFacade.firsts
public function firsts() { $messages = []; foreach ($this->errorMessages as $fieldsMessages) { foreach ($fieldsMessages as $fieldMessage) { $messages[] = $fieldMessage; break; } } return $messages; }
php
public function firsts() { $messages = []; foreach ($this->errorMessages as $fieldsMessages) { foreach ($fieldsMessages as $fieldMessage) { $messages[] = $fieldMessage; break; } } return $messages; }
[ "public", "function", "firsts", "(", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "errorMessages", "as", "$", "fieldsMessages", ")", "{", "foreach", "(", "$", "fieldsMessages", "as", "$", "fieldMessage", ")", "{", "$", "messages", "[", "]", "=", "$", "fieldMessage", ";", "break", ";", "}", "}", "return", "$", "messages", ";", "}" ]
For each rule get it's first message. @return array
[ "For", "each", "rule", "get", "it", "s", "first", "message", "." ]
f211abd1a8e7c67030401f8c4896d926da7dafef
https://github.com/progsmile/request-validator/blob/f211abd1a8e7c67030401f8c4896d926da7dafef/src/Helpers/ValidatorFacade.php#L101-L112
226,082
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.isPerUserEncryptionEnabled
public function isPerUserEncryptionEnabled() { $perUserEncryptionEnabled = false; if ($this->settings['per_user_encryption_enabled']) { $encryptionMetadata = $this->metadataFactory->getAllMetadata(); /** @var ClassMetadata $classEncryptionMetadata */ foreach ($encryptionMetadata as $classEncryptionMetadata) { if (self::MODE_PER_USER_SHAREABLE === $classEncryptionMetadata->encryptionMode) { $perUserEncryptionEnabled = true; break; } } } return $perUserEncryptionEnabled; }
php
public function isPerUserEncryptionEnabled() { $perUserEncryptionEnabled = false; if ($this->settings['per_user_encryption_enabled']) { $encryptionMetadata = $this->metadataFactory->getAllMetadata(); /** @var ClassMetadata $classEncryptionMetadata */ foreach ($encryptionMetadata as $classEncryptionMetadata) { if (self::MODE_PER_USER_SHAREABLE === $classEncryptionMetadata->encryptionMode) { $perUserEncryptionEnabled = true; break; } } } return $perUserEncryptionEnabled; }
[ "public", "function", "isPerUserEncryptionEnabled", "(", ")", "{", "$", "perUserEncryptionEnabled", "=", "false", ";", "if", "(", "$", "this", "->", "settings", "[", "'per_user_encryption_enabled'", "]", ")", "{", "$", "encryptionMetadata", "=", "$", "this", "->", "metadataFactory", "->", "getAllMetadata", "(", ")", ";", "/** @var ClassMetadata $classEncryptionMetadata */", "foreach", "(", "$", "encryptionMetadata", "as", "$", "classEncryptionMetadata", ")", "{", "if", "(", "self", "::", "MODE_PER_USER_SHAREABLE", "===", "$", "classEncryptionMetadata", "->", "encryptionMode", ")", "{", "$", "perUserEncryptionEnabled", "=", "true", ";", "break", ";", "}", "}", "}", "return", "$", "perUserEncryptionEnabled", ";", "}" ]
Checks if the Per User Encryption must be enabled @return bool
[ "Checks", "if", "the", "Per", "User", "Encryption", "must", "be", "enabled" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L118-L134
226,083
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getEncryptionEnabledEntitiesMetadata
public function getEncryptionEnabledEntitiesMetadata() { $entityManager = $this->doctrine->getManager(); $doctrineMetadataFactory = $entityManager->getMetadataFactory(); $encryptedEnabledTypes = array(); $encryptionMetadata = $this->metadataFactory->getAllMetadata(); /** @var ClassMetadata $encryptionClassMetadata */ foreach ($encryptionMetadata as $encryptionClassMetadata) { if ($encryptionClassMetadata->encryptionEnabled) { $className = $encryptionClassMetadata->name; $encryptedEnabledTypes[] = $doctrineMetadataFactory->getMetadataFor($className); } } return $encryptedEnabledTypes; }
php
public function getEncryptionEnabledEntitiesMetadata() { $entityManager = $this->doctrine->getManager(); $doctrineMetadataFactory = $entityManager->getMetadataFactory(); $encryptedEnabledTypes = array(); $encryptionMetadata = $this->metadataFactory->getAllMetadata(); /** @var ClassMetadata $encryptionClassMetadata */ foreach ($encryptionMetadata as $encryptionClassMetadata) { if ($encryptionClassMetadata->encryptionEnabled) { $className = $encryptionClassMetadata->name; $encryptedEnabledTypes[] = $doctrineMetadataFactory->getMetadataFor($className); } } return $encryptedEnabledTypes; }
[ "public", "function", "getEncryptionEnabledEntitiesMetadata", "(", ")", "{", "$", "entityManager", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", ";", "$", "doctrineMetadataFactory", "=", "$", "entityManager", "->", "getMetadataFactory", "(", ")", ";", "$", "encryptedEnabledTypes", "=", "array", "(", ")", ";", "$", "encryptionMetadata", "=", "$", "this", "->", "metadataFactory", "->", "getAllMetadata", "(", ")", ";", "/** @var ClassMetadata $encryptionClassMetadata */", "foreach", "(", "$", "encryptionMetadata", "as", "$", "encryptionClassMetadata", ")", "{", "if", "(", "$", "encryptionClassMetadata", "->", "encryptionEnabled", ")", "{", "$", "className", "=", "$", "encryptionClassMetadata", "->", "name", ";", "$", "encryptedEnabledTypes", "[", "]", "=", "$", "doctrineMetadataFactory", "->", "getMetadataFor", "(", "$", "className", ")", ";", "}", "}", "return", "$", "encryptedEnabledTypes", ";", "}" ]
Returns the doctrine metadata of all the encryption enabled entities @return array
[ "Returns", "the", "doctrine", "metadata", "of", "all", "the", "encryption", "enabled", "entities" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L141-L157
226,084
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.addEncryptionMetadata
public function addEncryptionMetadata(DoctrineClassMetadata $metadata) { if ($metadata->isMappedSuperclass) { return; } $reflection = $metadata->getReflectionClass(); if ($this->hasEncryptionEnabled($reflection) && !$this->hasEncryptionFieldsDoctrineMetadata($metadata)) { $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT); if ($this->keyPerEntityRequired($reflection)) { // Add the field required to hold the key used to encrypt this entity $keyField = array( 'fieldName' => 'key', 'columnName' => '_key', 'type' => 'object', 'nullable' => true, ); $metadata->mapField($keyField); // Add the field required to hold the initialization vector used to encrypt this entity $ivField = array( 'fieldName' => 'iv', 'columnName' => '_iv', 'type' => 'text', 'nullable' => true, ); $metadata->mapField($ivField); } // Field to control is the entity is already encrypted or not $isEncryptedField = array( 'fieldName' => 'encrypted', 'columnName' => '_encrypted', 'type' => 'boolean', ); $metadata->mapField($isEncryptedField); // Field to force the persitence of the entity in the migration process $isMigratedField = array( 'fieldName' => 'migrated', 'columnName' => '_migrated', 'type' => 'boolean', ); $metadata->mapField($isMigratedField); // Add a field to check if the associated file is encrypted if ($this->hasFileEncryptionEnabled($reflection)) { $isFileEncryptedField = array( 'fieldName' => 'fileEncrypted', 'columnName' => '_file_encrypted', 'type' => 'boolean', ); $metadata->mapField($isFileEncryptedField); } } if ($this->hasEncryptionEnabled($reflection)) { // Modify the metadata of the encrypted fields of the entity $encryptedFields = $this->getEncryptionEnabledFields($reflection); foreach ($encryptedFields as $encryptedField) { $fieldName = $encryptedField->name; $fieldMapping = $metadata->getFieldMapping($fieldName); // We process the field if has not already been process in another class of the hierarchy if (!isset($fieldMapping['_old_type'])) { $encryptedFieldMapping = $this->getEncryptedFieldMapping($fieldMapping); $override = $encryptedFieldMapping->getMappingAttributeOverride(); /* * It's not possible to change the type of a column using * Doctrine\ORM\Mapping\ClassMetadata::setAssociationOverride * The only alternative that I found it to directly access the fieldMappings property * that until the version 2.5 of Doctrine ORM is public. If this changes in comming * versions of Doctrine this should also be changed */ $metadata->fieldMappings[$fieldName] = $override; } } } return $metadata; }
php
public function addEncryptionMetadata(DoctrineClassMetadata $metadata) { if ($metadata->isMappedSuperclass) { return; } $reflection = $metadata->getReflectionClass(); if ($this->hasEncryptionEnabled($reflection) && !$this->hasEncryptionFieldsDoctrineMetadata($metadata)) { $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT); if ($this->keyPerEntityRequired($reflection)) { // Add the field required to hold the key used to encrypt this entity $keyField = array( 'fieldName' => 'key', 'columnName' => '_key', 'type' => 'object', 'nullable' => true, ); $metadata->mapField($keyField); // Add the field required to hold the initialization vector used to encrypt this entity $ivField = array( 'fieldName' => 'iv', 'columnName' => '_iv', 'type' => 'text', 'nullable' => true, ); $metadata->mapField($ivField); } // Field to control is the entity is already encrypted or not $isEncryptedField = array( 'fieldName' => 'encrypted', 'columnName' => '_encrypted', 'type' => 'boolean', ); $metadata->mapField($isEncryptedField); // Field to force the persitence of the entity in the migration process $isMigratedField = array( 'fieldName' => 'migrated', 'columnName' => '_migrated', 'type' => 'boolean', ); $metadata->mapField($isMigratedField); // Add a field to check if the associated file is encrypted if ($this->hasFileEncryptionEnabled($reflection)) { $isFileEncryptedField = array( 'fieldName' => 'fileEncrypted', 'columnName' => '_file_encrypted', 'type' => 'boolean', ); $metadata->mapField($isFileEncryptedField); } } if ($this->hasEncryptionEnabled($reflection)) { // Modify the metadata of the encrypted fields of the entity $encryptedFields = $this->getEncryptionEnabledFields($reflection); foreach ($encryptedFields as $encryptedField) { $fieldName = $encryptedField->name; $fieldMapping = $metadata->getFieldMapping($fieldName); // We process the field if has not already been process in another class of the hierarchy if (!isset($fieldMapping['_old_type'])) { $encryptedFieldMapping = $this->getEncryptedFieldMapping($fieldMapping); $override = $encryptedFieldMapping->getMappingAttributeOverride(); /* * It's not possible to change the type of a column using * Doctrine\ORM\Mapping\ClassMetadata::setAssociationOverride * The only alternative that I found it to directly access the fieldMappings property * that until the version 2.5 of Doctrine ORM is public. If this changes in comming * versions of Doctrine this should also be changed */ $metadata->fieldMappings[$fieldName] = $override; } } } return $metadata; }
[ "public", "function", "addEncryptionMetadata", "(", "DoctrineClassMetadata", "$", "metadata", ")", "{", "if", "(", "$", "metadata", "->", "isMappedSuperclass", ")", "{", "return", ";", "}", "$", "reflection", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "$", "this", "->", "hasEncryptionEnabled", "(", "$", "reflection", ")", "&&", "!", "$", "this", "->", "hasEncryptionFieldsDoctrineMetadata", "(", "$", "metadata", ")", ")", "{", "$", "metadata", "->", "setChangeTrackingPolicy", "(", "ClassMetadataInfo", "::", "CHANGETRACKING_DEFERRED_EXPLICIT", ")", ";", "if", "(", "$", "this", "->", "keyPerEntityRequired", "(", "$", "reflection", ")", ")", "{", "// Add the field required to hold the key used to encrypt this entity", "$", "keyField", "=", "array", "(", "'fieldName'", "=>", "'key'", ",", "'columnName'", "=>", "'_key'", ",", "'type'", "=>", "'object'", ",", "'nullable'", "=>", "true", ",", ")", ";", "$", "metadata", "->", "mapField", "(", "$", "keyField", ")", ";", "// Add the field required to hold the initialization vector used to encrypt this entity", "$", "ivField", "=", "array", "(", "'fieldName'", "=>", "'iv'", ",", "'columnName'", "=>", "'_iv'", ",", "'type'", "=>", "'text'", ",", "'nullable'", "=>", "true", ",", ")", ";", "$", "metadata", "->", "mapField", "(", "$", "ivField", ")", ";", "}", "// Field to control is the entity is already encrypted or not", "$", "isEncryptedField", "=", "array", "(", "'fieldName'", "=>", "'encrypted'", ",", "'columnName'", "=>", "'_encrypted'", ",", "'type'", "=>", "'boolean'", ",", ")", ";", "$", "metadata", "->", "mapField", "(", "$", "isEncryptedField", ")", ";", "// Field to force the persitence of the entity in the migration process", "$", "isMigratedField", "=", "array", "(", "'fieldName'", "=>", "'migrated'", ",", "'columnName'", "=>", "'_migrated'", ",", "'type'", "=>", "'boolean'", ",", ")", ";", "$", "metadata", "->", "mapField", "(", "$", "isMigratedField", ")", ";", "// Add a field to check if the associated file is encrypted", "if", "(", "$", "this", "->", "hasFileEncryptionEnabled", "(", "$", "reflection", ")", ")", "{", "$", "isFileEncryptedField", "=", "array", "(", "'fieldName'", "=>", "'fileEncrypted'", ",", "'columnName'", "=>", "'_file_encrypted'", ",", "'type'", "=>", "'boolean'", ",", ")", ";", "$", "metadata", "->", "mapField", "(", "$", "isFileEncryptedField", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasEncryptionEnabled", "(", "$", "reflection", ")", ")", "{", "// Modify the metadata of the encrypted fields of the entity", "$", "encryptedFields", "=", "$", "this", "->", "getEncryptionEnabledFields", "(", "$", "reflection", ")", ";", "foreach", "(", "$", "encryptedFields", "as", "$", "encryptedField", ")", "{", "$", "fieldName", "=", "$", "encryptedField", "->", "name", ";", "$", "fieldMapping", "=", "$", "metadata", "->", "getFieldMapping", "(", "$", "fieldName", ")", ";", "// We process the field if has not already been process in another class of the hierarchy", "if", "(", "!", "isset", "(", "$", "fieldMapping", "[", "'_old_type'", "]", ")", ")", "{", "$", "encryptedFieldMapping", "=", "$", "this", "->", "getEncryptedFieldMapping", "(", "$", "fieldMapping", ")", ";", "$", "override", "=", "$", "encryptedFieldMapping", "->", "getMappingAttributeOverride", "(", ")", ";", "/*\n * It's not possible to change the type of a column using\n * Doctrine\\ORM\\Mapping\\ClassMetadata::setAssociationOverride\n * The only alternative that I found it to directly access the fieldMappings property\n * that until the version 2.5 of Doctrine ORM is public. If this changes in comming\n * versions of Doctrine this should also be changed\n */", "$", "metadata", "->", "fieldMappings", "[", "$", "fieldName", "]", "=", "$", "override", ";", "}", "}", "}", "return", "$", "metadata", ";", "}" ]
Adds the metadata required to encrypt the doctrine entity @param DoctrineClassMetadata $metadata @return DoctrineClassMetadata
[ "Adds", "the", "metadata", "required", "to", "encrypt", "the", "doctrine", "entity" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L165-L244
226,085
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.processEntityPostPersist
public function processEntityPostPersist($entity) { $userClasses = $this->settings['user_classes']; foreach ($userClasses as $userClass) { if (class_exists($userClass) && $entity instanceof $userClass) { $relatedEntities = $this->getUserRelatedEntities($entity); foreach ($relatedEntities as $relatedEntity) { $classMetadata = $this->getEncryptionMetadataFor(ClassUtils::getClass($relatedEntity)); if (EncryptionService::MODE_PER_USER_SHAREABLE === $classMetadata->encryptionMode) { $encryptionKey = $relatedEntity->getKey(); if ($encryptionKey) { $encryptionKey->updateUnidentifiedKey($entity); } } } } } // Now we have to decrypt the entity once again to be able to work with it from this moment $this->processEntity($entity, self::DECRYPT); }
php
public function processEntityPostPersist($entity) { $userClasses = $this->settings['user_classes']; foreach ($userClasses as $userClass) { if (class_exists($userClass) && $entity instanceof $userClass) { $relatedEntities = $this->getUserRelatedEntities($entity); foreach ($relatedEntities as $relatedEntity) { $classMetadata = $this->getEncryptionMetadataFor(ClassUtils::getClass($relatedEntity)); if (EncryptionService::MODE_PER_USER_SHAREABLE === $classMetadata->encryptionMode) { $encryptionKey = $relatedEntity->getKey(); if ($encryptionKey) { $encryptionKey->updateUnidentifiedKey($entity); } } } } } // Now we have to decrypt the entity once again to be able to work with it from this moment $this->processEntity($entity, self::DECRYPT); }
[ "public", "function", "processEntityPostPersist", "(", "$", "entity", ")", "{", "$", "userClasses", "=", "$", "this", "->", "settings", "[", "'user_classes'", "]", ";", "foreach", "(", "$", "userClasses", "as", "$", "userClass", ")", "{", "if", "(", "class_exists", "(", "$", "userClass", ")", "&&", "$", "entity", "instanceof", "$", "userClass", ")", "{", "$", "relatedEntities", "=", "$", "this", "->", "getUserRelatedEntities", "(", "$", "entity", ")", ";", "foreach", "(", "$", "relatedEntities", "as", "$", "relatedEntity", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "ClassUtils", "::", "getClass", "(", "$", "relatedEntity", ")", ")", ";", "if", "(", "EncryptionService", "::", "MODE_PER_USER_SHAREABLE", "===", "$", "classMetadata", "->", "encryptionMode", ")", "{", "$", "encryptionKey", "=", "$", "relatedEntity", "->", "getKey", "(", ")", ";", "if", "(", "$", "encryptionKey", ")", "{", "$", "encryptionKey", "->", "updateUnidentifiedKey", "(", "$", "entity", ")", ";", "}", "}", "}", "}", "}", "// Now we have to decrypt the entity once again to be able to work with it from this moment", "$", "this", "->", "processEntity", "(", "$", "entity", ",", "self", "::", "DECRYPT", ")", ";", "}" ]
Process all encryption related actions on an Entity post persist event @param mixed $entity @return mixed
[ "Process", "all", "encryption", "related", "actions", "on", "an", "Entity", "post", "persist", "event" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L265-L285
226,086
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.processEntityMigration
public function processEntityMigration($entity) { if ($entity) { $reflection = ClassUtils::newReflectionObject($entity); if ($this->hasEncryptionEnabled($reflection) && !$entity->isEncrypted()) { $encryptionEnabledFields = $this->getEncryptionEnabledFields($reflection); // Normalize the field foreach ($encryptionEnabledFields as $field) { $fieldNormalizer = $this->getFieldNormalizer($field, $reflection); $value = $this->getFieldValue($entity, $field); $processedValue = $fieldNormalizer->normalize($value); $this->setFieldValue($entity, $field, $processedValue); } $entity->setMigrated(true); } } }
php
public function processEntityMigration($entity) { if ($entity) { $reflection = ClassUtils::newReflectionObject($entity); if ($this->hasEncryptionEnabled($reflection) && !$entity->isEncrypted()) { $encryptionEnabledFields = $this->getEncryptionEnabledFields($reflection); // Normalize the field foreach ($encryptionEnabledFields as $field) { $fieldNormalizer = $this->getFieldNormalizer($field, $reflection); $value = $this->getFieldValue($entity, $field); $processedValue = $fieldNormalizer->normalize($value); $this->setFieldValue($entity, $field, $processedValue); } $entity->setMigrated(true); } } }
[ "public", "function", "processEntityMigration", "(", "$", "entity", ")", "{", "if", "(", "$", "entity", ")", "{", "$", "reflection", "=", "ClassUtils", "::", "newReflectionObject", "(", "$", "entity", ")", ";", "if", "(", "$", "this", "->", "hasEncryptionEnabled", "(", "$", "reflection", ")", "&&", "!", "$", "entity", "->", "isEncrypted", "(", ")", ")", "{", "$", "encryptionEnabledFields", "=", "$", "this", "->", "getEncryptionEnabledFields", "(", "$", "reflection", ")", ";", "// Normalize the field", "foreach", "(", "$", "encryptionEnabledFields", "as", "$", "field", ")", "{", "$", "fieldNormalizer", "=", "$", "this", "->", "getFieldNormalizer", "(", "$", "field", ",", "$", "reflection", ")", ";", "$", "value", "=", "$", "this", "->", "getFieldValue", "(", "$", "entity", ",", "$", "field", ")", ";", "$", "processedValue", "=", "$", "fieldNormalizer", "->", "normalize", "(", "$", "value", ")", ";", "$", "this", "->", "setFieldValue", "(", "$", "entity", ",", "$", "field", ",", "$", "processedValue", ")", ";", "}", "$", "entity", "->", "setMigrated", "(", "true", ")", ";", "}", "}", "}" ]
Normalizes the data of the entity fields to the one required by the encryption after the encryption has been activated @param mixed $entity
[ "Normalizes", "the", "data", "of", "the", "entity", "fields", "to", "the", "one", "required", "by", "the", "encryption", "after", "the", "encryption", "has", "been", "activated" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L375-L393
226,087
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.isEncryptableFile
private function isEncryptableFile($entity) { $reflection = ClassUtils::newReflectionObject($entity); $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled && $classMetadata->encryptedFile; }
php
private function isEncryptableFile($entity) { $reflection = ClassUtils::newReflectionObject($entity); $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled && $classMetadata->encryptedFile; }
[ "private", "function", "isEncryptableFile", "(", "$", "entity", ")", "{", "$", "reflection", "=", "ClassUtils", "::", "newReflectionObject", "(", "$", "entity", ")", ";", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflection", "->", "getName", "(", ")", ")", ";", "return", "$", "classMetadata", "->", "encryptionEnabled", "&&", "$", "classMetadata", "->", "encryptedFile", ";", "}" ]
Checks if the entity has file encryption enabled @param mixed $entity @return boolean
[ "Checks", "if", "the", "entity", "has", "file", "encryption", "enabled" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L402-L408
226,088
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.processEntity
private function processEntity($entity, $operation) { if ($this->settings[$operation.'_on_backend']) { $reflection = ClassUtils::newReflectionObject($entity); $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); if ($classMetadata->encryptionEnabled && $this->toProcess($entity, $operation)) { // Get the encryption key data $keyData = $this->keyManager->getEntityEncryptionKeyData($entity); if ($keyData) { // get the encrypted fields $encryptionEnabledFields = $this->getEncryptionEnabledFields($reflection); // Encrypt the fields foreach ($encryptionEnabledFields as $fieldName => $field) { $fieldEncrypter = $this->getFieldEncrypter($field, $reflection); $value = $this->getFieldValue($entity, $field); $processedValue = $fieldEncrypter->{$operation}($value, $keyData); $this->setFieldValue($entity, $field, $processedValue); } // Set the encryption flag $entity->setEncrypted($operation === self::ENCRYPT); // If this entity has an encryptable file, process it if ($this->isEncryptableFile($entity) && $this->toProcessFile($entity, $operation)) { $method = $operation.'File'; $this->{$method}($entity, $keyData); } } } } }
php
private function processEntity($entity, $operation) { if ($this->settings[$operation.'_on_backend']) { $reflection = ClassUtils::newReflectionObject($entity); $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); if ($classMetadata->encryptionEnabled && $this->toProcess($entity, $operation)) { // Get the encryption key data $keyData = $this->keyManager->getEntityEncryptionKeyData($entity); if ($keyData) { // get the encrypted fields $encryptionEnabledFields = $this->getEncryptionEnabledFields($reflection); // Encrypt the fields foreach ($encryptionEnabledFields as $fieldName => $field) { $fieldEncrypter = $this->getFieldEncrypter($field, $reflection); $value = $this->getFieldValue($entity, $field); $processedValue = $fieldEncrypter->{$operation}($value, $keyData); $this->setFieldValue($entity, $field, $processedValue); } // Set the encryption flag $entity->setEncrypted($operation === self::ENCRYPT); // If this entity has an encryptable file, process it if ($this->isEncryptableFile($entity) && $this->toProcessFile($entity, $operation)) { $method = $operation.'File'; $this->{$method}($entity, $keyData); } } } } }
[ "private", "function", "processEntity", "(", "$", "entity", ",", "$", "operation", ")", "{", "if", "(", "$", "this", "->", "settings", "[", "$", "operation", ".", "'_on_backend'", "]", ")", "{", "$", "reflection", "=", "ClassUtils", "::", "newReflectionObject", "(", "$", "entity", ")", ";", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflection", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "classMetadata", "->", "encryptionEnabled", "&&", "$", "this", "->", "toProcess", "(", "$", "entity", ",", "$", "operation", ")", ")", "{", "// Get the encryption key data", "$", "keyData", "=", "$", "this", "->", "keyManager", "->", "getEntityEncryptionKeyData", "(", "$", "entity", ")", ";", "if", "(", "$", "keyData", ")", "{", "// get the encrypted fields", "$", "encryptionEnabledFields", "=", "$", "this", "->", "getEncryptionEnabledFields", "(", "$", "reflection", ")", ";", "// Encrypt the fields", "foreach", "(", "$", "encryptionEnabledFields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "$", "fieldEncrypter", "=", "$", "this", "->", "getFieldEncrypter", "(", "$", "field", ",", "$", "reflection", ")", ";", "$", "value", "=", "$", "this", "->", "getFieldValue", "(", "$", "entity", ",", "$", "field", ")", ";", "$", "processedValue", "=", "$", "fieldEncrypter", "->", "{", "$", "operation", "}", "(", "$", "value", ",", "$", "keyData", ")", ";", "$", "this", "->", "setFieldValue", "(", "$", "entity", ",", "$", "field", ",", "$", "processedValue", ")", ";", "}", "// Set the encryption flag", "$", "entity", "->", "setEncrypted", "(", "$", "operation", "===", "self", "::", "ENCRYPT", ")", ";", "// If this entity has an encryptable file, process it", "if", "(", "$", "this", "->", "isEncryptableFile", "(", "$", "entity", ")", "&&", "$", "this", "->", "toProcessFile", "(", "$", "entity", ",", "$", "operation", ")", ")", "{", "$", "method", "=", "$", "operation", ".", "'File'", ";", "$", "this", "->", "{", "$", "method", "}", "(", "$", "entity", ",", "$", "keyData", ")", ";", "}", "}", "}", "}", "}" ]
Processes an entity if it has encryption enabled and it's not already processed @param mixed $entity @param string $operation @return mixed
[ "Processes", "an", "entity", "if", "it", "has", "encryption", "enabled", "and", "it", "s", "not", "already", "processed" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L418-L450
226,089
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.encryptFile
private function encryptFile(EncryptableFile $fileEntity, KeyData $keyData) { $file = $fileEntity->getFile(); $encrypt = false; if ($file) { $filePath = $file->getRealPath(); $encrypt = true; } elseif ($fileEntity->getId() && $fileEntity->fileExists() && !$fileEntity->isFileEncrypted()) { // The document was persisted but somehow the file was not encrypted $filePath = $fileEntity->getAbsolutePath(); $encrypt = true; } if ($encrypt) { $fileContent = file_get_contents($filePath); // Get the encryption key data if ($keyData) { $encType = CryptographyProviderInterface::FILE_ENCRYPTION; $encryptedContent = $this->cryptographyProvider->encrypt($fileContent, $keyData, $encType); // Replace the file content with the encrypted file_put_contents($filePath, $encryptedContent); $fileEntity->setFileEncrypted(true); } } }
php
private function encryptFile(EncryptableFile $fileEntity, KeyData $keyData) { $file = $fileEntity->getFile(); $encrypt = false; if ($file) { $filePath = $file->getRealPath(); $encrypt = true; } elseif ($fileEntity->getId() && $fileEntity->fileExists() && !$fileEntity->isFileEncrypted()) { // The document was persisted but somehow the file was not encrypted $filePath = $fileEntity->getAbsolutePath(); $encrypt = true; } if ($encrypt) { $fileContent = file_get_contents($filePath); // Get the encryption key data if ($keyData) { $encType = CryptographyProviderInterface::FILE_ENCRYPTION; $encryptedContent = $this->cryptographyProvider->encrypt($fileContent, $keyData, $encType); // Replace the file content with the encrypted file_put_contents($filePath, $encryptedContent); $fileEntity->setFileEncrypted(true); } } }
[ "private", "function", "encryptFile", "(", "EncryptableFile", "$", "fileEntity", ",", "KeyData", "$", "keyData", ")", "{", "$", "file", "=", "$", "fileEntity", "->", "getFile", "(", ")", ";", "$", "encrypt", "=", "false", ";", "if", "(", "$", "file", ")", "{", "$", "filePath", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "$", "encrypt", "=", "true", ";", "}", "elseif", "(", "$", "fileEntity", "->", "getId", "(", ")", "&&", "$", "fileEntity", "->", "fileExists", "(", ")", "&&", "!", "$", "fileEntity", "->", "isFileEncrypted", "(", ")", ")", "{", "// The document was persisted but somehow the file was not encrypted", "$", "filePath", "=", "$", "fileEntity", "->", "getAbsolutePath", "(", ")", ";", "$", "encrypt", "=", "true", ";", "}", "if", "(", "$", "encrypt", ")", "{", "$", "fileContent", "=", "file_get_contents", "(", "$", "filePath", ")", ";", "// Get the encryption key data", "if", "(", "$", "keyData", ")", "{", "$", "encType", "=", "CryptographyProviderInterface", "::", "FILE_ENCRYPTION", ";", "$", "encryptedContent", "=", "$", "this", "->", "cryptographyProvider", "->", "encrypt", "(", "$", "fileContent", ",", "$", "keyData", ",", "$", "encType", ")", ";", "// Replace the file content with the encrypted", "file_put_contents", "(", "$", "filePath", ",", "$", "encryptedContent", ")", ";", "$", "fileEntity", "->", "setFileEncrypted", "(", "true", ")", ";", "}", "}", "}" ]
Encrypts the uploaded file contained in a File Entity @param EncryptableFile $fileEntity @param KeyData $keyData
[ "Encrypts", "the", "uploaded", "file", "contained", "in", "a", "File", "Entity" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L458-L484
226,090
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.decryptFile
private function decryptFile($fileEntity, KeyData $keyData) { if ($keyData) { $encryptedContent = $fileEntity->getContent(); if ($encryptedContent) { $encType = CryptographyProviderInterface::FILE_ENCRYPTION; $decryptedContent = $this->cryptographyProvider->decrypt($encryptedContent, $keyData, $encType); $fileEntity->setContent($decryptedContent); } } }
php
private function decryptFile($fileEntity, KeyData $keyData) { if ($keyData) { $encryptedContent = $fileEntity->getContent(); if ($encryptedContent) { $encType = CryptographyProviderInterface::FILE_ENCRYPTION; $decryptedContent = $this->cryptographyProvider->decrypt($encryptedContent, $keyData, $encType); $fileEntity->setContent($decryptedContent); } } }
[ "private", "function", "decryptFile", "(", "$", "fileEntity", ",", "KeyData", "$", "keyData", ")", "{", "if", "(", "$", "keyData", ")", "{", "$", "encryptedContent", "=", "$", "fileEntity", "->", "getContent", "(", ")", ";", "if", "(", "$", "encryptedContent", ")", "{", "$", "encType", "=", "CryptographyProviderInterface", "::", "FILE_ENCRYPTION", ";", "$", "decryptedContent", "=", "$", "this", "->", "cryptographyProvider", "->", "decrypt", "(", "$", "encryptedContent", ",", "$", "keyData", ",", "$", "encType", ")", ";", "$", "fileEntity", "->", "setContent", "(", "$", "decryptedContent", ")", ";", "}", "}", "}" ]
Decrpyts the content of a file associated with an Encryptable File Entity @param mixed $fileEntity @param KeyData $keyData
[ "Decrpyts", "the", "content", "of", "a", "file", "associated", "with", "an", "Encryptable", "File", "Entity" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L492-L503
226,091
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.hasEncryptionEnabled
public function hasEncryptionEnabled(\ReflectionClass $reflection, DoctrineClassMetadata $metadata = null) { $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled; }
php
public function hasEncryptionEnabled(\ReflectionClass $reflection, DoctrineClassMetadata $metadata = null) { $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled; }
[ "public", "function", "hasEncryptionEnabled", "(", "\\", "ReflectionClass", "$", "reflection", ",", "DoctrineClassMetadata", "$", "metadata", "=", "null", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflection", "->", "getName", "(", ")", ")", ";", "return", "$", "classMetadata", "->", "encryptionEnabled", ";", "}" ]
Checks if the class has been enabled for encryption @param \ReflectionClass $reflection @param \Doctrine\ORM\Mapping\ClassMetadata $metadata @return boolean
[ "Checks", "if", "the", "class", "has", "been", "enabled", "for", "encryption" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L553-L557
226,092
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.hasFileEncryptionEnabled
private function hasFileEncryptionEnabled(\ReflectionClass $reflection) { $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled && $classMetadata->encryptedFile; }
php
private function hasFileEncryptionEnabled(\ReflectionClass $reflection) { $classMetadata = $this->getEncryptionMetadataFor($reflection->getName()); return $classMetadata->encryptionEnabled && $classMetadata->encryptedFile; }
[ "private", "function", "hasFileEncryptionEnabled", "(", "\\", "ReflectionClass", "$", "reflection", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflection", "->", "getName", "(", ")", ")", ";", "return", "$", "classMetadata", "->", "encryptionEnabled", "&&", "$", "classMetadata", "->", "encryptedFile", ";", "}" ]
Checks if the class is a File entity and has the file encryption enabled @param \ReflectionClass $reflection @return boolean
[ "Checks", "if", "the", "class", "is", "a", "File", "entity", "and", "has", "the", "file", "encryption", "enabled" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L565-L569
226,093
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.keyPerEntityRequired
private function keyPerEntityRequired(\ReflectionClass $reflectionClass) { $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName()); $keyPerEntityModes = array( EncryptionService::MODE_PER_USER_SHAREABLE, EncryptionService::MODE_SYSTEM_ENCRYPTION, ); return $classMetadata->encryptionEnabled && in_array($classMetadata->encryptionMode, $keyPerEntityModes); }
php
private function keyPerEntityRequired(\ReflectionClass $reflectionClass) { $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName()); $keyPerEntityModes = array( EncryptionService::MODE_PER_USER_SHAREABLE, EncryptionService::MODE_SYSTEM_ENCRYPTION, ); return $classMetadata->encryptionEnabled && in_array($classMetadata->encryptionMode, $keyPerEntityModes); }
[ "private", "function", "keyPerEntityRequired", "(", "\\", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflectionClass", "->", "getName", "(", ")", ")", ";", "$", "keyPerEntityModes", "=", "array", "(", "EncryptionService", "::", "MODE_PER_USER_SHAREABLE", ",", "EncryptionService", "::", "MODE_SYSTEM_ENCRYPTION", ",", ")", ";", "return", "$", "classMetadata", "->", "encryptionEnabled", "&&", "in_array", "(", "$", "classMetadata", "->", "encryptionMode", ",", "$", "keyPerEntityModes", ")", ";", "}" ]
Checks if the entity needs a field to store a key for each instance @param \ReflectionClass $reflectionClass @return boolean
[ "Checks", "if", "the", "entity", "needs", "a", "field", "to", "store", "a", "key", "for", "each", "instance" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L578-L589
226,094
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getEncryptionEnabledFields
public function getEncryptionEnabledFields(\ReflectionClass $reflectionClass) { $encryptionEnabledFields = array(); $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName()); if ($classMetadata->encryptionEnabled) { /** @var PropertyMetadata $propertyMetadata */ foreach ($classMetadata->propertyMetadata as $propertyMetadata) { if ($propertyMetadata->encrypted) { $reflectionProperty = $reflectionClass->getProperty($propertyMetadata->name); $encryptionEnabledFields[$reflectionProperty->name] = $reflectionProperty; } } } return $encryptionEnabledFields; }
php
public function getEncryptionEnabledFields(\ReflectionClass $reflectionClass) { $encryptionEnabledFields = array(); $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName()); if ($classMetadata->encryptionEnabled) { /** @var PropertyMetadata $propertyMetadata */ foreach ($classMetadata->propertyMetadata as $propertyMetadata) { if ($propertyMetadata->encrypted) { $reflectionProperty = $reflectionClass->getProperty($propertyMetadata->name); $encryptionEnabledFields[$reflectionProperty->name] = $reflectionProperty; } } } return $encryptionEnabledFields; }
[ "public", "function", "getEncryptionEnabledFields", "(", "\\", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "encryptionEnabledFields", "=", "array", "(", ")", ";", "$", "classMetadata", "=", "$", "this", "->", "getEncryptionMetadataFor", "(", "$", "reflectionClass", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "classMetadata", "->", "encryptionEnabled", ")", "{", "/** @var PropertyMetadata $propertyMetadata */", "foreach", "(", "$", "classMetadata", "->", "propertyMetadata", "as", "$", "propertyMetadata", ")", "{", "if", "(", "$", "propertyMetadata", "->", "encrypted", ")", "{", "$", "reflectionProperty", "=", "$", "reflectionClass", "->", "getProperty", "(", "$", "propertyMetadata", "->", "name", ")", ";", "$", "encryptionEnabledFields", "[", "$", "reflectionProperty", "->", "name", "]", "=", "$", "reflectionProperty", ";", "}", "}", "}", "return", "$", "encryptionEnabledFields", ";", "}" ]
Checks the fields of the entity and returns a list of those with encryption enabled @param \ReflectionClass $reflectionClass @return array
[ "Checks", "the", "fields", "of", "the", "entity", "and", "returns", "a", "list", "of", "those", "with", "encryption", "enabled" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L598-L615
226,095
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getFieldValue
private function getFieldValue($entity, \ReflectionProperty $reflectionProperty) { $value = null; if ($reflectionProperty) { $reflectionProperty->setAccessible(true); $value = $reflectionProperty->getValue($entity); } return $value; }
php
private function getFieldValue($entity, \ReflectionProperty $reflectionProperty) { $value = null; if ($reflectionProperty) { $reflectionProperty->setAccessible(true); $value = $reflectionProperty->getValue($entity); } return $value; }
[ "private", "function", "getFieldValue", "(", "$", "entity", ",", "\\", "ReflectionProperty", "$", "reflectionProperty", ")", "{", "$", "value", "=", "null", ";", "if", "(", "$", "reflectionProperty", ")", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "value", "=", "$", "reflectionProperty", "->", "getValue", "(", "$", "entity", ")", ";", "}", "return", "$", "value", ";", "}" ]
Returns the value of an entity using reflection @param mixed $entity @param \ReflectionProperty $reflectionProperty @return mixed
[ "Returns", "the", "value", "of", "an", "entity", "using", "reflection" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L625-L634
226,096
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.setFieldValue
private function setFieldValue($entity, \ReflectionProperty $reflectionProperty, $value) { if ($reflectionProperty) { $reflectionProperty->setAccessible(true); $value = $reflectionProperty->setValue($entity, $value); } }
php
private function setFieldValue($entity, \ReflectionProperty $reflectionProperty, $value) { if ($reflectionProperty) { $reflectionProperty->setAccessible(true); $value = $reflectionProperty->setValue($entity, $value); } }
[ "private", "function", "setFieldValue", "(", "$", "entity", ",", "\\", "ReflectionProperty", "$", "reflectionProperty", ",", "$", "value", ")", "{", "if", "(", "$", "reflectionProperty", ")", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "value", "=", "$", "reflectionProperty", "->", "setValue", "(", "$", "entity", ",", "$", "value", ")", ";", "}", "}" ]
Sets the value of an entity using reflection @param mixed $entity @param \ReflectionProperty $reflectionProperty @param mixed $value
[ "Sets", "the", "value", "of", "an", "entity", "using", "reflection" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L643-L649
226,097
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getEncryptedFieldMapping
private function getEncryptedFieldMapping(array $fieldMapping) { switch($fieldMapping['type']) { case 'string': return new FieldMapping\StringFieldMapping($this, $fieldMapping); case 'text': case 'json_array': case 'simple_array': case 'array': case 'object': return new FieldMapping\TextFieldMapping($this, $fieldMapping); case 'date': case 'datetime': case 'time': return new FieldMapping\DateTimeFieldMapping($this, $fieldMapping); case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': return new FieldMapping\PrimitiveFieldMapping($this, $fieldMapping); default: throw new EncryptionException('Field type '.$fieldMapping['type'].' not supported.'); } }
php
private function getEncryptedFieldMapping(array $fieldMapping) { switch($fieldMapping['type']) { case 'string': return new FieldMapping\StringFieldMapping($this, $fieldMapping); case 'text': case 'json_array': case 'simple_array': case 'array': case 'object': return new FieldMapping\TextFieldMapping($this, $fieldMapping); case 'date': case 'datetime': case 'time': return new FieldMapping\DateTimeFieldMapping($this, $fieldMapping); case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': return new FieldMapping\PrimitiveFieldMapping($this, $fieldMapping); default: throw new EncryptionException('Field type '.$fieldMapping['type'].' not supported.'); } }
[ "private", "function", "getEncryptedFieldMapping", "(", "array", "$", "fieldMapping", ")", "{", "switch", "(", "$", "fieldMapping", "[", "'type'", "]", ")", "{", "case", "'string'", ":", "return", "new", "FieldMapping", "\\", "StringFieldMapping", "(", "$", "this", ",", "$", "fieldMapping", ")", ";", "case", "'text'", ":", "case", "'json_array'", ":", "case", "'simple_array'", ":", "case", "'array'", ":", "case", "'object'", ":", "return", "new", "FieldMapping", "\\", "TextFieldMapping", "(", "$", "this", ",", "$", "fieldMapping", ")", ";", "case", "'date'", ":", "case", "'datetime'", ":", "case", "'time'", ":", "return", "new", "FieldMapping", "\\", "DateTimeFieldMapping", "(", "$", "this", ",", "$", "fieldMapping", ")", ";", "case", "'boolean'", ":", "case", "'smallint'", ":", "case", "'integer'", ":", "case", "'bigint'", ":", "case", "'float'", ":", "return", "new", "FieldMapping", "\\", "PrimitiveFieldMapping", "(", "$", "this", ",", "$", "fieldMapping", ")", ";", "default", ":", "throw", "new", "EncryptionException", "(", "'Field type '", ".", "$", "fieldMapping", "[", "'type'", "]", ".", "' not supported.'", ")", ";", "}", "}" ]
Factory method to get the right EncryptedFieldMapping object for a determined field @param array $fieldMapping @return \Jagilpe\EncryptionBundle\Crypt\FieldMapping\EncryptedFieldMappingInterface @throws EncryptionException
[ "Factory", "method", "to", "get", "the", "right", "EncryptedFieldMapping", "object", "for", "a", "determined", "field" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L660-L684
226,098
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getFieldEncrypter
private function getFieldEncrypter(\ReflectionProperty $reflectionProperty, \ReflectionClass $reflectionClass) { $classMetadata = $this->doctrine->getManager()->getMetadataFactory()->getMetadataFor($reflectionClass->getName()); $fieldName = $reflectionProperty->getName(); $fieldMapping = $classMetadata->getFieldMapping($fieldName); if (!isset($fieldMapping['_old_type'])) { throw new EncryptionException('Field metadata not updated'); } switch ($fieldMapping['_old_type']) { case 'string': case 'text': $encrypterClass = FieldEncrypter\DefaultFieldEncrypter::class; break; case 'date': case 'datetime': case 'time': case 'json_array': case 'simple_array': case 'array': case 'object': $encrypterClass = FieldEncrypter\SerializableObjectFieldEncrypter::class; break; case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': $encrypterClass = FieldEncrypter\PrimitiveFieldEncrypter::class; $fieldType = $fieldMapping['_old_type']; if (!isset($this->encrypters[$encrypterClass][$fieldType])) { $this->encrypters[$encrypterClass][$fieldType] = new $encrypterClass($this->cryptographyProvider, $fieldType); } return $this->encrypters[$encrypterClass][$fieldType]; break; default: throw new EncryptionException('Field type '.$fieldMapping['_old_type'].' not supported.'); } if (!isset($this->encrypters[$encrypterClass])) { $this->encrypters[$encrypterClass] = new $encrypterClass($this->cryptographyProvider); } return $this->encrypters[$encrypterClass]; }
php
private function getFieldEncrypter(\ReflectionProperty $reflectionProperty, \ReflectionClass $reflectionClass) { $classMetadata = $this->doctrine->getManager()->getMetadataFactory()->getMetadataFor($reflectionClass->getName()); $fieldName = $reflectionProperty->getName(); $fieldMapping = $classMetadata->getFieldMapping($fieldName); if (!isset($fieldMapping['_old_type'])) { throw new EncryptionException('Field metadata not updated'); } switch ($fieldMapping['_old_type']) { case 'string': case 'text': $encrypterClass = FieldEncrypter\DefaultFieldEncrypter::class; break; case 'date': case 'datetime': case 'time': case 'json_array': case 'simple_array': case 'array': case 'object': $encrypterClass = FieldEncrypter\SerializableObjectFieldEncrypter::class; break; case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': $encrypterClass = FieldEncrypter\PrimitiveFieldEncrypter::class; $fieldType = $fieldMapping['_old_type']; if (!isset($this->encrypters[$encrypterClass][$fieldType])) { $this->encrypters[$encrypterClass][$fieldType] = new $encrypterClass($this->cryptographyProvider, $fieldType); } return $this->encrypters[$encrypterClass][$fieldType]; break; default: throw new EncryptionException('Field type '.$fieldMapping['_old_type'].' not supported.'); } if (!isset($this->encrypters[$encrypterClass])) { $this->encrypters[$encrypterClass] = new $encrypterClass($this->cryptographyProvider); } return $this->encrypters[$encrypterClass]; }
[ "private", "function", "getFieldEncrypter", "(", "\\", "ReflectionProperty", "$", "reflectionProperty", ",", "\\", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", "->", "getMetadataFactory", "(", ")", "->", "getMetadataFor", "(", "$", "reflectionClass", "->", "getName", "(", ")", ")", ";", "$", "fieldName", "=", "$", "reflectionProperty", "->", "getName", "(", ")", ";", "$", "fieldMapping", "=", "$", "classMetadata", "->", "getFieldMapping", "(", "$", "fieldName", ")", ";", "if", "(", "!", "isset", "(", "$", "fieldMapping", "[", "'_old_type'", "]", ")", ")", "{", "throw", "new", "EncryptionException", "(", "'Field metadata not updated'", ")", ";", "}", "switch", "(", "$", "fieldMapping", "[", "'_old_type'", "]", ")", "{", "case", "'string'", ":", "case", "'text'", ":", "$", "encrypterClass", "=", "FieldEncrypter", "\\", "DefaultFieldEncrypter", "::", "class", ";", "break", ";", "case", "'date'", ":", "case", "'datetime'", ":", "case", "'time'", ":", "case", "'json_array'", ":", "case", "'simple_array'", ":", "case", "'array'", ":", "case", "'object'", ":", "$", "encrypterClass", "=", "FieldEncrypter", "\\", "SerializableObjectFieldEncrypter", "::", "class", ";", "break", ";", "case", "'boolean'", ":", "case", "'smallint'", ":", "case", "'integer'", ":", "case", "'bigint'", ":", "case", "'float'", ":", "$", "encrypterClass", "=", "FieldEncrypter", "\\", "PrimitiveFieldEncrypter", "::", "class", ";", "$", "fieldType", "=", "$", "fieldMapping", "[", "'_old_type'", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", "[", "$", "fieldType", "]", ")", ")", "{", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", "[", "$", "fieldType", "]", "=", "new", "$", "encrypterClass", "(", "$", "this", "->", "cryptographyProvider", ",", "$", "fieldType", ")", ";", "}", "return", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", "[", "$", "fieldType", "]", ";", "break", ";", "default", ":", "throw", "new", "EncryptionException", "(", "'Field type '", ".", "$", "fieldMapping", "[", "'_old_type'", "]", ".", "' not supported.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", ")", ")", "{", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", "=", "new", "$", "encrypterClass", "(", "$", "this", "->", "cryptographyProvider", ")", ";", "}", "return", "$", "this", "->", "encrypters", "[", "$", "encrypterClass", "]", ";", "}" ]
Factory method to get the right EncryptedFieldEncrypter object for a determined field @param \ReflectionProperty $reflectionProperty @param \ReflectionClass $reflectionClass @return \Jagilpe\EncryptionBundle\Crypt\FieldEncrypter\EncryptedFieldEncrypterInterface @throws EncryptionException
[ "Factory", "method", "to", "get", "the", "right", "EncryptedFieldEncrypter", "object", "for", "a", "determined", "field" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L696-L743
226,099
jagilpe/encryption-bundle
Service/EncryptionService.php
EncryptionService.getFieldNormalizer
private function getFieldNormalizer(\ReflectionProperty $reflectionProperty, \ReflectionClass $reflectionClass) { $classMetadata = $this->doctrine->getManager()->getMetadataFactory()->getMetadataFor($reflectionClass->getName()); $fieldName = $reflectionProperty->getName(); $fieldMapping = $classMetadata->getFieldMapping($fieldName); if (!isset($fieldMapping['_old_type'])) { throw new EncryptionException('Field metadata not updated'); } switch ($fieldMapping['_old_type']) { case 'string': case 'text': $normalizerClass = FieldNormalizer\DefaultFieldNormalizer::class; break; case 'date': case 'datetime': case 'time': $normalizerClass = FieldNormalizer\DateTimeFieldNormalizer::class; break; case 'json_array': $normalizerClass = FieldNormalizer\JsonArrayFieldNormalizer::class; break; case 'simple_array': $normalizerClass = FieldNormalizer\SimpleArrayFieldNormalizer::class; break; case 'array': case 'object': $normalizerClass = FieldNormalizer\SerializableObjectFieldNormalizer::class; break; case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': $normalizerClass = FieldNormalizer\PrimitiveFieldNormalizer::class; $fieldType = $fieldMapping['_old_type']; if (!isset($this->normalizers[$normalizerClass][$fieldType])) { $this->normalizers[$normalizerClass][$fieldType] = new $normalizerClass($fieldType); } return $this->normalizers[$normalizerClass][$fieldType]; break; default: throw new EncryptionException('Field type '.$fieldMapping['_old_type'].' not supported.'); } if (!isset($this->normalizers[$normalizerClass])) { $this->normalizers[$normalizerClass] = new $normalizerClass(); } return $this->normalizers[$normalizerClass]; }
php
private function getFieldNormalizer(\ReflectionProperty $reflectionProperty, \ReflectionClass $reflectionClass) { $classMetadata = $this->doctrine->getManager()->getMetadataFactory()->getMetadataFor($reflectionClass->getName()); $fieldName = $reflectionProperty->getName(); $fieldMapping = $classMetadata->getFieldMapping($fieldName); if (!isset($fieldMapping['_old_type'])) { throw new EncryptionException('Field metadata not updated'); } switch ($fieldMapping['_old_type']) { case 'string': case 'text': $normalizerClass = FieldNormalizer\DefaultFieldNormalizer::class; break; case 'date': case 'datetime': case 'time': $normalizerClass = FieldNormalizer\DateTimeFieldNormalizer::class; break; case 'json_array': $normalizerClass = FieldNormalizer\JsonArrayFieldNormalizer::class; break; case 'simple_array': $normalizerClass = FieldNormalizer\SimpleArrayFieldNormalizer::class; break; case 'array': case 'object': $normalizerClass = FieldNormalizer\SerializableObjectFieldNormalizer::class; break; case 'boolean': case 'smallint': case 'integer': case 'bigint': case 'float': $normalizerClass = FieldNormalizer\PrimitiveFieldNormalizer::class; $fieldType = $fieldMapping['_old_type']; if (!isset($this->normalizers[$normalizerClass][$fieldType])) { $this->normalizers[$normalizerClass][$fieldType] = new $normalizerClass($fieldType); } return $this->normalizers[$normalizerClass][$fieldType]; break; default: throw new EncryptionException('Field type '.$fieldMapping['_old_type'].' not supported.'); } if (!isset($this->normalizers[$normalizerClass])) { $this->normalizers[$normalizerClass] = new $normalizerClass(); } return $this->normalizers[$normalizerClass]; }
[ "private", "function", "getFieldNormalizer", "(", "\\", "ReflectionProperty", "$", "reflectionProperty", ",", "\\", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "doctrine", "->", "getManager", "(", ")", "->", "getMetadataFactory", "(", ")", "->", "getMetadataFor", "(", "$", "reflectionClass", "->", "getName", "(", ")", ")", ";", "$", "fieldName", "=", "$", "reflectionProperty", "->", "getName", "(", ")", ";", "$", "fieldMapping", "=", "$", "classMetadata", "->", "getFieldMapping", "(", "$", "fieldName", ")", ";", "if", "(", "!", "isset", "(", "$", "fieldMapping", "[", "'_old_type'", "]", ")", ")", "{", "throw", "new", "EncryptionException", "(", "'Field metadata not updated'", ")", ";", "}", "switch", "(", "$", "fieldMapping", "[", "'_old_type'", "]", ")", "{", "case", "'string'", ":", "case", "'text'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "DefaultFieldNormalizer", "::", "class", ";", "break", ";", "case", "'date'", ":", "case", "'datetime'", ":", "case", "'time'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "DateTimeFieldNormalizer", "::", "class", ";", "break", ";", "case", "'json_array'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "JsonArrayFieldNormalizer", "::", "class", ";", "break", ";", "case", "'simple_array'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "SimpleArrayFieldNormalizer", "::", "class", ";", "break", ";", "case", "'array'", ":", "case", "'object'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "SerializableObjectFieldNormalizer", "::", "class", ";", "break", ";", "case", "'boolean'", ":", "case", "'smallint'", ":", "case", "'integer'", ":", "case", "'bigint'", ":", "case", "'float'", ":", "$", "normalizerClass", "=", "FieldNormalizer", "\\", "PrimitiveFieldNormalizer", "::", "class", ";", "$", "fieldType", "=", "$", "fieldMapping", "[", "'_old_type'", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", "[", "$", "fieldType", "]", ")", ")", "{", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", "[", "$", "fieldType", "]", "=", "new", "$", "normalizerClass", "(", "$", "fieldType", ")", ";", "}", "return", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", "[", "$", "fieldType", "]", ";", "break", ";", "default", ":", "throw", "new", "EncryptionException", "(", "'Field type '", ".", "$", "fieldMapping", "[", "'_old_type'", "]", ".", "' not supported.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", ")", ")", "{", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", "=", "new", "$", "normalizerClass", "(", ")", ";", "}", "return", "$", "this", "->", "normalizers", "[", "$", "normalizerClass", "]", ";", "}" ]
Factory method to get the right EncryptedFieldNormalizer object for a determined field @param \ReflectionProperty $reflectionProperty @param \ReflectionClass $reflectionClass @return \Jagilpe\EncryptionBundle\Crypt\FieldNormalizer\EncryptedFieldNormalizerInterface @throws EncryptionException
[ "Factory", "method", "to", "get", "the", "right", "EncryptedFieldNormalizer", "object", "for", "a", "determined", "field" ]
1e1ba13a3cc646b36e3407822f2e8339c5671f47
https://github.com/jagilpe/encryption-bundle/blob/1e1ba13a3cc646b36e3407822f2e8339c5671f47/Service/EncryptionService.php#L755-L808